1 #ifndef GIM_CLIP_POLYGON_H_INCLUDED     2 #define GIM_CLIP_POLYGON_H_INCLUDED    41         template<
typename CLASS_POINT,
typename CLASS_PLANE>
    50 template<
typename CLASS_POINT>
    52                                                 const CLASS_POINT & point0,
    53                                                 const CLASS_POINT & point1,
    56                                                 CLASS_POINT * clipped,
    57                                                 GUINT & clipped_count)
    61         if(_classif!=_prevclassif)
    63                 GREAL blendfactor = -dist0/(dist1-dist0);
    64                 VEC_BLEND(clipped[clipped_count],point0,point1,blendfactor);
    69                 VEC_COPY(clipped[clipped_count],point1);
    79 template<
typename CLASS_POINT,
typename CLASS_PLANE, 
typename DISTANCE_PLANE_FUNC>
    81                                                 const CLASS_PLANE & plane,
    82                                                 const CLASS_POINT * polygon_points,
    83                                                 GUINT polygon_point_count,
    84                                                 CLASS_POINT * clipped,DISTANCE_PLANE_FUNC distance_func)
    86     GUINT clipped_count = 0;
    90         GREAL firstdist = distance_func(plane,polygon_points[0]);;
    93                 VEC_COPY(clipped[clipped_count],polygon_points[0]);
    97         GREAL olddist = firstdist;
    98         for(
GUINT _i=1;_i<polygon_point_count;_i++)
   100                 GREAL dist = distance_func(plane,polygon_points[_i]);
   103                                                 polygon_points[_i-1],polygon_points[_i],
   116                                         polygon_points[polygon_point_count-1],polygon_points[0],
   122         return clipped_count;
   129 template<
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,
   135                                                 CLASS_POINT * clipped,DISTANCE_PLANE_FUNC distance_func)
   137     GUINT clipped_count = 0;
   140         GREAL firstdist = distance_func(plane,point0);;
   143                 VEC_COPY(clipped[clipped_count],point0);
   148         GREAL olddist = firstdist;
   149         GREAL dist = distance_func(plane,point1);
   162         dist = distance_func(plane,point2);
   182         return clipped_count;
   186 template<
typename CLASS_POINT,
typename CLASS_PLANE>
   188                                                 const CLASS_PLANE & plane,
   189                                                 const CLASS_POINT * polygon_points,
   190                                                 GUINT polygon_point_count,
   191                                                 CLASS_POINT * clipped)
   193         return PLANE_CLIP_POLYGON_GENERIC<CLASS_POINT,CLASS_PLANE>(plane,polygon_points,polygon_point_count,clipped,
DISTANCE_PLANE_3D_FUNC());
   197 template<
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,
   203                                                 CLASS_POINT * clipped)
   205         return PLANE_CLIP_TRIANGLE_GENERIC<CLASS_POINT,CLASS_PLANE>(plane,point0,point1,point2,clipped,
DISTANCE_PLANE_3D_FUNC());
   210 #endif // GIM_TRI_COLLISION_H_INCLUDED 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. 
GUINT PLANE_CLIP_POLYGON3D(const CLASS_PLANE &plane, const CLASS_POINT *polygon_points, GUINT polygon_point_count, CLASS_POINT *clipped)
#define SIMD_FORCE_INLINE
#define VEC_COPY(b, a)
Copy 3D vector. 
GREAL operator()(const CLASS_PLANE &plane, const CLASS_POINT &point)
This function calcs the distance from a 3D plane. 
GUINT PLANE_CLIP_TRIANGLE3D(const CLASS_PLANE &plane, const CLASS_POINT &point0, const CLASS_POINT &point1, const CLASS_POINT &point2, CLASS_POINT *clipped)
void PLANE_CLIP_POLYGON_COLLECT(const CLASS_POINT &point0, const CLASS_POINT &point1, GREAL dist0, GREAL dist1, CLASS_POINT *clipped, GUINT &clipped_count)
#define DISTANCE_PLANE_POINT(plane, point)
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. 
#define VEC_BLEND(vr, a, b, s)