From 0b77ae43a4ca39e42f8244374e47b11554c4a185 Mon Sep 17 00:00:00 2001 From: scrawl Date: Thu, 9 Apr 2015 16:51:57 +0200 Subject: [PATCH] Minor optimization for particle emitters --- components/nifosg/particle.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/components/nifosg/particle.cpp b/components/nifosg/particle.cpp index c4bf69579..59a4a981b 100644 --- a/components/nifosg/particle.cpp +++ b/components/nifosg/particle.cpp @@ -238,7 +238,12 @@ void Emitter::setCounter(osgParticle::Counter *counter) void Emitter::emitParticles(double dt) { + int n = mCounter->numParticlesToCreate(dt); + if (n == 0) + return; + 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()) @@ -271,8 +276,6 @@ void Emitter::emitParticles(double dt) emitterToPs.orthoNormalize(emitterToPs); - int n = mCounter->numParticlesToCreate(dt); - for (int i=0; icreateParticle(0);