From 2bc561d135bd58e102f7bfe0156a6c134d3af26f Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Mon, 11 Nov 2024 06:50:59 -0500 Subject: [PATCH 01/15] - add automap default markers for all games (can be overridden) --- wadsrc/static/graphics/AMMNUM0.png | Bin 0 -> 89 bytes wadsrc/static/graphics/AMMNUM1.png | Bin 0 -> 88 bytes wadsrc/static/graphics/AMMNUM2.png | Bin 0 -> 86 bytes wadsrc/static/graphics/AMMNUM3.png | Bin 0 -> 84 bytes wadsrc/static/graphics/AMMNUM4.png | Bin 0 -> 89 bytes wadsrc/static/graphics/AMMNUM5.png | Bin 0 -> 87 bytes wadsrc/static/graphics/AMMNUM6.png | Bin 0 -> 89 bytes wadsrc/static/graphics/AMMNUM7.png | Bin 0 -> 87 bytes wadsrc/static/graphics/AMMNUM8.png | Bin 0 -> 86 bytes wadsrc/static/graphics/AMMNUM9.png | Bin 0 -> 89 bytes 10 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 wadsrc/static/graphics/AMMNUM0.png create mode 100644 wadsrc/static/graphics/AMMNUM1.png create mode 100644 wadsrc/static/graphics/AMMNUM2.png create mode 100644 wadsrc/static/graphics/AMMNUM3.png create mode 100644 wadsrc/static/graphics/AMMNUM4.png create mode 100644 wadsrc/static/graphics/AMMNUM5.png create mode 100644 wadsrc/static/graphics/AMMNUM6.png create mode 100644 wadsrc/static/graphics/AMMNUM7.png create mode 100644 wadsrc/static/graphics/AMMNUM8.png create mode 100644 wadsrc/static/graphics/AMMNUM9.png diff --git a/wadsrc/static/graphics/AMMNUM0.png b/wadsrc/static/graphics/AMMNUM0.png new file mode 100644 index 0000000000000000000000000000000000000000..6924f3956f24e24996bd6968d0575a6eb5fd6a1d GIT binary patch literal 89 zcmeAS@N?(olHy`uVBq!ia0y~yU|?ooU|{87VPIg;s+gzAz`&s3>Eakt5vSX^k(Ysi tqj^JnWsUsh3@&EoFLRj0JJe4`PtN7A*jX78%)r3F;OXk;vd$@?2>=xd6^{S_ literal 0 HcmV?d00001 diff --git a/wadsrc/static/graphics/AMMNUM1.png b/wadsrc/static/graphics/AMMNUM1.png new file mode 100644 index 0000000000000000000000000000000000000000..14dab57fe8ed3743552cc1fdaac1a624ce8b1850 GIT binary patch literal 88 zcmeAS@N?(olHy`uVBq!ia0y~yU|?ooU|{87VPIg;s+gzAz`!8y>Eakt5ode+ASVL@ sN9zUm=B@w3j@pYfX;iJ~*!_M(#wPaSW4@B?3=9kmp00i_>zopr08?uh@Bjb+ literal 0 HcmV?d00001 diff --git a/wadsrc/static/graphics/AMMNUM2.png b/wadsrc/static/graphics/AMMNUM2.png new file mode 100644 index 0000000000000000000000000000000000000000..4c6514893b7e7b10c7c5fd635169f8aa95a6a5fe GIT binary patch literal 86 zcmeAS@N?(olHy`uVBq!ia0y~yU|?ooU|{87VPIg;s+gzAz`!8u>Eakt5og=6QILT_ qz}aZ#-|eU7EBU*waC`BpUG7y3?*f|?Z3_kl1_n=8KbLh*2~7Y5WEM35 literal 0 HcmV?d00001 diff --git a/wadsrc/static/graphics/AMMNUM3.png b/wadsrc/static/graphics/AMMNUM3.png new file mode 100644 index 0000000000000000000000000000000000000000..bcd495a680c77795f63c17fa4d13699b0d7a5329 GIT binary patch literal 84 zcmeAS@N?(olHy`uVBq!ia0y~yU|?ooU|{87VPIg;s+gzAz`!8w>Eakt5trL;DagRU o(BzT!Kg@2oL4ksQTaEtH4BiE&C+bXRU|?YIboFyt=akR{0Ih)(bpQYW literal 0 HcmV?d00001 diff --git a/wadsrc/static/graphics/AMMNUM4.png b/wadsrc/static/graphics/AMMNUM4.png new file mode 100644 index 0000000000000000000000000000000000000000..6d373156cfd4ca7b8a6504719478834905ccd96d GIT binary patch literal 89 zcmeAS@N?(olHy`uVBq!ia0y~yU|?ooU|{87VPIg;s+gzAz`&s3>Eakt5$D>mk&}Ue ur+G>H)Bo#lS*bb-oczS&_c`h@Eakt5og=Jk(Ysi rr)kHU|Mgd=9qHgZu;#ITm1*g#7~Taz{2kd03=9mOu6{1-oD!MEakt5og=Jk(Ysi tqxr(&sy+RgzC8z+UWul^6Vm#}_F@yS#=*@YH4F?444$rjF6*2UngC@w7Eakt5f|EaP>_Lv rqiF|Q@&C16zd89Gq&aUrd@0j^jpcXYq1~Eakt5tn;>BQFC3 r3&Vz@8INt<-dtLl<#*}eZr0l^JR78cOtfQQU|{fc^>bP0l+XkKDmoYE literal 0 HcmV?d00001 diff --git a/wadsrc/static/graphics/AMMNUM9.png b/wadsrc/static/graphics/AMMNUM9.png new file mode 100644 index 0000000000000000000000000000000000000000..fa9232fa46b5d757703a725d27db56784e038f2f GIT binary patch literal 89 zcmeAS@N?(olHy`uVBq!ia0y~yU|?ooU|{87VPIg;s+gzAz`&s3>Eakt5vP0nATI+0 u3&TdE84q>cREp-Wo~8ZrLF?`7On3EoH5N|}=wV=BVDNPHb6Mw<&;$TakQeg+ literal 0 HcmV?d00001 From a145eac056233caaeeb702f2a15eabdcb6b40dd9 Mon Sep 17 00:00:00 2001 From: Blue Shadow Date: Mon, 11 Nov 2024 14:25:20 +0300 Subject: [PATCH 02/15] added constants for the most recently added level flags --- wadsrc/static/zscript/constants.zs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/wadsrc/static/zscript/constants.zs b/wadsrc/static/zscript/constants.zs index ae57f7a4d..b39573bd9 100644 --- a/wadsrc/static/zscript/constants.zs +++ b/wadsrc/static/zscript/constants.zs @@ -1409,6 +1409,8 @@ enum ELevelFlags LEVEL3_AVOIDMELEE = 0x00020000, // global flag needed for proper MBF support. LEVEL3_NOJUMPDOWN = 0x00040000, // only for MBF21. Inverse of MBF's dog_jumping flag. LEVEL3_LIGHTCREATED = 0x00080000, // a light had been created in the last frame + LEVEL3_NOFOGOFWAR = 0x00100000, // disables effect of r_radarclipper CVAR on this map + LEVEL3_SECRET = 0x00200000, // level is a secret level }; // [RH] Compatibility flags. From ea7ea182edd9d8e5674b42fedf43b2db123aa0c1 Mon Sep 17 00:00:00 2001 From: nashmuhandes Date: Tue, 12 Nov 2024 09:34:46 +0800 Subject: [PATCH 03/15] Add missing CHANF_ constants and fix the styling of the comments for better readability --- wadsrc/static/zscript/engine/base.zs | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/wadsrc/static/zscript/engine/base.zs b/wadsrc/static/zscript/engine/base.zs index 69f5d66fe..e25c82229 100644 --- a/wadsrc/static/zscript/engine/base.zs +++ b/wadsrc/static/zscript/engine/base.zs @@ -15,27 +15,29 @@ enum ESoundFlags // modifier flags CHAN_LISTENERZ = 8, CHAN_MAYBE_LOCAL = 16, - CHAN_UI = 32, - CHAN_NOPAUSE = 64, + CHAN_UI = 32, // Do not record sound in savegames. + CHAN_NOPAUSE = 64, // Do not pause this sound in menus. CHAN_LOOP = 256, CHAN_PICKUP = (CHAN_ITEM|CHAN_MAYBE_LOCAL), // Do not use this with A_StartSound! It would not do what is expected. - CHAN_NOSTOP = 4096, - CHAN_OVERLAP = 8192, + CHAN_NOSTOP = 4096, // only for A_PlaySound. Does not start if channel is playing something. + CHAN_OVERLAP = 8192, // [MK] Does not stop any sounds in the channel and instead plays over them. // Same as above, with an F appended to allow better distinction of channel and channel flags. - CHANF_DEFAULT = 0, // just to make the code look better and avoid literal 0's. + CHANF_DEFAULT = 0, // just to make the code look better and avoid literal 0's. CHANF_LISTENERZ = 8, CHANF_MAYBE_LOCAL = 16, - CHANF_UI = 32, - CHANF_NOPAUSE = 64, + CHANF_UI = 32, // Do not record sound in savegames. + CHANF_NOPAUSE = 64, // Do not pause this sound in menus. CHANF_LOOP = 256, - CHANF_NOSTOP = 4096, - CHANF_OVERLAP = 8192, - CHANF_LOCAL = 16384, + CHANF_NOSTOP = 4096, // only for A_PlaySound. Does not start if channel is playing something. + CHANF_OVERLAP = 8192, // [MK] Does not stop any sounds in the channel and instead plays over them. + CHANF_LOCAL = 16384, // only plays locally for the calling actor + CHANF_TRANSIENT = 32768, // Do not record in savegames - used for sounds that get restarted outside the sound system (e.g. ambients in SW and Blood) + CHANF_FORCE = 65536, // Start, even if sound is paused. + CHANF_SINGULAR = 0x20000, // Only start if no sound of this name is already playing. CHANF_LOOPING = CHANF_LOOP | CHANF_NOSTOP, // convenience value for replicating the old 'looping' boolean. - }; // sound attenuation values From bb5c8d8124181180f505e34093fc133616f9cd17 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Thu, 13 Jun 2024 04:59:14 -0400 Subject: [PATCH 04/15] - don't fudge light position out of the floor for +NOINTERACTION actors --- src/playsim/a_dynlight.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/playsim/a_dynlight.cpp b/src/playsim/a_dynlight.cpp index 6d67d4e1b..3dc653898 100644 --- a/src/playsim/a_dynlight.cpp +++ b/src/playsim/a_dynlight.cpp @@ -383,10 +383,14 @@ void FDynamicLight::UpdateLocation() Pos = target->Vec3Offset(m_off.X * c + m_off.Y * s, m_off.X * s - m_off.Y * c, m_off.Z + target->GetBobOffset()); Sector = target->subsector->sector; // Get the render sector. target->Sector is the sector according to play logic. - // Some z-coordinate fudging to prevent the light from getting too close to the floor or ceiling planes. With proper attenuation this would render them invisible. - // A distance of 5 is needed so that the light's effect doesn't become too small. - if (Z() < target->floorz + 5.) Pos.Z = target->floorz + 5.; - else if (Z() > target->ceilingz - 5.) Pos.Z = target->ceilingz - 5.; + if (!(target->flags5 & MF5_NOINTERACTION)) + { + // Some z-coordinate fudging to prevent the light from getting too close to the floor or ceiling planes. With proper attenuation this would render them invisible. + // A distance of 5 is needed so that the light's effect doesn't become too small. + // [SP] don't do this if +NOINTERACTION is set, since the object can fly right through floors and ceilings with that flag + if (Z() < target->floorz + 5.) Pos.Z = target->floorz + 5.; + else if (Z() > target->ceilingz - 5.) Pos.Z = target->ceilingz - 5.; + } // The radius being used here is always the maximum possible with the // current settings. This avoids constant relinking of flickering lights From 1e4f17639556daed8ff44a4d85e7753fafd538c0 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Tue, 12 Nov 2024 06:34:26 -0500 Subject: [PATCH 05/15] - move appimage workflow to unused/ --- {.github/workflows => unused}/appimage.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {.github/workflows => unused}/appimage.yml (100%) diff --git a/.github/workflows/appimage.yml b/unused/appimage.yml similarity index 100% rename from .github/workflows/appimage.yml rename to unused/appimage.yml From 3a83762c5119061ec5e4cbd28305c20e6ac054c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Lu=C3=ADs=20Vaz=20Silva?= Date: Sat, 28 Oct 2023 16:38:12 -0300 Subject: [PATCH 06/15] Allow property-less flagdefs for non-actors --- src/scripting/zscript/zcc_compile_doom.cpp | 43 +++++++++++----------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/src/scripting/zscript/zcc_compile_doom.cpp b/src/scripting/zscript/zcc_compile_doom.cpp index a86ea9a0e..bd7ba9048 100644 --- a/src/scripting/zscript/zcc_compile_doom.cpp +++ b/src/scripting/zscript/zcc_compile_doom.cpp @@ -161,17 +161,14 @@ bool ZCCDoomCompiler::CompileProperties(PClass *type, TArray &Pr bool ZCCDoomCompiler::CompileFlagDefs(PClass *type, TArray &Properties, FName prefix) { - if (!type->IsDescendantOf(RUNTIME_CLASS(AActor))) - { - Error(Properties[0], "Flags can only be defined for actors"); - return false; - } + //[RL0] allow property-less flagdefs for non-actors + bool isActor = type->IsDescendantOf(RUNTIME_CLASS(AActor)); for (auto p : Properties) { PField *field; FName referenced = FName(p->RefName); - if (FName(p->NodeName) == FName("prefix") && fileSystem.GetFileContainer(Lump) == 0) + if (isActor && FName(p->NodeName) == FName("prefix") && fileSystem.GetFileContainer(Lump) == 0) { // only for internal definitions: Allow setting a prefix. This is only for compatiblity with the old DECORATE property parser, but not for general use. prefix = referenced; @@ -191,24 +188,28 @@ bool ZCCDoomCompiler::CompileFlagDefs(PClass *type, TArray &Prope } } else field = nullptr; - - - FString qualifiedname; - // Store the full qualified name and prepend some 'garbage' to the name so that no conflicts with other symbol types can happen. - // All these will be removed from the symbol table after the compiler finishes to free up the allocated space. + FName name = FName(p->NodeName); - for (int i = 0; i < 2; i++) - { - if (i == 0) qualifiedname.Format("@flagdef@%s", name.GetChars()); - else - { - if (prefix == NAME_None) continue; - qualifiedname.Format("@flagdef@%s.%s", prefix.GetChars(), name.GetChars()); - } - if (!type->VMType->Symbols.AddSymbol(Create(qualifiedname, field, p->BitValue, i == 0 && prefix != NAME_None))) + if(isActor) + { + FString qualifiedname; + // Store the full qualified name and prepend some 'garbage' to the name so that no conflicts with other symbol types can happen. + // All these will be removed from the symbol table after the compiler finishes to free up the allocated space. + + for (int i = 0; i < 2; i++) { - Error(p, "Unable to add flag definition %s to class %s", FName(p->NodeName).GetChars(), type->TypeName.GetChars()); + if (i == 0) qualifiedname.Format("@flagdef@%s", name.GetChars()); + else + { + if (prefix == NAME_None) continue; + qualifiedname.Format("@flagdef@%s.%s", prefix.GetChars(), name.GetChars()); + } + + if (!type->VMType->Symbols.AddSymbol(Create(qualifiedname, field, p->BitValue, i == 0 && prefix != NAME_None))) + { + Error(p, "Unable to add flag definition %s to class %s", FName(p->NodeName).GetChars(), type->TypeName.GetChars()); + } } } From 3622e2bb2a7d17ede6443c6bbb39011b923fd467 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Lu=C3=ADs=20Vaz=20Silva?= Date: Tue, 12 Nov 2024 16:00:41 -0300 Subject: [PATCH 07/15] Compress visualthinker bools into a flags field --- src/playsim/p_effect.cpp | 32 +++++++------------ src/playsim/p_effect.h | 18 +++++++---- src/rendering/hwrenderer/scene/hw_sprites.cpp | 7 ++-- wadsrc/static/zscript/constants.zs | 10 ++++++ wadsrc/static/zscript/visualthinker.zs | 21 +++++++----- 5 files changed, 49 insertions(+), 39 deletions(-) diff --git a/src/playsim/p_effect.cpp b/src/playsim/p_effect.cpp index bdceae149..2e5b3d342 100644 --- a/src/playsim/p_effect.cpp +++ b/src/playsim/p_effect.cpp @@ -364,9 +364,9 @@ void P_SpawnParticle(FLevelLocals *Level, const DVector3 &pos, const DVector3 &v particle->sizestep = sizestep; particle->texture = texture; particle->style = style; - particle->Roll = startroll; - particle->RollVel = rollvel; - particle->RollAcc = rollacc; + particle->Roll = (float)startroll; + particle->RollVel = (float)rollvel; + particle->RollAcc = (float)rollacc; particle->flags = flags; if(flags & SPF_LOCAL_ANIM) { @@ -1125,7 +1125,7 @@ int DVisualThinker::GetLightLevel(sector_t* rendersector) const { int lightlevel = rendersector->GetSpriteLight(); - if (bAddLightLevel) + if (flags & VTF_AddLightLevel) { lightlevel += LightLevel; } @@ -1138,7 +1138,7 @@ int DVisualThinker::GetLightLevel(sector_t* rendersector) const FVector3 DVisualThinker::InterpolatedPosition(double ticFrac) const { - if (bDontInterpolate) return FVector3(PT.Pos); + if (flags & VTF_DontInterpolate) return FVector3(PT.Pos); DVector3 proc = Prev + (ticFrac * (PT.Pos - Prev)); return FVector3(proc); @@ -1147,7 +1147,7 @@ FVector3 DVisualThinker::InterpolatedPosition(double ticFrac) const float DVisualThinker::InterpolatedRoll(double ticFrac) const { - if (bDontInterpolate) return PT.Roll; + if (flags & VTF_DontInterpolate) return PT.Roll; return float(PrevRoll + (PT.Roll - PrevRoll) * ticFrac); } @@ -1227,9 +1227,9 @@ int DVisualThinker::GetRenderStyle() float DVisualThinker::GetOffset(bool y) const // Needed for the renderer. { if (y) - return (float)(bFlipOffsetY ? Offset.Y : -Offset.Y); + return (float)((flags & VTF_FlipOffsetY) ? Offset.Y : -Offset.Y); else - return (float)(bFlipOffsetX ? Offset.X : -Offset.X); + return (float)((flags & VTF_FlipOffsetX) ? Offset.X : -Offset.X); } void DVisualThinker::Serialize(FSerializer& arc) @@ -1250,14 +1250,9 @@ void DVisualThinker::Serialize(FSerializer& arc) ("translation", Translation) ("cursector", cursector) ("scolor", PT.color) - ("flipx", bXFlip) - ("flipy", bYFlip) - ("dontinterpolate", bDontInterpolate) - ("addlightlevel", bAddLightLevel) - ("flipoffsetx", bFlipOffsetX) - ("flipoffsetY", bFlipOffsetY) ("lightlevel", LightLevel) - ("flags", PT.flags); + ("flags", PT.flags) + ("visualThinkerFlags", flags); } @@ -1269,6 +1264,7 @@ DEFINE_FIELD_NAMED(DVisualThinker, PT.Roll, Roll); DEFINE_FIELD_NAMED(DVisualThinker, PT.alpha, Alpha); DEFINE_FIELD_NAMED(DVisualThinker, PT.texture, Texture); DEFINE_FIELD_NAMED(DVisualThinker, PT.flags, Flags); +DEFINE_FIELD_NAMED(DVisualThinker, flags, VisualThinkerFlags); DEFINE_FIELD(DVisualThinker, Prev); DEFINE_FIELD(DVisualThinker, Scale); @@ -1277,9 +1273,3 @@ DEFINE_FIELD(DVisualThinker, PrevRoll); DEFINE_FIELD(DVisualThinker, Translation); DEFINE_FIELD(DVisualThinker, LightLevel); DEFINE_FIELD(DVisualThinker, cursector); -DEFINE_FIELD(DVisualThinker, bXFlip); -DEFINE_FIELD(DVisualThinker, bYFlip); -DEFINE_FIELD(DVisualThinker, bDontInterpolate); -DEFINE_FIELD(DVisualThinker, bAddLightLevel); -DEFINE_FIELD(DVisualThinker, bFlipOffsetX); -DEFINE_FIELD(DVisualThinker, bFlipOffsetY); diff --git a/src/playsim/p_effect.h b/src/playsim/p_effect.h index 735a87e81..fdb72c296 100644 --- a/src/playsim/p_effect.h +++ b/src/playsim/p_effect.h @@ -158,6 +158,17 @@ void P_DisconnectEffect (AActor *actor); //=========================================================================== class HWSprite; struct FTranslationID; + +enum EVisualThinkerFlags +{ + VTF_FlipOffsetX = 1 << 0, + VTF_FlipOffsetY = 1 << 1, + VTF_FlipX = 1 << 2, + VTF_FlipY = 1 << 3, // flip the sprite on the x/y axis. + VTF_DontInterpolate = 1 << 4, // disable all interpolation + VTF_AddLightLevel = 1 << 5, // adds sector light level to 'LightLevel' +}; + class DVisualThinker : public DThinker { DECLARE_CLASS(DVisualThinker, DThinker); @@ -171,12 +182,7 @@ public: FTextureID AnimatedTexture; sector_t *cursector; - bool bFlipOffsetX, - bFlipOffsetY, - bXFlip, - bYFlip, // flip the sprite on the x/y axis. - bDontInterpolate, // disable all interpolation - bAddLightLevel; // adds sector light level to 'LightLevel' + int flags; // internal only variables particle_t PT; diff --git a/src/rendering/hwrenderer/scene/hw_sprites.cpp b/src/rendering/hwrenderer/scene/hw_sprites.cpp index cbca1a90d..a8a9502fd 100644 --- a/src/rendering/hwrenderer/scene/hw_sprites.cpp +++ b/src/rendering/hwrenderer/scene/hw_sprites.cpp @@ -1599,7 +1599,7 @@ void HWSprite::AdjustVisualThinker(HWDrawInfo* di, DVisualThinker* spr, sector_t ? TexAnim.UpdateStandaloneAnimation(spr->PT.animData, di->Level->maptime + timefrac) : spr->PT.texture, !custom_anim); - if (spr->bDontInterpolate) + if (spr->flags & VTF_DontInterpolate) timefrac = 0.; FVector3 interp = spr->InterpolatedPosition(timefrac); @@ -1629,13 +1629,12 @@ void HWSprite::AdjustVisualThinker(HWDrawInfo* di, DVisualThinker* spr, sector_t double mult = 1.0 / sqrt(ps); // shrink slightly r.Scale(mult * ps, mult); } - - if (spr->bXFlip) + if (spr->flags & VTF_FlipX) { std::swap(ul,ur); r.left = -r.width - r.left; // mirror the sprite's x-offset } - if (spr->bYFlip) std::swap(vt,vb); + if (spr->flags & VTF_FlipY) std::swap(vt,vb); float viewvecX = vp.ViewVector.X; float viewvecY = vp.ViewVector.Y; diff --git a/wadsrc/static/zscript/constants.zs b/wadsrc/static/zscript/constants.zs index b39573bd9..5421c188e 100644 --- a/wadsrc/static/zscript/constants.zs +++ b/wadsrc/static/zscript/constants.zs @@ -1516,3 +1516,13 @@ enum EModelFlags MDL_CORRECTPIXELSTRETCH = 1<<13, // ensure model does not distort with pixel stretch when pitch/roll is applied MDL_FORCECULLBACKFACES = 1<<14, }; + +enum EVisualThinkerFlags +{ + VTF_FlipOffsetX = 1 << 0, + VTF_FlipOffsetY = 1 << 1, + VTF_FlipX = 1 << 2, + VTF_FlipY = 1 << 3, // flip the sprite on the x/y axis. + VTF_DontInterpolate = 1 << 4, // disable all interpolation + VTF_AddLightLevel = 1 << 5, // adds sector light level to 'LightLevel' +}; diff --git a/wadsrc/static/zscript/visualthinker.zs b/wadsrc/static/zscript/visualthinker.zs index 12a8c41d6..fad1d458c 100644 --- a/wadsrc/static/zscript/visualthinker.zs +++ b/wadsrc/static/zscript/visualthinker.zs @@ -10,14 +10,18 @@ Class VisualThinker : Thinker native Alpha; native TextureID Texture; native TranslationID Translation; - native uint16 Flags; native int16 LightLevel; - native bool bFlipOffsetX, - bFlipOffsetY, - bXFlip, - bYFlip, - bDontInterpolate, - bAddLightLevel; + + native uint16 Flags; + native int VisualThinkerFlags; + + FlagDef FlipOffsetX : VisualThinkerFlags, 0; + FlagDef FlipOffsetY : VisualThinkerFlags, 1; + FlagDef XFlip : VisualThinkerFlags, 2; + FlagDef YFlip : VisualThinkerFlags, 3; + FlagDef DontInterpolate : VisualThinkerFlags, 4; + FlagDef AddLightLevel : VisualThinkerFlags, 5; + native Color scolor; native Sector CurSector; // can be null! @@ -27,7 +31,7 @@ Class VisualThinker : Thinker native native bool IsFrozen(); static VisualThinker Spawn(Class type, TextureID tex, Vector3 pos, Vector3 vel, double alpha = 1.0, int flags = 0, - double roll = 0.0, Vector2 scale = (1,1), Vector2 offset = (0,0), int style = STYLE_Normal, TranslationID trans = 0) + double roll = 0.0, Vector2 scale = (1,1), Vector2 offset = (0,0), int style = STYLE_Normal, TranslationID trans = 0, int VisualThinkerFlags = 0) { if (!Level) return null; @@ -44,6 +48,7 @@ Class VisualThinker : Thinker native p.SetRenderStyle(style); p.Translation = trans; p.Flags = flags; + p.VisualThinkerFlags = VisualThinkerFlags; } return p; } From 174344ddf1490db83226b16997b8f70d10c68e4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Lu=C3=ADs=20Vaz=20Silva?= Date: Tue, 12 Nov 2024 16:03:28 -0300 Subject: [PATCH 08/15] move visual thinker definition into its own header --- src/common/objects/dobjtype.cpp | 10 ++- src/common/objects/dobjtype.h | 2 +- src/g_levellocals.h | 4 +- src/playsim/dthinker.cpp | 2 + src/playsim/p_effect.cpp | 1 + src/playsim/p_effect.h | 60 +----------------- src/playsim/p_visualthinker.h | 61 +++++++++++++++++++ src/rendering/hwrenderer/scene/hw_bsp.cpp | 2 + src/rendering/hwrenderer/scene/hw_sprites.cpp | 2 + 9 files changed, 80 insertions(+), 64 deletions(-) create mode 100644 src/playsim/p_visualthinker.h diff --git a/src/common/objects/dobjtype.cpp b/src/common/objects/dobjtype.cpp index 0d1bfdf9a..a3172c5e5 100644 --- a/src/common/objects/dobjtype.cpp +++ b/src/common/objects/dobjtype.cpp @@ -46,6 +46,8 @@ #include "symbols.h" #include "types.h" +#include "p_visualthinker.h" + // MACROS ------------------------------------------------------------------ // TYPES ------------------------------------------------------------------- @@ -421,7 +423,7 @@ PClass *PClass::FindClass (FName zaname) // //========================================================================== -DObject *PClass::CreateNew() +DObject *PClass::CreateNew(int *statnum) { uint8_t *mem = (uint8_t *)M_Malloc (Size); assert (mem != nullptr); @@ -444,6 +446,12 @@ DObject *PClass::CreateNew() ((DObject *)mem)->SetClass (const_cast(this)); InitializeSpecials(mem, Defaults, &PClass::SpecialInits); + + if(statnum && ((DObject *)mem)->IsKindOf(RUNTIME_CLASS(DVisualThinker))) + { + *statnum = STAT_VISUALTHINKER; + } + return (DObject *)mem; } diff --git a/src/common/objects/dobjtype.h b/src/common/objects/dobjtype.h index 62e6f5ccc..17ad29862 100644 --- a/src/common/objects/dobjtype.h +++ b/src/common/objects/dobjtype.h @@ -90,7 +90,7 @@ public: PClass(); ~PClass(); void InsertIntoHash(bool native); - DObject *CreateNew(); + DObject *CreateNew(int *statnum = nullptr); PClass *CreateDerivedClass(FName name, unsigned int size, bool *newlycreated = nullptr, int fileno = 0); void InitializeActorInfo(); diff --git a/src/g_levellocals.h b/src/g_levellocals.h index 1b6c82d1b..719427d26 100644 --- a/src/g_levellocals.h +++ b/src/g_levellocals.h @@ -425,11 +425,9 @@ public: DThinker *CreateThinker(PClass *cls, int statnum = STAT_DEFAULT) { - DThinker *thinker = static_cast(cls->CreateNew()); + DThinker *thinker = static_cast(cls->CreateNew(&statnum)); assert(thinker->IsKindOf(RUNTIME_CLASS(DThinker))); thinker->ObjectFlags |= OF_JustSpawned; - if (thinker->IsKindOf(RUNTIME_CLASS(DVisualThinker))) // [MC] This absolutely must happen for this class! - statnum = STAT_VISUALTHINKER; Thinkers.Link(thinker, statnum); thinker->Level = this; return thinker; diff --git a/src/playsim/dthinker.cpp b/src/playsim/dthinker.cpp index 4229de792..e84384752 100644 --- a/src/playsim/dthinker.cpp +++ b/src/playsim/dthinker.cpp @@ -46,6 +46,8 @@ #include "g_cvars.h" #include "d_main.h" +#include "p_visualthinker.h" + static int ThinkCount; static cycle_t ThinkCycles; extern cycle_t BotSupportCycles; diff --git a/src/playsim/p_effect.cpp b/src/playsim/p_effect.cpp index 2e5b3d342..bc9e88163 100644 --- a/src/playsim/p_effect.cpp +++ b/src/playsim/p_effect.cpp @@ -50,6 +50,7 @@ #include "actorinlines.h" #include "g_game.h" #include "serializer_doom.h" +#include "p_visualthinker.h" #include "hwrenderer/scene/hw_drawstructs.h" diff --git a/src/playsim/p_effect.h b/src/playsim/p_effect.h index fdb72c296..1e5ba2705 100644 --- a/src/playsim/p_effect.h +++ b/src/playsim/p_effect.h @@ -147,62 +147,4 @@ struct SPortalHit void P_DrawRailTrail(AActor *source, TArray &portalhits, int color1, int color2, double maxdiff = 0, int flags = 0, PClassActor *spawnclass = NULL, DAngle angle = nullAngle, int duration = TICRATE, double sparsity = 1.0, double drift = 1.0, int SpiralOffset = 270, DAngle pitch = nullAngle); void P_DrawSplash (FLevelLocals *Level, int count, const DVector3 &pos, DAngle angle, int kind); void P_DrawSplash2 (FLevelLocals *Level, int count, const DVector3 &pos, DAngle angle, int updown, int kind); -void P_DisconnectEffect (AActor *actor); - -//=========================================================================== -// -// VisualThinkers -// by Major Cooke -// Credit to phantombeta, RicardoLuis0 & RaveYard for aid -// -//=========================================================================== -class HWSprite; -struct FTranslationID; - -enum EVisualThinkerFlags -{ - VTF_FlipOffsetX = 1 << 0, - VTF_FlipOffsetY = 1 << 1, - VTF_FlipX = 1 << 2, - VTF_FlipY = 1 << 3, // flip the sprite on the x/y axis. - VTF_DontInterpolate = 1 << 4, // disable all interpolation - VTF_AddLightLevel = 1 << 5, // adds sector light level to 'LightLevel' -}; - -class DVisualThinker : public DThinker -{ - DECLARE_CLASS(DVisualThinker, DThinker); -public: - DVector3 Prev; - DVector2 Scale, - Offset; - float PrevRoll; - int16_t LightLevel; - FTranslationID Translation; - FTextureID AnimatedTexture; - sector_t *cursector; - - int flags; - - // internal only variables - particle_t PT; - HWSprite *spr; //in an effort to cache the result. - - DVisualThinker(); - void Construct(); - void OnDestroy() override; - - static DVisualThinker* NewVisualThinker(FLevelLocals* Level, PClass* type); - void SetTranslation(FName trname); - int GetRenderStyle(); - bool isFrozen(); - int GetLightLevel(sector_t *rendersector) const; - FVector3 InterpolatedPosition(double ticFrac) const; - float InterpolatedRoll(double ticFrac) const; - - void Tick() override; - void UpdateSpriteInfo(); - void Serialize(FSerializer& arc) override; - - float GetOffset(bool y) const; -}; \ No newline at end of file +void P_DisconnectEffect (AActor *actor); \ No newline at end of file diff --git a/src/playsim/p_visualthinker.h b/src/playsim/p_visualthinker.h new file mode 100644 index 000000000..c52cc1cd4 --- /dev/null +++ b/src/playsim/p_visualthinker.h @@ -0,0 +1,61 @@ +#pragma once + +#include "palettecontainer.h" +#include "hwrenderer/scene/hw_drawstructs.h" + + +//=========================================================================== +// +// VisualThinkers +// by Major Cooke +// Credit to phantombeta, RicardoLuis0 & RaveYard for aid +// +//=========================================================================== + +enum EVisualThinkerFlags +{ + VTF_FlipOffsetX = 1 << 0, + VTF_FlipOffsetY = 1 << 1, + VTF_FlipX = 1 << 2, + VTF_FlipY = 1 << 3, // flip the sprite on the x/y axis. + VTF_DontInterpolate = 1 << 4, // disable all interpolation + VTF_AddLightLevel = 1 << 5, // adds sector light level to 'LightLevel' +}; + +class DVisualThinker : public DThinker +{ + DECLARE_CLASS(DVisualThinker, DThinker); +public: + DVector3 Prev; + DVector2 Scale, + Offset; + float PrevRoll; + int16_t LightLevel; + FTranslationID Translation; + FTextureID AnimatedTexture; + sector_t *cursector; + + int flags; + + // internal only variables + particle_t PT; + HWSprite *spr; //in an effort to cache the result. + + DVisualThinker(); + void Construct(); + void OnDestroy() override; + + static DVisualThinker* NewVisualThinker(FLevelLocals* Level, PClass* type); + void SetTranslation(FName trname); + int GetRenderStyle(); + bool isFrozen(); + int GetLightLevel(sector_t *rendersector) const; + FVector3 InterpolatedPosition(double ticFrac) const; + float InterpolatedRoll(double ticFrac) const; + + void Tick() override; + void UpdateSpriteInfo(); + void Serialize(FSerializer& arc) override; + + float GetOffset(bool y) const; +}; \ No newline at end of file diff --git a/src/rendering/hwrenderer/scene/hw_bsp.cpp b/src/rendering/hwrenderer/scene/hw_bsp.cpp index c36f86e83..ef4c89cb1 100644 --- a/src/rendering/hwrenderer/scene/hw_bsp.cpp +++ b/src/rendering/hwrenderer/scene/hw_bsp.cpp @@ -44,6 +44,8 @@ #include "hw_vertexbuilder.h" #include "hw_walldispatcher.h" +#include "p_visualthinker.h" + #ifdef ARCH_IA32 #include #endif // ARCH_IA32 diff --git a/src/rendering/hwrenderer/scene/hw_sprites.cpp b/src/rendering/hwrenderer/scene/hw_sprites.cpp index a8a9502fd..b7e1f20fe 100644 --- a/src/rendering/hwrenderer/scene/hw_sprites.cpp +++ b/src/rendering/hwrenderer/scene/hw_sprites.cpp @@ -60,6 +60,8 @@ #include "hw_renderstate.h" #include "quaternion.h" +#include "p_visualthinker.h" + extern TArray sprites; extern TArray SpriteFrames; extern uint32_t r_renderercaps; From 9466c2d13880aa81360cee26086adf0497fc9f2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Lu=C3=ADs=20Vaz=20Silva?= Date: Tue, 12 Nov 2024 16:05:24 -0300 Subject: [PATCH 09/15] remove unecessary allocations --- src/playsim/p_effect.cpp | 6 ------ src/playsim/p_visualthinker.h | 1 - src/rendering/hwrenderer/scene/hw_bsp.cpp | 5 ++--- 3 files changed, 2 insertions(+), 10 deletions(-) diff --git a/src/playsim/p_effect.cpp b/src/playsim/p_effect.cpp index bc9e88163..86b9ac1bf 100644 --- a/src/playsim/p_effect.cpp +++ b/src/playsim/p_effect.cpp @@ -1006,7 +1006,6 @@ void DVisualThinker::Construct() PT.subsector = nullptr; cursector = nullptr; PT.color = 0xffffff; - spr = new HWSprite(); AnimatedTexture.SetNull(); } @@ -1018,11 +1017,6 @@ DVisualThinker::DVisualThinker() void DVisualThinker::OnDestroy() { PT.alpha = 0.0; // stops all rendering. - if(spr) - { - delete spr; - spr = nullptr; - } Super::OnDestroy(); } diff --git a/src/playsim/p_visualthinker.h b/src/playsim/p_visualthinker.h index c52cc1cd4..953f2f0ff 100644 --- a/src/playsim/p_visualthinker.h +++ b/src/playsim/p_visualthinker.h @@ -39,7 +39,6 @@ public: // internal only variables particle_t PT; - HWSprite *spr; //in an effort to cache the result. DVisualThinker(); void Construct(); diff --git a/src/rendering/hwrenderer/scene/hw_bsp.cpp b/src/rendering/hwrenderer/scene/hw_bsp.cpp index ef4c89cb1..2c1abdf7c 100644 --- a/src/rendering/hwrenderer/scene/hw_bsp.cpp +++ b/src/rendering/hwrenderer/scene/hw_bsp.cpp @@ -669,10 +669,9 @@ void HWDrawInfo::RenderParticles(subsector_t *sub, sector_t *front) int clipres = mClipPortal->ClipPoint(sp->PT.Pos.XY()); if (clipres == PClip_InFront) continue; } - - assert(sp->spr); - sp->spr->ProcessParticle(this, &sp->PT, front, sp); + HWSprite sprite; + sprite.ProcessParticle(this, &sp->PT, front, sp); } for (int i = Level->ParticlesInSubsec[sub->Index()]; i != NO_PARTICLE; i = Level->Particles[i].snext) { From d94a596bc2b6c401cf794072cc906ede6eeba7d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Lu=C3=ADs=20Vaz=20Silva?= Date: Tue, 12 Nov 2024 16:21:26 -0300 Subject: [PATCH 10/15] move crucial functions out of Tick, so that light custom tick overrides can be done without calling super.Tick for non-moving visualthinkers --- src/playsim/p_effect.cpp | 51 ++++++++++++++++++++------ src/playsim/p_visualthinker.h | 2 + wadsrc/static/zscript/visualthinker.zs | 5 +++ 3 files changed, 46 insertions(+), 12 deletions(-) diff --git a/src/playsim/p_effect.cpp b/src/playsim/p_effect.cpp index 86b9ac1bf..5abf899eb 100644 --- a/src/playsim/p_effect.cpp +++ b/src/playsim/p_effect.cpp @@ -1045,6 +1045,33 @@ static DVisualThinker* SpawnVisualThinker(FLevelLocals* Level, PClass* type) return DVisualThinker::NewVisualThinker(Level, type); } +void DVisualThinker::UpdateSector(subsector_t * newSubsector) +{ + assert(newSubsector); + if(PT.subsector != newSubsector) + { + PT.subsector = newSubsector; + cursector = newSubsector->sector; + } +} + +void DVisualThinker::UpdateSector() +{ + UpdateSector(Level->PointInRenderSubsector(PT.Pos)); +} + +static void UpdateSector(DVisualThinker * self) +{ + self->UpdateSector(); +} + +DEFINE_ACTION_FUNCTION_NATIVE(DVisualThinker, UpdateSector, UpdateSector) +{ + PARAM_SELF_PROLOGUE(DVisualThinker); + self->UpdateSector(); + return 0; +} + DEFINE_ACTION_FUNCTION_NATIVE(FLevelLocals, SpawnVisualThinker, SpawnVisualThinker) { PARAM_SELF_STRUCT_PROLOGUE(FLevelLocals); @@ -1092,27 +1119,27 @@ void DVisualThinker::Tick() PT.Pos.Y = newxy.Y; PT.Pos.Z += PT.Vel.Z; - PT.subsector = Level->PointInRenderSubsector(PT.Pos); - cursector = PT.subsector->sector; + subsector_t * ss = Level->PointInRenderSubsector(PT.Pos); + // Handle crossing a sector portal. - if (!cursector->PortalBlocksMovement(sector_t::ceiling)) + if (!ss->sector->PortalBlocksMovement(sector_t::ceiling)) { - if (PT.Pos.Z > cursector->GetPortalPlaneZ(sector_t::ceiling)) + if (PT.Pos.Z > ss->sector->GetPortalPlaneZ(sector_t::ceiling)) { - PT.Pos += cursector->GetPortalDisplacement(sector_t::ceiling); - PT.subsector = Level->PointInRenderSubsector(PT.Pos); - cursector = PT.subsector->sector; + PT.Pos += ss->sector->GetPortalDisplacement(sector_t::ceiling); + ss = Level->PointInRenderSubsector(PT.Pos); } } - else if (!cursector->PortalBlocksMovement(sector_t::floor)) + else if (!ss->sector->PortalBlocksMovement(sector_t::floor)) { - if (PT.Pos.Z < cursector->GetPortalPlaneZ(sector_t::floor)) + if (PT.Pos.Z < ss->sector->GetPortalPlaneZ(sector_t::floor)) { - PT.Pos += cursector->GetPortalDisplacement(sector_t::floor); - PT.subsector = Level->PointInRenderSubsector(PT.Pos); - cursector = PT.subsector->sector; + PT.Pos += ss->sector->GetPortalDisplacement(sector_t::floor); + ss = Level->PointInRenderSubsector(PT.Pos); } } + + UpdateSector(ss); UpdateSpriteInfo(); } diff --git a/src/playsim/p_visualthinker.h b/src/playsim/p_visualthinker.h index 953f2f0ff..d4b1e262d 100644 --- a/src/playsim/p_visualthinker.h +++ b/src/playsim/p_visualthinker.h @@ -25,6 +25,7 @@ enum EVisualThinkerFlags class DVisualThinker : public DThinker { DECLARE_CLASS(DVisualThinker, DThinker); + void UpdateSector(subsector_t * newSubsector); public: DVector3 Prev; DVector2 Scale, @@ -54,6 +55,7 @@ public: void Tick() override; void UpdateSpriteInfo(); + void UpdateSector(); void Serialize(FSerializer& arc) override; float GetOffset(bool y) const; diff --git a/wadsrc/static/zscript/visualthinker.zs b/wadsrc/static/zscript/visualthinker.zs index fad1d458c..45b32865c 100644 --- a/wadsrc/static/zscript/visualthinker.zs +++ b/wadsrc/static/zscript/visualthinker.zs @@ -30,6 +30,9 @@ Class VisualThinker : Thinker native native void SetRenderStyle(int mode); // see ERenderStyle native bool IsFrozen(); + native protected void UpdateSector(); // needs to be called if the thinker is set to a non-ticking statnum and the position is modified (or if Tick is overriden and doesn't call Super.Tick()) + native protected void UpdateSpriteInfo(); // needs to be called every time the texture is updated if the thinker uses SPF_LOCAL_ANIM and is set to a non-ticking statnum (or if Tick is overriden and doesn't call Super.Tick()) + static VisualThinker Spawn(Class type, TextureID tex, Vector3 pos, Vector3 vel, double alpha = 1.0, int flags = 0, double roll = 0.0, Vector2 scale = (1,1), Vector2 offset = (0,0), int style = STYLE_Normal, TranslationID trans = 0, int VisualThinkerFlags = 0) { @@ -49,6 +52,8 @@ Class VisualThinker : Thinker native p.Translation = trans; p.Flags = flags; p.VisualThinkerFlags = VisualThinkerFlags; + p.UpdateSector(); + p.UpdateSpriteInfo(); } return p; } From 925b62b8c579c33b3221906837fa243617ca032b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Lu=C3=ADs=20Vaz=20Silva?= Date: Tue, 12 Nov 2024 16:57:04 -0300 Subject: [PATCH 11/15] serialize animData, update subsector on deserialize --- src/common/engine/serializer.h | 3 ++- src/playsim/p_effect.cpp | 23 ++++++++++++++++++++--- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/common/engine/serializer.h b/src/common/engine/serializer.h index 40b6ab706..902d4226c 100644 --- a/src/common/engine/serializer.h +++ b/src/common/engine/serializer.h @@ -252,7 +252,8 @@ FSerializer &Serialize(FSerializer &arc, const char *key, struct ModelOverride & FSerializer &Serialize(FSerializer &arc, const char *key, struct AnimModelOverride &mo, struct AnimModelOverride *def); FSerializer &Serialize(FSerializer &arc, const char *key, ModelAnim &ao, ModelAnim *def); FSerializer &Serialize(FSerializer &arc, const char *key, ModelAnimFrame &ao, ModelAnimFrame *def); -FSerializer& Serialize(FSerializer& arc, const char* key, FTranslationID& value, FTranslationID* defval); +FSerializer &Serialize(FSerializer& arc, const char* key, FTranslationID& value, FTranslationID* defval); +FSerializer &Serialize(FSerializer& arc, const char* key, struct FStandaloneAnimation& value, struct FStandaloneAnimation* defval); void SerializeFunctionPointer(FSerializer &arc, const char *key, FunctionPointerValue *&p); diff --git a/src/playsim/p_effect.cpp b/src/playsim/p_effect.cpp index 5abf899eb..c48cafb85 100644 --- a/src/playsim/p_effect.cpp +++ b/src/playsim/p_effect.cpp @@ -1254,12 +1254,24 @@ float DVisualThinker::GetOffset(bool y) const // Needed for the renderer. return (float)((flags & VTF_FlipOffsetX) ? Offset.X : -Offset.X); } + +FSerializer& Serialize(FSerializer& arc, const char* key, FStandaloneAnimation& value, FStandaloneAnimation* defval) +{ + arc.BeginObject(key); + arc("SwitchTic", value.SwitchTic); + arc("AnimIndex", value.AnimIndex); + arc("CurFrame", value.CurFrame); + arc("Ok", value.ok); + arc("AnimType", value.AnimType); + arc.EndObject(); + return arc; +} + void DVisualThinker::Serialize(FSerializer& arc) { Super::Serialize(arc); - arc - ("pos", PT.Pos) + arc ("pos", PT.Pos) ("vel", PT.Vel) ("prev", Prev) ("scale", Scale) @@ -1273,9 +1285,14 @@ void DVisualThinker::Serialize(FSerializer& arc) ("cursector", cursector) ("scolor", PT.color) ("lightlevel", LightLevel) + ("animData", PT.animData) ("flags", PT.flags) ("visualThinkerFlags", flags); - + + if(arc.isReading()) + { + UpdateSector(); + } } IMPLEMENT_CLASS(DVisualThinker, false, false); From 6a067a76305dd4c5b7f90feab1b09289e414c299 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Lu=C3=ADs=20Vaz=20Silva?= Date: Tue, 12 Nov 2024 18:14:18 -0300 Subject: [PATCH 12/15] export UpdateSpriteInfo --- src/playsim/p_effect.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/playsim/p_effect.cpp b/src/playsim/p_effect.cpp index c48cafb85..f96ec1301 100644 --- a/src/playsim/p_effect.cpp +++ b/src/playsim/p_effect.cpp @@ -1090,6 +1090,19 @@ void DVisualThinker::UpdateSpriteInfo() } } +static void UpdateSpriteInfo(DVisualThinker * self) +{ + self->UpdateSpriteInfo(); +} + +DEFINE_ACTION_FUNCTION_NATIVE(DVisualThinker, UpdateSpriteInfo, UpdateSpriteInfo) +{ + PARAM_SELF_PROLOGUE(DVisualThinker); + self->UpdateSpriteInfo(); + return 0; +} + + // This runs just like Actor's, make sure to call Super.Tick() in ZScript. void DVisualThinker::Tick() { From ad40299da4faeca8e971e062b45764ae5bbfc9e6 Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Tue, 22 Oct 2024 18:22:43 -0400 Subject: [PATCH 13/15] - add sprite/frame support for VisualThinkers --- src/playsim/p_effect.cpp | 5 ++++- src/playsim/p_effect.h | 2 +- src/rendering/hwrenderer/scene/hw_sprites.cpp | 21 ++++++++++++++++--- wadsrc/static/zscript/visualthinker.zs | 3 +++ 4 files changed, 26 insertions(+), 5 deletions(-) diff --git a/src/playsim/p_effect.cpp b/src/playsim/p_effect.cpp index f96ec1301..c3bdaa6fc 100644 --- a/src/playsim/p_effect.cpp +++ b/src/playsim/p_effect.cpp @@ -1006,6 +1006,7 @@ void DVisualThinker::Construct() PT.subsector = nullptr; cursector = nullptr; PT.color = 0xffffff; + sprite = -1; AnimatedTexture.SetNull(); } @@ -1110,7 +1111,7 @@ void DVisualThinker::Tick() return; // There won't be a standard particle for this, it's only for graphics. - if (!PT.texture.isValid()) + if (!PT.texture.isValid() && (sprite == -1)) { Printf("No valid texture, destroyed"); Destroy(); @@ -1325,3 +1326,5 @@ DEFINE_FIELD(DVisualThinker, PrevRoll); DEFINE_FIELD(DVisualThinker, Translation); DEFINE_FIELD(DVisualThinker, LightLevel); DEFINE_FIELD(DVisualThinker, cursector); +DEFINE_FIELD(DVisualThinker, sprite); +DEFINE_FIELD(DVisualThinker, frame); diff --git a/src/playsim/p_effect.h b/src/playsim/p_effect.h index 1e5ba2705..d0a38f44c 100644 --- a/src/playsim/p_effect.h +++ b/src/playsim/p_effect.h @@ -147,4 +147,4 @@ struct SPortalHit void P_DrawRailTrail(AActor *source, TArray &portalhits, int color1, int color2, double maxdiff = 0, int flags = 0, PClassActor *spawnclass = NULL, DAngle angle = nullAngle, int duration = TICRATE, double sparsity = 1.0, double drift = 1.0, int SpiralOffset = 270, DAngle pitch = nullAngle); void P_DrawSplash (FLevelLocals *Level, int count, const DVector3 &pos, DAngle angle, int kind); void P_DrawSplash2 (FLevelLocals *Level, int count, const DVector3 &pos, DAngle angle, int updown, int kind); -void P_DisconnectEffect (AActor *actor); \ No newline at end of file +void P_DisconnectEffect (AActor *actor); diff --git a/src/rendering/hwrenderer/scene/hw_sprites.cpp b/src/rendering/hwrenderer/scene/hw_sprites.cpp index b7e1f20fe..326749c16 100644 --- a/src/rendering/hwrenderer/scene/hw_sprites.cpp +++ b/src/rendering/hwrenderer/scene/hw_sprites.cpp @@ -414,7 +414,7 @@ bool HWSprite::CalculateVertices(HWDrawInfo* di, FVector3* v, DVector3* vp) const bool drawBillboardFacingCamera = hw_force_cambbpref ? gl_billboard_faces_camera : gl_billboard_faces_camera || ((actor && (!(actor->renderflags2 & RF2_BILLBOARDNOFACECAMERA) && (actor->renderflags2 & RF2_BILLBOARDFACECAMERA))) - || (particle && particle->texture.isValid() && (!(particle->flags & SPF_NOFACECAMERA) && (particle->flags & SPF_FACECAMERA)))); + || ((!(particle->flags & SPF_NOFACECAMERA) && (particle->flags & SPF_FACECAMERA)))); // [Nash] has +ROLLSPRITE const bool drawRollSpriteActor = (actor != nullptr && actor->renderflags & RF_ROLLSPRITE); @@ -1409,8 +1409,10 @@ void HWSprite::ProcessParticle(HWDrawInfo *di, particle_t *particle, sector_t *s if (!particle || particle->alpha <= 0) return; - if (spr && spr->PT.texture.isNull()) + if (spr && spr->PT.texture.isNull() && (spr->sprite == -1)) + { return; + } lightlevel = hw_ClampLight(spr ? spr->GetLightLevel(sector) : sector->GetSpriteLight()); foglevel = (uint8_t)clamp(sector->lightlevel, 0, 255); @@ -1483,7 +1485,7 @@ void HWSprite::ProcessParticle(HWDrawInfo *di, particle_t *particle, sector_t *s } else { - bool has_texture = particle->texture.isValid(); + bool has_texture = particle->texture.isValid() || !!spr; bool custom_animated_texture = (particle->flags & SPF_LOCAL_ANIM) && particle->animData.ok; int particle_style = has_texture ? 2 : gl_particles_style; // Treat custom texture the same as smooth particles @@ -1505,6 +1507,19 @@ void HWSprite::ProcessParticle(HWDrawInfo *di, particle_t *particle, sector_t *s else if(has_texture) { lump = particle->texture; + if (spr && !lump.isValid()) + { + bool mirror = false; + DVector3 thingpos = (DVector3)spr->InterpolatedPosition(vp.TicFrac); + DAngle ang = (thingpos - vp.Pos).Angle(); + if (di->Viewpoint.IsOrtho()) ang = vp.Angles.Yaw; + + bool spriteflip = false; // !!(thing->renderflags & RF_SPRITEFLIP) + + int rot; + rot = -1; + lump = sprites[spr->sprite].GetSpriteFrame(spr->frame, rot, ang, &mirror, spriteflip); + } } else { diff --git a/wadsrc/static/zscript/visualthinker.zs b/wadsrc/static/zscript/visualthinker.zs index 45b32865c..46f9bb7d7 100644 --- a/wadsrc/static/zscript/visualthinker.zs +++ b/wadsrc/static/zscript/visualthinker.zs @@ -30,6 +30,9 @@ Class VisualThinker : Thinker native native void SetRenderStyle(int mode); // see ERenderStyle native bool IsFrozen(); + native SpriteID sprite; + native uint8 frame; + native protected void UpdateSector(); // needs to be called if the thinker is set to a non-ticking statnum and the position is modified (or if Tick is overriden and doesn't call Super.Tick()) native protected void UpdateSpriteInfo(); // needs to be called every time the texture is updated if the thinker uses SPF_LOCAL_ANIM and is set to a non-ticking statnum (or if Tick is overriden and doesn't call Super.Tick()) From a0c1f5b1b74f4aaf1f8e3259341745684b5fde1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Lu=C3=ADs=20Vaz=20Silva?= Date: Wed, 13 Nov 2024 17:02:50 -0300 Subject: [PATCH 14/15] fix compilation --- src/playsim/p_visualthinker.h | 2 ++ src/rendering/hwrenderer/scene/hw_sprites.cpp | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/playsim/p_visualthinker.h b/src/playsim/p_visualthinker.h index d4b1e262d..988119b2e 100644 --- a/src/playsim/p_visualthinker.h +++ b/src/playsim/p_visualthinker.h @@ -37,6 +37,8 @@ public: sector_t *cursector; int flags; + int sprite; // used to find patch_t and flip value + uint8_t frame; // sprite frame to draw // internal only variables particle_t PT; diff --git a/src/rendering/hwrenderer/scene/hw_sprites.cpp b/src/rendering/hwrenderer/scene/hw_sprites.cpp index 326749c16..7940affc1 100644 --- a/src/rendering/hwrenderer/scene/hw_sprites.cpp +++ b/src/rendering/hwrenderer/scene/hw_sprites.cpp @@ -414,7 +414,7 @@ bool HWSprite::CalculateVertices(HWDrawInfo* di, FVector3* v, DVector3* vp) const bool drawBillboardFacingCamera = hw_force_cambbpref ? gl_billboard_faces_camera : gl_billboard_faces_camera || ((actor && (!(actor->renderflags2 & RF2_BILLBOARDNOFACECAMERA) && (actor->renderflags2 & RF2_BILLBOARDFACECAMERA))) - || ((!(particle->flags & SPF_NOFACECAMERA) && (particle->flags & SPF_FACECAMERA)))); + || (particle && (!(particle->flags & SPF_NOFACECAMERA) && (particle->flags & SPF_FACECAMERA)))); // [Nash] has +ROLLSPRITE const bool drawRollSpriteActor = (actor != nullptr && actor->renderflags & RF_ROLLSPRITE); From ccd38afbcb403df4218cf1bf9992974317a542bb Mon Sep 17 00:00:00 2001 From: Rachael Alexanderson Date: Wed, 13 Nov 2024 16:16:36 -0500 Subject: [PATCH 15/15] - revert adding in the sprite/frame support for visual thinkers --- src/playsim/p_effect.cpp | 5 +---- src/playsim/p_effect.h | 2 +- src/playsim/p_visualthinker.h | 2 -- src/rendering/hwrenderer/scene/hw_sprites.cpp | 21 +++---------------- wadsrc/static/zscript/visualthinker.zs | 3 --- 5 files changed, 5 insertions(+), 28 deletions(-) diff --git a/src/playsim/p_effect.cpp b/src/playsim/p_effect.cpp index c3bdaa6fc..f96ec1301 100644 --- a/src/playsim/p_effect.cpp +++ b/src/playsim/p_effect.cpp @@ -1006,7 +1006,6 @@ void DVisualThinker::Construct() PT.subsector = nullptr; cursector = nullptr; PT.color = 0xffffff; - sprite = -1; AnimatedTexture.SetNull(); } @@ -1111,7 +1110,7 @@ void DVisualThinker::Tick() return; // There won't be a standard particle for this, it's only for graphics. - if (!PT.texture.isValid() && (sprite == -1)) + if (!PT.texture.isValid()) { Printf("No valid texture, destroyed"); Destroy(); @@ -1326,5 +1325,3 @@ DEFINE_FIELD(DVisualThinker, PrevRoll); DEFINE_FIELD(DVisualThinker, Translation); DEFINE_FIELD(DVisualThinker, LightLevel); DEFINE_FIELD(DVisualThinker, cursector); -DEFINE_FIELD(DVisualThinker, sprite); -DEFINE_FIELD(DVisualThinker, frame); diff --git a/src/playsim/p_effect.h b/src/playsim/p_effect.h index d0a38f44c..1e5ba2705 100644 --- a/src/playsim/p_effect.h +++ b/src/playsim/p_effect.h @@ -147,4 +147,4 @@ struct SPortalHit void P_DrawRailTrail(AActor *source, TArray &portalhits, int color1, int color2, double maxdiff = 0, int flags = 0, PClassActor *spawnclass = NULL, DAngle angle = nullAngle, int duration = TICRATE, double sparsity = 1.0, double drift = 1.0, int SpiralOffset = 270, DAngle pitch = nullAngle); void P_DrawSplash (FLevelLocals *Level, int count, const DVector3 &pos, DAngle angle, int kind); void P_DrawSplash2 (FLevelLocals *Level, int count, const DVector3 &pos, DAngle angle, int updown, int kind); -void P_DisconnectEffect (AActor *actor); +void P_DisconnectEffect (AActor *actor); \ No newline at end of file diff --git a/src/playsim/p_visualthinker.h b/src/playsim/p_visualthinker.h index 988119b2e..d4b1e262d 100644 --- a/src/playsim/p_visualthinker.h +++ b/src/playsim/p_visualthinker.h @@ -37,8 +37,6 @@ public: sector_t *cursector; int flags; - int sprite; // used to find patch_t and flip value - uint8_t frame; // sprite frame to draw // internal only variables particle_t PT; diff --git a/src/rendering/hwrenderer/scene/hw_sprites.cpp b/src/rendering/hwrenderer/scene/hw_sprites.cpp index 7940affc1..b7e1f20fe 100644 --- a/src/rendering/hwrenderer/scene/hw_sprites.cpp +++ b/src/rendering/hwrenderer/scene/hw_sprites.cpp @@ -414,7 +414,7 @@ bool HWSprite::CalculateVertices(HWDrawInfo* di, FVector3* v, DVector3* vp) const bool drawBillboardFacingCamera = hw_force_cambbpref ? gl_billboard_faces_camera : gl_billboard_faces_camera || ((actor && (!(actor->renderflags2 & RF2_BILLBOARDNOFACECAMERA) && (actor->renderflags2 & RF2_BILLBOARDFACECAMERA))) - || (particle && (!(particle->flags & SPF_NOFACECAMERA) && (particle->flags & SPF_FACECAMERA)))); + || (particle && particle->texture.isValid() && (!(particle->flags & SPF_NOFACECAMERA) && (particle->flags & SPF_FACECAMERA)))); // [Nash] has +ROLLSPRITE const bool drawRollSpriteActor = (actor != nullptr && actor->renderflags & RF_ROLLSPRITE); @@ -1409,10 +1409,8 @@ void HWSprite::ProcessParticle(HWDrawInfo *di, particle_t *particle, sector_t *s if (!particle || particle->alpha <= 0) return; - if (spr && spr->PT.texture.isNull() && (spr->sprite == -1)) - { + if (spr && spr->PT.texture.isNull()) return; - } lightlevel = hw_ClampLight(spr ? spr->GetLightLevel(sector) : sector->GetSpriteLight()); foglevel = (uint8_t)clamp(sector->lightlevel, 0, 255); @@ -1485,7 +1483,7 @@ void HWSprite::ProcessParticle(HWDrawInfo *di, particle_t *particle, sector_t *s } else { - bool has_texture = particle->texture.isValid() || !!spr; + bool has_texture = particle->texture.isValid(); bool custom_animated_texture = (particle->flags & SPF_LOCAL_ANIM) && particle->animData.ok; int particle_style = has_texture ? 2 : gl_particles_style; // Treat custom texture the same as smooth particles @@ -1507,19 +1505,6 @@ void HWSprite::ProcessParticle(HWDrawInfo *di, particle_t *particle, sector_t *s else if(has_texture) { lump = particle->texture; - if (spr && !lump.isValid()) - { - bool mirror = false; - DVector3 thingpos = (DVector3)spr->InterpolatedPosition(vp.TicFrac); - DAngle ang = (thingpos - vp.Pos).Angle(); - if (di->Viewpoint.IsOrtho()) ang = vp.Angles.Yaw; - - bool spriteflip = false; // !!(thing->renderflags & RF_SPRITEFLIP) - - int rot; - rot = -1; - lump = sprites[spr->sprite].GetSpriteFrame(spr->frame, rot, ang, &mirror, spriteflip); - } } else { diff --git a/wadsrc/static/zscript/visualthinker.zs b/wadsrc/static/zscript/visualthinker.zs index 46f9bb7d7..45b32865c 100644 --- a/wadsrc/static/zscript/visualthinker.zs +++ b/wadsrc/static/zscript/visualthinker.zs @@ -30,9 +30,6 @@ Class VisualThinker : Thinker native native void SetRenderStyle(int mode); // see ERenderStyle native bool IsFrozen(); - native SpriteID sprite; - native uint8 frame; - native protected void UpdateSector(); // needs to be called if the thinker is set to a non-ticking statnum and the position is modified (or if Tick is overriden and doesn't call Super.Tick()) native protected void UpdateSpriteInfo(); // needs to be called every time the texture is updated if the thinker uses SPF_LOCAL_ANIM and is set to a non-ticking statnum (or if Tick is overriden and doesn't call Super.Tick())