Panda3D
Loading...
Searching...
No Matches
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 */
20set_mass(float mass) {
21
22 _desc.mass = mass;
23}
24
25/**
26 * Get the mass of body.
27 */
29get_mass() const {
30
31 return _desc.mass;
32}
33
34/**
35 * Set the linear damping applied to the body.
36 */
38set_linear_damping(float damping) {
39
40 _desc.linearDamping = damping;
41}
42
43/**
44 * Get the linear damping applied to the body.
45 */
47get_linear_damping() const {
48
49 return _desc.linearDamping;
50}
51
52/**
53 * Set the angular damping applied to the body.
54 */
56set_angular_damping(float damping) {
57
58 _desc.angularDamping = damping;
59}
60
61/**
62 * Get the angular damping applied to the body.
63 */
65get_angular_damping() const {
66
67 return _desc.angularDamping;
68}
69
70/**
71 * Set the linear Velocity of the body.
72 */
74set_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 */
83get_linear_velocity() const {
84
85 return PhysxManager::nxVec3_to_vec3(_desc.linearVelocity);
86}
87
88/**
89 * Set the angular velocity of the body.
90 */
92set_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 */
101get_angular_velocity() const {
102
103 return PhysxManager::nxVec3_to_vec3(_desc.angularVelocity);
104}
105
106/**
107 * Set the maximum allowed angular velocity for this body.
108 */
110set_max_angular_velocity(float maximum) {
111
112 _desc.maxAngularVelocity = maximum;
113}
114
115/**
116 * Get the maximum allowed angular velocity for this body.
117 */
120
121 return _desc.maxAngularVelocity;
122}
123
124/**
125 * Set the maximum linear velocity at which the body can go to sleep.
126 */
128set_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 */
138
139 return _desc.sleepLinearVelocity;
140}
141
142/**
143 * Set the maximum angular velocity at which body can go to sleep.
144 */
146set_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 */
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 */
165set_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 */
174unsigned 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 */
185set_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 */
196
197 return _desc.sleepEnergyThreshold;
198}
199
200/**
201 * Set the damping factor for bodies that are about to sleep.
202 */
204set_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 */
213get_sleep_damping() const {
214
215 return _desc.sleepDamping;
216}
217
218/**
219 * Set the position and orientation of the center of mass.
220 */
222set_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 */
231get_mass_local_mat() const {
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 */
240set_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 */
250
251 return PhysxManager::nxVec3_to_vec3(_desc.massSpaceInertia);
252}
253
254/**
255 * Raise or lower individual body flags.
256 */
258set_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 */
272get_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 */
282set_ccd_motion_threshold(float threshold) {
283
284 _desc.CCDMotionThreshold = threshold;
285}
286
287/**
288 *
289 */
290float PhysxBodyDesc::
291get_ccd_motion_threshold() const {
292
293 return _desc.CCDMotionThreshold;
294}
295
296/**
297 * Set the body's initial wake up counter.
298 */
300set_wake_up_counter(float value) {
301
302 _desc.wakeUpCounter = value;
303}
304
305/**
306 *
307 */
308float PhysxBodyDesc::
309get_wake_up_counter() const {
310
311 return _desc.wakeUpCounter;
312}
313
314/**
315 * Set The force threshold for contact reports.
316 */
318set_contact_report_threshold(float threshold) {
319
320 _desc.contactReportThreshold = threshold;
321}
322
323/**
324 *
325 */
326float PhysxBodyDesc::
327get_contact_report_threshold() const {
328
329 return _desc.contactReportThreshold;
330}
float get_mass() const
Get the mass of body.
float get_max_angular_velocity() const
Get the maximum allowed angular velocity for this body.
float get_angular_damping() const
Get the angular damping applied to the body.
LVector3f get_angular_velocity() const
Get the angular velocity of the body.
float get_sleep_energy_threshold() const
Get the threshold for the energy-based sleeping algorithm.
void set_angular_velocity(const LVector3f &velocity)
Set the angular velocity of the 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_mass_space_inertia(const LVector3f &inertia)
Set the diagonal mass space inertia tensor in bodies mass frame.
void set_sleep_angular_velocity(float velocity)
Set the maximum angular velocity at which body can go to sleep.
void set_sleep_energy_threshold(float threshold)
Set the threshold for the energy-based sleeping algorithm.
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_sleep_damping(float damping)
Set the damping factor for bodies that are about to sleep.
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_linear_velocity(const LVector3f &velocity)
Set the linear Velocity of the body.
void set_angular_damping(float damping)
Set the angular damping applied to the body.
void set_flag(PhysxBodyFlag flag, bool value)
Raise or lower individual body flags.
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...
LVector3f get_linear_velocity() const
Get the linear Velocity of the body.
void set_mass(float mass)
Set the mass of body.
float get_linear_damping() const
Get the linear damping applied to the body.
bool get_flag(PhysxBodyFlag flag) const
Returns the specified body flag.
void set_mass_local_mat(const LMatrix4f &mat)
Set the position and orientation of the center of mass.
void set_sleep_linear_velocity(float velocity)
Set the maximum linear velocity at which the body can go to sleep.
void set_contact_report_threshold(float threshold)
Set The force threshold for contact reports.
LMatrix4f get_mass_local_mat() const
Get the position and orientation of the center of mass.
float get_sleep_damping() const
Get the damping factor for bodies that are about to sleep.
void set_max_angular_velocity(float maximum)
Set the maximum allowed angular velocity for this body.
LVector3f get_mass_space_inertia() const
Get the diagonal mass space inertia tensor in bodies mass frame.
float get_sleep_angular_velocity() const
Get the maximum angular velocity at which body can go to sleep.
float get_sleep_linear_velocity() const
Get the maximum linear velocity at which the body can go to sleep.
static NxVec3 vec3_to_nxVec3(const LVector3f &v)
Converts from LVector3f to NxVec3.
static NxMat34 mat4_to_nxMat34(const LMatrix4f &m)
Converts from LMatrix4f to NxMat34.
static LVector3f nxVec3_to_vec3(const NxVec3 &v)
Converts from NxVec3 to LVector3f.
static LMatrix4f nxMat34_to_mat4(const NxMat34 &m)
Converts from NxMat34 to LMatrix4f.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.