Panda3D
bulletSoftBodyControl.cxx
1 // Filename: bulletSoftBodyControl.cxx
2 // Created by: enn0x (04Mar10)
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 "bulletSoftBodyControl.h"
16 
17 ////////////////////////////////////////////////////////////////////
18 // Function: BulletSoftBodyControl::Constructor
19 // Access: Published
20 // Description:
21 ////////////////////////////////////////////////////////////////////
22 BulletSoftBodyControl::
23 BulletSoftBodyControl() {
24 
25  _goal = 0.0;
26  _maxtorque = 0.0;
27 
28  _angle = 0.0;
29  _sign = 0.0;
30 }
31 
32 ////////////////////////////////////////////////////////////////////
33 // Function: BulletSoftBodyControl::Destructor
34 // Access: Published
35 // Description:
36 ////////////////////////////////////////////////////////////////////
37 BulletSoftBodyControl::
38 ~BulletSoftBodyControl() {
39 
40 }
41 
42 ////////////////////////////////////////////////////////////////////
43 // Function: BulletSoftBodyControl::Prepare
44 // Access: Public
45 // Description:
46 ////////////////////////////////////////////////////////////////////
47 void BulletSoftBodyControl::
48 Prepare(btSoftBody::AJoint* joint) {
49 
50  if (btFabs(_sign) > 0.0) {
51  joint->m_refs[0][0] = btCos(_angle * _sign);
52  joint->m_refs[0][2] = btSin(_angle * _sign);
53  }
54 }
55 
56 ////////////////////////////////////////////////////////////////////
57 // Function: BulletSoftBodyControl::Speed
58 // Access: Public
59 // Description:
60 ////////////////////////////////////////////////////////////////////
61 btScalar BulletSoftBodyControl::
62 Speed(btSoftBody::AJoint *, btScalar current) {
63 
64  return (current + btMin(_maxtorque, btMax(-_maxtorque, _goal - current)));
65 }
66