15 #include "baseIntegrator.h"
16 #include "physicalNode.h"
17 #include "forceNode.h"
47 precompute_linear_matrices(
Physical *physical,
48 const LinearForceVector &forces) {
51 PhysicalNode *physical_node = physical->get_physical_node();
52 nassertv(physical_node);
55 int global_force_vec_size = forces.size();
58 int local_force_vec_size = physical->get_linear_forces().size();
63 _precomputed_linear_matrices.clear();
64 _precomputed_linear_matrices.reserve(
65 global_force_vec_size + local_force_vec_size);
67 NodePath physical_np(physical->get_physical_node_path());
71 LinearForceVector::const_iterator fi;
72 for (fi = forces.begin(); fi != forces.end(); ++fi) {
74 force_node = (*fi)->get_force_node();
75 nassertv(force_node != (
ForceNode *) NULL);
77 NodePath force_np = (*fi)->get_force_node_path();
78 _precomputed_linear_matrices.push_back(
83 const LinearForceVector &force_vector = physical->get_linear_forces();
84 for (fi = force_vector.begin(); fi != force_vector.end(); ++fi) {
85 force_node = (*fi)->get_force_node();
86 nassertv(force_node != (
ForceNode *) NULL);
88 NodePath force_np = (*fi)->get_force_node_path();
89 _precomputed_linear_matrices.push_back(
102 void BaseIntegrator::
103 precompute_angular_matrices(
Physical *physical,
104 const AngularForceVector &forces) {
107 PhysicalNode *physical_node = physical->get_physical_node();
108 nassertv(physical_node != NULL);
111 int global_force_vec_size = forces.size();
114 int local_force_vec_size = physical->get_angular_forces().size();
119 _precomputed_angular_matrices.clear();
120 _precomputed_angular_matrices.reserve(
121 global_force_vec_size + local_force_vec_size);
123 NodePath physical_np(physical->get_physical_node_path());
127 AngularForceVector::const_iterator fi;
128 for (fi = forces.begin(); fi != forces.end(); ++fi) {
129 force_node = (*fi)->get_force_node();
130 nassertv(force_node != (
ForceNode *) NULL);
132 NodePath force_np = (*fi)->get_force_node_path();
133 _precomputed_angular_matrices.push_back(
138 const AngularForceVector &force_vector = physical->get_angular_forces();
139 for (fi = force_vector.begin(); fi != force_vector.end(); ++fi) {
140 force_node = (*fi)->get_force_node();
141 nassertv(force_node != (
ForceNode *) NULL);
143 NodePath force_np = (*fi)->get_force_node_path();
144 _precomputed_angular_matrices.push_back(
158 out<<
"BaseIntegrator (id "<<
this<<
")";
172 out<<
""<<
"_precomputed_linear_matrices\n";
173 for (MatrixVector::const_iterator i=_precomputed_linear_matrices.begin();
174 i != _precomputed_linear_matrices.end();
176 out.width(indent+2); out<<
""; (*i).output(out); out<<
"\n";
191 out<<
""<<
"_precomputed_angular_matrices\n";
192 for (MatrixVector::const_iterator i=_precomputed_angular_matrices.begin();
193 i != _precomputed_angular_matrices.end();
195 out.width(indent+2); out<<
""; (*i).output(out); out<<
"\n";
207 write(ostream &out,
unsigned int indent)
const {
209 out.width(indent); out<<
""; out<<
"BaseIntegrator:\n";
NodePath get_parent(Thread *current_thread=Thread::get_current_thread()) const
Returns the NodePath to the parent of the referenced node: that is, this NodePath, shortened by one node.
A force that lives in the scene graph and is therefore subject to local coordinate systems...
const TransformState * get_transform(Thread *current_thread=Thread::get_current_thread()) const
Returns the complete transform object set on this node.
Graph node that encapsulated a series of physical objects.
virtual void output(ostream &out) const
Write a string representation of this instance to <out>.
virtual void write_precomputed_angular_matrices(ostream &out, unsigned int indent=0) const
Write a string representation of this instance to <out>.
virtual void write_precomputed_linear_matrices(ostream &out, unsigned int indent=0) const
Write a string representation of this instance to <out>.
Defines a set of physically modeled attributes.
virtual ~BaseIntegrator()
destructor
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
virtual void write(ostream &out, unsigned int indent=0) const
Write a string representation of this instance to <out>.