[Opal-commits] opal/src/ODE ODEJoint.cpp,1.28,1.29 ODEJoint.h,1.31,1.32 ODESimulator.cpp,1.85,1.86 O
Status: Inactive
Brought to you by:
tylerstreeter
|
From: tylerstreeter <tyl...@us...> - 2005-03-08 22:05:23
|
Update of /cvsroot/opal/opal/src/ODE In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13926/src/ODE Modified Files: ODEJoint.cpp ODEJoint.h ODESimulator.cpp ODESimulator.h Log Message: added a "contacts enabled" feature to Joints Index: ODESimulator.h =================================================================== RCS file: /cvsroot/opal/opal/src/ODE/ODESimulator.h,v retrieving revision 1.58 retrieving revision 1.59 diff -C2 -d -r1.58 -r1.59 *** ODESimulator.h 3 Mar 2005 04:39:57 -0000 1.58 --- ODESimulator.h 8 Mar 2005 22:05:05 -0000 1.59 *************** *** 132,136 **** { // These function don't use the OPAL_CALL calling convention ! // because they are functors passed to ODE which expects a different // calling convention. --- 132,136 ---- { // These function don't use the OPAL_CALL calling convention ! // because they are functors passed to ODE, which expects a different // calling convention. *************** *** 138,141 **** --- 138,146 ---- void internal_collisionCallback(void* data, dGeomID o0, dGeomID o1); + /// Assuming the two ODE bodies are connected by an ODE joint, this + /// function returns the OPAL Joint connecting the two bodies' + /// Solids. + Joint* internal_getCommonJoint(dBodyID body0, dBodyID body1); + /// Special collision callback functor for volume collision /// checking. Index: ODEJoint.h =================================================================== RCS file: /cvsroot/opal/opal/src/ODE/ODEJoint.h,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** ODEJoint.h 4 Mar 2005 23:26:54 -0000 1.31 --- ODEJoint.h 8 Mar 2005 22:05:04 -0000 1.32 *************** *** 74,77 **** --- 74,80 ---- real value); + /// Returns the ODE joint ID of this ODEJoint. + dJointID OPAL_CALL internal_getJointID()const; + protected: virtual void setAxis(int axisNum, const JointAxis& axis); Index: ODESimulator.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/ODE/ODESimulator.cpp,v retrieving revision 1.85 retrieving revision 1.86 diff -C2 -d -r1.85 -r1.86 *** ODESimulator.cpp 8 Mar 2005 16:10:24 -0000 1.85 --- ODESimulator.cpp 8 Mar 2005 22:05:04 -0000 1.86 *************** *** 291,302 **** // 5. Two Solids connected by a Joint (besides ODE // contact joints, which never generate ! // contacts) (note: both must have ! // bodies to check this): this is enforced for now; it ! // might be nice to have a Joint option that says whether ! // the Joint's two ! // Solids generate contacts with each other... I'll ! // mark that as a TODO; if this is implemented, be sure ! // to update the comments for ! // Simulator::setupContactGroups. // 6. Solid0 is static and Solid1 is sleeping: not enforced // because sometimes you might want to wake up a sleeping --- 291,296 ---- // 5. Two Solids connected by a Joint (besides ODE // contact joints, which never generate ! // contacts) with contacts disabled; (note: both must have ! // bodies to check this): this is enforced. // 6. Solid0 is static and Solid1 is sleeping: not enforced // because sometimes you might want to wake up a sleeping *************** *** 314,321 **** } ! // TODO: find a way to get access to the Joint* for #5... ! // check if ODE has user data* for joints. If this ! // doesn't work, just have a boolean in the Simulator that ! // affects all Joints. if (//(0 == o0BodyID && 0 == o1BodyID) //case 1 --- 308,319 ---- } ! Joint* commonJoint = NULL; ! if (bothHaveBodies && dAreConnectedExcluding(o0BodyID, ! o1BodyID, dJointTypeContact)) ! { ! // This will become non-NULL only if there exists an ODE ! // joint connecting the two bodies. ! commonJoint = internal_getCommonJoint(o0BodyID, o1BodyID); ! } if (//(0 == o0BodyID && 0 == o1BodyID) //case 1 *************** *** 323,330 **** (bothHaveBodies && !dBodyIsEnabled(o0BodyID) && !dBodyIsEnabled(o1BodyID)) //case 3 ! //|| (connected by a fixed joint) // case 4 TODO ! || (bothHaveBodies && dAreConnectedExcluding( ! o0BodyID, o1BodyID, dJointTypeContact)) //&& TODO ! //jointContactsEnabled) //case 5 //|| (0 == o0BodyID && !dBodyIsEnabled(o1BodyID)) //case 6 //|| (0 == o1BodyID && !dBodyIsEnabled(o0BodyID)) //case 7 --- 321,328 ---- (bothHaveBodies && !dBodyIsEnabled(o0BodyID) && !dBodyIsEnabled(o1BodyID)) //case 3 ! || (commonJoint && ! commonJoint->getType() == FIXED_JOINT) // case 4 ! || (commonJoint && ! !commonJoint->areContactsEnabled()) // case 5 //|| (0 == o0BodyID && !dBodyIsEnabled(o1BodyID)) //case 6 //|| (0 == o1BodyID && !dBodyIsEnabled(o0BodyID)) //case 7 *************** *** 650,653 **** --- 648,687 ---- } + Joint* internal_getCommonJoint(dBodyID body0, dBodyID body1) + { + // First we need to find the ODE joint connecting the bodies + // (it would be ideal if ODE included this functionality...). + // We only need to check one of the bodies' ODE joints + // because it is assumed here that the two bodies are + // connected, thus they should have a common ODE joint. + int numJoints0 = dBodyGetNumJoints(body0); + dJointID theJoint = 0; + + // Loop through body0's ODE joints. + int i=0; + for (i=0; i<numJoints0; ++i) + { + dJointID currentJoint = dBodyGetJoint(body0, i); + dBodyID jointBody0 = dJointGetBody(currentJoint, 0); + dBodyID jointBody1 = dJointGetBody(currentJoint, 1); + + if ((jointBody0 == body0 && jointBody1 == body1) || + (jointBody0 == body1 && jointBody1 == body0)) + { + // This is the ODE joint connecting the two bodies. + // Note that if the two bodies are connected by multiple + // Joints, the behavior is undefined. + theJoint = currentJoint; + } + } + + // Make sure the ODE joint was actually found. This should + // be guaranteed. + assert(theJoint); + + // Now return the associated OPAL Joint. + return (Joint*)dJointGetData(theJoint); + } + // Note: o0 should always be the main object (the geom to check against // everything else). Index: ODEJoint.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/ODE/ODEJoint.cpp,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** ODEJoint.cpp 8 Mar 2005 16:10:24 -0000 1.28 --- ODEJoint.cpp 8 Mar 2005 22:05:03 -0000 1.29 *************** *** 208,211 **** --- 208,221 ---- setAxis(1, data.axis[1]); setAxis(2, data.axis[2]); + + // Set the ODE joint's userdata pointer. + if (BALL_JOINT == mData.getType()) + { + dJointSetData(mAMotorID, this); + } + else + { + dJointSetData(mJointID, this); + } } *************** *** 865,868 **** --- 875,890 ---- } + dJointID ODEJoint::internal_getJointID()const + { + if (BALL_JOINT == mData.getType()) + { + return mAMotorID; + } + else + { + return mJointID; + } + } + void ODEJoint::attachODEBodies(Solid* s0, Solid* s1) { |