phyjoint.cpp
1 /********************************************************************************
2  * WorldSim -- library for robot simulations *
3  * Copyright (C) 2008-2011 Gianluca Massera <emmegian@yahoo.it> *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the Free Software *
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
18  ********************************************************************************/
19 
20 #include "phyjoint.h"
21 #include "private/phyjointprivate.h"
22 #include "private/phyobjectprivate.h"
23 #include "private/worldprivate.h"
24 
25 #ifdef FARSA_DEBUG
26  #include <QDebug>
27 #endif
28 
29 namespace farsa {
31  dofsv(),
32  dofv(0)
33 {
34  priv = new PhyJointPrivate();
35  this->parentv = parent;
36  if ( parentv == 0 ) {
37  parentpriv = 0;
38  priv->parent = 0;
39  } else {
40  parentpriv = parentv->priv;
41  priv->parent = parentpriv->body;
42  }
43  this->childv = child;
44  childpriv = child->priv;
45  priv->child = childpriv->body;
46  this->worldv = childv->world();
47  worldpriv = worldv->priv;
48  enabled = true;
49  worldv->pushJoint( this );
50 }
51 
53  worldv->popJoint( this );
54 #ifdef WORLDSIM_USE_NEWTON
55  NewtonDestroyJoint( worldpriv->world, priv->joint);
56 #endif
57  delete priv;
58  foreach( PhyDOF* dof, dofsv ) {
59  delete dof;
60  }
61 }
62 
63 void PhyJoint::enable( bool b ) {
64 // if ( enabled == b ) return;
65  enabled = b;
66 // #ifdef WORLDSIM_USE_NEWTON
67 // What do these callbacks do?!?!?!?!?!?
68 // if ( b ) {
69 // NewtonUserJointSetFeedbackCollectorCallback( priv->joint, PhyJointPrivate::userBilateralHandler );
70 // } else {
71 // NewtonUserJointSetFeedbackCollectorCallback( priv->joint, 0 );
72 // }
73 // #endif
74 }
75 
76 } // end namespace farsa