Skip to content

Commit

Permalink
Fix removing transform from an entity permanently breaking its physics
Browse files Browse the repository at this point in the history
  • Loading branch information
GinjaNinja32 committed Aug 29, 2024
1 parent 86f1257 commit cf81829
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/systems/collision.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,12 @@ void CollisionSystem::update(float delta)
if (!*entity_ptr || !(physics = entity_ptr->getComponent<Physics>()) || !(transform = entity_ptr->getComponent<Transform>())) {
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());
Expand Down

0 comments on commit cf81829

Please sign in to comment.