summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/render/jobs/updateboundingvolumejob.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/render/jobs/updateboundingvolumejob.cpp b/src/render/jobs/updateboundingvolumejob.cpp
index b31b7e85f..1a46ee2bc 100644
--- a/src/render/jobs/updateboundingvolumejob.cpp
+++ b/src/render/jobs/updateboundingvolumejob.cpp
@@ -56,13 +56,12 @@ void expandWorldBoundingVolume(Qt3DRender::Render::Entity *node)
Q_FOREACH (Entity *c, node->children())
expandWorldBoundingVolume(c);
- // Then traverse to root
+ // Then traverse back from leaf to root
// Initialize parent bounding volume to be equal to that of the first child
- Qt3DRender::Render::Entity *parentNode = node->parent();
- if (parentNode) {
- Qt3DRender::Render::Sphere *parentBoundingVolume = parentNode->worldBoundingVolumeWithChildren();
- Qt3DRender::Render::Sphere *nodeBoundingVolume = node->worldBoundingVolumeWithChildren();
- parentBoundingVolume->expandToContain(*nodeBoundingVolume);
+ if (node->hasChildren()) {
+ Qt3DRender::Render::Sphere *parentBoundingVolume = node->worldBoundingVolumeWithChildren();
+ Q_FOREACH (Entity *c, node->children())
+ parentBoundingVolume->expandToContain(*c->worldBoundingVolumeWithChildren());
}
}