physics: Fix crash in PhysicsNode::add_physicals_from()

This commit is contained in:
rdb 2021-03-21 14:39:31 +01:00
parent 74910ff310
commit f1782d73e5

View File

@ -72,13 +72,12 @@ make_copy() const {
*/ */
void PhysicalNode:: void PhysicalNode::
add_physicals_from(const PhysicalNode &other) { add_physicals_from(const PhysicalNode &other) {
pvector< PT(Physical) >::iterator last = _physicals.end() - 1; size_t num_physicals = _physicals.size();
_physicals.insert(_physicals.end(), _physicals.insert(_physicals.end(),
other._physicals.begin(), other._physicals.end()); other._physicals.begin(), other._physicals.end());
for (; last != _physicals.end(); last++) { for (size_t i = num_physicals; i < _physicals.size(); ++i) {
(*last)->_physical_node = this; _physicals[i]->_physical_node = this;
} }
} }