Browse Source

get body properties when body exists

fredakilla 9 years ago
parent
commit
10449971b9
1 changed files with 7 additions and 7 deletions
  1. 7 7
      Source/Urho3D/Urho2D/RigidBody2D.h

+ 7 - 7
Source/Urho3D/Urho2D/RigidBody2D.h

@@ -115,7 +115,7 @@ public:
     void RemoveConstraint2D(Constraint2D* constraint);
 
     /// Return body type.
-    BodyType2D GetBodyType() const { return (BodyType2D)bodyDef_.type; }
+    BodyType2D GetBodyType() const { return body_ ? (BodyType2D)body_->GetType() : (BodyType2D)bodyDef_.type; }
 
     /// Return mass.
     float GetMass() const;
@@ -128,22 +128,22 @@ public:
     bool GetUseFixtureMass() const { return useFixtureMass_; }
 
     /// Return linear damping.
-    float GetLinearDamping() const { return bodyDef_.linearDamping; }
+    float GetLinearDamping() const { return body_ ? body_->GetLinearDamping() : bodyDef_.linearDamping; }
 
     /// Return angular damping.
-    float GetAngularDamping() const { return bodyDef_.angularDamping; }
+    float GetAngularDamping() const { return body_ ? body_->GetAngularDamping() : bodyDef_.angularDamping; }
 
     /// Return allow sleep.
-    bool IsAllowSleep() const { return bodyDef_.allowSleep; }
+    bool IsAllowSleep() const { return body_ ? body_->IsSleepingAllowed() : bodyDef_.allowSleep; }
 
     /// Return fixed rotation.
-    bool IsFixedRotation() const { return bodyDef_.fixedRotation; }
+    bool IsFixedRotation() const { return body_ ? body_->IsFixedRotation() : bodyDef_.fixedRotation; }
 
     /// Return bullet mode.
-    bool IsBullet() const { return bodyDef_.bullet; }
+    bool IsBullet() const { return body_ ? body_->IsBullet() : bodyDef_.bullet; }
 
     /// Return gravity scale.
-    float GetGravityScale() const { return bodyDef_.gravityScale; }
+    float GetGravityScale() const { return body_ ? body_->GetGravityScale() : bodyDef_.gravityScale; }
 
     /// Return awake.
     bool IsAwake() const;