3131 */
3232package com .jme3 .effect ;
3333
34+ import java .io .IOException ;
35+
3436import com .jme3 .bounding .BoundingBox ;
3537import com .jme3 .effect .ParticleMesh .Type ;
3638import com .jme3 .effect .influencers .DefaultParticleInfluencer ;
5658import com .jme3 .util .TempVars ;
5759import com .jme3 .util .clone .Cloner ;
5860import com .jme3 .util .clone .JmeCloneable ;
59- import java .io .IOException ;
6061
6162/**
6263 * <code>ParticleEmitter</code> is a special kind of geometry which simulates
@@ -909,6 +910,7 @@ private Particle emitParticle(Vector3f min, Vector3f max) {
909910 p .size = startSize ;
910911 //shape.getRandomPoint(p.position);
911912 particleInfluencer .influenceParticle (p , shape );
913+
912914 if (worldSpace ) {
913915 worldTransform .transformVector (p .position , p .position );
914916 worldTransform .getRotation ().mult (p .velocity , p .velocity );
@@ -921,10 +923,8 @@ private Particle emitParticle(Vector3f min, Vector3f max) {
921923 p .rotateSpeed = rotateSpeed * (0.2f + (FastMath .nextRandomFloat () * 2f - 1f ) * .8f );
922924 }
923925
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 );
928928
929929 ++lastUsed ;
930930 firstUnUsed = idx + 1 ;
@@ -1038,15 +1038,19 @@ protected void updateParticle(Particle p, float tpf, Vector3f min, Vector3f max)
10381038 p .angle += p .rotateSpeed * tpf ;
10391039
10401040 // 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 );
10451042
10461043 if (!selectRandomImage ) {
10471044 p .imageIndex = (int ) (b * imagesX * imagesY );
10481045 }
10491046 }
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+ }
10501054
10511055 private void updateParticleState (float tpf ) {
10521056 // Force world transform to update
@@ -1180,16 +1184,14 @@ private void renderFromControl(RenderManager rm, ViewPort vp) {
11801184 this .getMaterial ().setFloat ("Quadratic" , C );
11811185 }
11821186
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 );
11911187 if (!worldSpace ) {
1188+ TempVars vars = TempVars .get ();
1189+ Matrix3f inverseRotation = this .getWorldRotation ().toRotationMatrix (vars .tempMat3 ).invertLocal ();
1190+ particleMesh .updateParticleData (particles , cam , inverseRotation );
11921191 vars .release ();
1192+
1193+ } else {
1194+ particleMesh .updateParticleData (particles , cam , Matrix3f .IDENTITY );
11931195 }
11941196 }
11951197
0 commit comments