diff --git a/jme3-core/src/main/java/com/jme3/scene/Spatial.java b/jme3-core/src/main/java/com/jme3/scene/Spatial.java index 2fe1775d3e..6879de00e1 100644 --- a/jme3-core/src/main/java/com/jme3/scene/Spatial.java +++ b/jme3-core/src/main/java/com/jme3/scene/Spatial.java @@ -772,16 +772,7 @@ public void runControlRender(RenderManager rm, ViewPort vp) { * @see Spatial#removeControl(java.lang.Class) */ public void addControl(Control control) { - boolean before = requiresUpdates(); - controls.add(control); - control.setSpatial(this); - boolean after = requiresUpdates(); - // If the requirement to be updated has changed, - // then we need to let the parent node know, so it - // can rebuild its update list. - if (parent != null && before != after) { - parent.invalidateUpdateList(); - } + addControlAt(controls.size(), control); } /** @@ -807,13 +798,17 @@ public void addControlAt(int index, Control control) { throw new IllegalStateException("Control is already added here."); } - addControl(control); // takes care of the bookkeeping - - if (index < numControls) { // re-arrange the list directly - boolean success = controls.remove(control); - assert success : "Surprising control remove failure. " + control.getClass().getSimpleName() + " from spatial " + getName(); - controls.add(index, control); + boolean before = requiresUpdates(); + controls.add(index, control); + control.setSpatial(this); + boolean after = requiresUpdates(); + // If the requirement to be updated has changed, + // then we need to let the parent node know, so it + // can rebuild its update list. + if (parent != null && before != after) { + parent.invalidateUpdateList(); } + } /**