Most everything is built as shared libraries now except services.
[fail.git] / include / collision / RayCollision.h
blobee4493c5bca984d92f481f18c6e2843db60079fb
1 #ifndef AWFUL_COLLISION_RAYCOLLISION_H_
2 #define AWFUL_COLLISION_RAYCOLLISION_H_
4 #include "core/core.h"
5 #include "collision/collision_export.h"
6 #include "math/math.h"
7 #include "Ray.h"
9 namespace awful { namespace collision
11 struct AWCOLLISION_EXPORT RayCollision
13 RayCollision() {}
15 bool rayTest( Pointer< Ray > pRay, Pointer< PlaceableGeom > pGeom )
17 dContactGeom contact;
19 pRay->updatePosition();
20 pGeom->updatePosition();
22 if( !dCollide( pRay->m_GeomID, pGeom->m_GeomID, 1, &contact, 0 ) )
23 return false;
25 m_position.x() = contact.pos[0];
26 m_position.y() = contact.pos[1];
27 m_position.z() = contact.pos[2];
29 m_normal.x() = contact.normal[0];
30 m_normal.y() = contact.normal[1];
31 m_normal.z() = contact.normal[2];
33 m_depth = contact.depth;
35 return true;
38 math::Vector3f& position() { return m_position; }
39 math::Vector3f& normal() { return m_normal; }
40 float& depth() { return m_depth; }
41 const math::Vector3f& position() const { return m_position; }
42 const math::Vector3f& normal() const { return m_normal; }
43 const float& depth() const { return m_depth; }
45 private:
46 math::Vector3f m_position;
47 math::Vector3f m_normal;
48 float m_depth;
52 #endif