From cf81829f94becb236a99e0644421de1171314e90 Mon Sep 17 00:00:00 2001 From: GinjaNinja32 Date: Thu, 29 Aug 2024 20:04:09 +0100 Subject: [PATCH] Fix removing transform from an entity permanently breaking its physics --- src/systems/collision.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/systems/collision.cpp b/src/systems/collision.cpp index ee69d13..952563e 100644 --- a/src/systems/collision.cpp +++ b/src/systems/collision.cpp @@ -120,6 +120,12 @@ void CollisionSystem::update(float delta) if (!*entity_ptr || !(physics = entity_ptr->getComponent()) || !(transform = entity_ptr->getComponent())) { delete entity_ptr; remove_list.push_back(body); + if (physics) { + // if we have a physics component (thus only missing transform), set it so + // that we'll recreate the body if the entity gets a transform again later + physics->physics_dirty = true; + physics->body = nullptr; + } } else { transform->position = b2v(body->GetPosition()); transform->rotation = glm::degrees(body->GetAngle());