Don't compute the world matrix multiple times

This commit is contained in:
scrawl 2016-02-22 18:58:19 +01:00
parent 055d35a2b0
commit 8bd16e4d5a
8 changed files with 30 additions and 30 deletions

View file

@ -261,10 +261,10 @@ void Emitter::emitParticles(double dt)
osg::Matrix worldToPs;
// maybe this could be optimized by halting at the lowest common ancestor of the particle and emitter nodes
osg::MatrixList worldMats = getParticleSystem()->getWorldMatrices();
if (!worldMats.empty())
osg::NodePathList partsysNodePaths = getParticleSystem()->getParentalNodePaths();
if (partsysNodePaths.size())
{
const osg::Matrix psToWorld = worldMats[0];
osg::Matrix psToWorld = osg::computeLocalToWorld(partsysNodePaths[0]);
worldToPs = osg::Matrix::inverse(psToWorld);
}

View file

@ -69,10 +69,10 @@ namespace
void transformInitialParticles(osgParticle::ParticleSystem* partsys, osg::Node* node)
{
osg::MatrixList mats = node->getWorldMatrices();
if (mats.empty())
osg::NodePathList nodepaths = node->getParentalNodePaths();
if (nodepaths.empty())
return;
osg::Matrixf worldMat = mats[0];
osg::Matrixf worldMat = osg::computeLocalToWorld(nodepaths[0]);
worldMat.orthoNormalize(worldMat); // scale is already applied on the particle node
for (int i=0; i<partsys->numParticles(); ++i)
{