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
This commit is contained in:
parent
861ef750ed
commit
24140708e3
10
OdeWorld.cc
10
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;
|
dGeomID other = o1 == ow->m_pick_ray ? o2 : o1;
|
||||||
ow->m_pick_points.push_back(
|
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;
|
return j;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool RPPickPointComparator(const refptr<OdeWorld::PickPoint> & one,
|
static bool RPPickedGeomComparator(const refptr<OdeWorld::PickedGeom> & one,
|
||||||
const refptr<OdeWorld::PickPoint> & two)
|
const refptr<OdeWorld::PickedGeom> & two)
|
||||||
{
|
{
|
||||||
return one->dist < two->dist;
|
return one->dist < two->dist;
|
||||||
}
|
}
|
||||||
@ -156,9 +156,9 @@ refptr< vector<OdeWorld::Object *> > OdeWorld::pickObjects(
|
|||||||
dSpaceCollide2(m_pick_ray, (dGeomID) m_space,
|
dSpaceCollide2(m_pick_ray, (dGeomID) m_space,
|
||||||
this, OdeWorld_pick_collide_callback);
|
this, OdeWorld_pick_collide_callback);
|
||||||
std::sort(m_pick_points.begin(), m_pick_points.end(),
|
std::sort(m_pick_points.begin(), m_pick_points.end(),
|
||||||
RPPickPointComparator);
|
RPPickedGeomComparator);
|
||||||
refptr< vector<Object *> > ret = new vector<Object *>();
|
refptr< vector<Object *> > ret = new vector<Object *>();
|
||||||
for (vector< refptr<PickPoint> >::const_iterator it = m_pick_points.begin();
|
for (vector< refptr<PickedGeom> >::const_iterator it = m_pick_points.begin();
|
||||||
it != m_pick_points.end();
|
it != m_pick_points.end();
|
||||||
it++)
|
it++)
|
||||||
{
|
{
|
||||||
|
38
OdeWorld.h
38
OdeWorld.h
@ -17,18 +17,6 @@ class OdeWorld
|
|||||||
public:
|
public:
|
||||||
enum GeomType { BOX, SPHERE, PLANE, CYLINDER, CAPSULE };
|
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
|
class Object
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -88,6 +76,30 @@ class OdeWorld
|
|||||||
dGeomID cloneGeom(dGeomID geom, dBodyID body);
|
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();
|
||||||
~OdeWorld();
|
~OdeWorld();
|
||||||
|
|
||||||
@ -183,7 +195,7 @@ class OdeWorld
|
|||||||
dJointGroupID m_contactJointGroup;
|
dJointGroupID m_contactJointGroup;
|
||||||
std::map<dBodyID, int> m_bodies;
|
std::map<dBodyID, int> m_bodies;
|
||||||
dGeomID m_pick_ray;
|
dGeomID m_pick_ray;
|
||||||
std::vector< refptr<PickPoint> > m_pick_points;
|
std::vector< refptr<PickedGeom> > m_pick_points;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user