How to get the name of a entity a ray or a ray sensor collides with?
In my sensor plugin, I have a ray sensor which casts a single ray. From this ray, I would like to get the name of the entity with which the ray intersects.
I have a working workaround by creating a test_ray (physics::RayShapePtr) and calling test_ray->GetIntersection() every time my ray measures a finite distance. However, it doesn't feel like the right way to do and furthermore, I get occasional segfaults which are caused somehow by underlying collision checks of the test_ray->GetIntersection() call.
Is there a better way to get the entity name?
In my plugin I have access to the parent ray sensor which is of type sensors::RaySensorPtr. From the parent sensor I can access the LaserShape (physics::MultiRayShapePtr), but apparently not the single ray (tried getChild(0) already).
Cheers,