Panda3D
linearIntegrator.cxx
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file linearIntegrator.cxx
10  * @author charles
11  * @date 2000-08-02
12  */
13 
14 #include "linearIntegrator.h"
15 #include "config_physics.h"
16 #include "physicalNode.h"
17 #include "forceNode.h"
18 
19 ConfigVariableDouble LinearIntegrator::_max_linear_dt
20 ("default_max_linear_dt", 1.0f / 30.0f);
21 
22 
23 /**
24  * constructor
25  */
26 LinearIntegrator::
27 LinearIntegrator() {
28 }
29 
30 /**
31  * destructor
32  */
35 }
36 
37 /**
38  * parent integration routine, hands off to child virtual.
39  */
42  PN_stdfloat dt) {
43 /* <-- darren, 2000.10.06
44  // cap dt so physics don't go flying off on lags
45  if (dt > _max_linear_dt)
46  dt = _max_linear_dt;
47 */
48 
49  PhysicsObject::Vector::const_iterator current_object_iter;
50  current_object_iter = physical->get_object_vector().begin();
51  for (; current_object_iter != physical->get_object_vector().end();
52  ++current_object_iter) {
53  PhysicsObject *current_object = *current_object_iter;
54 
55  // bail out if this object doesn't exist or doesn't want to be processed.
56  if (current_object == nullptr) {
57  continue;
58  }
59 
60  // set the object's last position to its current position before we move
61  // it
62  current_object->set_last_position(current_object->get_position());
63  }
64  child_integrate(physical, forces, dt);
65 }
66 
67 /**
68  * Write a string representation of this instance to <out>.
69  */
71 output(std::ostream &out) const {
72  #ifndef NDEBUG //[
73  out<<"LinearIntegrator";
74  #endif //] NDEBUG
75 }
76 
77 /**
78  * Write a string representation of this instance to <out>.
79  */
81 write(std::ostream &out, int indent) const {
82  #ifndef NDEBUG //[
83  out.width(indent); out<<""; out<<"LinearIntegrator:\n";
84  out.width(indent+2); out<<""; out<<"_max_linear_dt "<<_max_linear_dt<<" (class static)\n";
86  #endif //] NDEBUG
87 }
void integrate(Physical *physical, LinearForceVector &forces, PN_stdfloat dt)
parent integration routine, hands off to child virtual.
A body on which physics will be applied.
Definition: physicsObject.h:27
This is a convenience class to specialize ConfigVariable as a floating- point type.
void set_last_position(const LPoint3 &pos)
Last position assignment.
Definition: physicsObject.I:67
std::ostream & indent(std::ostream &out, int indent_level)
A handy function for doing text formatting.
Definition: indent.cxx:20
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
virtual void output(std::ostream &out) const
Write a string representation of this instance to <out>.
Defines a set of physically modeled attributes.
Definition: physical.h:37
virtual ~LinearIntegrator()
destructor
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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, int indent=0) const
Write a string representation of this instance to <out>.
LPoint3 get_position() const
Position Query.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.