本文整理汇总了C#中System.Utils.GetSideFix方法的典型用法代码示例。如果您正苦于以下问题:C# Utils.GetSideFix方法的具体用法?C# Utils.GetSideFix怎么用?C# Utils.GetSideFix使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Utils
的用法示例。
在下文中一共展示了Utils.GetSideFix方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Cut
float Cut(Mesh mesh, Transform meshTransform, Utils.Plane plane, bool triangulateHoles, bool fixPivot, bool getContourList,
out Mesh mesh0, out Mesh mesh1, out Vector3 centroid0, out Vector3 centroid1, out List<Vector3[]> contoursList)
{
var stopWatch = new Stopwatch();
stopWatch.Start();
#if PROFILING
MeasureIt.Begin("CutAllocations");
#endif
// cache mesh data
var trianglesNum = mesh.triangles.Length;
var verticesNum = mesh.vertices.Length;
var meshTriangles = mesh.triangles;
var meshVertices = mesh.vertices;
var meshNormals = mesh.normals;
var meshUV = mesh.uv;
// preallocate buffers
AllocateBuffers(trianglesNum, verticesNum);
#if PROFILING
MeasureIt.End("CutAllocations");
MeasureIt.Begin("CutCycleFirstPass");
#endif
// inverse transform cutting plane
plane.InverseTransform(meshTransform);
// first pass - find complete triangles on both sides of the plane
for (int i = 0; i < trianglesNum; i += 3)
{
// get triangle points
var v0 = meshVertices[meshTriangles[i]];
var v1 = meshVertices[meshTriangles[i + 1]];
var v2 = meshVertices[meshTriangles[i + 2]];
var side0 = plane.GetSideFix(ref v0);
var side1 = plane.GetSideFix(ref v1);
var side2 = plane.GetSideFix(ref v2);
meshVertices[meshTriangles[i]] = v0;
meshVertices[meshTriangles[i + 1]] = v1;
meshVertices[meshTriangles[i + 2]] = v2;
// all points on one side
if (side0 == side1 && side1 == side2)
{
var idx = side0 ? 0 : 1;
if (triCache[meshTriangles[i]] == 0)
{
triangles[idx].Add(triCounter[idx]);
vertices[idx].Add(meshVertices[meshTriangles[i]]);
normals[idx].Add(meshNormals[meshTriangles[i]]);
uvs[idx].Add(meshUV[meshTriangles[i]]);
centroid[idx] += meshVertices[meshTriangles[i]];
triCache[meshTriangles[i]] = triCounter[idx] + 1;
triCounter[idx]++;
}
else
{
triangles[idx].Add(triCache[meshTriangles[i]] - 1);
}
if (triCache[meshTriangles[i + 1]] == 0)
{
triangles[idx].Add(triCounter[idx]);
vertices[idx].Add(meshVertices[meshTriangles[i + 1]]);
normals[idx].Add(meshNormals[meshTriangles[i + 1]]);
uvs[idx].Add(meshUV[meshTriangles[i + 1]]);
centroid[idx] += meshVertices[meshTriangles[i + 1]];
triCache[meshTriangles[i + 1]] = triCounter[idx] + 1;
triCounter[idx]++;
}
else
{
triangles[idx].Add(triCache[meshTriangles[i + 1]] - 1);
}
if (triCache[meshTriangles[i + 2]] == 0)
{
triangles[idx].Add(triCounter[idx]);
vertices[idx].Add(meshVertices[meshTriangles[i + 2]]);
normals[idx].Add(meshNormals[meshTriangles[i + 2]]);
uvs[idx].Add(meshUV[meshTriangles[i + 2]]);
centroid[idx] += meshVertices[meshTriangles[i + 2]];
triCache[meshTriangles[i + 2]] = triCounter[idx] + 1;
triCounter[idx]++;
}
else
{
triangles[idx].Add(triCache[meshTriangles[i + 2]] - 1);
}
//.........这里部分代码省略.........