Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 19 additions & 17 deletions jme3-core/src/main/java/com/jme3/effect/ParticleEmitter.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
*/
package com.jme3.effect;

import java.io.IOException;

import com.jme3.bounding.BoundingBox;
import com.jme3.effect.ParticleMesh.Type;
import com.jme3.effect.influencers.DefaultParticleInfluencer;
Expand All @@ -56,7 +58,6 @@
import com.jme3.util.TempVars;
import com.jme3.util.clone.Cloner;
import com.jme3.util.clone.JmeCloneable;
import java.io.IOException;

/**
* <code>ParticleEmitter</code> is a special kind of geometry which simulates
Expand Down Expand Up @@ -909,6 +910,7 @@ private Particle emitParticle(Vector3f min, Vector3f max) {
p.size = startSize;
//shape.getRandomPoint(p.position);
particleInfluencer.influenceParticle(p, shape);

if (worldSpace) {
worldTransform.transformVector(p.position, p.position);
worldTransform.getRotation().mult(p.velocity, p.velocity);
Expand All @@ -921,10 +923,8 @@ private Particle emitParticle(Vector3f min, Vector3f max) {
p.rotateSpeed = rotateSpeed * (0.2f + (FastMath.nextRandomFloat() * 2f - 1f) * .8f);
}

temp.set(p.position).addLocal(p.size, p.size, p.size);
max.maxLocal(temp);
temp.set(p.position).subtractLocal(p.size, p.size, p.size);
min.minLocal(temp);
// Computing bounding volume
computeBoundingVolume(p, min, max);

++lastUsed;
firstUnUsed = idx + 1;
Expand Down Expand Up @@ -1038,15 +1038,19 @@ protected void updateParticle(Particle p, float tpf, Vector3f min, Vector3f max)
p.angle += p.rotateSpeed * tpf;

// Computing bounding volume
temp.set(p.position).addLocal(p.size, p.size, p.size);
max.maxLocal(temp);
temp.set(p.position).subtractLocal(p.size, p.size, p.size);
min.minLocal(temp);
computeBoundingVolume(p, min, max);

if (!selectRandomImage) {
p.imageIndex = (int) (b * imagesX * imagesY);
}
}

private void computeBoundingVolume(Particle p, Vector3f min, Vector3f max) {
temp.set(p.position).addLocal(p.size, p.size, p.size);
max.maxLocal(temp);
temp.set(p.position).subtractLocal(p.size, p.size, p.size);
min.minLocal(temp);
}

private void updateParticleState(float tpf) {
// Force world transform to update
Expand Down Expand Up @@ -1180,16 +1184,14 @@ private void renderFromControl(RenderManager rm, ViewPort vp) {
this.getMaterial().setFloat("Quadratic", C);
}

Matrix3f inverseRotation = Matrix3f.IDENTITY;
TempVars vars = null;
if (!worldSpace) {
vars = TempVars.get();

inverseRotation = this.getWorldRotation().toRotationMatrix(vars.tempMat3).invertLocal();
}
particleMesh.updateParticleData(particles, cam, inverseRotation);
if (!worldSpace) {
TempVars vars = TempVars.get();
Matrix3f inverseRotation = this.getWorldRotation().toRotationMatrix(vars.tempMat3).invertLocal();
particleMesh.updateParticleData(particles, cam, inverseRotation);
vars.release();

} else {
particleMesh.updateParticleData(particles, cam, Matrix3f.IDENTITY);
}
}

Expand Down