diff options
author | Camille Mohr-Daurat <pouleyKetchoup@gmail.com> | 2021-11-08 18:44:51 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-08 18:44:51 -0700 |
commit | c6062cd93e2a7caaf2aa988863cc5535934c5d7c (patch) | |
tree | 29a382eee91ede7360e4f29da82f5f45f2f7d0f2 /servers/physics_2d | |
parent | 59686536622473e14b253268354ecfbae63d0d58 (diff) | |
parent | fc8c766ef93454e43a5a31fd7fb0a0b07946e32b (diff) |
Merge pull request #54134 from nekomatata/body-center-of-mass-local
Expose local center of mass in physics servers
Diffstat (limited to 'servers/physics_2d')
-rw-r--r-- | servers/physics_2d/godot_body_2d.cpp | 2 | ||||
-rw-r--r-- | servers/physics_2d/godot_body_2d.h | 1 | ||||
-rw-r--r-- | servers/physics_2d/godot_body_direct_state_2d.cpp | 4 | ||||
-rw-r--r-- | servers/physics_2d/godot_body_direct_state_2d.h | 1 |
4 files changed, 7 insertions, 1 deletions
diff --git a/servers/physics_2d/godot_body_2d.cpp b/servers/physics_2d/godot_body_2d.cpp index 109914d585..442c580920 100644 --- a/servers/physics_2d/godot_body_2d.cpp +++ b/servers/physics_2d/godot_body_2d.cpp @@ -221,7 +221,7 @@ Variant GodotBody2D::get_param(PhysicsServer2D::BodyParameter p_param) const { return inertia; } case PhysicsServer2D::BODY_PARAM_CENTER_OF_MASS: { - return center_of_mass; + return center_of_mass_local; } case PhysicsServer2D::BODY_PARAM_GRAVITY_SCALE: { return gravity_scale; diff --git a/servers/physics_2d/godot_body_2d.h b/servers/physics_2d/godot_body_2d.h index 817d5f1b0d..7b11b50739 100644 --- a/servers/physics_2d/godot_body_2d.h +++ b/servers/physics_2d/godot_body_2d.h @@ -282,6 +282,7 @@ public: void reset_mass_properties(); _FORCE_INLINE_ const Vector2 &get_center_of_mass() const { return center_of_mass; } + _FORCE_INLINE_ const Vector2 &get_center_of_mass_local() const { return center_of_mass_local; } _FORCE_INLINE_ real_t get_inv_mass() const { return _inv_mass; } _FORCE_INLINE_ real_t get_inv_inertia() const { return _inv_inertia; } _FORCE_INLINE_ real_t get_friction() const { return friction; } diff --git a/servers/physics_2d/godot_body_direct_state_2d.cpp b/servers/physics_2d/godot_body_direct_state_2d.cpp index deebc57f37..9c9bd56268 100644 --- a/servers/physics_2d/godot_body_direct_state_2d.cpp +++ b/servers/physics_2d/godot_body_direct_state_2d.cpp @@ -50,6 +50,10 @@ Vector2 GodotPhysicsDirectBodyState2D::get_center_of_mass() const { return body->get_center_of_mass(); } +Vector2 GodotPhysicsDirectBodyState2D::get_center_of_mass_local() const { + return body->get_center_of_mass_local(); +} + real_t GodotPhysicsDirectBodyState2D::get_inverse_mass() const { return body->get_inv_mass(); } diff --git a/servers/physics_2d/godot_body_direct_state_2d.h b/servers/physics_2d/godot_body_direct_state_2d.h index 2f3e8e5095..ff25205d52 100644 --- a/servers/physics_2d/godot_body_direct_state_2d.h +++ b/servers/physics_2d/godot_body_direct_state_2d.h @@ -46,6 +46,7 @@ public: virtual real_t get_total_linear_damp() const override; virtual Vector2 get_center_of_mass() const override; + virtual Vector2 get_center_of_mass_local() const override; virtual real_t get_inverse_mass() const override; virtual real_t get_inverse_inertia() const override; |