Panda3D
 All Classes Functions Variables Enumerations
bulletSphericalConstraint.cxx
1 // Filename: bulletSphericalConstraint.cxx
2 // Created by: enn0x (01Mar10)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #include "bulletSphericalConstraint.h"
16 #include "bulletRigidBodyNode.h"
17 
18 TypeHandle BulletSphericalConstraint::_type_handle;
19 
20 ////////////////////////////////////////////////////////////////////
21 // Function: BulletSphericalConstraint::Constructor
22 // Access: Published
23 // Description:
24 ////////////////////////////////////////////////////////////////////
25 BulletSphericalConstraint::
26 BulletSphericalConstraint(const BulletRigidBodyNode *node_a,
27  const LPoint3 &pivot_a) {
28 
29  btRigidBody *ptr_a = btRigidBody::upcast(node_a->get_object());
30  btVector3 pos_a = LVecBase3_to_btVector3(pivot_a);
31 
32  _constraint = new btPoint2PointConstraint(*ptr_a, pos_a);
33 }
34 
35 ////////////////////////////////////////////////////////////////////
36 // Function: BulletSphericalConstraint::Constructor
37 // Access: Published
38 // Description:
39 ////////////////////////////////////////////////////////////////////
40 BulletSphericalConstraint::
41 BulletSphericalConstraint(const BulletRigidBodyNode *node_a,
42  const BulletRigidBodyNode *node_b,
43  const LPoint3 &pivot_a,
44  const LPoint3 &pivot_b) {
45 
46  btRigidBody *ptr_a = btRigidBody::upcast(node_a->get_object());
47  btVector3 pos_a = LVecBase3_to_btVector3(pivot_a);
48 
49  btRigidBody *ptr_b = btRigidBody::upcast(node_b->get_object());
50  btVector3 pos_b = LVecBase3_to_btVector3(pivot_b);
51 
52  _constraint = new btPoint2PointConstraint(*ptr_a, *ptr_b, pos_a, pos_b);
53 }
54 
55 ////////////////////////////////////////////////////////////////////
56 // Function: BulletSphericalConstraint::ptr
57 // Access: Public
58 // Description:
59 ////////////////////////////////////////////////////////////////////
60 btTypedConstraint *BulletSphericalConstraint::
61 ptr() const {
62 
63  return _constraint;
64 }
65 
66 ////////////////////////////////////////////////////////////////////
67 // Function: BulletSphericalConstraint::set_pivot_a
68 // Access: Published
69 // Description:
70 ////////////////////////////////////////////////////////////////////
71 void BulletSphericalConstraint::
72 set_pivot_a(const LPoint3 &pivot_a) {
73 
74  nassertv(!pivot_a.is_nan());
75  _constraint->setPivotA(LVecBase3_to_btVector3(pivot_a));
76 }
77 
78 ////////////////////////////////////////////////////////////////////
79 // Function: BulletSphericalConstraint::set_pivot_b
80 // Access: Published
81 // Description:
82 ////////////////////////////////////////////////////////////////////
83 void BulletSphericalConstraint::
84 set_pivot_b(const LPoint3 &pivot_b) {
85 
86  nassertv(!pivot_b.is_nan());
87  _constraint->setPivotB(LVecBase3_to_btVector3(pivot_b));
88 }
89 
90 ////////////////////////////////////////////////////////////////////
91 // Function: BulletSphericalConstraint::set_pivot_in_a
92 // Access: Published
93 // Description:
94 ////////////////////////////////////////////////////////////////////
95 LPoint3 BulletSphericalConstraint::
96 get_pivot_in_a() const {
97 
98  return btVector3_to_LPoint3(_constraint->getPivotInA());
99 }
100 
101 ////////////////////////////////////////////////////////////////////
102 // Function: BulletSphericalConstraint::set_pivot_in_b
103 // Access: Published
104 // Description:
105 ////////////////////////////////////////////////////////////////////
106 LPoint3 BulletSphericalConstraint::
107 get_pivot_in_b() const {
108 
109  return btVector3_to_LPoint3(_constraint->getPivotInB());
110 }
111 
This is a three-component point in space (as opposed to a three-component vector, which represents a ...
Definition: lpoint3.h:99
bool is_nan() const
Returns true if any component of the vector is not-a-number, false otherwise.
Definition: lvecBase3.h:463
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85