Panda3D

Loading...
Searching...
No Matches
physical.I
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 physical.I
10 * @author charles
11 * @date 2000-06-16
12 */
13
14#include <algorithm>
15
16/**
17 * Erases the linear force list
18 */
19INLINE void Physical::
20 clear_linear_forces() {
21 _linear_forces.erase(_linear_forces.begin(),
22 _linear_forces.end());
23}
24
25/**
26 * Erases the angular force list
27 */
28INLINE void Physical::
29 clear_angular_forces() {
30 _angular_forces.erase(_angular_forces.begin(),
31 _angular_forces.end());
32}
33
34/**
35 * Erases the object list
36 */
37INLINE void Physical::
38 clear_physics_objects() {
39 _physics_objects.erase(_physics_objects.begin(),
40 _physics_objects.end());
41}
42
43/**
44 * Adds a linear force to the force list
45 */
46INLINE void Physical::
47 add_linear_force(LinearForce *f) {
48 _linear_forces.push_back(f);
49}
50
51/**
52 * Adds an angular force to the force list
53 */
54INLINE void Physical::
55 add_angular_force(AngularForce *f) {
56 _angular_forces.push_back(f);
57}
58
59/**
60 * removes a linear force from the force list
61 */
62INLINE void Physical::
63 remove_linear_force(LinearForce *f) {
64 LinearForceVector::iterator found;
65
66 // this is a PT because the templates don't like what should be perfectly
67 // allowable, which is to search for bf directly.
68 PT(LinearForce) pt_lf = f;
69 found = find(_linear_forces.begin(), _linear_forces.end(), pt_lf);
70
71 if (found == _linear_forces.end())
72 return;
73
74 _linear_forces.erase(found);
75}
76
77/**
78 * removes an angular force from the force list
79 */
80INLINE void Physical::
81 remove_angular_force(AngularForce *f) {
82 AngularForceVector::iterator found;
83
84 PT(AngularForce) pt_af = f;
85 found = find(_angular_forces.begin(), _angular_forces.end(), pt_af);
86
87 if (found == _angular_forces.end())
88 return;
89
90 _angular_forces.erase(found);
91}
92
93/**
94 * Adds an object to the physics object vector
95 */
96INLINE void Physical::
97 add_physics_object(PhysicsObject *po) {
98 _physics_objects.push_back(po);
99}
100
101/**
102
103 */
104INLINE PhysicsManager *Physical::
105get_physics_manager() const {
106 return _physics_manager;
107}
108
109/**
110
111 */
112INLINE PhysicsObject *Physical::
113get_phys_body() const {
114 return _phys_body;
115}
116
117/**
118
119 */
120INLINE PhysicalNode *Physical::
121get_physical_node() const {
122 return _physical_node;
123}
124
125/**
126
127 */
128INLINE NodePath Physical::
129get_physical_node_path() const {
130 return NodePath((PandaNode*) _physical_node);
131}
132
133/**
134
135 */
136INLINE const PhysicsObject::Vector &Physical::
137get_object_vector() const {
138 return _physics_objects;
139}
140
141/**
142
143 */
144INLINE const Physical::LinearForceVector &Physical::
145get_linear_forces() const {
146 return _linear_forces;
147}
148
149/**
150
151 */
152INLINE const Physical::AngularForceVector &Physical::
153get_angular_forces() const {
154 return _angular_forces;
155}
156
157/**
158
159 */
160INLINE int Physical::
161get_num_linear_forces() const {
162 return _linear_forces.size();
163}
164
165/**
166
167 */
168INLINE PT(LinearForce) Physical::
169get_linear_force(int index) const {
170 nassertr(index >= 0 && index < (int)_linear_forces.size(), nullptr);
171 return _linear_forces[index];
172}
173
174/**
175
176 */
177INLINE int Physical::
178get_num_angular_forces() const {
179 return _angular_forces.size();
180}
181
182/**
183
184 */
185INLINE PT(AngularForce) Physical::
186get_angular_force(int index) const {
187 nassertr(index >= 0 && index < (int)_angular_forces.size(), nullptr);
188 return _angular_forces[index];
189}
190
191/**
192 * Set the local viscosity.
193 */
194INLINE void Physical::
195set_viscosity(PN_stdfloat viscosity) {
196 _viscosity=viscosity;
197}
198
199/**
200 * Get the local viscosity.
201 */
202INLINE PN_stdfloat Physical::
203 get_viscosity() const {
204 // zzzzzzzzzzzzzzzz return max(_viscosity,
205 // get_physics_manager()->get_viscosity());
206 return _viscosity;
207}
AngularForce
pure virtual parent of all quat-based forces.
Definition angularForce.h:22
LinearForce
A force that acts on a PhysicsObject by way of an Integrator.
Definition linearForce.h:23
NodePath
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
Definition nodePath.h:159
PhysicalNode
Graph node that encapsulated a series of physical objects.
Definition physicalNode.h:28
Physical::clear_physics_objects
void clear_physics_objects()
Erases the object list.
Definition physical.I:38
Physical::get_viscosity
get_viscosity
Get the local viscosity.
Definition physical.h:75
Physical::clear_angular_forces
void clear_angular_forces()
Erases the angular force list.
Definition physical.I:29
Physical::add_linear_force
void add_linear_force(LinearForce *f)
Adds a linear force to the force list.
Definition physical.I:47
Physical::add_angular_force
void add_angular_force(AngularForce *f)
Adds an angular force to the force list.
Definition physical.I:55
Physical::clear_linear_forces
void clear_linear_forces()
Erases the linear force list.
Definition physical.I:20
Physical::add_physics_object
void add_physics_object(PhysicsObject *po)
Adds an object to the physics object vector.
Definition physical.I:97
Physical::remove_angular_force
void remove_angular_force(AngularForce *f)
removes an angular force from the force list
Definition physical.I:81
Physical::remove_linear_force
void remove_linear_force(LinearForce *f)
removes a linear force from the force list
Definition physical.I:63
PhysicsManager
Physics don't get much higher-level than this.
Definition physicsManager.h:36
PhysicsObject
A body on which physics will be applied.
Definition physicsObject.h:27