Cuts the polygon at the plane. If the polygon is entirely above or below the plane, one of the returned polygons will be empty.
61 above._vertex.resize(0);
62 below._vertex.resize(0);
73 Vector3 polyNormal =
normal();
74 Vector3 planeNormal= plane.normal();
77 if (planeNormal.fuzzyEq(polyNormal) || planeNormal.fuzzyEq(-polyNormal)) {
84 plane.getEquation(a,b,c,d);
85 float r = (float)(a * pt.x + b * pt.y + c * pt.z + d);
105 bool lastAbove = plane.halfSpaceContains(
_vertex[v]);
108 above._vertex.append(
_vertex[v]);
110 below._vertex.append(
_vertex[v]);
113 for (v = 1; v <
length; ++v) {
114 bool isAbove = plane.halfSpaceContains(
_vertex[v]);
116 if (lastAbove ^ isAbove) {
121 Vector3 interp = line.intersection(plane);
123 if (! interp.isFinite()) {
132 above._vertex.resize(0);
137 above._vertex.append(interp);
138 below._vertex.append(interp);
140 newEdge.stop = interp;
142 newEdge.start = interp;
149 above._vertex.append(
_vertex[v]);
151 below._vertex.append(
_vertex[v]);
157 bool isAbove = plane.halfSpaceContains(
_vertex[0]);
158 if (lastAbove ^ isAbove) {
160 Vector3 interp = line.intersection(plane);
161 if (! interp.isFinite()) {
169 above._vertex.resize(0);
174 above._vertex.append(interp);
175 below._vertex.append(interp);
176 debugAssertM(count < 2,
"Convex polygons may only intersect planes at two edges.");
178 newEdge.stop = interp;
180 newEdge.start = interp;
185 debugAssertM((count == 2) || (count == 0),
"Convex polygons may only intersect planes at two edges.");
Array< Vector3 > _vertex
Definition: ConvexPolyhedron.h:37
#define debugAssertM(exp, message)
Definition: debugAssert.h:161
float length(float v)
Definition: vectorMath.h:208
bool isEmpty() const
Definition: ConvexPolyhedron.cpp:29
bool fuzzyGe(double a, double b)
Definition: g3dmath.h:869
static Line fromTwoPoints(const Vector3 &point1, const Vector3 &point2)
Definition: Line.h:52
Vector3 normal() const
Definition: ConvexPolyhedron.h:100