EdenAutoMorpherScript dll을 디컴파일한 결과를 그대로 가져옴

This commit is contained in:
2026-02-01 14:57:52 +09:00
parent 8e1adbd907
commit f9c4088ef4
85 changed files with 10524 additions and 0 deletions

View File

@@ -0,0 +1,285 @@
// Decompiled with JetBrains decompiler
// Type: Eden.AutoMorpher.ClothHumanoidMaskUtil
// Assembly: EdenAutoMorpherScript, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: D39968B3-E151-4276-BDB4-E82752BBAFF0
// Assembly location: D:\dev\AutoMorpher\Assets\@Eden_Tools\Eden_AutoMorpher\Script\EdenAutoMorpherScript.dll
using System.Collections.Generic;
using UnityEngine;
namespace Eden.AutoMorpher
{
public class ClothHumanoidMaskUtil
{
public void BuildExcludedVertexMaskForHandsAndHead(
ClothInstance clothInstance,
bool excludeHandRoot = false,
bool excludeThumbRoot = false)
{
if (clothInstance == null || Object.op_Equality((Object)clothInstance.smr, (Object)null))
{
Debug.LogWarning((object)"[ClothHumanoidMaskUtil] clothInstance / smr 가 null");
}
else
{
SkinnedMeshRenderer smr = clothInstance.smr;
Mesh mesh = clothInstance.editableMesh ?? smr.sharedMesh;
if (Object.op_Equality((Object)mesh, (Object)null))
{
Debug.LogWarning((object)"[ClothHumanoidMaskUtil] mesh 가 null");
}
else
{
BoneWeight[] boneWeights = mesh.boneWeights;
Transform[] bones = smr.bones;
if (boneWeights == null || boneWeights.Length == 0 || bones == null || bones.Length == 0)
Debug.LogWarning((object)"[ClothHumanoidMaskUtil] boneWeights 또는 bones 비어있음");
else if (clothInstance.humanoidMatchedBones == null || clothInstance.humanoidMatchedBones.Count == 0)
{
Debug.LogWarning((object)"[ClothHumanoidMaskUtil] humanoidMatchedBones 가 비어있음 (BodyToClothPoseApplier에서 매칭 안 되었을 가능성)");
}
else
{
int length = mesh.vertexCount;
if (boneWeights.Length != length)
length = Mathf.Min(length, boneWeights.Length);
HashSet<Transform> excludedBones = new HashSet<Transform>();
Dictionary<HumanBodyBones, HashSet<Transform>> humanoidMatchedBones = clothInstance.humanoidMatchedBones;
HashSet<Transform> transformSet1;
if (humanoidMatchedBones.TryGetValue((HumanBodyBones)10, out transformSet1) && transformSet1 != null)
{
foreach (Transform root in transformSet1)
{
if (!Object.op_Equality((Object)root, (Object)null))
AddHierarchy(root, true);
}
}
HashSet<Transform> transformSet2;
if (humanoidMatchedBones.TryGetValue((HumanBodyBones)17, out transformSet2) && transformSet2 != null)
{
foreach (Transform root in transformSet2)
{
if (!Object.op_Equality((Object)root, (Object)null))
AddHierarchy(root, excludeHandRoot);
}
}
HashSet<Transform> transformSet3;
if (humanoidMatchedBones.TryGetValue((HumanBodyBones)18, out transformSet3) && transformSet3 != null)
{
foreach (Transform root in transformSet3)
{
if (!Object.op_Equality((Object)root, (Object)null))
AddHierarchy(root, excludeHandRoot);
}
}
HashSet<Transform> transformSet4;
if (humanoidMatchedBones.TryGetValue((HumanBodyBones)24, out transformSet4) && transformSet4 != null)
{
foreach (Transform transform in transformSet4)
{
if (!Object.op_Equality((Object)transform, (Object)null))
{
if (excludeThumbRoot)
excludedBones.Add(transform);
else
excludedBones.Remove(transform);
}
}
}
HashSet<Transform> transformSet5;
if (humanoidMatchedBones.TryGetValue((HumanBodyBones)39, out transformSet5) && transformSet5 != null)
{
foreach (Transform transform in transformSet5)
{
if (!Object.op_Equality((Object)transform, (Object)null))
{
if (excludeThumbRoot)
excludedBones.Add(transform);
else
excludedBones.Remove(transform);
}
}
}
bool[] boneIndexExcluded = new bool[bones.Length];
for (int index = 0; index < bones.Length; ++index)
{
Transform transform = bones[index];
if (Object.op_Inequality((Object)transform, (Object)null) && excludedBones.Contains(transform))
boneIndexExcluded[index] = true;
}
bool[] flagArray = new bool[length];
for (int index = 0; index < length; ++index)
{
BoneWeight boneWeight = boneWeights[index];
float excludedWeightSum = 0.0f;
AddExcludedWeight(((BoneWeight)ref boneWeight).weight0, ((BoneWeight)ref boneWeight).boneIndex0);
AddExcludedWeight(((BoneWeight)ref boneWeight).weight1, ((BoneWeight)ref boneWeight).boneIndex1);
AddExcludedWeight(((BoneWeight)ref boneWeight).weight2, ((BoneWeight)ref boneWeight).boneIndex2);
AddExcludedWeight(((BoneWeight)ref boneWeight).weight3, ((BoneWeight)ref boneWeight).boneIndex3);
flagArray[index] = (double)excludedWeightSum >= 0.800000011920929;
void AddExcludedWeight(float w, int bi)
{
if ((double)w <= 0.0 || bi < 0 || bi >= boneIndexExcluded.Length || !boneIndexExcluded[bi])
return;
excludedWeightSum += w;
}
}
clothInstance.excludedVertices = flagArray;
this.BuildLegVertexMasks(clothInstance);
void AddHierarchy(Transform root, bool includeRoot)
{
if (Object.op_Equality((Object)root, (Object)null))
return;
Stack<Transform> transformStack = new Stack<Transform>();
if (includeRoot)
{
transformStack.Push(root);
}
else
{
for (int index = 0; index < root.childCount; ++index)
transformStack.Push(root.GetChild(index));
}
while (transformStack.Count > 0)
{
Transform transform = transformStack.Pop();
if (!Object.op_Equality((Object)transform, (Object)null) && excludedBones.Add(transform))
{
for (int index = 0; index < transform.childCount; ++index)
transformStack.Push(transform.GetChild(index));
}
}
}
}
}
}
}
public void BuildLegVertexMasks(ClothInstance clothInstance)
{
if (clothInstance == null || Object.op_Equality((Object)clothInstance.smr, (Object)null))
{
Debug.LogWarning((object)"[ClothHumanoidMaskUtil] clothInstance / smr 가 null");
}
else
{
SkinnedMeshRenderer smr = clothInstance.smr;
Mesh mesh = clothInstance.editableMesh ?? smr.sharedMesh;
if (Object.op_Equality((Object)mesh, (Object)null))
{
Debug.LogWarning((object)"[ClothHumanoidMaskUtil] mesh 가 null");
}
else
{
BoneWeight[] boneWeights = mesh.boneWeights;
Transform[] bones = smr.bones;
if (boneWeights == null || boneWeights.Length == 0 || bones == null || bones.Length == 0)
Debug.LogWarning((object)"[ClothHumanoidMaskUtil] boneWeights 또는 bones 비어있음");
else if (clothInstance.humanoidMatchedBones == null || clothInstance.humanoidMatchedBones.Count == 0)
{
Debug.LogWarning((object)"[ClothHumanoidMaskUtil] humanoidMatchedBones 가 비어있음 (BodyToClothPoseApplier에서 매칭 필요)");
}
else
{
int length = mesh.vertexCount;
if (boneWeights.Length != length)
length = Mathf.Min(length, boneWeights.Length);
Dictionary<HumanBodyBones, HashSet<Transform>> humanoidMatchedBones = clothInstance.humanoidMatchedBones;
HashSet<Transform> set1 = new HashSet<Transform>();
HashSet<Transform> set2 = new HashSet<Transform>();
HashSet<Transform> transformSet1;
if (humanoidMatchedBones.TryGetValue((HumanBodyBones)1, out transformSet1) && transformSet1 != null)
{
foreach (Transform root in transformSet1)
{
if (!Object.op_Equality((Object)root, (Object)null))
CollectHierarchy(root, set1);
}
}
HashSet<Transform> transformSet2;
if (humanoidMatchedBones.TryGetValue((HumanBodyBones)2, out transformSet2) && transformSet2 != null)
{
foreach (Transform root in transformSet2)
{
if (!Object.op_Equality((Object)root, (Object)null))
CollectHierarchy(root, set2);
}
}
bool[] boneIsLeftLeg = new bool[bones.Length];
bool[] boneIsRightLeg = new bool[bones.Length];
for (int index = 0; index < bones.Length; ++index)
{
Transform transform = bones[index];
if (!Object.op_Equality((Object)transform, (Object)null))
{
if (set1.Contains(transform))
boneIsLeftLeg[index] = true;
if (set2.Contains(transform))
boneIsRightLeg[index] = true;
}
}
bool[] flagArray1 = new bool[length];
bool[] flagArray2 = new bool[length];
for (int index = 0; index < length; ++index)
{
BoneWeight boneWeight = boneWeights[index];
float leftWeight = 0.0f;
float rightWeight = 0.0f;
Check(((BoneWeight)ref boneWeight).boneIndex0, ((BoneWeight)ref boneWeight).weight0);
Check(((BoneWeight)ref boneWeight).boneIndex1, ((BoneWeight)ref boneWeight).weight1);
Check(((BoneWeight)ref boneWeight).boneIndex2, ((BoneWeight)ref boneWeight).weight2);
Check(((BoneWeight)ref boneWeight).boneIndex3, ((BoneWeight)ref boneWeight).weight3);
if ((double)leftWeight > 0.800000011920929)
{
flagArray1[index] = true;
flagArray2[index] = false;
}
else if ((double)rightWeight > 0.800000011920929)
{
flagArray1[index] = false;
flagArray2[index] = true;
}
else
{
flagArray1[index] = false;
flagArray2[index] = false;
}
void Check(int bi, float w)
{
if (bi < 0 || bi >= bones.Length || (double)w <= 0.0)
return;
if (boneIsLeftLeg[bi])
leftWeight += w;
if (!boneIsRightLeg[bi])
return;
rightWeight += w;
}
}
clothInstance.isLeftLegVertex = flagArray1;
clothInstance.isRightLegVertex = flagArray2;
}
}
}
static void CollectHierarchy(Transform root, HashSet<Transform> set)
{
if (Object.op_Equality((Object)root, (Object)null))
return;
Stack<Transform> transformStack = new Stack<Transform>();
transformStack.Push(root);
while (transformStack.Count > 0)
{
Transform transform = transformStack.Pop();
if (!Object.op_Equality((Object)transform, (Object)null) && set.Add(transform))
{
for (int index = 0; index < transform.childCount; ++index)
transformStack.Push(transform.GetChild(index));
}
}
}
}
}
}