Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/ode/ode-0.9/GIMPACT/include/GIMPACT/gim_tri_capsule_collision.h @ 216

Last change on this file since 216 was 216, checked in by mathiask, 16 years ago

[Physik] add ode-0.9

File size: 3.6 KB
Line 
1#ifndef GIM_TRI_CAPSULE_COLLISION_H_INCLUDED
2#define GIM_TRI_CAPSULE_COLLISION_H_INCLUDED
3
4/*! \file gim_tri_capsule_collision.h
5\author Francisco León
6*/
7/*
8-----------------------------------------------------------------------------
9This source file is part of GIMPACT Library.
10
11For the latest info, see http://gimpact.sourceforge.net/
12
13Copyright (c) 2006 Francisco Leon. C.C. 80087371.
14email: projectileman@yahoo.com
15
16 This library is free software; you can redistribute it and/or
17 modify it under the terms of EITHER:
18   (1) The GNU Lesser General Public License as published by the Free
19       Software Foundation; either version 2.1 of the License, or (at
20       your option) any later version. The text of the GNU Lesser
21       General Public License is included with this library in the
22       file GIMPACT-LICENSE-LGPL.TXT.
23   (2) The BSD-style license that is included with this library in
24       the file GIMPACT-LICENSE-BSD.TXT.
25
26 This library is distributed in the hope that it will be useful,
27 but WITHOUT ANY WARRANTY; without even the implied warranty of
28 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files
29 GIMPACT-LICENSE-LGPL.TXT and GIMPACT-LICENSE-BSD.TXT for more details.
30
31-----------------------------------------------------------------------------
32*/
33
34#include "GIMPACT/gim_memory.h"
35
36/*! \addtogroup GEOMETRIC_OPERATIONS
37*/
38//! @{
39
40//! Capsule struct
41struct GIM_CAPSULE_DATA
42{
43    GREAL m_radius;
44    vec3f m_point1;
45    vec3f m_point2;
46};
47//typedef struct _GIM_CAPSULE_DATA GIM_CAPSULE_DATA;
48
49#define CALC_CAPSULE_AABB(capsule,aabb)\
50{\
51    if(capsule.m_point1[0]<capsule.m_point2[0])\
52    {\
53        aabb.minX = capsule.m_point1[0] - capsule.m_radius;\
54        aabb.maxX = capsule.m_point2[0] + capsule.m_radius;\
55    }\
56    else\
57    {\
58        aabb.minX = capsule.m_point2[0] - capsule.m_radius;\
59        aabb.maxX = capsule.m_point1[0] + capsule.m_radius;\
60    }\
61    if(capsule.m_point1[1]<capsule.m_point2[1])\
62    {\
63        aabb.minY = capsule.m_point1[1] - capsule.m_radius;\
64        aabb.maxY = capsule.m_point2[1] + capsule.m_radius;\
65    }\
66    else\
67    {\
68        aabb.minY = capsule.m_point2[1] - capsule.m_radius;\
69        aabb.maxY = capsule.m_point1[1] + capsule.m_radius;\
70    }\
71    if(capsule.m_point1[2]<capsule.m_point2[2])\
72    {\
73        aabb.minZ = capsule.m_point1[2] - capsule.m_radius;\
74        aabb.maxZ = capsule.m_point2[2] + capsule.m_radius;\
75    }\
76    else\
77    {\
78        aabb.minZ = capsule.m_point2[2] - capsule.m_radius;\
79        aabb.maxZ = capsule.m_point1[2] + capsule.m_radius;\
80    }\
81}\
82
83//! Utility function for find the closest point between a segment and a triangle
84/*!
85
86\param triangle
87\param s1
88\param s2
89\param contacts Contains the closest points on the segment (1,2), and the normal points to segment, and m_depth contains the distance
90
91\post The contacts array is not set to 0. It adds aditional contacts
92*/
93void gim_closest_point_triangle_segment(GIM_TRIANGLE_DATA * triangle, vec3f s1,vec3f s2, GDYNAMIC_ARRAY * contacts);
94
95
96
97
98
99//! Utility function for find the closest point between a capsule and a triangle
100/*!
101
102\param triangle
103\param capsule
104\param contacts Contains the closest points on the capsule, and the normal points to triangle
105\return 1 if the triangle collides the capsule
106\post The contacts array is not set to 0. It adds aditional contacts
107*/
108int gim_triangle_capsule_collision(GIM_TRIANGLE_DATA * triangle, GIM_CAPSULE_DATA * capsule, GDYNAMIC_ARRAY * contacts);
109//! @}
110
111#endif // GIM_TRI_CAPSULE_COLLISION_H_INCLUDED
Note: See TracBrowser for help on using the repository browser.