public Poly ClipToList(Poly poly, bool clipOnPlane) { switch (ClassifyPoly(poly)) { case eCP.FRONT: return(poly.CopyPoly()); case eCP.BACK: if (IsLast) { return(null); } return(Next.ClipToList(poly, clipOnPlane)); case eCP.ONPLANE: float angle = Vector3.Dot(plane.n, poly.plane.n) - 1; if (angle < Mathf.EPSILON && angle > -Mathf.EPSILON) { if (!clipOnPlane) { return(poly.CopyPoly()); } } if (IsLast) { return(null); } return(Next.ClipToList(poly, clipOnPlane)); case eCP.SPLIT: Poly front = null; Poly back = null; SplitPoly(poly, ref front, ref back); if (IsLast) { return(front); } Poly backFrags = Next.ClipToList(back, clipOnPlane); if (backFrags == null) { return(front); } if (backFrags == back) { return(poly.CopyPoly()); } front.AddPoly(backFrags); return(front); } return(null); }