diff options
author | PouleyKetchoupp <pouleyketchoup@gmail.com> | 2021-12-07 18:09:54 -0700 |
---|---|---|
committer | PouleyKetchoupp <pouleyketchoup@gmail.com> | 2021-12-10 15:55:40 -0700 |
commit | 940f3fde5c5f902b6efd0f35fb6c7d23edd1da14 (patch) | |
tree | 1af330b010e4234cfe2694e94d25756c8e4e3734 /servers/physics_server_3d.h | |
parent | e69fa16eb3cd4cf4a591eb4c533b9eff45f79850 (diff) |
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.
Diffstat (limited to 'servers/physics_server_3d.h')
-rw-r--r-- | servers/physics_server_3d.h | 43 |
1 files changed, 29 insertions, 14 deletions
diff --git a/servers/physics_server_3d.h b/servers/physics_server_3d.h index d58dccc41a..13719ba1c5 100644 --- a/servers/physics_server_3d.h +++ b/servers/physics_server_3d.h @@ -65,13 +65,24 @@ public: virtual Vector3 get_velocity_at_local_position(const Vector3 &p_position) const = 0; - virtual void add_central_force(const Vector3 &p_force) = 0; - virtual void add_force(const Vector3 &p_force, const Vector3 &p_position = Vector3()) = 0; - virtual void add_torque(const Vector3 &p_torque) = 0; virtual void apply_central_impulse(const Vector3 &p_impulse) = 0; virtual void apply_impulse(const Vector3 &p_impulse, const Vector3 &p_position = Vector3()) = 0; virtual void apply_torque_impulse(const Vector3 &p_impulse) = 0; + virtual void apply_central_force(const Vector3 &p_force) = 0; + virtual void apply_force(const Vector3 &p_force, const Vector3 &p_position = Vector3()) = 0; + virtual void apply_torque(const Vector3 &p_torque) = 0; + + virtual void add_constant_central_force(const Vector3 &p_force) = 0; + virtual void add_constant_force(const Vector3 &p_force, const Vector3 &p_position = Vector3()) = 0; + virtual void add_constant_torque(const Vector3 &p_torque) = 0; + + virtual void set_constant_force(const Vector3 &p_force) = 0; + virtual Vector3 get_constant_force() const = 0; + + virtual void set_constant_torque(const Vector3 &p_torque) = 0; + virtual Vector3 get_constant_torque() const = 0; + virtual void set_sleep_state(bool p_sleep) = 0; virtual bool is_sleeping() const = 0; @@ -434,20 +445,24 @@ public: virtual void body_set_state(RID p_body, BodyState p_state, const Variant &p_variant) = 0; virtual Variant body_get_state(RID p_body, BodyState p_state) const = 0; - //do something about it - virtual void body_set_applied_force(RID p_body, const Vector3 &p_force) = 0; - virtual Vector3 body_get_applied_force(RID p_body) const = 0; - - virtual void body_set_applied_torque(RID p_body, const Vector3 &p_torque) = 0; - virtual Vector3 body_get_applied_torque(RID p_body) const = 0; - - virtual void body_add_central_force(RID p_body, const Vector3 &p_force) = 0; - virtual void body_add_force(RID p_body, const Vector3 &p_force, const Vector3 &p_position = Vector3()) = 0; - virtual void body_add_torque(RID p_body, const Vector3 &p_torque) = 0; - virtual void body_apply_central_impulse(RID p_body, const Vector3 &p_impulse) = 0; virtual void body_apply_impulse(RID p_body, const Vector3 &p_impulse, const Vector3 &p_position = Vector3()) = 0; virtual void body_apply_torque_impulse(RID p_body, const Vector3 &p_impulse) = 0; + + virtual void body_apply_central_force(RID p_body, const Vector3 &p_force) = 0; + virtual void body_apply_force(RID p_body, const Vector3 &p_force, const Vector3 &p_position = Vector3()) = 0; + virtual void body_apply_torque(RID p_body, const Vector3 &p_torque) = 0; + + virtual void body_add_constant_central_force(RID p_body, const Vector3 &p_force) = 0; + virtual void body_add_constant_force(RID p_body, const Vector3 &p_force, const Vector3 &p_position = Vector3()) = 0; + virtual void body_add_constant_torque(RID p_body, const Vector3 &p_torque) = 0; + + virtual void body_set_constant_force(RID p_body, const Vector3 &p_force) = 0; + virtual Vector3 body_get_constant_force(RID p_body) const = 0; + + virtual void body_set_constant_torque(RID p_body, const Vector3 &p_torque) = 0; + virtual Vector3 body_get_constant_torque(RID p_body) const = 0; + virtual void body_set_axis_velocity(RID p_body, const Vector3 &p_axis_velocity) = 0; enum BodyAxis { |