Panda3D
physxBodyDesc.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 physxBodyDesc.cxx
10  * @author enn0x
11  * @date 2009-09-05
12  */
13 
14 #include "physxBodyDesc.h"
15 
16 /**
17  * Set the mass of body.
18  */
19 void PhysxBodyDesc::
20 set_mass(float mass) {
21 
22  _desc.mass = mass;
23 }
24 
25 /**
26  * Get the mass of body.
27  */
28 float PhysxBodyDesc::
29 get_mass() const {
30 
31  return _desc.mass;
32 }
33 
34 /**
35  * Set the linear damping applied to the body.
36  */
37 void PhysxBodyDesc::
38 set_linear_damping(float damping) {
39 
40  _desc.linearDamping = damping;
41 }
42 
43 /**
44  * Get the linear damping applied to the body.
45  */
46 float PhysxBodyDesc::
48 
49  return _desc.linearDamping;
50 }
51 
52 /**
53  * Set the angular damping applied to the body.
54  */
55 void PhysxBodyDesc::
56 set_angular_damping(float damping) {
57 
58  _desc.angularDamping = damping;
59 }
60 
61 /**
62  * Get the angular damping applied to the body.
63  */
64 float PhysxBodyDesc::
66 
67  return _desc.angularDamping;
68 }
69 
70 /**
71  * Set the linear Velocity of the body.
72  */
73 void PhysxBodyDesc::
74 set_linear_velocity(const LVector3f &velocity) {
75 
76  _desc.linearVelocity = PhysxManager::vec3_to_nxVec3(velocity);
77 }
78 
79 /**
80  * Get the linear Velocity of the body.
81  */
82 LVector3f PhysxBodyDesc::
84 
85  return PhysxManager::nxVec3_to_vec3(_desc.linearVelocity);
86 }
87 
88 /**
89  * Set the angular velocity of the body.
90  */
91 void PhysxBodyDesc::
92 set_angular_velocity(const LVector3f &velocity) {
93 
94  _desc.angularVelocity = PhysxManager::vec3_to_nxVec3(velocity);
95 }
96 
97 /**
98  * Get the angular velocity of the body.
99  */
100 LVector3f PhysxBodyDesc::
102 
103  return PhysxManager::nxVec3_to_vec3(_desc.angularVelocity);
104 }
105 
106 /**
107  * Set the maximum allowed angular velocity for this body.
108  */
109 void PhysxBodyDesc::
110 set_max_angular_velocity(float maximum) {
111 
112  _desc.maxAngularVelocity = maximum;
113 }
114 
115 /**
116  * Get the maximum allowed angular velocity for this body.
117  */
118 float PhysxBodyDesc::
120 
121  return _desc.maxAngularVelocity;
122 }
123 
124 /**
125  * Set the maximum linear velocity at which the body can go to sleep.
126  */
127 void PhysxBodyDesc::
128 set_sleep_linear_velocity(float velocity) {
129 
130  _desc.sleepLinearVelocity = velocity;
131 }
132 
133 /**
134  * Get the maximum linear velocity at which the body can go to sleep.
135  */
136 float PhysxBodyDesc::
138 
139  return _desc.sleepLinearVelocity;
140 }
141 
142 /**
143  * Set the maximum angular velocity at which body can go to sleep.
144  */
145 void PhysxBodyDesc::
146 set_sleep_angular_velocity(float velocity) {
147 
148  _desc.sleepAngularVelocity = velocity;
149 }
150 
151 /**
152  * Get the maximum angular velocity at which body can go to sleep.
153  */
154 float PhysxBodyDesc::
156 
157  return _desc.sleepAngularVelocity;
158 }
159 
160 /**
161  * Set the number of solver iterations performed when processing
162  * joint/contacts connected to this body.
163  */
164 void PhysxBodyDesc::
165 set_solver_iteration_count(unsigned int count) {
166 
167  _desc.solverIterationCount = count;
168 }
169 
170 /**
171  * Get the number of solver iterations performed when processing
172  * joint/contacts connected to this body.
173  */
174 unsigned int PhysxBodyDesc::
176 
177  return _desc.solverIterationCount;
178 }
179 
180 /**
181  * Set the threshold for the energy-based sleeping algorithm. Only used when
182  * the BF_energy_sleep_test flag is set.
183  */
184 void PhysxBodyDesc::
185 set_sleep_energy_threshold(float threshold) {
186 
187  _desc.sleepEnergyThreshold = threshold;
188 }
189 
190 /**
191  * Get the threshold for the energy-based sleeping algorithm. Only used when
192  * the BF_energy_sleep_test flag is set.
193  */
194 float PhysxBodyDesc::
196 
197  return _desc.sleepEnergyThreshold;
198 }
199 
200 /**
201  * Set the damping factor for bodies that are about to sleep.
202  */
203 void PhysxBodyDesc::
204 set_sleep_damping(float damping) {
205 
206  _desc.sleepDamping = damping;
207 }
208 
209 /**
210  * Get the damping factor for bodies that are about to sleep.
211  */
212 float PhysxBodyDesc::
214 
215  return _desc.sleepDamping;
216 }
217 
218 /**
219  * Set the position and orientation of the center of mass.
220  */
221 void PhysxBodyDesc::
222 set_mass_local_mat(const LMatrix4f &mat) {
223 
224  _desc.massLocalPose = PhysxManager::mat4_to_nxMat34(mat);
225 }
226 
227 /**
228  * Get the position and orientation of the center of mass.
229  */
230 LMatrix4f PhysxBodyDesc::
232 
233  return PhysxManager::nxMat34_to_mat4(_desc.massLocalPose);
234 }
235 
236 /**
237  * Set the diagonal mass space inertia tensor in bodies mass frame.
238  */
239 void PhysxBodyDesc::
240 set_mass_space_inertia(const LVector3f &inertia) {
241 
242  _desc.massSpaceInertia = PhysxManager::vec3_to_nxVec3(inertia);
243 }
244 
245 /**
246  * Get the diagonal mass space inertia tensor in bodies mass frame.
247  */
248 LVector3f PhysxBodyDesc::
250 
251  return PhysxManager::nxVec3_to_vec3(_desc.massSpaceInertia);
252 }
253 
254 /**
255  * Raise or lower individual body flags.
256  */
257 void PhysxBodyDesc::
258 set_flag(const PhysxBodyFlag flag, bool value) {
259 
260  if (value == true) {
261  _desc.flags |= flag;
262  }
263  else {
264  _desc.flags &= ~(flag);
265  }
266 }
267 
268 /**
269  * Returns the specified body flag.
270  */
271 bool PhysxBodyDesc::
272 get_flag(const PhysxBodyFlag flag) const {
273 
274  return (_desc.flags & flag) ? true : false;
275 }
276 
277 /**
278  * When CCD is globally enabled, it is still not performed if the motion
279  * distance of all points on the body is below this threshold.
280  */
281 void PhysxBodyDesc::
282 set_ccd_motion_threshold(float threshold) {
283 
284  _desc.CCDMotionThreshold = threshold;
285 }
286 
287 /**
288  *
289  */
290 float PhysxBodyDesc::
291 get_ccd_motion_threshold() const {
292 
293  return _desc.CCDMotionThreshold;
294 }
295 
296 /**
297  * Set the body's initial wake up counter.
298  */
299 void PhysxBodyDesc::
300 set_wake_up_counter(float value) {
301 
302  _desc.wakeUpCounter = value;
303 }
304 
305 /**
306  *
307  */
308 float PhysxBodyDesc::
309 get_wake_up_counter() const {
310 
311  return _desc.wakeUpCounter;
312 }
313 
314 /**
315  * Set The force threshold for contact reports.
316  */
317 void PhysxBodyDesc::
319 
320  _desc.contactReportThreshold = threshold;
321 }
322 
323 /**
324  *
325  */
326 float PhysxBodyDesc::
327 get_contact_report_threshold() const {
328 
329  return _desc.contactReportThreshold;
330 }
void set_wake_up_counter(float value)
Set the body's initial wake up counter.
void set_linear_damping(float damping)
Set the linear damping applied to the body.
void set_mass_local_mat(const LMatrix4f &mat)
Set the position and orientation of the center of mass.
float get_linear_damping() const
Get the linear damping applied to the body.
float get_max_angular_velocity() const
Get the maximum allowed angular velocity for this body.
unsigned int get_solver_iteration_count() const
Get the number of solver iterations performed when processing joint/contacts connected to this body.
void set_contact_report_threshold(float threshold)
Set The force threshold for contact reports.
void set_sleep_energy_threshold(float threshold)
Set the threshold for the energy-based sleeping algorithm.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void set_sleep_angular_velocity(float velocity)
Set the maximum angular velocity at which body can go to sleep.
static NxMat34 mat4_to_nxMat34(const LMatrix4f &m)
Converts from LMatrix4f to NxMat34.
Definition: physxManager.I:119
float get_sleep_energy_threshold() const
Get the threshold for the energy-based sleeping algorithm.
bool get_flag(PhysxBodyFlag flag) const
Returns the specified body flag.
void set_solver_iteration_count(unsigned int count)
Set the number of solver iterations performed when processing joint/contacts connected to this body.
void set_max_angular_velocity(float maximum)
Set the maximum allowed angular velocity for this body.
void set_linear_velocity(const LVector3f &velocity)
Set the linear Velocity of the body.
static NxVec3 vec3_to_nxVec3(const LVector3f &v)
Converts from LVector3f to NxVec3.
Definition: physxManager.I:27
static LVector3f nxVec3_to_vec3(const NxVec3 &v)
Converts from NxVec3 to LVector3f.
Definition: physxManager.I:36
float get_sleep_linear_velocity() const
Get the maximum linear velocity at which the body can go to sleep.
void set_mass_space_inertia(const LVector3f &inertia)
Set the diagonal mass space inertia tensor in bodies mass frame.
void set_sleep_linear_velocity(float velocity)
Set the maximum linear velocity at which the body can go to sleep.
float get_angular_damping() const
Get the angular damping applied to the body.
void set_ccd_motion_threshold(float threshold)
When CCD is globally enabled, it is still not performed if the motion distance of all points on the b...
LMatrix4f get_mass_local_mat() const
Get the position and orientation of the center of mass.
void set_mass(float mass)
Set the mass of body.
float get_sleep_damping() const
Get the damping factor for bodies that are about to sleep.
void set_angular_damping(float damping)
Set the angular damping applied to the body.
void set_angular_velocity(const LVector3f &velocity)
Set the angular velocity of the body.
LVector3f get_angular_velocity() const
Get the angular velocity of the body.
void set_sleep_damping(float damping)
Set the damping factor for bodies that are about to sleep.
LVector3f get_linear_velocity() const
Get the linear Velocity of the body.
static LMatrix4f nxMat34_to_mat4(const NxMat34 &m)
Converts from NxMat34 to LMatrix4f.
Definition: physxManager.I:130
LVector3f get_mass_space_inertia() const
Get the diagonal mass space inertia tensor in bodies mass frame.
void set_flag(PhysxBodyFlag flag, bool value)
Raise or lower individual body flags.
float get_mass() const
Get the mass of body.
float get_sleep_angular_velocity() const
Get the maximum angular velocity at which body can go to sleep.