Bläddra i källkod

Minor optimization to ParticleEmitter.cpp -- update() and draw() will back out if the emitter is not active.

Adam Blake 14 år sedan
förälder
incheckning
10c1529322
2 ändrade filer med 13 tillägg och 2 borttagningar
  1. 0 2
      gameplay.sln
  2. 13 0
      gameplay/src/ParticleEmitter.cpp

+ 0 - 2
gameplay.sln

@@ -25,8 +25,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sample03-character", "gamep
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gameplay-encoder", "gameplay-encoder\gameplay-encoder.vcxproj", "{9D69B743-4872-4DD1-8E30-0087C64298D7}"
 EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{D3CA8AE2-3ED6-458B-963A-EDA671E6F51C}"
-EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Win32 = Debug|Win32

+ 13 - 0
gameplay/src/ParticleEmitter.cpp

@@ -240,6 +240,9 @@ bool ParticleEmitter::isActive() const
     if (_started)
         return true;
 
+    if (!_node)
+        return false;
+
     bool active = false;
     for (unsigned int i = 0; i < _particleCount; i++)
     {
@@ -760,6 +763,11 @@ ParticleEmitter::TextureBlending ParticleEmitter::getTextureBlendingFromString(c
 
 void ParticleEmitter::update(long elapsedTime)
 {
+    if (!isActive())
+    {
+        return;
+    }
+
     // Calculate the time passed since last update.
     float elapsedSecs = (float)elapsedTime / 1000.0f;
 
@@ -866,6 +874,11 @@ void ParticleEmitter::update(long elapsedTime)
 
 void ParticleEmitter::draw()
 {
+    if (!isActive())
+    {
+        return;
+    }
+
     if (_particleCount > 0)
     {
         // Set our node's view projection matrix to this emitter's effect.