From 24140708e34dd4ef282d481ba998703de429fb11 Mon Sep 17 00:00:00 2001 From: josh Date: Thu, 16 Sep 2010 20:05:18 +0000 Subject: [PATCH] renamed OdeWorld::PickPoint to OdeWorld::PickedGeom and added OdeWorld::PickedObject in preparation for returning 3d coordinates along with picked objects git-svn-id: svn://anubis/misc/OdeWorld@239 bd8a9e45-a331-0410-811e-c64571078777 --- OdeWorld.cc | 10 +++++----- OdeWorld.h | 38 +++++++++++++++++++++++++------------- 2 files changed, 30 insertions(+), 18 deletions(-) diff --git a/OdeWorld.cc b/OdeWorld.cc index db7b5e7..a472bd3 100644 --- a/OdeWorld.cc +++ b/OdeWorld.cc @@ -47,7 +47,7 @@ void OdeWorld_pick_collide_callback(void * data, dGeomID o1, dGeomID o2) { dGeomID other = o1 == ow->m_pick_ray ? o2 : o1; ow->m_pick_points.push_back( - new OdeWorld::PickPoint(other, contact_geom.depth)); + new OdeWorld::PickedGeom(other, contact_geom.depth)); } } @@ -140,8 +140,8 @@ dJointID OdeWorld::createHinge(dBodyID b1, dBodyID b2, return j; } -static bool RPPickPointComparator(const refptr & one, - const refptr & two) +static bool RPPickedGeomComparator(const refptr & one, + const refptr & two) { return one->dist < two->dist; } @@ -156,9 +156,9 @@ refptr< vector > OdeWorld::pickObjects( dSpaceCollide2(m_pick_ray, (dGeomID) m_space, this, OdeWorld_pick_collide_callback); std::sort(m_pick_points.begin(), m_pick_points.end(), - RPPickPointComparator); + RPPickedGeomComparator); refptr< vector > ret = new vector(); - for (vector< refptr >::const_iterator it = m_pick_points.begin(); + for (vector< refptr >::const_iterator it = m_pick_points.begin(); it != m_pick_points.end(); it++) { diff --git a/OdeWorld.h b/OdeWorld.h index 23eff2a..543d695 100644 --- a/OdeWorld.h +++ b/OdeWorld.h @@ -17,18 +17,6 @@ class OdeWorld public: enum GeomType { BOX, SPHERE, PLANE, CYLINDER, CAPSULE }; - class PickPoint - { - public: - dGeomID geom; - float dist; - - PickPoint(dGeomID g, float d) - : geom(g), dist(d) - { - } - }; - class Object { public: @@ -88,6 +76,30 @@ class OdeWorld dGeomID cloneGeom(dGeomID geom, dBodyID body); }; + class PickedGeom + { + public: + dGeomID geom; + float dist; + + PickedGeom(dGeomID g, float d) + : geom(g), dist(d) + { + } + }; + + class PickedObject + { + public: + Object * obj; + float dist; + + PickedObject(Object * obj, float dist) + : obj(obj), dist(dist) + { + } + }; + OdeWorld(); ~OdeWorld(); @@ -183,7 +195,7 @@ class OdeWorld dJointGroupID m_contactJointGroup; std::map m_bodies; dGeomID m_pick_ray; - std::vector< refptr > m_pick_points; + std::vector< refptr > m_pick_points; }; #endif