mirror of
https://github.com/godotengine/godot.git
synced 2025-12-08 06:09:55 +00:00
Fix 2D center of mass not updated from transform
Same logic as what was done in 3D, applied to 2D center of mass. Also did some minor cleanup in 3D and fixed center of mass transform during the first frame after teleporting a dynamic body.
This commit is contained in:
parent
a4fbb67902
commit
c1577e5a3f
4 changed files with 26 additions and 12 deletions
|
|
@ -66,6 +66,7 @@ class GodotBody2D : public GodotCollisionObject2D {
|
|||
real_t inertia = 0.0;
|
||||
real_t _inv_inertia = 0.0;
|
||||
|
||||
Vector2 center_of_mass_local;
|
||||
Vector2 center_of_mass;
|
||||
|
||||
bool calculate_inertia = true;
|
||||
|
|
@ -139,7 +140,9 @@ class GodotBody2D : public GodotCollisionObject2D {
|
|||
|
||||
uint64_t island_step = 0;
|
||||
|
||||
_FORCE_INLINE_ void _compute_area_gravity_and_damping(const GodotArea2D *p_area);
|
||||
void _compute_area_gravity_and_damping(const GodotArea2D *p_area);
|
||||
|
||||
void _update_transform_dependent();
|
||||
|
||||
friend class GodotPhysicsDirectBodyState2D; // i give up, too many functions to expose
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue