Skip to content

Commit

Permalink
Fix issue in meshcombiner where it creates and claims the shared buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaimi committed Dec 9, 2020
1 parent 6eff87e commit 6953536
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,6 @@ public override void UpdateUMAMesh(bool updatedAtlas, UMAData umaData, int atlas
{
//Move umaMesh creation to with in the renderer loops
//May want to make sure to set all it's buffers to null instead of creating a new UMAMeshData
UMAMeshData umaMesh = new UMAMeshData();
umaMesh.ClaimSharedBuffers();

umaMesh.subMeshCount = 0;
umaMesh.vertexCount = 0;

combinedMeshList.Clear();
combinedMaterialList.Clear();
Expand All @@ -199,6 +194,12 @@ public override void UpdateUMAMesh(bool updatedAtlas, UMAData umaData, int atlas
}
else
{
UMAMeshData umaMesh = new UMAMeshData();
umaMesh.ClaimSharedBuffers();

umaMesh.subMeshCount = 0;
umaMesh.vertexCount = 0;

SkinnedMeshCombiner.CombineMeshes(umaMesh, combinedMeshList.ToArray(), umaData.blendShapeSettings );

if (updatedAtlas)
Expand All @@ -207,6 +208,7 @@ public override void UpdateUMAMesh(bool updatedAtlas, UMAData umaData, int atlas
}

umaMesh.ApplyDataToUnityMesh(renderers[currentRendererIndex], umaData.skeleton);
umaMesh.ReleaseSharedBuffers();
}
var cloth = renderers[currentRendererIndex].GetComponent<Cloth>();
if (clothProperties != null)
Expand All @@ -228,7 +230,6 @@ public override void UpdateUMAMesh(bool updatedAtlas, UMAData umaData, int atlas
combinedMaterialList[i].skinnedMeshRenderer = renderers[currentRendererIndex];
}
renderers[currentRendererIndex].sharedMaterials = materials;
umaMesh.ReleaseSharedBuffers();
}

umaData.umaRecipe.ClearDNAConverters();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ public virtual void UMAReady()
umaData.Show();
umaData.FireUpdatedEvent(false);
umaData.FireCharacterCompletedEvents();
if (umaData.skeleton.boneCount > 300)
if (umaData.skeleton.boneCount > 500)
{
if (Debug.isDebugBuild)
Debug.LogWarning("Skeleton has " + umaData.skeleton.boneCount + " bones, may be an error with slots!");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -593,19 +593,12 @@ public void ApplyDataToUnityMesh(SkinnedMeshRenderer renderer, UMASkeleton skele

Mesh mesh = renderer.sharedMesh;
#if UNITY_EDITOR
#if UNITY_2018_3_OR_NEWER
if (UnityEditor.PrefabUtility.IsAddedComponentOverride(renderer))
{
if (Debug.isDebugBuild)
Debug.LogError("Cannot apply changes to prefab!");
}
#else
if (UnityEditor.PrefabUtility.IsComponentAddedToPrefabInstance(renderer))
{
if (Debug.isDebugBuild)
Debug.LogError("Cannot apply changes to prefab!");
}
#endif

if (UnityEditor.AssetDatabase.IsSubAsset(mesh))
{
if (Debug.isDebugBuild)
Expand Down

0 comments on commit 6953536

Please sign in to comment.