Skip to content

Commit f2ea556

Browse files
cagueroiche033
authored andcommitted
Do not pre-render each visual's children twice per frame (#1309)
Assisted-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: Carlos Aguero <caguero@honurobotics.com> (cherry picked from commit d1b6cba)
1 parent af28689 commit f2ea556

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

include/gz/rendering/base/BaseVisual.hh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,8 +311,13 @@ namespace gz
311311
template <class T>
312312
void BaseVisual<T>::PreRender()
313313
{
314+
// T::PreRender() resolves to BaseNode<T>::PreRender(), which already
315+
// recurses into this visual's children through the virtual
316+
// PreRenderChildren(). Calling PreRenderChildren() a second time here
317+
// would pre-render every child twice, compounding to O(2^depth)
318+
// redundant visits down the scene graph. Children are therefore
319+
// pre-rendered exactly once, via T::PreRender().
314320
T::PreRender();
315-
this->PreRenderChildren();
316321
this->PreRenderGeometries();
317322
}
318323

0 commit comments

Comments
 (0)