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() {
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);
}
}
}
}