Skip to content

Commit 508714d

Browse files
authored
Merge pull request #66 from Csantucci/thread-safe-particleemitter
Solve ParticleEmitter.cs thread safety issue.
2 parents 35e188c + 05b9be2 commit 508714d

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Source/RunActivity/Viewer3D/ParticleEmitter.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,9 @@ public override void Draw(GraphicsDevice graphicsDevice)
436436
if (FirstActiveParticle < FirstFreeParticle)
437437
{
438438
var numParticles = FirstFreeParticle - FirstActiveParticle;
439-
graphicsDevice.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, FirstActiveParticle * VerticiesPerParticle, numParticles * VerticiesPerParticle, FirstActiveParticle * IndiciesPerParticle, numParticles * PrimitivesPerParticle);
439+
// thread safe clause
440+
if (numParticles > 0)
441+
graphicsDevice.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, FirstActiveParticle * VerticiesPerParticle, numParticles * VerticiesPerParticle, FirstActiveParticle * IndiciesPerParticle, numParticles * PrimitivesPerParticle);
440442
}
441443
else
442444
{

0 commit comments

Comments
 (0)