Panda3D
bulletSphericalConstraint.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 bulletSphericalConstraint.cxx
10  * @author enn0x
11  * @date 2010-03-01
12  */
13 
15 
16 #include "bulletRigidBodyNode.h"
17 #include "bulletWorld.h"
18 
19 TypeHandle BulletSphericalConstraint::_type_handle;
20 
21 /**
22  *
23  */
24 BulletSphericalConstraint::
25 BulletSphericalConstraint(const BulletRigidBodyNode *node_a,
26  const LPoint3 &pivot_a) {
27 
28  btRigidBody *ptr_a = btRigidBody::upcast(node_a->get_object());
29  btVector3 pos_a = LVecBase3_to_btVector3(pivot_a);
30 
31  _constraint = new btPoint2PointConstraint(*ptr_a, pos_a);
32 }
33 
34 /**
35  *
36  */
37 BulletSphericalConstraint::
38 BulletSphericalConstraint(const BulletRigidBodyNode *node_a,
39  const BulletRigidBodyNode *node_b,
40  const LPoint3 &pivot_a,
41  const LPoint3 &pivot_b) {
42 
43  btRigidBody *ptr_a = btRigidBody::upcast(node_a->get_object());
44  btVector3 pos_a = LVecBase3_to_btVector3(pivot_a);
45 
46  btRigidBody *ptr_b = btRigidBody::upcast(node_b->get_object());
47  btVector3 pos_b = LVecBase3_to_btVector3(pivot_b);
48 
49  _constraint = new btPoint2PointConstraint(*ptr_a, *ptr_b, pos_a, pos_b);
50 }
51 
52 /**
53  *
54  */
55 btTypedConstraint *BulletSphericalConstraint::
56 ptr() const {
57 
58  return _constraint;
59 }
60 
61 /**
62  *
63  */
64 void BulletSphericalConstraint::
65 set_pivot_a(const LPoint3 &pivot_a) {
66  LightMutexHolder holder(BulletWorld::get_global_lock());
67 
68  nassertv(!pivot_a.is_nan());
69  _constraint->setPivotA(LVecBase3_to_btVector3(pivot_a));
70 }
71 
72 /**
73  *
74  */
75 void BulletSphericalConstraint::
76 set_pivot_b(const LPoint3 &pivot_b) {
77  LightMutexHolder holder(BulletWorld::get_global_lock());
78 
79  nassertv(!pivot_b.is_nan());
80  _constraint->setPivotB(LVecBase3_to_btVector3(pivot_b));
81 }
82 
83 /**
84  *
85  */
86 LPoint3 BulletSphericalConstraint::
87 get_pivot_in_a() const {
88  LightMutexHolder holder(BulletWorld::get_global_lock());
89 
90  return btVector3_to_LPoint3(_constraint->getPivotInA());
91 }
92 
93 /**
94  *
95  */
96 LPoint3 BulletSphericalConstraint::
97 get_pivot_in_b() const {
98  LightMutexHolder holder(BulletWorld::get_global_lock());
99 
100  return btVector3_to_LPoint3(_constraint->getPivotInB());
101 }
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Similar to MutexHolder, but for a light mutex.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81