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,16 +43,15 @@ 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;
nassertd(physical->_physical_node == this) continue;
physical->_physical_node = nullptr; physical->_physical_node = nullptr;
if (physical->_physics_manager != nullptr) { if (physical->_physics_manager != nullptr) {
physical->_physics_manager->remove_physical(physical); physical->_physics_manager->remove_physical(physical);
} }
} }
} }
}
/** /**
* dynamic child copy * dynamic child copy