diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2019-11-21 08:53:24 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-21 08:53:24 +0100 |
commit | 5ef5e6a7e4715703820592b4036c9ed3de4f80e3 (patch) | |
tree | 9346b97264e612b4edca105eecf60c77f0c90f78 | |
parent | daefd4f0475283eb1fa097acb1a011f83332329c (diff) | |
parent | 101f1b802b363c73404c6065ef632841399f0688 (diff) |
Merge pull request #32274 from raphael10241024/fix_sync_physics_jitter
fix kinematicBody2D jitters when sync_to_physics is turned on
-rw-r--r-- | scene/2d/collision_object_2d.cpp | 10 | ||||
-rw-r--r-- | scene/2d/collision_object_2d.h | 1 |
2 files changed, 3 insertions, 8 deletions
diff --git a/scene/2d/collision_object_2d.cpp b/scene/2d/collision_object_2d.cpp index 228b67990c..9f79691405 100644 --- a/scene/2d/collision_object_2d.cpp +++ b/scene/2d/collision_object_2d.cpp @@ -46,8 +46,6 @@ void CollisionObject2D::_notification(int p_what) { else Physics2DServer::get_singleton()->body_set_state(rid, Physics2DServer::BODY_STATE_TRANSFORM, global_transform); - last_transform = global_transform; - RID space = get_world_2d()->get_space(); if (area) { Physics2DServer::get_singleton()->area_set_space(rid, space); @@ -73,19 +71,17 @@ void CollisionObject2D::_notification(int p_what) { } break; case NOTIFICATION_TRANSFORM_CHANGED: { - Transform2D global_transform = get_global_transform(); - - if (only_update_transform_changes && global_transform == last_transform) { + if (only_update_transform_changes) { return; } + Transform2D global_transform = get_global_transform(); + if (area) Physics2DServer::get_singleton()->area_set_transform(rid, global_transform); else Physics2DServer::get_singleton()->body_set_state(rid, Physics2DServer::BODY_STATE_TRANSFORM, global_transform); - last_transform = global_transform; - } break; case NOTIFICATION_EXIT_TREE: { diff --git a/scene/2d/collision_object_2d.h b/scene/2d/collision_object_2d.h index 4e7d01c8e6..0a9d33b8a6 100644 --- a/scene/2d/collision_object_2d.h +++ b/scene/2d/collision_object_2d.h @@ -67,7 +67,6 @@ class CollisionObject2D : public Node2D { int total_subshapes; Map<uint32_t, ShapeData> shapes; - Transform2D last_transform; bool only_update_transform_changes; //this is used for sync physics in KinematicBody protected: |