31
31
*/
32
32
package com .jme3 .effect ;
33
33
34
+ import java .io .IOException ;
35
+
34
36
import com .jme3 .bounding .BoundingBox ;
35
37
import com .jme3 .effect .ParticleMesh .Type ;
36
38
import com .jme3 .effect .influencers .DefaultParticleInfluencer ;
56
58
import com .jme3 .util .TempVars ;
57
59
import com .jme3 .util .clone .Cloner ;
58
60
import com .jme3 .util .clone .JmeCloneable ;
59
- import java .io .IOException ;
60
61
61
62
/**
62
63
* <code>ParticleEmitter</code> is a special kind of geometry which simulates
@@ -909,6 +910,7 @@ private Particle emitParticle(Vector3f min, Vector3f max) {
909
910
p .size = startSize ;
910
911
//shape.getRandomPoint(p.position);
911
912
particleInfluencer .influenceParticle (p , shape );
913
+
912
914
if (worldSpace ) {
913
915
worldTransform .transformVector (p .position , p .position );
914
916
worldTransform .getRotation ().mult (p .velocity , p .velocity );
@@ -921,10 +923,8 @@ private Particle emitParticle(Vector3f min, Vector3f max) {
921
923
p .rotateSpeed = rotateSpeed * (0.2f + (FastMath .nextRandomFloat () * 2f - 1f ) * .8f );
922
924
}
923
925
924
- temp .set (p .position ).addLocal (p .size , p .size , p .size );
925
- max .maxLocal (temp );
926
- temp .set (p .position ).subtractLocal (p .size , p .size , p .size );
927
- min .minLocal (temp );
926
+ // Computing bounding volume
927
+ computeBoundingVolume (p , min , max );
928
928
929
929
++lastUsed ;
930
930
firstUnUsed = idx + 1 ;
@@ -1038,15 +1038,19 @@ protected void updateParticle(Particle p, float tpf, Vector3f min, Vector3f max)
1038
1038
p .angle += p .rotateSpeed * tpf ;
1039
1039
1040
1040
// Computing bounding volume
1041
- temp .set (p .position ).addLocal (p .size , p .size , p .size );
1042
- max .maxLocal (temp );
1043
- temp .set (p .position ).subtractLocal (p .size , p .size , p .size );
1044
- min .minLocal (temp );
1041
+ computeBoundingVolume (p , min , max );
1045
1042
1046
1043
if (!selectRandomImage ) {
1047
1044
p .imageIndex = (int ) (b * imagesX * imagesY );
1048
1045
}
1049
1046
}
1047
+
1048
+ private void computeBoundingVolume (Particle p , Vector3f min , Vector3f max ) {
1049
+ temp .set (p .position ).addLocal (p .size , p .size , p .size );
1050
+ max .maxLocal (temp );
1051
+ temp .set (p .position ).subtractLocal (p .size , p .size , p .size );
1052
+ min .minLocal (temp );
1053
+ }
1050
1054
1051
1055
private void updateParticleState (float tpf ) {
1052
1056
// Force world transform to update
@@ -1180,16 +1184,14 @@ private void renderFromControl(RenderManager rm, ViewPort vp) {
1180
1184
this .getMaterial ().setFloat ("Quadratic" , C );
1181
1185
}
1182
1186
1183
- Matrix3f inverseRotation = Matrix3f .IDENTITY ;
1184
- TempVars vars = null ;
1185
- if (!worldSpace ) {
1186
- vars = TempVars .get ();
1187
-
1188
- inverseRotation = this .getWorldRotation ().toRotationMatrix (vars .tempMat3 ).invertLocal ();
1189
- }
1190
- particleMesh .updateParticleData (particles , cam , inverseRotation );
1191
1187
if (!worldSpace ) {
1188
+ TempVars vars = TempVars .get ();
1189
+ Matrix3f inverseRotation = this .getWorldRotation ().toRotationMatrix (vars .tempMat3 ).invertLocal ();
1190
+ particleMesh .updateParticleData (particles , cam , inverseRotation );
1192
1191
vars .release ();
1192
+
1193
+ } else {
1194
+ particleMesh .updateParticleData (particles , cam , Matrix3f .IDENTITY );
1193
1195
}
1194
1196
}
1195
1197
0 commit comments