37 _physics_manager(nullptr),
38 _physical_node(nullptr) {
40 if (total_objects == 1) {
46 if (pre_alloc ==
true) {
47 for (
int i = 0; i < total_objects; ++i) {
61 _physics_manager(nullptr),
62 _physical_node(nullptr) {
65 LinearForceVector::const_iterator lf_cur;
66 LinearForceVector::const_iterator lf_end = copy._linear_forces.end();
68 for (lf_cur = copy._linear_forces.begin(); lf_cur != lf_end; lf_cur++) {
69 _linear_forces.push_back((*lf_cur)->make_copy());
72 AngularForceVector::const_iterator af_cur;
73 AngularForceVector::const_iterator af_end = copy._angular_forces.end();
75 for (af_cur = copy._angular_forces.begin(); af_cur != af_end; af_cur++) {
76 _angular_forces.push_back((*af_cur)->make_copy());
80 PhysicsObject::Vector::const_iterator p_cur;
81 PhysicsObject::Vector::const_iterator p_end = copy._physics_objects.end();
83 for (p_cur = copy._physics_objects.begin(); p_cur != p_end; p_cur++) {
85 _physics_objects.push_back((*p_cur)->make_copy());
89 if (_physics_objects.size() == 1)
90 _phys_body = _physics_objects[0];
104 if (_physics_manager !=
nullptr) {
116 for (PhysicsObject::Vector::const_iterator i=_physics_objects.begin();
117 i != _physics_objects.end();
142 out<<
""<<
"_physics_objects ("<<_physics_objects.size()<<
" objects)\n";
143 for (PhysicsObject::Vector::const_iterator i=_physics_objects.begin();
144 i != _physics_objects.end();
146 (*i)->write(out,
indent+2);
158 out<<
""<<
"_linear_forces ("<<_linear_forces.size()<<
" forces)\n";
159 for (LinearForceVector::const_iterator i=_linear_forces.begin();
160 i != _linear_forces.end();
162 (*i)->write(out,
indent+2);
174 out<<
""<<
"_angular_forces ("<<_angular_forces.size()<<
" forces)\n";
175 for (AngularForceVector::const_iterator i=_angular_forces.begin();
176 i != _angular_forces.end();
178 (*i)->write(out,
indent+2);
189 out.width(
indent); out<<
""<<
"Physical\n";
194 out.width(
indent+2); out<<
""<<
"_phys_body\n";
197 out.width(
indent+2); out<<
""<<
"_phys_body is null\n";
virtual void write_linear_forces(std::ostream &out=std::cout, int indent=0) const
Write a string representation of this instance to <out>.
void remove_physical(Physical *p)
takes a physical out of the object list
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A body on which physics will be applied.
This is a set of zero or more PhysicsObjects.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
virtual void write_angular_forces(std::ostream &out=std::cout, int indent=0) const
Write a string representation of this instance to <out>.
std::ostream & indent(std::ostream &out, int indent_level)
A handy function for doing text formatting.
virtual ~Physical()
destructor
Defines a set of physically modeled attributes.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Physical(int total_objects=1, bool pre_alloc=false)
Default Constructor The idea here is that most physicals will NOT be collections of sets (i....
virtual void write(std::ostream &out, int indent=0) const
Write a string representation of this instance to <out>.
virtual void write(std::ostream &out=std::cout, int indent=0) const
Write a string representation of this instance to <out>.
void add_physics_object(PT(PhysicsObject) physics_object)
Adds a new PhysicsObject to the collection.
void add_physics_object(PhysicsObject *po)
Adds an object to the physics object vector.
TypeHandle is the identifier used to differentiate C++ class types.
virtual void write_physics_objects(std::ostream &out=std::cout, int indent=0) const
Write a string representation of this instance to <out>.
virtual void output(std::ostream &out=std::cout) const
Write a string representation of this instance to <out>.