DefaultParticleInfluencer / NewtonianParticleInfluencer : Fixed initialVelocity attribute naming that was kept as startVelocity while acessors where get/setInitialVelocity.

- Also changed serialization to reflect this change and incremented the serialization verison of DefaultParticleInfluencer.

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9663 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
rem..om 13 years ago
parent 4404566121
commit 27930a7cd9
  1. 24
      engine/src/core/com/jme3/effect/influencers/DefaultParticleInfluencer.java
  2. 2
      engine/src/core/com/jme3/effect/influencers/NewtonianParticleInfluencer.java

@ -18,10 +18,13 @@ import java.io.IOException;
*/
public class DefaultParticleInfluencer implements ParticleInfluencer {
//Version #1 : changed startVelocity to initialvelocity for consistency with accessors
//and also changed it in serialization
public static final int SAVABLE_VERSION = 1;
/** Temporary variable used to help with calculations. */
protected transient Vector3f temp = new Vector3f();
/** The initial velocity of the particles. */
protected Vector3f startVelocity = new Vector3f();
protected Vector3f initialVelocity = new Vector3f();
/** The velocity's variation of the particles. */
protected float velocityVariation = 0.2f;
@ -37,25 +40,30 @@ public class DefaultParticleInfluencer implements ParticleInfluencer {
* the particle to be affected
*/
protected void applyVelocityVariation(Particle particle) {
particle.velocity.set(startVelocity);
particle.velocity.set(initialVelocity);
temp.set(FastMath.nextRandomFloat(), FastMath.nextRandomFloat(), FastMath.nextRandomFloat());
temp.multLocal(2f);
temp.subtractLocal(1f, 1f, 1f);
temp.multLocal(startVelocity.length());
temp.multLocal(initialVelocity.length());
particle.velocity.interpolate(temp, velocityVariation);
}
@Override
public void write(JmeExporter ex) throws IOException {
OutputCapsule oc = ex.getCapsule(this);
oc.write(startVelocity, "startVelocity", Vector3f.ZERO);
oc.write(initialVelocity, "initialVelocity", Vector3f.ZERO);
oc.write(velocityVariation, "variation", 0.2f);
}
@Override
public void read(JmeImporter im) throws IOException {
InputCapsule ic = im.getCapsule(this);
startVelocity = (Vector3f) ic.readSavable("startVelocity", Vector3f.ZERO.clone());
// NOTE: In previous versions of jME3, initialVelocity was called startVelocity
if (ic.getSavableVersion(DefaultParticleInfluencer.class) == 0){
initialVelocity = (Vector3f) ic.readSavable("startVelocity", Vector3f.ZERO.clone());
}else{
initialVelocity = (Vector3f) ic.readSavable("initialVelocity", Vector3f.ZERO.clone());
}
velocityVariation = ic.readFloat("variation", 0.2f);
}
@ -63,7 +71,7 @@ public class DefaultParticleInfluencer implements ParticleInfluencer {
public ParticleInfluencer clone() {
try {
DefaultParticleInfluencer clone = (DefaultParticleInfluencer) super.clone();
clone.startVelocity = startVelocity.clone();
clone.initialVelocity = initialVelocity.clone();
return clone;
} catch (CloneNotSupportedException e) {
throw new AssertionError();
@ -72,12 +80,12 @@ public class DefaultParticleInfluencer implements ParticleInfluencer {
@Override
public void setInitialVelocity(Vector3f initialVelocity) {
this.startVelocity.set(initialVelocity);
this.initialVelocity.set(initialVelocity);
}
@Override
public Vector3f getInitialVelocity() {
return startVelocity;
return initialVelocity;
}
@Override

@ -115,7 +115,7 @@ public class NewtonianParticleInfluencer extends DefaultParticleInfluencer {
public ParticleInfluencer clone() {
NewtonianParticleInfluencer result = new NewtonianParticleInfluencer();
result.normalVelocity = normalVelocity;
result.startVelocity = startVelocity;
result.initialVelocity = initialVelocity;
result.velocityVariation = velocityVariation;
result.surfaceTangentFactor = surfaceTangentFactor;
result.surfaceTangentRotation = surfaceTangentRotation;

Loading…
Cancel
Save