- change Spatial and AbstractControl so that control.setSpatial doesn't have to be called in Control.cloneForSpatial but the engine also doesn't throw an exception if it does

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10367 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
nor..67 12 years ago
parent cc13547e19
commit b17fbf1f49
  1. 4
      engine/src/core/com/jme3/scene/Spatial.java
  2. 2
      engine/src/core/com/jme3/scene/control/AbstractControl.java

@ -1182,7 +1182,9 @@ public abstract class Spatial implements Savable, Cloneable, Collidable, Cloneab
clone.controls = new SafeArrayList<Control>(Control.class);
for (int i = 0; i < controls.size(); i++) {
clone.controls.add(controls.get(i).cloneForSpatial(clone));
Control newControl = controls.get(i).cloneForSpatial(clone);
newControl.setSpatial(this);
clone.controls.add(newControl);
}
if (userData != null) {

@ -54,7 +54,7 @@ public abstract class AbstractControl implements Control {
}
public void setSpatial(Spatial spatial) {
if (this.spatial != null && spatial != null) {
if (this.spatial != null && spatial != null && spatial != this.spatial) {
throw new IllegalStateException("This control has already been added to a Spatial");
}
this.spatial = spatial;

Loading…
Cancel
Save