From 349976b78738ede9cd9681e7c964b5d615ee15ab Mon Sep 17 00:00:00 2001 From: tymmkang Date: Sun, 1 Feb 2026 19:14:39 +0900 Subject: [PATCH] =?UTF-8?q?EdenAutoMorpherScript=20=EC=B6=94=EC=B6=9C=20?= =?UTF-8?q?=EC=BD=94=EB=93=9C=20=EC=A0=95=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Eden_AutoMorpher/Script/AutoMorpherDev.cs | 82 +- .../Script/AutoMorpherException.cs | 14 +- .../Eden_AutoMorpher/Script/BakedBodyMesh.cs | 40 +- .../Script/BodyPoseMatchSetupUtil.cs | 449 +- .../Script/BodyPoseMatchUtil.cs | 237 +- .../Script/BodyPoseMatch_Arm.cs | 1453 ++++--- .../Script/BodyPoseMatch_CommonUtil.cs | 598 ++- .../Script/BodyPoseMatch_Leg.cs | 1825 ++++---- .../Script/BodyPoseMatch_Torso.cs | 392 +- .../Script/BodyPoseToClothApplier.cs | 491 ++- .../Script/BoneAlignmentUtil.cs | 335 +- .../Script/BoneCorrespondenceUtil.cs | 348 +- .../Eden_AutoMorpher/Script/BoneMatchUtil.cs | 1243 +++--- .../Eden_AutoMorpher/Script/BvhNode.cs | 14 +- .../Eden_AutoMorpher/Script/BvhTriangle.cs | 12 +- .../Script/BvhTriangleMesh.cs | 1922 ++++----- .../Eden_AutoMorpher/Script/ClothBoneType.cs | 6 +- .../Script/ClothHumanoidMaskUtil.cs | 591 ++- .../Eden_AutoMorpher/Script/ClothInstance.cs | 1332 +++--- .../Script/ClothInstanceTotal.cs | 631 ++- .../Script/EdenAutoMorpher.cs | 1089 +++-- .../Script/EdenAutoMorpherConfig.cs | 49 +- .../Script/EdenAutoMorpherManager.cs | 749 ++-- .../Script/EdenAutoMorpher_SetUpUtil.cs | 1357 +++--- .../Eden_AutoMorpher/Script/MeshClassifier.cs | 539 +-- .../Eden_AutoMorpher/Script/MeshMatcher.cs | 662 +-- .../Eden_AutoMorpher/Script/MorpherMode.cs | 10 +- .../Eden_AutoMorpher/Script/MorpherState.cs | 12 +- .../Eden_AutoMorpher/Script/PcaUtil.cs | 405 +- .../Eden_AutoMorpher/Script/ProcessInfo.cs | 8 +- .../Eden_AutoMorpher/Script/RegionStats.cs | 10 +- .../Eden_AutoMorpher/Script/SkinningUtil.cs | 907 ++-- .../Eden_AutoMorpher/Script/TempBoneMarker.cs | 8 +- .../Eden_AutoMorpher/Script/TransformInfo.cs | 144 +- .../Eden_AutoMorpher/Script/TriangleUtil.cs | 210 +- .../Script/VertexFittingUtil.cs | 1709 ++++---- .../Script/VertexMoverUtil.cs | 357 +- .../Eden_AutoMorpher/Script/WeightKernel.cs | 6 +- .../Script/WeightTransferUtil.cs | 3717 ++++++++--------- .../Script/WorldVertexUtil.cs | 177 +- .../Script/profile.ProfileLoader.cs | 928 ++-- .../Script/profile.ProfilePoseMatchUtil.cs | 152 +- 42 files changed, 12616 insertions(+), 12604 deletions(-) diff --git a/Assets/@Eden_Tools/Eden_AutoMorpher/Script/AutoMorpherDev.cs b/Assets/@Eden_Tools/Eden_AutoMorpher/Script/AutoMorpherDev.cs index f20c2b6..0c187f4 100644 --- a/Assets/@Eden_Tools/Eden_AutoMorpher/Script/AutoMorpherDev.cs +++ b/Assets/@Eden_Tools/Eden_AutoMorpher/Script/AutoMorpherDev.cs @@ -1,58 +1,56 @@ -// Warning: Some assembly references could not be resolved automatically. This might lead to incorrect decompilation of some parts, +// 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.AutoMorpherDev using System; using System.Diagnostics; -using Eden.AutoMorpher; -using UnityEngine; public static class AutoMorpherDev { - public readonly struct ScopeTimer : IDisposable - { - private readonly bool _enabled; + public readonly struct ScopeTimer : IDisposable + { + private readonly bool _enabled; - private readonly string _label; + private readonly string _label; - private readonly Stopwatch _sw; + private readonly Stopwatch _sw; - public ScopeTimer(bool enabled, string label) - { - _enabled = enabled; - _label = label; - if (enabled) - { - _sw = Stopwatch.StartNew(); - } - else - { - _sw = null; - } - } + public ScopeTimer(bool enabled, string label) + { + this._enabled = enabled; + this._label = label; + if (enabled) + { + this._sw = Stopwatch.StartNew(); + } + else + { + this._sw = null; + } + } - public void Dispose() - { - if (_enabled && _sw != null) - { - _sw.Stop(); - Debug.Log((object)$"[DevTimer] {_label}: {_sw.ElapsedMilliseconds} ms"); - } - } - } + public void Dispose() + { + if (this._enabled && this._sw != null) + { + this._sw.Stop(); + UnityEngine.Debug.Log((object)$"[DevTimer] {this._label}: {this._sw.ElapsedMilliseconds} ms"); + } + } + } - public static bool isDeveloperMode; + public static bool isDeveloperMode; - public static void Log(string message) - { - if (isDeveloperMode) - { - Debug.Log((object)message); - } - } + public static void Log(string message) + { + if (isDeveloperMode) + { + UnityEngine.Debug.Log((object)message); + } + } - public static ScopeTimer Profile(string label) - { - return new ScopeTimer(isDeveloperMode, label); - } + public static ScopeTimer Profile(string label) + { + return new ScopeTimer(isDeveloperMode, label); + } } diff --git a/Assets/@Eden_Tools/Eden_AutoMorpher/Script/AutoMorpherException.cs b/Assets/@Eden_Tools/Eden_AutoMorpher/Script/AutoMorpherException.cs index 1421d22..10bc090 100644 --- a/Assets/@Eden_Tools/Eden_AutoMorpher/Script/AutoMorpherException.cs +++ b/Assets/@Eden_Tools/Eden_AutoMorpher/Script/AutoMorpherException.cs @@ -1,4 +1,4 @@ -// Warning: Some assembly references could not be resolved automatically. This might lead to incorrect decompilation of some parts, +// 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.AutoMorpherException @@ -6,11 +6,11 @@ using System; public class AutoMorpherException : Exception { - public string title; + public string title; - public AutoMorpherException(string title, string message) - : base(message) - { - this.title = title; - } + public AutoMorpherException(string title, string message) + : base(message) + { + this.title = title; + } } diff --git a/Assets/@Eden_Tools/Eden_AutoMorpher/Script/BakedBodyMesh.cs b/Assets/@Eden_Tools/Eden_AutoMorpher/Script/BakedBodyMesh.cs index fb9324a..0ec8a58 100644 --- a/Assets/@Eden_Tools/Eden_AutoMorpher/Script/BakedBodyMesh.cs +++ b/Assets/@Eden_Tools/Eden_AutoMorpher/Script/BakedBodyMesh.cs @@ -1,4 +1,4 @@ -// Warning: Some assembly references could not be resolved automatically. This might lead to incorrect decompilation of some parts, +// 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.BakedBodyMesh @@ -6,27 +6,27 @@ using UnityEngine; public class BakedBodyMesh { - public SkinnedMeshRenderer smr; + public SkinnedMeshRenderer smr; - public Mesh bakedMesh; + public Mesh bakedMesh; - public BakedBodyMesh(SkinnedMeshRenderer _smr) - { - //IL_000e: Unknown result type (might be due to invalid IL or missing references) - //IL_0018: Expected O, but got Unknown - smr = _smr; - bakedMesh = new Mesh(); - smr.BakeMesh(bakedMesh); - } + public BakedBodyMesh(SkinnedMeshRenderer _smr) + { + //IL_000e: Unknown result type (might be due to invalid IL or missing references) + //IL_0018: Expected O, but got Unknown + this.smr = _smr; + this.bakedMesh = new Mesh(); + this.smr.BakeMesh(this.bakedMesh); + } - public void ReBakeMesh() - { - smr.BakeMesh(bakedMesh); - } + public void ReBakeMesh() + { + this.smr.BakeMesh(this.bakedMesh); + } - ~BakedBodyMesh() - { - smr = null; - bakedMesh = null; - } + ~BakedBodyMesh() + { + this.smr = null; + this.bakedMesh = null; + } } diff --git a/Assets/@Eden_Tools/Eden_AutoMorpher/Script/BodyPoseMatchSetupUtil.cs b/Assets/@Eden_Tools/Eden_AutoMorpher/Script/BodyPoseMatchSetupUtil.cs index fdd5a2f..50939c5 100644 --- a/Assets/@Eden_Tools/Eden_AutoMorpher/Script/BodyPoseMatchSetupUtil.cs +++ b/Assets/@Eden_Tools/Eden_AutoMorpher/Script/BodyPoseMatchSetupUtil.cs @@ -1,238 +1,235 @@ -// Warning: Some assembly references could not be resolved automatically. This might lead to incorrect decompilation of some parts, +// 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.BodyPoseMatchSetupUtil using System.Collections.Generic; using System.Linq; -using Eden.AutoMorpher; -using Eden.AutoMorpher.profile; using UnityEngine; public class BodyPoseMatchSetupUtil { - public void AdjustAvatarScaleByNeck(Transform avatarRoot, Dictionary> humanBoneMap, float targetHeight) - { - //IL_004e: Unknown result type (might be due to invalid IL or missing references) - //IL_0059: Unknown result type (might be due to invalid IL or missing references) - //IL_0093: 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_009a: 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_00a2: Unknown result type (might be due to invalid IL or missing references) - //IL_00a5: Unknown result type (might be due to invalid IL or missing references) - if ((Object)(object)avatarRoot == (Object)null) - { - Debug.LogWarning((object)"[AvatarBodyMatchUtil] NormalizeAvatarScaleByNeck: avatar == null"); - return; - } - Transform boneFromBoneMap = new BodyPoseMatch_CommonUtil().GetBoneFromBoneMap(humanBoneMap, (HumanBodyBones)9); - if ((Object)(object)boneFromBoneMap == (Object)null) - { - Debug.LogWarning((object)("[AvatarBodyMatchUtil] " + ((Object)avatarRoot).name + " 에서 Neck 본을 찾지 못했습니다. 스케일 정규화를 건너뜁니다.")); - return; - } - Transform transform = ((Component)avatarRoot).transform; - float num = boneFromBoneMap.position.y - transform.position.y; - if (Mathf.Approximately(num, 0f)) - { - Debug.LogWarning((object)$"[AvatarBodyMatchUtil] {((Object)avatarRoot).name} Neck Y가 0에 가까워 스케일 계산을 건너뜁니다. (neckY = {num})"); - return; - } - float num2 = targetHeight / num; - Vector3 localScale = transform.localScale; - localScale *= num2; - transform.localScale = localScale; - } + public void AdjustAvatarScaleByNeck(Transform avatarRoot, Dictionary> humanBoneMap, float targetHeight) + { + //IL_004e: Unknown result type (might be due to invalid IL or missing references) + //IL_0059: Unknown result type (might be due to invalid IL or missing references) + //IL_0093: 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_009a: 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_00a2: Unknown result type (might be due to invalid IL or missing references) + //IL_00a5: Unknown result type (might be due to invalid IL or missing references) + if ((Object)(object)avatarRoot == (Object)null) + { + Debug.LogWarning((object)"[AvatarBodyMatchUtil] NormalizeAvatarScaleByNeck: avatar == null"); + return; + } + Transform boneFromBoneMap = new BodyPoseMatch_CommonUtil().GetBoneFromBoneMap(humanBoneMap, (HumanBodyBones)9); + if ((Object)(object)boneFromBoneMap == (Object)null) + { + Debug.LogWarning((object)("[AvatarBodyMatchUtil] " + ((Object)avatarRoot).name + " 에서 Neck 본을 찾지 못했습니다. 스케일 정규화를 건너뜁니다.")); + return; + } + Transform transform = ((Component)avatarRoot).transform; + float num = boneFromBoneMap.position.y - transform.position.y; + if (Mathf.Approximately(num, 0f)) + { + Debug.LogWarning((object)$"[AvatarBodyMatchUtil] {((Object)avatarRoot).name} Neck Y가 0에 가까워 스케일 계산을 건너뜁니다. (neckY = {num})"); + return; + } + float num2 = targetHeight / num; + Vector3 localScale = transform.localScale; + localScale *= num2; + transform.localScale = localScale; + } - public GameObject CreateBodyProxy(Animator sourceAvatar, IReadOnlyList sourceBodyMeshes, out List proxyBodyMeshes, out Dictionary sourceToProxy) - { - //IL_00c9: 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) - proxyBodyMeshes = null; - if ((Object)(object)sourceAvatar == (Object)null) - { - Debug.LogError((object)"[AvatarBodyMatchUtil] CreateSourceBodyProxy: sourceAvatar == null"); - sourceToProxy = new Dictionary(); - return null; - } - GameObject clone = Object.Instantiate(((Component)sourceAvatar).gameObject); - ((Object)clone).name = ((Object)sourceAvatar).name + "_BodyProxy"; - HashSet remainTransforms = new HashSet(); - remainTransforms.Add(clone.transform); - Animator component = clone.GetComponent(); - if ((Object)(object)component != (Object)null) - { - ((Behaviour)component).enabled = false; - remainTransforms.Add(((Component)component).transform); - } - if ((Object)(object)component != (Object)null && (Object)(object)component.avatar != (Object)null && component.avatar.isHuman) - { - for (int i = 0; i < 55; i++) - { - HumanBodyBones val = (HumanBodyBones)i; - Transform boneTransform = component.GetBoneTransform(val); - if ((Object)(object)boneTransform != (Object)null) - { - remainTransforms.Add(boneTransform); - } - } - } - HashSet hashSet = new HashSet(); - if (sourceBodyMeshes != null) - { - foreach (SkinnedMeshRenderer sourceBodyMesh in sourceBodyMeshes) - { - if (!((Object)(object)sourceBodyMesh == (Object)null) && !((Object)(object)sourceBodyMesh.sharedMesh == (Object)null)) - { - hashSet.Add(sourceBodyMesh.sharedMesh); - } - } - } - SkinnedMeshRenderer[] componentsInChildren = clone.GetComponentsInChildren(true); - List list = new List(); - SkinnedMeshRenderer[] array = componentsInChildren; - foreach (SkinnedMeshRenderer val2 in array) - { - if (!((Object)(object)val2 == (Object)null)) - { - Mesh sharedMesh = val2.sharedMesh; - if (!((Object)(object)sharedMesh == (Object)null) && hashSet.Contains(sharedMesh)) - { - list.Add(val2); - } - } - } - if (list.Count == 0) - { - Debug.LogWarning((object)"[AvatarBodyMatchUtil] CreateSourceBodyProxy: clone에서 동일 sharedMesh를 가진 BodyMesh를 찾지 못했습니다."); - } - if (list.Count > 0) - { - MeshClassifier meshClassifier = new MeshClassifier(); - foreach (SkinnedMeshRenderer item in list) - { - if ((Object)(object)item == (Object)null) - { - continue; - } - remainTransforms.Add(((Component)item).transform); - HashSet activeBones = meshClassifier.GetActiveBones(item); - if (activeBones == null) - { - string[] obj = new string[5] - { - "[AvatarBodyMatchUtil] CreateSourceBodyProxy: clone smr '", - ((Object)item).name, - "' has null bones array (mesh='", - null, - null - }; - Mesh sharedMesh2 = item.sharedMesh; - obj[3] = ((sharedMesh2 != null) ? ((Object)sharedMesh2).name : null); - obj[4] = "')"; - Debug.LogWarning((object)string.Concat(obj)); - continue; - } - foreach (Transform item2 in activeBones) - { - if (!((Object)(object)item2 == (Object)null)) - { - remainTransforms.Add(item2); - } - } - } - } - foreach (Transform item3 in remainTransforms.ToList()) - { - AddWithParents(item3); - } - Transform[] componentsInChildren2 = clone.GetComponentsInChildren(true); - for (int num = componentsInChildren2.Length - 1; num >= 0; num--) - { - Transform val3 = componentsInChildren2[num]; - if (!((Object)(object)val3 == (Object)null) && !((Object)(object)val3 == (Object)(object)clone.transform) && !remainTransforms.Contains(val3)) - { - Object.DestroyImmediate((Object)(object)((Component)val3).gameObject); - } - } - proxyBodyMeshes = list; - new BoneMatchUtil().BuildSourceToProxyBoneMap(sourceAvatar, component, out sourceToProxy); - return clone; - void AddWithParents(Transform t) - { - while ((Object)(object)t != (Object)null && (Object)(object)t != (Object)(object)clone.transform) - { - remainTransforms.Add(t); - t = t.parent; - } - } - } + public GameObject CreateBodyProxy(Animator sourceAvatar, IReadOnlyList sourceBodyMeshes, out List proxyBodyMeshes, out Dictionary sourceToProxy) + { + //IL_00c9: 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) + proxyBodyMeshes = null; + if ((Object)(object)sourceAvatar == (Object)null) + { + Debug.LogError((object)"[AvatarBodyMatchUtil] CreateSourceBodyProxy: sourceAvatar == null"); + sourceToProxy = new Dictionary(); + return null; + } + GameObject clone = Object.Instantiate(((Component)sourceAvatar).gameObject); + ((Object)clone).name = ((Object)sourceAvatar).name + "_BodyProxy"; + HashSet remainTransforms = new HashSet(); + remainTransforms.Add(clone.transform); + Animator component = clone.GetComponent(); + if ((Object)(object)component != (Object)null) + { + ((Behaviour)component).enabled = false; + remainTransforms.Add(((Component)component).transform); + } + if ((Object)(object)component != (Object)null && (Object)(object)component.avatar != (Object)null && component.avatar.isHuman) + { + for (int i = 0; i < 55; i++) + { + HumanBodyBones val = (HumanBodyBones)i; + Transform boneTransform = component.GetBoneTransform(val); + if ((Object)(object)boneTransform != (Object)null) + { + remainTransforms.Add(boneTransform); + } + } + } + HashSet hashSet = new HashSet(); + if (sourceBodyMeshes != null) + { + foreach (SkinnedMeshRenderer sourceBodyMesh in sourceBodyMeshes) + { + if (!((Object)(object)sourceBodyMesh == (Object)null) && !((Object)(object)sourceBodyMesh.sharedMesh == (Object)null)) + { + hashSet.Add(sourceBodyMesh.sharedMesh); + } + } + } + SkinnedMeshRenderer[] componentsInChildren = clone.GetComponentsInChildren(true); + List list = new List(); + SkinnedMeshRenderer[] array = componentsInChildren; + foreach (SkinnedMeshRenderer val2 in array) + { + if (!((Object)(object)val2 == (Object)null)) + { + Mesh sharedMesh = val2.sharedMesh; + if (!((Object)(object)sharedMesh == (Object)null) && hashSet.Contains(sharedMesh)) + { + list.Add(val2); + } + } + } + if (list.Count == 0) + { + Debug.LogWarning((object)"[AvatarBodyMatchUtil] CreateSourceBodyProxy: clone에서 동일 sharedMesh를 가진 BodyMesh를 찾지 못했습니다."); + } + if (list.Count > 0) + { + MeshClassifier meshClassifier = new MeshClassifier(); + foreach (SkinnedMeshRenderer item in list) + { + if ((Object)(object)item == (Object)null) + { + continue; + } + remainTransforms.Add(((Component)item).transform); + HashSet activeBones = meshClassifier.GetActiveBones(item); + if (activeBones == null) + { + string[] obj = new string[5] + { + "[AvatarBodyMatchUtil] CreateSourceBodyProxy: clone smr '", + ((Object)item).name, + "' has null bones array (mesh='", + null, + null + }; + Mesh sharedMesh2 = item.sharedMesh; + obj[3] = ((sharedMesh2 != null) ? ((Object)sharedMesh2).name : null); + obj[4] = "')"; + Debug.LogWarning((object)string.Concat(obj)); + continue; + } + foreach (Transform item2 in activeBones) + { + if (!((Object)(object)item2 == (Object)null)) + { + remainTransforms.Add(item2); + } + } + } + } + foreach (Transform item3 in remainTransforms.ToList()) + { + AddWithParents(item3); + } + Transform[] componentsInChildren2 = clone.GetComponentsInChildren(true); + for (int num = componentsInChildren2.Length - 1; num >= 0; num--) + { + Transform val3 = componentsInChildren2[num]; + if (!((Object)(object)val3 == (Object)null) && !((Object)(object)val3 == (Object)(object)clone.transform) && !remainTransforms.Contains(val3)) + { + Object.DestroyImmediate((Object)(object)((Component)val3).gameObject); + } + } + proxyBodyMeshes = list; + new BoneMatchUtil().BuildSourceToProxyBoneMap(sourceAvatar, component, out sourceToProxy); + return clone; + void AddWithParents(Transform t) + { + while ((Object)(object)t != (Object)null && (Object)(object)t != (Object)(object)clone.transform) + { + remainTransforms.Add(t); + t = t.parent; + } + } + } - public Vector3 GetComprehensiveScale(Transform rootT, Dictionary> clothHumanoidBoneMap, ProfileData profileData) - { - //IL_00c7: Unknown result type (might be due to invalid IL or missing references) - //IL_00fc: Unknown result type (might be due to invalid IL or missing references) - //IL_0101: Unknown result type (might be due to invalid IL or missing references) - //IL_0103: 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_010b: Unknown result type (might be due to invalid IL or missing references) - //IL_0110: 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_011b: Unknown result type (might be due to invalid IL or missing references) - //IL_0123: 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_0132: Unknown result type (might be due to invalid IL or missing references) - //IL_0139: Unknown result type (might be due to invalid IL or missing references) - //IL_0146: 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_0154: Unknown result type (might be due to invalid IL or missing references) - //IL_015b: Unknown result type (might be due to invalid IL or missing references) - //IL_0162: Unknown result type (might be due to invalid IL or missing references) - //IL_0169: Unknown result type (might be due to invalid IL or missing references) - //IL_0170: Unknown result type (might be due to invalid IL or missing references) - if ((Object)(object)rootT == (Object)null) - { - throw new AutoMorpherException("Root Transform is Missing", "[BodyPoseMatch_CommonUtil] GetComprehensiveScale\n - rootT is null"); - } - if (profileData.bones == null || profileData.bones.Count == 0) - { - throw new AutoMorpherException("Profile Bones are Missing", "[BodyPoseMatch_CommonUtil] GetComprehensiveScale\n - profileData.bones is null or empty"); - } - Transform val = null; - if (clothHumanoidBoneMap.TryGetValue((HumanBodyBones)0, out var value) && value != null && value.Count > 0) - { - foreach (Transform item in value) - { - if ((Object)(object)item != (Object)null) - { - val = item; - break; - } - } - } - if ((Object)(object)val == (Object)null) - { - throw new AutoMorpherException("Hip Transform is Missing", "[BodyPoseMatch_CommonUtil] GetComprehensiveScale\n - failed to get [hip] transform from clothHumanoidBoneMap"); - } - BoneData val2 = null; - for (int i = 0; i < profileData.bones.Count; i++) - { - BoneData val3 = profileData.bones[i]; - if (val3 != null && (int)val3.hBone == 0) - { - val2 = val3; - break; - } - } - if (val2 == null) - { - throw new AutoMorpherException("Hip Bone Data is Missing in Profile", "[BodyPoseMatch_CommonUtil] GetComprehensiveScale\n - profileData bones does not contain Hips"); - } - Vector3 rootLocalScale = val2.rootLocalScale; - Vector3 lossyScale = rootT.lossyScale; - Vector3 lossyScale2 = val.lossyScale; - Vector3 val4 = default(Vector3); - ((Vector3)(ref val4))._002Ector(lossyScale2.x / lossyScale.x, lossyScale2.y / lossyScale.y, lossyScale2.z / lossyScale.z); - return new Vector3(val4.x / rootLocalScale.x, val4.y / rootLocalScale.y, val4.z / rootLocalScale.z); - } + public Vector3 GetComprehensiveScale(Transform rootT, Dictionary> clothHumanoidBoneMap, ProfileData profileData) + { + //IL_00c7: Unknown result type (might be due to invalid IL or missing references) + //IL_00fc: Unknown result type (might be due to invalid IL or missing references) + //IL_0101: Unknown result type (might be due to invalid IL or missing references) + //IL_0103: 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_010b: Unknown result type (might be due to invalid IL or missing references) + //IL_0110: 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_011b: Unknown result type (might be due to invalid IL or missing references) + //IL_0123: 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_0132: Unknown result type (might be due to invalid IL or missing references) + //IL_0139: Unknown result type (might be due to invalid IL or missing references) + //IL_0146: 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_0154: Unknown result type (might be due to invalid IL or missing references) + //IL_015b: Unknown result type (might be due to invalid IL or missing references) + //IL_0162: Unknown result type (might be due to invalid IL or missing references) + //IL_0169: Unknown result type (might be due to invalid IL or missing references) + //IL_0170: Unknown result type (might be due to invalid IL or missing references) + if ((Object)(object)rootT == (Object)null) + { + throw new AutoMorpherException("Root Transform is Missing", "[BodyPoseMatch_CommonUtil] GetComprehensiveScale\n - rootT is null"); + } + if (profileData.bones == null || profileData.bones.Count == 0) + { + throw new AutoMorpherException("Profile Bones are Missing", "[BodyPoseMatch_CommonUtil] GetComprehensiveScale\n - profileData.bones is null or empty"); + } + Transform val = null; + if (clothHumanoidBoneMap.TryGetValue((HumanBodyBones)0, out var value) && value != null && value.Count > 0) + { + foreach (Transform item in value) + { + if ((Object)(object)item != (Object)null) + { + val = item; + break; + } + } + } + if ((Object)(object)val == (Object)null) + { + throw new AutoMorpherException("Hip Transform is Missing", "[BodyPoseMatch_CommonUtil] GetComprehensiveScale\n - failed to get [hip] transform from clothHumanoidBoneMap"); + } + BoneData val2 = null; + for (int i = 0; i < profileData.bones.Count; i++) + { + BoneData val3 = profileData.bones[i]; + if (val3 != null && (int)val3.hBone == 0) + { + val2 = val3; + break; + } + } + if (val2 == null) + { + throw new AutoMorpherException("Hip Bone Data is Missing in Profile", "[BodyPoseMatch_CommonUtil] GetComprehensiveScale\n - profileData bones does not contain Hips"); + } + Vector3 rootLocalScale = val2.rootLocalScale; + Vector3 lossyScale = rootT.lossyScale; + Vector3 lossyScale2 = val.lossyScale; + Vector3 val4 = new Vector3(lossyScale2.x / lossyScale.x, lossyScale2.y / lossyScale.y, lossyScale2.z / lossyScale.z); + return new Vector3(val4.x / rootLocalScale.x, val4.y / rootLocalScale.y, val4.z / rootLocalScale.z); + } } diff --git a/Assets/@Eden_Tools/Eden_AutoMorpher/Script/BodyPoseMatchUtil.cs b/Assets/@Eden_Tools/Eden_AutoMorpher/Script/BodyPoseMatchUtil.cs index 67e5cea..07cdbd2 100644 --- a/Assets/@Eden_Tools/Eden_AutoMorpher/Script/BodyPoseMatchUtil.cs +++ b/Assets/@Eden_Tools/Eden_AutoMorpher/Script/BodyPoseMatchUtil.cs @@ -1,133 +1,132 @@ -// Warning: Some assembly references could not be resolved automatically. This might lead to incorrect decompilation of some parts, +// 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.BodyPoseMatchUtil using System.Collections.Generic; -using Eden.AutoMorpher; using UnityEngine; public class BodyPoseMatchUtil { - private WorldVertexUtil _worldVertexUtil; + private WorldVertexUtil _worldVertexUtil; - private MeshClassifier meshClassifier; + private MeshClassifier meshClassifier; - private BodyPoseMatch_CommonUtil poseMatchCommonUtil; + private BodyPoseMatch_CommonUtil poseMatchCommonUtil; - private bool doDebug; + private bool doDebug; - public BodyPoseMatchUtil() - { - _worldVertexUtil = new WorldVertexUtil(); - meshClassifier = new MeshClassifier(); - poseMatchCommonUtil = new BodyPoseMatch_CommonUtil(); - } + public BodyPoseMatchUtil() + { + this._worldVertexUtil = new WorldVertexUtil(); + this.meshClassifier = new MeshClassifier(); + this.poseMatchCommonUtil = new BodyPoseMatch_CommonUtil(); + } - public GameObject AutoAdjustBodyPose(GameObject sourceAvatar, IReadOnlyList sourceBodyMeshes, GameObject targetAvatar, IReadOnlyList targetBodyMeshes, out Dictionary sourceToProxy, float neckTargetHeight = 1.5f, bool onlyScaling = false) - { - //IL_00bb: Unknown result type (might be due to invalid IL or missing references) - //IL_0119: Unknown result type (might be due to invalid IL or missing references) - //IL_01cd: Unknown result type (might be due to invalid IL or missing references) - //IL_01d2: Unknown result type (might be due to invalid IL or missing references) - //IL_01ec: Unknown result type (might be due to invalid IL or missing references) - //IL_01f1: Unknown result type (might be due to invalid IL or missing references) - //IL_025b: Unknown result type (might be due to invalid IL or missing references) - //IL_0260: Unknown result type (might be due to invalid IL or missing references) - //IL_027b: Unknown result type (might be due to invalid IL or missing references) - //IL_0280: Unknown result type (might be due to invalid IL or missing references) - //IL_03a3: Unknown result type (might be due to invalid IL or missing references) - //IL_03a8: Unknown result type (might be due to invalid IL or missing references) - //IL_03c5: Unknown result type (might be due to invalid IL or missing references) - //IL_03ca: Unknown result type (might be due to invalid IL or missing references) - //IL_03e5: Unknown result type (might be due to invalid IL or missing references) - //IL_03ea: Unknown result type (might be due to invalid IL or missing references) - //IL_0405: Unknown result type (might be due to invalid IL or missing references) - //IL_040a: Unknown result type (might be due to invalid IL or missing references) - Animator component = sourceAvatar.GetComponent(); - Animator component2 = targetAvatar.GetComponent(); - if ((Object)(object)component == (Object)null || (Object)(object)component2 == (Object)null) - { - Debug.LogError((object)"[AvatarBodyMatchUtil] sourceAvatar 또는 targetAvatar가 null입니다."); - sourceToProxy = new Dictionary(); - return null; - } - Dictionary> humanBoneMap = meshClassifier.MeshHumanoidBoneMatcher(component, sourceBodyMeshes); - Dictionary> dictionary = meshClassifier.MeshHumanoidBoneMatcher(component2, targetBodyMeshes); - BodyPoseMatchSetupUtil bodyPoseMatchSetupUtil = new BodyPoseMatchSetupUtil(); - bodyPoseMatchSetupUtil.AdjustAvatarScaleByNeck(sourceAvatar.transform, humanBoneMap, neckTargetHeight); - bodyPoseMatchSetupUtil.AdjustAvatarScaleByNeck(targetAvatar.transform, dictionary, neckTargetHeight); - List proxyBodyMeshes; - GameObject val = bodyPoseMatchSetupUtil.CreateBodyProxy(component, sourceBodyMeshes, out proxyBodyMeshes, out sourceToProxy); - Animator component3 = val.GetComponent(); - if (onlyScaling) - { - val.transform.SetParent(targetAvatar.transform); - val.transform.localPosition = Vector3.zero; - return val; - } - Dictionary> dictionary2 = meshClassifier.MeshHumanoidBoneMatcher(component3, proxyBodyMeshes); - if (dictionary2 == null || dictionary2.Count == 0) - { - throw new AutoMorpherException("Proxy Bone Map is Missing", "[BodyPoseMatch_Arm] AlignUpperArmByArmPcaCenters\n - proxyBoneMap is null"); - } - val.transform.SetParent(targetAvatar.transform); - val.transform.localPosition = Vector3.zero; - List list = new List(); - foreach (SkinnedMeshRenderer item in proxyBodyMeshes) - { - list.Add(new BakedBodyMesh(item)); - } - List list2 = new List(); - foreach (SkinnedMeshRenderer targetBodyMesh in targetBodyMeshes) - { - list2.Add(new BakedBodyMesh(targetBodyMesh)); - } - BodyPoseMatch_Torso bodyPoseMatch_Torso = new BodyPoseMatch_Torso(); - bodyPoseMatch_Torso.AlignTorsoByNeck(val, list, dictionary2, targetAvatar, list2, dictionary); - if (doDebug) - { - bodyPoseMatch_Torso.DrawTorsoPcaDebug(val, list, dictionary2, Color.yellow, Color.cyan, 1f, 20f); - bodyPoseMatch_Torso.DrawTorsoPcaDebug(targetAvatar, list2, dictionary, Color.red, Color.green, 1f, 20f); - } - foreach (BakedBodyMesh item2 in list) - { - item2.ReBakeMesh(); - } - BodyPoseMatch_Arm bodyPoseMatch_Arm = new BodyPoseMatch_Arm(); - bodyPoseMatch_Arm.AlignUpperArmByArmPcaCenters(list, dictionary2, list2, dictionary); - if (doDebug) - { - bodyPoseMatch_Arm.DrawArmPcaDebug(val, list, dictionary2, isLeft: true, Color.yellow, Color.cyan, 1f, 20f); - bodyPoseMatch_Arm.DrawArmPcaDebug(targetAvatar, list2, dictionary, isLeft: true, Color.red, Color.green, 1f, 20f); - } - foreach (BakedBodyMesh item3 in list) - { - item3.ReBakeMesh(); - } - bodyPoseMatch_Arm.ScalingBothArmsLength(list, dictionary2, list2, dictionary); - foreach (BakedBodyMesh item4 in list) - { - item4.ReBakeMesh(); - } - BodyPoseMatch_Leg bodyPoseMatch_Leg = new BodyPoseMatch_Leg(); - bodyPoseMatch_Leg.AlignBothUpperLegs(val, list, dictionary2, targetAvatar, list2, dictionary); - foreach (BakedBodyMesh item5 in list) - { - item5.ReBakeMesh(); - } - bodyPoseMatch_Leg.ScalingBothLegsAndFoots(val, list, dictionary2, targetAvatar, list2, dictionary); - if (doDebug) - { - foreach (BakedBodyMesh item6 in list) - { - item6.ReBakeMesh(); - } - bodyPoseMatch_Leg.DrawLegPcaDebug(val, list, dictionary2, isLeft: true, Color.yellow, Color.cyan, 1f, 5f); - bodyPoseMatch_Leg.DrawLegPcaDebug(val, list, dictionary2, isLeft: false, Color.yellow, Color.cyan, 1f, 5f); - bodyPoseMatch_Leg.DrawLegPcaDebug(targetAvatar, list2, dictionary, isLeft: true, Color.magenta, Color.green, 1f, 5f); - bodyPoseMatch_Leg.DrawLegPcaDebug(targetAvatar, list2, dictionary, isLeft: false, Color.magenta, Color.green, 1f, 5f); - bodyPoseMatch_Arm.DrawForearmExtremeDebugPair(val.gameObject, proxyBodyMeshes, targetAvatar, targetBodyMeshes, isLeft: true, 1f, 5f); - } - return val; - } + public GameObject AutoAdjustBodyPose(GameObject sourceAvatar, IReadOnlyList sourceBodyMeshes, GameObject targetAvatar, IReadOnlyList targetBodyMeshes, out Dictionary sourceToProxy, float neckTargetHeight = 1.5f, bool onlyScaling = false) + { + //IL_00bb: Unknown result type (might be due to invalid IL or missing references) + //IL_0119: Unknown result type (might be due to invalid IL or missing references) + //IL_01cd: Unknown result type (might be due to invalid IL or missing references) + //IL_01d2: Unknown result type (might be due to invalid IL or missing references) + //IL_01ec: Unknown result type (might be due to invalid IL or missing references) + //IL_01f1: Unknown result type (might be due to invalid IL or missing references) + //IL_025b: Unknown result type (might be due to invalid IL or missing references) + //IL_0260: Unknown result type (might be due to invalid IL or missing references) + //IL_027b: Unknown result type (might be due to invalid IL or missing references) + //IL_0280: Unknown result type (might be due to invalid IL or missing references) + //IL_03a3: Unknown result type (might be due to invalid IL or missing references) + //IL_03a8: Unknown result type (might be due to invalid IL or missing references) + //IL_03c5: Unknown result type (might be due to invalid IL or missing references) + //IL_03ca: Unknown result type (might be due to invalid IL or missing references) + //IL_03e5: Unknown result type (might be due to invalid IL or missing references) + //IL_03ea: Unknown result type (might be due to invalid IL or missing references) + //IL_0405: Unknown result type (might be due to invalid IL or missing references) + //IL_040a: Unknown result type (might be due to invalid IL or missing references) + Animator component = sourceAvatar.GetComponent(); + Animator component2 = targetAvatar.GetComponent(); + if ((Object)(object)component == (Object)null || (Object)(object)component2 == (Object)null) + { + Debug.LogError((object)"[AvatarBodyMatchUtil] sourceAvatar 또는 targetAvatar가 null입니다."); + sourceToProxy = new Dictionary(); + return null; + } + Dictionary> humanBoneMap = this.meshClassifier.MeshHumanoidBoneMatcher(component, sourceBodyMeshes); + Dictionary> dictionary = this.meshClassifier.MeshHumanoidBoneMatcher(component2, targetBodyMeshes); + BodyPoseMatchSetupUtil bodyPoseMatchSetupUtil = new BodyPoseMatchSetupUtil(); + bodyPoseMatchSetupUtil.AdjustAvatarScaleByNeck(sourceAvatar.transform, humanBoneMap, neckTargetHeight); + bodyPoseMatchSetupUtil.AdjustAvatarScaleByNeck(targetAvatar.transform, dictionary, neckTargetHeight); + List proxyBodyMeshes; + GameObject val = bodyPoseMatchSetupUtil.CreateBodyProxy(component, sourceBodyMeshes, out proxyBodyMeshes, out sourceToProxy); + Animator component3 = val.GetComponent(); + if (onlyScaling) + { + val.transform.SetParent(targetAvatar.transform); + val.transform.localPosition = Vector3.zero; + return val; + } + Dictionary> dictionary2 = this.meshClassifier.MeshHumanoidBoneMatcher(component3, proxyBodyMeshes); + if (dictionary2 == null || dictionary2.Count == 0) + { + throw new AutoMorpherException("Proxy Bone Map is Missing", "[BodyPoseMatch_Arm] AlignUpperArmByArmPcaCenters\n - proxyBoneMap is null"); + } + val.transform.SetParent(targetAvatar.transform); + val.transform.localPosition = Vector3.zero; + List list = new List(); + foreach (SkinnedMeshRenderer item in proxyBodyMeshes) + { + list.Add(new BakedBodyMesh(item)); + } + List list2 = new List(); + foreach (SkinnedMeshRenderer targetBodyMesh in targetBodyMeshes) + { + list2.Add(new BakedBodyMesh(targetBodyMesh)); + } + BodyPoseMatch_Torso bodyPoseMatch_Torso = new BodyPoseMatch_Torso(); + bodyPoseMatch_Torso.AlignTorsoByNeck(val, list, dictionary2, targetAvatar, list2, dictionary); + if (this.doDebug) + { + bodyPoseMatch_Torso.DrawTorsoPcaDebug(val, list, dictionary2, Color.yellow, Color.cyan, 1f, 20f); + bodyPoseMatch_Torso.DrawTorsoPcaDebug(targetAvatar, list2, dictionary, Color.red, Color.green, 1f, 20f); + } + foreach (BakedBodyMesh item2 in list) + { + item2.ReBakeMesh(); + } + BodyPoseMatch_Arm bodyPoseMatch_Arm = new BodyPoseMatch_Arm(); + bodyPoseMatch_Arm.AlignUpperArmByArmPcaCenters(list, dictionary2, list2, dictionary); + if (this.doDebug) + { + bodyPoseMatch_Arm.DrawArmPcaDebug(val, list, dictionary2, isLeft: true, Color.yellow, Color.cyan, 1f, 20f); + bodyPoseMatch_Arm.DrawArmPcaDebug(targetAvatar, list2, dictionary, isLeft: true, Color.red, Color.green, 1f, 20f); + } + foreach (BakedBodyMesh item3 in list) + { + item3.ReBakeMesh(); + } + bodyPoseMatch_Arm.ScalingBothArmsLength(list, dictionary2, list2, dictionary); + foreach (BakedBodyMesh item4 in list) + { + item4.ReBakeMesh(); + } + BodyPoseMatch_Leg bodyPoseMatch_Leg = new BodyPoseMatch_Leg(); + bodyPoseMatch_Leg.AlignBothUpperLegs(val, list, dictionary2, targetAvatar, list2, dictionary); + foreach (BakedBodyMesh item5 in list) + { + item5.ReBakeMesh(); + } + bodyPoseMatch_Leg.ScalingBothLegsAndFoots(val, list, dictionary2, targetAvatar, list2, dictionary); + if (this.doDebug) + { + foreach (BakedBodyMesh item6 in list) + { + item6.ReBakeMesh(); + } + bodyPoseMatch_Leg.DrawLegPcaDebug(val, list, dictionary2, isLeft: true, Color.yellow, Color.cyan, 1f, 5f); + bodyPoseMatch_Leg.DrawLegPcaDebug(val, list, dictionary2, isLeft: false, Color.yellow, Color.cyan, 1f, 5f); + bodyPoseMatch_Leg.DrawLegPcaDebug(targetAvatar, list2, dictionary, isLeft: true, Color.magenta, Color.green, 1f, 5f); + bodyPoseMatch_Leg.DrawLegPcaDebug(targetAvatar, list2, dictionary, isLeft: false, Color.magenta, Color.green, 1f, 5f); + bodyPoseMatch_Arm.DrawForearmExtremeDebugPair(val.gameObject, proxyBodyMeshes, targetAvatar, targetBodyMeshes, isLeft: true, 1f, 5f); + } + return val; + } } diff --git a/Assets/@Eden_Tools/Eden_AutoMorpher/Script/BodyPoseMatch_Arm.cs b/Assets/@Eden_Tools/Eden_AutoMorpher/Script/BodyPoseMatch_Arm.cs index c59a8db..aedb0d8 100644 --- a/Assets/@Eden_Tools/Eden_AutoMorpher/Script/BodyPoseMatch_Arm.cs +++ b/Assets/@Eden_Tools/Eden_AutoMorpher/Script/BodyPoseMatch_Arm.cs @@ -1,758 +1,751 @@ -// Warning: Some assembly references could not be resolved automatically. This might lead to incorrect decompilation of some parts, +// 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.BodyPoseMatch_Arm -using System; using System.Collections.Generic; -using System.Runtime.CompilerServices; -using Eden.AutoMorpher; -using Eden.AutoMorpher.profile; using UnityEngine; public class BodyPoseMatch_Arm { - private readonly BodyPoseMatch_CommonUtil poseMatchCommonUtil; + private readonly BodyPoseMatch_CommonUtil poseMatchCommonUtil; - public BodyPoseMatch_Arm() - { - poseMatchCommonUtil = new BodyPoseMatch_CommonUtil(); - } + public BodyPoseMatch_Arm() + { + this.poseMatchCommonUtil = new BodyPoseMatch_CommonUtil(); + } - public void AlignUpperArmByArmCenters(IReadOnlyCollection sourceLeftUpperArmSet, IReadOnlyCollection sourceRightUpperArmSet, Vector3 sourceShoulderCenterWorld, Vector3 targetShoulderCenterWorld, Transform axisReferenceTransform, bool lockRightAxis = true) - { - //IL_0050: Unknown result type (might be due to invalid IL or missing references) - //IL_0052: Unknown result type (might be due to invalid IL or missing references) - //IL_0053: Unknown result type (might be due to invalid IL or missing references) - //IL_0058: Unknown result type (might be due to invalid IL or missing references) - //IL_005f: Unknown result type (might be due to invalid IL or missing references) - //IL_0064: Unknown result type (might be due to invalid IL or missing references) - //IL_0065: Unknown result type (might be due to invalid IL or missing references) - //IL_0066: Unknown result type (might be due to invalid IL or missing references) - //IL_006d: Unknown result type (might be due to invalid IL or missing references) - //IL_006e: Unknown result type (might be due to invalid IL or missing references) - //IL_0070: Unknown result type (might be due to invalid IL or missing references) - //IL_0075: Unknown result type (might be due to invalid IL or missing references) - //IL_007a: 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_009e: Unknown result type (might be due to invalid IL or missing references) - //IL_009f: Unknown result type (might be due to invalid IL or missing references) - //IL_00db: Unknown result type (might be due to invalid IL or missing references) - //IL_00e0: Unknown result type (might be due to invalid IL or missing references) - //IL_00e1: Unknown result type (might be due to invalid IL or missing references) - if (sourceLeftUpperArmSet == null || sourceLeftUpperArmSet.Count == 0) - { - throw new AutoMorpherException("Source Left UpperArm Set is Missing", "[BodyPoseMatch_Arm] AlignUpperArmByArmCenters\n - sourceLeftUpperArmSet is null or empty"); - } - if (sourceRightUpperArmSet == null || sourceRightUpperArmSet.Count == 0) - { - throw new AutoMorpherException("Source Right UpperArm Set is Missing", "[BodyPoseMatch_Arm] AlignUpperArmByArmCenters\n - sourceRightUpperArmSet is null or empty"); - } - if ((Object)(object)axisReferenceTransform == (Object)null) - { - throw new AutoMorpherException("Axis Reference Transform is Missing", "[BodyPoseMatch_Arm] AlignUpperArmByArmCenters\n - axisReferenceTransform is null"); - } - Vector3 val = targetShoulderCenterWorld - sourceShoulderCenterWorld; - if (lockRightAxis) - { - Vector3 right = axisReferenceTransform.right; - float num = Vector3.Dot(val, right); - val -= right * num; - } - foreach (Transform item in sourceLeftUpperArmSet) - { - if (!((Object)(object)item == (Object)null)) - { - item.position += val; - } - } - foreach (Transform item2 in sourceRightUpperArmSet) - { - if (!((Object)(object)item2 == (Object)null)) - { - item2.position += val; - } - } - } + public void AlignUpperArmByArmCenters(IReadOnlyCollection sourceLeftUpperArmSet, IReadOnlyCollection sourceRightUpperArmSet, Vector3 sourceShoulderCenterWorld, Vector3 targetShoulderCenterWorld, Transform axisReferenceTransform, bool lockRightAxis = true) + { + //IL_0050: Unknown result type (might be due to invalid IL or missing references) + //IL_0052: Unknown result type (might be due to invalid IL or missing references) + //IL_0053: Unknown result type (might be due to invalid IL or missing references) + //IL_0058: Unknown result type (might be due to invalid IL or missing references) + //IL_005f: Unknown result type (might be due to invalid IL or missing references) + //IL_0064: Unknown result type (might be due to invalid IL or missing references) + //IL_0065: Unknown result type (might be due to invalid IL or missing references) + //IL_0066: Unknown result type (might be due to invalid IL or missing references) + //IL_006d: Unknown result type (might be due to invalid IL or missing references) + //IL_006e: Unknown result type (might be due to invalid IL or missing references) + //IL_0070: Unknown result type (might be due to invalid IL or missing references) + //IL_0075: Unknown result type (might be due to invalid IL or missing references) + //IL_007a: 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_009e: Unknown result type (might be due to invalid IL or missing references) + //IL_009f: Unknown result type (might be due to invalid IL or missing references) + //IL_00db: Unknown result type (might be due to invalid IL or missing references) + //IL_00e0: Unknown result type (might be due to invalid IL or missing references) + //IL_00e1: Unknown result type (might be due to invalid IL or missing references) + if (sourceLeftUpperArmSet == null || sourceLeftUpperArmSet.Count == 0) + { + throw new AutoMorpherException("Source Left UpperArm Set is Missing", "[BodyPoseMatch_Arm] AlignUpperArmByArmCenters\n - sourceLeftUpperArmSet is null or empty"); + } + if (sourceRightUpperArmSet == null || sourceRightUpperArmSet.Count == 0) + { + throw new AutoMorpherException("Source Right UpperArm Set is Missing", "[BodyPoseMatch_Arm] AlignUpperArmByArmCenters\n - sourceRightUpperArmSet is null or empty"); + } + if (axisReferenceTransform == null) + { + throw new AutoMorpherException("Axis Reference Transform is Missing", "[BodyPoseMatch_Arm] AlignUpperArmByArmCenters\n - axisReferenceTransform is null"); + } + Vector3 val = targetShoulderCenterWorld - sourceShoulderCenterWorld; + if (lockRightAxis) + { + Vector3 right = axisReferenceTransform.right; + float num = Vector3.Dot(val, right); + val -= right * num; + } + foreach (Transform item in sourceLeftUpperArmSet) + { + if (!(item == null)) + { + item.position += val; + } + } + foreach (Transform item2 in sourceRightUpperArmSet) + { + if (!(item2 == null)) + { + item2.position += val; + } + } + } - public void AlignUpperArmByArmPcaCenters(IReadOnlyList proxyBakedBodyMeshes, Dictionary> proxyBoneMap, IReadOnlyList targetBakedBodyMeshes, Dictionary> targetBoneMap) - { - //IL_0082: Unknown result type (might be due to invalid IL or missing references) - //IL_0088: Unknown result type (might be due to invalid IL or missing references) - //IL_008d: Unknown result type (might be due to invalid IL or missing references) - //IL_0092: Unknown result type (might be due to invalid IL or missing references) - //IL_00e6: 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_00f7: Unknown result type (might be due to invalid IL or missing references) - //IL_0150: Unknown result type (might be due to invalid IL or missing references) - //IL_0152: Unknown result type (might be due to invalid IL or missing references) - if (proxyBoneMap == null) - { - throw new AutoMorpherException("Proxy Bone Map is Missing", "[BodyPoseMatch_Arm] AlignUpperArmByArmPcaCenters\n - proxyBoneMap is null"); - } - Transform boneFromBoneMap = poseMatchCommonUtil.GetBoneFromBoneMap(proxyBoneMap, (HumanBodyBones)0); - if ((Object)(object)boneFromBoneMap == (Object)null) - { - throw new AutoMorpherException("Proxy Hips is Missing", "[BodyPoseMatch_Arm] AlignUpperArmByArmPcaCenters\n - proxy hips transform is null"); - } - RegionStats regionStats = ComputeArmRegionStats(proxyBakedBodyMeshes, proxyBoneMap, isLeft: true); - RegionStats regionStats2 = ComputeArmRegionStats(proxyBakedBodyMeshes, proxyBoneMap, isLeft: false); - bool flag = regionStats.length > 0.0001f; - bool flag2 = regionStats2.length > 0.0001f; - if (!flag && !flag2) - { - Debug.LogWarning((object)"[BodyPoseMatch_Arm] AlignUpperArmByArmPcaCenters: proxy arm PCA failed. Skip."); - return; - } - Vector3 sourceShoulderCenterWorld = CalculateShoulderCenter(flag, flag2, regionStats.center, regionStats2.center); - RegionStats regionStats3 = ComputeArmRegionStats(targetBakedBodyMeshes, targetBoneMap, isLeft: true); - RegionStats regionStats4 = ComputeArmRegionStats(targetBakedBodyMeshes, targetBoneMap, isLeft: false); - bool flag3 = regionStats3.length > 0.0001f; - bool flag4 = regionStats4.length > 0.0001f; - if (!flag3 && !flag4) - { - Debug.LogWarning((object)"[BodyPoseMatch_Arm] AlignUpperArmByArmPcaCenters: target arm PCA failed. Skip."); - return; - } - Vector3 targetShoulderCenterWorld = CalculateShoulderCenter(flag3, flag4, regionStats3.center, regionStats4.center); - if (!proxyBoneMap.TryGetValue((HumanBodyBones)13, out var value) || value == null || value.Count == 0) - { - throw new AutoMorpherException("Proxy Left UpperArm Set is Missing", "[BodyPoseMatch_Arm] AlignUpperArmByArmPcaCenters\n - proxyBoneMap has no LeftUpperArm set"); - } - if (!proxyBoneMap.TryGetValue((HumanBodyBones)14, out var value2) || value2 == null || value2.Count == 0) - { - throw new AutoMorpherException("Proxy Right UpperArm Set is Missing", "[BodyPoseMatch_Arm] AlignUpperArmByArmPcaCenters\n - proxyBoneMap has no RightUpperArm set"); - } - AlignUpperArmByArmCenters(value, value2, sourceShoulderCenterWorld, targetShoulderCenterWorld, boneFromBoneMap); - } + public void AlignUpperArmByArmPcaCenters(IReadOnlyList proxyBakedBodyMeshes, Dictionary> proxyBoneMap, IReadOnlyList targetBakedBodyMeshes, Dictionary> targetBoneMap) + { + //IL_0082: Unknown result type (might be due to invalid IL or missing references) + //IL_0088: Unknown result type (might be due to invalid IL or missing references) + //IL_008d: Unknown result type (might be due to invalid IL or missing references) + //IL_0092: Unknown result type (might be due to invalid IL or missing references) + //IL_00e6: 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_00f7: Unknown result type (might be due to invalid IL or missing references) + //IL_0150: Unknown result type (might be due to invalid IL or missing references) + //IL_0152: Unknown result type (might be due to invalid IL or missing references) + if (proxyBoneMap == null) + { + throw new AutoMorpherException("Proxy Bone Map is Missing", "[BodyPoseMatch_Arm] AlignUpperArmByArmPcaCenters\n - proxyBoneMap is null"); + } + Transform boneFromBoneMap = this.poseMatchCommonUtil.GetBoneFromBoneMap(proxyBoneMap, (HumanBodyBones)0); + if (boneFromBoneMap == null) + { + throw new AutoMorpherException("Proxy Hips is Missing", "[BodyPoseMatch_Arm] AlignUpperArmByArmPcaCenters\n - proxy hips transform is null"); + } + RegionStats regionStats = this.ComputeArmRegionStats(proxyBakedBodyMeshes, proxyBoneMap, isLeft: true); + RegionStats regionStats2 = this.ComputeArmRegionStats(proxyBakedBodyMeshes, proxyBoneMap, isLeft: false); + bool flag = regionStats.length > 0.0001f; + bool flag2 = regionStats2.length > 0.0001f; + if (!flag && !flag2) + { + Debug.LogWarning((object)"[BodyPoseMatch_Arm] AlignUpperArmByArmPcaCenters: proxy arm PCA failed. Skip."); + return; + } + Vector3 sourceShoulderCenterWorld = this.CalculateShoulderCenter(flag, flag2, regionStats.center, regionStats2.center); + RegionStats regionStats3 = this.ComputeArmRegionStats(targetBakedBodyMeshes, targetBoneMap, isLeft: true); + RegionStats regionStats4 = this.ComputeArmRegionStats(targetBakedBodyMeshes, targetBoneMap, isLeft: false); + bool flag3 = regionStats3.length > 0.0001f; + bool flag4 = regionStats4.length > 0.0001f; + if (!flag3 && !flag4) + { + Debug.LogWarning((object)"[BodyPoseMatch_Arm] AlignUpperArmByArmPcaCenters: target arm PCA failed. Skip."); + return; + } + Vector3 targetShoulderCenterWorld = this.CalculateShoulderCenter(flag3, flag4, regionStats3.center, regionStats4.center); + if (!proxyBoneMap.TryGetValue((HumanBodyBones)13, out var value) || value == null || value.Count == 0) + { + throw new AutoMorpherException("Proxy Left UpperArm Set is Missing", "[BodyPoseMatch_Arm] AlignUpperArmByArmPcaCenters\n - proxyBoneMap has no LeftUpperArm set"); + } + if (!proxyBoneMap.TryGetValue((HumanBodyBones)14, out var value2) || value2 == null || value2.Count == 0) + { + throw new AutoMorpherException("Proxy Right UpperArm Set is Missing", "[BodyPoseMatch_Arm] AlignUpperArmByArmPcaCenters\n - proxyBoneMap has no RightUpperArm set"); + } + this.AlignUpperArmByArmCenters(value, value2, sourceShoulderCenterWorld, targetShoulderCenterWorld, boneFromBoneMap); + } - public void AlignUpperArmByArmPcaCenters(IReadOnlyList targetBakedBodyMeshes, Dictionary> targetBoneMap, Dictionary> clothBoneMap, Transform clothesTransform, ProfileData profileData, Vector3 comprehensiveScale) - { - //IL_00c5: Unknown result type (might be due to invalid IL or missing references) - //IL_00ca: Unknown result type (might be due to invalid IL or missing references) - //IL_00e9: Unknown result type (might be due to invalid IL or missing references) - //IL_00ee: Unknown result type (might be due to invalid IL or missing references) - //IL_00dc: 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_0112: 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_0115: 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_0101: 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_016c: Unknown result type (might be due to invalid IL or missing references) - //IL_0173: Unknown result type (might be due to invalid IL or missing references) - //IL_0178: Unknown result type (might be due to invalid IL or missing references) - //IL_017d: Unknown result type (might be due to invalid IL or missing references) - //IL_01d6: Unknown result type (might be due to invalid IL or missing references) - //IL_01d8: Unknown result type (might be due to invalid IL or missing references) - if (clothBoneMap == null) - { - throw new AutoMorpherException("Cloth Bone Map is Missing", "[BodyPoseMatch_Arm] AlignUpperArmByArmPcaCenters\n - clothBoneMap is null"); - } - if (profileData == null) - { - throw new AutoMorpherException("Profile Data is Missing", "[BodyPoseMatch_Arm] AlignUpperArmByArmPcaCenters\n - profileData is null"); - } - Transform boneFromBoneMap = poseMatchCommonUtil.GetBoneFromBoneMap(clothBoneMap, (HumanBodyBones)0); - if ((Object)(object)boneFromBoneMap == (Object)null) - { - throw new AutoMorpherException("Cloth Hips is Missing", "[BodyPoseMatch_Arm] AlignUpperArmByArmPcaCenters\n - cloth hips transform is null"); - } - bool flag = profileData.LeftUpperArmSpatialData != null && profileData.LeftUpperArmSpatialData.pcaData != null && profileData.LeftUpperArmSpatialData.pcaData.pcaLength > 0.0001f; - bool flag2 = profileData.RightUpperArmSpatialData != null && profileData.RightUpperArmSpatialData.pcaData != null && profileData.RightUpperArmSpatialData.pcaData.pcaLength > 0.0001f; - if (!flag && !flag2) - { - Debug.LogWarning((object)"[BodyPoseMatch_Arm] AlignUpperArmByArmPcaCenters: profile arm data invalid. Skip."); - return; - } - Vector3 leftCenter = Vector3.zero; - if (flag) - { - leftCenter = poseMatchCommonUtil.GetProfilePcaCenterWorld(clothBoneMap, profileData.LeftUpperArmSpatialData, comprehensiveScale); - } - Vector3 rightCenter = Vector3.zero; - if (flag2) - { - rightCenter = poseMatchCommonUtil.GetProfilePcaCenterWorld(clothBoneMap, profileData.RightUpperArmSpatialData, comprehensiveScale); - } - Vector3 sourceShoulderCenterWorld = CalculateShoulderCenter(flag, flag2, leftCenter, rightCenter); - RegionStats regionStats = ComputeArmRegionStats(targetBakedBodyMeshes, targetBoneMap, isLeft: true); - RegionStats regionStats2 = ComputeArmRegionStats(targetBakedBodyMeshes, targetBoneMap, isLeft: false); - bool flag3 = regionStats.length > 0.0001f; - bool flag4 = regionStats2.length > 0.0001f; - if (!flag3 && !flag4) - { - Debug.LogWarning((object)"[BodyPoseMatch_Arm] AlignUpperArmByArmPcaCenters: target arm PCA failed. Skip."); - return; - } - Vector3 targetShoulderCenterWorld = CalculateShoulderCenter(flag3, flag4, regionStats.center, regionStats2.center); - if (!clothBoneMap.TryGetValue((HumanBodyBones)13, out var value) || value == null || value.Count == 0) - { - throw new AutoMorpherException("Cloth Left UpperArm Set is Missing", "[BodyPoseMatch_Arm] AlignUpperArmByArmPcaCenters\n - clothBoneMap has no LeftUpperArm set"); - } - if (!clothBoneMap.TryGetValue((HumanBodyBones)14, out var value2) || value2 == null || value2.Count == 0) - { - throw new AutoMorpherException("Cloth Right UpperArm Set is Missing", "[BodyPoseMatch_Arm] AlignUpperArmByArmPcaCenters\n - clothBoneMap has no RightUpperArm set"); - } - AlignUpperArmByArmCenters(value, value2, sourceShoulderCenterWorld, targetShoulderCenterWorld, boneFromBoneMap); - } + public void AlignUpperArmByArmPcaCenters(IReadOnlyList targetBakedBodyMeshes, Dictionary> targetBoneMap, Dictionary> clothBoneMap, Transform clothesTransform, ProfileData profileData, Vector3 comprehensiveScale) + { + //IL_00c5: Unknown result type (might be due to invalid IL or missing references) + //IL_00ca: Unknown result type (might be due to invalid IL or missing references) + //IL_00e9: Unknown result type (might be due to invalid IL or missing references) + //IL_00ee: Unknown result type (might be due to invalid IL or missing references) + //IL_00dc: 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_0112: 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_0115: 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_0101: 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_016c: Unknown result type (might be due to invalid IL or missing references) + //IL_0173: Unknown result type (might be due to invalid IL or missing references) + //IL_0178: Unknown result type (might be due to invalid IL or missing references) + //IL_017d: Unknown result type (might be due to invalid IL or missing references) + //IL_01d6: Unknown result type (might be due to invalid IL or missing references) + //IL_01d8: Unknown result type (might be due to invalid IL or missing references) + if (clothBoneMap == null) + { + throw new AutoMorpherException("Cloth Bone Map is Missing", "[BodyPoseMatch_Arm] AlignUpperArmByArmPcaCenters\n - clothBoneMap is null"); + } + if (profileData == null) + { + throw new AutoMorpherException("Profile Data is Missing", "[BodyPoseMatch_Arm] AlignUpperArmByArmPcaCenters\n - profileData is null"); + } + Transform boneFromBoneMap = this.poseMatchCommonUtil.GetBoneFromBoneMap(clothBoneMap, (HumanBodyBones)0); + if (boneFromBoneMap == null) + { + throw new AutoMorpherException("Cloth Hips is Missing", "[BodyPoseMatch_Arm] AlignUpperArmByArmPcaCenters\n - cloth hips transform is null"); + } + bool flag = profileData.LeftUpperArmSpatialData != null && profileData.LeftUpperArmSpatialData.pcaData != null && profileData.LeftUpperArmSpatialData.pcaData.pcaLength > 0.0001f; + bool flag2 = profileData.RightUpperArmSpatialData != null && profileData.RightUpperArmSpatialData.pcaData != null && profileData.RightUpperArmSpatialData.pcaData.pcaLength > 0.0001f; + if (!flag && !flag2) + { + Debug.LogWarning((object)"[BodyPoseMatch_Arm] AlignUpperArmByArmPcaCenters: profile arm data invalid. Skip."); + return; + } + Vector3 leftCenter = Vector3.zero; + if (flag) + { + leftCenter = this.poseMatchCommonUtil.GetProfilePcaCenterWorld(clothBoneMap, profileData.LeftUpperArmSpatialData, comprehensiveScale); + } + Vector3 rightCenter = Vector3.zero; + if (flag2) + { + rightCenter = this.poseMatchCommonUtil.GetProfilePcaCenterWorld(clothBoneMap, profileData.RightUpperArmSpatialData, comprehensiveScale); + } + Vector3 sourceShoulderCenterWorld = this.CalculateShoulderCenter(flag, flag2, leftCenter, rightCenter); + RegionStats regionStats = this.ComputeArmRegionStats(targetBakedBodyMeshes, targetBoneMap, isLeft: true); + RegionStats regionStats2 = this.ComputeArmRegionStats(targetBakedBodyMeshes, targetBoneMap, isLeft: false); + bool flag3 = regionStats.length > 0.0001f; + bool flag4 = regionStats2.length > 0.0001f; + if (!flag3 && !flag4) + { + Debug.LogWarning((object)"[BodyPoseMatch_Arm] AlignUpperArmByArmPcaCenters: target arm PCA failed. Skip."); + return; + } + Vector3 targetShoulderCenterWorld = this.CalculateShoulderCenter(flag3, flag4, regionStats.center, regionStats2.center); + if (!clothBoneMap.TryGetValue((HumanBodyBones)13, out var value) || value == null || value.Count == 0) + { + throw new AutoMorpherException("Cloth Left UpperArm Set is Missing", "[BodyPoseMatch_Arm] AlignUpperArmByArmPcaCenters\n - clothBoneMap has no LeftUpperArm set"); + } + if (!clothBoneMap.TryGetValue((HumanBodyBones)14, out var value2) || value2 == null || value2.Count == 0) + { + throw new AutoMorpherException("Cloth Right UpperArm Set is Missing", "[BodyPoseMatch_Arm] AlignUpperArmByArmPcaCenters\n - clothBoneMap has no RightUpperArm set"); + } + this.AlignUpperArmByArmCenters(value, value2, sourceShoulderCenterWorld, targetShoulderCenterWorld, boneFromBoneMap); + } - private Vector3 CalculateShoulderCenter(bool leftValid, bool rightValid, Vector3 leftCenter, Vector3 rightCenter) - { - //IL_000a: Unknown result type (might be due to invalid IL or missing references) - //IL_000b: Unknown result type (might be due to invalid IL or missing references) - //IL_000d: 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_001d: Unknown result type (might be due to invalid IL or missing references) - //IL_001b: Unknown result type (might be due to invalid IL or missing references) - if (leftValid && rightValid) - { - return 0.5f * (leftCenter + rightCenter); - } - if (leftValid) - { - return leftCenter; - } - return rightCenter; - } + private Vector3 CalculateShoulderCenter(bool leftValid, bool rightValid, Vector3 leftCenter, Vector3 rightCenter) + { + //IL_000a: Unknown result type (might be due to invalid IL or missing references) + //IL_000b: Unknown result type (might be due to invalid IL or missing references) + //IL_000d: 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_001d: Unknown result type (might be due to invalid IL or missing references) + //IL_001b: Unknown result type (might be due to invalid IL or missing references) + if (leftValid && rightValid) + { + return 0.5f * (leftCenter + rightCenter); + } + if (leftValid) + { + return leftCenter; + } + return rightCenter; + } - public RegionStats ComputeArmRegionStats(IReadOnlyList avatarBakedBodyMeshes, Dictionary> avatarBoneMap, bool isLeft) - { - //IL_00b8: Unknown result type (might be due to invalid IL or missing references) - //IL_00bd: Unknown result type (might be due to invalid IL or missing references) - //IL_00d4: Unknown result type (might be due to invalid IL or missing references) - //IL_00da: Unknown result type (might be due to invalid IL or missing references) - //IL_00df: Unknown result type (might be due to invalid IL or missing references) - //IL_00e4: Unknown result type (might be due to invalid IL or missing references) - //IL_00fd: Unknown result type (might be due to invalid IL or missing references) - //IL_0103: 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_0151: 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_0127: Unknown result type (might be due to invalid IL or missing references) - //IL_012e: Unknown result type (might be due to invalid IL or missing references) - //IL_0133: Unknown result type (might be due to invalid IL or missing references) - //IL_0138: Unknown result type (might be due to invalid IL or missing references) - HumanBodyBones[] array; - if (!isLeft) - { - array = new HumanBodyBones[3]; - RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/); - } - else - { - array = new HumanBodyBones[3]; - RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/); - } - HumanBodyBones[] targetHumanBones = (HumanBodyBones[])(object)array; - List list = poseMatchCommonUtil.CollectHumanoidVerticesWorld(targetHumanBones, avatarBakedBodyMeshes, avatarBoneMap); - if (list == null || list.Count == 0) - { - Debug.LogWarning((object)$"[BodyPoseMatch_Arm] ComputeArmRegionStats: arm vertices 0. isLeft={isLeft}"); - return default(RegionStats); - } - RegionStats result = new PcaUtil().ComputeRegionStats(list); - Transform boneFromBoneMap = poseMatchCommonUtil.GetBoneFromBoneMap(avatarBoneMap, (HumanBodyBones)(isLeft ? 13 : 14)); - Transform boneFromBoneMap2 = poseMatchCommonUtil.GetBoneFromBoneMap(avatarBoneMap, (HumanBodyBones)(isLeft ? 15 : 16)); - Transform boneFromBoneMap3 = poseMatchCommonUtil.GetBoneFromBoneMap(avatarBoneMap, (HumanBodyBones)(isLeft ? 17 : 18)); - Vector3 principalAxis = Vector3.zero; - if ((Object)(object)boneFromBoneMap != (Object)null && (Object)(object)boneFromBoneMap3 != (Object)null) - { - principalAxis = boneFromBoneMap3.position - boneFromBoneMap.position; - } - else if ((Object)(object)boneFromBoneMap != (Object)null && (Object)(object)boneFromBoneMap2 != (Object)null) - { - principalAxis = boneFromBoneMap2.position - boneFromBoneMap.position; - } - else if ((Object)(object)boneFromBoneMap2 != (Object)null && (Object)(object)boneFromBoneMap3 != (Object)null) - { - principalAxis = boneFromBoneMap3.position - boneFromBoneMap2.position; - } - if (((Vector3)(ref principalAxis)).sqrMagnitude > 1E-08f) - { - ((Vector3)(ref principalAxis)).Normalize(); - result.principalAxis = principalAxis; - } - return result; - } + public RegionStats ComputeArmRegionStats(IReadOnlyList avatarBakedBodyMeshes, Dictionary> avatarBoneMap, bool isLeft) + { + //IL_00b8: Unknown result type (might be due to invalid IL or missing references) + //IL_00bd: Unknown result type (might be due to invalid IL or missing references) + //IL_00d4: Unknown result type (might be due to invalid IL or missing references) + //IL_00da: Unknown result type (might be due to invalid IL or missing references) + //IL_00df: Unknown result type (might be due to invalid IL or missing references) + //IL_00e4: Unknown result type (might be due to invalid IL or missing references) + //IL_00fd: Unknown result type (might be due to invalid IL or missing references) + //IL_0103: 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_0151: 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_0127: Unknown result type (might be due to invalid IL or missing references) + //IL_012e: Unknown result type (might be due to invalid IL or missing references) + //IL_0133: Unknown result type (might be due to invalid IL or missing references) + //IL_0138: Unknown result type (might be due to invalid IL or missing references) + HumanBodyBones[] targetHumanBones; + if (!isLeft) + { + targetHumanBones = new HumanBodyBones[] { (HumanBodyBones)14, (HumanBodyBones)16, (HumanBodyBones)18 }; + } + else + { + targetHumanBones = new HumanBodyBones[] { (HumanBodyBones)13, (HumanBodyBones)15, (HumanBodyBones)17 }; + } + List list = this.poseMatchCommonUtil.CollectHumanoidVerticesWorld(targetHumanBones, avatarBakedBodyMeshes, avatarBoneMap); + if (list == null || list.Count == 0) + { + Debug.LogWarning((object)$"[BodyPoseMatch_Arm] ComputeArmRegionStats: arm vertices 0. isLeft={isLeft}"); + return default(RegionStats); + } + RegionStats result = new PcaUtil().ComputeRegionStats(list); + Transform boneFromBoneMap = this.poseMatchCommonUtil.GetBoneFromBoneMap(avatarBoneMap, (HumanBodyBones)(isLeft ? 13 : 14)); + Transform boneFromBoneMap2 = this.poseMatchCommonUtil.GetBoneFromBoneMap(avatarBoneMap, (HumanBodyBones)(isLeft ? 15 : 16)); + Transform boneFromBoneMap3 = this.poseMatchCommonUtil.GetBoneFromBoneMap(avatarBoneMap, (HumanBodyBones)(isLeft ? 17 : 18)); + Vector3 principalAxis = Vector3.zero; + if (boneFromBoneMap != null && boneFromBoneMap3 != null) + { + principalAxis = boneFromBoneMap3.position - boneFromBoneMap.position; + } + else if (boneFromBoneMap != null && boneFromBoneMap2 != null) + { + principalAxis = boneFromBoneMap2.position - boneFromBoneMap.position; + } + else if (boneFromBoneMap2 != null && boneFromBoneMap3 != null) + { + principalAxis = boneFromBoneMap3.position - boneFromBoneMap2.position; + } + if (principalAxis.sqrMagnitude > 1E-08f) + { + principalAxis.Normalize(); + result.principalAxis = principalAxis; + } + return result; + } - private void ScalingUpperArmLength(Dictionary> sourceBoneMap, Dictionary> targetBoneMap, bool isLeft, bool autoDetectAxis, int forceAxisIndex) - { - //IL_0009: Unknown result type (might be due to invalid IL or missing references) - //IL_0013: Unknown result type (might be due to invalid IL or missing references) - //IL_001d: Unknown result type (might be due to invalid IL or missing references) - //IL_0025: Unknown result type (might be due to invalid IL or missing references) - //IL_0033: Unknown result type (might be due to invalid IL or missing references) - //IL_0042: Unknown result type (might be due to invalid IL or missing references) - //IL_0051: Unknown result type (might be due to invalid IL or missing references) - //IL_0060: Unknown result type (might be due to invalid IL or missing references) - //IL_006f: Unknown result type (might be due to invalid IL or missing references) - //IL_00c1: Unknown result type (might be due to invalid IL or missing references) - HumanBodyBones val = (HumanBodyBones)(isLeft ? 13 : 14); - HumanBodyBones bone = (HumanBodyBones)(isLeft ? 15 : 16); - HumanBodyBones bone2 = (HumanBodyBones)(isLeft ? 17 : 18); - Transform boneFromBoneMap = poseMatchCommonUtil.GetBoneFromBoneMap(sourceBoneMap, val); - Transform boneFromBoneMap2 = poseMatchCommonUtil.GetBoneFromBoneMap(sourceBoneMap, bone); - Transform boneFromBoneMap3 = poseMatchCommonUtil.GetBoneFromBoneMap(sourceBoneMap, bone2); - Transform boneFromBoneMap4 = poseMatchCommonUtil.GetBoneFromBoneMap(targetBoneMap, val); - Transform boneFromBoneMap5 = poseMatchCommonUtil.GetBoneFromBoneMap(targetBoneMap, bone); - Transform boneFromBoneMap6 = poseMatchCommonUtil.GetBoneFromBoneMap(targetBoneMap, bone2); - HashSet value; - if ((Object)(object)boneFromBoneMap == (Object)null || (Object)(object)boneFromBoneMap2 == (Object)null || (Object)(object)boneFromBoneMap3 == (Object)null || (Object)(object)boneFromBoneMap4 == (Object)null || (Object)(object)boneFromBoneMap5 == (Object)null || (Object)(object)boneFromBoneMap6 == (Object)null) - { - Debug.LogWarning((object)"[BodyPoseMatch_Arm] ScalingSingArmLenght: some arm bones are null. Skip."); - } - else if (sourceBoneMap == null || !sourceBoneMap.TryGetValue(val, out value) || value == null || value.Count == 0) - { - Debug.LogWarning((object)"[BodyPoseMatch_Arm] ScalingSingArmLenght: sourceUpperSet missing. Skip."); - } - else - { - poseMatchCommonUtil.BoneLengthAdjust(boneFromBoneMap, boneFromBoneMap2, boneFromBoneMap4, boneFromBoneMap5, value, autoDetectAxis, forceAxisIndex); - } - } + private void ScalingUpperArmLength(Dictionary> sourceBoneMap, Dictionary> targetBoneMap, bool isLeft, bool autoDetectAxis, int forceAxisIndex) + { + //IL_0009: Unknown result type (might be due to invalid IL or missing references) + //IL_0013: Unknown result type (might be due to invalid IL or missing references) + //IL_001d: Unknown result type (might be due to invalid IL or missing references) + //IL_0025: Unknown result type (might be due to invalid IL or missing references) + //IL_0033: Unknown result type (might be due to invalid IL or missing references) + //IL_0042: Unknown result type (might be due to invalid IL or missing references) + //IL_0051: Unknown result type (might be due to invalid IL or missing references) + //IL_0060: Unknown result type (might be due to invalid IL or missing references) + //IL_006f: Unknown result type (might be due to invalid IL or missing references) + //IL_00c1: Unknown result type (might be due to invalid IL or missing references) + HumanBodyBones val = (HumanBodyBones)(isLeft ? 13 : 14); + HumanBodyBones bone = (HumanBodyBones)(isLeft ? 15 : 16); + HumanBodyBones bone2 = (HumanBodyBones)(isLeft ? 17 : 18); + Transform boneFromBoneMap = this.poseMatchCommonUtil.GetBoneFromBoneMap(sourceBoneMap, val); + Transform boneFromBoneMap2 = this.poseMatchCommonUtil.GetBoneFromBoneMap(sourceBoneMap, bone); + Transform boneFromBoneMap3 = this.poseMatchCommonUtil.GetBoneFromBoneMap(sourceBoneMap, bone2); + Transform boneFromBoneMap4 = this.poseMatchCommonUtil.GetBoneFromBoneMap(targetBoneMap, val); + Transform boneFromBoneMap5 = this.poseMatchCommonUtil.GetBoneFromBoneMap(targetBoneMap, bone); + Transform boneFromBoneMap6 = this.poseMatchCommonUtil.GetBoneFromBoneMap(targetBoneMap, bone2); + HashSet value; + if (boneFromBoneMap == null || boneFromBoneMap2 == null || boneFromBoneMap3 == null || boneFromBoneMap4 == null || boneFromBoneMap5 == null || boneFromBoneMap6 == null) + { + Debug.LogWarning((object)"[BodyPoseMatch_Arm] ScalingSingArmLenght: some arm bones are null. Skip."); + } + else if (sourceBoneMap == null || !sourceBoneMap.TryGetValue(val, out value) || value == null || value.Count == 0) + { + Debug.LogWarning((object)"[BodyPoseMatch_Arm] ScalingSingArmLenght: sourceUpperSet missing. Skip."); + } + else + { + this.poseMatchCommonUtil.BoneLengthAdjust(boneFromBoneMap, boneFromBoneMap2, boneFromBoneMap4, boneFromBoneMap5, value, autoDetectAxis, forceAxisIndex); + } + } - private void ScalingLowerArmLength(Dictionary> sourceBoneMap, Dictionary> targetBoneMap, bool isLeft, bool autoDetectAxis, int forceAxisIndex, float sourceLowerarmExtremeX, float targetLowerarmExtremeX) - { - //IL_0009: Unknown result type (might be due to invalid IL or missing references) - //IL_0013: Unknown result type (might be due to invalid IL or missing references) - //IL_001b: Unknown result type (might be due to invalid IL or missing references) - //IL_0029: Unknown result type (might be due to invalid IL or missing references) - //IL_0037: Unknown result type (might be due to invalid IL or missing references) - //IL_0067: Unknown result type (might be due to invalid IL or missing references) - //IL_0075: Unknown result type (might be due to invalid IL or missing references) - //IL_00df: Unknown result type (might be due to invalid IL or missing references) - //IL_00e4: Unknown result type (might be due to invalid IL or missing references) - //IL_0127: Unknown result type (might be due to invalid IL or missing references) - //IL_014b: Unknown result type (might be due to invalid IL or missing references) - HumanBodyBones val = (HumanBodyBones)(isLeft ? 15 : 16); - HumanBodyBones bone = (HumanBodyBones)(isLeft ? 17 : 18); - Transform boneFromBoneMap = poseMatchCommonUtil.GetBoneFromBoneMap(sourceBoneMap, val); - Transform boneFromBoneMap2 = poseMatchCommonUtil.GetBoneFromBoneMap(sourceBoneMap, bone); - Transform boneFromBoneMap3 = poseMatchCommonUtil.GetBoneFromBoneMap(targetBoneMap, val); - if ((Object)(object)boneFromBoneMap == (Object)null || (Object)(object)boneFromBoneMap2 == (Object)null || (Object)(object)boneFromBoneMap3 == (Object)null) - { - Debug.LogWarning((object)"[BodyPoseMatch_Arm] ScalingSingArmLenght: some arm bones are null. Skip."); - return; - } - float x = boneFromBoneMap.position.x; - float x2 = boneFromBoneMap3.position.x; - float num = Mathf.Abs(sourceLowerarmExtremeX - x); - float num2 = Mathf.Abs(targetLowerarmExtremeX - x2); - if (num < 0.0001f || num2 < 0.0001f) - { - Debug.LogWarning((object)$"[BodyPoseMatch_Arm] ScalingSingArmLenght: span too small. source={num}, target={num2}"); - return; - } - float num3 = num2 / num; - int num4 = ResolveArmLengthAxisIndex(boneFromBoneMap, boneFromBoneMap2, autoDetectAxis, forceAxisIndex); - Vector3 localScale = boneFromBoneMap.localScale; - switch (num4) - { - case 0: - localScale.x *= num3; - break; - case 1: - localScale.y *= num3; - break; - case 2: - localScale.z *= num3; - break; - } - foreach (Transform item in sourceBoneMap[val]) - { - if (!((Object)(object)item == (Object)null)) - { - item.localScale = localScale; - } - } - } + private void ScalingLowerArmLength(Dictionary> sourceBoneMap, Dictionary> targetBoneMap, bool isLeft, bool autoDetectAxis, int forceAxisIndex, float sourceLowerarmExtremeX, float targetLowerarmExtremeX) + { + //IL_0009: Unknown result type (might be due to invalid IL or missing references) + //IL_0013: Unknown result type (might be due to invalid IL or missing references) + //IL_001b: Unknown result type (might be due to invalid IL or missing references) + //IL_0029: Unknown result type (might be due to invalid IL or missing references) + //IL_0037: Unknown result type (might be due to invalid IL or missing references) + //IL_0067: Unknown result type (might be due to invalid IL or missing references) + //IL_0075: Unknown result type (might be due to invalid IL or missing references) + //IL_00df: Unknown result type (might be due to invalid IL or missing references) + //IL_00e4: Unknown result type (might be due to invalid IL or missing references) + //IL_0127: Unknown result type (might be due to invalid IL or missing references) + //IL_014b: Unknown result type (might be due to invalid IL or missing references) + HumanBodyBones val = (HumanBodyBones)(isLeft ? 15 : 16); + HumanBodyBones bone = (HumanBodyBones)(isLeft ? 17 : 18); + Transform boneFromBoneMap = this.poseMatchCommonUtil.GetBoneFromBoneMap(sourceBoneMap, val); + Transform boneFromBoneMap2 = this.poseMatchCommonUtil.GetBoneFromBoneMap(sourceBoneMap, bone); + Transform boneFromBoneMap3 = this.poseMatchCommonUtil.GetBoneFromBoneMap(targetBoneMap, val); + if (boneFromBoneMap == null || boneFromBoneMap2 == null || boneFromBoneMap3 == null) + { + Debug.LogWarning("[BodyPoseMatch_Arm] ScalingSingArmLenght: some arm bones are null. Skip."); + return; + } + float x = boneFromBoneMap.position.x; + float x2 = boneFromBoneMap3.position.x; + float num = Mathf.Abs(sourceLowerarmExtremeX - x); + float num2 = Mathf.Abs(targetLowerarmExtremeX - x2); + if (num < 0.0001f || num2 < 0.0001f) + { + Debug.LogWarning($"[BodyPoseMatch_Arm] ScalingSingArmLenght: span too small. source={num}, target={num2}"); + return; + } + float num3 = num2 / num; + int num4 = this.ResolveArmLengthAxisIndex(boneFromBoneMap, boneFromBoneMap2, autoDetectAxis, forceAxisIndex); + Vector3 localScale = boneFromBoneMap.localScale; + switch (num4) + { + case 0: + localScale.x *= num3; + break; + case 1: + localScale.y *= num3; + break; + case 2: + localScale.z *= num3; + break; + } + foreach (Transform item in sourceBoneMap[val]) + { + if (!(item == null)) + { + item.localScale = localScale; + } + } + } - public void ScalingBothArmsLength(IReadOnlyList proxyBakedBodyMeshes, Dictionary> proxyBoneMap, IReadOnlyList targetBakedBodyMeshes, Dictionary> targetBoneMap, bool autoDetectAxis = true, int forceAxisIndex = 1) - { - if (proxyBoneMap == null || targetBoneMap == null) - { - throw new AutoMorpherException("Cloth Bone Map is Missing", "[BodyPoseMatch_Arm] ScalingSingArmLenght\n - BoneMap is null"); - } - ScalingUpperArmLength(proxyBoneMap, targetBoneMap, isLeft: true, autoDetectAxis, forceAxisIndex); - ScalingUpperArmLength(proxyBoneMap, targetBoneMap, isLeft: false, autoDetectAxis, forceAxisIndex); - if (proxyBakedBodyMeshes != null) - { - foreach (BakedBodyMesh proxyBakedBodyMesh in proxyBakedBodyMeshes) - { - proxyBakedBodyMesh.ReBakeMesh(); - } - } - ScalingLowerArmLength_BodyMatch(proxyBakedBodyMeshes, proxyBoneMap, targetBakedBodyMeshes, targetBoneMap, autoDetectAxis, forceAxisIndex); - } + public void ScalingBothArmsLength(IReadOnlyList proxyBakedBodyMeshes, Dictionary> proxyBoneMap, IReadOnlyList targetBakedBodyMeshes, Dictionary> targetBoneMap, bool autoDetectAxis = true, int forceAxisIndex = 1) + { + if (proxyBoneMap == null || targetBoneMap == null) + { + throw new AutoMorpherException("Cloth Bone Map is Missing", "[BodyPoseMatch_Arm] ScalingSingArmLenght\n - BoneMap is null"); + } + this.ScalingUpperArmLength(proxyBoneMap, targetBoneMap, isLeft: true, autoDetectAxis, forceAxisIndex); + this.ScalingUpperArmLength(proxyBoneMap, targetBoneMap, isLeft: false, autoDetectAxis, forceAxisIndex); + if (proxyBakedBodyMeshes != null) + { + foreach (BakedBodyMesh proxyBakedBodyMesh in proxyBakedBodyMeshes) + { + proxyBakedBodyMesh.ReBakeMesh(); + } + } + this.ScalingLowerArmLength_BodyMatch(proxyBakedBodyMeshes, proxyBoneMap, targetBakedBodyMeshes, targetBoneMap, autoDetectAxis, forceAxisIndex); + } - private void ScalingLowerArmLength_BodyMatch(IReadOnlyList proxyBakedBodyMeshes, Dictionary> proxyBoneMap, IReadOnlyList targetBakedBodyMeshes, Dictionary> targetBoneMap, bool autoDetectAxis, int forceAxisIndex) - { - if (TryGetForearmExtremeX(proxyBakedBodyMeshes, proxyBoneMap, (HumanBodyBones)17, isLeft: true, out var extremeX) && TryGetForearmExtremeX(targetBakedBodyMeshes, targetBoneMap, (HumanBodyBones)17, isLeft: true, out var extremeX2)) - { - ScalingLowerArmLength(proxyBoneMap, targetBoneMap, isLeft: true, autoDetectAxis, forceAxisIndex, extremeX, extremeX2); - } - else - { - Debug.LogWarning((object)"[BodyPoseMatch_Arm] ScalingLowerArmLength_BodyMatch: left extreme calc failed. Skip left lower."); - } - if (TryGetForearmExtremeX(proxyBakedBodyMeshes, proxyBoneMap, (HumanBodyBones)18, isLeft: false, out var extremeX3) && TryGetForearmExtremeX(targetBakedBodyMeshes, targetBoneMap, (HumanBodyBones)18, isLeft: false, out var extremeX4)) - { - ScalingLowerArmLength(proxyBoneMap, targetBoneMap, isLeft: false, autoDetectAxis, forceAxisIndex, extremeX3, extremeX4); - } - else - { - Debug.LogWarning((object)"[BodyPoseMatch_Arm] ScalingLowerArmLength_BodyMatch: right extreme calc failed. Skip right lower."); - } - } + private void ScalingLowerArmLength_BodyMatch(IReadOnlyList proxyBakedBodyMeshes, Dictionary> proxyBoneMap, IReadOnlyList targetBakedBodyMeshes, Dictionary> targetBoneMap, bool autoDetectAxis, int forceAxisIndex) + { + if (this.TryGetForearmExtremeX(proxyBakedBodyMeshes, proxyBoneMap, (HumanBodyBones)17, isLeft: true, out var extremeX) && this.TryGetForearmExtremeX(targetBakedBodyMeshes, targetBoneMap, (HumanBodyBones)17, isLeft: true, out var extremeX2)) + { + this.ScalingLowerArmLength(proxyBoneMap, targetBoneMap, isLeft: true, autoDetectAxis, forceAxisIndex, extremeX, extremeX2); + } + else + { + Debug.LogWarning((object)"[BodyPoseMatch_Arm] ScalingLowerArmLength_BodyMatch: left extreme calc failed. Skip left lower."); + } + if (this.TryGetForearmExtremeX(proxyBakedBodyMeshes, proxyBoneMap, (HumanBodyBones)18, isLeft: false, out var extremeX3) && this.TryGetForearmExtremeX(targetBakedBodyMeshes, targetBoneMap, (HumanBodyBones)18, isLeft: false, out var extremeX4)) + { + this.ScalingLowerArmLength(proxyBoneMap, targetBoneMap, isLeft: false, autoDetectAxis, forceAxisIndex, extremeX3, extremeX4); + } + else + { + Debug.LogWarning((object)"[BodyPoseMatch_Arm] ScalingLowerArmLength_BodyMatch: right extreme calc failed. Skip right lower."); + } + } - public void ScalingBothArmsLength(IReadOnlyList targetBakedBodyMeshes, Dictionary> targetBoneMap, Dictionary> clothBoneMap, ProfileData profileData, Vector3 comprehensiveScale, bool autoDetectAxis = true, int forceAxisIndex = 1) - { - //IL_004a: Unknown result type (might be due to invalid IL or missing references) - if (clothBoneMap == null || targetBoneMap == null) - { - throw new AutoMorpherException("Cloth Bone Map is Missing", "[BodyPoseMatch_Arm] ScalingSingArmLenght\n - BoneMap is null"); - } - if (profileData == null) - { - throw new AutoMorpherException("Profile Data is Missing", "[BodyPoseMatch_Arm] ScalingSingArmLenght\n - profileData is null"); - } - ScalingUpperArmLength(clothBoneMap, targetBoneMap, isLeft: true, autoDetectAxis, forceAxisIndex); - ScalingUpperArmLength(clothBoneMap, targetBoneMap, isLeft: false, autoDetectAxis, forceAxisIndex); - ScalingLowerArmLength_ProfileMatch(targetBakedBodyMeshes, targetBoneMap, clothBoneMap, profileData, comprehensiveScale, autoDetectAxis, forceAxisIndex); - } + public void ScalingBothArmsLength(IReadOnlyList targetBakedBodyMeshes, Dictionary> targetBoneMap, Dictionary> clothBoneMap, ProfileData profileData, Vector3 comprehensiveScale, bool autoDetectAxis = true, int forceAxisIndex = 1) + { + //IL_004a: Unknown result type (might be due to invalid IL or missing references) + if (clothBoneMap == null || targetBoneMap == null) + { + throw new AutoMorpherException("Cloth Bone Map is Missing", "[BodyPoseMatch_Arm] ScalingSingArmLenght\n - BoneMap is null"); + } + if (profileData == null) + { + throw new AutoMorpherException("Profile Data is Missing", "[BodyPoseMatch_Arm] ScalingSingArmLenght\n - profileData is null"); + } + this.ScalingUpperArmLength(clothBoneMap, targetBoneMap, isLeft: true, autoDetectAxis, forceAxisIndex); + this.ScalingUpperArmLength(clothBoneMap, targetBoneMap, isLeft: false, autoDetectAxis, forceAxisIndex); + this.ScalingLowerArmLength_ProfileMatch(targetBakedBodyMeshes, targetBoneMap, clothBoneMap, profileData, comprehensiveScale, autoDetectAxis, forceAxisIndex); + } - private void ScalingLowerArmLength_ProfileMatch(IReadOnlyList targetBakedBodyMeshes, Dictionary> targetBoneMap, Dictionary> clothBoneMap, ProfileData profileData, Vector3 comprehensiveScale, bool autoDetectAxis, int forceAxisIndex) - { - //IL_0041: Unknown result type (might be due to invalid IL or missing references) - //IL_00a5: Unknown result type (might be due to invalid IL or missing references) - float extremeX; - if (profileData.LeftLowerArm_HandSpatialData == null || profileData.LeftLowerArm_HandSpatialData.volumeData == null) - { - Debug.LogWarning((object)"[BodyPoseMatch_Arm] ScalingLowerArmLength_ProfileMatch: left spatial data missing. Skip left lower."); - } - else if (TryGetForearmExtremeX(targetBakedBodyMeshes, targetBoneMap, (HumanBodyBones)17, isLeft: true, out extremeX)) - { - float profileForearmExtremeX = GetProfileForearmExtremeX(clothBoneMap, profileData.LeftLowerArm_HandSpatialData, comprehensiveScale, isLeft: true); - ScalingLowerArmLength(clothBoneMap, targetBoneMap, isLeft: true, autoDetectAxis, forceAxisIndex, profileForearmExtremeX, extremeX); - } - else - { - Debug.LogWarning((object)"[BodyPoseMatch_Arm] ScalingLowerArmLength_ProfileMatch: left target extreme calc failed. Skip left lower."); - } - float extremeX2; - if (profileData.RightLowerArm_HandSpatialData == null || profileData.RightLowerArm_HandSpatialData.volumeData == null) - { - Debug.LogWarning((object)"[BodyPoseMatch_Arm] ScalingLowerArmLength_ProfileMatch: right spatial data missing. Skip right lower."); - } - else if (TryGetForearmExtremeX(targetBakedBodyMeshes, targetBoneMap, (HumanBodyBones)18, isLeft: false, out extremeX2)) - { - float profileForearmExtremeX2 = GetProfileForearmExtremeX(clothBoneMap, profileData.RightLowerArm_HandSpatialData, comprehensiveScale, isLeft: false); - ScalingLowerArmLength(clothBoneMap, targetBoneMap, isLeft: false, autoDetectAxis, forceAxisIndex, profileForearmExtremeX2, extremeX2); - } - else - { - Debug.LogWarning((object)"[BodyPoseMatch_Arm] ScalingLowerArmLength_ProfileMatch: right target extreme calc failed. Skip right lower."); - } - } + private void ScalingLowerArmLength_ProfileMatch(IReadOnlyList targetBakedBodyMeshes, Dictionary> targetBoneMap, Dictionary> clothBoneMap, ProfileData profileData, Vector3 comprehensiveScale, bool autoDetectAxis, int forceAxisIndex) + { + //IL_0041: Unknown result type (might be due to invalid IL or missing references) + //IL_00a5: Unknown result type (might be due to invalid IL or missing references) + float extremeX; + if (profileData.LeftLowerArm_HandSpatialData == null || profileData.LeftLowerArm_HandSpatialData.volumeData == null) + { + Debug.LogWarning((object)"[BodyPoseMatch_Arm] ScalingLowerArmLength_ProfileMatch: left spatial data missing. Skip left lower."); + } + else if (this.TryGetForearmExtremeX(targetBakedBodyMeshes, targetBoneMap, (HumanBodyBones)17, isLeft: true, out extremeX)) + { + float profileForearmExtremeX = this.GetProfileForearmExtremeX(clothBoneMap, profileData.LeftLowerArm_HandSpatialData, comprehensiveScale, isLeft: true); + this.ScalingLowerArmLength(clothBoneMap, targetBoneMap, isLeft: true, autoDetectAxis, forceAxisIndex, profileForearmExtremeX, extremeX); + } + else + { + Debug.LogWarning((object)"[BodyPoseMatch_Arm] ScalingLowerArmLength_ProfileMatch: left target extreme calc failed. Skip left lower."); + } + float extremeX2; + if (profileData.RightLowerArm_HandSpatialData == null || profileData.RightLowerArm_HandSpatialData.volumeData == null) + { + Debug.LogWarning((object)"[BodyPoseMatch_Arm] ScalingLowerArmLength_ProfileMatch: right spatial data missing. Skip right lower."); + } + else if (this.TryGetForearmExtremeX(targetBakedBodyMeshes, targetBoneMap, (HumanBodyBones)18, isLeft: false, out extremeX2)) + { + float profileForearmExtremeX2 = this.GetProfileForearmExtremeX(clothBoneMap, profileData.RightLowerArm_HandSpatialData, comprehensiveScale, isLeft: false); + this.ScalingLowerArmLength(clothBoneMap, targetBoneMap, isLeft: false, autoDetectAxis, forceAxisIndex, profileForearmExtremeX2, extremeX2); + } + else + { + Debug.LogWarning((object)"[BodyPoseMatch_Arm] ScalingLowerArmLength_ProfileMatch: right target extreme calc failed. Skip right lower."); + } + } - private bool TryGetForearmExtremeX(IReadOnlyList bakedBodyMeshes, Dictionary> boneMap, HumanBodyBones targetBone, bool isLeft, out float extremeX, float weightThreshold = 0.15f, int sampleStep = 1) - { - //IL_001c: Unknown result type (might be due to invalid IL or missing references) - //IL_0058: Unknown result type (might be due to invalid IL or missing references) - extremeX = (isLeft ? float.PositiveInfinity : float.NegativeInfinity); - if (bakedBodyMeshes == null || boneMap == null) - { - return false; - } - if (!boneMap.TryGetValue(targetBone, out var value) || value == null || value.Count == 0) - { - return false; - } - List list = poseMatchCommonUtil.CollectWeightedVerticesWorld(bakedBodyMeshes, value, weightThreshold, sampleStep); - if (list == null || list.Count == 0) - { - return false; - } - for (int i = 0; i < list.Count; i++) - { - float x = list[i].x; - if (isLeft) - { - if (x < extremeX) - { - extremeX = x; - } - } - else if (x > extremeX) - { - extremeX = x; - } - } - return true; - } + private bool TryGetForearmExtremeX(IReadOnlyList bakedBodyMeshes, Dictionary> boneMap, HumanBodyBones targetBone, bool isLeft, out float extremeX, float weightThreshold = 0.15f, int sampleStep = 1) + { + //IL_001c: Unknown result type (might be due to invalid IL or missing references) + //IL_0058: Unknown result type (might be due to invalid IL or missing references) + extremeX = (isLeft ? float.PositiveInfinity : float.NegativeInfinity); + if (bakedBodyMeshes == null || boneMap == null) + { + return false; + } + if (!boneMap.TryGetValue(targetBone, out var value) || value == null || value.Count == 0) + { + return false; + } + List list = this.poseMatchCommonUtil.CollectWeightedVerticesWorld(bakedBodyMeshes, value, weightThreshold, sampleStep); + if (list == null || list.Count == 0) + { + return false; + } + for (int i = 0; i < list.Count; i++) + { + float x = list[i].x; + if (isLeft) + { + if (x < extremeX) + { + extremeX = x; + } + } + else if (x > extremeX) + { + extremeX = x; + } + } + return true; + } - private float GetProfileForearmExtremeX(Dictionary> clothBoneMap, BoneSpatialData spatialData, Vector3 comprehensiveScale, bool isLeft) - { - //IL_0023: Unknown result type (might be due to invalid IL or missing references) - //IL_004e: Unknown result type (might be due to invalid IL or missing references) - //IL_004f: Unknown result type (might be due to invalid IL or missing references) - //IL_005d: Unknown result type (might be due to invalid IL or missing references) - //IL_005e: Unknown result type (might be due to invalid IL or missing references) - if (spatialData == null || spatialData.volumeData == null) - { - throw new AutoMorpherException("Profile Volume Data is Missing", "[BodyPoseMatch_Arm] GetProfileForearmExtremeX\n - spatialData or spatialData.volumeData is null"); - } - if ((Object)(object)poseMatchCommonUtil.GetBoneFromBoneMap(clothBoneMap, spatialData.refBone) == (Object)null) - { - throw new AutoMorpherException("Profile Ref Bone Transform is Missing", "[BodyPoseMatch_Arm] GetProfileForearmExtremeX\n - refBone transform is null"); - } - BodyPoseMatch_CommonUtil bodyPoseMatch_CommonUtil = new BodyPoseMatch_CommonUtil(); - float x = bodyPoseMatch_CommonUtil.GetProfileVolumeMinWorld(clothBoneMap, spatialData, 1, comprehensiveScale).x; - float x2 = bodyPoseMatch_CommonUtil.GetProfileVolumeMaxWorld(clothBoneMap, spatialData, 1, comprehensiveScale).x; - if (!isLeft) - { - return x2; - } - return x; - } + private float GetProfileForearmExtremeX(Dictionary> clothBoneMap, BoneSpatialData spatialData, Vector3 comprehensiveScale, bool isLeft) + { + //IL_0023: Unknown result type (might be due to invalid IL or missing references) + //IL_004e: Unknown result type (might be due to invalid IL or missing references) + //IL_004f: Unknown result type (might be due to invalid IL or missing references) + //IL_005d: Unknown result type (might be due to invalid IL or missing references) + //IL_005e: Unknown result type (might be due to invalid IL or missing references) + if (spatialData == null || spatialData.volumeData == null) + { + throw new AutoMorpherException("Profile Volume Data is Missing", "[BodyPoseMatch_Arm] GetProfileForearmExtremeX\n - spatialData or spatialData.volumeData is null"); + } + if (this.poseMatchCommonUtil.GetBoneFromBoneMap(clothBoneMap, spatialData.refBone) == null) + { + throw new AutoMorpherException("Profile Ref Bone Transform is Missing", "[BodyPoseMatch_Arm] GetProfileForearmExtremeX\n - refBone transform is null"); + } + BodyPoseMatch_CommonUtil bodyPoseMatch_CommonUtil = new BodyPoseMatch_CommonUtil(); + float x = bodyPoseMatch_CommonUtil.GetProfileVolumeMinWorld(clothBoneMap, spatialData, 1, comprehensiveScale).x; + float x2 = bodyPoseMatch_CommonUtil.GetProfileVolumeMaxWorld(clothBoneMap, spatialData, 1, comprehensiveScale).x; + if (!isLeft) + { + return x2; + } + return x; + } - private int ResolveArmLengthAxisIndex(Transform lowerArm, Transform hand, bool autoDetectAxis, int forceAxisIndex) - { - //IL_000e: Unknown result type (might be due to invalid IL or missing references) - //IL_0014: Unknown result type (might be due to invalid IL or missing references) - //IL_0019: Unknown result type (might be due to invalid IL or missing references) - //IL_001e: Unknown result type (might be due to invalid IL or missing references) - //IL_0020: Unknown result type (might be due to invalid IL or missing references) - //IL_0021: Unknown result type (might be due to invalid IL or missing references) - //IL_0026: Unknown result type (might be due to invalid IL or missing references) - //IL_0032: Unknown result type (might be due to invalid IL or missing references) - if (!autoDetectAxis) - { - return Mathf.Clamp(forceAxisIndex, 0, 2); - } - Vector3 val = hand.position - lowerArm.position; - Vector3 val2 = lowerArm.InverseTransformDirection(val); - float num = Mathf.Abs(val2.x); - float num2 = Mathf.Abs(val2.y); - float num3 = Mathf.Abs(val2.z); - if (num2 >= num && num2 >= num3) - { - return 1; - } - if (num >= num3) - { - return 0; - } - return 2; - } + private int ResolveArmLengthAxisIndex(Transform lowerArm, Transform hand, bool autoDetectAxis, int forceAxisIndex) + { + //IL_000e: Unknown result type (might be due to invalid IL or missing references) + //IL_0014: Unknown result type (might be due to invalid IL or missing references) + //IL_0019: Unknown result type (might be due to invalid IL or missing references) + //IL_001e: Unknown result type (might be due to invalid IL or missing references) + //IL_0020: Unknown result type (might be due to invalid IL or missing references) + //IL_0021: Unknown result type (might be due to invalid IL or missing references) + //IL_0026: Unknown result type (might be due to invalid IL or missing references) + //IL_0032: Unknown result type (might be due to invalid IL or missing references) + if (!autoDetectAxis) + { + return Mathf.Clamp(forceAxisIndex, 0, 2); + } + Vector3 val = hand.position - lowerArm.position; + Vector3 val2 = lowerArm.InverseTransformDirection(val); + float num = Mathf.Abs(val2.x); + float num2 = Mathf.Abs(val2.y); + float num3 = Mathf.Abs(val2.z); + if (num2 >= num && num2 >= num3) + { + return 1; + } + if (num >= num3) + { + return 0; + } + return 2; + } - public void DrawArmPcaDebug(GameObject avatarObject, IReadOnlyList avatarBakedBodyMeshes, Dictionary> avatarBoneMap, bool isLeft, Color centerColor, Color axisColor, float axisScale = 1f, float duration = 0.1f) - { - //IL_0021: Unknown result type (might be due to invalid IL or missing references) - //IL_0026: Unknown result type (might be due to invalid IL or missing references) - //IL_0048: Unknown result type (might be due to invalid IL or missing references) - //IL_003a: Unknown result type (might be due to invalid IL or missing references) - //IL_004d: Unknown result type (might be due to invalid IL or missing references) - //IL_0057: Unknown result type (might be due to invalid IL or missing references) - //IL_0058: Unknown result type (might be due to invalid IL or missing references) - //IL_005e: Unknown result type (might be due to invalid IL or missing references) - //IL_0063: Unknown result type (might be due to invalid IL or missing references) - //IL_0068: Unknown result type (might be due to invalid IL or missing references) - //IL_0069: Unknown result type (might be due to invalid IL or missing references) - //IL_006f: Unknown result type (might be due to invalid IL or missing references) - //IL_0074: Unknown result type (might be due to invalid IL or missing references) - //IL_0079: 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_0083: Unknown result type (might be due to invalid IL or missing references) - //IL_0089: Unknown result type (might be due to invalid IL or missing references) - //IL_008e: Unknown result type (might be due to invalid IL or missing references) - //IL_0093: 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_009a: Unknown result type (might be due to invalid IL or missing references) - //IL_009f: Unknown result type (might be due to invalid IL or missing references) - //IL_00a4: Unknown result type (might be due to invalid IL or missing references) - //IL_00ad: Unknown result type (might be due to invalid IL or missing references) - //IL_00ae: Unknown result type (might be due to invalid IL or missing references) - //IL_00b4: Unknown result type (might be due to invalid IL or missing references) - //IL_00b9: Unknown result type (might be due to invalid IL or missing references) - //IL_00be: Unknown result type (might be due to invalid IL or missing references) - //IL_00bf: Unknown result type (might be due to invalid IL or missing references) - //IL_00c5: Unknown result type (might be due to invalid IL or missing references) - //IL_00ca: 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_00e9: Unknown result type (might be due to invalid IL or missing references) - //IL_00ea: 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_00f7: Unknown result type (might be due to invalid IL or missing references) - //IL_00f8: Unknown result type (might be due to invalid IL or missing references) - //IL_00fb: Unknown result type (might be due to invalid IL or missing references) - //IL_0100: 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) - if (avatarBakedBodyMeshes != null && avatarBoneMap != null) - { - RegionStats regionStats = ComputeArmRegionStats(avatarBakedBodyMeshes, avatarBoneMap, isLeft); - if (!(regionStats.length < 0.0001f)) - { - Vector3 center = regionStats.center; - Vector3 val = ((((Vector3)(ref regionStats.principalAxis)).sqrMagnitude > 1E-08f) ? ((Vector3)(ref regionStats.principalAxis)).normalized : Vector3.up); - float num = 0.02f * axisScale; - Debug.DrawLine(center + Vector3.up * num, center - Vector3.up * num, centerColor, duration); - Debug.DrawLine(center + Vector3.right * num, center - Vector3.right * num, centerColor, duration); - Debug.DrawLine(center + Vector3.forward * num, center - Vector3.forward * num, centerColor, duration); - float num2 = regionStats.length * 0.5f * axisScale; - Debug.DrawLine(center - val * num2, center + val * num2, axisColor, duration); - } - } - } + public void DrawArmPcaDebug(GameObject avatarObject, IReadOnlyList avatarBakedBodyMeshes, Dictionary> avatarBoneMap, bool isLeft, Color centerColor, Color axisColor, float axisScale = 1f, float duration = 0.1f) + { + //IL_0021: Unknown result type (might be due to invalid IL or missing references) + //IL_0026: Unknown result type (might be due to invalid IL or missing references) + //IL_0048: Unknown result type (might be due to invalid IL or missing references) + //IL_003a: Unknown result type (might be due to invalid IL or missing references) + //IL_004d: Unknown result type (might be due to invalid IL or missing references) + //IL_0057: Unknown result type (might be due to invalid IL or missing references) + //IL_0058: Unknown result type (might be due to invalid IL or missing references) + //IL_005e: Unknown result type (might be due to invalid IL or missing references) + //IL_0063: Unknown result type (might be due to invalid IL or missing references) + //IL_0068: Unknown result type (might be due to invalid IL or missing references) + //IL_0069: Unknown result type (might be due to invalid IL or missing references) + //IL_006f: Unknown result type (might be due to invalid IL or missing references) + //IL_0074: Unknown result type (might be due to invalid IL or missing references) + //IL_0079: 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_0083: Unknown result type (might be due to invalid IL or missing references) + //IL_0089: Unknown result type (might be due to invalid IL or missing references) + //IL_008e: Unknown result type (might be due to invalid IL or missing references) + //IL_0093: 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_009a: Unknown result type (might be due to invalid IL or missing references) + //IL_009f: Unknown result type (might be due to invalid IL or missing references) + //IL_00a4: Unknown result type (might be due to invalid IL or missing references) + //IL_00ad: Unknown result type (might be due to invalid IL or missing references) + //IL_00ae: Unknown result type (might be due to invalid IL or missing references) + //IL_00b4: Unknown result type (might be due to invalid IL or missing references) + //IL_00b9: Unknown result type (might be due to invalid IL or missing references) + //IL_00be: Unknown result type (might be due to invalid IL or missing references) + //IL_00bf: Unknown result type (might be due to invalid IL or missing references) + //IL_00c5: Unknown result type (might be due to invalid IL or missing references) + //IL_00ca: 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_00e9: Unknown result type (might be due to invalid IL or missing references) + //IL_00ea: 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_00f7: Unknown result type (might be due to invalid IL or missing references) + //IL_00f8: Unknown result type (might be due to invalid IL or missing references) + //IL_00fb: Unknown result type (might be due to invalid IL or missing references) + //IL_0100: 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) + if (avatarBakedBodyMeshes != null && avatarBoneMap != null) + { + RegionStats regionStats = this.ComputeArmRegionStats(avatarBakedBodyMeshes, avatarBoneMap, isLeft); + if (!(regionStats.length < 0.0001f)) + { + Vector3 center = regionStats.center; + Vector3 val = (regionStats.principalAxis.sqrMagnitude > 1E-08f) ? regionStats.principalAxis.normalized : Vector3.up; + float num = 0.02f * axisScale; + Debug.DrawLine(center + Vector3.up * num, center - Vector3.up * num, centerColor, duration); + Debug.DrawLine(center + Vector3.right * num, center - Vector3.right * num, centerColor, duration); + Debug.DrawLine(center + Vector3.forward * num, center - Vector3.forward * num, centerColor, duration); + float num2 = regionStats.length * 0.5f * axisScale; + Debug.DrawLine(center - val * num2, center + val * num2, axisColor, duration); + } + } + } - public void DrawForearmExtremeDebugPair(GameObject proxyObject, IReadOnlyList proxyBodyMeshes, GameObject targetObject, IReadOnlyList targetBodyMeshes, bool isLeft, float size = 0.03f, float duration = 3f) - { - //IL_0005: Unknown result type (might be due to invalid IL or missing references) - //IL_000a: Unknown result type (might be due to invalid IL or missing references) - //IL_001e: Unknown result type (might be due to invalid IL or missing references) - //IL_0023: Unknown result type (might be due to invalid IL or missing references) - DrawForearmExtremeDebugSingle(proxyObject, proxyBodyMeshes, isLeft, Color.blue, Color.cyan, size, duration); - DrawForearmExtremeDebugSingle(targetObject, targetBodyMeshes, isLeft, Color.red, Color.magenta, size, duration); - } + public void DrawForearmExtremeDebugPair(GameObject proxyObject, IReadOnlyList proxyBodyMeshes, GameObject targetObject, IReadOnlyList targetBodyMeshes, bool isLeft, float size = 0.03f, float duration = 3f) + { + //IL_0005: Unknown result type (might be due to invalid IL or missing references) + //IL_000a: Unknown result type (might be due to invalid IL or missing references) + //IL_001e: Unknown result type (might be due to invalid IL or missing references) + //IL_0023: Unknown result type (might be due to invalid IL or missing references) + this.DrawForearmExtremeDebugSingle(proxyObject, proxyBodyMeshes, isLeft, Color.blue, Color.cyan, size, duration); + this.DrawForearmExtremeDebugSingle(targetObject, targetBodyMeshes, isLeft, Color.red, Color.magenta, size, duration); + } - public void DrawForearmExtremeDebugSingle(GameObject avatarObject, IReadOnlyList bodyMeshes, bool isLeft, Color lineColor, Color pointColor, float size = 0.03f, float duration = 3f) - { - //IL_002f: Unknown result type (might be due to invalid IL or missing references) - //IL_0031: Unknown result type (might be due to invalid IL or missing references) - //IL_007b: Unknown result type (might be due to invalid IL or missing references) - //IL_0080: Unknown result type (might be due to invalid IL or missing references) - //IL_0081: Unknown result type (might be due to invalid IL or missing references) - //IL_008e: Unknown result type (might be due to invalid IL or missing references) - //IL_008f: Unknown result type (might be due to invalid IL or missing references) - //IL_0096: Unknown result type (might be due to invalid IL or missing references) - //IL_009b: Unknown result type (might be due to invalid IL or missing references) - //IL_00a0: Unknown result type (might be due to invalid IL or missing references) - //IL_00a1: Unknown result type (might be due to invalid IL or missing references) - //IL_00a8: Unknown result type (might be due to invalid IL or missing references) - //IL_00ad: Unknown result type (might be due to invalid IL or missing references) - //IL_00b2: Unknown result type (might be due to invalid IL or missing references) - //IL_00bb: Unknown result type (might be due to invalid IL or missing references) - //IL_00bc: Unknown result type (might be due to invalid IL or missing references) - //IL_00c3: Unknown result type (might be due to invalid IL or missing references) - //IL_00c8: Unknown result type (might be due to invalid IL or missing references) - //IL_00cd: Unknown result type (might be due to invalid IL or missing references) - //IL_00ce: Unknown result type (might be due to invalid IL or missing references) - //IL_00d5: Unknown result type (might be due to invalid IL or missing references) - //IL_00da: Unknown result type (might be due to invalid IL or missing references) - //IL_00df: 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_00e9: Unknown result type (might be due to invalid IL or missing references) - //IL_00f0: Unknown result type (might be due to invalid IL or missing references) - //IL_00f5: Unknown result type (might be due to invalid IL or missing references) - //IL_00fa: Unknown result type (might be due to invalid IL or missing references) - //IL_00fb: Unknown result type (might be due to invalid IL or missing references) - //IL_0102: Unknown result type (might be due to invalid IL or missing references) - //IL_0107: Unknown result type (might be due to invalid IL or missing references) - //IL_010c: Unknown result type (might be due to invalid IL or missing references) - if ((Object)(object)avatarObject == (Object)null || bodyMeshes == null || bodyMeshes.Count == 0) - { - return; - } - Animator component = avatarObject.GetComponent(); - if (!((Object)(object)component == (Object)null)) - { - HumanBodyBones val = (HumanBodyBones)(isLeft ? 15 : 16); - Transform boneTransform = component.GetBoneTransform(val); - if ((Object)(object)boneTransform == (Object)null) - { - Debug.LogWarning((object)$"[BodyPoseMatch_Arm] DrawForearmExtremeDebugSingle: elbow bone missing. isLeft={isLeft}"); - return; - } - if (!TryGetForearmExtremePoint(component, bodyMeshes, isLeft, out var extremePos)) - { - Debug.LogWarning((object)$"[BodyPoseMatch_Arm] DrawForearmExtremeDebugSingle: extreme vertex not found. isLeft={isLeft}"); - return; - } - Debug.DrawLine(boneTransform.position, extremePos, lineColor, duration); - Debug.DrawLine(extremePos + Vector3.up * size, extremePos - Vector3.up * size, pointColor, duration); - Debug.DrawLine(extremePos + Vector3.right * size, extremePos - Vector3.right * size, pointColor, duration); - Debug.DrawLine(extremePos + Vector3.forward * size, extremePos - Vector3.forward * size, pointColor, duration); - } - } + public void DrawForearmExtremeDebugSingle(GameObject avatarObject, IReadOnlyList bodyMeshes, bool isLeft, Color lineColor, Color pointColor, float size = 0.03f, float duration = 3f) + { + //IL_002f: Unknown result type (might be due to invalid IL or missing references) + //IL_0031: Unknown result type (might be due to invalid IL or missing references) + //IL_007b: Unknown result type (might be due to invalid IL or missing references) + //IL_0080: Unknown result type (might be due to invalid IL or missing references) + //IL_0081: Unknown result type (might be due to invalid IL or missing references) + //IL_008e: Unknown result type (might be due to invalid IL or missing references) + //IL_008f: Unknown result type (might be due to invalid IL or missing references) + //IL_0096: Unknown result type (might be due to invalid IL or missing references) + //IL_009b: Unknown result type (might be due to invalid IL or missing references) + //IL_00a0: Unknown result type (might be due to invalid IL or missing references) + //IL_00a1: Unknown result type (might be due to invalid IL or missing references) + //IL_00a8: Unknown result type (might be due to invalid IL or missing references) + //IL_00ad: Unknown result type (might be due to invalid IL or missing references) + //IL_00b2: Unknown result type (might be due to invalid IL or missing references) + //IL_00bb: Unknown result type (might be due to invalid IL or missing references) + //IL_00bc: Unknown result type (might be due to invalid IL or missing references) + //IL_00c3: Unknown result type (might be due to invalid IL or missing references) + //IL_00c8: Unknown result type (might be due to invalid IL or missing references) + //IL_00cd: Unknown result type (might be due to invalid IL or missing references) + //IL_00ce: Unknown result type (might be due to invalid IL or missing references) + //IL_00d5: Unknown result type (might be due to invalid IL or missing references) + //IL_00da: Unknown result type (might be due to invalid IL or missing references) + //IL_00df: 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_00e9: Unknown result type (might be due to invalid IL or missing references) + //IL_00f0: Unknown result type (might be due to invalid IL or missing references) + //IL_00f5: Unknown result type (might be due to invalid IL or missing references) + //IL_00fa: Unknown result type (might be due to invalid IL or missing references) + //IL_00fb: Unknown result type (might be due to invalid IL or missing references) + //IL_0102: Unknown result type (might be due to invalid IL or missing references) + //IL_0107: Unknown result type (might be due to invalid IL or missing references) + //IL_010c: Unknown result type (might be due to invalid IL or missing references) + if (avatarObject == null || bodyMeshes == null || bodyMeshes.Count == 0) + { + return; + } + Animator component = avatarObject.GetComponent(); + if (!(component == null)) + { + HumanBodyBones val = (HumanBodyBones)(isLeft ? 15 : 16); + Transform boneTransform = component.GetBoneTransform(val); + if (boneTransform == null) + { + Debug.LogWarning($"[BodyPoseMatch_Arm] DrawForearmExtremeDebugSingle: elbow bone missing. isLeft={isLeft}"); + return; + } + if (!this.TryGetForearmExtremePoint(component, bodyMeshes, isLeft, out var extremePos)) + { + Debug.LogWarning($"[BodyPoseMatch_Arm] DrawForearmExtremeDebugSingle: extreme vertex not found. isLeft={isLeft}"); + return; + } + Debug.DrawLine(boneTransform.position, extremePos, lineColor, duration); + Debug.DrawLine(extremePos + Vector3.up * size, extremePos - Vector3.up * size, pointColor, duration); + Debug.DrawLine(extremePos + Vector3.right * size, extremePos - Vector3.right * size, pointColor, duration); + Debug.DrawLine(extremePos + Vector3.forward * size, extremePos - Vector3.forward * size, pointColor, duration); + } + } - private bool TryGetForearmExtremePoint(Animator avatar, IReadOnlyList bodyMeshes, bool isLeft, out Vector3 extremePos) - { - //IL_0002: Unknown result type (might be due to invalid IL or missing references) - //IL_0027: Unknown result type (might be due to invalid IL or missing references) - //IL_0029: Unknown result type (might be due to invalid IL or missing references) - //IL_00e1: Unknown result type (might be due to invalid IL or missing references) - //IL_00e6: 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_00fe: Unknown result type (might be due to invalid IL or missing references) - //IL_0100: Unknown result type (might be due to invalid IL or missing references) - //IL_012b: Unknown result type (might be due to invalid IL or missing references) - //IL_012d: Unknown result type (might be due to invalid IL or missing references) - //IL_0116: 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) - extremePos = default(Vector3); - if ((Object)(object)avatar == (Object)null || bodyMeshes == null || bodyMeshes.Count == 0) - { - return false; - } - HumanBodyBones val = (HumanBodyBones)(isLeft ? 17 : 18); - Transform boneTransform = avatar.GetBoneTransform(val); - if ((Object)(object)boneTransform == (Object)null) - { - return false; - } - HashSet targetBoneSet = new HashSet { boneTransform }; - List list = new List(bodyMeshes.Count); - for (int i = 0; i < bodyMeshes.Count; i++) - { - SkinnedMeshRenderer val2 = bodyMeshes[i]; - if (!((Object)(object)val2 == (Object)null)) - { - BakedBodyMesh bakedBodyMesh = new BakedBodyMesh(val2); - bakedBodyMesh.ReBakeMesh(); - list.Add(bakedBodyMesh); - } - } - if (list.Count == 0) - { - return false; - } - List list2 = poseMatchCommonUtil.CollectWeightedVerticesWorld(list, targetBoneSet, 0.1f); - if (list2 == null || list2.Count == 0) - { - return false; - } - bool flag = false; - float num = (isLeft ? float.PositiveInfinity : float.NegativeInfinity); - for (int j = 0; j < list2.Count; j++) - { - Vector3 val3 = list2[j]; - float x = val3.x; - if (!flag) - { - flag = true; - num = x; - extremePos = val3; - } - else if (isLeft) - { - if (x < num) - { - num = x; - extremePos = val3; - } - } - else if (x > num) - { - num = x; - extremePos = val3; - } - } - return flag; - } + private bool TryGetForearmExtremePoint(Animator avatar, IReadOnlyList bodyMeshes, bool isLeft, out Vector3 extremePos) + { + //IL_0002: Unknown result type (might be due to invalid IL or missing references) + //IL_0027: Unknown result type (might be due to invalid IL or missing references) + //IL_0029: Unknown result type (might be due to invalid IL or missing references) + //IL_00e1: Unknown result type (might be due to invalid IL or missing references) + //IL_00e6: 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_00fe: Unknown result type (might be due to invalid IL or missing references) + //IL_0100: Unknown result type (might be due to invalid IL or missing references) + //IL_012b: Unknown result type (might be due to invalid IL or missing references) + //IL_012d: Unknown result type (might be due to invalid IL or missing references) + //IL_0116: 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) + extremePos = default(Vector3); + if (avatar == null || bodyMeshes == null || bodyMeshes.Count == 0) + { + return false; + } + HumanBodyBones val = (HumanBodyBones)(isLeft ? 17 : 18); + Transform boneTransform = avatar.GetBoneTransform(val); + if (boneTransform == null) + { + return false; + } + HashSet targetBoneSet = new HashSet { boneTransform }; + List list = new List(bodyMeshes.Count); + for (int i = 0; i < bodyMeshes.Count; i++) + { + SkinnedMeshRenderer val2 = bodyMeshes[i]; + if (!(val2 == null)) + { + BakedBodyMesh bakedBodyMesh = new BakedBodyMesh(val2); + bakedBodyMesh.ReBakeMesh(); + list.Add(bakedBodyMesh); + } + } + if (list.Count == 0) + { + return false; + } + List list2 = this.poseMatchCommonUtil.CollectWeightedVerticesWorld(list, targetBoneSet, 0.1f); + if (list2 == null || list2.Count == 0) + { + return false; + } + bool flag = false; + float num = (isLeft ? float.PositiveInfinity : float.NegativeInfinity); + for (int j = 0; j < list2.Count; j++) + { + Vector3 val3 = list2[j]; + float x = val3.x; + if (!flag) + { + flag = true; + num = x; + extremePos = val3; + } + else if (isLeft) + { + if (x < num) + { + num = x; + extremePos = val3; + } + } + else if (x > num) + { + num = x; + extremePos = val3; + } + } + return flag; + } } diff --git a/Assets/@Eden_Tools/Eden_AutoMorpher/Script/BodyPoseMatch_CommonUtil.cs b/Assets/@Eden_Tools/Eden_AutoMorpher/Script/BodyPoseMatch_CommonUtil.cs index d531145..b3c682a 100644 --- a/Assets/@Eden_Tools/Eden_AutoMorpher/Script/BodyPoseMatch_CommonUtil.cs +++ b/Assets/@Eden_Tools/Eden_AutoMorpher/Script/BodyPoseMatch_CommonUtil.cs @@ -1,319 +1,315 @@ -// Warning: Some assembly references could not be resolved automatically. This might lead to incorrect decompilation of some parts, +// 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.BodyPoseMatch_CommonUtil using System.Collections.Generic; using System.Linq; -using Eden.AutoMorpher; -using Eden.AutoMorpher.profile; using UnityEngine; public class BodyPoseMatch_CommonUtil { - public Transform GetBoneFromBoneMap(Dictionary> boneMap, HumanBodyBones bone) - { - //IL_0004: Unknown result type (might be due to invalid IL or missing references) - if (boneMap == null || !boneMap.TryGetValue(bone, out var value) || value == null) - { - return null; - } - return value.FirstOrDefault(); - } + public Transform GetBoneFromBoneMap(Dictionary> boneMap, HumanBodyBones bone) + { + //IL_0004: Unknown result type (might be due to invalid IL or missing references) + if (boneMap == null || !boneMap.TryGetValue(bone, out var value) || value == null) + { + return null; + } + return value.FirstOrDefault(); + } - public Vector3 GetProfilePcaCenterWorld(Dictionary> clothBoneMap, BoneSpatialData boneSpatialData, Vector3 comprehensiveScale, string errorContext = "") - { - //IL_0049: Unknown result type (might be due to invalid IL or missing references) - //IL_006c: Unknown result type (might be due to invalid IL or missing references) - //IL_00ba: Unknown result type (might be due to invalid IL or missing references) - //IL_00bf: Unknown result type (might be due to invalid IL or missing references) - //IL_00c2: Unknown result type (might be due to invalid IL or missing references) - //IL_00c8: 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_00d5: Unknown result type (might be due to invalid IL or missing references) - //IL_00dc: Unknown result type (might be due to invalid IL or missing references) - //IL_00e2: Unknown result type (might be due to invalid IL or missing references) - //IL_00ee: Unknown result type (might be due to invalid IL or missing references) - //IL_00ef: Unknown result type (might be due to invalid IL or missing references) - if (clothBoneMap == null) - { - throw new AutoMorpherException("Cloth Bone Map is Missing", "[BodyPoseMatch_CommonUtil] GetProfilePcaCenterWorld\n - clothBoneMap is null (context=" + errorContext + ")"); - } - if (boneSpatialData == null || boneSpatialData.pcaData == null) - { - throw new AutoMorpherException("Profile Bone Spatial Data is Missing", "[BodyPoseMatch_CommonUtil] GetProfilePcaCenterWorld\n - boneSpatialData or boneSpatialData.pcaData is null (context=" + errorContext + ")"); - } - Transform boneFromBoneMap = GetBoneFromBoneMap(clothBoneMap, boneSpatialData.refBone); - if ((Object)(object)boneFromBoneMap == (Object)null) - { - throw new AutoMorpherException("Profile Ref Bone Transform is Missing", "[BodyPoseMatch_CommonUtil] GetProfilePcaCenterWorld" + $"\n - refBone transform is null (refBone={boneSpatialData.refBone}, context={errorContext})"); - } - if ((Object)(object)GetBoneFromBoneMap(clothBoneMap, (HumanBodyBones)0) == (Object)null) - { - throw new AutoMorpherException("Hip Transform is Missing", "[BodyPoseMatch_CommonUtil] GetProfilePcaCenterWorld\n - hip transform is null (context=" + errorContext + ")"); - } - Vector3 pcaCenter = boneSpatialData.pcaData.pcaCenter; - Vector3 val = default(Vector3); - ((Vector3)(ref val))._002Ector(pcaCenter.x / comprehensiveScale.x, pcaCenter.y / comprehensiveScale.y, pcaCenter.z / comprehensiveScale.z); - return boneFromBoneMap.TransformPoint(val); - } + public Vector3 GetProfilePcaCenterWorld(Dictionary> clothBoneMap, BoneSpatialData boneSpatialData, Vector3 comprehensiveScale, string errorContext = "") + { + //IL_0049: Unknown result type (might be due to invalid IL or missing references) + //IL_006c: Unknown result type (might be due to invalid IL or missing references) + //IL_00ba: Unknown result type (might be due to invalid IL or missing references) + //IL_00bf: Unknown result type (might be due to invalid IL or missing references) + //IL_00c2: Unknown result type (might be due to invalid IL or missing references) + //IL_00c8: 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_00d5: Unknown result type (might be due to invalid IL or missing references) + //IL_00dc: Unknown result type (might be due to invalid IL or missing references) + //IL_00e2: Unknown result type (might be due to invalid IL or missing references) + //IL_00ee: Unknown result type (might be due to invalid IL or missing references) + //IL_00ef: Unknown result type (might be due to invalid IL or missing references) + if (clothBoneMap == null) + { + throw new AutoMorpherException("Cloth Bone Map is Missing", "[BodyPoseMatch_CommonUtil] GetProfilePcaCenterWorld\n - clothBoneMap is null (context=" + errorContext + ")"); + } + if (boneSpatialData == null || boneSpatialData.pcaData == null) + { + throw new AutoMorpherException("Profile Bone Spatial Data is Missing", "[BodyPoseMatch_CommonUtil] GetProfilePcaCenterWorld\n - boneSpatialData or boneSpatialData.pcaData is null (context=" + errorContext + ")"); + } + Transform boneFromBoneMap = this.GetBoneFromBoneMap(clothBoneMap, boneSpatialData.refBone); + if ((Object)(object)boneFromBoneMap == (Object)null) + { + throw new AutoMorpherException("Profile Ref Bone Transform is Missing", "[BodyPoseMatch_CommonUtil] GetProfilePcaCenterWorld" + $"\n - refBone transform is null (refBone={boneSpatialData.refBone}, context={errorContext})"); + } + if ((Object)(object)this.GetBoneFromBoneMap(clothBoneMap, (HumanBodyBones)0) == (Object)null) + { + throw new AutoMorpherException("Hip Transform is Missing", "[BodyPoseMatch_CommonUtil] GetProfilePcaCenterWorld\n - hip transform is null (context=" + errorContext + ")"); + } + Vector3 pcaCenter = boneSpatialData.pcaData.pcaCenter; + Vector3 val = new Vector3(pcaCenter.x / comprehensiveScale.x, pcaCenter.y / comprehensiveScale.y, pcaCenter.z / comprehensiveScale.z); + return boneFromBoneMap.TransformPoint(val); + } - public Vector3 GetProfileVolumeMinWorld(Dictionary> clothBoneMap, BoneSpatialData spatialData, int axis, Vector3 comprehensiveScale) - { - //IL_0004: Unknown result type (might be due to invalid IL or missing references) - //IL_0007: Unknown result type (might be due to invalid IL or missing references) - return GetProfileVolumeWorld(clothBoneMap, spatialData, axis, comprehensiveScale, isMin: true); - } + public Vector3 GetProfileVolumeMinWorld(Dictionary> clothBoneMap, BoneSpatialData spatialData, int axis, Vector3 comprehensiveScale) + { + //IL_0004: Unknown result type (might be due to invalid IL or missing references) + //IL_0007: Unknown result type (might be due to invalid IL or missing references) + return this.GetProfileVolumeWorld(clothBoneMap, spatialData, axis, comprehensiveScale, isMin: true); + } - public Vector3 GetProfileVolumeMaxWorld(Dictionary> clothBoneMap, BoneSpatialData spatialData, int axis, Vector3 comprehensiveScale) - { - //IL_0004: Unknown result type (might be due to invalid IL or missing references) - //IL_0007: Unknown result type (might be due to invalid IL or missing references) - return GetProfileVolumeWorld(clothBoneMap, spatialData, axis, comprehensiveScale, isMin: false); - } + public Vector3 GetProfileVolumeMaxWorld(Dictionary> clothBoneMap, BoneSpatialData spatialData, int axis, Vector3 comprehensiveScale) + { + //IL_0004: Unknown result type (might be due to invalid IL or missing references) + //IL_0007: Unknown result type (might be due to invalid IL or missing references) + return this.GetProfileVolumeWorld(clothBoneMap, spatialData, axis, comprehensiveScale, isMin: false); + } - public Vector3 GetProfileVolumeWorld(Dictionary> clothBoneMap, BoneSpatialData spatialData, int axisIndex, Vector3 comprehensiveScale, bool isMin) - { - //IL_0031: Unknown result type (might be due to invalid IL or missing references) - //IL_0055: Unknown result type (might be due to invalid IL or missing references) - //IL_009a: Unknown result type (might be due to invalid IL or missing references) - //IL_008d: Unknown result type (might be due to invalid IL or missing references) - //IL_00b9: Unknown result type (might be due to invalid IL or missing references) - //IL_00ac: 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_00cb: Unknown result type (might be due to invalid IL or missing references) - //IL_009f: Unknown result type (might be due to invalid IL or missing references) - //IL_00be: Unknown result type (might be due to invalid IL or missing references) - //IL_00dd: Unknown result type (might be due to invalid IL or missing references) - //IL_0107: 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_0115: Unknown result type (might be due to invalid IL or missing references) - //IL_011b: Unknown result type (might be due to invalid IL or missing references) - //IL_0123: Unknown result type (might be due to invalid IL or missing references) - //IL_0129: Unknown result type (might be due to invalid IL or missing references) - //IL_0137: Unknown result type (might be due to invalid IL or missing references) - //IL_0138: Unknown result type (might be due to invalid IL or missing references) - if (clothBoneMap == null) - { - throw new AutoMorpherException("Cloth Bone Map is Missing", "[BodyPoseMatch_CommonUtil] GetProfileVolumeWorld\n - clothBoneMap is null"); - } - if (spatialData == null || spatialData.volumeData == null) - { - throw new AutoMorpherException("Profile Volume Data is Missing", "[BodyPoseMatch_CommonUtil] GetProfileVolumeWorld\n - spatialData or spatialData.volumeData is null"); - } - Transform boneFromBoneMap = GetBoneFromBoneMap(clothBoneMap, spatialData.refBone); - if ((Object)(object)boneFromBoneMap == (Object)null) - { - throw new AutoMorpherException("Profile Ref Bone Transform is Missing", "[BodyPoseMatch_CommonUtil] GetProfileVolumeWorld" + $"\n - refBone transform is null (refBone={spatialData.refBone})"); - } - Vector3 val; - switch (axisIndex) - { - case 0: - val = (isMin ? spatialData.volumeData.fMinLocalPos : spatialData.volumeData.fMaxLocalPos); - break; - case 1: - val = (isMin ? spatialData.volumeData.rMinLocalPos : spatialData.volumeData.rMaxLocalPos); - break; - case 2: - val = (isMin ? spatialData.volumeData.uMinLocalPos : spatialData.volumeData.uMaxLocalPos); - break; - default: - throw new AutoMorpherException("Unsupported Volume Axis Index", "[BodyPoseMatch_CommonUtil] GetProfileVolumeWorld" + $"\n - axisIndex must be 0(Forward), 1(Right), 2(Up) (axisIndex={axisIndex})"); - } - Vector3 val2 = default(Vector3); - ((Vector3)(ref val2))._002Ector(val.x / comprehensiveScale.x, val.y / comprehensiveScale.y, val.z / comprehensiveScale.z); - return boneFromBoneMap.TransformPoint(val2); - } + public Vector3 GetProfileVolumeWorld(Dictionary> clothBoneMap, BoneSpatialData spatialData, int axisIndex, Vector3 comprehensiveScale, bool isMin) + { + //IL_0031: Unknown result type (might be due to invalid IL or missing references) + //IL_0055: Unknown result type (might be due to invalid IL or missing references) + //IL_009a: Unknown result type (might be due to invalid IL or missing references) + //IL_008d: Unknown result type (might be due to invalid IL or missing references) + //IL_00b9: Unknown result type (might be due to invalid IL or missing references) + //IL_00ac: 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_00cb: Unknown result type (might be due to invalid IL or missing references) + //IL_009f: Unknown result type (might be due to invalid IL or missing references) + //IL_00be: Unknown result type (might be due to invalid IL or missing references) + //IL_00dd: Unknown result type (might be due to invalid IL or missing references) + //IL_0107: 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_0115: Unknown result type (might be due to invalid IL or missing references) + //IL_011b: Unknown result type (might be due to invalid IL or missing references) + //IL_0123: Unknown result type (might be due to invalid IL or missing references) + //IL_0129: Unknown result type (might be due to invalid IL or missing references) + //IL_0137: Unknown result type (might be due to invalid IL or missing references) + //IL_0138: Unknown result type (might be due to invalid IL or missing references) + if (clothBoneMap == null) + { + throw new AutoMorpherException("Cloth Bone Map is Missing", "[BodyPoseMatch_CommonUtil] GetProfileVolumeWorld\n - clothBoneMap is null"); + } + if (spatialData == null || spatialData.volumeData == null) + { + throw new AutoMorpherException("Profile Volume Data is Missing", "[BodyPoseMatch_CommonUtil] GetProfileVolumeWorld\n - spatialData or spatialData.volumeData is null"); + } + Transform boneFromBoneMap = this.GetBoneFromBoneMap(clothBoneMap, spatialData.refBone); + if ((Object)(object)boneFromBoneMap == (Object)null) + { + throw new AutoMorpherException("Profile Ref Bone Transform is Missing", "[BodyPoseMatch_CommonUtil] GetProfileVolumeWorld" + $"\n - refBone transform is null (refBone={spatialData.refBone})"); + } + Vector3 val; + switch (axisIndex) + { + case 0: + val = (isMin ? spatialData.volumeData.fMinLocalPos : spatialData.volumeData.fMaxLocalPos); + break; + case 1: + val = (isMin ? spatialData.volumeData.rMinLocalPos : spatialData.volumeData.rMaxLocalPos); + break; + case 2: + val = (isMin ? spatialData.volumeData.uMinLocalPos : spatialData.volumeData.uMaxLocalPos); + break; + default: + throw new AutoMorpherException("Unsupported Volume Axis Index", "[BodyPoseMatch_CommonUtil] GetProfileVolumeWorld" + $"\n - axisIndex must be 0(Forward), 1(Right), 2(Up) (axisIndex={axisIndex})"); + } + Vector3 val2 = new Vector3(val.x / comprehensiveScale.x, val.y / comprehensiveScale.y, val.z / comprehensiveScale.z); + return boneFromBoneMap.TransformPoint(val2); + } - public List CollectWeightedVerticesWorld(IReadOnlyList bakedBodyMeshes, HashSet targetBoneSet, float weightThreshold = 0.15f, int sampleStep = 1) - { - //IL_00e9: Unknown result type (might be due to invalid IL or missing references) - //IL_00ee: 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) - List list = new List(); - if (bakedBodyMeshes == null || targetBoneSet == null || targetBoneSet.Count == 0) - { - return list; - } - foreach (BakedBodyMesh bakedBodyMesh in bakedBodyMeshes) - { - if (bakedBodyMesh == null || (Object)(object)bakedBodyMesh.smr == (Object)null) - { - continue; - } - Mesh sharedMesh = bakedBodyMesh.smr.sharedMesh; - if ((Object)(object)sharedMesh == (Object)null) - { - continue; - } - BoneWeight[] boneWeights = sharedMesh.boneWeights; - Transform[] bones = bakedBodyMesh.smr.bones; - if (boneWeights == null || boneWeights.Length == 0 || bones == null || bones.Length == 0) - { - continue; - } - Vector3[] worldVerticesWithBakedMesh = new WorldVertexUtil().GetWorldVerticesWithBakedMesh(bakedBodyMesh.smr, bakedBodyMesh.bakedMesh); - if (worldVerticesWithBakedMesh == null) - { - continue; - } - int num = Mathf.Min(worldVerticesWithBakedMesh.Length, boneWeights.Length); - for (int i = 0; i < num; i += sampleStep) - { - BoneWeight val = boneWeights[i]; - float wSum = 0f; - Acc(((BoneWeight)(ref val)).boneIndex0, ((BoneWeight)(ref val)).weight0); - Acc(((BoneWeight)(ref val)).boneIndex1, ((BoneWeight)(ref val)).weight1); - Acc(((BoneWeight)(ref val)).boneIndex2, ((BoneWeight)(ref val)).weight2); - Acc(((BoneWeight)(ref val)).boneIndex3, ((BoneWeight)(ref val)).weight3); - if (!(wSum < weightThreshold)) - { - list.Add(worldVerticesWithBakedMesh[i]); - } - void Acc(int index, float w) - { - if (index >= 0 && index < bones.Length && !(w <= 0f)) - { - Transform val2 = bones[index]; - if ((Object)(object)val2 != (Object)null && targetBoneSet.Contains(val2)) - { - wSum += w; - } - } - } - } - } - return list; - } + public List CollectWeightedVerticesWorld(IReadOnlyList bakedBodyMeshes, HashSet targetBoneSet, float weightThreshold = 0.15f, int sampleStep = 1) + { + //IL_00e9: Unknown result type (might be due to invalid IL or missing references) + //IL_00ee: 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) + List list = new List(); + if (bakedBodyMeshes == null || targetBoneSet == null || targetBoneSet.Count == 0) + { + return list; + } + foreach (BakedBodyMesh bakedBodyMesh in bakedBodyMeshes) + { + if (bakedBodyMesh == null || (Object)(object)bakedBodyMesh.smr == (Object)null) + { + continue; + } + Mesh sharedMesh = bakedBodyMesh.smr.sharedMesh; + if ((Object)(object)sharedMesh == (Object)null) + { + continue; + } + BoneWeight[] boneWeights = sharedMesh.boneWeights; + Transform[] bones = bakedBodyMesh.smr.bones; + if (boneWeights == null || boneWeights.Length == 0 || bones == null || bones.Length == 0) + { + continue; + } + Vector3[] worldVerticesWithBakedMesh = new WorldVertexUtil().GetWorldVerticesWithBakedMesh(bakedBodyMesh.smr, bakedBodyMesh.bakedMesh); + if (worldVerticesWithBakedMesh == null) + { + continue; + } + int num = Mathf.Min(worldVerticesWithBakedMesh.Length, boneWeights.Length); + for (int i = 0; i < num; i += sampleStep) + { + BoneWeight val = boneWeights[i]; + float wSum = 0f; + Acc(val.boneIndex0, val.weight0); + Acc(val.boneIndex1, val.weight1); + Acc(val.boneIndex2, val.weight2); + Acc(val.boneIndex3, val.weight3); + if (!(wSum < weightThreshold)) + { + list.Add(worldVerticesWithBakedMesh[i]); + } + void Acc(int index, float w) + { + if (index >= 0 && index < bones.Length && !(w <= 0f)) + { + Transform val2 = bones[index]; + if ((Object)(object)val2 != (Object)null && targetBoneSet.Contains(val2)) + { + wSum += w; + } + } + } + } + } + return list; + } - public List CollectHumanoidVerticesWorld(IReadOnlyList targetHumanBones, IReadOnlyList bakedBodyMeshes, Dictionary> boneMap, float weightThreshold = 0.15f, int sampleStep = 1) - { - //IL_0037: Unknown result type (might be due to invalid IL or missing references) - //IL_003c: Unknown result type (might be due to invalid IL or missing references) - //IL_003e: Unknown result type (might be due to invalid IL or missing references) - List result = new List(); - if (bakedBodyMeshes == null || boneMap == null || boneMap.Count == 0 || targetHumanBones == null) - { - throw new AutoMorpherException("Invalid Arguments for CollectHumanoidVerticesWorld", "[BodyPoseMatchCommonUtil] CollectHumanoidVerticesWorld\n - bakedBodyMeshes is null OR boneMap is null/empty OR targetHumanBones is null"); - } - HashSet hashSet = new HashSet(); - foreach (HumanBodyBones targetHumanBone in targetHumanBones) - { - if (!boneMap.TryGetValue(targetHumanBone, out var value) || value == null) - { - continue; - } - foreach (Transform item in value) - { - if ((Object)(object)item != (Object)null) - { - hashSet.Add(item); - } - } - } - if (hashSet.Count == 0) - { - Debug.Log((object)"[AvatarBodyMatchUtil] CollectBodyPartVerticesWorld: targetBoneSet is empty."); - return result; - } - return CollectWeightedVerticesWorld(bakedBodyMeshes, hashSet, weightThreshold, sampleStep); - } + public List CollectHumanoidVerticesWorld(IReadOnlyList targetHumanBones, IReadOnlyList bakedBodyMeshes, Dictionary> boneMap, float weightThreshold = 0.15f, int sampleStep = 1) + { + //IL_0037: Unknown result type (might be due to invalid IL or missing references) + //IL_003c: Unknown result type (might be due to invalid IL or missing references) + //IL_003e: Unknown result type (might be due to invalid IL or missing references) + List result = new List(); + if (bakedBodyMeshes == null || boneMap == null || boneMap.Count == 0 || targetHumanBones == null) + { + throw new AutoMorpherException("Invalid Arguments for CollectHumanoidVerticesWorld", "[BodyPoseMatchCommonUtil] CollectHumanoidVerticesWorld\n - bakedBodyMeshes is null OR boneMap is null/empty OR targetHumanBones is null"); + } + HashSet hashSet = new HashSet(); + foreach (HumanBodyBones targetHumanBone in targetHumanBones) + { + if (!boneMap.TryGetValue(targetHumanBone, out var value) || value == null) + { + continue; + } + foreach (Transform item in value) + { + if ((Object)(object)item != (Object)null) + { + hashSet.Add(item); + } + } + } + if (hashSet.Count == 0) + { + Debug.Log((object)"[AvatarBodyMatchUtil] CollectBodyPartVerticesWorld: targetBoneSet is empty."); + return result; + } + return this.CollectWeightedVerticesWorld(bakedBodyMeshes, hashSet, weightThreshold, sampleStep); + } - public void BoneLengthAdjust(Transform proxyParent, Transform proxyChild, Transform targetParent, Transform targetChild, HashSet proxyParentSet, bool autoDetectAxis = true, int forceAxisIndex = 1) - { - //IL_0031: Unknown result type (might be due to invalid IL or missing references) - //IL_0037: Unknown result type (might be due to invalid IL or missing references) - //IL_0043: Unknown result type (might be due to invalid IL or missing references) - //IL_004a: Unknown result type (might be due to invalid IL or missing references) - //IL_008a: Unknown result type (might be due to invalid IL or missing references) - //IL_0090: Unknown result type (might be due to invalid IL or missing references) - //IL_0095: Unknown result type (might be due to invalid IL or missing references) - //IL_009a: 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_009f: Unknown result type (might be due to invalid IL or missing references) - //IL_00a4: Unknown result type (might be due to invalid IL or missing references) - //IL_00b1: Unknown result type (might be due to invalid IL or missing references) - //IL_00f3: Unknown result type (might be due to invalid IL or missing references) - //IL_00f8: 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) - if ((Object)(object)proxyParent == (Object)null || (Object)(object)proxyChild == (Object)null || (Object)(object)targetParent == (Object)null || (Object)(object)targetChild == (Object)null) - { - Debug.LogWarning((object)"[AvatarBodyMatchUtil] MatchBoneSegmentLength: bone null"); - return; - } - float num = Vector3.Distance(proxyParent.position, proxyChild.position); - float num2 = Vector3.Distance(targetParent.position, targetChild.position); - if (num < 1E-06f || num2 < 1E-06f) - { - Debug.LogWarning((object)$"[AvatarBodyMatchUtil] MatchBoneSegmentLength: too small length. proxy={num}, target={num2}"); - return; - } - float num3 = num2 / num; - int num7; - if (autoDetectAxis) - { - Vector3 val = proxyChild.position - proxyParent.position; - Vector3 val2 = proxyParent.InverseTransformDirection(val); - float num4 = Mathf.Abs(val2.x); - float num5 = Mathf.Abs(val2.y); - float num6 = Mathf.Abs(val2.z); - num7 = ((num5 >= num4 && num5 >= num6) ? 1 : ((!(num4 >= num6)) ? 2 : 0)); - } - else - { - num7 = Mathf.Clamp(forceAxisIndex, 0, 2); - } - Vector3 localScale = proxyParent.localScale; - switch (num7) - { - case 0: - localScale.x *= num3; - break; - case 1: - localScale.y *= num3; - break; - case 2: - localScale.z *= num3; - break; - } - foreach (Transform item in proxyParentSet) - { - item.localScale = localScale; - } - } + public void BoneLengthAdjust(Transform proxyParent, Transform proxyChild, Transform targetParent, Transform targetChild, HashSet proxyParentSet, bool autoDetectAxis = true, int forceAxisIndex = 1) + { + //IL_0031: Unknown result type (might be due to invalid IL or missing references) + //IL_0037: Unknown result type (might be due to invalid IL or missing references) + //IL_0043: Unknown result type (might be due to invalid IL or missing references) + //IL_004a: Unknown result type (might be due to invalid IL or missing references) + //IL_008a: Unknown result type (might be due to invalid IL or missing references) + //IL_0090: Unknown result type (might be due to invalid IL or missing references) + //IL_0095: Unknown result type (might be due to invalid IL or missing references) + //IL_009a: 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_009f: Unknown result type (might be due to invalid IL or missing references) + //IL_00a4: Unknown result type (might be due to invalid IL or missing references) + //IL_00b1: Unknown result type (might be due to invalid IL or missing references) + //IL_00f3: Unknown result type (might be due to invalid IL or missing references) + //IL_00f8: 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) + if ((Object)(object)proxyParent == (Object)null || (Object)(object)proxyChild == (Object)null || (Object)(object)targetParent == (Object)null || (Object)(object)targetChild == (Object)null) + { + Debug.LogWarning((object)"[AvatarBodyMatchUtil] MatchBoneSegmentLength: bone null"); + return; + } + float num = Vector3.Distance(proxyParent.position, proxyChild.position); + float num2 = Vector3.Distance(targetParent.position, targetChild.position); + if (num < 1E-06f || num2 < 1E-06f) + { + Debug.LogWarning((object)$"[AvatarBodyMatchUtil] MatchBoneSegmentLength: too small length. proxy={num}, target={num2}"); + return; + } + float num3 = num2 / num; + int num7; + if (autoDetectAxis) + { + Vector3 val = proxyChild.position - proxyParent.position; + Vector3 val2 = proxyParent.InverseTransformDirection(val); + float num4 = Mathf.Abs(val2.x); + float num5 = Mathf.Abs(val2.y); + float num6 = Mathf.Abs(val2.z); + num7 = ((num5 >= num4 && num5 >= num6) ? 1 : ((!(num4 >= num6)) ? 2 : 0)); + } + else + { + num7 = Mathf.Clamp(forceAxisIndex, 0, 2); + } + Vector3 localScale = proxyParent.localScale; + switch (num7) + { + case 0: + localScale.x *= num3; + break; + case 1: + localScale.y *= num3; + break; + case 2: + localScale.z *= num3; + break; + } + foreach (Transform item in proxyParentSet) + { + item.localScale = localScale; + } + } - public Transform CreateTempMarker(string markerObjectName, Transform parentTransform, IReadOnlyList childTransforms, Vector3 markerWorldPosition, Quaternion markerWorldRotation, Vector3 markerLocalScale, out TempBoneMarker tempBoneMarker) - { - //IL_0044: Unknown result type (might be due to invalid IL or missing references) - //IL_0058: Unknown result type (might be due to invalid IL or missing references) - //IL_0060: Unknown result type (might be due to invalid IL or missing references) - //IL_0068: Unknown result type (might be due to invalid IL or missing references) - if ((Object)(object)parentTransform == (Object)null) - { - throw new AutoMorpherException("Marker Parent Transform is Missing", "[BodyPoseMatch_CommonUtil] CreateTempMarker\n - parentTransform is null"); - } - if (childTransforms == null || childTransforms.Count == 0) - { - throw new AutoMorpherException("Child Transforms are Missing", "[BodyPoseMatch_CommonUtil] CreateTempMarker\n - childTransforms is null or empty"); - } - Transform transform = new GameObject(string.IsNullOrEmpty(markerObjectName) ? "scaleSupportBone" : markerObjectName).transform; - transform.SetParent(parentTransform, true); - transform.position = markerWorldPosition; - transform.rotation = markerWorldRotation; - transform.localScale = markerLocalScale; - tempBoneMarker = ((Component)transform).gameObject.AddComponent(); - tempBoneMarker.originalParent = parentTransform; - tempBoneMarker.additionalInfo = ""; - tempBoneMarker.wrappedChildNames = new List(); - for (int i = 0; i < childTransforms.Count; i++) - { - Transform val = childTransforms[i]; - if (!((Object)(object)val == (Object)null)) - { - tempBoneMarker.wrappedChildNames.Add(((Object)val).name); - val.SetParent(transform, true); - } - } - return transform; - } + public Transform CreateTempMarker(string markerObjectName, Transform parentTransform, IReadOnlyList childTransforms, Vector3 markerWorldPosition, Quaternion markerWorldRotation, Vector3 markerLocalScale, out TempBoneMarker tempBoneMarker) + { + //IL_0044: Unknown result type (might be due to invalid IL or missing references) + //IL_0058: Unknown result type (might be due to invalid IL or missing references) + //IL_0060: Unknown result type (might be due to invalid IL or missing references) + //IL_0068: Unknown result type (might be due to invalid IL or missing references) + if ((Object)(object)parentTransform == (Object)null) + { + throw new AutoMorpherException("Marker Parent Transform is Missing", "[BodyPoseMatch_CommonUtil] CreateTempMarker\n - parentTransform is null"); + } + if (childTransforms == null || childTransforms.Count == 0) + { + throw new AutoMorpherException("Child Transforms are Missing", "[BodyPoseMatch_CommonUtil] CreateTempMarker\n - childTransforms is null or empty"); + } + Transform transform = new GameObject(string.IsNullOrEmpty(markerObjectName) ? "scaleSupportBone" : markerObjectName).transform; + transform.SetParent(parentTransform, true); + transform.position = markerWorldPosition; + transform.rotation = markerWorldRotation; + transform.localScale = markerLocalScale; + tempBoneMarker = ((Component)transform).gameObject.AddComponent(); + tempBoneMarker.originalParent = parentTransform; + tempBoneMarker.additionalInfo = ""; + tempBoneMarker.wrappedChildNames = new List(); + for (int i = 0; i < childTransforms.Count; i++) + { + Transform val = childTransforms[i]; + if (!((Object)(object)val == (Object)null)) + { + tempBoneMarker.wrappedChildNames.Add(((Object)val).name); + val.SetParent(transform, true); + } + } + return transform; + } } diff --git a/Assets/@Eden_Tools/Eden_AutoMorpher/Script/BodyPoseMatch_Leg.cs b/Assets/@Eden_Tools/Eden_AutoMorpher/Script/BodyPoseMatch_Leg.cs index 8acdd32..cc5d6f9 100644 --- a/Assets/@Eden_Tools/Eden_AutoMorpher/Script/BodyPoseMatch_Leg.cs +++ b/Assets/@Eden_Tools/Eden_AutoMorpher/Script/BodyPoseMatch_Leg.cs @@ -1,940 +1,937 @@ -// Warning: Some assembly references could not be resolved automatically. This might lead to incorrect decompilation of some parts, +// 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.BodyPoseMatch_Leg using System.Collections.Generic; -using Eden.AutoMorpher; -using Eden.AutoMorpher.profile; using UnityEngine; public class BodyPoseMatch_Leg { - private readonly BodyPoseMatch_CommonUtil poseMatchCommonUtil; + private readonly BodyPoseMatch_CommonUtil poseMatchCommonUtil; - public BodyPoseMatch_Leg() - { - poseMatchCommonUtil = new BodyPoseMatch_CommonUtil(); - } + public BodyPoseMatch_Leg() + { + this.poseMatchCommonUtil = new BodyPoseMatch_CommonUtil(); + } - public void AlignBothUpperLegs(GameObject proxyObject, IReadOnlyList proxyBakedBodyMeshes, Dictionary> proxyBoneMap, GameObject targetObject, IReadOnlyList targetBakedBodyMeshes, Dictionary> targetBoneMap) - { - if ((Object)(object)proxyObject == (Object)null || (Object)(object)targetObject == (Object)null) - { - throw new AutoMorpherException("Proxy or Target Object is Missing", "[BodyPoseMatch_Leg] AlignBothUpperLegs\n - proxyObject or targetObject is null"); - } - AlignUpperLeg_BodyMatch(proxyObject, proxyBakedBodyMeshes, proxyBoneMap, targetObject, targetBakedBodyMeshes, targetBoneMap, isLeft: true); - AlignUpperLeg_BodyMatch(proxyObject, proxyBakedBodyMeshes, proxyBoneMap, targetObject, targetBakedBodyMeshes, targetBoneMap, isLeft: false); - } + public void AlignBothUpperLegs(GameObject proxyObject, IReadOnlyList proxyBakedBodyMeshes, Dictionary> proxyBoneMap, GameObject targetObject, IReadOnlyList targetBakedBodyMeshes, Dictionary> targetBoneMap) + { + if ((Object)(object)proxyObject == (Object)null || (Object)(object)targetObject == (Object)null) + { + throw new AutoMorpherException("Proxy or Target Object is Missing", "[BodyPoseMatch_Leg] AlignBothUpperLegs\n - proxyObject or targetObject is null"); + } + this.AlignUpperLeg_BodyMatch(proxyObject, proxyBakedBodyMeshes, proxyBoneMap, targetObject, targetBakedBodyMeshes, targetBoneMap, isLeft: true); + this.AlignUpperLeg_BodyMatch(proxyObject, proxyBakedBodyMeshes, proxyBoneMap, targetObject, targetBakedBodyMeshes, targetBoneMap, isLeft: false); + } - public void AlignBothUpperLegs(Transform targetTransform, IReadOnlyList targetBakedBodyMeshes, Dictionary> targetBoneMap, Transform clothesTransform, Dictionary> clothBoneMap, ProfileData profileData, Vector3 comprehensiveScale) - { - //IL_000a: Unknown result type (might be due to invalid IL or missing references) - //IL_001c: Unknown result type (might be due to invalid IL or missing references) - AlignUpperLeg_Profile(targetTransform, targetBakedBodyMeshes, targetBoneMap, clothesTransform, clothBoneMap, profileData, comprehensiveScale, isLeft: true); - AlignUpperLeg_Profile(targetTransform, targetBakedBodyMeshes, targetBoneMap, clothesTransform, clothBoneMap, profileData, comprehensiveScale, isLeft: false); - } + public void AlignBothUpperLegs(Transform targetTransform, IReadOnlyList targetBakedBodyMeshes, Dictionary> targetBoneMap, Transform clothesTransform, Dictionary> clothBoneMap, ProfileData profileData, Vector3 comprehensiveScale) + { + //IL_000a: Unknown result type (might be due to invalid IL or missing references) + //IL_001c: Unknown result type (might be due to invalid IL or missing references) + this.AlignUpperLeg_Profile(targetTransform, targetBakedBodyMeshes, targetBoneMap, clothesTransform, clothBoneMap, profileData, comprehensiveScale, isLeft: true); + this.AlignUpperLeg_Profile(targetTransform, targetBakedBodyMeshes, targetBoneMap, clothesTransform, clothBoneMap, profileData, comprehensiveScale, isLeft: false); + } - public void AlignUpperLeg_BodyMatch(GameObject proxyObject, IReadOnlyList proxyBakedBodyMeshes, Dictionary> proxyBoneMap, GameObject targetObject, IReadOnlyList targetBakedBodyMeshes, Dictionary> targetBoneMap, bool isLeft) - { - //IL_0075: Unknown result type (might be due to invalid IL or missing references) - //IL_007a: 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_00a3: Unknown result type (might be due to invalid IL or missing references) - if ((Object)(object)proxyObject == (Object)null || (Object)(object)targetObject == (Object)null) - { - throw new AutoMorpherException("Proxy or Target Object is Missing", "[BodyPoseMatch_Leg] AlignUpperLeg_BodyMatch\n - proxyObject or targetObject is null"); - } - RegionStats regionStats = ComputeLegRegionStats(proxyObject.transform, proxyBakedBodyMeshes, proxyBoneMap, isLeft); - RegionStats regionStats2 = ComputeLegRegionStats(targetObject.transform, targetBakedBodyMeshes, targetBoneMap, isLeft); - if (regionStats.length < 0.0001f || regionStats2.length < 0.0001f) - { - Debug.LogWarning((object)"[BodyPoseMatch_Leg] AlignUpperLeg_BodyMatch: leg PCA 통계가 비정상입니다."); - return; - } - HumanBodyBones key = (HumanBodyBones)(isLeft ? 1 : 2); - if (proxyBoneMap == null || !proxyBoneMap.TryGetValue(key, out var value) || value == null || value.Count == 0) - { - Debug.LogWarning((object)"[BodyPoseMatch_Leg] AlignUpperLeg_BodyMatch: proxy UpperLeg 본을 찾지 못했습니다."); - } - else - { - AlignUpperLegCore(value, regionStats.center, regionStats2.center); - } - } + public void AlignUpperLeg_BodyMatch(GameObject proxyObject, IReadOnlyList proxyBakedBodyMeshes, Dictionary> proxyBoneMap, GameObject targetObject, IReadOnlyList targetBakedBodyMeshes, Dictionary> targetBoneMap, bool isLeft) + { + //IL_0075: Unknown result type (might be due to invalid IL or missing references) + //IL_007a: 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_00a3: Unknown result type (might be due to invalid IL or missing references) + if ((Object)(object)proxyObject == (Object)null || (Object)(object)targetObject == (Object)null) + { + throw new AutoMorpherException("Proxy or Target Object is Missing", "[BodyPoseMatch_Leg] AlignUpperLeg_BodyMatch\n - proxyObject or targetObject is null"); + } + RegionStats regionStats = this.ComputeLegRegionStats(proxyObject.transform, proxyBakedBodyMeshes, proxyBoneMap, isLeft); + RegionStats regionStats2 = this.ComputeLegRegionStats(targetObject.transform, targetBakedBodyMeshes, targetBoneMap, isLeft); + if (regionStats.length < 0.0001f || regionStats2.length < 0.0001f) + { + Debug.LogWarning((object)"[BodyPoseMatch_Leg] AlignUpperLeg_BodyMatch: leg PCA 통계가 비정상입니다."); + return; + } + HumanBodyBones key = (HumanBodyBones)(isLeft ? 1 : 2); + if (proxyBoneMap == null || !proxyBoneMap.TryGetValue(key, out var value) || value == null || value.Count == 0) + { + Debug.LogWarning((object)"[BodyPoseMatch_Leg] AlignUpperLeg_BodyMatch: proxy UpperLeg 본을 찾지 못했습니다."); + } + else + { + this.AlignUpperLegCore(value, regionStats.center, regionStats2.center); + } + } - public void AlignUpperLeg_Profile(Transform targetTransform, IReadOnlyList targetBakedBodyMeshes, Dictionary> targetBoneMap, Transform clothesTransform, Dictionary> clothBoneMap, ProfileData profileData, Vector3 comprehensiveScale, bool isLeft) - { - //IL_0021: Unknown result type (might be due to invalid IL or missing references) - //IL_0070: Unknown result type (might be due to invalid IL or missing references) - //IL_0077: Unknown result type (might be due to invalid IL or missing references) - //IL_007c: Unknown result type (might be due to invalid IL or missing references) - //IL_00a7: 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_00ce: Unknown result type (might be due to invalid IL or missing references) - if ((Object)(object)targetTransform == (Object)null) - { - throw new AutoMorpherException("Target Object is Missing", "[BodyPoseMatch_Leg] AlignUpperLeg_Profile\n - targetObject is null"); - } - HumanBodyBones key = (HumanBodyBones)(isLeft ? 1 : 2); - BoneSpatialData val = (isLeft ? profileData.LeftUpperLegSpatialData : profileData.RightUpperLegSpatialData); - if (val == null || val.pcaData == null) - { - Debug.LogWarning((object)("[BodyPoseMatch_Leg] AlignUpperLeg: " + (isLeft ? "Left" : "Right") + " spatial data missing.")); - return; - } - Vector3 profilePcaCenterWorld = poseMatchCommonUtil.GetProfilePcaCenterWorld(clothBoneMap, val, comprehensiveScale); - RegionStats regionStats = ComputeLegRegionStats(targetTransform, targetBakedBodyMeshes, targetBoneMap, isLeft); - HashSet value; - if (regionStats.length < 0.0001f) - { - Debug.LogWarning((object)"[BodyPoseMatch_Leg] AlignUpperLeg: Target leg PCA 통계가 비정상입니다."); - } - else if (clothBoneMap == null || !clothBoneMap.TryGetValue(key, out value) || value == null || value.Count == 0) - { - Debug.LogWarning((object)"[BodyPoseMatch_Leg] AlignUpperLeg: clothes UpperLeg 본을 찾지 못했습니다."); - } - else - { - AlignUpperLegCore(value, profilePcaCenterWorld, regionStats.center); - } - } + public void AlignUpperLeg_Profile(Transform targetTransform, IReadOnlyList targetBakedBodyMeshes, Dictionary> targetBoneMap, Transform clothesTransform, Dictionary> clothBoneMap, ProfileData profileData, Vector3 comprehensiveScale, bool isLeft) + { + //IL_0021: Unknown result type (might be due to invalid IL or missing references) + //IL_0070: Unknown result type (might be due to invalid IL or missing references) + //IL_0077: Unknown result type (might be due to invalid IL or missing references) + //IL_007c: Unknown result type (might be due to invalid IL or missing references) + //IL_00a7: 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_00ce: Unknown result type (might be due to invalid IL or missing references) + if ((Object)(object)targetTransform == (Object)null) + { + throw new AutoMorpherException("Target Object is Missing", "[BodyPoseMatch_Leg] AlignUpperLeg_Profile\n - targetObject is null"); + } + HumanBodyBones key = (HumanBodyBones)(isLeft ? 1 : 2); + BoneSpatialData val = (isLeft ? profileData.LeftUpperLegSpatialData : profileData.RightUpperLegSpatialData); + if (val == null || val.pcaData == null) + { + Debug.LogWarning((object)("[BodyPoseMatch_Leg] AlignUpperLeg: " + (isLeft ? "Left" : "Right") + " spatial data missing.")); + return; + } + Vector3 profilePcaCenterWorld = this.poseMatchCommonUtil.GetProfilePcaCenterWorld(clothBoneMap, val, comprehensiveScale); + RegionStats regionStats = this.ComputeLegRegionStats(targetTransform, targetBakedBodyMeshes, targetBoneMap, isLeft); + HashSet value; + if (regionStats.length < 0.0001f) + { + Debug.LogWarning((object)"[BodyPoseMatch_Leg] AlignUpperLeg: Target leg PCA 통계가 비정상입니다."); + } + else if (clothBoneMap == null || !clothBoneMap.TryGetValue(key, out value) || value == null || value.Count == 0) + { + Debug.LogWarning((object)"[BodyPoseMatch_Leg] AlignUpperLeg: clothes UpperLeg 본을 찾지 못했습니다."); + } + else + { + this.AlignUpperLegCore(value, profilePcaCenterWorld, regionStats.center); + } + } - private void AlignUpperLegCore(IReadOnlyCollection upperLegSet, Vector3 sourceLegCenterWorld, Vector3 targetLegCenterWorld) - { - //IL_000c: Unknown result type (might be due to invalid IL or missing references) - //IL_000d: Unknown result type (might be due to invalid IL or missing references) - //IL_000e: Unknown result type (might be due to invalid IL or missing references) - //IL_0013: Unknown result type (might be due to invalid IL or missing references) - //IL_003b: Unknown result type (might be due to invalid IL or missing references) - //IL_0040: Unknown result type (might be due to invalid IL or missing references) - //IL_0041: Unknown result type (might be due to invalid IL or missing references) - if (upperLegSet == null || upperLegSet.Count == 0) - { - return; - } - Vector3 val = targetLegCenterWorld - sourceLegCenterWorld; - val.y = 0f; - foreach (Transform item in upperLegSet) - { - if (!((Object)(object)item == (Object)null)) - { - item.position += val; - } - } - } + private void AlignUpperLegCore(IReadOnlyCollection upperLegSet, Vector3 sourceLegCenterWorld, Vector3 targetLegCenterWorld) + { + //IL_000c: Unknown result type (might be due to invalid IL or missing references) + //IL_000d: Unknown result type (might be due to invalid IL or missing references) + //IL_000e: Unknown result type (might be due to invalid IL or missing references) + //IL_0013: Unknown result type (might be due to invalid IL or missing references) + //IL_003b: Unknown result type (might be due to invalid IL or missing references) + //IL_0040: Unknown result type (might be due to invalid IL or missing references) + //IL_0041: Unknown result type (might be due to invalid IL or missing references) + if (upperLegSet == null || upperLegSet.Count == 0) + { + return; + } + Vector3 val = targetLegCenterWorld - sourceLegCenterWorld; + val.y = 0f; + foreach (Transform item in upperLegSet) + { + if (!((Object)(object)item == (Object)null)) + { + item.position += val; + } + } + } - public RegionStats ComputeLegRegionStats(Transform avatarTransform, IReadOnlyList avatarBakedBodyMeshes, Dictionary> avatarBoneMap, bool isLeft) - { - //IL_00bc: Unknown result type (might be due to invalid IL or missing references) - //IL_00c2: Unknown result type (might be due to invalid IL or missing references) - //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_00d0: Unknown result type (might be due to invalid IL or missing references) - //IL_00d5: Unknown result type (might be due to invalid IL or missing references) - //IL_00de: 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_00e5: Unknown result type (might be due to invalid IL or missing references) - //IL_00e7: Unknown result type (might be due to invalid IL or missing references) - //IL_0100: Unknown result type (might be due to invalid IL or missing references) - //IL_0102: Unknown result type (might be due to invalid IL or missing references) - //IL_00f5: Unknown result type (might be due to invalid IL or missing references) - //IL_00f7: Unknown result type (might be due to invalid IL or missing references) - //IL_00fc: Unknown result type (might be due to invalid IL or missing references) - HumanBodyBones[] targetHumanBones = (HumanBodyBones[])(object)((!isLeft) ? new HumanBodyBones[2] - { - (HumanBodyBones)2, - (HumanBodyBones)4 - } : new HumanBodyBones[2] - { - (HumanBodyBones)1, - (HumanBodyBones)3 - }); - List list = poseMatchCommonUtil.CollectHumanoidVerticesWorld(targetHumanBones, avatarBakedBodyMeshes, avatarBoneMap); - if (list == null || list.Count == 0) - { - Debug.LogWarning((object)$"[BodyPoseMatch_Leg] ComputeLegRegionStats: leg vertices 0개. avatar={((avatarTransform != null) ? ((Object)avatarTransform).name : null)}, isLeft={isLeft}"); - return default(RegionStats); - } - RegionStats result = new PcaUtil().ComputeRegionStats(list); - Transform boneFromBoneMap = poseMatchCommonUtil.GetBoneFromBoneMap(avatarBoneMap, (HumanBodyBones)(isLeft ? 1 : 2)); - Transform boneFromBoneMap2 = poseMatchCommonUtil.GetBoneFromBoneMap(avatarBoneMap, (HumanBodyBones)(isLeft ? 3 : 4)); - if ((Object)(object)boneFromBoneMap != (Object)null && (Object)(object)boneFromBoneMap2 != (Object)null) - { - Vector3 val = boneFromBoneMap2.position - boneFromBoneMap.position; - Vector3 normalized = ((Vector3)(ref val)).normalized; - Vector3 val2 = ((Vector3)(ref result.principalAxis)).normalized; - if (Vector3.Dot(val2, normalized) < 0f) - { - val2 = -val2; - } - result.principalAxis = val2; - } - return result; - } + public RegionStats ComputeLegRegionStats(Transform avatarTransform, IReadOnlyList avatarBakedBodyMeshes, Dictionary> avatarBoneMap, bool isLeft) + { + //IL_00bc: Unknown result type (might be due to invalid IL or missing references) + //IL_00c2: Unknown result type (might be due to invalid IL or missing references) + //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_00d0: Unknown result type (might be due to invalid IL or missing references) + //IL_00d5: Unknown result type (might be due to invalid IL or missing references) + //IL_00de: 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_00e5: Unknown result type (might be due to invalid IL or missing references) + //IL_00e7: Unknown result type (might be due to invalid IL or missing references) + //IL_0100: Unknown result type (might be due to invalid IL or missing references) + //IL_0102: Unknown result type (might be due to invalid IL or missing references) + //IL_00f5: Unknown result type (might be due to invalid IL or missing references) + //IL_00f7: Unknown result type (might be due to invalid IL or missing references) + //IL_00fc: Unknown result type (might be due to invalid IL or missing references) + HumanBodyBones[] targetHumanBones = (HumanBodyBones[])(object)((!isLeft) ? new HumanBodyBones[2] + { + (HumanBodyBones)2, + (HumanBodyBones)4 + } : new HumanBodyBones[2] + { + (HumanBodyBones)1, + (HumanBodyBones)3 + }); + List list = this.poseMatchCommonUtil.CollectHumanoidVerticesWorld(targetHumanBones, avatarBakedBodyMeshes, avatarBoneMap); + if (list == null || list.Count == 0) + { + Debug.LogWarning((object)$"[BodyPoseMatch_Leg] ComputeLegRegionStats: leg vertices 0개. avatar={((avatarTransform != null) ? ((Object)avatarTransform).name : null)}, isLeft={isLeft}"); + return default(RegionStats); + } + RegionStats result = new PcaUtil().ComputeRegionStats(list); + Transform boneFromBoneMap = this.poseMatchCommonUtil.GetBoneFromBoneMap(avatarBoneMap, (HumanBodyBones)(isLeft ? 1 : 2)); + Transform boneFromBoneMap2 = this.poseMatchCommonUtil.GetBoneFromBoneMap(avatarBoneMap, (HumanBodyBones)(isLeft ? 3 : 4)); + if ((Object)(object)boneFromBoneMap != (Object)null && (Object)(object)boneFromBoneMap2 != (Object)null) + { + Vector3 val = boneFromBoneMap2.position - boneFromBoneMap.position; + Vector3 normalized = val.normalized; + Vector3 val2 = result.principalAxis.normalized; + if (Vector3.Dot(val2, normalized) < 0f) + { + val2 = -val2; + } + result.principalAxis = val2; + } + return result; + } - public void ScalingBothLegsAndFoots(GameObject proxyObject, IReadOnlyList proxyBakedBodyMeshes, Dictionary> proxyBoneMap, GameObject targetObject, IReadOnlyList targetBakedBodyMeshes, Dictionary> targetBoneMap, bool autoDetectAxis = true, int forceAxisIndex = 1) - { - ScalingLeg(proxyBoneMap, targetBoneMap, isLeft: true, autoDetectAxis, forceAxisIndex); - ScalingLeg(proxyBoneMap, targetBoneMap, isLeft: false, autoDetectAxis, forceAxisIndex); - if (proxyBakedBodyMeshes != null) - { - foreach (BakedBodyMesh proxyBakedBodyMesh in proxyBakedBodyMeshes) - { - proxyBakedBodyMesh?.ReBakeMesh(); - } - } - ScalingFoot(proxyObject, proxyBakedBodyMeshes, proxyBoneMap, targetObject, targetBakedBodyMeshes, targetBoneMap, isLeft: true); - ScalingFoot(proxyObject, proxyBakedBodyMeshes, proxyBoneMap, targetObject, targetBakedBodyMeshes, targetBoneMap, isLeft: false); - } + public void ScalingBothLegsAndFoots(GameObject proxyObject, IReadOnlyList proxyBakedBodyMeshes, Dictionary> proxyBoneMap, GameObject targetObject, IReadOnlyList targetBakedBodyMeshes, Dictionary> targetBoneMap, bool autoDetectAxis = true, int forceAxisIndex = 1) + { + this.ScalingLeg(proxyBoneMap, targetBoneMap, isLeft: true, autoDetectAxis, forceAxisIndex); + this.ScalingLeg(proxyBoneMap, targetBoneMap, isLeft: false, autoDetectAxis, forceAxisIndex); + if (proxyBakedBodyMeshes != null) + { + foreach (BakedBodyMesh proxyBakedBodyMesh in proxyBakedBodyMeshes) + { + proxyBakedBodyMesh?.ReBakeMesh(); + } + } + this.ScalingFoot(proxyObject, proxyBakedBodyMeshes, proxyBoneMap, targetObject, targetBakedBodyMeshes, targetBoneMap, isLeft: true); + this.ScalingFoot(proxyObject, proxyBakedBodyMeshes, proxyBoneMap, targetObject, targetBakedBodyMeshes, targetBoneMap, isLeft: false); + } - public void ScalingBothLegsAndFoots(Transform targetTransform, IReadOnlyList targetBakedBodyMeshes, Dictionary> targetBoneMap, Transform clothTransform, Dictionary> clothBoneMap, ProfileData profileData, Vector3 comprehensiveScale, bool autoDetectAxis = true, int forceAxisIndex = 1) - { - //IL_001f: Unknown result type (might be due to invalid IL or missing references) - //IL_002f: Unknown result type (might be due to invalid IL or missing references) - ScalingLeg(clothBoneMap, targetBoneMap, isLeft: true, autoDetectAxis, forceAxisIndex); - ScalingLeg(clothBoneMap, targetBoneMap, isLeft: false, autoDetectAxis, forceAxisIndex); - ScalingFoot(profileData, comprehensiveScale, clothBoneMap, targetTransform, targetBakedBodyMeshes, targetBoneMap, isLeft: true); - ScalingFoot(profileData, comprehensiveScale, clothBoneMap, targetTransform, targetBakedBodyMeshes, targetBoneMap, isLeft: false); - } + public void ScalingBothLegsAndFoots(Transform targetTransform, IReadOnlyList targetBakedBodyMeshes, Dictionary> targetBoneMap, Transform clothTransform, Dictionary> clothBoneMap, ProfileData profileData, Vector3 comprehensiveScale, bool autoDetectAxis = true, int forceAxisIndex = 1) + { + //IL_001f: Unknown result type (might be due to invalid IL or missing references) + //IL_002f: Unknown result type (might be due to invalid IL or missing references) + this.ScalingLeg(clothBoneMap, targetBoneMap, isLeft: true, autoDetectAxis, forceAxisIndex); + this.ScalingLeg(clothBoneMap, targetBoneMap, isLeft: false, autoDetectAxis, forceAxisIndex); + this.ScalingFoot(profileData, comprehensiveScale, clothBoneMap, targetTransform, targetBakedBodyMeshes, targetBoneMap, isLeft: true); + this.ScalingFoot(profileData, comprehensiveScale, clothBoneMap, targetTransform, targetBakedBodyMeshes, targetBoneMap, isLeft: false); + } - public void ScalingLeg(Dictionary> proxyBoneMap, Dictionary> targetBoneMap, bool isLeft, bool autoDetectAxis = true, int forceAxisIndex = 1) - { - //IL_0007: Unknown result type (might be due to invalid IL or missing references) - //IL_000f: Unknown result type (might be due to invalid IL or missing references) - //IL_0017: Unknown result type (might be due to invalid IL or missing references) - //IL_0025: Unknown result type (might be due to invalid IL or missing references) - //IL_0033: Unknown result type (might be due to invalid IL or missing references) - //IL_0042: Unknown result type (might be due to invalid IL or missing references) - //IL_007f: Unknown result type (might be due to invalid IL or missing references) - //IL_00bf: Unknown result type (might be due to invalid IL or missing references) - //IL_00c8: 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_0102: Unknown result type (might be due to invalid IL or missing references) - //IL_0110: Unknown result type (might be due to invalid IL or missing references) - //IL_0144: Unknown result type (might be due to invalid IL or missing references) - //IL_017e: Unknown result type (might be due to invalid IL or missing references) - //IL_0183: Unknown result type (might be due to invalid IL or missing references) - //IL_0185: Unknown result type (might be due to invalid IL or missing references) - HumanBodyBones val = (HumanBodyBones)(isLeft ? 1 : 2); - HumanBodyBones bone = (HumanBodyBones)(isLeft ? 3 : 4); - Transform boneFromBoneMap = poseMatchCommonUtil.GetBoneFromBoneMap(proxyBoneMap, val); - Transform boneFromBoneMap2 = poseMatchCommonUtil.GetBoneFromBoneMap(proxyBoneMap, bone); - Transform boneFromBoneMap3 = poseMatchCommonUtil.GetBoneFromBoneMap(targetBoneMap, val); - Transform boneFromBoneMap4 = poseMatchCommonUtil.GetBoneFromBoneMap(targetBoneMap, bone); - if ((Object)(object)boneFromBoneMap == (Object)null || (Object)(object)boneFromBoneMap2 == (Object)null || (Object)(object)boneFromBoneMap3 == (Object)null || (Object)(object)boneFromBoneMap4 == (Object)null) - { - Debug.LogWarning((object)"[AvatarBodyMatchUtil] ScalingLeg: some leg bones are null"); - return; - } - if (proxyBoneMap == null || !proxyBoneMap.TryGetValue(val, out var value) || value == null || value.Count == 0) - { - Debug.LogWarning((object)"[AvatarBodyMatchUtil] ScalingLeg: proxy upperLeg bone set missing"); - return; - } - poseMatchCommonUtil.BoneLengthAdjust(boneFromBoneMap, boneFromBoneMap2, boneFromBoneMap3, boneFromBoneMap4, value, autoDetectAxis, forceAxisIndex); - HumanBodyBones val2 = (HumanBodyBones)(isLeft ? 5 : 6); - Transform boneFromBoneMap5 = poseMatchCommonUtil.GetBoneFromBoneMap(proxyBoneMap, val2); - Transform boneFromBoneMap6 = poseMatchCommonUtil.GetBoneFromBoneMap(targetBoneMap, val2); - if ((Object)(object)boneFromBoneMap5 == (Object)null || (Object)(object)boneFromBoneMap6 == (Object)null) - { - Debug.LogWarning((object)"[AvatarBodyMatchUtil] ScalingFoot: proxyFoot or targetFoot is null"); - return; - } - float y = boneFromBoneMap5.position.y; - float num = boneFromBoneMap6.position.y - y; - if (!(Mathf.Abs(num) > 1E-06f)) - { - return; - } - Vector3 val3 = default(Vector3); - ((Vector3)(ref val3))._002Ector(0f, num, 0f); - if (proxyBoneMap == null || !proxyBoneMap.TryGetValue(val2, out var value2) || value2 == null || value2.Count <= 0) - { - return; - } - foreach (Transform item in value2) - { - if (!((Object)(object)item == (Object)null)) - { - item.position += val3; - } - } - } + public void ScalingLeg(Dictionary> proxyBoneMap, Dictionary> targetBoneMap, bool isLeft, bool autoDetectAxis = true, int forceAxisIndex = 1) + { + //IL_0007: Unknown result type (might be due to invalid IL or missing references) + //IL_000f: Unknown result type (might be due to invalid IL or missing references) + //IL_0017: Unknown result type (might be due to invalid IL or missing references) + //IL_0025: Unknown result type (might be due to invalid IL or missing references) + //IL_0033: Unknown result type (might be due to invalid IL or missing references) + //IL_0042: Unknown result type (might be due to invalid IL or missing references) + //IL_007f: Unknown result type (might be due to invalid IL or missing references) + //IL_00bf: Unknown result type (might be due to invalid IL or missing references) + //IL_00c8: 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_0102: Unknown result type (might be due to invalid IL or missing references) + //IL_0110: Unknown result type (might be due to invalid IL or missing references) + //IL_0144: Unknown result type (might be due to invalid IL or missing references) + //IL_017e: Unknown result type (might be due to invalid IL or missing references) + //IL_0183: Unknown result type (might be due to invalid IL or missing references) + //IL_0185: Unknown result type (might be due to invalid IL or missing references) + HumanBodyBones val = (HumanBodyBones)(isLeft ? 1 : 2); + HumanBodyBones bone = (HumanBodyBones)(isLeft ? 3 : 4); + Transform boneFromBoneMap = this.poseMatchCommonUtil.GetBoneFromBoneMap(proxyBoneMap, val); + Transform boneFromBoneMap2 = this.poseMatchCommonUtil.GetBoneFromBoneMap(proxyBoneMap, bone); + Transform boneFromBoneMap3 = this.poseMatchCommonUtil.GetBoneFromBoneMap(targetBoneMap, val); + Transform boneFromBoneMap4 = this.poseMatchCommonUtil.GetBoneFromBoneMap(targetBoneMap, bone); + if ((Object)(object)boneFromBoneMap == (Object)null || (Object)(object)boneFromBoneMap2 == (Object)null || (Object)(object)boneFromBoneMap3 == (Object)null || (Object)(object)boneFromBoneMap4 == (Object)null) + { + Debug.LogWarning((object)"[AvatarBodyMatchUtil] ScalingLeg: some leg bones are null"); + return; + } + if (proxyBoneMap == null || !proxyBoneMap.TryGetValue(val, out var value) || value == null || value.Count == 0) + { + Debug.LogWarning((object)"[AvatarBodyMatchUtil] ScalingLeg: proxy upperLeg bone set missing"); + return; + } + this.poseMatchCommonUtil.BoneLengthAdjust(boneFromBoneMap, boneFromBoneMap2, boneFromBoneMap3, boneFromBoneMap4, value, autoDetectAxis, forceAxisIndex); + HumanBodyBones val2 = (HumanBodyBones)(isLeft ? 5 : 6); + Transform boneFromBoneMap5 = this.poseMatchCommonUtil.GetBoneFromBoneMap(proxyBoneMap, val2); + Transform boneFromBoneMap6 = this.poseMatchCommonUtil.GetBoneFromBoneMap(targetBoneMap, val2); + if ((Object)(object)boneFromBoneMap5 == (Object)null || (Object)(object)boneFromBoneMap6 == (Object)null) + { + Debug.LogWarning((object)"[AvatarBodyMatchUtil] ScalingFoot: proxyFoot or targetFoot is null"); + return; + } + float y = boneFromBoneMap5.position.y; + float num = boneFromBoneMap6.position.y - y; + if (!(Mathf.Abs(num) > 1E-06f)) + { + return; + } + Vector3 val3 = new Vector3(0f, num, 0f); + if (proxyBoneMap == null || !proxyBoneMap.TryGetValue(val2, out var value2) || value2 == null || value2.Count <= 0) + { + return; + } + foreach (Transform item in value2) + { + if (!((Object)(object)item == (Object)null)) + { + item.position += val3; + } + } + } - private void ScalingFootCore(Transform proxyHip, Transform targetFoot, bool isLeft, HashSet footBoneSet, float proxyToeF, float proxyHeelF, float proxySideMin, float proxySideMax, float proxySoleY, float targetToeF, float targetHeelF, float targetSideMin, float targetSideMax, float targetSoleY) - { - //IL_0109: Unknown result type (might be due to invalid IL or missing references) - //IL_010e: Unknown result type (might be due to invalid IL or missing references) - //IL_0115: 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_0136: 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_0154: Unknown result type (might be due to invalid IL or missing references) - //IL_0188: Unknown result type (might be due to invalid IL or missing references) - //IL_018e: Unknown result type (might be due to invalid IL or missing references) - if ((Object)(object)proxyHip == (Object)null || (Object)(object)targetFoot == (Object)null) - { - Debug.LogWarning((object)"[BodyPoseMatch_Leg] ScalingFootCore: proxyHip or targetFoot is null"); - return; - } - if (footBoneSet == null || footBoneSet.Count == 0) - { - Debug.LogWarning((object)"[BodyPoseMatch_Leg] ScalingFootCore: footBoneSet is null or empty"); - return; - } - Dictionary> dictionary = new Dictionary>(); - foreach (Transform item in footBoneSet) - { - if (!((Object)(object)item == (Object)null)) - { - Transform parent = item.parent; - if (!dictionary.TryGetValue(parent, out var value)) - { - value = new List(); - dictionary.Add(parent, value); - } - value.Add(item); - } - } - foreach (KeyValuePair> item2 in dictionary) - { - Transform key = item2.Key; - List value2 = item2.Value; - if ((Object)(object)key == (Object)null || value2 == null || value2.Count == 0) - { - continue; - } - Transform val = value2[0]; - if (!((Object)(object)val == (Object)null)) - { - TempBoneMarker tempBoneMarker; - Transform val2 = poseMatchCommonUtil.CreateTempMarker("scaleSupportBone", key, value2, val.position, Quaternion.identity, val.localScale, out tempBoneMarker); - if (!((Object)(object)val2 == (Object)null)) - { - ScaleAndAlignAlongAxis(proxyHip, proxyHip.forward, proxyHip.up, val2, proxyToeF, proxyHeelF, targetFoot, targetToeF, targetHeelF); - ScaleAndAlignAlongAxis(proxyHip, proxyHip.right, proxyHip.up, val2, isLeft ? proxySideMin : proxySideMax, isLeft ? proxySideMax : proxySideMin, targetFoot, isLeft ? targetSideMin : targetSideMax, isLeft ? targetSideMax : targetSideMin); - ScaleAndAlignAlongAxis(proxyHip, proxyHip.up, proxyHip.forward, val2, 0f, proxySoleY, targetFoot, 0f, targetSoleY); - } - } - } - } + private void ScalingFootCore(Transform proxyHip, Transform targetFoot, bool isLeft, HashSet footBoneSet, float proxyToeF, float proxyHeelF, float proxySideMin, float proxySideMax, float proxySoleY, float targetToeF, float targetHeelF, float targetSideMin, float targetSideMax, float targetSoleY) + { + //IL_0109: Unknown result type (might be due to invalid IL or missing references) + //IL_010e: Unknown result type (might be due to invalid IL or missing references) + //IL_0115: 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_0136: 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_0154: Unknown result type (might be due to invalid IL or missing references) + //IL_0188: Unknown result type (might be due to invalid IL or missing references) + //IL_018e: Unknown result type (might be due to invalid IL or missing references) + if ((Object)(object)proxyHip == (Object)null || (Object)(object)targetFoot == (Object)null) + { + Debug.LogWarning((object)"[BodyPoseMatch_Leg] ScalingFootCore: proxyHip or targetFoot is null"); + return; + } + if (footBoneSet == null || footBoneSet.Count == 0) + { + Debug.LogWarning((object)"[BodyPoseMatch_Leg] ScalingFootCore: footBoneSet is null or empty"); + return; + } + Dictionary> dictionary = new Dictionary>(); + foreach (Transform item in footBoneSet) + { + if (!((Object)(object)item == (Object)null)) + { + Transform parent = item.parent; + if (!dictionary.TryGetValue(parent, out var value)) + { + value = new List(); + dictionary.Add(parent, value); + } + value.Add(item); + } + } + foreach (KeyValuePair> item2 in dictionary) + { + Transform key = item2.Key; + List value2 = item2.Value; + if ((Object)(object)key == (Object)null || value2 == null || value2.Count == 0) + { + continue; + } + Transform val = value2[0]; + if (!((Object)(object)val == (Object)null)) + { + TempBoneMarker tempBoneMarker; + Transform val2 = this.poseMatchCommonUtil.CreateTempMarker("scaleSupportBone", key, value2, val.position, Quaternion.identity, val.localScale, out tempBoneMarker); + if (!((Object)(object)val2 == (Object)null)) + { + this.ScaleAndAlignAlongAxis(proxyHip, proxyHip.forward, proxyHip.up, val2, proxyToeF, proxyHeelF, targetFoot, targetToeF, targetHeelF); + this.ScaleAndAlignAlongAxis(proxyHip, proxyHip.right, proxyHip.up, val2, isLeft ? proxySideMin : proxySideMax, isLeft ? proxySideMax : proxySideMin, targetFoot, isLeft ? targetSideMin : targetSideMax, isLeft ? targetSideMax : targetSideMin); + this.ScaleAndAlignAlongAxis(proxyHip, proxyHip.up, proxyHip.forward, val2, 0f, proxySoleY, targetFoot, 0f, targetSoleY); + } + } + } + } - public void ScalingFoot(GameObject proxyObject, IReadOnlyList proxyBakedBodyMeshes, Dictionary> proxyBoneMap, GameObject targetObject, IReadOnlyList targetBakedBodyMeshes, Dictionary> targetBoneMap, bool isLeft) - { - //IL_002b: Unknown result type (might be due to invalid IL or missing references) - //IL_0033: Unknown result type (might be due to invalid IL or missing references) - //IL_0041: Unknown result type (might be due to invalid IL or missing references) - //IL_00e2: Unknown result type (might be due to invalid IL or missing references) - if ((Object)(object)proxyObject == (Object)null || (Object)(object)targetObject == (Object)null) - { - throw new AutoMorpherException("Proxy or Target Object is Missing", "[BodyPoseMatch_Leg] ScalingFoot\n - proxyObject or targetObject is null"); - } - HumanBodyBones val = (HumanBodyBones)(isLeft ? 5 : 6); - Transform boneFromBoneMap = poseMatchCommonUtil.GetBoneFromBoneMap(proxyBoneMap, val); - Transform boneFromBoneMap2 = poseMatchCommonUtil.GetBoneFromBoneMap(targetBoneMap, val); - if ((Object)(object)boneFromBoneMap == (Object)null || (Object)(object)boneFromBoneMap2 == (Object)null) - { - Debug.LogWarning((object)"[AvatarBodyMatchUtil] ScalingFoot: proxyFoot or targetFoot is null"); - return; - } - if (!TryGetFootSpatialData(proxyObject.transform, proxyBakedBodyMeshes, proxyBoneMap, isLeft, out var _, out var footMinUp, out var heelF, out var toeF, out var sideMin, out var sideMax) || !TryGetFootSpatialData(targetObject.transform, targetBakedBodyMeshes, targetBoneMap, isLeft, out var _, out var footMinUp2, out var heelF2, out var toeF2, out var sideMin2, out var sideMax2)) - { - Debug.LogWarning((object)"[AvatarBodyMatchUtil] ScalingFoot: foot spatial data 계산 실패"); - return; - } - Transform boneFromBoneMap3 = poseMatchCommonUtil.GetBoneFromBoneMap(proxyBoneMap, (HumanBodyBones)0); - HashSet value; - if ((Object)(object)boneFromBoneMap3 == (Object)null) - { - Debug.LogWarning((object)"[BodyPoseMatch_Leg] ScalingFoot: proxyHip is null"); - } - else if (proxyBoneMap == null || !proxyBoneMap.TryGetValue(val, out value) || value == null || value.Count == 0) - { - Debug.LogWarning((object)"[BodyPoseMatch_Leg] ScalingFoot: footBoneSet is missing"); - } - else - { - ScalingFootCore(boneFromBoneMap3, boneFromBoneMap2, isLeft, value, toeF, heelF, sideMin, sideMax, footMinUp, toeF2, heelF2, sideMin2, sideMax2, footMinUp2); - } - } + public void ScalingFoot(GameObject proxyObject, IReadOnlyList proxyBakedBodyMeshes, Dictionary> proxyBoneMap, GameObject targetObject, IReadOnlyList targetBakedBodyMeshes, Dictionary> targetBoneMap, bool isLeft) + { + //IL_002b: Unknown result type (might be due to invalid IL or missing references) + //IL_0033: Unknown result type (might be due to invalid IL or missing references) + //IL_0041: Unknown result type (might be due to invalid IL or missing references) + //IL_00e2: Unknown result type (might be due to invalid IL or missing references) + if ((Object)(object)proxyObject == (Object)null || (Object)(object)targetObject == (Object)null) + { + throw new AutoMorpherException("Proxy or Target Object is Missing", "[BodyPoseMatch_Leg] ScalingFoot\n - proxyObject or targetObject is null"); + } + HumanBodyBones val = (HumanBodyBones)(isLeft ? 5 : 6); + Transform boneFromBoneMap = this.poseMatchCommonUtil.GetBoneFromBoneMap(proxyBoneMap, val); + Transform boneFromBoneMap2 = this.poseMatchCommonUtil.GetBoneFromBoneMap(targetBoneMap, val); + if ((Object)(object)boneFromBoneMap == (Object)null || (Object)(object)boneFromBoneMap2 == (Object)null) + { + Debug.LogWarning((object)"[AvatarBodyMatchUtil] ScalingFoot: proxyFoot or targetFoot is null"); + return; + } + if (!this.TryGetFootSpatialData(proxyObject.transform, proxyBakedBodyMeshes, proxyBoneMap, isLeft, out var _, out var footMinUp, out var heelF, out var toeF, out var sideMin, out var sideMax) || !this.TryGetFootSpatialData(targetObject.transform, targetBakedBodyMeshes, targetBoneMap, isLeft, out var _, out var footMinUp2, out var heelF2, out var toeF2, out var sideMin2, out var sideMax2)) + { + Debug.LogWarning((object)"[AvatarBodyMatchUtil] ScalingFoot: foot spatial data 계산 실패"); + return; + } + Transform boneFromBoneMap3 = this.poseMatchCommonUtil.GetBoneFromBoneMap(proxyBoneMap, (HumanBodyBones)0); + HashSet value; + if ((Object)(object)boneFromBoneMap3 == (Object)null) + { + Debug.LogWarning((object)"[BodyPoseMatch_Leg] ScalingFoot: proxyHip is null"); + } + else if (proxyBoneMap == null || !proxyBoneMap.TryGetValue(val, out value) || value == null || value.Count == 0) + { + Debug.LogWarning((object)"[BodyPoseMatch_Leg] ScalingFoot: footBoneSet is missing"); + } + else + { + this.ScalingFootCore(boneFromBoneMap3, boneFromBoneMap2, isLeft, value, toeF, heelF, sideMin, sideMax, footMinUp, toeF2, heelF2, sideMin2, sideMax2, footMinUp2); + } + } - public void ScalingFoot(ProfileData profileData, Vector3 comprehensiveScale, Dictionary> clothBoneMap, Transform targetTransform, IReadOnlyList targetBakedBodyMeshes, Dictionary> targetBoneMap, bool isLeft) - { - //IL_0022: Unknown result type (might be due to invalid IL or missing references) - //IL_002a: Unknown result type (might be due to invalid IL or missing references) - //IL_0038: Unknown result type (might be due to invalid IL or missing references) - //IL_00c8: 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_00fd: Unknown result type (might be due to invalid IL or missing references) - //IL_00fe: Unknown result type (might be due to invalid IL or missing references) - //IL_010c: Unknown result type (might be due to invalid IL or missing references) - //IL_0117: 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_0127: Unknown result type (might be due to invalid IL or missing references) - //IL_0132: Unknown result type (might be due to invalid IL or missing references) - //IL_0133: Unknown result type (might be due to invalid IL or missing references) - //IL_0141: Unknown result type (might be due to invalid IL or missing references) - //IL_014c: 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_015c: Unknown result type (might be due to invalid IL or missing references) - //IL_0167: 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_0179: Unknown result type (might be due to invalid IL or missing references) - if ((Object)(object)targetTransform == (Object)null) - { - throw new AutoMorpherException("Target Transform is Missing", "[BodyPoseMatch_Leg] ScalingFoot\n - targetTransform is null"); - } - HumanBodyBones val = (HumanBodyBones)(isLeft ? 5 : 6); - Transform boneFromBoneMap = poseMatchCommonUtil.GetBoneFromBoneMap(clothBoneMap, val); - Transform boneFromBoneMap2 = poseMatchCommonUtil.GetBoneFromBoneMap(targetBoneMap, val); - if ((Object)(object)boneFromBoneMap == (Object)null || (Object)(object)boneFromBoneMap2 == (Object)null) - { - Debug.LogWarning((object)"[AvatarBodyMatchUtil] ScalingFoot: proxyFoot or targetFoot is null"); - return; - } - if (!TryGetFootSpatialData(((Component)targetTransform).transform, targetBakedBodyMeshes, targetBoneMap, isLeft, out var _, out var footMinUp, out var heelF, out var toeF, out var sideMin, out var sideMax)) - { - Debug.LogWarning((object)"[AvatarBodyMatchUtil] ScalingFoot: foot spatial data 계산 실패"); - return; - } - Transform boneFromBoneMap3 = poseMatchCommonUtil.GetBoneFromBoneMap(clothBoneMap, (HumanBodyBones)0); - BoneSpatialData val2 = (isLeft ? profileData.LeftFootSpatialData : profileData.RightFootSpatialData); - if (val2 == null) - { - Debug.LogWarning((object)"[AvatarBodyMatchUtil] AlignNeckCenterByPcaWithHipZ: Profile FootSpatialData Data is Not exist."); - return; - } - Transform boneFromBoneMap4 = poseMatchCommonUtil.GetBoneFromBoneMap(clothBoneMap, val2.refBone); - if ((Object)(object)boneFromBoneMap4 == (Object)null) - { - Debug.LogWarning((object)"[BodyPoseMatch_Leg] ScalingFoot: clothRefBone is null"); - return; - } - BodyPoseMatch_CommonUtil bodyPoseMatch_CommonUtil = new BodyPoseMatch_CommonUtil(); - float proxyToeF = Vector3.Distance(boneFromBoneMap4.position, bodyPoseMatch_CommonUtil.GetProfileVolumeMaxWorld(clothBoneMap, val2, 0, comprehensiveScale)); - float proxyHeelF = 0f - Vector3.Distance(boneFromBoneMap4.position, bodyPoseMatch_CommonUtil.GetProfileVolumeMinWorld(clothBoneMap, val2, 0, comprehensiveScale)); - float proxySideMax = Vector3.Distance(boneFromBoneMap4.position, bodyPoseMatch_CommonUtil.GetProfileVolumeMaxWorld(clothBoneMap, val2, 1, comprehensiveScale)); - float proxySideMin = 0f - Vector3.Distance(boneFromBoneMap4.position, bodyPoseMatch_CommonUtil.GetProfileVolumeMinWorld(clothBoneMap, val2, 1, comprehensiveScale)); - float proxySoleY = 0f - Vector3.Distance(boneFromBoneMap4.position, bodyPoseMatch_CommonUtil.GetProfileVolumeMinWorld(clothBoneMap, val2, 2, comprehensiveScale)); - if (clothBoneMap == null || !clothBoneMap.TryGetValue(val, out var value) || value == null || value.Count == 0) - { - Debug.LogWarning((object)"[BodyPoseMatch_Leg] ScalingFoot: cloth footBoneSet is missing"); - } - else - { - ScalingFootCore(boneFromBoneMap3, boneFromBoneMap2, isLeft, value, proxyToeF, proxyHeelF, proxySideMin, proxySideMax, proxySoleY, toeF, heelF, sideMin, sideMax, footMinUp); - } - } + public void ScalingFoot(ProfileData profileData, Vector3 comprehensiveScale, Dictionary> clothBoneMap, Transform targetTransform, IReadOnlyList targetBakedBodyMeshes, Dictionary> targetBoneMap, bool isLeft) + { + //IL_0022: Unknown result type (might be due to invalid IL or missing references) + //IL_002a: Unknown result type (might be due to invalid IL or missing references) + //IL_0038: Unknown result type (might be due to invalid IL or missing references) + //IL_00c8: 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_00fd: Unknown result type (might be due to invalid IL or missing references) + //IL_00fe: Unknown result type (might be due to invalid IL or missing references) + //IL_010c: Unknown result type (might be due to invalid IL or missing references) + //IL_0117: 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_0127: Unknown result type (might be due to invalid IL or missing references) + //IL_0132: Unknown result type (might be due to invalid IL or missing references) + //IL_0133: Unknown result type (might be due to invalid IL or missing references) + //IL_0141: Unknown result type (might be due to invalid IL or missing references) + //IL_014c: 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_015c: Unknown result type (might be due to invalid IL or missing references) + //IL_0167: 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_0179: Unknown result type (might be due to invalid IL or missing references) + if ((Object)(object)targetTransform == (Object)null) + { + throw new AutoMorpherException("Target Transform is Missing", "[BodyPoseMatch_Leg] ScalingFoot\n - targetTransform is null"); + } + HumanBodyBones val = (HumanBodyBones)(isLeft ? 5 : 6); + Transform boneFromBoneMap = this.poseMatchCommonUtil.GetBoneFromBoneMap(clothBoneMap, val); + Transform boneFromBoneMap2 = this.poseMatchCommonUtil.GetBoneFromBoneMap(targetBoneMap, val); + if ((Object)(object)boneFromBoneMap == (Object)null || (Object)(object)boneFromBoneMap2 == (Object)null) + { + Debug.LogWarning((object)"[AvatarBodyMatchUtil] ScalingFoot: proxyFoot or targetFoot is null"); + return; + } + if (!this.TryGetFootSpatialData(((Component)targetTransform).transform, targetBakedBodyMeshes, targetBoneMap, isLeft, out var _, out var footMinUp, out var heelF, out var toeF, out var sideMin, out var sideMax)) + { + Debug.LogWarning((object)"[AvatarBodyMatchUtil] ScalingFoot: foot spatial data 계산 실패"); + return; + } + Transform boneFromBoneMap3 = this.poseMatchCommonUtil.GetBoneFromBoneMap(clothBoneMap, (HumanBodyBones)0); + BoneSpatialData val2 = (isLeft ? profileData.LeftFootSpatialData : profileData.RightFootSpatialData); + if (val2 == null) + { + Debug.LogWarning((object)"[AvatarBodyMatchUtil] AlignNeckCenterByPcaWithHipZ: Profile FootSpatialData Data is Not exist."); + return; + } + Transform boneFromBoneMap4 = this.poseMatchCommonUtil.GetBoneFromBoneMap(clothBoneMap, val2.refBone); + if ((Object)(object)boneFromBoneMap4 == (Object)null) + { + Debug.LogWarning((object)"[BodyPoseMatch_Leg] ScalingFoot: clothRefBone is null"); + return; + } + BodyPoseMatch_CommonUtil bodyPoseMatch_CommonUtil = new BodyPoseMatch_CommonUtil(); + float proxyToeF = Vector3.Distance(boneFromBoneMap4.position, bodyPoseMatch_CommonUtil.GetProfileVolumeMaxWorld(clothBoneMap, val2, 0, comprehensiveScale)); + float proxyHeelF = 0f - Vector3.Distance(boneFromBoneMap4.position, bodyPoseMatch_CommonUtil.GetProfileVolumeMinWorld(clothBoneMap, val2, 0, comprehensiveScale)); + float proxySideMax = Vector3.Distance(boneFromBoneMap4.position, bodyPoseMatch_CommonUtil.GetProfileVolumeMaxWorld(clothBoneMap, val2, 1, comprehensiveScale)); + float proxySideMin = 0f - Vector3.Distance(boneFromBoneMap4.position, bodyPoseMatch_CommonUtil.GetProfileVolumeMinWorld(clothBoneMap, val2, 1, comprehensiveScale)); + float proxySoleY = 0f - Vector3.Distance(boneFromBoneMap4.position, bodyPoseMatch_CommonUtil.GetProfileVolumeMinWorld(clothBoneMap, val2, 2, comprehensiveScale)); + if (clothBoneMap == null || !clothBoneMap.TryGetValue(val, out var value) || value == null || value.Count == 0) + { + Debug.LogWarning((object)"[BodyPoseMatch_Leg] ScalingFoot: cloth footBoneSet is missing"); + } + else + { + this.ScalingFootCore(boneFromBoneMap3, boneFromBoneMap2, isLeft, value, proxyToeF, proxyHeelF, proxySideMin, proxySideMax, proxySoleY, toeF, heelF, sideMin, sideMax, footMinUp); + } + } - private void ScaleAndAlignAlongAxis(Transform baseTransform, Vector3 targetWorldAxis, Vector3 targetWorldUpAxis, Transform proxyFoot, float proxyMaxF, float proxyMinF, Transform targetFoot, float targetMaxF, float targetMinF) - { - //IL_005d: Unknown result type (might be due to invalid IL or missing references) - //IL_0062: Unknown result type (might be due to invalid IL or missing references) - //IL_0065: Unknown result type (might be due to invalid IL or missing references) - //IL_006a: Unknown result type (might be due to invalid IL or missing references) - //IL_006f: Unknown result type (might be due to invalid IL or missing references) - //IL_0072: Unknown result type (might be due to invalid IL or missing references) - //IL_0077: Unknown result type (might be due to invalid IL or missing references) - //IL_007a: Unknown result type (might be due to invalid IL or missing references) - //IL_007f: Unknown result type (might be due to invalid IL or missing references) - //IL_0084: Unknown result type (might be due to invalid IL or missing references) - //IL_008b: Unknown result type (might be due to invalid IL or missing references) - //IL_0092: Expected O, but got Unknown - //IL_00a7: Unknown result type (might be due to invalid IL or missing references) - //IL_00b2: Unknown result type (might be due to invalid IL or missing references) - //IL_00b7: 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_00ca: Unknown result type (might be due to invalid IL or missing references) - //IL_00dc: Unknown result type (might be due to invalid IL or missing references) - //IL_00e1: 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_00ff: 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_0109: Unknown result type (might be due to invalid IL or missing references) - //IL_010a: Unknown result type (might be due to invalid IL or missing references) - //IL_0120: 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) - //IL_0131: Unknown result type (might be due to invalid IL or missing references) - //IL_0141: 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_015b: 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_016d: Unknown result type (might be due to invalid IL or missing references) - //IL_0172: Unknown result type (might be due to invalid IL or missing references) - //IL_0177: Unknown result type (might be due to invalid IL or missing references) - //IL_017f: Unknown result type (might be due to invalid IL or missing references) - //IL_0182: Unknown result type (might be due to invalid IL or missing references) - //IL_0187: Unknown result type (might be due to invalid IL or missing references) - //IL_018c: Unknown result type (might be due to invalid IL or missing references) - //IL_0191: Unknown result type (might be due to invalid IL or missing references) - //IL_0193: Unknown result type (might be due to invalid IL or missing references) - //IL_01b5: Expected O, but got Unknown - float num = proxyMaxF - proxyMinF; - float num2 = targetMaxF - targetMinF; - if (Mathf.Abs(num) < 0.0001f || Mathf.Abs(num2) < 0.0001f) - { - Debug.LogWarning((object)"[AdjustFootForwardScale] foot span too small."); - return; - } - float num3 = num2 / num; - if (!float.IsFinite(num3) || num3 <= 0f) - { - Debug.LogWarning((object)$"[ScaleAndAlignAlongAxis] invalid scaleF: {num3}"); - return; - } - Vector3 position = proxyFoot.position + targetWorldAxis * proxyMinF; - Vector3 position2 = targetFoot.position + targetWorldAxis * targetMinF; - GameObject val = new GameObject("proxyAnchor"); - val.transform.SetParent(proxyFoot); - val.transform.position = position; - GameObject val2 = new GameObject("targetAnchor"); - val2.transform.SetParent(targetFoot); - val2.transform.position = position2; - Transform parent = proxyFoot.parent; - Vector3 position3 = proxyFoot.position; - Transform transform = new GameObject("ScaleParnet").transform; - transform.SetParent(parent); - transform.position = position3; - transform.rotation = Quaternion.LookRotation(targetWorldAxis, targetWorldUpAxis); - proxyFoot.SetParent(transform, true); - proxyFoot.localPosition = Vector3.zero; - Vector3 localScale = transform.localScale; - localScale.z *= num3; - transform.localScale = localScale; - proxyFoot.SetParent(parent, true); - proxyFoot.position = position3; - float num4 = Vector3.Dot(val2.transform.position - val.transform.position, targetWorldAxis); - Vector3 val3 = targetWorldAxis * num4; - proxyFoot.position += val3; - Object.DestroyImmediate((Object)(object)((Component)transform).gameObject); - Object.DestroyImmediate((Object)(object)val); - Object.DestroyImmediate((Object)val2); - } + private void ScaleAndAlignAlongAxis(Transform baseTransform, Vector3 targetWorldAxis, Vector3 targetWorldUpAxis, Transform proxyFoot, float proxyMaxF, float proxyMinF, Transform targetFoot, float targetMaxF, float targetMinF) + { + //IL_005d: Unknown result type (might be due to invalid IL or missing references) + //IL_0062: Unknown result type (might be due to invalid IL or missing references) + //IL_0065: Unknown result type (might be due to invalid IL or missing references) + //IL_006a: Unknown result type (might be due to invalid IL or missing references) + //IL_006f: Unknown result type (might be due to invalid IL or missing references) + //IL_0072: Unknown result type (might be due to invalid IL or missing references) + //IL_0077: Unknown result type (might be due to invalid IL or missing references) + //IL_007a: Unknown result type (might be due to invalid IL or missing references) + //IL_007f: Unknown result type (might be due to invalid IL or missing references) + //IL_0084: Unknown result type (might be due to invalid IL or missing references) + //IL_008b: Unknown result type (might be due to invalid IL or missing references) + //IL_0092: Expected O, but got Unknown + //IL_00a7: Unknown result type (might be due to invalid IL or missing references) + //IL_00b2: Unknown result type (might be due to invalid IL or missing references) + //IL_00b7: 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_00ca: Unknown result type (might be due to invalid IL or missing references) + //IL_00dc: Unknown result type (might be due to invalid IL or missing references) + //IL_00e1: 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_00ff: 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_0109: Unknown result type (might be due to invalid IL or missing references) + //IL_010a: Unknown result type (might be due to invalid IL or missing references) + //IL_0120: 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) + //IL_0131: Unknown result type (might be due to invalid IL or missing references) + //IL_0141: 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_015b: 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_016d: Unknown result type (might be due to invalid IL or missing references) + //IL_0172: Unknown result type (might be due to invalid IL or missing references) + //IL_0177: Unknown result type (might be due to invalid IL or missing references) + //IL_017f: Unknown result type (might be due to invalid IL or missing references) + //IL_0182: Unknown result type (might be due to invalid IL or missing references) + //IL_0187: Unknown result type (might be due to invalid IL or missing references) + //IL_018c: Unknown result type (might be due to invalid IL or missing references) + //IL_0191: Unknown result type (might be due to invalid IL or missing references) + //IL_0193: Unknown result type (might be due to invalid IL or missing references) + //IL_01b5: Expected O, but got Unknown + float num = proxyMaxF - proxyMinF; + float num2 = targetMaxF - targetMinF; + if (Mathf.Abs(num) < 0.0001f || Mathf.Abs(num2) < 0.0001f) + { + Debug.LogWarning((object)"[AdjustFootForwardScale] foot span too small."); + return; + } + float num3 = num2 / num; + if (!float.IsFinite(num3) || num3 <= 0f) + { + Debug.LogWarning((object)$"[ScaleAndAlignAlongAxis] invalid scaleF: {num3}"); + return; + } + Vector3 position = proxyFoot.position + targetWorldAxis * proxyMinF; + Vector3 position2 = targetFoot.position + targetWorldAxis * targetMinF; + GameObject val = new GameObject("proxyAnchor"); + val.transform.SetParent(proxyFoot); + val.transform.position = position; + GameObject val2 = new GameObject("targetAnchor"); + val2.transform.SetParent(targetFoot); + val2.transform.position = position2; + Transform parent = proxyFoot.parent; + Vector3 position3 = proxyFoot.position; + Transform transform = new GameObject("ScaleParnet").transform; + transform.SetParent(parent); + transform.position = position3; + transform.rotation = Quaternion.LookRotation(targetWorldAxis, targetWorldUpAxis); + proxyFoot.SetParent(transform, true); + proxyFoot.localPosition = Vector3.zero; + Vector3 localScale = transform.localScale; + localScale.z *= num3; + transform.localScale = localScale; + proxyFoot.SetParent(parent, true); + proxyFoot.position = position3; + float num4 = Vector3.Dot(val2.transform.position - val.transform.position, targetWorldAxis); + Vector3 val3 = targetWorldAxis * num4; + proxyFoot.position += val3; + Object.DestroyImmediate((Object)(object)((Component)transform).gameObject); + Object.DestroyImmediate((Object)(object)val); + Object.DestroyImmediate((Object)val2); + } - private bool TryGetFootSpatialData(Transform avatarTransform, IReadOnlyList avatarBakedBodyMeshes, Dictionary> avatarBoneMap, bool isLeft, out float footMaxUp, out float footMinUp, out float heelF, out float toeF, out float sideMin, out float sideMax, float weightThreshold = 0.15f, int sampleStep = 1) - { - //IL_0051: Unknown result type (might be due to invalid IL or missing references) - //IL_0053: Unknown result type (might be due to invalid IL or missing references) - //IL_0074: Unknown result type (might be due to invalid IL or missing references) - //IL_0079: Unknown result type (might be due to invalid IL or missing references) - //IL_007a: Unknown result type (might be due to invalid IL or missing references) - //IL_007f: Unknown result type (might be due to invalid IL or missing references) - //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_017c: Unknown result type (might be due to invalid IL or missing references) - //IL_0183: Unknown result type (might be due to invalid IL or missing references) - //IL_0188: 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_018e: Unknown result type (might be due to invalid IL or missing references) - //IL_01ae: Unknown result type (might be due to invalid IL or missing references) - //IL_01af: Unknown result type (might be due to invalid IL or missing references) - //IL_01cf: Unknown result type (might be due to invalid IL or missing references) - footMaxUp = float.NegativeInfinity; - footMinUp = float.PositiveInfinity; - heelF = float.PositiveInfinity; - toeF = float.NegativeInfinity; - sideMin = float.PositiveInfinity; - sideMax = float.NegativeInfinity; - if ((Object)(object)avatarTransform == (Object)null || avatarBakedBodyMeshes == null || avatarBoneMap == null || avatarBoneMap.Count == 0) - { - return false; - } - HumanBodyBones key = (HumanBodyBones)(isLeft ? 5 : 6); - if (!avatarBoneMap.TryGetValue(key, out var value) || value == null || value.Count == 0) - { - Debug.LogWarning((object)"[BodyPoseMatch_Leg] TryGetFootSpatialData\n - foot bone set is missing"); - return false; - } - Vector3 up = Vector3.up; - Vector3 forward = Vector3.forward; - Vector3 right = Vector3.right; - HashSet hashSet = new HashSet(); - Transform val = null; - foreach (Transform item in value) - { - if ((Object)(object)item == (Object)null) - { - continue; - } - if ((Object)(object)val == (Object)null) - { - val = item; - } - Stack stack = new Stack(); - stack.Push(item); - while (stack.Count > 0) - { - Transform val2 = stack.Pop(); - if (!((Object)(object)val2 == (Object)null) && hashSet.Add(val2)) - { - for (int i = 0; i < val2.childCount; i++) - { - stack.Push(val2.GetChild(i)); - } - } - } - } - if ((Object)(object)val == (Object)null || hashSet.Count == 0) - { - return false; - } - List list = poseMatchCommonUtil.CollectWeightedVerticesWorld(avatarBakedBodyMeshes, hashSet, weightThreshold, sampleStep); - if (list == null || list.Count == 0) - { - return false; - } - for (int j = 0; j < list.Count; j++) - { - Vector3 val3 = list[j] - val.position; - float num = Vector3.Dot(val3, up); - if (num < footMinUp) - { - footMinUp = num; - } - if (num > footMaxUp) - { - footMaxUp = num; - } - float num2 = Vector3.Dot(val3, forward); - if (num2 < heelF) - { - heelF = num2; - } - if (num2 > toeF) - { - toeF = num2; - } - float num3 = Vector3.Dot(val3, right); - if (num3 < sideMin) - { - sideMin = num3; - } - if (num3 > sideMax) - { - sideMax = num3; - } - } - return true; - } + private bool TryGetFootSpatialData(Transform avatarTransform, IReadOnlyList avatarBakedBodyMeshes, Dictionary> avatarBoneMap, bool isLeft, out float footMaxUp, out float footMinUp, out float heelF, out float toeF, out float sideMin, out float sideMax, float weightThreshold = 0.15f, int sampleStep = 1) + { + //IL_0051: Unknown result type (might be due to invalid IL or missing references) + //IL_0053: Unknown result type (might be due to invalid IL or missing references) + //IL_0074: Unknown result type (might be due to invalid IL or missing references) + //IL_0079: Unknown result type (might be due to invalid IL or missing references) + //IL_007a: Unknown result type (might be due to invalid IL or missing references) + //IL_007f: Unknown result type (might be due to invalid IL or missing references) + //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_017c: Unknown result type (might be due to invalid IL or missing references) + //IL_0183: Unknown result type (might be due to invalid IL or missing references) + //IL_0188: 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_018e: Unknown result type (might be due to invalid IL or missing references) + //IL_01ae: Unknown result type (might be due to invalid IL or missing references) + //IL_01af: Unknown result type (might be due to invalid IL or missing references) + //IL_01cf: Unknown result type (might be due to invalid IL or missing references) + footMaxUp = float.NegativeInfinity; + footMinUp = float.PositiveInfinity; + heelF = float.PositiveInfinity; + toeF = float.NegativeInfinity; + sideMin = float.PositiveInfinity; + sideMax = float.NegativeInfinity; + if ((Object)(object)avatarTransform == (Object)null || avatarBakedBodyMeshes == null || avatarBoneMap == null || avatarBoneMap.Count == 0) + { + return false; + } + HumanBodyBones key = (HumanBodyBones)(isLeft ? 5 : 6); + if (!avatarBoneMap.TryGetValue(key, out var value) || value == null || value.Count == 0) + { + Debug.LogWarning((object)"[BodyPoseMatch_Leg] TryGetFootSpatialData\n - foot bone set is missing"); + return false; + } + Vector3 up = Vector3.up; + Vector3 forward = Vector3.forward; + Vector3 right = Vector3.right; + HashSet hashSet = new HashSet(); + Transform val = null; + foreach (Transform item in value) + { + if ((Object)(object)item == (Object)null) + { + continue; + } + if ((Object)(object)val == (Object)null) + { + val = item; + } + Stack stack = new Stack(); + stack.Push(item); + while (stack.Count > 0) + { + Transform val2 = stack.Pop(); + if (!((Object)(object)val2 == (Object)null) && hashSet.Add(val2)) + { + for (int i = 0; i < val2.childCount; i++) + { + stack.Push(val2.GetChild(i)); + } + } + } + } + if ((Object)(object)val == (Object)null || hashSet.Count == 0) + { + return false; + } + List list = this.poseMatchCommonUtil.CollectWeightedVerticesWorld(avatarBakedBodyMeshes, hashSet, weightThreshold, sampleStep); + if (list == null || list.Count == 0) + { + return false; + } + for (int j = 0; j < list.Count; j++) + { + Vector3 val3 = list[j] - val.position; + float num = Vector3.Dot(val3, up); + if (num < footMinUp) + { + footMinUp = num; + } + if (num > footMaxUp) + { + footMaxUp = num; + } + float num2 = Vector3.Dot(val3, forward); + if (num2 < heelF) + { + heelF = num2; + } + if (num2 > toeF) + { + toeF = num2; + } + float num3 = Vector3.Dot(val3, right); + if (num3 < sideMin) + { + sideMin = num3; + } + if (num3 > sideMax) + { + sideMax = num3; + } + } + return true; + } - public void DrawLegPcaDebug(GameObject avatarObject, IReadOnlyList avatarBakedBodyMeshes, Dictionary> avatarBoneMap, bool isLeft, Color centerColor, Color axisColor, float axisScale = 1f, float duration = 1f) - { - //IL_0046: Unknown result type (might be due to invalid IL or missing references) - //IL_004b: Unknown result type (might be due to invalid IL or missing references) - //IL_0053: Unknown result type (might be due to invalid IL or missing references) - //IL_0058: Unknown result type (might be due to invalid IL or missing references) - //IL_0062: Unknown result type (might be due to invalid IL or missing references) - //IL_0063: Unknown result type (might be due to invalid IL or missing references) - //IL_0069: Unknown result type (might be due to invalid IL or missing references) - //IL_006e: Unknown result type (might be due to invalid IL or missing references) - //IL_0073: Unknown result type (might be due to invalid IL or missing references) - //IL_0074: Unknown result type (might be due to invalid IL or missing references) - //IL_007a: Unknown result type (might be due to invalid IL or missing references) - //IL_007f: Unknown result type (might be due to invalid IL or missing references) - //IL_0084: Unknown result type (might be due to invalid IL or missing references) - //IL_008d: Unknown result type (might be due to invalid IL or missing references) - //IL_008e: 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_009e: Unknown result type (might be due to invalid IL or missing references) - //IL_009f: Unknown result type (might be due to invalid IL or missing references) - //IL_00a5: Unknown result type (might be due to invalid IL or missing references) - //IL_00aa: Unknown result type (might be due to invalid IL or missing references) - //IL_00af: Unknown result type (might be due to invalid IL or missing references) - //IL_00b8: Unknown result type (might be due to invalid IL or missing references) - //IL_00b9: Unknown result type (might be due to invalid IL or missing references) - //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_00c9: Unknown result type (might be due to invalid IL or missing references) - //IL_00ca: 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_00d5: Unknown result type (might be due to invalid IL or missing references) - //IL_00da: Unknown result type (might be due to invalid IL or missing references) - //IL_00f4: Unknown result type (might be due to invalid IL or missing references) - //IL_00f5: Unknown result type (might be due to invalid IL or missing references) - //IL_00f8: Unknown result type (might be due to invalid IL or missing references) - //IL_00fd: Unknown result type (might be due to invalid IL or missing references) - //IL_0102: Unknown result type (might be due to invalid IL or missing references) - //IL_0103: Unknown result type (might be due to invalid IL or missing references) - //IL_0106: Unknown result type (might be due to invalid IL or missing references) - //IL_010b: Unknown result type (might be due to invalid IL or missing references) - //IL_0110: Unknown result type (might be due to invalid IL or missing references) - //IL_0112: 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_0141: Unknown result type (might be due to invalid IL or missing references) - //IL_014a: Unknown result type (might be due to invalid IL or missing references) - if (!((Object)(object)avatarObject == (Object)null)) - { - RegionStats regionStats = ComputeLegRegionStats(avatarObject.transform, avatarBakedBodyMeshes, avatarBoneMap, isLeft); - if (regionStats.length < 0.0001f) - { - Debug.LogWarning((object)$"[AvatarBodyMatchUtil] DrawLegPcaDebug: PCA length too small (avatar={((Object)avatarObject).name}, isLeft={isLeft})"); - return; - } - Vector3 center = regionStats.center; - Vector3 normalized = ((Vector3)(ref regionStats.principalAxis)).normalized; - float num = 0.03f * axisScale; - Debug.DrawLine(center + Vector3.up * num, center - Vector3.up * num, centerColor, duration); - Debug.DrawLine(center + Vector3.right * num, center - Vector3.right * num, centerColor, duration); - Debug.DrawLine(center + Vector3.forward * num, center - Vector3.forward * num, centerColor, duration); - float num2 = regionStats.length * 0.5f * axisScale; - Vector3 val = center - normalized * num2; - Vector3 val2 = center + normalized * num2; - Debug.DrawLine(val, val2, axisColor, duration); - Debug.Log((object)($"[DrawLegPcaDebug] avatar={((Object)avatarObject).name}, isLeft={isLeft}, " + $"center={center}, axis={normalized}, len={regionStats.length}, avgRadius={regionStats.avgRadius}")); - } - } + public void DrawLegPcaDebug(GameObject avatarObject, IReadOnlyList avatarBakedBodyMeshes, Dictionary> avatarBoneMap, bool isLeft, Color centerColor, Color axisColor, float axisScale = 1f, float duration = 1f) + { + //IL_0046: Unknown result type (might be due to invalid IL or missing references) + //IL_004b: Unknown result type (might be due to invalid IL or missing references) + //IL_0053: Unknown result type (might be due to invalid IL or missing references) + //IL_0058: Unknown result type (might be due to invalid IL or missing references) + //IL_0062: Unknown result type (might be due to invalid IL or missing references) + //IL_0063: Unknown result type (might be due to invalid IL or missing references) + //IL_0069: Unknown result type (might be due to invalid IL or missing references) + //IL_006e: Unknown result type (might be due to invalid IL or missing references) + //IL_0073: Unknown result type (might be due to invalid IL or missing references) + //IL_0074: Unknown result type (might be due to invalid IL or missing references) + //IL_007a: Unknown result type (might be due to invalid IL or missing references) + //IL_007f: Unknown result type (might be due to invalid IL or missing references) + //IL_0084: Unknown result type (might be due to invalid IL or missing references) + //IL_008d: Unknown result type (might be due to invalid IL or missing references) + //IL_008e: 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_009e: Unknown result type (might be due to invalid IL or missing references) + //IL_009f: Unknown result type (might be due to invalid IL or missing references) + //IL_00a5: Unknown result type (might be due to invalid IL or missing references) + //IL_00aa: Unknown result type (might be due to invalid IL or missing references) + //IL_00af: Unknown result type (might be due to invalid IL or missing references) + //IL_00b8: Unknown result type (might be due to invalid IL or missing references) + //IL_00b9: Unknown result type (might be due to invalid IL or missing references) + //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_00c9: Unknown result type (might be due to invalid IL or missing references) + //IL_00ca: 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_00d5: Unknown result type (might be due to invalid IL or missing references) + //IL_00da: Unknown result type (might be due to invalid IL or missing references) + //IL_00f4: Unknown result type (might be due to invalid IL or missing references) + //IL_00f5: Unknown result type (might be due to invalid IL or missing references) + //IL_00f8: Unknown result type (might be due to invalid IL or missing references) + //IL_00fd: Unknown result type (might be due to invalid IL or missing references) + //IL_0102: Unknown result type (might be due to invalid IL or missing references) + //IL_0103: Unknown result type (might be due to invalid IL or missing references) + //IL_0106: Unknown result type (might be due to invalid IL or missing references) + //IL_010b: Unknown result type (might be due to invalid IL or missing references) + //IL_0110: Unknown result type (might be due to invalid IL or missing references) + //IL_0112: 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_0141: Unknown result type (might be due to invalid IL or missing references) + //IL_014a: Unknown result type (might be due to invalid IL or missing references) + if (!((Object)(object)avatarObject == (Object)null)) + { + RegionStats regionStats = this.ComputeLegRegionStats(avatarObject.transform, avatarBakedBodyMeshes, avatarBoneMap, isLeft); + if (regionStats.length < 0.0001f) + { + Debug.LogWarning((object)$"[AvatarBodyMatchUtil] DrawLegPcaDebug: PCA length too small (avatar={((Object)avatarObject).name}, isLeft={isLeft})"); + return; + } + Vector3 center = regionStats.center; + Vector3 normalized = regionStats.principalAxis.normalized; + float num = 0.03f * axisScale; + Debug.DrawLine(center + Vector3.up * num, center - Vector3.up * num, centerColor, duration); + Debug.DrawLine(center + Vector3.right * num, center - Vector3.right * num, centerColor, duration); + Debug.DrawLine(center + Vector3.forward * num, center - Vector3.forward * num, centerColor, duration); + float num2 = regionStats.length * 0.5f * axisScale; + Vector3 val = center - normalized * num2; + Vector3 val2 = center + normalized * num2; + Debug.DrawLine(val, val2, axisColor, duration); + Debug.Log((object)($"[DrawLegPcaDebug] avatar={((Object)avatarObject).name}, isLeft={isLeft}, " + $"center={center}, axis={normalized}, len={regionStats.length}, avgRadius={regionStats.avgRadius}")); + } + } - public void DrawFootSpatialDebug(GameObject avatarObject, IReadOnlyList avatarBakedBodyMeshes, Dictionary> avatarBoneMap, bool isLeft, Color centerColor, Color axisColor, Color boxColor, float axisScale = 0.1f, float duration = 1f, float weightThreshold = 0.15f, int sampleStep = 1) - { - //IL_0067: Unknown result type (might be due to invalid IL or missing references) - //IL_006a: 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_00d5: Unknown result type (might be due to invalid IL or missing references) - //IL_00ff: Unknown result type (might be due to invalid IL or missing references) - //IL_00f6: Unknown result type (might be due to invalid IL or missing references) - //IL_0104: Unknown result type (might be due to invalid IL or missing references) - //IL_012e: Unknown result type (might be due to invalid IL or missing references) - //IL_0133: 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_0120: Unknown result type (might be due to invalid IL or missing references) - //IL_0125: Unknown result type (might be due to invalid IL or missing references) - //IL_014a: Unknown result type (might be due to invalid IL or missing references) - //IL_014f: Unknown result type (might be due to invalid IL or missing references) - //IL_0171: 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_0176: Unknown result type (might be due to invalid IL or missing references) - //IL_01a8: Unknown result type (might be due to invalid IL or missing references) - //IL_01aa: Unknown result type (might be due to invalid IL or missing references) - //IL_01ac: Unknown result type (might be due to invalid IL or missing references) - //IL_01ae: 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) - //IL_01bb: 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_01bf: Unknown result type (might be due to invalid IL or missing references) - //IL_01de: Unknown result type (might be due to invalid IL or missing references) - //IL_01e0: 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_01ed: Unknown result type (might be due to invalid IL or missing references) - //IL_01ef: Unknown result type (might be due to invalid IL or missing references) - //IL_01f3: Unknown result type (might be due to invalid IL or missing references) - //IL_01fc: Unknown result type (might be due to invalid IL or missing references) - //IL_01fe: Unknown result type (might be due to invalid IL or missing references) - //IL_0202: 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_018b: Unknown result type (might be due to invalid IL or missing references) - //IL_02a8: Unknown result type (might be due to invalid IL or missing references) - //IL_02ce: Unknown result type (might be due to invalid IL or missing references) - //IL_02d3: Unknown result type (might be due to invalid IL or missing references) - //IL_02d5: Unknown result type (might be due to invalid IL or missing references) - //IL_02d7: Unknown result type (might be due to invalid IL or missing references) - //IL_0317: Unknown result type (might be due to invalid IL or missing references) - //IL_037f: Unknown result type (might be due to invalid IL or missing references) - //IL_0386: Unknown result type (might be due to invalid IL or missing references) - //IL_038d: Unknown result type (might be due to invalid IL or missing references) - //IL_0251: Unknown result type (might be due to invalid IL or missing references) - //IL_0253: 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_0265: Unknown result type (might be due to invalid IL or missing references) - //IL_026a: Unknown result type (might be due to invalid IL or missing references) - //IL_026f: 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_027d: Unknown result type (might be due to invalid IL or missing references) - if ((Object)(object)avatarObject == (Object)null) - { - return; - } - if (!TryGetFootSpatialData(avatarObject.transform, avatarBakedBodyMeshes, avatarBoneMap, isLeft, out var footMaxUp, out var footMinUp, out var heelF, out var toeF, out var sideMin, out var sideMax, weightThreshold, sampleStep)) - { - Debug.LogWarning((object)("[BodyPoseMatch_Leg] DrawFootSpatialDebug" + $"\n - Failed to compute Foot Spatial Data (avatar={((Object)avatarObject).name}, isLeft={isLeft})")); - } - else - { - if (avatarBoneMap == null || avatarBoneMap.Count == 0) - { - return; - } - HumanBodyBones val = (HumanBodyBones)(isLeft ? 5 : 6); - if (!avatarBoneMap.TryGetValue(val, out var value) || value == null || value.Count == 0) - { - return; - } - Transform val2 = null; - foreach (Transform item in value) - { - if ((Object)(object)item != (Object)null) - { - val2 = item; - break; - } - } - if ((Object)(object)val2 == (Object)null) - { - return; - } - Vector3 position = val2.position; - Transform boneFromBoneMap = poseMatchCommonUtil.GetBoneFromBoneMap(avatarBoneMap, (HumanBodyBones)0); - Vector3 val3 = (((Object)(object)boneFromBoneMap != (Object)null) ? boneFromBoneMap.forward : avatarObject.transform.forward); - val3.y = 0f; - if (((Vector3)(ref val3)).sqrMagnitude < 1E-06f) - { - val3 = Vector3.forward; - } - ((Vector3)(ref val3)).Normalize(); - Vector3 val4 = Vector3.Cross(Vector3.up, val3); - if (((Vector3)(ref val4)).sqrMagnitude < 1E-06f) - { - val4 = Vector3.right; - } - ((Vector3)(ref val4)).Normalize(); - Vector3 val5 = (((Object)(object)boneFromBoneMap != (Object)null) ? boneFromBoneMap.up : avatarObject.transform.up); - if (((Vector3)(ref val5)).sqrMagnitude < 1E-06f) - { - val5 = Vector3.up; - } - ((Vector3)(ref val5)).Normalize(); - float num = Mathf.Max(0.0001f, axisScale * 0.5f); - DrawCross(position, val5, val4, centerColor, num, duration); - DrawCross(position, val5, val3, centerColor, num, duration); - float len = Mathf.Max(0.0001f, axisScale * 2f); - DrawAxisLine(position, val5, len, axisColor, duration); - DrawAxisLine(position, val3, len, axisColor, duration); - DrawAxisLine(position, val4, len, axisColor, duration); - Vector3[] array = (Vector3[])(object)new Vector3[8]; - int num2 = 0; - for (int i = 0; i < 2; i++) - { - float num3 = ((i == 0) ? footMinUp : footMaxUp); - for (int j = 0; j < 2; j++) - { - float num4 = ((j == 0) ? heelF : toeF); - for (int k = 0; k < 2; k++) - { - float num5 = ((k == 0) ? sideMin : sideMax); - array[num2++] = position + val5 * num3 + val3 * num4 + val4 * num5; - } - } - } - DrawBoxEdges(array, boxColor, duration); - float size = Mathf.Max(5E-05f, num * 0.6f); - for (int l = 0; l < array.Length; l++) - { - DrawCross(array[l], val3, val4, boxColor, size, duration); - } - Debug.Log((object)($"[DrawFootSpatialDebug] avatar={((Object)avatarObject).name}, isLeft={isLeft}\n" + $" - footBone={val}, footRoot={((Object)val2).name}\n" + $" - up(min,max)=({footMinUp:F4},{footMaxUp:F4})\n" + $" - forward(heel,toe)=({heelF:F4},{toeF:F4})\n" + $" - side(min,max)=({sideMin:F4},{sideMax:F4})\n" + $" - forwardDir={val3}, rightDir={val4}, upDir={val5}")); - } - void DrawAxisLine(Vector3 start, Vector3 dir, float num6, Color color, float d) - { - //IL_0016: Unknown result type (might be due to invalid IL or missing references) - //IL_0017: Unknown result type (might be due to invalid IL or missing references) - //IL_0018: Unknown result type (might be due to invalid IL or missing references) - //IL_001a: Unknown result type (might be due to invalid IL or missing references) - //IL_001f: 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) - if (!(((Vector3)(ref dir)).sqrMagnitude < 1E-10f)) - { - ((Vector3)(ref dir)).Normalize(); - Debug.DrawLine(start, start + dir * num6, color, d); - } - } - void DrawBoxEdges(Vector3[] c, Color color, float d) - { - //IL_0002: Unknown result type (might be due to invalid IL or missing references) - //IL_0009: Unknown result type (might be due to invalid IL or missing references) - //IL_000e: Unknown result type (might be due to invalid IL or missing references) - //IL_0017: Unknown result type (might be due to invalid IL or missing references) - //IL_001e: Unknown result type (might be due to invalid IL or missing references) - //IL_0023: Unknown result type (might be due to invalid IL or missing references) - //IL_002c: Unknown result type (might be due to invalid IL or missing references) - //IL_0033: Unknown result type (might be due to invalid IL or missing references) - //IL_0038: Unknown result type (might be due to invalid IL or missing references) - //IL_0041: Unknown result type (might be due to invalid IL or missing references) - //IL_0048: Unknown result type (might be due to invalid IL or missing references) - //IL_004d: Unknown result type (might be due to invalid IL or missing references) - //IL_0056: Unknown result type (might be due to invalid IL or missing references) - //IL_005d: Unknown result type (might be due to invalid IL or missing references) - //IL_0062: Unknown result type (might be due to invalid IL or missing references) - //IL_006b: Unknown result type (might be due to invalid IL or missing references) - //IL_0072: Unknown result type (might be due to invalid IL or missing references) - //IL_0077: Unknown result type (might be due to invalid IL or missing references) - //IL_0080: 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_0095: Unknown result type (might be due to invalid IL or missing references) - //IL_009c: Unknown result type (might be due to invalid IL or missing references) - //IL_00a1: Unknown result type (might be due to invalid IL or missing references) - //IL_00aa: Unknown result type (might be due to invalid IL or missing references) - //IL_00b1: Unknown result type (might be due to invalid IL or missing references) - //IL_00b6: Unknown result type (might be due to invalid IL or missing references) - //IL_00bf: Unknown result type (might be due to invalid IL or missing references) - //IL_00c6: 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_00d4: Unknown result type (might be due to invalid IL or missing references) - //IL_00db: Unknown result type (might be due to invalid IL or missing references) - //IL_00e0: Unknown result type (might be due to invalid IL or missing references) - //IL_00e9: Unknown result type (might be due to invalid IL or missing references) - //IL_00f0: Unknown result type (might be due to invalid IL or missing references) - //IL_00f5: Unknown result type (might be due to invalid IL or missing references) - DrawSegment(c[0], c[1], color, d); - DrawSegment(c[1], c[3], color, d); - DrawSegment(c[3], c[2], color, d); - DrawSegment(c[2], c[0], color, d); - DrawSegment(c[4], c[5], color, d); - DrawSegment(c[5], c[7], color, d); - DrawSegment(c[7], c[6], color, d); - DrawSegment(c[6], c[4], color, d); - DrawSegment(c[0], c[4], color, d); - DrawSegment(c[1], c[5], color, d); - DrawSegment(c[2], c[6], color, d); - DrawSegment(c[3], c[7], color, d); - } - void DrawCross(Vector3 pos, Vector3 axisA, Vector3 axisB, Color color, float num6, float d) - { - //IL_000e: Unknown result type (might be due to invalid IL or missing references) - //IL_0013: Unknown result type (might be due to invalid IL or missing references) - //IL_0038: Unknown result type (might be due to invalid IL or missing references) - //IL_0039: Unknown result type (might be due to invalid IL or missing references) - //IL_003c: Unknown result type (might be due to invalid IL or missing references) - //IL_0041: Unknown result type (might be due to invalid IL or missing references) - //IL_0046: Unknown result type (might be due to invalid IL or missing references) - //IL_0047: Unknown result type (might be due to invalid IL or missing references) - //IL_004a: Unknown result type (might be due to invalid IL or missing references) - //IL_004f: Unknown result type (might be due to invalid IL or missing references) - //IL_0054: Unknown result type (might be due to invalid IL or missing references) - //IL_005c: Unknown result type (might be due to invalid IL or missing references) - //IL_005d: Unknown result type (might be due to invalid IL or missing references) - //IL_0060: Unknown result type (might be due to invalid IL or missing references) - //IL_0065: Unknown result type (might be due to invalid IL or missing references) - //IL_006a: Unknown result type (might be due to invalid IL or missing references) - //IL_006b: Unknown result type (might be due to invalid IL or missing references) - //IL_006e: Unknown result type (might be due to invalid IL or missing references) - //IL_0073: Unknown result type (might be due to invalid IL or missing references) - //IL_0078: Unknown result type (might be due to invalid IL or missing references) - //IL_0023: Unknown result type (might be due to invalid IL or missing references) - //IL_0028: Unknown result type (might be due to invalid IL or missing references) - if (((Vector3)(ref axisA)).sqrMagnitude < 1E-10f) - { - axisA = Vector3.up; - } - if (((Vector3)(ref axisB)).sqrMagnitude < 1E-10f) - { - axisB = Vector3.right; - } - ((Vector3)(ref axisA)).Normalize(); - ((Vector3)(ref axisB)).Normalize(); - Debug.DrawLine(pos - axisA * num6, pos + axisA * num6, color, d); - Debug.DrawLine(pos - axisB * num6, pos + axisB * num6, color, d); - } - void DrawSegment(Vector3 p0, Vector3 p1, Color color, float d) - { - //IL_0000: Unknown result type (might be due to invalid IL or missing references) - //IL_0001: Unknown result type (might be due to invalid IL or missing references) - //IL_0002: Unknown result type (might be due to invalid IL or missing references) - Debug.DrawLine(p0, p1, color, d); - } - } + public void DrawFootSpatialDebug(GameObject avatarObject, IReadOnlyList avatarBakedBodyMeshes, Dictionary> avatarBoneMap, bool isLeft, Color centerColor, Color axisColor, Color boxColor, float axisScale = 0.1f, float duration = 1f, float weightThreshold = 0.15f, int sampleStep = 1) + { + //IL_0067: Unknown result type (might be due to invalid IL or missing references) + //IL_006a: 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_00d5: Unknown result type (might be due to invalid IL or missing references) + //IL_00ff: Unknown result type (might be due to invalid IL or missing references) + //IL_00f6: Unknown result type (might be due to invalid IL or missing references) + //IL_0104: Unknown result type (might be due to invalid IL or missing references) + //IL_012e: Unknown result type (might be due to invalid IL or missing references) + //IL_0133: 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_0120: Unknown result type (might be due to invalid IL or missing references) + //IL_0125: Unknown result type (might be due to invalid IL or missing references) + //IL_014a: Unknown result type (might be due to invalid IL or missing references) + //IL_014f: Unknown result type (might be due to invalid IL or missing references) + //IL_0171: 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_0176: Unknown result type (might be due to invalid IL or missing references) + //IL_01a8: Unknown result type (might be due to invalid IL or missing references) + //IL_01aa: Unknown result type (might be due to invalid IL or missing references) + //IL_01ac: Unknown result type (might be due to invalid IL or missing references) + //IL_01ae: 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) + //IL_01bb: 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_01bf: Unknown result type (might be due to invalid IL or missing references) + //IL_01de: Unknown result type (might be due to invalid IL or missing references) + //IL_01e0: 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_01ed: Unknown result type (might be due to invalid IL or missing references) + //IL_01ef: Unknown result type (might be due to invalid IL or missing references) + //IL_01f3: Unknown result type (might be due to invalid IL or missing references) + //IL_01fc: Unknown result type (might be due to invalid IL or missing references) + //IL_01fe: Unknown result type (might be due to invalid IL or missing references) + //IL_0202: 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_018b: Unknown result type (might be due to invalid IL or missing references) + //IL_02a8: Unknown result type (might be due to invalid IL or missing references) + //IL_02ce: Unknown result type (might be due to invalid IL or missing references) + //IL_02d3: Unknown result type (might be due to invalid IL or missing references) + //IL_02d5: Unknown result type (might be due to invalid IL or missing references) + //IL_02d7: Unknown result type (might be due to invalid IL or missing references) + //IL_0317: Unknown result type (might be due to invalid IL or missing references) + //IL_037f: Unknown result type (might be due to invalid IL or missing references) + //IL_0386: Unknown result type (might be due to invalid IL or missing references) + //IL_038d: Unknown result type (might be due to invalid IL or missing references) + //IL_0251: Unknown result type (might be due to invalid IL or missing references) + //IL_0253: 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_0265: Unknown result type (might be due to invalid IL or missing references) + //IL_026a: Unknown result type (might be due to invalid IL or missing references) + //IL_026f: 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_027d: Unknown result type (might be due to invalid IL or missing references) + if ((Object)(object)avatarObject == (Object)null) + { + return; + } + if (!this.TryGetFootSpatialData(avatarObject.transform, avatarBakedBodyMeshes, avatarBoneMap, isLeft, out var footMaxUp, out var footMinUp, out var heelF, out var toeF, out var sideMin, out var sideMax, weightThreshold, sampleStep)) + { + Debug.LogWarning((object)("[BodyPoseMatch_Leg] DrawFootSpatialDebug" + $"\n - Failed to compute Foot Spatial Data (avatar={((Object)avatarObject).name}, isLeft={isLeft})")); + } + else + { + if (avatarBoneMap == null || avatarBoneMap.Count == 0) + { + return; + } + HumanBodyBones val = (HumanBodyBones)(isLeft ? 5 : 6); + if (!avatarBoneMap.TryGetValue(val, out var value) || value == null || value.Count == 0) + { + return; + } + Transform val2 = null; + foreach (Transform item in value) + { + if ((Object)(object)item != (Object)null) + { + val2 = item; + break; + } + } + if ((Object)(object)val2 == (Object)null) + { + return; + } + Vector3 position = val2.position; + Transform boneFromBoneMap = this.poseMatchCommonUtil.GetBoneFromBoneMap(avatarBoneMap, (HumanBodyBones)0); + Vector3 val3 = (boneFromBoneMap != null) ? boneFromBoneMap.forward : avatarObject.transform.forward; + val3.y = 0f; + if (val3.sqrMagnitude < 1E-06f) + { + val3 = Vector3.forward; + } + val3.Normalize(); + Vector3 val4 = Vector3.Cross(Vector3.up, val3); + if (val4.sqrMagnitude < 1E-06f) + { + val4 = Vector3.right; + } + val4.Normalize(); + Vector3 val5 = (boneFromBoneMap != null) ? boneFromBoneMap.up : avatarObject.transform.up; + if (val5.sqrMagnitude < 1E-06f) + { + val5 = Vector3.up; + } + val5.Normalize(); + float num = Mathf.Max(0.0001f, axisScale * 0.5f); + DrawCross(position, val5, val4, centerColor, num, duration); + DrawCross(position, val5, val3, centerColor, num, duration); + float len = Mathf.Max(0.0001f, axisScale * 2f); + DrawAxisLine(position, val5, len, axisColor, duration); + DrawAxisLine(position, val3, len, axisColor, duration); + DrawAxisLine(position, val4, len, axisColor, duration); + Vector3[] array = (Vector3[])(object)new Vector3[8]; + int num2 = 0; + for (int i = 0; i < 2; i++) + { + float num3 = ((i == 0) ? footMinUp : footMaxUp); + for (int j = 0; j < 2; j++) + { + float num4 = ((j == 0) ? heelF : toeF); + for (int k = 0; k < 2; k++) + { + float num5 = ((k == 0) ? sideMin : sideMax); + array[num2++] = position + val5 * num3 + val3 * num4 + val4 * num5; + } + } + } + DrawBoxEdges(array, boxColor, duration); + float size = Mathf.Max(5E-05f, num * 0.6f); + for (int l = 0; l < array.Length; l++) + { + DrawCross(array[l], val3, val4, boxColor, size, duration); + } + Debug.Log((object)($"[DrawFootSpatialDebug] avatar={((Object)avatarObject).name}, isLeft={isLeft}\n" + $" - footBone={val}, footRoot={((Object)val2).name}\n" + $" - up(min,max)=({footMinUp:F4},{footMaxUp:F4})\n" + $" - forward(heel,toe)=({heelF:F4},{toeF:F4})\n" + $" - side(min,max)=({sideMin:F4},{sideMax:F4})\n" + $" - forwardDir={val3}, rightDir={val4}, upDir={val5}")); + } + void DrawAxisLine(Vector3 start, Vector3 dir, float num6, Color color, float d) + { + //IL_0016: Unknown result type (might be due to invalid IL or missing references) + //IL_0017: Unknown result type (might be due to invalid IL or missing references) + //IL_0018: Unknown result type (might be due to invalid IL or missing references) + //IL_001a: Unknown result type (might be due to invalid IL or missing references) + //IL_001f: 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) + if (!(dir.sqrMagnitude < 1E-10f)) + { + dir.Normalize(); + Debug.DrawLine(start, start + dir * num6, color, d); + } + } + void DrawBoxEdges(Vector3[] c, Color color, float d) + { + //IL_0002: Unknown result type (might be due to invalid IL or missing references) + //IL_0009: Unknown result type (might be due to invalid IL or missing references) + //IL_000e: Unknown result type (might be due to invalid IL or missing references) + //IL_0017: Unknown result type (might be due to invalid IL or missing references) + //IL_001e: Unknown result type (might be due to invalid IL or missing references) + //IL_0023: Unknown result type (might be due to invalid IL or missing references) + //IL_002c: Unknown result type (might be due to invalid IL or missing references) + //IL_0033: Unknown result type (might be due to invalid IL or missing references) + //IL_0038: Unknown result type (might be due to invalid IL or missing references) + //IL_0041: Unknown result type (might be due to invalid IL or missing references) + //IL_0048: Unknown result type (might be due to invalid IL or missing references) + //IL_004d: Unknown result type (might be due to invalid IL or missing references) + //IL_0056: Unknown result type (might be due to invalid IL or missing references) + //IL_005d: Unknown result type (might be due to invalid IL or missing references) + //IL_0062: Unknown result type (might be due to invalid IL or missing references) + //IL_006b: Unknown result type (might be due to invalid IL or missing references) + //IL_0072: Unknown result type (might be due to invalid IL or missing references) + //IL_0077: Unknown result type (might be due to invalid IL or missing references) + //IL_0080: 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_0095: Unknown result type (might be due to invalid IL or missing references) + //IL_009c: Unknown result type (might be due to invalid IL or missing references) + //IL_00a1: Unknown result type (might be due to invalid IL or missing references) + //IL_00aa: Unknown result type (might be due to invalid IL or missing references) + //IL_00b1: Unknown result type (might be due to invalid IL or missing references) + //IL_00b6: Unknown result type (might be due to invalid IL or missing references) + //IL_00bf: Unknown result type (might be due to invalid IL or missing references) + //IL_00c6: 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_00d4: Unknown result type (might be due to invalid IL or missing references) + //IL_00db: Unknown result type (might be due to invalid IL or missing references) + //IL_00e0: Unknown result type (might be due to invalid IL or missing references) + //IL_00e9: Unknown result type (might be due to invalid IL or missing references) + //IL_00f0: Unknown result type (might be due to invalid IL or missing references) + //IL_00f5: Unknown result type (might be due to invalid IL or missing references) + DrawSegment(c[0], c[1], color, d); + DrawSegment(c[1], c[3], color, d); + DrawSegment(c[3], c[2], color, d); + DrawSegment(c[2], c[0], color, d); + DrawSegment(c[4], c[5], color, d); + DrawSegment(c[5], c[7], color, d); + DrawSegment(c[7], c[6], color, d); + DrawSegment(c[6], c[4], color, d); + DrawSegment(c[0], c[4], color, d); + DrawSegment(c[1], c[5], color, d); + DrawSegment(c[2], c[6], color, d); + DrawSegment(c[3], c[7], color, d); + } + void DrawCross(Vector3 pos, Vector3 axisA, Vector3 axisB, Color color, float num6, float d) + { + //IL_000e: Unknown result type (might be due to invalid IL or missing references) + //IL_0013: Unknown result type (might be due to invalid IL or missing references) + //IL_0038: Unknown result type (might be due to invalid IL or missing references) + //IL_0039: Unknown result type (might be due to invalid IL or missing references) + //IL_003c: Unknown result type (might be due to invalid IL or missing references) + //IL_0041: Unknown result type (might be due to invalid IL or missing references) + //IL_0046: Unknown result type (might be due to invalid IL or missing references) + //IL_0047: Unknown result type (might be due to invalid IL or missing references) + //IL_004a: Unknown result type (might be due to invalid IL or missing references) + //IL_004f: Unknown result type (might be due to invalid IL or missing references) + //IL_0054: Unknown result type (might be due to invalid IL or missing references) + //IL_005c: Unknown result type (might be due to invalid IL or missing references) + //IL_005d: Unknown result type (might be due to invalid IL or missing references) + //IL_0060: Unknown result type (might be due to invalid IL or missing references) + //IL_0065: Unknown result type (might be due to invalid IL or missing references) + //IL_006a: Unknown result type (might be due to invalid IL or missing references) + //IL_006b: Unknown result type (might be due to invalid IL or missing references) + //IL_006e: Unknown result type (might be due to invalid IL or missing references) + //IL_0073: Unknown result type (might be due to invalid IL or missing references) + //IL_0078: Unknown result type (might be due to invalid IL or missing references) + //IL_0023: Unknown result type (might be due to invalid IL or missing references) + //IL_0028: Unknown result type (might be due to invalid IL or missing references) + if (axisA.sqrMagnitude < 1E-10f) + { + axisA = Vector3.up; + } + if (axisB.sqrMagnitude < 1E-10f) + { + axisB = Vector3.right; + } + axisA.Normalize(); + axisB.Normalize(); + Debug.DrawLine(pos - axisA * num6, pos + axisA * num6, color, d); + Debug.DrawLine(pos - axisB * num6, pos + axisB * num6, color, d); + } + void DrawSegment(Vector3 p0, Vector3 p1, Color color, float d) + { + //IL_0000: Unknown result type (might be due to invalid IL or missing references) + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + //IL_0002: Unknown result type (might be due to invalid IL or missing references) + Debug.DrawLine(p0, p1, color, d); + } + } } diff --git a/Assets/@Eden_Tools/Eden_AutoMorpher/Script/BodyPoseMatch_Torso.cs b/Assets/@Eden_Tools/Eden_AutoMorpher/Script/BodyPoseMatch_Torso.cs index a47012b..d1e5ca4 100644 --- a/Assets/@Eden_Tools/Eden_AutoMorpher/Script/BodyPoseMatch_Torso.cs +++ b/Assets/@Eden_Tools/Eden_AutoMorpher/Script/BodyPoseMatch_Torso.cs @@ -1,213 +1,211 @@ -// Warning: Some assembly references could not be resolved automatically. This might lead to incorrect decompilation of some parts, +// 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.BodyPoseMatch_Torso using System.Collections.Generic; using System.Linq; -using Eden.AutoMorpher; -using Eden.AutoMorpher.profile; using UnityEngine; public class BodyPoseMatch_Torso { - private readonly BodyPoseMatch_CommonUtil poseMatchCommonUtil; + private readonly BodyPoseMatch_CommonUtil poseMatchCommonUtil; - public BodyPoseMatch_Torso() - { - poseMatchCommonUtil = new BodyPoseMatch_CommonUtil(); - } + public BodyPoseMatch_Torso() + { + this.poseMatchCommonUtil = new BodyPoseMatch_CommonUtil(); + } - public void AlignTorsoByNeck(IReadOnlyCollection sourceHipSet, Vector3 sourceNeckCenterWorld, Vector3 targetNeckCenterWorld) - { - //IL_005a: Unknown result type (might be due to invalid IL or missing references) - //IL_005b: Unknown result type (might be due to invalid IL or missing references) - //IL_005c: Unknown result type (might be due to invalid IL or missing references) - //IL_0062: Unknown result type (might be due to invalid IL or missing references) - //IL_0067: Unknown result type (might be due to invalid IL or missing references) - //IL_0068: Unknown result type (might be due to invalid IL or missing references) - //IL_006f: Unknown result type (might be due to invalid IL or missing references) - //IL_0071: Unknown result type (might be due to invalid IL or missing references) - //IL_0076: Unknown result type (might be due to invalid IL or missing references) - //IL_0097: Unknown result type (might be due to invalid IL or missing references) - //IL_009c: 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) - if (sourceHipSet == null || sourceHipSet.Count == 0) - { - throw new AutoMorpherException("Source Hip Set is Missing", "[BodyPoseMatch_Torso] AlignTorsoByNeck\n - sourceHipSet is null or empty"); - } - Transform val = sourceHipSet.FirstOrDefault((Transform t) => (Object)(object)t != (Object)null); - if ((Object)(object)val == (Object)null) - { - throw new AutoMorpherException("Source Hip Transform is Missing", "[BodyPoseMatch_Torso] AlignTorsoByNeck\n - sourceHipSet has no valid Transform"); - } - Vector3 val2 = targetNeckCenterWorld - sourceNeckCenterWorld; - Vector3 forward = val.forward; - float num = Vector3.Dot(val2, forward); - Vector3 val3 = forward * num; - foreach (Transform item in sourceHipSet) - { - if (!((Object)(object)item == (Object)null)) - { - item.position += val3; - } - } - } + public void AlignTorsoByNeck(IReadOnlyCollection sourceHipSet, Vector3 sourceNeckCenterWorld, Vector3 targetNeckCenterWorld) + { + //IL_005a: Unknown result type (might be due to invalid IL or missing references) + //IL_005b: Unknown result type (might be due to invalid IL or missing references) + //IL_005c: Unknown result type (might be due to invalid IL or missing references) + //IL_0062: Unknown result type (might be due to invalid IL or missing references) + //IL_0067: Unknown result type (might be due to invalid IL or missing references) + //IL_0068: Unknown result type (might be due to invalid IL or missing references) + //IL_006f: Unknown result type (might be due to invalid IL or missing references) + //IL_0071: Unknown result type (might be due to invalid IL or missing references) + //IL_0076: Unknown result type (might be due to invalid IL or missing references) + //IL_0097: Unknown result type (might be due to invalid IL or missing references) + //IL_009c: 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) + if (sourceHipSet == null || sourceHipSet.Count == 0) + { + throw new AutoMorpherException("Source Hip Set is Missing", "[BodyPoseMatch_Torso] AlignTorsoByNeck\n - sourceHipSet is null or empty"); + } + Transform val = sourceHipSet.FirstOrDefault((Transform t) => (Object)(object)t != (Object)null); + if ((Object)(object)val == (Object)null) + { + throw new AutoMorpherException("Source Hip Transform is Missing", "[BodyPoseMatch_Torso] AlignTorsoByNeck\n - sourceHipSet has no valid Transform"); + } + Vector3 val2 = targetNeckCenterWorld - sourceNeckCenterWorld; + Vector3 forward = val.forward; + float num = Vector3.Dot(val2, forward); + Vector3 val3 = forward * num; + foreach (Transform item in sourceHipSet) + { + if (!((Object)(object)item == (Object)null)) + { + item.position += val3; + } + } + } - public void AlignTorsoByNeck(GameObject proxyObject, IReadOnlyList proxyBakedBodyMeshes, Dictionary> proxyBoneMap, GameObject targetObject, IReadOnlyList targetBakedBodyMeshes, Dictionary> targetBoneMap) - { - //IL_0095: Unknown result type (might be due to invalid IL or missing references) - //IL_009b: Unknown result type (might be due to invalid IL or missing references) - if ((Object)(object)proxyObject == (Object)null || (Object)(object)targetObject == (Object)null) - { - throw new AutoMorpherException("Proxy/Target Object is Missing", "[BodyPoseMatch_Torso] AlignTorsoByNeck\n - proxyObject or targetObject is null"); - } - RegionStats regionStats = ComputeNeckRegionStats(proxyObject.transform, proxyBakedBodyMeshes, proxyBoneMap); - RegionStats regionStats2 = ComputeNeckRegionStats(targetObject.transform, targetBakedBodyMeshes, targetBoneMap); - if (regionStats.length < 0.0001f || regionStats2.length < 0.0001f) - { - Debug.LogWarning((object)"[BodyPoseMatch_Torso] AlignTorsoByNeck: Neck PCA 통계가 비정상입니다."); - return; - } - if (proxyBoneMap == null || !proxyBoneMap.TryGetValue((HumanBodyBones)0, out var value) || value == null || value.Count == 0) - { - throw new AutoMorpherException("Proxy Hip Set is Missing", "[BodyPoseMatch_Torso] AlignTorsoByNeck\n - proxyBoneMap has no Hips bone set"); - } - AlignTorsoByNeck(value, regionStats.center, regionStats2.center); - } + public void AlignTorsoByNeck(GameObject proxyObject, IReadOnlyList proxyBakedBodyMeshes, Dictionary> proxyBoneMap, GameObject targetObject, IReadOnlyList targetBakedBodyMeshes, Dictionary> targetBoneMap) + { + //IL_0095: Unknown result type (might be due to invalid IL or missing references) + //IL_009b: Unknown result type (might be due to invalid IL or missing references) + if ((Object)(object)proxyObject == (Object)null || (Object)(object)targetObject == (Object)null) + { + throw new AutoMorpherException("Proxy/Target Object is Missing", "[BodyPoseMatch_Torso] AlignTorsoByNeck\n - proxyObject or targetObject is null"); + } + RegionStats regionStats = this.ComputeNeckRegionStats(proxyObject.transform, proxyBakedBodyMeshes, proxyBoneMap); + RegionStats regionStats2 = this.ComputeNeckRegionStats(targetObject.transform, targetBakedBodyMeshes, targetBoneMap); + if (regionStats.length < 0.0001f || regionStats2.length < 0.0001f) + { + Debug.LogWarning((object)"[BodyPoseMatch_Torso] AlignTorsoByNeck: Neck PCA 통계가 비정상입니다."); + return; + } + if (proxyBoneMap == null || !proxyBoneMap.TryGetValue((HumanBodyBones)0, out var value) || value == null || value.Count == 0) + { + throw new AutoMorpherException("Proxy Hip Set is Missing", "[BodyPoseMatch_Torso] AlignTorsoByNeck\n - proxyBoneMap has no Hips bone set"); + } + this.AlignTorsoByNeck(value, regionStats.center, regionStats2.center); + } - public void AlignTorsoByNeck(Transform targetTransform, IReadOnlyList targetBakedBodyMeshes, Dictionary> targetBoneMap, Dictionary> clothBoneMap, Transform clothesTransform, ProfileData profileData, Vector3 comprehensiveScale) - { - //IL_0092: 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_009e: Unknown result type (might be due to invalid IL or missing references) - //IL_00a1: Unknown result type (might be due to invalid IL or missing references) - //IL_00a3: Unknown result type (might be due to invalid IL or missing references) - if ((Object)(object)targetTransform == (Object)null) - { - throw new AutoMorpherException("Target Transform is Missing", "[BodyPoseMatch_Torso] AlignTorsoByNeck\n - targetTransform is null"); - } - if (profileData == null || profileData.NeckSpatialData == null) - { - throw new AutoMorpherException("Profile Neck Data is Missing", "[BodyPoseMatch_Torso] AlignTorsoByNeck\n - profileData or profileData.NeckSpatialData is null"); - } - RegionStats regionStats = ComputeNeckRegionStats(targetTransform, targetBakedBodyMeshes, targetBoneMap); - if (regionStats.length < 0.0001f) - { - Debug.LogWarning((object)"[BodyPoseMatch_Torso] AlignTorsoByNeck: Neck PCA 통계가 비정상입니다."); - return; - } - if (clothBoneMap == null || !clothBoneMap.TryGetValue((HumanBodyBones)0, out var value) || value == null || value.Count == 0) - { - throw new AutoMorpherException("Cloth Hip Set is Missing", "[BodyPoseMatch_Torso] AlignTorsoByNeck\n - clothBoneMap has no Hips bone set"); - } - Vector3 profilePcaCenterWorld = poseMatchCommonUtil.GetProfilePcaCenterWorld(clothBoneMap, profileData.NeckSpatialData, comprehensiveScale); - AlignTorsoByNeck(value, profilePcaCenterWorld, regionStats.center); - } + public void AlignTorsoByNeck(Transform targetTransform, IReadOnlyList targetBakedBodyMeshes, Dictionary> targetBoneMap, Dictionary> clothBoneMap, Transform clothesTransform, ProfileData profileData, Vector3 comprehensiveScale) + { + //IL_0092: 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_009e: Unknown result type (might be due to invalid IL or missing references) + //IL_00a1: Unknown result type (might be due to invalid IL or missing references) + //IL_00a3: Unknown result type (might be due to invalid IL or missing references) + if ((Object)(object)targetTransform == (Object)null) + { + throw new AutoMorpherException("Target Transform is Missing", "[BodyPoseMatch_Torso] AlignTorsoByNeck\n - targetTransform is null"); + } + if (profileData == null || profileData.NeckSpatialData == null) + { + throw new AutoMorpherException("Profile Neck Data is Missing", "[BodyPoseMatch_Torso] AlignTorsoByNeck\n - profileData or profileData.NeckSpatialData is null"); + } + RegionStats regionStats = this.ComputeNeckRegionStats(targetTransform, targetBakedBodyMeshes, targetBoneMap); + if (regionStats.length < 0.0001f) + { + Debug.LogWarning((object)"[BodyPoseMatch_Torso] AlignTorsoByNeck: Neck PCA 통계가 비정상입니다."); + return; + } + if (clothBoneMap == null || !clothBoneMap.TryGetValue((HumanBodyBones)0, out var value) || value == null || value.Count == 0) + { + throw new AutoMorpherException("Cloth Hip Set is Missing", "[BodyPoseMatch_Torso] AlignTorsoByNeck\n - clothBoneMap has no Hips bone set"); + } + Vector3 profilePcaCenterWorld = this.poseMatchCommonUtil.GetProfilePcaCenterWorld(clothBoneMap, profileData.NeckSpatialData, comprehensiveScale); + this.AlignTorsoByNeck(value, profilePcaCenterWorld, regionStats.center); + } - public RegionStats ComputeNeckRegionStats(Transform avatarTransform, IReadOnlyList avatarBakedBodyMeshes, Dictionary> avatarBoneMap) - { - //IL_005f: Unknown result type (might be due to invalid IL or missing references) - //IL_0064: 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_00d2: 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_00dc: Unknown result type (might be due to invalid IL or missing references) - //IL_011c: Unknown result type (might be due to invalid IL or missing references) - //IL_0123: Unknown result type (might be due to invalid IL or missing references) - //IL_00f5: Unknown result type (might be due to invalid IL or missing references) - //IL_00fc: Unknown result type (might be due to invalid IL or missing references) - //IL_0101: Unknown result type (might be due to invalid IL or missing references) - //IL_0106: Unknown result type (might be due to invalid IL or missing references) - //IL_013d: Unknown result type (might be due to invalid IL or missing references) - //IL_013e: Unknown result type (might be due to invalid IL or missing references) - //IL_0134: 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) - HumanBodyBones[] targetHumanBones = (HumanBodyBones[])(object)new HumanBodyBones[1] { (HumanBodyBones)9 }; - List list = poseMatchCommonUtil.CollectHumanoidVerticesWorld(targetHumanBones, avatarBakedBodyMeshes, avatarBoneMap); - if (list == null || list.Count == 0) - { - Debug.LogWarning((object)("[AvatarBodyMatchUtil] ComputeNeckRegionStats: neck vertices 0개. avatar=" + ((avatarTransform != null) ? ((Object)avatarTransform).name : null))); - return default(RegionStats); - } - RegionStats result = new PcaUtil().ComputeRegionStats(list); - Vector3 val = avatarTransform.up; - Transform boneFromBoneMap = poseMatchCommonUtil.GetBoneFromBoneMap(avatarBoneMap, (HumanBodyBones)10); - Transform boneFromBoneMap2 = poseMatchCommonUtil.GetBoneFromBoneMap(avatarBoneMap, (HumanBodyBones)54); - Transform boneFromBoneMap3 = poseMatchCommonUtil.GetBoneFromBoneMap(avatarBoneMap, (HumanBodyBones)8); - Transform boneFromBoneMap4 = poseMatchCommonUtil.GetBoneFromBoneMap(avatarBoneMap, (HumanBodyBones)0); - Transform val2 = (((Object)(object)boneFromBoneMap2 != (Object)null) ? boneFromBoneMap2 : boneFromBoneMap3); - if ((Object)(object)boneFromBoneMap != (Object)null && (Object)(object)val2 != (Object)null) - { - val = boneFromBoneMap.position - val2.position; - } - else if ((Object)(object)boneFromBoneMap != (Object)null && (Object)(object)boneFromBoneMap4 != (Object)null) - { - val = boneFromBoneMap.position - boneFromBoneMap4.position; - } - if (((Vector3)(ref val)).sqrMagnitude > 1E-08f) - { - ((Vector3)(ref val)).Normalize(); - } - if (Vector3.Dot(val, ((Component)avatarTransform).transform.up) < 0f) - { - val = -val; - } - result.principalAxis = val; - return result; - } + public RegionStats ComputeNeckRegionStats(Transform avatarTransform, IReadOnlyList avatarBakedBodyMeshes, Dictionary> avatarBoneMap) + { + //IL_005f: Unknown result type (might be due to invalid IL or missing references) + //IL_0064: 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_00d2: 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_00dc: Unknown result type (might be due to invalid IL or missing references) + //IL_011c: Unknown result type (might be due to invalid IL or missing references) + //IL_0123: Unknown result type (might be due to invalid IL or missing references) + //IL_00f5: Unknown result type (might be due to invalid IL or missing references) + //IL_00fc: Unknown result type (might be due to invalid IL or missing references) + //IL_0101: Unknown result type (might be due to invalid IL or missing references) + //IL_0106: Unknown result type (might be due to invalid IL or missing references) + //IL_013d: Unknown result type (might be due to invalid IL or missing references) + //IL_013e: Unknown result type (might be due to invalid IL or missing references) + //IL_0134: 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) + HumanBodyBones[] targetHumanBones = (HumanBodyBones[])(object)new HumanBodyBones[1] { (HumanBodyBones)9 }; + List list = this.poseMatchCommonUtil.CollectHumanoidVerticesWorld(targetHumanBones, avatarBakedBodyMeshes, avatarBoneMap); + if (list == null || list.Count == 0) + { + Debug.LogWarning((object)("[AvatarBodyMatchUtil] ComputeNeckRegionStats: neck vertices 0개. avatar=" + ((avatarTransform != null) ? ((Object)avatarTransform).name : null))); + return default(RegionStats); + } + RegionStats result = new PcaUtil().ComputeRegionStats(list); + Vector3 val = avatarTransform.up; + Transform boneFromBoneMap = this.poseMatchCommonUtil.GetBoneFromBoneMap(avatarBoneMap, (HumanBodyBones)10); + Transform boneFromBoneMap2 = this.poseMatchCommonUtil.GetBoneFromBoneMap(avatarBoneMap, (HumanBodyBones)54); + Transform boneFromBoneMap3 = this.poseMatchCommonUtil.GetBoneFromBoneMap(avatarBoneMap, (HumanBodyBones)8); + Transform boneFromBoneMap4 = this.poseMatchCommonUtil.GetBoneFromBoneMap(avatarBoneMap, (HumanBodyBones)0); + Transform val2 = (((Object)(object)boneFromBoneMap2 != (Object)null) ? boneFromBoneMap2 : boneFromBoneMap3); + if ((Object)(object)boneFromBoneMap != (Object)null && (Object)(object)val2 != (Object)null) + { + val = boneFromBoneMap.position - val2.position; + } + else if ((Object)(object)boneFromBoneMap != (Object)null && (Object)(object)boneFromBoneMap4 != (Object)null) + { + val = boneFromBoneMap.position - boneFromBoneMap4.position; + } + if (val.sqrMagnitude > 1E-08f) + { + val.Normalize(); + } + if (Vector3.Dot(val, ((Component)avatarTransform).transform.up) < 0f) + { + val = -val; + } + result.principalAxis = val; + return result; + } - public void DrawTorsoPcaDebug(GameObject avatarObject, IReadOnlyList avatarBakedBodyMeshes, Dictionary> avatarBoneMap, Color centerColor, Color axisColor, float axisScale = 1f, float duration = 0.1f) - { - //IL_0048: Unknown result type (might be due to invalid IL or missing references) - //IL_004d: Unknown result type (might be due to invalid IL or missing references) - //IL_0055: Unknown result type (might be due to invalid IL or missing references) - //IL_005a: Unknown result type (might be due to invalid IL or missing references) - //IL_0064: Unknown result type (might be due to invalid IL or missing references) - //IL_0065: Unknown result type (might be due to invalid IL or missing references) - //IL_006b: Unknown result type (might be due to invalid IL or missing references) - //IL_0070: Unknown result type (might be due to invalid IL or missing references) - //IL_0075: Unknown result type (might be due to invalid IL or missing references) - //IL_0076: Unknown result type (might be due to invalid IL or missing references) - //IL_007c: Unknown result type (might be due to invalid IL or missing references) - //IL_0081: Unknown result type (might be due to invalid IL or missing references) - //IL_0086: Unknown result type (might be due to invalid IL or missing references) - //IL_008f: Unknown result type (might be due to invalid IL or missing references) - //IL_0090: Unknown result type (might be due to invalid IL or missing references) - //IL_0096: Unknown result type (might be due to invalid IL or missing references) - //IL_009b: Unknown result type (might be due to invalid IL or missing references) - //IL_00a0: Unknown result type (might be due to invalid IL or missing references) - //IL_00a1: Unknown result type (might be due to invalid IL or missing references) - //IL_00a7: Unknown result type (might be due to invalid IL or missing references) - //IL_00ac: Unknown result type (might be due to invalid IL or missing references) - //IL_00b1: 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_00cc: Unknown result type (might be due to invalid IL or missing references) - //IL_00cd: 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_00d5: Unknown result type (might be due to invalid IL or missing references) - //IL_00da: Unknown result type (might be due to invalid IL or missing references) - //IL_00dc: Unknown result type (might be due to invalid IL or missing references) - //IL_00de: Unknown result type (might be due to invalid IL or missing references) - //IL_00fd: Unknown result type (might be due to invalid IL or missing references) - //IL_0106: Unknown result type (might be due to invalid IL or missing references) - if (!((Object)(object)avatarObject == (Object)null)) - { - RegionStats regionStats = ComputeNeckRegionStats(avatarObject.transform, avatarBakedBodyMeshes, avatarBoneMap); - if (regionStats.length < 0.0001f) - { - Debug.LogWarning((object)$"[AvatarBodyMatchUtil] DrawNeckPcaDebug: neck.length가 너무 작음. avatar={((Object)avatarObject).name}, length={regionStats.length}"); - return; - } - Vector3 center = regionStats.center; - Vector3 normalized = ((Vector3)(ref regionStats.principalAxis)).normalized; - float num = 0.02f * axisScale; - Debug.DrawLine(center + Vector3.up * num, center - Vector3.up * num, centerColor, duration); - Debug.DrawLine(center + Vector3.right * num, center - Vector3.right * num, centerColor, duration); - float num2 = regionStats.length * 0.5f * axisScale; - Vector3 val = center + normalized * num2; - Debug.DrawLine(center, val, axisColor, duration); - Debug.Log((object)$"[AvatarBodyMatchUtil] DrawNeckPcaDebug: avatar={((Object)avatarObject).name}, center={center}, axis={normalized}, halfLen={num2}"); - } - } + public void DrawTorsoPcaDebug(GameObject avatarObject, IReadOnlyList avatarBakedBodyMeshes, Dictionary> avatarBoneMap, Color centerColor, Color axisColor, float axisScale = 1f, float duration = 0.1f) + { + //IL_0048: Unknown result type (might be due to invalid IL or missing references) + //IL_004d: Unknown result type (might be due to invalid IL or missing references) + //IL_0055: Unknown result type (might be due to invalid IL or missing references) + //IL_005a: Unknown result type (might be due to invalid IL or missing references) + //IL_0064: Unknown result type (might be due to invalid IL or missing references) + //IL_0065: Unknown result type (might be due to invalid IL or missing references) + //IL_006b: Unknown result type (might be due to invalid IL or missing references) + //IL_0070: Unknown result type (might be due to invalid IL or missing references) + //IL_0075: Unknown result type (might be due to invalid IL or missing references) + //IL_0076: Unknown result type (might be due to invalid IL or missing references) + //IL_007c: Unknown result type (might be due to invalid IL or missing references) + //IL_0081: Unknown result type (might be due to invalid IL or missing references) + //IL_0086: Unknown result type (might be due to invalid IL or missing references) + //IL_008f: Unknown result type (might be due to invalid IL or missing references) + //IL_0090: Unknown result type (might be due to invalid IL or missing references) + //IL_0096: Unknown result type (might be due to invalid IL or missing references) + //IL_009b: Unknown result type (might be due to invalid IL or missing references) + //IL_00a0: Unknown result type (might be due to invalid IL or missing references) + //IL_00a1: Unknown result type (might be due to invalid IL or missing references) + //IL_00a7: Unknown result type (might be due to invalid IL or missing references) + //IL_00ac: Unknown result type (might be due to invalid IL or missing references) + //IL_00b1: 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_00cc: Unknown result type (might be due to invalid IL or missing references) + //IL_00cd: 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_00d5: Unknown result type (might be due to invalid IL or missing references) + //IL_00da: Unknown result type (might be due to invalid IL or missing references) + //IL_00dc: Unknown result type (might be due to invalid IL or missing references) + //IL_00de: Unknown result type (might be due to invalid IL or missing references) + //IL_00fd: Unknown result type (might be due to invalid IL or missing references) + //IL_0106: Unknown result type (might be due to invalid IL or missing references) + if (!((Object)(object)avatarObject == (Object)null)) + { + RegionStats regionStats = this.ComputeNeckRegionStats(avatarObject.transform, avatarBakedBodyMeshes, avatarBoneMap); + if (regionStats.length < 0.0001f) + { + Debug.LogWarning((object)$"[AvatarBodyMatchUtil] DrawNeckPcaDebug: neck.length가 너무 작음. avatar={((Object)avatarObject).name}, length={regionStats.length}"); + return; + } + Vector3 center = regionStats.center; + Vector3 normalized = regionStats.principalAxis.normalized; + float num = 0.02f * axisScale; + Debug.DrawLine(center + Vector3.up * num, center - Vector3.up * num, centerColor, duration); + Debug.DrawLine(center + Vector3.right * num, center - Vector3.right * num, centerColor, duration); + float num2 = regionStats.length * 0.5f * axisScale; + Vector3 val = center + normalized * num2; + Debug.DrawLine(center, val, axisColor, duration); + Debug.Log((object)$"[AvatarBodyMatchUtil] DrawNeckPcaDebug: avatar={((Object)avatarObject).name}, center={center}, axis={normalized}, halfLen={num2}"); + } + } } diff --git a/Assets/@Eden_Tools/Eden_AutoMorpher/Script/BodyPoseToClothApplier.cs b/Assets/@Eden_Tools/Eden_AutoMorpher/Script/BodyPoseToClothApplier.cs index 2908de3..1836535 100644 --- a/Assets/@Eden_Tools/Eden_AutoMorpher/Script/BodyPoseToClothApplier.cs +++ b/Assets/@Eden_Tools/Eden_AutoMorpher/Script/BodyPoseToClothApplier.cs @@ -1,265 +1,264 @@ -// Warning: Some assembly references could not be resolved automatically. This might lead to incorrect decompilation of some parts, +// 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.BodyPoseToClothApplier using System.Collections.Generic; using System.Linq; -using Eden.AutoMorpher; using UnityEngine; public class BodyPoseToClothApplier { - private class BoneMapping - { - public Transform proxyBone; + private class BoneMapping + { + public Transform proxyBone; - public Transform clothBone; + public Transform clothBone; - public int depth; + public int depth; - public HumanBodyBones? humanBone; - } + public HumanBodyBones? humanBone; + } - public void ApplyBodyPoseToClothes(Transform bodyProxyRoot, Transform clothesRoot, Dictionary clothToBodyMatched, Dictionary sourceToProxy, bool copyPosition = true, bool copyRotation = false, bool copyScale = true) - { - //IL_0063: Unknown result type (might be due to invalid IL or missing references) - //IL_011e: Unknown result type (might be due to invalid IL or missing references) - //IL_0123: Unknown result type (might be due to invalid IL or missing references) - //IL_0169: Unknown result type (might be due to invalid IL or missing references) - //IL_016d: Invalid comparison between Unknown and I4 - //IL_017b: Unknown result type (might be due to invalid IL or missing references) - //IL_0256: Unknown result type (might be due to invalid IL or missing references) - //IL_0272: Unknown result type (might be due to invalid IL or missing references) - //IL_028e: Unknown result type (might be due to invalid IL or missing references) - if ((Object)(object)bodyProxyRoot == (Object)null) - { - throw new AutoMorpherException("Body Proxy Root is Missing", "[BodyToClothPoseApplier] ApplyDeformedProxyPoseToCloth\n - bodyProxyRoot is null"); - } - if ((Object)(object)clothesRoot == (Object)null) - { - throw new AutoMorpherException("Clothes Root is Missing", "[BodyToClothPoseApplier] ApplyDeformedProxyPoseToCloth\n - clothesRoot is null"); - } - if (clothToBodyMatched == null || clothToBodyMatched.Count == 0) - { - throw new AutoMorpherException("Cloth To Body Matched Map is Missing", "[BodyToClothPoseApplier] ApplyDeformedProxyPoseToCloth\n - clothToBodyMatched is null or empty"); - } - if (sourceToProxy == null) - { - throw new AutoMorpherException("Source To Proxy Map is Missing", "[BodyToClothPoseApplier] ApplyDeformedProxyPoseToCloth\n - sourceToProxy is null"); - } - clothesRoot.localScale = bodyProxyRoot.localScale; - Animator component = ((Component)bodyProxyRoot).GetComponent(); - if ((Object)(object)component == (Object)null) - { - throw new AutoMorpherException("Body Proxy Animator is Missing", "[BodyToClothPoseApplier] ApplyDeformedProxyPoseToCloth\n - bodyProxyRoot has no Animator"); - } - Transform transform = ((Component)component).transform; - Dictionary dictionary = BuildDepthMap(transform); - Dictionary dictionary2 = new Dictionary(); - List list = new List(); - HashSet hashSet = new HashSet(); - foreach (KeyValuePair item in clothToBodyMatched) - { - Transform key = item.Key; - BoneMatchUtil.BoneRootLocalData value = item.Value; - if ((Object)(object)key == (Object)null || value == null) - { - continue; - } - Transform t = value.t; - if ((Object)(object)t == (Object)null || !sourceToProxy.TryGetValue(t, out var value2) || (Object)(object)value2 == (Object)null) - { - continue; - } - HumanBodyBones hBone = value.hBone; - if (hashSet.Add(key)) - { - int depth = 999; - if (dictionary != null && dictionary.TryGetValue(value2, out var value3)) - { - depth = value3; - } - list.Add(new BoneMapping - { - proxyBone = value2, - clothBone = key, - depth = depth, - humanBone = (((int)hBone != 55) ? new HumanBodyBones?(hBone) : ((HumanBodyBones?)null)) - }); - } - if (!dictionary2.ContainsKey(value2)) - { - dictionary2.Add(value2, key); - } - } - MirrorBoneMarkers(transform, dictionary2, dictionary, list); - foreach (BoneMapping item2 in (from m in list - where m != null && (Object)(object)m.proxyBone != (Object)null && (Object)(object)m.clothBone != (Object)null - orderby m.depth - select m).ToList()) - { - if (!((Object)(object)item2.proxyBone == (Object)null) && !((Object)(object)item2.clothBone == (Object)null)) - { - if (copyPosition) - { - item2.clothBone.position = item2.proxyBone.position; - } - if (copyRotation) - { - item2.clothBone.rotation = item2.proxyBone.rotation; - } - if (copyScale) - { - item2.clothBone.localScale = item2.proxyBone.localScale; - } - } - } - } + public void ApplyBodyPoseToClothes(Transform bodyProxyRoot, Transform clothesRoot, Dictionary clothToBodyMatched, Dictionary sourceToProxy, bool copyPosition = true, bool copyRotation = false, bool copyScale = true) + { + //IL_0063: Unknown result type (might be due to invalid IL or missing references) + //IL_011e: Unknown result type (might be due to invalid IL or missing references) + //IL_0123: Unknown result type (might be due to invalid IL or missing references) + //IL_0169: Unknown result type (might be due to invalid IL or missing references) + //IL_016d: Invalid comparison between Unknown and I4 + //IL_017b: Unknown result type (might be due to invalid IL or missing references) + //IL_0256: Unknown result type (might be due to invalid IL or missing references) + //IL_0272: Unknown result type (might be due to invalid IL or missing references) + //IL_028e: Unknown result type (might be due to invalid IL or missing references) + if ((Object)(object)bodyProxyRoot == (Object)null) + { + throw new AutoMorpherException("Body Proxy Root is Missing", "[BodyToClothPoseApplier] ApplyDeformedProxyPoseToCloth\n - bodyProxyRoot is null"); + } + if ((Object)(object)clothesRoot == (Object)null) + { + throw new AutoMorpherException("Clothes Root is Missing", "[BodyToClothPoseApplier] ApplyDeformedProxyPoseToCloth\n - clothesRoot is null"); + } + if (clothToBodyMatched == null || clothToBodyMatched.Count == 0) + { + throw new AutoMorpherException("Cloth To Body Matched Map is Missing", "[BodyToClothPoseApplier] ApplyDeformedProxyPoseToCloth\n - clothToBodyMatched is null or empty"); + } + if (sourceToProxy == null) + { + throw new AutoMorpherException("Source To Proxy Map is Missing", "[BodyToClothPoseApplier] ApplyDeformedProxyPoseToCloth\n - sourceToProxy is null"); + } + clothesRoot.localScale = bodyProxyRoot.localScale; + Animator component = ((Component)bodyProxyRoot).GetComponent(); + if ((Object)(object)component == (Object)null) + { + throw new AutoMorpherException("Body Proxy Animator is Missing", "[BodyToClothPoseApplier] ApplyDeformedProxyPoseToCloth\n - bodyProxyRoot has no Animator"); + } + Transform transform = ((Component)component).transform; + Dictionary dictionary = this.BuildDepthMap(transform); + Dictionary dictionary2 = new Dictionary(); + List list = new List(); + HashSet hashSet = new HashSet(); + foreach (KeyValuePair item in clothToBodyMatched) + { + Transform key = item.Key; + BoneMatchUtil.BoneRootLocalData value = item.Value; + if ((Object)(object)key == (Object)null || value == null) + { + continue; + } + Transform t = value.t; + if ((Object)(object)t == (Object)null || !sourceToProxy.TryGetValue(t, out var value2) || (Object)(object)value2 == (Object)null) + { + continue; + } + HumanBodyBones hBone = value.hBone; + if (hashSet.Add(key)) + { + int depth = 999; + if (dictionary != null && dictionary.TryGetValue(value2, out var value3)) + { + depth = value3; + } + list.Add(new BoneMapping + { + proxyBone = value2, + clothBone = key, + depth = depth, + humanBone = (((int)hBone != 55) ? new HumanBodyBones?(hBone) : ((HumanBodyBones?)null)) + }); + } + if (!dictionary2.ContainsKey(value2)) + { + dictionary2.Add(value2, key); + } + } + this.MirrorBoneMarkers(transform, dictionary2, dictionary, list); + foreach (BoneMapping item2 in (from m in list + where m != null && (Object)(object)m.proxyBone != (Object)null && (Object)(object)m.clothBone != (Object)null + orderby m.depth + select m).ToList()) + { + if (!((Object)(object)item2.proxyBone == (Object)null) && !((Object)(object)item2.clothBone == (Object)null)) + { + if (copyPosition) + { + item2.clothBone.position = item2.proxyBone.position; + } + if (copyRotation) + { + item2.clothBone.rotation = item2.proxyBone.rotation; + } + if (copyScale) + { + item2.clothBone.localScale = item2.proxyBone.localScale; + } + } + } + } - private Dictionary BuildDepthMap(Transform root) - { - Dictionary dictionary = new Dictionary(); - if ((Object)(object)root == (Object)null) - { - return dictionary; - } - Transform[] componentsInChildren = ((Component)root).GetComponentsInChildren(true); - foreach (Transform val in componentsInChildren) - { - if (!((Object)(object)val == (Object)null)) - { - dictionary[val] = GetDepthFromRoot(val, root); - } - } - return dictionary; - } + private Dictionary BuildDepthMap(Transform root) + { + Dictionary dictionary = new Dictionary(); + if ((Object)(object)root == (Object)null) + { + return dictionary; + } + Transform[] componentsInChildren = ((Component)root).GetComponentsInChildren(true); + foreach (Transform val in componentsInChildren) + { + if (!((Object)(object)val == (Object)null)) + { + dictionary[val] = this.GetDepthFromRoot(val, root); + } + } + return dictionary; + } - private int GetDepthFromRoot(Transform t, Transform root) - { - int num = 0; - Transform val = t; - while ((Object)(object)val != (Object)null && (Object)(object)val != (Object)(object)root) - { - num++; - val = val.parent; - } - return num; - } + private int GetDepthFromRoot(Transform t, Transform root) + { + int num = 0; + Transform val = t; + while ((Object)(object)val != (Object)null && (Object)(object)val != (Object)(object)root) + { + num++; + val = val.parent; + } + return num; + } - private void MirrorBoneMarkers(Transform proxyArmature, Dictionary proxyToCloth, Dictionary proxyDepthMap, List mappings) - { - //IL_0133: 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_0174: Unknown result type (might be due to invalid IL or missing references) - //IL_0182: Unknown result type (might be due to invalid IL or missing references) - if ((Object)(object)proxyArmature == (Object)null || proxyToCloth == null || mappings == null) - { - return; - } - TempBoneMarker[] componentsInChildren = ((Component)proxyArmature).GetComponentsInChildren(true); - if (componentsInChildren == null || componentsInChildren.Length == 0) - { - return; - } - HashSet hashSet = new HashSet(); - for (int i = 0; i < mappings.Count; i++) - { - BoneMapping boneMapping = mappings[i]; - if (boneMapping != null && (Object)(object)boneMapping.proxyBone != (Object)null) - { - hashSet.Add(boneMapping.proxyBone); - } - } - int value3; - foreach (TempBoneMarker item in (from bm in componentsInChildren - where (Object)(object)bm != (Object)null && (Object)(object)((Component)bm).transform != (Object)null - orderby (proxyDepthMap != null && proxyDepthMap.TryGetValue(((Component)bm).transform, out value3)) ? value3 : int.MaxValue - select bm).ToList()) - { - Transform transform = ((Component)item).transform; - if ((Object)(object)transform == (Object)null) - { - continue; - } - Transform originalParent = item.originalParent; - if ((Object)(object)originalParent == (Object)null || !proxyToCloth.TryGetValue(originalParent, out var value) || (Object)(object)value == (Object)null) - { - continue; - } - List list = CollectDirectChilds(value); - Transform val = FindMarkerInChild(value); - TempBoneMarker tempBoneMarker = null; - if ((Object)(object)val == (Object)null) - { - val = new GameObject(((Object)transform).name).transform; - val.SetParent(value, true); - tempBoneMarker = ((Component)val).gameObject.AddComponent(); - } - else - { - tempBoneMarker = ((Component)val).GetComponent(); - } - val.position = transform.position; - val.rotation = transform.rotation; - val.localScale = transform.localScale; - tempBoneMarker.originalParent = value; - tempBoneMarker.additionalInfo = item.additionalInfo; - tempBoneMarker.wrappedChildNames = item.wrappedChildNames; - for (int num = 0; num < list.Count; num++) - { - Transform val2 = list[num]; - if (!((Object)(object)val2 == (Object)null) && !((Object)(object)val2 == (Object)(object)val)) - { - val2.SetParent(val, true); - } - } - if (!proxyToCloth.ContainsKey(transform)) - { - proxyToCloth.Add(transform, val); - } - if (hashSet.Add(transform)) - { - int depth = 999; - if (proxyDepthMap != null && proxyDepthMap.TryGetValue(transform, out var value2)) - { - depth = value2; - } - mappings.Add(new BoneMapping - { - proxyBone = transform, - clothBone = val, - depth = depth, - humanBone = null - }); - } - } - } + private void MirrorBoneMarkers(Transform proxyArmature, Dictionary proxyToCloth, Dictionary proxyDepthMap, List mappings) + { + //IL_0133: 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_0174: Unknown result type (might be due to invalid IL or missing references) + //IL_0182: Unknown result type (might be due to invalid IL or missing references) + if ((Object)(object)proxyArmature == (Object)null || proxyToCloth == null || mappings == null) + { + return; + } + TempBoneMarker[] componentsInChildren = ((Component)proxyArmature).GetComponentsInChildren(true); + if (componentsInChildren == null || componentsInChildren.Length == 0) + { + return; + } + HashSet hashSet = new HashSet(); + for (int i = 0; i < mappings.Count; i++) + { + BoneMapping boneMapping = mappings[i]; + if (boneMapping != null && (Object)(object)boneMapping.proxyBone != (Object)null) + { + hashSet.Add(boneMapping.proxyBone); + } + } + int value3; + foreach (TempBoneMarker item in (from bm in componentsInChildren + where (Object)(object)bm != (Object)null && (Object)(object)((Component)bm).transform != (Object)null + orderby (proxyDepthMap != null && proxyDepthMap.TryGetValue(((Component)bm).transform, out value3)) ? value3 : int.MaxValue + select bm).ToList()) + { + Transform transform = ((Component)item).transform; + if ((Object)(object)transform == (Object)null) + { + continue; + } + Transform originalParent = item.originalParent; + if ((Object)(object)originalParent == (Object)null || !proxyToCloth.TryGetValue(originalParent, out var value) || (Object)(object)value == (Object)null) + { + continue; + } + List list = this.CollectDirectChilds(value); + Transform val = this.FindMarkerInChild(value); + TempBoneMarker tempBoneMarker = null; + if ((Object)(object)val == (Object)null) + { + val = new GameObject(((Object)transform).name).transform; + val.SetParent(value, true); + tempBoneMarker = ((Component)val).gameObject.AddComponent(); + } + else + { + tempBoneMarker = ((Component)val).GetComponent(); + } + val.position = transform.position; + val.rotation = transform.rotation; + val.localScale = transform.localScale; + tempBoneMarker.originalParent = value; + tempBoneMarker.additionalInfo = item.additionalInfo; + tempBoneMarker.wrappedChildNames = item.wrappedChildNames; + for (int num = 0; num < list.Count; num++) + { + Transform val2 = list[num]; + if (!((Object)(object)val2 == (Object)null) && !((Object)(object)val2 == (Object)(object)val)) + { + val2.SetParent(val, true); + } + } + if (!proxyToCloth.ContainsKey(transform)) + { + proxyToCloth.Add(transform, val); + } + if (hashSet.Add(transform)) + { + int depth = 999; + if (proxyDepthMap != null && proxyDepthMap.TryGetValue(transform, out var value2)) + { + depth = value2; + } + mappings.Add(new BoneMapping + { + proxyBone = transform, + clothBone = val, + depth = depth, + humanBone = null + }); + } + } + } - private Transform FindMarkerInChild(Transform parent) - { - if ((Object)(object)parent == (Object)null) - { - return null; - } - for (int i = 0; i < parent.childCount; i++) - { - Transform child = parent.GetChild(i); - if (!((Object)(object)child == (Object)null) && (Object)(object)((Component)child).GetComponent() != (Object)null) - { - return child; - } - } - return null; - } + private Transform FindMarkerInChild(Transform parent) + { + if ((Object)(object)parent == (Object)null) + { + return null; + } + for (int i = 0; i < parent.childCount; i++) + { + Transform child = parent.GetChild(i); + if (!((Object)(object)child == (Object)null) && (Object)(object)((Component)child).GetComponent() != (Object)null) + { + return child; + } + } + return null; + } - private List CollectDirectChilds(Transform parentTransform) - { - int childCount = parentTransform.childCount; - List list = new List(childCount); - for (int i = 0; i < childCount; i++) - { - list.Add(parentTransform.GetChild(i)); - } - return list; - } + private List CollectDirectChilds(Transform parentTransform) + { + int childCount = parentTransform.childCount; + List list = new List(childCount); + for (int i = 0; i < childCount; i++) + { + list.Add(parentTransform.GetChild(i)); + } + return list; + } } diff --git a/Assets/@Eden_Tools/Eden_AutoMorpher/Script/BoneAlignmentUtil.cs b/Assets/@Eden_Tools/Eden_AutoMorpher/Script/BoneAlignmentUtil.cs index 2b9a0dd..98cdf6e 100644 --- a/Assets/@Eden_Tools/Eden_AutoMorpher/Script/BoneAlignmentUtil.cs +++ b/Assets/@Eden_Tools/Eden_AutoMorpher/Script/BoneAlignmentUtil.cs @@ -1,180 +1,179 @@ -// Warning: Some assembly references could not be resolved automatically. This might lead to incorrect decompilation of some parts, +// 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.BoneAlignmentUtil using System.Collections.Generic; using System.Linq; -using Eden.AutoMorpher; using UnityEngine; public class BoneAlignmentUtil { - public void AlignClothBonesToAvatar(ClothInstance cloth, Animator targetAvatarAnimator) - { - //IL_0032: Unknown result type (might be due to invalid IL or missing references) - //IL_0037: Unknown result type (might be due to invalid IL or missing references) - //IL_005b: Unknown result type (might be due to invalid IL or missing references) - //IL_0071: Unknown result type (might be due to invalid IL or missing references) - //IL_007d: Unknown result type (might be due to invalid IL or missing references) - if (cloth == null || (Object)(object)targetAvatarAnimator == (Object)null) - { - Debug.LogWarning((object)"[BoneAlignmentUtil] cloth 또는 targetAvatarAnimator 가 null."); - return; - } - foreach (KeyValuePair> humanoidMatchedBone in cloth.humanoidMatchedBones) - { - HumanBodyBones key = humanoidMatchedBone.Key; - foreach (Transform item in humanoidMatchedBone.Value) - { - if (!((Object)(object)item == (Object)null)) - { - Transform boneTransform = targetAvatarAnimator.GetBoneTransform(key); - if (!((Object)(object)boneTransform == (Object)null)) - { - item.position = boneTransform.position; - item.localScale = Vector3.one; - ((Object)item).name = ((Object)boneTransform).name; - } - } - } - } - } + public void AlignClothBonesToAvatar(ClothInstance cloth, Animator targetAvatarAnimator) + { + //IL_0032: Unknown result type (might be due to invalid IL or missing references) + //IL_0037: Unknown result type (might be due to invalid IL or missing references) + //IL_005b: Unknown result type (might be due to invalid IL or missing references) + //IL_0071: Unknown result type (might be due to invalid IL or missing references) + //IL_007d: Unknown result type (might be due to invalid IL or missing references) + if (cloth == null || (Object)(object)targetAvatarAnimator == (Object)null) + { + Debug.LogWarning((object)"[BoneAlignmentUtil] cloth 또는 targetAvatarAnimator 가 null."); + return; + } + foreach (KeyValuePair> humanoidMatchedBone in cloth.humanoidMatchedBones) + { + HumanBodyBones key = humanoidMatchedBone.Key; + foreach (Transform item in humanoidMatchedBone.Value) + { + if (!((Object)(object)item == (Object)null)) + { + Transform boneTransform = targetAvatarAnimator.GetBoneTransform(key); + if (!((Object)(object)boneTransform == (Object)null)) + { + item.position = boneTransform.position; + item.localScale = Vector3.one; + ((Object)item).name = ((Object)boneTransform).name; + } + } + } + } + } - public void ReparentAccessoryBonesToAvatar(EdenAutoMorpherConfig config) - { - //IL_005e: Unknown result type (might be due to invalid IL or missing references) - //IL_0063: Unknown result type (might be due to invalid IL or missing references) - //IL_007f: Unknown result type (might be due to invalid IL or missing references) - //IL_01fa: Unknown result type (might be due to invalid IL or missing references) - //IL_0201: Expected O, but got Unknown - if (config.clothBoneTypeMap == null || (Object)(object)config.targetAvatarObject == (Object)null) - { - return; - } - Animator component = config.targetAvatarObject.GetComponent(); - if ((Object)(object)component == (Object)null || !component.isHuman) - { - return; - } - Dictionary dictionary = new Dictionary(); - if (config.clothesHumanoidMatchedBones != null) - { - foreach (KeyValuePair> clothesHumanoidMatchedBone in config.clothesHumanoidMatchedBones) - { - HumanBodyBones key = clothesHumanoidMatchedBone.Key; - foreach (Transform item2 in clothesHumanoidMatchedBone.Value) - { - Transform boneTransform = component.GetBoneTransform(key); - if ((Object)(object)item2 != (Object)null && (Object)(object)boneTransform != (Object)null) - { - dictionary[item2] = boneTransform; - } - } - } - } - foreach (KeyValuePair item3 in config.clothBoneTypeMap) - { - if (item3.Value != ClothBoneType.Accessory) - { - continue; - } - Transform key2 = item3.Key; - if ((Object)(object)key2 == (Object)null || !key2.IsChildOf(config.targetClothesObject.transform)) - { - continue; - } - Transform parent = key2.parent; - Transform val = null; - while ((Object)(object)parent != (Object)null) - { - if (config.clothBoneTypeMap.TryGetValue(parent, out var value) && value == ClothBoneType.Body) - { - val = parent; - break; - } - parent = parent.parent; - } - if (!((Object)(object)val == (Object)null) && dictionary.TryGetValue(val, out var value2)) - { - key2.SetParent(value2, true); - } - } - foreach (KeyValuePair item4 in dictionary) - { - Transform key3 = item4.Key; - Transform value3 = item4.Value; - if ((Object)(object)key3 == (Object)null || (Object)(object)value3 == (Object)null) - { - continue; - } - List list = new List(); - foreach (Transform item5 in key3) - { - Transform item = item5; - list.Add(item); - } - foreach (Transform item6 in list) - { - if (!((Object)(object)item6 == (Object)null) && !config.clothBoneTypeMap.ContainsKey(item6)) - { - item6.SetParent(value3, true); - } - } - } - } + public void ReparentAccessoryBonesToAvatar(EdenAutoMorpherConfig config) + { + //IL_005e: Unknown result type (might be due to invalid IL or missing references) + //IL_0063: Unknown result type (might be due to invalid IL or missing references) + //IL_007f: Unknown result type (might be due to invalid IL or missing references) + //IL_01fa: Unknown result type (might be due to invalid IL or missing references) + //IL_0201: Expected O, but got Unknown + if (config.clothBoneTypeMap == null || (Object)(object)config.targetAvatarObject == (Object)null) + { + return; + } + Animator component = config.targetAvatarObject.GetComponent(); + if ((Object)(object)component == (Object)null || !component.isHuman) + { + return; + } + Dictionary dictionary = new Dictionary(); + if (config.clothesHumanoidMatchedBones != null) + { + foreach (KeyValuePair> clothesHumanoidMatchedBone in config.clothesHumanoidMatchedBones) + { + HumanBodyBones key = clothesHumanoidMatchedBone.Key; + foreach (Transform item2 in clothesHumanoidMatchedBone.Value) + { + Transform boneTransform = component.GetBoneTransform(key); + if ((Object)(object)item2 != (Object)null && (Object)(object)boneTransform != (Object)null) + { + dictionary[item2] = boneTransform; + } + } + } + } + foreach (KeyValuePair item3 in config.clothBoneTypeMap) + { + if (item3.Value != ClothBoneType.Accessory) + { + continue; + } + Transform key2 = item3.Key; + if ((Object)(object)key2 == (Object)null || !key2.IsChildOf(config.targetClothesObject.transform)) + { + continue; + } + Transform parent = key2.parent; + Transform val = null; + while ((Object)(object)parent != (Object)null) + { + if (config.clothBoneTypeMap.TryGetValue(parent, out var value) && value == ClothBoneType.Body) + { + val = parent; + break; + } + parent = parent.parent; + } + if (!((Object)(object)val == (Object)null) && dictionary.TryGetValue(val, out var value2)) + { + key2.SetParent(value2, true); + } + } + foreach (KeyValuePair item4 in dictionary) + { + Transform key3 = item4.Key; + Transform value3 = item4.Value; + if ((Object)(object)key3 == (Object)null || (Object)(object)value3 == (Object)null) + { + continue; + } + List list = new List(); + foreach (Transform item5 in key3) + { + Transform item = item5; + list.Add(item); + } + foreach (Transform item6 in list) + { + if (!((Object)(object)item6 == (Object)null) && !config.clothBoneTypeMap.ContainsKey(item6)) + { + item6.SetParent(value3, true); + } + } + } + } - public void CleanupTempBones(Transform root) - { - if ((Object)(object)root == (Object)null) - { - return; - } - TempBoneMarker[] componentsInChildren = ((Component)root).GetComponentsInChildren(true); - if (componentsInChildren == null || componentsInChildren.Length == 0) - { - return; - } - TempBoneMarker[] array = (from m in componentsInChildren - where (Object)(object)m != (Object)null - orderby GetDepth(((Component)m).transform) descending - select m).ToArray(); - foreach (TempBoneMarker tempBoneMarker in array) - { - if ((Object)(object)tempBoneMarker == (Object)null) - { - continue; - } - Transform transform = ((Component)tempBoneMarker).transform; - Transform val = tempBoneMarker.originalParent; - if ((Object)(object)val == (Object)null) - { - val = transform.parent; - } - if ((Object)(object)val != (Object)null) - { - while (transform.childCount > 0) - { - transform.GetChild(0).SetParent(val, true); - } - } - if (!Application.isPlaying) - { - Object.DestroyImmediate((Object)(object)((Component)transform).gameObject); - } - else - { - Object.Destroy((Object)(object)((Component)transform).gameObject); - } - } - int GetDepth(Transform t) - { - int num2 = 0; - while ((Object)(object)t != (Object)null) - { - num2++; - t = t.parent; - } - return num2; - } - } + public void CleanupTempBones(Transform root) + { + if ((Object)(object)root == (Object)null) + { + return; + } + TempBoneMarker[] componentsInChildren = ((Component)root).GetComponentsInChildren(true); + if (componentsInChildren == null || componentsInChildren.Length == 0) + { + return; + } + TempBoneMarker[] array = (from m in componentsInChildren + where (Object)(object)m != (Object)null + orderby GetDepth(((Component)m).transform) descending + select m).ToArray(); + foreach (TempBoneMarker tempBoneMarker in array) + { + if ((Object)(object)tempBoneMarker == (Object)null) + { + continue; + } + Transform transform = ((Component)tempBoneMarker).transform; + Transform val = tempBoneMarker.originalParent; + if ((Object)(object)val == (Object)null) + { + val = transform.parent; + } + if ((Object)(object)val != (Object)null) + { + while (transform.childCount > 0) + { + transform.GetChild(0).SetParent(val, true); + } + } + if (!Application.isPlaying) + { + Object.DestroyImmediate((Object)(object)((Component)transform).gameObject); + } + else + { + Object.Destroy((Object)(object)((Component)transform).gameObject); + } + } + int GetDepth(Transform t) + { + int num2 = 0; + while ((Object)(object)t != (Object)null) + { + num2++; + t = t.parent; + } + return num2; + } + } } diff --git a/Assets/@Eden_Tools/Eden_AutoMorpher/Script/BoneCorrespondenceUtil.cs b/Assets/@Eden_Tools/Eden_AutoMorpher/Script/BoneCorrespondenceUtil.cs index 2df4eb0..e721450 100644 --- a/Assets/@Eden_Tools/Eden_AutoMorpher/Script/BoneCorrespondenceUtil.cs +++ b/Assets/@Eden_Tools/Eden_AutoMorpher/Script/BoneCorrespondenceUtil.cs @@ -1,4 +1,4 @@ -// Warning: Some assembly references could not be resolved automatically. This might lead to incorrect decompilation of some parts, +// 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.BoneCorrespondenceUtil @@ -9,187 +9,187 @@ using UnityEngine; public class BoneCorrespondenceUtil { - private char[] nameDelims = new char[8] { ' ', '-', '_', ':', '.', '|', '\\', '/' }; + private char[] nameDelims = new char[8] { ' ', '-', '_', ':', '.', '|', '\\', '/' }; - public float ComputeDistanceScore(float d, float near, float mid, float far) - { - if (d < near) - { - return 120f; - } - if (d < mid) - { - return 90f; - } - if (d < far) - { - return 50f; - } - return 0f; - } + public float ComputeDistanceScore(float d, float near, float mid, float far) + { + if (d < near) + { + return 120f; + } + if (d < mid) + { + return 90f; + } + if (d < far) + { + return 50f; + } + return 0f; + } - public float ComputeRotationScore(float ang, float RotTolDeg) - { - return Mathf.Clamp01(1f - ang / RotTolDeg); - } + public float ComputeRotationScore(float ang, float RotTolDeg) + { + return Mathf.Clamp01(1f - ang / RotTolDeg); + } - public float ComputeNameScore(string bodyName, string bodyPath, string clothesName, string clothesPath) - { - string text = StripDigits(NormalizeName(bodyName)); - string text2 = StripDigits(NormalizeName(clothesName)); - string text3 = StripDigits(NormalizePath(bodyPath)); - string text4 = StripDigits(NormalizePath(clothesPath)); - if (!string.IsNullOrEmpty(text3) && text3 == text4) - { - return 80f; - } - if (!string.IsNullOrEmpty(text) && text == text2) - { - return 70f; - } - if (!string.IsNullOrEmpty(text) && !string.IsNullOrEmpty(text2) && (text.Contains(text2) || text2.Contains(text))) - { - return 40f; - } - return SubsequenceCoverage(bodyName, clothesName) * 10f; - } + public float ComputeNameScore(string bodyName, string bodyPath, string clothesName, string clothesPath) + { + string text = this.StripDigits(this.NormalizeName(bodyName)); + string text2 = this.StripDigits(this.NormalizeName(clothesName)); + string text3 = this.StripDigits(this.NormalizePath(bodyPath)); + string text4 = this.StripDigits(this.NormalizePath(clothesPath)); + if (!string.IsNullOrEmpty(text3) && text3 == text4) + { + return 80f; + } + if (!string.IsNullOrEmpty(text) && text == text2) + { + return 70f; + } + if (!string.IsNullOrEmpty(text) && !string.IsNullOrEmpty(text2) && (text.Contains(text2) || text2.Contains(text))) + { + return 40f; + } + return this.SubsequenceCoverage(bodyName, clothesName) * 10f; + } - private float SubsequenceCoverage(string bodyRaw, string clothesRaw) - { - string text = StripDigits(NormalizeName(bodyRaw)); - string text2 = StripDigits(NormalizeName(clothesRaw)); - if (string.IsNullOrEmpty(text) || string.IsNullOrEmpty(text2)) - { - return 0f; - } - return (float)SubNameMatchBest(text, text2) / (float)text.Length; - } + private float SubsequenceCoverage(string bodyRaw, string clothesRaw) + { + string text = this.StripDigits(this.NormalizeName(bodyRaw)); + string text2 = this.StripDigits(this.NormalizeName(clothesRaw)); + if (string.IsNullOrEmpty(text) || string.IsNullOrEmpty(text2)) + { + return 0f; + } + return (float)this.SubNameMatchBest(text, text2) / (float)text.Length; + } - private int SubNameMatchBest(string a, string b, int minMatchCount = 3) - { - if (string.IsNullOrEmpty(a) || string.IsNullOrEmpty(b)) - { - return 0; - } - if (a.Length < minMatchCount || b.Length < minMatchCount) - { - return 0; - } - int num = 0; - for (int i = 0; i <= a.Length - minMatchCount; i++) - { - int num2 = SubNameMatch(a, i, b, minMatchCount); - if (num2 > num) - { - num = num2; - } - } - return num; - } + private int SubNameMatchBest(string a, string b, int minMatchCount = 3) + { + if (string.IsNullOrEmpty(a) || string.IsNullOrEmpty(b)) + { + return 0; + } + if (a.Length < minMatchCount || b.Length < minMatchCount) + { + return 0; + } + int num = 0; + for (int i = 0; i <= a.Length - minMatchCount; i++) + { + int num2 = this.SubNameMatch(a, i, b, minMatchCount); + if (num2 > num) + { + num = num2; + } + } + return num; + } - private int SubNameMatch(string a, int startA, string b, int minMatchCount = 3) - { - int length = a.Length; - int length2 = b.Length; - int num = 0; - int num2 = 0; - int num3 = 0; - int num4 = 0; - for (int i = startA; i < length; i++) - { - for (int j = num3; j < length2; j++) - { - num3 = j + 1; - if (a[i] == b[j]) - { - num4 = i + 1; - num2++; - if (num2 > num) - { - num = num2; - } - break; - } - if (num2 > num) - { - num = num2; - } - num2 = 0; - } - if (num3 >= length2) - { - break; - } - } - if (num2 > num) - { - num = num2; - } - if (num < minMatchCount) - { - return 0; - } - return num4 - startA; - } + private int SubNameMatch(string a, int startA, string b, int minMatchCount = 3) + { + int length = a.Length; + int length2 = b.Length; + int num = 0; + int num2 = 0; + int num3 = 0; + int num4 = 0; + for (int i = startA; i < length; i++) + { + for (int j = num3; j < length2; j++) + { + num3 = j + 1; + if (a[i] == b[j]) + { + num4 = i + 1; + num2++; + if (num2 > num) + { + num = num2; + } + break; + } + if (num2 > num) + { + num = num2; + } + num2 = 0; + } + if (num3 >= length2) + { + break; + } + } + if (num2 > num) + { + num = num2; + } + if (num < minMatchCount) + { + return 0; + } + return num4 - startA; + } - public string GetHierarchyPath(Transform root, Transform t) - { - if ((Object)(object)t == (Object)null) - { - return ""; - } - Stack stack = new Stack(); - Transform val = t; - while ((Object)(object)val != (Object)null && (Object)(object)val != (Object)(object)root) - { - stack.Push(((Object)val).name); - val = val.parent; - } - return string.Join("/", stack); - } + public string GetHierarchyPath(Transform root, Transform t) + { + if ((Object)(object)t == (Object)null) + { + return ""; + } + Stack stack = new Stack(); + Transform val = t; + while ((Object)(object)val != (Object)null && (Object)(object)val != (Object)(object)root) + { + stack.Push(((Object)val).name); + val = val.parent; + } + return string.Join("/", stack); + } - public string NormalizeName(string s) - { - if (string.IsNullOrEmpty(s)) - { - return ""; - } - s = s.ToLowerInvariant(); - s = s.Replace("left", "l").Replace("right", "r"); - char[] array = nameDelims; - foreach (char c in array) - { - s = s.Replace(c.ToString(), ""); - } - s = StripDigits(s); - return s; - } + public string NormalizeName(string s) + { + if (string.IsNullOrEmpty(s)) + { + return ""; + } + s = s.ToLowerInvariant(); + s = s.Replace("left", "l").Replace("right", "r"); + char[] array = this.nameDelims; + foreach (char c in array) + { + s = s.Replace(c.ToString(), ""); + } + s = this.StripDigits(s); + return s; + } - public string NormalizePath(string p) - { - if (string.IsNullOrEmpty(p)) - { - return ""; - } - return string.Join("/", (from x in p.Split('/') - where !string.IsNullOrEmpty(x) - select x).Select(NormalizeName)); - } + public string NormalizePath(string p) + { + if (string.IsNullOrEmpty(p)) + { + return ""; + } + return string.Join("/", (from x in p.Split('/') + where !string.IsNullOrEmpty(x) + select x).Select(this.NormalizeName)); + } - public string StripDigits(string s) - { - if (string.IsNullOrEmpty(s)) - { - return ""; - } - StringBuilder stringBuilder = new StringBuilder(s.Length); - foreach (char c in s) - { - if (!char.IsDigit(c)) - { - stringBuilder.Append(c); - } - } - return stringBuilder.ToString(); - } + public string StripDigits(string s) + { + if (string.IsNullOrEmpty(s)) + { + return ""; + } + StringBuilder stringBuilder = new StringBuilder(s.Length); + foreach (char c in s) + { + if (!char.IsDigit(c)) + { + stringBuilder.Append(c); + } + } + return stringBuilder.ToString(); + } } diff --git a/Assets/@Eden_Tools/Eden_AutoMorpher/Script/BoneMatchUtil.cs b/Assets/@Eden_Tools/Eden_AutoMorpher/Script/BoneMatchUtil.cs index ad55ca0..b2985f8 100644 --- a/Assets/@Eden_Tools/Eden_AutoMorpher/Script/BoneMatchUtil.cs +++ b/Assets/@Eden_Tools/Eden_AutoMorpher/Script/BoneMatchUtil.cs @@ -1,654 +1,651 @@ -// Warning: Some assembly references could not be resolved automatically. This might lead to incorrect decompilation of some parts, +// 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.BoneMatchUtil using System; using System.Collections.Generic; using System.Linq; -using Eden.AutoMorpher; -using Eden.AutoMorpher.profile; using UnityEngine; public class BoneMatchUtil { - public class BoneRootLocalData - { - public Transform t; + public class BoneRootLocalData + { + public Transform t; - public string name; + public string name; - public string path; + public string path; - public Vector3 rootLocalPos; + public Vector3 rootLocalPos; - public Quaternion rootLocalRot; + public Quaternion rootLocalRot; - public HumanBodyBones hBone = (HumanBodyBones)55; - } + public HumanBodyBones hBone = (HumanBodyBones)55; + } - private const float PosTolNear = 0.0001f; + private const float PosTolNear = 0.0001f; - private const float PosTolMid = 0.0005f; + private const float PosTolMid = 0.0005f; - private const float PosTolFar = 0.002f; + private const float PosTolFar = 0.002f; - private const float RotTolDeg = 30f; + private const float RotTolDeg = 30f; - private const float eps = 1E-06f; + private const float eps = 1E-06f; - public List ConvertProfileBoneDataToRootLocalData(List boneDataList) - { - //IL_0073: Unknown result type (might be due to invalid IL or missing references) - //IL_0078: Unknown result type (might be due to invalid IL or missing references) - //IL_007f: Unknown result type (might be due to invalid IL or missing references) - //IL_0084: Unknown result type (might be due to invalid IL or missing references) - //IL_008b: Unknown result type (might be due to invalid IL or missing references) - //IL_0090: Unknown result type (might be due to invalid IL or missing references) - if (boneDataList == null || boneDataList.Count == 0) - { - throw new AutoMorpherException("Profile Bone Data is Missing", "[BoneMatchUtil] ConvertProfileBoneDataToRootLocalData\n - boneDataList is null or empty"); - } - List list = new List(boneDataList.Count); - foreach (BoneData boneData in boneDataList) - { - if (boneData != null) - { - BoneRootLocalData item = new BoneRootLocalData - { - t = null, - name = (boneData.boneName ?? string.Empty), - path = (boneData.hierarchyPath ?? string.Empty), - rootLocalPos = boneData.rootLocalPosition, - rootLocalRot = boneData.rootLocalRotation, - hBone = boneData.hBone - }; - list.Add(item); - } - } - return list; - } + public List ConvertProfileBoneDataToRootLocalData(List boneDataList) + { + //IL_0073: Unknown result type (might be due to invalid IL or missing references) + //IL_0078: Unknown result type (might be due to invalid IL or missing references) + //IL_007f: Unknown result type (might be due to invalid IL or missing references) + //IL_0084: Unknown result type (might be due to invalid IL or missing references) + //IL_008b: Unknown result type (might be due to invalid IL or missing references) + //IL_0090: Unknown result type (might be due to invalid IL or missing references) + if (boneDataList == null || boneDataList.Count == 0) + { + throw new AutoMorpherException("Profile Bone Data is Missing", "[BoneMatchUtil] ConvertProfileBoneDataToRootLocalData\n - boneDataList is null or empty"); + } + List list = new List(boneDataList.Count); + foreach (BoneData boneData in boneDataList) + { + if (boneData != null) + { + BoneRootLocalData item = new BoneRootLocalData + { + t = null, + name = (boneData.boneName ?? string.Empty), + path = (boneData.hierarchyPath ?? string.Empty), + rootLocalPos = boneData.rootLocalPosition, + rootLocalRot = boneData.rootLocalRotation, + hBone = boneData.hBone + }; + list.Add(item); + } + } + return list; + } - public HashSet GetMeshBones(List meshRenderers) - { - HashSet hashSet = new HashSet(); - if (meshRenderers != null) - { - foreach (SkinnedMeshRenderer meshRenderer in meshRenderers) - { - if ((Object)(object)meshRenderer == (Object)null || meshRenderer.bones == null) - { - continue; - } - Transform[] bones = meshRenderer.bones; - foreach (Transform val in bones) - { - if ((Object)(object)val != (Object)null) - { - hashSet.Add(val); - } - } - } - } - return hashSet; - } + public HashSet GetMeshBones(List meshRenderers) + { + HashSet hashSet = new HashSet(); + if (meshRenderers != null) + { + foreach (SkinnedMeshRenderer meshRenderer in meshRenderers) + { + if (meshRenderer == null || meshRenderer.bones == null) + { + continue; + } + Transform[] bones = meshRenderer.bones; + foreach (Transform val in bones) + { + if (val != null) + { + hashSet.Add(val); + } + } + } + } + return hashSet; + } - public List GetRootLocalBones(Transform rootT, HashSet boneList) - { - BoneCorrespondenceUtil correspondenceUtil = new BoneCorrespondenceUtil(); - return (from t in boneList.Where((Transform t) => (Object)(object)t != (Object)null).Distinct() - select new BoneRootLocalData - { - t = t, - name = ((Object)t).name, - path = correspondenceUtil.GetHierarchyPath(rootT, t), - rootLocalPos = rootT.InverseTransformPoint(t.position), - rootLocalRot = Quaternion.Inverse(rootT.rotation) * t.rotation - }).ToList(); - } + public List GetRootLocalBones(Transform rootT, HashSet boneList) + { + BoneCorrespondenceUtil correspondenceUtil = new BoneCorrespondenceUtil(); + return (from t in boneList.Where((Transform t) => t != null).Distinct() + select new BoneRootLocalData + { + t = t, + name = t.name, + path = correspondenceUtil.GetHierarchyPath(rootT, t), + rootLocalPos = rootT.InverseTransformPoint(t.position), + rootLocalRot = Quaternion.Inverse(rootT.rotation) * t.rotation + }).ToList(); + } - public List GetBodyRootLocalBones(Transform bodyTransform, Animator bodyAnimator, List bodyMeshes) - { - //IL_00b1: Unknown result type (might be due to invalid IL or missing references) - //IL_00b8: Invalid comparison between Unknown and I4 - //IL_00cc: 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_0134: Unknown result type (might be due to invalid IL or missing references) - //IL_0139: Unknown result type (might be due to invalid IL or missing references) - //IL_013b: Unknown result type (might be due to invalid IL or missing references) - //IL_013f: Invalid comparison between Unknown and I4 - //IL_015e: Unknown result type (might be due to invalid IL or missing references) - //IL_0290: Unknown result type (might be due to invalid IL or missing references) - //IL_0283: Unknown result type (might be due to invalid IL or missing references) - //IL_0285: Unknown result type (might be due to invalid IL or missing references) - if ((Object)(object)bodyTransform == (Object)null) - { - throw new AutoMorpherException("Body Transform is Missing", "[BoneMatchUtil] GetBodyRootLocalBones\n - bodyTransform is null"); - } - if ((Object)(object)bodyAnimator == (Object)null) - { - throw new AutoMorpherException("Body Animator is Missing", "[BoneMatchUtil] GetBodyRootLocalBones\n - animator is null"); - } - Dictionary humanoidBoneList = GetHumanoidBoneList(bodyAnimator); - if (humanoidBoneList == null || humanoidBoneList.Count == 0) - { - throw new AutoMorpherException("Humanoid Bone Map is Missing", "[BoneMatchUtil] GetBodyRootLocalBones\n - Can't find Humanoid Bone List"); - } - if (bodyMeshes == null || bodyMeshes.Count == 0) - { - throw new AutoMorpherException("Body Meshes are Missing", "[BoneMatchUtil] GetBodyRootLocalBones\n - bodyMeshes is null or empty"); - } - HashSet meshBones = GetMeshBones(bodyMeshes); - Dictionary> dictionary = new MeshClassifier().MeshHumanoidBoneMatcher(bodyAnimator, bodyMeshes); - HashSet hashSet = new HashSet(); - HashSet hashSet2 = new HashSet(); - foreach (KeyValuePair item in humanoidBoneList) - { - if ((int)item.Value != 55 && !((Object)(object)item.Key == (Object)null)) - { - if (!dictionary.TryGetValue(item.Value, out var value) || value == null) - { - value = new HashSet(); - dictionary[item.Value] = value; - } - value.Add(item.Key); - } - } - foreach (KeyValuePair> item2 in dictionary) - { - HumanBodyBones key = item2.Key; - if ((int)key == 55) - { - continue; - } - HashSet value2 = item2.Value; - if (value2 == null || value2.Count == 0) - { - continue; - } - Transform val = bodyAnimator.GetBoneTransform(key); - if ((Object)(object)val == (Object)null) - { - val = value2.First(); - } - if ((Object)(object)val == (Object)null) - { - continue; - } - hashSet.Add(val); - foreach (Transform item3 in value2) - { - if (!((Object)(object)item3 == (Object)(object)val) && !((Object)(object)item3 == (Object)null)) - { - hashSet2.Add(item3); - } - } - } - foreach (Transform item4 in meshBones) - { - if (!((Object)(object)item4 == (Object)null) && !hashSet2.Contains(item4)) - { - hashSet.Add(item4); - } - } - List rootLocalBones = GetRootLocalBones(bodyTransform, hashSet); - foreach (BoneRootLocalData item5 in rootLocalBones) - { - if (item5 != null && !((Object)(object)item5.t == (Object)null)) - { - if (humanoidBoneList.TryGetValue(item5.t, out var value3)) - { - item5.hBone = value3; - } - else - { - item5.hBone = (HumanBodyBones)55; - } - } - } - return rootLocalBones; - } + public List GetBodyRootLocalBones(Transform bodyTransform, Animator bodyAnimator, List bodyMeshes) + { + //IL_00b1: Unknown result type (might be due to invalid IL or missing references) + //IL_00b8: Invalid comparison between Unknown and I4 + //IL_00cc: 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_0134: Unknown result type (might be due to invalid IL or missing references) + //IL_0139: Unknown result type (might be due to invalid IL or missing references) + //IL_013b: Unknown result type (might be due to invalid IL or missing references) + //IL_013f: Invalid comparison between Unknown and I4 + //IL_015e: Unknown result type (might be due to invalid IL or missing references) + //IL_0290: Unknown result type (might be due to invalid IL or missing references) + //IL_0283: Unknown result type (might be due to invalid IL or missing references) + //IL_0285: Unknown result type (might be due to invalid IL or missing references) + if (bodyTransform == null) + { + throw new AutoMorpherException("Body Transform is Missing", "[BoneMatchUtil] GetBodyRootLocalBones\n - bodyTransform is null"); + } + if (bodyAnimator == null) + { + throw new AutoMorpherException("Body Animator is Missing", "[BoneMatchUtil] GetBodyRootLocalBones\n - animator is null"); + } + Dictionary humanoidBoneList = this.GetHumanoidBoneList(bodyAnimator); + if (humanoidBoneList == null || humanoidBoneList.Count == 0) + { + throw new AutoMorpherException("Humanoid Bone Map is Missing", "[BoneMatchUtil] GetBodyRootLocalBones\n - Can't find Humanoid Bone List"); + } + if (bodyMeshes == null || bodyMeshes.Count == 0) + { + throw new AutoMorpherException("Body Meshes are Missing", "[BoneMatchUtil] GetBodyRootLocalBones\n - bodyMeshes is null or empty"); + } + HashSet meshBones = this.GetMeshBones(bodyMeshes); + Dictionary> dictionary = new MeshClassifier().MeshHumanoidBoneMatcher(bodyAnimator, bodyMeshes); + HashSet hashSet = new HashSet(); + HashSet hashSet2 = new HashSet(); + foreach (KeyValuePair item in humanoidBoneList) + { + if ((int)item.Value != 55 && !(item.Key == null)) + { + if (!dictionary.TryGetValue(item.Value, out var value) || value == null) + { + value = new HashSet(); + dictionary[item.Value] = value; + } + value.Add(item.Key); + } + } + foreach (KeyValuePair> item2 in dictionary) + { + HumanBodyBones key = item2.Key; + if ((int)key == 55) + { + continue; + } + HashSet value2 = item2.Value; + if (value2 == null || value2.Count == 0) + { + continue; + } + Transform val = bodyAnimator.GetBoneTransform(key); + if (val == null) + { + val = value2.First(); + } + if (val == null) + { + continue; + } + hashSet.Add(val); + foreach (Transform item3 in value2) + { + if (!(item3 == val) && !(item3 == null)) + { + hashSet2.Add(item3); + } + } + } + foreach (Transform item4 in meshBones) + { + if (!(item4 == null) && !hashSet2.Contains(item4)) + { + hashSet.Add(item4); + } + } + List rootLocalBones = this.GetRootLocalBones(bodyTransform, hashSet); + foreach (BoneRootLocalData item5 in rootLocalBones) + { + if (item5 != null && !(item5.t == null)) + { + if (humanoidBoneList.TryGetValue(item5.t, out var value3)) + { + item5.hBone = value3; + } + else + { + item5.hBone = (HumanBodyBones)55; + } + } + } + return rootLocalBones; + } - private Dictionary GetHumanoidBoneList(Animator bodyAnimator) - { - //IL_0049: Unknown result type (might be due to invalid IL or missing references) - //IL_004e: Unknown result type (might be due to invalid IL or missing references) - //IL_004f: Unknown result type (might be due to invalid IL or missing references) - //IL_0052: Invalid comparison between Unknown and I4 - //IL_0055: Unknown result type (might be due to invalid IL or missing references) - //IL_0067: Unknown result type (might be due to invalid IL or missing references) - Dictionary dictionary = new Dictionary(); - if ((Object)(object)bodyAnimator == (Object)null || (Object)(object)bodyAnimator.avatar == (Object)null || !bodyAnimator.avatar.isHuman) - { - return dictionary; - } - foreach (HumanBodyBones value in Enum.GetValues(typeof(HumanBodyBones))) - { - if ((int)value != 55) - { - Transform boneTransform = bodyAnimator.GetBoneTransform(value); - if (!((Object)(object)boneTransform == (Object)null)) - { - dictionary.TryAdd(boneTransform, value); - } - } - } - return dictionary; - } + private Dictionary GetHumanoidBoneList(Animator bodyAnimator) + { + //IL_0049: Unknown result type (might be due to invalid IL or missing references) + //IL_004e: Unknown result type (might be due to invalid IL or missing references) + //IL_004f: Unknown result type (might be due to invalid IL or missing references) + //IL_0052: Invalid comparison between Unknown and I4 + //IL_0055: Unknown result type (might be due to invalid IL or missing references) + //IL_0067: Unknown result type (might be due to invalid IL or missing references) + Dictionary dictionary = new Dictionary(); + if (bodyAnimator == null || bodyAnimator.avatar == null || !bodyAnimator.avatar.isHuman) + { + return dictionary; + } + foreach (HumanBodyBones value in Enum.GetValues(typeof(HumanBodyBones))) + { + if ((int)value != 55) + { + Transform boneTransform = bodyAnimator.GetBoneTransform(value); + if (!(boneTransform == null)) + { + dictionary.TryAdd(boneTransform, value); + } + } + } + return dictionary; + } - public void MatchClothesToBodyBones(List bodyBones, List clothesBones, out Dictionary> clothHumanBones, out Dictionary clothBoneTypeMap, out Dictionary clothToBodyMatched) - { - //IL_00ac: Unknown result type (might be due to invalid IL or missing references) - //IL_00b3: 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_011a: Unknown result type (might be due to invalid IL or missing references) - //IL_035d: Unknown result type (might be due to invalid IL or missing references) - //IL_0362: Unknown result type (might be due to invalid IL or missing references) - //IL_0364: Unknown result type (might be due to invalid IL or missing references) - //IL_0368: Invalid comparison between Unknown and I4 - //IL_036c: Unknown result type (might be due to invalid IL or missing references) - //IL_0380: Unknown result type (might be due to invalid IL or missing references) - clothHumanBones = new Dictionary>(); - clothBoneTypeMap = new Dictionary(); - clothToBodyMatched = new Dictionary(); - if (bodyBones == null || bodyBones.Count == 0) - { - throw new AutoMorpherException("Body Bones are Missing", "[BoneMatchUtil] MatchClothesToBodyBones\n - bodyBones is null or empty"); - } - if (clothesBones == null || clothesBones.Count == 0) - { - throw new AutoMorpherException("Clothes Bones are Missing", "[BoneMatchUtil] MatchClothesToBodyBones\n - clothesBones is null or empty"); - } - List<(BoneRootLocalData, BoneRootLocalData, float, float, float, float, float)> list = new List<(BoneRootLocalData, BoneRootLocalData, float, float, float, float, float)>(); - BoneCorrespondenceUtil boneCorrespondenceUtil = new BoneCorrespondenceUtil(); - foreach (BoneRootLocalData clothesBone in clothesBones) - { - BoneRootLocalData boneRootLocalData = null; - float num = float.NegativeInfinity; - float num2 = float.NegativeInfinity; - float num3 = float.NegativeInfinity; - float num4 = float.PositiveInfinity; - float num5 = float.PositiveInfinity; - foreach (BoneRootLocalData bodyBone in bodyBones) - { - float num6 = Vector3.Distance(clothesBone.rootLocalPos, bodyBone.rootLocalPos); - float num7 = boneCorrespondenceUtil.ComputeDistanceScore(num6, 0.0001f, 0.0005f, 0.002f); - if (num7 == 0f) - { - continue; - } - float num8 = boneCorrespondenceUtil.ComputeNameScore(bodyBone.name, bodyBone.path, clothesBone.name, clothesBone.path); - if (num8 != 0f) - { - float num9 = Quaternion.Angle(bodyBone.rootLocalRot, clothesBone.rootLocalRot); - float num10 = boneCorrespondenceUtil.ComputeRotationScore(num9, 30f) * 1f; - if (IsBetterCandidate(num7, num, num10, num2, num8, num3, num6, num4, num9, num5)) - { - boneRootLocalData = bodyBone; - num = num7; - num2 = num10; - num3 = num8; - num4 = num6; - num5 = num9; - } - } - } - if (boneRootLocalData != null) - { - list.Add((clothesBone, boneRootLocalData, num, num2, num3, num4, num5)); - } - } - Dictionary dictionary = new Dictionary(); - foreach (IGrouping item in from x in list - group x by x.body) - { - if (item.Key == null) - { - continue; - } - List<(BoneRootLocalData, BoneRootLocalData, float, float, float, float, float)> list2 = item.ToList(); - if (list2.Count == 0) - { - continue; - } - (BoneRootLocalData, BoneRootLocalData, float, float, float, float, float) tuple = list2[0]; - for (int num11 = 1; num11 < list2.Count; num11++) - { - (BoneRootLocalData, BoneRootLocalData, float, float, float, float, float) tuple2 = list2[num11]; - if (IsBetterCandidate(tuple2.Item3, tuple.Item3, tuple2.Item4, tuple.Item4, tuple2.Item5, tuple.Item5, tuple2.Item6, tuple.Item6, tuple2.Item7, tuple.Item7)) - { - tuple = tuple2; - } - } - if (tuple.Item1 != null && (Object)(object)tuple.Item1.t != (Object)null && tuple.Item2 != null) - { - dictionary[tuple.Item1.t] = tuple.Item2; - } - } - foreach (BoneRootLocalData clothesBone2 in clothesBones) - { - if ((Object)(object)clothesBone2?.t == (Object)null) - { - continue; - } - if (dictionary.TryGetValue(clothesBone2.t, out var value)) - { - clothBoneTypeMap[clothesBone2.t] = ClothBoneType.Body; - clothToBodyMatched[clothesBone2.t] = value; - HumanBodyBones hBone = value.hBone; - if ((int)hBone != 55) - { - if (!clothHumanBones.TryGetValue(hBone, out var value2)) - { - value2 = new HashSet(); - clothHumanBones[hBone] = value2; - } - value2.Add(clothesBone2.t); - } - } - else - { - clothBoneTypeMap[clothesBone2.t] = ClothBoneType.Accessory; - } - } - } + public void MatchClothesToBodyBones(List bodyBones, List clothesBones, out Dictionary> clothHumanBones, out Dictionary clothBoneTypeMap, out Dictionary clothToBodyMatched) + { + //IL_00ac: Unknown result type (might be due to invalid IL or missing references) + //IL_00b3: 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_011a: Unknown result type (might be due to invalid IL or missing references) + //IL_035d: Unknown result type (might be due to invalid IL or missing references) + //IL_0362: Unknown result type (might be due to invalid IL or missing references) + //IL_0364: Unknown result type (might be due to invalid IL or missing references) + //IL_0368: Invalid comparison between Unknown and I4 + //IL_036c: Unknown result type (might be due to invalid IL or missing references) + //IL_0380: Unknown result type (might be due to invalid IL or missing references) + clothHumanBones = new Dictionary>(); + clothBoneTypeMap = new Dictionary(); + clothToBodyMatched = new Dictionary(); + if (bodyBones == null || bodyBones.Count == 0) + { + throw new AutoMorpherException("Body Bones are Missing", "[BoneMatchUtil] MatchClothesToBodyBones\n - bodyBones is null or empty"); + } + if (clothesBones == null || clothesBones.Count == 0) + { + throw new AutoMorpherException("Clothes Bones are Missing", "[BoneMatchUtil] MatchClothesToBodyBones\n - clothesBones is null or empty"); + } + List<(BoneRootLocalData, BoneRootLocalData, float, float, float, float, float)> list = new List<(BoneRootLocalData, BoneRootLocalData, float, float, float, float, float)>(); + BoneCorrespondenceUtil boneCorrespondenceUtil = new BoneCorrespondenceUtil(); + foreach (BoneRootLocalData clothesBone in clothesBones) + { + BoneRootLocalData boneRootLocalData = null; + float num = float.NegativeInfinity; + float num2 = float.NegativeInfinity; + float num3 = float.NegativeInfinity; + float num4 = float.PositiveInfinity; + float num5 = float.PositiveInfinity; + foreach (BoneRootLocalData bodyBone in bodyBones) + { + float num6 = Vector3.Distance(clothesBone.rootLocalPos, bodyBone.rootLocalPos); + float num7 = boneCorrespondenceUtil.ComputeDistanceScore(num6, 0.0001f, 0.0005f, 0.002f); + if (num7 == 0f) + { + continue; + } + float num8 = boneCorrespondenceUtil.ComputeNameScore(bodyBone.name, bodyBone.path, clothesBone.name, clothesBone.path); + if (num8 != 0f) + { + float num9 = Quaternion.Angle(bodyBone.rootLocalRot, clothesBone.rootLocalRot); + float num10 = boneCorrespondenceUtil.ComputeRotationScore(num9, 30f) * 1f; + if (this.IsBetterCandidate(num7, num, num10, num2, num8, num3, num6, num4, num9, num5)) + { + boneRootLocalData = bodyBone; + num = num7; + num2 = num10; + num3 = num8; + num4 = num6; + num5 = num9; + } + } + } + if (boneRootLocalData != null) + { + list.Add((clothesBone, boneRootLocalData, num, num2, num3, num4, num5)); + } + } + Dictionary dictionary = new Dictionary(); + foreach (IGrouping item in from x in list group x by x.Item2) + { + if (item.Key == null) + { + continue; + } + List<(BoneRootLocalData, BoneRootLocalData, float, float, float, float, float)> list2 = item.ToList(); + if (list2.Count == 0) + { + continue; + } + (BoneRootLocalData, BoneRootLocalData, float, float, float, float, float) tuple = list2[0]; + for (int num11 = 1; num11 < list2.Count; num11++) + { + (BoneRootLocalData, BoneRootLocalData, float, float, float, float, float) tuple2 = list2[num11]; + if (this.IsBetterCandidate(tuple2.Item3, tuple.Item3, tuple2.Item4, tuple.Item4, tuple2.Item5, tuple.Item5, tuple2.Item6, tuple.Item6, tuple2.Item7, tuple.Item7)) + { + tuple = tuple2; + } + } + if (tuple.Item1 != null && tuple.Item1.t != null && tuple.Item2 != null) + { + dictionary[tuple.Item1.t] = tuple.Item2; + } + } + foreach (BoneRootLocalData clothesBone2 in clothesBones) + { + if (clothesBone2?.t == null) + { + continue; + } + if (dictionary.TryGetValue(clothesBone2.t, out var value)) + { + clothBoneTypeMap[clothesBone2.t] = ClothBoneType.Body; + clothToBodyMatched[clothesBone2.t] = value; + HumanBodyBones hBone = value.hBone; + if ((int)hBone != 55) + { + if (!clothHumanBones.TryGetValue(hBone, out var value2)) + { + value2 = new HashSet(); + clothHumanBones[hBone] = value2; + } + value2.Add(clothesBone2.t); + } + } + else + { + clothBoneTypeMap[clothesBone2.t] = ClothBoneType.Accessory; + } + } + } - private bool IsBetterCandidate(float candDistScore, float bestDistScore, float candRotScore, float bestRotScore, float candNameScore, float bestNameScore, float candD, float bestD, float candAng, float bestAng) - { - if (candDistScore > bestDistScore) - { - return true; - } - if (candDistScore < bestDistScore) - { - return false; - } - if (candNameScore > bestNameScore) - { - return true; - } - if (candNameScore < bestNameScore) - { - return false; - } - if (Mathf.Abs(candRotScore - bestRotScore) > 1E-06f) - { - if (candRotScore > bestRotScore) - { - return true; - } - if (candRotScore < bestRotScore) - { - return false; - } - } - if (Mathf.Abs(candD - bestD) > 1E-06f) - { - if (candD < bestD) - { - return true; - } - if (candD > bestD) - { - return false; - } - } - if (Mathf.Abs(candAng - bestAng) > 1E-06f) - { - if (candAng < bestAng) - { - return true; - } - return false; - } - return false; - } + private bool IsBetterCandidate(float candDistScore, float bestDistScore, float candRotScore, float bestRotScore, float candNameScore, float bestNameScore, float candD, float bestD, float candAng, float bestAng) + { + if (candDistScore > bestDistScore) + { + return true; + } + if (candDistScore < bestDistScore) + { + return false; + } + if (candNameScore > bestNameScore) + { + return true; + } + if (candNameScore < bestNameScore) + { + return false; + } + if (Mathf.Abs(candRotScore - bestRotScore) > 1E-06f) + { + if (candRotScore > bestRotScore) + { + return true; + } + if (candRotScore < bestRotScore) + { + return false; + } + } + if (Mathf.Abs(candD - bestD) > 1E-06f) + { + if (candD < bestD) + { + return true; + } + if (candD > bestD) + { + return false; + } + } + if (Mathf.Abs(candAng - bestAng) > 1E-06f) + { + if (candAng < bestAng) + { + return true; + } + return false; + } + return false; + } - public Dictionary BuildTransformMatchMap(List sourceBones, List destBones, bool resultReverse = false) - { - //IL_02b7: 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_02c3: Unknown result type (might be due to invalid IL or missing references) - if (sourceBones == null || sourceBones.Count == 0) - { - throw new AutoMorpherException("Source Bones are Missing", "[BoneMatchUtil] BuildTransformMatchMap\n - sourceBones is null or empty"); - } - if (destBones == null || destBones.Count == 0) - { - throw new AutoMorpherException("Destination Bones are Missing", "[BoneMatchUtil] BuildTransformMatchMap\n - destBones is null or empty"); - } - BoneCorrespondenceUtil boneCorrespondenceUtil = new BoneCorrespondenceUtil(); - Dictionary dictionary = new Dictionary(); - Dictionary dictionary2 = new Dictionary(); - Dictionary dictionary3 = new Dictionary(); - Dictionary> dictionary4 = new Dictionary>(); - foreach (BoneRootLocalData destBone in destBones) - { - if (destBone == null || (Object)(object)destBone.t == (Object)null) - { - continue; - } - string text = destBone.path ?? ""; - if (text.Length > 0 && !dictionary2.ContainsKey(text)) - { - dictionary2.Add(text, destBone); - } - if (text.Length > 0) - { - string text2 = boneCorrespondenceUtil.NormalizePath(text); - if (text2.Length > 0 && !dictionary3.ContainsKey(text2)) - { - dictionary3.Add(text2, destBone); - } - } - string text3 = destBone.name ?? ((Object)destBone.t).name; - if (!string.IsNullOrEmpty(text3)) - { - if (!dictionary4.TryGetValue(text3, out var value)) - { - value = (dictionary4[text3] = new List()); - } - value.Add(destBone); - } - } - HashSet hashSet = new HashSet(); - foreach (BoneRootLocalData sourceBone in sourceBones) - { - if (sourceBone == null || (Object)(object)sourceBone.t == (Object)null) - { - continue; - } - Transform val = null; - string text4 = sourceBone.path ?? ""; - if (text4.Length > 0 && dictionary2.TryGetValue(text4, out var value2) && value2 != null && (Object)(object)value2.t != (Object)null && !hashSet.Contains(value2.t)) - { - val = value2.t; - } - if ((Object)(object)val == (Object)null && text4.Length > 0) - { - string text5 = boneCorrespondenceUtil.NormalizePath(text4); - if (text5.Length > 0 && dictionary3.TryGetValue(text5, out var value3) && value3 != null && (Object)(object)value3.t != (Object)null && !hashSet.Contains(value3.t)) - { - val = value3.t; - } - } - if ((Object)(object)val == (Object)null) - { - string text6 = sourceBone.name ?? ((Object)sourceBone.t).name; - if (!string.IsNullOrEmpty(text6) && dictionary4.TryGetValue(text6, out var value4)) - { - float num = float.PositiveInfinity; - Transform val2 = null; - for (int i = 0; i < value4.Count; i++) - { - BoneRootLocalData boneRootLocalData = value4[i]; - if (boneRootLocalData != null && !((Object)(object)boneRootLocalData.t == (Object)null) && !hashSet.Contains(boneRootLocalData.t)) - { - float num2 = Vector3.SqrMagnitude(boneRootLocalData.rootLocalPos - sourceBone.rootLocalPos); - if (num2 < num) - { - num = num2; - val2 = boneRootLocalData.t; - } - } - } - val = val2; - } - } - if ((Object)(object)val != (Object)null) - { - if (resultReverse) - { - dictionary[val] = sourceBone.t; - } - else - { - dictionary[sourceBone.t] = val; - } - hashSet.Add(val); - } - } - return dictionary; - } + public Dictionary BuildTransformMatchMap(List sourceBones, List destBones, bool resultReverse = false) + { + //IL_02b7: 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_02c3: Unknown result type (might be due to invalid IL or missing references) + if (sourceBones == null || sourceBones.Count == 0) + { + throw new AutoMorpherException("Source Bones are Missing", "[BoneMatchUtil] BuildTransformMatchMap\n - sourceBones is null or empty"); + } + if (destBones == null || destBones.Count == 0) + { + throw new AutoMorpherException("Destination Bones are Missing", "[BoneMatchUtil] BuildTransformMatchMap\n - destBones is null or empty"); + } + BoneCorrespondenceUtil boneCorrespondenceUtil = new BoneCorrespondenceUtil(); + Dictionary dictionary = new Dictionary(); + Dictionary dictionary2 = new Dictionary(); + Dictionary dictionary3 = new Dictionary(); + Dictionary> dictionary4 = new Dictionary>(); + foreach (BoneRootLocalData destBone in destBones) + { + if (destBone == null || destBone.t == null) + { + continue; + } + string text = destBone.path ?? ""; + if (text.Length > 0 && !dictionary2.ContainsKey(text)) + { + dictionary2.Add(text, destBone); + } + if (text.Length > 0) + { + string text2 = boneCorrespondenceUtil.NormalizePath(text); + if (text2.Length > 0 && !dictionary3.ContainsKey(text2)) + { + dictionary3.Add(text2, destBone); + } + } + string text3 = destBone.name ?? destBone.t.name; + if (!string.IsNullOrEmpty(text3)) + { + if (!dictionary4.TryGetValue(text3, out var value)) + { + value = (dictionary4[text3] = new List()); + } + value.Add(destBone); + } + } + HashSet hashSet = new HashSet(); + foreach (BoneRootLocalData sourceBone in sourceBones) + { + if (sourceBone == null || sourceBone.t == null) + { + continue; + } + Transform val = null; + string text4 = sourceBone.path ?? ""; + if (text4.Length > 0 && dictionary2.TryGetValue(text4, out var value2) && value2 != null && value2.t != null && !hashSet.Contains(value2.t)) + { + val = value2.t; + } + if (val == null && text4.Length > 0) + { + string text5 = boneCorrespondenceUtil.NormalizePath(text4); + if (text5.Length > 0 && dictionary3.TryGetValue(text5, out var value3) && value3 != null && value3.t != null && !hashSet.Contains(value3.t)) + { + val = value3.t; + } + } + if (val == null) + { + string text6 = sourceBone.name ?? sourceBone.t.name; + if (!string.IsNullOrEmpty(text6) && dictionary4.TryGetValue(text6, out var value4)) + { + float num = float.PositiveInfinity; + Transform val2 = null; + for (int i = 0; i < value4.Count; i++) + { + BoneRootLocalData boneRootLocalData = value4[i]; + if (boneRootLocalData != null && !(boneRootLocalData.t == null) && !hashSet.Contains(boneRootLocalData.t)) + { + float num2 = Vector3.SqrMagnitude(boneRootLocalData.rootLocalPos - sourceBone.rootLocalPos); + if (num2 < num) + { + num = num2; + val2 = boneRootLocalData.t; + } + } + } + val = val2; + } + } + if (val != null) + { + if (resultReverse) + { + dictionary[val] = sourceBone.t; + } + else + { + dictionary[sourceBone.t] = val; + } + hashSet.Add(val); + } + } + return dictionary; + } - public void RemapSourceClothMatchToTargetCloth(Transform sourceClothRoot, Transform targetClothRoot, Dictionary> sourceClothHumanBones, Dictionary sourceClothBoneTypeMap, out Dictionary> targetClothHumanBones, out Dictionary targetClothBoneTypeMap) - { - //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_02b4: Unknown result type (might be due to invalid IL or missing references) - //IL_02c9: Unknown result type (might be due to invalid IL or missing references) - targetClothHumanBones = new Dictionary>(); - targetClothBoneTypeMap = new Dictionary(); - if ((Object)(object)sourceClothRoot == (Object)null || (Object)(object)targetClothRoot == (Object)null) - { - throw new AutoMorpherException("Cloth Root is Missing", "[BoneMatchUtil] RemapClothMatchResultToTargetCloth\n - sourceClothRoot or targetClothRoot is null"); - } - if (sourceClothHumanBones == null || sourceClothBoneTypeMap == null) - { - throw new AutoMorpherException("Source Cloth Match Data is Missing", "[BoneMatchUtil] RemapClothMatchResultToTargetCloth\n - sourceClothHumanBones or sourceClothBoneTypeMap is null"); - } - HashSet hashSet = new HashSet(); - foreach (KeyValuePair item in sourceClothBoneTypeMap) - { - if ((Object)(object)item.Key != (Object)null) - { - hashSet.Add(item.Key); - } - } - foreach (KeyValuePair> sourceClothHumanBone in sourceClothHumanBones) - { - HashSet value = sourceClothHumanBone.Value; - if (value == null || value.Count == 0) - { - continue; - } - foreach (Transform item2 in value) - { - if ((Object)(object)item2 != (Object)null) - { - hashSet.Add(item2); - } - } - } - if (hashSet.Count == 0) - { - throw new AutoMorpherException("Source Cloth Bone Candidates are Missing", "[BoneMatchUtil] RemapClothMatchResultToTargetCloth\n - sourceBoneSet is empty (no bones found in sourceClothBoneTypeMap/sourceClothHumanBones)"); - } - HashSet meshBones = GetMeshBones(((Component)targetClothRoot).GetComponentsInChildren(true).ToList()); - if (meshBones == null || meshBones.Count == 0) - { - throw new AutoMorpherException("Target Cloth Bone Candidates are Missing", "[BoneMatchUtil] RemapClothMatchResultToTargetCloth\n - targetBoneSet is null or empty (GetMeshBones returned no bones)"); - } - List rootLocalBones = GetRootLocalBones(sourceClothRoot, hashSet); - List rootLocalBones2 = GetRootLocalBones(targetClothRoot, meshBones); - if (rootLocalBones == null || rootLocalBones.Count == 0) - { - throw new AutoMorpherException("Source RootLocal Bones are Missing", "[BoneMatchUtil] RemapClothMatchResultToTargetCloth\n - sourceRootLocalBones is null or empty"); - } - if (rootLocalBones2 == null || rootLocalBones2.Count == 0) - { - throw new AutoMorpherException("Target RootLocal Bones are Missing", "[BoneMatchUtil] RemapClothMatchResultToTargetCloth\n - targetRootLocalBones is null or empty"); - } - Dictionary dictionary = BuildTransformMatchMap(rootLocalBones, rootLocalBones2); - foreach (KeyValuePair item3 in sourceClothBoneTypeMap) - { - Transform key = item3.Key; - ClothBoneType value2 = item3.Value; - if ((Object)(object)key == (Object)null || !dictionary.TryGetValue(key, out var value3) || (Object)(object)value3 == (Object)null) - { - continue; - } - if (targetClothBoneTypeMap.TryGetValue(value3, out var value4)) - { - if (value4 == ClothBoneType.Accessory && value2 == ClothBoneType.Body) - { - targetClothBoneTypeMap[value3] = ClothBoneType.Body; - } - } - else - { - targetClothBoneTypeMap.Add(value3, value2); - } - } - foreach (KeyValuePair> sourceClothHumanBone2 in sourceClothHumanBones) - { - HumanBodyBones key2 = sourceClothHumanBone2.Key; - HashSet value5 = sourceClothHumanBone2.Value; - if (value5 == null || value5.Count == 0) - { - continue; - } - foreach (Transform item4 in value5) - { - if (!((Object)(object)item4 == (Object)null) && dictionary.TryGetValue(item4, out var value6) && !((Object)(object)value6 == (Object)null)) - { - if (!targetClothHumanBones.TryGetValue(key2, out var value7)) - { - value7 = new HashSet(); - targetClothHumanBones[key2] = value7; - } - value7.Add(value6); - } - } - } - } + public void RemapSourceClothMatchToTargetCloth(Transform sourceClothRoot, Transform targetClothRoot, Dictionary> sourceClothHumanBones, Dictionary sourceClothBoneTypeMap, out Dictionary> targetClothHumanBones, out Dictionary targetClothBoneTypeMap) + { + //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_02b4: Unknown result type (might be due to invalid IL or missing references) + //IL_02c9: Unknown result type (might be due to invalid IL or missing references) + targetClothHumanBones = new Dictionary>(); + targetClothBoneTypeMap = new Dictionary(); + if (sourceClothRoot == null || targetClothRoot == null) + { + throw new AutoMorpherException("Cloth Root is Missing", "[BoneMatchUtil] RemapClothMatchResultToTargetCloth\n - sourceClothRoot or targetClothRoot is null"); + } + if (sourceClothHumanBones == null || sourceClothBoneTypeMap == null) + { + throw new AutoMorpherException("Source Cloth Match Data is Missing", "[BoneMatchUtil] RemapClothMatchResultToTargetCloth\n - sourceClothHumanBones or sourceClothBoneTypeMap is null"); + } + HashSet hashSet = new HashSet(); + foreach (KeyValuePair item in sourceClothBoneTypeMap) + { + if (item.Key != null) + { + hashSet.Add(item.Key); + } + } + foreach (KeyValuePair> sourceClothHumanBone in sourceClothHumanBones) + { + HashSet value = sourceClothHumanBone.Value; + if (value == null || value.Count == 0) + { + continue; + } + foreach (Transform item2 in value) + { + if (item2 != null) + { + hashSet.Add(item2); + } + } + } + if (hashSet.Count == 0) + { + throw new AutoMorpherException("Source Cloth Bone Candidates are Missing", "[BoneMatchUtil] RemapClothMatchResultToTargetCloth\n - sourceBoneSet is empty (no bones found in sourceClothBoneTypeMap/sourceClothHumanBones)"); + } + HashSet meshBones = this.GetMeshBones(((Component)targetClothRoot).GetComponentsInChildren(true).ToList()); + if (meshBones == null || meshBones.Count == 0) + { + throw new AutoMorpherException("Target Cloth Bone Candidates are Missing", "[BoneMatchUtil] RemapClothMatchResultToTargetCloth\n - targetBoneSet is null or empty (GetMeshBones returned no bones)"); + } + List rootLocalBones = this.GetRootLocalBones(sourceClothRoot, hashSet); + List rootLocalBones2 = this.GetRootLocalBones(targetClothRoot, meshBones); + if (rootLocalBones == null || rootLocalBones.Count == 0) + { + throw new AutoMorpherException("Source RootLocal Bones are Missing", "[BoneMatchUtil] RemapClothMatchResultToTargetCloth\n - sourceRootLocalBones is null or empty"); + } + if (rootLocalBones2 == null || rootLocalBones2.Count == 0) + { + throw new AutoMorpherException("Target RootLocal Bones are Missing", "[BoneMatchUtil] RemapClothMatchResultToTargetCloth\n - targetRootLocalBones is null or empty"); + } + Dictionary dictionary = this.BuildTransformMatchMap(rootLocalBones, rootLocalBones2); + foreach (KeyValuePair item3 in sourceClothBoneTypeMap) + { + Transform key = item3.Key; + ClothBoneType value2 = item3.Value; + if (key == null || !dictionary.TryGetValue(key, out var value3) || value3 == null) + { + continue; + } + if (targetClothBoneTypeMap.TryGetValue(value3, out var value4)) + { + if (value4 == ClothBoneType.Accessory && value2 == ClothBoneType.Body) + { + targetClothBoneTypeMap[value3] = ClothBoneType.Body; + } + } + else + { + targetClothBoneTypeMap.Add(value3, value2); + } + } + foreach (KeyValuePair> sourceClothHumanBone2 in sourceClothHumanBones) + { + HumanBodyBones key2 = sourceClothHumanBone2.Key; + HashSet value5 = sourceClothHumanBone2.Value; + if (value5 == null || value5.Count == 0) + { + continue; + } + foreach (Transform item4 in value5) + { + if (!(item4 == null) && dictionary.TryGetValue(item4, out var value6) && !(value6 == null)) + { + if (!targetClothHumanBones.TryGetValue(key2, out var value7)) + { + value7 = new HashSet(); + targetClothHumanBones[key2] = value7; + } + value7.Add(value6); + } + } + } + } - public void BuildSourceToProxyBoneMap(Animator sourceAvatar, Animator proxyAvatar, out Dictionary sourceToProxy) - { - sourceToProxy = new Dictionary(); - if ((Object)(object)sourceAvatar == (Object)null) - { - throw new AutoMorpherException("Source Avatar is Missing", "[AvatarBodyMatchUtil] BuildSourceToProxyBoneMap\n - sourceAvatar is null"); - } - if ((Object)(object)proxyAvatar == (Object)null) - { - throw new AutoMorpherException("Proxy Avatar is Missing", "[AvatarBodyMatchUtil] BuildSourceToProxyBoneMap\n - proxyAvatar is null"); - } - Transform transform = ((Component)sourceAvatar).transform; - Transform transform2 = ((Component)proxyAvatar).transform; - HashSet meshBones = GetMeshBones(((Component)transform2).GetComponentsInChildren(true).ToList()); - if (meshBones == null || meshBones.Count == 0) - { - throw new AutoMorpherException("Proxy Body Bone Candidates are Missing", "[AvatarBodyMatchUtil] BuildSourceToProxyBoneMap\n - proxyBoneSet is null or empty (GetMeshBones returned no bones)"); - } - HashSet meshBones2 = GetMeshBones(((Component)transform).GetComponentsInChildren(true).ToList()); - if (meshBones2 == null || meshBones2.Count == 0) - { - throw new AutoMorpherException("Source Body Bone Candidates are Missing", "[AvatarBodyMatchUtil] BuildSourceToProxyBoneMap\n - sourceBoneSet is null or empty (GetMeshBones returned no bones)"); - } - List rootLocalBones = GetRootLocalBones(transform2, meshBones); - List rootLocalBones2 = GetRootLocalBones(transform, meshBones2); - if (rootLocalBones == null || rootLocalBones.Count == 0) - { - throw new AutoMorpherException("Proxy RootLocal Bones are Missing", "[AvatarBodyMatchUtil] BuildSourceToProxyBoneMap\n - proxyRootLocalBones is null or empty"); - } - if (rootLocalBones2 == null || rootLocalBones2.Count == 0) - { - throw new AutoMorpherException("Source RootLocal Bones are Missing", "[AvatarBodyMatchUtil] BuildSourceToProxyBoneMap\n - sourceRootLocalBones is null or empty"); - } - sourceToProxy = BuildTransformMatchMap(rootLocalBones, rootLocalBones2, resultReverse: true); - if (sourceToProxy == null) - { - throw new AutoMorpherException("Source To Proxy Map Build Failed", "[AvatarBodyMatchUtil] BuildSourceToProxyBoneMap\n - BuildTransformMatchMap returned null"); - } - } + public void BuildSourceToProxyBoneMap(Animator sourceAvatar, Animator proxyAvatar, out Dictionary sourceToProxy) + { + sourceToProxy = new Dictionary(); + if (sourceAvatar == null) + { + throw new AutoMorpherException("Source Avatar is Missing", "[AvatarBodyMatchUtil] BuildSourceToProxyBoneMap\n - sourceAvatar is null"); + } + if (proxyAvatar == null) + { + throw new AutoMorpherException("Proxy Avatar is Missing", "[AvatarBodyMatchUtil] BuildSourceToProxyBoneMap\n - proxyAvatar is null"); + } + Transform transform = ((Component)sourceAvatar).transform; + Transform transform2 = ((Component)proxyAvatar).transform; + HashSet meshBones = this.GetMeshBones(((Component)transform2).GetComponentsInChildren(true).ToList()); + if (meshBones == null || meshBones.Count == 0) + { + throw new AutoMorpherException("Proxy Body Bone Candidates are Missing", "[AvatarBodyMatchUtil] BuildSourceToProxyBoneMap\n - proxyBoneSet is null or empty (GetMeshBones returned no bones)"); + } + HashSet meshBones2 = this.GetMeshBones(((Component)transform).GetComponentsInChildren(true).ToList()); + if (meshBones2 == null || meshBones2.Count == 0) + { + throw new AutoMorpherException("Source Body Bone Candidates are Missing", "[AvatarBodyMatchUtil] BuildSourceToProxyBoneMap\n - sourceBoneSet is null or empty (GetMeshBones returned no bones)"); + } + List rootLocalBones = this.GetRootLocalBones(transform2, meshBones); + List rootLocalBones2 = this.GetRootLocalBones(transform, meshBones2); + if (rootLocalBones == null || rootLocalBones.Count == 0) + { + throw new AutoMorpherException("Proxy RootLocal Bones are Missing", "[AvatarBodyMatchUtil] BuildSourceToProxyBoneMap\n - proxyRootLocalBones is null or empty"); + } + if (rootLocalBones2 == null || rootLocalBones2.Count == 0) + { + throw new AutoMorpherException("Source RootLocal Bones are Missing", "[AvatarBodyMatchUtil] BuildSourceToProxyBoneMap\n - sourceRootLocalBones is null or empty"); + } + sourceToProxy = this.BuildTransformMatchMap(rootLocalBones, rootLocalBones2, resultReverse: true); + if (sourceToProxy == null) + { + throw new AutoMorpherException("Source To Proxy Map Build Failed", "[AvatarBodyMatchUtil] BuildSourceToProxyBoneMap\n - BuildTransformMatchMap returned null"); + } + } } diff --git a/Assets/@Eden_Tools/Eden_AutoMorpher/Script/BvhNode.cs b/Assets/@Eden_Tools/Eden_AutoMorpher/Script/BvhNode.cs index 8b3d6d9..6044dec 100644 --- a/Assets/@Eden_Tools/Eden_AutoMorpher/Script/BvhNode.cs +++ b/Assets/@Eden_Tools/Eden_AutoMorpher/Script/BvhNode.cs @@ -1,4 +1,4 @@ -// Warning: Some assembly references could not be resolved automatically. This might lead to incorrect decompilation of some parts, +// 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.BvhNode @@ -6,15 +6,15 @@ using UnityEngine; public struct BvhNode { - public Bounds bounds; + public Bounds bounds; - public int leftChild; + public int leftChild; - public int rightChild; + public int rightChild; - public int start; + public int start; - public int count; + public int count; - public bool isLeaf; + public bool isLeaf; } diff --git a/Assets/@Eden_Tools/Eden_AutoMorpher/Script/BvhTriangle.cs b/Assets/@Eden_Tools/Eden_AutoMorpher/Script/BvhTriangle.cs index 51f0663..d4fda90 100644 --- a/Assets/@Eden_Tools/Eden_AutoMorpher/Script/BvhTriangle.cs +++ b/Assets/@Eden_Tools/Eden_AutoMorpher/Script/BvhTriangle.cs @@ -1,4 +1,4 @@ -// Warning: Some assembly references could not be resolved automatically. This might lead to incorrect decompilation of some parts, +// 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.BvhTriangle @@ -6,13 +6,13 @@ using UnityEngine; public struct BvhTriangle { - public Vector3 a; + public Vector3 a; - public Vector3 b; + public Vector3 b; - public Vector3 c; + public Vector3 c; - public Vector3 normal; + public Vector3 normal; - public HumanBodyBones mainHumanBone; + public HumanBodyBones mainHumanBone; } diff --git a/Assets/@Eden_Tools/Eden_AutoMorpher/Script/BvhTriangleMesh.cs b/Assets/@Eden_Tools/Eden_AutoMorpher/Script/BvhTriangleMesh.cs index 0d87acf..a80f3a8 100644 --- a/Assets/@Eden_Tools/Eden_AutoMorpher/Script/BvhTriangleMesh.cs +++ b/Assets/@Eden_Tools/Eden_AutoMorpher/Script/BvhTriangleMesh.cs @@ -1,983 +1,1013 @@ -// Warning: Some assembly references could not be resolved automatically. This might lead to incorrect decompilation of some parts, +// 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.BvhTriangleMesh -using System; using System.Collections.Generic; -using System.Runtime.CompilerServices; -using Eden.AutoMorpher; using UnityEngine; public class BvhTriangleMesh { - public struct ClosestHit - { - public int triangleIndex; + public struct ClosestHit + { + public int triangleIndex; - public Vector3 closestPoint; + public Vector3 closestPoint; - public Vector3 normal; + public Vector3 normal; - public float sqrDistance; + public float sqrDistance; - public HumanBodyBones mainHumanBone; - } + public HumanBodyBones mainHumanBone; + } - private TriangleUtil triangleUtil; + private TriangleUtil triangleUtil; - private HumanBodyBones[] humanBones; + private HumanBodyBones[] humanBones; - public BvhTriangle[] triangles; + public BvhTriangle[] triangles; - public BvhNode[] nodes; + public BvhNode[] nodes; - public int[] triIndices; + public int[] triIndices; - private const int LeafMaxTriangles = 4; + private const int LeafMaxTriangles = 4; - public BvhTriangleMesh() - { - HumanBodyBones[] array = new HumanBodyBones[34]; - RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/); - humanBones = (HumanBodyBones[])(object)array; - base._002Ector(); - triangleUtil = new TriangleUtil(); - } + public BvhTriangleMesh() + { + this.humanBones = new HumanBodyBones[34] + { + HumanBodyBones.Hips, + HumanBodyBones.LeftUpperLeg, + HumanBodyBones.RightUpperLeg, + HumanBodyBones.LeftLowerLeg, + HumanBodyBones.RightLowerLeg, + HumanBodyBones.LeftFoot, + HumanBodyBones.RightFoot, + HumanBodyBones.Spine, + HumanBodyBones.Chest, + HumanBodyBones.Neck, + HumanBodyBones.Head, + HumanBodyBones.LeftShoulder, + HumanBodyBones.RightShoulder, + HumanBodyBones.LeftUpperArm, + HumanBodyBones.RightUpperArm, + HumanBodyBones.LeftLowerArm, + HumanBodyBones.RightLowerArm, + HumanBodyBones.LeftHand, + HumanBodyBones.RightHand, + HumanBodyBones.LeftToes, + HumanBodyBones.RightToes, + HumanBodyBones.LeftEye, + HumanBodyBones.RightEye, + HumanBodyBones.Jaw, + HumanBodyBones.LeftThumbProximal, + HumanBodyBones.LeftIndexProximal, + HumanBodyBones.LeftMiddleProximal, + HumanBodyBones.LeftRingProximal, + HumanBodyBones.RightThumbProximal, + HumanBodyBones.RightIndexProximal, + HumanBodyBones.RightMiddleProximal, + HumanBodyBones.RightRingProximal, + HumanBodyBones.LeftLittleProximal, + HumanBodyBones.RightLittleProximal + }; + this.triangleUtil = new TriangleUtil(); + } - private HumanBodyBones[] BuildVertexMainHumanBone(SkinnedMeshRenderer smr, Animator animator, HumanBodyBones[] bodyBones) - { - //IL_0035: Unknown result type (might be due to invalid IL or missing references) - //IL_003a: Unknown result type (might be due to invalid IL or missing references) - Mesh sharedMesh = smr.sharedMesh; - BoneWeight[] boneWeights = sharedMesh.boneWeights; - int[] boneToBodyIndex = BuildBoneToBodyIndexMap(smr, animator, bodyBones); - HumanBodyBones[] array = (HumanBodyBones[])(object)new HumanBodyBones[sharedMesh.vertexCount]; - for (int i = 0; i < sharedMesh.vertexCount; i++) - { - BoneWeight val = boneWeights[i]; - int bestBodyIdx = -1; - float bestWeight = 0f; - Try(((BoneWeight)(ref val)).boneIndex0, ((BoneWeight)(ref val)).weight0); - Try(((BoneWeight)(ref val)).boneIndex1, ((BoneWeight)(ref val)).weight1); - Try(((BoneWeight)(ref val)).boneIndex2, ((BoneWeight)(ref val)).weight2); - Try(((BoneWeight)(ref val)).boneIndex3, ((BoneWeight)(ref val)).weight3); - array[i] = (HumanBodyBones)((bestBodyIdx >= 0) ? ((int)bodyBones[bestBodyIdx]) : 55); - void Try(int boneIdx, float w) - { - if (!(w <= 0f) && boneIdx >= 0 && boneIdx < boneToBodyIndex.Length) - { - int num = boneToBodyIndex[boneIdx]; - if (num >= 0 && w > bestWeight) - { - bestWeight = w; - bestBodyIdx = num; - } - } - } - } - return array; - } + private HumanBodyBones[] BuildVertexMainHumanBone(SkinnedMeshRenderer smr, Animator animator, HumanBodyBones[] bodyBones) + { + //IL_0035: Unknown result type (might be due to invalid IL or missing references) + //IL_003a: Unknown result type (might be due to invalid IL or missing references) + Mesh sharedMesh = smr.sharedMesh; + BoneWeight[] boneWeights = sharedMesh.boneWeights; + int[] boneToBodyIndex = this.BuildBoneToBodyIndexMap(smr, animator, bodyBones); + HumanBodyBones[] array = (HumanBodyBones[])(object)new HumanBodyBones[sharedMesh.vertexCount]; + for (int i = 0; i < sharedMesh.vertexCount; i++) + { + BoneWeight val = boneWeights[i]; + int bestBodyIdx = -1; + float bestWeight = 0f; + Try(val.boneIndex0, val.weight0); + Try(val.boneIndex1, val.weight1); + Try(val.boneIndex2, val.weight2); + Try(val.boneIndex3, val.weight3); + array[i] = (HumanBodyBones)((bestBodyIdx >= 0) ? ((int)bodyBones[bestBodyIdx]) : 55); + void Try(int boneIdx, float w) + { + if (!(w <= 0f) && boneIdx >= 0 && boneIdx < boneToBodyIndex.Length) + { + int num = boneToBodyIndex[boneIdx]; + if (num >= 0 && w > bestWeight) + { + bestWeight = w; + bestBodyIdx = num; + } + } + } + } + return array; + } - public BvhTriangleMesh BuildFromSkinnedMeshes(IReadOnlyList renderers, Animator animator) - { - //IL_007e: Unknown result type (might be due to invalid IL or missing references) - //IL_0084: Expected O, but got Unknown - //IL_010c: 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_011a: Unknown result type (might be due to invalid IL or missing references) - //IL_0131: 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_015f: Unknown result type (might be due to invalid IL or missing references) - //IL_0164: 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_016b: Unknown result type (might be due to invalid IL or missing references) - //IL_0170: 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_01b1: Unknown result type (might be due to invalid IL or missing references) - //IL_01b6: Unknown result type (might be due to invalid IL or missing references) - //IL_01bb: 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_01c8: Unknown result type (might be due to invalid IL or missing references) - //IL_01cd: Unknown result type (might be due to invalid IL or missing references) - //IL_01cf: Unknown result type (might be due to invalid IL or missing references) - //IL_01d1: Unknown result type (might be due to invalid IL or missing references) - //IL_01d3: Unknown result type (might be due to invalid IL or missing references) - //IL_01d8: 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_01dc: Unknown result type (might be due to invalid IL or missing references) - //IL_01e1: Unknown result type (might be due to invalid IL or missing references) - //IL_01e6: Unknown result type (might be due to invalid IL or missing references) - //IL_0207: 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_01fa: Unknown result type (might be due to invalid IL or missing references) - //IL_01fe: Unknown result type (might be due to invalid IL or missing references) - //IL_0203: 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_0251: Unknown result type (might be due to invalid IL or missing references) - //IL_0253: Unknown result type (might be due to invalid IL or missing references) - //IL_025a: 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_0263: 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_026c: 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_0275: Unknown result type (might be due to invalid IL or missing references) - //IL_0277: Unknown result type (might be due to invalid IL or missing references) - if (renderers == null || renderers.Count == 0) - { - return null; - } - BvhTriangleMesh bvhTriangleMesh = new BvhTriangleMesh(); - int num = 0; - foreach (SkinnedMeshRenderer renderer in renderers) - { - if (!((Object)(object)renderer == (Object)null) && !((Object)(object)renderer.sharedMesh == (Object)null)) - { - num += renderer.sharedMesh.triangles.Length / 3; - } - } - if (num == 0) - { - return null; - } - bvhTriangleMesh.triangles = new BvhTriangle[num]; - int num2 = 0; - Mesh val = new Mesh(); - Vector3 val2 = default(Vector3); - foreach (SkinnedMeshRenderer renderer2 in renderers) - { - if (!((Object)(object)renderer2 == (Object)null) && !((Object)(object)renderer2.sharedMesh == (Object)null)) - { - val.Clear(); - renderer2.BakeMesh(val); - Vector3[] vertices = val.vertices; - int[] array = renderer2.sharedMesh.triangles; - BoneWeight[] boneWeights = renderer2.sharedMesh.boneWeights; - int[] boneToBodyIndex = BuildBoneToBodyIndexMap(renderer2, animator, humanBones); - int num3 = array.Length / 3; - Transform transform = ((Component)renderer2).transform; - Vector3 lossyScale = transform.lossyScale; - ((Vector3)(ref val2))._002Ector(1f / Mathf.Max(lossyScale.x, 1E-08f), 1f / Mathf.Max(lossyScale.y, 1E-08f), 1f / Mathf.Max(lossyScale.z, 1E-08f)); - Matrix4x4 val3 = transform.localToWorldMatrix * Matrix4x4.Scale(val2); - for (int i = 0; i < num3; i++) - { - int num4 = array[i * 3]; - int num5 = array[i * 3 + 1]; - int num6 = array[i * 3 + 2]; - Vector3 val4 = ((Matrix4x4)(ref val3)).MultiplyPoint3x4(vertices[num4]); - Vector3 val5 = ((Matrix4x4)(ref val3)).MultiplyPoint3x4(vertices[num5]); - Vector3 val6 = ((Matrix4x4)(ref val3)).MultiplyPoint3x4(vertices[num6]); - Vector3 val7 = Vector3.Cross(val5 - val4, val6 - val4); - float magnitude = ((Vector3)(ref val7)).magnitude; - val7 = ((!(magnitude > 1E-08f)) ? Vector3.up : (val7 / magnitude)); - int num7 = ComputeTriangleMainHumanBoneIndex(num4, num5, num6, boneWeights, boneToBodyIndex, humanBones.Length); - HumanBodyBones mainHumanBone = (HumanBodyBones)((num7 >= 0) ? ((int)humanBones[num7]) : 55); - bvhTriangleMesh.triangles[num2++] = new BvhTriangle - { - a = val4, - b = val5, - c = val6, - normal = val7, - mainHumanBone = mainHumanBone - }; - val.Clear(); - } - } - } - int num8 = num; - int[] array2 = new int[num8]; - for (int j = 0; j < num8; j++) - { - array2[j] = j; - } - bvhTriangleMesh.triIndices = array2; - List list = new List(); - BuildRecursive(bvhTriangleMesh.triangles, array2, 0, num8, list); - bvhTriangleMesh.nodes = list.ToArray(); - return bvhTriangleMesh; - } + public BvhTriangleMesh BuildFromSkinnedMeshes(IReadOnlyList renderers, Animator animator) + { + //IL_007e: Unknown result type (might be due to invalid IL or missing references) + //IL_0084: Expected O, but got Unknown + //IL_010c: 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_011a: Unknown result type (might be due to invalid IL or missing references) + //IL_0131: 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_015f: Unknown result type (might be due to invalid IL or missing references) + //IL_0164: 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_016b: Unknown result type (might be due to invalid IL or missing references) + //IL_0170: 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_01b1: Unknown result type (might be due to invalid IL or missing references) + //IL_01b6: Unknown result type (might be due to invalid IL or missing references) + //IL_01bb: 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_01c8: Unknown result type (might be due to invalid IL or missing references) + //IL_01cd: Unknown result type (might be due to invalid IL or missing references) + //IL_01cf: Unknown result type (might be due to invalid IL or missing references) + //IL_01d1: Unknown result type (might be due to invalid IL or missing references) + //IL_01d3: Unknown result type (might be due to invalid IL or missing references) + //IL_01d8: 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_01dc: Unknown result type (might be due to invalid IL or missing references) + //IL_01e1: Unknown result type (might be due to invalid IL or missing references) + //IL_01e6: Unknown result type (might be due to invalid IL or missing references) + //IL_0207: 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_01fa: Unknown result type (might be due to invalid IL or missing references) + //IL_01fe: Unknown result type (might be due to invalid IL or missing references) + //IL_0203: 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_0251: Unknown result type (might be due to invalid IL or missing references) + //IL_0253: Unknown result type (might be due to invalid IL or missing references) + //IL_025a: 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_0263: 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_026c: 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_0275: Unknown result type (might be due to invalid IL or missing references) + //IL_0277: Unknown result type (might be due to invalid IL or missing references) + if (renderers == null || renderers.Count == 0) + { + return null; + } + BvhTriangleMesh bvhTriangleMesh = new BvhTriangleMesh(); + int num = 0; + foreach (SkinnedMeshRenderer renderer in renderers) + { + if (!(renderer == null) && !(renderer.sharedMesh == null)) + { + num += renderer.sharedMesh.triangles.Length / 3; + } + } + if (num == 0) + { + return null; + } + bvhTriangleMesh.triangles = new BvhTriangle[num]; + int num2 = 0; + Mesh val = new Mesh(); + Vector3 val2 = default(Vector3); + foreach (SkinnedMeshRenderer renderer2 in renderers) + { + if (!(renderer2 == null) && !(renderer2.sharedMesh == null)) + { + val.Clear(); + renderer2.BakeMesh(val); + Vector3[] vertices = val.vertices; + int[] array = renderer2.sharedMesh.triangles; + BoneWeight[] boneWeights = renderer2.sharedMesh.boneWeights; + int[] boneToBodyIndex = this.BuildBoneToBodyIndexMap(renderer2, animator, this.humanBones); + int num3 = array.Length / 3; + Transform transform = ((Component)renderer2).transform; + Vector3 lossyScale = transform.lossyScale; + val2 = new Vector3(1f / Mathf.Max(lossyScale.x, 1E-08f), 1f / Mathf.Max(lossyScale.y, 1E-08f), 1f / Mathf.Max(lossyScale.z, 1E-08f)); + Matrix4x4 val3 = transform.localToWorldMatrix * Matrix4x4.Scale(val2); + for (int i = 0; i < num3; i++) + { + int num4 = array[i * 3]; + int num5 = array[i * 3 + 1]; + int num6 = array[i * 3 + 2]; + Vector3 val4 = val3.MultiplyPoint3x4(vertices[num4]); + Vector3 val5 = val3.MultiplyPoint3x4(vertices[num5]); + Vector3 val6 = val3.MultiplyPoint3x4(vertices[num6]); + Vector3 val7 = Vector3.Cross(val5 - val4, val6 - val4); + float magnitude = val7.magnitude; + val7 = ((!(magnitude > 1E-08f)) ? Vector3.up : (val7 / magnitude)); + int num7 = this.ComputeTriangleMainHumanBoneIndex(num4, num5, num6, boneWeights, boneToBodyIndex, this.humanBones.Length); + HumanBodyBones mainHumanBone = (HumanBodyBones)((num7 >= 0) ? ((int)this.humanBones[num7]) : 55); + bvhTriangleMesh.triangles[num2++] = new BvhTriangle + { + a = val4, + b = val5, + c = val6, + normal = val7, + mainHumanBone = mainHumanBone + }; + val.Clear(); + } + } + } + int num8 = num; + int[] array2 = new int[num8]; + for (int j = 0; j < num8; j++) + { + array2[j] = j; + } + bvhTriangleMesh.triIndices = array2; + List list = new List(); + this.BuildRecursive(bvhTriangleMesh.triangles, array2, 0, num8, list); + bvhTriangleMesh.nodes = list.ToArray(); + return bvhTriangleMesh; + } - private int[] BuildBoneToBodyIndexMap(SkinnedMeshRenderer smr, Animator animator, HumanBodyBones[] bodyBones) - { - //IL_009d: Unknown result type (might be due to invalid IL or missing references) - //IL_00a0: Unknown result type (might be due to invalid IL or missing references) - Transform[] bones = smr.bones; - int[] array = new int[bones.Length]; - for (int i = 0; i < array.Length; i++) - { - array[i] = -1; - } - if ((Object)(object)animator == (Object)null || bodyBones == null || bones == null) - { - return array; - } - Dictionary dictionary = new Dictionary(); - for (int j = 0; j < bones.Length; j++) - { - if (!((Object)(object)bones[j] == (Object)null) && !dictionary.ContainsKey(bones[j])) - { - dictionary.Add(bones[j], j); - } - } - Dictionary> dictionary2 = new MeshClassifier().MeshHumanoidBoneMatcher(animator, (IReadOnlyList)(object)new SkinnedMeshRenderer[1] { smr }); - for (int k = 0; k < bodyBones.Length; k++) - { - HumanBodyBones key = bodyBones[k]; - if (!dictionary2.TryGetValue(key, out var value) || value == null) - { - continue; - } - foreach (Transform item in value) - { - if (!((Object)(object)item == (Object)null) && dictionary.TryGetValue(item, out var value2)) - { - array[value2] = k; - } - } - } - for (int l = 0; l < bones.Length; l++) - { - if (array[l] != -1) - { - continue; - } - Transform val = bones[l]; - if ((Object)(object)val == (Object)null) - { - continue; - } - Transform parent = val.parent; - if (!((Object)(object)parent == (Object)null) && dictionary.TryGetValue(parent, out var value3)) - { - int num = array[value3]; - if (num != -1) - { - array[l] = num; - } - } - } - return array; - } + private int[] BuildBoneToBodyIndexMap(SkinnedMeshRenderer smr, Animator animator, HumanBodyBones[] bodyBones) + { + //IL_009d: Unknown result type (might be due to invalid IL or missing references) + //IL_00a0: Unknown result type (might be due to invalid IL or missing references) + Transform[] bones = smr.bones; + int[] array = new int[bones.Length]; + for (int i = 0; i < array.Length; i++) + { + array[i] = -1; + } + if (animator == null || bodyBones == null || bones == null) + { + return array; + } + Dictionary dictionary = new Dictionary(); + for (int j = 0; j < bones.Length; j++) + { + if (!(bones[j] == null) && !dictionary.ContainsKey(bones[j])) + { + dictionary.Add(bones[j], j); + } + } + Dictionary> dictionary2 = new MeshClassifier().MeshHumanoidBoneMatcher(animator, (IReadOnlyList)(object)new SkinnedMeshRenderer[1] { smr }); + for (int k = 0; k < bodyBones.Length; k++) + { + HumanBodyBones key = bodyBones[k]; + if (!dictionary2.TryGetValue(key, out var value) || value == null) + { + continue; + } + foreach (Transform item in value) + { + if (!(item == null) && dictionary.TryGetValue(item, out var value2)) + { + array[value2] = k; + } + } + } + for (int l = 0; l < bones.Length; l++) + { + if (array[l] != -1) + { + continue; + } + Transform val = bones[l]; + if (val == null) + { + continue; + } + Transform parent = val.parent; + if (!(parent == null) && dictionary.TryGetValue(parent, out var value3)) + { + int num = array[value3]; + if (num != -1) + { + array[l] = num; + } + } + } + return array; + } - private int ComputeTriangleMainHumanBoneIndex(int vi0, int vi1, int vi2, BoneWeight[] weights, int[] boneToBodyIndex, int bodyBonesCount) - { - if (weights == null || weights.Length == 0 || boneToBodyIndex == null || boneToBodyIndex.Length == 0) - { - return -1; - } - float[] scores = new float[bodyBonesCount]; - Accumulate(vi0); - Accumulate(vi1); - Accumulate(vi2); - int result = -1; - float num = 0f; - for (int i = 0; i < scores.Length; i++) - { - if (scores[i] > num) - { - num = scores[i]; - result = i; - } - } - return result; - void Accumulate(int v) - { - //IL_0017: Unknown result type (might be due to invalid IL or missing references) - //IL_001c: Unknown result type (might be due to invalid IL or missing references) - if (v >= 0 && v < weights.Length) - { - BoneWeight val = weights[v]; - Add(((BoneWeight)(ref val)).boneIndex0, ((BoneWeight)(ref val)).weight0); - Add(((BoneWeight)(ref val)).boneIndex1, ((BoneWeight)(ref val)).weight1); - Add(((BoneWeight)(ref val)).boneIndex2, ((BoneWeight)(ref val)).weight2); - Add(((BoneWeight)(ref val)).boneIndex3, ((BoneWeight)(ref val)).weight3); - } - } - void Add(int boneIdx, float w) - { - if (!(w <= 0f) && boneIdx >= 0 && boneIdx < boneToBodyIndex.Length) - { - int num2 = boneToBodyIndex[boneIdx]; - if (num2 >= 0) - { - scores[num2] += w; - } - } - } - } + private int ComputeTriangleMainHumanBoneIndex(int vi0, int vi1, int vi2, BoneWeight[] weights, int[] boneToBodyIndex, int bodyBonesCount) + { + if (weights == null || weights.Length == 0 || boneToBodyIndex == null || boneToBodyIndex.Length == 0) + { + return -1; + } + float[] scores = new float[bodyBonesCount]; + Accumulate(vi0); + Accumulate(vi1); + Accumulate(vi2); + int result = -1; + float num = 0f; + for (int i = 0; i < scores.Length; i++) + { + if (scores[i] > num) + { + num = scores[i]; + result = i; + } + } + return result; + void Accumulate(int v) + { + //IL_0017: Unknown result type (might be due to invalid IL or missing references) + //IL_001c: Unknown result type (might be due to invalid IL or missing references) + if (v >= 0 && v < weights.Length) + { + BoneWeight val = weights[v]; + Add(val.boneIndex0, val.weight0); + Add(val.boneIndex1, val.weight1); + Add(val.boneIndex2, val.weight2); + Add(val.boneIndex3, val.weight3); + } + } + void Add(int boneIdx, float w) + { + if (!(w <= 0f) && boneIdx >= 0 && boneIdx < boneToBodyIndex.Length) + { + int num2 = boneToBodyIndex[boneIdx]; + if (num2 >= 0) + { + scores[num2] += w; + } + } + } + } - public BvhTriangleMesh BuildFromSkinnedMeshes(IList renderers) - { - //IL_0103: 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_011a: Unknown result type (might be due to invalid IL or missing references) - //IL_011f: Unknown result type (might be due to invalid IL or missing references) - //IL_0124: Unknown result type (might be due to invalid IL or missing references) - //IL_0131: Unknown result type (might be due to invalid IL or missing references) - //IL_0136: Unknown result type (might be due to invalid IL or missing references) - //IL_013b: Unknown result type (might be due to invalid IL or missing references) - //IL_013d: Unknown result type (might be due to invalid IL or missing references) - //IL_013f: Unknown result type (might be due to invalid IL or missing references) - //IL_0141: Unknown result type (might be due to invalid IL or missing references) - //IL_0146: 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_014a: Unknown result type (might be due to invalid IL or missing references) - //IL_014f: 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_0175: Unknown result type (might be due to invalid IL or missing references) - //IL_017a: 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_016c: Unknown result type (might be due to invalid IL or missing references) - //IL_0171: Unknown result type (might be due to invalid IL or missing references) - //IL_0191: Unknown result type (might be due to invalid IL or missing references) - //IL_0193: 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_019c: Unknown result type (might be due to invalid IL or missing references) - //IL_01a3: Unknown result type (might be due to invalid IL or missing references) - //IL_01a5: Unknown result type (might be due to invalid IL or missing references) - //IL_01ac: Unknown result type (might be due to invalid IL or missing references) - //IL_01ae: Unknown result type (might be due to invalid IL or missing references) - if (renderers == null || renderers.Count == 0) - { - return null; - } - BvhTriangleMesh bvhTriangleMesh = new BvhTriangleMesh(); - int num = 0; - foreach (SkinnedMeshRenderer renderer in renderers) - { - if (!((Object)(object)renderer == (Object)null) && !((Object)(object)renderer.sharedMesh == (Object)null)) - { - num += renderer.sharedMesh.triangles.Length / 3; - } - } - if (num == 0) - { - return null; - } - bvhTriangleMesh.triangles = new BvhTriangle[num]; - int num2 = 0; - foreach (SkinnedMeshRenderer renderer2 in renderers) - { - if (!((Object)(object)renderer2 == (Object)null) && !((Object)(object)renderer2.sharedMesh == (Object)null)) - { - Mesh sharedMesh = renderer2.sharedMesh; - Vector3[] vertices = sharedMesh.vertices; - int[] array = sharedMesh.triangles; - int num3 = array.Length / 3; - for (int i = 0; i < num3; i++) - { - int num4 = array[i * 3]; - int num5 = array[i * 3 + 1]; - int num6 = array[i * 3 + 2]; - Vector3 val = ((Component)renderer2).transform.TransformPoint(vertices[num4]); - Vector3 val2 = ((Component)renderer2).transform.TransformPoint(vertices[num5]); - Vector3 val3 = ((Component)renderer2).transform.TransformPoint(vertices[num6]); - Vector3 val4 = Vector3.Cross(val2 - val, val3 - val); - float magnitude = ((Vector3)(ref val4)).magnitude; - val4 = ((!(magnitude > 1E-08f)) ? Vector3.up : (val4 / magnitude)); - bvhTriangleMesh.triangles[num2++] = new BvhTriangle - { - a = val, - b = val2, - c = val3, - normal = val4 - }; - } - } - } - int num7 = num; - int[] array2 = new int[num7]; - for (int j = 0; j < num7; j++) - { - array2[j] = j; - } - bvhTriangleMesh.triIndices = array2; - List list = new List(); - BuildRecursive(bvhTriangleMesh.triangles, array2, 0, num7, list); - bvhTriangleMesh.nodes = list.ToArray(); - return bvhTriangleMesh; - } + public BvhTriangleMesh BuildFromSkinnedMeshes(IList renderers) + { + //IL_0103: 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_011a: Unknown result type (might be due to invalid IL or missing references) + //IL_011f: Unknown result type (might be due to invalid IL or missing references) + //IL_0124: Unknown result type (might be due to invalid IL or missing references) + //IL_0131: Unknown result type (might be due to invalid IL or missing references) + //IL_0136: Unknown result type (might be due to invalid IL or missing references) + //IL_013b: Unknown result type (might be due to invalid IL or missing references) + //IL_013d: Unknown result type (might be due to invalid IL or missing references) + //IL_013f: Unknown result type (might be due to invalid IL or missing references) + //IL_0141: Unknown result type (might be due to invalid IL or missing references) + //IL_0146: 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_014a: Unknown result type (might be due to invalid IL or missing references) + //IL_014f: 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_0175: Unknown result type (might be due to invalid IL or missing references) + //IL_017a: 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_016c: Unknown result type (might be due to invalid IL or missing references) + //IL_0171: Unknown result type (might be due to invalid IL or missing references) + //IL_0191: Unknown result type (might be due to invalid IL or missing references) + //IL_0193: 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_019c: Unknown result type (might be due to invalid IL or missing references) + //IL_01a3: Unknown result type (might be due to invalid IL or missing references) + //IL_01a5: Unknown result type (might be due to invalid IL or missing references) + //IL_01ac: Unknown result type (might be due to invalid IL or missing references) + //IL_01ae: Unknown result type (might be due to invalid IL or missing references) + if (renderers == null || renderers.Count == 0) + { + return null; + } + BvhTriangleMesh bvhTriangleMesh = new BvhTriangleMesh(); + int num = 0; + foreach (SkinnedMeshRenderer renderer in renderers) + { + if (!(renderer == null) && !(renderer.sharedMesh == null)) + { + num += renderer.sharedMesh.triangles.Length / 3; + } + } + if (num == 0) + { + return null; + } + bvhTriangleMesh.triangles = new BvhTriangle[num]; + int num2 = 0; + foreach (SkinnedMeshRenderer renderer2 in renderers) + { + if (!(renderer2 == null) && !(renderer2.sharedMesh == null)) + { + Mesh sharedMesh = renderer2.sharedMesh; + Vector3[] vertices = sharedMesh.vertices; + int[] array = sharedMesh.triangles; + int num3 = array.Length / 3; + for (int i = 0; i < num3; i++) + { + int num4 = array[i * 3]; + int num5 = array[i * 3 + 1]; + int num6 = array[i * 3 + 2]; + Vector3 val = ((Component)renderer2).transform.TransformPoint(vertices[num4]); + Vector3 val2 = ((Component)renderer2).transform.TransformPoint(vertices[num5]); + Vector3 val3 = ((Component)renderer2).transform.TransformPoint(vertices[num6]); + Vector3 val4 = Vector3.Cross(val2 - val, val3 - val); + float magnitude = val4.magnitude; + val4 = ((!(magnitude > 1E-08f)) ? Vector3.up : (val4 / magnitude)); + bvhTriangleMesh.triangles[num2++] = new BvhTriangle + { + a = val, + b = val2, + c = val3, + normal = val4 + }; + } + } + } + int num7 = num; + int[] array2 = new int[num7]; + for (int j = 0; j < num7; j++) + { + array2[j] = j; + } + bvhTriangleMesh.triIndices = array2; + List list = new List(); + this.BuildRecursive(bvhTriangleMesh.triangles, array2, 0, num7, list); + bvhTriangleMesh.nodes = list.ToArray(); + return bvhTriangleMesh; + } - public BvhTriangleMesh BuildFromMesh(Mesh mesh, Transform transform) - { - //IL_004e: Unknown result type (might be due to invalid IL or missing references) - //IL_0053: Unknown result type (might be due to invalid IL or missing references) - //IL_0058: Unknown result type (might be due to invalid IL or missing references) - //IL_005e: Unknown result type (might be due to invalid IL or missing references) - //IL_0063: Unknown result type (might be due to invalid IL or missing references) - //IL_0068: Unknown result type (might be due to invalid IL or missing references) - //IL_006e: Unknown result type (might be due to invalid IL or missing references) - //IL_0073: Unknown result type (might be due to invalid IL or missing references) - //IL_0078: Unknown result type (might be due to invalid IL or missing references) - //IL_007a: Unknown result type (might be due to invalid IL or missing references) - //IL_007c: Unknown result type (might be due to invalid IL or missing references) - //IL_007e: Unknown result type (might be due to invalid IL or missing references) - //IL_0083: 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_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_0091: Unknown result type (might be due to invalid IL or missing references) - //IL_00b2: Unknown result type (might be due to invalid IL or missing references) - //IL_00b7: Unknown result type (might be due to invalid IL or missing references) - //IL_00a5: Unknown result type (might be due to invalid IL or missing references) - //IL_00a9: Unknown result type (might be due to invalid IL or missing references) - //IL_00ae: 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_00cd: Unknown result type (might be due to invalid IL or missing references) - //IL_00d4: 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_00dd: Unknown result type (might be due to invalid IL or missing references) - //IL_00df: Unknown result type (might be due to invalid IL or missing references) - //IL_00e6: 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) - BvhTriangleMesh bvhTriangleMesh = new BvhTriangleMesh(); - Vector3[] vertices = mesh.vertices; - int[] array = mesh.triangles; - int num = array.Length / 3; - bvhTriangleMesh.triangles = new BvhTriangle[num]; - for (int i = 0; i < num; i++) - { - int num2 = array[i * 3]; - int num3 = array[i * 3 + 1]; - int num4 = array[i * 3 + 2]; - Vector3 val = transform.TransformPoint(vertices[num2]); - Vector3 val2 = transform.TransformPoint(vertices[num3]); - Vector3 val3 = transform.TransformPoint(vertices[num4]); - Vector3 val4 = Vector3.Cross(val2 - val, val3 - val); - float magnitude = ((Vector3)(ref val4)).magnitude; - val4 = ((!(magnitude > 1E-08f)) ? Vector3.up : (val4 / magnitude)); - bvhTriangleMesh.triangles[i] = new BvhTriangle - { - a = val, - b = val2, - c = val3, - normal = val4 - }; - } - int[] array2 = new int[num]; - for (int j = 0; j < num; j++) - { - array2[j] = j; - } - bvhTriangleMesh.triIndices = array2; - List list = new List(); - BuildRecursive(bvhTriangleMesh.triangles, array2, 0, num, list); - bvhTriangleMesh.nodes = list.ToArray(); - return bvhTriangleMesh; - } + public BvhTriangleMesh BuildFromMesh(Mesh mesh, Transform transform) + { + //IL_004e: Unknown result type (might be due to invalid IL or missing references) + //IL_0053: Unknown result type (might be due to invalid IL or missing references) + //IL_0058: Unknown result type (might be due to invalid IL or missing references) + //IL_005e: Unknown result type (might be due to invalid IL or missing references) + //IL_0063: Unknown result type (might be due to invalid IL or missing references) + //IL_0068: Unknown result type (might be due to invalid IL or missing references) + //IL_006e: Unknown result type (might be due to invalid IL or missing references) + //IL_0073: Unknown result type (might be due to invalid IL or missing references) + //IL_0078: Unknown result type (might be due to invalid IL or missing references) + //IL_007a: Unknown result type (might be due to invalid IL or missing references) + //IL_007c: Unknown result type (might be due to invalid IL or missing references) + //IL_007e: Unknown result type (might be due to invalid IL or missing references) + //IL_0083: 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_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_0091: Unknown result type (might be due to invalid IL or missing references) + //IL_00b2: Unknown result type (might be due to invalid IL or missing references) + //IL_00b7: Unknown result type (might be due to invalid IL or missing references) + //IL_00a5: Unknown result type (might be due to invalid IL or missing references) + //IL_00a9: Unknown result type (might be due to invalid IL or missing references) + //IL_00ae: 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_00cd: Unknown result type (might be due to invalid IL or missing references) + //IL_00d4: 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_00dd: Unknown result type (might be due to invalid IL or missing references) + //IL_00df: Unknown result type (might be due to invalid IL or missing references) + //IL_00e6: 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) + BvhTriangleMesh bvhTriangleMesh = new BvhTriangleMesh(); + Vector3[] vertices = mesh.vertices; + int[] array = mesh.triangles; + int num = array.Length / 3; + bvhTriangleMesh.triangles = new BvhTriangle[num]; + for (int i = 0; i < num; i++) + { + int num2 = array[i * 3]; + int num3 = array[i * 3 + 1]; + int num4 = array[i * 3 + 2]; + Vector3 val = transform.TransformPoint(vertices[num2]); + Vector3 val2 = transform.TransformPoint(vertices[num3]); + Vector3 val3 = transform.TransformPoint(vertices[num4]); + Vector3 val4 = Vector3.Cross(val2 - val, val3 - val); + float magnitude = val4.magnitude; + val4 = ((!(magnitude > 1E-08f)) ? Vector3.up : (val4 / magnitude)); + bvhTriangleMesh.triangles[i] = new BvhTriangle + { + a = val, + b = val2, + c = val3, + normal = val4 + }; + } + int[] array2 = new int[num]; + for (int j = 0; j < num; j++) + { + array2[j] = j; + } + bvhTriangleMesh.triIndices = array2; + List list = new List(); + this.BuildRecursive(bvhTriangleMesh.triangles, array2, 0, num, list); + bvhTriangleMesh.nodes = list.ToArray(); + return bvhTriangleMesh; + } - private int BuildRecursive(BvhTriangle[] tris, int[] triIndices, int start, int count, List outNodes) - { - //IL_0012: Unknown result type (might be due to invalid IL or missing references) - //IL_009b: Unknown result type (might be due to invalid IL or missing references) - //IL_009c: Unknown result type (might be due to invalid IL or missing references) - //IL_0065: Unknown result type (might be due to invalid IL or missing references) - //IL_0073: Unknown result type (might be due to invalid IL or missing references) - //IL_0081: Unknown result type (might be due to invalid IL or missing references) - //IL_0032: Unknown result type (might be due to invalid IL or missing references) - //IL_0037: Unknown result type (might be due to invalid IL or missing references) - //IL_0045: Unknown result type (might be due to invalid IL or missing references) - //IL_0053: Unknown result type (might be due to invalid IL or missing references) - //IL_00db: Unknown result type (might be due to invalid IL or missing references) - //IL_00e0: Unknown result type (might be due to invalid IL or missing references) - //IL_00e5: Unknown result type (might be due to invalid IL or missing references) - //IL_00ec: Unknown result type (might be due to invalid IL or missing references) - //IL_010a: 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_00f5: Unknown result type (might be due to invalid IL or missing references) - //IL_00fc: 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_0121: Unknown result type (might be due to invalid IL or missing references) - //IL_0147: 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_015a: Unknown result type (might be due to invalid IL or missing references) - //IL_015f: Unknown result type (might be due to invalid IL or missing references) - //IL_0169: Unknown result type (might be due to invalid IL or missing references) - //IL_016e: Unknown result type (might be due to invalid IL or missing references) - int count2 = outNodes.Count; - BvhNode bvhNode = default(BvhNode); - Bounds bounds = default(Bounds); - bool flag = true; - for (int i = start; i < start + count; i++) - { - BvhTriangle bvhTriangle = tris[triIndices[i]]; - if (flag) - { - ((Bounds)(ref bounds))._002Ector(bvhTriangle.a, Vector3.zero); - ((Bounds)(ref bounds)).Encapsulate(bvhTriangle.b); - ((Bounds)(ref bounds)).Encapsulate(bvhTriangle.c); - flag = false; - } - else - { - ((Bounds)(ref bounds)).Encapsulate(bvhTriangle.a); - ((Bounds)(ref bounds)).Encapsulate(bvhTriangle.b); - ((Bounds)(ref bounds)).Encapsulate(bvhTriangle.c); - } - } - bvhNode.bounds = bounds; - if (count <= 4) - { - bvhNode.isLeaf = true; - bvhNode.start = start; - bvhNode.count = count; - bvhNode.leftChild = -1; - bvhNode.rightChild = -1; - outNodes.Add(bvhNode); - return count2; - } - Vector3 size = ((Bounds)(ref bounds)).size; - int num = 0; - if (size.y > size.x && size.y > size.z) - { - num = 1; - } - else if (size.z > size.x && size.z > size.y) - { - num = 2; - } - float num2 = 0f; - for (int j = start; j < start + count; j++) - { - BvhTriangle bvhTriangle2 = tris[triIndices[j]]; - Vector3 val = (bvhTriangle2.a + bvhTriangle2.b + bvhTriangle2.c) / 3f; - num2 += ((Vector3)(ref val))[num]; - } - num2 /= (float)count; - int num3 = Partition(tris, triIndices, start, count, num, num2); - if (num3 == start || num3 == start + count) - { - num3 = start + count / 2; - } - bvhNode.isLeaf = false; - bvhNode.start = -1; - bvhNode.count = 0; - outNodes.Add(bvhNode); - int leftChild = BuildRecursive(tris, triIndices, start, num3 - start, outNodes); - int rightChild = BuildRecursive(tris, triIndices, num3, start + count - num3, outNodes); - bvhNode.leftChild = leftChild; - bvhNode.rightChild = rightChild; - outNodes[count2] = bvhNode; - return count2; - } + private int BuildRecursive(BvhTriangle[] tris, int[] triIndices, int start, int count, List outNodes) + { + //IL_0012: Unknown result type (might be due to invalid IL or missing references) + //IL_009b: Unknown result type (might be due to invalid IL or missing references) + //IL_009c: Unknown result type (might be due to invalid IL or missing references) + //IL_0065: Unknown result type (might be due to invalid IL or missing references) + //IL_0073: Unknown result type (might be due to invalid IL or missing references) + //IL_0081: Unknown result type (might be due to invalid IL or missing references) + //IL_0032: Unknown result type (might be due to invalid IL or missing references) + //IL_0037: Unknown result type (might be due to invalid IL or missing references) + //IL_0045: Unknown result type (might be due to invalid IL or missing references) + //IL_0053: Unknown result type (might be due to invalid IL or missing references) + //IL_00db: Unknown result type (might be due to invalid IL or missing references) + //IL_00e0: Unknown result type (might be due to invalid IL or missing references) + //IL_00e5: Unknown result type (might be due to invalid IL or missing references) + //IL_00ec: Unknown result type (might be due to invalid IL or missing references) + //IL_010a: 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_00f5: Unknown result type (might be due to invalid IL or missing references) + //IL_00fc: 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_0121: Unknown result type (might be due to invalid IL or missing references) + //IL_0147: 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_015a: Unknown result type (might be due to invalid IL or missing references) + //IL_015f: Unknown result type (might be due to invalid IL or missing references) + //IL_0169: Unknown result type (might be due to invalid IL or missing references) + //IL_016e: Unknown result type (might be due to invalid IL or missing references) + int count2 = outNodes.Count; + BvhNode bvhNode = default(BvhNode); + Bounds bounds = default(Bounds); + bool flag = true; + for (int i = start; i < start + count; i++) + { + BvhTriangle bvhTriangle = tris[triIndices[i]]; + if (flag) + { + bounds = new Bounds(bvhTriangle.a, Vector3.zero); + bounds.Encapsulate(bvhTriangle.b); + bounds.Encapsulate(bvhTriangle.c); + flag = false; + } + else + { + bounds.Encapsulate(bvhTriangle.a); + bounds.Encapsulate(bvhTriangle.b); + bounds.Encapsulate(bvhTriangle.c); + } + } + bvhNode.bounds = bounds; + if (count <= 4) + { + bvhNode.isLeaf = true; + bvhNode.start = start; + bvhNode.count = count; + bvhNode.leftChild = -1; + bvhNode.rightChild = -1; + outNodes.Add(bvhNode); + return count2; + } + Vector3 size = bounds.size; + int num = 0; + if (size.y > size.x && size.y > size.z) + { + num = 1; + } + else if (size.z > size.x && size.z > size.y) + { + num = 2; + } + float num2 = 0f; + for (int j = start; j < start + count; j++) + { + BvhTriangle bvhTriangle2 = tris[triIndices[j]]; + Vector3 val = (bvhTriangle2.a + bvhTriangle2.b + bvhTriangle2.c) / 3f; + num2 += val[num]; + } + num2 /= (float)count; + int num3 = this.Partition(tris, triIndices, start, count, num, num2); + if (num3 == start || num3 == start + count) + { + num3 = start + count / 2; + } + bvhNode.isLeaf = false; + bvhNode.start = -1; + bvhNode.count = 0; + outNodes.Add(bvhNode); + int leftChild = this.BuildRecursive(tris, triIndices, start, num3 - start, outNodes); + int rightChild = this.BuildRecursive(tris, triIndices, num3, start + count - num3, outNodes); + bvhNode.leftChild = leftChild; + bvhNode.rightChild = rightChild; + outNodes[count2] = bvhNode; + return count2; + } - private int Partition(BvhTriangle[] tris, int[] triIndices, int start, int count, int axis, float splitPos) - { - int num = start; - int num2 = start + count - 1; - while (num <= num2) - { - BvhTriangle bvhTriangle = tris[triIndices[num]]; - BvhTriangle bvhTriangle2 = tris[triIndices[num2]]; - float num3 = (((Vector3)(ref bvhTriangle.a))[axis] + ((Vector3)(ref bvhTriangle.b))[axis] + ((Vector3)(ref bvhTriangle.c))[axis]) / 3f; - _ = (((Vector3)(ref bvhTriangle2.a))[axis] + ((Vector3)(ref bvhTriangle2.b))[axis] + ((Vector3)(ref bvhTriangle2.c))[axis]) / 3f; - if (num3 < splitPos) - { - num++; - continue; - } - int num4 = triIndices[num]; - triIndices[num] = triIndices[num2]; - triIndices[num2] = num4; - num2--; - } - return num; - } + private int Partition(BvhTriangle[] tris, int[] triIndices, int start, int count, int axis, float splitPos) + { + int num = start; + int num2 = start + count - 1; + while (num <= num2) + { + BvhTriangle bvhTriangle = tris[triIndices[num]]; + BvhTriangle bvhTriangle2 = tris[triIndices[num2]]; + float num3 = (bvhTriangle.a[axis] + bvhTriangle.b[axis] + bvhTriangle.c[axis]) / 3f; + _ = (bvhTriangle2.a[axis] + bvhTriangle2.b[axis] + bvhTriangle2.c[axis]) / 3f; + if (num3 < splitPos) + { + num++; + continue; + } + int num4 = triIndices[num]; + triIndices[num] = triIndices[num2]; + triIndices[num2] = num4; + num2--; + } + return num; + } - public ClosestHit QueryClosest(Vector3 point) - { - //IL_0033: Unknown result type (might be due to invalid IL or missing references) - ClosestHit best = new ClosestHit - { - triangleIndex = -1, - sqrDistance = float.MaxValue - }; - if (nodes == null || nodes.Length == 0) - { - return best; - } - QueryClosestRecursive(0, point, ref best); - return best; - } + public ClosestHit QueryClosest(Vector3 point) + { + //IL_0033: Unknown result type (might be due to invalid IL or missing references) + ClosestHit best = new ClosestHit + { + triangleIndex = -1, + sqrDistance = float.MaxValue + }; + if (this.nodes == null || this.nodes.Length == 0) + { + return best; + } + this.QueryClosestRecursive(0, point, ref best); + return best; + } - public ClosestHit QueryClosest(Vector3 point, HashSet allowedBones) - { - //IL_003e: Unknown result type (might be due to invalid IL or missing references) - //IL_004a: Unknown result type (might be due to invalid IL or missing references) - ClosestHit best = new ClosestHit - { - triangleIndex = -1, - sqrDistance = float.MaxValue - }; - if (nodes == null || nodes.Length == 0) - { - return best; - } - if (allowedBones == null || allowedBones.Count == 0) - { - QueryClosestRecursive(0, point, ref best); - } - else - { - QueryClosestRecursiveFiltered(0, point, ref best, allowedBones); - } - return best; - } + public ClosestHit QueryClosest(Vector3 point, HashSet allowedBones) + { + //IL_003e: Unknown result type (might be due to invalid IL or missing references) + //IL_004a: Unknown result type (might be due to invalid IL or missing references) + ClosestHit best = new ClosestHit + { + triangleIndex = -1, + sqrDistance = float.MaxValue + }; + if (this.nodes == null || this.nodes.Length == 0) + { + return best; + } + if (allowedBones == null || allowedBones.Count == 0) + { + this.QueryClosestRecursive(0, point, ref best); + } + else + { + this.QueryClosestRecursiveFiltered(0, point, ref best, allowedBones); + } + return best; + } - private void QueryClosestRecursiveFiltered(int nodeIndex, Vector3 p, ref ClosestHit best, HashSet allowedBones) - { - //IL_000e: Unknown result type (might be due to invalid IL or missing references) - //IL_0010: Unknown result type (might be due to invalid IL or missing references) - //IL_00fd: Unknown result type (might be due to invalid IL or missing references) - //IL_010b: Unknown result type (might be due to invalid IL or missing references) - //IL_0116: Unknown result type (might be due to invalid IL or missing references) - //IL_0124: Unknown result type (might be due to invalid IL or missing references) - //IL_0150: Unknown result type (might be due to invalid IL or missing references) - //IL_015c: Unknown result type (might be due to invalid IL or missing references) - //IL_0137: Unknown result type (might be due to invalid IL or missing references) - //IL_0143: Unknown result type (might be due to invalid IL or missing references) - //IL_0063: Unknown result type (might be due to invalid IL or missing references) - //IL_0075: Unknown result type (might be due to invalid IL or missing references) - //IL_0078: Unknown result type (might be due to invalid IL or missing references) - //IL_007f: Unknown result type (might be due to invalid IL or missing references) - //IL_0086: Unknown result type (might be due to invalid IL or missing references) - //IL_008b: Unknown result type (might be due to invalid IL or missing references) - //IL_0090: Unknown result type (might be due to invalid IL or missing references) - //IL_0092: Unknown result type (might be due to invalid IL or missing references) - //IL_0093: Unknown result type (might be due to invalid IL or missing references) - //IL_0095: Unknown result type (might be due to invalid IL or missing references) - //IL_009a: Unknown result type (might be due to invalid IL or missing references) - //IL_00bf: Unknown result type (might be due to invalid IL or missing references) - //IL_00c1: Unknown result type (might be due to invalid IL or missing references) - //IL_00c9: Unknown result type (might be due to invalid IL or missing references) - //IL_00ce: 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_00db: Unknown result type (might be due to invalid IL or missing references) - BvhNode bvhNode = nodes[nodeIndex]; - if (DistanceSqPointAABB(p, bvhNode.bounds) > best.sqrDistance) - { - return; - } - if (bvhNode.isLeaf) - { - int num = bvhNode.start + bvhNode.count; - for (int i = bvhNode.start; i < num; i++) - { - int num2 = triIndices[i]; - BvhTriangle bvhTriangle = triangles[num2]; - if (allowedBones.Contains(bvhTriangle.mainHumanBone)) - { - Vector3 val = triangleUtil.ClosestPointOnTriangle(p, bvhTriangle.a, bvhTriangle.b, bvhTriangle.c); - Vector3 val2 = p - val; - float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude; - if (sqrMagnitude < best.sqrDistance) - { - best.sqrDistance = sqrMagnitude; - best.triangleIndex = num2; - best.closestPoint = val; - best.normal = bvhTriangle.normal; - best.mainHumanBone = bvhTriangle.mainHumanBone; - } - } - } - } - else - { - int leftChild = bvhNode.leftChild; - int rightChild = bvhNode.rightChild; - float num3 = DistanceSqPointAABB(p, nodes[leftChild].bounds); - float num4 = DistanceSqPointAABB(p, nodes[rightChild].bounds); - if (num3 < num4) - { - QueryClosestRecursiveFiltered(leftChild, p, ref best, allowedBones); - QueryClosestRecursiveFiltered(rightChild, p, ref best, allowedBones); - } - else - { - QueryClosestRecursiveFiltered(rightChild, p, ref best, allowedBones); - QueryClosestRecursiveFiltered(leftChild, p, ref best, allowedBones); - } - } - } + private void QueryClosestRecursiveFiltered(int nodeIndex, Vector3 p, ref ClosestHit best, HashSet allowedBones) + { + //IL_000e: Unknown result type (might be due to invalid IL or missing references) + //IL_0010: Unknown result type (might be due to invalid IL or missing references) + //IL_00fd: Unknown result type (might be due to invalid IL or missing references) + //IL_010b: Unknown result type (might be due to invalid IL or missing references) + //IL_0116: Unknown result type (might be due to invalid IL or missing references) + //IL_0124: Unknown result type (might be due to invalid IL or missing references) + //IL_0150: Unknown result type (might be due to invalid IL or missing references) + //IL_015c: Unknown result type (might be due to invalid IL or missing references) + //IL_0137: Unknown result type (might be due to invalid IL or missing references) + //IL_0143: Unknown result type (might be due to invalid IL or missing references) + //IL_0063: Unknown result type (might be due to invalid IL or missing references) + //IL_0075: Unknown result type (might be due to invalid IL or missing references) + //IL_0078: Unknown result type (might be due to invalid IL or missing references) + //IL_007f: Unknown result type (might be due to invalid IL or missing references) + //IL_0086: Unknown result type (might be due to invalid IL or missing references) + //IL_008b: Unknown result type (might be due to invalid IL or missing references) + //IL_0090: Unknown result type (might be due to invalid IL or missing references) + //IL_0092: Unknown result type (might be due to invalid IL or missing references) + //IL_0093: Unknown result type (might be due to invalid IL or missing references) + //IL_0095: Unknown result type (might be due to invalid IL or missing references) + //IL_009a: Unknown result type (might be due to invalid IL or missing references) + //IL_00bf: Unknown result type (might be due to invalid IL or missing references) + //IL_00c1: Unknown result type (might be due to invalid IL or missing references) + //IL_00c9: Unknown result type (might be due to invalid IL or missing references) + //IL_00ce: 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_00db: Unknown result type (might be due to invalid IL or missing references) + BvhNode bvhNode = this.nodes[nodeIndex]; + if (this.DistanceSqPointAABB(p, bvhNode.bounds) > best.sqrDistance) + { + return; + } + if (bvhNode.isLeaf) + { + int num = bvhNode.start + bvhNode.count; + for (int i = bvhNode.start; i < num; i++) + { + int num2 = this.triIndices[i]; + BvhTriangle bvhTriangle = this.triangles[num2]; + if (allowedBones.Contains(bvhTriangle.mainHumanBone)) + { + Vector3 val = this.triangleUtil.ClosestPointOnTriangle(p, bvhTriangle.a, bvhTriangle.b, bvhTriangle.c); + Vector3 val2 = p - val; + float sqrMagnitude = val2.sqrMagnitude; + if (sqrMagnitude < best.sqrDistance) + { + best.sqrDistance = sqrMagnitude; + best.triangleIndex = num2; + best.closestPoint = val; + best.normal = bvhTriangle.normal; + best.mainHumanBone = bvhTriangle.mainHumanBone; + } + } + } + } + else + { + int leftChild = bvhNode.leftChild; + int rightChild = bvhNode.rightChild; + float num3 = this.DistanceSqPointAABB(p, this.nodes[leftChild].bounds); + float num4 = this.DistanceSqPointAABB(p, this.nodes[rightChild].bounds); + if (num3 < num4) + { + this.QueryClosestRecursiveFiltered(leftChild, p, ref best, allowedBones); + this.QueryClosestRecursiveFiltered(rightChild, p, ref best, allowedBones); + } + else + { + this.QueryClosestRecursiveFiltered(rightChild, p, ref best, allowedBones); + this.QueryClosestRecursiveFiltered(leftChild, p, ref best, allowedBones); + } + } + } - private void QueryClosestRecursive(int nodeIndex, Vector3 p, ref ClosestHit best) - { - //IL_000e: Unknown result type (might be due to invalid IL or missing references) - //IL_0010: 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_00fb: Unknown result type (might be due to invalid IL or missing references) - //IL_0106: 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_013c: Unknown result type (might be due to invalid IL or missing references) - //IL_0146: Unknown result type (might be due to invalid IL or missing references) - //IL_0127: Unknown result type (might be due to invalid IL or missing references) - //IL_0131: Unknown result type (might be due to invalid IL or missing references) - //IL_0065: Unknown result type (might be due to invalid IL or missing references) - //IL_0068: Unknown result type (might be due to invalid IL or missing references) - //IL_006f: Unknown result type (might be due to invalid IL or missing references) - //IL_0076: Unknown result type (might be due to invalid IL or missing references) - //IL_007b: Unknown result type (might be due to invalid IL or missing references) - //IL_0080: 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_0083: 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_008a: Unknown result type (might be due to invalid IL or missing references) - //IL_00af: Unknown result type (might be due to invalid IL or missing references) - //IL_00b1: Unknown result type (might be due to invalid IL or missing references) - //IL_00b9: Unknown result type (might be due to invalid IL or missing references) - //IL_00be: Unknown result type (might be due to invalid IL or missing references) - //IL_00c6: 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) - BvhNode bvhNode = nodes[nodeIndex]; - if (DistanceSqPointAABB(p, bvhNode.bounds) > best.sqrDistance) - { - return; - } - if (bvhNode.isLeaf) - { - int num = bvhNode.start + bvhNode.count; - for (int i = bvhNode.start; i < num; i++) - { - int num2 = triIndices[i]; - BvhTriangle bvhTriangle = triangles[num2]; - Vector3 val = triangleUtil.ClosestPointOnTriangle(p, bvhTriangle.a, bvhTriangle.b, bvhTriangle.c); - Vector3 val2 = p - val; - float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude; - if (sqrMagnitude < best.sqrDistance) - { - best.sqrDistance = sqrMagnitude; - best.triangleIndex = num2; - best.closestPoint = val; - best.normal = bvhTriangle.normal; - best.mainHumanBone = bvhTriangle.mainHumanBone; - } - } - } - else - { - int leftChild = bvhNode.leftChild; - int rightChild = bvhNode.rightChild; - float num3 = DistanceSqPointAABB(p, nodes[leftChild].bounds); - float num4 = DistanceSqPointAABB(p, nodes[rightChild].bounds); - if (num3 < num4) - { - QueryClosestRecursive(leftChild, p, ref best); - QueryClosestRecursive(rightChild, p, ref best); - } - else - { - QueryClosestRecursive(rightChild, p, ref best); - QueryClosestRecursive(leftChild, p, ref best); - } - } - } + private void QueryClosestRecursive(int nodeIndex, Vector3 p, ref ClosestHit best) + { + //IL_000e: Unknown result type (might be due to invalid IL or missing references) + //IL_0010: 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_00fb: Unknown result type (might be due to invalid IL or missing references) + //IL_0106: 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_013c: Unknown result type (might be due to invalid IL or missing references) + //IL_0146: Unknown result type (might be due to invalid IL or missing references) + //IL_0127: Unknown result type (might be due to invalid IL or missing references) + //IL_0131: Unknown result type (might be due to invalid IL or missing references) + //IL_0065: Unknown result type (might be due to invalid IL or missing references) + //IL_0068: Unknown result type (might be due to invalid IL or missing references) + //IL_006f: Unknown result type (might be due to invalid IL or missing references) + //IL_0076: Unknown result type (might be due to invalid IL or missing references) + //IL_007b: Unknown result type (might be due to invalid IL or missing references) + //IL_0080: 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_0083: 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_008a: Unknown result type (might be due to invalid IL or missing references) + //IL_00af: Unknown result type (might be due to invalid IL or missing references) + //IL_00b1: Unknown result type (might be due to invalid IL or missing references) + //IL_00b9: Unknown result type (might be due to invalid IL or missing references) + //IL_00be: Unknown result type (might be due to invalid IL or missing references) + //IL_00c6: 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) + BvhNode bvhNode = this.nodes[nodeIndex]; + if (this.DistanceSqPointAABB(p, bvhNode.bounds) > best.sqrDistance) + { + return; + } + if (bvhNode.isLeaf) + { + int num = bvhNode.start + bvhNode.count; + for (int i = bvhNode.start; i < num; i++) + { + int num2 = this.triIndices[i]; + BvhTriangle bvhTriangle = this.triangles[num2]; + Vector3 val = this.triangleUtil.ClosestPointOnTriangle(p, bvhTriangle.a, bvhTriangle.b, bvhTriangle.c); + Vector3 val2 = p - val; + float sqrMagnitude = val2.sqrMagnitude; + if (sqrMagnitude < best.sqrDistance) + { + best.sqrDistance = sqrMagnitude; + best.triangleIndex = num2; + best.closestPoint = val; + best.normal = bvhTriangle.normal; + best.mainHumanBone = bvhTriangle.mainHumanBone; + } + } + } + else + { + int leftChild = bvhNode.leftChild; + int rightChild = bvhNode.rightChild; + float num3 = this.DistanceSqPointAABB(p, this.nodes[leftChild].bounds); + float num4 = this.DistanceSqPointAABB(p, this.nodes[rightChild].bounds); + if (num3 < num4) + { + this.QueryClosestRecursive(leftChild, p, ref best); + this.QueryClosestRecursive(rightChild, p, ref best); + } + else + { + this.QueryClosestRecursive(rightChild, p, ref best); + this.QueryClosestRecursive(leftChild, p, ref best); + } + } + } - private float DistanceSqPointAABB(Vector3 p, Bounds b) - { - //IL_000a: Unknown result type (might be due to invalid IL or missing references) - //IL_0014: Unknown result type (might be due to invalid IL or missing references) - //IL_001e: Unknown result type (might be due to invalid IL or missing references) - //IL_0026: Unknown result type (might be due to invalid IL or missing references) - //IL_0042: Unknown result type (might be due to invalid IL or missing references) - //IL_004c: Unknown result type (might be due to invalid IL or missing references) - //IL_0056: Unknown result type (might be due to invalid IL or missing references) - //IL_005e: Unknown result type (might be due to invalid IL or missing references) - //IL_007a: Unknown result type (might be due to invalid IL or missing references) - //IL_0084: Unknown result type (might be due to invalid IL or missing references) - //IL_008e: Unknown result type (might be due to invalid IL or missing references) - //IL_0096: Unknown result type (might be due to invalid IL or missing references) - float num = Mathf.Max(new float[3] - { - ((Bounds)(ref b)).min.x - p.x, - 0f, - p.x - ((Bounds)(ref b)).max.x - }); - float num2 = Mathf.Max(new float[3] - { - ((Bounds)(ref b)).min.y - p.y, - 0f, - p.y - ((Bounds)(ref b)).max.y - }); - float num3 = Mathf.Max(new float[3] - { - ((Bounds)(ref b)).min.z - p.z, - 0f, - p.z - ((Bounds)(ref b)).max.z - }); - return num * num + num2 * num2 + num3 * num3; - } + private float DistanceSqPointAABB(Vector3 p, Bounds b) + { + //IL_000a: Unknown result type (might be due to invalid IL or missing references) + //IL_0014: Unknown result type (might be due to invalid IL or missing references) + //IL_001e: Unknown result type (might be due to invalid IL or missing references) + //IL_0026: Unknown result type (might be due to invalid IL or missing references) + //IL_0042: Unknown result type (might be due to invalid IL or missing references) + //IL_004c: Unknown result type (might be due to invalid IL or missing references) + //IL_0056: Unknown result type (might be due to invalid IL or missing references) + //IL_005e: Unknown result type (might be due to invalid IL or missing references) + //IL_007a: Unknown result type (might be due to invalid IL or missing references) + //IL_0084: Unknown result type (might be due to invalid IL or missing references) + //IL_008e: Unknown result type (might be due to invalid IL or missing references) + //IL_0096: Unknown result type (might be due to invalid IL or missing references) + float num = Mathf.Max(new float[3] + { + b.min.x - p.x, + 0f, + p.x - b.max.x + }); + float num2 = Mathf.Max(new float[3] + { + b.min.y - p.y, + 0f, + p.y - b.max.y + }); + float num3 = Mathf.Max(new float[3] + { + b.min.z - p.z, + 0f, + p.z - b.max.z + }); + return num * num + num2 * num2 + num3 * num3; + } - public int QueryClosestN(Vector3 point, int maxCount, float maxDistance, List results) - { - //IL_0026: Unknown result type (might be due to invalid IL or missing references) - results.Clear(); - if (nodes == null || nodes.Length == 0 || maxCount <= 0) - { - return 0; - } - float num = maxDistance * maxDistance; - float currentMaxSq = num; - QueryClosestNRecursive(0, point, maxCount, num, results, ref currentMaxSq); - return results.Count; - } + public int QueryClosestN(Vector3 point, int maxCount, float maxDistance, List results) + { + //IL_0026: Unknown result type (might be due to invalid IL or missing references) + results.Clear(); + if (this.nodes == null || this.nodes.Length == 0 || maxCount <= 0) + { + return 0; + } + float num = maxDistance * maxDistance; + float currentMaxSq = num; + this.QueryClosestNRecursive(0, point, maxCount, num, results, ref currentMaxSq); + return results.Count; + } - private void QueryClosestNRecursive(int nodeIndex, Vector3 p, int maxCount, float maxDistanceSq, List bestHits, ref float currentMaxSq) - { - //IL_000e: Unknown result type (might be due to invalid IL or missing references) - //IL_0010: Unknown result type (might be due to invalid IL or missing references) - //IL_01c8: Unknown result type (might be due to invalid IL or missing references) - //IL_01d6: Unknown result type (might be due to invalid IL or missing references) - //IL_01e1: Unknown result type (might be due to invalid IL or missing references) - //IL_01ef: Unknown result type (might be due to invalid IL or missing references) - //IL_0223: 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_0202: Unknown result type (might be due to invalid IL or missing references) - //IL_0212: Unknown result type (might be due to invalid IL or missing references) - //IL_0062: Unknown result type (might be due to invalid IL or missing references) - //IL_0065: Unknown result type (might be due to invalid IL or missing references) - //IL_006c: Unknown result type (might be due to invalid IL or missing references) - //IL_0073: Unknown result type (might be due to invalid IL or missing references) - //IL_0078: Unknown result type (might be due to invalid IL or missing references) - //IL_007d: Unknown result type (might be due to invalid IL or missing references) - //IL_007f: Unknown result type (might be due to invalid IL or missing references) - //IL_0080: 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_00b9: Unknown result type (might be due to invalid IL or missing references) - //IL_00bb: 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_00c9: Unknown result type (might be due to invalid IL or missing references) - //IL_00db: Unknown result type (might be due to invalid IL or missing references) - //IL_00e0: Unknown result type (might be due to invalid IL or missing references) - //IL_0179: Unknown result type (might be due to invalid IL or missing references) - //IL_017b: Unknown result type (might be due to invalid IL or missing references) - //IL_0184: Unknown result type (might be due to invalid IL or missing references) - //IL_0189: Unknown result type (might be due to invalid IL or missing references) - BvhNode bvhNode = nodes[nodeIndex]; - if (DistanceSqPointAABB(p, bvhNode.bounds) > currentMaxSq) - { - return; - } - if (bvhNode.isLeaf) - { - int num = bvhNode.start + bvhNode.count; - for (int i = bvhNode.start; i < num; i++) - { - int num2 = triIndices[i]; - BvhTriangle bvhTriangle = triangles[num2]; - Vector3 val = triangleUtil.ClosestPointOnTriangle(p, bvhTriangle.a, bvhTriangle.b, bvhTriangle.c); - Vector3 val2 = p - val; - float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude; - if (sqrMagnitude > maxDistanceSq) - { - continue; - } - if (bestHits.Count < maxCount) - { - bestHits.Add(new ClosestHit - { - triangleIndex = num2, - closestPoint = val, - normal = bvhTriangle.normal, - sqrDistance = sqrMagnitude, - mainHumanBone = bvhTriangle.mainHumanBone - }); - if (bestHits.Count == maxCount) - { - currentMaxSq = GetMaxSqrDistance(bestHits, maxDistanceSq); - } - } - else - { - if (sqrMagnitude >= currentMaxSq) - { - continue; - } - int index = 0; - float sqrDistance = bestHits[0].sqrDistance; - for (int j = 1; j < bestHits.Count; j++) - { - if (bestHits[j].sqrDistance > sqrDistance) - { - sqrDistance = bestHits[j].sqrDistance; - index = j; - } - } - bestHits[index] = new ClosestHit - { - triangleIndex = num2, - closestPoint = val, - normal = bvhTriangle.normal, - sqrDistance = sqrMagnitude - }; - currentMaxSq = GetMaxSqrDistance(bestHits, maxDistanceSq); - } - } - } - else - { - int leftChild = bvhNode.leftChild; - int rightChild = bvhNode.rightChild; - float num3 = DistanceSqPointAABB(p, nodes[leftChild].bounds); - float num4 = DistanceSqPointAABB(p, nodes[rightChild].bounds); - if (num3 < num4) - { - QueryClosestNRecursive(leftChild, p, maxCount, maxDistanceSq, bestHits, ref currentMaxSq); - QueryClosestNRecursive(rightChild, p, maxCount, maxDistanceSq, bestHits, ref currentMaxSq); - } - else - { - QueryClosestNRecursive(rightChild, p, maxCount, maxDistanceSq, bestHits, ref currentMaxSq); - QueryClosestNRecursive(leftChild, p, maxCount, maxDistanceSq, bestHits, ref currentMaxSq); - } - } - } + private void QueryClosestNRecursive(int nodeIndex, Vector3 p, int maxCount, float maxDistanceSq, List bestHits, ref float currentMaxSq) + { + //IL_000e: Unknown result type (might be due to invalid IL or missing references) + //IL_0010: Unknown result type (might be due to invalid IL or missing references) + //IL_01c8: Unknown result type (might be due to invalid IL or missing references) + //IL_01d6: Unknown result type (might be due to invalid IL or missing references) + //IL_01e1: Unknown result type (might be due to invalid IL or missing references) + //IL_01ef: Unknown result type (might be due to invalid IL or missing references) + //IL_0223: 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_0202: Unknown result type (might be due to invalid IL or missing references) + //IL_0212: Unknown result type (might be due to invalid IL or missing references) + //IL_0062: Unknown result type (might be due to invalid IL or missing references) + //IL_0065: Unknown result type (might be due to invalid IL or missing references) + //IL_006c: Unknown result type (might be due to invalid IL or missing references) + //IL_0073: Unknown result type (might be due to invalid IL or missing references) + //IL_0078: Unknown result type (might be due to invalid IL or missing references) + //IL_007d: Unknown result type (might be due to invalid IL or missing references) + //IL_007f: Unknown result type (might be due to invalid IL or missing references) + //IL_0080: 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_00b9: Unknown result type (might be due to invalid IL or missing references) + //IL_00bb: 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_00c9: Unknown result type (might be due to invalid IL or missing references) + //IL_00db: Unknown result type (might be due to invalid IL or missing references) + //IL_00e0: Unknown result type (might be due to invalid IL or missing references) + //IL_0179: Unknown result type (might be due to invalid IL or missing references) + //IL_017b: Unknown result type (might be due to invalid IL or missing references) + //IL_0184: Unknown result type (might be due to invalid IL or missing references) + //IL_0189: Unknown result type (might be due to invalid IL or missing references) + BvhNode bvhNode = this.nodes[nodeIndex]; + if (this.DistanceSqPointAABB(p, bvhNode.bounds) > currentMaxSq) + { + return; + } + if (bvhNode.isLeaf) + { + int num = bvhNode.start + bvhNode.count; + for (int i = bvhNode.start; i < num; i++) + { + int num2 = this.triIndices[i]; + BvhTriangle bvhTriangle = this.triangles[num2]; + Vector3 val = this.triangleUtil.ClosestPointOnTriangle(p, bvhTriangle.a, bvhTriangle.b, bvhTriangle.c); + Vector3 val2 = p - val; + float sqrMagnitude = val2.sqrMagnitude; + if (sqrMagnitude > maxDistanceSq) + { + continue; + } + if (bestHits.Count < maxCount) + { + bestHits.Add(new ClosestHit + { + triangleIndex = num2, + closestPoint = val, + normal = bvhTriangle.normal, + sqrDistance = sqrMagnitude, + mainHumanBone = bvhTriangle.mainHumanBone + }); + if (bestHits.Count == maxCount) + { + currentMaxSq = this.GetMaxSqrDistance(bestHits, maxDistanceSq); + } + } + else + { + if (sqrMagnitude >= currentMaxSq) + { + continue; + } + int index = 0; + float sqrDistance = bestHits[0].sqrDistance; + for (int j = 1; j < bestHits.Count; j++) + { + if (bestHits[j].sqrDistance > sqrDistance) + { + sqrDistance = bestHits[j].sqrDistance; + index = j; + } + } + bestHits[index] = new ClosestHit + { + triangleIndex = num2, + closestPoint = val, + normal = bvhTriangle.normal, + sqrDistance = sqrMagnitude + }; + currentMaxSq = this.GetMaxSqrDistance(bestHits, maxDistanceSq); + } + } + } + else + { + int leftChild = bvhNode.leftChild; + int rightChild = bvhNode.rightChild; + float num3 = this.DistanceSqPointAABB(p, this.nodes[leftChild].bounds); + float num4 = this.DistanceSqPointAABB(p, this.nodes[rightChild].bounds); + if (num3 < num4) + { + this.QueryClosestNRecursive(leftChild, p, maxCount, maxDistanceSq, bestHits, ref currentMaxSq); + this.QueryClosestNRecursive(rightChild, p, maxCount, maxDistanceSq, bestHits, ref currentMaxSq); + } + else + { + this.QueryClosestNRecursive(rightChild, p, maxCount, maxDistanceSq, bestHits, ref currentMaxSq); + this.QueryClosestNRecursive(leftChild, p, maxCount, maxDistanceSq, bestHits, ref currentMaxSq); + } + } + } - private float GetMaxSqrDistance(List bestHits, float maxDistanceSq) - { - if (bestHits.Count == 0) - { - return maxDistanceSq; - } - float sqrDistance = bestHits[0].sqrDistance; - for (int i = 1; i < bestHits.Count; i++) - { - if (bestHits[i].sqrDistance > sqrDistance) - { - sqrDistance = bestHits[i].sqrDistance; - } - } - return Mathf.Min(sqrDistance, maxDistanceSq); - } + private float GetMaxSqrDistance(List bestHits, float maxDistanceSq) + { + if (bestHits.Count == 0) + { + return maxDistanceSq; + } + float sqrDistance = bestHits[0].sqrDistance; + for (int i = 1; i < bestHits.Count; i++) + { + if (bestHits[i].sqrDistance > sqrDistance) + { + sqrDistance = bestHits[i].sqrDistance; + } + } + return Mathf.Min(sqrDistance, maxDistanceSq); + } - public Vector3 ComputeMoveVectorToSurface(Vector3 p, float targetGap = 0f) - { - //IL_0001: Unknown result type (might be due to invalid IL or missing references) - //IL_0018: Unknown result type (might be due to invalid IL or missing references) - //IL_001d: Unknown result type (might be due to invalid IL or missing references) - //IL_001e: Unknown result type (might be due to invalid IL or missing references) - //IL_0023: Unknown result type (might be due to invalid IL or missing references) - //IL_0011: Unknown result type (might be due to invalid IL or missing references) - //IL_0045: Unknown result type (might be due to invalid IL or missing references) - //IL_002c: Unknown result type (might be due to invalid IL or missing references) - //IL_0034: Unknown result type (might be due to invalid IL or missing references) - //IL_003a: Unknown result type (might be due to invalid IL or missing references) - //IL_003f: Unknown result type (might be due to invalid IL or missing references) - //IL_0044: Unknown result type (might be due to invalid IL or missing references) - ClosestHit closestHit = QueryClosest(p); - if (closestHit.triangleIndex < 0) - { - return Vector3.zero; - } - Vector3 val = closestHit.closestPoint - p; - if (targetGap > 0f) - { - val += ((Vector3)(ref closestHit.normal)).normalized * targetGap; - } - return val; - } + public Vector3 ComputeMoveVectorToSurface(Vector3 p, float targetGap = 0f) + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + //IL_0018: Unknown result type (might be due to invalid IL or missing references) + //IL_001d: Unknown result type (might be due to invalid IL or missing references) + //IL_001e: Unknown result type (might be due to invalid IL or missing references) + //IL_0023: Unknown result type (might be due to invalid IL or missing references) + //IL_0011: Unknown result type (might be due to invalid IL or missing references) + //IL_0045: Unknown result type (might be due to invalid IL or missing references) + //IL_002c: Unknown result type (might be due to invalid IL or missing references) + //IL_0034: Unknown result type (might be due to invalid IL or missing references) + //IL_003a: Unknown result type (might be due to invalid IL or missing references) + //IL_003f: Unknown result type (might be due to invalid IL or missing references) + //IL_0044: Unknown result type (might be due to invalid IL or missing references) + ClosestHit closestHit = this.QueryClosest(p); + if (closestHit.triangleIndex < 0) + { + return Vector3.zero; + } + Vector3 val = closestHit.closestPoint - p; + if (targetGap > 0f) + { + val += closestHit.normal.normalized * targetGap; + } + return val; + } } diff --git a/Assets/@Eden_Tools/Eden_AutoMorpher/Script/ClothBoneType.cs b/Assets/@Eden_Tools/Eden_AutoMorpher/Script/ClothBoneType.cs index fa26ca7..bc57e23 100644 --- a/Assets/@Eden_Tools/Eden_AutoMorpher/Script/ClothBoneType.cs +++ b/Assets/@Eden_Tools/Eden_AutoMorpher/Script/ClothBoneType.cs @@ -1,9 +1,9 @@ -// Warning: Some assembly references could not be resolved automatically. This might lead to incorrect decompilation of some parts, +// 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.ClothBoneType public enum ClothBoneType { - Body, - Accessory + Body, + Accessory } diff --git a/Assets/@Eden_Tools/Eden_AutoMorpher/Script/ClothHumanoidMaskUtil.cs b/Assets/@Eden_Tools/Eden_AutoMorpher/Script/ClothHumanoidMaskUtil.cs index 8226383..1481852 100644 --- a/Assets/@Eden_Tools/Eden_AutoMorpher/Script/ClothHumanoidMaskUtil.cs +++ b/Assets/@Eden_Tools/Eden_AutoMorpher/Script/ClothHumanoidMaskUtil.cs @@ -1,306 +1,305 @@ -// Warning: Some assembly references could not be resolved automatically. This might lead to incorrect decompilation of some parts, +// 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.ClothHumanoidMaskUtil using System.Collections.Generic; -using Eden.AutoMorpher; using UnityEngine; public class ClothHumanoidMaskUtil { - public void BuildExcludedVertexMaskForHandsAndHead(ClothInstance clothInstance, bool excludeHandRoot = false, bool excludeThumbRoot = false) - { - //IL_02ea: Unknown result type (might be due to invalid IL or missing references) - //IL_02ef: Unknown result type (might be due to invalid IL or missing references) - if (clothInstance == null || (Object)(object)clothInstance.smr == (Object)null) - { - Debug.LogWarning((object)"[ClothHumanoidMaskUtil] clothInstance / smr 가 null"); - return; - } - SkinnedMeshRenderer smr = clothInstance.smr; - Mesh val = clothInstance.editableMesh ?? smr.sharedMesh; - if ((Object)(object)val == (Object)null) - { - Debug.LogWarning((object)"[ClothHumanoidMaskUtil] mesh 가 null"); - return; - } - BoneWeight[] boneWeights = val.boneWeights; - Transform[] bones = smr.bones; - if (boneWeights == null || boneWeights.Length == 0 || bones == null || bones.Length == 0) - { - Debug.LogWarning((object)"[ClothHumanoidMaskUtil] boneWeights 또는 bones 비어있음"); - return; - } - if (clothInstance.humanoidMatchedBones == null || clothInstance.humanoidMatchedBones.Count == 0) - { - Debug.LogWarning((object)"[ClothHumanoidMaskUtil] humanoidMatchedBones 가 비어있음 (BodyToClothPoseApplier에서 매칭 안 되었을 가능성)"); - return; - } - int num = val.vertexCount; - if (boneWeights.Length != num) - { - num = Mathf.Min(num, boneWeights.Length); - } - HashSet excludedBones = new HashSet(); - Dictionary> humanoidMatchedBones = clothInstance.humanoidMatchedBones; - if (humanoidMatchedBones.TryGetValue((HumanBodyBones)10, out var value) && value != null) - { - foreach (Transform item in value) - { - if (!((Object)(object)item == (Object)null)) - { - AddHierarchy(item, includeRoot: true); - } - } - } - if (humanoidMatchedBones.TryGetValue((HumanBodyBones)17, out var value2) && value2 != null) - { - foreach (Transform item2 in value2) - { - if (!((Object)(object)item2 == (Object)null)) - { - AddHierarchy(item2, excludeHandRoot); - } - } - } - if (humanoidMatchedBones.TryGetValue((HumanBodyBones)18, out var value3) && value3 != null) - { - foreach (Transform item3 in value3) - { - if (!((Object)(object)item3 == (Object)null)) - { - AddHierarchy(item3, excludeHandRoot); - } - } - } - if (humanoidMatchedBones.TryGetValue((HumanBodyBones)24, out var value4) && value4 != null) - { - foreach (Transform item4 in value4) - { - if (!((Object)(object)item4 == (Object)null)) - { - if (excludeThumbRoot) - { - excludedBones.Add(item4); - } - else - { - excludedBones.Remove(item4); - } - } - } - } - if (humanoidMatchedBones.TryGetValue((HumanBodyBones)39, out var value5) && value5 != null) - { - foreach (Transform item5 in value5) - { - if (!((Object)(object)item5 == (Object)null)) - { - if (excludeThumbRoot) - { - excludedBones.Add(item5); - } - else - { - excludedBones.Remove(item5); - } - } - } - } - bool[] boneIndexExcluded = new bool[bones.Length]; - for (int i = 0; i < bones.Length; i++) - { - Transform val2 = bones[i]; - if ((Object)(object)val2 != (Object)null && excludedBones.Contains(val2)) - { - boneIndexExcluded[i] = true; - } - } - bool[] array = new bool[num]; - for (int j = 0; j < num; j++) - { - BoneWeight val3 = boneWeights[j]; - float excludedWeightSum = 0f; - AddExcludedWeight(((BoneWeight)(ref val3)).weight0, ((BoneWeight)(ref val3)).boneIndex0); - AddExcludedWeight(((BoneWeight)(ref val3)).weight1, ((BoneWeight)(ref val3)).boneIndex1); - AddExcludedWeight(((BoneWeight)(ref val3)).weight2, ((BoneWeight)(ref val3)).boneIndex2); - AddExcludedWeight(((BoneWeight)(ref val3)).weight3, ((BoneWeight)(ref val3)).boneIndex3); - array[j] = excludedWeightSum >= 0.8f; - void AddExcludedWeight(float w, int bi) - { - if (!(w <= 0f) && bi >= 0 && bi < boneIndexExcluded.Length && boneIndexExcluded[bi]) - { - excludedWeightSum += w; - } - } - } - clothInstance.excludedVertices = array; - BuildLegVertexMasks(clothInstance); - void AddHierarchy(Transform root, bool includeRoot) - { - if (!((Object)(object)root == (Object)null)) - { - Stack stack = new Stack(); - if (includeRoot) - { - stack.Push(root); - } - else - { - for (int k = 0; k < root.childCount; k++) - { - stack.Push(root.GetChild(k)); - } - } - while (stack.Count > 0) - { - Transform val4 = stack.Pop(); - if (!((Object)(object)val4 == (Object)null) && excludedBones.Add(val4)) - { - for (int l = 0; l < val4.childCount; l++) - { - stack.Push(val4.GetChild(l)); - } - } - } - } - } - } + public void BuildExcludedVertexMaskForHandsAndHead(ClothInstance clothInstance, bool excludeHandRoot = false, bool excludeThumbRoot = false) + { + //IL_02ea: Unknown result type (might be due to invalid IL or missing references) + //IL_02ef: Unknown result type (might be due to invalid IL or missing references) + if (clothInstance == null || (Object)(object)clothInstance.smr == (Object)null) + { + Debug.LogWarning((object)"[ClothHumanoidMaskUtil] clothInstance / smr 가 null"); + return; + } + SkinnedMeshRenderer smr = clothInstance.smr; + Mesh val = clothInstance.editableMesh ?? smr.sharedMesh; + if ((Object)(object)val == (Object)null) + { + Debug.LogWarning((object)"[ClothHumanoidMaskUtil] mesh 가 null"); + return; + } + BoneWeight[] boneWeights = val.boneWeights; + Transform[] bones = smr.bones; + if (boneWeights == null || boneWeights.Length == 0 || bones == null || bones.Length == 0) + { + Debug.LogWarning((object)"[ClothHumanoidMaskUtil] boneWeights 또는 bones 비어있음"); + return; + } + if (clothInstance.humanoidMatchedBones == null || clothInstance.humanoidMatchedBones.Count == 0) + { + Debug.LogWarning((object)"[ClothHumanoidMaskUtil] humanoidMatchedBones 가 비어있음 (BodyToClothPoseApplier에서 매칭 안 되었을 가능성)"); + return; + } + int num = val.vertexCount; + if (boneWeights.Length != num) + { + num = Mathf.Min(num, boneWeights.Length); + } + HashSet excludedBones = new HashSet(); + Dictionary> humanoidMatchedBones = clothInstance.humanoidMatchedBones; + if (humanoidMatchedBones.TryGetValue((HumanBodyBones)10, out var value) && value != null) + { + foreach (Transform item in value) + { + if (!((Object)(object)item == (Object)null)) + { + AddHierarchy(item, includeRoot: true); + } + } + } + if (humanoidMatchedBones.TryGetValue((HumanBodyBones)17, out var value2) && value2 != null) + { + foreach (Transform item2 in value2) + { + if (!((Object)(object)item2 == (Object)null)) + { + AddHierarchy(item2, excludeHandRoot); + } + } + } + if (humanoidMatchedBones.TryGetValue((HumanBodyBones)18, out var value3) && value3 != null) + { + foreach (Transform item3 in value3) + { + if (!((Object)(object)item3 == (Object)null)) + { + AddHierarchy(item3, excludeHandRoot); + } + } + } + if (humanoidMatchedBones.TryGetValue((HumanBodyBones)24, out var value4) && value4 != null) + { + foreach (Transform item4 in value4) + { + if (!((Object)(object)item4 == (Object)null)) + { + if (excludeThumbRoot) + { + excludedBones.Add(item4); + } + else + { + excludedBones.Remove(item4); + } + } + } + } + if (humanoidMatchedBones.TryGetValue((HumanBodyBones)39, out var value5) && value5 != null) + { + foreach (Transform item5 in value5) + { + if (!((Object)(object)item5 == (Object)null)) + { + if (excludeThumbRoot) + { + excludedBones.Add(item5); + } + else + { + excludedBones.Remove(item5); + } + } + } + } + bool[] boneIndexExcluded = new bool[bones.Length]; + for (int i = 0; i < bones.Length; i++) + { + Transform val2 = bones[i]; + if ((Object)(object)val2 != (Object)null && excludedBones.Contains(val2)) + { + boneIndexExcluded[i] = true; + } + } + bool[] array = new bool[num]; + for (int j = 0; j < num; j++) + { + BoneWeight val3 = boneWeights[j]; + float excludedWeightSum = 0f; + AddExcludedWeight(val3.weight0, val3.boneIndex0); + AddExcludedWeight(val3.weight1, val3.boneIndex1); + AddExcludedWeight(val3.weight2, val3.boneIndex2); + AddExcludedWeight(val3.weight3, val3.boneIndex3); + array[j] = excludedWeightSum >= 0.8f; + void AddExcludedWeight(float w, int bi) + { + if (!(w <= 0f) && bi >= 0 && bi < boneIndexExcluded.Length && boneIndexExcluded[bi]) + { + excludedWeightSum += w; + } + } + } + clothInstance.excludedVertices = array; + this.BuildLegVertexMasks(clothInstance); + void AddHierarchy(Transform root, bool includeRoot) + { + if (!((Object)(object)root == (Object)null)) + { + Stack stack = new Stack(); + if (includeRoot) + { + stack.Push(root); + } + else + { + for (int k = 0; k < root.childCount; k++) + { + stack.Push(root.GetChild(k)); + } + } + while (stack.Count > 0) + { + Transform val4 = stack.Pop(); + if (!((Object)(object)val4 == (Object)null) && excludedBones.Add(val4)) + { + for (int l = 0; l < val4.childCount; l++) + { + stack.Push(val4.GetChild(l)); + } + } + } + } + } + } - public void BuildLegVertexMasks(ClothInstance clothInstance) - { - //IL_020b: Unknown result type (might be due to invalid IL or missing references) - //IL_0210: Unknown result type (might be due to invalid IL or missing references) - if (clothInstance == null || (Object)(object)clothInstance.smr == (Object)null) - { - Debug.LogWarning((object)"[ClothHumanoidMaskUtil] clothInstance / smr 가 null"); - return; - } - SkinnedMeshRenderer smr = clothInstance.smr; - Mesh val = clothInstance.editableMesh ?? smr.sharedMesh; - if ((Object)(object)val == (Object)null) - { - Debug.LogWarning((object)"[ClothHumanoidMaskUtil] mesh 가 null"); - return; - } - BoneWeight[] boneWeights = val.boneWeights; - Transform[] bones = smr.bones; - if (boneWeights == null || boneWeights.Length == 0 || bones == null || bones.Length == 0) - { - Debug.LogWarning((object)"[ClothHumanoidMaskUtil] boneWeights 또는 bones 비어있음"); - return; - } - if (clothInstance.humanoidMatchedBones == null || clothInstance.humanoidMatchedBones.Count == 0) - { - Debug.LogWarning((object)"[ClothHumanoidMaskUtil] humanoidMatchedBones 가 비어있음 (BodyToClothPoseApplier에서 매칭 필요)"); - return; - } - int num = val.vertexCount; - if (boneWeights.Length != num) - { - num = Mathf.Min(num, boneWeights.Length); - } - Dictionary> humanoidMatchedBones = clothInstance.humanoidMatchedBones; - HashSet hashSet = new HashSet(); - HashSet hashSet2 = new HashSet(); - if (humanoidMatchedBones.TryGetValue((HumanBodyBones)1, out var value) && value != null) - { - foreach (Transform item in value) - { - if (!((Object)(object)item == (Object)null)) - { - CollectHierarchy(item, hashSet); - } - } - } - if (humanoidMatchedBones.TryGetValue((HumanBodyBones)2, out var value2) && value2 != null) - { - foreach (Transform item2 in value2) - { - if (!((Object)(object)item2 == (Object)null)) - { - CollectHierarchy(item2, hashSet2); - } - } - } - bool[] boneIsLeftLeg = new bool[bones.Length]; - bool[] boneIsRightLeg = new bool[bones.Length]; - for (int i = 0; i < bones.Length; i++) - { - Transform val2 = bones[i]; - if (!((Object)(object)val2 == (Object)null)) - { - if (hashSet.Contains(val2)) - { - boneIsLeftLeg[i] = true; - } - if (hashSet2.Contains(val2)) - { - boneIsRightLeg[i] = true; - } - } - } - bool[] array = new bool[num]; - bool[] array2 = new bool[num]; - for (int j = 0; j < num; j++) - { - BoneWeight val3 = boneWeights[j]; - float leftWeight = 0f; - float rightWeight = 0f; - Check(((BoneWeight)(ref val3)).boneIndex0, ((BoneWeight)(ref val3)).weight0); - Check(((BoneWeight)(ref val3)).boneIndex1, ((BoneWeight)(ref val3)).weight1); - Check(((BoneWeight)(ref val3)).boneIndex2, ((BoneWeight)(ref val3)).weight2); - Check(((BoneWeight)(ref val3)).boneIndex3, ((BoneWeight)(ref val3)).weight3); - if (leftWeight > 0.8f) - { - array[j] = true; - array2[j] = false; - } - else if (rightWeight > 0.8f) - { - array[j] = false; - array2[j] = true; - } - else - { - array[j] = false; - array2[j] = false; - } - void Check(int bi, float w) - { - if (bi >= 0 && bi < bones.Length && !(w <= 0f)) - { - if (boneIsLeftLeg[bi]) - { - leftWeight += w; - } - if (boneIsRightLeg[bi]) - { - rightWeight += w; - } - } - } - } - clothInstance.isLeftLegVertex = array; - clothInstance.isRightLegVertex = array2; - void CollectHierarchy(Transform root, HashSet set) - { - if (!((Object)(object)root == (Object)null)) - { - Stack stack = new Stack(); - stack.Push(root); - while (stack.Count > 0) - { - Transform val4 = stack.Pop(); - if (!((Object)(object)val4 == (Object)null) && set.Add(val4)) - { - for (int k = 0; k < val4.childCount; k++) - { - stack.Push(val4.GetChild(k)); - } - } - } - } - } - } + public void BuildLegVertexMasks(ClothInstance clothInstance) + { + //IL_020b: Unknown result type (might be due to invalid IL or missing references) + //IL_0210: Unknown result type (might be due to invalid IL or missing references) + if (clothInstance == null || (Object)(object)clothInstance.smr == (Object)null) + { + Debug.LogWarning((object)"[ClothHumanoidMaskUtil] clothInstance / smr 가 null"); + return; + } + SkinnedMeshRenderer smr = clothInstance.smr; + Mesh val = clothInstance.editableMesh ?? smr.sharedMesh; + if ((Object)(object)val == (Object)null) + { + Debug.LogWarning((object)"[ClothHumanoidMaskUtil] mesh 가 null"); + return; + } + BoneWeight[] boneWeights = val.boneWeights; + Transform[] bones = smr.bones; + if (boneWeights == null || boneWeights.Length == 0 || bones == null || bones.Length == 0) + { + Debug.LogWarning((object)"[ClothHumanoidMaskUtil] boneWeights 또는 bones 비어있음"); + return; + } + if (clothInstance.humanoidMatchedBones == null || clothInstance.humanoidMatchedBones.Count == 0) + { + Debug.LogWarning((object)"[ClothHumanoidMaskUtil] humanoidMatchedBones 가 비어있음 (BodyToClothPoseApplier에서 매칭 필요)"); + return; + } + int num = val.vertexCount; + if (boneWeights.Length != num) + { + num = Mathf.Min(num, boneWeights.Length); + } + Dictionary> humanoidMatchedBones = clothInstance.humanoidMatchedBones; + HashSet hashSet = new HashSet(); + HashSet hashSet2 = new HashSet(); + if (humanoidMatchedBones.TryGetValue((HumanBodyBones)1, out var value) && value != null) + { + foreach (Transform item in value) + { + if (!((Object)(object)item == (Object)null)) + { + CollectHierarchy(item, hashSet); + } + } + } + if (humanoidMatchedBones.TryGetValue((HumanBodyBones)2, out var value2) && value2 != null) + { + foreach (Transform item2 in value2) + { + if (!((Object)(object)item2 == (Object)null)) + { + CollectHierarchy(item2, hashSet2); + } + } + } + bool[] boneIsLeftLeg = new bool[bones.Length]; + bool[] boneIsRightLeg = new bool[bones.Length]; + for (int i = 0; i < bones.Length; i++) + { + Transform val2 = bones[i]; + if (!((Object)(object)val2 == (Object)null)) + { + if (hashSet.Contains(val2)) + { + boneIsLeftLeg[i] = true; + } + if (hashSet2.Contains(val2)) + { + boneIsRightLeg[i] = true; + } + } + } + bool[] array = new bool[num]; + bool[] array2 = new bool[num]; + for (int j = 0; j < num; j++) + { + BoneWeight val3 = boneWeights[j]; + float leftWeight = 0f; + float rightWeight = 0f; + Check(val3.boneIndex0, val3.weight0); + Check(val3.boneIndex1, val3.weight1); + Check(val3.boneIndex2, val3.weight2); + Check(val3.boneIndex3, val3.weight3); + if (leftWeight > 0.8f) + { + array[j] = true; + array2[j] = false; + } + else if (rightWeight > 0.8f) + { + array[j] = false; + array2[j] = true; + } + else + { + array[j] = false; + array2[j] = false; + } + void Check(int bi, float w) + { + if (bi >= 0 && bi < bones.Length && !(w <= 0f)) + { + if (boneIsLeftLeg[bi]) + { + leftWeight += w; + } + if (boneIsRightLeg[bi]) + { + rightWeight += w; + } + } + } + } + clothInstance.isLeftLegVertex = array; + clothInstance.isRightLegVertex = array2; + void CollectHierarchy(Transform root, HashSet set) + { + if (!((Object)(object)root == (Object)null)) + { + Stack stack = new Stack(); + stack.Push(root); + while (stack.Count > 0) + { + Transform val4 = stack.Pop(); + if (!((Object)(object)val4 == (Object)null) && set.Add(val4)) + { + for (int k = 0; k < val4.childCount; k++) + { + stack.Push(val4.GetChild(k)); + } + } + } + } + } + } } diff --git a/Assets/@Eden_Tools/Eden_AutoMorpher/Script/ClothInstance.cs b/Assets/@Eden_Tools/Eden_AutoMorpher/Script/ClothInstance.cs index f72cec3..4766f2d 100644 --- a/Assets/@Eden_Tools/Eden_AutoMorpher/Script/ClothInstance.cs +++ b/Assets/@Eden_Tools/Eden_AutoMorpher/Script/ClothInstance.cs @@ -1,702 +1,700 @@ -// Warning: Some assembly references could not be resolved automatically. This might lead to incorrect decompilation of some parts, +// 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.ClothInstance using System; using System.Collections.Generic; -using Eden.AutoMorpher; using UnityEngine; [Serializable] public class ClothInstance { - public SkinnedMeshRenderer smr; + public SkinnedMeshRenderer smr; - public Mesh editableMesh; + public Mesh editableMesh; - public Mesh bakedMesh; + public Mesh bakedMesh; - public Matrix4x4 worldNoScale; + public Matrix4x4 worldNoScale; - public Vector3[] worldVertices; + public Vector3[] worldVertices; - public Vector3[] minDistanceVector; + public Vector3[] minDistanceVector; - public float[] minDistance; + public float[] minDistance; - public Vector3[] deltas; + public Vector3[] deltas; - public Vector3[] deltasLocal; + public Vector3[] deltasLocal; - public List[] vertexAdjacency; + public List[] vertexAdjacency; - public List> equivalentVertices; + public List> equivalentVertices; - public bool[] isInsideVertex; + public bool[] isInsideVertex; - public bool[] excludedVertices; + public bool[] excludedVertices; - public bool[] isLeftLegVertex; + public bool[] isLeftLegVertex; - public bool[] isRightLegVertex; + public bool[] isRightLegVertex; - public Vector3[] bakedWorldNormals; + public Vector3[] bakedWorldNormals; - public Vector4[] bakedWorldTangents; + public Vector4[] bakedWorldTangents; - public Dictionary> humanoidMatchedBones; + public Dictionary> humanoidMatchedBones; - public ClothInstance(SkinnedMeshRenderer clotheSMR, bool duplicateMesh = true) - { - smr = clotheSMR; - if (duplicateMesh) - { - string name = ((Object)smr.sharedMesh).name; - editableMesh = Object.Instantiate(clotheSMR.sharedMesh); - ((Object)editableMesh).name = name + "_EditableMesh"; - smr.sharedMesh = editableMesh; - } - else - { - editableMesh = smr.sharedMesh; - } - UpdateWorldVertices(); - int vertexCount = editableMesh.vertexCount; - minDistanceVector = (Vector3[])(object)new Vector3[vertexCount]; - deltas = (Vector3[])(object)new Vector3[vertexCount]; - minDistance = new float[vertexCount]; - isInsideVertex = new bool[vertexCount]; - excludedVertices = new bool[vertexCount]; - isLeftLegVertex = new bool[vertexCount]; - isRightLegVertex = new bool[vertexCount]; - humanoidMatchedBones = new Dictionary>(); - vertexAdjacency = BuildVertexAdjacency(editableMesh); - BuildEquivalentVerticesFromWorld(); - } + public ClothInstance(SkinnedMeshRenderer clotheSMR, bool duplicateMesh = true) + { + this.smr = clotheSMR; + if (duplicateMesh) + { + string name = this.smr.sharedMesh.name; + this.editableMesh = UnityEngine.Object.Instantiate(clotheSMR.sharedMesh); + this.editableMesh.name = name + "_EditableMesh"; + this.smr.sharedMesh = this.editableMesh; + } + else + { + this.editableMesh = this.smr.sharedMesh; + } + this.UpdateWorldVertices(); + int vertexCount = this.editableMesh.vertexCount; + this.minDistanceVector = (Vector3[])(object)new Vector3[vertexCount]; + this.deltas = (Vector3[])(object)new Vector3[vertexCount]; + this.minDistance = new float[vertexCount]; + this.isInsideVertex = new bool[vertexCount]; + this.excludedVertices = new bool[vertexCount]; + this.isLeftLegVertex = new bool[vertexCount]; + this.isRightLegVertex = new bool[vertexCount]; + this.humanoidMatchedBones = new Dictionary>(); + this.vertexAdjacency = this.BuildVertexAdjacency(this.editableMesh); + this.BuildEquivalentVerticesFromWorld(); + } - public void UpdateWorldVertices() - { - //IL_000f: Unknown result type (might be due to invalid IL or missing references) - //IL_0019: Expected O, but got Unknown - //IL_004e: Unknown result type (might be due to invalid IL or missing references) - //IL_0053: Unknown result type (might be due to invalid IL or missing references) - //IL_005b: Unknown result type (might be due to invalid IL or missing references) - //IL_0071: 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_00a9: Unknown result type (might be due to invalid IL or missing references) - //IL_00ae: Unknown result type (might be due to invalid IL or missing references) - //IL_00af: Unknown result type (might be due to invalid IL or missing references) - //IL_00b4: Unknown result type (might be due to invalid IL or missing references) - //IL_00b9: Unknown result type (might be due to invalid IL or missing references) - //IL_00f6: Unknown result type (might be due to invalid IL or missing references) - //IL_00fb: Unknown result type (might be due to invalid IL or missing references) - //IL_0100: 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_0112: Unknown result type (might be due to invalid IL or missing references) - //IL_0185: Unknown result type (might be due to invalid IL or missing references) - //IL_018a: Unknown result type (might be due to invalid IL or missing references) - //IL_018f: Unknown result type (might be due to invalid IL or missing references) - //IL_0193: Unknown result type (might be due to invalid IL or missing references) - //IL_0198: 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_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_01e8: Unknown result type (might be due to invalid IL or missing references) - //IL_01ed: Unknown result type (might be due to invalid IL or missing references) - //IL_01f7: Unknown result type (might be due to invalid IL or missing references) - //IL_01fe: 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_021a: Unknown result type (might be due to invalid IL or missing references) - //IL_021f: Unknown result type (might be due to invalid IL or missing references) - if ((Object)(object)bakedMesh == (Object)null) - { - bakedMesh = new Mesh(); - } - else - { - bakedMesh.Clear(); - } - smr.BakeMesh(bakedMesh); - int vertexCount = editableMesh.vertexCount; - Vector3 lossyScale = ((Component)smr).transform.lossyScale; - Vector3 val = default(Vector3); - ((Vector3)(ref val))._002Ector(1f / Mathf.Max(lossyScale.x, 1E-08f), 1f / Mathf.Max(lossyScale.y, 1E-08f), 1f / Mathf.Max(lossyScale.z, 1E-08f)); - worldNoScale = ((Component)smr).transform.localToWorldMatrix * Matrix4x4.Scale(val); - worldVertices = (Vector3[])(object)new Vector3[vertexCount]; - deltasLocal = (Vector3[])(object)new Vector3[vertexCount]; - for (int i = 0; i < vertexCount; i++) - { - worldVertices[i] = ((Matrix4x4)(ref worldNoScale)).MultiplyPoint3x4(bakedMesh.vertices[i]); - deltasLocal[i] = Vector3.zero; - } - Vector3[] normals = bakedMesh.normals; - Vector4[] tangents = bakedMesh.tangents; - bakedWorldNormals = (Vector3[])(object)new Vector3[vertexCount]; - if (tangents != null && tangents.Length == vertexCount) - { - bakedWorldTangents = (Vector4[])(object)new Vector4[vertexCount]; - } - else - { - bakedWorldTangents = null; - } - for (int j = 0; j < vertexCount; j++) - { - Vector3[] array = bakedWorldNormals; - int num = j; - Vector3 val2 = ((Component)smr).transform.TransformDirection(normals[j]); - array[num] = ((Vector3)(ref val2)).normalized; - if (bakedWorldTangents != null) - { - val2 = ((Component)smr).transform.TransformDirection(new Vector3(tangents[j].x, tangents[j].y, tangents[j].z)); - Vector3 normalized = ((Vector3)(ref val2)).normalized; - bakedWorldTangents[j] = new Vector4(normalized.x, normalized.y, normalized.z, tangents[j].w); - } - } - } + public void UpdateWorldVertices() + { + //IL_000f: Unknown result type (might be due to invalid IL or missing references) + //IL_0019: Expected O, but got Unknown + //IL_004e: Unknown result type (might be due to invalid IL or missing references) + //IL_0053: Unknown result type (might be due to invalid IL or missing references) + //IL_005b: Unknown result type (might be due to invalid IL or missing references) + //IL_0071: 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_00a9: Unknown result type (might be due to invalid IL or missing references) + //IL_00ae: Unknown result type (might be due to invalid IL or missing references) + //IL_00af: Unknown result type (might be due to invalid IL or missing references) + //IL_00b4: Unknown result type (might be due to invalid IL or missing references) + //IL_00b9: Unknown result type (might be due to invalid IL or missing references) + //IL_00f6: Unknown result type (might be due to invalid IL or missing references) + //IL_00fb: Unknown result type (might be due to invalid IL or missing references) + //IL_0100: 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_0112: Unknown result type (might be due to invalid IL or missing references) + //IL_0185: Unknown result type (might be due to invalid IL or missing references) + //IL_018a: Unknown result type (might be due to invalid IL or missing references) + //IL_018f: Unknown result type (might be due to invalid IL or missing references) + //IL_0193: Unknown result type (might be due to invalid IL or missing references) + //IL_0198: 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_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_01e8: Unknown result type (might be due to invalid IL or missing references) + //IL_01ed: Unknown result type (might be due to invalid IL or missing references) + //IL_01f7: Unknown result type (might be due to invalid IL or missing references) + //IL_01fe: 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_021a: Unknown result type (might be due to invalid IL or missing references) + //IL_021f: Unknown result type (might be due to invalid IL or missing references) + if (this.bakedMesh == null) + { + this.bakedMesh = new Mesh(); + } + else + { + this.bakedMesh.Clear(); + } + this.smr.BakeMesh(this.bakedMesh); + int vertexCount = this.editableMesh.vertexCount; + Vector3 lossyScale = ((Component)this.smr).transform.lossyScale; + Vector3 val = new Vector3(1f / Mathf.Max(lossyScale.x, 1E-08f), 1f / Mathf.Max(lossyScale.y, 1E-08f), 1f / Mathf.Max(lossyScale.z, 1E-08f)); + this.worldNoScale = ((Component)this.smr).transform.localToWorldMatrix * Matrix4x4.Scale(val); + this.worldVertices = (Vector3[])(object)new Vector3[vertexCount]; + this.deltasLocal = (Vector3[])(object)new Vector3[vertexCount]; + for (int i = 0; i < vertexCount; i++) + { + this.worldVertices[i] = this.worldNoScale.MultiplyPoint3x4(this.bakedMesh.vertices[i]); + this.deltasLocal[i] = Vector3.zero; + } + Vector3[] normals = this.bakedMesh.normals; + Vector4[] tangents = this.bakedMesh.tangents; + this.bakedWorldNormals = (Vector3[])(object)new Vector3[vertexCount]; + if (tangents != null && tangents.Length == vertexCount) + { + this.bakedWorldTangents = (Vector4[])(object)new Vector4[vertexCount]; + } + else + { + this.bakedWorldTangents = null; + } + for (int j = 0; j < vertexCount; j++) + { + Vector3[] array = this.bakedWorldNormals; + int num = j; + Vector3 val2 = ((Component)this.smr).transform.TransformDirection(normals[j]); + array[num] = val2.normalized; + if (this.bakedWorldTangents != null) + { + val2 = ((Component)this.smr).transform.TransformDirection(new Vector3(tangents[j].x, tangents[j].y, tangents[j].z)); + Vector3 normalized = val2.normalized; + this.bakedWorldTangents[j] = new Vector4(normalized.x, normalized.y, normalized.z, tangents[j].w); + } + } + } - public List[] BuildVertexAdjacency(Mesh mesh, float seamThreshold = 0.0001f, float proximityThreshold = 0f) - { - //IL_00e6: Unknown result type (might be due to invalid IL or missing references) - //IL_00eb: Unknown result type (might be due to invalid IL or missing references) - //IL_00ef: Unknown result type (might be due to invalid IL or missing references) - //IL_00fe: 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_0123: Unknown result type (might be due to invalid IL or missing references) - //IL_0367: Unknown result type (might be due to invalid IL or missing references) - //IL_036c: Unknown result type (might be due to invalid IL or missing references) - //IL_0370: Unknown result type (might be due to invalid IL or missing references) - //IL_037f: Unknown result type (might be due to invalid IL or missing references) - //IL_038e: Unknown result type (might be due to invalid IL or missing references) - //IL_03a4: Unknown result type (might be due to invalid IL or missing references) - //IL_0137: Unknown result type (might be due to invalid IL or missing references) - //IL_03b8: Unknown result type (might be due to invalid IL or missing references) - //IL_016d: Unknown result type (might be due to invalid IL or missing references) - //IL_0172: Unknown result type (might be due to invalid IL or missing references) - //IL_03ee: Unknown result type (might be due to invalid IL or missing references) - //IL_03f3: Unknown result type (might be due to invalid IL or missing references) - //IL_01e0: Unknown result type (might be due to invalid IL or missing references) - //IL_0461: Unknown result type (might be due to invalid IL or missing references) - //IL_01ee: Unknown result type (might be due to invalid IL or missing references) - //IL_01f0: Unknown result type (might be due to invalid IL or missing references) - //IL_046f: Unknown result type (might be due to invalid IL or missing references) - //IL_0471: Unknown result type (might be due to invalid IL or missing references) - //IL_0290: 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_020f: Unknown result type (might be due to invalid IL or missing references) - //IL_0214: Unknown result type (might be due to invalid IL or missing references) - //IL_0511: Unknown result type (might be due to invalid IL or missing references) - //IL_0516: 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_02aa: Unknown result type (might be due to invalid IL or missing references) - //IL_02af: Unknown result type (might be due to invalid IL or missing references) - //IL_02b1: Unknown result type (might be due to invalid IL or missing references) - //IL_02b6: Unknown result type (might be due to invalid IL or missing references) - //IL_022c: Unknown result type (might be due to invalid IL or missing references) - //IL_0231: 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_0238: Unknown result type (might be due to invalid IL or missing references) - //IL_052b: Unknown result type (might be due to invalid IL or missing references) - //IL_0530: Unknown result type (might be due to invalid IL or missing references) - //IL_0532: Unknown result type (might be due to invalid IL or missing references) - //IL_0537: Unknown result type (might be due to invalid IL or missing references) - //IL_04ad: 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_04b4: Unknown result type (might be due to invalid IL or missing references) - //IL_04b9: Unknown result type (might be due to invalid IL or missing references) - if ((Object)(object)mesh == (Object)null) - { - throw new AutoMorpherException("Mesh is Missing", "[VertexAdjacencyUtil] BuildVertexAdjacency\n - mesh is null"); - } - int vertexCount = mesh.vertexCount; - int[] triangles = mesh.triangles; - Vector3[] vertices = mesh.vertices; - List[] array = new List[vertexCount]; - for (int i = 0; i < vertexCount; i++) - { - array[i] = new List(); - } - int num = triangles.Length / 3; - for (int j = 0; j < num; j++) - { - int num2 = triangles[j * 3]; - int num3 = triangles[j * 3 + 1]; - int num4 = triangles[j * 3 + 2]; - AddNeighbor(array, num2, num3); - AddNeighbor(array, num3, num2); - AddNeighbor(array, num3, num4); - AddNeighbor(array, num4, num3); - AddNeighbor(array, num4, num2); - AddNeighbor(array, num2, num4); - } - Vector3 val4; - if (seamThreshold > 0f) - { - float num5 = seamThreshold * 2f; - float num6 = seamThreshold * seamThreshold; - Dictionary> dictionary = new Dictionary>(); - Vector3Int key = default(Vector3Int); - for (int k = 0; k < vertexCount; k++) - { - Vector3 val = vertices[k]; - ((Vector3Int)(ref key))._002Ector(Mathf.FloorToInt(val.x / num5), Mathf.FloorToInt(val.y / num5), Mathf.FloorToInt(val.z / num5)); - if (!dictionary.TryGetValue(key, out var value)) - { - value = (dictionary[key] = new List()); - } - value.Add(k); - } - Vector3Int val2 = default(Vector3Int); - foreach (KeyValuePair> item in dictionary) - { - Vector3Int key2 = item.Key; - List value2 = item.Value; - for (int l = -1; l <= 1; l++) - { - for (int m = -1; m <= 1; m++) - { - for (int n = -1; n <= 1; n++) - { - if (l < 0 || (l == 0 && m < 0) || (l == 0 && m == 0 && n < 0)) - { - continue; - } - ((Vector3Int)(ref val2))._002Ector(((Vector3Int)(ref key2)).x + l, ((Vector3Int)(ref key2)).y + m, ((Vector3Int)(ref key2)).z + n); - if (!dictionary.TryGetValue(val2, out var value3)) - { - continue; - } - if (val2 == key2) - { - for (int num7 = 0; num7 < value2.Count; num7++) - { - int num8 = value2[num7]; - Vector3 val3 = vertices[num8]; - for (int num9 = num7 + 1; num9 < value2.Count; num9++) - { - int num10 = value2[num9]; - val4 = vertices[num10] - val3; - if (((Vector3)(ref val4)).sqrMagnitude <= num6) - { - AddNeighbor(array, num8, num10); - AddNeighbor(array, num10, num8); - } - } - } - continue; - } - for (int num11 = 0; num11 < value2.Count; num11++) - { - int num12 = value2[num11]; - Vector3 val5 = vertices[num12]; - for (int num13 = 0; num13 < value3.Count; num13++) - { - int num14 = value3[num13]; - val4 = vertices[num14] - val5; - if (((Vector3)(ref val4)).sqrMagnitude <= num6) - { - AddNeighbor(array, num12, num14); - AddNeighbor(array, num14, num12); - } - } - } - } - } - } - } - } - if (proximityThreshold > 0f) - { - float num15 = proximityThreshold * 2f; - float num16 = proximityThreshold * proximityThreshold; - Dictionary> dictionary2 = new Dictionary>(); - Vector3Int key3 = default(Vector3Int); - for (int num17 = 0; num17 < vertexCount; num17++) - { - Vector3 val6 = vertices[num17]; - ((Vector3Int)(ref key3))._002Ector(Mathf.FloorToInt(val6.x / num15), Mathf.FloorToInt(val6.y / num15), Mathf.FloorToInt(val6.z / num15)); - if (!dictionary2.TryGetValue(key3, out var value4)) - { - value4 = (dictionary2[key3] = new List()); - } - value4.Add(num17); - } - Vector3Int val7 = default(Vector3Int); - foreach (KeyValuePair> item2 in dictionary2) - { - Vector3Int key4 = item2.Key; - List value5 = item2.Value; - for (int num18 = -1; num18 <= 1; num18++) - { - for (int num19 = -1; num19 <= 1; num19++) - { - for (int num20 = -1; num20 <= 1; num20++) - { - if (num18 < 0 || (num18 == 0 && num19 < 0) || (num18 == 0 && num19 == 0 && num20 < 0)) - { - continue; - } - ((Vector3Int)(ref val7))._002Ector(((Vector3Int)(ref key4)).x + num18, ((Vector3Int)(ref key4)).y + num19, ((Vector3Int)(ref key4)).z + num20); - if (!dictionary2.TryGetValue(val7, out var value6)) - { - continue; - } - if (val7 == key4) - { - for (int num21 = 0; num21 < value5.Count; num21++) - { - int num22 = value5[num21]; - Vector3 val8 = vertices[num22]; - for (int num23 = num21 + 1; num23 < value5.Count; num23++) - { - int num24 = value5[num23]; - val4 = vertices[num24] - val8; - if (((Vector3)(ref val4)).sqrMagnitude <= num16) - { - AddNeighbor(array, num22, num24); - AddNeighbor(array, num24, num22); - } - } - } - continue; - } - for (int num25 = 0; num25 < value5.Count; num25++) - { - int num26 = value5[num25]; - Vector3 val9 = vertices[num26]; - for (int num27 = 0; num27 < value6.Count; num27++) - { - int num28 = value6[num27]; - val4 = vertices[num28] - val9; - if (((Vector3)(ref val4)).sqrMagnitude <= num16) - { - AddNeighbor(array, num26, num28); - AddNeighbor(array, num28, num26); - } - } - } - } - } - } - } - } - return array; - void AddNeighbor(List[] adj, int from, int to) - { - List list3 = adj[from]; - if (!list3.Contains(to)) - { - list3.Add(to); - } - } - } + public List[] BuildVertexAdjacency(Mesh mesh, float seamThreshold = 0.0001f, float proximityThreshold = 0f) + { + //IL_00e6: Unknown result type (might be due to invalid IL or missing references) + //IL_00eb: Unknown result type (might be due to invalid IL or missing references) + //IL_00ef: Unknown result type (might be due to invalid IL or missing references) + //IL_00fe: 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_0123: Unknown result type (might be due to invalid IL or missing references) + //IL_0367: Unknown result type (might be due to invalid IL or missing references) + //IL_036c: Unknown result type (might be due to invalid IL or missing references) + //IL_0370: Unknown result type (might be due to invalid IL or missing references) + //IL_037f: Unknown result type (might be due to invalid IL or missing references) + //IL_038e: Unknown result type (might be due to invalid IL or missing references) + //IL_03a4: Unknown result type (might be due to invalid IL or missing references) + //IL_0137: Unknown result type (might be due to invalid IL or missing references) + //IL_03b8: Unknown result type (might be due to invalid IL or missing references) + //IL_016d: Unknown result type (might be due to invalid IL or missing references) + //IL_0172: Unknown result type (might be due to invalid IL or missing references) + //IL_03ee: Unknown result type (might be due to invalid IL or missing references) + //IL_03f3: Unknown result type (might be due to invalid IL or missing references) + //IL_01e0: Unknown result type (might be due to invalid IL or missing references) + //IL_0461: Unknown result type (might be due to invalid IL or missing references) + //IL_01ee: Unknown result type (might be due to invalid IL or missing references) + //IL_01f0: Unknown result type (might be due to invalid IL or missing references) + //IL_046f: Unknown result type (might be due to invalid IL or missing references) + //IL_0471: Unknown result type (might be due to invalid IL or missing references) + //IL_0290: 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_020f: Unknown result type (might be due to invalid IL or missing references) + //IL_0214: Unknown result type (might be due to invalid IL or missing references) + //IL_0511: Unknown result type (might be due to invalid IL or missing references) + //IL_0516: 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_02aa: Unknown result type (might be due to invalid IL or missing references) + //IL_02af: Unknown result type (might be due to invalid IL or missing references) + //IL_02b1: Unknown result type (might be due to invalid IL or missing references) + //IL_02b6: Unknown result type (might be due to invalid IL or missing references) + //IL_022c: Unknown result type (might be due to invalid IL or missing references) + //IL_0231: 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_0238: Unknown result type (might be due to invalid IL or missing references) + //IL_052b: Unknown result type (might be due to invalid IL or missing references) + //IL_0530: Unknown result type (might be due to invalid IL or missing references) + //IL_0532: Unknown result type (might be due to invalid IL or missing references) + //IL_0537: Unknown result type (might be due to invalid IL or missing references) + //IL_04ad: 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_04b4: Unknown result type (might be due to invalid IL or missing references) + //IL_04b9: Unknown result type (might be due to invalid IL or missing references) + if (mesh == null) + { + throw new AutoMorpherException("Mesh is Missing", "[VertexAdjacencyUtil] BuildVertexAdjacency\n - mesh is null"); + } + int vertexCount = mesh.vertexCount; + int[] triangles = mesh.triangles; + Vector3[] vertices = mesh.vertices; + List[] array = new List[vertexCount]; + for (int i = 0; i < vertexCount; i++) + { + array[i] = new List(); + } + int num = triangles.Length / 3; + for (int j = 0; j < num; j++) + { + int num2 = triangles[j * 3]; + int num3 = triangles[j * 3 + 1]; + int num4 = triangles[j * 3 + 2]; + AddNeighbor(array, num2, num3); + AddNeighbor(array, num3, num2); + AddNeighbor(array, num3, num4); + AddNeighbor(array, num4, num3); + AddNeighbor(array, num4, num2); + AddNeighbor(array, num2, num4); + } + Vector3 val4; + if (seamThreshold > 0f) + { + float num5 = seamThreshold * 2f; + float num6 = seamThreshold * seamThreshold; + Dictionary> dictionary = new Dictionary>(); + Vector3Int key = default(Vector3Int); + for (int k = 0; k < vertexCount; k++) + { + Vector3 val = vertices[k]; + key = new Vector3Int(Mathf.FloorToInt(val.x / num5), Mathf.FloorToInt(val.y / num5), Mathf.FloorToInt(val.z / num5)); + if (!dictionary.TryGetValue(key, out var value)) + { + value = (dictionary[key] = new List()); + } + value.Add(k); + } + Vector3Int val2 = default(Vector3Int); + foreach (KeyValuePair> item in dictionary) + { + Vector3Int key2 = item.Key; + List value2 = item.Value; + for (int l = -1; l <= 1; l++) + { + for (int m = -1; m <= 1; m++) + { + for (int n = -1; n <= 1; n++) + { + if (l < 0 || (l == 0 && m < 0) || (l == 0 && m == 0 && n < 0)) + { + continue; + } + val2 = new(key2.x + l, key2.y + m, key2.z + n); + if (!dictionary.TryGetValue(val2, out var value3)) + { + continue; + } + if (val2 == key2) + { + for (int num7 = 0; num7 < value2.Count; num7++) + { + int num8 = value2[num7]; + Vector3 val3 = vertices[num8]; + for (int num9 = num7 + 1; num9 < value2.Count; num9++) + { + int num10 = value2[num9]; + val4 = vertices[num10] - val3; + if (val4.sqrMagnitude <= num6) + { + AddNeighbor(array, num8, num10); + AddNeighbor(array, num10, num8); + } + } + } + continue; + } + for (int num11 = 0; num11 < value2.Count; num11++) + { + int num12 = value2[num11]; + Vector3 val5 = vertices[num12]; + for (int num13 = 0; num13 < value3.Count; num13++) + { + int num14 = value3[num13]; + val4 = vertices[num14] - val5; + if (val4.sqrMagnitude <= num6) + { + AddNeighbor(array, num12, num14); + AddNeighbor(array, num14, num12); + } + } + } + } + } + } + } + } + if (proximityThreshold > 0f) + { + float num15 = proximityThreshold * 2f; + float num16 = proximityThreshold * proximityThreshold; + Dictionary> dictionary2 = new Dictionary>(); + Vector3Int key3 = default(Vector3Int); + for (int num17 = 0; num17 < vertexCount; num17++) + { + Vector3 val6 = vertices[num17]; + key3 = new Vector3Int(Mathf.FloorToInt(val6.x / num15), Mathf.FloorToInt(val6.y / num15), Mathf.FloorToInt(val6.z / num15)); + if (!dictionary2.TryGetValue(key3, out var value4)) + { + value4 = (dictionary2[key3] = new List()); + } + value4.Add(num17); + } + Vector3Int val7 = default(Vector3Int); + foreach (KeyValuePair> item2 in dictionary2) + { + Vector3Int key4 = item2.Key; + List value5 = item2.Value; + for (int num18 = -1; num18 <= 1; num18++) + { + for (int num19 = -1; num19 <= 1; num19++) + { + for (int num20 = -1; num20 <= 1; num20++) + { + if (num18 < 0 || (num18 == 0 && num19 < 0) || (num18 == 0 && num19 == 0 && num20 < 0)) + { + continue; + } + val7 = new Vector3Int(key4.x + num18, key4.y + num19, key4.z + num20); + if (!dictionary2.TryGetValue(val7, out var value6)) + { + continue; + } + if (val7 == key4) + { + for (int num21 = 0; num21 < value5.Count; num21++) + { + int num22 = value5[num21]; + Vector3 val8 = vertices[num22]; + for (int num23 = num21 + 1; num23 < value5.Count; num23++) + { + int num24 = value5[num23]; + val4 = vertices[num24] - val8; + if (val4.sqrMagnitude <= num16) + { + AddNeighbor(array, num22, num24); + AddNeighbor(array, num24, num22); + } + } + } + continue; + } + for (int num25 = 0; num25 < value5.Count; num25++) + { + int num26 = value5[num25]; + Vector3 val9 = vertices[num26]; + for (int num27 = 0; num27 < value6.Count; num27++) + { + int num28 = value6[num27]; + val4 = vertices[num28] - val9; + if (val4.sqrMagnitude <= num16) + { + AddNeighbor(array, num26, num28); + AddNeighbor(array, num28, num26); + } + } + } + } + } + } + } + } + return array; + void AddNeighbor(List[] adj, int from, int to) + { + List list3 = adj[from]; + if (!list3.Contains(to)) + { + list3.Add(to); + } + } + } - public void ApplyWorldVerticesToMesh() - { - //IL_0147: Unknown result type (might be due to invalid IL or missing references) - //IL_014c: Unknown result type (might be due to invalid IL or missing references) - //IL_0151: Unknown result type (might be due to invalid IL or missing references) - //IL_016c: Unknown result type (might be due to invalid IL or missing references) - //IL_016e: Unknown result type (might be due to invalid IL or missing references) - //IL_0157: Unknown result type (might be due to invalid IL or missing references) - //IL_015d: Unknown result type (might be due to invalid IL or missing references) - //IL_0162: Unknown result type (might be due to invalid IL or missing references) - //IL_0167: Unknown result type (might be due to invalid IL or missing references) - //IL_00f7: Unknown result type (might be due to invalid IL or missing references) - //IL_0100: Unknown result type (might be due to invalid IL or missing references) - //IL_0107: Unknown result type (might be due to invalid IL or missing references) - //IL_010c: 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_02fe: Unknown result type (might be due to invalid IL or missing references) - //IL_0303: Unknown result type (might be due to invalid IL or missing references) - //IL_0308: 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_0248: Unknown result type (might be due to invalid IL or missing references) - //IL_024f: Unknown result type (might be due to invalid IL or missing references) - //IL_0254: Unknown result type (might be due to invalid IL or missing references) - //IL_0259: Unknown result type (might be due to invalid IL or missing references) - //IL_0268: Unknown result type (might be due to invalid IL or missing references) - //IL_0271: 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_027d: 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_0326: Unknown result type (might be due to invalid IL or missing references) - //IL_032b: Unknown result type (might be due to invalid IL or missing references) - //IL_030e: Unknown result type (might be due to invalid IL or missing references) - //IL_0314: Unknown result type (might be due to invalid IL or missing references) - //IL_0319: Unknown result type (might be due to invalid IL or missing references) - //IL_031e: Unknown result type (might be due to invalid IL or missing references) - //IL_037e: Unknown result type (might be due to invalid IL or missing references) - //IL_0380: Unknown result type (might be due to invalid IL or missing references) - //IL_0385: Unknown result type (might be due to invalid IL or missing references) - //IL_039f: Unknown result type (might be due to invalid IL or missing references) - //IL_03a4: Unknown result type (might be due to invalid IL or missing references) - //IL_03aa: Unknown result type (might be due to invalid IL or missing references) - //IL_03b1: Unknown result type (might be due to invalid IL or missing references) - //IL_03b8: Unknown result type (might be due to invalid IL or missing references) - //IL_03d1: Unknown result type (might be due to invalid IL or missing references) - //IL_03d6: Unknown result type (might be due to invalid IL or missing references) - //IL_038b: Unknown result type (might be due to invalid IL or missing references) - //IL_0391: Unknown result type (might be due to invalid IL or missing references) - //IL_0396: Unknown result type (might be due to invalid IL or missing references) - //IL_039b: Unknown result type (might be due to invalid IL or missing references) - if ((Object)(object)editableMesh == (Object)null || (Object)(object)smr == (Object)null || worldVertices == null) - { - return; - } - Mesh val = editableMesh; - int vertexCount = val.vertexCount; - Vector3[] vertices = val.vertices; - SkinningUtil skinningUtil = new SkinningUtil(); - Vector3[] array = null; - int blendShapeCount = val.blendShapeCount; - if (blendShapeCount > 0) - { - array = (Vector3[])(object)new Vector3[vertexCount]; - Vector3[] array2 = (Vector3[])(object)new Vector3[vertexCount]; - Vector3[] array3 = (Vector3[])(object)new Vector3[vertexCount]; - Vector3[] array4 = (Vector3[])(object)new Vector3[vertexCount]; - for (int i = 0; i < blendShapeCount; i++) - { - float blendShapeWeight = smr.GetBlendShapeWeight(i); - if (Mathf.Approximately(blendShapeWeight, 0f)) - { - continue; - } - int num = val.GetBlendShapeFrameCount(i) - 1; - float blendShapeFrameWeight = val.GetBlendShapeFrameWeight(i, num); - val.GetBlendShapeFrameVertices(i, num, array2, array3, array4); - float num2 = ((blendShapeFrameWeight != 0f) ? (blendShapeWeight / blendShapeFrameWeight) : 0f); - if (!Mathf.Approximately(num2, 0f)) - { - for (int j = 0; j < vertexCount; j++) - { - ref Vector3 reference = ref array[j]; - reference += array2[j] * num2; - } - } - } - } - for (int k = 0; k < vertexCount; k++) - { - Vector3 val2 = skinningUtil.WorldPosToBindPos_Full(smr, val, k, worldVertices[k]); - if (array != null) - { - val2 -= array[k]; - } - vertices[k] = val2; - } - val.vertices = vertices; - Vector3[] array5 = null; - Vector3[] array6 = null; - if (blendShapeCount > 0) - { - array5 = (Vector3[])(object)new Vector3[vertexCount]; - array6 = (Vector3[])(object)new Vector3[vertexCount]; - Vector3[] array7 = (Vector3[])(object)new Vector3[vertexCount]; - Vector3[] array8 = (Vector3[])(object)new Vector3[vertexCount]; - Vector3[] array9 = (Vector3[])(object)new Vector3[vertexCount]; - for (int l = 0; l < blendShapeCount; l++) - { - float blendShapeWeight2 = smr.GetBlendShapeWeight(l); - if (Mathf.Approximately(blendShapeWeight2, 0f)) - { - continue; - } - int num3 = val.GetBlendShapeFrameCount(l) - 1; - float blendShapeFrameWeight2 = val.GetBlendShapeFrameWeight(l, num3); - val.GetBlendShapeFrameVertices(l, num3, array7, array8, array9); - float num4 = ((blendShapeFrameWeight2 != 0f) ? (blendShapeWeight2 / blendShapeFrameWeight2) : 0f); - if (!Mathf.Approximately(num4, 0f)) - { - for (int m = 0; m < vertexCount; m++) - { - ref Vector3 reference2 = ref array5[m]; - reference2 += array8[m] * num4; - ref Vector3 reference3 = ref array6[m]; - reference3 += array9[m] * num4; - } - } - } - } - if (bakedWorldNormals == null || bakedWorldNormals.Length != vertexCount) - { - return; - } - Vector3[] array10 = (Vector3[])(object)new Vector3[vertexCount]; - bool flag = bakedWorldTangents != null && bakedWorldTangents.Length == vertexCount; - Vector4[] array11 = (Vector4[])(object)(flag ? new Vector4[vertexCount] : null); - Vector3 targetWorldDir = default(Vector3); - for (int n = 0; n < vertexCount; n++) - { - Vector3 val3 = skinningUtil.WorldDirToBindDir_Full(smr, val, n, bakedWorldNormals[n]); - if (array5 != null) - { - val3 -= array5[n]; - } - array10[n] = ((Vector3)(ref val3)).normalized; - if (flag) - { - ((Vector3)(ref targetWorldDir))._002Ector(bakedWorldTangents[n].x, bakedWorldTangents[n].y, bakedWorldTangents[n].z); - Vector3 val4 = skinningUtil.WorldDirToBindDir_Full(smr, val, n, targetWorldDir); - if (array6 != null) - { - val4 -= array6[n]; - } - val4 = ((Vector3)(ref val4)).normalized; - array11[n] = new Vector4(val4.x, val4.y, val4.z, bakedWorldTangents[n].w); - } - } - val.normals = array10; - if (array11 != null) - { - val.tangents = array11; - } - } + public void ApplyWorldVerticesToMesh() + { + //IL_0147: Unknown result type (might be due to invalid IL or missing references) + //IL_014c: Unknown result type (might be due to invalid IL or missing references) + //IL_0151: Unknown result type (might be due to invalid IL or missing references) + //IL_016c: Unknown result type (might be due to invalid IL or missing references) + //IL_016e: Unknown result type (might be due to invalid IL or missing references) + //IL_0157: Unknown result type (might be due to invalid IL or missing references) + //IL_015d: Unknown result type (might be due to invalid IL or missing references) + //IL_0162: Unknown result type (might be due to invalid IL or missing references) + //IL_0167: Unknown result type (might be due to invalid IL or missing references) + //IL_00f7: Unknown result type (might be due to invalid IL or missing references) + //IL_0100: Unknown result type (might be due to invalid IL or missing references) + //IL_0107: Unknown result type (might be due to invalid IL or missing references) + //IL_010c: 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_02fe: Unknown result type (might be due to invalid IL or missing references) + //IL_0303: Unknown result type (might be due to invalid IL or missing references) + //IL_0308: 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_0248: Unknown result type (might be due to invalid IL or missing references) + //IL_024f: Unknown result type (might be due to invalid IL or missing references) + //IL_0254: Unknown result type (might be due to invalid IL or missing references) + //IL_0259: Unknown result type (might be due to invalid IL or missing references) + //IL_0268: Unknown result type (might be due to invalid IL or missing references) + //IL_0271: 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_027d: 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_0326: Unknown result type (might be due to invalid IL or missing references) + //IL_032b: Unknown result type (might be due to invalid IL or missing references) + //IL_030e: Unknown result type (might be due to invalid IL or missing references) + //IL_0314: Unknown result type (might be due to invalid IL or missing references) + //IL_0319: Unknown result type (might be due to invalid IL or missing references) + //IL_031e: Unknown result type (might be due to invalid IL or missing references) + //IL_037e: Unknown result type (might be due to invalid IL or missing references) + //IL_0380: Unknown result type (might be due to invalid IL or missing references) + //IL_0385: Unknown result type (might be due to invalid IL or missing references) + //IL_039f: Unknown result type (might be due to invalid IL or missing references) + //IL_03a4: Unknown result type (might be due to invalid IL or missing references) + //IL_03aa: Unknown result type (might be due to invalid IL or missing references) + //IL_03b1: Unknown result type (might be due to invalid IL or missing references) + //IL_03b8: Unknown result type (might be due to invalid IL or missing references) + //IL_03d1: Unknown result type (might be due to invalid IL or missing references) + //IL_03d6: Unknown result type (might be due to invalid IL or missing references) + //IL_038b: Unknown result type (might be due to invalid IL or missing references) + //IL_0391: Unknown result type (might be due to invalid IL or missing references) + //IL_0396: Unknown result type (might be due to invalid IL or missing references) + //IL_039b: Unknown result type (might be due to invalid IL or missing references) + if (this.editableMesh == null || this.smr == null || this.worldVertices == null) + { + return; + } + Mesh val = this.editableMesh; + int vertexCount = val.vertexCount; + Vector3[] vertices = val.vertices; + SkinningUtil skinningUtil = new SkinningUtil(); + Vector3[] array = null; + int blendShapeCount = val.blendShapeCount; + if (blendShapeCount > 0) + { + array = (Vector3[])(object)new Vector3[vertexCount]; + Vector3[] array2 = new Vector3[vertexCount]; + Vector3[] array3 = new Vector3[vertexCount]; + Vector3[] array4 = new Vector3[vertexCount]; + for (int i = 0; i < blendShapeCount; i++) + { + float blendShapeWeight = this.smr.GetBlendShapeWeight(i); + if (Mathf.Approximately(blendShapeWeight, 0f)) + { + continue; + } + int num = val.GetBlendShapeFrameCount(i) - 1; + float blendShapeFrameWeight = val.GetBlendShapeFrameWeight(i, num); + val.GetBlendShapeFrameVertices(i, num, array2, array3, array4); + float num2 = ((blendShapeFrameWeight != 0f) ? (blendShapeWeight / blendShapeFrameWeight) : 0f); + if (!Mathf.Approximately(num2, 0f)) + { + for (int j = 0; j < vertexCount; j++) + { + ref Vector3 reference = ref array[j]; + reference += array2[j] * num2; + } + } + } + } + for (int k = 0; k < vertexCount; k++) + { + Vector3 val2 = skinningUtil.WorldPosToBindPos_Full(this.smr, val, k, this.worldVertices[k]); + if (array != null) + { + val2 -= array[k]; + } + vertices[k] = val2; + } + val.vertices = vertices; + Vector3[] array5 = null; + Vector3[] array6 = null; + if (blendShapeCount > 0) + { + array5 = (Vector3[])(object)new Vector3[vertexCount]; + array6 = (Vector3[])(object)new Vector3[vertexCount]; + Vector3[] array7 = (Vector3[])(object)new Vector3[vertexCount]; + Vector3[] array8 = (Vector3[])(object)new Vector3[vertexCount]; + Vector3[] array9 = (Vector3[])(object)new Vector3[vertexCount]; + for (int l = 0; l < blendShapeCount; l++) + { + float blendShapeWeight2 = this.smr.GetBlendShapeWeight(l); + if (Mathf.Approximately(blendShapeWeight2, 0f)) + { + continue; + } + int num3 = val.GetBlendShapeFrameCount(l) - 1; + float blendShapeFrameWeight2 = val.GetBlendShapeFrameWeight(l, num3); + val.GetBlendShapeFrameVertices(l, num3, array7, array8, array9); + float num4 = ((blendShapeFrameWeight2 != 0f) ? (blendShapeWeight2 / blendShapeFrameWeight2) : 0f); + if (!Mathf.Approximately(num4, 0f)) + { + for (int m = 0; m < vertexCount; m++) + { + ref Vector3 reference2 = ref array5[m]; + reference2 += array8[m] * num4; + ref Vector3 reference3 = ref array6[m]; + reference3 += array9[m] * num4; + } + } + } + } + if (this.bakedWorldNormals == null || this.bakedWorldNormals.Length != vertexCount) + { + return; + } + Vector3[] array10 = (Vector3[])(object)new Vector3[vertexCount]; + bool flag = this.bakedWorldTangents != null && this.bakedWorldTangents.Length == vertexCount; + Vector4[] array11 = (Vector4[])(object)(flag ? new Vector4[vertexCount] : null); + Vector3 targetWorldDir = default(Vector3); + for (int n = 0; n < vertexCount; n++) + { + Vector3 val3 = skinningUtil.WorldDirToBindDir_Full(this.smr, val, n, this.bakedWorldNormals[n]); + if (array5 != null) + { + val3 -= array5[n]; + } + array10[n] = val3.normalized; + if (flag) + { + targetWorldDir = new Vector3(this.bakedWorldTangents[n].x, this.bakedWorldTangents[n].y, this.bakedWorldTangents[n].z); + Vector3 val4 = skinningUtil.WorldDirToBindDir_Full(this.smr, val, n, targetWorldDir); + if (array6 != null) + { + val4 -= array6[n]; + } + val4 = val4.normalized; + array11[n] = new Vector4(val4.x, val4.y, val4.z, this.bakedWorldTangents[n].w); + } + } + val.normals = array10; + if (array11 != null) + { + val.tangents = array11; + } + } - public void BuildEquivalentVerticesFromWorld(float maxDistance = 1E-05f) - { - //IL_005e: Unknown result type (might be due to invalid IL or missing references) - //IL_0063: Unknown result type (might be due to invalid IL or missing references) - //IL_0067: Unknown result type (might be due to invalid IL or missing references) - //IL_0075: Unknown result type (might be due to invalid IL or missing references) - //IL_0083: Unknown result type (might be due to invalid IL or missing references) - //IL_0097: Unknown result type (might be due to invalid IL or missing references) - //IL_00aa: 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_013f: Unknown result type (might be due to invalid IL or missing references) - //IL_015c: 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_0163: Unknown result type (might be due to invalid IL or missing references) - //IL_0165: Unknown result type (might be due to invalid IL or missing references) - //IL_0167: Unknown result type (might be due to invalid IL or missing references) - //IL_016c: Unknown result type (might be due to invalid IL or missing references) - if (worldVertices == null || worldVertices.Length == 0) - { - Debug.LogWarning((object)"[ClothInstance] BuildEquivalentVerticesFromWorld: worldVertices is null or empty. Call UpdateWorldVertices() first."); - return; - } - int num = worldVertices.Length; - if (equivalentVertices == null) - { - equivalentVertices = new List>(); - } - else - { - equivalentVertices.Clear(); - } - float num2 = maxDistance * maxDistance; - Dictionary> dictionary = new Dictionary>(); - Vector3Int key = default(Vector3Int); - for (int i = 0; i < num; i++) - { - Vector3 val = worldVertices[i]; - ((Vector3Int)(ref key))._002Ector(Mathf.FloorToInt(val.x / maxDistance), Mathf.FloorToInt(val.y / maxDistance), Mathf.FloorToInt(val.z / maxDistance)); - if (!dictionary.TryGetValue(key, out var value)) - { - value = (dictionary[key] = new List()); - } - value.Add(i); - } - foreach (KeyValuePair> item in dictionary) - { - List value2 = item.Value; - int count = value2.Count; - if (count < 2) - { - continue; - } - int[] parent = new int[count]; - for (int j = 0; j < count; j++) - { - parent[j] = j; - } - for (int k = 0; k < count; k++) - { - int num3 = value2[k]; - Vector3 val2 = worldVertices[num3]; - for (int l = k + 1; l < count; l++) - { - int num4 = value2[l]; - Vector3 val3 = worldVertices[num4]; - Vector3 val4 = val2 - val3; - if (((Vector3)(ref val4)).sqrMagnitude <= num2) - { - Union(k, l); - } - } - } - Dictionary> dictionary2 = new Dictionary>(); - for (int m = 0; m < count; m++) - { - int key2 = Find(m); - if (!dictionary2.TryGetValue(key2, out var value3)) - { - value3 = (dictionary2[key2] = new List()); - } - value3.Add(value2[m]); - } - foreach (List value4 in dictionary2.Values) - { - if (value4.Count >= 2) - { - equivalentVertices.Add(value4); - } - } - int Find(int x) - { - if (parent[x] != x) - { - parent[x] = Find(parent[x]); - } - return parent[x]; - } - void Union(int a, int b) - { - int num5 = Find(a); - int num6 = Find(b); - if (num5 != num6) - { - parent[num6] = num5; - } - } - } - } + public void BuildEquivalentVerticesFromWorld(float maxDistance = 1E-05f) + { + //IL_005e: Unknown result type (might be due to invalid IL or missing references) + //IL_0063: Unknown result type (might be due to invalid IL or missing references) + //IL_0067: Unknown result type (might be due to invalid IL or missing references) + //IL_0075: Unknown result type (might be due to invalid IL or missing references) + //IL_0083: Unknown result type (might be due to invalid IL or missing references) + //IL_0097: Unknown result type (might be due to invalid IL or missing references) + //IL_00aa: 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_013f: Unknown result type (might be due to invalid IL or missing references) + //IL_015c: 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_0163: Unknown result type (might be due to invalid IL or missing references) + //IL_0165: Unknown result type (might be due to invalid IL or missing references) + //IL_0167: Unknown result type (might be due to invalid IL or missing references) + //IL_016c: Unknown result type (might be due to invalid IL or missing references) + if (this.worldVertices == null || this.worldVertices.Length == 0) + { + Debug.LogWarning((object)"[ClothInstance] BuildEquivalentVerticesFromWorld: worldVertices is null or empty. Call UpdateWorldVertices() first."); + return; + } + int num = this.worldVertices.Length; + if (this.equivalentVertices == null) + { + this.equivalentVertices = new List>(); + } + else + { + this.equivalentVertices.Clear(); + } + float num2 = maxDistance * maxDistance; + Dictionary> dictionary = new Dictionary>(); + Vector3Int key = default(Vector3Int); + for (int i = 0; i < num; i++) + { + Vector3 val = this.worldVertices[i]; + key = new Vector3Int(Mathf.FloorToInt(val.x / maxDistance), Mathf.FloorToInt(val.y / maxDistance), Mathf.FloorToInt(val.z / maxDistance)); + if (!dictionary.TryGetValue(key, out var value)) + { + value = (dictionary[key] = new List()); + } + value.Add(i); + } + foreach (KeyValuePair> item in dictionary) + { + List value2 = item.Value; + int count = value2.Count; + if (count < 2) + { + continue; + } + int[] parent = new int[count]; + for (int j = 0; j < count; j++) + { + parent[j] = j; + } + for (int k = 0; k < count; k++) + { + int num3 = value2[k]; + Vector3 val2 = this.worldVertices[num3]; + for (int l = k + 1; l < count; l++) + { + int num4 = value2[l]; + Vector3 val3 = this.worldVertices[num4]; + Vector3 val4 = val2 - val3; + if (val4.sqrMagnitude <= num2) + { + Union(k, l); + } + } + } + Dictionary> dictionary2 = new Dictionary>(); + for (int m = 0; m < count; m++) + { + int key2 = Find(m); + if (!dictionary2.TryGetValue(key2, out var value3)) + { + value3 = (dictionary2[key2] = new List()); + } + value3.Add(value2[m]); + } + foreach (List value4 in dictionary2.Values) + { + if (value4.Count >= 2) + { + this.equivalentVertices.Add(value4); + } + } + int Find(int x) + { + if (parent[x] != x) + { + parent[x] = Find(parent[x]); + } + return parent[x]; + } + void Union(int a, int b) + { + int num5 = Find(a); + int num6 = Find(b); + if (num5 != num6) + { + parent[num6] = num5; + } + } + } + } - ~ClothInstance() - { - Dispose(); - } + ~ClothInstance() + { + this.Dispose(); + } - public void Dispose() - { - if ((Object)(object)bakedMesh != (Object)null) - { - Object.DestroyImmediate((Object)(object)bakedMesh); - bakedMesh = null; - } - worldVertices = null; - minDistanceVector = null; - minDistance = null; - deltas = null; - deltasLocal = null; - isInsideVertex = null; - excludedVertices = null; - isLeftLegVertex = null; - isRightLegVertex = null; - vertexAdjacency = null; - if (equivalentVertices != null) - { - for (int i = 0; i < equivalentVertices.Count; i++) - { - equivalentVertices[i]?.Clear(); - } - equivalentVertices.Clear(); - equivalentVertices = null; - } - humanoidMatchedBones = null; - smr = null; - editableMesh = null; - } + public void Dispose() + { + if (this.bakedMesh != null) + { + UnityEngine.Object.DestroyImmediate(this.bakedMesh); + this.bakedMesh = null; + } + this.worldVertices = null; + this.minDistanceVector = null; + this.minDistance = null; + this.deltas = null; + this.deltasLocal = null; + this.isInsideVertex = null; + this.excludedVertices = null; + this.isLeftLegVertex = null; + this.isRightLegVertex = null; + this.vertexAdjacency = null; + if (this.equivalentVertices != null) + { + for (int i = 0; i < this.equivalentVertices.Count; i++) + { + this.equivalentVertices[i]?.Clear(); + } + this.equivalentVertices.Clear(); + this.equivalentVertices = null; + } + this.humanoidMatchedBones = null; + this.smr = null; + this.editableMesh = null; + } } diff --git a/Assets/@Eden_Tools/Eden_AutoMorpher/Script/ClothInstanceTotal.cs b/Assets/@Eden_Tools/Eden_AutoMorpher/Script/ClothInstanceTotal.cs index d3c54f1..d950a1e 100644 --- a/Assets/@Eden_Tools/Eden_AutoMorpher/Script/ClothInstanceTotal.cs +++ b/Assets/@Eden_Tools/Eden_AutoMorpher/Script/ClothInstanceTotal.cs @@ -1,342 +1,341 @@ -// Warning: Some assembly references could not be resolved automatically. This might lead to incorrect decompilation of some parts, +// 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.ClothInstanceTotal using System.Collections.Generic; -using Eden.AutoMorpher; using UnityEngine; public class ClothInstanceTotal { - private readonly List clothInstances; + private readonly List clothInstances; - public int TotalVertexCount { get; private set; } + public int TotalVertexCount { get; private set; } - public Vector3[] GlobalPositions { get; private set; } + public Vector3[] GlobalPositions { get; private set; } - public Vector3[] GlobalDeltas { get; private set; } + public Vector3[] GlobalDeltas { get; private set; } - public List[] GlobalAdjacencyTopology { get; private set; } + public List[] GlobalAdjacencyTopology { get; private set; } - public List[] GlobalAdjacencyDistance { get; private set; } + public List[] GlobalAdjacencyDistance { get; private set; } - public List[] GlobalAdjacencyMerged { get; private set; } + public List[] GlobalAdjacencyMerged { get; private set; } - public int[] VertexOffsets { get; private set; } + public int[] VertexOffsets { get; private set; } - public ClothInstanceTotal(List clothInstances, float distanceBuildRadius, int maxNeighborsPerVertex = 0) - { - if (clothInstances == null || clothInstances.Count == 0) - { - throw new AutoMorpherException("Cloth Instances are Missing", "[ClothInstanceTotal] ClothInstanceTotal\n - clothInstances is null or empty"); - } - if (distanceBuildRadius <= 0f) - { - throw new AutoMorpherException("Distance Build Radius is Invalid", "[ClothInstanceTotal] ClothInstanceTotal\n - distanceBuildRadius must be > 0"); - } - this.clothInstances = clothInstances; - BuildTopologyCache(); - BuildDistanceAdjacencyCandidates(distanceBuildRadius, maxNeighborsPerVertex); - BuildMergedAdjacency(); - } + public ClothInstanceTotal(List clothInstances, float distanceBuildRadius, int maxNeighborsPerVertex = 0) + { + if (clothInstances == null || clothInstances.Count == 0) + { + throw new AutoMorpherException("Cloth Instances are Missing", "[ClothInstanceTotal] ClothInstanceTotal\n - clothInstances is null or empty"); + } + if (distanceBuildRadius <= 0f) + { + throw new AutoMorpherException("Distance Build Radius is Invalid", "[ClothInstanceTotal] ClothInstanceTotal\n - distanceBuildRadius must be > 0"); + } + this.clothInstances = clothInstances; + this.BuildTopologyCache(); + this.BuildDistanceAdjacencyCandidates(distanceBuildRadius, maxNeighborsPerVertex); + this.BuildMergedAdjacency(); + } - public void SetGlobalDeltas(Vector3[] globalDeltas) - { - if (globalDeltas == null || globalDeltas.Length != TotalVertexCount) - { - throw new AutoMorpherException("Global Deltas are Invalid", "[ClothInstanceTotal] SetGlobalDeltas\n - globalDeltas is null or length mismatch"); - } - GlobalDeltas = globalDeltas; - } + public void SetGlobalDeltas(Vector3[] globalDeltas) + { + if (globalDeltas == null || globalDeltas.Length != this.TotalVertexCount) + { + throw new AutoMorpherException("Global Deltas are Invalid", "[ClothInstanceTotal] SetGlobalDeltas\n - globalDeltas is null or length mismatch"); + } + this.GlobalDeltas = globalDeltas; + } - public void UpdateGlobalBuffersFromClothInstances() - { - //IL_0089: Unknown result type (might be due to invalid IL or missing references) - //IL_008e: Unknown result type (might be due to invalid IL or missing references) - //IL_00a5: Unknown result type (might be due to invalid IL or missing references) - //IL_00aa: Unknown result type (might be due to invalid IL or missing references) - ValidateGlobalBufferReady("[ClothInstanceTotal] UpdateGlobalBuffersFromClothInstances"); - for (int i = 0; i < clothInstances.Count; i++) - { - ClothInstance clothInstance = clothInstances[i]; - if (clothInstance != null) - { - if (clothInstance.worldVertices == null || clothInstance.deltasLocal == null) - { - throw new AutoMorpherException("Cloth Instance Data is Missing", "[ClothInstanceTotal] UpdateGlobalBuffersFromClothInstances\n - worldVertices or deltasLocal is null"); - } - int num = VertexOffsets[i]; - int num2 = clothInstance.worldVertices.Length; - if (num2 != clothInstance.deltasLocal.Length) - { - throw new AutoMorpherException("Cloth Instance Array Length Mismatch", "[ClothInstanceTotal] UpdateGlobalBuffersFromClothInstances\n - worldVertices.Length != deltasLocal.Length"); - } - for (int j = 0; j < num2; j++) - { - GlobalPositions[num + j] = clothInstance.worldVertices[j]; - GlobalDeltas[num + j] = clothInstance.deltasLocal[j]; - } - } - } - } + public void UpdateGlobalBuffersFromClothInstances() + { + //IL_0089: Unknown result type (might be due to invalid IL or missing references) + //IL_008e: Unknown result type (might be due to invalid IL or missing references) + //IL_00a5: Unknown result type (might be due to invalid IL or missing references) + //IL_00aa: Unknown result type (might be due to invalid IL or missing references) + this.ValidateGlobalBufferReady("[ClothInstanceTotal] UpdateGlobalBuffersFromClothInstances"); + for (int i = 0; i < this.clothInstances.Count; i++) + { + ClothInstance clothInstance = this.clothInstances[i]; + if (clothInstance != null) + { + if (clothInstance.worldVertices == null || clothInstance.deltasLocal == null) + { + throw new AutoMorpherException("Cloth Instance Data is Missing", "[ClothInstanceTotal] UpdateGlobalBuffersFromClothInstances\n - worldVertices or deltasLocal is null"); + } + int num = this.VertexOffsets[i]; + int num2 = clothInstance.worldVertices.Length; + if (num2 != clothInstance.deltasLocal.Length) + { + throw new AutoMorpherException("Cloth Instance Array Length Mismatch", "[ClothInstanceTotal] UpdateGlobalBuffersFromClothInstances\n - worldVertices.Length != deltasLocal.Length"); + } + for (int j = 0; j < num2; j++) + { + this.GlobalPositions[num + j] = clothInstance.worldVertices[j]; + this.GlobalDeltas[num + j] = clothInstance.deltasLocal[j]; + } + } + } + } - public void ApplyGlobalDeltasToClothInstances() - { - //IL_0060: Unknown result type (might be due to invalid IL or missing references) - //IL_0065: Unknown result type (might be due to invalid IL or missing references) - ValidateGlobalBufferReady("[ClothInstanceTotal] ApplyGlobalDeltasToClothInstances"); - for (int i = 0; i < clothInstances.Count; i++) - { - ClothInstance clothInstance = clothInstances[i]; - if (clothInstance != null) - { - if (clothInstance.deltasLocal == null) - { - throw new AutoMorpherException("Cloth Deltas are Missing", "[ClothInstanceTotal] ApplyGlobalDeltasToClothInstances\n - deltasLocal is null"); - } - int num = VertexOffsets[i]; - int num2 = clothInstance.deltasLocal.Length; - for (int j = 0; j < num2; j++) - { - clothInstance.deltasLocal[j] = GlobalDeltas[num + j]; - } - } - } - } + public void ApplyGlobalDeltasToClothInstances() + { + //IL_0060: Unknown result type (might be due to invalid IL or missing references) + //IL_0065: Unknown result type (might be due to invalid IL or missing references) + this.ValidateGlobalBufferReady("[ClothInstanceTotal] ApplyGlobalDeltasToClothInstances"); + for (int i = 0; i < this.clothInstances.Count; i++) + { + ClothInstance clothInstance = this.clothInstances[i]; + if (clothInstance != null) + { + if (clothInstance.deltasLocal == null) + { + throw new AutoMorpherException("Cloth Deltas are Missing", "[ClothInstanceTotal] ApplyGlobalDeltasToClothInstances\n - deltasLocal is null"); + } + int num = this.VertexOffsets[i]; + int num2 = clothInstance.deltasLocal.Length; + for (int j = 0; j < num2; j++) + { + clothInstance.deltasLocal[j] = this.GlobalDeltas[num + j]; + } + } + } + } - private void ValidateGlobalBufferReady(string functionContext) - { - if (clothInstances == null || clothInstances.Count == 0) - { - throw new AutoMorpherException("Cloth Instances are Missing", functionContext + "\n - clothInstances is null or empty"); - } - if (TotalVertexCount <= 0 || GlobalPositions == null || GlobalDeltas == null || VertexOffsets == null || GlobalAdjacencyMerged == null) - { - throw new AutoMorpherException("Cloth Instance Total Cache is Not Ready", functionContext + "\n - total/global buffers/merged adjacency are not initialized"); - } - } + private void ValidateGlobalBufferReady(string functionContext) + { + if (this.clothInstances == null || this.clothInstances.Count == 0) + { + throw new AutoMorpherException("Cloth Instances are Missing", functionContext + "\n - clothInstances is null or empty"); + } + if (this.TotalVertexCount <= 0 || this.GlobalPositions == null || this.GlobalDeltas == null || this.VertexOffsets == null || this.GlobalAdjacencyMerged == null) + { + throw new AutoMorpherException("Cloth Instance Total Cache is Not Ready", functionContext + "\n - total/global buffers/merged adjacency are not initialized"); + } + } - private void BuildTopologyCache() - { - //IL_0107: Unknown result type (might be due to invalid IL or missing references) - //IL_010c: Unknown result type (might be due to invalid IL or missing references) - //IL_0123: Unknown result type (might be due to invalid IL or missing references) - //IL_0128: Unknown result type (might be due to invalid IL or missing references) - TotalVertexCount = CalculateTotalVertexCount(clothInstances); - if (TotalVertexCount <= 0) - { - throw new AutoMorpherException("Total Vertex Count is Zero", "[ClothInstanceTotal] BuildTopologyCache\n - TotalVertexCount <= 0"); - } - GlobalPositions = (Vector3[])(object)new Vector3[TotalVertexCount]; - GlobalDeltas = (Vector3[])(object)new Vector3[TotalVertexCount]; - GlobalAdjacencyTopology = new List[TotalVertexCount]; - VertexOffsets = new int[clothInstances.Count]; - int num = 0; - for (int i = 0; i < clothInstances.Count; i++) - { - ClothInstance clothInstance = clothInstances[i]; - VertexOffsets[i] = num; - if (clothInstance == null) - { - continue; - } - if (clothInstance.worldVertices == null || clothInstance.deltasLocal == null || clothInstance.vertexAdjacency == null) - { - throw new AutoMorpherException("Cloth Instance Data is Missing", "[ClothInstanceTotal] BuildTopologyCache\n - worldVertices/deltasLocal/vertexAdjacency is null"); - } - int num2 = clothInstance.worldVertices.Length; - if (num2 != clothInstance.deltasLocal.Length || num2 != clothInstance.vertexAdjacency.Length) - { - throw new AutoMorpherException("Cloth Instance Array Length Mismatch", "[ClothInstanceTotal] BuildTopologyCache\n - worldVertices/deltasLocal/vertexAdjacency lengths differ"); - } - for (int j = 0; j < num2; j++) - { - GlobalPositions[num + j] = clothInstance.worldVertices[j]; - GlobalDeltas[num + j] = clothInstance.deltasLocal[j]; - int capacity = clothInstance.vertexAdjacency[j]?.Count ?? 0; - GlobalAdjacencyTopology[num + j] = new List(capacity); - } - for (int k = 0; k < num2; k++) - { - List list = clothInstance.vertexAdjacency[k]; - if (list == null) - { - continue; - } - int num3 = num + k; - List list2 = GlobalAdjacencyTopology[num3]; - for (int l = 0; l < list.Count; l++) - { - int num4 = list[l]; - if ((uint)num4 >= (uint)num2) - { - throw new AutoMorpherException("Vertex Adjacency Index is Out of Range", "[ClothInstanceTotal] BuildTopologyCache\n - vertexAdjacency contains invalid neighbor index"); - } - list2.Add(num + num4); - } - } - num += num2; - } - } + private void BuildTopologyCache() + { + //IL_0107: Unknown result type (might be due to invalid IL or missing references) + //IL_010c: Unknown result type (might be due to invalid IL or missing references) + //IL_0123: Unknown result type (might be due to invalid IL or missing references) + //IL_0128: Unknown result type (might be due to invalid IL or missing references) + this.TotalVertexCount = this.CalculateTotalVertexCount(this.clothInstances); + if (this.TotalVertexCount <= 0) + { + throw new AutoMorpherException("Total Vertex Count is Zero", "[ClothInstanceTotal] BuildTopologyCache\n - TotalVertexCount <= 0"); + } + this.GlobalPositions = (Vector3[])(object)new Vector3[this.TotalVertexCount]; + this.GlobalDeltas = (Vector3[])(object)new Vector3[this.TotalVertexCount]; + this.GlobalAdjacencyTopology = new List[this.TotalVertexCount]; + this.VertexOffsets = new int[this.clothInstances.Count]; + int num = 0; + for (int i = 0; i < this.clothInstances.Count; i++) + { + ClothInstance clothInstance = this.clothInstances[i]; + this.VertexOffsets[i] = num; + if (clothInstance == null) + { + continue; + } + if (clothInstance.worldVertices == null || clothInstance.deltasLocal == null || clothInstance.vertexAdjacency == null) + { + throw new AutoMorpherException("Cloth Instance Data is Missing", "[ClothInstanceTotal] BuildTopologyCache\n - worldVertices/deltasLocal/vertexAdjacency is null"); + } + int num2 = clothInstance.worldVertices.Length; + if (num2 != clothInstance.deltasLocal.Length || num2 != clothInstance.vertexAdjacency.Length) + { + throw new AutoMorpherException("Cloth Instance Array Length Mismatch", "[ClothInstanceTotal] BuildTopologyCache\n - worldVertices/deltasLocal/vertexAdjacency lengths differ"); + } + for (int j = 0; j < num2; j++) + { + this.GlobalPositions[num + j] = clothInstance.worldVertices[j]; + this.GlobalDeltas[num + j] = clothInstance.deltasLocal[j]; + int capacity = clothInstance.vertexAdjacency[j]?.Count ?? 0; + this.GlobalAdjacencyTopology[num + j] = new List(capacity); + } + for (int k = 0; k < num2; k++) + { + List list = clothInstance.vertexAdjacency[k]; + if (list == null) + { + continue; + } + int num3 = num + k; + List list2 = this.GlobalAdjacencyTopology[num3]; + for (int l = 0; l < list.Count; l++) + { + int num4 = list[l]; + if ((uint)num4 >= (uint)num2) + { + throw new AutoMorpherException("Vertex Adjacency Index is Out of Range", "[ClothInstanceTotal] BuildTopologyCache\n - vertexAdjacency contains invalid neighbor index"); + } + list2.Add(num + num4); + } + } + num += num2; + } + } - private void BuildDistanceAdjacencyCandidates(float radius, int maxNeighborsPerVertex) - { - if (GlobalPositions == null || GlobalPositions.Length == 0) - { - throw new AutoMorpherException("Reference Positions are Missing", "[ClothInstanceTotal] BuildDistanceAdjacencyCandidates\n - GlobalPositions is null or empty"); - } - GlobalAdjacencyDistance = BuildDistanceAdjacencyCandidatesInternal(GlobalPositions, radius, maxNeighborsPerVertex); - } + private void BuildDistanceAdjacencyCandidates(float radius, int maxNeighborsPerVertex) + { + if (this.GlobalPositions == null || this.GlobalPositions.Length == 0) + { + throw new AutoMorpherException("Reference Positions are Missing", "[ClothInstanceTotal] BuildDistanceAdjacencyCandidates\n - GlobalPositions is null or empty"); + } + this.GlobalAdjacencyDistance = this.BuildDistanceAdjacencyCandidatesInternal(this.GlobalPositions, radius, maxNeighborsPerVertex); + } - private void BuildMergedAdjacency() - { - if (GlobalAdjacencyTopology == null || GlobalAdjacencyDistance == null) - { - throw new AutoMorpherException("Adjacency Inputs are Missing", "[ClothInstanceTotal] BuildMergedAdjacency\n - GlobalAdjacencyTopology or GlobalAdjacencyDistance is null"); - } - if (GlobalAdjacencyTopology.Length != GlobalAdjacencyDistance.Length) - { - throw new AutoMorpherException("Adjacency Length Mismatch", "[ClothInstanceTotal] BuildMergedAdjacency\n - topology and distance adjacency length differ"); - } - int num = GlobalAdjacencyTopology.Length; - GlobalAdjacencyMerged = new List[num]; - for (int i = 0; i < num; i++) - { - List list = new List((GlobalAdjacencyTopology[i]?.Count ?? 0) + (GlobalAdjacencyDistance[i]?.Count ?? 0)); - HashSet hashSet = new HashSet(); - List list2 = GlobalAdjacencyTopology[i]; - if (list2 != null) - { - for (int j = 0; j < list2.Count; j++) - { - int num2 = list2[j]; - if (num2 != i && hashSet.Add(num2)) - { - list.Add(num2); - } - } - } - List list3 = GlobalAdjacencyDistance[i]; - if (list3 != null) - { - for (int k = 0; k < list3.Count; k++) - { - int num3 = list3[k]; - if (num3 != i && hashSet.Add(num3)) - { - list.Add(num3); - } - } - } - GlobalAdjacencyMerged[i] = list; - } - } + private void BuildMergedAdjacency() + { + if (this.GlobalAdjacencyTopology == null || this.GlobalAdjacencyDistance == null) + { + throw new AutoMorpherException("Adjacency Inputs are Missing", "[ClothInstanceTotal] BuildMergedAdjacency\n - GlobalAdjacencyTopology or GlobalAdjacencyDistance is null"); + } + if (this.GlobalAdjacencyTopology.Length != this.GlobalAdjacencyDistance.Length) + { + throw new AutoMorpherException("Adjacency Length Mismatch", "[ClothInstanceTotal] BuildMergedAdjacency\n - topology and distance adjacency length differ"); + } + int num = this.GlobalAdjacencyTopology.Length; + this.GlobalAdjacencyMerged = new List[num]; + for (int i = 0; i < num; i++) + { + List list = new List((this.GlobalAdjacencyTopology[i]?.Count ?? 0) + (this.GlobalAdjacencyDistance[i]?.Count ?? 0)); + HashSet hashSet = new HashSet(); + List list2 = this.GlobalAdjacencyTopology[i]; + if (list2 != null) + { + for (int j = 0; j < list2.Count; j++) + { + int num2 = list2[j]; + if (num2 != i && hashSet.Add(num2)) + { + list.Add(num2); + } + } + } + List list3 = this.GlobalAdjacencyDistance[i]; + if (list3 != null) + { + for (int k = 0; k < list3.Count; k++) + { + int num3 = list3[k]; + if (num3 != i && hashSet.Add(num3)) + { + list.Add(num3); + } + } + } + this.GlobalAdjacencyMerged[i] = list; + } + } - private int CalculateTotalVertexCount(List clothInstances) - { - int num = 0; - for (int i = 0; i < clothInstances.Count; i++) - { - ClothInstance clothInstance = clothInstances[i]; - if (clothInstance != null && clothInstance.worldVertices != null) - { - num += clothInstance.worldVertices.Length; - } - } - return num; - } + private int CalculateTotalVertexCount(List clothInstances) + { + int num = 0; + for (int i = 0; i < clothInstances.Count; i++) + { + ClothInstance clothInstance = clothInstances[i]; + if (clothInstance != null && clothInstance.worldVertices != null) + { + num += clothInstance.worldVertices.Length; + } + } + return num; + } - private List[] BuildDistanceAdjacencyCandidatesInternal(Vector3[] referencePositions, float radius, int maxNeighborsPerVertex) - { - //IL_007d: 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_0086: 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_00a2: Unknown result type (might be due to invalid IL or missing references) - //IL_00b7: Unknown result type (might be due to invalid IL or missing references) - //IL_00cd: Unknown result type (might be due to invalid IL or missing references) - //IL_00f5: Unknown result type (might be due to invalid IL or missing references) - //IL_00fa: Unknown result type (might be due to invalid IL or missing references) - //IL_00fe: Unknown result type (might be due to invalid IL or missing references) - //IL_010c: 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_0172: Unknown result type (might be due to invalid IL or missing references) - //IL_0196: Unknown result type (might be due to invalid IL or missing references) - //IL_019b: Unknown result type (might be due to invalid IL or missing references) - //IL_019d: Unknown result type (might be due to invalid IL or missing references) - //IL_01a2: Unknown result type (might be due to invalid IL or missing references) - if (referencePositions == null || referencePositions.Length == 0) - { - throw new AutoMorpherException("Reference Positions are Missing", "[ClothInstanceTotal] BuildDistanceAdjacencyCandidatesInternal\n - referencePositions is null or empty"); - } - if (radius <= 0f) - { - throw new AutoMorpherException("Radius is Invalid", "[ClothInstanceTotal] BuildDistanceAdjacencyCandidatesInternal\n - radius must be > 0"); - } - int num = referencePositions.Length; - List[] array = new List[num]; - for (int i = 0; i < num; i++) - { - array[i] = new List(8); - } - float num2 = 1f / Mathf.Max(radius, 1E-12f); - float num3 = radius * radius; - Dictionary> dictionary = new Dictionary>(num); - Vector3Int key = default(Vector3Int); - for (int j = 0; j < num; j++) - { - Vector3 val = referencePositions[j]; - ((Vector3Int)(ref key))._002Ector(Mathf.FloorToInt(val.x * num2), Mathf.FloorToInt(val.y * num2), Mathf.FloorToInt(val.z * num2)); - if (!dictionary.TryGetValue(key, out var value)) - { - value = new List(16); - dictionary.Add(key, value); - } - value.Add(j); - } - Vector3Int val3 = default(Vector3Int); - Vector3Int key2 = default(Vector3Int); - for (int k = 0; k < num; k++) - { - Vector3 val2 = referencePositions[k]; - ((Vector3Int)(ref val3))._002Ector(Mathf.FloorToInt(val2.x * num2), Mathf.FloorToInt(val2.y * num2), Mathf.FloorToInt(val2.z * num2)); - List list = array[k]; - for (int l = -1; l <= 1; l++) - { - for (int m = -1; m <= 1; m++) - { - for (int n = -1; n <= 1; n++) - { - ((Vector3Int)(ref key2))._002Ector(((Vector3Int)(ref val3)).x + l, ((Vector3Int)(ref val3)).y + m, ((Vector3Int)(ref val3)).z + n); - if (!dictionary.TryGetValue(key2, out var value2)) - { - continue; - } - for (int num4 = 0; num4 < value2.Count; num4++) - { - int num5 = value2[num4]; - if (num5 == k) - { - continue; - } - Vector3 val4 = referencePositions[num5] - val2; - if (!(((Vector3)(ref val4)).sqrMagnitude > num3)) - { - list.Add(num5); - if (maxNeighborsPerVertex > 0 && list.Count >= maxNeighborsPerVertex) - { - break; - } - } - } - if (maxNeighborsPerVertex > 0 && list.Count >= maxNeighborsPerVertex) - { - break; - } - } - } - } - } - return array; - } + private List[] BuildDistanceAdjacencyCandidatesInternal(Vector3[] referencePositions, float radius, int maxNeighborsPerVertex) + { + //IL_007d: 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_0086: 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_00a2: Unknown result type (might be due to invalid IL or missing references) + //IL_00b7: Unknown result type (might be due to invalid IL or missing references) + //IL_00cd: Unknown result type (might be due to invalid IL or missing references) + //IL_00f5: Unknown result type (might be due to invalid IL or missing references) + //IL_00fa: Unknown result type (might be due to invalid IL or missing references) + //IL_00fe: Unknown result type (might be due to invalid IL or missing references) + //IL_010c: 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_0172: Unknown result type (might be due to invalid IL or missing references) + //IL_0196: Unknown result type (might be due to invalid IL or missing references) + //IL_019b: Unknown result type (might be due to invalid IL or missing references) + //IL_019d: Unknown result type (might be due to invalid IL or missing references) + //IL_01a2: Unknown result type (might be due to invalid IL or missing references) + if (referencePositions == null || referencePositions.Length == 0) + { + throw new AutoMorpherException("Reference Positions are Missing", "[ClothInstanceTotal] BuildDistanceAdjacencyCandidatesInternal\n - referencePositions is null or empty"); + } + if (radius <= 0f) + { + throw new AutoMorpherException("Radius is Invalid", "[ClothInstanceTotal] BuildDistanceAdjacencyCandidatesInternal\n - radius must be > 0"); + } + int num = referencePositions.Length; + List[] array = new List[num]; + for (int i = 0; i < num; i++) + { + array[i] = new List(8); + } + float num2 = 1f / Mathf.Max(radius, 1E-12f); + float num3 = radius * radius; + Dictionary> dictionary = new Dictionary>(num); + Vector3Int key = default(Vector3Int); + for (int j = 0; j < num; j++) + { + Vector3 val = referencePositions[j]; + key = new Vector3Int(Mathf.FloorToInt(val.x * num2), Mathf.FloorToInt(val.y * num2), Mathf.FloorToInt(val.z * num2)); + if (!dictionary.TryGetValue(key, out var value)) + { + value = new List(16); + dictionary.Add(key, value); + } + value.Add(j); + } + Vector3Int val3 = default(Vector3Int); + Vector3Int key2 = default(Vector3Int); + for (int k = 0; k < num; k++) + { + Vector3 val2 = referencePositions[k]; + val3 = new Vector3Int(Mathf.FloorToInt(val2.x * num2), Mathf.FloorToInt(val2.y * num2), Mathf.FloorToInt(val2.z * num2)); + List list = array[k]; + for (int l = -1; l <= 1; l++) + { + for (int m = -1; m <= 1; m++) + { + for (int n = -1; n <= 1; n++) + { + key2 = new Vector3Int(val3.x + l, val3.y + m, val3.z + n); + if (!dictionary.TryGetValue(key2, out var value2)) + { + continue; + } + for (int num4 = 0; num4 < value2.Count; num4++) + { + int num5 = value2[num4]; + if (num5 == k) + { + continue; + } + Vector3 val4 = referencePositions[num5] - val2; + if (!(val4.sqrMagnitude > num3)) + { + list.Add(num5); + if (maxNeighborsPerVertex > 0 && list.Count >= maxNeighborsPerVertex) + { + break; + } + } + } + if (maxNeighborsPerVertex > 0 && list.Count >= maxNeighborsPerVertex) + { + break; + } + } + } + } + } + return array; + } } diff --git a/Assets/@Eden_Tools/Eden_AutoMorpher/Script/EdenAutoMorpher.cs b/Assets/@Eden_Tools/Eden_AutoMorpher/Script/EdenAutoMorpher.cs index 24ca331..be92e4f 100644 --- a/Assets/@Eden_Tools/Eden_AutoMorpher/Script/EdenAutoMorpher.cs +++ b/Assets/@Eden_Tools/Eden_AutoMorpher/Script/EdenAutoMorpher.cs @@ -1,602 +1,601 @@ -// Warning: Some assembly references could not be resolved automatically. This might lead to incorrect decompilation of some parts, +// 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.EdenAutoMorpher using System.Collections; using System.Collections.Generic; using System.Text; -using Eden.AutoMorpher; using UnityEngine; public class EdenAutoMorpher : MonoBehaviour { - [SerializeField] - public GameObject sourceAvatarObject; + [SerializeField] + public GameObject sourceAvatarObject; - [SerializeField] - public GameObject sourceClothesObject; + [SerializeField] + public GameObject sourceClothesObject; - [SerializeField] - private List sourceBodyMeshes = new List(); + [SerializeField] + private List sourceBodyMeshes = new List(); - [SerializeField] - private IReadOnlyList sourceBodyMeshesReadOnly = new List(); + [SerializeField] + private IReadOnlyList sourceBodyMeshesReadOnly = new List(); - [SerializeField] - public string profileName; + [SerializeField] + public string profileName; - [SerializeField] - public GameObject targetAvatarObject; + [SerializeField] + public GameObject targetAvatarObject; - [SerializeField] - private GameObject targetClothesObject; + [SerializeField] + private GameObject targetClothesObject; - [SerializeField] - private GameObject targetClothesObjectOriginal; + [SerializeField] + private GameObject targetClothesObjectOriginal; - [SerializeField] - private List targetBodyMeshes = new List(); + [SerializeField] + private List targetBodyMeshes = new List(); - [SerializeField] - private IReadOnlyList targetBodyMeshesReadOnly = new List(); + [SerializeField] + private IReadOnlyList targetBodyMeshesReadOnly = new List(); - [SerializeField] - private float minMargin = 0.003f; + [SerializeField] + private float minMargin = 0.003f; - [SerializeField] - private float worldRadius = 0.1f; + [SerializeField] + private float worldRadius = 0.1f; - [SerializeField] - private float sigma = 0.85f; + [SerializeField] + private float sigma = 0.85f; - [SerializeField] - private int smoothingIteration = 1; + [SerializeField] + private int smoothingIteration = 1; - [SerializeField] - private int fittingExpandIteration = 10; + [SerializeField] + private int fittingExpandIteration = 10; - [SerializeField] - private int fittingShrinkIteration = 12; + [SerializeField] + private int fittingShrinkIteration = 12; - [SerializeField] - public bool isBodyAutoSetup = true; + [SerializeField] + public bool isBodyAutoSetup = true; - [SerializeField] - public bool isReparentAccessoryBonesToTargetAvatar = true; + [SerializeField] + public bool isReparentAccessoryBonesToTargetAvatar = true; - [SerializeField] - public bool skipFootFitting; + [SerializeField] + public bool skipFootFitting; - [SerializeField] - public bool transferWeightToAvatar; + [SerializeField] + public bool transferWeightToAvatar; - [SerializeField] - public bool addAnchorBone = true; + [SerializeField] + public bool addAnchorBone = true; - [SerializeField] - public bool armatureBoneScaleCopy; + [SerializeField] + public bool armatureBoneScaleCopy; - [SerializeField] - public bool isRemoveAutoMorphedClothes = true; + [SerializeField] + public bool isRemoveAutoMorphedClothes = true; - private Dictionary> clothesHumanoidMatchedBones; + private Dictionary> clothesHumanoidMatchedBones; - private Dictionary clothBoneTypeMap; + private Dictionary clothBoneTypeMap; - private GameObject fittedTargetAvatar; + private GameObject fittedTargetAvatar; - private GameObject fittedTargetClothes; + private GameObject fittedTargetClothes; - private const string EditedMeshRootFolder = "Assets/@Eden_Mesh"; + private const string EditedMeshRootFolder = "Assets/@Eden_Mesh"; - private string tagEdenMorpehrCloth = "EDENAutoMorpher_EditedCloth"; + private string tagEdenMorpehrCloth = "EDENAutoMorpher_EditedCloth"; - private bool doProcess; + private bool doProcess; - private MorpherMode morpherMode; + private MorpherMode morpherMode; - private MorpherState morpherState; + private MorpherState morpherState; - private ProcessInfo processInfo; + private ProcessInfo processInfo; - public ProcessInfo GetProcessInfo() - { - return processInfo; - } + public ProcessInfo GetProcessInfo() + { + return this.processInfo; + } - public void ChangeMode(MorpherMode newMode) - { - morpherMode = newMode; - morpherState = MorpherState.Idle; - } + public void ChangeMode(MorpherMode newMode) + { + this.morpherMode = newMode; + this.morpherState = MorpherState.Idle; + } - public void StopProcess() - { - doProcess = false; - switch (morpherState) - { - case MorpherState.Fitting_Doing: - morpherState = MorpherState.Idle; - break; - case MorpherState.Weighting_Doing: - morpherState = MorpherState.Fitting_End; - break; - default: - morpherState = MorpherState.Idle; - break; - } - } + public void StopProcess() + { + this.doProcess = false; + switch (this.morpherState) + { + case MorpherState.Fitting_Doing: + this.morpherState = MorpherState.Idle; + break; + case MorpherState.Weighting_Doing: + this.morpherState = MorpherState.Fitting_End; + break; + default: + this.morpherState = MorpherState.Idle; + break; + } + } - private EdenAutoMorpherConfig SetupConfigData(MorpherMode morpherMode) - { - EdenAutoMorpherConfig result = default(EdenAutoMorpherConfig); - switch (morpherMode) - { - case MorpherMode.AutoMorpher: - case MorpherMode.ManualMorpher: - result.sourceAvatarObject = sourceAvatarObject; - result.sourceClothesObject = sourceClothesObject; - result.sourceBodyMeshes = sourceBodyMeshesReadOnly; - result.profileName = string.Empty; - break; - case MorpherMode.ProfileMorpher: - result.sourceAvatarObject = null; - result.sourceClothesObject = sourceClothesObject; - result.sourceBodyMeshes = null; - result.profileName = profileName; - break; - default: - result.sourceAvatarObject = null; - result.sourceClothesObject = null; - result.sourceBodyMeshes = null; - result.profileName = string.Empty; - break; - } - result.targetAvatarObject = targetAvatarObject; - result.targetClothesObject = targetClothesObject; - result.targetBodyMeshes = targetBodyMeshesReadOnly; - result.minMargin = minMargin; - result.worldRadius = worldRadius; - result.sigma = sigma; - result.smoothingIteration = smoothingIteration; - result.fittingExpandIteration = fittingExpandIteration; - result.fittingShrinkIteration = fittingShrinkIteration; - result.isBodyAutoSetup = isBodyAutoSetup; - result.isReparentAccessoryBonesToTargetAvatar = isReparentAccessoryBonesToTargetAvatar; - result.skipFootFitting = skipFootFitting; - result.clothesHumanoidMatchedBones = clothesHumanoidMatchedBones; - result.clothBoneTypeMap = clothBoneTypeMap; - result.tagEdenMorpehrCloth = tagEdenMorpehrCloth; - result.transferWeightToAvatar = transferWeightToAvatar; - result.addAnchorBone = addAnchorBone; - result.armatureBoneScaleCopy = armatureBoneScaleCopy; - result.isRemoveAutoMorphedClothes = isRemoveAutoMorphedClothes; - return result; - } + private EdenAutoMorpherConfig SetupConfigData(MorpherMode morpherMode) + { + EdenAutoMorpherConfig result = default(EdenAutoMorpherConfig); + switch (morpherMode) + { + case MorpherMode.AutoMorpher: + case MorpherMode.ManualMorpher: + result.sourceAvatarObject = this.sourceAvatarObject; + result.sourceClothesObject = this.sourceClothesObject; + result.sourceBodyMeshes = this.sourceBodyMeshesReadOnly; + result.profileName = string.Empty; + break; + case MorpherMode.ProfileMorpher: + result.sourceAvatarObject = null; + result.sourceClothesObject = this.sourceClothesObject; + result.sourceBodyMeshes = null; + result.profileName = this.profileName; + break; + default: + result.sourceAvatarObject = null; + result.sourceClothesObject = null; + result.sourceBodyMeshes = null; + result.profileName = string.Empty; + break; + } + result.targetAvatarObject = this.targetAvatarObject; + result.targetClothesObject = this.targetClothesObject; + result.targetBodyMeshes = this.targetBodyMeshesReadOnly; + result.minMargin = this.minMargin; + result.worldRadius = this.worldRadius; + result.sigma = this.sigma; + result.smoothingIteration = this.smoothingIteration; + result.fittingExpandIteration = this.fittingExpandIteration; + result.fittingShrinkIteration = this.fittingShrinkIteration; + result.isBodyAutoSetup = this.isBodyAutoSetup; + result.isReparentAccessoryBonesToTargetAvatar = this.isReparentAccessoryBonesToTargetAvatar; + result.skipFootFitting = this.skipFootFitting; + result.clothesHumanoidMatchedBones = this.clothesHumanoidMatchedBones; + result.clothBoneTypeMap = this.clothBoneTypeMap; + result.tagEdenMorpehrCloth = this.tagEdenMorpehrCloth; + result.transferWeightToAvatar = this.transferWeightToAvatar; + result.addAnchorBone = this.addAnchorBone; + result.armatureBoneScaleCopy = this.armatureBoneScaleCopy; + result.isRemoveAutoMorphedClothes = this.isRemoveAutoMorphedClothes; + return result; + } - public void AutoPoseSetup(MorpherMode morpherMode) - { - //IL_0095: Unknown result type (might be due to invalid IL or missing references) - //IL_00bc: Unknown result type (might be due to invalid IL or missing references) - TransformInfo transformInfo = new TransformInfo(sourceAvatarObject.transform); - TransformInfo transformInfo2 = new TransformInfo(targetAvatarObject.transform); - try - { - EdenAutoMorpher_SetUpUtil edenAutoMorpher_SetUpUtil = new EdenAutoMorpher_SetUpUtil(); - sourceBodyMeshesReadOnly = edenAutoMorpher_SetUpUtil.SetupBodyMeshes(sourceAvatarObject, isBodyAutoSetup, sourceBodyMeshes, "Source ").AsReadOnly(); - targetBodyMeshesReadOnly = edenAutoMorpher_SetUpUtil.SetupBodyMeshes(targetAvatarObject, isBodyAutoSetup, targetBodyMeshes, "Target ").AsReadOnly(); - targetAvatarObject.transform.SetParent((Transform)null, true); - targetAvatarObject.transform.localRotation = Quaternion.identity; - sourceAvatarObject.transform.SetParent((Transform)null, true); - sourceAvatarObject.transform.localRotation = Quaternion.identity; - EdenAutoMorpherConfig config = SetupConfigData(morpherMode); - new EdenAutoMorpher_SetUpUtil().AutoSetup(ref config, out clothesHumanoidMatchedBones, out clothBoneTypeMap); - targetClothesObject = config.targetClothesObject; - targetClothesObjectOriginal = targetClothesObject; - } - finally - { - transformInfo.ApplyToTransform(sourceAvatarObject.transform, applyParent: true, applyPosition: false, applyRotation: true, applyScale: true); - transformInfo2.ApplyToTransform(targetAvatarObject.transform, applyParent: true, applyPosition: false, applyRotation: true, applyScale: true); - } - } + public void AutoPoseSetup(MorpherMode morpherMode) + { + //IL_0095: Unknown result type (might be due to invalid IL or missing references) + //IL_00bc: Unknown result type (might be due to invalid IL or missing references) + TransformInfo transformInfo = new TransformInfo(this.sourceAvatarObject.transform); + TransformInfo transformInfo2 = new TransformInfo(this.targetAvatarObject.transform); + try + { + EdenAutoMorpher_SetUpUtil edenAutoMorpher_SetUpUtil = new EdenAutoMorpher_SetUpUtil(); + this.sourceBodyMeshesReadOnly = edenAutoMorpher_SetUpUtil.SetupBodyMeshes(this.sourceAvatarObject, this.isBodyAutoSetup, this.sourceBodyMeshes, "Source ").AsReadOnly(); + this.targetBodyMeshesReadOnly = edenAutoMorpher_SetUpUtil.SetupBodyMeshes(this.targetAvatarObject, this.isBodyAutoSetup, this.targetBodyMeshes, "Target ").AsReadOnly(); + this.targetAvatarObject.transform.SetParent((Transform)null, true); + this.targetAvatarObject.transform.localRotation = Quaternion.identity; + this.sourceAvatarObject.transform.SetParent((Transform)null, true); + this.sourceAvatarObject.transform.localRotation = Quaternion.identity; + EdenAutoMorpherConfig config = this.SetupConfigData(morpherMode); + new EdenAutoMorpher_SetUpUtil().AutoSetup(ref config, out this.clothesHumanoidMatchedBones, out this.clothBoneTypeMap); + this.targetClothesObject = config.targetClothesObject; + this.targetClothesObjectOriginal = this.targetClothesObject; + } + finally + { + transformInfo.ApplyToTransform(this.sourceAvatarObject.transform, applyParent: true, applyPosition: false, applyRotation: true, applyScale: true); + transformInfo2.ApplyToTransform(this.targetAvatarObject.transform, applyParent: true, applyPosition: false, applyRotation: true, applyScale: true); + } + } - public void ProfileSetup(MorpherMode morpherMode) - { - //IL_006d: 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_00a9: Unknown result type (might be due to invalid IL or missing references) - TransformInfo transformInfo = new TransformInfo(sourceClothesObject.transform); - TransformInfo transformInfo2 = new TransformInfo(targetAvatarObject.transform); - try - { - EdenAutoMorpher_SetUpUtil edenAutoMorpher_SetUpUtil = new EdenAutoMorpher_SetUpUtil(); - targetBodyMeshesReadOnly = edenAutoMorpher_SetUpUtil.SetupBodyMeshes(targetAvatarObject, isBodyAutoSetup, targetBodyMeshes, "Target ").AsReadOnly(); - targetAvatarObject.transform.SetParent((Transform)null, true); - targetAvatarObject.transform.localRotation = Quaternion.identity; - sourceClothesObject.transform.SetParent((Transform)null, true); - sourceClothesObject.transform.localScale = Vector3.one; - sourceClothesObject.transform.localRotation = Quaternion.identity; - EdenAutoMorpherConfig config = SetupConfigData(morpherMode); - new EdenAutoMorpher_SetUpUtil().ProfileAutoSetup(ref config, out clothesHumanoidMatchedBones, out clothBoneTypeMap); - targetClothesObject = config.targetClothesObject; - targetClothesObjectOriginal = targetClothesObject; - } - finally - { - transformInfo.ApplyToTransform(sourceClothesObject.transform, applyParent: true, applyPosition: false, applyRotation: true, applyScale: true); - transformInfo2.ApplyToTransform(targetAvatarObject.transform, applyParent: true, applyPosition: false, applyRotation: true, applyScale: true); - } - } + public void ProfileSetup(MorpherMode morpherMode) + { + //IL_006d: 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_00a9: Unknown result type (might be due to invalid IL or missing references) + TransformInfo transformInfo = new TransformInfo(this.sourceClothesObject.transform); + TransformInfo transformInfo2 = new TransformInfo(this.targetAvatarObject.transform); + try + { + EdenAutoMorpher_SetUpUtil edenAutoMorpher_SetUpUtil = new EdenAutoMorpher_SetUpUtil(); + this.targetBodyMeshesReadOnly = edenAutoMorpher_SetUpUtil.SetupBodyMeshes(this.targetAvatarObject, this.isBodyAutoSetup, this.targetBodyMeshes, "Target ").AsReadOnly(); + this.targetAvatarObject.transform.SetParent((Transform)null, true); + this.targetAvatarObject.transform.localRotation = Quaternion.identity; + this.sourceClothesObject.transform.SetParent((Transform)null, true); + this.sourceClothesObject.transform.localScale = Vector3.one; + this.sourceClothesObject.transform.localRotation = Quaternion.identity; + EdenAutoMorpherConfig config = this.SetupConfigData(morpherMode); + new EdenAutoMorpher_SetUpUtil().ProfileAutoSetup(ref config, out this.clothesHumanoidMatchedBones, out this.clothBoneTypeMap); + this.targetClothesObject = config.targetClothesObject; + this.targetClothesObjectOriginal = this.targetClothesObject; + } + finally + { + transformInfo.ApplyToTransform(this.sourceClothesObject.transform, applyParent: true, applyPosition: false, applyRotation: true, applyScale: true); + transformInfo2.ApplyToTransform(this.targetAvatarObject.transform, applyParent: true, applyPosition: false, applyRotation: true, applyScale: true); + } + } - public IEnumerator AutoMorphingEnumerator(MorpherMode morpherMode) - { - doProcess = true; - yield return null; - ProcessInfoDebug(morpherMode, "Run ALL"); - morpherState = MorpherState.Fitting_Doing; - IEnumerator fitEnum = null; - this.morpherMode = morpherMode; - yield return null; - Debug.Log((object)"[Eden Auto Morpher] Run ALL - Start Fitting"); - switch (morpherMode) - { - case MorpherMode.AutoMorpher: - fitEnum = AutoFitting(morpherMode); - break; - case MorpherMode.ManualMorpher: - fitEnum = ManualFitting(morpherMode); - break; - case MorpherMode.ProfileMorpher: - fitEnum = ProfileFitting(morpherMode); - break; - default: - Debug.LogError((object)"Unknown Mode Index"); - break; - } - while (fitEnum != null && fitEnum.MoveNext() && doProcess) - { - yield return fitEnum.Current; - } - morpherState = MorpherState.Fitting_End; - yield return null; - morpherState = MorpherState.Weighting_Doing; - yield return null; - Debug.Log((object)"[Eden Auto Morpher] Run ALL - Start Weighting"); - using (EdenAutoMorpherManager eamManager = new EdenAutoMorpherManager()) - { - EdenAutoMorpherConfig config = SetupConfigData(morpherMode); - IEnumerator eamFitting = eamManager.WeightingEnumerator(config); - while (eamFitting.MoveNext() && doProcess) - { - ref string title = ref processInfo.title; - ref string text = ref processInfo.text; - ref float progress = ref processInfo.progress; - (title, text, progress) = eamManager.GetProgressInfo(); - yield return eamFitting.Current; - } - } - yield return null; - doProcess = false; - morpherState = MorpherState.Idle; - Debug.Log((object)"[Eden Auto Morpher] Ended Run ALL"); - yield return null; - } + public IEnumerator AutoMorphingEnumerator(MorpherMode morpherMode) + { + this.doProcess = true; + yield return null; + this.ProcessInfoDebug(morpherMode, "Run ALL"); + this.morpherState = MorpherState.Fitting_Doing; + IEnumerator fitEnum = null; + this.morpherMode = morpherMode; + yield return null; + Debug.Log((object)"[Eden Auto Morpher] Run ALL - Start Fitting"); + switch (morpherMode) + { + case MorpherMode.AutoMorpher: + fitEnum = this.AutoFitting(morpherMode); + break; + case MorpherMode.ManualMorpher: + fitEnum = this.ManualFitting(morpherMode); + break; + case MorpherMode.ProfileMorpher: + fitEnum = this.ProfileFitting(morpherMode); + break; + default: + Debug.LogError((object)"Unknown Mode Index"); + break; + } + while (fitEnum != null && fitEnum.MoveNext() && this.doProcess) + { + yield return fitEnum.Current; + } + this.morpherState = MorpherState.Fitting_End; + yield return null; + this.morpherState = MorpherState.Weighting_Doing; + yield return null; + Debug.Log((object)"[Eden Auto Morpher] Run ALL - Start Weighting"); + using (EdenAutoMorpherManager eamManager = new EdenAutoMorpherManager()) + { + EdenAutoMorpherConfig config = this.SetupConfigData(morpherMode); + IEnumerator eamFitting = eamManager.WeightingEnumerator(config); + while (eamFitting.MoveNext() && this.doProcess) + { + string title = this.processInfo.title; + string text = this.processInfo.text; + float progress = this.processInfo.progress; + (title, text, progress) = eamManager.GetProgressInfo(); + yield return eamFitting.Current; + } + } + yield return null; + this.doProcess = false; + this.morpherState = MorpherState.Idle; + Debug.Log((object)"[Eden Auto Morpher] Ended Run ALL"); + yield return null; + } - public IEnumerator FittingEnumerator(MorpherMode morpherMode) - { - doProcess = true; - ref string title = ref processInfo.title; - ref string text = ref processInfo.text; - ref float progress = ref processInfo.progress; - title = "Setup Avatar Pose"; - text = "Calculating avatar shape and skeletal data."; - progress = 0f; - yield return null; - ProcessInfoDebug(morpherMode, "Fitting"); - yield return null; - morpherState = MorpherState.Fitting_Doing; - IEnumerator fitEnum = null; - this.morpherMode = morpherMode; - yield return null; - switch (morpherMode) - { - case MorpherMode.AutoMorpher: - fitEnum = AutoFitting(morpherMode); - break; - case MorpherMode.ManualMorpher: - fitEnum = ManualFitting(morpherMode); - break; - case MorpherMode.ProfileMorpher: - fitEnum = ProfileFitting(morpherMode); - break; - default: - Debug.LogError((object)"Unknown Mode Index"); - break; - } - while (fitEnum != null && fitEnum.MoveNext() && doProcess) - { - yield return null; - } - morpherState = MorpherState.Fitting_End; - yield return null; - doProcess = false; - Debug.Log((object)"[Eden Auto Morpher] Ended Fitting"); - yield return null; - } + public IEnumerator FittingEnumerator(MorpherMode morpherMode) + { + this.doProcess = true; + string title = this.processInfo.title; + string text = this.processInfo.text; + float progress = this.processInfo.progress; + title = "Setup Avatar Pose"; + text = "Calculating avatar shape and skeletal data."; + progress = 0f; + yield return null; + this.ProcessInfoDebug(morpherMode, "Fitting"); + yield return null; + this.morpherState = MorpherState.Fitting_Doing; + IEnumerator fitEnum = null; + this.morpherMode = morpherMode; + yield return null; + switch (morpherMode) + { + case MorpherMode.AutoMorpher: + fitEnum = this.AutoFitting(morpherMode); + break; + case MorpherMode.ManualMorpher: + fitEnum = this.ManualFitting(morpherMode); + break; + case MorpherMode.ProfileMorpher: + fitEnum = this.ProfileFitting(morpherMode); + break; + default: + Debug.LogError((object)"Unknown Mode Index"); + break; + } + while (fitEnum != null && fitEnum.MoveNext() && this.doProcess) + { + yield return null; + } + this.morpherState = MorpherState.Fitting_End; + yield return null; + this.doProcess = false; + Debug.Log((object)"[Eden Auto Morpher] Ended Fitting"); + yield return null; + } - public IEnumerator WeightingEnumerator() - { - morpherState = MorpherState.Weighting_Doing; - doProcess = true; - yield return null; - ProcessInfoDebug(morpherMode, "Weighting"); - using (EdenAutoMorpherManager eamManager = new EdenAutoMorpherManager()) - { - EdenAutoMorpherConfig config = SetupConfigData(MorpherMode.ETC); - IEnumerator eamFitting = eamManager.WeightingEnumerator(config); - while (eamFitting.MoveNext() && doProcess) - { - ref string title = ref processInfo.title; - ref string text = ref processInfo.text; - ref float progress = ref processInfo.progress; - (title, text, progress) = eamManager.GetProgressInfo(); - yield return eamFitting.Current; - } - } - yield return null; - doProcess = false; - morpherState = MorpherState.Idle; - Debug.Log((object)"[Eden Auto Morpher] Ended Weighting"); - yield return null; - } + public IEnumerator WeightingEnumerator() + { + this.morpherState = MorpherState.Weighting_Doing; + this.doProcess = true; + yield return null; + this.ProcessInfoDebug(this.morpherMode, "Weighting"); + using (EdenAutoMorpherManager eamManager = new EdenAutoMorpherManager()) + { + EdenAutoMorpherConfig config = this.SetupConfigData(MorpherMode.ETC); + IEnumerator eamFitting = eamManager.WeightingEnumerator(config); + while (eamFitting.MoveNext() && this.doProcess) + { + string title = this.processInfo.title; + string text = this.processInfo.text; + float progress = this.processInfo.progress; + (title, text, progress) = eamManager.GetProgressInfo(); + yield return eamFitting.Current; + } + } + yield return null; + this.doProcess = false; + this.morpherState = MorpherState.Idle; + Debug.Log((object)"[Eden Auto Morpher] Ended Weighting"); + yield return null; + } - public IEnumerator AutoFitting(MorpherMode morpherMode) - { - TransformInfo sourceAvatarInfo = new TransformInfo(sourceAvatarObject.transform); - TransformInfo targetAvatarInfo = new TransformInfo(targetAvatarObject.transform); - try - { - EdenAutoMorpher_SetUpUtil edenAutoMorpher_SetUpUtil = new EdenAutoMorpher_SetUpUtil(); - sourceBodyMeshesReadOnly = edenAutoMorpher_SetUpUtil.SetupBodyMeshes(sourceAvatarObject, isBodyAutoSetup, sourceBodyMeshes, "Source ").AsReadOnly(); - targetBodyMeshesReadOnly = edenAutoMorpher_SetUpUtil.SetupBodyMeshes(targetAvatarObject, isBodyAutoSetup, targetBodyMeshes, "Target ").AsReadOnly(); - targetAvatarObject.transform.SetParent((Transform)null, true); - targetAvatarObject.transform.localRotation = Quaternion.identity; - sourceAvatarObject.transform.SetParent((Transform)null, true); - sourceAvatarObject.transform.localRotation = Quaternion.identity; - EdenAutoMorpherConfig configData = SetupConfigData(morpherMode); - new EdenAutoMorpher_SetUpUtil().AutoSetup(ref configData, out clothesHumanoidMatchedBones, out clothBoneTypeMap); - targetClothesObject = configData.targetClothesObject; - targetClothesObjectOriginal = targetClothesObject; - yield return null; - fittedTargetAvatar = null; - fittedTargetClothes = null; - yield return null; - configData = SetupConfigData(morpherMode); - using (EdenAutoMorpherManager eamManager = new EdenAutoMorpherManager()) - { - IEnumerator eamFitting = eamManager.FittingIteration(configData, morpherMode); - while (eamFitting.MoveNext() && doProcess) - { - ref string title = ref processInfo.title; - ref string text = ref processInfo.text; - ref float progress = ref processInfo.progress; - (title, text, progress) = eamManager.GetProgressInfo(); - yield return eamFitting.Current; - } - } - fittedTargetAvatar = configData.targetAvatarObject; - fittedTargetClothes = configData.targetClothesObject; - } - finally - { - EdenAutoMorpher edenAutoMorpher = this; - sourceAvatarInfo.ApplyToTransform(edenAutoMorpher.sourceAvatarObject.transform, applyParent: true, applyPosition: false, applyRotation: true, applyScale: true); - targetAvatarInfo.ApplyToTransform(edenAutoMorpher.targetAvatarObject.transform, applyParent: true, applyPosition: false, applyRotation: true, applyScale: true); - } - yield return null; - } + public IEnumerator AutoFitting(MorpherMode morpherMode) + { + TransformInfo sourceAvatarInfo = new TransformInfo(this.sourceAvatarObject.transform); + TransformInfo targetAvatarInfo = new TransformInfo(this.targetAvatarObject.transform); + try + { + EdenAutoMorpher_SetUpUtil edenAutoMorpher_SetUpUtil = new EdenAutoMorpher_SetUpUtil(); + this.sourceBodyMeshesReadOnly = edenAutoMorpher_SetUpUtil.SetupBodyMeshes(this.sourceAvatarObject, this.isBodyAutoSetup, this.sourceBodyMeshes, "Source ").AsReadOnly(); + this.targetBodyMeshesReadOnly = edenAutoMorpher_SetUpUtil.SetupBodyMeshes(this.targetAvatarObject, this.isBodyAutoSetup, this.targetBodyMeshes, "Target ").AsReadOnly(); + this.targetAvatarObject.transform.SetParent((Transform)null, true); + this.targetAvatarObject.transform.localRotation = Quaternion.identity; + this.sourceAvatarObject.transform.SetParent((Transform)null, true); + this.sourceAvatarObject.transform.localRotation = Quaternion.identity; + EdenAutoMorpherConfig configData = this.SetupConfigData(morpherMode); + new EdenAutoMorpher_SetUpUtil().AutoSetup(ref configData, out this.clothesHumanoidMatchedBones, out this.clothBoneTypeMap); + this.targetClothesObject = configData.targetClothesObject; + this.targetClothesObjectOriginal = this.targetClothesObject; + yield return null; + this.fittedTargetAvatar = null; + this.fittedTargetClothes = null; + yield return null; + configData = this.SetupConfigData(morpherMode); + using (EdenAutoMorpherManager eamManager = new EdenAutoMorpherManager()) + { + IEnumerator eamFitting = eamManager.FittingIteration(configData, morpherMode); + while (eamFitting.MoveNext() && this.doProcess) + { + string title = this.processInfo.title; + string text = this.processInfo.text; + float progress = this.processInfo.progress; + (title, text, progress) = eamManager.GetProgressInfo(); + yield return eamFitting.Current; + } + } + this.fittedTargetAvatar = configData.targetAvatarObject; + this.fittedTargetClothes = configData.targetClothesObject; + } + finally + { + EdenAutoMorpher edenAutoMorpher = this; + sourceAvatarInfo.ApplyToTransform(edenAutoMorpher.sourceAvatarObject.transform, applyParent: true, applyPosition: false, applyRotation: true, applyScale: true); + targetAvatarInfo.ApplyToTransform(edenAutoMorpher.targetAvatarObject.transform, applyParent: true, applyPosition: false, applyRotation: true, applyScale: true); + } + yield return null; + } - public IEnumerator ManualFitting(MorpherMode morpherMode) - { - TransformInfo sourceAvatarInfo = new TransformInfo(sourceAvatarObject.transform); - TransformInfo targetAvatarInfo = new TransformInfo(targetAvatarObject.transform); - try - { - EdenAutoMorpher_SetUpUtil edenAutoMorpher_SetUpUtil = new EdenAutoMorpher_SetUpUtil(); - sourceBodyMeshesReadOnly = edenAutoMorpher_SetUpUtil.SetupBodyMeshes(sourceAvatarObject, isBodyAutoSetup, sourceBodyMeshes, "Source ").AsReadOnly(); - targetBodyMeshesReadOnly = edenAutoMorpher_SetUpUtil.SetupBodyMeshes(targetAvatarObject, isBodyAutoSetup, targetBodyMeshes, "Target ").AsReadOnly(); - targetClothesObject = targetClothesObjectOriginal; - EdenAutoMorpherConfig configData = SetupConfigData(morpherMode); - new EdenAutoMorpher_SetUpUtil().ManulSetup(ref configData, out clothesHumanoidMatchedBones, out clothBoneTypeMap); - yield return null; - fittedTargetAvatar = null; - fittedTargetClothes = null; - configData = SetupConfigData(morpherMode); - using (EdenAutoMorpherManager eamManager = new EdenAutoMorpherManager()) - { - IEnumerator eamFitting = eamManager.FittingIteration(configData, morpherMode); - while (eamFitting.MoveNext() && doProcess) - { - ref string title = ref processInfo.title; - ref string text = ref processInfo.text; - ref float progress = ref processInfo.progress; - (title, text, progress) = eamManager.GetProgressInfo(); - yield return eamFitting.Current; - } - } - fittedTargetAvatar = configData.targetAvatarObject; - fittedTargetClothes = configData.targetClothesObject; - } - finally - { - EdenAutoMorpher edenAutoMorpher = this; - sourceAvatarInfo.ApplyToTransform(edenAutoMorpher.sourceAvatarObject.transform, applyParent: true, applyPosition: false, applyRotation: true, applyScale: true); - targetAvatarInfo.ApplyToTransform(edenAutoMorpher.targetAvatarObject.transform, applyParent: true, applyPosition: false, applyRotation: true, applyScale: true); - } - yield return null; - } + public IEnumerator ManualFitting(MorpherMode morpherMode) + { + TransformInfo sourceAvatarInfo = new TransformInfo(this.sourceAvatarObject.transform); + TransformInfo targetAvatarInfo = new TransformInfo(this.targetAvatarObject.transform); + try + { + EdenAutoMorpher_SetUpUtil edenAutoMorpher_SetUpUtil = new EdenAutoMorpher_SetUpUtil(); + this.sourceBodyMeshesReadOnly = edenAutoMorpher_SetUpUtil.SetupBodyMeshes(this.sourceAvatarObject, this.isBodyAutoSetup, this.sourceBodyMeshes, "Source ").AsReadOnly(); + this.targetBodyMeshesReadOnly = edenAutoMorpher_SetUpUtil.SetupBodyMeshes(this.targetAvatarObject, this.isBodyAutoSetup, this.targetBodyMeshes, "Target ").AsReadOnly(); + this.targetClothesObject = this.targetClothesObjectOriginal; + EdenAutoMorpherConfig configData = this.SetupConfigData(morpherMode); + new EdenAutoMorpher_SetUpUtil().ManulSetup(ref configData, out this.clothesHumanoidMatchedBones, out this.clothBoneTypeMap); + yield return null; + this.fittedTargetAvatar = null; + this.fittedTargetClothes = null; + configData = this.SetupConfigData(morpherMode); + using (EdenAutoMorpherManager eamManager = new EdenAutoMorpherManager()) + { + IEnumerator eamFitting = eamManager.FittingIteration(configData, morpherMode); + while (eamFitting.MoveNext() && this.doProcess) + { + string title = this.processInfo.title; + string text = this.processInfo.text; + float progress = this.processInfo.progress; + (title, text, progress) = eamManager.GetProgressInfo(); + yield return eamFitting.Current; + } + } + this.fittedTargetAvatar = configData.targetAvatarObject; + this.fittedTargetClothes = configData.targetClothesObject; + } + finally + { + EdenAutoMorpher edenAutoMorpher = this; + sourceAvatarInfo.ApplyToTransform(edenAutoMorpher.sourceAvatarObject.transform, applyParent: true, applyPosition: false, applyRotation: true, applyScale: true); + targetAvatarInfo.ApplyToTransform(edenAutoMorpher.targetAvatarObject.transform, applyParent: true, applyPosition: false, applyRotation: true, applyScale: true); + } + yield return null; + } - public IEnumerator ProfileFitting(MorpherMode morpherMode) - { - TransformInfo sourceClothesInfo = new TransformInfo(sourceClothesObject.transform); - TransformInfo targetAvatarInfo = new TransformInfo(targetAvatarObject.transform); - try - { - EdenAutoMorpher_SetUpUtil edenAutoMorpher_SetUpUtil = new EdenAutoMorpher_SetUpUtil(); - targetBodyMeshesReadOnly = edenAutoMorpher_SetUpUtil.SetupBodyMeshes(targetAvatarObject, isBodyAutoSetup, targetBodyMeshes, "Target ").AsReadOnly(); - targetAvatarObject.transform.SetParent((Transform)null, true); - targetAvatarObject.transform.localRotation = Quaternion.identity; - sourceClothesObject.transform.SetParent((Transform)null, true); - sourceClothesObject.transform.localScale = Vector3.one; - sourceClothesObject.transform.localRotation = Quaternion.identity; - EdenAutoMorpherConfig configData = SetupConfigData(morpherMode); - new EdenAutoMorpher_SetUpUtil().ProfileAutoSetup(ref configData, out clothesHumanoidMatchedBones, out clothBoneTypeMap); - targetClothesObject = configData.targetClothesObject; - targetClothesObjectOriginal = targetClothesObject; - yield return null; - fittedTargetAvatar = null; - fittedTargetClothes = null; - yield return null; - configData = SetupConfigData(morpherMode); - using (EdenAutoMorpherManager eamManager = new EdenAutoMorpherManager()) - { - IEnumerator eamFitting = eamManager.FittingIteration(configData, morpherMode); - while (eamFitting.MoveNext() && doProcess) - { - ref string title = ref processInfo.title; - ref string text = ref processInfo.text; - ref float progress = ref processInfo.progress; - (title, text, progress) = eamManager.GetProgressInfo(); - yield return eamFitting.Current; - } - } - fittedTargetAvatar = configData.targetAvatarObject; - fittedTargetClothes = configData.targetClothesObject; - yield return null; - } - finally - { - EdenAutoMorpher edenAutoMorpher = this; - sourceClothesInfo.ApplyToTransform(edenAutoMorpher.sourceClothesObject.transform, applyParent: true, applyPosition: false, applyRotation: true, applyScale: true); - targetAvatarInfo.ApplyToTransform(edenAutoMorpher.targetAvatarObject.transform, applyParent: true, applyPosition: false, applyRotation: true, applyScale: true); - } - } + public IEnumerator ProfileFitting(MorpherMode morpherMode) + { + TransformInfo sourceClothesInfo = new TransformInfo(this.sourceClothesObject.transform); + TransformInfo targetAvatarInfo = new TransformInfo(this.targetAvatarObject.transform); + try + { + EdenAutoMorpher_SetUpUtil edenAutoMorpher_SetUpUtil = new EdenAutoMorpher_SetUpUtil(); + this.targetBodyMeshesReadOnly = edenAutoMorpher_SetUpUtil.SetupBodyMeshes(this.targetAvatarObject, this.isBodyAutoSetup, this.targetBodyMeshes, "Target ").AsReadOnly(); + this.targetAvatarObject.transform.SetParent((Transform)null, true); + this.targetAvatarObject.transform.localRotation = Quaternion.identity; + this.sourceClothesObject.transform.SetParent((Transform)null, true); + this.sourceClothesObject.transform.localScale = Vector3.one; + this.sourceClothesObject.transform.localRotation = Quaternion.identity; + EdenAutoMorpherConfig configData = this.SetupConfigData(morpherMode); + new EdenAutoMorpher_SetUpUtil().ProfileAutoSetup(ref configData, out this.clothesHumanoidMatchedBones, out this.clothBoneTypeMap); + this.targetClothesObject = configData.targetClothesObject; + this.targetClothesObjectOriginal = this.targetClothesObject; + yield return null; + this.fittedTargetAvatar = null; + this.fittedTargetClothes = null; + yield return null; + configData = this.SetupConfigData(morpherMode); + using (EdenAutoMorpherManager eamManager = new EdenAutoMorpherManager()) + { + IEnumerator eamFitting = eamManager.FittingIteration(configData, morpherMode); + while (eamFitting.MoveNext() && this.doProcess) + { + string title = this.processInfo.title; + string text = this.processInfo.text; + float progress = this.processInfo.progress; + (title, text, progress) = eamManager.GetProgressInfo(); + yield return eamFitting.Current; + } + } + this.fittedTargetAvatar = configData.targetAvatarObject; + this.fittedTargetClothes = configData.targetClothesObject; + yield return null; + } + finally + { + EdenAutoMorpher edenAutoMorpher = this; + sourceClothesInfo.ApplyToTransform(edenAutoMorpher.sourceClothesObject.transform, applyParent: true, applyPosition: false, applyRotation: true, applyScale: true); + targetAvatarInfo.ApplyToTransform(edenAutoMorpher.targetAvatarObject.transform, applyParent: true, applyPosition: false, applyRotation: true, applyScale: true); + } + } - public bool IsWeightingReady(bool isAutoMode) - { - bool flag = morpherState == MorpherState.Fitting_End && (Object)(object)fittedTargetAvatar != (Object)null && (Object)(object)fittedTargetAvatar == (Object)(object)targetAvatarObject; - if (!isAutoMode) - { - flag = flag && (Object)(object)fittedTargetClothes == (Object)(object)targetClothesObjectOriginal; - } - return flag; - } + public bool IsWeightingReady(bool isAutoMode) + { + bool flag = this.morpherState == MorpherState.Fitting_End && (Object)(object)this.fittedTargetAvatar != (Object)null && (Object)(object)this.fittedTargetAvatar == (Object)(object)this.targetAvatarObject; + if (!isAutoMode) + { + flag = flag && (Object)(object)this.fittedTargetClothes == (Object)(object)this.targetClothesObjectOriginal; + } + return flag; + } - private void ProcessInfoDebug(MorpherMode morpherMode, string processType) - { - StringBuilder stringBuilder = new StringBuilder(); - stringBuilder.AppendLine($"Start Process [{processType} / {morpherMode}]"); - EdenAutoMorpherConfig edenAutoMorpherConfig = SetupConfigData(morpherMode); - string text = (((Object)(object)edenAutoMorpherConfig.sourceAvatarObject != (Object)null) ? ((Object)edenAutoMorpherConfig.sourceAvatarObject).name : "null"); - string text2 = (((Object)(object)edenAutoMorpherConfig.sourceClothesObject != (Object)null) ? ((Object)edenAutoMorpherConfig.sourceClothesObject).name : "null"); - string text3 = (((Object)(object)edenAutoMorpherConfig.targetAvatarObject != (Object)null) ? ((Object)edenAutoMorpherConfig.targetAvatarObject).name : "null"); - string text4 = (((Object)(object)edenAutoMorpherConfig.targetClothesObject != (Object)null) ? ((Object)edenAutoMorpherConfig.targetClothesObject).name : "null"); - stringBuilder.AppendLine("[Objects]"); - if (morpherMode == MorpherMode.ProfileMorpher) - { - stringBuilder.AppendLine("- profileName: " + (string.IsNullOrEmpty(edenAutoMorpherConfig.profileName) ? "null/empty" : edenAutoMorpherConfig.profileName)); - } - stringBuilder.AppendLine("- sourceAvatarObject: " + text); - stringBuilder.AppendLine("- sourceClothesObject: " + text2); - if ((Object)(object)edenAutoMorpherConfig.sourceClothesObject != (Object)null) - { - SkinnedMeshRenderer[] componentsInChildren = edenAutoMorpherConfig.sourceClothesObject.GetComponentsInChildren(true); - stringBuilder.AppendLine($" - sourceClothes SkinnedMeshRenderers Count: {componentsInChildren.Length}"); - int num = Mathf.Min(componentsInChildren.Length, 10); - for (int i = 0; i < num; i++) - { - SkinnedMeshRenderer val = componentsInChildren[i]; - string text5 = (((Object)(object)val != (Object)null) ? ((Object)val).name : "null"); - string text6 = (((Object)(object)val != (Object)null && (Object)(object)val.rootBone != (Object)null) ? ((Object)val.rootBone).name : "null"); - string text7 = (((Object)(object)val != (Object)null && (Object)(object)val.sharedMesh != (Object)null) ? ((Object)val.sharedMesh).name : "null"); - stringBuilder.AppendLine($" - [{i}] SMR: {text5} / rootBone: {text6} / mesh: {text7}"); - } - if (componentsInChildren.Length > num) - { - stringBuilder.AppendLine($" - ... ({componentsInChildren.Length - num} more)"); - } - } - stringBuilder.AppendLine("- targetAvatarObject: " + text3); - stringBuilder.AppendLine("- targetClothesObject: " + text4); - if ((Object)(object)edenAutoMorpherConfig.targetClothesObject != (Object)null) - { - SkinnedMeshRenderer[] componentsInChildren2 = edenAutoMorpherConfig.targetClothesObject.GetComponentsInChildren(true); - stringBuilder.AppendLine($" - targetClothes SkinnedMeshRenderers Count: {componentsInChildren2.Length}"); - int num2 = Mathf.Min(componentsInChildren2.Length, 10); - for (int j = 0; j < num2; j++) - { - SkinnedMeshRenderer val2 = componentsInChildren2[j]; - string text8 = (((Object)(object)val2 != (Object)null) ? ((Object)val2).name : "null"); - string text9 = (((Object)(object)val2 != (Object)null && (Object)(object)val2.rootBone != (Object)null) ? ((Object)val2.rootBone).name : "null"); - string text10 = (((Object)(object)val2 != (Object)null && (Object)(object)val2.sharedMesh != (Object)null) ? ((Object)val2.sharedMesh).name : "null"); - stringBuilder.AppendLine($" - [{j}] SMR: {text8} / rootBone: {text9} / mesh: {text10}"); - } - if (componentsInChildren2.Length > num2) - { - stringBuilder.AppendLine($" - ... ({componentsInChildren2.Length - num2} more)"); - } - } - stringBuilder.AppendLine(); - stringBuilder.AppendLine("[Body Meshes]"); - stringBuilder.AppendLine($"- isBodyAutoSetup: {edenAutoMorpherConfig.isBodyAutoSetup}"); - if (!edenAutoMorpherConfig.isBodyAutoSetup) - { - if (edenAutoMorpherConfig.sourceBodyMeshes == null) - { - stringBuilder.AppendLine("- sourceBodyMeshes: null"); - } - else - { - stringBuilder.AppendLine($"- sourceBodyMeshes Count: {sourceBodyMeshes.Count}"); - for (int k = 0; k < sourceBodyMeshes.Count; k++) - { - SkinnedMeshRenderer val3 = sourceBodyMeshes[k]; - string text11 = (((Object)(object)val3 != (Object)null) ? ((Object)val3).name : "null"); - string text12 = (((Object)(object)val3 != (Object)null && (Object)(object)val3.rootBone != (Object)null) ? ((Object)val3.rootBone).name : "null"); - string text13 = (((Object)(object)val3 != (Object)null && (Object)(object)val3.sharedMesh != (Object)null) ? ((Object)val3.sharedMesh).name : "null"); - stringBuilder.AppendLine($" - [{k}] SMR: {text11} / rootBone: {text12} / mesh: {text13}"); - } - } - if (targetBodyMeshes == null) - { - stringBuilder.AppendLine("- targetBodyMeshes: null"); - } - else - { - stringBuilder.AppendLine($"- targetBodyMeshes Count: {targetBodyMeshes.Count}"); - for (int l = 0; l < targetBodyMeshes.Count; l++) - { - SkinnedMeshRenderer val4 = targetBodyMeshes[l]; - string text14 = (((Object)(object)val4 != (Object)null) ? ((Object)val4).name : "null"); - string text15 = (((Object)(object)val4 != (Object)null && (Object)(object)val4.rootBone != (Object)null) ? ((Object)val4.rootBone).name : "null"); - string text16 = (((Object)(object)val4 != (Object)null && (Object)(object)val4.sharedMesh != (Object)null) ? ((Object)val4.sharedMesh).name : "null"); - stringBuilder.AppendLine($" - [{l}] SMR: {text14} / rootBone: {text15} / mesh: {text16}"); - } - } - } - stringBuilder.AppendLine(); - stringBuilder.AppendLine("[Parameters]"); - stringBuilder.AppendLine($"- minMargin: {edenAutoMorpherConfig.minMargin}"); - stringBuilder.AppendLine($"- worldRadius: {edenAutoMorpherConfig.worldRadius}"); - stringBuilder.AppendLine($"- sigma: {edenAutoMorpherConfig.sigma}"); - stringBuilder.AppendLine($"- smoothingIteration: {edenAutoMorpherConfig.smoothingIteration}"); - stringBuilder.AppendLine($"- fittingExpandIteration: {edenAutoMorpherConfig.fittingExpandIteration}"); - stringBuilder.AppendLine($"- fittingShrinkIteration: {edenAutoMorpherConfig.fittingShrinkIteration}"); - stringBuilder.AppendLine(); - stringBuilder.AppendLine("[Options]"); - stringBuilder.AppendLine($"- isReparentAccessoryBonesToTargetAvatar: {edenAutoMorpherConfig.isReparentAccessoryBonesToTargetAvatar}"); - stringBuilder.AppendLine($"- skipFootFitting: {edenAutoMorpherConfig.skipFootFitting}"); - Debug.Log((object)stringBuilder.ToString()); - } + private void ProcessInfoDebug(MorpherMode morpherMode, string processType) + { + StringBuilder stringBuilder = new StringBuilder(); + stringBuilder.AppendLine($"Start Process [{processType} / {morpherMode}]"); + EdenAutoMorpherConfig edenAutoMorpherConfig = this.SetupConfigData(morpherMode); + string text = (((Object)(object)edenAutoMorpherConfig.sourceAvatarObject != (Object)null) ? ((Object)edenAutoMorpherConfig.sourceAvatarObject).name : "null"); + string text2 = (((Object)(object)edenAutoMorpherConfig.sourceClothesObject != (Object)null) ? ((Object)edenAutoMorpherConfig.sourceClothesObject).name : "null"); + string text3 = (((Object)(object)edenAutoMorpherConfig.targetAvatarObject != (Object)null) ? ((Object)edenAutoMorpherConfig.targetAvatarObject).name : "null"); + string text4 = (((Object)(object)edenAutoMorpherConfig.targetClothesObject != (Object)null) ? ((Object)edenAutoMorpherConfig.targetClothesObject).name : "null"); + stringBuilder.AppendLine("[Objects]"); + if (morpherMode == MorpherMode.ProfileMorpher) + { + stringBuilder.AppendLine("- profileName: " + (string.IsNullOrEmpty(edenAutoMorpherConfig.profileName) ? "null/empty" : edenAutoMorpherConfig.profileName)); + } + stringBuilder.AppendLine("- sourceAvatarObject: " + text); + stringBuilder.AppendLine("- sourceClothesObject: " + text2); + if ((Object)(object)edenAutoMorpherConfig.sourceClothesObject != (Object)null) + { + SkinnedMeshRenderer[] componentsInChildren = edenAutoMorpherConfig.sourceClothesObject.GetComponentsInChildren(true); + stringBuilder.AppendLine($" - sourceClothes SkinnedMeshRenderers Count: {componentsInChildren.Length}"); + int num = Mathf.Min(componentsInChildren.Length, 10); + for (int i = 0; i < num; i++) + { + SkinnedMeshRenderer val = componentsInChildren[i]; + string text5 = (((Object)(object)val != (Object)null) ? ((Object)val).name : "null"); + string text6 = (((Object)(object)val != (Object)null && (Object)(object)val.rootBone != (Object)null) ? ((Object)val.rootBone).name : "null"); + string text7 = (((Object)(object)val != (Object)null && (Object)(object)val.sharedMesh != (Object)null) ? ((Object)val.sharedMesh).name : "null"); + stringBuilder.AppendLine($" - [{i}] SMR: {text5} / rootBone: {text6} / mesh: {text7}"); + } + if (componentsInChildren.Length > num) + { + stringBuilder.AppendLine($" - ... ({componentsInChildren.Length - num} more)"); + } + } + stringBuilder.AppendLine("- targetAvatarObject: " + text3); + stringBuilder.AppendLine("- targetClothesObject: " + text4); + if ((Object)(object)edenAutoMorpherConfig.targetClothesObject != (Object)null) + { + SkinnedMeshRenderer[] componentsInChildren2 = edenAutoMorpherConfig.targetClothesObject.GetComponentsInChildren(true); + stringBuilder.AppendLine($" - targetClothes SkinnedMeshRenderers Count: {componentsInChildren2.Length}"); + int num2 = Mathf.Min(componentsInChildren2.Length, 10); + for (int j = 0; j < num2; j++) + { + SkinnedMeshRenderer val2 = componentsInChildren2[j]; + string text8 = (((Object)(object)val2 != (Object)null) ? ((Object)val2).name : "null"); + string text9 = (((Object)(object)val2 != (Object)null && (Object)(object)val2.rootBone != (Object)null) ? ((Object)val2.rootBone).name : "null"); + string text10 = (((Object)(object)val2 != (Object)null && (Object)(object)val2.sharedMesh != (Object)null) ? ((Object)val2.sharedMesh).name : "null"); + stringBuilder.AppendLine($" - [{j}] SMR: {text8} / rootBone: {text9} / mesh: {text10}"); + } + if (componentsInChildren2.Length > num2) + { + stringBuilder.AppendLine($" - ... ({componentsInChildren2.Length - num2} more)"); + } + } + stringBuilder.AppendLine(); + stringBuilder.AppendLine("[Body Meshes]"); + stringBuilder.AppendLine($"- isBodyAutoSetup: {edenAutoMorpherConfig.isBodyAutoSetup}"); + if (!edenAutoMorpherConfig.isBodyAutoSetup) + { + if (edenAutoMorpherConfig.sourceBodyMeshes == null) + { + stringBuilder.AppendLine("- sourceBodyMeshes: null"); + } + else + { + stringBuilder.AppendLine($"- sourceBodyMeshes Count: {this.sourceBodyMeshes.Count}"); + for (int k = 0; k < this.sourceBodyMeshes.Count; k++) + { + SkinnedMeshRenderer val3 = this.sourceBodyMeshes[k]; + string text11 = (((Object)(object)val3 != (Object)null) ? ((Object)val3).name : "null"); + string text12 = (((Object)(object)val3 != (Object)null && (Object)(object)val3.rootBone != (Object)null) ? ((Object)val3.rootBone).name : "null"); + string text13 = (((Object)(object)val3 != (Object)null && (Object)(object)val3.sharedMesh != (Object)null) ? ((Object)val3.sharedMesh).name : "null"); + stringBuilder.AppendLine($" - [{k}] SMR: {text11} / rootBone: {text12} / mesh: {text13}"); + } + } + if (this.targetBodyMeshes == null) + { + stringBuilder.AppendLine("- targetBodyMeshes: null"); + } + else + { + stringBuilder.AppendLine($"- targetBodyMeshes Count: {this.targetBodyMeshes.Count}"); + for (int l = 0; l < this.targetBodyMeshes.Count; l++) + { + SkinnedMeshRenderer val4 = this.targetBodyMeshes[l]; + string text14 = (((Object)(object)val4 != (Object)null) ? ((Object)val4).name : "null"); + string text15 = (((Object)(object)val4 != (Object)null && (Object)(object)val4.rootBone != (Object)null) ? ((Object)val4.rootBone).name : "null"); + string text16 = (((Object)(object)val4 != (Object)null && (Object)(object)val4.sharedMesh != (Object)null) ? ((Object)val4.sharedMesh).name : "null"); + stringBuilder.AppendLine($" - [{l}] SMR: {text14} / rootBone: {text15} / mesh: {text16}"); + } + } + } + stringBuilder.AppendLine(); + stringBuilder.AppendLine("[Parameters]"); + stringBuilder.AppendLine($"- minMargin: {edenAutoMorpherConfig.minMargin}"); + stringBuilder.AppendLine($"- worldRadius: {edenAutoMorpherConfig.worldRadius}"); + stringBuilder.AppendLine($"- sigma: {edenAutoMorpherConfig.sigma}"); + stringBuilder.AppendLine($"- smoothingIteration: {edenAutoMorpherConfig.smoothingIteration}"); + stringBuilder.AppendLine($"- fittingExpandIteration: {edenAutoMorpherConfig.fittingExpandIteration}"); + stringBuilder.AppendLine($"- fittingShrinkIteration: {edenAutoMorpherConfig.fittingShrinkIteration}"); + stringBuilder.AppendLine(); + stringBuilder.AppendLine("[Options]"); + stringBuilder.AppendLine($"- isReparentAccessoryBonesToTargetAvatar: {edenAutoMorpherConfig.isReparentAccessoryBonesToTargetAvatar}"); + stringBuilder.AppendLine($"- skipFootFitting: {edenAutoMorpherConfig.skipFootFitting}"); + Debug.Log((object)stringBuilder.ToString()); + } } diff --git a/Assets/@Eden_Tools/Eden_AutoMorpher/Script/EdenAutoMorpherConfig.cs b/Assets/@Eden_Tools/Eden_AutoMorpher/Script/EdenAutoMorpherConfig.cs index 853e3e0..ec4502e 100644 --- a/Assets/@Eden_Tools/Eden_AutoMorpher/Script/EdenAutoMorpherConfig.cs +++ b/Assets/@Eden_Tools/Eden_AutoMorpher/Script/EdenAutoMorpherConfig.cs @@ -1,56 +1,55 @@ -// Warning: Some assembly references could not be resolved automatically. This might lead to incorrect decompilation of some parts, +// 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.EdenAutoMorpherConfig using System.Collections.Generic; -using Eden.AutoMorpher; using UnityEngine; public struct EdenAutoMorpherConfig { - public GameObject sourceAvatarObject; + public GameObject sourceAvatarObject; - public GameObject sourceClothesObject; + public GameObject sourceClothesObject; - public IReadOnlyList sourceBodyMeshes; + public IReadOnlyList sourceBodyMeshes; - public GameObject targetAvatarObject; + public GameObject targetAvatarObject; - public GameObject targetClothesObject; + public GameObject targetClothesObject; - public IReadOnlyList targetBodyMeshes; + public IReadOnlyList targetBodyMeshes; - public string profileName; + public string profileName; - public float minMargin; + public float minMargin; - public float worldRadius; + public float worldRadius; - public float sigma; + public float sigma; - public int smoothingIteration; + public int smoothingIteration; - public int fittingExpandIteration; + public int fittingExpandIteration; - public int fittingShrinkIteration; + public int fittingShrinkIteration; - public bool isBodyAutoSetup; + public bool isBodyAutoSetup; - public bool isReparentAccessoryBonesToTargetAvatar; + public bool isReparentAccessoryBonesToTargetAvatar; - public bool skipFootFitting; + public bool skipFootFitting; - public bool isRemoveAutoMorphedClothes; + public bool isRemoveAutoMorphedClothes; - public bool transferWeightToAvatar; + public bool transferWeightToAvatar; - public bool addAnchorBone; + public bool addAnchorBone; - public bool armatureBoneScaleCopy; + public bool armatureBoneScaleCopy; - public Dictionary> clothesHumanoidMatchedBones; + public Dictionary> clothesHumanoidMatchedBones; - public Dictionary clothBoneTypeMap; + public Dictionary clothBoneTypeMap; - public string tagEdenMorpehrCloth; + public string tagEdenMorpehrCloth; } diff --git a/Assets/@Eden_Tools/Eden_AutoMorpher/Script/EdenAutoMorpherManager.cs b/Assets/@Eden_Tools/Eden_AutoMorpher/Script/EdenAutoMorpherManager.cs index 3ca6cab..f449245 100644 --- a/Assets/@Eden_Tools/Eden_AutoMorpher/Script/EdenAutoMorpherManager.cs +++ b/Assets/@Eden_Tools/Eden_AutoMorpher/Script/EdenAutoMorpherManager.cs @@ -1,399 +1,398 @@ -// Warning: Some assembly references could not be resolved automatically. This might lead to incorrect decompilation of some parts, +// 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.EdenAutoMorpherManager +using Eden.AutoMorpher; using System; using System.Collections; using System.Collections.Generic; using System.IO; -using Eden.AutoMorpher; -using Eden.AutoMorpher.profile; using UnityEditor; using UnityEngine; public class EdenAutoMorpherManager : IDisposable { - private string displayTitle; + private string displayTitle; - private string displayText; + private string displayText; - private float displayProgress; + private float displayProgress; - private List clothInstances; + private List clothInstances; - public (string, string, float) GetProgressInfo() - { - return (displayTitle, displayText, displayProgress); - } + public (string, string, float) GetProgressInfo() + { + return (this.displayTitle, this.displayText, this.displayProgress); + } - private void SetupProgress(string title, string text, float progress) - { - displayTitle = title; - displayText = text; - displayProgress = progress; - } + private void SetupProgress(string title, string text, float progress) + { + this.displayTitle = title; + this.displayText = text; + this.displayProgress = progress; + } - private IEnumerator SetupClothInstances(GameObject targetClothesObject, Dictionary> clothesHumanoidMatchedBones, bool duplicateMesh = true) - { - clothInstances = new List(); - SkinnedMeshRenderer[] targetClothesSMRs = targetClothesObject.GetComponentsInChildren(false); - if (targetClothesSMRs.Length == 0) - { - throw new AutoMorpherException("There is NO Skinned Mesh Renderer in Clothes", "[EdenAutoMorpherManager] SetupClothInstance\n - There is NO Skinned Mesh Renderer in Clothes"); - } - EdenAutoMorpher_SetUpUtil setupUtil = new EdenAutoMorpher_SetUpUtil(); - for (int rendereri = 0; rendereri < targetClothesSMRs.Length; rendereri++) - { - SetupProgress("Set Up", $"Setup Clothes Info [{rendereri}/{targetClothesSMRs.Length}] - ({((Object)targetClothesSMRs[rendereri]).name})", Mathf.Lerp(0.05f, 0.1f, (float)(rendereri / targetClothesSMRs.Length))); - yield return null; - ClothInstance clothInstance = setupUtil.SetupClothInstance(targetClothesSMRs[rendereri], clothesHumanoidMatchedBones, duplicateMesh); - if (clothInstance != null) - { - clothInstances.Add(clothInstance); - } - } - if (clothInstances.Count == 0) - { - throw new AutoMorpherException(LanguageManager.Get("UI.Exception.title.ClothInstanceAllocateFail"), LanguageManager.Get("UI.Exception.message.ClothInstanceAllocateFail")); - } - } + private IEnumerator SetupClothInstances(GameObject targetClothesObject, Dictionary> clothesHumanoidMatchedBones, bool duplicateMesh = true) + { + this.clothInstances = new List(); + SkinnedMeshRenderer[] targetClothesSMRs = targetClothesObject.GetComponentsInChildren(false); + if (targetClothesSMRs.Length == 0) + { + throw new AutoMorpherException("There is NO Skinned Mesh Renderer in Clothes", "[EdenAutoMorpherManager] SetupClothInstance\n - There is NO Skinned Mesh Renderer in Clothes"); + } + EdenAutoMorpher_SetUpUtil setupUtil = new EdenAutoMorpher_SetUpUtil(); + for (int rendereri = 0; rendereri < targetClothesSMRs.Length; rendereri++) + { + this.SetupProgress("Set Up", $"Setup Clothes Info [{rendereri}/{targetClothesSMRs.Length}] - ({targetClothesSMRs[rendereri].name})", Mathf.Lerp(0.05f, 0.1f, (float)(rendereri / targetClothesSMRs.Length))); + yield return null; + ClothInstance clothInstance = setupUtil.SetupClothInstance(targetClothesSMRs[rendereri], clothesHumanoidMatchedBones, duplicateMesh); + if (clothInstance != null) + { + this.clothInstances.Add(clothInstance); + } + } + if (this.clothInstances.Count == 0) + { + throw new AutoMorpherException(LanguageManager.Get("UI.Exception.title.ClothInstanceAllocateFail"), LanguageManager.Get("UI.Exception.message.ClothInstanceAllocateFail")); + } + } - private IEnumerator SetupClothInstances(GameObject targetClothesObject, Dictionary> clothesHumanoidMatchedBones, GameObject sourceClothesObject, MeshMatcher meshMatcher) - { - clothInstances = new List(); - SkinnedMeshRenderer[] targetClothesSMRs = targetClothesObject.GetComponentsInChildren(false); - if (targetClothesSMRs.Length == 0) - { - throw new AutoMorpherException("There is NO Skinned Mesh Renderer in Clothes", "[EdenAutoMorpherManager] SetupClothInstance\n - There is NO Skinned Mesh Renderer in Clothes"); - } - SkinnedMeshRenderer[] sourceClothesSMRs = sourceClothesObject.GetComponentsInChildren(false); - if (sourceClothesSMRs.Length == 0 || targetClothesSMRs.Length != sourceClothesSMRs.Length) - { - throw new AutoMorpherException("Clothes Skinned Mesh Renderer is Not Matched", "[EdenAutoMorpherManager] SetupClothInstance\n - Skinned Mesh Renderer of Source Clothes and Target Clothes is Not Matched"); - } - EdenAutoMorpher_SetUpUtil setupUtil = new EdenAutoMorpher_SetUpUtil(); - for (int rendereri = 0; rendereri < targetClothesSMRs.Length; rendereri++) - { - SetupProgress("Set Up", $"Setup Clothes Info [{rendereri}/{targetClothesSMRs.Length}] - ({((Object)targetClothesSMRs[rendereri]).name})", Mathf.Lerp(0.07f, 0.1f, (float)(rendereri / targetClothesSMRs.Length))); - yield return null; - ClothInstance clothInstance = setupUtil.SetupClothInstance(targetClothesSMRs[rendereri], sourceClothesSMRs[rendereri], meshMatcher, clothesHumanoidMatchedBones, duplicateMesh: true); - if (clothInstance != null) - { - clothInstances.Add(clothInstance); - } - } - if (clothInstances.Count == 0) - { - throw new AutoMorpherException(LanguageManager.Get("UI.Exception.title.ClothInstanceAllocateFail"), LanguageManager.Get("UI.Exception.message.ClothInstanceAllocateFail")); - } - } + private IEnumerator SetupClothInstances(GameObject targetClothesObject, Dictionary> clothesHumanoidMatchedBones, GameObject sourceClothesObject, MeshMatcher meshMatcher) + { + this.clothInstances = new List(); + SkinnedMeshRenderer[] targetClothesSMRs = targetClothesObject.GetComponentsInChildren(false); + if (targetClothesSMRs.Length == 0) + { + throw new AutoMorpherException("There is NO Skinned Mesh Renderer in Clothes", "[EdenAutoMorpherManager] SetupClothInstance\n - There is NO Skinned Mesh Renderer in Clothes"); + } + SkinnedMeshRenderer[] sourceClothesSMRs = sourceClothesObject.GetComponentsInChildren(false); + if (sourceClothesSMRs.Length == 0 || targetClothesSMRs.Length != sourceClothesSMRs.Length) + { + throw new AutoMorpherException("Clothes Skinned Mesh Renderer is Not Matched", "[EdenAutoMorpherManager] SetupClothInstance\n - Skinned Mesh Renderer of Source Clothes and Target Clothes is Not Matched"); + } + EdenAutoMorpher_SetUpUtil setupUtil = new EdenAutoMorpher_SetUpUtil(); + for (int rendereri = 0; rendereri < targetClothesSMRs.Length; rendereri++) + { + this.SetupProgress("Set Up", $"Setup Clothes Info [{rendereri}/{targetClothesSMRs.Length}] - ({targetClothesSMRs[rendereri].name})", Mathf.Lerp(0.07f, 0.1f, (float)(rendereri / targetClothesSMRs.Length))); + yield return null; + ClothInstance clothInstance = setupUtil.SetupClothInstance(targetClothesSMRs[rendereri], sourceClothesSMRs[rendereri], meshMatcher, clothesHumanoidMatchedBones, duplicateMesh: true); + if (clothInstance != null) + { + this.clothInstances.Add(clothInstance); + } + } + if (this.clothInstances.Count == 0) + { + throw new AutoMorpherException(LanguageManager.Get("UI.Exception.title.ClothInstanceAllocateFail"), LanguageManager.Get("UI.Exception.message.ClothInstanceAllocateFail")); + } + } - public IEnumerator FittingIteration(EdenAutoMorpherConfig config, MorpherMode morpherMode) - { - SetupProgress("Set Up", "Setup Target Avatar Info", 0.03f); - yield return null; - MeshMatcher meshMatcher = new MeshMatcher(); - BvhTriangleMesh targetBodyBVH = meshMatcher.BuildBvhMulti(config.targetBodyMeshes, config.targetAvatarObject.GetComponent()); - if (targetBodyBVH == null) - { - throw new AutoMorpherException("targetBodyBVH is Null", "[EdenAutoMorpherManater] FittingIteration\n - targetBodyBVH is null"); - } - yield return null; - SetupProgress("Set Up", "Setup Source Avatar Info", 0.05f); - yield return null; - BvhTriangleMesh sourceBodyBVH = null; - switch (morpherMode) - { - case MorpherMode.AutoMorpher: - case MorpherMode.ManualMorpher: - sourceBodyBVH = meshMatcher.BuildBvhMulti(config.sourceBodyMeshes, config.sourceAvatarObject.GetComponent()); - break; - case MorpherMode.ProfileMorpher: - { - ProfileLoader profileLoader = new ProfileLoader(); - sourceBodyBVH = profileLoader.LoadBvhWithRootTransform(config.sourceClothesObject.transform, config.profileName); - break; - } - default: - Debug.LogError((object)"Unknown MorpherMode"); - break; - } - yield return null; - if (sourceBodyBVH == null) - { - throw new AutoMorpherException("sourceBodyBVH is Null", "[EdenAutoMorpherManater] FittingIteration\n - sourceBodyBVH is null"); - } - meshMatcher.bodyBVH = sourceBodyBVH; - SetupProgress("Set Up", "Setup Clothes Info", 0.07f); - yield return null; - IEnumerator setupClothEnum = SetupClothInstances(config.targetClothesObject, config.clothesHumanoidMatchedBones, config.sourceClothesObject, meshMatcher); - while (setupClothEnum.MoveNext()) - { - yield return setupClothEnum.Current; - } - yield return null; - float fittingRadius = config.worldRadius; - meshMatcher.bodyBVH = targetBodyBVH; - VertexFittingUtil vertexFittingUtil = new VertexFittingUtil(); - int fittingI; - for (fittingI = 0; fittingI < config.fittingExpandIteration; fittingI++) - { - foreach (ClothInstance clothInstance in clothInstances) - { - SetupProgress("Fitting", $"Phase 1 Expanding [{fittingI + 1}/{config.fittingExpandIteration}] - {((Object)((Component)clothInstance.smr).transform).name}", Mathf.Lerp(0.1f, 0.4f, (float)fittingI / (float)config.fittingExpandIteration)); - yield return null; - vertexFittingUtil.ExpandClothes_World(clothInstance, clothInstances, meshMatcher, config, fittingRadius); - yield return null; - } - if (fittingI % 2 == 0) - { - fittingRadius *= 0.97f; - } - } - fittingRadius = config.worldRadius; - for (fittingI = 0; fittingI < config.fittingShrinkIteration; fittingI++) - { - foreach (ClothInstance clothInstance in clothInstances) - { - SetupProgress("Fitting", $"Phase 2 Fitting [{fittingI + 1}/{config.fittingShrinkIteration}] - {((Object)((Component)clothInstance.smr).transform).name}", Mathf.Lerp(0.4f, 0.8f, (float)fittingI / (float)config.fittingShrinkIteration)); - yield return null; - vertexFittingUtil.ShrinkClothes_World(clothInstance, clothInstances, meshMatcher, config, fittingRadius); - yield return null; - vertexFittingUtil.ExpandClothes_World(clothInstance, clothInstances, meshMatcher, config, fittingRadius); - yield return null; - } - if (fittingI % 2 == 0) - { - fittingRadius *= 0.97f; - } - } - fittingRadius = config.worldRadius / 2f; - for (fittingI = 0; fittingI < config.fittingExpandIteration; fittingI++) - { - foreach (ClothInstance clothInstance in clothInstances) - { - SetupProgress("Fitting", $"Phase 3 Fine-tuning [{fittingI + 1}/{config.fittingExpandIteration}] - {((Object)((Component)clothInstance.smr).transform).name}", Mathf.Lerp(0.8f, 0.9f, (float)fittingI / (float)config.fittingExpandIteration)); - yield return null; - vertexFittingUtil.ExpandClothes_World(clothInstance, clothInstances, meshMatcher, config, fittingRadius); - yield return null; - } - if (fittingI % 2 == 0) - { - fittingRadius *= 0.97f; - } - } - yield return null; - SetupProgress("Fitting", "Apply Transform Bone", 0.93f); - yield return null; - BoneAlignmentUtil boneAlignmentUtil = new BoneAlignmentUtil(); - boneAlignmentUtil.CleanupTempBones(config.targetClothesObject.transform); - MorpherMode morpherMode2 = morpherMode; - if (morpherMode2 == MorpherMode.AutoMorpher || morpherMode2 == MorpherMode.ProfileMorpher) - { - config.targetClothesObject.transform.localScale = Vector3.one; - boneAlignmentUtil.AlignClothBonesToAvatar(clothInstances[0], config.targetAvatarObject.GetComponent()); - } - yield return null; - SetupProgress("Fitting", "Apply Transform Mesh", 0.99f); - yield return null; - fittingI = 0; - while (fittingI < clothInstances.Count) - { - ClothInstance clothInstance = clothInstances[fittingI]; - SetupProgress("Fitting", $"Apply to Mesh [{fittingI + 1}/{clothInstances.Count}] - {((Object)((Component)clothInstance.smr).transform).name}", Mathf.Lerp(0.93f, 0.98f, (float)fittingI / (float)clothInstances.Count)); - yield return null; - clothInstance.ApplyWorldVerticesToMesh(); - ((Renderer)clothInstance.smr).localBounds = new Bounds(Vector3.zero, Vector3.one * 2f); - EditorUtility.SetDirty((Object)(object)clothInstance.smr.sharedMesh); - EditorUtility.SetDirty((Object)(object)clothInstance.smr); - yield return null; - int num = fittingI + 1; - fittingI = num; - } - yield return null; - SetupProgress("Saving", "Saving Mesh Data", 0.99f); - yield return null; - SaveEditedMeshesToAssets(clothInstances, config); - yield return null; - SetupProgress("Finishing", "Finishing", 1f); - foreach (ClothInstance clothInstance2 in clothInstances) - { - clothInstance2.Dispose(); - } - clothInstances = null; - yield return null; - } + public IEnumerator FittingIteration(EdenAutoMorpherConfig config, MorpherMode morpherMode) + { + this.SetupProgress("Set Up", "Setup Target Avatar Info", 0.03f); + yield return null; + MeshMatcher meshMatcher = new MeshMatcher(); + BvhTriangleMesh targetBodyBVH = meshMatcher.BuildBvhMulti(config.targetBodyMeshes, config.targetAvatarObject.GetComponent()); + if (targetBodyBVH == null) + { + throw new AutoMorpherException("targetBodyBVH is Null", "[EdenAutoMorpherManater] FittingIteration\n - targetBodyBVH is null"); + } + yield return null; + this.SetupProgress("Set Up", "Setup Source Avatar Info", 0.05f); + yield return null; + BvhTriangleMesh sourceBodyBVH = null; + switch (morpherMode) + { + case MorpherMode.AutoMorpher: + case MorpherMode.ManualMorpher: + sourceBodyBVH = meshMatcher.BuildBvhMulti(config.sourceBodyMeshes, config.sourceAvatarObject.GetComponent()); + break; + case MorpherMode.ProfileMorpher: + { + ProfileLoader profileLoader = new ProfileLoader(); + sourceBodyBVH = profileLoader.LoadBvhWithRootTransform(config.sourceClothesObject.transform, config.profileName); + break; + } + default: + Debug.LogError((object)"Unknown MorpherMode"); + break; + } + yield return null; + if (sourceBodyBVH == null) + { + throw new AutoMorpherException("sourceBodyBVH is Null", "[EdenAutoMorpherManater] FittingIteration\n - sourceBodyBVH is null"); + } + meshMatcher.bodyBVH = sourceBodyBVH; + this.SetupProgress("Set Up", "Setup Clothes Info", 0.07f); + yield return null; + IEnumerator setupClothEnum = this.SetupClothInstances(config.targetClothesObject, config.clothesHumanoidMatchedBones, config.sourceClothesObject, meshMatcher); + while (setupClothEnum.MoveNext()) + { + yield return setupClothEnum.Current; + } + yield return null; + float fittingRadius = config.worldRadius; + meshMatcher.bodyBVH = targetBodyBVH; + VertexFittingUtil vertexFittingUtil = new VertexFittingUtil(); + int fittingI; + for (fittingI = 0; fittingI < config.fittingExpandIteration; fittingI++) + { + foreach (ClothInstance clothInstance in this.clothInstances) + { + this.SetupProgress("Fitting", $"Phase 1 Expanding [{fittingI + 1}/{config.fittingExpandIteration}] - {clothInstance.smr.transform.name}", Mathf.Lerp(0.1f, 0.4f, (float)fittingI / (float)config.fittingExpandIteration)); + yield return null; + vertexFittingUtil.ExpandClothes_World(clothInstance, this.clothInstances, meshMatcher, config, fittingRadius); + yield return null; + } + if (fittingI % 2 == 0) + { + fittingRadius *= 0.97f; + } + } + fittingRadius = config.worldRadius; + for (fittingI = 0; fittingI < config.fittingShrinkIteration; fittingI++) + { + foreach (ClothInstance clothInstance in this.clothInstances) + { + this.SetupProgress("Fitting", $"Phase 2 Fitting [{fittingI + 1}/{config.fittingShrinkIteration}] - {clothInstance.smr.transform.name}", Mathf.Lerp(0.4f, 0.8f, (float)fittingI / (float)config.fittingShrinkIteration)); + yield return null; + vertexFittingUtil.ShrinkClothes_World(clothInstance, this.clothInstances, meshMatcher, config, fittingRadius); + yield return null; + vertexFittingUtil.ExpandClothes_World(clothInstance, this.clothInstances, meshMatcher, config, fittingRadius); + yield return null; + } + if (fittingI % 2 == 0) + { + fittingRadius *= 0.97f; + } + } + fittingRadius = config.worldRadius / 2f; + for (fittingI = 0; fittingI < config.fittingExpandIteration; fittingI++) + { + foreach (ClothInstance clothInstance in this.clothInstances) + { + this.SetupProgress("Fitting", $"Phase 3 Fine-tuning [{fittingI + 1}/{config.fittingExpandIteration}] - {clothInstance.smr.transform.name}", Mathf.Lerp(0.8f, 0.9f, (float)fittingI / (float)config.fittingExpandIteration)); + yield return null; + vertexFittingUtil.ExpandClothes_World(clothInstance, this.clothInstances, meshMatcher, config, fittingRadius); + yield return null; + } + if (fittingI % 2 == 0) + { + fittingRadius *= 0.97f; + } + } + yield return null; + this.SetupProgress("Fitting", "Apply Transform Bone", 0.93f); + yield return null; + BoneAlignmentUtil boneAlignmentUtil = new BoneAlignmentUtil(); + boneAlignmentUtil.CleanupTempBones(config.targetClothesObject.transform); + MorpherMode morpherMode2 = morpherMode; + if (morpherMode2 == MorpherMode.AutoMorpher || morpherMode2 == MorpherMode.ProfileMorpher) + { + config.targetClothesObject.transform.localScale = Vector3.one; + boneAlignmentUtil.AlignClothBonesToAvatar(this.clothInstances[0], config.targetAvatarObject.GetComponent()); + } + yield return null; + this.SetupProgress("Fitting", "Apply Transform Mesh", 0.99f); + yield return null; + fittingI = 0; + while (fittingI < this.clothInstances.Count) + { + ClothInstance clothInstance = this.clothInstances[fittingI]; + this.SetupProgress("Fitting", $"Apply to Mesh [{fittingI + 1}/{this.clothInstances.Count}] - {clothInstance.smr.transform.name}", Mathf.Lerp(0.93f, 0.98f, (float)fittingI / (float)this.clothInstances.Count)); + yield return null; + clothInstance.ApplyWorldVerticesToMesh(); + clothInstance.smr.localBounds = new Bounds(Vector3.zero, Vector3.one * 2f); + EditorUtility.SetDirty(clothInstance.smr.sharedMesh); + EditorUtility.SetDirty(clothInstance.smr); + yield return null; + int num = fittingI + 1; + fittingI = num; + } + yield return null; + this.SetupProgress("Saving", "Saving Mesh Data", 0.99f); + yield return null; + this.SaveEditedMeshesToAssets(this.clothInstances, config); + yield return null; + this.SetupProgress("Finishing", "Finishing", 1f); + foreach (ClothInstance clothInstance2 in this.clothInstances) + { + clothInstance2.Dispose(); + } + this.clothInstances = null; + yield return null; + } - public IEnumerator WeightingEnumerator(EdenAutoMorpherConfig config) - { - SetupProgress("Set Up", "Setup Target Avatar Info", 0f); - yield return null; - if (new MeshMatcher().BuildBvhMulti(config.targetBodyMeshes, config.targetAvatarObject.GetComponent()) == null) - { - throw new AutoMorpherException("targetBodyBVH is Null", "[EdenAutoMorpherManater] FittingIteration\n - targetBodyBVH is null"); - } - yield return null; - List bakedTargetBodyMeshes = new List(); - foreach (SkinnedMeshRenderer bodyMesh in config.targetBodyMeshes) - { - SetupProgress("Set Up", "Setup Target Avatar BodyMesh Info", Mathf.Lerp(0.02f, 0.05f, (float)(bakedTargetBodyMeshes.Count / config.targetBodyMeshes.Count))); - yield return null; - Mesh val = new Mesh(); - bodyMesh.BakeMesh(val); - val.triangles = bodyMesh.sharedMesh.triangles; - val.boneWeights = bodyMesh.sharedMesh.boneWeights; - bakedTargetBodyMeshes.Add(val); - } - yield return null; - IEnumerator setupClothEnum = SetupClothInstances(config.targetClothesObject, config.clothesHumanoidMatchedBones, duplicateMesh: false); - while (setupClothEnum.MoveNext()) - { - yield return setupClothEnum.Current; - } - yield return null; - Dictionary clonedBoneMap = null; - if (!config.transferWeightToAvatar) - { - new EdenAutoMorpher_SetUpUtil().CreateClothesArmature(config, out clonedBoneMap); - } - yield return null; - WeightTransferUtil weightTransferUtil = new WeightTransferUtil(); - WeightTransferUtil.Settings wtSettings = new WeightTransferUtil.Settings - { - maxDistance = 0.07f, - maxNormalAngleDeg = 35f, - allowFlippedNormal = true, - enableSmoothing = true, - smoothingIterations = 4, - smoothingAlpha = 0.25f, - enforceFourBoneLimit = true, - weightInClothes = !config.transferWeightToAvatar - }; - yield return null; - int weightingI = 0; - while (weightingI < clothInstances.Count) - { - ClothInstance clothInstance = clothInstances[weightingI]; - float num = 0.1f; - float num2 = (0.95f - num) / (float)Mathf.Max(1, clothInstances.Count); - float num3 = num + num2 * (float)weightingI; - float num4 = 0.8f; - float weightingStart = num3; - float weightingEnd = num3 + num2 * num4; - float applyStart = num3 + num2 * num4; - int step = 1; - SetupProgress("Weighting", $"Weighting | Step {step} [{weightingI + 1}/{clothInstances.Count}] - {((Object)((Component)clothInstance.smr).transform).name}", weightingStart); - yield return null; - IEnumerator weightingEnum = weightTransferUtil.RetargetAndTransfer(clothInstance, config.targetAvatarObject.GetComponent(), config.targetBodyMeshes, bakedTargetBodyMeshes, 0, wtSettings, config.clothBoneTypeMap, clonedBoneMap); - while (weightingEnum.MoveNext()) - { - yield return null; - step++; - float num5 = 1f - 1f / ((float)step + 1f); - float progress = Mathf.Lerp(weightingStart, weightingEnd, num5); - SetupProgress("Weighting", $"Weighting | Step {step} [{weightingI + 1}/{clothInstances.Count}] - {((Object)((Component)clothInstance.smr).transform).name}", progress); - yield return weightingEnum.Current; - } - yield return null; - step++; - SetupProgress("Weighting", $"Weighting | Step {step} - Apply to Mesh [{weightingI + 1}/{clothInstances.Count}] - {((Object)((Component)clothInstance.smr).transform).name}", applyStart); - yield return null; - clothInstance.ApplyWorldVerticesToMesh(); - ((Renderer)clothInstance.smr).localBounds = new Bounds(Vector3.zero, Vector3.one * 2f); - EditorUtility.SetDirty((Object)(object)clothInstance.smr.sharedMesh); - EditorUtility.SetDirty((Object)(object)clothInstance.smr); - yield return null; - int num6 = weightingI + 1; - weightingI = num6; - } - SetupProgress("Weighting", "Allocate Bones", 0.95f); - yield return null; - if (config.transferWeightToAvatar && config.isReparentAccessoryBonesToTargetAvatar) - { - new BoneAlignmentUtil().ReparentAccessoryBonesToAvatar(config); - } - SetupProgress("Finishing", "Finishing", 1f); - yield return null; - foreach (ClothInstance clothInstance2 in clothInstances) - { - clothInstance2.Dispose(); - } - clothInstances = null; - yield return null; - } + public IEnumerator WeightingEnumerator(EdenAutoMorpherConfig config) + { + this.SetupProgress("Set Up", "Setup Target Avatar Info", 0f); + yield return null; + if (new MeshMatcher().BuildBvhMulti(config.targetBodyMeshes, config.targetAvatarObject.GetComponent()) == null) + { + throw new AutoMorpherException("targetBodyBVH is Null", "[EdenAutoMorpherManater] FittingIteration\n - targetBodyBVH is null"); + } + yield return null; + List bakedTargetBodyMeshes = new List(); + foreach (SkinnedMeshRenderer bodyMesh in config.targetBodyMeshes) + { + this.SetupProgress("Set Up", "Setup Target Avatar BodyMesh Info", Mathf.Lerp(0.02f, 0.05f, (float)(bakedTargetBodyMeshes.Count / config.targetBodyMeshes.Count))); + yield return null; + Mesh val = new Mesh(); + bodyMesh.BakeMesh(val); + val.triangles = bodyMesh.sharedMesh.triangles; + val.boneWeights = bodyMesh.sharedMesh.boneWeights; + bakedTargetBodyMeshes.Add(val); + } + yield return null; + IEnumerator setupClothEnum = this.SetupClothInstances(config.targetClothesObject, config.clothesHumanoidMatchedBones, duplicateMesh: false); + while (setupClothEnum.MoveNext()) + { + yield return setupClothEnum.Current; + } + yield return null; + Dictionary clonedBoneMap = null; + if (!config.transferWeightToAvatar) + { + new EdenAutoMorpher_SetUpUtil().CreateClothesArmature(config, out clonedBoneMap); + } + yield return null; + WeightTransferUtil weightTransferUtil = new WeightTransferUtil(); + WeightTransferUtil.Settings wtSettings = new WeightTransferUtil.Settings + { + maxDistance = 0.07f, + maxNormalAngleDeg = 35f, + allowFlippedNormal = true, + enableSmoothing = true, + smoothingIterations = 4, + smoothingAlpha = 0.25f, + enforceFourBoneLimit = true, + weightInClothes = !config.transferWeightToAvatar + }; + yield return null; + int weightingI = 0; + while (weightingI < this.clothInstances.Count) + { + ClothInstance clothInstance = this.clothInstances[weightingI]; + float num = 0.1f; + float num2 = (0.95f - num) / (float)Mathf.Max(1, this.clothInstances.Count); + float num3 = num + num2 * (float)weightingI; + float num4 = 0.8f; + float weightingStart = num3; + float weightingEnd = num3 + num2 * num4; + float applyStart = num3 + num2 * num4; + int step = 1; + this.SetupProgress("Weighting", $"Weighting | Step {step} [{weightingI + 1}/{this.clothInstances.Count}] - {clothInstance.smr.transform.name}", weightingStart); + yield return null; + IEnumerator weightingEnum = weightTransferUtil.RetargetAndTransfer(clothInstance, config.targetAvatarObject.GetComponent(), config.targetBodyMeshes, bakedTargetBodyMeshes, 0, wtSettings, config.clothBoneTypeMap, clonedBoneMap); + while (weightingEnum.MoveNext()) + { + yield return null; + step++; + float num5 = 1f - 1f / ((float)step + 1f); + float progress = Mathf.Lerp(weightingStart, weightingEnd, num5); + this.SetupProgress("Weighting", $"Weighting | Step {step} [{weightingI + 1}/{this.clothInstances.Count}] - {clothInstance.smr.transform.name}", progress); + yield return weightingEnum.Current; + } + yield return null; + step++; + this.SetupProgress("Weighting", $"Weighting | Step {step} - Apply to Mesh [{weightingI + 1}/{this.clothInstances.Count}] - {clothInstance.smr.transform.name}", applyStart); + yield return null; + clothInstance.ApplyWorldVerticesToMesh(); + ((Renderer)clothInstance.smr).localBounds = new Bounds(Vector3.zero, Vector3.one * 2f); + EditorUtility.SetDirty(clothInstance.smr.sharedMesh); + EditorUtility.SetDirty(clothInstance.smr); + yield return null; + int num6 = weightingI + 1; + weightingI = num6; + } + this.SetupProgress("Weighting", "Allocate Bones", 0.95f); + yield return null; + if (config.transferWeightToAvatar && config.isReparentAccessoryBonesToTargetAvatar) + { + new BoneAlignmentUtil().ReparentAccessoryBonesToAvatar(config); + } + this.SetupProgress("Finishing", "Finishing", 1f); + yield return null; + foreach (ClothInstance clothInstance2 in this.clothInstances) + { + clothInstance2.Dispose(); + } + this.clothInstances = null; + yield return null; + } - private void SaveEditedMeshesToAssets(List clothInstances, EdenAutoMorpherConfig config) - { - //IL_00ee: Unknown result type (might be due to invalid IL or missing references) - //IL_00f3: Unknown result type (might be due to invalid IL or missing references) - //IL_010b: Expected O, but got Unknown - if (clothInstances == null || clothInstances.Count == 0) - { - Debug.LogWarning((object)"[EdenAutoMorpher] 저장할 ClothInstance가 없습니다."); - throw new AutoMorpherException("Can't Save Mesh", "Therer is no ClothInstance to save mesh"); - } - if ((Object)(object)config.targetClothesObject == (Object)null || (Object)(object)config.targetAvatarObject == (Object)null) - { - Debug.LogWarning((object)"[EdenAutoMorpher] targetClothesObject 또는 targetAvatarObject 가 null 입니다. 메쉬 저장 경로를 만들 수 없습니다."); - throw new AutoMorpherException("Can't Save Mesh", "Target Clothes Object or Target Avatar Object is null.\nCan't Create Mesh Folder"); - } - string text = "Assets/@Eden_Mesh"; - if (!AssetDatabase.IsValidFolder(text)) - { - AssetDatabase.CreateFolder("Assets", "@Eden_Mesh"); - } - string text2 = SanitizeForAssetName(((Object)config.targetAvatarObject).name); - string text3 = text + "/" + text2; - if (!AssetDatabase.IsValidFolder(text3)) - { - AssetDatabase.CreateFolder(text, text2); - } - string text4 = SanitizeForAssetName(((Object)config.targetClothesObject).name); - string text5 = text3 + "/" + text4; - if (!AssetDatabase.IsValidFolder(text5)) - { - AssetDatabase.CreateFolder(text3, text4); - } - string text6 = AssetDatabase.GenerateUniqueAssetPath(text5 + "/" + text4 + "_Meshes.asset"); - int num = 0; - AssetDatabase.CreateAsset((Object)new Mesh - { - name = text4 + "_RootMesh" - }, text6); - foreach (ClothInstance clothInstance in clothInstances) - { - if (clothInstance != null && !((Object)(object)clothInstance.smr == (Object)null)) - { - Mesh sharedMesh = clothInstance.smr.sharedMesh; - if (!((Object)(object)sharedMesh == (Object)null)) - { - Mesh val = Object.Instantiate(sharedMesh); - ((Object)val).name = SanitizeForAssetName(((Object)((Component)clothInstance.smr).gameObject).name + "_EditedMesh"); - AssetDatabase.AddObjectToAsset((Object)(object)val, text6); - clothInstance.smr.sharedMesh = val; - clothInstance.editableMesh = clothInstance.smr.sharedMesh; - EditorUtility.SetDirty((Object)(object)clothInstance.smr); - EditorUtility.SetDirty((Object)(object)clothInstance.smr.sharedMesh); - EditorUtility.SetDirty((Object)(object)((Component)clothInstance.smr).gameObject); - num++; - } - } - } - AssetDatabase.SaveAssets(); - AssetDatabase.Refresh(); - Debug.Log((object)($"[EdenAutoMorpher] 편집된 메쉬 {num}개를 " + "'" + text6 + "' 에 서브 에셋으로 저장했습니다. (원본 프리팹은 변경하지 않음)")); - string SanitizeForAssetName(string rawName) - { - char[] invalidFileNameChars = Path.GetInvalidFileNameChars(); - foreach (char oldChar in invalidFileNameChars) - { - rawName = rawName.Replace(oldChar, '_'); - } - return rawName.Trim(); - } - } + private void SaveEditedMeshesToAssets(List clothInstances, EdenAutoMorpherConfig config) + { + //IL_00ee: Unknown result type (might be due to invalid IL or missing references) + //IL_00f3: Unknown result type (might be due to invalid IL or missing references) + //IL_010b: Expected O, but got Unknown + if (clothInstances == null || clothInstances.Count == 0) + { + Debug.LogWarning((object)"[EdenAutoMorpher] 저장할 ClothInstance가 없습니다."); + throw new AutoMorpherException("Can't Save Mesh", "Therer is no ClothInstance to save mesh"); + } + if (config.targetClothesObject == null || config.targetAvatarObject == null) + { + Debug.LogWarning((object)"[EdenAutoMorpher] targetClothesObject 또는 targetAvatarObject 가 null 입니다. 메쉬 저장 경로를 만들 수 없습니다."); + throw new AutoMorpherException("Can't Save Mesh", "Target Clothes Object or Target Avatar Object is null.\nCan't Create Mesh Folder"); + } + string text = "Assets/@Eden_Mesh"; + if (!AssetDatabase.IsValidFolder(text)) + { + AssetDatabase.CreateFolder("Assets", "@Eden_Mesh"); + } + string text2 = SanitizeForAssetName(config.targetAvatarObject.name); + string text3 = text + "/" + text2; + if (!AssetDatabase.IsValidFolder(text3)) + { + AssetDatabase.CreateFolder(text, text2); + } + string text4 = SanitizeForAssetName(config.targetClothesObject.name); + string text5 = text3 + "/" + text4; + if (!AssetDatabase.IsValidFolder(text5)) + { + AssetDatabase.CreateFolder(text3, text4); + } + string text6 = AssetDatabase.GenerateUniqueAssetPath(text5 + "/" + text4 + "_Meshes.asset"); + int num = 0; + AssetDatabase.CreateAsset(new Mesh + { + name = text4 + "_RootMesh" + }, text6); + foreach (ClothInstance clothInstance in clothInstances) + { + if (clothInstance != null && !(clothInstance.smr == null)) + { + Mesh sharedMesh = clothInstance.smr.sharedMesh; + if (!(sharedMesh == null)) + { + Mesh val = UnityEngine.Object.Instantiate(sharedMesh); + val.name = SanitizeForAssetName(clothInstance.smr.gameObject.name + "_EditedMesh"); + AssetDatabase.AddObjectToAsset(val, text6); + clothInstance.smr.sharedMesh = val; + clothInstance.editableMesh = clothInstance.smr.sharedMesh; + EditorUtility.SetDirty(clothInstance.smr); + EditorUtility.SetDirty(clothInstance.smr.sharedMesh); + EditorUtility.SetDirty(clothInstance.smr.gameObject); + num++; + } + } + } + AssetDatabase.SaveAssets(); + AssetDatabase.Refresh(); + Debug.Log((object)($"[EdenAutoMorpher] 편집된 메쉬 {num}개를 " + "'" + text6 + "' 에 서브 에셋으로 저장했습니다. (원본 프리팹은 변경하지 않음)")); + string SanitizeForAssetName(string rawName) + { + char[] invalidFileNameChars = Path.GetInvalidFileNameChars(); + foreach (char oldChar in invalidFileNameChars) + { + rawName = rawName.Replace(oldChar, '_'); + } + return rawName.Trim(); + } + } - public void Dispose() - { - } + public void Dispose() + { + } } diff --git a/Assets/@Eden_Tools/Eden_AutoMorpher/Script/EdenAutoMorpher_SetUpUtil.cs b/Assets/@Eden_Tools/Eden_AutoMorpher/Script/EdenAutoMorpher_SetUpUtil.cs index 6e3f70d..59308c0 100644 --- a/Assets/@Eden_Tools/Eden_AutoMorpher/Script/EdenAutoMorpher_SetUpUtil.cs +++ b/Assets/@Eden_Tools/Eden_AutoMorpher/Script/EdenAutoMorpher_SetUpUtil.cs @@ -1,708 +1,707 @@ -// Warning: Some assembly references could not be resolved automatically. This might lead to incorrect decompilation of some parts, +// 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.EdenAutoMorpher_SetUpUtil +using Eden.AutoMorpher; using System; using System.Collections.Generic; using System.Linq; using System.Reflection; using System.Text; -using Eden.AutoMorpher; -using Eden.AutoMorpher.profile; using UnityEditor; using UnityEditorInternal; using UnityEngine; public class EdenAutoMorpher_SetUpUtil { - public GameObject InstantiateTargetClothes(GameObject sourceClothesObject, GameObject targetAvatarObject, string tagEdenMorpherCloth, bool removeAutoMorphedClothes) - { - //IL_0095: Unknown result type (might be due to invalid IL or missing references) - //IL_00a5: Unknown result type (might be due to invalid IL or missing references) - //IL_00b5: Unknown result type (might be due to invalid IL or missing references) - EnsureTagExists(tagEdenMorpherCloth); - if (removeAutoMorphedClothes) - { - List list = new List(); - Transform[] componentsInChildren = targetAvatarObject.GetComponentsInChildren(true); - foreach (Transform val in componentsInChildren) - { - if (!((Object)(object)((Component)val).gameObject == (Object)(object)targetAvatarObject) && ((Component)val).CompareTag(tagEdenMorpherCloth)) - { - list.Add(((Component)val).gameObject); - } - } - foreach (GameObject item in list) - { - Object.DestroyImmediate((Object)(object)item); - } - } - GameObject obj = Object.Instantiate(sourceClothesObject, targetAvatarObject.transform); - obj.SetActive(true); - obj.transform.localPosition = Vector3.zero; - obj.transform.localRotation = Quaternion.identity; - obj.transform.localScale = Vector3.one; - obj.tag = tagEdenMorpherCloth; - return obj; - } + public GameObject InstantiateTargetClothes(GameObject sourceClothesObject, GameObject targetAvatarObject, string tagEdenMorpherCloth, bool removeAutoMorphedClothes) + { + //IL_0095: Unknown result type (might be due to invalid IL or missing references) + //IL_00a5: Unknown result type (might be due to invalid IL or missing references) + //IL_00b5: Unknown result type (might be due to invalid IL or missing references) + EnsureTagExists(tagEdenMorpherCloth); + if (removeAutoMorphedClothes) + { + List list = new List(); + Transform[] componentsInChildren = targetAvatarObject.GetComponentsInChildren(true); + foreach (Transform val in componentsInChildren) + { + if (!(val.gameObject == targetAvatarObject) && val.CompareTag(tagEdenMorpherCloth)) + { + list.Add(((Component)val).gameObject); + } + } + foreach (GameObject item in list) + { + UnityEngine.Object.DestroyImmediate(item); + } + } + GameObject obj = UnityEngine.Object.Instantiate(sourceClothesObject, targetAvatarObject.transform); + obj.SetActive(true); + obj.transform.localPosition = Vector3.zero; + obj.transform.localRotation = Quaternion.identity; + obj.transform.localScale = Vector3.one; + obj.tag = tagEdenMorpherCloth; + return obj; + } - private static void EnsureTagExists(string tag) - { - //IL_0044: Unknown result type (might be due to invalid IL or missing references) - //IL_0049: Unknown result type (might be due to invalid IL or missing references) - if (string.IsNullOrEmpty(tag)) - { - throw new AutoMorpherException("Clothes Tag is Invalid", "[EdenAutoMorpherManager] EnsureTagExists\n - tagEdenMorpherCloth is null or empty"); - } - string[] tags = InternalEditorUtility.tags; - for (int i = 0; i < tags.Length; i++) - { - if (tags[i] == tag) - { - return; - } - } - SerializedObject val = new SerializedObject(AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/TagManager.asset")[0]); - SerializedProperty obj = val.FindProperty("tags"); - int arraySize = obj.arraySize; - obj.InsertArrayElementAtIndex(arraySize); - obj.GetArrayElementAtIndex(arraySize).stringValue = tag; - val.ApplyModifiedProperties(); - } + private static void EnsureTagExists(string tag) + { + //IL_0044: Unknown result type (might be due to invalid IL or missing references) + //IL_0049: Unknown result type (might be due to invalid IL or missing references) + if (string.IsNullOrEmpty(tag)) + { + throw new AutoMorpherException("Clothes Tag is Invalid", "[EdenAutoMorpherManager] EnsureTagExists\n - tagEdenMorpherCloth is null or empty"); + } + string[] tags = InternalEditorUtility.tags; + for (int i = 0; i < tags.Length; i++) + { + if (tags[i] == tag) + { + return; + } + } + SerializedObject val = new SerializedObject(AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/TagManager.asset")[0]); + SerializedProperty obj = val.FindProperty("tags"); + int arraySize = obj.arraySize; + obj.InsertArrayElementAtIndex(arraySize); + obj.GetArrayElementAtIndex(arraySize).stringValue = tag; + val.ApplyModifiedProperties(); + } - public void AutoSetup(ref EdenAutoMorpherConfig config, out Dictionary> clothesHumanoidMatchedBones, out Dictionary clothBoneTypeMap) - { - config.targetClothesObject = InstantiateTargetClothes(config.sourceClothesObject, config.targetAvatarObject, config.tagEdenMorpehrCloth, config.isRemoveAutoMorphedClothes); - if ((Object)(object)config.targetClothesObject == (Object)null) - { - throw new AutoMorpherException("Target Clothes Object is Null", "[EdenAutoMorpher_SetUpUtil] AutoSetup\n - config.targetClothesObject is null"); - } - BoneMatchUtil boneMatchUtil = new BoneMatchUtil(); - List bodyRootLocalBones = boneMatchUtil.GetBodyRootLocalBones(config.sourceAvatarObject.transform, config.sourceAvatarObject.GetComponent(), config.sourceBodyMeshes.ToList()); - List rootLocalBones = boneMatchUtil.GetRootLocalBones(config.targetClothesObject.transform, boneMatchUtil.GetMeshBones(config.targetClothesObject.GetComponentsInChildren().ToList())); - boneMatchUtil.MatchClothesToBodyBones(bodyRootLocalBones, rootLocalBones, out clothesHumanoidMatchedBones, out clothBoneTypeMap, out var clothToBodyMatched); - Dictionary sourceToProxy; - GameObject val = new BodyPoseMatchUtil().AutoAdjustBodyPose(config.sourceAvatarObject, config.sourceBodyMeshes, config.targetAvatarObject, config.targetBodyMeshes, out sourceToProxy); - if ((Object)(object)val == (Object)null) - { - throw new AutoMorpherException(LanguageManager.Get("UI.Exception.title.BodyProxyNull"), LanguageManager.Get("UI.Exception.message.BodyProxyNull")); - } - try - { - if (clothesHumanoidMatchedBones == null || clothesHumanoidMatchedBones.Count == 0) - { - throw new AutoMorpherException("Clothes Humanoid Matched Bones is Null", "[EdenAutoMorpher_SetUpUtil] AutoSetup\n - clothesHumanoidMatchedBones is null\n - Please check whether the outfit’s bones match the bones of the source avatar."); - } - if (clothBoneTypeMap == null) - { - throw new AutoMorpherException("Cloth Bone Type Map is Null", "[EdenAutoMorpher_SetUpUtil] AutoSetup\n - clothBoneTypeMap is null\n - Please check whether the outfit’s bones match the bones of the source avatar."); - } - if (AutoMorpherDev.isDeveloperMode) - { - DebugPrintSameNameBonePaths(clothToBodyMatched, sourceToProxy); - } - new BodyPoseToClothApplier().ApplyBodyPoseToClothes(val.transform, config.targetClothesObject.transform, clothToBodyMatched, sourceToProxy); - } - finally - { - Object.DestroyImmediate((Object)(object)val); - } - } + public void AutoSetup(ref EdenAutoMorpherConfig config, out Dictionary> clothesHumanoidMatchedBones, out Dictionary clothBoneTypeMap) + { + config.targetClothesObject = this.InstantiateTargetClothes(config.sourceClothesObject, config.targetAvatarObject, config.tagEdenMorpehrCloth, config.isRemoveAutoMorphedClothes); + if (config.targetClothesObject == null) + { + throw new AutoMorpherException("Target Clothes Object is Null", "[EdenAutoMorpher_SetUpUtil] AutoSetup\n - config.targetClothesObject is null"); + } + BoneMatchUtil boneMatchUtil = new BoneMatchUtil(); + List bodyRootLocalBones = boneMatchUtil.GetBodyRootLocalBones(config.sourceAvatarObject.transform, config.sourceAvatarObject.GetComponent(), config.sourceBodyMeshes.ToList()); + List rootLocalBones = boneMatchUtil.GetRootLocalBones(config.targetClothesObject.transform, boneMatchUtil.GetMeshBones(config.targetClothesObject.GetComponentsInChildren().ToList())); + boneMatchUtil.MatchClothesToBodyBones(bodyRootLocalBones, rootLocalBones, out clothesHumanoidMatchedBones, out clothBoneTypeMap, out var clothToBodyMatched); + Dictionary sourceToProxy; + GameObject val = new BodyPoseMatchUtil().AutoAdjustBodyPose(config.sourceAvatarObject, config.sourceBodyMeshes, config.targetAvatarObject, config.targetBodyMeshes, out sourceToProxy); + if (val == null) + { + throw new AutoMorpherException(LanguageManager.Get("UI.Exception.title.BodyProxyNull"), LanguageManager.Get("UI.Exception.message.BodyProxyNull")); + } + try + { + if (clothesHumanoidMatchedBones == null || clothesHumanoidMatchedBones.Count == 0) + { + throw new AutoMorpherException("Clothes Humanoid Matched Bones is Null", "[EdenAutoMorpher_SetUpUtil] AutoSetup\n - clothesHumanoidMatchedBones is null\n - Please check whether the outfit’s bones match the bones of the source avatar."); + } + if (clothBoneTypeMap == null) + { + throw new AutoMorpherException("Cloth Bone Type Map is Null", "[EdenAutoMorpher_SetUpUtil] AutoSetup\n - clothBoneTypeMap is null\n - Please check whether the outfit’s bones match the bones of the source avatar."); + } + if (AutoMorpherDev.isDeveloperMode) + { + this.DebugPrintSameNameBonePaths(clothToBodyMatched, sourceToProxy); + } + new BodyPoseToClothApplier().ApplyBodyPoseToClothes(val.transform, config.targetClothesObject.transform, clothToBodyMatched, sourceToProxy); + } + finally + { + UnityEngine.Object.DestroyImmediate(val); + } + } - public void DebugPrintSameNameBonePaths(Dictionary clothToBodyMatched, Dictionary sourceToProxy) - { - if (clothToBodyMatched == null) - { - throw new AutoMorpherException("clothToBodyMatched is Missing", "[DebugBonePath] DebugPrintSameNameBonePaths\n - clothToBodyMatched is null"); - } - if (sourceToProxy == null) - { - throw new AutoMorpherException("sourceToProxy is Missing", "[DebugBonePath] DebugPrintSameNameBonePaths\n - sourceToProxy is null"); - } - Dictionary> dictionary = new Dictionary>(); - foreach (KeyValuePair item in sourceToProxy) - { - Transform key = item.Key; - if (!((Object)(object)key == (Object)null)) - { - if (!dictionary.TryGetValue(((Object)key).name, out var value)) - { - value = new List(); - dictionary.Add(((Object)key).name, value); - } - value.Add(key); - } - } - StringBuilder stringBuilder = new StringBuilder(); - stringBuilder.AppendLine("[DebugBonePath] Same-name bone path comparison"); - stringBuilder.AppendLine("--------------------------------------------------"); - foreach (KeyValuePair item2 in clothToBodyMatched) - { - _ = item2.Key; - Transform val = GetSourceTransform(item2.Value); - if ((Object)(object)val == (Object)null) - { - continue; - } - string name = ((Object)val).name; - if (!dictionary.TryGetValue(name, out var value2)) - { - continue; - } - stringBuilder.AppendLine("[Bone Name] " + name); - stringBuilder.AppendLine(" - BoneRootLocalData Source Path: " + GetPath(val)); - foreach (Transform item3 in value2) - { - stringBuilder.AppendLine(" - sourceToProxy Source Path : " + GetPath(item3)); - } - stringBuilder.AppendLine("--------------------------------------------------"); - } - Debug.Log((object)stringBuilder.ToString()); - string GetPath(Transform t) - { - if ((Object)(object)t == (Object)null) - { - return "(null)"; - } - StringBuilder stringBuilder2 = new StringBuilder(); - while ((Object)(object)t != (Object)null) - { - stringBuilder2.Insert(0, ((Object)t).name); - t = t.parent; - if ((Object)(object)t != (Object)null) - { - stringBuilder2.Insert(0, "/"); - } - } - return stringBuilder2.ToString(); - } - Transform GetSourceTransform(BoneMatchUtil.BoneRootLocalData data) - { - if (data == null) - { - return null; - } - FieldInfo[] fields = data.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); - foreach (FieldInfo fieldInfo in fields) - { - if (typeof(Transform).IsAssignableFrom(fieldInfo.FieldType)) - { - object value3 = fieldInfo.GetValue(data); - return (Transform)((value3 is Transform) ? value3 : null); - } - } - return null; - } - } + public void DebugPrintSameNameBonePaths(Dictionary clothToBodyMatched, Dictionary sourceToProxy) + { + if (clothToBodyMatched == null) + { + throw new AutoMorpherException("clothToBodyMatched is Missing", "[DebugBonePath] DebugPrintSameNameBonePaths\n - clothToBodyMatched is null"); + } + if (sourceToProxy == null) + { + throw new AutoMorpherException("sourceToProxy is Missing", "[DebugBonePath] DebugPrintSameNameBonePaths\n - sourceToProxy is null"); + } + Dictionary> dictionary = new Dictionary>(); + foreach (KeyValuePair item in sourceToProxy) + { + Transform key = item.Key; + if (!(key == null)) + { + if (!dictionary.TryGetValue(key.name, out var value)) + { + value = new List(); + dictionary.Add(key.name, value); + } + value.Add(key); + } + } + StringBuilder stringBuilder = new StringBuilder(); + stringBuilder.AppendLine("[DebugBonePath] Same-name bone path comparison"); + stringBuilder.AppendLine("--------------------------------------------------"); + foreach (KeyValuePair item2 in clothToBodyMatched) + { + _ = item2.Key; + Transform val = GetSourceTransform(item2.Value); + if (val == null) + { + continue; + } + string name = val.name; + if (!dictionary.TryGetValue(name, out var value2)) + { + continue; + } + stringBuilder.AppendLine("[Bone Name] " + name); + stringBuilder.AppendLine(" - BoneRootLocalData Source Path: " + GetPath(val)); + foreach (Transform item3 in value2) + { + stringBuilder.AppendLine(" - sourceToProxy Source Path : " + GetPath(item3)); + } + stringBuilder.AppendLine("--------------------------------------------------"); + } + Debug.Log(stringBuilder.ToString()); + string GetPath(Transform t) + { + if (t == null) + { + return "(null)"; + } + StringBuilder stringBuilder2 = new StringBuilder(); + while (t != null) + { + stringBuilder2.Insert(0, t.name); + t = t.parent; + if (t != null) + { + stringBuilder2.Insert(0, "/"); + } + } + return stringBuilder2.ToString(); + } + Transform GetSourceTransform(BoneMatchUtil.BoneRootLocalData data) + { + if (data == null) + { + return null; + } + FieldInfo[] fields = data.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); + foreach (FieldInfo fieldInfo in fields) + { + if (typeof(Transform).IsAssignableFrom(fieldInfo.FieldType)) + { + object value3 = fieldInfo.GetValue(data); + return (Transform)((value3 is Transform) ? value3 : null); + } + } + return null; + } + } - public void ManulSetup(ref EdenAutoMorpherConfig config, out Dictionary> clothesHumanoidMatchedBones, out Dictionary clothBoneTypeMap) - { - BoneMatchUtil boneMatchUtil = new BoneMatchUtil(); - List bodyRootLocalBones = boneMatchUtil.GetBodyRootLocalBones(config.sourceAvatarObject.transform, config.sourceAvatarObject.GetComponent(), config.sourceBodyMeshes.ToList()); - List rootLocalBones = boneMatchUtil.GetRootLocalBones(config.sourceClothesObject.transform, boneMatchUtil.GetMeshBones(config.sourceClothesObject.GetComponentsInChildren().ToList())); - boneMatchUtil.MatchClothesToBodyBones(bodyRootLocalBones, rootLocalBones, out var clothHumanBones, out var clothBoneTypeMap2, out var _); - boneMatchUtil.RemapSourceClothMatchToTargetCloth(config.sourceClothesObject.transform, config.targetClothesObject.transform, clothHumanBones, clothBoneTypeMap2, out clothesHumanoidMatchedBones, out clothBoneTypeMap); - if (clothesHumanoidMatchedBones == null || clothesHumanoidMatchedBones.Count == 0) - { - throw new AutoMorpherException("Clothes Humanoid Matched Bones is Null", "[EdenAutoMorpher_SetUpUtil] ManulSetup\n - clothesHumanoidMatchedBones is null\n - Please check whether the Source Clothes’s bones match the bones of the source avatar."); - } - if (clothBoneTypeMap == null) - { - throw new AutoMorpherException("Cloth Bone Type Map is Null", "[EdenAutoMorpher_SetUpUtil] ManulSetup\n - clothBoneTypeMap is null\n - Please check whether the Source Clothes’s bones match the bones of the source avatar."); - } - MeshClassifier meshClassifier = new MeshClassifier(); - Dictionary> humanBoneMap = meshClassifier.MeshHumanoidBoneMatcher(config.sourceAvatarObject.GetComponent(), config.sourceBodyMeshes); - Dictionary> humanBoneMap2 = meshClassifier.MeshHumanoidBoneMatcher(config.targetAvatarObject.GetComponent(), config.sourceBodyMeshes); - BodyPoseMatchSetupUtil bodyPoseMatchSetupUtil = new BodyPoseMatchSetupUtil(); - bodyPoseMatchSetupUtil.AdjustAvatarScaleByNeck(config.sourceAvatarObject.transform, humanBoneMap, 1.5f); - bodyPoseMatchSetupUtil.AdjustAvatarScaleByNeck(config.targetAvatarObject.transform, humanBoneMap2, 1.5f); - } + public void ManulSetup(ref EdenAutoMorpherConfig config, out Dictionary> clothesHumanoidMatchedBones, out Dictionary clothBoneTypeMap) + { + BoneMatchUtil boneMatchUtil = new BoneMatchUtil(); + List bodyRootLocalBones = boneMatchUtil.GetBodyRootLocalBones(config.sourceAvatarObject.transform, config.sourceAvatarObject.GetComponent(), config.sourceBodyMeshes.ToList()); + List rootLocalBones = boneMatchUtil.GetRootLocalBones(config.sourceClothesObject.transform, boneMatchUtil.GetMeshBones(config.sourceClothesObject.GetComponentsInChildren().ToList())); + boneMatchUtil.MatchClothesToBodyBones(bodyRootLocalBones, rootLocalBones, out var clothHumanBones, out var clothBoneTypeMap2, out var _); + boneMatchUtil.RemapSourceClothMatchToTargetCloth(config.sourceClothesObject.transform, config.targetClothesObject.transform, clothHumanBones, clothBoneTypeMap2, out clothesHumanoidMatchedBones, out clothBoneTypeMap); + if (clothesHumanoidMatchedBones == null || clothesHumanoidMatchedBones.Count == 0) + { + throw new AutoMorpherException("Clothes Humanoid Matched Bones is Null", "[EdenAutoMorpher_SetUpUtil] ManulSetup\n - clothesHumanoidMatchedBones is null\n - Please check whether the Source Clothes’s bones match the bones of the source avatar."); + } + if (clothBoneTypeMap == null) + { + throw new AutoMorpherException("Cloth Bone Type Map is Null", "[EdenAutoMorpher_SetUpUtil] ManulSetup\n - clothBoneTypeMap is null\n - Please check whether the Source Clothes’s bones match the bones of the source avatar."); + } + MeshClassifier meshClassifier = new MeshClassifier(); + Dictionary> humanBoneMap = meshClassifier.MeshHumanoidBoneMatcher(config.sourceAvatarObject.GetComponent(), config.sourceBodyMeshes); + Dictionary> humanBoneMap2 = meshClassifier.MeshHumanoidBoneMatcher(config.targetAvatarObject.GetComponent(), config.sourceBodyMeshes); + BodyPoseMatchSetupUtil bodyPoseMatchSetupUtil = new BodyPoseMatchSetupUtil(); + bodyPoseMatchSetupUtil.AdjustAvatarScaleByNeck(config.sourceAvatarObject.transform, humanBoneMap, 1.5f); + bodyPoseMatchSetupUtil.AdjustAvatarScaleByNeck(config.targetAvatarObject.transform, humanBoneMap2, 1.5f); + } - public void ProfileAutoSetup(ref EdenAutoMorpherConfig config, out Dictionary> clothesHumanoidMatchedBones, out Dictionary clothBoneTypeMap) - { - config.targetClothesObject = InstantiateTargetClothes(config.sourceClothesObject, config.targetAvatarObject, config.tagEdenMorpehrCloth, config.isRemoveAutoMorphedClothes); - if ((Object)(object)config.targetClothesObject == (Object)null) - { - throw new AutoMorpherException("Target Clothes Object is Null", "[EdenAutoMorpher_SetUpUtil] ProfileAutoSetup\n - config.targetClothesObject is null"); - } - ProfileData val = new ProfileLoader().LoadProfileData(config.profileName); - if (val == null) - { - throw new AutoMorpherException("Clothes Humanoid Matched Bones is Null", "[EdenAutoMorpher_SetUpUtil] ProfileAutoSetup\n - profile Data is null"); - } - BoneMatchUtil boneMatchUtil = new BoneMatchUtil(); - List bodyBones = boneMatchUtil.ConvertProfileBoneDataToRootLocalData(val.bones); - List rootLocalBones = boneMatchUtil.GetRootLocalBones(config.targetClothesObject.transform, boneMatchUtil.GetMeshBones(config.targetClothesObject.GetComponentsInChildren().ToList())); - boneMatchUtil.MatchClothesToBodyBones(bodyBones, rootLocalBones, out clothesHumanoidMatchedBones, out clothBoneTypeMap, out var _); - if (clothesHumanoidMatchedBones == null || clothesHumanoidMatchedBones.Count == 0) - { - throw new AutoMorpherException("Cloth Body Bones is Null", "[EdenAutoMorpher_SetUpUtil] ProfileAutoSetup\n - clothesHumanoidMatchedBones is null\n - Please check whether you have selected the correct profile for the outfit."); - } - if (clothBoneTypeMap == null) - { - throw new AutoMorpherException("Cloth Bone Type Map is Null", "[EdenAutoMorpher_SetUpUtil] ProfileAutoSetup\n - clothBoneTypeMap is null\n - Please check whether you have selected the correct profile for the outfit."); - } - new ProfilePoseMatchUtil().ProfilePoseMatcher(config.targetAvatarObject, config.targetBodyMeshes, config.targetClothesObject, val, clothesHumanoidMatchedBones, clothBoneTypeMap); - } + public void ProfileAutoSetup(ref EdenAutoMorpherConfig config, out Dictionary> clothesHumanoidMatchedBones, out Dictionary clothBoneTypeMap) + { + config.targetClothesObject = this.InstantiateTargetClothes(config.sourceClothesObject, config.targetAvatarObject, config.tagEdenMorpehrCloth, config.isRemoveAutoMorphedClothes); + if (config.targetClothesObject == null) + { + throw new AutoMorpherException("Target Clothes Object is Null", "[EdenAutoMorpher_SetUpUtil] ProfileAutoSetup\n - config.targetClothesObject is null"); + } + ProfileData val = new ProfileLoader().LoadProfileData(config.profileName); + if (val == null) + { + throw new AutoMorpherException("Clothes Humanoid Matched Bones is Null", "[EdenAutoMorpher_SetUpUtil] ProfileAutoSetup\n - profile Data is null"); + } + BoneMatchUtil boneMatchUtil = new BoneMatchUtil(); + List bodyBones = boneMatchUtil.ConvertProfileBoneDataToRootLocalData(val.bones); + List rootLocalBones = boneMatchUtil.GetRootLocalBones(config.targetClothesObject.transform, boneMatchUtil.GetMeshBones(config.targetClothesObject.GetComponentsInChildren().ToList())); + boneMatchUtil.MatchClothesToBodyBones(bodyBones, rootLocalBones, out clothesHumanoidMatchedBones, out clothBoneTypeMap, out var _); + if (clothesHumanoidMatchedBones == null || clothesHumanoidMatchedBones.Count == 0) + { + throw new AutoMorpherException("Cloth Body Bones is Null", "[EdenAutoMorpher_SetUpUtil] ProfileAutoSetup\n - clothesHumanoidMatchedBones is null\n - Please check whether you have selected the correct profile for the outfit."); + } + if (clothBoneTypeMap == null) + { + throw new AutoMorpherException("Cloth Bone Type Map is Null", "[EdenAutoMorpher_SetUpUtil] ProfileAutoSetup\n - clothBoneTypeMap is null\n - Please check whether you have selected the correct profile for the outfit."); + } + new ProfilePoseMatchUtil().ProfilePoseMatcher(config.targetAvatarObject, config.targetBodyMeshes, config.targetClothesObject, val, clothesHumanoidMatchedBones, clothBoneTypeMap); + } - public List SetupBodyMeshes(GameObject bodyObject, bool isBodyAutoSetup, List userAllocatedBoeyMeshes, string errorPreFix = "") - { - new EdenAutoMorpherManager(); - List list = (isBodyAutoSetup ? GetBodyMeshes(bodyObject) : userAllocatedBoeyMeshes); - if (list == null) - { - throw new AutoMorpherException(errorPreFix + "Body Mesh Is Null or Empty", errorPreFix + "Body Mesh list is null or empty"); - } - foreach (SkinnedMeshRenderer item in list) - { - if ((Object)(object)item == (Object)null) - { - throw new AutoMorpherException(errorPreFix + "Body Mesh Is Null", "Null Mesh in " + errorPreFix + " Body Meshes"); - } - } - return list; - } + public List SetupBodyMeshes(GameObject bodyObject, bool isBodyAutoSetup, List userAllocatedBoeyMeshes, string errorPreFix = "") + { + new EdenAutoMorpherManager(); + List list = (isBodyAutoSetup ? this.GetBodyMeshes(bodyObject) : userAllocatedBoeyMeshes); + if (list == null) + { + throw new AutoMorpherException(errorPreFix + "Body Mesh Is Null or Empty", errorPreFix + "Body Mesh list is null or empty"); + } + foreach (SkinnedMeshRenderer item in list) + { + if (item == null) + { + throw new AutoMorpherException(errorPreFix + "Body Mesh Is Null", "Null Mesh in " + errorPreFix + " Body Meshes"); + } + } + return list; + } - public List GetBodyMeshes(GameObject avatarObject) - { - MeshClassifier meshClassifier = new MeshClassifier(); - List list = new List(); - Animator component = avatarObject.GetComponent(); - if ((Object)(object)component != (Object)null && (Object)(object)component.avatar != (Object)null && component.avatar.isHuman) - { - list.Add(meshClassifier.GetBodyMesh(avatarObject.transform, component)); - { - foreach (SkinnedMeshRenderer item in list) - { - if ((Object)(object)item == (Object)null) - { - throw new AutoMorpherException(LanguageManager.Get("UI.Exception.title.BodyMeshNull"), LanguageManager.GetFormat("UI.Exception.message.BodyMeshNull", new object[1] { ((Object)avatarObject).name })); - } - } - return list; - } - } - throw new AutoMorpherException(LanguageManager.Get("UI.Exception.title.BodyMeshNull"), LanguageManager.GetFormat("UI.Exception.message.BodyMeshNull", new object[1] { ((Object)avatarObject).name })); - } + public List GetBodyMeshes(GameObject avatarObject) + { + MeshClassifier meshClassifier = new MeshClassifier(); + List list = new List(); + Animator component = avatarObject.GetComponent(); + if (component != null && component.avatar != null && component.avatar.isHuman) + { + list.Add(meshClassifier.GetBodyMesh(avatarObject.transform, component)); + { + foreach (SkinnedMeshRenderer item in list) + { + if (item == null) + { + throw new AutoMorpherException(LanguageManager.Get("UI.Exception.title.BodyMeshNull"), LanguageManager.GetFormat("UI.Exception.message.BodyMeshNull", new object[1] { avatarObject.name })); + } + } + return list; + } + } + throw new AutoMorpherException(LanguageManager.Get("UI.Exception.title.BodyMeshNull"), LanguageManager.GetFormat("UI.Exception.message.BodyMeshNull", new object[1] { avatarObject.name })); + } - public ClothInstance SetupClothInstance(SkinnedMeshRenderer clothSMR, Dictionary> clothesHumanoidMatchedBones, bool duplicateMesh) - { - ClothHumanoidMaskUtil clothHumanoidMaskUtil = new ClothHumanoidMaskUtil(); - if ((Object)(object)clothSMR == (Object)null || (Object)(object)clothSMR.sharedMesh == (Object)null) - { - throw new AutoMorpherException(LanguageManager.Get("UI.Exception.title.TargetRendererNull"), LanguageManager.Get("UI.Exception.message.TargetRendererNull")); - } - ClothInstance clothInstance = new ClothInstance(clothSMR, duplicateMesh); - clothInstance.humanoidMatchedBones = clothesHumanoidMatchedBones; - clothHumanoidMaskUtil.BuildExcludedVertexMaskForHandsAndHead(clothInstance); - return clothInstance; - } + public ClothInstance SetupClothInstance(SkinnedMeshRenderer clothSMR, Dictionary> clothesHumanoidMatchedBones, bool duplicateMesh) + { + ClothHumanoidMaskUtil clothHumanoidMaskUtil = new ClothHumanoidMaskUtil(); + if (clothSMR == null || clothSMR.sharedMesh == null) + { + throw new AutoMorpherException(LanguageManager.Get("UI.Exception.title.TargetRendererNull"), LanguageManager.Get("UI.Exception.message.TargetRendererNull")); + } + ClothInstance clothInstance = new ClothInstance(clothSMR, duplicateMesh); + clothInstance.humanoidMatchedBones = clothesHumanoidMatchedBones; + clothHumanoidMaskUtil.BuildExcludedVertexMaskForHandsAndHead(clothInstance); + return clothInstance; + } - public ClothInstance SetupClothInstance(SkinnedMeshRenderer clothSMR, SkinnedMeshRenderer coupledSMR, MeshMatcher meshMatcher, Dictionary> clothesHumanoidMatchedBones, bool duplicateMesh) - { - if ((Object)(object)coupledSMR == (Object)null) - { - throw new AutoMorpherException("Coupled Skinned Mesh Renderer is Null", "[EdenAutoMorpher_SetupUtil] SetupClothInstance\n\n - Coupled Skinned Mesh Renderer is null"); - } - if ((Object)(object)coupledSMR.sharedMesh == (Object)null || coupledSMR.sharedMesh.vertexCount == 0) - { - throw new AutoMorpherException("Coupled Skinned Mesh Renderer's Mesh is Null or empty", "[EdenAutoMorpher_SetupUtil] SetupClothInstance\n\n - Coupled Skinned Mesh Renderer's mesh is null or no vertices"); - } - ClothInstance clothInstance = SetupClothInstance(clothSMR, clothesHumanoidMatchedBones, duplicateMesh); - if (clothInstance == null) - { - return null; - } - Vector3[] worldVertices = new WorldVertexUtil().GetWorldVertices(coupledSMR); - clothInstance.minDistanceVector = meshMatcher.GetMinDistanceToBody(worldVertices); - if (clothInstance.minDistanceVector == null || clothInstance.minDistanceVector.Length == 0) - { - throw new AutoMorpherException("Min Distance is Null", "[EdenAutoMorpher_SetupUtil] SetupClothInstance\n - minDistanceVector is null or empty"); - } - if (clothInstance.minDistanceVector != null) - { - clothInstance.minDistance = clothInstance.minDistanceVector.Select((Vector3 v) => ((Vector3)(ref v)).magnitude).ToArray(); - } - clothInstance.isInsideVertex = meshMatcher.GetBodyInsideFlags(worldVertices); - if (clothInstance.isInsideVertex == null || clothInstance.isInsideVertex.Length == 0) - { - throw new AutoMorpherException("isInsideVertex is Null", "[EdenAutoMorpher_SetupUtil] SetupClothInstance\n - isInsideVertex is null or empty"); - } - return clothInstance; - } + public ClothInstance SetupClothInstance(SkinnedMeshRenderer clothSMR, SkinnedMeshRenderer coupledSMR, MeshMatcher meshMatcher, Dictionary> clothesHumanoidMatchedBones, bool duplicateMesh) + { + if (coupledSMR == null) + { + throw new AutoMorpherException("Coupled Skinned Mesh Renderer is Null", "[EdenAutoMorpher_SetupUtil] SetupClothInstance\n\n - Coupled Skinned Mesh Renderer is null"); + } + if (coupledSMR.sharedMesh == null || coupledSMR.sharedMesh.vertexCount == 0) + { + throw new AutoMorpherException("Coupled Skinned Mesh Renderer's Mesh is Null or empty", "[EdenAutoMorpher_SetupUtil] SetupClothInstance\n\n - Coupled Skinned Mesh Renderer's mesh is null or no vertices"); + } + ClothInstance clothInstance = this.SetupClothInstance(clothSMR, clothesHumanoidMatchedBones, duplicateMesh); + if (clothInstance == null) + { + return null; + } + Vector3[] worldVertices = new WorldVertexUtil().GetWorldVertices(coupledSMR); + clothInstance.minDistanceVector = meshMatcher.GetMinDistanceToBody(worldVertices); + if (clothInstance.minDistanceVector == null || clothInstance.minDistanceVector.Length == 0) + { + throw new AutoMorpherException("Min Distance is Null", "[EdenAutoMorpher_SetupUtil] SetupClothInstance\n - minDistanceVector is null or empty"); + } + if (clothInstance.minDistanceVector != null) + { + clothInstance.minDistance = clothInstance.minDistanceVector.Select((Vector3 v) => v.magnitude).ToArray(); + } + clothInstance.isInsideVertex = meshMatcher.GetBodyInsideFlags(worldVertices); + if (clothInstance.isInsideVertex == null || clothInstance.isInsideVertex.Length == 0) + { + throw new AutoMorpherException("isInsideVertex is Null", "[EdenAutoMorpher_SetupUtil] SetupClothInstance\n - isInsideVertex is null or empty"); + } + return clothInstance; + } - public Transform CreateClothesArmature(EdenAutoMorpherConfig config, out Dictionary clonedBoneMap) - { - //IL_00df: Unknown result type (might be due to invalid IL or missing references) - //IL_00f3: Unknown result type (might be due to invalid IL or missing references) - //IL_00fe: Unknown result type (might be due to invalid IL or missing references) - //IL_0109: Unknown result type (might be due to invalid IL or missing references) - //IL_0170: Unknown result type (might be due to invalid IL or missing references) - //IL_0175: Unknown result type (might be due to invalid IL or missing references) - //IL_0194: Unknown result type (might be due to invalid IL or missing references) - //IL_04d2: Unknown result type (might be due to invalid IL or missing references) - //IL_04eb: Unknown result type (might be due to invalid IL or missing references) - //IL_04f9: Unknown result type (might be due to invalid IL or missing references) - //IL_051d: Unknown result type (might be due to invalid IL or missing references) - //IL_050f: Unknown result type (might be due to invalid IL or missing references) - //IL_0491: Unknown result type (might be due to invalid IL or missing references) - //IL_0403: 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_042a: Unknown result type (might be due to invalid IL or missing references) - //IL_0436: Unknown result type (might be due to invalid IL or missing references) - //IL_0464: Unknown result type (might be due to invalid IL or missing references) - //IL_0470: 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_04b1: Unknown result type (might be due to invalid IL or missing references) - clonedBoneMap = null; - if ((Object)(object)config.targetClothesObject == (Object)null) - { - throw new AutoMorpherException("Target Clothes Object is Missing", "[EdenAutoMorpherManager] CreateClothesArmature\n - config.targetClothesObject is null"); - } - if ((Object)(object)config.targetAvatarObject == (Object)null) - { - throw new AutoMorpherException("Target Avatar Object is Missing", "[EdenAutoMorpherManager] CreateClothesArmature\n - config.targetAvatarObject is null"); - } - Animator component = config.targetAvatarObject.GetComponent(); - if ((Object)(object)component == (Object)null || !component.isHuman) - { - throw new AutoMorpherException("Target Avatar Animator is Invalid", "[EdenAutoMorpherManager] CreateClothesArmature\n - targetAvatarAnimator is null or not a Humanoid"); - } - Transform boneTransform = component.GetBoneTransform((HumanBodyBones)0); - if ((Object)(object)boneTransform == (Object)null) - { - throw new AutoMorpherException("Humanoid Root Bone is Missing", "[EdenAutoMorpherManager] CreateClothesArmature\n - Animator.GetBoneTransform(HumanBodyBones.Hips) returned null"); - } - if (config.targetBodyMeshes == null || config.targetBodyMeshes.Count == 0) - { - throw new AutoMorpherException("Target Body Meshes are Missing", "[EdenAutoMorpherManager] CreateClothesArmature\n - config.targetBodyMeshes is null or empty"); - } - Transform transform = config.targetClothesObject.transform; - Transform val = FindArmature(config, config.targetClothesObject.transform); - if ((Object)(object)val == (Object)null) - { - val = new GameObject("Armature.1").transform; - val.SetParent(transform, false); - val.localPosition = Vector3.zero; - val.localRotation = Quaternion.identity; - val.localScale = Vector3.one; - } - if (((Object)val).name == "Armature") - { - ((Object)val).name = "Armature.1"; - } - Dictionary dictionary = new Dictionary(); - if (config.clothesHumanoidMatchedBones != null && config.clothesHumanoidMatchedBones.Count > 0) - { - foreach (KeyValuePair> clothesHumanoidMatchedBone in config.clothesHumanoidMatchedBones) - { - HumanBodyBones key = clothesHumanoidMatchedBone.Key; - HashSet value = clothesHumanoidMatchedBone.Value; - if (value == null || value.Count == 0) - { - continue; - } - Transform boneTransform2 = component.GetBoneTransform(key); - if ((Object)(object)boneTransform2 == (Object)null) - { - continue; - } - Transform val2 = null; - int num = int.MaxValue; - foreach (Transform item in value) - { - if (!((Object)(object)item == (Object)null)) - { - int num2 = 0; - Transform val3 = item; - while ((Object)(object)val3 != (Object)null) - { - num2++; - val3 = val3.parent; - } - if (num2 < num) - { - num = num2; - val2 = item; - } - else if (num2 == num && (Object)(object)val2 != (Object)null && string.Compare(((Object)item).name, ((Object)val2).name, StringComparison.Ordinal) < 0) - { - val2 = item; - } - } - } - if (!((Object)(object)val2 == (Object)null) && !dictionary.ContainsKey(boneTransform2)) - { - dictionary.Add(boneTransform2, val2); - } - } - } - MeshClassifier meshClassifier = new MeshClassifier(); - HashSet hashSet = new HashSet(); - for (int i = 0; i < config.targetBodyMeshes.Count; i++) - { - SkinnedMeshRenderer val4 = config.targetBodyMeshes[i]; - if ((Object)(object)val4 == (Object)null) - { - continue; - } - HashSet activeBones = meshClassifier.GetActiveBones(val4); - if (activeBones == null) - { - continue; - } - foreach (Transform item2 in activeBones) - { - if ((Object)(object)item2 != (Object)null) - { - hashSet.Add(item2); - } - } - } - HashSet hashSet2 = new HashSet(hashSet); - foreach (Transform item3 in hashSet) - { - if ((Object)(object)item3 == (Object)null) - { - continue; - } - Transform val5 = item3; - while ((Object)(object)val5 != (Object)null) - { - hashSet2.Add(val5); - if ((Object)(object)val5 == (Object)(object)boneTransform) - { - break; - } - val5 = val5.parent; - } - } - Dictionary dictionary2 = new Dictionary(hashSet2.Count); - Dictionary dictionary3 = new Dictionary(hashSet2.Count); - foreach (Transform item4 in hashSet2) - { - if ((Object)(object)item4 == (Object)null) - { - continue; - } - Transform val6 = null; - Transform val7 = null; - if (dictionary.TryGetValue(item4, out var value2) && (Object)(object)value2 != (Object)null) - { - val6 = value2; - if (config.addAnchorBone) - { - val7 = new GameObject(((Object)item4).name).transform; - val7.SetParent(val, false); - val7.position = item4.position; - val7.rotation = item4.rotation; - val7.localScale = Vector3.one; - val6.SetParent(val7, true); - ((Object)val6).name = ((Object)item4).name + "_clothes"; - val6.localPosition = Vector3.zero; - val6.localScale = Vector3.one; - } - else - { - ((Object)val6).name = ((Object)item4).name; - val6.position = item4.position; - ChildBonePositionPreserve(val6, item4); - if (config.armatureBoneScaleCopy) - { - val6.localScale = item4.localScale; - } - else - { - val6.localScale = Vector3.one; - } - } - } - else - { - val6 = new GameObject(((Object)item4).name).transform; - val6.SetParent(val, false); - val6.position = item4.position; - val6.rotation = item4.rotation; - if (config.armatureBoneScaleCopy) - { - val6.localScale = item4.localScale; - } - else - { - val6.localScale = Vector3.one; - } - } - if (!((Object)(object)val6 == (Object)null)) - { - dictionary2[item4] = val6; - dictionary3[item4] = (((Object)(object)val7 != (Object)null) ? val7 : val6); - } - } - foreach (Transform item5 in hashSet2) - { - if ((Object)(object)item5 == (Object)null) - { - continue; - } - if (!dictionary2.TryGetValue(item5, out var value3) || (Object)(object)value3 == (Object)null) - { - throw new AutoMorpherException("Mapped Clothes Bone is Missing", "[EdenAutoMorpherManager] CreateClothesArmature\n - clonedByOriginal does not contain originalBone or mappedClothesBone is null\n - originalBone: " + ((Object)item5).name); - } - if (!dictionary3.TryGetValue(item5, out var value4) || (Object)(object)value4 == (Object)null) - { - throw new AutoMorpherException("Mapped Anchor Bone is Missing", "[EdenAutoMorpherManager] CreateClothesArmature\n - parentAnchorByOriginal does not contain originalBone or mappedAnchorBone is null\n - originalBone: " + ((Object)item5).name); - } - if ((Object)(object)item5 == (Object)(object)boneTransform) - { - value4.SetParent(val, true); - continue; - } - Transform parent = item5.parent; - Transform value5; - if ((Object)(object)parent == (Object)null) - { - value4.SetParent(val, true); - } - else if (dictionary3.TryGetValue(parent, out value5) && (Object)(object)value5 != (Object)null) - { - value4.SetParent(value5, true); - } - else - { - value4.SetParent(val, true); - } - } - if (!dictionary3.TryGetValue(boneTransform, out var value6) || (Object)(object)value6 == (Object)null) - { - throw new AutoMorpherException("Cloned Humanoid Root Bone is Missing", "[EdenAutoMorpherManager] CreateClothesArmature\n - failed to map clone for HumanBodyBones.Hips"); - } - value6.SetParent(val, true); - clonedBoneMap = dictionary2; - return val; - } + public Transform CreateClothesArmature(EdenAutoMorpherConfig config, out Dictionary clonedBoneMap) + { + //IL_00df: Unknown result type (might be due to invalid IL or missing references) + //IL_00f3: Unknown result type (might be due to invalid IL or missing references) + //IL_00fe: Unknown result type (might be due to invalid IL or missing references) + //IL_0109: Unknown result type (might be due to invalid IL or missing references) + //IL_0170: Unknown result type (might be due to invalid IL or missing references) + //IL_0175: Unknown result type (might be due to invalid IL or missing references) + //IL_0194: Unknown result type (might be due to invalid IL or missing references) + //IL_04d2: Unknown result type (might be due to invalid IL or missing references) + //IL_04eb: Unknown result type (might be due to invalid IL or missing references) + //IL_04f9: Unknown result type (might be due to invalid IL or missing references) + //IL_051d: Unknown result type (might be due to invalid IL or missing references) + //IL_050f: Unknown result type (might be due to invalid IL or missing references) + //IL_0491: Unknown result type (might be due to invalid IL or missing references) + //IL_0403: 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_042a: Unknown result type (might be due to invalid IL or missing references) + //IL_0436: Unknown result type (might be due to invalid IL or missing references) + //IL_0464: Unknown result type (might be due to invalid IL or missing references) + //IL_0470: 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_04b1: Unknown result type (might be due to invalid IL or missing references) + clonedBoneMap = null; + if (config.targetClothesObject == null) + { + throw new AutoMorpherException("Target Clothes Object is Missing", "[EdenAutoMorpherManager] CreateClothesArmature\n - config.targetClothesObject is null"); + } + if (config.targetAvatarObject == null) + { + throw new AutoMorpherException("Target Avatar Object is Missing", "[EdenAutoMorpherManager] CreateClothesArmature\n - config.targetAvatarObject is null"); + } + Animator component = config.targetAvatarObject.GetComponent(); + if (component == null || !component.isHuman) + { + throw new AutoMorpherException("Target Avatar Animator is Invalid", "[EdenAutoMorpherManager] CreateClothesArmature\n - targetAvatarAnimator is null or not a Humanoid"); + } + Transform boneTransform = component.GetBoneTransform((HumanBodyBones)0); + if (boneTransform == null) + { + throw new AutoMorpherException("Humanoid Root Bone is Missing", "[EdenAutoMorpherManager] CreateClothesArmature\n - Animator.GetBoneTransform(HumanBodyBones.Hips) returned null"); + } + if (config.targetBodyMeshes == null || config.targetBodyMeshes.Count == 0) + { + throw new AutoMorpherException("Target Body Meshes are Missing", "[EdenAutoMorpherManager] CreateClothesArmature\n - config.targetBodyMeshes is null or empty"); + } + Transform transform = config.targetClothesObject.transform; + Transform val = this.FindArmature(config, config.targetClothesObject.transform); + if (val == null) + { + val = new GameObject("Armature.1").transform; + val.SetParent(transform, false); + val.localPosition = Vector3.zero; + val.localRotation = Quaternion.identity; + val.localScale = Vector3.one; + } + if (val.name == "Armature") + { + val.name = "Armature.1"; + } + Dictionary dictionary = new Dictionary(); + if (config.clothesHumanoidMatchedBones != null && config.clothesHumanoidMatchedBones.Count > 0) + { + foreach (KeyValuePair> clothesHumanoidMatchedBone in config.clothesHumanoidMatchedBones) + { + HumanBodyBones key = clothesHumanoidMatchedBone.Key; + HashSet value = clothesHumanoidMatchedBone.Value; + if (value == null || value.Count == 0) + { + continue; + } + Transform boneTransform2 = component.GetBoneTransform(key); + if (boneTransform2 == null) + { + continue; + } + Transform val2 = null; + int num = int.MaxValue; + foreach (Transform item in value) + { + if (!(item == null)) + { + int num2 = 0; + Transform val3 = item; + while (val3 != null) + { + num2++; + val3 = val3.parent; + } + if (num2 < num) + { + num = num2; + val2 = item; + } + else if (num2 == num && val2 != null && string.Compare(item.name, val2.name, StringComparison.Ordinal) < 0) + { + val2 = item; + } + } + } + if (!(val2 == null) && !dictionary.ContainsKey(boneTransform2)) + { + dictionary.Add(boneTransform2, val2); + } + } + } + MeshClassifier meshClassifier = new MeshClassifier(); + HashSet hashSet = new HashSet(); + for (int i = 0; i < config.targetBodyMeshes.Count; i++) + { + SkinnedMeshRenderer val4 = config.targetBodyMeshes[i]; + if (val4 == null) + { + continue; + } + HashSet activeBones = meshClassifier.GetActiveBones(val4); + if (activeBones == null) + { + continue; + } + foreach (Transform item2 in activeBones) + { + if (item2 != null) + { + hashSet.Add(item2); + } + } + } + HashSet hashSet2 = new HashSet(hashSet); + foreach (Transform item3 in hashSet) + { + if (item3 == null) + { + continue; + } + Transform val5 = item3; + while (val5 != null) + { + hashSet2.Add(val5); + if (val5 == (object)boneTransform) + { + break; + } + val5 = val5.parent; + } + } + Dictionary dictionary2 = new Dictionary(hashSet2.Count); + Dictionary dictionary3 = new Dictionary(hashSet2.Count); + foreach (Transform item4 in hashSet2) + { + if (item4 == null) + { + continue; + } + Transform val6 = null; + Transform val7 = null; + if (dictionary.TryGetValue(item4, out var value2) && value2 != null) + { + val6 = value2; + if (config.addAnchorBone) + { + val7 = new GameObject(item4.name).transform; + val7.SetParent(val, false); + val7.position = item4.position; + val7.rotation = item4.rotation; + val7.localScale = Vector3.one; + val6.SetParent(val7, true); + val6.name = item4.name + "_clothes"; + val6.localPosition = Vector3.zero; + val6.localScale = Vector3.one; + } + else + { + val6.name = item4.name; + val6.position = item4.position; + this.ChildBonePositionPreserve(val6, item4); + if (config.armatureBoneScaleCopy) + { + val6.localScale = item4.localScale; + } + else + { + val6.localScale = Vector3.one; + } + } + } + else + { + val6 = new GameObject(item4.name).transform; + val6.SetParent(val, false); + val6.position = item4.position; + val6.rotation = item4.rotation; + if (config.armatureBoneScaleCopy) + { + val6.localScale = item4.localScale; + } + else + { + val6.localScale = Vector3.one; + } + } + if (!(val6 == null)) + { + dictionary2[item4] = val6; + dictionary3[item4] = ((val7 != null) ? val7 : val6); + } + } + foreach (Transform item5 in hashSet2) + { + if (item5 == null) + { + continue; + } + if (!dictionary2.TryGetValue(item5, out var value3) || value3 == null) + { + throw new AutoMorpherException("Mapped Clothes Bone is Missing", "[EdenAutoMorpherManager] CreateClothesArmature\n - clonedByOriginal does not contain originalBone or mappedClothesBone is null\n - originalBone: " + item5.name); + } + if (!dictionary3.TryGetValue(item5, out var value4) || value4 == null) + { + throw new AutoMorpherException("Mapped Anchor Bone is Missing", "[EdenAutoMorpherManager] CreateClothesArmature\n - parentAnchorByOriginal does not contain originalBone or mappedAnchorBone is null\n - originalBone: " + item5.name); + } + if (item5 == (object)boneTransform) + { + value4.SetParent(val, true); + continue; + } + Transform parent = item5.parent; + Transform value5; + if (parent == null) + { + value4.SetParent(val, true); + } + else if (dictionary3.TryGetValue(parent, out value5) && value5 != null) + { + value4.SetParent(value5, true); + } + else + { + value4.SetParent(val, true); + } + } + if (!dictionary3.TryGetValue(boneTransform, out var value6) || value6 == null) + { + throw new AutoMorpherException("Cloned Humanoid Root Bone is Missing", "[EdenAutoMorpherManager] CreateClothesArmature\n - failed to map clone for HumanBodyBones.Hips"); + } + value6.SetParent(val, true); + clonedBoneMap = dictionary2; + return val; + } - private Transform FindArmature(EdenAutoMorpherConfig config, Transform clothesRoot) - { - if ((Object)(object)clothesRoot == (Object)null) - { - throw new AutoMorpherException("Armature Root Resolve Failed", "[EdenAutoMorpherManager] FindSingleArmatureRootFromHumanoidMatchedBones\n - config is null or clothesRoot is null"); - } - if (config.clothesHumanoidMatchedBones == null || config.clothesHumanoidMatchedBones.Count == 0) - { - return null; - } - Transform val = null; - bool flag = false; - foreach (KeyValuePair> clothesHumanoidMatchedBone in config.clothesHumanoidMatchedBones) - { - HashSet value = clothesHumanoidMatchedBone.Value; - if (value == null || value.Count == 0) - { - continue; - } - foreach (Transform item in value) - { - if (!((Object)(object)item == (Object)null) && (!((Object)(object)item != (Object)(object)clothesRoot) || item.IsChildOf(clothesRoot))) - { - flag = true; - Transform topChildUnderRoot = GetTopChildUnderRoot(item, clothesRoot); - if ((Object)(object)topChildUnderRoot == (Object)null || (Object)(object)topChildUnderRoot == (Object)(object)clothesRoot) - { - return null; - } - if ((Object)(object)val == (Object)null) - { - val = topChildUnderRoot; - } - else if ((Object)(object)val != (Object)(object)topChildUnderRoot) - { - return null; - } - } - } - } - if (!flag) - { - return null; - } - if ((Object)(object)val == (Object)null || (Object)(object)val == (Object)(object)clothesRoot) - { - return null; - } - return val; - } + private Transform FindArmature(EdenAutoMorpherConfig config, Transform clothesRoot) + { + if (clothesRoot == null) + { + throw new AutoMorpherException("Armature Root Resolve Failed", "[EdenAutoMorpherManager] FindSingleArmatureRootFromHumanoidMatchedBones\n - config is null or clothesRoot is null"); + } + if (config.clothesHumanoidMatchedBones == null || config.clothesHumanoidMatchedBones.Count == 0) + { + return null; + } + Transform val = null; + bool flag = false; + foreach (KeyValuePair> clothesHumanoidMatchedBone in config.clothesHumanoidMatchedBones) + { + HashSet value = clothesHumanoidMatchedBone.Value; + if (value == null || value.Count == 0) + { + continue; + } + foreach (Transform item in value) + { + if (!(item == null) && (!(item != clothesRoot) || item.IsChildOf(clothesRoot))) + { + flag = true; + Transform topChildUnderRoot = this.GetTopChildUnderRoot(item, clothesRoot); + if (topChildUnderRoot == null || topChildUnderRoot == clothesRoot) + { + return null; + } + if (val == null) + { + val = topChildUnderRoot; + } + else if (val != topChildUnderRoot) + { + return null; + } + } + } + } + if (!flag) + { + return null; + } + if (val == null || val == clothesRoot) + { + return null; + } + return val; + } - private Transform GetTopChildUnderRoot(Transform bone, Transform clothesRoot) - { - if ((Object)(object)bone == (Object)null || (Object)(object)clothesRoot == (Object)null) - { - return null; - } - if ((Object)(object)bone == (Object)(object)clothesRoot) - { - return clothesRoot; - } - Transform val = bone; - while ((Object)(object)val.parent != (Object)null && (Object)(object)val.parent != (Object)(object)clothesRoot) - { - val = val.parent; - } - if ((Object)(object)val.parent == (Object)(object)clothesRoot) - { - return val; - } - return clothesRoot; - } + private Transform GetTopChildUnderRoot(Transform bone, Transform clothesRoot) + { + if (bone == null || clothesRoot == null) + { + return null; + } + if (bone == clothesRoot) + { + return clothesRoot; + } + Transform val = bone; + while (val.parent != null && val.parent != clothesRoot) + { + val = val.parent; + } + if (val.parent == clothesRoot) + { + return val; + } + return clothesRoot; + } - private void ChildBonePositionPreserve(Transform reusableClothBone, Transform referenceAvatarBone) - { - //IL_0073: Unknown result type (might be due to invalid IL or missing references) - //IL_0080: Unknown result type (might be due to invalid IL or missing references) - //IL_009c: Unknown result type (might be due to invalid IL or missing references) - //IL_00b6: Unknown result type (might be due to invalid IL or missing references) - //IL_00be: Unknown result type (might be due to invalid IL or missing references) - if ((Object)(object)reusableClothBone == (Object)null || (Object)(object)referenceAvatarBone == (Object)null) - { - throw new AutoMorpherException("Reusable Bone Sync Failed", "[EdenAutoMorpherManager] SyncReusableBoneRotationPreserveChildrenWorld\n - reusableClothBone or referenceAvatarBone is null"); - } - List list = new List(); - List list2 = new List(); - List list3 = new List(); - for (int i = 0; i < reusableClothBone.childCount; i++) - { - Transform child = reusableClothBone.GetChild(i); - if (!((Object)(object)child == (Object)null)) - { - CollectDescendants(child, list); - } - } - for (int j = 0; j < list.Count; j++) - { - Transform val = list[j]; - list2.Add(val.position); - list3.Add(val.rotation); - } - reusableClothBone.localRotation = referenceAvatarBone.localRotation; - for (int k = 0; k < list.Count; k++) - { - list[k].SetPositionAndRotation(list2[k], list3[k]); - } - } + private void ChildBonePositionPreserve(Transform reusableClothBone, Transform referenceAvatarBone) + { + //IL_0073: Unknown result type (might be due to invalid IL or missing references) + //IL_0080: Unknown result type (might be due to invalid IL or missing references) + //IL_009c: Unknown result type (might be due to invalid IL or missing references) + //IL_00b6: Unknown result type (might be due to invalid IL or missing references) + //IL_00be: Unknown result type (might be due to invalid IL or missing references) + if (reusableClothBone == null || referenceAvatarBone == null) + { + throw new AutoMorpherException("Reusable Bone Sync Failed", "[EdenAutoMorpherManager] SyncReusableBoneRotationPreserveChildrenWorld\n - reusableClothBone or referenceAvatarBone is null"); + } + List list = new List(); + List list2 = new List(); + List list3 = new List(); + for (int i = 0; i < reusableClothBone.childCount; i++) + { + Transform child = reusableClothBone.GetChild(i); + if (!(child == null)) + { + this.CollectDescendants(child, list); + } + } + for (int j = 0; j < list.Count; j++) + { + Transform val = list[j]; + list2.Add(val.position); + list3.Add(val.rotation); + } + reusableClothBone.localRotation = referenceAvatarBone.localRotation; + for (int k = 0; k < list.Count; k++) + { + list[k].SetPositionAndRotation(list2[k], list3[k]); + } + } - private void CollectDescendants(Transform root, List resultList) - { - if ((Object)(object)root == (Object)null) - { - return; - } - resultList.Add(root); - for (int i = 0; i < root.childCount; i++) - { - Transform child = root.GetChild(i); - if (!((Object)(object)child == (Object)null)) - { - CollectDescendants(child, resultList); - } - } - } + private void CollectDescendants(Transform root, List resultList) + { + if (root == null) + { + return; + } + resultList.Add(root); + for (int i = 0; i < root.childCount; i++) + { + Transform child = root.GetChild(i); + if (!(child == null)) + { + this.CollectDescendants(child, resultList); + } + } + } } diff --git a/Assets/@Eden_Tools/Eden_AutoMorpher/Script/MeshClassifier.cs b/Assets/@Eden_Tools/Eden_AutoMorpher/Script/MeshClassifier.cs index dee28bf..c49ebc4 100644 --- a/Assets/@Eden_Tools/Eden_AutoMorpher/Script/MeshClassifier.cs +++ b/Assets/@Eden_Tools/Eden_AutoMorpher/Script/MeshClassifier.cs @@ -1,277 +1,306 @@ -// Warning: Some assembly references could not be resolved automatically. This might lead to incorrect decompilation of some parts, +// 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.MeshClassifier using System; using System.Collections.Generic; -using System.Runtime.CompilerServices; -using Eden.AutoMorpher; using UnityEngine; public class MeshClassifier { - private HumanBodyBones[] bodyBones; + private HumanBodyBones[] bodyBones; - private HumanBodyBones[] headBones; + private HumanBodyBones[] headBones; - public SkinnedMeshRenderer GetBodyMesh(Transform root, Animator animator) - { - List list = HumanBodyBonesTrsnforms(bodyBones, animator); - if (list.Count != bodyBones.Length) - { - if (AutoMorpherDev.isDeveloperMode) - { - Debug.LogWarning((object)"[Body Mesh] Animator Bone is not enough"); - } - return null; - } - return GetBoneMatchedMesh(root, list); - } + public SkinnedMeshRenderer GetBodyMesh(Transform root, Animator animator) + { + List list = this.HumanBodyBonesTrsnforms(this.bodyBones, animator); + if (list.Count != this.bodyBones.Length) + { + if (AutoMorpherDev.isDeveloperMode) + { + Debug.LogWarning("[Body Mesh] Animator Bone is not enough"); + } + return null; + } + return this.GetBoneMatchedMesh(root, list); + } - public SkinnedMeshRenderer GetHeadMesh(Transform root, Animator animator) - { - List list = HumanBodyBonesTrsnforms(headBones, animator); - if (list.Count != headBones.Length) - { - return null; - } - return GetBoneMatchedMesh(root, list); - } + public SkinnedMeshRenderer GetHeadMesh(Transform root, Animator animator) + { + List list = this.HumanBodyBonesTrsnforms(this.headBones, animator); + if (list.Count != this.headBones.Length) + { + return null; + } + return this.GetBoneMatchedMesh(root, list); + } - private List HumanBodyBonesTrsnforms(HumanBodyBones[] humanBonesList, Animator animator) - { - //IL_0015: Unknown result type (might be due to invalid IL or missing references) - //IL_0018: Unknown result type (might be due to invalid IL or missing references) - //IL_002c: Unknown result type (might be due to invalid IL or missing references) - List list = new List(); - List list2 = new List(); - foreach (HumanBodyBones val in humanBonesList) - { - Transform boneTransform = animator.GetBoneTransform(val); - if ((Object)(object)boneTransform == (Object)null) - { - list2.Add(val); - } - else - { - list.Add(boneTransform); - } - } - if (list2.Count > 0) - { - string text = string.Join(", ", list2); - throw new AutoMorpherException("[Body Mesh Finding] Required Humanoid Bones are Missing", "[BodyMeshUtil] HumanBodyBonesTrsnforms\n - Missing Humanoid Bones: [" + text + "]\n - Animator Humanoid mapping may be broken\n - Please check whether the missing humanoid bones are correctly assigned in [Animator → Avatar → Configure]."); - } - return list; - } + private List HumanBodyBonesTrsnforms(HumanBodyBones[] humanBonesList, Animator animator) + { + //IL_0015: Unknown result type (might be due to invalid IL or missing references) + //IL_0018: Unknown result type (might be due to invalid IL or missing references) + //IL_002c: Unknown result type (might be due to invalid IL or missing references) + List list = new List(); + List list2 = new List(); + foreach (HumanBodyBones val in humanBonesList) + { + Transform boneTransform = animator.GetBoneTransform(val); + if (boneTransform == null) + { + list2.Add(val); + } + else + { + list.Add(boneTransform); + } + } + if (list2.Count > 0) + { + string text = string.Join(", ", list2); + throw new AutoMorpherException("[Body Mesh Finding] Required Humanoid Bones are Missing", "[BodyMeshUtil] HumanBodyBonesTrsnforms\n - Missing Humanoid Bones: [" + text + "]\n - Animator Humanoid mapping may be broken\n - Please check whether the missing humanoid bones are correctly assigned in [Animator → Avatar → Configure]."); + } + return list; + } - private SkinnedMeshRenderer GetBoneMatchedMesh(Transform root, List humanBoneTransforms) - { - SkinnedMeshRenderer[] componentsInChildren = ((Component)root).GetComponentsInChildren(false); - foreach (SkinnedMeshRenderer val in componentsInChildren) - { - bool flag = true; - HashSet activeBones = GetActiveBones(val); - if (AutoMorpherDev.isDeveloperMode) - { - Debug.Log((object)$"[Body Mesh] {((Object)((Component)val).gameObject).name} have bone Set {activeBones.Count}"); - } - foreach (Transform humanBoneTransform in humanBoneTransforms) - { - if (!activeBones.Contains(humanBoneTransform) && !BoneExistsByPosition(humanBoneTransform, activeBones)) - { - flag = false; - if (AutoMorpherDev.isDeveloperMode) - { - Debug.Log((object)("[Body Mesh] " + ((Object)((Component)val).gameObject).name + " Doesn't hav bone " + ((Object)humanBoneTransform).name)); - } - break; - } - } - if (flag) - { - return val; - } - } - return null; - } + private SkinnedMeshRenderer GetBoneMatchedMesh(Transform root, List humanBoneTransforms) + { + SkinnedMeshRenderer[] componentsInChildren = ((Component)root).GetComponentsInChildren(false); + foreach (SkinnedMeshRenderer val in componentsInChildren) + { + bool flag = true; + HashSet activeBones = this.GetActiveBones(val); + if (AutoMorpherDev.isDeveloperMode) + { + Debug.Log($"[Body Mesh] {val.gameObject.name} have bone Set {activeBones.Count}"); + } + foreach (Transform humanBoneTransform in humanBoneTransforms) + { + if (!activeBones.Contains(humanBoneTransform) && !this.BoneExistsByPosition(humanBoneTransform, activeBones)) + { + flag = false; + if (AutoMorpherDev.isDeveloperMode) + { + Debug.Log(("[Body Mesh] " + val.gameObject.name + " Doesn't hav bone " + humanBoneTransform.name)); + } + break; + } + } + if (flag) + { + return val; + } + } + return null; + } - private bool BoneExistsByPosition(Transform boneToCheck, HashSet smrBoneSet, float posTolerance = 0.0001f) - { - //IL_0010: Unknown result type (might be due to invalid IL or missing references) - //IL_0016: Unknown result type (might be due to invalid IL or missing references) - //IL_001b: Unknown result type (might be due to invalid IL or missing references) - //IL_0020: Unknown result type (might be due to invalid IL or missing references) - foreach (Transform item in smrBoneSet) - { - Vector3 val = item.position - boneToCheck.position; - if (((Vector3)(ref val)).sqrMagnitude <= posTolerance * posTolerance) - { - return true; - } - } - return false; - } + private bool BoneExistsByPosition(Transform boneToCheck, HashSet smrBoneSet, float posTolerance = 0.0001f) + { + //IL_0010: Unknown result type (might be due to invalid IL or missing references) + //IL_0016: Unknown result type (might be due to invalid IL or missing references) + //IL_001b: Unknown result type (might be due to invalid IL or missing references) + //IL_0020: Unknown result type (might be due to invalid IL or missing references) + foreach (Transform item in smrBoneSet) + { + Vector3 val = item.position - boneToCheck.position; + if (val.sqrMagnitude <= posTolerance * posTolerance) + { + return true; + } + } + return false; + } - public HashSet GetActiveBones(SkinnedMeshRenderer smr, float weightThreshold = 0.0001f) - { - //IL_003e: Unknown result type (might be due to invalid IL or missing references) - //IL_0043: Unknown result type (might be due to invalid IL or missing references) - Mesh sharedMesh = smr.sharedMesh; - if ((Object)(object)sharedMesh == (Object)null) - { - Debug.LogWarning((object)"SkinnedMeshRenderer에 연결된 Mesh가 없습니다."); - return new HashSet(); - } - Transform[] bones = smr.bones; - BoneWeight[] boneWeights = sharedMesh.boneWeights; - HashSet hashSet = new HashSet(); - BoneWeight[] array = boneWeights; - for (int i = 0; i < array.Length; i++) - { - BoneWeight val = array[i]; - if (((BoneWeight)(ref val)).weight0 > weightThreshold) - { - hashSet.Add(((BoneWeight)(ref val)).boneIndex0); - } - if (((BoneWeight)(ref val)).weight1 > weightThreshold) - { - hashSet.Add(((BoneWeight)(ref val)).boneIndex1); - } - if (((BoneWeight)(ref val)).weight2 > weightThreshold) - { - hashSet.Add(((BoneWeight)(ref val)).boneIndex2); - } - if (((BoneWeight)(ref val)).weight3 > weightThreshold) - { - hashSet.Add(((BoneWeight)(ref val)).boneIndex3); - } - } - HashSet hashSet2 = new HashSet(); - foreach (int item in hashSet) - { - if (item >= 0 && item < bones.Length) - { - hashSet2.Add(bones[item]); - } - } - return hashSet2; - } + public HashSet GetActiveBones(SkinnedMeshRenderer smr, float weightThreshold = 0.0001f) + { + //IL_003e: Unknown result type (might be due to invalid IL or missing references) + //IL_0043: Unknown result type (might be due to invalid IL or missing references) + Mesh sharedMesh = smr.sharedMesh; + if (sharedMesh == null) + { + Debug.LogWarning("SkinnedMeshRenderer에 연결된 Mesh가 없습니다."); + return new HashSet(); + } + Transform[] bones = smr.bones; + BoneWeight[] boneWeights = sharedMesh.boneWeights; + HashSet hashSet = new HashSet(); + BoneWeight[] array = boneWeights; + for (int i = 0; i < array.Length; i++) + { + BoneWeight val = array[i]; + if (val.weight0 > weightThreshold) + { + hashSet.Add(val.boneIndex0); + } + if (val.weight1 > weightThreshold) + { + hashSet.Add(val.boneIndex1); + } + if (val.weight2 > weightThreshold) + { + hashSet.Add(val.boneIndex2); + } + if (val.weight3 > weightThreshold) + { + hashSet.Add(val.boneIndex3); + } + } + HashSet hashSet2 = new HashSet(); + foreach (int item in hashSet) + { + if (item >= 0 && item < bones.Length) + { + hashSet2.Add(bones[item]); + } + } + return hashSet2; + } - public Dictionary> MeshHumanoidBoneMatcher(Animator animator, IReadOnlyList bodyMeshes, float posTolerance = 0.0001f, float weightThreshold = 0.0001f) - { - //IL_00a3: Unknown result type (might be due to invalid IL or missing references) - //IL_00a6: Unknown result type (might be due to invalid IL or missing references) - //IL_010a: Unknown result type (might be due to invalid IL or missing references) - Dictionary> dictionary = new Dictionary>(); - if ((Object)(object)animator == (Object)null) - { - throw new AutoMorpherException("Animator is Missing", "[MeshHumanoidBoneMatcher] MeshHumanoidBoneMatcher\n - animator is null"); - } - HashSet hashSet = new HashSet(); - if (bodyMeshes != null) - { - foreach (SkinnedMeshRenderer bodyMesh in bodyMeshes) - { - if ((Object)(object)bodyMesh == (Object)null) - { - continue; - } - foreach (Transform activeBone in GetActiveBones(bodyMesh, weightThreshold)) - { - if ((Object)(object)activeBone != (Object)null) - { - hashSet.Add(activeBone); - } - } - } - } - for (int i = 0; i < 55; i++) - { - HumanBodyBones val = (HumanBodyBones)i; - Transform boneTransform = animator.GetBoneTransform(val); - if ((Object)(object)boneTransform == (Object)null) - { - continue; - } - HashSet hashSet2 = new HashSet(); - hashSet2.Add(boneTransform); - foreach (Transform item in FindBonesByPosition(boneTransform, hashSet, posTolerance)) - { - hashSet2.Add(item); - } - dictionary[val] = hashSet2; - } - return dictionary; - } + public Dictionary> MeshHumanoidBoneMatcher(Animator animator, IReadOnlyList bodyMeshes, float posTolerance = 0.0001f, float weightThreshold = 0.0001f) + { + //IL_00a3: Unknown result type (might be due to invalid IL or missing references) + //IL_00a6: Unknown result type (might be due to invalid IL or missing references) + //IL_010a: Unknown result type (might be due to invalid IL or missing references) + Dictionary> dictionary = new Dictionary>(); + if (animator == null) + { + throw new AutoMorpherException("Animator is Missing", "[MeshHumanoidBoneMatcher] MeshHumanoidBoneMatcher\n - animator is null"); + } + HashSet hashSet = new HashSet(); + if (bodyMeshes != null) + { + foreach (SkinnedMeshRenderer bodyMesh in bodyMeshes) + { + if (bodyMesh == null) + { + continue; + } + foreach (Transform activeBone in this.GetActiveBones(bodyMesh, weightThreshold)) + { + if (activeBone != null) + { + hashSet.Add(activeBone); + } + } + } + } + for (int i = 0; i < 55; i++) + { + HumanBodyBones val = (HumanBodyBones)i; + Transform boneTransform = animator.GetBoneTransform(val); + if (boneTransform == null) + { + continue; + } + HashSet hashSet2 = new HashSet(); + hashSet2.Add(boneTransform); + foreach (Transform item in this.FindBonesByPosition(boneTransform, hashSet, posTolerance)) + { + hashSet2.Add(item); + } + dictionary[val] = hashSet2; + } + return dictionary; + } - private List FindBonesByPosition(Transform boneToCheck, HashSet smrBoneSet, float posTolerance = 0.0001f) - { - //IL_0016: Unknown result type (might be due to invalid IL or missing references) - //IL_001b: Unknown result type (might be due to invalid IL or missing references) - //IL_0063: Unknown result type (might be due to invalid IL or missing references) - //IL_0068: Unknown result type (might be due to invalid IL or missing references) - //IL_0069: Unknown result type (might be due to invalid IL or missing references) - //IL_006e: Unknown result type (might be due to invalid IL or missing references) - List list = new List(); - if ((Object)(object)boneToCheck == (Object)null) - { - return list; - } - float num = posTolerance * posTolerance; - Vector3 position = boneToCheck.position; - foreach (Transform item in smrBoneSet) - { - if (!((Object)(object)item == (Object)null) && !((Object)(object)item == (Object)(object)boneToCheck) && NameMatches(((Object)((Component)item).gameObject).name, ((Object)((Component)boneToCheck).gameObject).name)) - { - Vector3 val = item.position - position; - if (((Vector3)(ref val)).sqrMagnitude <= num) - { - list.Add(item); - } - } - } - return list; - } + private List FindBonesByPosition(Transform boneToCheck, HashSet smrBoneSet, float posTolerance = 0.0001f) + { + //IL_0016: Unknown result type (might be due to invalid IL or missing references) + //IL_001b: Unknown result type (might be due to invalid IL or missing references) + //IL_0063: Unknown result type (might be due to invalid IL or missing references) + //IL_0068: Unknown result type (might be due to invalid IL or missing references) + //IL_0069: Unknown result type (might be due to invalid IL or missing references) + //IL_006e: Unknown result type (might be due to invalid IL or missing references) + List list = new List(); + if (boneToCheck == null) + { + return list; + } + float num = posTolerance * posTolerance; + Vector3 position = boneToCheck.position; + foreach (Transform item in smrBoneSet) + { + if (!(item == null) && !(item == boneToCheck) && this.NameMatches((((Component)item).gameObject).name, (((Component)boneToCheck).gameObject).name)) + { + Vector3 val = item.position - position; + if (val.sqrMagnitude <= num) + { + list.Add(item); + } + } + } + return list; + } - private string[] TokenizeBoneName(string name) - { - if (string.IsNullOrWhiteSpace(name)) - { - return Array.Empty(); - } - char[] separator = new char[5] { '-', '_', ':', '.', '|' }; - name = name.Trim(); - return name.Split(separator, StringSplitOptions.RemoveEmptyEntries); - } + private string[] TokenizeBoneName(string name) + { + if (string.IsNullOrWhiteSpace(name)) + { + return Array.Empty(); + } + char[] separator = new char[5] { '-', '_', ':', '.', '|' }; + name = name.Trim(); + return name.Split(separator, StringSplitOptions.RemoveEmptyEntries); + } - private bool NameMatches(string boneToCheckName, string candidateName) - { - string[] array = TokenizeBoneName(boneToCheckName); - string[] array2 = TokenizeBoneName(candidateName); - if (array.Length == 0 || array2.Length == 0) - { - return false; - } - if (!array[0].Equals(array2[0], StringComparison.OrdinalIgnoreCase)) - { - return false; - } - if (array.Length > 1 && array2.Length > 1 && !array[1].Equals(array2[1], StringComparison.OrdinalIgnoreCase)) - { - return false; - } - return true; - } + private bool NameMatches(string boneToCheckName, string candidateName) + { + string[] array = this.TokenizeBoneName(boneToCheckName); + string[] array2 = this.TokenizeBoneName(candidateName); + if (array.Length == 0 || array2.Length == 0) + { + return false; + } + if (!array[0].Equals(array2[0], StringComparison.OrdinalIgnoreCase)) + { + return false; + } + if (array.Length > 1 && array2.Length > 1 && !array[1].Equals(array2[1], StringComparison.OrdinalIgnoreCase)) + { + return false; + } + return true; + } - public MeshClassifier() - { - HumanBodyBones[] array = new HumanBodyBones[28]; - RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/); - bodyBones = (HumanBodyBones[])(object)array; - HumanBodyBones[] array2 = new HumanBodyBones[3]; - RuntimeHelpers.InitializeArray(array2, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/); - headBones = (HumanBodyBones[])(object)array2; - base._002Ector(); - } + public MeshClassifier() + { + this.bodyBones = new HumanBodyBones[28] + { + HumanBodyBones.Hips, + HumanBodyBones.Spine, + HumanBodyBones.Chest, + HumanBodyBones.Neck, + HumanBodyBones.LeftShoulder, + HumanBodyBones.LeftUpperArm, + HumanBodyBones.LeftLowerArm, + HumanBodyBones.LeftHand, + HumanBodyBones.LeftThumbProximal, + HumanBodyBones.LeftIndexProximal, + HumanBodyBones.LeftMiddleProximal, + HumanBodyBones.LeftRingProximal, + HumanBodyBones.LeftLittleProximal, + HumanBodyBones.RightShoulder, + HumanBodyBones.RightUpperArm, + HumanBodyBones.RightLowerArm, + HumanBodyBones.RightHand, + HumanBodyBones.RightThumbProximal, + HumanBodyBones.RightIndexProximal, + HumanBodyBones.RightMiddleProximal, + HumanBodyBones.RightRingProximal, + HumanBodyBones.RightLittleProximal, + HumanBodyBones.LeftUpperLeg, + HumanBodyBones.LeftLowerLeg, + HumanBodyBones.LeftFoot, + HumanBodyBones.RightUpperLeg, + HumanBodyBones.RightLowerLeg, + HumanBodyBones.RightFoot + }; + + this.headBones = new HumanBodyBones[3] + { + HumanBodyBones.Head, + HumanBodyBones.LeftEye, + HumanBodyBones.RightEye + }; + } } diff --git a/Assets/@Eden_Tools/Eden_AutoMorpher/Script/MeshMatcher.cs b/Assets/@Eden_Tools/Eden_AutoMorpher/Script/MeshMatcher.cs index 819d61e..0355af1 100644 --- a/Assets/@Eden_Tools/Eden_AutoMorpher/Script/MeshMatcher.cs +++ b/Assets/@Eden_Tools/Eden_AutoMorpher/Script/MeshMatcher.cs @@ -1,351 +1,351 @@ -// Warning: Some assembly references could not be resolved automatically. This might lead to incorrect decompilation of some parts, +// 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.MeshMatcher -using System.Collections.Generic; using Eden.AutoMorpher; +using System.Collections.Generic; using UnityEngine; public class MeshMatcher { - public struct ClosestHit - { - public Vector3 closestP; + public struct ClosestHit + { + public Vector3 closestP; - public Vector3 direction; + public Vector3 direction; - public Vector3 moveVector; + public Vector3 moveVector; - public float distance; - } + public float distance; + } - public BvhTriangleMesh bodyBVH; + public BvhTriangleMesh bodyBVH; - private readonly HashSet LeftLegBones = new HashSet - { - (HumanBodyBones)1, - (HumanBodyBones)3, - (HumanBodyBones)5, - (HumanBodyBones)19 - }; + private readonly HashSet LeftLegBones = new HashSet + { + (HumanBodyBones)1, + (HumanBodyBones)3, + (HumanBodyBones)5, + (HumanBodyBones)19 + }; - private readonly HashSet RightLegBones = new HashSet - { - (HumanBodyBones)2, - (HumanBodyBones)4, - (HumanBodyBones)6, - (HumanBodyBones)20 - }; + private readonly HashSet RightLegBones = new HashSet + { + (HumanBodyBones)2, + (HumanBodyBones)4, + (HumanBodyBones)6, + (HumanBodyBones)20 + }; - public BvhTriangleMesh BuildBvhMulti(IReadOnlyList bodies, Animator bodyAnimator) - { - if (bodies == null || bodies.Count == 0) - { - throw new AutoMorpherException("Body Meshes are Missing", "[BuildBvhMulti] BuildBvhMulti\n - bodies is null or empty"); - } - BvhTriangleMesh bvhTriangleMesh = new BvhTriangleMesh().BuildFromSkinnedMeshes(bodies, bodyAnimator); - if (bvhTriangleMesh == null || bvhTriangleMesh.triangles == null) - { - Debug.LogError((object)"Failed to build multi-body BVH (no triangles)."); - throw new AutoMorpherException(LanguageManager.Get("UI.Exception.title.BodyBVHFail"), LanguageManager.GetFormat("UI.Exception.message.BodyBVHFail", new object[3] - { - ((Object)((Component)bodyAnimator).gameObject).name, - bvhTriangleMesh == null, - bvhTriangleMesh.triangles == null - })); - } - return bvhTriangleMesh; - } + public BvhTriangleMesh BuildBvhMulti(IReadOnlyList bodies, Animator bodyAnimator) + { + if (bodies == null || bodies.Count == 0) + { + throw new AutoMorpherException("Body Meshes are Missing", "[BuildBvhMulti] BuildBvhMulti\n - bodies is null or empty"); + } + BvhTriangleMesh bvhTriangleMesh = new BvhTriangleMesh().BuildFromSkinnedMeshes(bodies, bodyAnimator); + if (bvhTriangleMesh == null || bvhTriangleMesh.triangles == null) + { + Debug.LogError((object)"Failed to build multi-body BVH (no triangles)."); + throw new AutoMorpherException(LanguageManager.Get("UI.Exception.title.BodyBVHFail"), LanguageManager.GetFormat("UI.Exception.message.BodyBVHFail", new object[3] + { + ((Object)((Component)bodyAnimator).gameObject).name, + bvhTriangleMesh == null, + bvhTriangleMesh.triangles == null + })); + } + return bvhTriangleMesh; + } - public Vector3[] ExpandVertexMatch(ClothInstance clothInstance, float defaultMinDist = 0.005f, bool skipFootFitting = false, float maxMatchDistance = 0.1f) - { - //IL_008d: Unknown result type (might be due to invalid IL or missing references) - //IL_0092: Unknown result type (might be due to invalid IL or missing references) - //IL_00aa: Unknown result type (might be due to invalid IL or missing references) - //IL_00af: Unknown result type (might be due to invalid IL or missing references) - //IL_00d5: 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_00fd: Unknown result type (might be due to invalid IL or missing references) - //IL_012b: Unknown result type (might be due to invalid IL or missing references) - //IL_0131: Invalid comparison between Unknown and I4 - //IL_0183: Unknown result type (might be due to invalid IL or missing references) - //IL_018b: Unknown result type (might be due to invalid IL or missing references) - //IL_0190: Unknown result type (might be due to invalid IL or missing references) - //IL_0195: Unknown result type (might be due to invalid IL or missing references) - //IL_0199: Unknown result type (might be due to invalid IL or missing references) - //IL_019e: Unknown result type (might be due to invalid IL or missing references) - //IL_01a0: 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_0172: Unknown result type (might be due to invalid IL or missing references) - //IL_0177: Unknown result type (might be due to invalid IL or missing references) - //IL_0156: Unknown result type (might be due to invalid IL or missing references) - //IL_015b: 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_013b: Invalid comparison between Unknown and I4 - //IL_01c3: Unknown result type (might be due to invalid IL or missing references) - //IL_01c8: Unknown result type (might be due to invalid IL or missing references) - //IL_01cc: Unknown result type (might be due to invalid IL or missing references) - //IL_01d1: 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_01de: Unknown result type (might be due to invalid IL or missing references) - //IL_01e3: Unknown result type (might be due to invalid IL or missing references) - //IL_013f: Unknown result type (might be due to invalid IL or missing references) - //IL_0146: Invalid comparison between Unknown and I4 - //IL_0230: Unknown result type (might be due to invalid IL or missing references) - //IL_0235: Unknown result type (might be due to invalid IL or missing references) - //IL_014a: Unknown result type (might be due to invalid IL or missing references) - //IL_0151: Invalid comparison between Unknown and I4 - //IL_0206: Unknown result type (might be due to invalid IL or missing references) - //IL_020b: Unknown result type (might be due to invalid IL or missing references) - //IL_020f: Unknown result type (might be due to invalid IL or missing references) - //IL_0214: Unknown result type (might be due to invalid IL or missing references) - //IL_021c: Unknown result type (might be due to invalid IL or missing references) - //IL_0221: Unknown result type (might be due to invalid IL or missing references) - //IL_0226: Unknown result type (might be due to invalid IL or missing references) - Vector3[] worldVertices = clothInstance.worldVertices; - float[] minDistance = clothInstance.minDistance; - if (bodyBVH == null) - { - throw new AutoMorpherException("Body BVH is Missing", "[ExpandVertexMatch] ExpandVertexMatch\n - bodyBVH is null"); - } - if (worldVertices == null) - { - throw new AutoMorpherException("Cloth World Vertices are Missing", "[ExpandVertexMatch] ExpandVertexMatch\n - clothInstance.worldVertices is null"); - } - if (worldVertices.Length == 0) - { - Debug.LogWarning((object)"clothes mesh has no vertices"); - return null; - } - if (minDistance == null) - { - Debug.LogWarning((object)"minDists is null"); - } - if (minDistance.Length != worldVertices.Length) - { - Debug.LogWarning((object)"minDists.Length != worldVertexs.Length"); - } - Vector3[] array = (Vector3[])(object)new Vector3[worldVertices.Length]; - float num = maxMatchDistance * maxMatchDistance; - for (int i = 0; i < worldVertices.Length; i++) - { - if (clothInstance.excludedVertices[i]) - { - array[i] = Vector3.zero; - continue; - } - if (clothInstance.isInsideVertex[i]) - { - array[i] = Vector3.zero; - continue; - } - float num2 = minDistance[i] + defaultMinDist; - BvhTriangleMesh.ClosestHit closestHit = (clothInstance.isLeftLegVertex[i] ? bodyBVH.QueryClosest(worldVertices[i], LeftLegBones) : ((!clothInstance.isRightLegVertex[i]) ? bodyBVH.QueryClosest(worldVertices[i]) : bodyBVH.QueryClosest(worldVertices[i], RightLegBones))); - if (skipFootFitting && ((int)closestHit.mainHumanBone == 5 || (int)closestHit.mainHumanBone == 6 || (int)closestHit.mainHumanBone == 20 || (int)closestHit.mainHumanBone == 19)) - { - array[i] = Vector3.zero; - continue; - } - if (closestHit.sqrDistance > num) - { - array[i] = Vector3.zero; - continue; - } - Vector3 val = closestHit.closestPoint - worldVertices[i]; - Vector3 normalized = ((Vector3)(ref val)).normalized; - float num3 = Vector3.Dot(normalized, ((Vector3)(ref closestHit.normal)).normalized); - if (num3 > 0.7f) - { - array[i] = closestHit.closestPoint + normalized * num2 - worldVertices[i]; - } - else if (num3 < -0.7f) - { - if (closestHit.sqrDistance < num2 * num2) - { - array[i] = closestHit.closestPoint - normalized * num2 - worldVertices[i]; - } - } - else - { - array[i] = Vector3.zero; - } - } - return array; - } + public Vector3[] ExpandVertexMatch(ClothInstance clothInstance, float defaultMinDist = 0.005f, bool skipFootFitting = false, float maxMatchDistance = 0.1f) + { + //IL_008d: Unknown result type (might be due to invalid IL or missing references) + //IL_0092: Unknown result type (might be due to invalid IL or missing references) + //IL_00aa: Unknown result type (might be due to invalid IL or missing references) + //IL_00af: Unknown result type (might be due to invalid IL or missing references) + //IL_00d5: 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_00fd: Unknown result type (might be due to invalid IL or missing references) + //IL_012b: Unknown result type (might be due to invalid IL or missing references) + //IL_0131: Invalid comparison between Unknown and I4 + //IL_0183: Unknown result type (might be due to invalid IL or missing references) + //IL_018b: Unknown result type (might be due to invalid IL or missing references) + //IL_0190: Unknown result type (might be due to invalid IL or missing references) + //IL_0195: Unknown result type (might be due to invalid IL or missing references) + //IL_0199: Unknown result type (might be due to invalid IL or missing references) + //IL_019e: Unknown result type (might be due to invalid IL or missing references) + //IL_01a0: 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_0172: Unknown result type (might be due to invalid IL or missing references) + //IL_0177: Unknown result type (might be due to invalid IL or missing references) + //IL_0156: Unknown result type (might be due to invalid IL or missing references) + //IL_015b: 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_013b: Invalid comparison between Unknown and I4 + //IL_01c3: Unknown result type (might be due to invalid IL or missing references) + //IL_01c8: Unknown result type (might be due to invalid IL or missing references) + //IL_01cc: Unknown result type (might be due to invalid IL or missing references) + //IL_01d1: 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_01de: Unknown result type (might be due to invalid IL or missing references) + //IL_01e3: Unknown result type (might be due to invalid IL or missing references) + //IL_013f: Unknown result type (might be due to invalid IL or missing references) + //IL_0146: Invalid comparison between Unknown and I4 + //IL_0230: Unknown result type (might be due to invalid IL or missing references) + //IL_0235: Unknown result type (might be due to invalid IL or missing references) + //IL_014a: Unknown result type (might be due to invalid IL or missing references) + //IL_0151: Invalid comparison between Unknown and I4 + //IL_0206: Unknown result type (might be due to invalid IL or missing references) + //IL_020b: Unknown result type (might be due to invalid IL or missing references) + //IL_020f: Unknown result type (might be due to invalid IL or missing references) + //IL_0214: Unknown result type (might be due to invalid IL or missing references) + //IL_021c: Unknown result type (might be due to invalid IL or missing references) + //IL_0221: Unknown result type (might be due to invalid IL or missing references) + //IL_0226: Unknown result type (might be due to invalid IL or missing references) + Vector3[] worldVertices = clothInstance.worldVertices; + float[] minDistance = clothInstance.minDistance; + if (this.bodyBVH == null) + { + throw new AutoMorpherException("Body BVH is Missing", "[ExpandVertexMatch] ExpandVertexMatch\n - bodyBVH is null"); + } + if (worldVertices == null) + { + throw new AutoMorpherException("Cloth World Vertices are Missing", "[ExpandVertexMatch] ExpandVertexMatch\n - clothInstance.worldVertices is null"); + } + if (worldVertices.Length == 0) + { + Debug.LogWarning((object)"clothes mesh has no vertices"); + return null; + } + if (minDistance == null) + { + Debug.LogWarning((object)"minDists is null"); + } + if (minDistance.Length != worldVertices.Length) + { + Debug.LogWarning((object)"minDists.Length != worldVertexs.Length"); + } + Vector3[] array = (Vector3[])(object)new Vector3[worldVertices.Length]; + float num = maxMatchDistance * maxMatchDistance; + for (int i = 0; i < worldVertices.Length; i++) + { + if (clothInstance.excludedVertices[i]) + { + array[i] = Vector3.zero; + continue; + } + if (clothInstance.isInsideVertex[i]) + { + array[i] = Vector3.zero; + continue; + } + float num2 = minDistance[i] + defaultMinDist; + BvhTriangleMesh.ClosestHit closestHit = (clothInstance.isLeftLegVertex[i] ? this.bodyBVH.QueryClosest(worldVertices[i], this.LeftLegBones) : ((!clothInstance.isRightLegVertex[i]) ? this.bodyBVH.QueryClosest(worldVertices[i]) : this.bodyBVH.QueryClosest(worldVertices[i], this.RightLegBones))); + if (skipFootFitting && ((int)closestHit.mainHumanBone == 5 || (int)closestHit.mainHumanBone == 6 || (int)closestHit.mainHumanBone == 20 || (int)closestHit.mainHumanBone == 19)) + { + array[i] = Vector3.zero; + continue; + } + if (closestHit.sqrDistance > num) + { + array[i] = Vector3.zero; + continue; + } + Vector3 val = closestHit.closestPoint - worldVertices[i]; + Vector3 normalized = val.normalized; + float num3 = Vector3.Dot(normalized, closestHit.normal.normalized); + if (num3 > 0.7f) + { + array[i] = closestHit.closestPoint + normalized * num2 - worldVertices[i]; + } + else if (num3 < -0.7f) + { + if (closestHit.sqrDistance < num2 * num2) + { + array[i] = closestHit.closestPoint - normalized * num2 - worldVertices[i]; + } + } + else + { + array[i] = Vector3.zero; + } + } + return array; + } - public Vector3[] ShrinkVertexMatch(ClothInstance clothInstance, float defaultMinDist = 0.005f, float maxMatchDistance = 0.1f) - { - //IL_0099: Unknown result type (might be due to invalid IL or missing references) - //IL_009e: Unknown result type (might be due to invalid IL or missing references) - //IL_00b6: Unknown result type (might be due to invalid IL or missing references) - //IL_00bb: Unknown result type (might be due to invalid IL or missing references) - //IL_00e1: Unknown result type (might be due to invalid IL or missing references) - //IL_0126: Unknown result type (might be due to invalid IL or missing references) - //IL_0109: Unknown result type (might be due to invalid IL or missing references) - //IL_0150: Unknown result type (might be due to invalid IL or missing references) - //IL_0156: Invalid comparison between Unknown and I4 - //IL_013f: Unknown result type (might be due to invalid IL or missing references) - //IL_0144: Unknown result type (might be due to invalid IL or missing references) - //IL_017b: Unknown result type (might be due to invalid IL or missing references) - //IL_0180: Unknown result type (might be due to invalid IL or missing references) - //IL_015a: Unknown result type (might be due to invalid IL or missing references) - //IL_0160: Invalid comparison between Unknown and I4 - //IL_0164: Unknown result type (might be due to invalid IL or missing references) - //IL_016b: Invalid comparison between Unknown and I4 - //IL_016f: Unknown result type (might be due to invalid IL or missing references) - //IL_0176: Invalid comparison between Unknown and I4 - //IL_018c: Unknown result type (might be due to invalid IL or missing references) - //IL_0194: Unknown result type (might be due to invalid IL or missing references) - //IL_0199: Unknown result type (might be due to invalid IL or missing references) - //IL_019e: Unknown result type (might be due to invalid IL or missing references) - //IL_01a2: Unknown result type (might be due to invalid IL or missing references) - //IL_01a7: 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_01b2: Unknown result type (might be due to invalid IL or missing references) - //IL_01cc: Unknown result type (might be due to invalid IL or missing references) - //IL_01d1: 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_01e2: Unknown result type (might be due to invalid IL or missing references) - //IL_01e7: Unknown result type (might be due to invalid IL or missing references) - //IL_01ec: Unknown result type (might be due to invalid IL or missing references) - //IL_0239: Unknown result type (might be due to invalid IL or missing references) - //IL_023e: Unknown result type (might be due to invalid IL or missing references) - //IL_020f: Unknown result type (might be due to invalid IL or missing references) - //IL_0214: Unknown result type (might be due to invalid IL or missing references) - //IL_0218: Unknown result type (might be due to invalid IL or missing references) - //IL_021d: Unknown result type (might be due to invalid IL or missing references) - //IL_0225: Unknown result type (might be due to invalid IL or missing references) - //IL_022a: 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) - Vector3[] worldVertices = clothInstance.worldVertices; - float[] minDistance = clothInstance.minDistance; - if (bodyBVH == null) - { - throw new AutoMorpherException("Body BVH is Missing", "[ShrinkVertexMatch] ShrinkVertexMatch\n - bodyBVH is null"); - } - if (worldVertices == null) - { - throw new AutoMorpherException("Cloth World Vertices are Missing", "[ShrinkVertexMatch] ShrinkVertexMatch\n - clothInstance.worldVertices is null"); - } - if (worldVertices.Length == 0) - { - Debug.LogWarning((object)"clothes mesh has no vertices"); - return null; - } - if (minDistance == null) - { - Debug.LogWarning((object)"minDists is null"); - } - if (minDistance.Length != worldVertices.Length) - { - Debug.LogWarning((object)"minDists.Length != worldVertexs.Length"); - } - Vector3[] array = (Vector3[])(object)new Vector3[worldVertices.Length]; - float num = maxMatchDistance * maxMatchDistance; - _ = clothInstance.isLeftLegVertex; - _ = clothInstance.isRightLegVertex; - for (int i = 0; i < worldVertices.Length; i++) - { - if (clothInstance.excludedVertices[i]) - { - array[i] = Vector3.zero; - continue; - } - if (clothInstance.isInsideVertex[i]) - { - array[i] = Vector3.zero; - continue; - } - float num2 = minDistance[i] + defaultMinDist; - BvhTriangleMesh.ClosestHit closestHit = (clothInstance.isLeftLegVertex[i] ? bodyBVH.QueryClosest(worldVertices[i], LeftLegBones) : ((!clothInstance.isRightLegVertex[i]) ? bodyBVH.QueryClosest(worldVertices[i]) : bodyBVH.QueryClosest(worldVertices[i], RightLegBones))); - if (closestHit.sqrDistance > num) - { - array[i] = Vector3.zero; - continue; - } - if ((int)closestHit.mainHumanBone == 5 || (int)closestHit.mainHumanBone == 6 || (int)closestHit.mainHumanBone == 20 || (int)closestHit.mainHumanBone == 19) - { - array[i] = Vector3.zero; - continue; - } - Vector3 val = closestHit.closestPoint - worldVertices[i]; - Vector3 normalized = ((Vector3)(ref val)).normalized; - float num3 = Vector3.Dot(normalized, ((Vector3)(ref closestHit.normal)).normalized); - if (num3 < -0.7f) - { - array[i] = closestHit.closestPoint - normalized * num2 - worldVertices[i]; - } - else if (num3 < -0.7f) - { - if (closestHit.sqrDistance < num2 * num2) - { - array[i] = closestHit.closestPoint + normalized * num2 - worldVertices[i]; - } - } - else - { - array[i] = Vector3.zero; - } - } - return array; - } + public Vector3[] ShrinkVertexMatch(ClothInstance clothInstance, float defaultMinDist = 0.005f, float maxMatchDistance = 0.1f) + { + //IL_0099: Unknown result type (might be due to invalid IL or missing references) + //IL_009e: Unknown result type (might be due to invalid IL or missing references) + //IL_00b6: Unknown result type (might be due to invalid IL or missing references) + //IL_00bb: Unknown result type (might be due to invalid IL or missing references) + //IL_00e1: Unknown result type (might be due to invalid IL or missing references) + //IL_0126: Unknown result type (might be due to invalid IL or missing references) + //IL_0109: Unknown result type (might be due to invalid IL or missing references) + //IL_0150: Unknown result type (might be due to invalid IL or missing references) + //IL_0156: Invalid comparison between Unknown and I4 + //IL_013f: Unknown result type (might be due to invalid IL or missing references) + //IL_0144: Unknown result type (might be due to invalid IL or missing references) + //IL_017b: Unknown result type (might be due to invalid IL or missing references) + //IL_0180: Unknown result type (might be due to invalid IL or missing references) + //IL_015a: Unknown result type (might be due to invalid IL or missing references) + //IL_0160: Invalid comparison between Unknown and I4 + //IL_0164: Unknown result type (might be due to invalid IL or missing references) + //IL_016b: Invalid comparison between Unknown and I4 + //IL_016f: Unknown result type (might be due to invalid IL or missing references) + //IL_0176: Invalid comparison between Unknown and I4 + //IL_018c: Unknown result type (might be due to invalid IL or missing references) + //IL_0194: Unknown result type (might be due to invalid IL or missing references) + //IL_0199: Unknown result type (might be due to invalid IL or missing references) + //IL_019e: Unknown result type (might be due to invalid IL or missing references) + //IL_01a2: Unknown result type (might be due to invalid IL or missing references) + //IL_01a7: 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_01b2: Unknown result type (might be due to invalid IL or missing references) + //IL_01cc: Unknown result type (might be due to invalid IL or missing references) + //IL_01d1: 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_01e2: Unknown result type (might be due to invalid IL or missing references) + //IL_01e7: Unknown result type (might be due to invalid IL or missing references) + //IL_01ec: Unknown result type (might be due to invalid IL or missing references) + //IL_0239: Unknown result type (might be due to invalid IL or missing references) + //IL_023e: Unknown result type (might be due to invalid IL or missing references) + //IL_020f: Unknown result type (might be due to invalid IL or missing references) + //IL_0214: Unknown result type (might be due to invalid IL or missing references) + //IL_0218: Unknown result type (might be due to invalid IL or missing references) + //IL_021d: Unknown result type (might be due to invalid IL or missing references) + //IL_0225: Unknown result type (might be due to invalid IL or missing references) + //IL_022a: 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) + Vector3[] worldVertices = clothInstance.worldVertices; + float[] minDistance = clothInstance.minDistance; + if (this.bodyBVH == null) + { + throw new AutoMorpherException("Body BVH is Missing", "[ShrinkVertexMatch] ShrinkVertexMatch\n - bodyBVH is null"); + } + if (worldVertices == null) + { + throw new AutoMorpherException("Cloth World Vertices are Missing", "[ShrinkVertexMatch] ShrinkVertexMatch\n - clothInstance.worldVertices is null"); + } + if (worldVertices.Length == 0) + { + Debug.LogWarning((object)"clothes mesh has no vertices"); + return null; + } + if (minDistance == null) + { + Debug.LogWarning((object)"minDists is null"); + } + if (minDistance.Length != worldVertices.Length) + { + Debug.LogWarning((object)"minDists.Length != worldVertexs.Length"); + } + Vector3[] array = (Vector3[])(object)new Vector3[worldVertices.Length]; + float num = maxMatchDistance * maxMatchDistance; + _ = clothInstance.isLeftLegVertex; + _ = clothInstance.isRightLegVertex; + for (int i = 0; i < worldVertices.Length; i++) + { + if (clothInstance.excludedVertices[i]) + { + array[i] = Vector3.zero; + continue; + } + if (clothInstance.isInsideVertex[i]) + { + array[i] = Vector3.zero; + continue; + } + float num2 = minDistance[i] + defaultMinDist; + BvhTriangleMesh.ClosestHit closestHit = (clothInstance.isLeftLegVertex[i] ? this.bodyBVH.QueryClosest(worldVertices[i], this.LeftLegBones) : ((!clothInstance.isRightLegVertex[i]) ? this.bodyBVH.QueryClosest(worldVertices[i]) : this.bodyBVH.QueryClosest(worldVertices[i], this.RightLegBones))); + if (closestHit.sqrDistance > num) + { + array[i] = Vector3.zero; + continue; + } + if ((int)closestHit.mainHumanBone == 5 || (int)closestHit.mainHumanBone == 6 || (int)closestHit.mainHumanBone == 20 || (int)closestHit.mainHumanBone == 19) + { + array[i] = Vector3.zero; + continue; + } + Vector3 val = closestHit.closestPoint - worldVertices[i]; + Vector3 normalized = val.normalized; + float num3 = Vector3.Dot(normalized, closestHit.normal.normalized); + if (num3 < -0.7f) + { + array[i] = closestHit.closestPoint - normalized * num2 - worldVertices[i]; + } + else if (num3 < -0.7f) + { + if (closestHit.sqrDistance < num2 * num2) + { + array[i] = closestHit.closestPoint + normalized * num2 - worldVertices[i]; + } + } + else + { + array[i] = Vector3.zero; + } + } + return array; + } - public Vector3[] GetMinDistanceToBody(Vector3[] clothesVertices) - { - //IL_003e: Unknown result type (might be due to invalid IL or missing references) - //IL_0043: Unknown result type (might be due to invalid IL or missing references) - //IL_004a: Unknown result type (might be due to invalid IL or missing references) - //IL_0050: Unknown result type (might be due to invalid IL or missing references) - //IL_0055: Unknown result type (might be due to invalid IL or missing references) - //IL_0056: Unknown result type (might be due to invalid IL or missing references) - //IL_005b: Unknown result type (might be due to invalid IL or missing references) - //IL_005e: Unknown result type (might be due to invalid IL or missing references) - //IL_005f: Unknown result type (might be due to invalid IL or missing references) - if (bodyBVH == null) - { - throw new AutoMorpherException("sourceBodyBVH is null", "[MeshMatcher] GetMinDistanceToBodysourceBodyBVH is null"); - } - if (clothesVertices == null || clothesVertices.Length == 0) - { - throw new AutoMorpherException("Source Vertices is null", "[MeshMatcher] GetMinDistanceToBodySource Vertices is null or no vertices"); - } - Vector3[] array = (Vector3[])(object)new Vector3[clothesVertices.Length]; - for (int i = 0; i < clothesVertices.Length; i++) - { - Vector3 val = clothesVertices[i]; - Vector3 val2 = bodyBVH.QueryClosest(val).closestPoint - val; - array[i] = val2; - } - return array; - } + public Vector3[] GetMinDistanceToBody(Vector3[] clothesVertices) + { + //IL_003e: Unknown result type (might be due to invalid IL or missing references) + //IL_0043: Unknown result type (might be due to invalid IL or missing references) + //IL_004a: Unknown result type (might be due to invalid IL or missing references) + //IL_0050: Unknown result type (might be due to invalid IL or missing references) + //IL_0055: Unknown result type (might be due to invalid IL or missing references) + //IL_0056: Unknown result type (might be due to invalid IL or missing references) + //IL_005b: Unknown result type (might be due to invalid IL or missing references) + //IL_005e: Unknown result type (might be due to invalid IL or missing references) + //IL_005f: Unknown result type (might be due to invalid IL or missing references) + if (this.bodyBVH == null) + { + throw new AutoMorpherException("sourceBodyBVH is null", "[MeshMatcher] GetMinDistanceToBodysourceBodyBVH is null"); + } + if (clothesVertices == null || clothesVertices.Length == 0) + { + throw new AutoMorpherException("Source Vertices is null", "[MeshMatcher] GetMinDistanceToBodySource Vertices is null or no vertices"); + } + Vector3[] array = (Vector3[])(object)new Vector3[clothesVertices.Length]; + for (int i = 0; i < clothesVertices.Length; i++) + { + Vector3 val = clothesVertices[i]; + Vector3 val2 = this.bodyBVH.QueryClosest(val).closestPoint - val; + array[i] = val2; + } + return array; + } - public bool[] GetBodyInsideFlags(Vector3[] worldVertices) - { - //IL_004e: Unknown result type (might be due to invalid IL or missing references) - //IL_005a: Unknown result type (might be due to invalid IL or missing references) - //IL_0061: Unknown result type (might be due to invalid IL or missing references) - //IL_0066: Unknown result type (might be due to invalid IL or missing references) - //IL_006b: Unknown result type (might be due to invalid IL or missing references) - //IL_006f: Unknown result type (might be due to invalid IL or missing references) - //IL_007b: Unknown result type (might be due to invalid IL or missing references) - if (bodyBVH == null) - { - throw new AutoMorpherException("sourceBodyBVH is null", "[MeshMatcher] GetBodyInsideFlagssourceBodyBVH is null"); - } - if (worldVertices == null || worldVertices.Length == 0) - { - Debug.LogError((object)"clothes is null"); - throw new AutoMorpherException("Source Vertices is null", "[MeshMatcher] GetMinDistanceToBodySource Vertices is null or no vertices"); - } - bool[] array = new bool[worldVertices.Length]; - for (int i = 0; i < worldVertices.Length; i++) - { - BvhTriangleMesh.ClosestHit closestHit = bodyBVH.QueryClosest(worldVertices[i]); - Vector3 val = closestHit.closestPoint - worldVertices[i]; - float num = Vector3.Dot(((Vector3)(ref val)).normalized, ((Vector3)(ref closestHit.normal)).normalized); - array[i] = num > 0f; - } - return array; - } + public bool[] GetBodyInsideFlags(Vector3[] worldVertices) + { + //IL_004e: Unknown result type (might be due to invalid IL or missing references) + //IL_005a: Unknown result type (might be due to invalid IL or missing references) + //IL_0061: Unknown result type (might be due to invalid IL or missing references) + //IL_0066: Unknown result type (might be due to invalid IL or missing references) + //IL_006b: Unknown result type (might be due to invalid IL or missing references) + //IL_006f: Unknown result type (might be due to invalid IL or missing references) + //IL_007b: Unknown result type (might be due to invalid IL or missing references) + if (this.bodyBVH == null) + { + throw new AutoMorpherException("sourceBodyBVH is null", "[MeshMatcher] GetBodyInsideFlagssourceBodyBVH is null"); + } + if (worldVertices == null || worldVertices.Length == 0) + { + Debug.LogError((object)"clothes is null"); + throw new AutoMorpherException("Source Vertices is null", "[MeshMatcher] GetMinDistanceToBodySource Vertices is null or no vertices"); + } + bool[] array = new bool[worldVertices.Length]; + for (int i = 0; i < worldVertices.Length; i++) + { + BvhTriangleMesh.ClosestHit closestHit = this.bodyBVH.QueryClosest(worldVertices[i]); + Vector3 val = closestHit.closestPoint - worldVertices[i]; + float num = Vector3.Dot(val.normalized, closestHit.normal.normalized); + array[i] = num > 0f; + } + return array; + } } diff --git a/Assets/@Eden_Tools/Eden_AutoMorpher/Script/MorpherMode.cs b/Assets/@Eden_Tools/Eden_AutoMorpher/Script/MorpherMode.cs index 1d7e77e..7acc28b 100644 --- a/Assets/@Eden_Tools/Eden_AutoMorpher/Script/MorpherMode.cs +++ b/Assets/@Eden_Tools/Eden_AutoMorpher/Script/MorpherMode.cs @@ -1,11 +1,11 @@ -// Warning: Some assembly references could not be resolved automatically. This might lead to incorrect decompilation of some parts, +// 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.MorpherMode public enum MorpherMode { - AutoMorpher = 0, - ManualMorpher = 1, - ProfileMorpher = 2, - ETC = 99 + AutoMorpher = 0, + ManualMorpher = 1, + ProfileMorpher = 2, + ETC = 99 } diff --git a/Assets/@Eden_Tools/Eden_AutoMorpher/Script/MorpherState.cs b/Assets/@Eden_Tools/Eden_AutoMorpher/Script/MorpherState.cs index 26a65e7..ec40cd7 100644 --- a/Assets/@Eden_Tools/Eden_AutoMorpher/Script/MorpherState.cs +++ b/Assets/@Eden_Tools/Eden_AutoMorpher/Script/MorpherState.cs @@ -1,12 +1,12 @@ -// Warning: Some assembly references could not be resolved automatically. This might lead to incorrect decompilation of some parts, +// 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.MorpherState public enum MorpherState { - Idle, - Fitting_Doing, - Fitting_End, - Weighting_Doing, - Weighting_End + Idle, + Fitting_Doing, + Fitting_End, + Weighting_Doing, + Weighting_End } diff --git a/Assets/@Eden_Tools/Eden_AutoMorpher/Script/PcaUtil.cs b/Assets/@Eden_Tools/Eden_AutoMorpher/Script/PcaUtil.cs index 0929d0e..9a2b964 100644 --- a/Assets/@Eden_Tools/Eden_AutoMorpher/Script/PcaUtil.cs +++ b/Assets/@Eden_Tools/Eden_AutoMorpher/Script/PcaUtil.cs @@ -1,213 +1,212 @@ -// Warning: Some assembly references could not be resolved automatically. This might lead to incorrect decompilation of some parts, +// 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.PcaUtil using System.Collections.Generic; -using Eden.AutoMorpher; using UnityEngine; public class PcaUtil { - public RegionStats ComputeRegionStats(IList points) - { - //IL_001c: Unknown result type (might be due to invalid IL or missing references) - //IL_0021: Unknown result type (might be due to invalid IL or missing references) - //IL_0027: Unknown result type (might be due to invalid IL or missing references) - //IL_002b: Unknown result type (might be due to invalid IL or missing references) - //IL_0030: Unknown result type (might be due to invalid IL or missing references) - //IL_0035: Unknown result type (might be due to invalid IL or missing references) - //IL_0041: Unknown result type (might be due to invalid IL or missing references) - //IL_0044: Unknown result type (might be due to invalid IL or missing references) - //IL_0049: Unknown result type (might be due to invalid IL or missing references) - //IL_007e: Unknown result type (might be due to invalid IL or missing references) - //IL_0083: Unknown result type (might be due to invalid IL or missing references) - //IL_0084: Unknown result type (might be due to invalid IL or missing references) - //IL_0089: 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_0093: Unknown result type (might be due to invalid IL or missing references) - //IL_009f: Unknown result type (might be due to invalid IL or missing references) - //IL_00a6: Unknown result type (might be due to invalid IL or missing references) - //IL_00b3: Unknown result type (might be due to invalid IL or missing references) - //IL_00ba: Unknown result type (might be due to invalid IL or missing references) - //IL_00c7: Unknown result type (might be due to invalid IL or missing references) - //IL_00ce: Unknown result type (might be due to invalid IL or missing references) - //IL_00db: Unknown result type (might be due to invalid IL or missing references) - //IL_00e2: Unknown result type (might be due to invalid IL or missing references) - //IL_00ef: Unknown result type (might be due to invalid IL or missing references) - //IL_00f6: Unknown result type (might be due to invalid IL or missing references) - //IL_017e: Unknown result type (might be due to invalid IL or missing references) - //IL_0183: Unknown result type (might be due to invalid IL or missing references) - //IL_01a2: Unknown result type (might be due to invalid IL or missing references) - //IL_01a7: Unknown result type (might be due to invalid IL or missing references) - //IL_01a8: Unknown result type (might be due to invalid IL or missing references) - //IL_01ad: Unknown result type (might be due to invalid IL or missing references) - //IL_0209: 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_0211: Unknown result type (might be due to invalid IL or missing references) - //IL_0213: Unknown result type (might be due to invalid IL or missing references) - //IL_01ca: 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_01cf: Unknown result type (might be due to invalid IL or missing references) - //IL_01d4: 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_01de: Unknown result type (might be due to invalid IL or missing references) - //IL_01e3: Unknown result type (might be due to invalid IL or missing references) - //IL_01e5: Unknown result type (might be due to invalid IL or missing references) - //IL_01ea: Unknown result type (might be due to invalid IL or missing references) - RegionStats result = default(RegionStats); - if (points == null || points.Count == 0) - { - return result; - } - int count = points.Count; - Vector3 val = Vector3.zero; - for (int i = 0; i < count; i++) - { - val += points[i]; - } - val /= (float)count; - float num = 0f; - float num2 = 0f; - float num3 = 0f; - float num4 = 0f; - float num5 = 0f; - float num6 = 0f; - for (int j = 0; j < count; j++) - { - Vector3 val2 = points[j] - val; - num += val2.x * val2.x; - num2 += val2.x * val2.y; - num3 += val2.x * val2.z; - num4 += val2.y * val2.y; - num5 += val2.y * val2.z; - num6 += val2.z * val2.z; - } - float num7 = 1f / (float)count; - num *= num7; - num2 *= num7; - num3 *= num7; - num4 *= num7; - num5 *= num7; - num6 *= num7; - JacobiEigenDecomposition3x3(num, num2, num3, num4, num5, num6, out var eigenValues, out var eigenVectors); - int num8 = 0; - if (eigenValues[1] > eigenValues[num8]) - { - num8 = 1; - } - if (eigenValues[2] > eigenValues[num8]) - { - num8 = 2; - } - Vector3 normalized = ((Vector3)(ref eigenVectors[num8])).normalized; - float num9 = float.PositiveInfinity; - float num10 = float.NegativeInfinity; - float num11 = 0f; - for (int k = 0; k < count; k++) - { - float num12 = Vector3.Dot(points[k] - val, normalized); - if (num12 < num9) - { - num9 = num12; - } - if (num12 > num10) - { - num10 = num12; - } - Vector3 val3 = val + normalized * num12; - Vector3 val4 = points[k] - val3; - float magnitude = ((Vector3)(ref val4)).magnitude; - num11 += magnitude; - } - result.center = val; - result.principalAxis = normalized; - result.length = num10 - num9; - result.avgRadius = num11 / (float)count; - return result; - } + public RegionStats ComputeRegionStats(IList points) + { + //IL_001c: Unknown result type (might be due to invalid IL or missing references) + //IL_0021: Unknown result type (might be due to invalid IL or missing references) + //IL_0027: Unknown result type (might be due to invalid IL or missing references) + //IL_002b: Unknown result type (might be due to invalid IL or missing references) + //IL_0030: Unknown result type (might be due to invalid IL or missing references) + //IL_0035: Unknown result type (might be due to invalid IL or missing references) + //IL_0041: Unknown result type (might be due to invalid IL or missing references) + //IL_0044: Unknown result type (might be due to invalid IL or missing references) + //IL_0049: Unknown result type (might be due to invalid IL or missing references) + //IL_007e: Unknown result type (might be due to invalid IL or missing references) + //IL_0083: Unknown result type (might be due to invalid IL or missing references) + //IL_0084: Unknown result type (might be due to invalid IL or missing references) + //IL_0089: 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_0093: Unknown result type (might be due to invalid IL or missing references) + //IL_009f: Unknown result type (might be due to invalid IL or missing references) + //IL_00a6: Unknown result type (might be due to invalid IL or missing references) + //IL_00b3: Unknown result type (might be due to invalid IL or missing references) + //IL_00ba: Unknown result type (might be due to invalid IL or missing references) + //IL_00c7: Unknown result type (might be due to invalid IL or missing references) + //IL_00ce: Unknown result type (might be due to invalid IL or missing references) + //IL_00db: Unknown result type (might be due to invalid IL or missing references) + //IL_00e2: Unknown result type (might be due to invalid IL or missing references) + //IL_00ef: Unknown result type (might be due to invalid IL or missing references) + //IL_00f6: Unknown result type (might be due to invalid IL or missing references) + //IL_017e: Unknown result type (might be due to invalid IL or missing references) + //IL_0183: Unknown result type (might be due to invalid IL or missing references) + //IL_01a2: Unknown result type (might be due to invalid IL or missing references) + //IL_01a7: Unknown result type (might be due to invalid IL or missing references) + //IL_01a8: Unknown result type (might be due to invalid IL or missing references) + //IL_01ad: Unknown result type (might be due to invalid IL or missing references) + //IL_0209: 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_0211: Unknown result type (might be due to invalid IL or missing references) + //IL_0213: Unknown result type (might be due to invalid IL or missing references) + //IL_01ca: 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_01cf: Unknown result type (might be due to invalid IL or missing references) + //IL_01d4: 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_01de: Unknown result type (might be due to invalid IL or missing references) + //IL_01e3: Unknown result type (might be due to invalid IL or missing references) + //IL_01e5: Unknown result type (might be due to invalid IL or missing references) + //IL_01ea: Unknown result type (might be due to invalid IL or missing references) + RegionStats result = default(RegionStats); + if (points == null || points.Count == 0) + { + return result; + } + int count = points.Count; + Vector3 val = Vector3.zero; + for (int i = 0; i < count; i++) + { + val += points[i]; + } + val /= (float)count; + float num = 0f; + float num2 = 0f; + float num3 = 0f; + float num4 = 0f; + float num5 = 0f; + float num6 = 0f; + for (int j = 0; j < count; j++) + { + Vector3 val2 = points[j] - val; + num += val2.x * val2.x; + num2 += val2.x * val2.y; + num3 += val2.x * val2.z; + num4 += val2.y * val2.y; + num5 += val2.y * val2.z; + num6 += val2.z * val2.z; + } + float num7 = 1f / (float)count; + num *= num7; + num2 *= num7; + num3 *= num7; + num4 *= num7; + num5 *= num7; + num6 *= num7; + this.JacobiEigenDecomposition3x3(num, num2, num3, num4, num5, num6, out var eigenValues, out var eigenVectors); + int num8 = 0; + if (eigenValues[1] > eigenValues[num8]) + { + num8 = 1; + } + if (eigenValues[2] > eigenValues[num8]) + { + num8 = 2; + } + Vector3 normalized = eigenVectors[num8].normalized; + float num9 = float.PositiveInfinity; + float num10 = float.NegativeInfinity; + float num11 = 0f; + for (int k = 0; k < count; k++) + { + float num12 = Vector3.Dot(points[k] - val, normalized); + if (num12 < num9) + { + num9 = num12; + } + if (num12 > num10) + { + num10 = num12; + } + Vector3 val3 = val + normalized * num12; + Vector3 val4 = points[k] - val3; + float magnitude = val4.magnitude; + num11 += magnitude; + } + result.center = val; + result.principalAxis = normalized; + result.length = num10 - num9; + result.avgRadius = num11 / (float)count; + return result; + } - private void JacobiEigenDecomposition3x3(float c00, float c01, float c02, float c11, float c12, float c22, out float[] eigenValues, out Vector3[] eigenVectors) - { - //IL_032d: Unknown result type (might be due to invalid IL or missing references) - //IL_0332: Unknown result type (might be due to invalid IL or missing references) - //IL_0353: Unknown result type (might be due to invalid IL or missing references) - //IL_0358: Unknown result type (might be due to invalid IL or missing references) - //IL_0379: Unknown result type (might be due to invalid IL or missing references) - //IL_037e: Unknown result type (might be due to invalid IL or missing references) - float[,] array = new float[3, 3] - { - { c00, c01, c02 }, - { c01, c11, c12 }, - { c02, c12, c22 } - }; - float[,] array2 = new float[3, 3] - { - { 1f, 0f, 0f }, - { 0f, 1f, 0f }, - { 0f, 0f, 1f } - }; - for (int i = 0; i < 32; i++) - { - int num = 0; - int num2 = 1; - float num3 = Mathf.Abs(array[0, 1]); - float num4 = Mathf.Abs(array[0, 2]); - if (num4 > num3) - { - num3 = num4; - num = 0; - num2 = 2; - } - float num5 = Mathf.Abs(array[1, 2]); - if (num5 > num3) - { - num3 = num5; - num = 1; - num2 = 2; - } - if (num3 < 1E-10f) - { - break; - } - float num6 = array[num, num]; - float num7 = array[num2, num2]; - float num8 = array[num, num2]; - float num9 = 0.5f * Mathf.Atan2(2f * num8, num7 - num6); - float num10 = Mathf.Cos(num9); - float num11 = Mathf.Sin(num9); - for (int j = 0; j < 3; j++) - { - if (j != num && j != num2) - { - float num12 = array[j, num]; - float num13 = array[j, num2]; - array[j, num] = num10 * num12 - num11 * num13; - array[num, j] = array[j, num]; - array[j, num2] = num11 * num12 + num10 * num13; - array[num2, j] = array[j, num2]; - } - } - float num14 = num10 * num10 * num6 - 2f * num11 * num10 * num8 + num11 * num11 * num7; - float num15 = num11 * num11 * num6 + 2f * num11 * num10 * num8 + num10 * num10 * num7; - array[num, num] = num14; - array[num2, num2] = num15; - array[num, num2] = 0f; - array[num2, num] = 0f; - for (int k = 0; k < 3; k++) - { - float num16 = array2[k, num]; - float num17 = array2[k, num2]; - array2[k, num] = num10 * num16 - num11 * num17; - array2[k, num2] = num11 * num16 + num10 * num17; - } - } - eigenValues = new float[3]; - eigenVectors = (Vector3[])(object)new Vector3[3]; - eigenValues[0] = array[0, 0]; - eigenValues[1] = array[1, 1]; - eigenValues[2] = array[2, 2]; - eigenVectors[0] = new Vector3(array2[0, 0], array2[1, 0], array2[2, 0]); - eigenVectors[1] = new Vector3(array2[0, 1], array2[1, 1], array2[2, 1]); - eigenVectors[2] = new Vector3(array2[0, 2], array2[1, 2], array2[2, 2]); - } + private void JacobiEigenDecomposition3x3(float c00, float c01, float c02, float c11, float c12, float c22, out float[] eigenValues, out Vector3[] eigenVectors) + { + //IL_032d: Unknown result type (might be due to invalid IL or missing references) + //IL_0332: Unknown result type (might be due to invalid IL or missing references) + //IL_0353: Unknown result type (might be due to invalid IL or missing references) + //IL_0358: Unknown result type (might be due to invalid IL or missing references) + //IL_0379: Unknown result type (might be due to invalid IL or missing references) + //IL_037e: Unknown result type (might be due to invalid IL or missing references) + float[,] array = new float[3, 3] + { + { c00, c01, c02 }, + { c01, c11, c12 }, + { c02, c12, c22 } + }; + float[,] array2 = new float[3, 3] + { + { 1f, 0f, 0f }, + { 0f, 1f, 0f }, + { 0f, 0f, 1f } + }; + for (int i = 0; i < 32; i++) + { + int num = 0; + int num2 = 1; + float num3 = Mathf.Abs(array[0, 1]); + float num4 = Mathf.Abs(array[0, 2]); + if (num4 > num3) + { + num3 = num4; + num = 0; + num2 = 2; + } + float num5 = Mathf.Abs(array[1, 2]); + if (num5 > num3) + { + num3 = num5; + num = 1; + num2 = 2; + } + if (num3 < 1E-10f) + { + break; + } + float num6 = array[num, num]; + float num7 = array[num2, num2]; + float num8 = array[num, num2]; + float num9 = 0.5f * Mathf.Atan2(2f * num8, num7 - num6); + float num10 = Mathf.Cos(num9); + float num11 = Mathf.Sin(num9); + for (int j = 0; j < 3; j++) + { + if (j != num && j != num2) + { + float num12 = array[j, num]; + float num13 = array[j, num2]; + array[j, num] = num10 * num12 - num11 * num13; + array[num, j] = array[j, num]; + array[j, num2] = num11 * num12 + num10 * num13; + array[num2, j] = array[j, num2]; + } + } + float num14 = num10 * num10 * num6 - 2f * num11 * num10 * num8 + num11 * num11 * num7; + float num15 = num11 * num11 * num6 + 2f * num11 * num10 * num8 + num10 * num10 * num7; + array[num, num] = num14; + array[num2, num2] = num15; + array[num, num2] = 0f; + array[num2, num] = 0f; + for (int k = 0; k < 3; k++) + { + float num16 = array2[k, num]; + float num17 = array2[k, num2]; + array2[k, num] = num10 * num16 - num11 * num17; + array2[k, num2] = num11 * num16 + num10 * num17; + } + } + eigenValues = new float[3]; + eigenVectors = (Vector3[])(object)new Vector3[3]; + eigenValues[0] = array[0, 0]; + eigenValues[1] = array[1, 1]; + eigenValues[2] = array[2, 2]; + eigenVectors[0] = new Vector3(array2[0, 0], array2[1, 0], array2[2, 0]); + eigenVectors[1] = new Vector3(array2[0, 1], array2[1, 1], array2[2, 1]); + eigenVectors[2] = new Vector3(array2[0, 2], array2[1, 2], array2[2, 2]); + } } diff --git a/Assets/@Eden_Tools/Eden_AutoMorpher/Script/ProcessInfo.cs b/Assets/@Eden_Tools/Eden_AutoMorpher/Script/ProcessInfo.cs index e3370d4..bb7c763 100644 --- a/Assets/@Eden_Tools/Eden_AutoMorpher/Script/ProcessInfo.cs +++ b/Assets/@Eden_Tools/Eden_AutoMorpher/Script/ProcessInfo.cs @@ -1,12 +1,12 @@ -// Warning: Some assembly references could not be resolved automatically. This might lead to incorrect decompilation of some parts, +// 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.ProcessInfo public struct ProcessInfo { - public string title; + public string title; - public string text; + public string text; - public float progress; + public float progress; } diff --git a/Assets/@Eden_Tools/Eden_AutoMorpher/Script/RegionStats.cs b/Assets/@Eden_Tools/Eden_AutoMorpher/Script/RegionStats.cs index 9e79049..ac97f9d 100644 --- a/Assets/@Eden_Tools/Eden_AutoMorpher/Script/RegionStats.cs +++ b/Assets/@Eden_Tools/Eden_AutoMorpher/Script/RegionStats.cs @@ -1,4 +1,4 @@ -// Warning: Some assembly references could not be resolved automatically. This might lead to incorrect decompilation of some parts, +// 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.RegionStats @@ -6,11 +6,11 @@ using UnityEngine; public struct RegionStats { - public Vector3 center; + public Vector3 center; - public Vector3 principalAxis; + public Vector3 principalAxis; - public float length; + public float length; - public float avgRadius; + public float avgRadius; } diff --git a/Assets/@Eden_Tools/Eden_AutoMorpher/Script/SkinningUtil.cs b/Assets/@Eden_Tools/Eden_AutoMorpher/Script/SkinningUtil.cs index bb7b2b2..3c07f58 100644 --- a/Assets/@Eden_Tools/Eden_AutoMorpher/Script/SkinningUtil.cs +++ b/Assets/@Eden_Tools/Eden_AutoMorpher/Script/SkinningUtil.cs @@ -1,4 +1,4 @@ -// Warning: Some assembly references could not be resolved automatically. This might lead to incorrect decompilation of some parts, +// 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.SkinningUtil @@ -6,459 +6,458 @@ using UnityEngine; public class SkinningUtil { - public Vector3 WorldPosToBindPos(SkinnedMeshRenderer smr, Mesh bindMesh, int vertexIndex, Vector3 targetWorld) - { - //IL_0012: Unknown result type (might be due to invalid IL or missing references) - //IL_0052: Unknown result type (might be due to invalid IL or missing references) - //IL_0054: Unknown result type (might be due to invalid IL or missing references) - //IL_006a: Unknown result type (might be due to invalid IL or missing references) - //IL_006c: 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_008a: 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_023a: Unknown result type (might be due to invalid IL or missing references) - //IL_023c: Unknown result type (might be due to invalid IL or missing references) - //IL_0241: 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_0250: Unknown result type (might be due to invalid IL or missing references) - //IL_0255: Unknown result type (might be due to invalid IL or missing references) - //IL_025a: Unknown result type (might be due to invalid IL or missing references) - //IL_0210: Unknown result type (might be due to invalid IL or missing references) - //IL_0212: Unknown result type (might be due to invalid IL or missing references) - //IL_02c8: Unknown result type (might be due to invalid IL or missing references) - //IL_02cf: Unknown result type (might be due to invalid IL or missing references) - //IL_02d6: Unknown result type (might be due to invalid IL or missing references) - //IL_02de: Unknown result type (might be due to invalid IL or missing references) - //IL_02e5: Unknown result type (might be due to invalid IL or missing references) - //IL_02ef: Unknown result type (might be due to invalid IL or missing references) - //IL_02f6: Unknown result type (might be due to invalid IL or missing references) - //IL_02fd: Unknown result type (might be due to invalid IL or missing references) - //IL_0305: Unknown result type (might be due to invalid IL or missing references) - //IL_030c: Unknown result type (might be due to invalid IL or missing references) - //IL_0317: Unknown result type (might be due to invalid IL or missing references) - //IL_031e: Unknown result type (might be due to invalid IL or missing references) - //IL_0325: Unknown result type (might be due to invalid IL or missing references) - //IL_032d: Unknown result type (might be due to invalid IL or missing references) - //IL_0334: 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_035c: Unknown result type (might be due to invalid IL or missing references) - //IL_0361: Unknown result type (might be due to invalid IL or missing references) - //IL_0365: Unknown result type (might be due to invalid IL or missing references) - //IL_0367: Unknown result type (might be due to invalid IL or missing references) - //IL_036c: Unknown result type (might be due to invalid IL or missing references) - //IL_0379: Unknown result type (might be due to invalid IL or missing references) - //IL_037b: Unknown result type (might be due to invalid IL or missing references) - //IL_0380: Unknown result type (might be due to invalid IL or missing references) - //IL_0382: Unknown result type (might be due to invalid IL or missing references) - //IL_0396: Unknown result type (might be due to invalid IL or missing references) - //IL_034b: Unknown result type (might be due to invalid IL or missing references) - if ((Object)(object)smr == (Object)null || (Object)(object)bindMesh == (Object)null) - { - return Vector3.zero; - } - BoneWeight[] boneWeights = bindMesh.boneWeights; - Matrix4x4[] bindposes = bindMesh.bindposes; - Transform[] bones = smr.bones; - if (boneWeights == null || bindposes == null || bones == null) - { - return ((Component)smr).transform.InverseTransformPoint(targetWorld); - } - if (vertexIndex < 0 || vertexIndex >= boneWeights.Length) - { - return ((Component)smr).transform.InverseTransformPoint(targetWorld); - } - if (bindposes.Length != bones.Length) - { - return ((Component)smr).transform.InverseTransformPoint(targetWorld); - } - BoneWeight val = boneWeights[vertexIndex]; - bool flag = ((BoneWeight)(ref val)).boneIndex0 >= 0 && ((BoneWeight)(ref val)).boneIndex0 < bones.Length && (Object)(object)bones[((BoneWeight)(ref val)).boneIndex0] != (Object)null && ((BoneWeight)(ref val)).weight0 > 0f; - bool flag2 = ((BoneWeight)(ref val)).boneIndex1 >= 0 && ((BoneWeight)(ref val)).boneIndex1 < bones.Length && (Object)(object)bones[((BoneWeight)(ref val)).boneIndex1] != (Object)null && ((BoneWeight)(ref val)).weight1 > 0f; - bool flag3 = ((BoneWeight)(ref val)).boneIndex2 >= 0 && ((BoneWeight)(ref val)).boneIndex2 < bones.Length && (Object)(object)bones[((BoneWeight)(ref val)).boneIndex2] != (Object)null && ((BoneWeight)(ref val)).weight2 > 0f; - bool num = ((BoneWeight)(ref val)).boneIndex3 >= 0 && ((BoneWeight)(ref val)).boneIndex3 < bones.Length && (Object)(object)bones[((BoneWeight)(ref val)).boneIndex3] != (Object)null && ((BoneWeight)(ref val)).weight3 > 0f; - float num2 = (flag ? ((BoneWeight)(ref val)).weight0 : 0f); - float num3 = (flag2 ? ((BoneWeight)(ref val)).weight1 : 0f); - float num4 = (flag3 ? ((BoneWeight)(ref val)).weight2 : 0f); - float num5 = (num ? ((BoneWeight)(ref val)).weight3 : 0f); - float num6 = num2 + num3 + num4 + num5; - if (num6 <= 1E-08f) - { - return ((Component)smr).transform.InverseTransformPoint(targetWorld); - } - num2 /= num6; - num3 /= num6; - num4 /= num6; - num5 /= num6; - Vector3 val2 = ((Component)smr).transform.InverseTransformPoint(targetWorld); - Matrix4x4 objWorldInv = ((Component)smr).transform.worldToLocalMatrix; - Matrix4x4 acc = Matrix4x4.zero; - if (num2 > 0f) - { - Acc(ref acc, ((BoneWeight)(ref val)).boneIndex0, num2); - } - if (num3 > 0f) - { - Acc(ref acc, ((BoneWeight)(ref val)).boneIndex1, num3); - } - if (num4 > 0f) - { - Acc(ref acc, ((BoneWeight)(ref val)).boneIndex2, num4); - } - if (num5 > 0f) - { - Acc(ref acc, ((BoneWeight)(ref val)).boneIndex3, num5); - } - if (Mathf.Abs(acc.m00 * (acc.m11 * acc.m22 - acc.m12 * acc.m21) - acc.m01 * (acc.m10 * acc.m22 - acc.m12 * acc.m20) + acc.m02 * (acc.m10 * acc.m21 - acc.m11 * acc.m20)) < 1E-12f) - { - return val2; - } - acc.m33 = 1f; - Matrix4x4 val3 = Matrix4x4.Inverse(acc); - Vector3 val4 = ((Matrix4x4)(ref val3)).MultiplyPoint3x4(val2); - Debug.Log((object)$"Diff{((Component)smr).transform.TransformPoint(val4) - targetWorld}"); - return val4; - void Acc(ref Matrix4x4 reference, int boneIndex, float w) - { - //IL_000a: Unknown result type (might be due to invalid IL or missing references) - //IL_0017: Unknown result type (might be due to invalid IL or missing references) - //IL_001c: Unknown result type (might be due to invalid IL or missing references) - //IL_0028: Unknown result type (might be due to invalid IL or missing references) - //IL_002d: Unknown result type (might be due to invalid IL or missing references) - //IL_0032: Unknown result type (might be due to invalid IL or missing references) - //IL_003b: Unknown result type (might be due to invalid IL or missing references) - //IL_004d: Unknown result type (might be due to invalid IL or missing references) - //IL_005f: Unknown result type (might be due to invalid IL or missing references) - //IL_0071: Unknown result type (might be due to invalid IL or missing references) - //IL_0083: Unknown result type (might be due to invalid IL or missing references) - //IL_0095: Unknown result type (might be due to invalid IL or missing references) - //IL_00a7: Unknown result type (might be due to invalid IL or missing references) - //IL_00b9: 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) - if (!(w <= 0f)) - { - Matrix4x4 val5 = objWorldInv * bones[boneIndex].localToWorldMatrix * bindposes[boneIndex]; - reference.m00 += val5.m00 * w; - reference.m01 += val5.m01 * w; - reference.m02 += val5.m02 * w; - reference.m10 += val5.m10 * w; - reference.m11 += val5.m11 * w; - reference.m12 += val5.m12 * w; - reference.m20 += val5.m20 * w; - reference.m21 += val5.m21 * w; - reference.m22 += val5.m22 * w; - } - } - } + public Vector3 WorldPosToBindPos(SkinnedMeshRenderer smr, Mesh bindMesh, int vertexIndex, Vector3 targetWorld) + { + //IL_0012: Unknown result type (might be due to invalid IL or missing references) + //IL_0052: Unknown result type (might be due to invalid IL or missing references) + //IL_0054: Unknown result type (might be due to invalid IL or missing references) + //IL_006a: Unknown result type (might be due to invalid IL or missing references) + //IL_006c: 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_008a: 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_023a: Unknown result type (might be due to invalid IL or missing references) + //IL_023c: Unknown result type (might be due to invalid IL or missing references) + //IL_0241: 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_0250: Unknown result type (might be due to invalid IL or missing references) + //IL_0255: Unknown result type (might be due to invalid IL or missing references) + //IL_025a: Unknown result type (might be due to invalid IL or missing references) + //IL_0210: Unknown result type (might be due to invalid IL or missing references) + //IL_0212: Unknown result type (might be due to invalid IL or missing references) + //IL_02c8: Unknown result type (might be due to invalid IL or missing references) + //IL_02cf: Unknown result type (might be due to invalid IL or missing references) + //IL_02d6: Unknown result type (might be due to invalid IL or missing references) + //IL_02de: Unknown result type (might be due to invalid IL or missing references) + //IL_02e5: Unknown result type (might be due to invalid IL or missing references) + //IL_02ef: Unknown result type (might be due to invalid IL or missing references) + //IL_02f6: Unknown result type (might be due to invalid IL or missing references) + //IL_02fd: Unknown result type (might be due to invalid IL or missing references) + //IL_0305: Unknown result type (might be due to invalid IL or missing references) + //IL_030c: Unknown result type (might be due to invalid IL or missing references) + //IL_0317: Unknown result type (might be due to invalid IL or missing references) + //IL_031e: Unknown result type (might be due to invalid IL or missing references) + //IL_0325: Unknown result type (might be due to invalid IL or missing references) + //IL_032d: Unknown result type (might be due to invalid IL or missing references) + //IL_0334: 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_035c: Unknown result type (might be due to invalid IL or missing references) + //IL_0361: Unknown result type (might be due to invalid IL or missing references) + //IL_0365: Unknown result type (might be due to invalid IL or missing references) + //IL_0367: Unknown result type (might be due to invalid IL or missing references) + //IL_036c: Unknown result type (might be due to invalid IL or missing references) + //IL_0379: Unknown result type (might be due to invalid IL or missing references) + //IL_037b: Unknown result type (might be due to invalid IL or missing references) + //IL_0380: Unknown result type (might be due to invalid IL or missing references) + //IL_0382: Unknown result type (might be due to invalid IL or missing references) + //IL_0396: Unknown result type (might be due to invalid IL or missing references) + //IL_034b: Unknown result type (might be due to invalid IL or missing references) + if (smr == null || bindMesh == null) + { + return Vector3.zero; + } + BoneWeight[] boneWeights = bindMesh.boneWeights; + Matrix4x4[] bindposes = bindMesh.bindposes; + Transform[] bones = smr.bones; + if (boneWeights == null || bindposes == null || bones == null) + { + return ((Component)smr).transform.InverseTransformPoint(targetWorld); + } + if (vertexIndex < 0 || vertexIndex >= boneWeights.Length) + { + return ((Component)smr).transform.InverseTransformPoint(targetWorld); + } + if (bindposes.Length != bones.Length) + { + return ((Component)smr).transform.InverseTransformPoint(targetWorld); + } + BoneWeight val = boneWeights[vertexIndex]; + bool flag = val.boneIndex0 >= 0 && val.boneIndex0 < bones.Length && bones[val.boneIndex0] != null && val.weight0 > 0f; + bool flag2 = val.boneIndex1 >= 0 && val.boneIndex1 < bones.Length && bones[val.boneIndex1] != null && val.weight1 > 0f; + bool flag3 = val.boneIndex2 >= 0 && val.boneIndex2 < bones.Length && bones[val.boneIndex2] != null && val.weight2 > 0f; + bool num = val.boneIndex3 >= 0 && val.boneIndex3 < bones.Length && bones[val.boneIndex3] != null && val.weight3 > 0f; + float num2 = (flag ? val.weight0 : 0f); + float num3 = (flag2 ? val.weight1 : 0f); + float num4 = (flag3 ? val.weight2 : 0f); + float num5 = (num ? val.weight3 : 0f); + float num6 = num2 + num3 + num4 + num5; + if (num6 <= 1E-08f) + { + return ((Component)smr).transform.InverseTransformPoint(targetWorld); + } + num2 /= num6; + num3 /= num6; + num4 /= num6; + num5 /= num6; + Vector3 val2 = ((Component)smr).transform.InverseTransformPoint(targetWorld); + Matrix4x4 objWorldInv = ((Component)smr).transform.worldToLocalMatrix; + Matrix4x4 acc = Matrix4x4.zero; + if (num2 > 0f) + { + Acc(ref acc, val.boneIndex0, num2); + } + if (num3 > 0f) + { + Acc(ref acc, val.boneIndex1, num3); + } + if (num4 > 0f) + { + Acc(ref acc, val.boneIndex2, num4); + } + if (num5 > 0f) + { + Acc(ref acc, val.boneIndex3, num5); + } + if (Mathf.Abs(acc.m00 * (acc.m11 * acc.m22 - acc.m12 * acc.m21) - acc.m01 * (acc.m10 * acc.m22 - acc.m12 * acc.m20) + acc.m02 * (acc.m10 * acc.m21 - acc.m11 * acc.m20)) < 1E-12f) + { + return val2; + } + acc.m33 = 1f; + Matrix4x4 val3 = Matrix4x4.Inverse(acc); + Vector3 val4 = val3.MultiplyPoint3x4(val2); + Debug.Log($"Diff{((Component)smr).transform.TransformPoint(val4) - targetWorld}"); + return val4; + void Acc(ref Matrix4x4 reference, int boneIndex, float w) + { + //IL_000a: Unknown result type (might be due to invalid IL or missing references) + //IL_0017: Unknown result type (might be due to invalid IL or missing references) + //IL_001c: Unknown result type (might be due to invalid IL or missing references) + //IL_0028: Unknown result type (might be due to invalid IL or missing references) + //IL_002d: Unknown result type (might be due to invalid IL or missing references) + //IL_0032: Unknown result type (might be due to invalid IL or missing references) + //IL_003b: Unknown result type (might be due to invalid IL or missing references) + //IL_004d: Unknown result type (might be due to invalid IL or missing references) + //IL_005f: Unknown result type (might be due to invalid IL or missing references) + //IL_0071: Unknown result type (might be due to invalid IL or missing references) + //IL_0083: Unknown result type (might be due to invalid IL or missing references) + //IL_0095: Unknown result type (might be due to invalid IL or missing references) + //IL_00a7: Unknown result type (might be due to invalid IL or missing references) + //IL_00b9: 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) + if (!(w <= 0f)) + { + Matrix4x4 val5 = objWorldInv * bones[boneIndex].localToWorldMatrix * bindposes[boneIndex]; + reference.m00 += val5.m00 * w; + reference.m01 += val5.m01 * w; + reference.m02 += val5.m02 * w; + reference.m10 += val5.m10 * w; + reference.m11 += val5.m11 * w; + reference.m12 += val5.m12 * w; + reference.m20 += val5.m20 * w; + reference.m21 += val5.m21 * w; + reference.m22 += val5.m22 * w; + } + } + } - public Vector3 WorldPosToBindPos_Full(SkinnedMeshRenderer smr, Mesh bindMesh, int vertexIndex, Vector3 targetWorld) - { - //IL_0012: Unknown result type (might be due to invalid IL or missing references) - //IL_0052: Unknown result type (might be due to invalid IL or missing references) - //IL_0054: Unknown result type (might be due to invalid IL or missing references) - //IL_006a: Unknown result type (might be due to invalid IL or missing references) - //IL_006c: 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_008a: 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_0157: 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_0183: Unknown result type (might be due to invalid IL or missing references) - //IL_0185: Unknown result type (might be due to invalid IL or missing references) - //IL_018a: Unknown result type (might be due to invalid IL or missing references) - //IL_018e: Unknown result type (might be due to invalid IL or missing references) - //IL_0195: Unknown result type (might be due to invalid IL or missing references) - //IL_019c: Unknown result type (might be due to invalid IL or missing references) - //IL_01b5: Unknown result type (might be due to invalid IL or missing references) - //IL_01ba: Unknown result type (might be due to invalid IL or missing references) - //IL_01bf: Unknown result type (might be due to invalid IL or missing references) - //IL_01c4: 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_0211: Unknown result type (might be due to invalid IL or missing references) - //IL_0218: Unknown result type (might be due to invalid IL or missing references) - //IL_0220: Unknown result type (might be due to invalid IL or missing references) - //IL_0227: Unknown result type (might be due to invalid IL or missing references) - //IL_0231: Unknown result type (might be due to invalid IL or missing references) - //IL_0238: 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_0247: 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_0259: Unknown result type (might be due to invalid IL or missing references) - //IL_0260: 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_026f: Unknown result type (might be due to invalid IL or missing references) - //IL_0276: Unknown result type (might be due to invalid IL or missing references) - //IL_0290: Unknown result type (might be due to invalid IL or missing references) - //IL_0292: Unknown result type (might be due to invalid IL or missing references) - //IL_0297: Unknown result type (might be due to invalid IL or missing references) - //IL_029b: Unknown result type (might be due to invalid IL or missing references) - //IL_029d: Unknown result type (might be due to invalid IL or missing references) - //IL_02a2: Unknown result type (might be due to invalid IL or missing references) - //IL_028d: Unknown result type (might be due to invalid IL or missing references) - if ((Object)(object)smr == (Object)null || (Object)(object)bindMesh == (Object)null) - { - return Vector3.zero; - } - BoneWeight[] boneWeights = bindMesh.boneWeights; - Matrix4x4[] bindposes = bindMesh.bindposes; - Transform[] bones = smr.bones; - if (boneWeights == null || bindposes == null || bones == null) - { - return ((Component)smr).transform.InverseTransformPoint(targetWorld); - } - if (vertexIndex < 0 || vertexIndex >= boneWeights.Length) - { - return ((Component)smr).transform.InverseTransformPoint(targetWorld); - } - if (bindposes.Length != bones.Length) - { - return ((Component)smr).transform.InverseTransformPoint(targetWorld); - } - BoneWeight val = boneWeights[vertexIndex]; - float[] array = new float[4]; - int[] array2 = new int[4]; - array[0] = ((BoneWeight)(ref val)).weight0; - array2[0] = ((BoneWeight)(ref val)).boneIndex0; - array[1] = ((BoneWeight)(ref val)).weight1; - array2[1] = ((BoneWeight)(ref val)).boneIndex1; - array[2] = ((BoneWeight)(ref val)).weight2; - array2[2] = ((BoneWeight)(ref val)).boneIndex2; - array[3] = ((BoneWeight)(ref val)).weight3; - array2[3] = ((BoneWeight)(ref val)).boneIndex3; - float num = 0f; - for (int i = 0; i < 4; i++) - { - if (array2[i] >= 0 && array2[i] < bones.Length && (Object)(object)bones[array2[i]] != (Object)null) - { - num += array[i]; - } - } - if (num < 1E-08f) - { - return ((Component)smr).transform.InverseTransformPoint(targetWorld); - } - for (int j = 0; j < 4; j++) - { - array[j] /= num; - } - Vector3 val2 = ((Component)smr).transform.InverseTransformPoint(targetWorld); - Vector4 val3 = default(Vector4); - ((Vector4)(ref val3))._002Ector(val2.x, val2.y, val2.z, 1f); - Matrix4x4 objWorldInv = ((Component)smr).transform.worldToLocalMatrix; - Matrix4x4 acc = Matrix4x4.zero; - for (int k = 0; k < 4; k++) - { - if (array[k] > 0f && array2[k] >= 0 && array2[k] < bones.Length) - { - Accumulate(ref acc, array2[k], array[k]); - } - } - if (Mathf.Abs(acc.m00 * (acc.m11 * acc.m22 - acc.m12 * acc.m21) - acc.m01 * (acc.m10 * acc.m22 - acc.m12 * acc.m20) + acc.m02 * (acc.m10 * acc.m21 - acc.m11 * acc.m20)) < 1E-12f) - { - return val2; - } - Matrix4x4 val4 = Matrix4x4.Inverse(acc); - return ((Matrix4x4)(ref val4)).MultiplyPoint3x4(Vector4.op_Implicit(val3)); - void Accumulate(ref Matrix4x4 reference, int bi, float w) - { - //IL_000a: Unknown result type (might be due to invalid IL or missing references) - //IL_0017: Unknown result type (might be due to invalid IL or missing references) - //IL_001c: Unknown result type (might be due to invalid IL or missing references) - //IL_0028: Unknown result type (might be due to invalid IL or missing references) - //IL_002d: Unknown result type (might be due to invalid IL or missing references) - //IL_0032: Unknown result type (might be due to invalid IL or missing references) - //IL_003b: Unknown result type (might be due to invalid IL or missing references) - //IL_004d: Unknown result type (might be due to invalid IL or missing references) - //IL_005f: Unknown result type (might be due to invalid IL or missing references) - //IL_0071: Unknown result type (might be due to invalid IL or missing references) - //IL_0083: Unknown result type (might be due to invalid IL or missing references) - //IL_0095: Unknown result type (might be due to invalid IL or missing references) - //IL_00a7: Unknown result type (might be due to invalid IL or missing references) - //IL_00b9: 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_00dd: Unknown result type (might be due to invalid IL or missing references) - //IL_00ef: Unknown result type (might be due to invalid IL or missing references) - //IL_0101: 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_0125: Unknown result type (might be due to invalid IL or missing references) - //IL_0137: 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) - if (!(w <= 0f)) - { - Matrix4x4 val5 = objWorldInv * bones[bi].localToWorldMatrix * bindposes[bi]; - reference.m00 += val5.m00 * w; - reference.m01 += val5.m01 * w; - reference.m02 += val5.m02 * w; - reference.m03 += val5.m03 * w; - reference.m10 += val5.m10 * w; - reference.m11 += val5.m11 * w; - reference.m12 += val5.m12 * w; - reference.m13 += val5.m13 * w; - reference.m20 += val5.m20 * w; - reference.m21 += val5.m21 * w; - reference.m22 += val5.m22 * w; - reference.m23 += val5.m23 * w; - reference.m30 += val5.m30 * w; - reference.m31 += val5.m31 * w; - reference.m32 += val5.m32 * w; - reference.m33 += val5.m33 * w; - } - } - } + public Vector3 WorldPosToBindPos_Full(SkinnedMeshRenderer smr, Mesh bindMesh, int vertexIndex, Vector3 targetWorld) + { + //IL_0012: Unknown result type (might be due to invalid IL or missing references) + //IL_0052: Unknown result type (might be due to invalid IL or missing references) + //IL_0054: Unknown result type (might be due to invalid IL or missing references) + //IL_006a: Unknown result type (might be due to invalid IL or missing references) + //IL_006c: 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_008a: 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_0157: 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_0183: Unknown result type (might be due to invalid IL or missing references) + //IL_0185: Unknown result type (might be due to invalid IL or missing references) + //IL_018a: Unknown result type (might be due to invalid IL or missing references) + //IL_018e: Unknown result type (might be due to invalid IL or missing references) + //IL_0195: Unknown result type (might be due to invalid IL or missing references) + //IL_019c: Unknown result type (might be due to invalid IL or missing references) + //IL_01b5: Unknown result type (might be due to invalid IL or missing references) + //IL_01ba: Unknown result type (might be due to invalid IL or missing references) + //IL_01bf: Unknown result type (might be due to invalid IL or missing references) + //IL_01c4: 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_0211: Unknown result type (might be due to invalid IL or missing references) + //IL_0218: Unknown result type (might be due to invalid IL or missing references) + //IL_0220: Unknown result type (might be due to invalid IL or missing references) + //IL_0227: Unknown result type (might be due to invalid IL or missing references) + //IL_0231: Unknown result type (might be due to invalid IL or missing references) + //IL_0238: 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_0247: 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_0259: Unknown result type (might be due to invalid IL or missing references) + //IL_0260: 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_026f: Unknown result type (might be due to invalid IL or missing references) + //IL_0276: Unknown result type (might be due to invalid IL or missing references) + //IL_0290: Unknown result type (might be due to invalid IL or missing references) + //IL_0292: Unknown result type (might be due to invalid IL or missing references) + //IL_0297: Unknown result type (might be due to invalid IL or missing references) + //IL_029b: Unknown result type (might be due to invalid IL or missing references) + //IL_029d: Unknown result type (might be due to invalid IL or missing references) + //IL_02a2: Unknown result type (might be due to invalid IL or missing references) + //IL_028d: Unknown result type (might be due to invalid IL or missing references) + if (smr == null || bindMesh == null) + { + return Vector3.zero; + } + BoneWeight[] boneWeights = bindMesh.boneWeights; + Matrix4x4[] bindposes = bindMesh.bindposes; + Transform[] bones = smr.bones; + if (boneWeights == null || bindposes == null || bones == null) + { + return ((Component)smr).transform.InverseTransformPoint(targetWorld); + } + if (vertexIndex < 0 || vertexIndex >= boneWeights.Length) + { + return ((Component)smr).transform.InverseTransformPoint(targetWorld); + } + if (bindposes.Length != bones.Length) + { + return ((Component)smr).transform.InverseTransformPoint(targetWorld); + } + BoneWeight val = boneWeights[vertexIndex]; + float[] array = new float[4]; + int[] array2 = new int[4]; + array[0] = val.weight0; + array2[0] = val.boneIndex0; + array[1] = val.weight1; + array2[1] = val.boneIndex1; + array[2] = val.weight2; + array2[2] = val.boneIndex2; + array[3] = val.weight3; + array2[3] = val.boneIndex3; + float num = 0f; + for (int i = 0; i < 4; i++) + { + if (array2[i] >= 0 && array2[i] < bones.Length && bones[array2[i]] != null) + { + num += array[i]; + } + } + if (num < 1E-08f) + { + return ((Component)smr).transform.InverseTransformPoint(targetWorld); + } + for (int j = 0; j < 4; j++) + { + array[j] /= num; + } + Vector3 val2 = smr.transform.InverseTransformPoint(targetWorld); + Vector4 val3 = new Vector4(val2.x, val2.y, val2.z, 1f); + Matrix4x4 objWorldInv = ((Component)smr).transform.worldToLocalMatrix; + Matrix4x4 acc = Matrix4x4.zero; + for (int k = 0; k < 4; k++) + { + if (array[k] > 0f && array2[k] >= 0 && array2[k] < bones.Length) + { + Accumulate(ref acc, array2[k], array[k]); + } + } + if (Mathf.Abs(acc.m00 * (acc.m11 * acc.m22 - acc.m12 * acc.m21) - acc.m01 * (acc.m10 * acc.m22 - acc.m12 * acc.m20) + acc.m02 * (acc.m10 * acc.m21 - acc.m11 * acc.m20)) < 1E-12f) + { + return val2; + } + Matrix4x4 val4 = Matrix4x4.Inverse(acc); + return val4.MultiplyPoint3x4((Vector4)val3); + void Accumulate(ref Matrix4x4 reference, int bi, float w) + { + //IL_000a: Unknown result type (might be due to invalid IL or missing references) + //IL_0017: Unknown result type (might be due to invalid IL or missing references) + //IL_001c: Unknown result type (might be due to invalid IL or missing references) + //IL_0028: Unknown result type (might be due to invalid IL or missing references) + //IL_002d: Unknown result type (might be due to invalid IL or missing references) + //IL_0032: Unknown result type (might be due to invalid IL or missing references) + //IL_003b: Unknown result type (might be due to invalid IL or missing references) + //IL_004d: Unknown result type (might be due to invalid IL or missing references) + //IL_005f: Unknown result type (might be due to invalid IL or missing references) + //IL_0071: Unknown result type (might be due to invalid IL or missing references) + //IL_0083: Unknown result type (might be due to invalid IL or missing references) + //IL_0095: Unknown result type (might be due to invalid IL or missing references) + //IL_00a7: Unknown result type (might be due to invalid IL or missing references) + //IL_00b9: 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_00dd: Unknown result type (might be due to invalid IL or missing references) + //IL_00ef: Unknown result type (might be due to invalid IL or missing references) + //IL_0101: 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_0125: Unknown result type (might be due to invalid IL or missing references) + //IL_0137: 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) + if (!(w <= 0f)) + { + Matrix4x4 val5 = objWorldInv * bones[bi].localToWorldMatrix * bindposes[bi]; + reference.m00 += val5.m00 * w; + reference.m01 += val5.m01 * w; + reference.m02 += val5.m02 * w; + reference.m03 += val5.m03 * w; + reference.m10 += val5.m10 * w; + reference.m11 += val5.m11 * w; + reference.m12 += val5.m12 * w; + reference.m13 += val5.m13 * w; + reference.m20 += val5.m20 * w; + reference.m21 += val5.m21 * w; + reference.m22 += val5.m22 * w; + reference.m23 += val5.m23 * w; + reference.m30 += val5.m30 * w; + reference.m31 += val5.m31 * w; + reference.m32 += val5.m32 * w; + reference.m33 += val5.m33 * w; + } + } + } - public Vector3 WorldDirToBindDir_Full(SkinnedMeshRenderer smr, Mesh bindMesh, int vertexIndex, Vector3 targetWorldDir) - { - //IL_0012: Unknown result type (might be due to invalid IL or missing references) - //IL_0052: Unknown result type (might be due to invalid IL or missing references) - //IL_0054: Unknown result type (might be due to invalid IL or missing references) - //IL_0059: Unknown result type (might be due to invalid IL or missing references) - //IL_005d: Unknown result type (might be due to invalid IL or missing references) - //IL_0073: Unknown result type (might be due to invalid IL or missing references) - //IL_0075: Unknown result type (might be due to invalid IL or missing references) - //IL_007a: Unknown result type (might be due to invalid IL or missing references) - //IL_007e: Unknown result type (might be due to invalid IL or missing references) - //IL_00af: Unknown result type (might be due to invalid IL or missing references) - //IL_00b4: Unknown result type (might be due to invalid IL or missing references) - //IL_009c: Unknown result type (might be due to invalid IL or missing references) - //IL_009e: Unknown result type (might be due to invalid IL or missing references) - //IL_00a3: Unknown result type (might be due to invalid IL or missing references) - //IL_00a7: Unknown result type (might be due to invalid IL or missing references) - //IL_0172: Unknown result type (might be due to invalid IL or missing references) - //IL_0174: Unknown result type (might be due to invalid IL or missing references) - //IL_0179: Unknown result type (might be due to invalid IL or missing references) - //IL_017d: Unknown result type (might be due to invalid IL or missing references) - //IL_01a7: 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_01ae: Unknown result type (might be due to invalid IL or missing references) - //IL_01cc: Unknown result type (might be due to invalid IL or missing references) - //IL_01d1: Unknown result type (might be due to invalid IL or missing references) - //IL_01d6: Unknown result type (might be due to invalid IL or missing references) - //IL_01db: 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_0223: Unknown result type (might be due to invalid IL or missing references) - //IL_0228: Unknown result type (might be due to invalid IL or missing references) - //IL_022c: Unknown result type (might be due to invalid IL or missing references) - //IL_022e: 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_024d: Unknown result type (might be due to invalid IL or missing references) - //IL_0245: Unknown result type (might be due to invalid IL or missing references) - if ((Object)(object)smr == (Object)null || (Object)(object)bindMesh == (Object)null) - { - return Vector3.zero; - } - BoneWeight[] boneWeights = bindMesh.boneWeights; - Matrix4x4[] bindposes = bindMesh.bindposes; - Transform[] bones = smr.bones; - Vector3 val; - if (boneWeights == null || bindposes == null || bones == null) - { - val = ((Component)smr).transform.InverseTransformDirection(targetWorldDir); - return ((Vector3)(ref val)).normalized; - } - if (vertexIndex < 0 || vertexIndex >= boneWeights.Length) - { - val = ((Component)smr).transform.InverseTransformDirection(targetWorldDir); - return ((Vector3)(ref val)).normalized; - } - if (bindposes.Length != bones.Length) - { - val = ((Component)smr).transform.InverseTransformDirection(targetWorldDir); - return ((Vector3)(ref val)).normalized; - } - BoneWeight val2 = boneWeights[vertexIndex]; - float[] array = new float[4]; - int[] array2 = new int[4]; - array[0] = ((BoneWeight)(ref val2)).weight0; - array2[0] = ((BoneWeight)(ref val2)).boneIndex0; - array[1] = ((BoneWeight)(ref val2)).weight1; - array2[1] = ((BoneWeight)(ref val2)).boneIndex1; - array[2] = ((BoneWeight)(ref val2)).weight2; - array2[2] = ((BoneWeight)(ref val2)).boneIndex2; - array[3] = ((BoneWeight)(ref val2)).weight3; - array2[3] = ((BoneWeight)(ref val2)).boneIndex3; - float num = 0f; - for (int i = 0; i < 4; i++) - { - if (array2[i] >= 0 && array2[i] < bones.Length && (Object)(object)bones[array2[i]] != (Object)null) - { - num += array[i]; - } - } - if (num < 1E-08f) - { - val = ((Component)smr).transform.InverseTransformDirection(targetWorldDir); - return ((Vector3)(ref val)).normalized; - } - for (int j = 0; j < 4; j++) - { - array[j] /= num; - } - Vector3 val3 = ((Component)smr).transform.InverseTransformDirection(targetWorldDir); - if (((Vector3)(ref val3)).sqrMagnitude < 1E-12f) - { - return Vector3.up; - } - Matrix4x4 objWorldInv = ((Component)smr).transform.worldToLocalMatrix; - Matrix4x4 acc = Matrix4x4.zero; - for (int k = 0; k < 4; k++) - { - if (array[k] > 0f && array2[k] >= 0 && array2[k] < bones.Length) - { - Accumulate(ref acc, array2[k], array[k]); - } - } - Matrix4x4 transpose = ((Matrix4x4)(ref acc)).transpose; - Vector3 val4 = ((Matrix4x4)(ref transpose)).MultiplyVector(val3); - if (((Vector3)(ref val4)).sqrMagnitude < 1E-12f) - { - return ((Vector3)(ref val3)).normalized; - } - return ((Vector3)(ref val4)).normalized; - void Accumulate(ref Matrix4x4 reference, int bi, float w) - { - //IL_000a: Unknown result type (might be due to invalid IL or missing references) - //IL_0017: Unknown result type (might be due to invalid IL or missing references) - //IL_001c: Unknown result type (might be due to invalid IL or missing references) - //IL_0028: Unknown result type (might be due to invalid IL or missing references) - //IL_002d: Unknown result type (might be due to invalid IL or missing references) - //IL_0032: Unknown result type (might be due to invalid IL or missing references) - //IL_003b: Unknown result type (might be due to invalid IL or missing references) - //IL_004d: Unknown result type (might be due to invalid IL or missing references) - //IL_005f: Unknown result type (might be due to invalid IL or missing references) - //IL_0071: Unknown result type (might be due to invalid IL or missing references) - //IL_0083: Unknown result type (might be due to invalid IL or missing references) - //IL_0095: Unknown result type (might be due to invalid IL or missing references) - //IL_00a7: Unknown result type (might be due to invalid IL or missing references) - //IL_00b9: 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_00dd: Unknown result type (might be due to invalid IL or missing references) - //IL_00ef: Unknown result type (might be due to invalid IL or missing references) - //IL_0101: 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_0125: Unknown result type (might be due to invalid IL or missing references) - //IL_0137: 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) - if (!(w <= 0f)) - { - Matrix4x4 val5 = objWorldInv * bones[bi].localToWorldMatrix * bindposes[bi]; - reference.m00 += val5.m00 * w; - reference.m01 += val5.m01 * w; - reference.m02 += val5.m02 * w; - reference.m03 += val5.m03 * w; - reference.m10 += val5.m10 * w; - reference.m11 += val5.m11 * w; - reference.m12 += val5.m12 * w; - reference.m13 += val5.m13 * w; - reference.m20 += val5.m20 * w; - reference.m21 += val5.m21 * w; - reference.m22 += val5.m22 * w; - reference.m23 += val5.m23 * w; - reference.m30 += val5.m30 * w; - reference.m31 += val5.m31 * w; - reference.m32 += val5.m32 * w; - reference.m33 += val5.m33 * w; - } - } - } + public Vector3 WorldDirToBindDir_Full(SkinnedMeshRenderer smr, Mesh bindMesh, int vertexIndex, Vector3 targetWorldDir) + { + //IL_0012: Unknown result type (might be due to invalid IL or missing references) + //IL_0052: Unknown result type (might be due to invalid IL or missing references) + //IL_0054: Unknown result type (might be due to invalid IL or missing references) + //IL_0059: Unknown result type (might be due to invalid IL or missing references) + //IL_005d: Unknown result type (might be due to invalid IL or missing references) + //IL_0073: Unknown result type (might be due to invalid IL or missing references) + //IL_0075: Unknown result type (might be due to invalid IL or missing references) + //IL_007a: Unknown result type (might be due to invalid IL or missing references) + //IL_007e: Unknown result type (might be due to invalid IL or missing references) + //IL_00af: Unknown result type (might be due to invalid IL or missing references) + //IL_00b4: Unknown result type (might be due to invalid IL or missing references) + //IL_009c: Unknown result type (might be due to invalid IL or missing references) + //IL_009e: Unknown result type (might be due to invalid IL or missing references) + //IL_00a3: Unknown result type (might be due to invalid IL or missing references) + //IL_00a7: Unknown result type (might be due to invalid IL or missing references) + //IL_0172: Unknown result type (might be due to invalid IL or missing references) + //IL_0174: Unknown result type (might be due to invalid IL or missing references) + //IL_0179: Unknown result type (might be due to invalid IL or missing references) + //IL_017d: Unknown result type (might be due to invalid IL or missing references) + //IL_01a7: 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_01ae: Unknown result type (might be due to invalid IL or missing references) + //IL_01cc: Unknown result type (might be due to invalid IL or missing references) + //IL_01d1: Unknown result type (might be due to invalid IL or missing references) + //IL_01d6: Unknown result type (might be due to invalid IL or missing references) + //IL_01db: 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_0223: Unknown result type (might be due to invalid IL or missing references) + //IL_0228: Unknown result type (might be due to invalid IL or missing references) + //IL_022c: Unknown result type (might be due to invalid IL or missing references) + //IL_022e: 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_024d: Unknown result type (might be due to invalid IL or missing references) + //IL_0245: Unknown result type (might be due to invalid IL or missing references) + if (smr == null || bindMesh == null) + { + return Vector3.zero; + } + BoneWeight[] boneWeights = bindMesh.boneWeights; + Matrix4x4[] bindposes = bindMesh.bindposes; + Transform[] bones = smr.bones; + Vector3 val; + if (boneWeights == null || bindposes == null || bones == null) + { + val = ((Component)smr).transform.InverseTransformDirection(targetWorldDir); + return val.normalized; + } + if (vertexIndex < 0 || vertexIndex >= boneWeights.Length) + { + val = ((Component)smr).transform.InverseTransformDirection(targetWorldDir); + return val.normalized; + } + if (bindposes.Length != bones.Length) + { + val = ((Component)smr).transform.InverseTransformDirection(targetWorldDir); + return val.normalized; + } + BoneWeight val2 = boneWeights[vertexIndex]; + float[] array = new float[4]; + int[] array2 = new int[4]; + array[0] = val2.weight0; + array2[0] = val2.boneIndex0; + array[1] = val2.weight1; + array2[1] = val2.boneIndex1; + array[2] = val2.weight2; + array2[2] = val2.boneIndex2; + array[3] = val2.weight3; + array2[3] = val2.boneIndex3; + float num = 0f; + for (int i = 0; i < 4; i++) + { + if (array2[i] >= 0 && array2[i] < bones.Length && bones[array2[i]] != null) + { + num += array[i]; + } + } + if (num < 1E-08f) + { + val = ((Component)smr).transform.InverseTransformDirection(targetWorldDir); + return val.normalized; + } + for (int j = 0; j < 4; j++) + { + array[j] /= num; + } + Vector3 val3 = ((Component)smr).transform.InverseTransformDirection(targetWorldDir); + if (val3.sqrMagnitude < 1E-12f) + { + return Vector3.up; + } + Matrix4x4 objWorldInv = ((Component)smr).transform.worldToLocalMatrix; + Matrix4x4 acc = Matrix4x4.zero; + for (int k = 0; k < 4; k++) + { + if (array[k] > 0f && array2[k] >= 0 && array2[k] < bones.Length) + { + Accumulate(ref acc, array2[k], array[k]); + } + } + Matrix4x4 transpose = acc.transpose; + Vector3 val4 = transpose.MultiplyVector(val3); + if (val4.sqrMagnitude < 1E-12f) + { + return val3.normalized; + } + return val4.normalized; + void Accumulate(ref Matrix4x4 reference, int bi, float w) + { + //IL_000a: Unknown result type (might be due to invalid IL or missing references) + //IL_0017: Unknown result type (might be due to invalid IL or missing references) + //IL_001c: Unknown result type (might be due to invalid IL or missing references) + //IL_0028: Unknown result type (might be due to invalid IL or missing references) + //IL_002d: Unknown result type (might be due to invalid IL or missing references) + //IL_0032: Unknown result type (might be due to invalid IL or missing references) + //IL_003b: Unknown result type (might be due to invalid IL or missing references) + //IL_004d: Unknown result type (might be due to invalid IL or missing references) + //IL_005f: Unknown result type (might be due to invalid IL or missing references) + //IL_0071: Unknown result type (might be due to invalid IL or missing references) + //IL_0083: Unknown result type (might be due to invalid IL or missing references) + //IL_0095: Unknown result type (might be due to invalid IL or missing references) + //IL_00a7: Unknown result type (might be due to invalid IL or missing references) + //IL_00b9: 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_00dd: Unknown result type (might be due to invalid IL or missing references) + //IL_00ef: Unknown result type (might be due to invalid IL or missing references) + //IL_0101: 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_0125: Unknown result type (might be due to invalid IL or missing references) + //IL_0137: 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) + if (!(w <= 0f)) + { + Matrix4x4 val5 = objWorldInv * bones[bi].localToWorldMatrix * bindposes[bi]; + reference.m00 += val5.m00 * w; + reference.m01 += val5.m01 * w; + reference.m02 += val5.m02 * w; + reference.m03 += val5.m03 * w; + reference.m10 += val5.m10 * w; + reference.m11 += val5.m11 * w; + reference.m12 += val5.m12 * w; + reference.m13 += val5.m13 * w; + reference.m20 += val5.m20 * w; + reference.m21 += val5.m21 * w; + reference.m22 += val5.m22 * w; + reference.m23 += val5.m23 * w; + reference.m30 += val5.m30 * w; + reference.m31 += val5.m31 * w; + reference.m32 += val5.m32 * w; + reference.m33 += val5.m33 * w; + } + } + } } diff --git a/Assets/@Eden_Tools/Eden_AutoMorpher/Script/TempBoneMarker.cs b/Assets/@Eden_Tools/Eden_AutoMorpher/Script/TempBoneMarker.cs index f04c52e..4691e6f 100644 --- a/Assets/@Eden_Tools/Eden_AutoMorpher/Script/TempBoneMarker.cs +++ b/Assets/@Eden_Tools/Eden_AutoMorpher/Script/TempBoneMarker.cs @@ -1,4 +1,4 @@ -// Warning: Some assembly references could not be resolved automatically. This might lead to incorrect decompilation of some parts, +// 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 // TempBoneMarker @@ -7,9 +7,9 @@ using UnityEngine; public class TempBoneMarker : MonoBehaviour { - public Transform originalParent; + public Transform originalParent; - public string additionalInfo = ""; + public string additionalInfo = ""; - public List wrappedChildNames = new List(); + public List wrappedChildNames = new List(); } diff --git a/Assets/@Eden_Tools/Eden_AutoMorpher/Script/TransformInfo.cs b/Assets/@Eden_Tools/Eden_AutoMorpher/Script/TransformInfo.cs index 664dbd1..5d1d271 100644 --- a/Assets/@Eden_Tools/Eden_AutoMorpher/Script/TransformInfo.cs +++ b/Assets/@Eden_Tools/Eden_AutoMorpher/Script/TransformInfo.cs @@ -1,4 +1,4 @@ -// Warning: Some assembly references could not be resolved automatically. This might lead to incorrect decompilation of some parts, +// 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.TransformInfo @@ -6,83 +6,83 @@ using UnityEngine; public class TransformInfo { - public Transform parentTransform; + public Transform parentTransform; - public Vector3 position; + public Vector3 position; - public Vector3 localPosition; + public Vector3 localPosition; - public Quaternion rotation; + public Quaternion rotation; - public Quaternion localRotation; + public Quaternion localRotation; - public Vector3 localScale; + public Vector3 localScale; - public string name; + public string name; - public TransformInfo(Transform t) - { - //IL_0014: Unknown result type (might be due to invalid IL or missing references) - //IL_0019: Unknown result type (might be due to invalid IL or missing references) - //IL_0020: Unknown result type (might be due to invalid IL or missing references) - //IL_0025: Unknown result type (might be due to invalid IL or missing references) - //IL_002c: Unknown result type (might be due to invalid IL or missing references) - //IL_0031: Unknown result type (might be due to invalid IL or missing references) - //IL_0038: Unknown result type (might be due to invalid IL or missing references) - //IL_003d: Unknown result type (might be due to invalid IL or missing references) - //IL_0044: Unknown result type (might be due to invalid IL or missing references) - //IL_0049: Unknown result type (might be due to invalid IL or missing references) - parentTransform = t.parent; - position = t.position; - localPosition = t.localPosition; - rotation = t.rotation; - localRotation = t.localRotation; - localScale = t.localScale; - name = ((Object)t).name; - } + public TransformInfo(Transform t) + { + //IL_0014: Unknown result type (might be due to invalid IL or missing references) + //IL_0019: Unknown result type (might be due to invalid IL or missing references) + //IL_0020: Unknown result type (might be due to invalid IL or missing references) + //IL_0025: Unknown result type (might be due to invalid IL or missing references) + //IL_002c: Unknown result type (might be due to invalid IL or missing references) + //IL_0031: Unknown result type (might be due to invalid IL or missing references) + //IL_0038: Unknown result type (might be due to invalid IL or missing references) + //IL_003d: Unknown result type (might be due to invalid IL or missing references) + //IL_0044: Unknown result type (might be due to invalid IL or missing references) + //IL_0049: Unknown result type (might be due to invalid IL or missing references) + this.parentTransform = t.parent; + this.position = t.position; + this.localPosition = t.localPosition; + this.rotation = t.rotation; + this.localRotation = t.localRotation; + this.localScale = t.localScale; + this.name = ((Object)t).name; + } - public void ApplyToTransform(Transform t, bool applyParent, bool applyPosition, bool applyRotation, bool applyScale, bool applyName = false) - { - //IL_0046: Unknown result type (might be due to invalid IL or missing references) - //IL_0015: Unknown result type (might be due to invalid IL or missing references) - //IL_0056: Unknown result type (might be due to invalid IL or missing references) - //IL_0025: Unknown result type (might be due to invalid IL or missing references) - //IL_0066: Unknown result type (might be due to invalid IL or missing references) - //IL_0035: Unknown result type (might be due to invalid IL or missing references) - if (applyParent) - { - t.SetParent(parentTransform, true); - if (applyPosition) - { - t.localPosition = localPosition; - } - if (applyRotation) - { - t.localRotation = localRotation; - } - if (applyScale) - { - t.localScale = localScale; - } - } - else - { - if (applyPosition) - { - t.position = position; - } - if (applyRotation) - { - t.rotation = rotation; - } - if (applyScale) - { - t.localScale = localScale; - } - } - if (applyName) - { - ((Object)t).name = name; - } - } + public void ApplyToTransform(Transform t, bool applyParent, bool applyPosition, bool applyRotation, bool applyScale, bool applyName = false) + { + //IL_0046: Unknown result type (might be due to invalid IL or missing references) + //IL_0015: Unknown result type (might be due to invalid IL or missing references) + //IL_0056: Unknown result type (might be due to invalid IL or missing references) + //IL_0025: Unknown result type (might be due to invalid IL or missing references) + //IL_0066: Unknown result type (might be due to invalid IL or missing references) + //IL_0035: Unknown result type (might be due to invalid IL or missing references) + if (applyParent) + { + t.SetParent(this.parentTransform, true); + if (applyPosition) + { + t.localPosition = this.localPosition; + } + if (applyRotation) + { + t.localRotation = this.localRotation; + } + if (applyScale) + { + t.localScale = this.localScale; + } + } + else + { + if (applyPosition) + { + t.position = this.position; + } + if (applyRotation) + { + t.rotation = this.rotation; + } + if (applyScale) + { + t.localScale = this.localScale; + } + } + if (applyName) + { + ((Object)t).name = this.name; + } + } } diff --git a/Assets/@Eden_Tools/Eden_AutoMorpher/Script/TriangleUtil.cs b/Assets/@Eden_Tools/Eden_AutoMorpher/Script/TriangleUtil.cs index eeac3e3..3b2959d 100644 --- a/Assets/@Eden_Tools/Eden_AutoMorpher/Script/TriangleUtil.cs +++ b/Assets/@Eden_Tools/Eden_AutoMorpher/Script/TriangleUtil.cs @@ -1,4 +1,4 @@ -// Warning: Some assembly references could not be resolved automatically. This might lead to incorrect decompilation of some parts, +// 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.TriangleUtil @@ -6,108 +6,108 @@ using UnityEngine; public class TriangleUtil { - public Vector3 ClosestPointOnTriangle(Vector3 p, Vector3 a, Vector3 b, Vector3 c) - { - //IL_0000: Unknown result type (might be due to invalid IL or missing references) - //IL_0001: Unknown result type (might be due to invalid IL or missing references) - //IL_0002: Unknown result type (might be due to invalid IL or missing references) - //IL_0007: Unknown result type (might be due to invalid IL or missing references) - //IL_0008: Unknown result type (might be due to invalid IL or missing references) - //IL_000a: Unknown result type (might be due to invalid IL or missing references) - //IL_000b: Unknown result type (might be due to invalid IL or missing references) - //IL_0010: Unknown result type (might be due to invalid IL or missing references) - //IL_0011: 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_0013: Unknown result type (might be due to invalid IL or missing references) - //IL_0018: Unknown result type (might be due to invalid IL or missing references) - //IL_0019: Unknown result type (might be due to invalid IL or missing references) - //IL_001a: Unknown result type (might be due to invalid IL or missing references) - //IL_0021: Unknown result type (might be due to invalid IL or missing references) - //IL_0022: Unknown result type (might be due to invalid IL or missing references) - //IL_003d: Unknown result type (might be due to invalid IL or missing references) - //IL_003e: Unknown result type (might be due to invalid IL or missing references) - //IL_003f: Unknown result type (might be due to invalid IL or missing references) - //IL_0044: Unknown result type (might be due to invalid IL or missing references) - //IL_0046: Unknown result type (might be due to invalid IL or missing references) - //IL_0047: Unknown result type (might be due to invalid IL or missing references) - //IL_0050: Unknown result type (might be due to invalid IL or missing references) - //IL_0051: Unknown result type (might be due to invalid IL or missing references) - //IL_003b: Unknown result type (might be due to invalid IL or missing references) - //IL_00a8: Unknown result type (might be due to invalid IL or missing references) - //IL_00a9: Unknown result type (might be due to invalid IL or missing references) - //IL_00ab: Unknown result type (might be due to invalid IL or missing references) - //IL_00b0: Unknown result type (might be due to invalid IL or missing references) - //IL_00b2: Unknown result type (might be due to invalid IL or missing references) - //IL_00b3: Unknown result type (might be due to invalid IL or missing references) - //IL_00bc: Unknown result type (might be due to invalid IL or missing references) - //IL_00bd: Unknown result type (might be due to invalid IL or missing references) - //IL_0069: Unknown result type (might be due to invalid IL or missing references) - //IL_00d5: 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_009c: 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_00a2: 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_018e: Unknown result type (might be due to invalid IL or missing references) - //IL_0191: Unknown result type (might be due to invalid IL or missing references) - //IL_0196: Unknown result type (might be due to invalid IL or missing references) - //IL_019b: Unknown result type (might be due to invalid IL or missing references) - //IL_019e: Unknown result type (might be due to invalid IL or missing references) - //IL_01a3: Unknown result type (might be due to invalid IL or missing references) - //IL_0109: Unknown result type (might be due to invalid IL or missing references) - //IL_010c: 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_0112: 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_015c: 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) - //IL_015f: Unknown result type (might be due to invalid IL or missing references) - //IL_0164: Unknown result type (might be due to invalid IL or missing references) - //IL_0169: Unknown result type (might be due to invalid IL or missing references) - Vector3 val = b - a; - Vector3 val2 = c - a; - Vector3 val3 = p - a; - float num = Vector3.Dot(val, val3); - float num2 = Vector3.Dot(val2, val3); - if (num <= 0f && num2 <= 0f) - { - return a; - } - Vector3 val4 = p - b; - float num3 = Vector3.Dot(val, val4); - float num4 = Vector3.Dot(val2, val4); - if (num3 >= 0f && num4 <= num3) - { - return b; - } - float num5 = num * num4 - num3 * num2; - if (num5 <= 0f && num >= 0f && num3 <= 0f) - { - float num6 = num / (num - num3); - return a + num6 * val; - } - Vector3 val5 = p - c; - float num7 = Vector3.Dot(val, val5); - float num8 = Vector3.Dot(val2, val5); - if (num8 >= 0f && num7 <= num8) - { - return c; - } - float num9 = num7 * num2 - num * num8; - if (num9 <= 0f && num2 >= 0f && num8 <= 0f) - { - float num10 = num2 / (num2 - num8); - return a + num10 * val2; - } - float num11 = num3 * num8 - num7 * num4; - if (num11 <= 0f && num4 - num3 >= 0f && num7 - num8 >= 0f) - { - float num12 = (num4 - num3) / (num4 - num3 + (num7 - num8)); - return b + num12 * (c - b); - } - float num13 = 1f / (num11 + num9 + num5); - float num14 = num9 * num13; - float num15 = num5 * num13; - return a + val * num14 + val2 * num15; - } + public Vector3 ClosestPointOnTriangle(Vector3 p, Vector3 a, Vector3 b, Vector3 c) + { + //IL_0000: Unknown result type (might be due to invalid IL or missing references) + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + //IL_0002: Unknown result type (might be due to invalid IL or missing references) + //IL_0007: Unknown result type (might be due to invalid IL or missing references) + //IL_0008: Unknown result type (might be due to invalid IL or missing references) + //IL_000a: Unknown result type (might be due to invalid IL or missing references) + //IL_000b: Unknown result type (might be due to invalid IL or missing references) + //IL_0010: Unknown result type (might be due to invalid IL or missing references) + //IL_0011: 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_0013: Unknown result type (might be due to invalid IL or missing references) + //IL_0018: Unknown result type (might be due to invalid IL or missing references) + //IL_0019: Unknown result type (might be due to invalid IL or missing references) + //IL_001a: Unknown result type (might be due to invalid IL or missing references) + //IL_0021: Unknown result type (might be due to invalid IL or missing references) + //IL_0022: Unknown result type (might be due to invalid IL or missing references) + //IL_003d: Unknown result type (might be due to invalid IL or missing references) + //IL_003e: Unknown result type (might be due to invalid IL or missing references) + //IL_003f: Unknown result type (might be due to invalid IL or missing references) + //IL_0044: Unknown result type (might be due to invalid IL or missing references) + //IL_0046: Unknown result type (might be due to invalid IL or missing references) + //IL_0047: Unknown result type (might be due to invalid IL or missing references) + //IL_0050: Unknown result type (might be due to invalid IL or missing references) + //IL_0051: Unknown result type (might be due to invalid IL or missing references) + //IL_003b: Unknown result type (might be due to invalid IL or missing references) + //IL_00a8: Unknown result type (might be due to invalid IL or missing references) + //IL_00a9: Unknown result type (might be due to invalid IL or missing references) + //IL_00ab: Unknown result type (might be due to invalid IL or missing references) + //IL_00b0: Unknown result type (might be due to invalid IL or missing references) + //IL_00b2: Unknown result type (might be due to invalid IL or missing references) + //IL_00b3: Unknown result type (might be due to invalid IL or missing references) + //IL_00bc: Unknown result type (might be due to invalid IL or missing references) + //IL_00bd: Unknown result type (might be due to invalid IL or missing references) + //IL_0069: Unknown result type (might be due to invalid IL or missing references) + //IL_00d5: 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_009c: 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_00a2: 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_018e: Unknown result type (might be due to invalid IL or missing references) + //IL_0191: Unknown result type (might be due to invalid IL or missing references) + //IL_0196: Unknown result type (might be due to invalid IL or missing references) + //IL_019b: Unknown result type (might be due to invalid IL or missing references) + //IL_019e: Unknown result type (might be due to invalid IL or missing references) + //IL_01a3: Unknown result type (might be due to invalid IL or missing references) + //IL_0109: Unknown result type (might be due to invalid IL or missing references) + //IL_010c: 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_0112: 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_015c: 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) + //IL_015f: Unknown result type (might be due to invalid IL or missing references) + //IL_0164: Unknown result type (might be due to invalid IL or missing references) + //IL_0169: Unknown result type (might be due to invalid IL or missing references) + Vector3 val = b - a; + Vector3 val2 = c - a; + Vector3 val3 = p - a; + float num = Vector3.Dot(val, val3); + float num2 = Vector3.Dot(val2, val3); + if (num <= 0f && num2 <= 0f) + { + return a; + } + Vector3 val4 = p - b; + float num3 = Vector3.Dot(val, val4); + float num4 = Vector3.Dot(val2, val4); + if (num3 >= 0f && num4 <= num3) + { + return b; + } + float num5 = num * num4 - num3 * num2; + if (num5 <= 0f && num >= 0f && num3 <= 0f) + { + float num6 = num / (num - num3); + return a + num6 * val; + } + Vector3 val5 = p - c; + float num7 = Vector3.Dot(val, val5); + float num8 = Vector3.Dot(val2, val5); + if (num8 >= 0f && num7 <= num8) + { + return c; + } + float num9 = num7 * num2 - num * num8; + if (num9 <= 0f && num2 >= 0f && num8 <= 0f) + { + float num10 = num2 / (num2 - num8); + return a + num10 * val2; + } + float num11 = num3 * num8 - num7 * num4; + if (num11 <= 0f && num4 - num3 >= 0f && num7 - num8 >= 0f) + { + float num12 = (num4 - num3) / (num4 - num3 + (num7 - num8)); + return b + num12 * (c - b); + } + float num13 = 1f / (num11 + num9 + num5); + float num14 = num9 * num13; + float num15 = num5 * num13; + return a + val * num14 + val2 * num15; + } } diff --git a/Assets/@Eden_Tools/Eden_AutoMorpher/Script/VertexFittingUtil.cs b/Assets/@Eden_Tools/Eden_AutoMorpher/Script/VertexFittingUtil.cs index 36847de..c9b09f9 100644 --- a/Assets/@Eden_Tools/Eden_AutoMorpher/Script/VertexFittingUtil.cs +++ b/Assets/@Eden_Tools/Eden_AutoMorpher/Script/VertexFittingUtil.cs @@ -1,874 +1,873 @@ -// Warning: Some assembly references could not be resolved automatically. This might lead to incorrect decompilation of some parts, +// 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 Eden.AutoMorpher; using UnityEngine; public class VertexFittingUtil { - private struct Node - { - public int index; + private struct Node + { + public int index; - public int depth; - } + public int depth; + } - public void ExpandClothes_World_Test(List 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(); - 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 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_Test(List 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 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 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(); - SmoothDeltasByDistance(clothInstanceTotal.GlobalPositions, ref deltas, clothInstanceTotal.GlobalAdjacencyMerged, config.worldRadius, 3, config.smoothingIteration, 0.5f, config.sigma); - clothInstanceTotal.SetGlobalDeltas(deltas); - clothInstanceTotal.ApplyGlobalDeltasToClothInstances(); - 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 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 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 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 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) - { - 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 list = null; - using (AutoMorpherDev.Profile("[Expand] Select Anchors time")) - { - list = SelectAnchors(clothInstance, fittingRadius); - } - if (AutoMorpherDev.isDeveloperMode) - { - Debug.Log((object)$"[Expand] Anchor Count {list.Count}"); - } - if (list.Count == 0) - { - if (AutoMorpherDev.isDeveloperMode) - { - stopwatch.Stop(); - Debug.Log((object)$"[Expand] TOTAL ShrinkClothes time: {stopwatch.ElapsedMilliseconds} ms"); - 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) - { - Debug.Log((object)$"[Expand] Selected Expand Vertes: {((Object)((Component)clothInstance.smr).gameObject).name} / {item}"); - 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; - } - } - 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 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(); - Debug.Log((object)$"[Expand] Renderer Move Vector Calculate: {((Object)((Component)clothInstance.smr).gameObject).name} : {num}"); - Debug.Log((object)$"[Expand] Other Renderer Move Vector Calculate: {((Object)((Component)clothInstance.smr).gameObject).name} : {num2}"); - Debug.Log((object)$"[Expand] Total Move Vector Calculate: {((Object)((Component)clothInstance.smr).gameObject).name} : {stopwatch2.ElapsedMilliseconds}"); - stopwatch.Stop(); - Debug.Log((object)$"[Expand] TOTAL ShrinkClothes time: {stopwatch.ElapsedMilliseconds} ms"); - Debug.Log((object)("[Expand] End " + ((Object)((Component)clothInstance.smr).gameObject).name + "//===============================================================================================================")); - } - } + public void ExpandClothes_World(ClothInstance clothInstance, List 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 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 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 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) - { - 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 list = null; - using (AutoMorpherDev.Profile("[Shrink] Select Anchors time")) - { - list = SelectAnchors(clothInstance, fittingRadius); - } - if (AutoMorpherDev.isDeveloperMode) - { - Debug.Log((object)$"[Shrink] Anchor Count {list.Count}"); - } - if (list.Count == 0) - { - if (AutoMorpherDev.isDeveloperMode) - { - stopwatch.Stop(); - Debug.Log((object)$"[Shrink] TOTAL ShrinkClothes time: {stopwatch.ElapsedMilliseconds} ms"); - 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) - { - Debug.Log((object)$"[Shrink] Selected Expand Vertes: {((Object)((Component)clothInstance.smr).gameObject).name} / {item}"); - 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; - } - } - 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 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(); - Debug.Log((object)$"[Shrink] Renderer Move Vector Calculate: {((Object)((Component)clothInstance.smr).gameObject).name} : {num}"); - Debug.Log((object)$"[Shrink] Other Renderer Move Vector Calculate: {((Object)((Component)clothInstance.smr).gameObject).name} : {num2}"); - Debug.Log((object)$"[Shrink] Total Move Vector Calculate: {((Object)((Component)clothInstance.smr).gameObject).name} : {stopwatch2.ElapsedMilliseconds}"); - stopwatch.Stop(); - Debug.Log((object)$"[Shrink] TOTAL ShrinkClothes time: {stopwatch.ElapsedMilliseconds} ms"); - Debug.Log((object)("[Shrink] End " + ((Object)((Component)clothInstance.smr).gameObject).name + "//===============================================================================================================")); - } - } + public void ShrinkClothes_World(ClothInstance clothInstance, List 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 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 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 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) - 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(); - 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 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(); - Debug.Log((object)$"[Expand] TOTAL ShrinkClothes time: {stopwatch.ElapsedMilliseconds} ms"); - Debug.Log((object)("[Expand] " + ((Object)((Component)clothInstance.smr).gameObject).name + "//===============================================================================================================")); - } + public void ExpandFitClothes_World(ClothInstance clothInstance, List 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 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 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 list = new List(); - List list2 = new List(); - int num = clothInstance.worldVertices.Length; - for (int i = 0; i < num; i++) - { - if (!clothInstance.isInsideVertex[i] && ((Vector3)(ref clothInstance.deltas[i])).sqrMagnitude > minDeltaSq) - { - list2.Add(i); - } - } - if (list2.Count == 0) - { - return list; - } - list2.Sort(delegate(int a, int b) - { - float sqrMagnitude = ((Vector3)(ref clothInstance.deltas[a])).sqrMagnitude; - float num9 = ((Vector3)(ref 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> dictionary = new Dictionary>(); - 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; - } - ((Vector3Int)(ref key2))._002Ector(((Vector3Int)(ref key)).x + num4, ((Vector3Int)(ref key)).y + num5, ((Vector3Int)(ref 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 (((Vector3)(ref val)).sqrMagnitude < num3) - { - flag = true; - break; - } - } - } - } - } - if (!flag) - { - list.Add(item); - if (!dictionary.TryGetValue(key, out var value2)) - { - value2 = (dictionary[key] = new List()); - } - 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)); - } - } + private List 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 list = new List(); + List list2 = new List(); + 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> dictionary = new Dictionary>(); + 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()); + } + 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[] 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 queue = new Queue(); - List list = new List(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 = ((Vector3)(ref val3)).sqrMagnitude; - if (index != j && sqrMagnitude <= num2) - { - list.Add(index); - } - if (depth >= maxDepth) - { - continue; - } - List 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 (!(((Vector3)(ref 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 = ((Vector3)(ref 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 SmoothDeltasByDistance(Vector3[] positions, ref Vector3[] deltas, List[] 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 queue = new Queue(); + List list = new List(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 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 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[] array2 = new List[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[] 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(); - } - for (int l = 0; l < num3; l++) - { - List list = vertexAdjacency[l]; - if (list != null) - { - int num4 = num2 + l; - List list2 = array2[num4]; - for (int m = 0; m < list.Count; m++) - { - int num5 = list[m]; - int item = num2 + num5; - list2.Add(item); - } - } - } - num2 += num3; - } - 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]; - } - } - } - } + public void SmoothAllClothesDeltasByDistance(List 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[] array2 = new List[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[] 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(); + } + for (int l = 0; l < num3; l++) + { + List list = vertexAdjacency[l]; + if (list != null) + { + int num4 = num2 + l; + List 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]; + } + } + } + } } diff --git a/Assets/@Eden_Tools/Eden_AutoMorpher/Script/VertexMoverUtil.cs b/Assets/@Eden_Tools/Eden_AutoMorpher/Script/VertexMoverUtil.cs index adf1ab2..bf13806 100644 --- a/Assets/@Eden_Tools/Eden_AutoMorpher/Script/VertexMoverUtil.cs +++ b/Assets/@Eden_Tools/Eden_AutoMorpher/Script/VertexMoverUtil.cs @@ -1,195 +1,194 @@ -// Warning: Some assembly references could not be resolved automatically. This might lead to incorrect decompilation of some parts, +// 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.VertexMoverUtil -using Eden.AutoMorpher; using UnityEngine; public class VertexMoverUtil { - public Vector3[] MoveVertices(ClothInstance cloth, Vector3 targetPoint, bool centerIsLeftLeg, bool centerIsRightLeg, float maxRadius, float param, Vector3 vertexMovement) - { - //IL_0028: Unknown result type (might be due to invalid IL or missing references) - //IL_006e: Unknown result type (might be due to invalid IL or missing references) - //IL_0073: 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_00c8: Unknown result type (might be due to invalid IL or missing references) - //IL_00cd: Unknown result type (might be due to invalid IL or missing references) - //IL_008d: Unknown result type (might be due to invalid IL or missing references) - //IL_0092: Unknown result type (might be due to invalid IL or missing references) - //IL_00ad: Unknown result type (might be due to invalid IL or missing references) - //IL_00b2: Unknown result type (might be due to invalid IL or missing references) - if (cloth == null || cloth.worldVertices == null) - { - throw new AutoMorpherException("Cloth or World Vertices are Missing", "[MoveVertices] MoveVertices\n - cloth is null or cloth.worldVertices is null"); - } - Vector3[] worldVertices = cloth.worldVertices; - int num = worldVertices.Length; - bool[] isInboundVerts; - float[] array = ComputeEuclideanDistances(worldVertices, targetPoint, maxRadius, out isInboundVerts); - if (array == null) - { - return null; - } - float[] array2 = ComputeKernelWeights(array, isInboundVerts, maxRadius, WeightKernel.Gaussian, param); - Vector3[] array3 = (Vector3[])(object)new Vector3[num]; - bool[] isLeftLegVertex = cloth.isLeftLegVertex; - bool[] isRightLegVertex = cloth.isRightLegVertex; - for (int i = 0; i < num; i++) - { - if (!isInboundVerts[i]) - { - array3[i] = Vector3.zero; - continue; - } - if (centerIsLeftLeg && IsRightLegVertex(isRightLegVertex, i)) - { - array3[i] = Vector3.zero; - continue; - } - if (centerIsRightLeg && IsLeftLegVertex(isLeftLegVertex, i)) - { - array3[i] = Vector3.zero; - continue; - } - float num2 = array2[i]; - array3[i] = vertexMovement * num2; - } - return array3; - } + public Vector3[] MoveVertices(ClothInstance cloth, Vector3 targetPoint, bool centerIsLeftLeg, bool centerIsRightLeg, float maxRadius, float param, Vector3 vertexMovement) + { + //IL_0028: Unknown result type (might be due to invalid IL or missing references) + //IL_006e: Unknown result type (might be due to invalid IL or missing references) + //IL_0073: 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_00c8: Unknown result type (might be due to invalid IL or missing references) + //IL_00cd: Unknown result type (might be due to invalid IL or missing references) + //IL_008d: Unknown result type (might be due to invalid IL or missing references) + //IL_0092: Unknown result type (might be due to invalid IL or missing references) + //IL_00ad: Unknown result type (might be due to invalid IL or missing references) + //IL_00b2: Unknown result type (might be due to invalid IL or missing references) + if (cloth == null || cloth.worldVertices == null) + { + throw new AutoMorpherException("Cloth or World Vertices are Missing", "[MoveVertices] MoveVertices\n - cloth is null or cloth.worldVertices is null"); + } + Vector3[] worldVertices = cloth.worldVertices; + int num = worldVertices.Length; + bool[] isInboundVerts; + float[] array = this.ComputeEuclideanDistances(worldVertices, targetPoint, maxRadius, out isInboundVerts); + if (array == null) + { + return null; + } + float[] array2 = this.ComputeKernelWeights(array, isInboundVerts, maxRadius, WeightKernel.Gaussian, param); + Vector3[] array3 = (Vector3[])(object)new Vector3[num]; + bool[] isLeftLegVertex = cloth.isLeftLegVertex; + bool[] isRightLegVertex = cloth.isRightLegVertex; + for (int i = 0; i < num; i++) + { + if (!isInboundVerts[i]) + { + array3[i] = Vector3.zero; + continue; + } + if (centerIsLeftLeg && this.IsRightLegVertex(isRightLegVertex, i)) + { + array3[i] = Vector3.zero; + continue; + } + if (centerIsRightLeg && this.IsLeftLegVertex(isLeftLegVertex, i)) + { + array3[i] = Vector3.zero; + continue; + } + float num2 = array2[i]; + array3[i] = vertexMovement * num2; + } + return array3; + } - public Vector3[] MoveVertices(ClothInstance cloth, int targetVertexIdx, bool centerIsLeftLeg, bool centerIsRightLeg, float maxRadius, float param, Vector3 vertexMovement) - { - //IL_006e: Unknown result type (might be due to invalid IL or missing references) - //IL_0073: 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_00c8: Unknown result type (might be due to invalid IL or missing references) - //IL_00cd: Unknown result type (might be due to invalid IL or missing references) - //IL_008d: Unknown result type (might be due to invalid IL or missing references) - //IL_0092: Unknown result type (might be due to invalid IL or missing references) - //IL_00ad: Unknown result type (might be due to invalid IL or missing references) - //IL_00b2: Unknown result type (might be due to invalid IL or missing references) - if (cloth == null || cloth.worldVertices == null) - { - throw new AutoMorpherException("Cloth or World Vertices are Missing", "[MoveVertices] MoveVertices\n - cloth is null or cloth.worldVertices is null"); - } - Vector3[] worldVertices = cloth.worldVertices; - int num = worldVertices.Length; - bool[] isInboundVerts; - float[] array = ComputeEuclideanDistances(worldVertices, targetVertexIdx, maxRadius, out isInboundVerts); - if (array == null) - { - return null; - } - float[] array2 = ComputeKernelWeights(array, isInboundVerts, maxRadius, WeightKernel.Gaussian, param); - Vector3[] array3 = (Vector3[])(object)new Vector3[num]; - bool[] isLeftLegVertex = cloth.isLeftLegVertex; - bool[] isRightLegVertex = cloth.isRightLegVertex; - for (int i = 0; i < num; i++) - { - if (!isInboundVerts[i]) - { - array3[i] = Vector3.zero; - continue; - } - if (centerIsLeftLeg && IsRightLegVertex(isRightLegVertex, i)) - { - array3[i] = Vector3.zero; - continue; - } - if (centerIsRightLeg && IsLeftLegVertex(isLeftLegVertex, i)) - { - array3[i] = Vector3.zero; - continue; - } - float num2 = array2[i]; - array3[i] = vertexMovement * num2; - } - return array3; - } + public Vector3[] MoveVertices(ClothInstance cloth, int targetVertexIdx, bool centerIsLeftLeg, bool centerIsRightLeg, float maxRadius, float param, Vector3 vertexMovement) + { + //IL_006e: Unknown result type (might be due to invalid IL or missing references) + //IL_0073: 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_00c8: Unknown result type (might be due to invalid IL or missing references) + //IL_00cd: Unknown result type (might be due to invalid IL or missing references) + //IL_008d: Unknown result type (might be due to invalid IL or missing references) + //IL_0092: Unknown result type (might be due to invalid IL or missing references) + //IL_00ad: Unknown result type (might be due to invalid IL or missing references) + //IL_00b2: Unknown result type (might be due to invalid IL or missing references) + if (cloth == null || cloth.worldVertices == null) + { + throw new AutoMorpherException("Cloth or World Vertices are Missing", "[MoveVertices] MoveVertices\n - cloth is null or cloth.worldVertices is null"); + } + Vector3[] worldVertices = cloth.worldVertices; + int num = worldVertices.Length; + bool[] isInboundVerts; + float[] array = this.ComputeEuclideanDistances(worldVertices, targetVertexIdx, maxRadius, out isInboundVerts); + if (array == null) + { + return null; + } + float[] array2 = this.ComputeKernelWeights(array, isInboundVerts, maxRadius, WeightKernel.Gaussian, param); + Vector3[] array3 = (Vector3[])(object)new Vector3[num]; + bool[] isLeftLegVertex = cloth.isLeftLegVertex; + bool[] isRightLegVertex = cloth.isRightLegVertex; + for (int i = 0; i < num; i++) + { + if (!isInboundVerts[i]) + { + array3[i] = Vector3.zero; + continue; + } + if (centerIsLeftLeg && this.IsRightLegVertex(isRightLegVertex, i)) + { + array3[i] = Vector3.zero; + continue; + } + if (centerIsRightLeg && this.IsLeftLegVertex(isLeftLegVertex, i)) + { + array3[i] = Vector3.zero; + continue; + } + float num2 = array2[i]; + array3[i] = vertexMovement * num2; + } + return array3; + } - private float[] ComputeEuclideanDistances(Vector3[] verts, int targetVertIdx, float maxRadius, out bool[] isInboundVerts) - { - //IL_0004: Unknown result type (might be due to invalid IL or missing references) - return ComputeEuclideanDistances(verts, verts[targetVertIdx], maxRadius, out isInboundVerts); - } + private float[] ComputeEuclideanDistances(Vector3[] verts, int targetVertIdx, float maxRadius, out bool[] isInboundVerts) + { + //IL_0004: Unknown result type (might be due to invalid IL or missing references) + return this.ComputeEuclideanDistances(verts, verts[targetVertIdx], maxRadius, out isInboundVerts); + } - private float[] ComputeEuclideanDistances(Vector3[] verts, Vector3 targetVert, float maxRadius, out bool[] isInboundVerts) - { - //IL_001e: Unknown result type (might be due to invalid IL or missing references) - //IL_0023: Unknown result type (might be due to invalid IL or missing references) - int num = verts.Length; - float[] array = new float[num]; - isInboundVerts = new bool[num]; - bool flag = false; - for (int i = 0; i < num; i++) - { - array[i] = Vector3.Distance(verts[i], targetVert); - isInboundVerts[i] = array[i] <= maxRadius; - flag |= isInboundVerts[i]; - } - if (!flag) - { - return null; - } - return array; - } + private float[] ComputeEuclideanDistances(Vector3[] verts, Vector3 targetVert, float maxRadius, out bool[] isInboundVerts) + { + //IL_001e: Unknown result type (might be due to invalid IL or missing references) + //IL_0023: Unknown result type (might be due to invalid IL or missing references) + int num = verts.Length; + float[] array = new float[num]; + isInboundVerts = new bool[num]; + bool flag = false; + for (int i = 0; i < num; i++) + { + array[i] = Vector3.Distance(verts[i], targetVert); + isInboundVerts[i] = array[i] <= maxRadius; + flag |= isInboundVerts[i]; + } + if (!flag) + { + return null; + } + return array; + } - private float ComputeGaussianWeight(float distance, float alpah) - { - return Mathf.Exp((0f - distance * distance) / (2f * alpah * alpah)); - } + private float ComputeGaussianWeight(float distance, float alpah) + { + return Mathf.Exp((0f - distance * distance) / (2f * alpah * alpah)); + } - private float ComputeLaplacianWeight(float distance, float beta) - { - return Mathf.Exp(0f - distance / beta); - } + private float ComputeLaplacianWeight(float distance, float beta) + { + return Mathf.Exp(0f - distance / beta); + } - private float[] ComputeKernelWeights(float[] dist, bool[] isInboundVerts, float maxRadius, WeightKernel kernel, float param) - { - int num = dist.Length; - float[] array = new float[num]; - float num2 = Mathf.Max(1E-08f, param); - for (int i = 0; i < num; i++) - { - if (!isInboundVerts[i]) - { - array[i] = 0f; - continue; - } - switch (kernel) - { - case WeightKernel.Gaussian: - array[i] = ComputeGaussianWeight(dist[i], num2); - break; - case WeightKernel.Laplacian: - array[i] = ComputeLaplacianWeight(dist[i], num2); - break; - default: - array[i] = 0f; - break; - } - float num3 = 1f - dist[i] / maxRadius; - array[i] *= num3 * num3; - } - return array; - } + private float[] ComputeKernelWeights(float[] dist, bool[] isInboundVerts, float maxRadius, WeightKernel kernel, float param) + { + int num = dist.Length; + float[] array = new float[num]; + float num2 = Mathf.Max(1E-08f, param); + for (int i = 0; i < num; i++) + { + if (!isInboundVerts[i]) + { + array[i] = 0f; + continue; + } + switch (kernel) + { + case WeightKernel.Gaussian: + array[i] = this.ComputeGaussianWeight(dist[i], num2); + break; + case WeightKernel.Laplacian: + array[i] = this.ComputeLaplacianWeight(dist[i], num2); + break; + default: + array[i] = 0f; + break; + } + float num3 = 1f - dist[i] / maxRadius; + array[i] *= num3 * num3; + } + return array; + } - private bool IsLeftLegVertex(bool[] leftMask, int index) - { - if (leftMask != null && index >= 0 && index < leftMask.Length) - { - return leftMask[index]; - } - return false; - } + private bool IsLeftLegVertex(bool[] leftMask, int index) + { + if (leftMask != null && index >= 0 && index < leftMask.Length) + { + return leftMask[index]; + } + return false; + } - private bool IsRightLegVertex(bool[] rightMask, int index) - { - if (rightMask != null && index >= 0 && index < rightMask.Length) - { - return rightMask[index]; - } - return false; - } + private bool IsRightLegVertex(bool[] rightMask, int index) + { + if (rightMask != null && index >= 0 && index < rightMask.Length) + { + return rightMask[index]; + } + return false; + } } diff --git a/Assets/@Eden_Tools/Eden_AutoMorpher/Script/WeightKernel.cs b/Assets/@Eden_Tools/Eden_AutoMorpher/Script/WeightKernel.cs index f6abe4e..1f15f16 100644 --- a/Assets/@Eden_Tools/Eden_AutoMorpher/Script/WeightKernel.cs +++ b/Assets/@Eden_Tools/Eden_AutoMorpher/Script/WeightKernel.cs @@ -1,9 +1,9 @@ -// Warning: Some assembly references could not be resolved automatically. This might lead to incorrect decompilation of some parts, +// 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.WeightKernel public enum WeightKernel { - Gaussian, - Laplacian + Gaussian, + Laplacian } diff --git a/Assets/@Eden_Tools/Eden_AutoMorpher/Script/WeightTransferUtil.cs b/Assets/@Eden_Tools/Eden_AutoMorpher/Script/WeightTransferUtil.cs index 2b9556e..59eee00 100644 --- a/Assets/@Eden_Tools/Eden_AutoMorpher/Script/WeightTransferUtil.cs +++ b/Assets/@Eden_Tools/Eden_AutoMorpher/Script/WeightTransferUtil.cs @@ -1,4 +1,4 @@ -// Warning: Some assembly references could not be resolved automatically. This might lead to incorrect decompilation of some parts, +// 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.WeightTransferUtil @@ -6,1910 +6,1909 @@ using System; using System.Collections; using System.Collections.Generic; using System.Linq; -using Eden.AutoMorpher; using Unity.Collections; using UnityEditor; using UnityEngine; public class WeightTransferUtil { - [Serializable] - public class Settings - { - [Header("최근접 표면 매칭")] - public float maxDistance = 0.1f; + [Serializable] + public class Settings + { + [Header("최근접 표면 매칭")] + public float maxDistance = 0.1f; - public float maxNormalAngleDeg = 35f; + public float maxNormalAngleDeg = 35f; - public bool allowFlippedNormal = true; + public bool allowFlippedNormal = true; - [Header("추가 스무딩")] - public bool enableSmoothing = true; + [Header("추가 스무딩")] + public bool enableSmoothing = true; - public int smoothingIterations = 4; + public int smoothingIterations = 4; - [Range(0f, 1f)] - public float smoothingAlpha = 0.25f; + [Range(0f, 1f)] + public float smoothingAlpha = 0.25f; - [Header("본 수 제한 & 임계값")] - public bool enforceFourBoneLimit = true; + [Header("본 수 제한 & 임계값")] + public bool enforceFourBoneLimit = true; - public float tinyWeight = 0.0001f; + public float tinyWeight = 0.0001f; - public bool weightInClothes; - } + public bool weightInClothes; + } - private bool NameContainsAny(string lowerName, string[] patterns) - { - for (int i = 0; i < patterns.Length; i++) - { - if (lowerName.Contains(patterns[i])) - { - return true; - } - } - return false; - } + private bool NameContainsAny(string lowerName, string[] patterns) + { + for (int i = 0; i < patterns.Length; i++) + { + if (lowerName.Contains(patterns[i])) + { + return true; + } + } + return false; + } - private bool IsBreastOrButtBone(Transform t) - { - if ((Object)(object)t == (Object)null) - { - return false; - } - string[] patterns = new string[6] { "breast", "boob", "bust", "oppai", "chichi", "mune" }; - string[] patterns2 = new string[6] { "butt", "buttock", "buttox", "glute", "glutes", "gluteus" }; - string lowerName = ((Object)t).name.ToLowerInvariant(); - if (NameContainsAny(lowerName, patterns)) - { - return true; - } - if (NameContainsAny(lowerName, patterns2)) - { - return true; - } - return false; - } + private bool IsBreastOrButtBone(Transform t) + { + if (t == null) + { + return false; + } + string[] patterns = new string[6] { "breast", "boob", "bust", "oppai", "chichi", "mune" }; + string[] patterns2 = new string[6] { "butt", "buttock", "buttox", "glute", "glutes", "gluteus" }; + string lowerName = (t).name.ToLowerInvariant(); + if (this.NameContainsAny(lowerName, patterns)) + { + return true; + } + if (this.NameContainsAny(lowerName, patterns2)) + { + return true; + } + return false; + } - public IEnumerator RetargetAndTransfer(ClothInstance cloth, Animator avatarAnimator, IReadOnlyList bodyMeshes, IReadOnlyList bodyBakedMeshes, int referenceBodyIndex = 0, Settings settings = null, Dictionary boneTypeMap = null, Dictionary bodyToClothesMap = null) - { - if (cloth == null || (Object)(object)cloth.smr == (Object)null || (Object)(object)cloth.editableMesh == (Object)null) - { - throw new AutoMorpherException("Cloth Instance is Invalid", "[WeightTransferUtil] RetargetAndTransfer\n - cloth is null or cloth.smr is null or cloth.editableMesh is null"); - } - if (cloth.worldVertices == null || cloth.worldVertices.Length == 0) - { - throw new AutoMorpherException("Cloth World Vertices are Missing", "[WeightTransferUtil] RetargetAndTransfer\n - cloth.worldVertices is null or empty"); - } - if ((Object)(object)cloth.bakedMesh == (Object)null) - { - throw new AutoMorpherException("Cloth Baked Mesh is Missing", "[WeightTransferUtil] RetargetAndTransfer\n - cloth.bakedMesh is null"); - } - if ((Object)(object)avatarAnimator == (Object)null || !avatarAnimator.isHuman) - { - throw new AutoMorpherException("Avatar Animator is Invalid", "[WeightTransferUtil] RetargetAndTransfer\n - avatarAnimator is null or not a Humanoid"); - } - if (bodyMeshes == null || bodyMeshes.Count == 0) - { - throw new AutoMorpherException("Body Meshes are Missing", "[WeightTransferUtil] RetargetAndTransfer\n - bodyMeshes is null or empty"); - } - if (referenceBodyIndex < 0 || referenceBodyIndex >= bodyMeshes.Count) - { - referenceBodyIndex = 0; - } - SkinnedMeshRenderer bodyRefSmr = bodyMeshes[referenceBodyIndex]; - if ((Object)(object)bodyRefSmr == (Object)null || (Object)(object)bodyRefSmr.sharedMesh == (Object)null) - { - throw new AutoMorpherException("Reference Body Mesh is Invalid", "[WeightTransferUtil] RetargetAndTransfer\n - bodyRefSmr is null or bodyRefSmr.sharedMesh is null\n - referenceBodyIndex : " + referenceBodyIndex); - } - if (settings == null) - { - settings = new Settings(); - } - Transform[] accessoryBones = null; - float[,] accessoryWeights = null; - BoneWeight[] prevBoneWeights = null; - yield return null; - Transform[] bones; - Dictionary accIndexByTransform; - float tiny; - if (boneTypeMap != null && (Object)(object)cloth.smr != (Object)null && (Object)(object)cloth.editableMesh != (Object)null) - { - bones = cloth.smr.bones; - if (bones != null && bones.Length != 0) - { - HashSet value = null; - if (cloth.humanoidMatchedBones != null) - { - cloth.humanoidMatchedBones.TryGetValue((HumanBodyBones)10, out value); - } - HashSet hashSet = new HashSet(); - foreach (Transform val in bones) - { - if (!((Object)(object)val == (Object)null) && boneTypeMap.TryGetValue(val, out var value2) && value2 == ClothBoneType.Accessory) - { - hashSet.Add(val); - } - } - if (value != null) - { - foreach (Transform item in value) - { - if (!((Object)(object)item == (Object)null) && Array.IndexOf(bones, item) >= 0) - { - hashSet.Add(item); - } - } - } - List list = new List(); - accIndexByTransform = new Dictionary(); - foreach (Transform val2 in bones) - { - if (!((Object)(object)val2 == (Object)null) && hashSet.Contains(val2) && !IsBreastOrButtBone(val2) && !accIndexByTransform.ContainsKey(val2)) - { - accIndexByTransform[val2] = list.Count; - list.Add(val2); - } - } - if (list.Count > 0) - { - accessoryBones = list.ToArray(); - int vertexCount = cloth.editableMesh.vertexCount; - accessoryWeights = new float[vertexCount, accessoryBones.Length]; - BoneWeight[] boneWeights = cloth.editableMesh.boneWeights; - if (boneWeights != null && boneWeights.Length == vertexCount) - { - tiny = 1E-06f; - for (int k = 0; k < vertexCount; k++) - { - BoneWeight val3 = boneWeights[k]; - Acc(((BoneWeight)(ref val3)).boneIndex0, ((BoneWeight)(ref val3)).weight0, k); - Acc(((BoneWeight)(ref val3)).boneIndex1, ((BoneWeight)(ref val3)).weight1, k); - Acc(((BoneWeight)(ref val3)).boneIndex2, ((BoneWeight)(ref val3)).weight2, k); - Acc(((BoneWeight)(ref val3)).boneIndex3, ((BoneWeight)(ref val3)).weight3, k); - } - } - } - } - } - int bodyBoneCount = bodyRefSmr.bones.Length; - yield return null; - RetargetClothToAvatarSkeleton(cloth, avatarAnimator, bodyRefSmr, accessoryBones); - TransferFromBodyToCloth(avatarAnimator, cloth, bodyMeshes, bodyBakedMeshes, settings, accessoryBones, accessoryWeights, bodyBoneCount, prevBoneWeights); - if (settings.weightInClothes) - { - MoveBodyWeightsToClothesBones(cloth.smr, cloth.smr.sharedMesh, bodyToClothesMap, accessoryBones); - } - void Acc(int boneIndex, float w, int v) - { - if (!(w <= tiny) && boneIndex >= 0 && boneIndex < bones.Length) - { - Transform val4 = bones[boneIndex]; - if (!((Object)(object)val4 == (Object)null) && accIndexByTransform.TryGetValue(val4, out var value3)) - { - accessoryWeights[v, value3] += w; - } - } - } - } + public IEnumerator RetargetAndTransfer(ClothInstance cloth, Animator avatarAnimator, IReadOnlyList bodyMeshes, IReadOnlyList bodyBakedMeshes, int referenceBodyIndex = 0, Settings settings = null, Dictionary boneTypeMap = null, Dictionary bodyToClothesMap = null) + { + if (cloth == null || cloth.smr == null || cloth.editableMesh == null) + { + throw new AutoMorpherException("Cloth Instance is Invalid", "[WeightTransferUtil] RetargetAndTransfer\n - cloth is null or cloth.smr is null or cloth.editableMesh is null"); + } + if (cloth.worldVertices == null || cloth.worldVertices.Length == 0) + { + throw new AutoMorpherException("Cloth World Vertices are Missing", "[WeightTransferUtil] RetargetAndTransfer\n - cloth.worldVertices is null or empty"); + } + if (cloth.bakedMesh == null) + { + throw new AutoMorpherException("Cloth Baked Mesh is Missing", "[WeightTransferUtil] RetargetAndTransfer\n - cloth.bakedMesh is null"); + } + if (avatarAnimator == null || !avatarAnimator.isHuman) + { + throw new AutoMorpherException("Avatar Animator is Invalid", "[WeightTransferUtil] RetargetAndTransfer\n - avatarAnimator is null or not a Humanoid"); + } + if (bodyMeshes == null || bodyMeshes.Count == 0) + { + throw new AutoMorpherException("Body Meshes are Missing", "[WeightTransferUtil] RetargetAndTransfer\n - bodyMeshes is null or empty"); + } + if (referenceBodyIndex < 0 || referenceBodyIndex >= bodyMeshes.Count) + { + referenceBodyIndex = 0; + } + SkinnedMeshRenderer bodyRefSmr = bodyMeshes[referenceBodyIndex]; + if (bodyRefSmr == null || bodyRefSmr.sharedMesh == null) + { + throw new AutoMorpherException("Reference Body Mesh is Invalid", "[WeightTransferUtil] RetargetAndTransfer\n - bodyRefSmr is null or bodyRefSmr.sharedMesh is null\n - referenceBodyIndex : " + referenceBodyIndex); + } + if (settings == null) + { + settings = new Settings(); + } + Transform[] accessoryBones = null; + float[,] accessoryWeights = null; + BoneWeight[] prevBoneWeights = null; + yield return null; + Transform[] bones; + Dictionary accIndexByTransform; + float tiny; + if (boneTypeMap != null && cloth.smr != null && cloth.editableMesh != null) + { + bones = cloth.smr.bones; + if (bones != null && bones.Length != 0) + { + HashSet value = null; + if (cloth.humanoidMatchedBones != null) + { + cloth.humanoidMatchedBones.TryGetValue((HumanBodyBones)10, out value); + } + HashSet hashSet = new HashSet(); + foreach (Transform val in bones) + { + if (!(val == null) && boneTypeMap.TryGetValue(val, out var value2) && value2 == ClothBoneType.Accessory) + { + hashSet.Add(val); + } + } + if (value != null) + { + foreach (Transform item in value) + { + if (!(item == null) && Array.IndexOf(bones, item) >= 0) + { + hashSet.Add(item); + } + } + } + List list = new List(); + accIndexByTransform = new Dictionary(); + foreach (Transform val2 in bones) + { + if (!(val2 == null) && hashSet.Contains(val2) && !this.IsBreastOrButtBone(val2) && !accIndexByTransform.ContainsKey(val2)) + { + accIndexByTransform[val2] = list.Count; + list.Add(val2); + } + } + if (list.Count > 0) + { + accessoryBones = list.ToArray(); + int vertexCount = cloth.editableMesh.vertexCount; + accessoryWeights = new float[vertexCount, accessoryBones.Length]; + BoneWeight[] boneWeights = cloth.editableMesh.boneWeights; + if (boneWeights != null && boneWeights.Length == vertexCount) + { + tiny = 1E-06f; + for (int k = 0; k < vertexCount; k++) + { + BoneWeight val3 = boneWeights[k]; + Acc(val3.boneIndex0, val3.weight0, k); + Acc(val3.boneIndex1, val3.weight1, k); + Acc(val3.boneIndex2, val3.weight2, k); + Acc(val3.boneIndex3, val3.weight3, k); + } + } + } + } + } + int bodyBoneCount = bodyRefSmr.bones.Length; + yield return null; + this.RetargetClothToAvatarSkeleton(cloth, avatarAnimator, bodyRefSmr, accessoryBones); + this.TransferFromBodyToCloth(avatarAnimator, cloth, bodyMeshes, bodyBakedMeshes, settings, accessoryBones, accessoryWeights, bodyBoneCount, prevBoneWeights); + if (settings.weightInClothes) + { + this.MoveBodyWeightsToClothesBones(cloth.smr, cloth.smr.sharedMesh, bodyToClothesMap, accessoryBones); + } + void Acc(int boneIndex, float w, int v) + { + if (!(w <= tiny) && boneIndex >= 0 && boneIndex < bones.Length) + { + Transform val4 = bones[boneIndex]; + if (!(val4 == null) && accIndexByTransform.TryGetValue(val4, out var value3)) + { + accessoryWeights[v, value3] += w; + } + } + } + } - private void RetargetClothToAvatarSkeleton(ClothInstance cloth, Animator avatarAnimator, SkinnedMeshRenderer bodyRefSmr, Transform[] accessoryBones = null) - { - //IL_008c: Unknown result type (might be due to invalid IL or missing references) - //IL_0091: Unknown result type (might be due to invalid IL or missing references) - //IL_00c0: Unknown result type (might be due to invalid IL or missing references) - //IL_00c5: Unknown result type (might be due to invalid IL or missing references) - //IL_0101: 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_01a6: Unknown result type (might be due to invalid IL or missing references) - //IL_01aa: Invalid comparison between Unknown and I4 - //IL_01ad: Unknown result type (might be due to invalid IL or missing references) - //IL_045a: Unknown result type (might be due to invalid IL or missing references) - //IL_045f: Unknown result type (might be due to invalid IL or missing references) - //IL_0443: Unknown result type (might be due to invalid IL or missing references) - //IL_0448: Unknown result type (might be due to invalid IL or missing references) - //IL_044a: Unknown result type (might be due to invalid IL or missing references) - //IL_044f: Unknown result type (might be due to invalid IL or missing references) - //IL_01cf: Unknown result type (might be due to invalid IL or missing references) - //IL_047c: Unknown result type (might be due to invalid IL or missing references) - //IL_0481: Unknown result type (might be due to invalid IL or missing references) - //IL_04cf: Unknown result type (might be due to invalid IL or missing references) - //IL_04d1: Unknown result type (might be due to invalid IL or missing references) - //IL_0238: Unknown result type (might be due to invalid IL or missing references) - //IL_023d: Unknown result type (might be due to invalid IL or missing references) - //IL_04ba: 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_04c1: Unknown result type (might be due to invalid IL or missing references) - //IL_04c6: Unknown result type (might be due to invalid IL or missing references) - //IL_030e: 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_02f7: 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_02fe: Unknown result type (might be due to invalid IL or missing references) - //IL_0303: Unknown result type (might be due to invalid IL or missing references) - //IL_04af: Unknown result type (might be due to invalid IL or missing references) - //IL_04b4: Unknown result type (might be due to invalid IL or missing references) - SkinnedMeshRenderer smr = cloth.smr; - Mesh sharedMesh = cloth.smr.sharedMesh; - if ((Object)(object)sharedMesh == (Object)null) - { - throw new AutoMorpherException("Cloth Mesh is Missing", "[WeightTransferUtil] RetargetClothToAvatarSkeleton\n - clothMesh is null"); - } - Transform[] bones = smr.bones; - Transform[] bones2 = bodyRefSmr.bones; - if (bones == null || bones.Length == 0 || bones2 == null || bones2.Length == 0) - { - throw new AutoMorpherException("Cloth or Target Bones are Missing", "[WeightTransferUtil] RetargetClothToAvatarSkeleton\n - clothBones is null/empty or targetBones is null/empty\n - clothBones.Length : " + ((bones == null) ? (-1) : bones.Length) + "\n - targetBones.Length : " + ((bones2 == null) ? (-1) : bones2.Length)); - } - Matrix4x4 localToWorldMatrix = ((Component)smr).transform.localToWorldMatrix; - if (accessoryBones == null || accessoryBones.Length == 0) - { - Dictionary dictionary = new Dictionary(); - foreach (KeyValuePair> humanoidMatchedBone in cloth.humanoidMatchedBones) - { - HumanBodyBones key = humanoidMatchedBone.Key; - HashSet value = humanoidMatchedBone.Value; - if (value == null) - { - continue; - } - foreach (Transform item in value) - { - if (!((Object)(object)item == (Object)null) && !dictionary.ContainsKey(item)) - { - dictionary.Add(item, key); - } - } - } - Dictionary dictionary2 = new Dictionary(); - Dictionary dictionary3 = new Dictionary(); - for (int i = 0; i < bones2.Length; i++) - { - Transform val = bones2[i]; - if ((Object)(object)val != (Object)null && !dictionary3.ContainsKey(val)) - { - dictionary3.Add(val, i); - } - } - foreach (HumanBodyBones value4 in Enum.GetValues(typeof(HumanBodyBones))) - { - if ((int)value4 != 55) - { - Transform boneTransform = avatarAnimator.GetBoneTransform(value4); - if (!((Object)(object)boneTransform == (Object)null) && dictionary3.TryGetValue(boneTransform, out var value2)) - { - dictionary2[value4] = value2; - } - } - } - BoneWeight[] boneWeights = sharedMesh.boneWeights; - if (boneWeights == null || boneWeights.Length == 0) - { - Debug.LogWarning((object)"[WeightTransferUtil] clothMesh.boneWeights 가 비어 있음. 리타겟할 weight 가 없음."); - return; - } - int vertexCount = sharedMesh.vertexCount; - int num = bones2.Length; - float[,] array = new float[vertexCount, num]; - for (int j = 0; j < vertexCount; j++) - { - BoneWeight val3 = boneWeights[j]; - AccumulateRetargetWeight(array, j, ((BoneWeight)(ref val3)).boneIndex0, ((BoneWeight)(ref val3)).weight0, bones, dictionary, dictionary2); - AccumulateRetargetWeight(array, j, ((BoneWeight)(ref val3)).boneIndex1, ((BoneWeight)(ref val3)).weight1, bones, dictionary, dictionary2); - AccumulateRetargetWeight(array, j, ((BoneWeight)(ref val3)).boneIndex2, ((BoneWeight)(ref val3)).weight2, bones, dictionary, dictionary2); - AccumulateRetargetWeight(array, j, ((BoneWeight)(ref val3)).boneIndex3, ((BoneWeight)(ref val3)).weight3, bones, dictionary, dictionary2); - } - BoneWeight[] boneWeights2 = CollapseWeightsToBoneWeights(array, 4, 0.0001f); - Matrix4x4[] array2 = (Matrix4x4[])(object)new Matrix4x4[bones2.Length]; - for (int k = 0; k < bones2.Length; k++) - { - Transform val4 = bones2[k]; - if ((Object)(object)val4 != (Object)null) - { - array2[k] = val4.worldToLocalMatrix * localToWorldMatrix; - } - else - { - array2[k] = Matrix4x4.identity; - } - } - sharedMesh.boneWeights = boneWeights2; - sharedMesh.bindposes = array2; - smr.rootBone = bodyRefSmr.rootBone; - smr.bones = bones2; - EditorUtility.SetDirty((Object)(object)sharedMesh); - EditorUtility.SetDirty((Object)(object)smr); - return; - } - Transform[] bones3 = bodyRefSmr.bones; - if (bones3 == null || bones3.Length == 0) - { - throw new AutoMorpherException("Target Body Bones are Missing", "[WeightTransferUtil] RetargetClothToAvatarSkeleton\n - bodyRefSmr.bones is null or empty"); - } - Transform[] bones4 = smr.bones; - Matrix4x4[] bindposes = sharedMesh.bindposes; - Dictionary dictionary4 = new Dictionary(); - if (bones4 != null) - { - for (int l = 0; l < bones4.Length; l++) - { - Transform val5 = bones4[l]; - if (!((Object)(object)val5 == (Object)null) && !dictionary4.ContainsKey(val5)) - { - dictionary4.Add(val5, l); - } - } - } - int num2 = bones3.Length; - int num3 = accessoryBones.Length; - Transform[] array3 = (Transform[])(object)new Transform[num2 + num3]; - for (int m = 0; m < num2; m++) - { - array3[m] = bones3[m]; - } - for (int n = 0; n < num3; n++) - { - array3[num2 + n] = accessoryBones[n]; - } - Matrix4x4[] array4 = (Matrix4x4[])(object)new Matrix4x4[array3.Length]; - for (int num4 = 0; num4 < num2; num4++) - { - Transform val6 = bones3[num4]; - if ((Object)(object)val6 != (Object)null) - { - array4[num4] = val6.worldToLocalMatrix * localToWorldMatrix; - } - else - { - array4[num4] = Matrix4x4.identity; - } - } - for (int num5 = 0; num5 < num3; num5++) - { - Transform val7 = accessoryBones[num5]; - Matrix4x4 val8 = Matrix4x4.identity; - if ((Object)(object)val7 != (Object)null && dictionary4.TryGetValue(val7, out var value3)) - { - val8 = ((bindposes == null || value3 < 0 || value3 >= bindposes.Length) ? (val7.worldToLocalMatrix * localToWorldMatrix) : bindposes[value3]); - } - array4[num2 + num5] = val8; - } - sharedMesh.bindposes = array4; - sharedMesh.boneWeights = (BoneWeight[])(object)new BoneWeight[sharedMesh.vertexCount]; - smr.rootBone = bodyRefSmr.rootBone; - smr.bones = array3; - EditorUtility.SetDirty((Object)(object)sharedMesh); - EditorUtility.SetDirty((Object)(object)smr); - } + private void RetargetClothToAvatarSkeleton(ClothInstance cloth, Animator avatarAnimator, SkinnedMeshRenderer bodyRefSmr, Transform[] accessoryBones = null) + { + //IL_008c: Unknown result type (might be due to invalid IL or missing references) + //IL_0091: Unknown result type (might be due to invalid IL or missing references) + //IL_00c0: Unknown result type (might be due to invalid IL or missing references) + //IL_00c5: Unknown result type (might be due to invalid IL or missing references) + //IL_0101: 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_01a6: Unknown result type (might be due to invalid IL or missing references) + //IL_01aa: Invalid comparison between Unknown and I4 + //IL_01ad: Unknown result type (might be due to invalid IL or missing references) + //IL_045a: Unknown result type (might be due to invalid IL or missing references) + //IL_045f: Unknown result type (might be due to invalid IL or missing references) + //IL_0443: Unknown result type (might be due to invalid IL or missing references) + //IL_0448: Unknown result type (might be due to invalid IL or missing references) + //IL_044a: Unknown result type (might be due to invalid IL or missing references) + //IL_044f: Unknown result type (might be due to invalid IL or missing references) + //IL_01cf: Unknown result type (might be due to invalid IL or missing references) + //IL_047c: Unknown result type (might be due to invalid IL or missing references) + //IL_0481: Unknown result type (might be due to invalid IL or missing references) + //IL_04cf: Unknown result type (might be due to invalid IL or missing references) + //IL_04d1: Unknown result type (might be due to invalid IL or missing references) + //IL_0238: Unknown result type (might be due to invalid IL or missing references) + //IL_023d: Unknown result type (might be due to invalid IL or missing references) + //IL_04ba: 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_04c1: Unknown result type (might be due to invalid IL or missing references) + //IL_04c6: Unknown result type (might be due to invalid IL or missing references) + //IL_030e: 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_02f7: 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_02fe: Unknown result type (might be due to invalid IL or missing references) + //IL_0303: Unknown result type (might be due to invalid IL or missing references) + //IL_04af: Unknown result type (might be due to invalid IL or missing references) + //IL_04b4: Unknown result type (might be due to invalid IL or missing references) + SkinnedMeshRenderer smr = cloth.smr; + Mesh sharedMesh = cloth.smr.sharedMesh; + if (sharedMesh == null) + { + throw new AutoMorpherException("Cloth Mesh is Missing", "[WeightTransferUtil] RetargetClothToAvatarSkeleton\n - clothMesh is null"); + } + Transform[] bones = smr.bones; + Transform[] bones2 = bodyRefSmr.bones; + if (bones == null || bones.Length == 0 || bones2 == null || bones2.Length == 0) + { + throw new AutoMorpherException("Cloth or Target Bones are Missing", "[WeightTransferUtil] RetargetClothToAvatarSkeleton\n - clothBones is null/empty or targetBones is null/empty\n - clothBones.Length : " + ((bones == null) ? (-1) : bones.Length) + "\n - targetBones.Length : " + ((bones2 == null) ? (-1) : bones2.Length)); + } + Matrix4x4 localToWorldMatrix = ((Component)smr).transform.localToWorldMatrix; + if (accessoryBones == null || accessoryBones.Length == 0) + { + Dictionary dictionary = new Dictionary(); + foreach (KeyValuePair> humanoidMatchedBone in cloth.humanoidMatchedBones) + { + HumanBodyBones key = humanoidMatchedBone.Key; + HashSet value = humanoidMatchedBone.Value; + if (value == null) + { + continue; + } + foreach (Transform item in value) + { + if (!(item == null) && !dictionary.ContainsKey(item)) + { + dictionary.Add(item, key); + } + } + } + Dictionary dictionary2 = new Dictionary(); + Dictionary dictionary3 = new Dictionary(); + for (int i = 0; i < bones2.Length; i++) + { + Transform val = bones2[i]; + if (val != null && !dictionary3.ContainsKey(val)) + { + dictionary3.Add(val, i); + } + } + foreach (HumanBodyBones value4 in Enum.GetValues(typeof(HumanBodyBones))) + { + if ((int)value4 != 55) + { + Transform boneTransform = avatarAnimator.GetBoneTransform(value4); + if (!(boneTransform == null) && dictionary3.TryGetValue(boneTransform, out var value2)) + { + dictionary2[value4] = value2; + } + } + } + BoneWeight[] boneWeights = sharedMesh.boneWeights; + if (boneWeights == null || boneWeights.Length == 0) + { + Debug.LogWarning("[WeightTransferUtil] clothMesh.boneWeights 가 비어 있음. 리타겟할 weight 가 없음."); + return; + } + int vertexCount = sharedMesh.vertexCount; + int num = bones2.Length; + float[,] array = new float[vertexCount, num]; + for (int j = 0; j < vertexCount; j++) + { + BoneWeight val3 = boneWeights[j]; + this.AccumulateRetargetWeight(array, j, val3.boneIndex0, val3.weight0, bones, dictionary, dictionary2); + this.AccumulateRetargetWeight(array, j, val3.boneIndex1, val3.weight1, bones, dictionary, dictionary2); + this.AccumulateRetargetWeight(array, j, val3.boneIndex2, val3.weight2, bones, dictionary, dictionary2); + this.AccumulateRetargetWeight(array, j, val3.boneIndex3, val3.weight3, bones, dictionary, dictionary2); + } + BoneWeight[] boneWeights2 = this.CollapseWeightsToBoneWeights(array, 4, 0.0001f); + Matrix4x4[] array2 = (Matrix4x4[])new Matrix4x4[bones2.Length]; + for (int k = 0; k < bones2.Length; k++) + { + Transform val4 = bones2[k]; + if (val4 != null) + { + array2[k] = val4.worldToLocalMatrix * localToWorldMatrix; + } + else + { + array2[k] = Matrix4x4.identity; + } + } + sharedMesh.boneWeights = boneWeights2; + sharedMesh.bindposes = array2; + smr.rootBone = bodyRefSmr.rootBone; + smr.bones = bones2; + EditorUtility.SetDirty(sharedMesh); + EditorUtility.SetDirty(smr); + return; + } + Transform[] bones3 = bodyRefSmr.bones; + if (bones3 == null || bones3.Length == 0) + { + throw new AutoMorpherException("Target Body Bones are Missing", "[WeightTransferUtil] RetargetClothToAvatarSkeleton\n - bodyRefSmr.bones is null or empty"); + } + Transform[] bones4 = smr.bones; + Matrix4x4[] bindposes = sharedMesh.bindposes; + Dictionary dictionary4 = new Dictionary(); + if (bones4 != null) + { + for (int l = 0; l < bones4.Length; l++) + { + Transform val5 = bones4[l]; + if (!(val5 == null) && !dictionary4.ContainsKey(val5)) + { + dictionary4.Add(val5, l); + } + } + } + int num2 = bones3.Length; + int num3 = accessoryBones.Length; + Transform[] array3 = (Transform[])new Transform[num2 + num3]; + for (int m = 0; m < num2; m++) + { + array3[m] = bones3[m]; + } + for (int n = 0; n < num3; n++) + { + array3[num2 + n] = accessoryBones[n]; + } + Matrix4x4[] array4 = (Matrix4x4[])new Matrix4x4[array3.Length]; + for (int num4 = 0; num4 < num2; num4++) + { + Transform val6 = bones3[num4]; + if (val6 != null) + { + array4[num4] = val6.worldToLocalMatrix * localToWorldMatrix; + } + else + { + array4[num4] = Matrix4x4.identity; + } + } + for (int num5 = 0; num5 < num3; num5++) + { + Transform val7 = accessoryBones[num5]; + Matrix4x4 val8 = Matrix4x4.identity; + if (val7 != null && dictionary4.TryGetValue(val7, out var value3)) + { + val8 = ((bindposes == null || value3 < 0 || value3 >= bindposes.Length) ? (val7.worldToLocalMatrix * localToWorldMatrix) : bindposes[value3]); + } + array4[num2 + num5] = val8; + } + sharedMesh.bindposes = array4; + sharedMesh.boneWeights = (BoneWeight[])new BoneWeight[sharedMesh.vertexCount]; + smr.rootBone = bodyRefSmr.rootBone; + smr.bones = array3; + EditorUtility.SetDirty(sharedMesh); + EditorUtility.SetDirty(smr); + } - private void AccumulateRetargetWeight(float[,] W, int vertIndex, int clothBoneIndex, float weight, Transform[] clothBones, Dictionary clothBoneToHuman, Dictionary humanToTargetBoneIndex) - { - //IL_0034: Unknown result type (might be due to invalid IL or missing references) - if (!(weight <= 0f) && clothBoneIndex >= 0 && clothBoneIndex < clothBones.Length) - { - Transform val = clothBones[clothBoneIndex]; - if (!((Object)(object)val == (Object)null) && clothBoneToHuman.TryGetValue(val, out var value) && humanToTargetBoneIndex.TryGetValue(value, out var value2)) - { - W[vertIndex, value2] += weight; - } - } - } + private void AccumulateRetargetWeight(float[,] W, int vertIndex, int clothBoneIndex, float weight, Transform[] clothBones, Dictionary clothBoneToHuman, Dictionary humanToTargetBoneIndex) + { + //IL_0034: Unknown result type (might be due to invalid IL or missing references) + if (!(weight <= 0f) && clothBoneIndex >= 0 && clothBoneIndex < clothBones.Length) + { + Transform val = clothBones[clothBoneIndex]; + if (!(val == null) && clothBoneToHuman.TryGetValue(val, out var value) && humanToTargetBoneIndex.TryGetValue(value, out var value2)) + { + W[vertIndex, value2] += weight; + } + } + } - private void TransferFromBodyToCloth(Animator avatarAnimator, ClothInstance cloth, IReadOnlyList bodyMeshes, IReadOnlyList bodyBakedMeshes, Settings settings, Transform[] accessoryBones, float[,] accessoryWeights, int bodyBoneCount, BoneWeight[] prevBoneWeights = null) - { - //IL_01e5: Unknown result type (might be due to invalid IL or missing references) - //IL_01ea: Unknown result type (might be due to invalid IL or missing references) - //IL_01f3: 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_0221: 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_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_0250: Unknown result type (might be due to invalid IL or missing references) - //IL_0264: Unknown result type (might be due to invalid IL or missing references) - //IL_0269: 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_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_0283: 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_028c: 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_0297: Unknown result type (might be due to invalid IL or missing references) - //IL_0302: Unknown result type (might be due to invalid IL or missing references) - //IL_0307: Unknown result type (might be due to invalid IL or missing references) - Vector3[] worldVertices = cloth.worldVertices; - if (worldVertices == null || worldVertices.Length == 0) - { - throw new AutoMorpherException("Cloth World Vertices are Missing", "[WeightTransferUtil] TransferFromBodyToCloth\n - cloth.worldVertices is null or empty"); - } - int[] triangles = cloth.editableMesh.triangles; - Vector3[] clothWorldNormals = GetClothWorldNormals(cloth); - if (clothWorldNormals == null || clothWorldNormals.Length != worldVertices.Length) - { - throw new AutoMorpherException("Cloth World Normals Calculation Failed", "[WeightTransferUtil] TransferFromBodyToCloth\n - targetNormalsWorld is null or length mismatch\n - targetVertsWorld.Length : " + ((worldVertices == null) ? (-1) : worldVertices.Length) + "\n - targetNormalsWorld.Length : " + ((clothWorldNormals == null) ? (-1) : clothWorldNormals.Length)); - } - Transform[] bones = cloth.smr.bones; - int num = bones.Length; - Dictionary dictionary = new Dictionary(); - for (int i = 0; i < bones.Length; i++) - { - Transform val = bones[i]; - if ((Object)(object)val != (Object)null && !dictionary.ContainsKey(val)) - { - dictionary.Add(val, i); - } - } - int num2 = 0; - int num3 = 0; - foreach (SkinnedMeshRenderer bodyMesh in bodyMeshes) - { - if (!((Object)(object)bodyMesh == (Object)null) && !((Object)(object)bodyMesh.sharedMesh == (Object)null)) - { - num2 += bodyMesh.sharedMesh.vertexCount; - num3 += bodyMesh.sharedMesh.triangles.Length; - } - } - if (num2 == 0 || num3 == 0) - { - throw new AutoMorpherException("Valid Body Mesh is Missing", "[WeightTransferUtil] TransferFromBodyToCloth\n - bodyMeshes has no valid mesh (totalVerts == 0 or totalTris == 0)"); - } - Vector3[] array = (Vector3[])(object)new Vector3[num2]; - Vector3[] array2 = (Vector3[])(object)new Vector3[num2]; - int[] array3 = new int[num3]; - float[,] W = new float[num2, num]; - int num4 = 0; - int num5 = 0; - Vector3 val3 = default(Vector3); - for (int j = 0; j < bodyMeshes.Count; j++) - { - SkinnedMeshRenderer val2 = bodyMeshes[j]; - if ((Object)(object)val2 == (Object)null || (Object)(object)val2.sharedMesh == (Object)null) - { - continue; - } - Mesh sharedMesh = val2.sharedMesh; - Mesh obj = bodyBakedMeshes[j]; - Vector3[] vertices = obj.vertices; - Vector3[] normals = obj.normals; - int[] triangles2 = obj.triangles; - int vertexCount = obj.vertexCount; - Vector3 lossyScale = ((Component)val2).transform.lossyScale; - ((Vector3)(ref val3))._002Ector(1f / Mathf.Max(lossyScale.x, 1E-08f), 1f / Mathf.Max(lossyScale.y, 1E-08f), 1f / Mathf.Max(lossyScale.z, 1E-08f)); - Matrix4x4 val4 = ((Component)val2).transform.localToWorldMatrix * Matrix4x4.Scale(val3); - for (int k = 0; k < vertexCount; k++) - { - array[num4 + k] = ((Matrix4x4)(ref val4)).MultiplyPoint3x4(vertices[k]); - Vector3 val5 = ((Matrix4x4)(ref val4)).MultiplyVector(normals[k]); - Vector3 normalized = ((Vector3)(ref val5)).normalized; - array2[num4 + k] = normalized; - } - for (int l = 0; l < triangles2.Length; l++) - { - array3[num5 + l] = triangles2[l] + num4; - } - BoneWeight[] boneWeights = sharedMesh.boneWeights; - Transform[] bones2 = val2.bones; - if (boneWeights != null && boneWeights.Length == vertexCount && bones2 != null) - { - for (int m = 0; m < vertexCount; m++) - { - BoneWeight val6 = boneWeights[m]; - AccumulateBodyWeight(ref W, num4 + m, ((BoneWeight)(ref val6)).boneIndex0, ((BoneWeight)(ref val6)).weight0, bones2, dictionary); - AccumulateBodyWeight(ref W, num4 + m, ((BoneWeight)(ref val6)).boneIndex1, ((BoneWeight)(ref val6)).weight1, bones2, dictionary); - AccumulateBodyWeight(ref W, num4 + m, ((BoneWeight)(ref val6)).boneIndex2, ((BoneWeight)(ref val6)).weight2, bones2, dictionary); - AccumulateBodyWeight(ref W, num4 + m, ((BoneWeight)(ref val6)).boneIndex3, ((BoneWeight)(ref val6)).weight3, bones2, dictionary); - } - } - num4 += vertexCount; - num5 += triangles2.Length; - } - List[] array4 = cloth.vertexAdjacency; - if (array4 == null || array4.Length != worldVertices.Length) - { - array4 = BuildAdjacencyFromTriangles(worldVertices.Length, triangles); - } - float[,] weights = FindMatchesClosestSurface(array, array3, array2, worldVertices, clothWorldNormals, W, settings.maxDistance * settings.maxDistance, settings.maxNormalAngleDeg, settings.allowFlippedNormal, out var matchedMask); - weights = InpaintApprox(worldVertices, triangles, weights, matchedMask, array4, 20, 0.7f); - if (settings.enableSmoothing && settings.smoothingIterations > 0 && settings.smoothingAlpha > 0f) - { - weights = SmoothWeightsApprox(worldVertices, weights, matchedMask, array4, settings.smoothingIterations, settings.smoothingAlpha, settings.maxDistance); - } - ApplyLegVertexConstraints(avatarAnimator, cloth, weights, bodyBoneCount, settings.tinyWeight); - int vertexCount2 = cloth.editableMesh.vertexCount; - num = cloth.smr.bones.Length; - if (accessoryBones != null && accessoryBones.Length != 0 && accessoryWeights != null && bodyBoneCount > 0) - { - HashSet value = null; - if (cloth.humanoidMatchedBones != null) - { - cloth.humanoidMatchedBones.TryGetValue((HumanBodyBones)10, out value); - } - Transform val7 = null; - if ((Object)(object)avatarAnimator != (Object)null) - { - val7 = avatarAnimator.GetBoneTransform((HumanBodyBones)10); - } - if (value != null && (Object)(object)val7 != (Object)null) - { - int num6 = Array.IndexOf(cloth.smr.bones, val7); - if (num6 >= 0 && num6 < bodyBoneCount) - { - foreach (Transform item in value) - { - if ((Object)(object)item == (Object)null) - { - continue; - } - int num7 = Array.IndexOf(accessoryBones, item); - if (num7 < 0) - { - continue; - } - for (int n = 0; n < vertexCount2; n++) - { - float num8 = accessoryWeights[n, num7]; - if (!(num8 <= settings.tinyWeight)) - { - weights[n, num6] += num8; - accessoryWeights[n, num7] = 0f; - } - } - } - } - } - } - BoneWeight[] array5; - if (accessoryBones != null && accessoryBones.Length != 0 && accessoryWeights != null && bodyBoneCount > 0 && bodyBoneCount + accessoryBones.Length == num) - { - array5 = MergeBodyAndAccessoryWeights(weights, accessoryWeights, bodyBoneCount, settings.tinyWeight, settings.enforceFourBoneLimit); - } - else - { - if (settings.enforceFourBoneLimit) - { - EnforceMaxBonesPerVertex(weights, 4, settings.tinyWeight); - } - else - { - ZeroSmallWeights(weights, settings.tinyWeight); - } - NormalizeWeightsPerVertex(weights, settings.tinyWeight); - array5 = CollapseWeightsToBoneWeights(weights, 4, settings.tinyWeight); - } - Mesh sharedMesh2 = cloth.smr.sharedMesh; - if (sharedMesh2.vertexCount != array5.Length) - { - throw new AutoMorpherException("Vertex Count and Weight Length Mismatch", "[WeightTransferUtil] TransferFromBodyToCloth\n - mesh.vertexCount : " + sharedMesh2.vertexCount + "\n - finalWeights.Length : " + array5.Length); - } - EnsureNonZeroAndNormalizeFinalWeights(cloth, array5, array4, settings.tinyWeight); - ApplyEquivalentVertexWeights(cloth, array5); - NormalizeAllBoneWeightsInPlace(array5, settings.tinyWeight); - sharedMesh2.boneWeights = array5; - cloth.smr.sharedMesh = sharedMesh2; - if (!TryApplyBoneWeightsWithValidation(sharedMesh2, array5, 1E-10f, out var zeroWeightVertexCount)) - { - Debug.LogWarning((object)$"[WeightValidation] Zero-weight vertices detected: {zeroWeightVertexCount}"); - } - } + private void TransferFromBodyToCloth(Animator avatarAnimator, ClothInstance cloth, IReadOnlyList bodyMeshes, IReadOnlyList bodyBakedMeshes, Settings settings, Transform[] accessoryBones, float[,] accessoryWeights, int bodyBoneCount, BoneWeight[] prevBoneWeights = null) + { + //IL_01e5: Unknown result type (might be due to invalid IL or missing references) + //IL_01ea: Unknown result type (might be due to invalid IL or missing references) + //IL_01f3: 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_0221: 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_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_0250: Unknown result type (might be due to invalid IL or missing references) + //IL_0264: Unknown result type (might be due to invalid IL or missing references) + //IL_0269: 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_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_0283: 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_028c: 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_0297: Unknown result type (might be due to invalid IL or missing references) + //IL_0302: Unknown result type (might be due to invalid IL or missing references) + //IL_0307: Unknown result type (might be due to invalid IL or missing references) + Vector3[] worldVertices = cloth.worldVertices; + if (worldVertices == null || worldVertices.Length == 0) + { + throw new AutoMorpherException("Cloth World Vertices are Missing", "[WeightTransferUtil] TransferFromBodyToCloth\n - cloth.worldVertices is null or empty"); + } + int[] triangles = cloth.editableMesh.triangles; + Vector3[] clothWorldNormals = this.GetClothWorldNormals(cloth); + if (clothWorldNormals == null || clothWorldNormals.Length != worldVertices.Length) + { + throw new AutoMorpherException("Cloth World Normals Calculation Failed", "[WeightTransferUtil] TransferFromBodyToCloth\n - targetNormalsWorld is null or length mismatch\n - targetVertsWorld.Length : " + ((worldVertices == null) ? (-1) : worldVertices.Length) + "\n - targetNormalsWorld.Length : " + ((clothWorldNormals == null) ? (-1) : clothWorldNormals.Length)); + } + Transform[] bones = cloth.smr.bones; + int num = bones.Length; + Dictionary dictionary = new Dictionary(); + for (int i = 0; i < bones.Length; i++) + { + Transform val = bones[i]; + if (val != null && !dictionary.ContainsKey(val)) + { + dictionary.Add(val, i); + } + } + int num2 = 0; + int num3 = 0; + foreach (SkinnedMeshRenderer bodyMesh in bodyMeshes) + { + if (!(bodyMesh == null) && !(bodyMesh.sharedMesh == null)) + { + num2 += bodyMesh.sharedMesh.vertexCount; + num3 += bodyMesh.sharedMesh.triangles.Length; + } + } + if (num2 == 0 || num3 == 0) + { + throw new AutoMorpherException("Valid Body Mesh is Missing", "[WeightTransferUtil] TransferFromBodyToCloth\n - bodyMeshes has no valid mesh (totalVerts == 0 or totalTris == 0)"); + } + Vector3[] array = (Vector3[])new Vector3[num2]; + Vector3[] array2 = (Vector3[])new Vector3[num2]; + int[] array3 = new int[num3]; + float[,] W = new float[num2, num]; + int num4 = 0; + int num5 = 0; + Vector3 val3 = default(Vector3); + for (int j = 0; j < bodyMeshes.Count; j++) + { + SkinnedMeshRenderer val2 = bodyMeshes[j]; + if (val2 == null || val2.sharedMesh == null) + { + continue; + } + Mesh sharedMesh = val2.sharedMesh; + Mesh obj = bodyBakedMeshes[j]; + Vector3[] vertices = obj.vertices; + Vector3[] normals = obj.normals; + int[] triangles2 = obj.triangles; + int vertexCount = obj.vertexCount; + Vector3 lossyScale = ((Component)val2).transform.lossyScale; + val3 = new Vector3(1f / Mathf.Max(lossyScale.x, 1E-08f), 1f / Mathf.Max(lossyScale.y, 1E-08f), 1f / Mathf.Max(lossyScale.z, 1E-08f)); + Matrix4x4 val4 = ((Component)val2).transform.localToWorldMatrix * Matrix4x4.Scale(val3); + for (int k = 0; k < vertexCount; k++) + { + array[num4 + k] = val4.MultiplyPoint3x4(vertices[k]); + Vector3 val5 = val4.MultiplyVector(normals[k]); + Vector3 normalized = val5.normalized; + array2[num4 + k] = normalized; + } + for (int l = 0; l < triangles2.Length; l++) + { + array3[num5 + l] = triangles2[l] + num4; + } + BoneWeight[] boneWeights = sharedMesh.boneWeights; + Transform[] bones2 = val2.bones; + if (boneWeights != null && boneWeights.Length == vertexCount && bones2 != null) + { + for (int m = 0; m < vertexCount; m++) + { + BoneWeight val6 = boneWeights[m]; + this.AccumulateBodyWeight(ref W, num4 + m, val6.boneIndex0, val6.weight0, bones2, dictionary); + this.AccumulateBodyWeight(ref W, num4 + m, val6.boneIndex1, val6.weight1, bones2, dictionary); + this.AccumulateBodyWeight(ref W, num4 + m, val6.boneIndex2, val6.weight2, bones2, dictionary); + this.AccumulateBodyWeight(ref W, num4 + m, val6.boneIndex3, val6.weight3, bones2, dictionary); + } + } + num4 += vertexCount; + num5 += triangles2.Length; + } + List[] array4 = cloth.vertexAdjacency; + if (array4 == null || array4.Length != worldVertices.Length) + { + array4 = this.BuildAdjacencyFromTriangles(worldVertices.Length, triangles); + } + float[,] weights = this.FindMatchesClosestSurface(array, array3, array2, worldVertices, clothWorldNormals, W, settings.maxDistance * settings.maxDistance, settings.maxNormalAngleDeg, settings.allowFlippedNormal, out var matchedMask); + weights = this.InpaintApprox(worldVertices, triangles, weights, matchedMask, array4, 20, 0.7f); + if (settings.enableSmoothing && settings.smoothingIterations > 0 && settings.smoothingAlpha > 0f) + { + weights = this.SmoothWeightsApprox(worldVertices, weights, matchedMask, array4, settings.smoothingIterations, settings.smoothingAlpha, settings.maxDistance); + } + this.ApplyLegVertexConstraints(avatarAnimator, cloth, weights, bodyBoneCount, settings.tinyWeight); + int vertexCount2 = cloth.editableMesh.vertexCount; + num = cloth.smr.bones.Length; + if (accessoryBones != null && accessoryBones.Length != 0 && accessoryWeights != null && bodyBoneCount > 0) + { + HashSet value = null; + if (cloth.humanoidMatchedBones != null) + { + cloth.humanoidMatchedBones.TryGetValue((HumanBodyBones)10, out value); + } + Transform val7 = null; + if (avatarAnimator != null) + { + val7 = avatarAnimator.GetBoneTransform((HumanBodyBones)10); + } + if (value != null && val7 != null) + { + int num6 = Array.IndexOf(cloth.smr.bones, val7); + if (num6 >= 0 && num6 < bodyBoneCount) + { + foreach (Transform item in value) + { + if (item == null) + { + continue; + } + int num7 = Array.IndexOf(accessoryBones, item); + if (num7 < 0) + { + continue; + } + for (int n = 0; n < vertexCount2; n++) + { + float num8 = accessoryWeights[n, num7]; + if (!(num8 <= settings.tinyWeight)) + { + weights[n, num6] += num8; + accessoryWeights[n, num7] = 0f; + } + } + } + } + } + } + BoneWeight[] array5; + if (accessoryBones != null && accessoryBones.Length != 0 && accessoryWeights != null && bodyBoneCount > 0 && bodyBoneCount + accessoryBones.Length == num) + { + array5 = this.MergeBodyAndAccessoryWeights(weights, accessoryWeights, bodyBoneCount, settings.tinyWeight, settings.enforceFourBoneLimit); + } + else + { + if (settings.enforceFourBoneLimit) + { + this.EnforceMaxBonesPerVertex(weights, 4, settings.tinyWeight); + } + else + { + this.ZeroSmallWeights(weights, settings.tinyWeight); + } + this.NormalizeWeightsPerVertex(weights, settings.tinyWeight); + array5 = this.CollapseWeightsToBoneWeights(weights, 4, settings.tinyWeight); + } + Mesh sharedMesh2 = cloth.smr.sharedMesh; + if (sharedMesh2.vertexCount != array5.Length) + { + throw new AutoMorpherException("Vertex Count and Weight Length Mismatch", "[WeightTransferUtil] TransferFromBodyToCloth\n - mesh.vertexCount : " + sharedMesh2.vertexCount + "\n - finalWeights.Length : " + array5.Length); + } + this.EnsureNonZeroAndNormalizeFinalWeights(cloth, array5, array4, settings.tinyWeight); + this.ApplyEquivalentVertexWeights(cloth, array5); + this.NormalizeAllBoneWeightsInPlace(array5, settings.tinyWeight); + sharedMesh2.boneWeights = array5; + cloth.smr.sharedMesh = sharedMesh2; + if (!this.TryApplyBoneWeightsWithValidation(sharedMesh2, array5, 1E-10f, out var zeroWeightVertexCount)) + { + Debug.LogWarning($"[WeightValidation] Zero-weight vertices detected: {zeroWeightVertexCount}"); + } + } - public void MoveBodyWeightsToClothesBones(SkinnedMeshRenderer clothesSmr, Mesh clothesMesh, Dictionary bodyToClothesMap, Transform[] accessoryBones) - { - //IL_01af: Unknown result type (might be due to invalid IL or missing references) - //IL_01b6: Unknown result type (might be due to invalid IL or missing references) - //IL_01bb: Unknown result type (might be due to invalid IL or missing references) - //IL_01c0: Unknown result type (might be due to invalid IL or missing references) - if ((Object)(object)clothesSmr == (Object)null) - { - throw new AutoMorpherException("Clothes SMR is Missing", "[WeightTransferUtil] MoveBodyWeightsToClothesBones\n - clothesSmr is null"); - } - if ((Object)(object)clothesMesh == (Object)null) - { - throw new AutoMorpherException("Clothes Mesh is Missing", "[WeightTransferUtil] MoveBodyWeightsToClothesBones\n - clothesMesh is null"); - } - if (bodyToClothesMap == null) - { - throw new AutoMorpherException("Body To Clothes Map is Missing", "[WeightTransferUtil] MoveBodyWeightsToClothesBones\n - bodyToClothesMap is null"); - } - Transform clothesFallbackRoot = (((Object)(object)clothesSmr.rootBone != (Object)null) ? clothesSmr.rootBone : ((Component)clothesSmr).transform); - HashSet hashSet = null; - if (accessoryBones != null && accessoryBones.Length != 0) - { - hashSet = new HashSet(accessoryBones); - } - Transform[] bones = clothesSmr.bones; - if (bones == null || bones.Length == 0) - { - throw new AutoMorpherException("Clothes Bones are Missing", "[WeightTransferUtil] MoveBodyWeightsToClothesBones\n - clothesSmr.bones is null or empty"); - } - Transform[] array = (Transform[])(object)new Transform[bones.Length]; - for (int i = 0; i < bones.Length; i++) - { - Transform val = bones[i]; - if ((Object)(object)val == (Object)null) - { - array[i] = clothesFallbackRoot; - continue; - } - if (hashSet != null && hashSet.Contains(val)) - { - array[i] = val; - continue; - } - Transform val2 = EnsureClothesBoneExists(val); - array[i] = (((Object)(object)val2 != (Object)null) ? val2 : clothesFallbackRoot); - } - clothesSmr.bones = array; - if ((Object)(object)clothesSmr.rootBone != (Object)null && (hashSet == null || !hashSet.Contains(clothesSmr.rootBone))) - { - Transform val3 = EnsureClothesBoneExists(clothesSmr.rootBone); - if ((Object)(object)val3 != (Object)null) - { - clothesSmr.rootBone = val3; - } - } - Transform val4 = (((Object)(object)clothesSmr.rootBone != (Object)null) ? clothesSmr.rootBone : ((Component)clothesSmr).transform); - Matrix4x4[] array2 = (Matrix4x4[])(object)new Matrix4x4[array.Length]; - for (int j = 0; j < array.Length; j++) - { - Transform val5 = array[j]; - if ((Object)(object)val5 == (Object)null) - { - throw new AutoMorpherException("Remapped Bone is Null", "[WeightTransferUtil] MoveBodyWeightsToClothesBones\n - remappedBones contains null bone after fallback"); - } - array2[j] = val5.worldToLocalMatrix * val4.localToWorldMatrix; - } - clothesMesh.bindposes = array2; - Transform EnsureClothesBoneExists(Transform bodyBone) - { - //IL_0059: Unknown result type (might be due to invalid IL or missing references) - //IL_006e: Unknown result type (might be due to invalid IL or missing references) - //IL_007a: Unknown result type (might be due to invalid IL or missing references) - //IL_0086: Unknown result type (might be due to invalid IL or missing references) - if ((Object)(object)bodyBone == (Object)null) - { - return null; - } - if (bodyToClothesMap.TryGetValue(bodyBone, out var value) && (Object)(object)value != (Object)null) - { - return value; - } - Transform val6 = null; - if ((Object)(object)bodyBone.parent != (Object)null) - { - val6 = EnsureClothesBoneExists(bodyBone.parent); - } - if ((Object)(object)val6 == (Object)null) - { - val6 = clothesFallbackRoot; - } - Transform transform = new GameObject(((Object)bodyBone).name).transform; - transform.SetParent(val6, false); - transform.localPosition = bodyBone.localPosition; - transform.localRotation = bodyBone.localRotation; - transform.localScale = bodyBone.localScale; - bodyToClothesMap[bodyBone] = transform; - return transform; - } - } + public void MoveBodyWeightsToClothesBones(SkinnedMeshRenderer clothesSmr, Mesh clothesMesh, Dictionary bodyToClothesMap, Transform[] accessoryBones) + { + //IL_01af: Unknown result type (might be due to invalid IL or missing references) + //IL_01b6: Unknown result type (might be due to invalid IL or missing references) + //IL_01bb: Unknown result type (might be due to invalid IL or missing references) + //IL_01c0: Unknown result type (might be due to invalid IL or missing references) + if (clothesSmr == null) + { + throw new AutoMorpherException("Clothes SMR is Missing", "[WeightTransferUtil] MoveBodyWeightsToClothesBones\n - clothesSmr is null"); + } + if (clothesMesh == null) + { + throw new AutoMorpherException("Clothes Mesh is Missing", "[WeightTransferUtil] MoveBodyWeightsToClothesBones\n - clothesMesh is null"); + } + if (bodyToClothesMap == null) + { + throw new AutoMorpherException("Body To Clothes Map is Missing", "[WeightTransferUtil] MoveBodyWeightsToClothesBones\n - bodyToClothesMap is null"); + } + Transform clothesFallbackRoot = ((clothesSmr.rootBone != null) ? clothesSmr.rootBone : ((Component)clothesSmr).transform); + HashSet hashSet = null; + if (accessoryBones != null && accessoryBones.Length != 0) + { + hashSet = new HashSet(accessoryBones); + } + Transform[] bones = clothesSmr.bones; + if (bones == null || bones.Length == 0) + { + throw new AutoMorpherException("Clothes Bones are Missing", "[WeightTransferUtil] MoveBodyWeightsToClothesBones\n - clothesSmr.bones is null or empty"); + } + Transform[] array = (Transform[])new Transform[bones.Length]; + for (int i = 0; i < bones.Length; i++) + { + Transform val = bones[i]; + if (val == null) + { + array[i] = clothesFallbackRoot; + continue; + } + if (hashSet != null && hashSet.Contains(val)) + { + array[i] = val; + continue; + } + Transform val2 = EnsureClothesBoneExists(val); + array[i] = ((val2 != null) ? val2 : clothesFallbackRoot); + } + clothesSmr.bones = array; + if (clothesSmr.rootBone != null && (hashSet == null || !hashSet.Contains(clothesSmr.rootBone))) + { + Transform val3 = EnsureClothesBoneExists(clothesSmr.rootBone); + if (val3 != null) + { + clothesSmr.rootBone = val3; + } + } + Transform val4 = ((clothesSmr.rootBone != null) ? clothesSmr.rootBone : ((Component)clothesSmr).transform); + Matrix4x4[] array2 = (Matrix4x4[])new Matrix4x4[array.Length]; + for (int j = 0; j < array.Length; j++) + { + Transform val5 = array[j]; + if (val5 == null) + { + throw new AutoMorpherException("Remapped Bone is Null", "[WeightTransferUtil] MoveBodyWeightsToClothesBones\n - remappedBones contains null bone after fallback"); + } + array2[j] = val5.worldToLocalMatrix * val4.localToWorldMatrix; + } + clothesMesh.bindposes = array2; + Transform EnsureClothesBoneExists(Transform bodyBone) + { + //IL_0059: Unknown result type (might be due to invalid IL or missing references) + //IL_006e: Unknown result type (might be due to invalid IL or missing references) + //IL_007a: Unknown result type (might be due to invalid IL or missing references) + //IL_0086: Unknown result type (might be due to invalid IL or missing references) + if (bodyBone == null) + { + return null; + } + if (bodyToClothesMap.TryGetValue(bodyBone, out var value) && value != null) + { + return value; + } + Transform val6 = null; + if (bodyBone.parent != null) + { + val6 = EnsureClothesBoneExists(bodyBone.parent); + } + if (val6 == null) + { + val6 = clothesFallbackRoot; + } + Transform transform = new GameObject((bodyBone).name).transform; + transform.SetParent(val6, false); + transform.localPosition = bodyBone.localPosition; + transform.localRotation = bodyBone.localRotation; + transform.localScale = bodyBone.localScale; + bodyToClothesMap[bodyBone] = transform; + return transform; + } + } - private bool TryApplyBoneWeightsWithValidation(Mesh mesh, BoneWeight[] weights, float tiny, out int zeroWeightVertexCount) - { - //IL_001f: Unknown result type (might be due to invalid IL or missing references) - //IL_0030: Unknown result type (might be due to invalid IL or missing references) - //IL_0035: 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_00e6: Unknown result type (might be due to invalid IL or missing references) - //IL_0101: Unknown result type (might be due to invalid IL or missing references) - //IL_0102: Unknown result type (might be due to invalid IL or missing references) - bool result = true; - zeroWeightVertexCount = 0; - int num = weights.Length; - NativeArray val = default(NativeArray); - val._002Ector(num, (Allocator)2, (NativeArrayOptions)1); - List list = new List(num * 4); - NativeArray val2 = default(NativeArray); - try - { - for (int i = 0; i < num; i++) - { - BoneWeight val3 = weights[i]; - int count = 0; - AddIfValid(list, ((BoneWeight)(ref val3)).boneIndex0, ((BoneWeight)(ref val3)).weight0, tiny, ref count); - AddIfValid(list, ((BoneWeight)(ref val3)).boneIndex1, ((BoneWeight)(ref val3)).weight1, tiny, ref count); - AddIfValid(list, ((BoneWeight)(ref val3)).boneIndex2, ((BoneWeight)(ref val3)).weight2, tiny, ref count); - AddIfValid(list, ((BoneWeight)(ref val3)).boneIndex3, ((BoneWeight)(ref val3)).weight3, tiny, ref count); - if (count == 0) - { - zeroWeightVertexCount++; - } - val[i] = (byte)count; - } - if (zeroWeightVertexCount > 0) - { - return false; - } - val2 = new NativeArray(list.Count, (Allocator)2, (NativeArrayOptions)1); - for (int j = 0; j < list.Count; j++) - { - val2[j] = list[j]; - } - mesh.SetBoneWeights(val, val2); - } - catch (Exception ex) - { - Debug.LogWarning((object)("[SetBoneWeights] Failed: " + ex.Message)); - result = false; - } - finally - { - if (val2.IsCreated) - { - val2.Dispose(); - } - if (val.IsCreated) - { - val.Dispose(); - } - } - return result; - } + private bool TryApplyBoneWeightsWithValidation(Mesh mesh, BoneWeight[] weights, float tiny, out int zeroWeightVertexCount) + { + //IL_001f: Unknown result type (might be due to invalid IL or missing references) + //IL_0030: Unknown result type (might be due to invalid IL or missing references) + //IL_0035: 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_00e6: Unknown result type (might be due to invalid IL or missing references) + //IL_0101: Unknown result type (might be due to invalid IL or missing references) + //IL_0102: Unknown result type (might be due to invalid IL or missing references) + bool result = true; + zeroWeightVertexCount = 0; + int num = weights.Length; + NativeArray val = default(NativeArray); + val = new NativeArray(num, (Allocator)2, (NativeArrayOptions)1); + List list = new List(num * 4); + NativeArray val2 = default(NativeArray); + try + { + for (int i = 0; i < num; i++) + { + BoneWeight val3 = weights[i]; + int count = 0; + this.AddIfValid(list, val3.boneIndex0, val3.weight0, tiny, ref count); + this.AddIfValid(list, val3.boneIndex1, val3.weight1, tiny, ref count); + this.AddIfValid(list, val3.boneIndex2, val3.weight2, tiny, ref count); + this.AddIfValid(list, val3.boneIndex3, val3.weight3, tiny, ref count); + if (count == 0) + { + zeroWeightVertexCount++; + } + val[i] = (byte)count; + } + if (zeroWeightVertexCount > 0) + { + return false; + } + val2 = new NativeArray(list.Count, (Allocator)2, (NativeArrayOptions)1); + for (int j = 0; j < list.Count; j++) + { + val2[j] = list[j]; + } + mesh.SetBoneWeights(val, val2); + } + catch (Exception ex) + { + Debug.LogWarning(("[SetBoneWeights] Failed: " + ex.Message)); + result = false; + } + finally + { + if (val2.IsCreated) + { + val2.Dispose(); + } + if (val.IsCreated) + { + val.Dispose(); + } + } + return result; + } - private void AddIfValid(List list, int boneIndex, float weight, float tiny, ref int count) - { - //IL_000e: 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) - if (boneIndex >= 0 && !(weight <= tiny)) - { - BoneWeight1 item = default(BoneWeight1); - ((BoneWeight1)(ref item)).boneIndex = boneIndex; - ((BoneWeight1)(ref item)).weight = weight; - list.Add(item); - count++; - } - } + private void AddIfValid(List list, int boneIndex, float weight, float tiny, ref int count) + { + //IL_000e: 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) + if (boneIndex >= 0 && !(weight <= tiny)) + { + BoneWeight1 item = default(BoneWeight1); + item.boneIndex = boneIndex; + item.weight = weight; + list.Add(item); + count++; + } + } - private void ApplyEquivalentVertexWeights(ClothInstance cloth, BoneWeight[] finalWeights) - { - //IL_00d2: 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_01d7: Unknown result type (might be due to invalid IL or missing references) - //IL_02a8: Unknown result type (might be due to invalid IL or missing references) - //IL_02aa: Unknown result type (might be due to invalid IL or missing references) - if (cloth == null || cloth.equivalentVertices == null || cloth.equivalentVertices.Count == 0 || finalWeights == null || finalWeights.Length == 0) - { - return; - } - List> equivalentVertices = cloth.equivalentVertices; - int num = finalWeights.Length; - bool[] array = new bool[num]; - foreach (List item in equivalentVertices) - { - if (item == null || item.Count == 0) - { - continue; - } - List list = null; - bool flag = false; - for (int i = 0; i < item.Count; i++) - { - int num2 = item[i]; - if (num2 >= 0 && num2 < num) - { - if (list == null) - { - list = new List(); - } - list.Add(num2); - if (!array[num2]) - { - flag = true; - } - } - } - if (list == null || !flag) - { - continue; - } - Dictionary weightMap = new Dictionary(); - foreach (int item2 in list) - { - BoneWeight val = finalWeights[item2]; - Accumulate(((BoneWeight)(ref val)).boneIndex0, ((BoneWeight)(ref val)).weight0); - Accumulate(((BoneWeight)(ref val)).boneIndex1, ((BoneWeight)(ref val)).weight1); - Accumulate(((BoneWeight)(ref val)).boneIndex2, ((BoneWeight)(ref val)).weight2); - Accumulate(((BoneWeight)(ref val)).boneIndex3, ((BoneWeight)(ref val)).weight3); - } - if (weightMap.Count == 0) - { - continue; - } - List> list2 = weightMap.OrderByDescending((KeyValuePair kv) => kv.Value).Take(4).ToList(); - float num3 = 0f; - for (int num4 = 0; num4 < Math.Min(4, list2.Count); num4++) - { - num3 += list2[num4].Value; - } - if (num3 <= 1E-08f) - { - continue; - } - BoneWeight val2 = default(BoneWeight); - for (int num5 = 0; num5 < Math.Min(4, list2.Count); num5++) - { - int key = list2[num5].Key; - float num6 = list2[num5].Value / num3; - switch (num5) - { - case 0: - ((BoneWeight)(ref val2)).boneIndex0 = key; - ((BoneWeight)(ref val2)).weight0 = num6; - break; - case 1: - ((BoneWeight)(ref val2)).boneIndex1 = key; - ((BoneWeight)(ref val2)).weight1 = num6; - break; - case 2: - ((BoneWeight)(ref val2)).boneIndex2 = key; - ((BoneWeight)(ref val2)).weight2 = num6; - break; - case 3: - ((BoneWeight)(ref val2)).boneIndex3 = key; - ((BoneWeight)(ref val2)).weight3 = num6; - break; - } - } - foreach (int item3 in list) - { - finalWeights[item3] = val2; - array[item3] = true; - } - void Accumulate(int boneIndex, float w) - { - if (!(w <= 0f) && boneIndex >= 0) - { - if (weightMap.TryGetValue(boneIndex, out var value)) - { - weightMap[boneIndex] = value + w; - } - else - { - weightMap[boneIndex] = w; - } - } - } - } - } + private void ApplyEquivalentVertexWeights(ClothInstance cloth, BoneWeight[] finalWeights) + { + //IL_00d2: 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_01d7: Unknown result type (might be due to invalid IL or missing references) + //IL_02a8: Unknown result type (might be due to invalid IL or missing references) + //IL_02aa: Unknown result type (might be due to invalid IL or missing references) + if (cloth == null || cloth.equivalentVertices == null || cloth.equivalentVertices.Count == 0 || finalWeights == null || finalWeights.Length == 0) + { + return; + } + List> equivalentVertices = cloth.equivalentVertices; + int num = finalWeights.Length; + bool[] array = new bool[num]; + foreach (List item in equivalentVertices) + { + if (item == null || item.Count == 0) + { + continue; + } + List list = null; + bool flag = false; + for (int i = 0; i < item.Count; i++) + { + int num2 = item[i]; + if (num2 >= 0 && num2 < num) + { + if (list == null) + { + list = new List(); + } + list.Add(num2); + if (!array[num2]) + { + flag = true; + } + } + } + if (list == null || !flag) + { + continue; + } + Dictionary weightMap = new Dictionary(); + foreach (int item2 in list) + { + BoneWeight val = finalWeights[item2]; + Accumulate(val.boneIndex0, val.weight0); + Accumulate(val.boneIndex1, val.weight1); + Accumulate(val.boneIndex2, val.weight2); + Accumulate(val.boneIndex3, val.weight3); + } + if (weightMap.Count == 0) + { + continue; + } + List> list2 = weightMap.OrderByDescending((KeyValuePair kv) => kv.Value).Take(4).ToList(); + float num3 = 0f; + for (int num4 = 0; num4 < Math.Min(4, list2.Count); num4++) + { + num3 += list2[num4].Value; + } + if (num3 <= 1E-08f) + { + continue; + } + BoneWeight val2 = default(BoneWeight); + for (int num5 = 0; num5 < Math.Min(4, list2.Count); num5++) + { + int key = list2[num5].Key; + float num6 = list2[num5].Value / num3; + switch (num5) + { + case 0: + val2.boneIndex0 = key; + val2.weight0 = num6; + break; + case 1: + val2.boneIndex1 = key; + val2.weight1 = num6; + break; + case 2: + val2.boneIndex2 = key; + val2.weight2 = num6; + break; + case 3: + val2.boneIndex3 = key; + val2.weight3 = num6; + break; + } + } + foreach (int item3 in list) + { + finalWeights[item3] = val2; + array[item3] = true; + } + void Accumulate(int boneIndex, float w) + { + if (!(w <= 0f) && boneIndex >= 0) + { + if (weightMap.TryGetValue(boneIndex, out var value)) + { + weightMap[boneIndex] = value + w; + } + else + { + weightMap[boneIndex] = w; + } + } + } + } + } - private void ApplyLegVertexConstraints(Animator avatarAnimator, ClothInstance cloth, float[,] weights, int bodyBoneCount, float tinyWeight) - { - if (cloth == null || (Object)(object)cloth.smr == (Object)null) - { - return; - } - bool[] isLeftLegVertex = cloth.isLeftLegVertex; - bool[] isRightLegVertex = cloth.isRightLegVertex; - if (isLeftLegVertex == null && isRightLegVertex == null) - { - return; - } - Transform[] bones = cloth.smr.bones; - if (bones == null) - { - return; - } - int length = weights.GetLength(0); - int length2 = weights.GetLength(1); - Transform boneTransform = avatarAnimator.GetBoneTransform((HumanBodyBones)1); - Transform boneTransform2 = avatarAnimator.GetBoneTransform((HumanBodyBones)2); - bool[] array = new bool[length2]; - bool[] array2 = new bool[length2]; - int num = Mathf.Min(bodyBoneCount, bones.Length); - for (int i = 0; i < num; i++) - { - Transform val = bones[i]; - if (!((Object)(object)val == (Object)null)) - { - if (val.IsChildOf(boneTransform)) - { - array[i] = true; - } - else if (val.IsChildOf(boneTransform2)) - { - array2[i] = true; - } - } - } - for (int j = 0; j < length; j++) - { - bool flag = isLeftLegVertex != null && j < isLeftLegVertex.Length && isLeftLegVertex[j]; - bool flag2 = isRightLegVertex != null && j < isRightLegVertex.Length && isRightLegVertex[j]; - if (!flag && !flag2) - { - continue; - } - for (int k = 0; k < length2; k++) - { - if (weights[j, k] <= tinyWeight) - { - continue; - } - if (flag) - { - if (array2[k]) - { - weights[j, k] = 0f; - } - } - else if (flag2 && array[k]) - { - weights[j, k] = 0f; - } - } - } - } + private void ApplyLegVertexConstraints(Animator avatarAnimator, ClothInstance cloth, float[,] weights, int bodyBoneCount, float tinyWeight) + { + if (cloth == null || cloth.smr == null) + { + return; + } + bool[] isLeftLegVertex = cloth.isLeftLegVertex; + bool[] isRightLegVertex = cloth.isRightLegVertex; + if (isLeftLegVertex == null && isRightLegVertex == null) + { + return; + } + Transform[] bones = cloth.smr.bones; + if (bones == null) + { + return; + } + int length = weights.GetLength(0); + int length2 = weights.GetLength(1); + Transform boneTransform = avatarAnimator.GetBoneTransform((HumanBodyBones)1); + Transform boneTransform2 = avatarAnimator.GetBoneTransform((HumanBodyBones)2); + bool[] array = new bool[length2]; + bool[] array2 = new bool[length2]; + int num = Mathf.Min(bodyBoneCount, bones.Length); + for (int i = 0; i < num; i++) + { + Transform val = bones[i]; + if (!(val == null)) + { + if (val.IsChildOf(boneTransform)) + { + array[i] = true; + } + else if (val.IsChildOf(boneTransform2)) + { + array2[i] = true; + } + } + } + for (int j = 0; j < length; j++) + { + bool flag = isLeftLegVertex != null && j < isLeftLegVertex.Length && isLeftLegVertex[j]; + bool flag2 = isRightLegVertex != null && j < isRightLegVertex.Length && isRightLegVertex[j]; + if (!flag && !flag2) + { + continue; + } + for (int k = 0; k < length2; k++) + { + if (weights[j, k] <= tinyWeight) + { + continue; + } + if (flag) + { + if (array2[k]) + { + weights[j, k] = 0f; + } + } + else if (flag2 && array[k]) + { + weights[j, k] = 0f; + } + } + } + } - private Vector3[] GetClothWorldNormals(ClothInstance cloth) - { - //IL_00ae: Unknown result type (might be due to invalid IL or missing references) - //IL_00b3: Unknown result type (might be due to invalid IL or missing references) - //IL_00b8: Unknown result type (might be due to invalid IL or missing references) - //IL_00bc: Unknown result type (might be due to invalid IL or missing references) - //IL_00c1: Unknown result type (might be due to invalid IL or missing references) - //IL_00c6: Unknown result type (might be due to invalid IL or missing references) - //IL_00c8: Unknown result type (might be due to invalid IL or missing references) - if (cloth.worldVertices == null) - { - return null; - } - int num = cloth.worldVertices.Length; - if ((Object)(object)cloth.bakedMesh == (Object)null || cloth.bakedMesh.vertexCount != num) - { - throw new AutoMorpherException("Cloth Baked Mesh is Invalid", "[WeightTransferUtil] GetClothWorldNormals\n - bakedMesh is null or vertexCount mismatch\n - bakedMesh.vertexCount : " + (((Object)(object)cloth.bakedMesh == (Object)null) ? (-1) : cloth.bakedMesh.vertexCount) + "\n - worldVertices.Length : " + num); - } - Vector3[] array = (Vector3[])(object)new Vector3[num]; - Mesh bakedMesh = cloth.bakedMesh; - Vector3[] normals = bakedMesh.normals; - if (normals == null || normals.Length != num) - { - bakedMesh.RecalculateNormals(); - normals = bakedMesh.normals; - } - for (int i = 0; i < num; i++) - { - Vector3 val = ((Matrix4x4)(ref cloth.worldNoScale)).MultiplyVector(normals[i]); - Vector3 normalized = ((Vector3)(ref val)).normalized; - array[i] = normalized; - } - return array; - } + private Vector3[] GetClothWorldNormals(ClothInstance cloth) + { + //IL_00ae: Unknown result type (might be due to invalid IL or missing references) + //IL_00b3: Unknown result type (might be due to invalid IL or missing references) + //IL_00b8: Unknown result type (might be due to invalid IL or missing references) + //IL_00bc: Unknown result type (might be due to invalid IL or missing references) + //IL_00c1: Unknown result type (might be due to invalid IL or missing references) + //IL_00c6: Unknown result type (might be due to invalid IL or missing references) + //IL_00c8: Unknown result type (might be due to invalid IL or missing references) + if (cloth.worldVertices == null) + { + return null; + } + int num = cloth.worldVertices.Length; + if (cloth.bakedMesh == null || cloth.bakedMesh.vertexCount != num) + { + throw new AutoMorpherException("Cloth Baked Mesh is Invalid", "[WeightTransferUtil] GetClothWorldNormals\n - bakedMesh is null or vertexCount mismatch\n - bakedMesh.vertexCount : " + ((cloth.bakedMesh == null) ? (-1) : cloth.bakedMesh.vertexCount) + "\n - worldVertices.Length : " + num); + } + Vector3[] array = (Vector3[])new Vector3[num]; + Mesh bakedMesh = cloth.bakedMesh; + Vector3[] normals = bakedMesh.normals; + if (normals == null || normals.Length != num) + { + bakedMesh.RecalculateNormals(); + normals = bakedMesh.normals; + } + for (int i = 0; i < num; i++) + { + Vector3 val = cloth.worldNoScale.MultiplyVector(normals[i]); + Vector3 normalized = val.normalized; + array[i] = normalized; + } + return array; + } - private void AccumulateBodyWeight(ref float[,] W, int vIndex, int localBoneIndex, float weight, Transform[] bodyBones, Dictionary targetBoneIndexByTransform) - { - if (!(weight <= 0f) && bodyBones != null && localBoneIndex >= 0 && localBoneIndex < bodyBones.Length) - { - Transform val = bodyBones[localBoneIndex]; - if (!((Object)(object)val == (Object)null) && targetBoneIndexByTransform.TryGetValue(val, out var value)) - { - W[vIndex, value] += weight; - } - } - } + private void AccumulateBodyWeight(ref float[,] W, int vIndex, int localBoneIndex, float weight, Transform[] bodyBones, Dictionary targetBoneIndexByTransform) + { + if (!(weight <= 0f) && bodyBones != null && localBoneIndex >= 0 && localBoneIndex < bodyBones.Length) + { + Transform val = bodyBones[localBoneIndex]; + if (!(val == null) && targetBoneIndexByTransform.TryGetValue(val, out var value)) + { + W[vIndex, value] += weight; + } + } + } - private List[] BuildAdjacencyFromTriangles(int vertexCount, int[] triangles) - { - List[] array = new List[vertexCount]; - for (int i = 0; i < vertexCount; i++) - { - array[i] = new List(); - } - int num = triangles.Length / 3; - for (int j = 0; j < num; j++) - { - int num2 = triangles[j * 3]; - int num3 = triangles[j * 3 + 1]; - int num4 = triangles[j * 3 + 2]; - AddEdge(array, num2, num3); - AddEdge(array, num3, num4); - AddEdge(array, num4, num2); - } - return array; - } + private List[] BuildAdjacencyFromTriangles(int vertexCount, int[] triangles) + { + List[] array = new List[vertexCount]; + for (int i = 0; i < vertexCount; i++) + { + array[i] = new List(); + } + int num = triangles.Length / 3; + for (int j = 0; j < num; j++) + { + int num2 = triangles[j * 3]; + int num3 = triangles[j * 3 + 1]; + int num4 = triangles[j * 3 + 2]; + this.AddEdge(array, num2, num3); + this.AddEdge(array, num3, num4); + this.AddEdge(array, num4, num2); + } + return array; + } - private void AddEdge(List[] adj, int a, int b) - { - if (!adj[a].Contains(b)) - { - adj[a].Add(b); - } - if (!adj[b].Contains(a)) - { - adj[b].Add(a); - } - } + private void AddEdge(List[] adj, int a, int b) + { + if (!adj[a].Contains(b)) + { + adj[a].Add(b); + } + if (!adj[b].Contains(a)) + { + adj[b].Add(a); + } + } - private float[,] FindMatchesClosestSurface(Vector3[] sourceVerts, int[] sourceTris, Vector3[] sourceNormals, Vector3[] targetVerts, Vector3[] targetNormals, float[,] sourceWeights, float distanceThresholdSqr, float angleThresholdDeg, bool flipVertexNormal, out bool[] matchedMask) - { - //IL_003b: Unknown result type (might be due to invalid IL or missing references) - //IL_0040: Unknown result type (might be due to invalid IL or missing references) - //IL_004c: Unknown result type (might be due to invalid IL or missing references) - //IL_0051: Unknown result type (might be due to invalid IL or missing references) - //IL_0077: Unknown result type (might be due to invalid IL or missing references) - //IL_007c: Unknown result type (might be due to invalid IL or missing references) - //IL_0081: Unknown result type (might be due to invalid IL or missing references) - //IL_0086: Unknown result type (might be due to invalid IL or missing references) - //IL_008b: Unknown result type (might be due to invalid IL or missing references) - //IL_0090: Unknown result type (might be due to invalid IL or missing references) - //IL_0093: Unknown result type (might be due to invalid IL or missing references) - //IL_0095: Unknown result type (might be due to invalid IL or missing references) - //IL_0097: 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_009d: Unknown result type (might be due to invalid IL or missing references) - //IL_00a2: Unknown result type (might be due to invalid IL or missing references) - //IL_00a4: Unknown result type (might be due to invalid IL or missing references) - //IL_00a6: Unknown result type (might be due to invalid IL or missing references) - //IL_00a8: Unknown result type (might be due to invalid IL or missing references) - //IL_00ad: Unknown result type (might be due to invalid IL or missing references) - //IL_00c6: Unknown result type (might be due to invalid IL or missing references) - //IL_00c8: Unknown result type (might be due to invalid IL or missing references) - //IL_010e: Unknown result type (might be due to invalid IL or missing references) - //IL_0116: Unknown result type (might be due to invalid IL or missing references) - //IL_011b: Unknown result type (might be due to invalid IL or missing references) - //IL_0120: Unknown result type (might be due to invalid IL or missing references) - //IL_0125: Unknown result type (might be due to invalid IL or missing references) - //IL_0127: Unknown result type (might be due to invalid IL or missing references) - //IL_012e: Unknown result type (might be due to invalid IL or missing references) - //IL_0133: 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_013c: Unknown result type (might be due to invalid IL or missing references) - //IL_0141: Unknown result type (might be due to invalid IL or missing references) - //IL_0146: 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_014f: 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_015d: Unknown result type (might be due to invalid IL or missing references) - //IL_016b: Unknown result type (might be due to invalid IL or missing references) - //IL_0170: Unknown result type (might be due to invalid IL or missing references) - //IL_0172: Unknown result type (might be due to invalid IL or missing references) - //IL_01ed: Unknown result type (might be due to invalid IL or missing references) - //IL_01f7: Unknown result type (might be due to invalid IL or missing references) - //IL_0202: Unknown result type (might be due to invalid IL or missing references) - int num = targetVerts.Length; - int length = sourceWeights.GetLength(1); - float[,] array = new float[num, length]; - matchedMask = new bool[num]; - int num2 = sourceTris.Length / 3; - float num3 = angleThresholdDeg * (MathF.PI / 180f); - for (int i = 0; i < num; i++) - { - Vector3 val = targetVerts[i]; - float num4 = float.PositiveInfinity; - int num5 = -1; - Vector3 val2 = Vector3.zero; - Vector3 val4; - for (int j = 0; j < num2; j++) - { - int num6 = sourceTris[j * 3]; - int num7 = sourceTris[j * 3 + 1]; - int num8 = sourceTris[j * 3 + 2]; - Vector3 a = sourceVerts[num6]; - Vector3 b = sourceVerts[num7]; - Vector3 c = sourceVerts[num8]; - Vector3 bary; - Vector3 val3 = ClosestPointOnTriangle(val, a, b, c, out bary); - val4 = val - val3; - float sqrMagnitude = ((Vector3)(ref val4)).sqrMagnitude; - if (sqrMagnitude < num4) - { - num4 = sqrMagnitude; - num5 = j; - val2 = bary; - } - } - if (num5 < 0) - { - matchedMask[i] = false; - continue; - } - bool num9 = num4 <= distanceThresholdSqr; - int num10 = sourceTris[num5 * 3]; - int num11 = sourceTris[num5 * 3 + 1]; - int num12 = sourceTris[num5 * 3 + 2]; - Vector3 val5 = sourceNormals[num10]; - Vector3 val6 = sourceNormals[num11]; - Vector3 val7 = sourceNormals[num12]; - val4 = val5 * val2.x + val6 * val2.y + val7 * val2.z; - Vector3 normalized = ((Vector3)(ref val4)).normalized; - Vector3 normalized2 = ((Vector3)(ref targetNormals[i])).normalized; - float num13 = Mathf.Acos(Mathf.Clamp(Vector3.Dot(normalized, normalized2), -1f, 1f)); - bool flag = num13 <= num3; - if (flipVertexNormal && MathF.PI - num13 <= num3) - { - flag = true; - } - bool flag2 = num9 && flag; - matchedMask[i] = flag2; - for (int k = 0; k < length; k++) - { - float num14 = sourceWeights[num10, k]; - float num15 = sourceWeights[num11, k]; - float num16 = sourceWeights[num12, k]; - array[i, k] = num14 * val2.x + num15 * val2.y + num16 * val2.z; - } - } - return array; - } + private float[,] FindMatchesClosestSurface(Vector3[] sourceVerts, int[] sourceTris, Vector3[] sourceNormals, Vector3[] targetVerts, Vector3[] targetNormals, float[,] sourceWeights, float distanceThresholdSqr, float angleThresholdDeg, bool flipVertexNormal, out bool[] matchedMask) + { + //IL_003b: Unknown result type (might be due to invalid IL or missing references) + //IL_0040: Unknown result type (might be due to invalid IL or missing references) + //IL_004c: Unknown result type (might be due to invalid IL or missing references) + //IL_0051: Unknown result type (might be due to invalid IL or missing references) + //IL_0077: Unknown result type (might be due to invalid IL or missing references) + //IL_007c: Unknown result type (might be due to invalid IL or missing references) + //IL_0081: Unknown result type (might be due to invalid IL or missing references) + //IL_0086: Unknown result type (might be due to invalid IL or missing references) + //IL_008b: Unknown result type (might be due to invalid IL or missing references) + //IL_0090: Unknown result type (might be due to invalid IL or missing references) + //IL_0093: Unknown result type (might be due to invalid IL or missing references) + //IL_0095: Unknown result type (might be due to invalid IL or missing references) + //IL_0097: 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_009d: Unknown result type (might be due to invalid IL or missing references) + //IL_00a2: Unknown result type (might be due to invalid IL or missing references) + //IL_00a4: Unknown result type (might be due to invalid IL or missing references) + //IL_00a6: Unknown result type (might be due to invalid IL or missing references) + //IL_00a8: Unknown result type (might be due to invalid IL or missing references) + //IL_00ad: Unknown result type (might be due to invalid IL or missing references) + //IL_00c6: Unknown result type (might be due to invalid IL or missing references) + //IL_00c8: Unknown result type (might be due to invalid IL or missing references) + //IL_010e: Unknown result type (might be due to invalid IL or missing references) + //IL_0116: Unknown result type (might be due to invalid IL or missing references) + //IL_011b: Unknown result type (might be due to invalid IL or missing references) + //IL_0120: Unknown result type (might be due to invalid IL or missing references) + //IL_0125: Unknown result type (might be due to invalid IL or missing references) + //IL_0127: Unknown result type (might be due to invalid IL or missing references) + //IL_012e: Unknown result type (might be due to invalid IL or missing references) + //IL_0133: 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_013c: Unknown result type (might be due to invalid IL or missing references) + //IL_0141: Unknown result type (might be due to invalid IL or missing references) + //IL_0146: 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_014f: 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_015d: Unknown result type (might be due to invalid IL or missing references) + //IL_016b: Unknown result type (might be due to invalid IL or missing references) + //IL_0170: Unknown result type (might be due to invalid IL or missing references) + //IL_0172: Unknown result type (might be due to invalid IL or missing references) + //IL_01ed: Unknown result type (might be due to invalid IL or missing references) + //IL_01f7: Unknown result type (might be due to invalid IL or missing references) + //IL_0202: Unknown result type (might be due to invalid IL or missing references) + int num = targetVerts.Length; + int length = sourceWeights.GetLength(1); + float[,] array = new float[num, length]; + matchedMask = new bool[num]; + int num2 = sourceTris.Length / 3; + float num3 = angleThresholdDeg * (MathF.PI / 180f); + for (int i = 0; i < num; i++) + { + Vector3 val = targetVerts[i]; + float num4 = float.PositiveInfinity; + int num5 = -1; + Vector3 val2 = Vector3.zero; + Vector3 val4; + for (int j = 0; j < num2; j++) + { + int num6 = sourceTris[j * 3]; + int num7 = sourceTris[j * 3 + 1]; + int num8 = sourceTris[j * 3 + 2]; + Vector3 a = sourceVerts[num6]; + Vector3 b = sourceVerts[num7]; + Vector3 c = sourceVerts[num8]; + Vector3 bary; + Vector3 val3 = this.ClosestPointOnTriangle(val, a, b, c, out bary); + val4 = val - val3; + float sqrMagnitude = val4.sqrMagnitude; + if (sqrMagnitude < num4) + { + num4 = sqrMagnitude; + num5 = j; + val2 = bary; + } + } + if (num5 < 0) + { + matchedMask[i] = false; + continue; + } + bool num9 = num4 <= distanceThresholdSqr; + int num10 = sourceTris[num5 * 3]; + int num11 = sourceTris[num5 * 3 + 1]; + int num12 = sourceTris[num5 * 3 + 2]; + Vector3 val5 = sourceNormals[num10]; + Vector3 val6 = sourceNormals[num11]; + Vector3 val7 = sourceNormals[num12]; + val4 = val5 * val2.x + val6 * val2.y + val7 * val2.z; + Vector3 normalized = val4.normalized; + Vector3 normalized2 = targetNormals[i].normalized; + float num13 = Mathf.Acos(Mathf.Clamp(Vector3.Dot(normalized, normalized2), -1f, 1f)); + bool flag = num13 <= num3; + if (flipVertexNormal && MathF.PI - num13 <= num3) + { + flag = true; + } + bool flag2 = num9 && flag; + matchedMask[i] = flag2; + for (int k = 0; k < length; k++) + { + float num14 = sourceWeights[num10, k]; + float num15 = sourceWeights[num11, k]; + float num16 = sourceWeights[num12, k]; + array[i, k] = num14 * val2.x + num15 * val2.y + num16 * val2.z; + } + } + return array; + } - private Vector3 ClosestPointOnTriangle(Vector3 p, Vector3 a, Vector3 b, Vector3 c, out Vector3 bary) - { - //IL_0000: Unknown result type (might be due to invalid IL or missing references) - //IL_0001: Unknown result type (might be due to invalid IL or missing references) - //IL_0002: Unknown result type (might be due to invalid IL or missing references) - //IL_0007: Unknown result type (might be due to invalid IL or missing references) - //IL_0008: Unknown result type (might be due to invalid IL or missing references) - //IL_000a: Unknown result type (might be due to invalid IL or missing references) - //IL_000b: Unknown result type (might be due to invalid IL or missing references) - //IL_0010: Unknown result type (might be due to invalid IL or missing references) - //IL_0011: 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_0013: Unknown result type (might be due to invalid IL or missing references) - //IL_0018: Unknown result type (might be due to invalid IL or missing references) - //IL_0019: Unknown result type (might be due to invalid IL or missing references) - //IL_001a: Unknown result type (might be due to invalid IL or missing references) - //IL_0021: Unknown result type (might be due to invalid IL or missing references) - //IL_0022: Unknown result type (might be due to invalid IL or missing references) - //IL_0058: Unknown result type (might be due to invalid IL or missing references) - //IL_0059: Unknown result type (might be due to invalid IL or missing references) - //IL_005a: Unknown result type (might be due to invalid IL or missing references) - //IL_005f: Unknown result type (might be due to invalid IL or missing references) - //IL_0061: Unknown result type (might be due to invalid IL or missing references) - //IL_0062: Unknown result type (might be due to invalid IL or missing references) - //IL_006b: Unknown result type (might be due to invalid IL or missing references) - //IL_006c: Unknown result type (might be due to invalid IL or missing references) - //IL_004c: Unknown result type (might be due to invalid IL or missing references) - //IL_0051: Unknown result type (might be due to invalid IL or missing references) - //IL_0056: Unknown result type (might be due to invalid IL or missing references) - //IL_00f9: Unknown result type (might be due to invalid IL or missing references) - //IL_00fa: Unknown result type (might be due to invalid IL or missing references) - //IL_00fc: Unknown result type (might be due to invalid IL or missing references) - //IL_0101: Unknown result type (might be due to invalid IL or missing references) - //IL_0103: Unknown result type (might be due to invalid IL or missing references) - //IL_0104: 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_010e: Unknown result type (might be due to invalid IL or missing references) - //IL_0095: Unknown result type (might be due to invalid IL or missing references) - //IL_009a: Unknown result type (might be due to invalid IL or missing references) - //IL_009f: Unknown result type (might be due to invalid IL or missing references) - //IL_0137: Unknown result type (might be due to invalid IL or missing references) - //IL_013c: Unknown result type (might be due to invalid IL or missing references) - //IL_0141: Unknown result type (might be due to invalid IL or missing references) - //IL_00e0: Unknown result type (might be due to invalid IL or missing references) - //IL_00e5: Unknown result type (might be due to invalid IL or missing references) - //IL_00ea: Unknown result type (might be due to invalid IL or missing references) - //IL_00eb: Unknown result type (might be due to invalid IL or missing references) - //IL_00ee: Unknown result type (might be due to invalid IL or missing references) - //IL_00f3: 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_0249: 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_0251: Unknown result type (might be due to invalid IL or missing references) - //IL_0256: Unknown result type (might be due to invalid IL or missing references) - //IL_0259: Unknown result type (might be due to invalid IL or missing references) - //IL_025e: Unknown result type (might be due to invalid IL or missing references) - //IL_0263: 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_026c: 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_018b: Unknown result type (might be due to invalid IL or missing references) - //IL_0190: Unknown result type (might be due to invalid IL or missing references) - //IL_0191: Unknown result type (might be due to invalid IL or missing references) - //IL_0194: Unknown result type (might be due to invalid IL or missing references) - //IL_0199: Unknown result type (might be due to invalid IL or missing references) - //IL_01f1: Unknown result type (might be due to invalid IL or missing references) - //IL_01f6: 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_01fc: Unknown result type (might be due to invalid IL or missing references) - //IL_01fe: Unknown result type (might be due to invalid IL or missing references) - //IL_01ff: Unknown result type (might be due to invalid IL or missing references) - //IL_0206: Unknown result type (might be due to invalid IL or missing references) - //IL_020b: Unknown result type (might be due to invalid IL or missing references) - Vector3 val = b - a; - Vector3 val2 = c - a; - Vector3 val3 = p - a; - float num = Vector3.Dot(val, val3); - float num2 = Vector3.Dot(val2, val3); - if (num <= 0f && num2 <= 0f) - { - bary = new Vector3(1f, 0f, 0f); - return a; - } - Vector3 val4 = p - b; - float num3 = Vector3.Dot(val, val4); - float num4 = Vector3.Dot(val2, val4); - if (num3 >= 0f && num4 <= num3) - { - bary = new Vector3(0f, 1f, 0f); - return b; - } - float num5 = num * num4 - num3 * num2; - if (num5 <= 0f && num >= 0f && num3 <= 0f) - { - float num6 = num / (num - num3); - bary = new Vector3(1f - num6, num6, 0f); - return a + val * num6; - } - Vector3 val5 = p - c; - float num7 = Vector3.Dot(val, val5); - float num8 = Vector3.Dot(val2, val5); - if (num8 >= 0f && num7 <= num8) - { - bary = new Vector3(0f, 0f, 1f); - return c; - } - float num9 = num7 * num2 - num * num8; - if (num9 <= 0f && num2 >= 0f && num8 <= 0f) - { - float num10 = num2 / (num2 - num8); - bary = new Vector3(1f - num10, 0f, num10); - return a + val2 * num10; - } - float num11 = num3 * num8 - num7 * num4; - if (num11 <= 0f && num4 - num3 >= 0f && num7 - num8 >= 0f) - { - float num12 = (num4 - num3) / (num4 - num3 + (num7 - num8)); - bary = new Vector3(0f, 1f - num12, num12); - return b + (c - b) * num12; - } - float num13 = 1f / (num11 + num9 + num5); - float num14 = num9 * num13; - float num15 = num5 * num13; - float num16 = 1f - num14 - num15; - bary = new Vector3(num16, num14, num15); - return a * num16 + b * num14 + c * num15; - } + private Vector3 ClosestPointOnTriangle(Vector3 p, Vector3 a, Vector3 b, Vector3 c, out Vector3 bary) + { + //IL_0000: Unknown result type (might be due to invalid IL or missing references) + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + //IL_0002: Unknown result type (might be due to invalid IL or missing references) + //IL_0007: Unknown result type (might be due to invalid IL or missing references) + //IL_0008: Unknown result type (might be due to invalid IL or missing references) + //IL_000a: Unknown result type (might be due to invalid IL or missing references) + //IL_000b: Unknown result type (might be due to invalid IL or missing references) + //IL_0010: Unknown result type (might be due to invalid IL or missing references) + //IL_0011: 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_0013: Unknown result type (might be due to invalid IL or missing references) + //IL_0018: Unknown result type (might be due to invalid IL or missing references) + //IL_0019: Unknown result type (might be due to invalid IL or missing references) + //IL_001a: Unknown result type (might be due to invalid IL or missing references) + //IL_0021: Unknown result type (might be due to invalid IL or missing references) + //IL_0022: Unknown result type (might be due to invalid IL or missing references) + //IL_0058: Unknown result type (might be due to invalid IL or missing references) + //IL_0059: Unknown result type (might be due to invalid IL or missing references) + //IL_005a: Unknown result type (might be due to invalid IL or missing references) + //IL_005f: Unknown result type (might be due to invalid IL or missing references) + //IL_0061: Unknown result type (might be due to invalid IL or missing references) + //IL_0062: Unknown result type (might be due to invalid IL or missing references) + //IL_006b: Unknown result type (might be due to invalid IL or missing references) + //IL_006c: Unknown result type (might be due to invalid IL or missing references) + //IL_004c: Unknown result type (might be due to invalid IL or missing references) + //IL_0051: Unknown result type (might be due to invalid IL or missing references) + //IL_0056: Unknown result type (might be due to invalid IL or missing references) + //IL_00f9: Unknown result type (might be due to invalid IL or missing references) + //IL_00fa: Unknown result type (might be due to invalid IL or missing references) + //IL_00fc: Unknown result type (might be due to invalid IL or missing references) + //IL_0101: Unknown result type (might be due to invalid IL or missing references) + //IL_0103: Unknown result type (might be due to invalid IL or missing references) + //IL_0104: 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_010e: Unknown result type (might be due to invalid IL or missing references) + //IL_0095: Unknown result type (might be due to invalid IL or missing references) + //IL_009a: Unknown result type (might be due to invalid IL or missing references) + //IL_009f: Unknown result type (might be due to invalid IL or missing references) + //IL_0137: Unknown result type (might be due to invalid IL or missing references) + //IL_013c: Unknown result type (might be due to invalid IL or missing references) + //IL_0141: Unknown result type (might be due to invalid IL or missing references) + //IL_00e0: Unknown result type (might be due to invalid IL or missing references) + //IL_00e5: Unknown result type (might be due to invalid IL or missing references) + //IL_00ea: Unknown result type (might be due to invalid IL or missing references) + //IL_00eb: Unknown result type (might be due to invalid IL or missing references) + //IL_00ee: Unknown result type (might be due to invalid IL or missing references) + //IL_00f3: 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_0249: 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_0251: Unknown result type (might be due to invalid IL or missing references) + //IL_0256: Unknown result type (might be due to invalid IL or missing references) + //IL_0259: Unknown result type (might be due to invalid IL or missing references) + //IL_025e: Unknown result type (might be due to invalid IL or missing references) + //IL_0263: 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_026c: 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_018b: Unknown result type (might be due to invalid IL or missing references) + //IL_0190: Unknown result type (might be due to invalid IL or missing references) + //IL_0191: Unknown result type (might be due to invalid IL or missing references) + //IL_0194: Unknown result type (might be due to invalid IL or missing references) + //IL_0199: Unknown result type (might be due to invalid IL or missing references) + //IL_01f1: Unknown result type (might be due to invalid IL or missing references) + //IL_01f6: 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_01fc: Unknown result type (might be due to invalid IL or missing references) + //IL_01fe: Unknown result type (might be due to invalid IL or missing references) + //IL_01ff: Unknown result type (might be due to invalid IL or missing references) + //IL_0206: Unknown result type (might be due to invalid IL or missing references) + //IL_020b: Unknown result type (might be due to invalid IL or missing references) + Vector3 val = b - a; + Vector3 val2 = c - a; + Vector3 val3 = p - a; + float num = Vector3.Dot(val, val3); + float num2 = Vector3.Dot(val2, val3); + if (num <= 0f && num2 <= 0f) + { + bary = new Vector3(1f, 0f, 0f); + return a; + } + Vector3 val4 = p - b; + float num3 = Vector3.Dot(val, val4); + float num4 = Vector3.Dot(val2, val4); + if (num3 >= 0f && num4 <= num3) + { + bary = new Vector3(0f, 1f, 0f); + return b; + } + float num5 = num * num4 - num3 * num2; + if (num5 <= 0f && num >= 0f && num3 <= 0f) + { + float num6 = num / (num - num3); + bary = new Vector3(1f - num6, num6, 0f); + return a + val * num6; + } + Vector3 val5 = p - c; + float num7 = Vector3.Dot(val, val5); + float num8 = Vector3.Dot(val2, val5); + if (num8 >= 0f && num7 <= num8) + { + bary = new Vector3(0f, 0f, 1f); + return c; + } + float num9 = num7 * num2 - num * num8; + if (num9 <= 0f && num2 >= 0f && num8 <= 0f) + { + float num10 = num2 / (num2 - num8); + bary = new Vector3(1f - num10, 0f, num10); + return a + val2 * num10; + } + float num11 = num3 * num8 - num7 * num4; + if (num11 <= 0f && num4 - num3 >= 0f && num7 - num8 >= 0f) + { + float num12 = (num4 - num3) / (num4 - num3 + (num7 - num8)); + bary = new Vector3(0f, 1f - num12, num12); + return b + (c - b) * num12; + } + float num13 = 1f / (num11 + num9 + num5); + float num14 = num9 * num13; + float num15 = num5 * num13; + float num16 = 1f - num14 - num15; + bary = new Vector3(num16, num14, num15); + return a * num16 + b * num14 + c * num15; + } - private void ZeroSmallWeights(float[,] weights, float tiny) - { - int length = weights.GetLength(0); - int length2 = weights.GetLength(1); - for (int i = 0; i < length; i++) - { - for (int j = 0; j < length2; j++) - { - if (weights[i, j] <= tiny) - { - weights[i, j] = 0f; - } - } - } - } + private void ZeroSmallWeights(float[,] weights, float tiny) + { + int length = weights.GetLength(0); + int length2 = weights.GetLength(1); + for (int i = 0; i < length; i++) + { + for (int j = 0; j < length2; j++) + { + if (weights[i, j] <= tiny) + { + weights[i, j] = 0f; + } + } + } + } - private void EnforceMaxBonesPerVertex(float[,] weights, int maxBonesPerVertex, float tinyWeight) - { - int length = weights.GetLength(0); - int length2 = weights.GetLength(1); - for (int i = 0; i < length; i++) - { - List<(int, float)> list = new List<(int, float)>(); - for (int j = 0; j < length2; j++) - { - float num = weights[i, j]; - if (num > tinyWeight) - { - list.Add((j, num)); - } - } - list.Sort(((int bone, float w) a, (int bone, float w) b) => b.w.CompareTo(a.w)); - HashSet hashSet = new HashSet(); - int num2 = Mathf.Min(maxBonesPerVertex, list.Count); - for (int num3 = 0; num3 < num2; num3++) - { - hashSet.Add(list[num3].Item1); - } - for (int num4 = 0; num4 < length2; num4++) - { - if (!hashSet.Contains(num4) || weights[i, num4] <= tinyWeight) - { - weights[i, num4] = 0f; - } - } - } - } + private void EnforceMaxBonesPerVertex(float[,] weights, int maxBonesPerVertex, float tinyWeight) + { + int length = weights.GetLength(0); + int length2 = weights.GetLength(1); + for (int i = 0; i < length; i++) + { + List<(int, float)> list = new List<(int, float)>(); + for (int j = 0; j < length2; j++) + { + float num = weights[i, j]; + if (num > tinyWeight) + { + list.Add((j, num)); + } + } + list.Sort(((int bone, float w) a, (int bone, float w) b) => b.w.CompareTo(a.w)); + HashSet hashSet = new HashSet(); + int num2 = Mathf.Min(maxBonesPerVertex, list.Count); + for (int num3 = 0; num3 < num2; num3++) + { + hashSet.Add(list[num3].Item1); + } + for (int num4 = 0; num4 < length2; num4++) + { + if (!hashSet.Contains(num4) || weights[i, num4] <= tinyWeight) + { + weights[i, num4] = 0f; + } + } + } + } - private void NormalizeWeightsPerVertex(float[,] weights, float tiny) - { - int length = weights.GetLength(0); - int length2 = weights.GetLength(1); - for (int i = 0; i < length; i++) - { - float num = 0f; - for (int j = 0; j < length2; j++) - { - num += weights[i, j]; - } - if (!(num < tiny)) - { - float num2 = 1f / num; - for (int k = 0; k < length2; k++) - { - weights[i, k] *= num2; - } - } - } - } + private void NormalizeWeightsPerVertex(float[,] weights, float tiny) + { + int length = weights.GetLength(0); + int length2 = weights.GetLength(1); + for (int i = 0; i < length; i++) + { + float num = 0f; + for (int j = 0; j < length2; j++) + { + num += weights[i, j]; + } + if (!(num < tiny)) + { + float num2 = 1f / num; + for (int k = 0; k < length2; k++) + { + weights[i, k] *= num2; + } + } + } + } - private BoneWeight[] CollapseWeightsToBoneWeights(float[,] weights, int maxBonesPerVert, float tiny) - { - //IL_0065: 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_0191: Unknown result type (might be due to invalid IL or missing references) - //IL_0193: Unknown result type (might be due to invalid IL or missing references) - int length = weights.GetLength(0); - int length2 = weights.GetLength(1); - BoneWeight[] array = (BoneWeight[])(object)new BoneWeight[length]; - for (int i = 0; i < length; i++) - { - List<(int, float)> list = new List<(int, float)>(); - for (int j = 0; j < length2; j++) - { - float num = weights[i, j]; - if (num > tiny) - { - list.Add((j, num)); - } - } - if (list.Count == 0) - { - array[i] = default(BoneWeight); - continue; - } - list.Sort(((int idx, float w) a, (int idx, float w) b) => b.w.CompareTo(a.w)); - int num2 = Mathf.Min(maxBonesPerVert, list.Count); - float num3 = 0f; - for (int num4 = 0; num4 < num2; num4++) - { - num3 += list[num4].Item2; - } - if (num3 < tiny) - { - num3 = 1f; - } - float num5 = 1f / num3; - BoneWeight val = default(BoneWeight); - for (int num6 = 0; num6 < num2; num6++) - { - int item = list[num6].Item1; - float num7 = list[num6].Item2 * num5; - switch (num6) - { - case 0: - ((BoneWeight)(ref val)).boneIndex0 = item; - ((BoneWeight)(ref val)).weight0 = num7; - break; - case 1: - ((BoneWeight)(ref val)).boneIndex1 = item; - ((BoneWeight)(ref val)).weight1 = num7; - break; - case 2: - ((BoneWeight)(ref val)).boneIndex2 = item; - ((BoneWeight)(ref val)).weight2 = num7; - break; - case 3: - ((BoneWeight)(ref val)).boneIndex3 = item; - ((BoneWeight)(ref val)).weight3 = num7; - break; - } - } - array[i] = val; - } - return array; - } + private BoneWeight[] CollapseWeightsToBoneWeights(float[,] weights, int maxBonesPerVert, float tiny) + { + //IL_0065: 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_0191: Unknown result type (might be due to invalid IL or missing references) + //IL_0193: Unknown result type (might be due to invalid IL or missing references) + int length = weights.GetLength(0); + int length2 = weights.GetLength(1); + BoneWeight[] array = (BoneWeight[])new BoneWeight[length]; + for (int i = 0; i < length; i++) + { + List<(int, float)> list = new List<(int, float)>(); + for (int j = 0; j < length2; j++) + { + float num = weights[i, j]; + if (num > tiny) + { + list.Add((j, num)); + } + } + if (list.Count == 0) + { + array[i] = default(BoneWeight); + continue; + } + list.Sort(((int idx, float w) a, (int idx, float w) b) => b.w.CompareTo(a.w)); + int num2 = Mathf.Min(maxBonesPerVert, list.Count); + float num3 = 0f; + for (int num4 = 0; num4 < num2; num4++) + { + num3 += list[num4].Item2; + } + if (num3 < tiny) + { + num3 = 1f; + } + float num5 = 1f / num3; + BoneWeight val = default(BoneWeight); + for (int num6 = 0; num6 < num2; num6++) + { + int item = list[num6].Item1; + float num7 = list[num6].Item2 * num5; + switch (num6) + { + case 0: + val.boneIndex0 = item; + val.weight0 = num7; + break; + case 1: + val.boneIndex1 = item; + val.weight1 = num7; + break; + case 2: + val.boneIndex2 = item; + val.weight2 = num7; + break; + case 3: + val.boneIndex3 = item; + val.weight3 = num7; + break; + } + } + array[i] = val; + } + return array; + } - private float[,] InpaintApprox(Vector3[] verts, int[] triangles, float[,] weights, bool[] matched, List[] adjacency, int iterations, float alpha) - { - int num = verts.Length; - int length = weights.GetLength(1); - float[,] array = (float[,])weights.Clone(); - float[,] array2 = new float[num, length]; - for (int i = 0; i < iterations; i++) - { - for (int j = 0; j < num; j++) - { - if (matched[j]) - { - for (int k = 0; k < length; k++) - { - array2[j, k] = array[j, k]; - } - continue; - } - List list = adjacency[j]; - if (list == null || list.Count == 0) - { - for (int l = 0; l < length; l++) - { - array2[j, l] = array[j, l]; - } - continue; - } - for (int m = 0; m < length; m++) - { - float num2 = 0f; - for (int n = 0; n < list.Count; n++) - { - int num3 = list[n]; - num2 += array[num3, m]; - } - float num4 = num2 / (float)list.Count; - array2[j, m] = Mathf.Lerp(array[j, m], num4, alpha); - } - } - float[,] array3 = array2; - float[,] array4 = array; - array = array3; - array2 = array4; - } - return array; - } + private float[,] InpaintApprox(Vector3[] verts, int[] triangles, float[,] weights, bool[] matched, List[] adjacency, int iterations, float alpha) + { + int num = verts.Length; + int length = weights.GetLength(1); + float[,] array = (float[,])weights.Clone(); + float[,] array2 = new float[num, length]; + for (int i = 0; i < iterations; i++) + { + for (int j = 0; j < num; j++) + { + if (matched[j]) + { + for (int k = 0; k < length; k++) + { + array2[j, k] = array[j, k]; + } + continue; + } + List list = adjacency[j]; + if (list == null || list.Count == 0) + { + for (int l = 0; l < length; l++) + { + array2[j, l] = array[j, l]; + } + continue; + } + for (int m = 0; m < length; m++) + { + float num2 = 0f; + for (int n = 0; n < list.Count; n++) + { + int num3 = list[n]; + num2 += array[num3, m]; + } + float num4 = num2 / (float)list.Count; + array2[j, m] = Mathf.Lerp(array[j, m], num4, alpha); + } + } + float[,] array3 = array2; + float[,] array4 = array; + array = array3; + array2 = array4; + } + return array; + } - private float[,] SmoothWeightsApprox(Vector3[] verts, float[,] weights, bool[] matched, List[] adjacency, int numSmoothIterSteps, float smoothAlpha, float distanceThreshold) - { - int num = verts.Length; - int length = weights.GetLength(1); - bool[] array = new bool[num]; - for (int i = 0; i < num; i++) - { - if (!matched[i]) - { - FloodFillWithinDistance(verts, adjacency, i, distanceThreshold, array); - } - } - float[,] array2 = (float[,])weights.Clone(); - float[,] array3 = new float[num, length]; - for (int j = 0; j < numSmoothIterSteps; j++) - { - for (int k = 0; k < num; k++) - { - if (!array[k]) - { - for (int l = 0; l < length; l++) - { - array3[k, l] = array2[k, l]; - } - continue; - } - List list = adjacency[k]; - if (list == null || list.Count == 0) - { - for (int m = 0; m < length; m++) - { - array3[k, m] = array2[k, m]; - } - continue; - } - for (int n = 0; n < length; n++) - { - float num2 = 0f; - for (int num3 = 0; num3 < list.Count; num3++) - { - int num4 = list[num3]; - num2 += array2[num4, n]; - } - float num5 = num2 / (float)list.Count; - array3[k, n] = Mathf.Lerp(array2[k, n], num5, smoothAlpha); - } - } - float[,] array4 = array3; - float[,] array5 = array2; - array2 = array4; - array3 = array5; - } - return array2; - } + private float[,] SmoothWeightsApprox(Vector3[] verts, float[,] weights, bool[] matched, List[] adjacency, int numSmoothIterSteps, float smoothAlpha, float distanceThreshold) + { + int num = verts.Length; + int length = weights.GetLength(1); + bool[] array = new bool[num]; + for (int i = 0; i < num; i++) + { + if (!matched[i]) + { + this.FloodFillWithinDistance(verts, adjacency, i, distanceThreshold, array); + } + } + float[,] array2 = (float[,])weights.Clone(); + float[,] array3 = new float[num, length]; + for (int j = 0; j < numSmoothIterSteps; j++) + { + for (int k = 0; k < num; k++) + { + if (!array[k]) + { + for (int l = 0; l < length; l++) + { + array3[k, l] = array2[k, l]; + } + continue; + } + List list = adjacency[k]; + if (list == null || list.Count == 0) + { + for (int m = 0; m < length; m++) + { + array3[k, m] = array2[k, m]; + } + continue; + } + for (int n = 0; n < length; n++) + { + float num2 = 0f; + for (int num3 = 0; num3 < list.Count; num3++) + { + int num4 = list[num3]; + num2 += array2[num4, n]; + } + float num5 = num2 / (float)list.Count; + array3[k, n] = Mathf.Lerp(array2[k, n], num5, smoothAlpha); + } + } + float[,] array4 = array3; + float[,] array5 = array2; + array2 = array4; + array3 = array5; + } + return array2; + } - private void FloodFillWithinDistance(Vector3[] verts, List[] adjacency, int startIndex, float maxDistance, bool[] visited) - { - //IL_0036: Unknown result type (might be due to invalid IL or missing references) - //IL_003d: Unknown result type (might be due to invalid IL or missing references) - //IL_0042: Unknown result type (might be due to invalid IL or missing references) - //IL_0047: Unknown result type (might be due to invalid IL or missing references) - Queue queue = new Queue(); - queue.Enqueue(startIndex); - visited[startIndex] = true; - while (queue.Count > 0) - { - int num = queue.Dequeue(); - foreach (int item in adjacency[num]) - { - if (!visited[item]) - { - Vector3 val = verts[startIndex] - verts[item]; - if (((Vector3)(ref val)).magnitude < maxDistance) - { - visited[item] = true; - queue.Enqueue(item); - } - } - } - } - } + private void FloodFillWithinDistance(Vector3[] verts, List[] adjacency, int startIndex, float maxDistance, bool[] visited) + { + //IL_0036: Unknown result type (might be due to invalid IL or missing references) + //IL_003d: Unknown result type (might be due to invalid IL or missing references) + //IL_0042: Unknown result type (might be due to invalid IL or missing references) + //IL_0047: Unknown result type (might be due to invalid IL or missing references) + Queue queue = new Queue(); + queue.Enqueue(startIndex); + visited[startIndex] = true; + while (queue.Count > 0) + { + int num = queue.Dequeue(); + foreach (int item in adjacency[num]) + { + if (!visited[item]) + { + Vector3 val = verts[startIndex] - verts[item]; + if (val.magnitude < maxDistance) + { + visited[item] = true; + queue.Enqueue(item); + } + } + } + } + } - private BoneWeight[] MergeBodyAndAccessoryWeights(float[,] bodyWeights, float[,] accessoryWeights, int bodyBoneCount, float tiny, bool enforceFour) - { - //IL_01f1: 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_034e: Unknown result type (might be due to invalid IL or missing references) - //IL_0350: Unknown result type (might be due to invalid IL or missing references) - int length = bodyWeights.GetLength(0); - bodyWeights.GetLength(1); - int length2 = accessoryWeights.GetLength(1); - BoneWeight[] array = (BoneWeight[])(object)new BoneWeight[length]; - for (int i = 0; i < length; i++) - { - List<(int, float)> list = new List<(int, float)>(); - float num = 0f; - for (int j = 0; j < length2; j++) - { - float num2 = accessoryWeights[i, j]; - if (num2 > tiny) - { - int item = bodyBoneCount + j; - list.Add((item, num2)); - num += num2; - } - } - List<(int, float)> list2 = new List<(int, float)>(); - float num3 = 0f; - for (int k = 0; k < bodyBoneCount; k++) - { - float num4 = bodyWeights[i, k]; - if (num4 > tiny) - { - list2.Add((k, num4)); - num3 += num4; - } - } - if (num3 > tiny && num < 1f - tiny) - { - float num5 = Mathf.Max(0f, 1f - num); - float num6 = num5 / num3; - for (int l = 0; l < list2.Count; l++) - { - list2[l] = (list2[l].Item1, list2[l].Item2 * num6); - } - num3 = num5; - } - else - { - for (int m = 0; m < list2.Count; m++) - { - list2[m] = (list2[m].Item1, 0f); - } - num3 = 0f; - } - List<(int, float)> list3 = new List<(int, float)>(); - list3.AddRange(list); - list3.AddRange(list2); - list3.RemoveAll(((int bone, float w) t) => t.w <= tiny); - if (list3.Count == 0) - { - array[i] = default(BoneWeight); - continue; - } - if (enforceFour && list3.Count > 4) - { - list3.Sort(delegate((int bone, float w) a, (int bone, float w) b) - { - bool flag = a.bone >= bodyBoneCount; - bool flag2 = b.bone >= bodyBoneCount; - return (flag != flag2) ? ((!flag) ? 1 : (-1)) : b.w.CompareTo(a.w); - }); - list3 = list3.GetRange(0, 4); - } - float num7 = 0f; - foreach (var item3 in list3) - { - num7 += item3.Item2; - } - if (num7 < tiny) - { - num7 = 1f; - } - float num8 = 1f / num7; - BoneWeight val = default(BoneWeight); - for (int num9 = 0; num9 < list3.Count && num9 < 4; num9++) - { - int item2 = list3[num9].Item1; - float num10 = list3[num9].Item2 * num8; - switch (num9) - { - case 0: - ((BoneWeight)(ref val)).boneIndex0 = item2; - ((BoneWeight)(ref val)).weight0 = num10; - break; - case 1: - ((BoneWeight)(ref val)).boneIndex1 = item2; - ((BoneWeight)(ref val)).weight1 = num10; - break; - case 2: - ((BoneWeight)(ref val)).boneIndex2 = item2; - ((BoneWeight)(ref val)).weight2 = num10; - break; - case 3: - ((BoneWeight)(ref val)).boneIndex3 = item2; - ((BoneWeight)(ref val)).weight3 = num10; - break; - } - } - array[i] = val; - } - return array; - } + private BoneWeight[] MergeBodyAndAccessoryWeights(float[,] bodyWeights, float[,] accessoryWeights, int bodyBoneCount, float tiny, bool enforceFour) + { + //IL_01f1: 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_034e: Unknown result type (might be due to invalid IL or missing references) + //IL_0350: Unknown result type (might be due to invalid IL or missing references) + int length = bodyWeights.GetLength(0); + bodyWeights.GetLength(1); + int length2 = accessoryWeights.GetLength(1); + BoneWeight[] array = (BoneWeight[])new BoneWeight[length]; + for (int i = 0; i < length; i++) + { + List<(int, float)> list = new List<(int, float)>(); + float num = 0f; + for (int j = 0; j < length2; j++) + { + float num2 = accessoryWeights[i, j]; + if (num2 > tiny) + { + int item = bodyBoneCount + j; + list.Add((item, num2)); + num += num2; + } + } + List<(int, float)> list2 = new List<(int, float)>(); + float num3 = 0f; + for (int k = 0; k < bodyBoneCount; k++) + { + float num4 = bodyWeights[i, k]; + if (num4 > tiny) + { + list2.Add((k, num4)); + num3 += num4; + } + } + if (num3 > tiny && num < 1f - tiny) + { + float num5 = Mathf.Max(0f, 1f - num); + float num6 = num5 / num3; + for (int l = 0; l < list2.Count; l++) + { + list2[l] = (list2[l].Item1, list2[l].Item2 * num6); + } + num3 = num5; + } + else + { + for (int m = 0; m < list2.Count; m++) + { + list2[m] = (list2[m].Item1, 0f); + } + num3 = 0f; + } + List<(int, float)> list3 = new List<(int, float)>(); + list3.AddRange(list); + list3.AddRange(list2); + list3.RemoveAll(((int bone, float w) t) => t.w <= tiny); + if (list3.Count == 0) + { + array[i] = default(BoneWeight); + continue; + } + if (enforceFour && list3.Count > 4) + { + list3.Sort(delegate ((int bone, float w) a, (int bone, float w) b) + { + bool flag = a.bone >= bodyBoneCount; + bool flag2 = b.bone >= bodyBoneCount; + return (flag != flag2) ? ((!flag) ? 1 : (-1)) : b.w.CompareTo(a.w); + }); + list3 = list3.GetRange(0, 4); + } + float num7 = 0f; + foreach (var item3 in list3) + { + num7 += item3.Item2; + } + if (num7 < tiny) + { + num7 = 1f; + } + float num8 = 1f / num7; + BoneWeight val = default(BoneWeight); + for (int num9 = 0; num9 < list3.Count && num9 < 4; num9++) + { + int item2 = list3[num9].Item1; + float num10 = list3[num9].Item2 * num8; + switch (num9) + { + case 0: + val.boneIndex0 = item2; + val.weight0 = num10; + break; + case 1: + val.boneIndex1 = item2; + val.weight1 = num10; + break; + case 2: + val.boneIndex2 = item2; + val.weight2 = num10; + break; + case 3: + val.boneIndex3 = item2; + val.weight3 = num10; + break; + } + } + array[i] = val; + } + return array; + } - private void EnsureNonZeroAndNormalizeFinalWeights(ClothInstance cloth, BoneWeight[] weights, List[] adjacency, float tiny) - { - if (cloth != null && weights != null && weights.Length != 0) - { - PreNormalizeBoneWeightsInPlace(weights, tiny); - FillZeroWeightsFromNeighbors(weights, adjacency, tiny); - NormalizeAllBoneWeightsInPlace(weights, tiny); - } - } + private void EnsureNonZeroAndNormalizeFinalWeights(ClothInstance cloth, BoneWeight[] weights, List[] adjacency, float tiny) + { + if (cloth != null && weights != null && weights.Length != 0) + { + this.PreNormalizeBoneWeightsInPlace(weights, tiny); + this.FillZeroWeightsFromNeighbors(weights, adjacency, tiny); + this.NormalizeAllBoneWeightsInPlace(weights, tiny); + } + } - private void PreNormalizeBoneWeightsInPlace(BoneWeight[] weights, float tiny) - { - //IL_0006: Unknown result type (might be due to invalid IL or missing references) - //IL_000b: Unknown result type (might be due to invalid IL or missing references) - //IL_0064: Unknown result type (might be due to invalid IL or missing references) - //IL_0065: Unknown result type (might be due to invalid IL or missing references) - for (int i = 0; i < weights.Length; i++) - { - BoneWeight val = weights[i]; - float num = Sum(in weights[i]); - if (!(num < tiny)) - { - float num2 = 1f / num; - ((BoneWeight)(ref val)).weight0 = ((BoneWeight)(ref val)).weight0 * num2; - ((BoneWeight)(ref val)).weight1 = ((BoneWeight)(ref val)).weight1 * num2; - ((BoneWeight)(ref val)).weight2 = ((BoneWeight)(ref val)).weight2 * num2; - ((BoneWeight)(ref val)).weight3 = ((BoneWeight)(ref val)).weight3 * num2; - weights[i] = val; - } - } - } + private void PreNormalizeBoneWeightsInPlace(BoneWeight[] weights, float tiny) + { + //IL_0006: Unknown result type (might be due to invalid IL or missing references) + //IL_000b: Unknown result type (might be due to invalid IL or missing references) + //IL_0064: Unknown result type (might be due to invalid IL or missing references) + //IL_0065: Unknown result type (might be due to invalid IL or missing references) + for (int i = 0; i < weights.Length; i++) + { + BoneWeight val = weights[i]; + float num = this.Sum(in weights[i]); + if (!(num < tiny)) + { + float num2 = 1f / num; + val.weight0 = val.weight0 * num2; + val.weight1 = val.weight1 * num2; + val.weight2 = val.weight2 * num2; + val.weight3 = val.weight3 * num2; + weights[i] = val; + } + } + } - private void FillZeroWeightsFromNeighbors(BoneWeight[] weights, List[] adjacency, float tiny) - { - //IL_001e: Unknown result type (might be due to invalid IL or missing references) - //IL_0023: Unknown result type (might be due to invalid IL or missing references) - //IL_0031: Unknown result type (might be due to invalid IL or missing references) - //IL_0032: Unknown result type (might be due to invalid IL or missing references) - //IL_0078: 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_0096: Unknown result type (might be due to invalid IL or missing references) - //IL_006a: Unknown result type (might be due to invalid IL or missing references) - //IL_006f: Unknown result type (might be due to invalid IL or missing references) - int num = weights.Length; - for (int i = 0; i < num; i++) - { - if (!(Sum(in weights[i]) >= tiny)) - { - BoneWeight bw = AverageFromNeighbors(i, weights, adjacency, tiny, 1); - if (Sum(in bw) >= tiny) - { - weights[i] = bw; - } - } - } - for (int j = 0; j < num; j++) - { - if (!(Sum(in weights[j]) >= tiny)) - { - int num2 = FindNearestNonZeroVertexBfs(j, weights, adjacency, tiny, 8); - if (num2 >= 0) - { - weights[j] = weights[num2]; - continue; - } - BoneWeight val = default(BoneWeight); - ((BoneWeight)(ref val)).boneIndex0 = 0; - ((BoneWeight)(ref val)).weight0 = 1f; - weights[j] = val; - } - } - } + private void FillZeroWeightsFromNeighbors(BoneWeight[] weights, List[] adjacency, float tiny) + { + //IL_001e: Unknown result type (might be due to invalid IL or missing references) + //IL_0023: Unknown result type (might be due to invalid IL or missing references) + //IL_0031: Unknown result type (might be due to invalid IL or missing references) + //IL_0032: Unknown result type (might be due to invalid IL or missing references) + //IL_0078: 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_0096: Unknown result type (might be due to invalid IL or missing references) + //IL_006a: Unknown result type (might be due to invalid IL or missing references) + //IL_006f: Unknown result type (might be due to invalid IL or missing references) + int num = weights.Length; + for (int i = 0; i < num; i++) + { + if (!(this.Sum(in weights[i]) >= tiny)) + { + BoneWeight bw = this.AverageFromNeighbors(i, weights, adjacency, tiny, 1); + if (this.Sum(in bw) >= tiny) + { + weights[i] = bw; + } + } + } + for (int j = 0; j < num; j++) + { + if (!(this.Sum(in weights[j]) >= tiny)) + { + int num2 = this.FindNearestNonZeroVertexBfs(j, weights, adjacency, tiny, 8); + if (num2 >= 0) + { + weights[j] = weights[num2]; + continue; + } + BoneWeight val = default(BoneWeight); + val.boneIndex0 = 0; + val.weight0 = 1f; + weights[j] = val; + } + } + } - private BoneWeight AverageFromNeighbors(int v, BoneWeight[] weights, List[] adjacency, float tiny, int maxRing) - { - //IL_0144: Unknown result type (might be due to invalid IL or missing references) - //IL_00a9: Unknown result type (might be due to invalid IL or missing references) - //IL_00ae: Unknown result type (might be due to invalid IL or missing references) - Dictionary map = new Dictionary(); - Queue queue = new Queue(); - Dictionary dictionary = new Dictionary(); - HashSet hashSet = new HashSet(); - queue.Enqueue(v); - dictionary[v] = 0; - hashSet.Add(v); - while (queue.Count > 0) - { - int num = queue.Dequeue(); - int num2 = dictionary[num]; - if (num2 >= maxRing) - { - continue; - } - List list = adjacency[num]; - if (list == null) - { - continue; - } - foreach (int item in list) - { - if (item >= 0 && item < weights.Length && hashSet.Add(item)) - { - dictionary[item] = num2 + 1; - queue.Enqueue(item); - BoneWeight bw = weights[item]; - if (!(Sum(in bw) < tiny)) - { - Acc(map, ((BoneWeight)(ref bw)).boneIndex0, ((BoneWeight)(ref bw)).weight0, tiny); - Acc(map, ((BoneWeight)(ref bw)).boneIndex1, ((BoneWeight)(ref bw)).weight1, tiny); - Acc(map, ((BoneWeight)(ref bw)).boneIndex2, ((BoneWeight)(ref bw)).weight2, tiny); - Acc(map, ((BoneWeight)(ref bw)).boneIndex3, ((BoneWeight)(ref bw)).weight3, tiny); - } - } - } - } - return BuildTop4Normalized(map, tiny); - } + private BoneWeight AverageFromNeighbors(int v, BoneWeight[] weights, List[] adjacency, float tiny, int maxRing) + { + //IL_0144: Unknown result type (might be due to invalid IL or missing references) + //IL_00a9: Unknown result type (might be due to invalid IL or missing references) + //IL_00ae: Unknown result type (might be due to invalid IL or missing references) + Dictionary map = new Dictionary(); + Queue queue = new Queue(); + Dictionary dictionary = new Dictionary(); + HashSet hashSet = new HashSet(); + queue.Enqueue(v); + dictionary[v] = 0; + hashSet.Add(v); + while (queue.Count > 0) + { + int num = queue.Dequeue(); + int num2 = dictionary[num]; + if (num2 >= maxRing) + { + continue; + } + List list = adjacency[num]; + if (list == null) + { + continue; + } + foreach (int item in list) + { + if (item >= 0 && item < weights.Length && hashSet.Add(item)) + { + dictionary[item] = num2 + 1; + queue.Enqueue(item); + BoneWeight bw = weights[item]; + if (!(this.Sum(in bw) < tiny)) + { + this.Acc(map, bw.boneIndex0, bw.weight0, tiny); + this.Acc(map, bw.boneIndex1, bw.weight1, tiny); + this.Acc(map, bw.boneIndex2, bw.weight2, tiny); + this.Acc(map, bw.boneIndex3, bw.weight3, tiny); + } + } + } + } + return this.BuildTop4Normalized(map, tiny); + } - private int FindNearestNonZeroVertexBfs(int start, BoneWeight[] weights, List[] adjacency, float tiny, int maxDepth) - { - Queue queue = new Queue(); - Dictionary dictionary = new Dictionary(); - HashSet hashSet = new HashSet(); - queue.Enqueue(start); - dictionary[start] = 0; - hashSet.Add(start); - while (queue.Count > 0) - { - int num = queue.Dequeue(); - int num2 = dictionary[num]; - if (num2 > 0 && Sum(in weights[num]) >= tiny) - { - return num; - } - if (num2 >= maxDepth) - { - continue; - } - List list = adjacency[num]; - if (list == null) - { - continue; - } - foreach (int item in list) - { - if (item >= 0 && item < weights.Length && hashSet.Add(item)) - { - dictionary[item] = num2 + 1; - queue.Enqueue(item); - } - } - } - return -1; - } + private int FindNearestNonZeroVertexBfs(int start, BoneWeight[] weights, List[] adjacency, float tiny, int maxDepth) + { + Queue queue = new Queue(); + Dictionary dictionary = new Dictionary(); + HashSet hashSet = new HashSet(); + queue.Enqueue(start); + dictionary[start] = 0; + hashSet.Add(start); + while (queue.Count > 0) + { + int num = queue.Dequeue(); + int num2 = dictionary[num]; + if (num2 > 0 && this.Sum(in weights[num]) >= tiny) + { + return num; + } + if (num2 >= maxDepth) + { + continue; + } + List list = adjacency[num]; + if (list == null) + { + continue; + } + foreach (int item in list) + { + if (item >= 0 && item < weights.Length && hashSet.Add(item)) + { + dictionary[item] = num2 + 1; + queue.Enqueue(item); + } + } + } + return -1; + } - private void NormalizeAllBoneWeightsInPlace(BoneWeight[] weights, float tiny) - { - //IL_0020: Unknown result type (might be due to invalid IL or missing references) - //IL_0025: Unknown result type (might be due to invalid IL or missing references) - //IL_0064: Unknown result type (might be due to invalid IL or missing references) - //IL_0065: Unknown result type (might be due to invalid IL or missing references) - for (int i = 0; i < weights.Length; i++) - { - float num = Sum(in weights[i]); - if (!(num < tiny)) - { - float num2 = 1f / num; - BoneWeight val = weights[i]; - ((BoneWeight)(ref val)).weight0 = ((BoneWeight)(ref val)).weight0 * num2; - ((BoneWeight)(ref val)).weight1 = ((BoneWeight)(ref val)).weight1 * num2; - ((BoneWeight)(ref val)).weight2 = ((BoneWeight)(ref val)).weight2 * num2; - ((BoneWeight)(ref val)).weight3 = ((BoneWeight)(ref val)).weight3 * num2; - weights[i] = val; - } - } - } + private void NormalizeAllBoneWeightsInPlace(BoneWeight[] weights, float tiny) + { + //IL_0020: Unknown result type (might be due to invalid IL or missing references) + //IL_0025: Unknown result type (might be due to invalid IL or missing references) + //IL_0064: Unknown result type (might be due to invalid IL or missing references) + //IL_0065: Unknown result type (might be due to invalid IL or missing references) + for (int i = 0; i < weights.Length; i++) + { + float num = this.Sum(in weights[i]); + if (!(num < tiny)) + { + float num2 = 1f / num; + BoneWeight val = weights[i]; + val.weight0 = val.weight0 * num2; + val.weight1 = val.weight1 * num2; + val.weight2 = val.weight2 * num2; + val.weight3 = val.weight3 * num2; + weights[i] = val; + } + } + } - private float Sum(in BoneWeight bw) - { - //IL_0001: Unknown result type (might be due to invalid IL or missing references) - //IL_0006: Unknown result type (might be due to invalid IL or missing references) - //IL_000f: Unknown result type (might be due to invalid IL or missing references) - //IL_0014: Unknown result type (might be due to invalid IL or missing references) - //IL_001e: Unknown result type (might be due to invalid IL or missing references) - //IL_0023: Unknown result type (might be due to invalid IL or missing references) - //IL_002d: Unknown result type (might be due to invalid IL or missing references) - //IL_0032: Unknown result type (might be due to invalid IL or missing references) - BoneWeight val = bw; - float weight = ((BoneWeight)(ref val)).weight0; - val = bw; - float num = weight + ((BoneWeight)(ref val)).weight1; - val = bw; - float num2 = num + ((BoneWeight)(ref val)).weight2; - val = bw; - return num2 + ((BoneWeight)(ref val)).weight3; - } + private float Sum(in BoneWeight bw) + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + //IL_0006: Unknown result type (might be due to invalid IL or missing references) + //IL_000f: Unknown result type (might be due to invalid IL or missing references) + //IL_0014: Unknown result type (might be due to invalid IL or missing references) + //IL_001e: Unknown result type (might be due to invalid IL or missing references) + //IL_0023: Unknown result type (might be due to invalid IL or missing references) + //IL_002d: Unknown result type (might be due to invalid IL or missing references) + //IL_0032: Unknown result type (might be due to invalid IL or missing references) + BoneWeight val = bw; + float weight = val.weight0; + val = bw; + float num = weight + val.weight1; + val = bw; + float num2 = num + val.weight2; + val = bw; + return num2 + val.weight3; + } - private void Acc(Dictionary map, int boneIndex, float w, float tiny) - { - if (boneIndex >= 0 && !(w <= tiny)) - { - if (map.TryGetValue(boneIndex, out var value)) - { - map[boneIndex] = value + w; - } - else - { - map[boneIndex] = w; - } - } - } + private void Acc(Dictionary map, int boneIndex, float w, float tiny) + { + if (boneIndex >= 0 && !(w <= tiny)) + { + if (map.TryGetValue(boneIndex, out var value)) + { + map[boneIndex] = value + w; + } + else + { + map[boneIndex] = w; + } + } + } - private BoneWeight BuildTop4Normalized(Dictionary map, float tiny) - { - //IL_000d: Unknown result type (might be due to invalid IL or missing references) - //IL_0013: Unknown result type (might be due to invalid IL or missing references) - //IL_008f: Unknown result type (might be due to invalid IL or missing references) - //IL_007c: 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_013f: Unknown result type (might be due to invalid IL or missing references) - if (map == null || map.Count == 0) - { - return default(BoneWeight); - } - List> list = map.OrderByDescending((KeyValuePair kv) => kv.Value).Take(4).ToList(); - float num = 0f; - for (int num2 = 0; num2 < list.Count; num2++) - { - num += list[num2].Value; - } - if (num < tiny) - { - return default(BoneWeight); - } - float num3 = 1f / num; - BoneWeight result = default(BoneWeight); - for (int num4 = 0; num4 < list.Count; num4++) - { - int key = list[num4].Key; - float num5 = list[num4].Value * num3; - switch (num4) - { - case 0: - ((BoneWeight)(ref result)).boneIndex0 = key; - ((BoneWeight)(ref result)).weight0 = num5; - break; - case 1: - ((BoneWeight)(ref result)).boneIndex1 = key; - ((BoneWeight)(ref result)).weight1 = num5; - break; - case 2: - ((BoneWeight)(ref result)).boneIndex2 = key; - ((BoneWeight)(ref result)).weight2 = num5; - break; - case 3: - ((BoneWeight)(ref result)).boneIndex3 = key; - ((BoneWeight)(ref result)).weight3 = num5; - break; - } - } - return result; - } + private BoneWeight BuildTop4Normalized(Dictionary map, float tiny) + { + //IL_000d: Unknown result type (might be due to invalid IL or missing references) + //IL_0013: Unknown result type (might be due to invalid IL or missing references) + //IL_008f: Unknown result type (might be due to invalid IL or missing references) + //IL_007c: 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_013f: Unknown result type (might be due to invalid IL or missing references) + if (map == null || map.Count == 0) + { + return default(BoneWeight); + } + List> list = map.OrderByDescending((KeyValuePair kv) => kv.Value).Take(4).ToList(); + float num = 0f; + for (int num2 = 0; num2 < list.Count; num2++) + { + num += list[num2].Value; + } + if (num < tiny) + { + return default(BoneWeight); + } + float num3 = 1f / num; + BoneWeight result = default(BoneWeight); + for (int num4 = 0; num4 < list.Count; num4++) + { + int key = list[num4].Key; + float num5 = list[num4].Value * num3; + switch (num4) + { + case 0: + result.boneIndex0 = key; + result.weight0 = num5; + break; + case 1: + result.boneIndex1 = key; + result.weight1 = num5; + break; + case 2: + result.boneIndex2 = key; + result.weight2 = num5; + break; + case 3: + result.boneIndex3 = key; + result.weight3 = num5; + break; + } + } + return result; + } } diff --git a/Assets/@Eden_Tools/Eden_AutoMorpher/Script/WorldVertexUtil.cs b/Assets/@Eden_Tools/Eden_AutoMorpher/Script/WorldVertexUtil.cs index bcff4a2..a67b161 100644 --- a/Assets/@Eden_Tools/Eden_AutoMorpher/Script/WorldVertexUtil.cs +++ b/Assets/@Eden_Tools/Eden_AutoMorpher/Script/WorldVertexUtil.cs @@ -1,100 +1,97 @@ -// Warning: Some assembly references could not be resolved automatically. This might lead to incorrect decompilation of some parts, +// 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.WorldVertexUtil -using Eden.AutoMorpher; using UnityEngine; public class WorldVertexUtil { - public Vector3[] GetWorldVertices(SkinnedMeshRenderer smr) - { - //IL_0000: Unknown result type (might be due to invalid IL or missing references) - //IL_0006: Expected O, but got Unknown - Mesh bakedMesh = new Mesh(); - return GetWorldVertices(smr, ref bakedMesh); - } + public Vector3[] GetWorldVertices(SkinnedMeshRenderer smr) + { + //IL_0000: Unknown result type (might be due to invalid IL or missing references) + //IL_0006: Expected O, but got Unknown + Mesh bakedMesh = new Mesh(); + return this.GetWorldVertices(smr, ref bakedMesh); + } - public Vector3[] GetWorldVertices(SkinnedMeshRenderer smr, ref Mesh bakedMesh) - { - //IL_0024: Unknown result type (might be due to invalid IL or missing references) - //IL_002a: Expected O, but got Unknown - //IL_0042: Unknown result type (might be due to invalid IL or missing references) - //IL_0047: Unknown result type (might be due to invalid IL or missing references) - //IL_004f: Unknown result type (might be due to invalid IL or missing references) - //IL_0065: Unknown result type (might be due to invalid IL or missing references) - //IL_007b: Unknown result type (might be due to invalid IL or missing references) - //IL_0091: Unknown result type (might be due to invalid IL or missing references) - //IL_0096: Unknown result type (might be due to invalid IL or missing references) - //IL_0097: Unknown result type (might be due to invalid IL or missing references) - //IL_009c: Unknown result type (might be due to invalid IL or missing references) - //IL_00a1: Unknown result type (might be due to invalid IL or missing references) - //IL_00c6: 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) - if ((Object)(object)smr == (Object)null) - { - throw new AutoMorpherException("SkinnedMeshRenderer is Missing", "[SkinnedMeshWorldUtil] GetWorldVertices\n - smr is null"); - } - if ((Object)(object)bakedMesh == (Object)null) - { - bakedMesh = new Mesh(); - } - else - { - bakedMesh.Clear(); - } - smr.BakeMesh(bakedMesh); - Transform transform = ((Component)smr).transform; - Vector3 lossyScale = transform.lossyScale; - Vector3 val = default(Vector3); - ((Vector3)(ref val))._002Ector(1f / Mathf.Max(lossyScale.x, 1E-08f), 1f / Mathf.Max(lossyScale.y, 1E-08f), 1f / Mathf.Max(lossyScale.z, 1E-08f)); - Matrix4x4 val2 = transform.localToWorldMatrix * Matrix4x4.Scale(val); - Vector3[] vertices = bakedMesh.vertices; - int num = vertices.Length; - Vector3[] array = (Vector3[])(object)new Vector3[num]; - for (int i = 0; i < num; i++) - { - array[i] = ((Matrix4x4)(ref val2)).MultiplyPoint3x4(vertices[i]); - } - return array; - } + public Vector3[] GetWorldVertices(SkinnedMeshRenderer smr, ref Mesh bakedMesh) + { + //IL_0024: Unknown result type (might be due to invalid IL or missing references) + //IL_002a: Expected O, but got Unknown + //IL_0042: Unknown result type (might be due to invalid IL or missing references) + //IL_0047: Unknown result type (might be due to invalid IL or missing references) + //IL_004f: Unknown result type (might be due to invalid IL or missing references) + //IL_0065: Unknown result type (might be due to invalid IL or missing references) + //IL_007b: Unknown result type (might be due to invalid IL or missing references) + //IL_0091: Unknown result type (might be due to invalid IL or missing references) + //IL_0096: Unknown result type (might be due to invalid IL or missing references) + //IL_0097: Unknown result type (might be due to invalid IL or missing references) + //IL_009c: Unknown result type (might be due to invalid IL or missing references) + //IL_00a1: Unknown result type (might be due to invalid IL or missing references) + //IL_00c6: 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) + if ((Object)(object)smr == (Object)null) + { + throw new AutoMorpherException("SkinnedMeshRenderer is Missing", "[SkinnedMeshWorldUtil] GetWorldVertices\n - smr is null"); + } + if ((Object)(object)bakedMesh == (Object)null) + { + bakedMesh = new Mesh(); + } + else + { + bakedMesh.Clear(); + } + smr.BakeMesh(bakedMesh); + Transform transform = ((Component)smr).transform; + Vector3 lossyScale = transform.lossyScale; + Vector3 val = new Vector3(1f / Mathf.Max(lossyScale.x, 1E-08f), 1f / Mathf.Max(lossyScale.y, 1E-08f), 1f / Mathf.Max(lossyScale.z, 1E-08f)); + Matrix4x4 val2 = transform.localToWorldMatrix * Matrix4x4.Scale(val); + Vector3[] vertices = bakedMesh.vertices; + int num = vertices.Length; + Vector3[] array = (Vector3[])(object)new Vector3[num]; + for (int i = 0; i < num; i++) + { + array[i] = val2.MultiplyPoint3x4(vertices[i]); + } + return array; + } - public Vector3[] GetWorldVerticesWithBakedMesh(SkinnedMeshRenderer smr, Mesh bakedMesh) - { - //IL_002b: Unknown result type (might be due to invalid IL or missing references) - //IL_0030: Unknown result type (might be due to invalid IL or missing references) - //IL_0038: Unknown result type (might be due to invalid IL or missing references) - //IL_004e: Unknown result type (might be due to invalid IL or missing references) - //IL_0064: Unknown result type (might be due to invalid IL or missing references) - //IL_007a: Unknown result type (might be due to invalid IL or missing references) - //IL_007f: Unknown result type (might be due to invalid IL or missing references) - //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_008a: Unknown result type (might be due to invalid IL or missing references) - //IL_00ae: Unknown result type (might be due to invalid IL or missing references) - //IL_00b3: Unknown result type (might be due to invalid IL or missing references) - //IL_00b8: Unknown result type (might be due to invalid IL or missing references) - if ((Object)(object)smr == (Object)null) - { - throw new AutoMorpherException("SkinnedMeshRenderer is Missing", "[SkinnedMeshWorldUtil] GetWorldVerticesWithBakedMesh\n - smr is null"); - } - if ((Object)(object)bakedMesh == (Object)null) - { - return null; - } - Transform transform = ((Component)smr).transform; - Vector3 lossyScale = transform.lossyScale; - Vector3 val = default(Vector3); - ((Vector3)(ref val))._002Ector(1f / Mathf.Max(lossyScale.x, 1E-08f), 1f / Mathf.Max(lossyScale.y, 1E-08f), 1f / Mathf.Max(lossyScale.z, 1E-08f)); - Matrix4x4 val2 = transform.localToWorldMatrix * Matrix4x4.Scale(val); - Vector3[] vertices = bakedMesh.vertices; - int num = vertices.Length; - Vector3[] array = (Vector3[])(object)new Vector3[num]; - for (int i = 0; i < num; i++) - { - array[i] = ((Matrix4x4)(ref val2)).MultiplyPoint3x4(vertices[i]); - } - return array; - } + public Vector3[] GetWorldVerticesWithBakedMesh(SkinnedMeshRenderer smr, Mesh bakedMesh) + { + //IL_002b: Unknown result type (might be due to invalid IL or missing references) + //IL_0030: Unknown result type (might be due to invalid IL or missing references) + //IL_0038: Unknown result type (might be due to invalid IL or missing references) + //IL_004e: Unknown result type (might be due to invalid IL or missing references) + //IL_0064: Unknown result type (might be due to invalid IL or missing references) + //IL_007a: Unknown result type (might be due to invalid IL or missing references) + //IL_007f: Unknown result type (might be due to invalid IL or missing references) + //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_008a: Unknown result type (might be due to invalid IL or missing references) + //IL_00ae: Unknown result type (might be due to invalid IL or missing references) + //IL_00b3: Unknown result type (might be due to invalid IL or missing references) + //IL_00b8: Unknown result type (might be due to invalid IL or missing references) + if ((Object)(object)smr == (Object)null) + { + throw new AutoMorpherException("SkinnedMeshRenderer is Missing", "[SkinnedMeshWorldUtil] GetWorldVerticesWithBakedMesh\n - smr is null"); + } + if ((Object)(object)bakedMesh == (Object)null) + { + return null; + } + Transform transform = ((Component)smr).transform; + Vector3 lossyScale = transform.lossyScale; + Vector3 val = new Vector3(1f / Mathf.Max(lossyScale.x, 1E-08f), 1f / Mathf.Max(lossyScale.y, 1E-08f), 1f / Mathf.Max(lossyScale.z, 1E-08f)); + Matrix4x4 val2 = transform.localToWorldMatrix * Matrix4x4.Scale(val); + Vector3[] vertices = bakedMesh.vertices; + int num = vertices.Length; + Vector3[] array = (Vector3[])(object)new Vector3[num]; + for (int i = 0; i < num; i++) + { + array[i] = val2.MultiplyPoint3x4(vertices[i]); + } + return array; + } } diff --git a/Assets/@Eden_Tools/Eden_AutoMorpher/Script/profile.ProfileLoader.cs b/Assets/@Eden_Tools/Eden_AutoMorpher/Script/profile.ProfileLoader.cs index f3d0800..d2b28fb 100644 --- a/Assets/@Eden_Tools/Eden_AutoMorpher/Script/profile.ProfileLoader.cs +++ b/Assets/@Eden_Tools/Eden_AutoMorpher/Script/profile.ProfileLoader.cs @@ -1,4 +1,4 @@ -// Warning: Some assembly references could not be resolved automatically. This might lead to incorrect decompilation of some parts, +// 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.profile.ProfileLoader @@ -6,485 +6,483 @@ using System; using System.Collections.Generic; using System.IO; using System.Text; -using Eden.AutoMorpher; -using Eden.AutoMorpher.profile; using UnityEngine; public class ProfileLoader { - private ProfileData loadedProfileData; + private ProfileData loadedProfileData; - private const int HEX32_W = 8; + private const int HEX32_W = 8; - public List GetProfileList() - { - //IL_0000: Unknown result type (might be due to invalid IL or missing references) - //IL_0006: Expected O, but got Unknown - ProfileUtils val = new ProfileUtils(); - string text = Path.Combine(Application.dataPath, val.GetProfileBasePath()); - List list = new List(); - if (!Directory.Exists(text)) - { - Debug.LogWarning((object)("[ProfileUtils] Profile base path does not exist: " + text)); - return list; - } - string[] directories = Directory.GetDirectories(text); - foreach (string text2 in directories) - { - string fileName = Path.GetFileName(text2); - if (!string.IsNullOrEmpty(fileName)) - { - string path = Path.Combine(text2, fileName + ".json"); - string path2 = Path.Combine(text2, fileName + ".eb"); - if (File.Exists(path) && File.Exists(path2)) - { - list.Add(fileName); - } - } - } - return list; - } + public List GetProfileList() + { + //IL_0000: Unknown result type (might be due to invalid IL or missing references) + //IL_0006: Expected O, but got Unknown + ProfileUtils val = new ProfileUtils(); + string text = Path.Combine(Application.dataPath, val.GetProfileBasePath()); + List list = new List(); + if (!Directory.Exists(text)) + { + Debug.LogWarning((object)("[ProfileUtils] Profile base path does not exist: " + text)); + return list; + } + string[] directories = Directory.GetDirectories(text); + foreach (string text2 in directories) + { + string fileName = Path.GetFileName(text2); + if (!string.IsNullOrEmpty(fileName)) + { + string path = Path.Combine(text2, fileName + ".json"); + string path2 = Path.Combine(text2, fileName + ".eb"); + if (File.Exists(path) && File.Exists(path2)) + { + list.Add(fileName); + } + } + } + return list; + } - public ProfileData LoadProfileData(string profileName) - { - //IL_0000: Unknown result type (might be due to invalid IL or missing references) - //IL_0006: Expected O, but got Unknown - ProfileUtils val = new ProfileUtils(); - string path = Path.Combine(Application.dataPath, val.GetProfileBasePath()); - path = Path.Combine(path, profileName); - path = Path.Combine(path, profileName + ".json"); - if (string.IsNullOrWhiteSpace(path)) - { - throw new AutoMorpherException("Profile File Path is Invalid", "[ProfileLoader] LoadProfileData\n - Profile Path is null, empty, or whitespace"); - } - if (!File.Exists(path)) - { - throw new AutoMorpherException("Profile File Does Not Exist", "[ProfileLoader] LoadProfileData\n - profile file does not exist\n - path : " + path); - } - string text = File.ReadAllText(path); - loadedProfileData = JsonUtility.FromJson(text); - if (loadedProfileData == null) - { - throw new AutoMorpherException("Failed to Load Profile Data", "[ProfileLoader] LoadProfileData\n - Can't Load Profile Data\n - Please place a valid profile data file at " + path); - } - return loadedProfileData; - } + public ProfileData LoadProfileData(string profileName) + { + //IL_0000: Unknown result type (might be due to invalid IL or missing references) + //IL_0006: Expected O, but got Unknown + ProfileUtils val = new ProfileUtils(); + string path = Path.Combine(Application.dataPath, val.GetProfileBasePath()); + path = Path.Combine(path, profileName); + path = Path.Combine(path, profileName + ".json"); + if (string.IsNullOrWhiteSpace(path)) + { + throw new AutoMorpherException("Profile File Path is Invalid", "[ProfileLoader] LoadProfileData\n - Profile Path is null, empty, or whitespace"); + } + if (!File.Exists(path)) + { + throw new AutoMorpherException("Profile File Does Not Exist", "[ProfileLoader] LoadProfileData\n - profile file does not exist\n - path : " + path); + } + string text = File.ReadAllText(path); + this.loadedProfileData = JsonUtility.FromJson(text); + if (this.loadedProfileData == null) + { + throw new AutoMorpherException("Failed to Load Profile Data", "[ProfileLoader] LoadProfileData\n - Can't Load Profile Data\n - Please place a valid profile data file at " + path); + } + return this.loadedProfileData; + } - public BvhTriangleMesh LoadBvhWithRootTransform(Transform rootTransform, string profileName) - { - //IL_0000: Unknown result type (might be due to invalid IL or missing references) - //IL_0006: Expected O, but got Unknown - //IL_00a0: Unknown result type (might be due to invalid IL or missing references) - //IL_00a5: Unknown result type (might be due to invalid IL or missing references) - //IL_010b: Unknown result type (might be due to invalid IL or missing references) - //IL_0110: Unknown result type (might be due to invalid IL or missing references) - //IL_011f: Unknown result type (might be due to invalid IL or missing references) - //IL_0124: Unknown result type (might be due to invalid IL or missing references) - //IL_0133: Unknown result type (might be due to invalid IL or missing references) - //IL_0138: Unknown result type (might be due to invalid IL or missing references) - //IL_013c: Unknown result type (might be due to invalid IL or missing references) - //IL_013e: Unknown result type (might be due to invalid IL or missing references) - //IL_0143: Unknown result type (might be due to invalid IL or missing references) - //IL_0147: 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_0152: 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_015c: 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) - //IL_0160: Unknown result type (might be due to invalid IL or missing references) - //IL_0162: Unknown result type (might be due to invalid IL or missing references) - //IL_0167: Unknown result type (might be due to invalid IL or missing references) - //IL_017c: Unknown result type (might be due to invalid IL or missing references) - //IL_017e: Unknown result type (might be due to invalid IL or missing references) - //IL_0185: Unknown result type (might be due to invalid IL or missing references) - //IL_0187: Unknown result type (might be due to invalid IL or missing references) - //IL_018e: Unknown result type (might be due to invalid IL or missing references) - //IL_0190: Unknown result type (might be due to invalid IL or missing references) - //IL_0197: Unknown result type (might be due to invalid IL or missing references) - //IL_0199: Unknown result type (might be due to invalid IL or missing references) - //IL_01a2: 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_0248: Unknown result type (might be due to invalid IL or missing references) - //IL_024d: Unknown result type (might be due to invalid IL or missing references) - //IL_0252: Unknown result type (might be due to invalid IL or missing references) - ProfileUtils val = new ProfileUtils(); - string path = Path.Combine(Application.dataPath, val.GetProfileBasePath()); - path = Path.Combine(path, profileName); - path = Path.Combine(path, profileName + ".eb"); - if ((Object)(object)rootTransform == (Object)null) - { - throw new AutoMorpherException("Root Transform is Null", "[ProfileLoader] LoadBvhWithRootTransform\n - rootTransform is null"); - } - if (string.IsNullOrEmpty(path)) - { - throw new AutoMorpherException("Profile BVH Path is Invalid", "[ProfileLoader] LoadBvhWithRootTransform\n - profileBvhPath is null or empty"); - } - int version; - ProfileBVH val2 = LoadProfileBVHData(path, out version); - if (val2 == null || val2.vertices == null || val2.datas == null || val2.nodes == null || val2.dataIndices == null) - { - throw new AutoMorpherException("Profile BVH Data is Invalid", "[ProfileLoader] LoadBvhWithRootTransform\n - profile or one of its internal data fields is null"); - } - Matrix4x4 localToWorldMatrix = rootTransform.localToWorldMatrix; - int num = val2.datas.Length; - BvhTriangleMesh bvhTriangleMesh = new BvhTriangleMesh - { - triangles = new BvhTriangle[num], - triIndices = new int[val2.dataIndices.Length], - nodes = new BvhNode[val2.nodes.Length] - }; - for (int i = 0; i < num; i++) - { - profileBVHData val3 = val2.datas[i]; - Vector3 val4 = val2.vertices[val3.verA]; - Vector3 val5 = val2.vertices[val3.verB]; - Vector3 val6 = val2.vertices[val3.verC]; - Vector3 a = ((Matrix4x4)(ref localToWorldMatrix)).MultiplyPoint3x4(val4); - Vector3 b = ((Matrix4x4)(ref localToWorldMatrix)).MultiplyPoint3x4(val5); - Vector3 c = ((Matrix4x4)(ref localToWorldMatrix)).MultiplyPoint3x4(val6); - Vector3 normal = ComputeTriangleNormal(a, b, c); - bvhTriangleMesh.triangles[i] = new BvhTriangle - { - a = a, - b = b, - c = c, - normal = normal, - mainHumanBone = (HumanBodyBones)55 - }; - } - Array.Copy(val2.dataIndices, bvhTriangleMesh.triIndices, val2.dataIndices.Length); - for (int j = 0; j < val2.nodes.Length; j++) - { - profileBVHNode val7 = val2.nodes[j]; - bvhTriangleMesh.nodes[j] = new BvhNode - { - isLeaf = val7.isLeaf, - leftChild = val7.leftChild, - rightChild = val7.rightChild, - start = val7.start, - count = val7.count, - bounds = TransformBoundsToWorldAABB(localToWorldMatrix, val7.bounds) - }; - } - return bvhTriangleMesh; - } + public BvhTriangleMesh LoadBvhWithRootTransform(Transform rootTransform, string profileName) + { + //IL_0000: Unknown result type (might be due to invalid IL or missing references) + //IL_0006: Expected O, but got Unknown + //IL_00a0: Unknown result type (might be due to invalid IL or missing references) + //IL_00a5: Unknown result type (might be due to invalid IL or missing references) + //IL_010b: Unknown result type (might be due to invalid IL or missing references) + //IL_0110: Unknown result type (might be due to invalid IL or missing references) + //IL_011f: Unknown result type (might be due to invalid IL or missing references) + //IL_0124: Unknown result type (might be due to invalid IL or missing references) + //IL_0133: Unknown result type (might be due to invalid IL or missing references) + //IL_0138: Unknown result type (might be due to invalid IL or missing references) + //IL_013c: Unknown result type (might be due to invalid IL or missing references) + //IL_013e: Unknown result type (might be due to invalid IL or missing references) + //IL_0143: Unknown result type (might be due to invalid IL or missing references) + //IL_0147: 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_0152: 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_015c: 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) + //IL_0160: Unknown result type (might be due to invalid IL or missing references) + //IL_0162: Unknown result type (might be due to invalid IL or missing references) + //IL_0167: Unknown result type (might be due to invalid IL or missing references) + //IL_017c: Unknown result type (might be due to invalid IL or missing references) + //IL_017e: Unknown result type (might be due to invalid IL or missing references) + //IL_0185: Unknown result type (might be due to invalid IL or missing references) + //IL_0187: Unknown result type (might be due to invalid IL or missing references) + //IL_018e: Unknown result type (might be due to invalid IL or missing references) + //IL_0190: Unknown result type (might be due to invalid IL or missing references) + //IL_0197: Unknown result type (might be due to invalid IL or missing references) + //IL_0199: Unknown result type (might be due to invalid IL or missing references) + //IL_01a2: 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_0248: Unknown result type (might be due to invalid IL or missing references) + //IL_024d: Unknown result type (might be due to invalid IL or missing references) + //IL_0252: Unknown result type (might be due to invalid IL or missing references) + ProfileUtils val = new ProfileUtils(); + string path = Path.Combine(Application.dataPath, val.GetProfileBasePath()); + path = Path.Combine(path, profileName); + path = Path.Combine(path, profileName + ".eb"); + if (rootTransform == null) + { + throw new AutoMorpherException("Root Transform is Null", "[ProfileLoader] LoadBvhWithRootTransform\n - rootTransform is null"); + } + if (string.IsNullOrEmpty(path)) + { + throw new AutoMorpherException("Profile BVH Path is Invalid", "[ProfileLoader] LoadBvhWithRootTransform\n - profileBvhPath is null or empty"); + } + int version; + ProfileBVH val2 = this.LoadProfileBVHData(path, out version); + if (val2 == null || val2.vertices == null || val2.datas == null || val2.nodes == null || val2.dataIndices == null) + { + throw new AutoMorpherException("Profile BVH Data is Invalid", "[ProfileLoader] LoadBvhWithRootTransform\n - profile or one of its internal data fields is null"); + } + Matrix4x4 localToWorldMatrix = rootTransform.localToWorldMatrix; + int num = val2.datas.Length; + BvhTriangleMesh bvhTriangleMesh = new BvhTriangleMesh + { + triangles = new BvhTriangle[num], + triIndices = new int[val2.dataIndices.Length], + nodes = new BvhNode[val2.nodes.Length] + }; + for (int i = 0; i < num; i++) + { + profileBVHData val3 = val2.datas[i]; + Vector3 val4 = val2.vertices[val3.verA]; + Vector3 val5 = val2.vertices[val3.verB]; + Vector3 val6 = val2.vertices[val3.verC]; + Vector3 a = localToWorldMatrix.MultiplyPoint3x4(val4); + Vector3 b = localToWorldMatrix.MultiplyPoint3x4(val5); + Vector3 c = localToWorldMatrix.MultiplyPoint3x4(val6); + Vector3 normal = this.ComputeTriangleNormal(a, b, c); + bvhTriangleMesh.triangles[i] = new BvhTriangle + { + a = a, + b = b, + c = c, + normal = normal, + mainHumanBone = (HumanBodyBones)55 + }; + } + Array.Copy(val2.dataIndices, bvhTriangleMesh.triIndices, val2.dataIndices.Length); + for (int j = 0; j < val2.nodes.Length; j++) + { + profileBVHNode val7 = val2.nodes[j]; + bvhTriangleMesh.nodes[j] = new BvhNode + { + isLeaf = val7.isLeaf, + leftChild = val7.leftChild, + rightChild = val7.rightChild, + start = val7.start, + count = val7.count, + bounds = this.TransformBoundsToWorldAABB(localToWorldMatrix, val7.bounds) + }; + } + return bvhTriangleMesh; + } - private ProfileBVH LoadProfileBVHData(string path, out int version) - { - //IL_0031: Unknown result type (might be due to invalid IL or missing references) - //IL_0037: Expected O, but got Unknown - //IL_00fa: Unknown result type (might be due to invalid IL or missing references) - //IL_00ff: Unknown result type (might be due to invalid IL or missing references) - //IL_0110: Unknown result type (might be due to invalid IL or missing references) - //IL_0144: 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_0179: Unknown result type (might be due to invalid IL or missing references) - //IL_0187: Unknown result type (might be due to invalid IL or missing references) - //IL_018c: Unknown result type (might be due to invalid IL or missing references) - //IL_0191: Unknown result type (might be due to invalid IL or missing references) - //IL_01a2: Unknown result type (might be due to invalid IL or missing references) - //IL_01a7: 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_01c1: Unknown result type (might be due to invalid IL or missing references) - //IL_01ce: Unknown result type (might be due to invalid IL or missing references) - //IL_01dd: Expected O, but got Unknown - //IL_01f9: Unknown result type (might be due to invalid IL or missing references) - //IL_01fe: Unknown result type (might be due to invalid IL or missing references) - //IL_020d: Unknown result type (might be due to invalid IL or missing references) - //IL_021c: Unknown result type (might be due to invalid IL or missing references) - //IL_022c: Expected O, but got Unknown - //IL_0244: Unknown result type (might be due to invalid IL or missing references) - //IL_0249: Unknown result type (might be due to invalid IL or missing references) - //IL_024f: Unknown result type (might be due to invalid IL or missing references) - //IL_0254: Unknown result type (might be due to invalid IL or missing references) - //IL_025f: Unknown result type (might be due to invalid IL or missing references) - //IL_0264: 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_0267: 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_027d: Unknown result type (might be due to invalid IL or missing references) - //IL_028c: Unknown result type (might be due to invalid IL or missing references) - //IL_029b: Unknown result type (might be due to invalid IL or missing references) - //IL_02aa: 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_02db: Expected O, but got Unknown - version = 0; - int num = 0; - if (!File.Exists(path)) - { - throw new AutoMorpherException("Profile BVH File Not Found", "[ProfileLoader] LoadProfileBVHData\n - file not found\n - path : " + path); - } - string text = File.ReadAllText(path, Encoding.UTF8); - int num2 = 0; - ProfileUtils val = new ProfileUtils(); - string profileMagic = val.GetProfileMagic(); - if (text.Length < profileMagic.Length || text.Substring(0, profileMagic.Length) != profileMagic) - { - throw new AutoMorpherException("Profile BVH Magic Mismatch", "[ProfileLoader] LoadProfileBVHData\n - magic string mismatch\n - invalid or corrupted BVH file"); - } - num2 += profileMagic.Length; - version = ReadHexIntSafe(text, ref num2); - num = ReadHexIntSafe(text, ref num2); - int num3 = ReadHexIntSafe(text, ref num2); - int num4 = ReadHexIntSafe(text, ref num2); - int num5 = ReadHexIntSafe(text, ref num2); - int num6 = ReadHexIntSafe(text, ref num2); - if (num3 < 0 || num4 < 0 || num5 < 0 || num6 < 0) - { - throw new AutoMorpherException("Profile BVH Count Data is Invalid", "[ProfileLoader] LoadProfileBVHData\n - one or more count values are negative"); - } - Vector3[] array = (Vector3[])(object)new Vector3[num3]; - for (int i = 0; i < num3; i++) - { - array[i] = ReadHexVec3Safe(text, ref num2); - } - int num7 = default(int); - int num8 = default(int); - BaseKey3[] array2 = new ProfileUtils_VertexUtil().LoadTable(val.GetBaseDataPath(), ref num7, ref num8); - if (array2 == null || array2.Length == 0) - { - throw new AutoMorpherException("Profile BVH Base Vertex Table is Invalid", "[ProfileLoader] LoadProfileBVHData\n - base vertex table is null or empty"); - } - ProfileUtil_IndexUtil val2 = new ProfileUtil_IndexUtil(9783); - val2.Build(num); - Vector3[] array3 = (Vector3[])(object)new Vector3[num3]; - val2.DecodeInto(array, array3); - Vector3[] array4 = (Vector3[])(object)new Vector3[num3]; - for (int j = 0; j < num3; j++) - { - array4[j] = TransformVec3(array3[j], array2[j % array2.Length]); - } - ProfileBVH val3 = new ProfileBVH - { - vertices = new List(num3), - datas = (profileBVHData[])(object)new profileBVHData[num4], - nodes = (profileBVHNode[])(object)new profileBVHNode[num5], - dataIndices = new int[num6] - }; - val3.vertices.AddRange(array4); - for (int k = 0; k < num4; k++) - { - val3.datas[k] = new profileBVHData - { - verA = ReadHexIntSafe(text, ref num2), - verB = ReadHexIntSafe(text, ref num2), - verC = ReadHexIntSafe(text, ref num2) - }; - } - for (int l = 0; l < num5; l++) - { - Vector3 val4 = ReadHexVec3Safe(text, ref num2); - Vector3 val5 = ReadHexVec3Safe(text, ref num2); - val3.nodes[l] = new profileBVHNode - { - bounds = new Bounds(val4, val5 * 2f), - leftChild = ReadHexIntSafe(text, ref num2), - rightChild = ReadHexIntSafe(text, ref num2), - start = ReadHexIntSafe(text, ref num2), - count = ReadHexIntSafe(text, ref num2), - isLeaf = (num2 < text.Length && text[num2++] == '1') - }; - } - for (int m = 0; m < num6; m++) - { - val3.dataIndices[m] = ReadHexIntSafe(text, ref num2); - } - return val3; - } + private ProfileBVH LoadProfileBVHData(string path, out int version) + { + //IL_0031: Unknown result type (might be due to invalid IL or missing references) + //IL_0037: Expected O, but got Unknown + //IL_00fa: Unknown result type (might be due to invalid IL or missing references) + //IL_00ff: Unknown result type (might be due to invalid IL or missing references) + //IL_0110: Unknown result type (might be due to invalid IL or missing references) + //IL_0144: 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_0179: Unknown result type (might be due to invalid IL or missing references) + //IL_0187: Unknown result type (might be due to invalid IL or missing references) + //IL_018c: Unknown result type (might be due to invalid IL or missing references) + //IL_0191: Unknown result type (might be due to invalid IL or missing references) + //IL_01a2: Unknown result type (might be due to invalid IL or missing references) + //IL_01a7: 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_01c1: Unknown result type (might be due to invalid IL or missing references) + //IL_01ce: Unknown result type (might be due to invalid IL or missing references) + //IL_01dd: Expected O, but got Unknown + //IL_01f9: Unknown result type (might be due to invalid IL or missing references) + //IL_01fe: Unknown result type (might be due to invalid IL or missing references) + //IL_020d: Unknown result type (might be due to invalid IL or missing references) + //IL_021c: Unknown result type (might be due to invalid IL or missing references) + //IL_022c: Expected O, but got Unknown + //IL_0244: Unknown result type (might be due to invalid IL or missing references) + //IL_0249: Unknown result type (might be due to invalid IL or missing references) + //IL_024f: Unknown result type (might be due to invalid IL or missing references) + //IL_0254: Unknown result type (might be due to invalid IL or missing references) + //IL_025f: Unknown result type (might be due to invalid IL or missing references) + //IL_0264: 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_0267: 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_027d: Unknown result type (might be due to invalid IL or missing references) + //IL_028c: Unknown result type (might be due to invalid IL or missing references) + //IL_029b: Unknown result type (might be due to invalid IL or missing references) + //IL_02aa: 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_02db: Expected O, but got Unknown + version = 0; + int num = 0; + if (!File.Exists(path)) + { + throw new AutoMorpherException("Profile BVH File Not Found", "[ProfileLoader] LoadProfileBVHData\n - file not found\n - path : " + path); + } + string text = File.ReadAllText(path, Encoding.UTF8); + int num2 = 0; + ProfileUtils val = new ProfileUtils(); + string profileMagic = val.GetProfileMagic(); + if (text.Length < profileMagic.Length || text.Substring(0, profileMagic.Length) != profileMagic) + { + throw new AutoMorpherException("Profile BVH Magic Mismatch", "[ProfileLoader] LoadProfileBVHData\n - magic string mismatch\n - invalid or corrupted BVH file"); + } + num2 += profileMagic.Length; + version = this.ReadHexIntSafe(text, ref num2); + num = this.ReadHexIntSafe(text, ref num2); + int num3 = this.ReadHexIntSafe(text, ref num2); + int num4 = this.ReadHexIntSafe(text, ref num2); + int num5 = this.ReadHexIntSafe(text, ref num2); + int num6 = this.ReadHexIntSafe(text, ref num2); + if (num3 < 0 || num4 < 0 || num5 < 0 || num6 < 0) + { + throw new AutoMorpherException("Profile BVH Count Data is Invalid", "[ProfileLoader] LoadProfileBVHData\n - one or more count values are negative"); + } + Vector3[] array = (Vector3[])(object)new Vector3[num3]; + for (int i = 0; i < num3; i++) + { + array[i] = this.ReadHexVec3Safe(text, ref num2); + } + int num7 = default(int); + int num8 = default(int); + BaseKey3[] array2 = new ProfileUtils_VertexUtil().LoadTable(val.GetBaseDataPath(), out num7, out num8); + if (array2 == null || array2.Length == 0) + { + throw new AutoMorpherException("Profile BVH Base Vertex Table is Invalid", "[ProfileLoader] LoadProfileBVHData\n - base vertex table is null or empty"); + } + ProfileUtil_IndexUtil val2 = new ProfileUtil_IndexUtil(9783); + val2.Build(num); + Vector3[] array3 = (Vector3[])(object)new Vector3[num3]; + val2.DecodeInto(array, array3); + Vector3[] array4 = (Vector3[])(object)new Vector3[num3]; + for (int j = 0; j < num3; j++) + { + array4[j] = this.TransformVec3(array3[j], array2[j % array2.Length]); + } + ProfileBVH val3 = new ProfileBVH + { + vertices = new List(num3), + datas = (profileBVHData[])(object)new profileBVHData[num4], + nodes = (profileBVHNode[])(object)new profileBVHNode[num5], + dataIndices = new int[num6] + }; + val3.vertices.AddRange(array4); + for (int k = 0; k < num4; k++) + { + val3.datas[k] = new profileBVHData + { + verA = this.ReadHexIntSafe(text, ref num2), + verB = this.ReadHexIntSafe(text, ref num2), + verC = this.ReadHexIntSafe(text, ref num2) + }; + } + for (int l = 0; l < num5; l++) + { + Vector3 val4 = this.ReadHexVec3Safe(text, ref num2); + Vector3 val5 = this.ReadHexVec3Safe(text, ref num2); + val3.nodes[l] = new profileBVHNode + { + bounds = new Bounds(val4, val5 * 2f), + leftChild = this.ReadHexIntSafe(text, ref num2), + rightChild = this.ReadHexIntSafe(text, ref num2), + start = this.ReadHexIntSafe(text, ref num2), + count = this.ReadHexIntSafe(text, ref num2), + isLeaf = (num2 < text.Length && text[num2++] == '1') + }; + } + for (int m = 0; m < num6; m++) + { + val3.dataIndices[m] = this.ReadHexIntSafe(text, ref num2); + } + return val3; + } - private int ReadHexIntSafe(string s, ref int p) - { - if (p + 8 > s.Length) - { - p = s.Length; - throw new AutoMorpherException("Profile BVH ReadHexInt Out of Range", "[ProfileBVH] ReadHexIntSafe\n - read position exceeds string length"); - } - uint result = Convert.ToUInt32(s.Substring(p, 8), 16); - p += 8; - return (int)result; - } + private int ReadHexIntSafe(string s, ref int p) + { + if (p + 8 > s.Length) + { + p = s.Length; + throw new AutoMorpherException("Profile BVH ReadHexInt Out of Range", "[ProfileBVH] ReadHexIntSafe\n - read position exceeds string length"); + } + uint result = Convert.ToUInt32(s.Substring(p, 8), 16); + p += 8; + return (int)result; + } - private Vector3 ReadHexVec3Safe(string s, ref int p) - { - //IL_0018: Unknown result type (might be due to invalid IL or missing references) - return new Vector3(ReadHexFloatSafe(s, ref p), ReadHexFloatSafe(s, ref p), ReadHexFloatSafe(s, ref p)); - } + private Vector3 ReadHexVec3Safe(string s, ref int p) + { + //IL_0018: Unknown result type (might be due to invalid IL or missing references) + return new Vector3(this.ReadHexFloatSafe(s, ref p), this.ReadHexFloatSafe(s, ref p), this.ReadHexFloatSafe(s, ref p)); + } - private float ReadHexFloatSafe(string s, ref int p) - { - if (p + 8 > s.Length) - { - p = s.Length; - throw new AutoMorpherException("Profile BVH ReadHexFloat Out of Range", "[ProfileBVH] ReadHexFloat\n - read position exceeds string length"); - } - uint value = Convert.ToUInt32(s.Substring(p, 8), 16); - p += 8; - return BitConverter.Int32BitsToSingle((int)value); - } + private float ReadHexFloatSafe(string s, ref int p) + { + if (p + 8 > s.Length) + { + p = s.Length; + throw new AutoMorpherException("Profile BVH ReadHexFloat Out of Range", "[ProfileBVH] ReadHexFloat\n - read position exceeds string length"); + } + uint value = Convert.ToUInt32(s.Substring(p, 8), 16); + p += 8; + return BitConverter.Int32BitsToSingle((int)value); + } - private Vector3 TransformVec3(Vector3 v, BaseKey3 k) - { - //IL_0001: Unknown result type (might be due to invalid IL or missing references) - //IL_0007: Unknown result type (might be due to invalid IL or missing references) - //IL_0013: Unknown result type (might be due to invalid IL or missing references) - //IL_0019: Unknown result type (might be due to invalid IL or missing references) - //IL_0025: Unknown result type (might be due to invalid IL or missing references) - //IL_002b: 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 Vector3(TransformFloatBits(v.x, k.x), TransformFloatBits(v.y, k.y), TransformFloatBits(v.z, k.z)); - } + private Vector3 TransformVec3(Vector3 v, BaseKey3 k) + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + //IL_0007: Unknown result type (might be due to invalid IL or missing references) + //IL_0013: Unknown result type (might be due to invalid IL or missing references) + //IL_0019: Unknown result type (might be due to invalid IL or missing references) + //IL_0025: Unknown result type (might be due to invalid IL or missing references) + //IL_002b: 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 Vector3(this.TransformFloatBits(v.x, k.x), this.TransformFloatBits(v.y, k.y), this.TransformFloatBits(v.z, k.z)); + } - private float TransformFloatBits(float a, uint keyBits) - { - return BitConverter.Int32BitsToSingle(BitConverter.SingleToInt32Bits(a) ^ (int)keyBits); - } + private float TransformFloatBits(float a, uint keyBits) + { + return BitConverter.Int32BitsToSingle(BitConverter.SingleToInt32Bits(a) ^ (int)keyBits); + } - private Vector3 ComputeTriangleNormal(Vector3 a, Vector3 b, Vector3 c) - { - //IL_0000: Unknown result type (might be due to invalid IL or missing references) - //IL_0001: Unknown result type (might be due to invalid IL or missing references) - //IL_0002: Unknown result type (might be due to invalid IL or missing references) - //IL_0007: Unknown result type (might be due to invalid IL or missing references) - //IL_0008: Unknown result type (might be due to invalid IL or missing references) - //IL_0009: Unknown result type (might be due to invalid IL or missing references) - //IL_000e: Unknown result type (might be due to invalid IL or missing references) - //IL_0013: Unknown result type (might be due to invalid IL or missing references) - //IL_002c: 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_0026: Unknown result type (might be due to invalid IL or missing references) - Vector3 val = Vector3.Cross(b - a, c - a); - float magnitude = ((Vector3)(ref val)).magnitude; - if (magnitude > 1E-08f) - { - return val / magnitude; - } - return Vector3.up; - } + private Vector3 ComputeTriangleNormal(Vector3 a, Vector3 b, Vector3 c) + { + //IL_0000: Unknown result type (might be due to invalid IL or missing references) + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + //IL_0002: Unknown result type (might be due to invalid IL or missing references) + //IL_0007: Unknown result type (might be due to invalid IL or missing references) + //IL_0008: Unknown result type (might be due to invalid IL or missing references) + //IL_0009: Unknown result type (might be due to invalid IL or missing references) + //IL_000e: Unknown result type (might be due to invalid IL or missing references) + //IL_0013: Unknown result type (might be due to invalid IL or missing references) + //IL_002c: 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_0026: Unknown result type (might be due to invalid IL or missing references) + Vector3 val = Vector3.Cross(b - a, c - a); + float magnitude = val.magnitude; + if (magnitude > 1E-08f) + { + return val / magnitude; + } + return Vector3.up; + } - private Bounds TransformBoundsToWorldAABB(Matrix4x4 l2w, Bounds localBounds) - { - //IL_0002: Unknown result type (might be due to invalid IL or missing references) - //IL_0007: Unknown result type (might be due to invalid IL or missing references) - //IL_000a: Unknown result type (might be due to invalid IL or missing references) - //IL_000f: 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_0013: Unknown result type (might be due to invalid IL or missing references) - //IL_001a: Unknown result type (might be due to invalid IL or missing references) - //IL_0021: Unknown result type (might be due to invalid IL or missing references) - //IL_0028: Unknown result type (might be due to invalid IL or missing references) - //IL_002d: Unknown result type (might be due to invalid IL or missing references) - //IL_0032: Unknown result type (might be due to invalid IL or missing references) - //IL_0039: Unknown result type (might be due to invalid IL or missing references) - //IL_003a: Unknown result type (might be due to invalid IL or missing references) - //IL_0041: Unknown result type (might be due to invalid IL or missing references) - //IL_0048: Unknown result type (might be due to invalid IL or missing references) - //IL_004e: Unknown result type (might be due to invalid IL or missing references) - //IL_0053: Unknown result type (might be due to invalid IL or missing references) - //IL_0058: Unknown result type (might be due to invalid IL or missing references) - //IL_005d: Unknown result type (might be due to invalid IL or missing references) - //IL_0060: Unknown result type (might be due to invalid IL or missing references) - //IL_0061: Unknown result type (might be due to invalid IL or missing references) - //IL_0068: Unknown result type (might be due to invalid IL or missing references) - //IL_006e: Unknown result type (might be due to invalid IL or missing references) - //IL_0075: Unknown result type (might be due to invalid IL or missing references) - //IL_007a: Unknown result type (might be due to invalid IL or missing references) - //IL_007f: Unknown result type (might be due to invalid IL or missing references) - //IL_0084: 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_0088: Unknown result type (might be due to invalid IL or missing references) - //IL_008f: Unknown result type (might be due to invalid IL or missing references) - //IL_0095: Unknown result type (might be due to invalid IL or missing references) - //IL_009b: Unknown result type (might be due to invalid IL or missing references) - //IL_00a0: Unknown result type (might be due to invalid IL or missing references) - //IL_00a5: Unknown result type (might be due to invalid IL or missing references) - //IL_00aa: Unknown result type (might be due to invalid IL or missing references) - //IL_00ae: Unknown result type (might be due to invalid IL or missing references) - //IL_00af: Unknown result type (might be due to invalid IL or missing references) - //IL_00b5: Unknown result type (might be due to invalid IL or missing references) - //IL_00bc: Unknown result type (might be due to invalid IL or missing references) - //IL_00c3: Unknown result type (might be due to invalid IL or missing references) - //IL_00c8: Unknown result type (might be due to invalid IL or missing references) - //IL_00cd: Unknown result type (might be due to invalid IL or missing references) - //IL_00d2: 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_00d7: Unknown result type (might be due to invalid IL or missing references) - //IL_00dd: Unknown result type (might be due to invalid IL or missing references) - //IL_00e4: Unknown result type (might be due to invalid IL or missing references) - //IL_00ea: Unknown result type (might be due to invalid IL or missing references) - //IL_00ef: Unknown result type (might be due to invalid IL or missing references) - //IL_00f4: Unknown result type (might be due to invalid IL or missing references) - //IL_00f9: Unknown result type (might be due to invalid IL or missing references) - //IL_00fd: Unknown result type (might be due to invalid IL or missing references) - //IL_00fe: Unknown result type (might be due to invalid IL or missing references) - //IL_0104: Unknown result type (might be due to invalid IL or missing references) - //IL_010a: 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_0116: Unknown result type (might be due to invalid IL or missing references) - //IL_011b: Unknown result type (might be due to invalid IL or missing references) - //IL_0120: Unknown result type (might be due to invalid IL or missing references) - //IL_0124: Unknown result type (might be due to invalid IL or missing references) - //IL_0125: Unknown result type (might be due to invalid IL or missing references) - //IL_012b: Unknown result type (might be due to invalid IL or missing references) - //IL_0131: Unknown result type (might be due to invalid IL or missing references) - //IL_0137: Unknown result type (might be due to invalid IL or missing references) - //IL_013c: Unknown result type (might be due to invalid IL or missing references) - //IL_0141: Unknown result type (might be due to invalid IL or missing references) - //IL_0146: 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_0149: Unknown result type (might be due to invalid IL or missing references) - //IL_014b: Unknown result type (might be due to invalid IL or missing references) - //IL_0152: Unknown result type (might be due to invalid IL or missing references) - //IL_015d: 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_0174: Unknown result type (might be due to invalid IL or missing references) - //IL_0180: Unknown result type (might be due to invalid IL or missing references) - //IL_018c: Unknown result type (might be due to invalid IL or missing references) - //IL_0198: 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_01a1: Unknown result type (might be due to invalid IL or missing references) - //IL_01a3: Unknown result type (might be due to invalid IL or missing references) - //IL_01ad: Unknown result type (might be due to invalid IL or missing references) - //IL_01b2: 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_01b6: Unknown result type (might be due to invalid IL or missing references) - //IL_01bb: Unknown result type (might be due to invalid IL or missing references) - Vector3 center = ((Bounds)(ref localBounds)).center; - Vector3 extents = ((Bounds)(ref localBounds)).extents; - Vector3 val = ((Matrix4x4)(ref l2w)).MultiplyPoint3x4(center + new Vector3(0f - extents.x, 0f - extents.y, 0f - extents.z)); - Vector3 p = ((Matrix4x4)(ref l2w)).MultiplyPoint3x4(center + new Vector3(0f - extents.x, 0f - extents.y, extents.z)); - Vector3 p2 = ((Matrix4x4)(ref l2w)).MultiplyPoint3x4(center + new Vector3(0f - extents.x, extents.y, 0f - extents.z)); - Vector3 p3 = ((Matrix4x4)(ref l2w)).MultiplyPoint3x4(center + new Vector3(0f - extents.x, extents.y, extents.z)); - Vector3 p4 = ((Matrix4x4)(ref l2w)).MultiplyPoint3x4(center + new Vector3(extents.x, 0f - extents.y, 0f - extents.z)); - Vector3 p5 = ((Matrix4x4)(ref l2w)).MultiplyPoint3x4(center + new Vector3(extents.x, 0f - extents.y, extents.z)); - Vector3 p6 = ((Matrix4x4)(ref l2w)).MultiplyPoint3x4(center + new Vector3(extents.x, extents.y, 0f - extents.z)); - Vector3 p7 = ((Matrix4x4)(ref l2w)).MultiplyPoint3x4(center + new Vector3(extents.x, extents.y, extents.z)); - Vector3 min = val; - Vector3 max = val; - Encapsulate(ref min, ref max, p); - Encapsulate(ref min, ref max, p2); - Encapsulate(ref min, ref max, p3); - Encapsulate(ref min, ref max, p4); - Encapsulate(ref min, ref max, p5); - Encapsulate(ref min, ref max, p6); - Encapsulate(ref min, ref max, p7); - return new Bounds((min + max) * 0.5f, max - min); - } + private Bounds TransformBoundsToWorldAABB(Matrix4x4 l2w, Bounds localBounds) + { + //IL_0002: Unknown result type (might be due to invalid IL or missing references) + //IL_0007: Unknown result type (might be due to invalid IL or missing references) + //IL_000a: Unknown result type (might be due to invalid IL or missing references) + //IL_000f: 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_0013: Unknown result type (might be due to invalid IL or missing references) + //IL_001a: Unknown result type (might be due to invalid IL or missing references) + //IL_0021: Unknown result type (might be due to invalid IL or missing references) + //IL_0028: Unknown result type (might be due to invalid IL or missing references) + //IL_002d: Unknown result type (might be due to invalid IL or missing references) + //IL_0032: Unknown result type (might be due to invalid IL or missing references) + //IL_0039: Unknown result type (might be due to invalid IL or missing references) + //IL_003a: Unknown result type (might be due to invalid IL or missing references) + //IL_0041: Unknown result type (might be due to invalid IL or missing references) + //IL_0048: Unknown result type (might be due to invalid IL or missing references) + //IL_004e: Unknown result type (might be due to invalid IL or missing references) + //IL_0053: Unknown result type (might be due to invalid IL or missing references) + //IL_0058: Unknown result type (might be due to invalid IL or missing references) + //IL_005d: Unknown result type (might be due to invalid IL or missing references) + //IL_0060: Unknown result type (might be due to invalid IL or missing references) + //IL_0061: Unknown result type (might be due to invalid IL or missing references) + //IL_0068: Unknown result type (might be due to invalid IL or missing references) + //IL_006e: Unknown result type (might be due to invalid IL or missing references) + //IL_0075: Unknown result type (might be due to invalid IL or missing references) + //IL_007a: Unknown result type (might be due to invalid IL or missing references) + //IL_007f: Unknown result type (might be due to invalid IL or missing references) + //IL_0084: 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_0088: Unknown result type (might be due to invalid IL or missing references) + //IL_008f: Unknown result type (might be due to invalid IL or missing references) + //IL_0095: Unknown result type (might be due to invalid IL or missing references) + //IL_009b: Unknown result type (might be due to invalid IL or missing references) + //IL_00a0: Unknown result type (might be due to invalid IL or missing references) + //IL_00a5: Unknown result type (might be due to invalid IL or missing references) + //IL_00aa: Unknown result type (might be due to invalid IL or missing references) + //IL_00ae: Unknown result type (might be due to invalid IL or missing references) + //IL_00af: Unknown result type (might be due to invalid IL or missing references) + //IL_00b5: Unknown result type (might be due to invalid IL or missing references) + //IL_00bc: Unknown result type (might be due to invalid IL or missing references) + //IL_00c3: Unknown result type (might be due to invalid IL or missing references) + //IL_00c8: Unknown result type (might be due to invalid IL or missing references) + //IL_00cd: Unknown result type (might be due to invalid IL or missing references) + //IL_00d2: 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_00d7: Unknown result type (might be due to invalid IL or missing references) + //IL_00dd: Unknown result type (might be due to invalid IL or missing references) + //IL_00e4: Unknown result type (might be due to invalid IL or missing references) + //IL_00ea: Unknown result type (might be due to invalid IL or missing references) + //IL_00ef: Unknown result type (might be due to invalid IL or missing references) + //IL_00f4: Unknown result type (might be due to invalid IL or missing references) + //IL_00f9: Unknown result type (might be due to invalid IL or missing references) + //IL_00fd: Unknown result type (might be due to invalid IL or missing references) + //IL_00fe: Unknown result type (might be due to invalid IL or missing references) + //IL_0104: Unknown result type (might be due to invalid IL or missing references) + //IL_010a: 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_0116: Unknown result type (might be due to invalid IL or missing references) + //IL_011b: Unknown result type (might be due to invalid IL or missing references) + //IL_0120: Unknown result type (might be due to invalid IL or missing references) + //IL_0124: Unknown result type (might be due to invalid IL or missing references) + //IL_0125: Unknown result type (might be due to invalid IL or missing references) + //IL_012b: Unknown result type (might be due to invalid IL or missing references) + //IL_0131: Unknown result type (might be due to invalid IL or missing references) + //IL_0137: Unknown result type (might be due to invalid IL or missing references) + //IL_013c: Unknown result type (might be due to invalid IL or missing references) + //IL_0141: Unknown result type (might be due to invalid IL or missing references) + //IL_0146: 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_0149: Unknown result type (might be due to invalid IL or missing references) + //IL_014b: Unknown result type (might be due to invalid IL or missing references) + //IL_0152: Unknown result type (might be due to invalid IL or missing references) + //IL_015d: 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_0174: Unknown result type (might be due to invalid IL or missing references) + //IL_0180: Unknown result type (might be due to invalid IL or missing references) + //IL_018c: Unknown result type (might be due to invalid IL or missing references) + //IL_0198: 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_01a1: Unknown result type (might be due to invalid IL or missing references) + //IL_01a3: Unknown result type (might be due to invalid IL or missing references) + //IL_01ad: Unknown result type (might be due to invalid IL or missing references) + //IL_01b2: 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_01b6: Unknown result type (might be due to invalid IL or missing references) + //IL_01bb: Unknown result type (might be due to invalid IL or missing references) + Vector3 center = localBounds.center; + Vector3 extents = localBounds.extents; + Vector3 val = l2w.MultiplyPoint3x4(center + new Vector3(0f - extents.x, 0f - extents.y, 0f - extents.z)); + Vector3 p = l2w.MultiplyPoint3x4(center + new Vector3(0f - extents.x, 0f - extents.y, extents.z)); + Vector3 p2 = l2w.MultiplyPoint3x4(center + new Vector3(0f - extents.x, extents.y, 0f - extents.z)); + Vector3 p3 = l2w.MultiplyPoint3x4(center + new Vector3(0f - extents.x, extents.y, extents.z)); + Vector3 p4 = l2w.MultiplyPoint3x4(center + new Vector3(extents.x, 0f - extents.y, 0f - extents.z)); + Vector3 p5 = l2w.MultiplyPoint3x4(center + new Vector3(extents.x, 0f - extents.y, extents.z)); + Vector3 p6 = l2w.MultiplyPoint3x4(center + new Vector3(extents.x, extents.y, 0f - extents.z)); + Vector3 p7 = l2w.MultiplyPoint3x4(center + new Vector3(extents.x, extents.y, extents.z)); + Vector3 min = val; + Vector3 max = val; + this.Encapsulate(ref min, ref max, p); + this.Encapsulate(ref min, ref max, p2); + this.Encapsulate(ref min, ref max, p3); + this.Encapsulate(ref min, ref max, p4); + this.Encapsulate(ref min, ref max, p5); + this.Encapsulate(ref min, ref max, p6); + this.Encapsulate(ref min, ref max, p7); + return new Bounds((min + max) * 0.5f, max - min); + } - private void Encapsulate(ref Vector3 min, ref Vector3 max, Vector3 p) - { - //IL_0002: Unknown result type (might be due to invalid IL or missing references) - //IL_0007: Unknown result type (might be due to invalid IL or missing references) - //IL_0008: Unknown result type (might be due to invalid IL or missing references) - //IL_000d: Unknown result type (might be due to invalid IL or missing references) - //IL_0014: Unknown result type (might be due to invalid IL or missing references) - //IL_0019: Unknown result type (might be due to invalid IL or missing references) - //IL_001a: Unknown result type (might be due to invalid IL or missing references) - //IL_001f: Unknown result type (might be due to invalid IL or missing references) - min = Vector3.Min(min, p); - max = Vector3.Max(max, p); - } + private void Encapsulate(ref Vector3 min, ref Vector3 max, Vector3 p) + { + //IL_0002: Unknown result type (might be due to invalid IL or missing references) + //IL_0007: Unknown result type (might be due to invalid IL or missing references) + //IL_0008: Unknown result type (might be due to invalid IL or missing references) + //IL_000d: Unknown result type (might be due to invalid IL or missing references) + //IL_0014: Unknown result type (might be due to invalid IL or missing references) + //IL_0019: Unknown result type (might be due to invalid IL or missing references) + //IL_001a: Unknown result type (might be due to invalid IL or missing references) + //IL_001f: Unknown result type (might be due to invalid IL or missing references) + min = Vector3.Min(min, p); + max = Vector3.Max(max, p); + } } diff --git a/Assets/@Eden_Tools/Eden_AutoMorpher/Script/profile.ProfilePoseMatchUtil.cs b/Assets/@Eden_Tools/Eden_AutoMorpher/Script/profile.ProfilePoseMatchUtil.cs index 88037c2..0e7d395 100644 --- a/Assets/@Eden_Tools/Eden_AutoMorpher/Script/profile.ProfilePoseMatchUtil.cs +++ b/Assets/@Eden_Tools/Eden_AutoMorpher/Script/profile.ProfilePoseMatchUtil.cs @@ -1,89 +1,87 @@ -// Warning: Some assembly references could not be resolved automatically. This might lead to incorrect decompilation of some parts, +// 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.profile.ProfilePoseMatchUtil using System.Collections.Generic; -using Eden.AutoMorpher; -using Eden.AutoMorpher.profile; using UnityEngine; public class ProfilePoseMatchUtil { - private WorldVertexUtil _worldVertexUtil; + private WorldVertexUtil _worldVertexUtil; - private MeshClassifier meshClassifier; + private MeshClassifier meshClassifier; - public ProfilePoseMatchUtil() - { - _worldVertexUtil = new WorldVertexUtil(); - meshClassifier = new MeshClassifier(); - } + public ProfilePoseMatchUtil() + { + this._worldVertexUtil = new WorldVertexUtil(); + this.meshClassifier = new MeshClassifier(); + } - public void ProfilePoseMatcher(GameObject targetAvatar, IReadOnlyList targetBodyMeshes, GameObject targetCloth, ProfileData profileData, Dictionary> clothHumanBonesMap, Dictionary clothBoneTypeMap, float neckTargetHeight = 1.5f) - { - //IL_00d7: Unknown result type (might be due to invalid IL or missing references) - //IL_0127: 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) - //IL_0133: Unknown result type (might be due to invalid IL or missing references) - //IL_01a7: 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_01cc: Unknown result type (might be due to invalid IL or missing references) - //IL_01e5: Unknown result type (might be due to invalid IL or missing references) - //IL_01f6: Unknown result type (might be due to invalid IL or missing references) - if ((Object)(object)targetAvatar == (Object)null) - { - throw new AutoMorpherException("Target Avatar is Null", "[ProfilePoseMatchUtil] ProfilePoseMatcher\n - targetAvatar is null"); - } - if ((Object)(object)targetAvatar.GetComponent() == (Object)null) - { - throw new AutoMorpherException("Target Avatar Animator is Null", "[ProfilePoseMatchUtil] ProfilePoseMatcher\n - targetAvatar has no animator"); - } - if (targetBodyMeshes == null || targetBodyMeshes.Count == 0) - { - throw new AutoMorpherException("Target Body Meshes are Missing", "[ProfilePoseMatchUtil] ProfilePoseMatcher\n - targetBodyMeshes is null or empty"); - } - if ((Object)(object)targetCloth == (Object)null) - { - throw new AutoMorpherException("Target Cloth is Null", "[ProfilePoseMatchUtil] ProfilePoseMatcher\n - targetCloth is null"); - } - if (profileData == null) - { - throw new AutoMorpherException("Profile Data is Null", "[ProfilePoseMatchUtil] ProfilePoseMatcher\n - profileData is null"); - } - if (clothHumanBonesMap == null || clothHumanBonesMap.Count == 0 || clothBoneTypeMap == null || clothBoneTypeMap.Count == 0) - { - throw new AutoMorpherException("Clothing Bone Match Data is Missing", "[ProfilePoseMatchUtil] ProfilePoseMatcher\n - profile Clothe Bone Match Data is null or empty"); - } - Transform transform = targetAvatar.transform; - Transform transform2 = targetCloth.transform; - Transform parent = transform.parent; - transform.SetParent((Transform)null, true); - Transform parent2 = transform2.parent; - transform2.SetParent((Transform)null, true); - transform2.position = transform.position; - Dictionary> dictionary = meshClassifier.MeshHumanoidBoneMatcher(targetAvatar.GetComponent(), targetBodyMeshes); - if (dictionary == null || dictionary.Count == 0) - { - throw new AutoMorpherException("Target Avatar Bone Match Data is Missing", "[ProfilePoseMatchUtil] ProfilePoseMatcher\n - target Avatar Bone Match Data is null or empty"); - } - BodyPoseMatchSetupUtil bodyPoseMatchSetupUtil = new BodyPoseMatchSetupUtil(); - Vector3 comprehensiveScale = bodyPoseMatchSetupUtil.GetComprehensiveScale(transform2, clothHumanBonesMap, profileData); - Debug.Log((object)$"ComprehensiveScale: {comprehensiveScale}"); - bodyPoseMatchSetupUtil.AdjustAvatarScaleByNeck(transform, dictionary, neckTargetHeight); - bodyPoseMatchSetupUtil.AdjustAvatarScaleByNeck(transform2, clothHumanBonesMap, neckTargetHeight); - List list = new List(); - foreach (SkinnedMeshRenderer targetBodyMesh in targetBodyMeshes) - { - list.Add(new BakedBodyMesh(targetBodyMesh)); - } - new BodyPoseMatch_Torso().AlignTorsoByNeck(transform, list, dictionary, clothHumanBonesMap, transform2, profileData, comprehensiveScale); - BodyPoseMatch_Arm bodyPoseMatch_Arm = new BodyPoseMatch_Arm(); - bodyPoseMatch_Arm.AlignUpperArmByArmPcaCenters(list, dictionary, clothHumanBonesMap, transform2, profileData, comprehensiveScale); - bodyPoseMatch_Arm.ScalingBothArmsLength(list, dictionary, clothHumanBonesMap, profileData, comprehensiveScale); - BodyPoseMatch_Leg bodyPoseMatch_Leg = new BodyPoseMatch_Leg(); - bodyPoseMatch_Leg.AlignBothUpperLegs(transform, list, dictionary, transform2, clothHumanBonesMap, profileData, comprehensiveScale); - bodyPoseMatch_Leg.ScalingBothLegsAndFoots(transform, list, dictionary, transform2, clothHumanBonesMap, profileData, comprehensiveScale); - transform.SetParent(parent, true); - transform2.SetParent(parent2, true); - } + public void ProfilePoseMatcher(GameObject targetAvatar, IReadOnlyList targetBodyMeshes, GameObject targetCloth, ProfileData profileData, Dictionary> clothHumanBonesMap, Dictionary clothBoneTypeMap, float neckTargetHeight = 1.5f) + { + //IL_00d7: Unknown result type (might be due to invalid IL or missing references) + //IL_0127: 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) + //IL_0133: Unknown result type (might be due to invalid IL or missing references) + //IL_01a7: 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_01cc: Unknown result type (might be due to invalid IL or missing references) + //IL_01e5: Unknown result type (might be due to invalid IL or missing references) + //IL_01f6: Unknown result type (might be due to invalid IL or missing references) + if ((Object)(object)targetAvatar == (Object)null) + { + throw new AutoMorpherException("Target Avatar is Null", "[ProfilePoseMatchUtil] ProfilePoseMatcher\n - targetAvatar is null"); + } + if ((Object)(object)targetAvatar.GetComponent() == (Object)null) + { + throw new AutoMorpherException("Target Avatar Animator is Null", "[ProfilePoseMatchUtil] ProfilePoseMatcher\n - targetAvatar has no animator"); + } + if (targetBodyMeshes == null || targetBodyMeshes.Count == 0) + { + throw new AutoMorpherException("Target Body Meshes are Missing", "[ProfilePoseMatchUtil] ProfilePoseMatcher\n - targetBodyMeshes is null or empty"); + } + if ((Object)(object)targetCloth == (Object)null) + { + throw new AutoMorpherException("Target Cloth is Null", "[ProfilePoseMatchUtil] ProfilePoseMatcher\n - targetCloth is null"); + } + if (profileData == null) + { + throw new AutoMorpherException("Profile Data is Null", "[ProfilePoseMatchUtil] ProfilePoseMatcher\n - profileData is null"); + } + if (clothHumanBonesMap == null || clothHumanBonesMap.Count == 0 || clothBoneTypeMap == null || clothBoneTypeMap.Count == 0) + { + throw new AutoMorpherException("Clothing Bone Match Data is Missing", "[ProfilePoseMatchUtil] ProfilePoseMatcher\n - profile Clothe Bone Match Data is null or empty"); + } + Transform transform = targetAvatar.transform; + Transform transform2 = targetCloth.transform; + Transform parent = transform.parent; + transform.SetParent((Transform)null, true); + Transform parent2 = transform2.parent; + transform2.SetParent((Transform)null, true); + transform2.position = transform.position; + Dictionary> dictionary = this.meshClassifier.MeshHumanoidBoneMatcher(targetAvatar.GetComponent(), targetBodyMeshes); + if (dictionary == null || dictionary.Count == 0) + { + throw new AutoMorpherException("Target Avatar Bone Match Data is Missing", "[ProfilePoseMatchUtil] ProfilePoseMatcher\n - target Avatar Bone Match Data is null or empty"); + } + BodyPoseMatchSetupUtil bodyPoseMatchSetupUtil = new BodyPoseMatchSetupUtil(); + Vector3 comprehensiveScale = bodyPoseMatchSetupUtil.GetComprehensiveScale(transform2, clothHumanBonesMap, profileData); + Debug.Log((object)$"ComprehensiveScale: {comprehensiveScale}"); + bodyPoseMatchSetupUtil.AdjustAvatarScaleByNeck(transform, dictionary, neckTargetHeight); + bodyPoseMatchSetupUtil.AdjustAvatarScaleByNeck(transform2, clothHumanBonesMap, neckTargetHeight); + List list = new List(); + foreach (SkinnedMeshRenderer targetBodyMesh in targetBodyMeshes) + { + list.Add(new BakedBodyMesh(targetBodyMesh)); + } + new BodyPoseMatch_Torso().AlignTorsoByNeck(transform, list, dictionary, clothHumanBonesMap, transform2, profileData, comprehensiveScale); + BodyPoseMatch_Arm bodyPoseMatch_Arm = new BodyPoseMatch_Arm(); + bodyPoseMatch_Arm.AlignUpperArmByArmPcaCenters(list, dictionary, clothHumanBonesMap, transform2, profileData, comprehensiveScale); + bodyPoseMatch_Arm.ScalingBothArmsLength(list, dictionary, clothHumanBonesMap, profileData, comprehensiveScale); + BodyPoseMatch_Leg bodyPoseMatch_Leg = new BodyPoseMatch_Leg(); + bodyPoseMatch_Leg.AlignBothUpperLegs(transform, list, dictionary, transform2, clothHumanBonesMap, profileData, comprehensiveScale); + bodyPoseMatch_Leg.ScalingBothLegsAndFoots(transform, list, dictionary, transform2, clothHumanBonesMap, profileData, comprehensiveScale); + transform.SetParent(parent, true); + transform2.SetParent(parent2, true); + } }