From ba27deef06f0152a59c86e3b0ab3ebb0976344ad Mon Sep 17 00:00:00 2001 From: Aaron Franke Date: Thu, 26 Mar 2020 00:23:34 -0400 Subject: Refactor physics force and impulse code --- scene/3d/physics_body_3d.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'scene/3d/physics_body_3d.cpp') diff --git a/scene/3d/physics_body_3d.cpp b/scene/3d/physics_body_3d.cpp index de8f1eea2e..9fc46a62cb 100644 --- a/scene/3d/physics_body_3d.cpp +++ b/scene/3d/physics_body_3d.cpp @@ -638,8 +638,9 @@ void RigidBody3D::add_central_force(const Vector3 &p_force) { PhysicsServer3D::get_singleton()->body_add_central_force(get_rid(), p_force); } -void RigidBody3D::add_force(const Vector3 &p_force, const Vector3 &p_pos) { - PhysicsServer3D::get_singleton()->body_add_force(get_rid(), p_force, p_pos); +void RigidBody3D::add_force(const Vector3 &p_force, const Vector3 &p_position) { + PhysicsServer3D *singleton = PhysicsServer3D::get_singleton(); + singleton->body_add_force(get_rid(), p_force, p_position); } void RigidBody3D::add_torque(const Vector3 &p_torque) { @@ -650,8 +651,9 @@ void RigidBody3D::apply_central_impulse(const Vector3 &p_impulse) { PhysicsServer3D::get_singleton()->body_apply_central_impulse(get_rid(), p_impulse); } -void RigidBody3D::apply_impulse(const Vector3 &p_pos, const Vector3 &p_impulse) { - PhysicsServer3D::get_singleton()->body_apply_impulse(get_rid(), p_pos, p_impulse); +void RigidBody3D::apply_impulse(const Vector3 &p_impulse, const Vector3 &p_position) { + PhysicsServer3D *singleton = PhysicsServer3D::get_singleton(); + singleton->body_apply_impulse(get_rid(), p_impulse, p_position); } void RigidBody3D::apply_torque_impulse(const Vector3 &p_impulse) { @@ -782,11 +784,11 @@ void RigidBody3D::_bind_methods() { ClassDB::bind_method(D_METHOD("set_axis_velocity", "axis_velocity"), &RigidBody3D::set_axis_velocity); ClassDB::bind_method(D_METHOD("add_central_force", "force"), &RigidBody3D::add_central_force); - ClassDB::bind_method(D_METHOD("add_force", "force", "position"), &RigidBody3D::add_force); + ClassDB::bind_method(D_METHOD("add_force", "force", "position"), &RigidBody3D::add_force, Vector3()); ClassDB::bind_method(D_METHOD("add_torque", "torque"), &RigidBody3D::add_torque); ClassDB::bind_method(D_METHOD("apply_central_impulse", "impulse"), &RigidBody3D::apply_central_impulse); - ClassDB::bind_method(D_METHOD("apply_impulse", "position", "impulse"), &RigidBody3D::apply_impulse); + ClassDB::bind_method(D_METHOD("apply_impulse", "impulse", "position"), &RigidBody3D::apply_impulse, Vector3()); ClassDB::bind_method(D_METHOD("apply_torque_impulse", "impulse"), &RigidBody3D::apply_torque_impulse); ClassDB::bind_method(D_METHOD("set_sleeping", "sleeping"), &RigidBody3D::set_sleeping); @@ -1370,8 +1372,8 @@ void PhysicalBone3D::apply_central_impulse(const Vector3 &p_impulse) { PhysicsServer3D::get_singleton()->body_apply_central_impulse(get_rid(), p_impulse); } -void PhysicalBone3D::apply_impulse(const Vector3 &p_pos, const Vector3 &p_impulse) { - PhysicsServer3D::get_singleton()->body_apply_impulse(get_rid(), p_pos, p_impulse); +void PhysicalBone3D::apply_impulse(const Vector3 &p_impulse, const Vector3 &p_position) { + PhysicsServer3D::get_singleton()->body_apply_impulse(get_rid(), p_impulse, p_position); } void PhysicalBone3D::reset_physics_simulation_state() { @@ -2097,7 +2099,7 @@ void PhysicalBone3D::_direct_state_changed(Object *p_state) { void PhysicalBone3D::_bind_methods() { ClassDB::bind_method(D_METHOD("apply_central_impulse", "impulse"), &PhysicalBone3D::apply_central_impulse); - ClassDB::bind_method(D_METHOD("apply_impulse", "position", "impulse"), &PhysicalBone3D::apply_impulse); + ClassDB::bind_method(D_METHOD("apply_impulse", "impulse", "position"), &PhysicalBone3D::apply_impulse, Vector3()); ClassDB::bind_method(D_METHOD("_direct_state_changed"), &PhysicalBone3D::_direct_state_changed); -- cgit v1.2.3