public void Split(Vector3 P0, Vector3 n, Shape2 shapeAbove, Shape2 shapeBelow, NewPointsGetter newPoints, ref int numInside) { LinkedPoint1 = null; LinkedPoint2 = null; var comp = Vector3.Dot(Point - P0, n); if (Mathf.Abs(comp) <= Utils.PointInPlaneTol) { var newAbove = this; var newBelow = new Point2(Point); newPoints.AddPoints(this, newAbove, newBelow); shapeAbove.AddPoint(newAbove); shapeBelow.AddPoint(newBelow); PlaneRelationship = PointPlaneRelationship.Inside; numInside++; } else if (comp > 0.0f) { shapeAbove.AddPoint(this); PlaneRelationship = PointPlaneRelationship.Above; } else { shapeBelow.AddPoint(this); PlaneRelationship = PointPlaneRelationship.Below; } }
private void SplitInHalf(Vector3 x, NewPointsGetter newPoints, Shape2 shapeAbove, Shape2 shapeBelow) { var a = new Point2(x); var b = new Point2(x); newPoints.AddPoints(EdgeP1, EdgeP2, a, b); shapeAbove.AddPoint(a); shapeBelow.AddPoint(b); if (EdgeP1.PlaneRelationship == PointPlaneRelationship.Above) { var newForBelow = new Edge2(EdgeP2, b); EdgeP2 = a; shapeAbove.Edges.Add(this); shapeBelow.Edges.Add(newForBelow); } else { var newForAbove = new Edge2(EdgeP2, a); EdgeP2 = b; shapeAbove.Edges.Add(newForAbove); shapeBelow.Edges.Add(this); } }