diff --git a/CMakeLists.txt b/CMakeLists.txt index 199a1fca86..ce6a81dcde 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -48,12 +48,14 @@ function( add_pk3 PK3_NAME PK3_DIR ) COMMAND zipdir -udf ${ZDOOM_OUTPUT_DIR}/${PK3_NAME} ${PK3_DIR} DEPENDS zipdir ) endif() - - # Touch the zipdir executable here so that the pk3s are forced to - # rebuild each time since their dependecy has "changed." - add_custom_target( ${PK3_TARGET} ALL - COMMAND ${CMAKE_COMMAND} -E touch $ - DEPENDS ${ZDOOM_OUTPUT_DIR}/${PK3_NAME} ) + # Grab a list of top-level PK3 folder files, so we can conveniently see them in the IDE + file(GLOB PK3_SRCS ${PK3_DIR}/*) + # Touch the zipdir executable here so that the pk3s are forced to + # rebuild each time since their dependecy has "changed." + add_custom_target( ${PK3_TARGET} ALL + COMMAND ${CMAKE_COMMAND} -E touch $ + DEPENDS ${ZDOOM_OUTPUT_DIR}/${PK3_NAME} + SOURCES "${PK3_SRCS}") endfunction() # Macro for building libraries without debugging information diff --git a/src/actor.h b/src/actor.h index bf76cc15ea..2ae26e7efb 100644 --- a/src/actor.h +++ b/src/actor.h @@ -417,7 +417,10 @@ enum ActorRenderFlag RF_INVISIBLE = 0x8000, // Don't bother drawing this actor RF_ROLLSPRITE = 0x40000, //[marrub]roll the sprite billboard RF_DONTFLIP = 0x80000, // Don't flip it when viewed from behind. - RF_ROLLCENTER = 0x100000, // Rotate from the center of sprite instead of offsets + RF_ROLLCENTER = 0x00100000, // Rotate from the center of sprite instead of offsets + RF_MASKROTATION = 0x00200000, // [MC] Only draw the actor when viewed from a certain angle range. + RF_ABSMASKANGLE = 0x00400000, // [MC] The mask rotation does not offset by the actor's angle. + RF_ABSMASKPITCH = 0x00800000, // [MC] The mask rotation does not offset by the actor's pitch. RF_FORCEYBILLBOARD = 0x10000, // [BB] OpenGL only: draw with y axis billboard, i.e. anchored to the floor (overrides gl_billboard_mode setting) RF_FORCEXYBILLBOARD = 0x20000, // [BB] OpenGL only: draw with xy axis billboard, i.e. unanchored (overrides gl_billboard_mode setting) @@ -959,6 +962,7 @@ public: inline void SetFriendPlayer(player_t *player); bool IsVisibleToPlayer() const; + bool IsInsideVisibleAngles() const; // Calculate amount of missile damage virtual int GetMissileDamage(int mask, int add); @@ -984,6 +988,10 @@ public: DAngle SpriteAngle; DAngle SpriteRotation; + DAngle VisibleStartAngle; + DAngle VisibleStartPitch; + DAngle VisibleEndAngle; + DAngle VisibleEndPitch; DRotator Angles; DVector3 Vel; double Speed; diff --git a/src/g_game.cpp b/src/g_game.cpp index 5d1f83b828..629202ea5b 100644 --- a/src/g_game.cpp +++ b/src/g_game.cpp @@ -1884,7 +1884,7 @@ void G_DoLoadGame () } else { - Printf("Savegame is from another ZDoom-based engine: %s\n", engine); + Printf("Savegame is from another ZDoom-based engine: %s\n", engine.GetChars()); } delete resfile; return; @@ -2261,7 +2261,7 @@ void G_DoSaveGame (bool okForQuicksave, FString filename, const char *descriptio } auto picdata = savepic.GetBuffer(); - FCompressedBuffer bufpng = { picdata->Size(), picdata->Size(), METHOD_STORED, 0, crc32(0, &(*picdata)[0], picdata->Size()), (char*)&(*picdata)[0] }; + FCompressedBuffer bufpng = { picdata->Size(), picdata->Size(), METHOD_STORED, 0, static_cast(crc32(0, &(*picdata)[0], picdata->Size())), (char*)&(*picdata)[0] }; savegame_content.Push(bufpng); savegame_filenames.Push("savepic.png"); diff --git a/src/gl/dynlights/a_dynlight.cpp b/src/gl/dynlights/a_dynlight.cpp index 36ef1b9483..20d0d60782 100644 --- a/src/gl/dynlights/a_dynlight.cpp +++ b/src/gl/dynlights/a_dynlight.cpp @@ -163,7 +163,7 @@ void ADynamicLight::Serialize(FSerializer &arc) ("lighttype", lighttype, def->lighttype) ("tickcount", m_tickCount, def->m_tickCount) ("currentradius", m_currentRadius, def->m_currentRadius) - .Array("radius", m_Radius, def->m_Radius, 2); + .Array("lightradius", m_Radius, def->m_Radius, 2); if (lighttype == PulseLight) arc("lastupdate", m_lastUpdate, def->m_lastUpdate) diff --git a/src/gl/scene/gl_sprite.cpp b/src/gl/scene/gl_sprite.cpp index 123bf258cb..19753f742e 100644 --- a/src/gl/scene/gl_sprite.cpp +++ b/src/gl/scene/gl_sprite.cpp @@ -636,7 +636,7 @@ void GLSprite::Process(AActor* thing, sector_t * sector, int thruportal) sector_t * rendersector; // Don't waste time projecting sprites that are definitely not visible. - if (thing == nullptr || thing->sprite == 0 || !thing->IsVisibleToPlayer()) + if (thing == nullptr || thing->sprite == 0 || !thing->IsVisibleToPlayer() || !thing->IsInsideVisibleAngles()) { return; } diff --git a/src/namedef.h b/src/namedef.h index f1279d27cc..c8b0d15246 100644 --- a/src/namedef.h +++ b/src/namedef.h @@ -336,6 +336,10 @@ xx(ReactionTime) xx(MeleeRange) xx(Speed) xx(Clamp) +xx(VisibleStartAngle) +xx(VisibleStartPitch) +xx(VisibleEndAngle) +xx(VisibleEndPitch) // Various actor names which are used internally xx(MapSpot) diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 657d5db49c..8d6d752379 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -306,7 +306,11 @@ void AActor::Serialize(FSerializer &arc) A("spriteangle", SpriteAngle) A("spriterotation", SpriteRotation) ("alternative", alternative) - A("tag", Tag); + A("tag", Tag) + A("visiblestartangle",VisibleStartAngle) + A("visibleendangle",VisibleEndAngle) + A("visiblestartpitch",VisibleStartPitch) + A("visibleendpitch",VisibleEndPitch); } #undef A @@ -1019,6 +1023,69 @@ bool AActor::CheckLocalView (int playernum) const return false; } +//============================================================================ +// +// AActor :: IsInsideVisibleAngles +// +// Returns true if this actor is within viewing angle/pitch visibility. +// +//============================================================================ + +bool AActor::IsInsideVisibleAngles() const +{ + // Don't bother masking if not wanted. + if (!(renderflags & RF_MASKROTATION)) + return true; + + if (players[consoleplayer].camera == nullptr) + return true; + + DAngle anglestart = VisibleStartAngle.Normalized180(); + DAngle angleend = VisibleEndAngle.Normalized180(); + DAngle pitchstart = VisibleStartPitch.Normalized180(); + DAngle pitchend = VisibleEndPitch.Normalized180(); + + if (anglestart > angleend) + { + DAngle temp = anglestart; + anglestart = angleend; + angleend = temp; + } + + if (pitchstart > angleend) + { + DAngle temp = pitchstart; + pitchstart = pitchend; + pitchend = temp; + } + + player_t* pPlayer = players[consoleplayer].camera->player; + + if (pPlayer && pPlayer->mo) + { + AActor *mo = pPlayer->mo; + DVector3 diffang = Vec3To(mo); + DAngle to = diffang.Angle(); + + if (!(renderflags & RF_ABSMASKANGLE)) + to = deltaangle(Angles.Yaw, to); + + // Note that this check is inversed due to only being able to vectorize + // from one way (this actor to the player). It still means to pass + // if the player is within the visible angles. + if ((to <= anglestart || to >= angleend)) + { + to = diffang.Pitch(); + if (!(renderflags & RF_ABSMASKPITCH)) + to = deltaangle(Angles.Pitch, to); + + return !!(to >= pitchstart && to <= pitchend); + } + else return false; + } + return true; +} + //============================================================================ // // AActor :: IsVisibleToPlayer diff --git a/src/r_things.cpp b/src/r_things.cpp index 6f1fb2700c..49d7333faa 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -761,7 +761,8 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor if (thing == NULL || (thing->renderflags & RF_INVISIBLE) || !thing->RenderStyle.IsVisible(thing->Alpha) || - !thing->IsVisibleToPlayer()) + !thing->IsVisibleToPlayer() || + !thing->IsInsideVisibleAngles()) { return; } diff --git a/src/serializer.cpp b/src/serializer.cpp index ae1c55a7a7..a23459ced0 100644 --- a/src/serializer.cpp +++ b/src/serializer.cpp @@ -859,7 +859,7 @@ void FSerializer::ReadObjects(bool hubtravel) PClass *cls = PClass::FindClass(clsname); if (cls == nullptr) { - Printf("Unknown object class '%d' in savegame", clsname.GetChars()); + Printf("Unknown object class '%s' in savegame", clsname.GetChars()); founderrors = true; r->mDObjects[i] = RUNTIME_CLASS(AActor)->CreateNew(); // make sure we got at least a valid pointer for the duration of the loading process. r->mDObjects[i]->Destroy(); // but we do not want to keep this around, so destroy it right away. diff --git a/src/serializer.h b/src/serializer.h index f1d35e1f88..a3e1f531ea 100644 --- a/src/serializer.h +++ b/src/serializer.h @@ -163,7 +163,7 @@ public: template FSerializer &Enum(const char *key, T &obj) { - auto val = (std::underlying_type::type)obj; + auto val = (typename std::underlying_type::type)obj; Serialize(*this, key, val, nullptr); obj = (T)val; return *this; @@ -299,4 +299,4 @@ FSerializer &Serialize(FSerializer &arc, const char *key, TFlags &flags, } -#endif \ No newline at end of file +#endif diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index 21551364bc..153c3b5970 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -7344,3 +7344,55 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetSpriteRotation) mobj->SpriteRotation = angle; ACTION_RETURN_BOOL(true); } + +//========================================================================== +// +// A_SetMaskRotation(anglestart, angleend, pitchstart, pitchend, flags, ptr) +// +// Specifies how much to fake a sprite rotation. +//========================================================================== + +enum VRFFlags +{ + VRF_NOANGLESTART = 1, + VRF_NOANGLEEND = 1 << 1, + VRF_NOPITCHSTART = 1 << 2, + VRF_NOPITCHEND = 1 << 3, +}; + +DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetVisibleRotation) +{ + PARAM_ACTION_PROLOGUE; + PARAM_ANGLE_OPT(anglestart) { anglestart = 0.; } + PARAM_ANGLE_OPT(angleend) { angleend = 0.; } + PARAM_ANGLE_OPT(pitchstart) { pitchstart = 0.; } + PARAM_ANGLE_OPT(pitchend) { pitchend = 0.; } + PARAM_INT_OPT(flags) { flags = 0; } + PARAM_INT_OPT(ptr) { ptr = AAPTR_DEFAULT; } + + AActor *mobj = COPY_AAPTR(self, ptr); + + if (mobj == nullptr) + { + ACTION_RETURN_BOOL(false); + } + + if (!(flags & VRF_NOANGLESTART)) + { + mobj->VisibleStartAngle = anglestart; + } + if (!(flags & VRF_NOANGLEEND)) + { + mobj->VisibleEndAngle = angleend; + } + if (!(flags & VRF_NOPITCHSTART)) + { + mobj->VisibleStartPitch = pitchstart; + } + if (!(flags & VRF_NOPITCHEND)) + { + mobj->VisibleEndPitch = pitchend; + } + + ACTION_RETURN_BOOL(true); +} diff --git a/src/thingdef/thingdef_data.cpp b/src/thingdef/thingdef_data.cpp index 8248634a38..efdd649216 100644 --- a/src/thingdef/thingdef_data.cpp +++ b/src/thingdef/thingdef_data.cpp @@ -275,6 +275,9 @@ static FFlagDef ActorFlagDefs[]= DEFINE_FLAG(RF, WALLSPRITE, AActor, renderflags), DEFINE_FLAG(RF, DONTFLIP, AActor, renderflags), DEFINE_FLAG(RF, ROLLCENTER, AActor, renderflags), + DEFINE_FLAG(RF, MASKROTATION, AActor, renderflags), + DEFINE_FLAG(RF, ABSMASKANGLE, AActor, renderflags), + DEFINE_FLAG(RF, ABSMASKPITCH, AActor, renderflags), // Bounce flags DEFINE_FLAG2(BOUNCE_Walls, BOUNCEONWALLS, AActor, BounceFlags), @@ -667,4 +670,8 @@ void InitThingdef() symt.AddSymbol(new PField(NAME_Threshold, TypeSInt32, VARF_Native|VARF_ReadOnly, myoffsetof(AActor, threshold))); symt.AddSymbol(new PField(NAME_DefThreshold, TypeSInt32, VARF_Native|VARF_ReadOnly, myoffsetof(AActor, DefThreshold))); symt.AddSymbol(new PField(NAME_Damage, TypeSInt32, VARF_Native|VARF_ReadOnly, myoffsetof(AActor, DamageVal))); + symt.AddSymbol(new PField(NAME_VisibleStartAngle, TypeFloat64, VARF_Native, myoffsetof(AActor, VisibleStartAngle))); + symt.AddSymbol(new PField(NAME_VisibleStartPitch, TypeFloat64, VARF_Native, myoffsetof(AActor, VisibleStartPitch))); + symt.AddSymbol(new PField(NAME_VisibleEndAngle, TypeFloat64, VARF_Native, myoffsetof(AActor, VisibleEndAngle))); + symt.AddSymbol(new PField(NAME_VisibleEndPitch, TypeFloat64, VARF_Native, myoffsetof(AActor, VisibleEndPitch))); } diff --git a/src/thingdef/thingdef_properties.cpp b/src/thingdef/thingdef_properties.cpp index 3cb424ea32..8ada05aa67 100644 --- a/src/thingdef/thingdef_properties.cpp +++ b/src/thingdef/thingdef_properties.cpp @@ -1431,6 +1431,28 @@ DEFINE_PROPERTY(spriterotation, F, Actor) defaults->SpriteRotation = i; } +//========================================================================== +// +//========================================================================== +DEFINE_PROPERTY(visibleangles, Ff, Actor) +{ + PROP_DOUBLE_PARM(visstart, 0); + PROP_DOUBLE_PARM(visend, 0); + defaults->VisibleStartAngle = visstart; + defaults->VisibleEndAngle = visend; +} + +//========================================================================== +// +//========================================================================== +DEFINE_PROPERTY(visiblepitch, Ff, Actor) +{ + PROP_DOUBLE_PARM(visstart, 0); + PROP_DOUBLE_PARM(visend, 0); + defaults->VisibleStartPitch = visstart; + defaults->VisibleEndPitch = visend; +} + //========================================================================== // //========================================================================== diff --git a/src/version.h b/src/version.h index a88d3e20b3..0c9b851206 100644 --- a/src/version.h +++ b/src/version.h @@ -75,7 +75,7 @@ const char *GetVersionString(); #define SAVEGAME_EXT "zds" // MINSAVEVER is the minimum level snapshot version that can be loaded. -#define MINSAVEVER 4545 +#define MINSAVEVER 4550 // Use 4500 as the base git save version, since it's higher than the // SVN revision ever got. diff --git a/wadsrc/static/actors/actor.txt b/wadsrc/static/actors/actor.txt index 374e2472d1..3354b91d63 100644 --- a/wadsrc/static/actors/actor.txt +++ b/wadsrc/static/actors/actor.txt @@ -38,6 +38,8 @@ ACTOR Actor native //: Thinker SpriteAngle 0 SpriteRotation 0 StencilColor "00 00 00" + VisibleAngles 0, 0 + VisiblePitch 0, 0 // Functions native bool CheckClass(class checkclass, int ptr_select = AAPTR_DEFAULT, bool match_superclass = false); @@ -340,6 +342,7 @@ ACTOR Actor native //: Thinker action native bool A_CopySpriteFrame(int from, int to, int flags = 0); action native bool A_SetSpriteAngle(float angle = 0, int ptr = AAPTR_DEFAULT); action native bool A_SetSpriteRotation(float angle = 0, int ptr = AAPTR_DEFAULT); + action native bool A_SetVisibleRotation(float anglestart = 0, float angleend = 0, float pitchstart = 0, float pitchend = 0, int flags = 0, int ptr = AAPTR_DEFAULT); native void A_RearrangePointers(int newtarget, int newmaster = AAPTR_DEFAULT, int newtracer = AAPTR_DEFAULT, int flags=0); native void A_TransferPointer(int ptr_source, int ptr_recepient, int sourcefield, int recepientfield=AAPTR_DEFAULT, int flags=0); diff --git a/wadsrc/static/actors/constants.txt b/wadsrc/static/actors/constants.txt index 2a6f1c4836..bd6d656434 100644 --- a/wadsrc/static/actors/constants.txt +++ b/wadsrc/static/actors/constants.txt @@ -677,4 +677,16 @@ enum { CPSF_NOSPRITE = 1, CPSF_NOFRAME = 1 << 1, +}; + +//Flags for A_SetMaskRotation +enum +{ + VRF_NOANGLESTART = 1, + VRF_NOANGLEEND = 1 << 1, + VRF_NOPITCHSTART = 1 << 2, + VRF_NOPITCHEND = 1 << 3, + + VRF_NOANGLE = VRF_NOANGLESTART|VRF_NOANGLEEND, + VRF_NOPITCH = VRF_NOPITCHSTART|VRF_NOPITCHEND, }; \ No newline at end of file