Skip to content

Commit 8cc3086

Browse files
authored
Merge pull request #2506 from capdevon/capdevon-NewtonianParticleInfluencer
Refactor: NewtonianParticleInfluencer reduce object allocations
2 parents 7ead28e + e55807f commit 8cc3086

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

jme3-core/src/main/java/com/jme3/effect/influencers/NewtonianParticleInfluencer.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ public class NewtonianParticleInfluencer extends DefaultParticleInfluencer {
5454
/** Emitters tangent rotation factor. */
5555
protected float surfaceTangentRotation;
5656

57+
protected Matrix3f tempMat3 = new Matrix3f();
58+
5759
/**
5860
* Constructor. Sets velocity variation to 0.0f.
5961
*/
@@ -71,9 +73,8 @@ public void influenceParticle(Particle particle, EmitterShape emitterShape) {
7173
// calculating surface tangent (velocity contains the 'normal' value)
7274
temp.set(particle.velocity.z * surfaceTangentFactor, particle.velocity.y * surfaceTangentFactor, -particle.velocity.x * surfaceTangentFactor);
7375
if (surfaceTangentRotation != 0.0f) {// rotating the tangent
74-
Matrix3f m = new Matrix3f();
75-
m.fromAngleNormalAxis(FastMath.PI * surfaceTangentRotation, particle.velocity);
76-
temp = m.multLocal(temp);
76+
tempMat3.fromAngleNormalAxis(FastMath.PI * surfaceTangentRotation, particle.velocity);
77+
temp = tempMat3.multLocal(temp);
7778
}
7879
// applying normal factor (this must be done first)
7980
particle.velocity.multLocal(normalVelocity);

0 commit comments

Comments
 (0)