From 2bbf14c1e8ae2f3eaef2681748db7b0abc8a82c9 Mon Sep 17 00:00:00 2001 From: ihsoft Date: Mon, 23 May 2016 22:06:57 -0700 Subject: [PATCH] Fix assembly meshes regression FindModelComponents only finds meshes in the part, not in the assembly. Go thru all the children to collect the meshes. Old implementation had a bug anyways: same meshes could get collected multiple times. --- Plugins/Source/KISAddonPointer.cs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Plugins/Source/KISAddonPointer.cs b/Plugins/Source/KISAddonPointer.cs index 5ccef7b1..e5b8e789 100644 --- a/Plugins/Source/KISAddonPointer.cs +++ b/Plugins/Source/KISAddonPointer.cs @@ -691,7 +691,7 @@ private static void CollectMeshesFromAssembly(Part assembly, // Always use world transformation from the root. var rootWorldTransform = worldTransform ?? assembly.transform.localToWorldMatrix.inverse; - // This gives part's mesh(es) and all surface attached children part meshes. + // Get all meshes from the part's model. MeshFilter[] meshFilters = assembly.FindModelComponents(); if (meshFilters.Length > 0) { Logger.logInfo("Found {0} children meshes in: {1}", meshFilters.Length, assembly); @@ -703,7 +703,8 @@ private static void CollectMeshesFromAssembly(Part assembly, } } - // Skinned meshes are only availabe via the renderers. + // Skinned meshes are baked on every frame before rendering. Bake them to get current mesh + // state. var skinnedMeshRenderers = assembly.FindModelComponents(); if (skinnedMeshRenderers.Length > 0) { Logger.logInfo("Found {0} skinned meshes in: {1}", skinnedMeshRenderers.Length, assembly); @@ -715,12 +716,10 @@ private static void CollectMeshesFromAssembly(Part assembly, meshCombines.Add(combine); } } - - // Go thru the stacked children parts. They don't have local transformation. + + // Collect meshes from the children parts. foreach (Part child in assembly.children) { - if (child.transform.position.Equals(child.transform.localPosition)) { - CollectMeshesFromAssembly(child, meshCombines, worldTransform: rootWorldTransform); - } + CollectMeshesFromAssembly(child, meshCombines, worldTransform: rootWorldTransform); } } }