874 lines
46 KiB
C#
874 lines
46 KiB
C#
// Warning: Some assembly references could not be resolved automatically. This might lead to incorrect decompilation of some parts,
|
|
// for ex. property getter/setter access. To get optimal decompilation results, please manually add the missing references to the list of loaded assemblies.
|
|
// EdenAutoMorpherScript, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
|
|
// Eden.AutoMorpher.VertexFittingUtil
|
|
using System.Collections.Generic;
|
|
using System.Diagnostics;
|
|
using UnityEngine;
|
|
|
|
public class VertexFittingUtil
|
|
{
|
|
private struct Node
|
|
{
|
|
public int index;
|
|
|
|
public int depth;
|
|
}
|
|
|
|
public void ExpandClothes_World_Test(List<ClothInstance> clothInstances, MeshMatcher meshMatcher, EdenAutoMorpherConfig config, ClothInstanceTotal clothInstanceTotal)
|
|
{
|
|
//IL_0122: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0130: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0135: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_013a: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0148: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_014d: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0181: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0186: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_018d: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_019f: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
|
|
using (AutoMorpherDev.Profile("[Expand] BVH Mesh Matching time"))
|
|
{
|
|
foreach (ClothInstance clothInstance in clothInstances)
|
|
{
|
|
clothInstance.deltas = meshMatcher.ExpandVertexMatch(clothInstance, config.minMargin, config.skipFootFitting);
|
|
}
|
|
}
|
|
foreach (ClothInstance clothInstance2 in clothInstances)
|
|
{
|
|
clothInstance2.deltasLocal = clothInstance2.deltas;
|
|
}
|
|
Vector3[] deltas = clothInstanceTotal.GlobalDeltas;
|
|
clothInstanceTotal.UpdateGlobalBuffersFromClothInstances();
|
|
this.SmoothDeltasByDistance(clothInstanceTotal.GlobalPositions, ref deltas, clothInstanceTotal.GlobalAdjacencyMerged, config.worldRadius, 1, config.smoothingIteration, 0.5f, config.sigma);
|
|
clothInstanceTotal.SetGlobalDeltas(deltas);
|
|
clothInstanceTotal.ApplyGlobalDeltasToClothInstances();
|
|
foreach (ClothInstance clothInstance3 in clothInstances)
|
|
{
|
|
for (int i = 0; i < clothInstance3.worldVertices.Length; i++)
|
|
{
|
|
if (!clothInstance3.excludedVertices[i] || !clothInstance3.isInsideVertex[i])
|
|
{
|
|
ref Vector3 reference = ref clothInstance3.worldVertices[i];
|
|
reference += clothInstance3.deltasLocal[i];
|
|
}
|
|
clothInstance3.deltasLocal[i] = Vector3.zero;
|
|
}
|
|
foreach (List<int> equivalentVertex in clothInstance3.equivalentVertices)
|
|
{
|
|
Vector3 val = Vector3.zero;
|
|
for (int j = 0; j < equivalentVertex.Count; j++)
|
|
{
|
|
val += clothInstance3.worldVertices[equivalentVertex[j]];
|
|
}
|
|
val /= (float)equivalentVertex.Count;
|
|
for (int k = 0; k < equivalentVertex.Count; k++)
|
|
{
|
|
clothInstance3.worldVertices[equivalentVertex[k]] = val;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public void ShrinkClothes_World_Test(List<ClothInstance> clothInstances, MeshMatcher meshMatcher, EdenAutoMorpherConfig config, ClothInstanceTotal clothInstanceTotal)
|
|
{
|
|
//IL_013b: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0149: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_014e: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0153: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0161: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0166: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_019a: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_019f: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_01df: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
|
|
using (AutoMorpherDev.Profile("[Expand] BVH Mesh Matching time"))
|
|
{
|
|
foreach (ClothInstance clothInstance in clothInstances)
|
|
{
|
|
clothInstance.deltas = meshMatcher.ShrinkVertexMatch(clothInstance, config.minMargin);
|
|
}
|
|
}
|
|
foreach (ClothInstance clothInstance2 in clothInstances)
|
|
{
|
|
clothInstance2.deltasLocal = clothInstance2.deltas;
|
|
}
|
|
Vector3[] deltas = clothInstanceTotal.GlobalDeltas;
|
|
clothInstanceTotal.UpdateGlobalBuffersFromClothInstances();
|
|
this.SmoothDeltasByDistance(clothInstanceTotal.GlobalPositions, ref deltas, clothInstanceTotal.GlobalAdjacencyMerged, config.worldRadius, 3, config.smoothingIteration, 0.5f, config.sigma);
|
|
clothInstanceTotal.SetGlobalDeltas(deltas);
|
|
clothInstanceTotal.ApplyGlobalDeltasToClothInstances();
|
|
this.SmoothAllClothesDeltasByDistance(clothInstances, config.worldRadius, config.smoothingIteration, config.sigma);
|
|
foreach (ClothInstance clothInstance3 in clothInstances)
|
|
{
|
|
for (int i = 0; i < clothInstance3.worldVertices.Length; i++)
|
|
{
|
|
if (!clothInstance3.excludedVertices[i] || !clothInstance3.isInsideVertex[i])
|
|
{
|
|
ref Vector3 reference = ref clothInstance3.worldVertices[i];
|
|
reference += clothInstance3.deltasLocal[i];
|
|
}
|
|
clothInstance3.deltasLocal[i] = Vector3.zero;
|
|
}
|
|
foreach (List<int> equivalentVertex in clothInstance3.equivalentVertices)
|
|
{
|
|
Vector3 val = Vector3.zero;
|
|
for (int j = 0; j < equivalentVertex.Count; j++)
|
|
{
|
|
val += clothInstance3.worldVertices[equivalentVertex[j]];
|
|
}
|
|
val /= (float)equivalentVertex.Count;
|
|
for (int k = 0; k < equivalentVertex.Count; k++)
|
|
{
|
|
clothInstance3.worldVertices[equivalentVertex[k]] = val;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public void ExpandClothes_World(ClothInstance clothInstance, List<ClothInstance> clothInstances, MeshMatcher meshMatcher, EdenAutoMorpherConfig config, float fittingRadius)
|
|
{
|
|
//IL_020c: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_01be: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_044b: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0450: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0425: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0433: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0438: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_043d: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0246: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_024b: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0265: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_026e: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0273: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0278: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0484: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0489: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0490: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_04a2: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_04a7: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_04ac: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_04bf: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_04c9: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_04ce: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_04e5: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_04e7: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_02eb: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0313: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_032c: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0331: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_034c: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0355: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_035a: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_035f: Unknown result type (might be due to invalid IL or missing references)
|
|
if (AutoMorpherDev.isDeveloperMode)
|
|
{
|
|
UnityEngine.Debug.Log((object)("[Expand] Start " + ((Object)((Component)clothInstance.smr).gameObject).name + "//==============================================================================================================="));
|
|
}
|
|
Stopwatch stopwatch = (AutoMorpherDev.isDeveloperMode ? Stopwatch.StartNew() : null);
|
|
Stopwatch.StartNew();
|
|
using (AutoMorpherDev.Profile("[Expand] BVH Mesh Matching time"))
|
|
{
|
|
clothInstance.deltas = meshMatcher.ExpandVertexMatch(clothInstance, config.minMargin, config.skipFootFitting);
|
|
}
|
|
List<int> list = null;
|
|
using (AutoMorpherDev.Profile("[Expand] Select Anchors time"))
|
|
{
|
|
list = this.SelectAnchors(clothInstance, fittingRadius);
|
|
}
|
|
if (AutoMorpherDev.isDeveloperMode)
|
|
{
|
|
UnityEngine.Debug.Log((object)$"[Expand] Anchor Count {list.Count}");
|
|
}
|
|
if (list.Count == 0)
|
|
{
|
|
if (AutoMorpherDev.isDeveloperMode)
|
|
{
|
|
stopwatch.Stop();
|
|
UnityEngine.Debug.Log((object)$"[Expand] TOTAL ShrinkClothes time: {stopwatch.ElapsedMilliseconds} ms");
|
|
UnityEngine.Debug.Log((object)("[Expand] End " + ((Object)((Component)clothInstance.smr).gameObject).name + "//==============================================================================================================="));
|
|
}
|
|
return;
|
|
}
|
|
Stopwatch stopwatch2 = (AutoMorpherDev.isDeveloperMode ? Stopwatch.StartNew() : null);
|
|
float num = 0f;
|
|
float num2 = 0f;
|
|
VertexMoverUtil vertexMoverUtil = new VertexMoverUtil();
|
|
foreach (int item in list)
|
|
{
|
|
if (clothInstance.excludedVertices[item])
|
|
{
|
|
continue;
|
|
}
|
|
Stopwatch stopwatch3 = (AutoMorpherDev.isDeveloperMode ? Stopwatch.StartNew() : null);
|
|
if (AutoMorpherDev.isDeveloperMode)
|
|
{
|
|
UnityEngine.Debug.Log((object)$"[Expand] Selected Expand Vertes: {((Object)((Component)clothInstance.smr).gameObject).name} / {item}");
|
|
UnityEngine.Debug.Log((object)$"[Expand] SelectedCEnter {item} {clothInstance.deltas[item]} {clothInstance.worldVertices[item]}");
|
|
}
|
|
Vector3[] array = vertexMoverUtil.MoveVertices(clothInstance, item, clothInstance.isLeftLegVertex[item], clothInstance.isRightLegVertex[item], fittingRadius, config.sigma, clothInstance.deltas[item]);
|
|
if (array == null)
|
|
{
|
|
if (AutoMorpherDev.isDeveloperMode)
|
|
{
|
|
stopwatch3.Stop();
|
|
num += (float)stopwatch3.ElapsedMilliseconds;
|
|
}
|
|
continue;
|
|
}
|
|
for (int i = 0; i < clothInstance.worldVertices.Length && i < array.Length; i++)
|
|
{
|
|
if (array[i] != Vector3.zero)
|
|
{
|
|
ref Vector3 reference = ref clothInstance.deltasLocal[i];
|
|
reference += array[i];
|
|
}
|
|
}
|
|
if (AutoMorpherDev.isDeveloperMode)
|
|
{
|
|
stopwatch3.Stop();
|
|
num += (float)stopwatch3.ElapsedMilliseconds;
|
|
}
|
|
Stopwatch stopwatch4 = (AutoMorpherDev.isDeveloperMode ? Stopwatch.StartNew() : null);
|
|
foreach (ClothInstance clothInstance2 in clothInstances)
|
|
{
|
|
if (clothInstance2 == clothInstance)
|
|
{
|
|
continue;
|
|
}
|
|
Vector3[] array2 = vertexMoverUtil.MoveVertices(clothInstance2, clothInstance.worldVertices[item], clothInstance.isLeftLegVertex[item], clothInstance.isRightLegVertex[item], fittingRadius, config.sigma, clothInstance.deltas[item]);
|
|
if (array2 == null)
|
|
{
|
|
continue;
|
|
}
|
|
for (int j = 0; j < clothInstance2.worldVertices.Length && j < array2.Length; j++)
|
|
{
|
|
if (array2[j] != Vector3.zero)
|
|
{
|
|
ref Vector3 reference2 = ref clothInstance2.deltasLocal[j];
|
|
reference2 += array2[j];
|
|
}
|
|
}
|
|
}
|
|
if (AutoMorpherDev.isDeveloperMode)
|
|
{
|
|
stopwatch4.Stop();
|
|
num2 += (float)stopwatch4.ElapsedMilliseconds;
|
|
}
|
|
}
|
|
this.SmoothAllClothesDeltasByDistance(clothInstances, fittingRadius, config.smoothingIteration, config.sigma);
|
|
foreach (ClothInstance clothInstance3 in clothInstances)
|
|
{
|
|
for (int k = 0; k < clothInstance3.worldVertices.Length; k++)
|
|
{
|
|
if (!clothInstance3.excludedVertices[k])
|
|
{
|
|
ref Vector3 reference3 = ref clothInstance3.worldVertices[k];
|
|
reference3 += clothInstance3.deltasLocal[k];
|
|
}
|
|
clothInstance3.deltasLocal[k] = Vector3.zero;
|
|
}
|
|
foreach (List<int> equivalentVertex in clothInstance3.equivalentVertices)
|
|
{
|
|
Vector3 val = Vector3.zero;
|
|
for (int l = 0; l < equivalentVertex.Count; l++)
|
|
{
|
|
val += clothInstance3.worldVertices[equivalentVertex[l]];
|
|
}
|
|
val /= (float)equivalentVertex.Count;
|
|
for (int m = 0; m < equivalentVertex.Count; m++)
|
|
{
|
|
clothInstance3.worldVertices[equivalentVertex[m]] = val;
|
|
}
|
|
}
|
|
}
|
|
if (AutoMorpherDev.isDeveloperMode)
|
|
{
|
|
stopwatch2.Stop();
|
|
UnityEngine.Debug.Log((object)$"[Expand] Renderer Move Vector Calculate: {((Object)((Component)clothInstance.smr).gameObject).name} : {num}");
|
|
UnityEngine.Debug.Log((object)$"[Expand] Other Renderer Move Vector Calculate: {((Object)((Component)clothInstance.smr).gameObject).name} : {num2}");
|
|
UnityEngine.Debug.Log((object)$"[Expand] Total Move Vector Calculate: {((Object)((Component)clothInstance.smr).gameObject).name} : {stopwatch2.ElapsedMilliseconds}");
|
|
stopwatch.Stop();
|
|
UnityEngine.Debug.Log((object)$"[Expand] TOTAL ShrinkClothes time: {stopwatch.ElapsedMilliseconds} ms");
|
|
UnityEngine.Debug.Log((object)("[Expand] End " + ((Object)((Component)clothInstance.smr).gameObject).name + "//==============================================================================================================="));
|
|
}
|
|
}
|
|
|
|
public void ShrinkClothes_World(ClothInstance clothInstance, List<ClothInstance> clothInstances, MeshMatcher meshMatcher, EdenAutoMorpherConfig config, float fittingRadius)
|
|
{
|
|
//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0434: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0439: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_040e: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_041c: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0421: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0426: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_022f: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0234: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_024e: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0257: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_025c: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0261: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_046d: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0472: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0479: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_048b: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0490: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0495: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_04a8: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_04b2: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_04b7: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_04ce: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_04d0: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_02d4: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_02fc: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0315: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_031a: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0335: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_033e: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0343: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0348: Unknown result type (might be due to invalid IL or missing references)
|
|
if (AutoMorpherDev.isDeveloperMode)
|
|
{
|
|
UnityEngine.Debug.Log((object)("[Shrink] Start " + ((Object)((Component)clothInstance.smr).gameObject).name + "//==============================================================================================================="));
|
|
}
|
|
Stopwatch stopwatch = (AutoMorpherDev.isDeveloperMode ? Stopwatch.StartNew() : null);
|
|
using (AutoMorpherDev.Profile("[Shrink] BVH Mesh Matching time"))
|
|
{
|
|
clothInstance.deltas = meshMatcher.ShrinkVertexMatch(clothInstance, config.minMargin);
|
|
}
|
|
List<int> list = null;
|
|
using (AutoMorpherDev.Profile("[Shrink] Select Anchors time"))
|
|
{
|
|
list = this.SelectAnchors(clothInstance, fittingRadius);
|
|
}
|
|
if (AutoMorpherDev.isDeveloperMode)
|
|
{
|
|
UnityEngine.Debug.Log((object)$"[Shrink] Anchor Count {list.Count}");
|
|
}
|
|
if (list.Count == 0)
|
|
{
|
|
if (AutoMorpherDev.isDeveloperMode)
|
|
{
|
|
stopwatch.Stop();
|
|
UnityEngine.Debug.Log((object)$"[Shrink] TOTAL ShrinkClothes time: {stopwatch.ElapsedMilliseconds} ms");
|
|
UnityEngine.Debug.Log((object)("[Shrink] End " + ((Object)((Component)clothInstance.smr).gameObject).name + "//==============================================================================================================="));
|
|
}
|
|
return;
|
|
}
|
|
Stopwatch stopwatch2 = (AutoMorpherDev.isDeveloperMode ? Stopwatch.StartNew() : null);
|
|
float num = 0f;
|
|
float num2 = 0f;
|
|
VertexMoverUtil vertexMoverUtil = new VertexMoverUtil();
|
|
foreach (int item in list)
|
|
{
|
|
if (clothInstance.excludedVertices[item])
|
|
{
|
|
continue;
|
|
}
|
|
Stopwatch stopwatch3 = (AutoMorpherDev.isDeveloperMode ? Stopwatch.StartNew() : null);
|
|
if (AutoMorpherDev.isDeveloperMode)
|
|
{
|
|
UnityEngine.Debug.Log((object)$"[Shrink] Selected Expand Vertes: {((Object)((Component)clothInstance.smr).gameObject).name} / {item}");
|
|
UnityEngine.Debug.Log((object)$"[Shrink] SelectedCEnter {item} {clothInstance.deltas[item]} {clothInstance.worldVertices[item]}");
|
|
}
|
|
Vector3[] array = vertexMoverUtil.MoveVertices(clothInstance, item, clothInstance.isLeftLegVertex[item], clothInstance.isRightLegVertex[item], fittingRadius, config.sigma, clothInstance.deltas[item]);
|
|
if (array == null)
|
|
{
|
|
stopwatch3.Stop();
|
|
num += (float)stopwatch3.ElapsedMilliseconds;
|
|
continue;
|
|
}
|
|
for (int i = 0; i < clothInstance.worldVertices.Length && i < array.Length; i++)
|
|
{
|
|
if (array[i] != Vector3.zero)
|
|
{
|
|
ref Vector3 reference = ref clothInstance.deltasLocal[i];
|
|
reference += array[i];
|
|
}
|
|
}
|
|
if (AutoMorpherDev.isDeveloperMode)
|
|
{
|
|
stopwatch3.Stop();
|
|
num += (float)stopwatch3.ElapsedMilliseconds;
|
|
}
|
|
Stopwatch stopwatch4 = (AutoMorpherDev.isDeveloperMode ? Stopwatch.StartNew() : null);
|
|
foreach (ClothInstance clothInstance2 in clothInstances)
|
|
{
|
|
if (clothInstance2 == clothInstance)
|
|
{
|
|
continue;
|
|
}
|
|
Vector3[] array2 = vertexMoverUtil.MoveVertices(clothInstance2, clothInstance.worldVertices[item], clothInstance.isLeftLegVertex[item], clothInstance.isRightLegVertex[item], fittingRadius, config.sigma, clothInstance.deltas[item]);
|
|
if (array2 == null)
|
|
{
|
|
continue;
|
|
}
|
|
for (int j = 0; j < clothInstance2.worldVertices.Length && j < array2.Length; j++)
|
|
{
|
|
if (array2[j] != Vector3.zero)
|
|
{
|
|
ref Vector3 reference2 = ref clothInstance2.deltasLocal[j];
|
|
reference2 += array2[j];
|
|
}
|
|
}
|
|
}
|
|
if (AutoMorpherDev.isDeveloperMode)
|
|
{
|
|
stopwatch4.Stop();
|
|
num2 += (float)stopwatch4.ElapsedMilliseconds;
|
|
}
|
|
}
|
|
this.SmoothAllClothesDeltasByDistance(clothInstances, fittingRadius, config.smoothingIteration, config.sigma);
|
|
foreach (ClothInstance clothInstance3 in clothInstances)
|
|
{
|
|
for (int k = 0; k < clothInstance3.worldVertices.Length; k++)
|
|
{
|
|
if (!clothInstance3.excludedVertices[k])
|
|
{
|
|
ref Vector3 reference3 = ref clothInstance3.worldVertices[k];
|
|
reference3 += clothInstance3.deltasLocal[k];
|
|
}
|
|
clothInstance3.deltasLocal[k] = Vector3.zero;
|
|
}
|
|
foreach (List<int> equivalentVertex in clothInstance3.equivalentVertices)
|
|
{
|
|
Vector3 val = Vector3.zero;
|
|
for (int l = 0; l < equivalentVertex.Count; l++)
|
|
{
|
|
val += clothInstance3.worldVertices[equivalentVertex[l]];
|
|
}
|
|
val /= (float)equivalentVertex.Count;
|
|
for (int m = 0; m < equivalentVertex.Count; m++)
|
|
{
|
|
clothInstance3.worldVertices[equivalentVertex[m]] = val;
|
|
}
|
|
}
|
|
}
|
|
if (AutoMorpherDev.isDeveloperMode)
|
|
{
|
|
stopwatch2.Stop();
|
|
UnityEngine.Debug.Log((object)$"[Shrink] Renderer Move Vector Calculate: {((Object)((Component)clothInstance.smr).gameObject).name} : {num}");
|
|
UnityEngine.Debug.Log((object)$"[Shrink] Other Renderer Move Vector Calculate: {((Object)((Component)clothInstance.smr).gameObject).name} : {num2}");
|
|
UnityEngine.Debug.Log((object)$"[Shrink] Total Move Vector Calculate: {((Object)((Component)clothInstance.smr).gameObject).name} : {stopwatch2.ElapsedMilliseconds}");
|
|
stopwatch.Stop();
|
|
UnityEngine.Debug.Log((object)$"[Shrink] TOTAL ShrinkClothes time: {stopwatch.ElapsedMilliseconds} ms");
|
|
UnityEngine.Debug.Log((object)("[Shrink] End " + ((Object)((Component)clothInstance.smr).gameObject).name + "//==============================================================================================================="));
|
|
}
|
|
}
|
|
|
|
public void ExpandFitClothes_World(ClothInstance clothInstance, List<ClothInstance> clothInstances, MeshMatcher meshMatcher, float worldRadius, float sigma, float minMargin)
|
|
{
|
|
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0105: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_010f: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0114: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_012a: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_012c: Unknown result type (might be due to invalid IL or missing references)
|
|
UnityEngine.Debug.Log((object)("[Expand] " + ((Object)((Component)clothInstance.smr).gameObject).name + "//==============================================================================================================="));
|
|
Stopwatch stopwatch = Stopwatch.StartNew();
|
|
Stopwatch stopwatch2 = Stopwatch.StartNew();
|
|
clothInstance.deltas = meshMatcher.ExpandVertexMatch(clothInstance, minMargin);
|
|
stopwatch2.Stop();
|
|
UnityEngine.Debug.Log((object)$"[Expand] BVH Mesh Matching time: {stopwatch2.ElapsedMilliseconds} ms");
|
|
for (int i = 0; i < clothInstance.worldVertices.Length; i++)
|
|
{
|
|
ref Vector3 reference = ref clothInstance.worldVertices[i];
|
|
reference += clothInstance.deltas[i];
|
|
clothInstance.deltasLocal[i] = Vector3.zero;
|
|
}
|
|
foreach (List<int> equivalentVertex in clothInstance.equivalentVertices)
|
|
{
|
|
Vector3 val = Vector3.zero;
|
|
for (int j = 0; j < equivalentVertex.Count; j++)
|
|
{
|
|
val += clothInstance.worldVertices[equivalentVertex[j]];
|
|
}
|
|
val /= (float)equivalentVertex.Count;
|
|
for (int k = 0; k < equivalentVertex.Count; k++)
|
|
{
|
|
clothInstance.worldVertices[equivalentVertex[k]] = val;
|
|
}
|
|
}
|
|
stopwatch.Stop();
|
|
UnityEngine.Debug.Log((object)$"[Expand] TOTAL ShrinkClothes time: {stopwatch.ElapsedMilliseconds} ms");
|
|
UnityEngine.Debug.Log((object)("[Expand] " + ((Object)((Component)clothInstance.smr).gameObject).name + "//==============================================================================================================="));
|
|
}
|
|
|
|
private List<int> SelectAnchors(ClothInstance clothInstance, float worldRadius, float minDeltaSq = 1E-05f, float maxDelta = 0.1f)
|
|
{
|
|
//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_011a: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0142: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0154: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0159: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_015e: Unknown result type (might be due to invalid IL or missing references)
|
|
List<int> list = new List<int>();
|
|
List<int> list2 = new List<int>();
|
|
int num = clothInstance.worldVertices.Length;
|
|
for (int i = 0; i < num; i++)
|
|
{
|
|
if (!clothInstance.isInsideVertex[i] && clothInstance.deltas[i].sqrMagnitude > minDeltaSq)
|
|
{
|
|
list2.Add(i);
|
|
}
|
|
}
|
|
if (list2.Count == 0)
|
|
{
|
|
return list;
|
|
}
|
|
list2.Sort(delegate (int a, int b)
|
|
{
|
|
float sqrMagnitude = clothInstance.deltas[a].sqrMagnitude;
|
|
float num9 = clothInstance.deltas[b].sqrMagnitude - sqrMagnitude;
|
|
if (Mathf.Abs(num9) > 1E-06f)
|
|
{
|
|
if (!(num9 > 0f))
|
|
{
|
|
return -1;
|
|
}
|
|
return 1;
|
|
}
|
|
float num10 = clothInstance.minDistance[a];
|
|
float value3 = clothInstance.minDistance[b];
|
|
return num10.CompareTo(value3);
|
|
});
|
|
float num2 = worldRadius * 2f;
|
|
float num3 = num2 * num2;
|
|
float cellSize = num2;
|
|
Dictionary<Vector3Int, List<int>> dictionary = new Dictionary<Vector3Int, List<int>>();
|
|
Vector3Int key2 = default(Vector3Int);
|
|
foreach (int item in list2)
|
|
{
|
|
Vector3 p = clothInstance.worldVertices[item];
|
|
Vector3Int key = GetCellIndex(p);
|
|
bool flag = false;
|
|
for (int num4 = -1; num4 <= 1; num4++)
|
|
{
|
|
if (flag)
|
|
{
|
|
break;
|
|
}
|
|
for (int num5 = -1; num5 <= 1; num5++)
|
|
{
|
|
if (flag)
|
|
{
|
|
break;
|
|
}
|
|
for (int num6 = -1; num6 <= 1; num6++)
|
|
{
|
|
if (flag)
|
|
{
|
|
break;
|
|
}
|
|
key2 = new Vector3Int(key.x + num4, key.y + num5, key.z + num6);
|
|
if (!dictionary.TryGetValue(key2, out var value))
|
|
{
|
|
continue;
|
|
}
|
|
for (int num7 = 0; num7 < value.Count; num7++)
|
|
{
|
|
int num8 = value[num7];
|
|
Vector3 val = clothInstance.worldVertices[item] - clothInstance.worldVertices[num8];
|
|
if (val.sqrMagnitude < num3)
|
|
{
|
|
flag = true;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (!flag)
|
|
{
|
|
list.Add(item);
|
|
if (!dictionary.TryGetValue(key, out var value2))
|
|
{
|
|
value2 = (dictionary[key] = new List<int>());
|
|
}
|
|
value2.Add(item);
|
|
}
|
|
}
|
|
return list;
|
|
Vector3Int GetCellIndex(Vector3 val2)
|
|
{
|
|
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
|
|
return new Vector3Int(Mathf.FloorToInt(val2.x / cellSize), Mathf.FloorToInt(val2.y / cellSize), Mathf.FloorToInt(val2.z / cellSize));
|
|
}
|
|
}
|
|
|
|
public void SmoothDeltasByDistance(Vector3[] positions, ref Vector3[] deltas, List<int>[] adjacency, float radius, int maxDepth = 3, int iterations = 1, float smoothFactor = 0.5f, float gaussianSigma = -1f)
|
|
{
|
|
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_02be: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0108: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_010d: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_010f: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0111: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0113: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0118: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_01da: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0205: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_020a: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_020c: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0211: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_022d: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0233: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_023a: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_023f: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0244: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0295: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_029a: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0267: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_026b: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0270: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0279: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_027e: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0282: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0287: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0163: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_0168: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_016a: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_016f: Unknown result type (might be due to invalid IL or missing references)
|
|
if (positions == null || deltas == null || adjacency == null || positions.Length != deltas.Length || positions.Length != adjacency.Length)
|
|
{
|
|
return;
|
|
}
|
|
int num = positions.Length;
|
|
if (num == 0)
|
|
{
|
|
return;
|
|
}
|
|
if (gaussianSigma <= 0f)
|
|
{
|
|
gaussianSigma = radius * 0.5f;
|
|
}
|
|
float num2 = radius * radius;
|
|
float num3 = 2f * gaussianSigma * gaussianSigma;
|
|
Vector3[] array = (Vector3[])(object)new Vector3[num];
|
|
Queue<Node> queue = new Queue<Node>();
|
|
List<int> list = new List<int>(32);
|
|
int[] array2 = new int[num];
|
|
int num4 = 1;
|
|
for (int i = 0; i < iterations; i++)
|
|
{
|
|
for (int j = 0; j < num; j++)
|
|
{
|
|
if (deltas[j] == Vector3.zero)
|
|
{
|
|
array[j] = Vector3.zero;
|
|
continue;
|
|
}
|
|
list.Clear();
|
|
queue.Clear();
|
|
num4 = (array2[j] = num4 + 1);
|
|
queue.Enqueue(new Node
|
|
{
|
|
index = j,
|
|
depth = 0
|
|
});
|
|
Vector3 val = positions[j];
|
|
Vector3 val3;
|
|
while (queue.Count > 0)
|
|
{
|
|
Node node = queue.Dequeue();
|
|
int index = node.index;
|
|
int depth = node.depth;
|
|
Vector3 val2 = positions[index];
|
|
val3 = val2 - val;
|
|
float sqrMagnitude = val3.sqrMagnitude;
|
|
if (index != j && sqrMagnitude <= num2)
|
|
{
|
|
list.Add(index);
|
|
}
|
|
if (depth >= maxDepth)
|
|
{
|
|
continue;
|
|
}
|
|
List<int> list2 = adjacency[index];
|
|
if (list2 == null)
|
|
{
|
|
continue;
|
|
}
|
|
for (int k = 0; k < list2.Count; k++)
|
|
{
|
|
int num5 = list2[k];
|
|
if (array2[num5] != num4)
|
|
{
|
|
val3 = positions[num5] - val2;
|
|
if (!(val3.sqrMagnitude > num2))
|
|
{
|
|
array2[num5] = num4;
|
|
queue.Enqueue(new Node
|
|
{
|
|
index = num5,
|
|
depth = depth + 1
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (list.Count == 0)
|
|
{
|
|
array[j] = deltas[j];
|
|
continue;
|
|
}
|
|
Vector3 val4 = Vector3.zero;
|
|
float num6 = 0f;
|
|
for (int l = 0; l < list.Count; l++)
|
|
{
|
|
int num7 = list[l];
|
|
val3 = positions[num7] - val;
|
|
float sqrMagnitude2 = val3.sqrMagnitude;
|
|
if (!(sqrMagnitude2 > num2))
|
|
{
|
|
float num8 = Mathf.Exp((0f - sqrMagnitude2) / num3);
|
|
val4 += deltas[num7] * num8;
|
|
num6 += num8;
|
|
}
|
|
}
|
|
if (num6 > 1E-08f)
|
|
{
|
|
Vector3 val5 = val4 / num6;
|
|
array[j] = Vector3.Lerp(deltas[j], val5, smoothFactor);
|
|
}
|
|
else
|
|
{
|
|
array[j] = deltas[j];
|
|
}
|
|
}
|
|
for (int m = 0; m < num; m++)
|
|
{
|
|
deltas[m] = array[m];
|
|
}
|
|
}
|
|
}
|
|
|
|
public void SmoothAllClothesDeltasByDistance(List<ClothInstance> clothesInstances, float radius, int iterations = 1, float gaussianSigma = -1f, int maxDepth = 3, float smoothFactor = 0.5f)
|
|
{
|
|
//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
|
|
//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
|
|
if (clothesInstances == null || clothesInstances.Count == 0)
|
|
{
|
|
return;
|
|
}
|
|
int num = 0;
|
|
for (int i = 0; i < clothesInstances.Count; i++)
|
|
{
|
|
ClothInstance clothInstance = clothesInstances[i];
|
|
if (clothInstance != null && clothInstance.worldVertices != null)
|
|
{
|
|
num += clothInstance.worldVertices.Length;
|
|
}
|
|
}
|
|
if (num == 0)
|
|
{
|
|
return;
|
|
}
|
|
Vector3[] array = (Vector3[])(object)new Vector3[num];
|
|
Vector3[] deltas = (Vector3[])(object)new Vector3[num];
|
|
List<int>[] array2 = new List<int>[num];
|
|
int[] array3 = new int[clothesInstances.Count];
|
|
int num2 = 0;
|
|
for (int j = 0; j < clothesInstances.Count; j++)
|
|
{
|
|
ClothInstance clothInstance2 = clothesInstances[j];
|
|
if (clothInstance2 == null)
|
|
{
|
|
continue;
|
|
}
|
|
array3[j] = num2;
|
|
Vector3[] worldVertices = clothInstance2.worldVertices;
|
|
Vector3[] deltasLocal = clothInstance2.deltasLocal;
|
|
List<int>[] vertexAdjacency = clothInstance2.vertexAdjacency;
|
|
int num3 = worldVertices.Length;
|
|
for (int k = 0; k < num3; k++)
|
|
{
|
|
array[num2 + k] = worldVertices[k];
|
|
deltas[num2 + k] = deltasLocal[k];
|
|
array2[num2 + k] = new List<int>();
|
|
}
|
|
for (int l = 0; l < num3; l++)
|
|
{
|
|
List<int> list = vertexAdjacency[l];
|
|
if (list != null)
|
|
{
|
|
int num4 = num2 + l;
|
|
List<int> list2 = array2[num4];
|
|
for (int m = 0; m < list.Count; m++)
|
|
{
|
|
int num5 = list[m];
|
|
int item = num2 + num5;
|
|
list2.Add(item);
|
|
}
|
|
}
|
|
}
|
|
num2 += num3;
|
|
}
|
|
this.SmoothDeltasByDistance(array, ref deltas, array2, radius, maxDepth, iterations, smoothFactor, gaussianSigma);
|
|
for (int n = 0; n < clothesInstances.Count; n++)
|
|
{
|
|
ClothInstance clothInstance3 = clothesInstances[n];
|
|
if (clothInstance3 != null)
|
|
{
|
|
int num6 = array3[n];
|
|
int num7 = clothInstance3.deltasLocal.Length;
|
|
for (int num8 = 0; num8 < num7; num8++)
|
|
{
|
|
clothInstance3.deltasLocal[num8] = deltas[num6 + num8];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|