Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ///
- ///Header
- ///
- #include "Box2D\Box2D.h"
- class RayCastListener: public b2RayCastCallback
- {
- protected:
- bool intersectedObject;
- public:
- bool ObjectIntersected();
- RayCastListener();
- ~RayCastListener(void);
- float32 ReportFixture(b2Fixture* fixture, const b2Vec2& point,const b2Vec2& normal, float32 fraction);
- };
- ///
- ///Source
- ///
- #include "RayCastListener.h"
- RayCastListener::RayCastListener():intersectedObject(false){}
- RayCastListener::~RayCastListener(void){}
- float32 RayCastListener::ReportFixture(b2Fixture* fixture, const b2Vec2& point,const b2Vec2& normal, float32 fraction){
- intersectedObject = true;
- return 0.0f;
- }
- bool RayCastListener::ObjectIntersected(){
- return intersectedObject;
- }
- ///
- ///To Use
- ///
- RayCasListener *rayCastListener = new RayCastListener(mWorld)
- mWorld->RayCast(rayCastListener,startPoint,endPoint);
- if(rayCastListener->ObjectIntersected()){
- //hit something
- }
- delete rayCastListener;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement