ParticleEmitter and related classes (ugh) now implement JmeCloneable.
It hasn't replaced the old clone() method yet and is still untested.
This commit is contained in:
parent
6e999aa79b
commit
7665fef2de
@ -211,6 +211,42 @@ public class ParticleEmitter extends Geometry {
|
|||||||
return clone;
|
return clone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called internally by com.jme3.util.clone.Cloner. Do not call directly.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void cloneFields( Cloner cloner, Object original ) {
|
||||||
|
this.shape = cloner.clone(shape);
|
||||||
|
this.control = cloner.clone(control);
|
||||||
|
this.faceNormal = cloner.clone(faceNormal);
|
||||||
|
this.startColor = cloner.clone(startColor);
|
||||||
|
this.endColor = cloner.clone(endColor);
|
||||||
|
this.particleInfluencer = cloner.clone(particleInfluencer);
|
||||||
|
|
||||||
|
// change in behavior: gravity was not cloned before -pspeed
|
||||||
|
this.gravity = cloner.clone(gravity);
|
||||||
|
|
||||||
|
// So, simply setting the mesh type will cause all kinds of things
|
||||||
|
// to happen:
|
||||||
|
// 1) the new mesh gets created.
|
||||||
|
// 2) it is set to the Geometry
|
||||||
|
// 3) the particles array is recreated because setNumParticles()
|
||||||
|
//
|
||||||
|
// ...so this should be equivalent but simpler than half of the old clone()
|
||||||
|
// method. Note: we do not ever want to share particleMesh so we do not
|
||||||
|
// clone it at all.
|
||||||
|
setMeshType(meshType);
|
||||||
|
|
||||||
|
// change in behavior: temp and lastPos were not cloned before...
|
||||||
|
// perhaps because it was believed that 'transient' fields were exluded
|
||||||
|
// from cloning? (they aren't)
|
||||||
|
// If it was ok for these to be shared because of how they are used
|
||||||
|
// then they could just as well be made static... else I think it's clearer
|
||||||
|
// to clone them.
|
||||||
|
this.temp = cloner.clone(temp);
|
||||||
|
this.lastPos = cloner.clone(lastPos);
|
||||||
|
}
|
||||||
|
|
||||||
public ParticleEmitter(String name, Type type, int numParticles) {
|
public ParticleEmitter(String name, Type type, int numParticles) {
|
||||||
super(name);
|
super(name);
|
||||||
setBatchHint(BatchHint.Never);
|
setBatchHint(BatchHint.Never);
|
||||||
|
@ -39,6 +39,8 @@ import com.jme3.export.JmeImporter;
|
|||||||
import com.jme3.export.OutputCapsule;
|
import com.jme3.export.OutputCapsule;
|
||||||
import com.jme3.math.FastMath;
|
import com.jme3.math.FastMath;
|
||||||
import com.jme3.math.Vector3f;
|
import com.jme3.math.Vector3f;
|
||||||
|
import com.jme3.util.clone.Cloner;
|
||||||
|
import com.jme3.util.clone.JmeCloneable;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -109,6 +111,35 @@ public class DefaultParticleInfluencer implements ParticleInfluencer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called internally by com.jme3.util.clone.Cloner. Do not call directly.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Object jmeClone() {
|
||||||
|
try {
|
||||||
|
return super.clone();
|
||||||
|
} catch (CloneNotSupportedException ex) {
|
||||||
|
throw new AssertionError();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called internally by com.jme3.util.clone.Cloner. Do not call directly.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void cloneFields( Cloner cloner, Object original ) {
|
||||||
|
this.initialVelocity = cloner.clone(initialVelocity);
|
||||||
|
|
||||||
|
// Change in behavior: I'm cloning 'for real' the 'temp' field because
|
||||||
|
// otherwise it will be shared across all clones. Note: if this is
|
||||||
|
// ok because of how its used then it might as well be static and let
|
||||||
|
// everything share it.
|
||||||
|
// Note 2: transient fields _are_ cloned just like anything else so
|
||||||
|
// thinking it wouldn't get cloned is also not right.
|
||||||
|
// -pspeed
|
||||||
|
this.temp = cloner.clone(temp);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setInitialVelocity(Vector3f initialVelocity) {
|
public void setInitialVelocity(Vector3f initialVelocity) {
|
||||||
this.initialVelocity.set(initialVelocity);
|
this.initialVelocity.set(initialVelocity);
|
||||||
|
@ -36,6 +36,8 @@ import com.jme3.effect.shapes.EmitterShape;
|
|||||||
import com.jme3.export.JmeExporter;
|
import com.jme3.export.JmeExporter;
|
||||||
import com.jme3.export.JmeImporter;
|
import com.jme3.export.JmeImporter;
|
||||||
import com.jme3.math.Vector3f;
|
import com.jme3.math.Vector3f;
|
||||||
|
import com.jme3.util.clone.Cloner;
|
||||||
|
import com.jme3.util.clone.JmeCloneable;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -83,4 +85,23 @@ public class EmptyParticleInfluencer implements ParticleInfluencer {
|
|||||||
throw new AssertionError();
|
throw new AssertionError();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called internally by com.jme3.util.clone.Cloner. Do not call directly.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Object jmeClone() {
|
||||||
|
try {
|
||||||
|
return super.clone();
|
||||||
|
} catch (CloneNotSupportedException ex) {
|
||||||
|
throw new AssertionError();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called internally by com.jme3.util.clone.Cloner. Do not call directly.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void cloneFields( Cloner cloner, Object original ) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,6 +39,8 @@ import com.jme3.export.JmeImporter;
|
|||||||
import com.jme3.export.OutputCapsule;
|
import com.jme3.export.OutputCapsule;
|
||||||
import com.jme3.math.FastMath;
|
import com.jme3.math.FastMath;
|
||||||
import com.jme3.math.Matrix3f;
|
import com.jme3.math.Matrix3f;
|
||||||
|
import com.jme3.util.clone.Cloner;
|
||||||
|
import com.jme3.util.clone.JmeCloneable;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -36,12 +36,13 @@ import com.jme3.effect.ParticleEmitter;
|
|||||||
import com.jme3.effect.shapes.EmitterShape;
|
import com.jme3.effect.shapes.EmitterShape;
|
||||||
import com.jme3.export.Savable;
|
import com.jme3.export.Savable;
|
||||||
import com.jme3.math.Vector3f;
|
import com.jme3.math.Vector3f;
|
||||||
|
import com.jme3.util.clone.JmeCloneable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An interface that defines the methods to affect initial velocity of the particles.
|
* An interface that defines the methods to affect initial velocity of the particles.
|
||||||
* @author Marcin Roguski (Kaelthas)
|
* @author Marcin Roguski (Kaelthas)
|
||||||
*/
|
*/
|
||||||
public interface ParticleInfluencer extends Savable, Cloneable {
|
public interface ParticleInfluencer extends Savable, Cloneable, JmeCloneable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method influences the particle.
|
* This method influences the particle.
|
||||||
|
@ -38,6 +38,7 @@ import com.jme3.export.JmeImporter;
|
|||||||
import com.jme3.export.OutputCapsule;
|
import com.jme3.export.OutputCapsule;
|
||||||
import com.jme3.math.FastMath;
|
import com.jme3.math.FastMath;
|
||||||
import com.jme3.math.Vector3f;
|
import com.jme3.math.Vector3f;
|
||||||
|
import com.jme3.util.clone.Cloner;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -119,6 +120,16 @@ public class RadialParticleInfluencer extends DefaultParticleInfluencer {
|
|||||||
this.horizontal = horizontal;
|
this.horizontal = horizontal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called internally by com.jme3.util.clone.Cloner. Do not call directly.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void cloneFields( Cloner cloner, Object original ) {
|
||||||
|
// Change in behavior: the old origin was not cloned -pspeed
|
||||||
|
this.origin = cloner.clone(origin);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(JmeExporter ex) throws IOException {
|
public void write(JmeExporter ex) throws IOException {
|
||||||
super.write(ex);
|
super.write(ex);
|
||||||
|
@ -37,6 +37,8 @@ import com.jme3.export.JmeImporter;
|
|||||||
import com.jme3.export.OutputCapsule;
|
import com.jme3.export.OutputCapsule;
|
||||||
import com.jme3.math.FastMath;
|
import com.jme3.math.FastMath;
|
||||||
import com.jme3.math.Vector3f;
|
import com.jme3.math.Vector3f;
|
||||||
|
import com.jme3.util.clone.Cloner;
|
||||||
|
import com.jme3.util.clone.JmeCloneable;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class EmitterBoxShape implements EmitterShape {
|
public class EmitterBoxShape implements EmitterShape {
|
||||||
@ -86,6 +88,27 @@ public class EmitterBoxShape implements EmitterShape {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called internally by com.jme3.util.clone.Cloner. Do not call directly.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Object jmeClone() {
|
||||||
|
try {
|
||||||
|
return super.clone();
|
||||||
|
} catch (CloneNotSupportedException ex) {
|
||||||
|
throw new AssertionError();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called internally by com.jme3.util.clone.Cloner. Do not call directly.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void cloneFields( Cloner cloner, Object original ) {
|
||||||
|
this.min = cloner.clone(min);
|
||||||
|
this.len = cloner.clone(len);
|
||||||
|
}
|
||||||
|
|
||||||
public Vector3f getMin() {
|
public Vector3f getMin() {
|
||||||
return min;
|
return min;
|
||||||
}
|
}
|
||||||
|
@ -40,6 +40,8 @@ import com.jme3.math.Vector3f;
|
|||||||
import com.jme3.scene.Mesh;
|
import com.jme3.scene.Mesh;
|
||||||
import com.jme3.scene.VertexBuffer.Type;
|
import com.jme3.scene.VertexBuffer.Type;
|
||||||
import com.jme3.util.BufferUtils;
|
import com.jme3.util.BufferUtils;
|
||||||
|
import com.jme3.util.clone.Cloner;
|
||||||
|
import com.jme3.util.clone.JmeCloneable;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -168,6 +170,27 @@ public class EmitterMeshVertexShape implements EmitterShape {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called internally by com.jme3.util.clone.Cloner. Do not call directly.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Object jmeClone() {
|
||||||
|
try {
|
||||||
|
return super.clone();
|
||||||
|
} catch (CloneNotSupportedException ex) {
|
||||||
|
throw new AssertionError();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called internally by com.jme3.util.clone.Cloner. Do not call directly.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void cloneFields( Cloner cloner, Object original ) {
|
||||||
|
this.vertices = cloner.clone(vertices);
|
||||||
|
this.normals = cloner.clone(normals);
|
||||||
|
}
|
||||||
|
|
||||||
@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);
|
||||||
|
@ -35,6 +35,8 @@ import com.jme3.export.JmeExporter;
|
|||||||
import com.jme3.export.JmeImporter;
|
import com.jme3.export.JmeImporter;
|
||||||
import com.jme3.export.OutputCapsule;
|
import com.jme3.export.OutputCapsule;
|
||||||
import com.jme3.math.Vector3f;
|
import com.jme3.math.Vector3f;
|
||||||
|
import com.jme3.util.clone.Cloner;
|
||||||
|
import com.jme3.util.clone.JmeCloneable;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class EmitterPointShape implements EmitterShape {
|
public class EmitterPointShape implements EmitterShape {
|
||||||
@ -59,6 +61,26 @@ public class EmitterPointShape implements EmitterShape {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called internally by com.jme3.util.clone.Cloner. Do not call directly.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Object jmeClone() {
|
||||||
|
try {
|
||||||
|
return super.clone();
|
||||||
|
} catch (CloneNotSupportedException ex) {
|
||||||
|
throw new AssertionError();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called internally by com.jme3.util.clone.Cloner. Do not call directly.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void cloneFields( Cloner cloner, Object original ) {
|
||||||
|
this.point = cloner.clone(point);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void getRandomPoint(Vector3f store) {
|
public void getRandomPoint(Vector3f store) {
|
||||||
store.set(point);
|
store.set(point);
|
||||||
|
@ -33,12 +33,13 @@ package com.jme3.effect.shapes;
|
|||||||
|
|
||||||
import com.jme3.export.Savable;
|
import com.jme3.export.Savable;
|
||||||
import com.jme3.math.Vector3f;
|
import com.jme3.math.Vector3f;
|
||||||
|
import com.jme3.util.clone.JmeCloneable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This interface declares methods used by all shapes that represent particle emitters.
|
* This interface declares methods used by all shapes that represent particle emitters.
|
||||||
* @author Kirill
|
* @author Kirill
|
||||||
*/
|
*/
|
||||||
public interface EmitterShape extends Savable, Cloneable {
|
public interface EmitterShape extends Savable, Cloneable, JmeCloneable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method fills in the initial position of the particle.
|
* This method fills in the initial position of the particle.
|
||||||
|
@ -37,6 +37,8 @@ import com.jme3.export.JmeImporter;
|
|||||||
import com.jme3.export.OutputCapsule;
|
import com.jme3.export.OutputCapsule;
|
||||||
import com.jme3.math.FastMath;
|
import com.jme3.math.FastMath;
|
||||||
import com.jme3.math.Vector3f;
|
import com.jme3.math.Vector3f;
|
||||||
|
import com.jme3.util.clone.Cloner;
|
||||||
|
import com.jme3.util.clone.JmeCloneable;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class EmitterSphereShape implements EmitterShape {
|
public class EmitterSphereShape implements EmitterShape {
|
||||||
@ -71,6 +73,26 @@ public class EmitterSphereShape implements EmitterShape {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called internally by com.jme3.util.clone.Cloner. Do not call directly.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Object jmeClone() {
|
||||||
|
try {
|
||||||
|
return super.clone();
|
||||||
|
} catch (CloneNotSupportedException ex) {
|
||||||
|
throw new AssertionError();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called internally by com.jme3.util.clone.Cloner. Do not call directly.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void cloneFields( Cloner cloner, Object original ) {
|
||||||
|
this.center = cloner.clone(center);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void getRandomPoint(Vector3f store) {
|
public void getRandomPoint(Vector3f store) {
|
||||||
do {
|
do {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user