Panda3D

physxActor.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 physxActor.cxx
10 * @author enn0x
11 * @date 2009-09-14
12 */
13
14 #include "physxActor.h"
15 #include "physxActorDesc.h"
16 #include "physxBodyDesc.h"
17 #include "physxShapeDesc.h"
18 #include "physxManager.h"
19
20 TypeHandle PhysxActor::_type_handle;
21
22 /**
23 *
24 */
25 void PhysxActor::
26 link(NxActor *actorPtr) {
27
28 // Link self
29 _ptr = actorPtr;
30 _ptr->userData = this;
31 _error_type = ET_ok;
32
33 set_name(actorPtr->getName());
34
35 PhysxScene *scene = (PhysxScene *)_ptr->getScene().userData;
36 scene->_actors.add(this);
37
38 // Link shapes
39 NxShape * const *shapes = _ptr->getShapes();
40 NxU32 nShapes = _ptr->getNbShapes();
41
42 for (NxU32 i=0; i < nShapes; i++) {
43 PhysxShape *shape = PhysxShape::factory(shapes[i]->getType());
44 shape->link(shapes[i]);
45 }
46 }
47
48 /**
49 *
50 */
51 void PhysxActor::
52 unlink() {
53
54 // Unlink shapes
55 NxShape * const *shapes = _ptr->getShapes();
56 NxU32 nShapes = _ptr->getNbShapes();
57
58 for (NxU32 i=0; i < nShapes; i++) {
59 PhysxShape *shape = (PhysxShape *)shapes[i]->userData;
60 shape->unlink();
61 }
62
63 // Unlink self
64 _ptr->userData = nullptr;
65 _error_type = ET_released;
66
67 PhysxScene *scene = (PhysxScene *)_ptr->getScene().userData;
68 scene->_actors.remove(this);
69 }
70
71 /**
72 *
73 */
74 void PhysxActor::
75 release() {
76
77 nassertv(_error_type == ET_ok);
78
79 unlink();
80 _ptr->getScene().releaseActor(*_ptr);
81 _ptr = nullptr;
82 }
83
84 /**
85 *
86 */
87 void PhysxActor::
88 link_controller(PhysxController *controller) {
89
90 _controller = controller;
91 }
92
93 /**
94 * Saves the body information of a dynamic actor to the passed body
95 * descriptor.
96 */
97 bool PhysxActor::
98 save_body_to_desc(PhysxBodyDesc &bodyDesc) const {
99
100 nassertr(_error_type == ET_ok, false);
101 return _ptr->saveBodyToDesc(bodyDesc._desc);
102 }
103
104 /**
105 * Saves the state of the actor to the passed descriptor.
106 */
107 void PhysxActor::
108 save_to_desc(PhysxActorDesc &actorDesc) const {
109
110 nassertv(_error_type == ET_ok);
111 _ptr->saveToDesc(actorDesc._desc);
112 }
113
114 /**
115 * Sets a name string for the object that can be retrieved with get_name().
116 * This is for debugging and is not used by the engine.
117 */
118 void PhysxActor::
119 set_name(const char *name) {
120
121 nassertv(_error_type == ET_ok);
122
123 _name = name ? name : "";
124 _ptr->setName(_name.c_str());
125 }
126
127 /**
128 * Retrieves the name string.
129 */
130 const char *PhysxActor::
131 get_name() const {
132
133 nassertr(_error_type == ET_ok, "");
134 return _ptr->getName();
135 }
136
137 /**
138 * Updates the transform of an assigned NodePath. If the actor has been
139 * created by a PhysxController then this method will update the NodePath's
140 * transform from the controller's transform.
141 */
142 void PhysxActor::
143 update_transform(const LMatrix4f &m) {
144
145 // Active transforms are update AFTER scene.fetchResults() has been called,
146 // and thus can contain removed objects. So either update transforms after
147 // scene.fetchResults() - which means poor performance - or check if an
148 // actor has been removed here in this method.
149 if (_error_type != ET_ok) return;
150
151 if (_np.is_empty()) return;
152
153 if (_controller) {
154 LVector3f hpr(_controller->get_h(), 0.0f, 0.0f);
155 LPoint3f pos = _controller->get_pos();
156 _np.set_transform(_np.get_top(), TransformState::make_pos_hpr(pos, hpr));
157 }
158 else {
159 _np.set_transform(_np.get_top(), TransformState::make_mat(m));
160 }
161 }
162
163 /**
164 * Retrieves the actors world space position.
165 */
166 LPoint3f PhysxActor::
167 get_global_pos() const {
168
169 nassertr(_error_type == ET_ok, LPoint3f::zero());
170 return PhysxManager::nxVec3_to_point3(_ptr->getGlobalPosition());
171 }
172
173 /**
174 * Retrieves the actors world space transform.
175 */
176 LMatrix4f PhysxActor::
177 get_global_mat() const {
178
179 nassertr(_error_type == ET_ok, LMatrix4f::zeros_mat());
180 return PhysxManager::nxMat34_to_mat4(_ptr->getGlobalPose());
181 }
182
183 /**
184 * Retrieves the actors world space orientation.
185 */
186 LQuaternionf PhysxActor::
187 get_global_quat() const {
188
189 nassertr(_error_type == ET_ok, LQuaternionf::zero());
190 return PhysxManager::nxQuat_to_quat(_ptr->getGlobalOrientation());
191 }
192
193 /**
194 * Method for setting a dynamic actor's position in the world. Please see
195 * set_global_mat for some caveats.
196 */
197 void PhysxActor::
198 set_global_pos(const LPoint3f &pos) {
199
200 nassertv(_error_type == ET_ok);
201 nassertv_always(!pos.is_nan());
202
203 _ptr->setGlobalPosition(PhysxManager::point3_to_nxVec3(pos));
204 }
205
206 /**
207 * Method for setting a dynamic actor's transform matrix in the world.
208 *
209 * This method instantaneously changes the actor space to world space
210 * transformation.
211 *
212 * One should exercise restraint in making use of these methods.
213 *
214 * Static actors should not be moved at all. There are various internal data
215 * structures for static actors which may need to be recomputed when one
216 * moves. Also, moving static actors will not interact correctly with dynamic
217 * actors or joints. If you would like to directly control an actor's
218 * position and would like to have it correctly interact with dynamic bodies
219 * and joints, you should create a dynamic body with the BF_kinematic flag,
220 * and then use the move_global_*() commands to move it along a path!
221 *
222 * When briefly moving dynamic actors, one should not: - Move actors into
223 * other actors, thus causing interpenetration (an invalid physical state). -
224 * Move an actor that is connected by a joint to another away from the other
225 * (thus causing joint error). - When moving jointed actors the joints' cached
226 * transform information is destroyed and recreated next frame; thus this call
227 * is expensive for jointed actors.
228 */
229 void PhysxActor::
230 set_global_mat(const LMatrix4f &mat) {
231
232 nassertv(_error_type == ET_ok);
233 nassertv_always(!mat.is_nan());
234
235 _ptr->setGlobalPose(PhysxManager::mat4_to_nxMat34(mat));
236 }
237
238 /**
239 * Method for setting a dynamic actor's orientation in the world. Please see
240 * set_global_mat for some caveats.
241 */
242 void PhysxActor::
243 set_global_hpr(float h, float p, float r) {
244
245 nassertv(_error_type == ET_ok);
246
247 LQuaternionf q;
248 q.set_hpr(LVector3f(h, p, r));
249 _ptr->setGlobalOrientationQuat(PhysxManager::quat_to_nxQuat(q));
250 }
251
252 /**
253 * The move_global_* calls serve to move kinematically controlled dynamic
254 * actors through the game world.
255 *
256 * See move_global_mat() for more information.
257 *
258 * This call wakes the actor if it is sleeping.
259 */
260 void PhysxActor::
261 move_global_pos(const LPoint3f &pos) {
262
263 nassertv(_error_type == ET_ok);
264 nassertv_always(!pos.is_nan());
265
266 _ptr->moveGlobalPosition(PhysxManager::point3_to_nxVec3(pos));
267 }
268
269 /**
270 * The move_global_* calls serve to move kinematically controlled dynamic
271 * actors through the game world.
272 *
273 * You set a dynamic actor to be kinematic using the BF_KINEMATIC body flag,
274 * used either in the PhysBodyDesc or with set_body_flag().
275 *
276 * The move command will result in a velocity that, when successfully carried
277 * out (i.e. the motion is not blocked due to joints or collisions) inside
278 * run*(), will move the body into the desired pose. After the move is
279 * carried out during a single time step, the velocity is returned to zero.
280 * Thus, you must continuously call this in every time step for kinematic
281 * actors so that they move along a path.
282 *
283 * These functions simply store the move destination until run*() is called,
284 * so consecutive calls will simply overwrite the stored target variable.
285 *
286 * This call wakes the actor if it is sleeping.
287 */
288 void PhysxActor::
289 move_global_mat(const LMatrix4f &mat) {
290
291 nassertv(_error_type == ET_ok);
292 nassertv_always(!mat.is_nan());
293
294 _ptr->moveGlobalPose(PhysxManager::mat4_to_nxMat34(mat));
295 }
296
297 /**
298 * The move_global_* calls serve to move kinematically controlled dynamic
299 * actors through the game world.
300 *
301 * See move_global_mat() for more information.
302 *
303 * This call wakes the actor if it is sleeping.
304 */
305 void PhysxActor::
306 move_global_hpr(float h, float p, float r) {
307
308 nassertv(_error_type == ET_ok);
309
310 LQuaternionf q;
311 q.set_hpr(LVector3f(h, p, r));
312 _ptr->moveGlobalOrientationQuat(PhysxManager::quat_to_nxQuat(q));
313 }
314
315 /**
316 * Attaches a node path to this actor. The node path's transform will be
317 * updated automatically if the actor's transform changes (and only then).
318 *
319 * Note: any non-uniform scale or shear set on the NodePath's transform will
320 * be overwritten at the time of the first update.
321 */
322 void PhysxActor::
323 attach_node_path(const NodePath &np) {
324
325 nassertv(_error_type == ET_ok);
326 nassertv_always(!np.is_empty());
327
328 _np = NodePath(np);
329 }
330
331 /**
332 * Detaches a previously assigned NodePath from this actor. The NodePath's
333 * transform will no longer be updated from the actor's transform.
334 */
335 void PhysxActor::
336 detach_node_path() {
337
338 nassertv(_error_type == ET_ok);
339
340 _np = NodePath();
341 }
342
343 /**
344 * Retrieves a previously attached NodePath. An empty NodePath will be
345 * returned if no NodePath has been attached to this actor.
346 */
347 NodePath PhysxActor::
348 get_node_path() const {
349
350 nassertr(_error_type == ET_ok, NodePath::fail());
351
352 return _np;
353 }
354
355 /**
356 * Retrieves the scene which this actor belongs to.
357 */
358 PhysxScene *PhysxActor::
359 get_scene() const {
360
361 nassertr(_error_type == ET_ok, nullptr);
362
363 NxScene *scenePtr = &(_ptr->getScene());
364 PhysxScene *scene = (PhysxScene *)(scenePtr->userData);
365
366 return scene;
367 }
368
369 /**
370 * Returns the number of shapes assigned to the actor.
371 */
372 unsigned int PhysxActor::
373 get_num_shapes() const {
374
375 nassertr(_error_type == ET_ok, -1);
376
377 return _ptr->getNbShapes();
378 }
379
380 /**
381 * Creates a new shape and adds it to the list of shapes of this actor.
382 *
383 * Mass properties of dynamic actors will not automatically be recomputed to
384 * reflect the new mass distribution implied by the shape. Follow this call
385 * with a call to update_mass_from_shapes() to do that.
386 */
387 PhysxShape *PhysxActor::
388 create_shape(PhysxShapeDesc &desc) {
389
390 nassertr(_error_type == ET_ok, nullptr);
391 nassertr(desc.is_valid(),nullptr);
392
393 PhysxShape *shape = PhysxShape::factory(desc.ptr()->getType());
394 nassertr(shape, nullptr);
395
396 NxShape *shapePtr = _ptr->createShape(*desc.ptr());
397 nassertr(shapePtr, nullptr);
398
399 shape->link(shapePtr);
400
401 return shape;
402 }
403
404 /**
405 * Retrieves an individual shape from the actor's array of shapes. Index must
406 * be in the range from zero to (number-of-shapes minus 1).
407 */
408 PhysxShape *PhysxActor::
409 get_shape(unsigned int idx) const {
410
411 nassertr(_error_type == ET_ok, nullptr);
412 nassertr_always(idx < _ptr->getNbShapes(), nullptr);
413
414 NxShape * const *shapes = _ptr->getShapes();
415 NxShape *shapePtr = shapes[idx];
416 PhysxShape *shape = (PhysxShape *)(shapePtr->userData);
417
418 return shape;
419 }
420
421 /**
422 * Retrieves an individual shape from the actor's array of shapes. The first
423 * shape for which the shape's name matches the specified name is returned, or
424 * NULL if no shape has a matching name.
425 */
426 PhysxShape *PhysxActor::
427 get_shape_by_name(const char *name) const {
428
429 nassertr(_error_type == ET_ok, nullptr);
430
431 NxShape * const *shapes = _ptr->getShapes();
432 NxShape *shapePtr = nullptr;
433 NxU32 nShapes = _ptr->getNbShapes();
434
435 for (NxU32 i=0; i < nShapes; i++) {
436 shapePtr = shapes[i];
437
438 if (strcmp(shapePtr->getName(), name) == 0) {
439 return (PhysxShape *) shapePtr->userData;
440 }
441 }
442
443 return nullptr;
444 }
445
446 /**
447 * Applies a force (or impulse) defined in the global coordinate frame to the
448 * actor.
449 *
450 * This will not induce a torque.
451 *
452 * Mode determines if the torque is to be conventional or impulsive.
453 *
454 * The actor must be dynamic. This call wakes the actor if it is sleeping and
455 * the wakeup parameter is true (default).
456 */
457 void PhysxActor::
458 add_force(const LVector3f force, PhysxForceMode mode, bool wakeup) {
459
460 nassertv(_error_type == ET_ok);
461 nassertv_always(!force.is_nan());
462
463 _ptr->addForce(PhysxManager::vec3_to_nxVec3(force), (NxForceMode)mode, wakeup);
464 }
465
466 /**
467 * Applies a force (or impulse) defined in the global coordinate frame, acting
468 * at a particular point in global coordinates, to the actor.
469 *
470 * Note that if the force does not act along the center of mass of the actor,
471 * this will also add the corresponding torque. Because forces are reset at
472 * the end of every timestep, you can maintain a total external force on an
473 * object by calling this once every frame.
474 *
475 * Mode determines if the torque is to be conventional or impulsive.
476 *
477 * The actor must be dynamic. This call wakes the actor if it is sleeping and
478 * the wakeup parameter is true (default).
479 */
480 void PhysxActor::
481 add_force_at_pos(const LVector3f force, const LPoint3f &pos, PhysxForceMode mode, bool wakeup) {
482
483 nassertv(_error_type == ET_ok);
484 nassertv_always(!force.is_nan());
485 nassertv_always(!pos.is_nan());
486
487 _ptr->addForceAtPos(PhysxManager::vec3_to_nxVec3(force), PhysxManager::point3_to_nxVec3(pos), (NxForceMode)mode, wakeup);
488 }
489
490 /**
491 * Applies a force (or impulse) defined in the global coordinate frame, acting
492 * at a particular point in local coordinates, to the actor.
493 *
494 * Note that if the force does not act along the center of mass of the actor,
495 * this will also add the corresponding torque. Because forces are reset at
496 * the end of every timestep, you can maintain a total external force on an
497 * object by calling this once every frame.
498 *
499 * Mode determines if the torque is to be conventional or impulsive.
500 *
501 * The actor must be dynamic. This call wakes the actor if it is sleeping and
502 * the wakeup parameter is true (default).
503 */
504 void PhysxActor::
505 add_force_at_local_pos(const LVector3f force, const LPoint3f &pos, PhysxForceMode mode, bool wakeup) {
506
507 nassertv(_error_type == ET_ok);
508 nassertv_always(!force.is_nan());
509 nassertv_always(!pos.is_nan());
510
511 _ptr->addForceAtLocalPos(PhysxManager::vec3_to_nxVec3(force), PhysxManager::point3_to_nxVec3(pos), (NxForceMode)mode, wakeup);
512 }
513
514 /**
515 * Applies an impulsive torque defined in the global coordinate frame to the
516 * actor.
517 *
518 * Mode determines if the torque is to be conventional or impulsive.
519 *
520 * The actor must be dynamic. This call wakes the actor if it is sleeping and
521 * the wakeup parameter is true (default).
522 */
523 void PhysxActor::
524 add_torque(const LVector3f torque, PhysxForceMode mode, bool wakeup) {
525
526 nassertv(_error_type == ET_ok);
527 nassertv_always(!torque.is_nan());
528
529 _ptr->addTorque(PhysxManager::vec3_to_nxVec3(torque), (NxForceMode)mode, wakeup);
530 }
531
532 /**
533 * Applies a force (or impulse) defined in the actor local coordinate frame to
534 * the actor. This will not induce a torque.
535 *
536 * Mode determines if the torque is to be conventional or impulsive.
537 *
538 * The actor must be dynamic. This call wakes the actor if it is sleeping and
539 * the wakeup parameter is true (default).
540 */
541 void PhysxActor::
542 add_local_force(const LVector3f force, PhysxForceMode mode, bool wakeup) {
543
544 nassertv(_error_type == ET_ok);
545 nassertv_always(!force.is_nan());
546
547 _ptr->addLocalForce(PhysxManager::vec3_to_nxVec3(force), (NxForceMode)mode, wakeup);
548 }
549
550 /**
551 * Applies a force (or impulse) defined in the actor local coordinate frame,
552 * acting at a particular point in global coordinates, to the actor.
553 *
554 * Note that if the force does not act along the center of mass of the actor,
555 * this will also add the corresponding torque. Because forces are reset at
556 * the end of every timestep, you can maintain a total external force on an
557 * object by calling this once every frame.
558 *
559 * Mode determines if the torque is to be conventional or impulsive.
560 *
561 * The actor must be dynamic. This call wakes the actor if it is sleeping and
562 * the wakeup parameter is true (default).
563 */
564 void PhysxActor::
565 add_local_force_at_pos(const LVector3f force, const LPoint3f &pos, PhysxForceMode mode, bool wakeup) {
566
567 nassertv(_error_type == ET_ok);
568 nassertv_always(!force.is_nan());
569 nassertv_always(!pos.is_nan());
570
571 _ptr->addLocalForceAtPos(PhysxManager::vec3_to_nxVec3(force), PhysxManager::point3_to_nxVec3(pos), (NxForceMode)mode, wakeup);
572 }
573
574 /**
575 * Applies a force (or impulse) defined in the actor local coordinate frame,
576 * acting at a particular point in local coordinates, to the actor.
577 *
578 * Note that if the force does not act along the center of mass of the actor,
579 * this will also add the corresponding torque. Because forces are reset at
580 * the end of every timestep, you can maintain a total external force on an
581 * object by calling this once every frame.
582 *
583 * Mode determines if the torque is to be conventional or impulsive.
584 *
585 * The actor must be dynamic. This call wakes the actor if it is sleeping and
586 * the wakeup parameter is true (default).
587 */
588 void PhysxActor::
589 add_local_force_at_local_pos(const LVector3f force, const LPoint3f &pos, PhysxForceMode mode, bool wakeup) {
590
591 nassertv(_error_type == ET_ok);
592 nassertv_always(!force.is_nan());
593 nassertv_always(!pos.is_nan());
594
595 _ptr->addLocalForceAtLocalPos(PhysxManager::vec3_to_nxVec3(force), PhysxManager::point3_to_nxVec3(pos), (NxForceMode)mode, wakeup);
596 }
597
598 /**
599 * Applies an impulsive torque defined in the actor local coordinate frame to
600 * the actor.
601 *
602 * Mode determines if the torque is to be conventional or impulsive.
603 *
604 * The actor must be dynamic. This call wakes the actor if it is sleeping and
605 * the wakeup parameter is true (default).
606 */
607 void PhysxActor::
608 add_local_torque(const LVector3f torque, PhysxForceMode mode, bool wakeup) {
609
610 nassertv(_error_type == ET_ok);
611 nassertv_always(!torque.is_nan());
612
613 _ptr->addLocalTorque(PhysxManager::vec3_to_nxVec3(torque), (NxForceMode)mode, wakeup);
614 }
615
616 /**
617 * Recomputes a dynamic actor's mass properties from its shapes.
618 *
619 * Given a constant density or total mass, the actors mass properties can be
620 * recomputed using the shapes attached to the actor. If the actor has no
621 * shapes, then only the totalMass parameter can be used. If all shapes in
622 * the actor are trigger shapes (non-physical), the call will fail.
623 *
624 * The mass of each shape is either the shape's local density (as specified in
625 * the PhysxShapeDesc; default 1.0) multiplied by the shape's volume or a
626 * directly specified shape mass.
627 *
628 * The inertia tensor, mass frame and center of mass will always be
629 * recomputed. If there are no shapes in the actor, the mass will be
630 * totalMass, and the mass frame will be set to the center of the actor.
631 *
632 * If you supply a non-zero total mass, the actor's mass and inertia will
633 * first be computed as above and then scaled to fit this total mass.
634 *
635 * If you supply a non-zero density, the actor's mass and inertia will first
636 * be computed as above and then scaled by this factor.
637 *
638 * Either totalMass or density must be non-zero.
639 *
640 * The actor must be dynamic.
641 */
642 bool PhysxActor::
643 update_mass_from_shapes(float density, float totalMass) {
644
645 nassertr(_error_type == ET_ok, false);
646 return _ptr->updateMassFromShapes(density, totalMass);
647 }
648
649 /**
650 * Computes the total kinetic (rotational and translational) energy of the
651 * object. The actor must be dynamic.
652 */
653 float PhysxActor::
654 compute_kinetic_energy() const {
655
656 nassertr(_error_type == ET_ok, 0.0f);
657 return _ptr->computeKineticEnergy();
658 }
659
660 /**
661 * Returns true if the actor is dynamic.
662 */
663 bool PhysxActor::
664 is_dynamic() const {
665
666 nassertr(_error_type == ET_ok, false);
667 return _ptr->isDynamic();
668 }
669
670 /**
671 * Sets the collision group for all shapes of this actor. See
672 * PhysxShape.setGroup().
673 */
674 void PhysxActor::
675 set_shape_group(unsigned int group) {
676
677 nassertv(_error_type == ET_ok);
678 nassertv(group >= 0 && group < 32);
679
680 NxShape * const *shapes = _ptr->getShapes();
681 NxU32 nShapes = _ptr->getNbShapes();
682
683 for (NxU32 i=0; i < nShapes; i++) {
684 shapes[i]->setGroup( group );
685 }
686 }
687
688 /**
689 * Raise or lower individual BodyFlag flags.
690 */
691 void PhysxActor::
692 set_body_flag(PhysxBodyFlag flag, bool value) {
693
694 if (value == true) {
695 _ptr->raiseBodyFlag((NxBodyFlag)flag);
696 }
697 else {
698 _ptr->clearBodyFlag((NxBodyFlag)flag);
699 }
700 }
701
702 /**
703 * Return the specified BodyFlag flag.
704 */
705 bool PhysxActor::
706 get_body_flag(PhysxBodyFlag flag) const {
707
708 nassertr(_error_type == ET_ok, false);
709 return ptr()->readBodyFlag((NxBodyFlag)flag);
710 }
711
712 /**
713 * Raise or lower individual ActorFlag flags.
714 */
715 void PhysxActor::
716 set_actor_flag(PhysxActorFlag flag, bool value) {
717
718 if (value == true) {
719 _ptr->raiseActorFlag((NxActorFlag)flag);
720 }
721 else {
722 _ptr->clearActorFlag((NxActorFlag)flag);
723 }
724 }
725
726 /**
727 * Return the specified ActorFlag flag.
728 */
729 bool PhysxActor::
730 get_actor_flag(PhysxActorFlag flag) const {
731
732 nassertr(_error_type == ET_ok, false);
733 return ptr()->readActorFlag((NxActorFlag)flag);
734 }
735
736 /**
737 * Sets the actor's contact report flags.
738 *
739 * These flags are used to determine the kind of report that is generated for
740 * interactions with other actors.
741 *
742 * Please note: If the actor is part of an interacting pair for which the
743 * contact report generation is controlled already through any other mechanism
744 * (for example by use of PhysxScene::set_actor_pair_flags) then the union of
745 * all the specified contact report flags will be used to generate the report.
746 */
747 void PhysxActor::
748 set_contact_report_flag(PhysxContactPairFlag flag, bool value) {
749
750 nassertv(_error_type == ET_ok);
751
752 NxU32 flags = _ptr->getContactReportFlags();
753
754 if (value == true) {
755 flags |= flag;
756 }
757 else {
758 flags &= ~(flag);
759 }
760
761 _ptr->setContactReportFlags(flags);
762 }
763
764 /**
765 * Sets the force threshold for contact reports. The actor must be dynamic.
766 */
767 void PhysxActor::
768 set_contact_report_threshold(float threshold) {
769
770 nassertv(_error_type == ET_ok);
771 nassertv(threshold >= 0.0f);
772
773 _ptr->setContactReportThreshold(threshold);
774 }
775
776 /**
777 * Assigns the actor to a user defined group of actors. The actor group must
778 * be an integer in between 0 and 0x7fff (32767).
779 *
780 * This is similar to NxShape groups, except those are only five bits and
781 * serve a different purpose.
782 *
783 * The PhysxScene::set_actor_group_pair_flags() lets you set certain behaviors
784 * for pairs of actor groups.
785 *
786 * By default every actor is created in group 0.
787 */
788 void PhysxActor::
789 set_group(unsigned int group) {
790
791 nassertv(_error_type == ET_ok);
792 nassertv(group >= 0 && group < 0x8000);
793
794 ptr()->setGroup(group);
795 }
796
797 /**
798 * Retrieves the actor group this actor is assigned to.
799 */
800 unsigned int PhysxActor::
801 get_group() const {
802
803 nassertr(_error_type == ET_ok, 0);
804
805 return ptr()->getGroup();
806 }
807
808 /**
809 * Assigns dynamic actors a dominance group identifier. Dominance groups are
810 * integere in the range from 0 to 31.
811 *
812 * This is similar to shape groups, except those serve a different purpose.
813 *
814 * The PhysxScene::set_dominance_group_pair() lets you set certain behaviors
815 * for pairs of dominance groups.
816 *
817 * By default every actor is created in group 0. Static actors must stay in
818 * group 0; thus you can only call this on dynamic actors.
819 */
820 void PhysxActor::
821 set_dominance_group(unsigned int group) {
822
823 nassertv(_error_type == ET_ok);
824 nassertv(group >= 0 && group < 32);
825 nassertv(is_dynamic() == true);
826
827 _ptr->setDominanceGroup(group);
828 }
829
830 /**
831 * Retrieves the dominance group of this actor.
832 */
833 unsigned int PhysxActor::
834 get_dominance_group() const {
835
836 nassertr(_error_type == ET_ok, 0);
837
838 return ptr()->getDominanceGroup();
839 }
840
841 /**
842 * Sets the angular damping coefficient. Zero represents no damping. The
843 * angular damping coefficient must be nonnegative. The actor must be
844 * dynamic. Default: 0.05
845 */
846 void PhysxActor::
847 set_angular_damping(float angDamp) {
848
849 nassertv(_error_type == ET_ok);
850 nassertv(angDamp >= 0.0f);
851
852 _ptr->setAngularDamping(angDamp);
853 }
854
855 /**
856 * Returns the angular damping coefficient. The actor must be dynamic.
857 */
858 float PhysxActor::
859 get_angular_damping() const {
860
861 nassertr(_error_type == ET_ok, 0.0f);
862 return _ptr->getAngularDamping();
863 }
864
865 /**
866 * Sets the linear damping coefficient. Zero represents no damping. The
867 * damping coefficient must be nonnegative. The actor must be dynamic.
868 * Default: 0
869 */
870 void PhysxActor::
871 set_linear_damping(float linDamp) {
872
873 nassertv(_error_type == ET_ok);
874 nassertv(linDamp >= 0.0f);
875
876 _ptr->setLinearDamping(linDamp);
877 }
878
879 /**
880 * Retrieves the linear damping coefficient. The actor must be dynamic.
881 */
882 float PhysxActor::
883 get_linear_damping() const {
884
885 nassertr(_error_type == ET_ok, 0.0f);
886 return _ptr->getLinearDamping();
887 }
888
889 /**
890 * Sets the linear velocity of the actor.
891 *
892 * Note that if you continuously set the velocity of an actor yourself, forces
893 * such as gravity or friction will not be able to manifest themselves,
894 * because forces directly influence only the velocity/momentum of an actor.
895 *
896 * The actor must be dynamic.
897 */
898 void PhysxActor::
899 set_linear_velocity(const LVector3f &linVel) {
900
901 nassertv(_error_type == ET_ok);
902 nassertv(_ptr->isDynamic());
903
904 _ptr->setLinearVelocity(PhysxManager::vec3_to_nxVec3(linVel));
905 }
906
907 /**
908 * Sets the angular velocity of the actor.
909 *
910 * Note that if you continuously set the angular velocity of an actor
911 * yourself, forces such as friction will not be able to rotate the actor,
912 * because forces directly influence only the velocity/momentum.
913 *
914 * The actor must be dynamic.
915 */
916 void PhysxActor::
917 set_angular_velocity(const LVector3f &angVel) {
918
919 nassertv(_error_type == ET_ok);
920 nassertv(_ptr->isDynamic());
921
922 _ptr->setAngularVelocity(PhysxManager::vec3_to_nxVec3(angVel));
923 }
924
925 /**
926 * Lets you set the maximum angular velocity permitted for this actor.
927 *
928 * Because for various internal computations, very quickly rotating actors
929 * introduce error into the simulation, which leads to undesired results.
930 *
931 * With PhysxManager::set_parameter(PP_max_angular_velocity) you can set the
932 * default maximum velocity for actors created after the call. Bodies' high
933 * angular velocities are clamped to this value.
934 *
935 * However, because some actors, such as car wheels, should be able to rotate
936 * quickly, you can override the default setting on a per-actor basis with the
937 * below call. Note that objects such as wheels which are approximated with
938 * spherical or other smooth collision primitives can be simulated with
939 * stability at a much higher angular velocity than, say, a box that has
940 * corners.
941 *
942 * The actor must be dynamic.
943 */
944 void PhysxActor::
945 set_max_angular_velocity(float maxAngVel) {
946
947 nassertv(_error_type == ET_ok);
948 nassertv(_ptr->isDynamic());
949
950 _ptr->setMaxAngularVelocity(maxAngVel);
951 }
952
953 /**
954 * Returns the linear velocity of an actor. The actor must be dynamic.
955 */
956 LVector3f PhysxActor::
957 get_linear_velocity() const {
958
959 nassertr(_error_type == ET_ok, LVector3f::zero());
960 return PhysxManager::nxVec3_to_vec3(_ptr->getLinearVelocity());
961 }
962
963 /**
964 * Returns the angular velocity of the actor. The actor must be dynamic.
965 */
966 LVector3f PhysxActor::
967 get_angular_velocity() const {
968
969 nassertr(_error_type == ET_ok, LVector3f::zero());
970 return PhysxManager::nxVec3_to_vec3(_ptr->getAngularVelocity());
971 }
972
973 /**
974 * Returns the maximum angular velocity permitted for this actor.
975 */
976 float PhysxActor::
977 get_max_angular_velocity() const {
978
979 nassertr(_error_type == ET_ok, 0.0f);
980 return _ptr->getMaxAngularVelocity();
981 }
982
983 /**
984 * Computes the velocity of a point given in world coordinates if it were
985 * attached to the actor and moving with it.
986 *
987 * The actor must be dynamic.
988 */
989 LVector3f PhysxActor::
990 get_point_velocity(const LPoint3f &point) const {
991
992 nassertr(_error_type == ET_ok, LVector3f::zero());
993 nassertr_always(!point.is_nan(), LVector3f::zero());
994
995 NxVec3 nPoint = PhysxManager::point3_to_nxVec3(point);
996 return PhysxManager::nxVec3_to_vec3(_ptr->getPointVelocity(nPoint));
997 }
998
999 /**
1000 * Computes the velocity of a point given in body local coordinates as if it
1001 * were attached to the actor and moving with it.
1002 *
1003 * The actor must be dynamic.
1004 */
1005 LVector3f PhysxActor::
1006 get_local_point_velocity(const LPoint3f &point) const {
1007
1008 nassertr(_error_type == ET_ok, LVector3f::zero());
1009 nassertr_always(!point.is_nan(), LVector3f::zero());
1010
1011 NxVec3 nPoint = PhysxManager::point3_to_nxVec3(point);
1012 return PhysxManager::nxVec3_to_vec3(_ptr->getLocalPointVelocity(nPoint));
1013 }
1014
1015 /**
1016 * Sets the linear momentum of the actor. Note that if you continuously set
1017 * the linear momentum of an actor yourself, forces such as gravity or
1018 * friction will not be able to manifest themselves, because forces directly
1019 * influence only the velocity/momentum of a actor. The actor must be
1020 * dynamic.
1021 */
1022 void PhysxActor::
1023 set_linear_momentum(const LVector3f &momentum) {
1024
1025 nassertv(_error_type == ET_ok);
1026 _ptr->setLinearMomentum(PhysxManager::vec3_to_nxVec3(momentum));
1027 }
1028
1029 /**
1030 * Sets the angular momentum of the actor. Note that if you continuously set
1031 * the angular velocity of an actor yourself, forces such as friction will not
1032 * be able to rotate the actor, because forces directly influence only the
1033 * velocity of actor. The actor must be dynamic.
1034 */
1035 void PhysxActor::
1036 set_angular_momentum(const LVector3f &momentum) {
1037
1038 nassertv(_error_type == ET_ok);
1039 _ptr->setAngularMomentum(PhysxManager::vec3_to_nxVec3(momentum));
1040 }
1041
1042 /**
1043 * Retrieves the linear momentum of an actor. The momentum is equal to the
1044 * velocity times the mass. The actor must be dynamic.
1045 */
1046 LVector3f PhysxActor::
1047 get_linear_momentum() const {
1048
1049 nassertr(_error_type == ET_ok, LVector3f::zero());
1050 return PhysxManager::nxVec3_to_vec3(_ptr->getLinearMomentum());
1051 }
1052
1053 /**
1054 * Retrieves the angular momentum of an actor. The angular momentum is equal
1055 * to the angular velocity times the global space inertia tensor. The actor
1056 * must be dynamic.
1057 */
1058 LVector3f PhysxActor::
1059 get_angular_momentum() const {
1060
1061 nassertr(_error_type == ET_ok, LVector3f::zero());
1062 return PhysxManager::nxVec3_to_vec3(_ptr->getAngularMomentum());
1063 }
1064
1065 /**
1066 * Sets the linear velocity below which an actor may go to sleep. Actors
1067 * whose linear velocity is above this threshold will not be put to sleep.
1068 *
1069 * Setting the sleep angular/linear velocity only makes sense when the
1070 * BF_energy_sleep_test is not set.
1071 *
1072 * The actor must be dynamic.
1073 */
1074 void PhysxActor::
1075 set_sleep_linear_velocity(float threshold) {
1076
1077 nassertv(_error_type == ET_ok);
1078 _ptr->setSleepLinearVelocity(threshold);
1079 }
1080
1081 /**
1082 * Sets the angular velocity below which an actor may go to sleep. Actors
1083 * whose angular velocity is above this threshold will not be put to sleep.
1084 *
1085 * Setting the sleep angular/linear velocity only makes sense when the
1086 * BF_energy_sleep_test is not set.
1087 *
1088 * The actor must be dynamic.
1089 */
1090 void PhysxActor::
1091 set_sleep_angular_velocity(float threshold) {
1092
1093 nassertv(_error_type == ET_ok);
1094 _ptr->setSleepAngularVelocity(threshold);
1095 }
1096
1097 /**
1098 * Sets the energy threshold below which an actor may go to sleep. Actors
1099 * whose kinematic energy is above this threshold will not be put to sleep.
1100 *
1101 * Setting the sleep energy threshold only makes sense when the
1102 * BF_energy_sleep_test is set. There are also other types of sleeping that
1103 * uses the linear and angular velocities directly instead of the energy.
1104 *
1105 * The actor must be dynamic.
1106 */
1107 void PhysxActor::
1108 set_sleep_energy_threshold(float threshold) {
1109
1110 nassertv(_error_type == ET_ok);
1111 _ptr->setSleepEnergyThreshold(threshold);
1112 }
1113
1114 /**
1115 * Returns the linear velocity below which an actor may go to sleep. Actors
1116 * whose linear velocity is above this threshold will not be put to sleep.
1117 * The actor must be dynamic.
1118 */
1119 float PhysxActor::
1120 get_sleep_linear_velocity() const {
1121
1122 nassertr(_error_type == ET_ok, 0.0f);
1123 return _ptr->getSleepLinearVelocity();
1124 }
1125
1126 /**
1127 * Returns the angular velocity below which an actor may go to sleep. Actors
1128 * whose angular velocity is above this threshold will not be put to sleep.
1129 * The actor must be dynamic.
1130 */
1131 float PhysxActor::
1132 get_sleep_angular_velocity() const {
1133
1134 nassertr(_error_type == ET_ok, 0.0f);
1135 return _ptr->getSleepAngularVelocity();
1136 }
1137
1138 /**
1139 * Returns the energy below which an actor may go to sleep. Actors whose
1140 * energy is above this threshold will not be put to sleep. The actor must be
1141 * dynamic.
1142 */
1143 float PhysxActor::
1144 get_sleep_energy_threshold() const {
1145
1146 nassertr(_error_type == ET_ok, 0.0f);
1147 return _ptr->getSleepEnergyThreshold();
1148 }
1149
1150 /**
1151 * Returns true if this body is sleeping.
1152 *
1153 * When an actor does not move for a period of time, it is no longer simulated
1154 * in order to save time. This state is called sleeping. However, because
1155 * the object automatically wakes up when it is either touched by an awake
1156 * object, or one of its properties is changed by the user, the entire sleep
1157 * mechanism should be transparent to the user.
1158 *
1159 * The actor must be dynamic.
1160 */
1161 bool PhysxActor::
1162 is_sleeping() const {
1163
1164 nassertr(_error_type == ET_ok, false);
1165 return _ptr->isSleeping();
1166 }
1167
1168 /**
1169 * Wakes up the actor if it is sleeping.
1170 *
1171 * The wakeCounterValue determines how long until the body is put to sleep, a
1172 * value of zero means that the body is sleeping. wake_up(0) is equivalent to
1173 * PhysxActor::put_to_sleep().
1174 *
1175 * The actor must be dynamic.
1176 */
1177 void PhysxActor::
1178 wake_up(float wakeCounterValue) {
1179
1180 nassertv(_error_type == ET_ok);
1181 _ptr->wakeUp(wakeCounterValue);
1182 }
1183
1184 /**
1185 * Forces the actor to sleep.
1186 *
1187 * The actor will stay asleep until the next call to simulate, and will not
1188 * wake up until then even when otherwise it would (for example a force is
1189 * applied to it). It can however wake up during the next do_physics call.
1190 *
1191 * The actor must be dynamic.
1192 */
1193 void PhysxActor::
1194 put_to_sleep() {
1195
1196 nassertv(_error_type == ET_ok);
1197 _ptr->putToSleep();
1198 }
1199
1200 /**
1201 * Sets the mass of a dynamic actor.
1202 */
1203 void PhysxActor::
1204 set_mass(float mass) {
1205
1206 nassertv(_error_type == ET_ok);
1207 _ptr->setMass(mass);
1208 }
1209
1210 /**
1211 * Returns the mass of the actor.
1212 */
1213 float PhysxActor::
1214 get_mass() const {
1215
1216 nassertr(_error_type == ET_ok, 0.0f);
1217 return _ptr->getMass();
1218 }
1219
1220 /**
1221 * Sets the matrix of the center of mass relative to the actor.
1222 */
1223 void PhysxActor::
1224 set_c_mass_offset_local_mat(const LMatrix4f &mat) {
1225
1226 nassertv(_error_type == ET_ok);
1227 _ptr->setCMassOffsetLocalPose(PhysxManager::mat4_to_nxMat34(mat));
1228 }
1229
1230 /**
1231 * Sets the position of the center of mass relative to the actor.
1232 */
1233 void PhysxActor::
1234 set_c_mass_offset_local_pos(const LPoint3f &pos) {
1235
1236 nassertv(_error_type == ET_ok);
1237 _ptr->setCMassOffsetLocalPosition(PhysxManager::point3_to_nxVec3(pos));
1238 }
1239
1240 /**
1241 * Sets the orientation of the center of mass relative to the actor.
1242 */
1243 void PhysxActor::
1244 set_c_mass_offset_local_orientation(const LMatrix3f &mat) {
1245
1246 nassertv(_error_type == ET_ok);
1247 _ptr->setCMassOffsetLocalOrientation(PhysxManager::mat3_to_nxMat33(mat));
1248 }
1249
1250 /**
1251 * Sets the matrix of the center of mass relative to world space.
1252 */
1253 void PhysxActor::
1254 set_c_mass_offset_global_mat(const LMatrix4f &mat) {
1255
1256 nassertv(_error_type == ET_ok);
1257 _ptr->setCMassOffsetGlobalPose(PhysxManager::mat4_to_nxMat34(mat));
1258 }
1259
1260 /**
1261 * Sets the position of the center of mass relative to world space.
1262 */
1263 void PhysxActor::
1264 set_c_mass_offset_global_pos(const LPoint3f &pos) {
1265
1266 nassertv(_error_type == ET_ok);
1267 _ptr->setCMassOffsetGlobalPosition(PhysxManager::point3_to_nxVec3(pos));
1268 }
1269
1270 /**
1271 * Sets the orientation of the center of mass relative to world space.
1272 */
1273 void PhysxActor::
1274 set_c_mass_offset_global_orientation(const LMatrix3f &mat) {
1275
1276 nassertv(_error_type == ET_ok);
1277 _ptr->setCMassOffsetGlobalOrientation(PhysxManager::mat3_to_nxMat33(mat));
1278 }
1279
1280 /**
1281 * Moves the actor by setting the transform of the center of mass.
1282 */
1283 void PhysxActor::
1284 set_c_mass_global_mat(const LMatrix4f &mat) {
1285
1286 nassertv(_error_type == ET_ok);
1287 _ptr->setCMassGlobalPose(PhysxManager::mat4_to_nxMat34(mat));
1288 }
1289
1290 /**
1291 * Moves the actor by setting the position of the center of mass.
1292 */
1293 void PhysxActor::
1294 set_c_mass_global_pos(const LPoint3f &pos) {
1295
1296 nassertv(_error_type == ET_ok);
1297 _ptr->setCMassGlobalPosition(PhysxManager::point3_to_nxVec3(pos));
1298 }
1299
1300 /**
1301 * Moves the actor by setting the orientation of the center of mass.
1302 */
1303 void PhysxActor::
1304 set_c_mass_global_orientation(const LMatrix3f &mat) {
1305
1306 nassertv(_error_type == ET_ok);
1307 _ptr->setCMassGlobalOrientation(PhysxManager::mat3_to_nxMat33(mat));
1308 }
1309
1310 /**
1311 * Sets the inertia tensor, using a parameter specified in mass space
1312 * coordinates.
1313 */
1314 void PhysxActor::
1315 set_mass_space_inertia_tensor(const LVector3f &m) {
1316
1317 nassertv(_error_type == ET_ok);
1318 _ptr->setMassSpaceInertiaTensor(PhysxManager::vec3_to_nxVec3(m));
1319 }
1320
1321 /**
1322 * Returns the center of mass transform in world space.
1323 */
1324 LMatrix4f PhysxActor::
1325 get_c_mass_global_mat() const {
1326
1327 nassertr(_error_type == ET_ok, LMatrix4f::zeros_mat());
1328 return PhysxManager::nxMat34_to_mat4(_ptr->getCMassGlobalPose());
1329 }
1330
1331 /**
1332 * Returns the center of mass position in world space.
1333 */
1334 LPoint3f PhysxActor::
1335 get_c_mass_global_pos() const {
1336
1337 nassertr(_error_type == ET_ok, LPoint3f::zero());
1338 return PhysxManager::nxVec3_to_point3(_ptr->getCMassGlobalPosition());
1339 }
1340
1341 /**
1342 * Returns the center of mass orientation in world space.
1343 */
1344 LMatrix3f PhysxActor::
1345 get_c_mass_global_orientation() const {
1346
1347 nassertr(_error_type == ET_ok, LMatrix3f::ident_mat());
1348 return PhysxManager::nxMat33_to_mat3(_ptr->getCMassGlobalOrientation());
1349 }
1350
1351 /**
1352 * Returns the center of mass transform relative to the actor.
1353 */
1354 LMatrix4f PhysxActor::
1355 get_c_mass_local_mat() const {
1356
1357 nassertr(_error_type == ET_ok, LMatrix4f::zeros_mat());
1358 return PhysxManager::nxMat34_to_mat4(_ptr->getCMassLocalPose());
1359 }
1360
1361 /**
1362 * Returns the center of mass position relative to the actor.
1363 */
1364 LPoint3f PhysxActor::
1365 get_c_mass_local_pos() const {
1366
1367 nassertr(_error_type == ET_ok, LPoint3f::zero());
1368 return PhysxManager::nxVec3_to_point3(_ptr->getCMassLocalPosition());
1369 }
1370
1371 /**
1372 * Returns the center of mass orientation relative to the actor.
1373 */
1374 LMatrix3f PhysxActor::
1375 get_c_mass_local_orientation() const {
1376
1377 nassertr(_error_type == ET_ok, LMatrix3f::ident_mat());
1378 return PhysxManager::nxMat33_to_mat3(_ptr->getCMassLocalOrientation());
1379 }
1380
1381 /**
1382 * Returns the diagonal inertia tensor of the actor relative to the mass
1383 * coordinate frame.
1384 */
1385 LVector3f PhysxActor::
1386 get_mass_space_inertia_tensor() const {
1387
1388 nassertr(_error_type == ET_ok, LVector3f::zero());
1389 return PhysxManager::nxVec3_to_vec3(_ptr->getMassSpaceInertiaTensor());
1390 }
1391
1392 /**
1393 * Returns the inertia tensor of the actor relative to the world coordinate
1394 * frame.
1395 */
1396 LMatrix3f PhysxActor::
1397 get_global_inertia_tensor() const {
1398
1399 nassertr(_error_type == ET_ok, LMatrix3f::ident_mat());
1400 return PhysxManager::nxMat33_to_mat3(_ptr->getGlobalInertiaTensor());
1401 }
1402
1403 /**
1404 * Returns the inverse of the inertia tensor of the actor relative to the
1405 * world coordinate frame.
1406 */
1407 LMatrix3f PhysxActor::
1408 get_global_inertia_tensor_inverse() const {
1409
1410 nassertr(_error_type == ET_ok, LMatrix3f::ident_mat());
1411 return PhysxManager::nxMat33_to_mat3(_ptr->getGlobalInertiaTensorInverse());
1412 }
NodePath
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
Definition: nodePath.h:159
NodePath::is_empty
bool is_empty() const
Returns true if the NodePath contains no nodes.
Definition: nodePath.I:188
NodePath::get_top
NodePath get_top(Thread *current_thread=Thread::get_current_thread()) const
Returns a singleton NodePath that represents the top of the path, or empty NodePath if this path is e...
Definition: nodePath.cxx:209
NodePath::fail
static NodePath fail()
Creates a NodePath with the ET_fail error type set.
Definition: nodePath.I:149
NodePath::set_transform
void set_transform(const TransformState *transform, Thread *current_thread=Thread::get_current_thread())
Changes the complete transform object on this node.
Definition: nodePath.I:565
PhysxActorDesc
Descriptor for PhysxActor.
Definition: physxActorDesc.h:28
PhysxActor::get_c_mass_global_pos
LPoint3f get_c_mass_global_pos() const
Returns the center of mass position in world space.
Definition: physxActor.cxx:1335
PhysxActor::set_c_mass_global_orientation
void set_c_mass_global_orientation(const LMatrix3f &mat)
Moves the actor by setting the orientation of the center of mass.
Definition: physxActor.cxx:1304
PhysxActor::set_name
void set_name(const char *name)
Sets a name string for the object that can be retrieved with get_name().
Definition: physxActor.cxx:119
PhysxActor::move_global_mat
void move_global_mat(const LMatrix4f &mat)
The move_global_* calls serve to move kinematically controlled dynamic actors through the game world.
Definition: physxActor.cxx:289
PhysxActor::get_node_path
NodePath get_node_path() const
Retrieves a previously attached NodePath.
Definition: physxActor.cxx:348
PhysxActor::get_name
const char * get_name() const
Retrieves the name string.
Definition: physxActor.cxx:131
PhysxActor::add_local_torque
void add_local_torque(const LVector3f torque, PhysxForceMode mode=FM_force, bool wakeup=true)
Applies an impulsive torque defined in the actor local coordinate frame to the actor.
Definition: physxActor.cxx:608
PhysxActor::save_to_desc
void save_to_desc(PhysxActorDesc &actorDesc) const
Saves the state of the actor to the passed descriptor.
Definition: physxActor.cxx:108
PhysxActor::get_global_inertia_tensor_inverse
LMatrix3f get_global_inertia_tensor_inverse() const
Returns the inverse of the inertia tensor of the actor relative to the world coordinate frame.
Definition: physxActor.cxx:1408
PhysxActor::put_to_sleep
void put_to_sleep()
Forces the actor to sleep.
Definition: physxActor.cxx:1194
PhysxActor::set_linear_momentum
void set_linear_momentum(const LVector3f &momentum)
Sets the linear momentum of the actor.
Definition: physxActor.cxx:1023
PhysxActor::add_force_at_local_pos
void add_force_at_local_pos(const LVector3f force, const LPoint3f &pos, PhysxForceMode mode=FM_force, bool wakeup=true)
Applies a force (or impulse) defined in the global coordinate frame, acting at a particular point in ...
Definition: physxActor.cxx:505
PhysxActor::set_body_flag
void set_body_flag(PhysxBodyFlag flag, bool value)
Raise or lower individual BodyFlag flags.
Definition: physxActor.cxx:692
PhysxActor::set_contact_report_threshold
void set_contact_report_threshold(float threshold)
Sets the force threshold for contact reports.
Definition: physxActor.cxx:768
PhysxActor::add_local_force
void add_local_force(const LVector3f force, PhysxForceMode mode=FM_force, bool wakeup=true)
Applies a force (or impulse) defined in the actor local coordinate frame to the actor.
Definition: physxActor.cxx:542
PhysxActor::update_transform
void update_transform(const LMatrix4f &m)
Updates the transform of an assigned NodePath.
Definition: physxActor.cxx:143
PhysxActor::get_shape_by_name
PhysxShape * get_shape_by_name(const char *name) const
Retrieves an individual shape from the actor's array of shapes.
Definition: physxActor.cxx:427
PhysxActor::get_angular_momentum
LVector3f get_angular_momentum() const
Retrieves the angular momentum of an actor.
Definition: physxActor.cxx:1059
PhysxActor::set_c_mass_offset_local_pos
void set_c_mass_offset_local_pos(const LPoint3f &pos)
Sets the position of the center of mass relative to the actor.
Definition: physxActor.cxx:1234
PhysxActor::set_group
void set_group(unsigned int group)
Assigns the actor to a user defined group of actors.
Definition: physxActor.cxx:789
PhysxActor::set_linear_velocity
void set_linear_velocity(const LVector3f &linVel)
Sets the linear velocity of the actor.
Definition: physxActor.cxx:899
PhysxActor::set_dominance_group
void set_dominance_group(unsigned int group)
Assigns dynamic actors a dominance group identifier.
Definition: physxActor.cxx:821
PhysxActor::add_torque
void add_torque(const LVector3f torque, PhysxForceMode mode=FM_force, bool wakeup=true)
Applies an impulsive torque defined in the global coordinate frame to the actor.
Definition: physxActor.cxx:524
PhysxActor::move_global_hpr
void move_global_hpr(float h, float p, float r)
The move_global_* calls serve to move kinematically controlled dynamic actors through the game world.
Definition: physxActor.cxx:306
PhysxActor::set_angular_damping
void set_angular_damping(float angDamp)
Sets the angular damping coefficient.
Definition: physxActor.cxx:847
PhysxActor::get_c_mass_local_orientation
LMatrix3f get_c_mass_local_orientation() const
Returns the center of mass orientation relative to the actor.
Definition: physxActor.cxx:1375
PhysxActor::set_shape_group
void set_shape_group(unsigned int group)
Sets the collision group for all shapes of this actor.
Definition: physxActor.cxx:675
PhysxActor::get_num_shapes
get_num_shapes
Returns the number of shapes assigned to the actor.
Definition: physxActor.h:90
PhysxActor::get_angular_damping
float get_angular_damping() const
Returns the angular damping coefficient.
Definition: physxActor.cxx:859
PhysxActor::set_c_mass_global_mat
void set_c_mass_global_mat(const LMatrix4f &mat)
Moves the actor by setting the transform of the center of mass.
Definition: physxActor.cxx:1284
PhysxActor::get_global_inertia_tensor
LMatrix3f get_global_inertia_tensor() const
Returns the inertia tensor of the actor relative to the world coordinate frame.
Definition: physxActor.cxx:1397
PhysxActor::is_sleeping
bool is_sleeping() const
Returns true if this body is sleeping.
Definition: physxActor.cxx:1162
PhysxActor::set_c_mass_offset_local_mat
void set_c_mass_offset_local_mat(const LMatrix4f &mat)
Sets the matrix of the center of mass relative to the actor.
Definition: physxActor.cxx:1224
PhysxActor::set_c_mass_offset_global_orientation
void set_c_mass_offset_global_orientation(const LMatrix3f &mat)
Sets the orientation of the center of mass relative to world space.
Definition: physxActor.cxx:1274
PhysxActor::get_mass
float get_mass() const
Returns the mass of the actor.
Definition: physxActor.cxx:1214
PhysxActor::set_sleep_linear_velocity
void set_sleep_linear_velocity(float threshold)
Sets the linear velocity below which an actor may go to sleep.
Definition: physxActor.cxx:1075
PhysxActor::update_mass_from_shapes
bool update_mass_from_shapes(float density, float totalMass)
Recomputes a dynamic actor's mass properties from its shapes.
Definition: physxActor.cxx:643
PhysxActor::get_global_pos
LPoint3f get_global_pos() const
Retrieves the actors world space position.
Definition: physxActor.cxx:167
PhysxActor::attach_node_path
void attach_node_path(const NodePath &np)
Attaches a node path to this actor.
Definition: physxActor.cxx:323
PhysxActor::get_group
unsigned int get_group() const
Retrieves the actor group this actor is assigned to.
Definition: physxActor.cxx:801
PhysxActor::wake_up
void wake_up(float wakeCounterValue=NX_SLEEP_INTERVAL)
Wakes up the actor if it is sleeping.
Definition: physxActor.cxx:1178
PhysxActor::add_local_force_at_pos
void add_local_force_at_pos(const LVector3f force, const LPoint3f &pos, PhysxForceMode mode=FM_force, bool wakeup=true)
Applies a force (or impulse) defined in the actor local coordinate frame, acting at a particular poin...
Definition: physxActor.cxx:565
PhysxActor::get_max_angular_velocity
float get_max_angular_velocity() const
Returns the maximum angular velocity permitted for this actor.
Definition: physxActor.cxx:977
PhysxActor::get_scene
PhysxScene * get_scene() const
Retrieves the scene which this actor belongs to.
Definition: physxActor.cxx:359
PhysxActor::add_force
void add_force(const LVector3f force, PhysxForceMode mode=FM_force, bool wakeup=true)
Applies a force (or impulse) defined in the global coordinate frame to the actor.
Definition: physxActor.cxx:458
PhysxActor::get_sleep_energy_threshold
float get_sleep_energy_threshold() const
Returns the energy below which an actor may go to sleep.
Definition: physxActor.cxx:1144
PhysxActor::get_c_mass_local_mat
LMatrix4f get_c_mass_local_mat() const
Returns the center of mass transform relative to the actor.
Definition: physxActor.cxx:1355
PhysxActor::add_force_at_pos
void add_force_at_pos(const LVector3f force, const LPoint3f &pos, PhysxForceMode mode=FM_force, bool wakeup=true)
Applies a force (or impulse) defined in the global coordinate frame, acting at a particular point in ...
Definition: physxActor.cxx:481
PhysxActor::create_shape
PhysxShape * create_shape(PhysxShapeDesc &desc)
Creates a new shape and adds it to the list of shapes of this actor.
Definition: physxActor.cxx:388
PhysxActor::get_actor_flag
bool get_actor_flag(PhysxActorFlag flag) const
Return the specified ActorFlag flag.
Definition: physxActor.cxx:730
PhysxActor::is_dynamic
bool is_dynamic() const
Returns true if the actor is dynamic.
Definition: physxActor.cxx:664
PhysxActor::get_linear_momentum
LVector3f get_linear_momentum() const
Retrieves the linear momentum of an actor.
Definition: physxActor.cxx:1047
PhysxActor::get_shape
get_shape
Retrieves an individual shape from the actor's array of shapes.
Definition: physxActor.h:90
PhysxActor::get_linear_velocity
LVector3f get_linear_velocity() const
Returns the linear velocity of an actor.
Definition: physxActor.cxx:957
PhysxActor::get_sleep_angular_velocity
float get_sleep_angular_velocity() const
Returns the angular velocity below which an actor may go to sleep.
Definition: physxActor.cxx:1132
PhysxActor::get_global_mat
LMatrix4f get_global_mat() const
Retrieves the actors world space transform.
Definition: physxActor.cxx:177
PhysxActor::set_global_hpr
void set_global_hpr(float h, float p, float r)
Method for setting a dynamic actor's orientation in the world.
Definition: physxActor.cxx:243
PhysxActor::set_max_angular_velocity
void set_max_angular_velocity(float maxAngVel)
Lets you set the maximum angular velocity permitted for this actor.
Definition: physxActor.cxx:945
PhysxActor::add_local_force_at_local_pos
void add_local_force_at_local_pos(const LVector3f force, const LPoint3f &pos, PhysxForceMode mode=FM_force, bool wakeup=true)
Applies a force (or impulse) defined in the actor local coordinate frame, acting at a particular poin...
Definition: physxActor.cxx:589
PhysxActor::set_actor_flag
void set_actor_flag(PhysxActorFlag flag, bool value)
Raise or lower individual ActorFlag flags.
Definition: physxActor.cxx:716
PhysxActor::get_c_mass_local_pos
LPoint3f get_c_mass_local_pos() const
Returns the center of mass position relative to the actor.
Definition: physxActor.cxx:1365
PhysxActor::set_c_mass_offset_global_pos
void set_c_mass_offset_global_pos(const LPoint3f &pos)
Sets the position of the center of mass relative to world space.
Definition: physxActor.cxx:1264
PhysxActor::set_c_mass_global_pos
void set_c_mass_global_pos(const LPoint3f &pos)
Moves the actor by setting the position of the center of mass.
Definition: physxActor.cxx:1294
PhysxActor::get_angular_velocity
LVector3f get_angular_velocity() const
Returns the angular velocity of the actor.
Definition: physxActor.cxx:967
PhysxActor::set_c_mass_offset_local_orientation
void set_c_mass_offset_local_orientation(const LMatrix3f &mat)
Sets the orientation of the center of mass relative to the actor.
Definition: physxActor.cxx:1244
PhysxActor::get_point_velocity
LVector3f get_point_velocity(const LPoint3f &point) const
Computes the velocity of a point given in world coordinates if it were attached to the actor and movi...
Definition: physxActor.cxx:990
PhysxActor::get_local_point_velocity
LVector3f get_local_point_velocity(const LPoint3f &point) const
Computes the velocity of a point given in body local coordinates as if it were attached to the actor ...
Definition: physxActor.cxx:1006
PhysxActor::set_mass
void set_mass(float mass)
Sets the mass of a dynamic actor.
Definition: physxActor.cxx:1204
PhysxActor::get_body_flag
bool get_body_flag(PhysxBodyFlag flag) const
Return the specified BodyFlag flag.
Definition: physxActor.cxx:706
PhysxActor::get_global_quat
LQuaternionf get_global_quat() const
Retrieves the actors world space orientation.
Definition: physxActor.cxx:187
PhysxActor::detach_node_path
void detach_node_path()
Detaches a previously assigned NodePath from this actor.
Definition: physxActor.cxx:336
PhysxActor::get_c_mass_global_mat
LMatrix4f get_c_mass_global_mat() const
Returns the center of mass transform in world space.
Definition: physxActor.cxx:1325
PhysxActor::set_linear_damping
void set_linear_damping(float linDamp)
Sets the linear damping coefficient.
Definition: physxActor.cxx:871
PhysxActor::set_contact_report_flag
void set_contact_report_flag(PhysxContactPairFlag flag, bool value)
Sets the actor's contact report flags.
Definition: physxActor.cxx:748
PhysxActor::get_sleep_linear_velocity
float get_sleep_linear_velocity() const
Returns the linear velocity below which an actor may go to sleep.
Definition: physxActor.cxx:1120
PhysxActor::set_c_mass_offset_global_mat
void set_c_mass_offset_global_mat(const LMatrix4f &mat)
Sets the matrix of the center of mass relative to world space.
Definition: physxActor.cxx:1254
PhysxActor::set_angular_momentum
void set_angular_momentum(const LVector3f &momentum)
Sets the angular momentum of the actor.
Definition: physxActor.cxx:1036
PhysxActor::save_body_to_desc
bool save_body_to_desc(PhysxBodyDesc &bodyDesc) const
Saves the body information of a dynamic actor to the passed body descriptor.
Definition: physxActor.cxx:98
PhysxActor::compute_kinetic_energy
float compute_kinetic_energy() const
Computes the total kinetic (rotational and translational) energy of the object.
Definition: physxActor.cxx:654
PhysxActor::set_sleep_angular_velocity
void set_sleep_angular_velocity(float threshold)
Sets the angular velocity below which an actor may go to sleep.
Definition: physxActor.cxx:1091
PhysxActor::set_angular_velocity
void set_angular_velocity(const LVector3f &angVel)
Sets the angular velocity of the actor.
Definition: physxActor.cxx:917
PhysxActor::get_dominance_group
unsigned int get_dominance_group() const
Retrieves the dominance group of this actor.
Definition: physxActor.cxx:834
PhysxActor::get_mass_space_inertia_tensor
LVector3f get_mass_space_inertia_tensor() const
Returns the diagonal inertia tensor of the actor relative to the mass coordinate frame.
Definition: physxActor.cxx:1386
PhysxActor::set_global_pos
void set_global_pos(const LPoint3f &pos)
Method for setting a dynamic actor's position in the world.
Definition: physxActor.cxx:198
PhysxActor::set_global_mat
void set_global_mat(const LMatrix4f &mat)
Method for setting a dynamic actor's transform matrix in the world.
Definition: physxActor.cxx:230
PhysxActor::get_c_mass_global_orientation
LMatrix3f get_c_mass_global_orientation() const
Returns the center of mass orientation in world space.
Definition: physxActor.cxx:1345
PhysxActor::set_sleep_energy_threshold
void set_sleep_energy_threshold(float threshold)
Sets the energy threshold below which an actor may go to sleep.
Definition: physxActor.cxx:1108
PhysxActor::set_mass_space_inertia_tensor
void set_mass_space_inertia_tensor(const LVector3f &m)
Sets the inertia tensor, using a parameter specified in mass space coordinates.
Definition: physxActor.cxx:1315
PhysxActor::move_global_pos
void move_global_pos(const LPoint3f &pos)
The move_global_* calls serve to move kinematically controlled dynamic actors through the game world.
Definition: physxActor.cxx:261
PhysxActor::get_linear_damping
float get_linear_damping() const
Retrieves the linear damping coefficient.
Definition: physxActor.cxx:883
PhysxBodyDesc
Descriptor for the optional rigid body dynamic state of PhysxActor.
Definition: physxBodyDesc.h:26
PhysxController
Abstract base class for character controllers.
Definition: physxController.h:30
PhysxManager::vec3_to_nxVec3
static NxVec3 vec3_to_nxVec3(const LVector3f &v)
Converts from LVector3f to NxVec3.
Definition: physxManager.I:27
PhysxManager::point3_to_nxVec3
static NxVec3 point3_to_nxVec3(const LPoint3f &p)
Converts from LPoint3f to NxVec3.
Definition: physxManager.I:63
PhysxManager::mat4_to_nxMat34
static NxMat34 mat4_to_nxMat34(const LMatrix4f &m)
Converts from LMatrix4f to NxMat34.
Definition: physxManager.I:119
PhysxManager::nxVec3_to_point3
static LPoint3f nxVec3_to_point3(const NxVec3 &p)
Converts from NxVec3 to LPoint3f.
Definition: physxManager.I:72
PhysxManager::nxMat33_to_mat3
static LMatrix3f nxMat33_to_mat3(const NxMat33 &m)
Converts from NxMat33 to LMatrix3f.
Definition: physxManager.I:150
PhysxManager::quat_to_nxQuat
static NxQuat quat_to_nxQuat(const LQuaternionf &q)
Converts from LQuaternionf to NxQuat.
Definition: physxManager.I:99
PhysxManager::nxQuat_to_quat
static LQuaternionf nxQuat_to_quat(const NxQuat &q)
Converts from NxQuat to LQuaternionf.
Definition: physxManager.I:110
PhysxManager::mat3_to_nxMat33
static NxMat33 mat3_to_nxMat33(const LMatrix3f &m)
Converts from LMatrix3f to NxMat33.
Definition: physxManager.I:139
PhysxManager::nxVec3_to_vec3
static LVector3f nxVec3_to_vec3(const NxVec3 &v)
Converts from NxVec3 to LVector3f.
Definition: physxManager.I:36
PhysxManager::nxMat34_to_mat4
static LMatrix4f nxMat34_to_mat4(const NxMat34 &m)
Converts from NxMat34 to LMatrix4f.
Definition: physxManager.I:130
PhysxScene
A scene is a collection of bodies, constraints, and effectors which can interact.
Definition: physxScene.h:69
PhysxShapeDesc
Abstract base class for shape descriptors.
Definition: physxShapeDesc.h:29
PhysxShape
Abstract base class for shapes.
Definition: physxShape.h:39
TypeHandle
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
physxActorDesc.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
physxActor.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
physxBodyDesc.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
physxManager.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
physxShapeDesc.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.