From 74910ff310dc3d769151336fd642d1f3c17622a8 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 21 Mar 2021 14:36:14 +0100 Subject: [PATCH] physics: Don't assert destructing This could have been produced with make_copy(), which can create a situation where the Physical objects don't have the same node associated -- see b6a118448dce974d25c1d5ae4043baa6dfe12db0 --- panda/src/physics/physicalNode.cxx | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/panda/src/physics/physicalNode.cxx b/panda/src/physics/physicalNode.cxx index 1fcd1ce903..bda2dd9140 100644 --- a/panda/src/physics/physicalNode.cxx +++ b/panda/src/physics/physicalNode.cxx @@ -43,13 +43,12 @@ PhysicalNode(const PhysicalNode ©) : */ PhysicalNode:: ~PhysicalNode() { - PhysicalsVector::iterator it; - for (it = _physicals.begin(); it != _physicals.end(); ++it) { - Physical *physical = *it; - nassertd(physical->_physical_node == this) continue; - physical->_physical_node = nullptr; - if (physical->_physics_manager != nullptr) { - physical->_physics_manager->remove_physical(physical); + for (Physical *physical : _physicals) { + if (physical->_physical_node == this) { + physical->_physical_node = nullptr; + if (physical->_physics_manager != nullptr) { + physical->_physics_manager->remove_physical(physical); + } } } }