[Opal-commits] opal/src/ODE ODESimulator.cpp,1.90,1.91 ODESimulator.h,1.63,1.64
Status: Inactive
Brought to you by:
tylerstreeter
|
From: tylerstreeter <tyl...@us...> - 2005-03-14 01:21:16
|
Update of /cvsroot/opal/opal/src/ODE In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27784/src/ODE Modified Files: ODESimulator.cpp ODESimulator.h Log Message: finished implementing RaycastSensor and VolumeSensor Index: ODESimulator.h =================================================================== RCS file: /cvsroot/opal/opal/src/ODE/ODESimulator.h,v retrieving revision 1.63 retrieving revision 1.64 diff -C2 -d -r1.63 -r1.64 *** ODESimulator.h 12 Mar 2005 01:21:15 -0000 1.63 --- ODESimulator.h 14 Mar 2005 01:20:55 -0000 1.64 *************** *** 97,101 **** virtual const RaycastResult& OPAL_CALL internal_fireRay( ! const Rayr& r, real length); /// Helper function used for ray casting. --- 97,101 ---- virtual const RaycastResult& OPAL_CALL internal_fireRay( ! const Rayr& r, real length, const Solid* attachedSolid); /// Helper function used for ray casting. *************** *** 107,111 **** virtual const VolumeQueryResult& OPAL_CALL internal_queryVolume( ! const Solid* volume); protected: --- 107,111 ---- virtual const VolumeQueryResult& OPAL_CALL internal_queryVolume( ! const Solid* volume, const Solid* attachedSolid); protected: *************** *** 132,135 **** --- 132,141 ---- /// Used for ray casting. RaycastResult mRaycastResult; + + /// Used for ray casting and volume queries. If a RaycastSensor or + /// VolumeSensor is attached to a Solid, this pointer will point to + /// that Solid. It is used to make sure the raycasts and collision + /// query doesn't collide with the attached Solid. + const Solid* mSensorSolid; private: }; Index: ODESimulator.cpp =================================================================== RCS file: /cvsroot/opal/opal/src/ODE/ODESimulator.cpp,v retrieving revision 1.90 retrieving revision 1.91 diff -C2 -d -r1.90 -r1.91 *** ODESimulator.cpp 12 Mar 2005 01:21:08 -0000 1.90 --- ODESimulator.cpp 14 Mar 2005 01:20:55 -0000 1.91 *************** *** 76,79 **** --- 76,81 ---- setSolverAccuracy(defaults::solverAccuracy); mCollisionCount = 0; + // "mRaycastResult" is initialized in its own constructor. + mSensorSolid = NULL; } *************** *** 82,85 **** --- 84,108 ---- } + Solid* ODESimulator::createSolid() + { + Solid* newSolid = new ODESolid(mWorldID, mRootSpaceID); + addSolid(newSolid); + return newSolid; + } + + Space* ODESimulator::createSpace() + { + Space* newSpace = new ODESpace(); + addSpace(newSpace); + return newSpace; + } + + Joint* ODESimulator::createJoint() + { + Joint* newJoint = new ODEJoint(mWorldID); + addJoint(newJoint); + return newJoint; + } + void ODESimulator::destroy() { *************** *** 690,694 **** if (dGeomIsSpace(o0) || dGeomIsSpace(o1)) { ! //colliding a space with either a geom or another space dSpaceCollide2(o0, o1, data, &internal_volumeCollisionCallback); --- 713,717 ---- if (dGeomIsSpace(o0) || dGeomIsSpace(o1)) { ! // Colliding a space with either a geom or another space. dSpaceCollide2(o0, o1, data, &internal_volumeCollisionCallback); *************** *** 696,700 **** else { ! //colliding two geoms dBodyID o0BodyID = dGeomGetBody(o0); --- 719,723 ---- else { ! // Colliding two geoms. dBodyID o0BodyID = dGeomGetBody(o0); *************** *** 749,753 **** if (dGeomIsSpace(o0) || dGeomIsSpace(o1)) { ! //colliding a space with either a geom or another space dSpaceCollide2(o0, o1, data, &internal_volumeCollisionCallback); --- 772,776 ---- if (dGeomIsSpace(o0) || dGeomIsSpace(o1)) { ! // Colliding a space with either a geom or another space. dSpaceCollide2(o0, o1, data, &internal_volumeCollisionCallback); *************** *** 755,761 **** else { ! //colliding two geoms ! //now actually test for collision between the two geoms dContactGeom contactArray[1]; int numContacts = dCollide(o0, o1, 1, contactArray, --- 778,784 ---- else { ! // Colliding two geoms. ! // Now actually test for collision between the two geoms. dContactGeom contactArray[1]; int numContacts = dCollide(o0, o1, 1, contactArray, *************** *** 768,772 **** else { ! //these two geoms must be intersecting ODESimulator* sim = (ODESimulator*)data; --- 791,795 ---- else { ! // These two geoms must be intersecting. ODESimulator* sim = (ODESimulator*)data; *************** *** 789,792 **** --- 812,822 ---- void ODESimulator::internal_addCollidedSolid(Solid* solid) { + // If the collided Solid is attached to the Sensor performing the + // volume query, ignore this intersection. + if (mSensorSolid == solid) + { + return; + } + ODESolid* solidPtr = ((ODESolid*)solid); *************** *** 801,804 **** --- 831,843 ---- const Point3r& intersection, const Vec3r& normal, real distance) { + // If the collided Solid is attached to the Sensor performing the + // raycast, ignore this intersection. + if (mSensorSolid == solid) + { + return; + } + + // If this is the first collided Solid or the new intersection + // distance is less than the previous intersection's distance... if (NULL == mRaycastResult.solid || (distance < mRaycastResult.distance)) { *************** *** 830,856 **** //} - Solid* ODESimulator::createSolid() - { - Solid* newSolid = new ODESolid(mWorldID, mRootSpaceID); - addSolid(newSolid); - return newSolid; - } - - Space* ODESimulator::createSpace() - { - Space* newSpace = new ODESpace(); - addSpace(newSpace); - return newSpace; - } - - Joint* ODESimulator::createJoint() - { - Joint* newJoint = new ODEJoint(mWorldID); - addJoint(newJoint); - return newJoint; - } - const RaycastResult& ODESimulator::internal_fireRay(const Rayr& r, ! real length) { Point3r origin = r.getOrigin(); --- 869,874 ---- //} const RaycastResult& ODESimulator::internal_fireRay(const Rayr& r, ! real length, const Solid* attachedSolid) { Point3r origin = r.getOrigin(); *************** *** 861,864 **** --- 879,883 ---- mRaycastResult.normal.set(1,0,0); mRaycastResult.distance = 0; + mSensorSolid = attachedSolid; dGeomID rayGeomID = dCreateRay(mRootSpaceID, length); *************** *** 877,882 **** const VolumeQueryResult& ODESimulator::internal_queryVolume( ! const Solid* volume) { mCollisionCount++; mVolumeQueryResult.internal_clearSolids(); --- 896,902 ---- const VolumeQueryResult& ODESimulator::internal_queryVolume( ! const Solid* volume, const Solid* attachedSolid) { + mSensorSolid = attachedSolid; mCollisionCount++; mVolumeQueryResult.internal_clearSolids(); |