22 static std::atomic_flag warned_copy_physical_node = ATOMIC_FLAG_INIT;
40 PandaNode(copy), _physicals(copy._physicals) {
48 for (
Physical *physical : _physicals) {
49 if (physical->_physical_node ==
this) {
50 physical->_physical_node =
nullptr;
51 if (physical->_physics_manager !=
nullptr) {
52 physical->_physics_manager->remove_physical(physical);
63 if (!_physicals.empty() && !warned_copy_physical_node.test_and_set()) {
67 <<
"Detected attempt to copy PhysicalNode object with physicals.\n";
77 size_t num_physicals = _physicals.size();
78 _physicals.insert(_physicals.end(),
79 other._physicals.begin(), other._physicals.end());
81 for (
size_t i = num_physicals; i < _physicals.size(); ++i) {
82 _physicals[i]->_physical_node =
this;
91 nassertv(index < _physicals.size());
93 _physicals[index]->_physical_node =
nullptr;
94 _physicals[index] = physical;
95 physical->_physical_node =
this;
103 if (index > _physicals.size()) {
104 index = _physicals.size();
107 _physicals.insert(_physicals.begin() + index, physical);
108 physical->_physical_node =
this;
118 found = find(_physicals.begin(), _physicals.end(), ptp);
119 if (found == _physicals.end()) {
122 _physicals.erase(found);
124 nassertv(ptp->_physical_node ==
this);
125 ptp->_physical_node =
nullptr;
133 nassertv(index <= _physicals.size());
136 remove = _physicals.begin() + index;
137 (*remove)->_physical_node =
nullptr;
139 _physicals.erase(remove);
148 out.width(
indent); out<<
""; out<<
"PhysicalNode:\n";
A basic node of the scene graph or data graph.
Graph node that encapsulated a series of physical objects.
virtual PandaNode * make_copy() const
dynamic child copy
remove_physical
remove operation
void add_physicals_from(const PhysicalNode &other)
append operation
PhysicalNode(const std::string &name)
default constructor
virtual ~PhysicalNode()
destructor
insert_physical
insert operation
set_physical
replace operation
virtual void write(std::ostream &out, int indent=0) const
Write a string representation of this instance to <out>.
Defines a set of physically modeled attributes.
TypeHandle is the identifier used to differentiate C++ class types.
This is our own Panda specialization on the default STL vector.
std::ostream & indent(std::ostream &out, int indent_level)
A handy function for doing text formatting.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.