Panda3D
Loading...
Searching...
No Matches
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
19ConfigVariableDouble LinearIntegrator::_max_linear_dt
20("default_max_linear_dt", 1.0f / 30.0f);
21
22
23/**
24 * constructor
25 */
26LinearIntegrator::
27LinearIntegrator() {
28}
29
30/**
31 * destructor
32 */
36
37/**
38 * parent integration routine, hands off to child virtual.
39 */
41integrate(Physical *physical, LinearForceVector &forces,
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 */
71output(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 */
81write(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}
virtual void write(std::ostream &out, int indent=0) const
Write a string representation of this instance to <out>.
This is a convenience class to specialize ConfigVariable as a floating- point type.
virtual void write(std::ostream &out, int indent=0) const
Write a string representation of this instance to <out>.
virtual void output(std::ostream &out) const
Write a string representation of this instance to <out>.
void integrate(Physical *physical, LinearForceVector &forces, PN_stdfloat dt)
parent integration routine, hands off to child virtual.
virtual ~LinearIntegrator()
destructor
Defines a set of physically modeled attributes.
Definition physical.h:37
A body on which physics will be applied.
get_position
Position Query.
set_last_position
Last position assignment.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.