Bullet Collision Detection & Physics Library
gim_clip_polygon.h
Go to the documentation of this file.
1#ifndef GIM_CLIP_POLYGON_H_INCLUDED
2#define GIM_CLIP_POLYGON_H_INCLUDED
3
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 Najera. 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 (3) The zlib/libpng license that is included with this library in
26 the file GIMPACT-LICENSE-ZLIB.TXT.
27
28 This library is distributed in the hope that it will be useful,
29 but WITHOUT ANY WARRANTY; without even the implied warranty of
30 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files
31 GIMPACT-LICENSE-LGPL.TXT, GIMPACT-LICENSE-ZLIB.TXT and GIMPACT-LICENSE-BSD.TXT for more details.
32
33-----------------------------------------------------------------------------
34*/
35
36
39{
40public:
41 template<typename CLASS_POINT,typename CLASS_PLANE>
42 inline GREAL operator()(const CLASS_PLANE & plane, const CLASS_POINT & point)
43 {
44 return DISTANCE_PLANE_POINT(plane, point);
45 }
46};
47
48
49
50template<typename CLASS_POINT>
52 const CLASS_POINT & point0,
53 const CLASS_POINT & point1,
58{
62 {
66 }
67 if(!_classif)
68 {
71 }
72}
73
74
76
79template<typename CLASS_POINT,typename CLASS_PLANE, typename DISTANCE_PLANE_FUNC>
81 const CLASS_PLANE & plane,
85{
87
88
89 //clip first point
91 if(!(firstdist>G_EPSILON))
92 {
95 }
96
99 {
101
104 olddist,
105 dist,
106 clipped,
108
109
110 olddist = dist;
111 }
112
113 //RETURN TO FIRST point
114
117 olddist,
118 firstdist,
119 clipped,
121
122 return clipped_count;
123}
124
126
129template<typename CLASS_POINT,typename CLASS_PLANE, typename DISTANCE_PLANE_FUNC>
131 const CLASS_PLANE & plane,
132 const CLASS_POINT & point0,
133 const CLASS_POINT & point1,
134 const CLASS_POINT & point2,
136{
138
139 //clip first point
141 if(!(firstdist>G_EPSILON))
142 {
145 }
146
147 // point 1
150
153 olddist,
154 dist,
155 clipped,
157
158 olddist = dist;
159
160
161 // point 2
162 dist = distance_func(plane,point2);
163
166 olddist,
167 dist,
168 clipped,
170 olddist = dist;
171
172
173
174 //RETURN TO FIRST point
177 olddist,
178 firstdist,
179 clipped,
181
182 return clipped_count;
183}
184
185
186template<typename CLASS_POINT,typename CLASS_PLANE>
188 const CLASS_PLANE & plane,
192{
194}
195
196
197template<typename CLASS_POINT,typename CLASS_PLANE>
199 const CLASS_PLANE & plane,
200 const CLASS_POINT & point0,
201 const CLASS_POINT & point1,
202 const CLASS_POINT & point2,
204{
206}
207
208
209
210#endif // GIM_TRI_COLLISION_H_INCLUDED
const T & btMax(const T &a, const T &b)
Definition btMinMax.h:29
#define SIMD_FORCE_INLINE
Definition btScalar.h:81
This function calcs the distance from a 3D plane.
GREAL operator()(const CLASS_PLANE &plane, const CLASS_POINT &point)
#define DISTANCE_PLANE_POINT(plane, point)
GUINT PLANE_CLIP_POLYGON3D(const CLASS_PLANE &plane, const CLASS_POINT *polygon_points, GUINT polygon_point_count, CLASS_POINT *clipped)
GUINT PLANE_CLIP_POLYGON_GENERIC(const CLASS_PLANE &plane, const CLASS_POINT *polygon_points, GUINT polygon_point_count, CLASS_POINT *clipped, DISTANCE_PLANE_FUNC distance_func)
Clips a polygon by a plane.
GUINT PLANE_CLIP_TRIANGLE3D(const CLASS_PLANE &plane, const CLASS_POINT &point0, const CLASS_POINT &point1, const CLASS_POINT &point2, CLASS_POINT *clipped)
GUINT PLANE_CLIP_TRIANGLE_GENERIC(const CLASS_PLANE &plane, const CLASS_POINT &point0, const CLASS_POINT &point1, const CLASS_POINT &point2, CLASS_POINT *clipped, DISTANCE_PLANE_FUNC distance_func)
Clips a polygon by a plane.
void PLANE_CLIP_POLYGON_COLLECT(const CLASS_POINT &point0, const CLASS_POINT &point1, GREAL dist0, GREAL dist1, CLASS_POINT *clipped, GUINT &clipped_count)
#define VEC_COPY(b, a)
Copy 3D vector.
#define VEC_BLEND(vr, a, b, s)
#define GREAL
Definition gim_math.h:39
#define GUINT
Definition gim_math.h:42
#define G_EPSILON
Definition gim_math.h:60