Panda3D
physxSphericalJoint.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 physxSphericalJoint.cxx
10  * @author enn0x
11  * @date 2009-10-02
12  */
13 
14 #include "physxSphericalJoint.h"
16 
17 TypeHandle PhysxSphericalJoint::_type_handle;
18 
19 /**
20  *
21  */
22 void PhysxSphericalJoint::
23 link(NxJoint *jointPtr) {
24 
25  _ptr = jointPtr->isSphericalJoint();
26  _ptr->userData = this;
27  _error_type = ET_ok;
28 
29  set_name(jointPtr->getName());
30 
31  PhysxScene *scene = (PhysxScene *)_ptr->getScene().userData;
32  scene->_joints.add(this);
33 }
34 
35 /**
36  *
37  */
38 void PhysxSphericalJoint::
39 unlink() {
40 
41  _ptr->userData = nullptr;
42  _error_type = ET_released;
43 
44  PhysxScene *scene = (PhysxScene *)_ptr->getScene().userData;
45  scene->_joints.remove(this);
46 }
47 
48 /**
49  * Saves the state of the joint object to a descriptor.
50  */
53 
54  nassertv(_error_type == ET_ok);
55  _ptr->saveToDesc(jointDesc._desc);
56 }
57 
58 /**
59  * Loads the entire state of the joint from a descriptor with a single call.
60  */
63 
64  nassertv(_error_type == ET_ok);
65  _ptr->loadFromDesc(jointDesc._desc);
66 }
67 
68 /**
69  * Sets the joint projection mode.
70  */
72 set_projection_mode(PhysxProjectionMode mode) {
73 
74  nassertv(_error_type == ET_ok);
75  _ptr->setProjectionMode((NxJointProjectionMode)mode);
76 }
77 
78 /**
79  * Returns the current projection mode settings.
80  */
81 PhysxEnums::PhysxProjectionMode PhysxSphericalJoint::
83 
84  nassertr(_error_type == ET_ok, PM_none);
85  return (PhysxProjectionMode)_ptr->getProjectionMode();
86 }
87 
88 /**
89  * Sets or clears a single SphericalJointFlag.
90  */
92 set_flag(PhysxSphericalJointFlag flag, bool value) {
93 
94  nassertv(_error_type == ET_ok);
95  NxU32 flags = _ptr->getFlags();
96 
97  if (value == true) {
98  flags |= flag;
99  }
100  else {
101  flags &= ~(flag);
102  }
103 
104  _ptr->setFlags(flags);
105 }
106 
107 /**
108  * Returns the value of a single SphericalJointFlag.
109  */
111 get_flag(PhysxSphericalJointFlag flag) const {
112 
113  nassertr(_error_type == ET_ok, false);
114  return (_ptr->getFlags() & flag) ? true : false;
115 }
void save_to_desc(PhysxSphericalJointDesc &jointDesc) const
Saves the state of the joint object to a descriptor.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A scene is a collection of bodies, constraints, and effectors which can interact.
Definition: physxScene.h:69
Descriptor class for distance joint.
bool get_flag(PhysxSphericalJointFlag flag) const
Returns the value of a single SphericalJointFlag.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PhysxProjectionMode get_projection_mode() const
Returns the current projection mode settings.
void set_projection_mode(PhysxProjectionMode mode)
Sets the joint projection mode.
void set_name(const char *name)
Sets a name string for this object.
Definition: physxJoint.cxx:91
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
void load_from_desc(const PhysxSphericalJointDesc &jointDesc)
Loads the entire state of the joint from a descriptor with a single call.
void set_flag(PhysxSphericalJointFlag flag, bool value)
Sets or clears a single SphericalJointFlag.