From 8d6620b0745991a46d73077de171e9a4b51b021e Mon Sep 17 00:00:00 2001 From: scrawl Date: Thu, 11 Jun 2015 02:37:49 +0200 Subject: [PATCH] Assign an initial bounding box to particle systems --- components/nifosg/nifloader.cpp | 4 ++++ components/resource/scenemanager.cpp | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/components/nifosg/nifloader.cpp b/components/nifosg/nifloader.cpp index 2c409ac96..b95eeebfc 100644 --- a/components/nifosg/nifloader.cpp +++ b/components/nifosg/nifloader.cpp @@ -749,6 +749,10 @@ namespace NifOsg created->setSizeRange(osgParticle::rangef(size, size)); } + + osg::BoundingBox box; + box.expandBy(osg::BoundingSphere(osg::Vec3(0,0,0), particledata->radius)); + partsys->setInitialBound(box); } static osg::ref_ptr handleParticleEmitter(const Nif::NiParticleSystemController* partctrl) diff --git a/components/resource/scenemanager.cpp b/components/resource/scenemanager.cpp index 8de08bd9d..bb4c57e4c 100644 --- a/components/resource/scenemanager.cpp +++ b/components/resource/scenemanager.cpp @@ -14,6 +14,7 @@ #include #include +#include namespace { @@ -61,6 +62,13 @@ namespace { partsys->getParticle(i)->transformPositionVelocity(worldMat); } + + // transform initial bounds to worldspace + osg::BoundingSphere sphere(partsys->getInitialBound()); + SceneUtil::transformBoundingSphere(worldMat, sphere); + osg::BoundingBox box; + box.expandBy(sphere); + partsys->setInitialBound(box); } };