From 76049c76f309bceb5eaae43ef78d60e43988ec5a Mon Sep 17 00:00:00 2001 From: Quazi Irfan Date: Tue, 19 Mar 2019 14:52:21 -0500 Subject: [PATCH] =?UTF-8?q?Add=20getSpatial=20to=20GhostControl,=20RigidBo?= =?UTF-8?q?dyControl,=20AbstractPhysicsCont=E2=80=A6=20(#1041)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add getSpatial to GhostControl, RigidBodyControl, AbstractPhysicsControl and CharacterControl. Fix issue 1008 * Fix doc: control is attached to spatial. Not the other way around. * Update doc: Clarify what getSpatial returns --- .../com/jme3/bullet/control/AbstractPhysicsControl.java | 7 +++++++ .../java/com/jme3/bullet/control/CharacterControl.java | 7 +++++++ .../common/java/com/jme3/bullet/control/GhostControl.java | 7 +++++++ .../java/com/jme3/bullet/control/RigidBodyControl.java | 7 +++++++ 4 files changed, 28 insertions(+) diff --git a/jme3-bullet/src/common/java/com/jme3/bullet/control/AbstractPhysicsControl.java b/jme3-bullet/src/common/java/com/jme3/bullet/control/AbstractPhysicsControl.java index f858d0e00..739701d9f 100644 --- a/jme3-bullet/src/common/java/com/jme3/bullet/control/AbstractPhysicsControl.java +++ b/jme3-bullet/src/common/java/com/jme3/bullet/control/AbstractPhysicsControl.java @@ -246,6 +246,13 @@ public abstract class AbstractPhysicsControl implements PhysicsControl, JmeClone setPhysicsRotation(getSpatialRotation()); } + /** + * @return returns the spatial the control is added to, or null if the control is not attached to a spatial yet. + */ + public Spatial getSpatial(){ + return this.spatial; + } + /** * Enable or disable this control. *

diff --git a/jme3-bullet/src/common/java/com/jme3/bullet/control/CharacterControl.java b/jme3-bullet/src/common/java/com/jme3/bullet/control/CharacterControl.java index e34b5b3b6..2ee7fbe62 100644 --- a/jme3-bullet/src/common/java/com/jme3/bullet/control/CharacterControl.java +++ b/jme3-bullet/src/common/java/com/jme3/bullet/control/CharacterControl.java @@ -129,6 +129,13 @@ public class CharacterControl extends PhysicsCharacter implements PhysicsControl setPhysicsLocation(getSpatialTranslation()); } + /** + * @return returns the spatial the control is added to, or null if the control is not attached to a spatial yet. + */ + public Spatial getSpatial(){ + return this.spatial; + } + public void setEnabled(boolean enabled) { this.enabled = enabled; if (space != null) { diff --git a/jme3-bullet/src/common/java/com/jme3/bullet/control/GhostControl.java b/jme3-bullet/src/common/java/com/jme3/bullet/control/GhostControl.java index 7ff51670d..ca3fc7254 100644 --- a/jme3-bullet/src/common/java/com/jme3/bullet/control/GhostControl.java +++ b/jme3-bullet/src/common/java/com/jme3/bullet/control/GhostControl.java @@ -206,6 +206,13 @@ public class GhostControl extends PhysicsGhostObject implements PhysicsControl, setPhysicsRotation(getSpatialRotation()); } + /** + * @return returns the spatial the control is added to, or null if the control is not attached to a spatial yet. + */ + public Spatial getSpatial(){ + return this.spatial; + } + /** * Enable or disable this control. *

diff --git a/jme3-bullet/src/common/java/com/jme3/bullet/control/RigidBodyControl.java b/jme3-bullet/src/common/java/com/jme3/bullet/control/RigidBodyControl.java index 4094ab4db..cee3401e1 100644 --- a/jme3-bullet/src/common/java/com/jme3/bullet/control/RigidBodyControl.java +++ b/jme3-bullet/src/common/java/com/jme3/bullet/control/RigidBodyControl.java @@ -207,6 +207,13 @@ public class RigidBodyControl extends PhysicsRigidBody implements PhysicsControl setPhysicsRotation(getSpatialRotation()); } + /** + * @return returns the spatial the control is added to, or null if the control is not attached to a spatial yet. + */ + public Spatial getSpatial(){ + return this.spatial; + } + /** * Set the collision shape based on the controlled spatial and its * descendents.