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
This commit is contained in:
parent
4404566121
commit
27930a7cd9
@ -18,10 +18,13 @@ import java.io.IOException;
|
|||||||
*/
|
*/
|
||||||
public class DefaultParticleInfluencer implements ParticleInfluencer {
|
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. */
|
/** Temporary variable used to help with calculations. */
|
||||||
protected transient Vector3f temp = new Vector3f();
|
protected transient Vector3f temp = new Vector3f();
|
||||||
/** The initial velocity of the particles. */
|
/** The initial velocity of the particles. */
|
||||||
protected Vector3f startVelocity = new Vector3f();
|
protected Vector3f initialVelocity = new Vector3f();
|
||||||
/** The velocity's variation of the particles. */
|
/** The velocity's variation of the particles. */
|
||||||
protected float velocityVariation = 0.2f;
|
protected float velocityVariation = 0.2f;
|
||||||
|
|
||||||
@ -37,25 +40,30 @@ public class DefaultParticleInfluencer implements ParticleInfluencer {
|
|||||||
* the particle to be affected
|
* the particle to be affected
|
||||||
*/
|
*/
|
||||||
protected void applyVelocityVariation(Particle particle) {
|
protected void applyVelocityVariation(Particle particle) {
|
||||||
particle.velocity.set(startVelocity);
|
particle.velocity.set(initialVelocity);
|
||||||
temp.set(FastMath.nextRandomFloat(), FastMath.nextRandomFloat(), FastMath.nextRandomFloat());
|
temp.set(FastMath.nextRandomFloat(), FastMath.nextRandomFloat(), FastMath.nextRandomFloat());
|
||||||
temp.multLocal(2f);
|
temp.multLocal(2f);
|
||||||
temp.subtractLocal(1f, 1f, 1f);
|
temp.subtractLocal(1f, 1f, 1f);
|
||||||
temp.multLocal(startVelocity.length());
|
temp.multLocal(initialVelocity.length());
|
||||||
particle.velocity.interpolate(temp, velocityVariation);
|
particle.velocity.interpolate(temp, velocityVariation);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(JmeExporter ex) throws IOException {
|
public void write(JmeExporter ex) throws IOException {
|
||||||
OutputCapsule oc = ex.getCapsule(this);
|
OutputCapsule oc = ex.getCapsule(this);
|
||||||
oc.write(startVelocity, "startVelocity", Vector3f.ZERO);
|
oc.write(initialVelocity, "initialVelocity", Vector3f.ZERO);
|
||||||
oc.write(velocityVariation, "variation", 0.2f);
|
oc.write(velocityVariation, "variation", 0.2f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void read(JmeImporter im) throws IOException {
|
public void read(JmeImporter im) throws IOException {
|
||||||
InputCapsule ic = im.getCapsule(this);
|
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);
|
velocityVariation = ic.readFloat("variation", 0.2f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,7 +71,7 @@ public class DefaultParticleInfluencer implements ParticleInfluencer {
|
|||||||
public ParticleInfluencer clone() {
|
public ParticleInfluencer clone() {
|
||||||
try {
|
try {
|
||||||
DefaultParticleInfluencer clone = (DefaultParticleInfluencer) super.clone();
|
DefaultParticleInfluencer clone = (DefaultParticleInfluencer) super.clone();
|
||||||
clone.startVelocity = startVelocity.clone();
|
clone.initialVelocity = initialVelocity.clone();
|
||||||
return clone;
|
return clone;
|
||||||
} catch (CloneNotSupportedException e) {
|
} catch (CloneNotSupportedException e) {
|
||||||
throw new AssertionError();
|
throw new AssertionError();
|
||||||
@ -72,12 +80,12 @@ public class DefaultParticleInfluencer implements ParticleInfluencer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setInitialVelocity(Vector3f initialVelocity) {
|
public void setInitialVelocity(Vector3f initialVelocity) {
|
||||||
this.startVelocity.set(initialVelocity);
|
this.initialVelocity.set(initialVelocity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Vector3f getInitialVelocity() {
|
public Vector3f getInitialVelocity() {
|
||||||
return startVelocity;
|
return initialVelocity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -115,7 +115,7 @@ public class NewtonianParticleInfluencer extends DefaultParticleInfluencer {
|
|||||||
public ParticleInfluencer clone() {
|
public ParticleInfluencer clone() {
|
||||||
NewtonianParticleInfluencer result = new NewtonianParticleInfluencer();
|
NewtonianParticleInfluencer result = new NewtonianParticleInfluencer();
|
||||||
result.normalVelocity = normalVelocity;
|
result.normalVelocity = normalVelocity;
|
||||||
result.startVelocity = startVelocity;
|
result.initialVelocity = initialVelocity;
|
||||||
result.velocityVariation = velocityVariation;
|
result.velocityVariation = velocityVariation;
|
||||||
result.surfaceTangentFactor = surfaceTangentFactor;
|
result.surfaceTangentFactor = surfaceTangentFactor;
|
||||||
result.surfaceTangentRotation = surfaceTangentRotation;
|
result.surfaceTangentRotation = surfaceTangentRotation;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user