From 940f3fde5c5f902b6efd0f35fb6c7d23edd1da14 Mon Sep 17 00:00:00 2001 From: PouleyKetchoupp Date: Tue, 7 Dec 2021 18:09:54 -0700 Subject: Improve RigidDynamicBody force and torque API Makes the API for forces and impulses more flexible, easier to understand and harmonized between 2D and 3D. Rigid bodies now have 3 sets of methods for forces and impulses: -apply_impulse() for impulses (one-shot and time independent) -apply_force() for forces (time dependent) applied for the current step -add_constant_force() for forces that keeps being applied each step Also updated the documentation to clarify the different methods and parameters in rigid body nodes, body direct state and physics servers. --- scene/3d/physics_body_3d.h | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'scene/3d/physics_body_3d.h') diff --git a/scene/3d/physics_body_3d.h b/scene/3d/physics_body_3d.h index 2ea796d335..beed8a6b36 100644 --- a/scene/3d/physics_body_3d.h +++ b/scene/3d/physics_body_3d.h @@ -306,14 +306,24 @@ public: Array get_colliding_bodies() const; - void add_central_force(const Vector3 &p_force); - void add_force(const Vector3 &p_force, const Vector3 &p_position = Vector3()); - void add_torque(const Vector3 &p_torque); - void apply_central_impulse(const Vector3 &p_impulse); void apply_impulse(const Vector3 &p_impulse, const Vector3 &p_position = Vector3()); void apply_torque_impulse(const Vector3 &p_impulse); + void apply_central_force(const Vector3 &p_force); + void apply_force(const Vector3 &p_force, const Vector3 &p_position = Vector3()); + void apply_torque(const Vector3 &p_torque); + + void add_constant_central_force(const Vector3 &p_force); + void add_constant_force(const Vector3 &p_force, const Vector3 &p_position = Vector3()); + void add_constant_torque(const Vector3 &p_torque); + + void set_constant_force(const Vector3 &p_force); + Vector3 get_constant_force() const; + + void set_constant_torque(const Vector3 &p_torque); + Vector3 get_constant_torque() const; + virtual TypedArray get_configuration_warnings() const override; RigidDynamicBody3D(); -- cgit v1.2.3