/** * If enabled, add this control's body to the specified physics space. In * not enabled, alter where the body would be added. The body is removed * from any other space it's currently in. * * @param newSpace where to add, or null to simply remove */ @Override public void setPhysicsSpace(PhysicsSpace newSpace) { if (space == newSpace) { return; } if (added) { space.removeCollisionObject(this); added = false; } if (newSpace != null && isEnabled()) { newSpace.addCollisionObject(this); added = true; } /* * If this control isn't enabled, its body will be * added to the new space when the control becomes enabled. */ space = newSpace; }
/** * If enabled, add this control's body to the specified physics space. In * not enabled, alter where the body would be added. The body is removed * from any other space it's currently in. * * @param newSpace where to add, or null to simply remove */ @Override public void setPhysicsSpace(PhysicsSpace newSpace) { if (space == newSpace) { return; } if (added) { space.removeCollisionObject(this); added = false; } if (newSpace != null && isEnabled()) { newSpace.addCollisionObject(this); added = true; } /* * If this control isn't enabled, its body will be * added to the new space when the control becomes enabled. */ space = newSpace; }
control.setEnabled(isEnabled());
control.setEnabled(isEnabled());
private Vector3f getLocation() { if (rbc != null && rbc.isEnabled()) { return rbc.getPhysicsLocation(); } else { return spatial.getWorldTranslation(); } }
private Quaternion getRotation() { if (rbc != null && rbc.isEnabled()) { return rbc.getPhysicsRotation(); } else { return spatial.getWorldRotation(); } }
public void setPhysicsSpace(PhysicsSpace space) { if (space == null) { if (this.space != null) { this.space.removeCollisionObject(this); added = false; } } else { if (this.space == space) return; // if this object isn't enabled, it will be added when it will be enabled. if (isEnabled()) { space.addCollisionObject(this); added = true; } } this.space = space; }
/** * If enabled, add this control's body to the specified physics space. In * not enabled, alter where the body would be added. The body is removed * from any other space it's currently in. * * @param newSpace where to add, or null to simply remove */ @Override public void setPhysicsSpace(PhysicsSpace newSpace) { if (space == newSpace) { return; } if (added) { space.removeCollisionObject(this); added = false; } if (newSpace != null && isEnabled()) { newSpace.addCollisionObject(this); added = true; } /* * If this control isn't enabled, its body will be * added to the new space when the control becomes enabled. */ space = newSpace; }
@Override public Object jmeClone() { RigidBodyControl control = new RigidBodyControl(collisionShape, mass); control.setAngularFactor(getAngularFactor()); control.setAngularSleepingThreshold(getAngularSleepingThreshold()); control.setCcdMotionThreshold(getCcdMotionThreshold()); control.setCcdSweptSphereRadius(getCcdSweptSphereRadius()); control.setCollideWithGroups(getCollideWithGroups()); control.setCollisionGroup(getCollisionGroup()); control.setDamping(getLinearDamping(), getAngularDamping()); control.setFriction(getFriction()); control.setGravity(getGravity()); control.setKinematic(isKinematic()); control.setKinematicSpatial(isKinematicSpatial()); control.setLinearSleepingThreshold(getLinearSleepingThreshold()); control.setPhysicsLocation(getPhysicsLocation(null)); control.setPhysicsRotation(getPhysicsRotationMatrix(null)); control.setRestitution(getRestitution()); if (mass > 0) { control.setAngularVelocity(getAngularVelocity()); control.setLinearVelocity(getLinearVelocity()); } control.setApplyPhysicsLocal(isApplyPhysicsLocal()); control.spatial = this.spatial; control.setEnabled(isEnabled()); return control; }
control.setEnabled(isEnabled());