Optimize dirty shadow bounds update for particles and foliage

This commit is contained in:
2026-07-13 17:38:59 +02:00
parent b80dc2dee8
commit 4c0a2e26cd
3 changed files with 13 additions and 4 deletions
+1 -1
View File
@@ -909,7 +909,7 @@ void Foliage::RebuildClusters()
_box = BoundingBox(_transform.Translation, _transform.Translation);
_sphere = BoundingSphere(_transform.Translation, 0.0f);
if (_sceneRenderingKey != -1)
GetSceneRendering()->UpdateActor(this, _sceneRenderingKey);
GetSceneRendering()->UpdateActor(this, _sceneRenderingKey, ISceneRenderingListener::Bounds);
return;
}
+1 -1
View File
@@ -372,7 +372,7 @@ void ParticleEffect::UpdateBounds()
_box = bounds;
BoundingSphere::FromBox(bounds, _sphere);
if (_sceneRenderingKey != -1)
GetSceneRendering()->UpdateActor(this, _sceneRenderingKey);
GetSceneRendering()->UpdateActor(this, _sceneRenderingKey, ISceneRenderingListener::Bounds);
}
void ParticleEffect::Sync()
+11 -2
View File
@@ -404,8 +404,17 @@ public:
// Dirty static objects to redraw when changed (eg. material modification)
if (a->HasStaticFlag(StaticFlags::Shadow))
{
DirtyStaticBounds(prevBounds);
DirtyStaticBounds(a->GetSphere());
// TODO: skip actors that don't cast shadows (eg. particles)
BoundingSphere bounds = a->GetSphere();
if (bounds != prevBounds)
{
// Avoid dirtying twice when bounds are close to each other
if (BoundingSphere::NearEqual(bounds, prevBounds, METERS_TO_UNITS_SCALE))
BoundingSphere::Merge(bounds, prevBounds, bounds);
else
DirtyStaticBounds(prevBounds);
}
DirtyStaticBounds(bounds);
}
else if (flags & StaticFlags)
{