/** * Alter which spatial is controlled. Invoked when the control is added to * or removed from a spatial. Should be invoked only by a subclass or from * Spatial. Do not invoke directly from user code. * * @param spatial the spatial to control (or null) */ public void setSpatial(Spatial spatial) { if (this.spatial != null && this.spatial != spatial) { removeSpatialData(this.spatial); } else if (this.spatial == spatial) { return; } this.spatial = spatial; if (spatial == null) { return; } createSpatialData(this.spatial); setPhysicsLocation(getSpatialTranslation()); setPhysicsRotation(getSpatialRotation()); }
/** * Alter which spatial is controlled. Invoked when the control is added to * or removed from a spatial. Should be invoked only by a subclass or from * Spatial. Do not invoke directly from user code. * * @param spatial the spatial to control (or null) */ public void setSpatial(Spatial spatial) { if (this.spatial != null && this.spatial != spatial) { removeSpatialData(this.spatial); } else if (this.spatial == spatial) { return; } this.spatial = spatial; if (spatial == null) { return; } createSpatialData(this.spatial); setPhysicsLocation(getSpatialTranslation()); setPhysicsRotation(getSpatialRotation()); }
/** * Enable or disable this control. * <p> * When the control is disabled, the physics object is removed from physics * space. When the control is enabled again, the physics object is moved to * the spatial's location and then added to the physics space. * * @param enabled true→enable the control, false→disable it */ public void setEnabled(boolean enabled) { this.enabled = enabled; if (space != null) { if (enabled && !added) { if (spatial != null) { setPhysicsLocation(getSpatialTranslation()); setPhysicsRotation(getSpatialRotation()); } addPhysics(space); added = true; } else if (!enabled && added) { removePhysics(space); added = false; } } }
/** * Enable or disable this control. * <p> * When the control is disabled, the physics object is removed from physics * space. When the control is enabled again, the physics object is moved to * the spatial's location and then added to the physics space. * * @param enabled true→enable the control, false→disable it */ public void setEnabled(boolean enabled) { this.enabled = enabled; if (space != null) { if (enabled && !added) { if (spatial != null) { setPhysicsLocation(getSpatialTranslation()); setPhysicsRotation(getSpatialRotation()); } addPhysics(space); added = true; } else if (!enabled && added) { removePhysics(space); added = false; } } }
public void setSpatial(Spatial spatial) { if (this.spatial != null && this.spatial != spatial) { removeSpatialData(this.spatial); } else if (this.spatial == spatial) { return; } this.spatial = spatial; if (spatial == null) { return; } createSpatialData(this.spatial); setPhysicsLocation(getSpatialTranslation()); setPhysicsRotation(getSpatialRotation()); }
public void setEnabled(boolean enabled) { this.enabled = enabled; if (space != null) { if (enabled && !added) { if (spatial != null) { setPhysicsLocation(getSpatialTranslation()); setPhysicsRotation(getSpatialRotation()); } addPhysics(space); added = true; } else if (!enabled && added) { removePhysics(space); added = false; } } }
/** * Alter which spatial is controlled. Invoked when the control is added to * or removed from a spatial. Should be invoked only by a subclass or from * Spatial. Do not invoke directly from user code. * * @param spatial the spatial to control (or null) */ public void setSpatial(Spatial spatial) { if (this.spatial != null && this.spatial != spatial) { removeSpatialData(this.spatial); } else if (this.spatial == spatial) { return; } this.spatial = spatial; if (spatial == null) { return; } createSpatialData(this.spatial); setPhysicsLocation(getSpatialTranslation()); setPhysicsRotation(getSpatialRotation()); }
/** * Enable or disable this control. * <p> * When the control is disabled, the physics object is removed from physics * space. When the control is enabled again, the physics object is moved to * the spatial's location and then added to the physics space. * * @param enabled true→enable the control, false→disable it */ public void setEnabled(boolean enabled) { this.enabled = enabled; if (space != null) { if (enabled && !added) { if (spatial != null) { setPhysicsLocation(getSpatialTranslation()); setPhysicsRotation(getSpatialRotation()); } addPhysics(space); added = true; } else if (!enabled && added) { removePhysics(space); added = false; } } }