Update of /cvsroot/opal/opal/src/ODE
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17961/src/ODE
Modified Files:
ODEJoint.cpp ODEJoint.h ODESolid.cpp
Log Message:
Fixed bugs in Joint::getAnchor and Joint::getAxis. Previously they returned the initial anchor and axis. Now they return the current anchor and axis.
Index: ODEJoint.h
===================================================================
RCS file: /cvsroot/opal/opal/src/ODE/ODEJoint.h,v
retrieving revision 1.32
retrieving revision 1.33
diff -C2 -d -r1.32 -r1.33
*** ODEJoint.h 8 Mar 2005 22:05:04 -0000 1.32
--- ODEJoint.h 4 May 2005 21:04:18 -0000 1.33
***************
*** 66,69 ****
--- 66,73 ----
virtual void OPAL_CALL setLimitBounciness(int axisNum, real b);
+ virtual JointAxis OPAL_CALL getAxis(int axisNum)const;
+
+ virtual Point3r OPAL_CALL getAnchor()const;
+
virtual void OPAL_CALL internal_update();
Index: ODESolid.cpp
===================================================================
RCS file: /cvsroot/opal/opal/src/ODE/ODESolid.cpp,v
retrieving revision 1.85
retrieving revision 1.86
diff -C2 -d -r1.85 -r1.86
*** ODESolid.cpp 27 Apr 2005 02:28:19 -0000 1.85
--- ODESolid.cpp 4 May 2005 21:04:18 -0000 1.86
***************
*** 394,405 ****
}
if (sleeping)
{
- mData.sleeping = true;
dBodyDisable(mBodyID);
}
else
{
- mData.sleeping = false;
dBodyEnable(mBodyID);
}
--- 394,405 ----
}
+ // Note: mData.sleeping gets updated in Solid::getData.
+
if (sleeping)
{
dBodyDisable(mBodyID);
}
else
{
dBodyEnable(mBodyID);
}
Index: ODEJoint.cpp
===================================================================
RCS file: /cvsroot/opal/opal/src/ODE/ODEJoint.cpp,v
retrieving revision 1.29
retrieving revision 1.30
diff -C2 -d -r1.29 -r1.30
*** ODEJoint.cpp 8 Mar 2005 22:05:03 -0000 1.29
--- ODEJoint.cpp 4 May 2005 21:04:01 -0000 1.30
***************
*** 433,436 ****
--- 433,539 ----
}
+ JointAxis ODEJoint::getAxis(int axisNum)const
+ {
+ // Silently ignore invalid axes.
+ if (axisNum < 0 || axisNum >= mNumAxes)
+ {
+ return JointAxis();
+ }
+
+ // First we need to get an updated direction vector from ODE.
+ dVector3 direction;
+
+ switch(mData.getType())
+ {
+ case HINGE_JOINT:
+ dJointGetHingeAxis(mJointID, direction);
+ break;
+ case UNIVERSAL_JOINT:
+ if (0 == axisNum)
+ {
+ dJointGetUniversalAxis1(mJointID, direction);
+ }
+ else
+ {
+ dJointGetUniversalAxis2(mJointID, direction);
+ }
+ break;
+ case BALL_JOINT:
+ if (0 == axisNum)
+ {
+ dJointGetAMotorAxis(mAMotorID, 0, direction);
+ }
+ else if (1 == axisNum)
+ {
+ dJointGetAMotorAxis(mAMotorID, 1, direction);
+ }
+ else
+ {
+ dJointGetAMotorAxis(mAMotorID, 2, direction);
+ }
+ break;
+ case SLIDER_JOINT:
+ dJointGetSliderAxis(mJointID, direction);
+ break;
+ case WHEEL_JOINT:
+ if (0 == axisNum)
+ {
+ dJointGetHinge2Axis1(mJointID, direction);
+ }
+ else
+ {
+ dJointGetHinge2Axis2(mJointID, direction);
+ }
+ break;
+ case FIXED_JOINT:
+ // Fixed Joints don't have any axes.
+ break;
+ default:
+ assert(false);
+ break;
+ }
+
+ JointAxis axis = mData.axis[axisNum];
+
+ // All data in this JointAxis is valid except for the direction
+ // vector.
+ axis.direction.set(direction[0], direction[1], direction[2]);
+
+ return axis;
+ }
+
+ Point3r ODEJoint::getAnchor()const
+ {
+ // We need to get an updated anchor point from ODE.
+ dVector3 anchor;
+
+ switch(mData.getType())
+ {
+ case HINGE_JOINT:
+ dJointGetHingeAnchor(mJointID, anchor);
+ break;
+ case UNIVERSAL_JOINT:
+ dJointGetUniversalAnchor(mJointID, anchor);
+ break;
+ case BALL_JOINT:
+ dJointGetBallAnchor(mJointID, anchor);
+ break;
+ case SLIDER_JOINT:
+ // Slider Joints don't have an anchor point.
+ break;
+ case WHEEL_JOINT:
+ dJointGetHinge2Anchor(mJointID, anchor);
+ break;
+ case FIXED_JOINT:
+ // Fixed Joints don't have an anchor point.
+ break;
+ default:
+ assert(false);
+ break;
+ }
+
+ return Point3r(anchor[0], anchor[1], anchor[2]);
+ }
+
void ODEJoint::internal_update()
{
|