diff options
author | Tiger Caldwell <tiger@caldwellfive.com> | 2018-07-24 03:49:12 -0400 |
---|---|---|
committer | Tiger Caldwell <tiger@caldwellfive.com> | 2018-07-24 05:00:56 -0400 |
commit | 40c7716586db9182208b51d22e117d099bb4c97d (patch) | |
tree | 658b3a51f9712097e82ec1f46b08e9b39cdfd690 /scene/3d | |
parent | 4b277c2c20438c5aada0d45f1e4228b15249faee (diff) |
Modified RigidBody, PhysicsDirectBodyState, PhysicsServer, and their respective 2D counterparts to be more consistent and to include more useful methods.
RigidBody:
- Added add_central_force
- Added add_force
- Added add_torque
- Added apply_central_impulse
RigidBody2D:
- Added add_central_force
- Added add_torque
- Added apply_central_impulse
- Added apply_torque_impulse
PhysicsDirectBodyState:
- Added apply_central_impulse
Physics2DDirectBodyState:
- Added add_central_force
- Added add_force
- Added add_torque
- Added apply_central_impulse
- Added apply_impulse
- Added apply_torque_impulse
PhysicsServer:
- Added body_add_force
- Added body_add_torque
- Added body_add_central_force
- Added body_apply_central_impulse
Physics2DServer:
- Added body_add_torque
- Added body_add_central_force
- Added body_apply_central_impulse
- Added body_apply_torque_impulse
Also fixed some small bugs along the way
Diffstat (limited to 'scene/3d')
-rw-r--r-- | scene/3d/physics_body.cpp | 22 | ||||
-rw-r--r-- | scene/3d/physics_body.h | 5 |
2 files changed, 27 insertions, 0 deletions
diff --git a/scene/3d/physics_body.cpp b/scene/3d/physics_body.cpp index 7529a0e524..c1b867d114 100644 --- a/scene/3d/physics_body.cpp +++ b/scene/3d/physics_body.cpp @@ -795,6 +795,22 @@ int RigidBody::get_max_contacts_reported() const { return max_contacts_reported; } +void RigidBody::add_central_force(const Vector3 &p_force) { + PhysicsServer::get_singleton()->body_add_central_force(get_rid(), p_force); +} + +void RigidBody::add_force(const Vector3 &p_force, const Vector3 &p_pos) { + PhysicsServer::get_singleton()->body_add_force(get_rid(), p_force, p_pos); +} + +void RigidBody::add_torque(const Vector3 &p_torque) { + PhysicsServer::get_singleton()->body_add_torque(get_rid(), p_torque); +} + +void RigidBody::apply_central_impulse(const Vector3 &p_impulse) { + PhysicsServer::get_singleton()->body_apply_central_impulse(get_rid(), p_impulse); +} + void RigidBody::apply_impulse(const Vector3 &p_pos, const Vector3 &p_impulse) { PhysicsServer::get_singleton()->body_apply_impulse(get_rid(), p_pos, p_impulse); @@ -947,6 +963,12 @@ void RigidBody::_bind_methods() { ClassDB::bind_method(D_METHOD("is_using_continuous_collision_detection"), &RigidBody::is_using_continuous_collision_detection); ClassDB::bind_method(D_METHOD("set_axis_velocity", "axis_velocity"), &RigidBody::set_axis_velocity); + + ClassDB::bind_method(D_METHOD("add_central_force", "force"), &RigidBody::add_central_force); + ClassDB::bind_method(D_METHOD("add_force", "force", "position"), &RigidBody::add_force); + ClassDB::bind_method(D_METHOD("add_torque", "torque"), &RigidBody::add_torque); + + ClassDB::bind_method(D_METHOD("apply_central_impulse", "impulse"), &RigidBody::apply_central_impulse); ClassDB::bind_method(D_METHOD("apply_impulse", "position", "impulse"), &RigidBody::apply_impulse); ClassDB::bind_method(D_METHOD("apply_torque_impulse", "impulse"), &RigidBody::apply_torque_impulse); diff --git a/scene/3d/physics_body.h b/scene/3d/physics_body.h index 44d6502be1..4143989671 100644 --- a/scene/3d/physics_body.h +++ b/scene/3d/physics_body.h @@ -254,6 +254,11 @@ public: Array get_colliding_bodies() const; + void add_central_force(const Vector3 &p_force); + void add_force(const Vector3 &p_force, const Vector3 &p_pos); + void add_torque(const Vector3 &p_torque); + + void apply_central_impulse(const Vector3 &p_impulse); void apply_impulse(const Vector3 &p_pos, const Vector3 &p_impulse); void apply_torque_impulse(const Vector3 &p_impulse); |