Updated AudioNode with a JmeCloneable cloneFields() method
to clone its fields. Some small change in behavior since the new methods will clone the filters, too, to avoid 'user surprise'.
This commit is contained in:
parent
2f246b25bb
commit
eda92656dd
@ -41,6 +41,7 @@ import com.jme3.export.OutputCapsule;
|
|||||||
import com.jme3.math.Vector3f;
|
import com.jme3.math.Vector3f;
|
||||||
import com.jme3.scene.Node;
|
import com.jme3.scene.Node;
|
||||||
import com.jme3.util.PlaceholderAssets;
|
import com.jme3.util.PlaceholderAssets;
|
||||||
|
import com.jme3.util.clone.Cloner;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
@ -724,6 +725,28 @@ public class AudioNode extends Node implements AudioSource {
|
|||||||
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.direction = cloner.clone(direction);
|
||||||
|
this.velocity = cloner.clone(velocity);
|
||||||
|
|
||||||
|
// Change in behavior: the filters were not cloned before meaning
|
||||||
|
// that two cloned audio nodes would share the same filter instance.
|
||||||
|
// While settings will only be applied when the filter is actually
|
||||||
|
// set, I think it's probably surprising to callers if the values of
|
||||||
|
// a filter change from one AudioNode when a different AudioNode's
|
||||||
|
// filter attributes are updated.
|
||||||
|
// Plus if they disable and re-enable the thing using the filter then
|
||||||
|
// the settings get reapplied and it might be surprising to have them
|
||||||
|
// suddenly be strange.
|
||||||
|
// ...so I'll clone them. -pspeed
|
||||||
|
this.dryFilter = cloner.clone(dryFilter);
|
||||||
|
this.reverbFilter = cloner.clone(reverbFilter);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(JmeExporter ex) throws IOException {
|
public void write(JmeExporter ex) throws IOException {
|
||||||
super.write(ex);
|
super.write(ex);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user