Bullet Collision Detection & Physics Library
btClipPolygon.h
Go to the documentation of this file.
1#ifndef BT_CLIP_POLYGON_H_INCLUDED
2#define BT_CLIP_POLYGON_H_INCLUDED
3
7/*
8This source file is part of GIMPACT Library.
9
10For the latest info, see http://gimpact.sourceforge.net/
11
12Copyright (c) 2007 Francisco Leon Najera. C.C. 80087371.
13email: projectileman@yahoo.com
14
15
16This software is provided 'as-is', without any express or implied warranty.
17In no event will the authors be held liable for any damages arising from the use of this software.
18Permission is granted to anyone to use this software for any purpose,
19including commercial applications, and to alter it and redistribute it freely,
20subject to the following restrictions:
21
221. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
232. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
243. This notice may not be removed or altered from any source distribution.
25*/
26
29
30
32{
33 return point.dot(plane) - plane[3];
34}
35
39{
41}
42
45 const btVector3 & point0,
46 const btVector3 & point1,
50 int & clipped_count)
51{
55 {
59 }
60 if(!_classif)
61 {
64 }
65}
66
67
69
73 const btVector4 & plane,
77{
78 int clipped_count = 0;
79
80
81 //clip first point
84 {
87 }
88
90 for(int i=1;i<polygon_point_count;i++)
91 {
93
96 olddist,
97 dist,
98 clipped,
100
101
102 olddist = dist;
103 }
104
105 //RETURN TO FIRST point
106
109 olddist,
110 firstdist,
111 clipped,
113
114 return clipped_count;
115}
116
118
123 const btVector4 & plane,
124 const btVector3 & point0,
125 const btVector3 & point1,
126 const btVector3& point2,
127 btVector3 * clipped // an allocated array of 16 points at least
128 )
129{
130 int clipped_count = 0;
131
132 //clip first point0
135 {
138 }
139
140 // point 1
143
146 olddist,
147 dist,
148 clipped,
150
151 olddist = dist;
152
153
154 // point 2
156
159 olddist,
160 dist,
161 clipped,
163 olddist = dist;
164
165
166
167 //RETURN TO FIRST point0
170 olddist,
171 firstdist,
172 clipped,
174
175 return clipped_count;
176}
177
178
179
180
181
182#endif // GIM_TRI_COLLISION_H_INCLUDED
void bt_plane_clip_polygon_collect(const btVector3 &point0, const btVector3 &point1, btScalar dist0, btScalar dist1, btVector3 *clipped, int &clipped_count)
This function calcs the distance from a 3D plane.
int bt_plane_clip_triangle(const btVector4 &plane, const btVector3 &point0, const btVector3 &point1, const btVector3 &point2, btVector3 *clipped)
Clips a polygon by a plane.
btScalar bt_distance_point_plane(const btVector4 &plane, const btVector3 &point)
void bt_vec_blend(btVector3 &vr, const btVector3 &va, const btVector3 &vb, btScalar blend_factor)
int bt_plane_clip_polygon(const btVector4 &plane, const btVector3 *polygon_points, int polygon_point_count, btVector3 *clipped)
Clips a polygon by a plane.
const T & btMax(const T &a, const T &b)
Definition btMinMax.h:29
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
Definition btScalar.h:292
#define SIMD_FORCE_INLINE
Definition btScalar.h:81
#define SIMD_EPSILON
Definition btScalar.h:521
btVector3 can be used to represent 3D points and vectors.
Definition btVector3.h:84
btScalar dot(const btVector3 &v) const
Return the dot product.
Definition btVector3.h:235