Define the shadow casting style on an Actor using a property. Currently only for lightmaps.

This commit is contained in:
nashmuhandes 2025-06-13 02:27:19 +08:00 committed by Nash Muhandes
commit a39c84a77a
5 changed files with 29 additions and 7 deletions

View file

@ -87,6 +87,14 @@ struct sun_trace_cache_t
bool SunResult = false;
};
enum FShadowCastingTypes
{
SHADOWCASTING_None = 0,
SHADOWCASTING_Lightmap,
// Not yet implemented.
//SHADOWCASTING_Dynamic
};
extern thread_local FDynLightData lightdata;

View file

@ -875,6 +875,7 @@ xx(lm_suncolor)
xx(lm_sunintensity)
xx(lm_bounce)
xx(lm_ao)
xx(ShadowCastingType)
// Light keywords
xx(light_softshadowradius)

View file

@ -295,16 +295,19 @@ DoomLevelMesh::DoomLevelMesh(FLevelLocals& doomMap)
// Collect all the models we want to bake into the level mesh
if (lm_models)
{
TThinkerIterator<AActor> it(&doomMap, PClass::FindClass("StaticMapModel"), STAT_STATIC, true);
TThinkerIterator<AActor> it(&doomMap, PClass::FindClass("Actor"), STAT_STATIC, true);
AActor* thing;
while ((thing = it.Next()) != nullptr)
{
bool isPicnumOverride = thing->picnum.isValid();
int spritenum = thing->sprite;
FSpriteModelFrame* modelframe = isPicnumOverride ? nullptr : FindModelFrame(thing, spritenum, thing->frame, !!(thing->flags & MF_DROPPED));
if (modelframe && modelframe->modelIDs.size() != 0)
if (thing->IntVar(NAME_ShadowCastingType) == SHADOWCASTING_Lightmap)
{
CreateModelSurfaces(thing, modelframe);
bool isPicnumOverride = thing->picnum.isValid();
int spritenum = thing->sprite;
FSpriteModelFrame* modelframe = isPicnumOverride ? nullptr : FindModelFrame(thing, spritenum, thing->frame, !!(thing->flags & MF_DROPPED));
if (modelframe && modelframe->modelIDs.size() != 0)
{
CreateModelSurfaces(thing, modelframe);
}
}
}
}

View file

@ -286,6 +286,9 @@ class Actor : Thinker native
meta double FastSpeed; // speed in fast mode
meta Sound PushSound; // Sound being played when pushed by something
// VKDoom
meta readonly int ShadowCastingType;
// todo: implement access to native meta properties.
// native meta int infighting_group;
// native meta int projectile_group;
@ -372,6 +375,7 @@ class Actor : Thinker native
property ShadowPenaltyFactor: ShadowPenaltyFactor;
property AutomapOffsets : AutomapOffsets;
property LandingSpeed: LandingSpeed;
property ShadowCastingType: ShadowCastingType;
// need some definition work first
//FRenderStyle RenderStyle;

View file

@ -988,4 +988,10 @@ struct Lightmap
native static void SetSunIntensity(double intensity);
};
class StaticMapModel : Actor {}
enum FShadowCastingTypes
{
SHADOWCASTING_None = 0,
SHADOWCASTING_Lightmap,
// Not yet implemented.
//SHADOWCASTING_Dynamic
}