/// <summary> /// Test if the angle between next edge and current edge is less or equal to 180 degrees. /// </summary> /// <param name="currentEdge">Current Edge</param> /// <param name="nextEdge">Next Edge</param> /// <param name="cw">Direction is clockwise?</param> /// <returns></returns> private int TestInnerSide(Edge currentEdge, Edge nextEdge, bool cw) { PlaneMath plane = new PlaneMath(currentEdge.Left, currentEdge.Normal); float pointSide = plane.PointSide(cw ? nextEdge.Right : nextEdge.Left); if (pointSide < -.000001f) // less than zero with a threshold, inner side { return(1); } if (pointSide < .000001f) // < 180 degree angle, needs to be melted { return(0); } return(-1); }
private void SplitTriangle(int offset) { int i0 = offset % 3; int i1 = (1 + offset) % 3; int i2 = (2 + offset) % 3; int indexHit0 = _mesh.AddLerpVertex(triIndicies[i0], triIndicies[i1], lineLerp[i0]); int indexHit1 = _mesh.AddLerpVertex(triIndicies[i1], triIndicies[i2], lineLerp[i1]); AddCapIndex(indexHit0); AddCapIndex(indexHit1); smallTri[0] = indexHit0; smallTri[1] = triIndicies[i1]; smallTri[2] = indexHit1; bigTri[0] = triIndicies[i0]; bigTri[1] = indexHit0; bigTri[2] = indexHit1; bigTri[3] = triIndicies[i0]; bigTri[4] = indexHit1; bigTri[5] = triIndicies[i2]; if (_splitPlane.PointSide(_mesh.wsVerts[triIndicies[i1]]) > 0f) { _mesh.trisUp.Add(smallTri[0]); _mesh.trisUp.Add(smallTri[1]); _mesh.trisUp.Add(smallTri[2]); _mesh.trisDown.Add(bigTri[0]); _mesh.trisDown.Add(bigTri[1]); _mesh.trisDown.Add(bigTri[2]); _mesh.trisDown.Add(bigTri[3]); _mesh.trisDown.Add(bigTri[4]); _mesh.trisDown.Add(bigTri[5]); #if UNITY_EDITOR if (ShowDebug) { DrawDebugTri(smallTri, Color.cyan); DrawDebugTriDouble(bigTri, Color.magenta); } #endif } else { _mesh.trisDown.Add(smallTri[0]); _mesh.trisDown.Add(smallTri[1]); _mesh.trisDown.Add(smallTri[2]); _mesh.trisUp.Add(bigTri[0]); _mesh.trisUp.Add(bigTri[1]); _mesh.trisUp.Add(bigTri[2]); _mesh.trisUp.Add(bigTri[3]); _mesh.trisUp.Add(bigTri[4]); _mesh.trisUp.Add(bigTri[5]); #if UNITY_EDITOR if (ShowDebug) { DrawDebugTri(smallTri, Color.magenta); DrawDebugTriDouble(bigTri, Color.cyan); } #endif } }