本文整理汇总了C#中System.Utils.IntersectSegment方法的典型用法代码示例。如果您正苦于以下问题:C# Utils.IntersectSegment方法的具体用法?C# Utils.IntersectSegment怎么用?C# Utils.IntersectSegment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Utils
的用法示例。
在下文中一共展示了Utils.IntersectSegment方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Cut
//.........这里部分代码省略.........
}
#if PROFILING
MeasureIt.End("CutCycleFirstPass");
MeasureIt.Begin("CutCycleSecondPass");
#endif
AllocateContours(cutTris.Count);
// second pass - cut intersecting triangles in half
foreach (var cutTri in cutTris)
{
var triangle = new Triangle
{
ids = new[] { meshTriangles[cutTri + 0], meshTriangles[cutTri + 1], meshTriangles[cutTri + 2] },
pos = new[] { meshVertices[meshTriangles[cutTri + 0]], meshVertices[meshTriangles[cutTri + 1]], meshVertices[meshTriangles[cutTri + 2]] },
normal = new[] { meshNormals[meshTriangles[cutTri + 0]], meshNormals[meshTriangles[cutTri + 1]], meshNormals[meshTriangles[cutTri + 2]] },
uvs = new[] { meshUV[meshTriangles[cutTri + 0]], meshUV[meshTriangles[cutTri + 1]], meshUV[meshTriangles[cutTri + 2]] }
};
// check points with a plane
var side0 = plane.GetSide(triangle.pos[0]);
var side1 = plane.GetSide(triangle.pos[1]);
var side2 = plane.GetSide(triangle.pos[2]);
float t0, t1;
Vector3 s0, s1;
var idxLeft = side0 ? 0 : 1;
var idxRight = 1 - idxLeft;
if (side0 == side1)
{
var a = plane.IntersectSegment(triangle.pos[2], triangle.pos[0], out t0, out s0);
var b = plane.IntersectSegment(triangle.pos[2], triangle.pos[1], out t1, out s1);
MeshUtils.Assert(a && b, "!!!!!!!!!!!!!!!");
// left side ... 2 triangles
var s0Left = AddIntersectionPoint(s0, triangle, triangle.ids[2], triangle.ids[0], cutVertCache[idxLeft], vertices[idxLeft], normals[idxLeft], uvs[idxLeft]);
var s1Left = AddIntersectionPoint(s1, triangle, triangle.ids[2], triangle.ids[1], cutVertCache[idxLeft], vertices[idxLeft], normals[idxLeft], uvs[idxLeft]);
var v0Left = AddTrianglePoint(triangle.pos[0], triangle.normal[0], triangle.uvs[0], triangle.ids[0], triCache, cornerVertCache[idxLeft], vertices[idxLeft], normals[idxLeft], uvs[idxLeft]);
var v1Left = AddTrianglePoint(triangle.pos[1], triangle.normal[1], triangle.uvs[1], triangle.ids[1], triCache, cornerVertCache[idxLeft], vertices[idxLeft], normals[idxLeft], uvs[idxLeft]);
// Triangle (s0, v0, s1)
triangles[idxLeft].Add(s0Left);
triangles[idxLeft].Add(v0Left);
triangles[idxLeft].Add(s1Left);
// Triangle (s1, v0, v1)
triangles[idxLeft].Add(s1Left);
triangles[idxLeft].Add(v0Left);
triangles[idxLeft].Add(v1Left);
// right side ... 1 triangle
var s0Right = AddIntersectionPoint(s0, triangle, triangle.ids[2], triangle.ids[0], cutVertCache[idxRight], vertices[idxRight], normals[idxRight], uvs[idxRight]);
var s1Right = AddIntersectionPoint(s1, triangle, triangle.ids[2], triangle.ids[1], cutVertCache[idxRight], vertices[idxRight], normals[idxRight], uvs[idxRight]);
var v2Right = AddTrianglePoint(triangle.pos[2], triangle.normal[2], triangle.uvs[2], triangle.ids[2], triCache, cornerVertCache[idxRight], vertices[idxRight], normals[idxRight], uvs[idxRight]);
// Triangle (v2, s0, s1)
triangles[idxRight].Add(v2Right);
triangles[idxRight].Add(s0Right);
triangles[idxRight].Add(s1Right);
// buffer intersection vertices for triangulation
if (triangulateHoles)