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
This commit is contained in:
rdb 2021-03-21 14:36:14 +01:00
parent b6a118448d
commit 74910ff310

View File

@ -43,13 +43,12 @@ PhysicalNode(const PhysicalNode &copy) :
*/ */
PhysicalNode:: PhysicalNode::
~PhysicalNode() { ~PhysicalNode() {
PhysicalsVector::iterator it; for (Physical *physical : _physicals) {
for (it = _physicals.begin(); it != _physicals.end(); ++it) { if (physical->_physical_node == this) {
Physical *physical = *it; physical->_physical_node = nullptr;
nassertd(physical->_physical_node == this) continue; if (physical->_physics_manager != nullptr) {
physical->_physical_node = nullptr; physical->_physics_manager->remove_physical(physical);
if (physical->_physics_manager != nullptr) { }
physical->_physics_manager->remove_physical(physical);
} }
} }
} }