- 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
This commit is contained in:
nor..67 2013-02-09 01:36:36 +00:00
parent cc13547e19
commit b17fbf1f49
2 changed files with 4 additions and 2 deletions

View File

@ -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) {

View File

@ -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;