Skip to main content

TriangleVisibilityUtility

A static class in Root.Township, the global namespace.

Editor-time mesh tool that finds triangles which can never be seen, using raycasts and small offscreen renders. StaticObjectCombiner uses it to strip hidden faces from combined meshes.

Methods​

MemberWhat it is
static void CalculateOccludedTriangles(Mesh mesh, int renderResolution, List<RemovingTriangle> trianglesToRemove, Func<Vector3, bool> validateVertex = null, IEnumerable<Vector3> additionalCheckPoints = null, Func<Vector3, Vector3, Vector3, bool> triangleValidation = null)Fills a list with the mesh's triangles that no vertex raycast or test render from around the mesh can see.
3 private and internal methods
MemberWhat it is
private static bool CheckVisibilityAroundAxis(float distance, TriangleVisibilityUtility.RenderingHandler renderingParameters, Vector3 center, Vector3 planeVector, ref Vector3 normalDirection, Quaternion axisRotation)Tilts the view direction and tries 8 angles around the triangle's normal; returns true if none of them sees the triangle.
private static void RaycastForVertices(Func<Vector3, bool> validateVertex, List<Vector3> vertices, List<Vector3> normals, bool hasNormals, bool[] checks, int layer, bool[] nonValid, Vector3 additionalPoint)Marks vertices that a raycast from the given point reaches unblocked, so their triangles are kept.
private static IEnumerable<Quaternion> Rotations() (iterator)The 14 view directions used for raycasting: 6 axis directions and 8 diagonals.