3 Copyright 2007 Antoine Chavasse <a.chavasse@gmail.com>
5 This file is part of Fail.
7 Fail is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License version 3
9 as published by the Free Software Foundation.
11 Fail is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #ifndef FAIL_COLLISION_RAYCOLLISION_H_
20 #define FAIL_COLLISION_RAYCOLLISION_H_
22 #include "core/core.h"
23 #include "collision/collision_export.h"
24 #include "math/math.h"
27 namespace fail
{ namespace collision
29 struct FLCOLLISION_EXPORT RayCollision
33 bool rayTest( Pointer
< Ray
> pRay
, Pointer
< PlaceableGeom
> pGeom
)
37 pRay
->updatePosition();
38 pGeom
->updatePosition();
40 if( !dCollide( pRay
->m_GeomID
, pGeom
->m_GeomID
, 1, &contact
, 0 ) )
43 m_position
.x() = contact
.pos
[0];
44 m_position
.y() = contact
.pos
[1];
45 m_position
.z() = contact
.pos
[2];
47 m_normal
.x() = contact
.normal
[0];
48 m_normal
.y() = contact
.normal
[1];
49 m_normal
.z() = contact
.normal
[2];
51 m_depth
= contact
.depth
;
56 math::Vector3f
& position() { return m_position
; }
57 math::Vector3f
& normal() { return m_normal
; }
58 float& depth() { return m_depth
; }
59 const math::Vector3f
& position() const { return m_position
; }
60 const math::Vector3f
& normal() const { return m_normal
; }
61 const float& depth() const { return m_depth
; }
64 math::Vector3f m_position
;
65 math::Vector3f m_normal
;