From dbabe4c07cd9c0d825c14b961bd472f77e525162 Mon Sep 17 00:00:00 2001 From: Josh Grams Date: Wed, 20 Apr 2016 19:49:35 -0400 Subject: [PATCH] RigidBody2D: add and bind get/set_applied_torque. --- doc/base/classes.xml | 56 ++++++++++++++++++++++++++++++++++++ scene/2d/physics_body_2d.cpp | 13 +++++++++ scene/2d/physics_body_2d.h | 3 ++ 3 files changed, 72 insertions(+) diff --git a/doc/base/classes.xml b/doc/base/classes.xml index b77a1c29a89..9b951be0d2d 100644 --- a/doc/base/classes.xml +++ b/doc/base/classes.xml @@ -2900,6 +2900,12 @@ + + + + + + @@ -13887,6 +13893,12 @@ Returns an empty String "" at the end of the list. + + + + + + @@ -19118,6 +19130,14 @@ Example: (content-length:12), (Content-Type:application/json; charset=UTF-8) Set the mesh of the item. + + + + + + + + @@ -19144,6 +19164,14 @@ Example: (content-length:12), (Content-Type:application/json; charset=UTF-8) Return the mesh of the item. + + + + + + + + @@ -30206,6 +30234,18 @@ This method controls whether the position between two cached points is interpola Return the applied force vector. + + + + + + + + + + + + @@ -36069,6 +36109,22 @@ This method controls whether the position between two cached points is interpola + + + + + + + + + + + + + + + + diff --git a/scene/2d/physics_body_2d.cpp b/scene/2d/physics_body_2d.cpp index dc038f010c8..cc6145677e8 100644 --- a/scene/2d/physics_body_2d.cpp +++ b/scene/2d/physics_body_2d.cpp @@ -782,6 +782,16 @@ Vector2 RigidBody2D::get_applied_force() const { return Physics2DServer::get_singleton()->body_get_applied_force(get_rid()); }; +void RigidBody2D::set_applied_torque(const float p_torque) { + + Physics2DServer::get_singleton()->body_set_applied_torque(get_rid(), p_torque); +}; + +float RigidBody2D::get_applied_torque() const { + + return Physics2DServer::get_singleton()->body_get_applied_torque(get_rid()); +}; + void RigidBody2D::set_continuous_collision_detection_mode(CCDMode p_mode) { @@ -900,6 +910,9 @@ void RigidBody2D::_bind_methods() { ObjectTypeDB::bind_method(_MD("set_applied_force","force"),&RigidBody2D::set_applied_force); ObjectTypeDB::bind_method(_MD("get_applied_force"),&RigidBody2D::get_applied_force); + ObjectTypeDB::bind_method(_MD("set_applied_torque","torque"),&RigidBody2D::set_applied_torque); + ObjectTypeDB::bind_method(_MD("get_applied_torque"),&RigidBody2D::get_applied_torque); + ObjectTypeDB::bind_method(_MD("set_sleeping","sleeping"),&RigidBody2D::set_sleeping); ObjectTypeDB::bind_method(_MD("is_sleeping"),&RigidBody2D::is_sleeping); diff --git a/scene/2d/physics_body_2d.h b/scene/2d/physics_body_2d.h index 999e63dd5d1..40cb25d8c1e 100644 --- a/scene/2d/physics_body_2d.h +++ b/scene/2d/physics_body_2d.h @@ -266,6 +266,9 @@ public: void set_applied_force(const Vector2& p_force); Vector2 get_applied_force() const; + void set_applied_torque(const float p_torque); + float get_applied_torque() const; + Array get_colliding_bodies() const; //function for script