Skip to main content

LodMeshJoiner

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

Static helper that merges all renderers of each LOD level in a prefab's LODGroup into one mesh per level, keeping skinning data when present. Used by CombinedMeshSource.

Fields​

16 private and internal fields
MemberWhat it is
private static List<Matrix4x4> bindPosesShared buffer for the joined mesh's bind poses.
private static List<BoneWeight> boneWeightsShared buffer for the joined mesh's bone weights.
private static List<Color> colorsShared buffer for the joined mesh's vertex colours; black is filled in for meshes without colours.
private static List<Vector3> normalsShared buffer for the joined mesh's normals.
private static List<Vector4> tangentsShared buffer for the joined mesh's tangents.
private static List<int> trianglesShared buffer for the joined mesh's triangle indices.
private static List<Vector2> uvShared buffer for the joined mesh's first UV channel.
private static List<Vector3> verticesShared buffer for the joined mesh's vertices.
private static List<Matrix4x4> workingBindPosesScratch buffer for one source mesh's bind poses.
private static List<BoneWeight> workingBoneWeightsScratch buffer for one source mesh's bone weights.
private static List<Color> workingColorsScratch buffer for one source mesh's colours.
private static List<Vector3> workingNormalsScratch buffer for one source mesh's normals.
private static List<Vector4> workingTangentsScratch buffer for one source mesh's tangents.
private static List<int> workingTrianglesScratch buffer for one source mesh's triangles.
private static List<Vector2> workingUvScratch buffer for one source mesh's UVs.
private static List<Vector3> workingVerticesScratch buffer for one source mesh's vertices.

Methods​

MemberWhat it is
static void Batch(GameObject prefab, ref Mesh[] meshes, Transform[] bones)Sorts the prefab's renderers by LOD level and builds or refills one joined mesh per level into meshes, remapped to bones.
2 private and internal methods
MemberWhat it is
private static int GetLODLevel(LOD[] lods, Renderer renderer)Returns the LOD level a renderer belongs to, or -1 if it is not in the group.
private static void JoinMeshes(Transform origin, int lod, List<Renderer> renderers, ref Mesh mesh, Transform[] bones)Combines one LOD level's renderers into a single mesh in the prefab's local space, merging bind poses and bone weights for skinned meshes.