From 729013311d0829fc5f3b7876a835b11407b6e48b Mon Sep 17 00:00:00 2001 From: Robert Beckebans Date: Mon, 13 May 2024 23:11:02 +0200 Subject: [PATCH] Killed remnants of renderLight precalculated shadowvolume models --- neo/d3xp/Light.cpp | 33 ++----------------------------- neo/d3xp/Light.h | 4 ++++ neo/d3xp/gamesys/SaveGame.cpp | 4 ---- neo/idlib/MapFile.cpp | 3 ++- neo/renderer/RenderWorld.cpp | 7 +------ neo/renderer/RenderWorld.h | 5 ----- neo/renderer/RenderWorld_defs.cpp | 2 ++ 7 files changed, 11 insertions(+), 47 deletions(-) diff --git a/neo/d3xp/Light.cpp b/neo/d3xp/Light.cpp index cd864a0b..1ccd1202 100644 --- a/neo/d3xp/Light.cpp +++ b/neo/d3xp/Light.cpp @@ -290,7 +290,8 @@ void idLight::Save( idSaveGame* savefile ) const { savefile->WriteRenderLight( renderLight ); - savefile->WriteBool( renderLight.prelightModel != NULL ); + // RB keep it for savegame compatibility but we have no support for dmap generated shadow models + savefile->WriteBool( false ); savefile->WriteVec3( localLightOrigin ); savefile->WriteMat3( localLightAxis ); @@ -326,21 +327,6 @@ void idLight::Restore( idRestoreGame* savefile ) savefile->ReadRenderLight( renderLight ); savefile->ReadBool( hadPrelightModel ); - renderLight.prelightModel = renderModelManager->CheckModel( va( "_prelight_%s", name.c_str() ) ); - if( ( renderLight.prelightModel == NULL ) && hadPrelightModel ) - { - assert( 0 ); - if( developer.GetBool() ) - { - // we really want to know if this happens - gameLocal.Error( "idLight::Restore: prelightModel '_prelight_%s' not found", name.c_str() ); - } - else - { - // but let it slide after release - gameLocal.Warning( "idLight::Restore: prelightModel '_prelight_%s' not found", name.c_str() ); - } - } savefile->ReadVec3( localLightOrigin ); savefile->ReadMat3( localLightAxis ); @@ -415,17 +401,6 @@ void idLight::Spawn() lightDefHandle = -1; // no static version yet - // see if an optimized shadow volume exists - // the renderer will ignore this value after a light has been moved, - // but there may still be a chance to get it wrong if the game moves - // a light before the first present, and doesn't clear the prelight - renderLight.prelightModel = 0; - if( name[ 0 ] ) - { - // this will return 0 if not found - renderLight.prelightModel = renderModelManager->CheckModel( va( "_prelight_%s", name.c_str() ) ); - } - spawnArgs.GetBool( "start_off", "0", start_off ); if( start_off ) { @@ -803,7 +778,6 @@ void idLight::BecomeBroken( idEntity* activator ) if( common->IsServer() ) { - ServerSendEvent( EVENT_BECOMEBROKEN, NULL, true ); if( spawnArgs.GetString( "def_damage", "", &damageDefName ) ) @@ -811,7 +785,6 @@ void idLight::BecomeBroken( idEntity* activator ) idVec3 origin = renderEntity.origin + renderEntity.bounds.GetCenter() * renderEntity.axis; gameLocal.RadiusDamage( origin, activator, activator, this, this, damageDefName ); } - } ActivateTargets( activator ); @@ -871,7 +844,6 @@ idLight::PresentModelDefChange */ void idLight::PresentModelDefChange() { - if( !renderEntity.hModel || IsHidden() ) { return; @@ -1366,7 +1338,6 @@ idLight::WriteToSnapshot */ void idLight::WriteToSnapshot( idBitMsg& msg ) const { - GetPhysics()->WriteToSnapshot( msg ); WriteBindToSnapshot( msg ); diff --git a/neo/d3xp/Light.h b/neo/d3xp/Light.h index bfb5259a..5bd0f457 100644 --- a/neo/d3xp/Light.h +++ b/neo/d3xp/Light.h @@ -71,6 +71,7 @@ ID_INLINE void rvmLightStyleState_t::Reset() // jmarshall end +//class idStaticEntity; class idLight : public idEntity { @@ -174,6 +175,9 @@ private: int fadeEnd; bool soundWasPlaying; + // RB: pointing to static model because this light entity was split into 2 entities by convertMapToValve220 + //idEntityPtr staticModel; + private: void PresentLightDefChange(); void PresentModelDefChange(); diff --git a/neo/d3xp/gamesys/SaveGame.cpp b/neo/d3xp/gamesys/SaveGame.cpp index 9590e54a..d651ccf6 100644 --- a/neo/d3xp/gamesys/SaveGame.cpp +++ b/neo/d3xp/gamesys/SaveGame.cpp @@ -1627,10 +1627,6 @@ void idRestoreGame::ReadRenderLight( renderLight_t& renderLight ) ReadVec3( renderLight.start ); ReadVec3( renderLight.end ); - // only idLight has a prelightModel and it's always based on the entityname, so we'll restore it there - // ReadModel( renderLight.prelightModel ); - renderLight.prelightModel = NULL; - ReadInt( renderLight.lightId ); ReadMaterial( renderLight.shader ); diff --git a/neo/idlib/MapFile.cpp b/neo/idlib/MapFile.cpp index 352b2aab..7dbf1fa6 100644 --- a/neo/idlib/MapFile.cpp +++ b/neo/idlib/MapFile.cpp @@ -3157,7 +3157,6 @@ bool idMapFile::ConvertToValve220Format() lightEnt->epairs.Delete( "light_rotation" ); lightEnt->epairs.Delete( "light_angles" ); - lightEnt->epairs.Delete( "angles" ); lightEnt->epairs.Delete( "angle" ); lightEnt->epairs.Delete( "model" ); @@ -3177,6 +3176,8 @@ bool idMapFile::ConvertToValve220Format() ent->epairs.Set( "name", uniqueName ); ent->epairs.Set( "model", uniqueName ); + + // TODO replace this with other key that links idLight to func_static entity for syncing color/broken model lightEnt->epairs.Set( "model", uniqueName ); ent->epairs.SetInt( "_tb_group", tbGroupID ); diff --git a/neo/renderer/RenderWorld.cpp b/neo/renderer/RenderWorld.cpp index 30844ce7..ced55332 100644 --- a/neo/renderer/RenderWorld.cpp +++ b/neo/renderer/RenderWorld.cpp @@ -497,7 +497,7 @@ void idRenderWorldLocal::UpdateLightDef( qhandle_t lightHandle, const renderLigh rlight->parallel == light->parms.parallel && rlight->pointLight == light->parms.pointLight && rlight->right == light->parms.right && rlight->start == light->parms.start && rlight->target == light->parms.target && rlight->up == light->parms.up && - rlight->shader == light->lightShader && rlight->prelightModel == light->parms.prelightModel ) + rlight->shader == light->lightShader ) { justUpdate = true; } @@ -528,11 +528,6 @@ void idRenderWorldLocal::UpdateLightDef( qhandle_t lightHandle, const renderLigh light->parms.noShadows = true; } - if( light->lightHasMoved ) - { - light->parms.prelightModel = NULL; - } - if( !justUpdate ) { R_CreateLightRefs( light ); diff --git a/neo/renderer/RenderWorld.h b/neo/renderer/RenderWorld.h index 4ee0966a..8c3ca01c 100644 --- a/neo/renderer/RenderWorld.h +++ b/neo/renderer/RenderWorld.h @@ -203,11 +203,6 @@ typedef struct renderLight_s idVec3 start; idVec3 end; - // Dmap will generate an optimized shadow volume named _prelight_ - // for the light against all the _area* models in the map. The renderer will - // ignore this value if the light has been moved after initial creation - idRenderModel* prelightModel; - // muzzle flash lights will not cast shadows from player and weapon world models int lightId; diff --git a/neo/renderer/RenderWorld_defs.cpp b/neo/renderer/RenderWorld_defs.cpp index 477b3322..f0841989 100644 --- a/neo/renderer/RenderWorld_defs.cpp +++ b/neo/renderer/RenderWorld_defs.cpp @@ -713,11 +713,13 @@ void R_CreateLightRefs( idRenderLightLocal* light ) // we can limit the area references to those visible through the portals from the light center. // We can't do this in the normal case, because shadows are cast from back facing triangles, which // may be in areas not directly visible to the light projection center. + /* if( light->parms.prelightModel != NULL && r_useLightPortalFlow.GetBool() && light->lightShader->LightCastsShadows() ) { light->world->FlowLightThroughPortals( light ); } else + */ { // push the light frustum down the BSP tree into areas light->world->PushFrustumIntoTree( NULL, light, light->inverseBaseLightProject, bounds_zeroOneCube );