C4 Engine
C4 Engine API Documentation


Defined in:  C4Computation.h
Clips a convex polygon against a plane.

int32 ClipPolygon(int32 vertexCount, const Point3D *vertex, const Plane3D& plane, float *restrict location, Point3D *restrict result);

vertexCount The number of vertices defining the boundary of the polygon. This must be at least 3.
vertex An array containing the vertices of the polygon, wound in counterclockwise order.
plane The plane against which the polygon is clipped.
location An array large enough to hold vertexCount elements for internal use.
result An array of points large enough to hold vertexCount + 1 vertices where the clipped polygon is to be returned.
The ClipPolygon function clips the polygon specified by the vertexCount and vertex parameters and clips it against the plane specified by the plane parameter. Any portion of the polygon that lies on the negative side of the clipping plane is removed, and the resulting polygon is stored in the array pointed to by the result parameter. The return value of this function is the number of vertices in the clipped polygon. If the polygon is completely clipped away, then the return value is 0.