mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-28 07:48:37 -04:00
physics: Prevent adding same Physical to more than one PhysicalNode
Also silently ignore if the same Physical is added to the same PhysicalNode more than once.
This commit is contained in:
parent
52c0e2759e
commit
1c754738bd
@ -42,10 +42,14 @@ get_num_physicals() const {
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
* Adds a Physical to this PhysicalNode. If it is already added to this node,
|
||||
* does nothing. It is an error to add a Physical to multiple PhysicalNodes.
|
||||
*/
|
||||
INLINE void PhysicalNode::
|
||||
add_physical(Physical *physical) {
|
||||
_physicals.push_back(physical);
|
||||
physical->_physical_node = this;
|
||||
if (physical->_physical_node != this) {
|
||||
nassertv(physical->_physical_node == nullptr);
|
||||
_physicals.push_back(physical);
|
||||
physical->_physical_node = this;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user