Compare commits
1 Commits
main
...
f9c4088ef4
| Author | SHA1 | Date | |
|---|---|---|---|
| f9c4088ef4 |
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3f15b8b51b341c647a98a34a47707efb
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0a87e8255c6175649ab3d14c5d7390a0
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,19 +0,0 @@
|
||||
// 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.
|
||||
// EdenAutoMorpher_ProfileSaver_Script, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||
// Eden.AutoMorpher.profile.BaseKey3
|
||||
public struct BaseKey3
|
||||
{
|
||||
public uint x;
|
||||
|
||||
public uint y;
|
||||
|
||||
public uint z;
|
||||
|
||||
public BaseKey3(uint x, uint y, uint z)
|
||||
{
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 33819e87e935234448269d35d6e155b5
|
||||
@@ -1,31 +0,0 @@
|
||||
// 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.
|
||||
// EdenAutoMorpher_ProfileSaver_Script, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||
// Eden.AutoMorpher.profile.BoneData
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
[Serializable]
|
||||
public class BoneData
|
||||
{
|
||||
public int id;
|
||||
|
||||
public string boneName;
|
||||
|
||||
public string parentName;
|
||||
|
||||
public string hierarchyPath;
|
||||
|
||||
public HumanBodyBones hBone;
|
||||
|
||||
public int parentId;
|
||||
|
||||
public List<int> childrenIds;
|
||||
|
||||
public Vector3 rootLocalPosition;
|
||||
|
||||
public Quaternion rootLocalRotation;
|
||||
|
||||
public Vector3 rootLocalScale;
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8d3573fd768baee41b6e2b78d647bf04
|
||||
@@ -1,16 +0,0 @@
|
||||
// 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.
|
||||
// EdenAutoMorpher_ProfileSaver_Script, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||
// Eden.AutoMorpher.profile.BoneSpatialData
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
[Serializable]
|
||||
public class BoneSpatialData
|
||||
{
|
||||
public HumanBodyBones refBone;
|
||||
|
||||
public PCAData pcaData;
|
||||
|
||||
public VolumeData volumeData;
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 48d80c2519b3d8b4a97a8d6d5cd7b159
|
||||
@@ -1,332 +0,0 @@
|
||||
// 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.
|
||||
// EdenAutoMorpher_ProfileSaver_Script, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||
// Eden.AutoMorpher.profile.EdenAutoMorpher_ProfileSaver
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
public class EdenAutoMorpher_ProfileSaver : MonoBehaviour
|
||||
{
|
||||
public Transform sourceAvatar;
|
||||
|
||||
public List<SkinnedMeshRenderer> sourceBodyMeshes = new List<SkinnedMeshRenderer>();
|
||||
|
||||
public string profileName;
|
||||
|
||||
private const float adjustHigh = 1.5f;
|
||||
|
||||
[ContextMenu("SaveProfile")]
|
||||
public void SaveProfile()
|
||||
{
|
||||
//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_0012: 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_0042: 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_0062: 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_01f9: 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)
|
||||
Vector3 position = this.sourceAvatar.position;
|
||||
Quaternion rotation = this.sourceAvatar.rotation;
|
||||
Vector3 localScale = this.sourceAvatar.localScale;
|
||||
Transform parent = this.sourceAvatar.parent;
|
||||
this.sourceAvatar.SetParent((Transform)null);
|
||||
this.sourceAvatar.position = Vector3.zero;
|
||||
this.sourceAvatar.rotation = Quaternion.identity;
|
||||
this.sourceAvatar.localScale = Vector3.one;
|
||||
ProfileData newProfileData = new ProfileData();
|
||||
ProfileUtils profileUtils = new ProfileUtils();
|
||||
newProfileData.version = profileUtils.GetProfileVersion();
|
||||
Animator component = ((Component)this.sourceAvatar).GetComponent<Animator>();
|
||||
if (component == null)
|
||||
{
|
||||
Debug.LogError((object)("[EdenAutoMorpher_ProfileSaver] Source Avatar Has No Animator\nSet Animator to Source Avatar " + this.sourceAvatar.name));
|
||||
}
|
||||
Dictionary<HumanBodyBones, HashSet<Transform>> humanoidMeshBoneMap = profileUtils.GetHumanoidMeshBoneMap(component, this.sourceBodyMeshes);
|
||||
List<ProfileBakedBodyMesh> list = new List<ProfileBakedBodyMesh>();
|
||||
foreach (SkinnedMeshRenderer sourceBodyMesh in this.sourceBodyMeshes)
|
||||
{
|
||||
list.Add(new ProfileBakedBodyMesh(sourceBodyMesh));
|
||||
}
|
||||
this.SaveBoneData(ref newProfileData, this.sourceAvatar, humanoidMeshBoneMap, list);
|
||||
ProfileUtils_BVHUtil profileUtils_BVHUtil = new ProfileUtils_BVHUtil();
|
||||
ProfileBVH bVHData = profileUtils_BVHUtil.GetBVHData(this.sourceAvatar, list);
|
||||
profileUtils_BVHUtil.SaveProfileBVH(bVHData, Path.Combine(profileUtils.GetProfileBasePath(), this.profileName), this.profileName);
|
||||
newProfileData.neckTargetHeight = 1.5f;
|
||||
this.AdjustAvatarHigh(this.sourceAvatar, humanoidMeshBoneMap, 1.5f);
|
||||
foreach (ProfileBakedBodyMesh item in list)
|
||||
{
|
||||
item.ReBakeMesh();
|
||||
}
|
||||
this.SaveSpatialData(ref newProfileData, humanoidMeshBoneMap, list);
|
||||
this.SaveProfileToJson(newProfileData, Path.Combine(profileUtils.GetProfileBasePath(), this.profileName), this.profileName);
|
||||
this.sourceAvatar.SetParent(parent);
|
||||
this.sourceAvatar.position = position;
|
||||
this.sourceAvatar.rotation = rotation;
|
||||
this.sourceAvatar.localScale = localScale;
|
||||
}
|
||||
|
||||
public void SaveSpatialData(ref ProfileData newProfileData, Dictionary<HumanBodyBones, HashSet<Transform>> sourceBoneMap, List<ProfileBakedBodyMesh> sourceBodyBakedMeshes)
|
||||
{
|
||||
ProfileUtils profileUtils = new ProfileUtils();
|
||||
HumanBodyBones[] influencedBones = new HumanBodyBones[1] { HumanBodyBones.Neck };
|
||||
newProfileData.NeckSpatialData = profileUtils.GetBoneSpatialData(HumanBodyBones.Neck, influencedBones, sourceBoneMap, sourceBodyBakedMeshes);
|
||||
|
||||
influencedBones = new HumanBodyBones[3] { HumanBodyBones.LeftUpperArm, HumanBodyBones.LeftLowerArm, HumanBodyBones.LeftHand };
|
||||
newProfileData.LeftUpperArmSpatialData = profileUtils.GetBoneSpatialData(HumanBodyBones.LeftUpperArm, influencedBones, sourceBoneMap, sourceBodyBakedMeshes);
|
||||
|
||||
influencedBones = new HumanBodyBones[3] { HumanBodyBones.RightUpperArm, HumanBodyBones.RightLowerArm, HumanBodyBones.RightHand };
|
||||
newProfileData.RightUpperArmSpatialData = profileUtils.GetBoneSpatialData(HumanBodyBones.RightUpperArm, influencedBones, sourceBoneMap, sourceBodyBakedMeshes);
|
||||
|
||||
influencedBones = new HumanBodyBones[1] { HumanBodyBones.LeftLowerArm };
|
||||
newProfileData.LeftLowerArmSpatialData = profileUtils.GetBoneSpatialData(HumanBodyBones.LeftLowerArm, influencedBones, sourceBoneMap, sourceBodyBakedMeshes);
|
||||
|
||||
influencedBones = new HumanBodyBones[1] { HumanBodyBones.RightLowerArm };
|
||||
newProfileData.RightLowerArmSpatialData = profileUtils.GetBoneSpatialData(HumanBodyBones.RightLowerArm, influencedBones, sourceBoneMap, sourceBodyBakedMeshes);
|
||||
|
||||
influencedBones = new HumanBodyBones[1] { HumanBodyBones.LeftHand };
|
||||
newProfileData.LeftLowerArm_HandSpatialData = profileUtils.GetBoneSpatialData(HumanBodyBones.LeftLowerArm, influencedBones, sourceBoneMap, sourceBodyBakedMeshes);
|
||||
|
||||
influencedBones = new HumanBodyBones[1] { HumanBodyBones.RightHand };
|
||||
newProfileData.RightLowerArm_HandSpatialData = profileUtils.GetBoneSpatialData(HumanBodyBones.RightLowerArm, influencedBones, sourceBoneMap, sourceBodyBakedMeshes);
|
||||
|
||||
influencedBones = new HumanBodyBones[2] { HumanBodyBones.LeftUpperLeg, HumanBodyBones.LeftLowerLeg };
|
||||
newProfileData.LeftUpperLegSpatialData = profileUtils.GetBoneSpatialData(HumanBodyBones.LeftUpperLeg, influencedBones, sourceBoneMap, sourceBodyBakedMeshes);
|
||||
|
||||
influencedBones = new HumanBodyBones[2] { HumanBodyBones.RightUpperLeg, HumanBodyBones.RightLowerLeg };
|
||||
newProfileData.RightUpperLegSpatialData = profileUtils.GetBoneSpatialData(HumanBodyBones.RightUpperLeg, influencedBones, sourceBoneMap, sourceBodyBakedMeshes);
|
||||
|
||||
influencedBones = new HumanBodyBones[1] { HumanBodyBones.LeftFoot };
|
||||
newProfileData.LeftFootSpatialData = profileUtils.GetBoneSpatialData(HumanBodyBones.LeftFoot, influencedBones, sourceBoneMap, sourceBodyBakedMeshes, addChildBones: true);
|
||||
|
||||
influencedBones = new HumanBodyBones[1] { HumanBodyBones.RightFoot };
|
||||
newProfileData.RightFootSpatialData = profileUtils.GetBoneSpatialData(HumanBodyBones.RightFoot, influencedBones, sourceBoneMap, sourceBodyBakedMeshes, addChildBones: true);
|
||||
|
||||
influencedBones = new HumanBodyBones[1] { HumanBodyBones.Chest };
|
||||
newProfileData.ChestSpatialData = profileUtils.GetBoneSpatialData(HumanBodyBones.Chest, influencedBones, sourceBoneMap, sourceBodyBakedMeshes);
|
||||
|
||||
influencedBones = new HumanBodyBones[1] { HumanBodyBones.UpperChest };
|
||||
newProfileData.UpperChestSpatialData = profileUtils.GetBoneSpatialData(HumanBodyBones.UpperChest, influencedBones, sourceBoneMap, sourceBodyBakedMeshes);
|
||||
|
||||
influencedBones = new HumanBodyBones[2] { HumanBodyBones.Chest, HumanBodyBones.UpperChest };
|
||||
newProfileData.IntegratedChestSpatialData = profileUtils.GetBoneSpatialData(HumanBodyBones.Chest, influencedBones, sourceBoneMap, sourceBodyBakedMeshes);
|
||||
|
||||
influencedBones = new HumanBodyBones[1] { HumanBodyBones.Spine };
|
||||
newProfileData.SpineSpatialData = profileUtils.GetBoneSpatialData(HumanBodyBones.Spine, influencedBones, sourceBoneMap, sourceBodyBakedMeshes);
|
||||
|
||||
influencedBones = new HumanBodyBones[1] { HumanBodyBones.LeftHand };
|
||||
newProfileData.LeftHandSpatialData = profileUtils.GetBoneSpatialData(HumanBodyBones.LeftHand, influencedBones, sourceBoneMap, sourceBodyBakedMeshes);
|
||||
|
||||
influencedBones = new HumanBodyBones[3] { HumanBodyBones.LeftThumbProximal, HumanBodyBones.LeftThumbIntermediate, HumanBodyBones.LeftThumbDistal };
|
||||
newProfileData.LeftHandThumbSpatialData = profileUtils.GetBoneSpatialData(HumanBodyBones.LeftThumbProximal, influencedBones, sourceBoneMap, sourceBodyBakedMeshes, addChildBones: true);
|
||||
|
||||
influencedBones = new HumanBodyBones[1] { HumanBodyBones.LeftThumbProximal };
|
||||
newProfileData.LeftHandThumbProximalSpatialData = profileUtils.GetBoneSpatialData(HumanBodyBones.LeftThumbProximal, influencedBones, sourceBoneMap, sourceBodyBakedMeshes);
|
||||
|
||||
influencedBones = new HumanBodyBones[1] { HumanBodyBones.LeftThumbIntermediate };
|
||||
newProfileData.LeftHandThumbIntermediateSpatialData = profileUtils.GetBoneSpatialData(HumanBodyBones.LeftThumbIntermediate, influencedBones, sourceBoneMap, sourceBodyBakedMeshes);
|
||||
|
||||
influencedBones = new HumanBodyBones[1] { HumanBodyBones.LeftThumbDistal };
|
||||
newProfileData.LeftHandThumbDistalSpatialData = profileUtils.GetBoneSpatialData(HumanBodyBones.LeftThumbDistal, influencedBones, sourceBoneMap, sourceBodyBakedMeshes);
|
||||
|
||||
influencedBones = new HumanBodyBones[3] { HumanBodyBones.LeftIndexProximal, HumanBodyBones.LeftIndexIntermediate, HumanBodyBones.LeftIndexDistal };
|
||||
newProfileData.LeftHandIndexSpatialData = profileUtils.GetBoneSpatialData(HumanBodyBones.LeftIndexProximal, influencedBones, sourceBoneMap, sourceBodyBakedMeshes, addChildBones: true);
|
||||
|
||||
influencedBones = new HumanBodyBones[1] { HumanBodyBones.LeftIndexProximal };
|
||||
newProfileData.LeftHandIndexProximalSpatialData = profileUtils.GetBoneSpatialData(HumanBodyBones.LeftIndexProximal, influencedBones, sourceBoneMap, sourceBodyBakedMeshes);
|
||||
|
||||
influencedBones = new HumanBodyBones[1] { HumanBodyBones.LeftIndexIntermediate };
|
||||
newProfileData.LeftHandIndexIntermediateSpatialData = profileUtils.GetBoneSpatialData(HumanBodyBones.LeftIndexIntermediate, influencedBones, sourceBoneMap, sourceBodyBakedMeshes);
|
||||
|
||||
influencedBones = new HumanBodyBones[1] { HumanBodyBones.LeftIndexDistal };
|
||||
newProfileData.LeftHandIndexDistalSpatialData = profileUtils.GetBoneSpatialData(HumanBodyBones.LeftIndexDistal, influencedBones, sourceBoneMap, sourceBodyBakedMeshes);
|
||||
|
||||
influencedBones = new HumanBodyBones[3] { HumanBodyBones.LeftMiddleProximal, HumanBodyBones.LeftMiddleIntermediate, HumanBodyBones.LeftMiddleDistal };
|
||||
newProfileData.LeftHandMiddleSpatialData = profileUtils.GetBoneSpatialData(HumanBodyBones.LeftMiddleProximal, influencedBones, sourceBoneMap, sourceBodyBakedMeshes, addChildBones: true);
|
||||
|
||||
influencedBones = new HumanBodyBones[1] { HumanBodyBones.LeftMiddleProximal };
|
||||
newProfileData.LeftHandMiddleProximalSpatialData = profileUtils.GetBoneSpatialData(HumanBodyBones.LeftMiddleProximal, influencedBones, sourceBoneMap, sourceBodyBakedMeshes);
|
||||
|
||||
influencedBones = new HumanBodyBones[1] { HumanBodyBones.LeftMiddleIntermediate };
|
||||
newProfileData.LeftHandMiddleIntermediateSpatialData = profileUtils.GetBoneSpatialData(HumanBodyBones.LeftMiddleIntermediate, influencedBones, sourceBoneMap, sourceBodyBakedMeshes);
|
||||
|
||||
influencedBones = new HumanBodyBones[1] { HumanBodyBones.LeftMiddleDistal };
|
||||
newProfileData.LeftHandMiddleDistalSpatialData = profileUtils.GetBoneSpatialData(HumanBodyBones.LeftMiddleDistal, influencedBones, sourceBoneMap, sourceBodyBakedMeshes);
|
||||
|
||||
influencedBones = new HumanBodyBones[3] { HumanBodyBones.LeftRingProximal, HumanBodyBones.LeftRingIntermediate, HumanBodyBones.LeftRingDistal };
|
||||
newProfileData.LeftHandRingSpatialData = profileUtils.GetBoneSpatialData(HumanBodyBones.LeftRingProximal, influencedBones, sourceBoneMap, sourceBodyBakedMeshes, addChildBones: true);
|
||||
|
||||
influencedBones = new HumanBodyBones[1] { HumanBodyBones.LeftRingProximal };
|
||||
newProfileData.LeftHandRingProximalSpatialData = profileUtils.GetBoneSpatialData(HumanBodyBones.LeftRingProximal, influencedBones, sourceBoneMap, sourceBodyBakedMeshes);
|
||||
|
||||
influencedBones = new HumanBodyBones[1] { HumanBodyBones.LeftRingIntermediate };
|
||||
newProfileData.LeftHandRingIntermediateSpatialData = profileUtils.GetBoneSpatialData(HumanBodyBones.LeftRingIntermediate, influencedBones, sourceBoneMap, sourceBodyBakedMeshes);
|
||||
|
||||
influencedBones = new HumanBodyBones[1] { HumanBodyBones.LeftRingDistal };
|
||||
newProfileData.LeftHandRingDistalSpatialData = profileUtils.GetBoneSpatialData(HumanBodyBones.LeftRingDistal, influencedBones, sourceBoneMap, sourceBodyBakedMeshes);
|
||||
|
||||
influencedBones = new HumanBodyBones[3] { HumanBodyBones.LeftLittleProximal, HumanBodyBones.LeftLittleIntermediate, HumanBodyBones.LeftLittleDistal };
|
||||
newProfileData.LeftHandLittleSpatialData = profileUtils.GetBoneSpatialData(HumanBodyBones.LeftLittleProximal, influencedBones, sourceBoneMap, sourceBodyBakedMeshes, addChildBones: true);
|
||||
|
||||
influencedBones = new HumanBodyBones[1] { HumanBodyBones.LeftLittleProximal };
|
||||
newProfileData.LeftHandLittleProximalSpatialData = profileUtils.GetBoneSpatialData(HumanBodyBones.LeftLittleProximal, influencedBones, sourceBoneMap, sourceBodyBakedMeshes);
|
||||
|
||||
influencedBones = new HumanBodyBones[1] { HumanBodyBones.LeftLittleIntermediate };
|
||||
newProfileData.LeftHandLittleIntermediateSpatialData = profileUtils.GetBoneSpatialData(HumanBodyBones.LeftLittleIntermediate, influencedBones, sourceBoneMap, sourceBodyBakedMeshes);
|
||||
|
||||
influencedBones = new HumanBodyBones[1] { HumanBodyBones.LeftLittleDistal };
|
||||
newProfileData.LeftHandLittleDistalSpatialData = profileUtils.GetBoneSpatialData(HumanBodyBones.LeftLittleDistal, influencedBones, sourceBoneMap, sourceBodyBakedMeshes);
|
||||
|
||||
influencedBones = new HumanBodyBones[1] { HumanBodyBones.RightHand };
|
||||
newProfileData.RightHandSpatialData = profileUtils.GetBoneSpatialData(HumanBodyBones.RightHand, influencedBones, sourceBoneMap, sourceBodyBakedMeshes);
|
||||
|
||||
influencedBones = new HumanBodyBones[3] { HumanBodyBones.RightThumbProximal, HumanBodyBones.RightThumbIntermediate, HumanBodyBones.RightThumbDistal };
|
||||
newProfileData.RightHandThumbSpatialData = profileUtils.GetBoneSpatialData(HumanBodyBones.RightThumbProximal, influencedBones, sourceBoneMap, sourceBodyBakedMeshes, addChildBones: true);
|
||||
|
||||
influencedBones = new HumanBodyBones[1] { HumanBodyBones.RightThumbProximal };
|
||||
newProfileData.RightHandThumbProximalSpatialData = profileUtils.GetBoneSpatialData(HumanBodyBones.RightThumbProximal, influencedBones, sourceBoneMap, sourceBodyBakedMeshes);
|
||||
|
||||
influencedBones = new HumanBodyBones[1] { HumanBodyBones.RightThumbIntermediate };
|
||||
newProfileData.RightHandThumbIntermediateSpatialData = profileUtils.GetBoneSpatialData(HumanBodyBones.RightThumbIntermediate, influencedBones, sourceBoneMap, sourceBodyBakedMeshes);
|
||||
|
||||
influencedBones = new HumanBodyBones[1] { HumanBodyBones.RightThumbDistal };
|
||||
newProfileData.RightHandThumbDistalSpatialData = profileUtils.GetBoneSpatialData(HumanBodyBones.RightThumbDistal, influencedBones, sourceBoneMap, sourceBodyBakedMeshes);
|
||||
|
||||
influencedBones = new HumanBodyBones[3] { HumanBodyBones.RightIndexProximal, HumanBodyBones.RightIndexIntermediate, HumanBodyBones.RightIndexDistal };
|
||||
newProfileData.RightHandIndexSpatialData = profileUtils.GetBoneSpatialData(HumanBodyBones.RightIndexProximal, influencedBones, sourceBoneMap, sourceBodyBakedMeshes, addChildBones: true);
|
||||
|
||||
influencedBones = new HumanBodyBones[1] { HumanBodyBones.RightIndexProximal };
|
||||
newProfileData.RightHandIndexProximalSpatialData = profileUtils.GetBoneSpatialData(HumanBodyBones.RightIndexProximal, influencedBones, sourceBoneMap, sourceBodyBakedMeshes);
|
||||
|
||||
influencedBones = new HumanBodyBones[1] { HumanBodyBones.RightIndexIntermediate };
|
||||
newProfileData.RightHandIndexIntermediateSpatialData = profileUtils.GetBoneSpatialData(HumanBodyBones.RightIndexIntermediate, influencedBones, sourceBoneMap, sourceBodyBakedMeshes);
|
||||
|
||||
influencedBones = new HumanBodyBones[1] { HumanBodyBones.RightIndexDistal };
|
||||
newProfileData.RightHandIndexDistalSpatialData = profileUtils.GetBoneSpatialData(HumanBodyBones.RightIndexDistal, influencedBones, sourceBoneMap, sourceBodyBakedMeshes);
|
||||
|
||||
influencedBones = new HumanBodyBones[3] { HumanBodyBones.RightMiddleProximal, HumanBodyBones.RightMiddleIntermediate, HumanBodyBones.RightMiddleDistal };
|
||||
newProfileData.RightHandMiddleSpatialData = profileUtils.GetBoneSpatialData(HumanBodyBones.RightMiddleProximal, influencedBones, sourceBoneMap, sourceBodyBakedMeshes, addChildBones: true);
|
||||
|
||||
influencedBones = new HumanBodyBones[1] { HumanBodyBones.RightMiddleProximal };
|
||||
newProfileData.RightHandMiddleProximalSpatialData = profileUtils.GetBoneSpatialData(HumanBodyBones.RightMiddleProximal, influencedBones, sourceBoneMap, sourceBodyBakedMeshes);
|
||||
|
||||
influencedBones = new HumanBodyBones[1] { HumanBodyBones.RightMiddleIntermediate };
|
||||
newProfileData.RightHandMiddleIntermediateSpatialData = profileUtils.GetBoneSpatialData(HumanBodyBones.RightMiddleIntermediate, influencedBones, sourceBoneMap, sourceBodyBakedMeshes);
|
||||
|
||||
influencedBones = new HumanBodyBones[1] { HumanBodyBones.RightMiddleDistal };
|
||||
newProfileData.RightHandMiddleDistalSpatialData = profileUtils.GetBoneSpatialData(HumanBodyBones.RightMiddleDistal, influencedBones, sourceBoneMap, sourceBodyBakedMeshes);
|
||||
|
||||
influencedBones = new HumanBodyBones[3] { HumanBodyBones.RightRingProximal, HumanBodyBones.RightRingIntermediate, HumanBodyBones.RightRingDistal };
|
||||
newProfileData.RightHandRingSpatialData = profileUtils.GetBoneSpatialData(HumanBodyBones.RightRingProximal, influencedBones, sourceBoneMap, sourceBodyBakedMeshes, addChildBones: true);
|
||||
|
||||
influencedBones = new HumanBodyBones[1] { HumanBodyBones.RightRingProximal };
|
||||
newProfileData.RightHandRingProximalSpatialData = profileUtils.GetBoneSpatialData(HumanBodyBones.RightRingProximal, influencedBones, sourceBoneMap, sourceBodyBakedMeshes);
|
||||
|
||||
influencedBones = new HumanBodyBones[1] { HumanBodyBones.RightRingIntermediate };
|
||||
newProfileData.RightHandRingIntermediateSpatialData = profileUtils.GetBoneSpatialData(HumanBodyBones.RightRingIntermediate, influencedBones, sourceBoneMap, sourceBodyBakedMeshes);
|
||||
|
||||
influencedBones = new HumanBodyBones[1] { HumanBodyBones.RightRingDistal };
|
||||
newProfileData.RightHandRingDistalSpatialData = profileUtils.GetBoneSpatialData(HumanBodyBones.RightRingDistal, influencedBones, sourceBoneMap, sourceBodyBakedMeshes);
|
||||
|
||||
influencedBones = new HumanBodyBones[3] { HumanBodyBones.RightLittleProximal, HumanBodyBones.RightLittleIntermediate, HumanBodyBones.RightLittleDistal };
|
||||
newProfileData.RightHandLittleSpatialData = profileUtils.GetBoneSpatialData(HumanBodyBones.RightLittleProximal, influencedBones, sourceBoneMap, sourceBodyBakedMeshes, addChildBones: true);
|
||||
|
||||
influencedBones = new HumanBodyBones[1] { HumanBodyBones.RightLittleProximal };
|
||||
newProfileData.RightHandLittleProximalSpatialData = profileUtils.GetBoneSpatialData(HumanBodyBones.RightLittleProximal, influencedBones, sourceBoneMap, sourceBodyBakedMeshes);
|
||||
|
||||
influencedBones = new HumanBodyBones[1] { HumanBodyBones.RightLittleIntermediate };
|
||||
newProfileData.RightHandLittleIntermediateSpatialData = profileUtils.GetBoneSpatialData(HumanBodyBones.RightLittleIntermediate, influencedBones, sourceBoneMap, sourceBodyBakedMeshes);
|
||||
|
||||
influencedBones = new HumanBodyBones[1] { HumanBodyBones.RightLittleDistal };
|
||||
newProfileData.RightHandLittleDistalSpatialData = profileUtils.GetBoneSpatialData(HumanBodyBones.RightLittleDistal, influencedBones, sourceBoneMap, sourceBodyBakedMeshes);
|
||||
}
|
||||
|
||||
public void SaveBoneData(ref ProfileData newProfileData, Transform sourceAvatar, Dictionary<HumanBodyBones, HashSet<Transform>> sourceBoneMap, List<ProfileBakedBodyMesh> sourceBodyBakedMeshes)
|
||||
{
|
||||
ProfileUtils profileUtils = new ProfileUtils();
|
||||
HashSet<Transform> hashSet = new HashSet<Transform>();
|
||||
foreach (ProfileBakedBodyMesh sourceBodyBakedMesh in sourceBodyBakedMeshes)
|
||||
{
|
||||
foreach (Transform bodyMeshBone in profileUtils.GetBodyMeshBones(sourceBodyBakedMesh.smr))
|
||||
{
|
||||
hashSet.Add(bodyMeshBone);
|
||||
}
|
||||
}
|
||||
if (hashSet.Count == 0)
|
||||
{
|
||||
Debug.LogWarning((object)"[EdenAutoMorpher_ProfileSaver] SaveBoneData - avatarBones is empty.");
|
||||
newProfileData.boneRootId = -1;
|
||||
newProfileData.bones = new List<BoneData>();
|
||||
}
|
||||
else
|
||||
{
|
||||
newProfileData.boneRootId = 0;
|
||||
newProfileData.bones = profileUtils.GetBoneDatas(sourceAvatar, hashSet, sourceBoneMap);
|
||||
}
|
||||
}
|
||||
|
||||
private void AdjustAvatarHigh(Transform sourceRoot, Dictionary<HumanBodyBones, HashSet<Transform>> sourceBoneMap, float targetHeight)
|
||||
{
|
||||
//IL_0027: 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_006c: 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_0073: 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_007e: Unknown result type (might be due to invalid IL or missing references)
|
||||
if (!sourceBoneMap.TryGetValue(HumanBodyBones.Neck, out var value) || value.Count == 0)
|
||||
{
|
||||
Debug.LogError("[EdenAutoMorpher_ProfileSaver] Can't Find Neck Bones");
|
||||
return;
|
||||
}
|
||||
float num = value.FirstOrDefault().position.y - sourceRoot.position.y;
|
||||
if (Mathf.Approximately(num, 0f))
|
||||
{
|
||||
Debug.LogWarning($"[EdenAutoMorpher_ProfileSaver] {sourceRoot.name} Neck Y가 0에 가까워 스케일 계산을 건너뜁니다. (neckY = {num})");
|
||||
return;
|
||||
}
|
||||
float num2 = targetHeight / num;
|
||||
Vector3 localScale = sourceRoot.localScale;
|
||||
localScale *= num2;
|
||||
sourceRoot.localScale = localScale;
|
||||
}
|
||||
|
||||
private void SaveProfileToJson(ProfileData profileData, string savePath, string profileName)
|
||||
{
|
||||
if (profileData == null)
|
||||
{
|
||||
Debug.LogError("[EdenAutoMorpher_ProfileSaver] ProfileData is null. Abort save.");
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(profileName))
|
||||
{
|
||||
Debug.LogError("[EdenAutoMorpher_ProfileSaver] profileName is empty.");
|
||||
return;
|
||||
}
|
||||
string path = profileName.EndsWith(".json") ? profileName : (profileName + ".json");
|
||||
string text = Path.Combine(Application.dataPath, savePath ?? string.Empty);
|
||||
if (!Directory.Exists(text))
|
||||
{
|
||||
Directory.CreateDirectory(text);
|
||||
}
|
||||
string text2 = Path.Combine(text, path);
|
||||
string contents = JsonUtility.ToJson(profileData, true);
|
||||
File.WriteAllText(text2, contents);
|
||||
Debug.Log("[EdenAutoMorpher_ProfileSaver] Profile saved successfully.\nPath: " + text2);
|
||||
AssetDatabase.Refresh();
|
||||
}
|
||||
|
||||
public bool IsExistBaseData()
|
||||
{
|
||||
ProfileUtils profileUtils = new ProfileUtils();
|
||||
return File.Exists(Path.Combine(Application.dataPath, profileUtils.GetBaseDataPath()));
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2fd1a8210b48a8d49843a3f2859e67b6
|
||||
@@ -1,18 +0,0 @@
|
||||
// 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.
|
||||
// EdenAutoMorpher_ProfileSaver_Script, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||
// Eden.AutoMorpher.profile.PCAData
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
[Serializable]
|
||||
public class PCAData
|
||||
{
|
||||
public Vector3 pcaCenter;
|
||||
|
||||
public Vector3 pcaPrincipalAxis;
|
||||
|
||||
public float pcaLength;
|
||||
|
||||
public float pcaAvgRadius;
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ba923ad66ccb9824aa21217281bc8f03
|
||||
@@ -1,17 +0,0 @@
|
||||
// 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.
|
||||
// EdenAutoMorpher_ProfileSaver_Script, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||
// Eden.AutoMorpher.profile.ProfileBVH
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class ProfileBVH
|
||||
{
|
||||
public List<Vector3> vertices;
|
||||
|
||||
public profileBVHData[] datas;
|
||||
|
||||
public profileBVHNode[] nodes;
|
||||
|
||||
public int[] dataIndices;
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ca85c008bacb4c04fab51354ef3d6365
|
||||
@@ -1,106 +0,0 @@
|
||||
// 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.
|
||||
// EdenAutoMorpher_ProfileSaver_Script, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||
// Eden.AutoMorpher.profile.ProfileBakedBodyMesh
|
||||
using UnityEngine;
|
||||
|
||||
public class ProfileBakedBodyMesh
|
||||
{
|
||||
public SkinnedMeshRenderer smr;
|
||||
|
||||
public Mesh bakedMesh;
|
||||
|
||||
public Vector3[] worldVertices;
|
||||
|
||||
public BoneWeight[] boneWeights
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!((Object)(object)this.smr != (Object)null))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return this.smr.sharedMesh.boneWeights;
|
||||
}
|
||||
}
|
||||
|
||||
public Transform[] bones
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!((Object)(object)this.smr != (Object)null))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return this.smr.bones;
|
||||
}
|
||||
}
|
||||
|
||||
public ProfileBakedBodyMesh(SkinnedMeshRenderer _smr)
|
||||
{
|
||||
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_006d: Expected O, but got Unknown
|
||||
if ((Object)(object)_smr == (Object)null)
|
||||
{
|
||||
Debug.LogError((object)("[ProfileUtil - ProfileBakedBodyMesh] BakeBodyMesh Init : SkinnedMeshRenderer " + ((Object)((Component)_smr).gameObject).name + " is null"));
|
||||
}
|
||||
this.smr = _smr;
|
||||
if ((Object)(object)_smr.sharedMesh == (Object)null)
|
||||
{
|
||||
Debug.LogError((object)("[ProfileUtil - ProfileBakedBodyMesh] BakeBodyMesh Init : SkinnedMeshRenderer " + ((Object)((Component)_smr).gameObject).name + " has null sharedMesh."));
|
||||
}
|
||||
this.bakedMesh = new Mesh();
|
||||
this.smr.BakeMesh(this.bakedMesh);
|
||||
this.worldVertices = this.CalculateWorldVertices(this.smr, this.bakedMesh);
|
||||
}
|
||||
|
||||
public void ReBakeMesh()
|
||||
{
|
||||
this.smr.BakeMesh(this.bakedMesh);
|
||||
this.worldVertices = this.CalculateWorldVertices(this.smr, this.bakedMesh);
|
||||
}
|
||||
|
||||
~ProfileBakedBodyMesh()
|
||||
{
|
||||
this.smr = null;
|
||||
this.bakedMesh = null;
|
||||
}
|
||||
|
||||
private Vector3[] CalculateWorldVertices(SkinnedMeshRenderer smr, Mesh bakedMesh)
|
||||
{
|
||||
//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_0049: 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_0075: 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_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_009b: 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)
|
||||
if ((Object)(object)smr == (Object)null)
|
||||
{
|
||||
Debug.LogError((object)("[ProfileUtil - ProfileBakedBodyMesh] CalculateWorldVertices: smr " + ((Object)((Component)smr).gameObject).name + " == null"));
|
||||
return 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;
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1b9accce356c005478e76fd0fa193f3a
|
||||
@@ -1,132 +0,0 @@
|
||||
// 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.
|
||||
// EdenAutoMorpher_ProfileSaver_Script, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||
// Eden.AutoMorpher.profile.ProfileData
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
[Serializable]
|
||||
public class ProfileData
|
||||
{
|
||||
public int version = 1;
|
||||
|
||||
public float neckTargetHeight = 1.5f;
|
||||
|
||||
public BoneSpatialData NeckSpatialData;
|
||||
|
||||
public BoneSpatialData LeftUpperArmSpatialData;
|
||||
|
||||
public BoneSpatialData RightUpperArmSpatialData;
|
||||
|
||||
public BoneSpatialData LeftLowerArmSpatialData;
|
||||
|
||||
public BoneSpatialData RightLowerArmSpatialData;
|
||||
|
||||
public BoneSpatialData LeftLowerArm_HandSpatialData;
|
||||
|
||||
public BoneSpatialData RightLowerArm_HandSpatialData;
|
||||
|
||||
public BoneSpatialData LeftUpperLegSpatialData;
|
||||
|
||||
public BoneSpatialData RightUpperLegSpatialData;
|
||||
|
||||
public BoneSpatialData LeftFootSpatialData;
|
||||
|
||||
public BoneSpatialData RightFootSpatialData;
|
||||
|
||||
public BoneSpatialData ChestSpatialData;
|
||||
|
||||
public BoneSpatialData UpperChestSpatialData;
|
||||
|
||||
public BoneSpatialData IntegratedChestSpatialData;
|
||||
|
||||
public BoneSpatialData SpineSpatialData;
|
||||
|
||||
public BoneSpatialData LeftHandSpatialData;
|
||||
|
||||
public BoneSpatialData LeftHandThumbSpatialData;
|
||||
|
||||
public BoneSpatialData LeftHandThumbProximalSpatialData;
|
||||
|
||||
public BoneSpatialData LeftHandThumbIntermediateSpatialData;
|
||||
|
||||
public BoneSpatialData LeftHandThumbDistalSpatialData;
|
||||
|
||||
public BoneSpatialData LeftHandIndexSpatialData;
|
||||
|
||||
public BoneSpatialData LeftHandIndexProximalSpatialData;
|
||||
|
||||
public BoneSpatialData LeftHandIndexIntermediateSpatialData;
|
||||
|
||||
public BoneSpatialData LeftHandIndexDistalSpatialData;
|
||||
|
||||
public BoneSpatialData LeftHandMiddleSpatialData;
|
||||
|
||||
public BoneSpatialData LeftHandMiddleProximalSpatialData;
|
||||
|
||||
public BoneSpatialData LeftHandMiddleIntermediateSpatialData;
|
||||
|
||||
public BoneSpatialData LeftHandMiddleDistalSpatialData;
|
||||
|
||||
public BoneSpatialData LeftHandRingSpatialData;
|
||||
|
||||
public BoneSpatialData LeftHandRingProximalSpatialData;
|
||||
|
||||
public BoneSpatialData LeftHandRingIntermediateSpatialData;
|
||||
|
||||
public BoneSpatialData LeftHandRingDistalSpatialData;
|
||||
|
||||
public BoneSpatialData LeftHandLittleSpatialData;
|
||||
|
||||
public BoneSpatialData LeftHandLittleProximalSpatialData;
|
||||
|
||||
public BoneSpatialData LeftHandLittleIntermediateSpatialData;
|
||||
|
||||
public BoneSpatialData LeftHandLittleDistalSpatialData;
|
||||
|
||||
public BoneSpatialData RightHandSpatialData;
|
||||
|
||||
public BoneSpatialData RightHandThumbSpatialData;
|
||||
|
||||
public BoneSpatialData RightHandThumbProximalSpatialData;
|
||||
|
||||
public BoneSpatialData RightHandThumbIntermediateSpatialData;
|
||||
|
||||
public BoneSpatialData RightHandThumbDistalSpatialData;
|
||||
|
||||
public BoneSpatialData RightHandIndexSpatialData;
|
||||
|
||||
public BoneSpatialData RightHandIndexProximalSpatialData;
|
||||
|
||||
public BoneSpatialData RightHandIndexIntermediateSpatialData;
|
||||
|
||||
public BoneSpatialData RightHandIndexDistalSpatialData;
|
||||
|
||||
public BoneSpatialData RightHandMiddleSpatialData;
|
||||
|
||||
public BoneSpatialData RightHandMiddleProximalSpatialData;
|
||||
|
||||
public BoneSpatialData RightHandMiddleIntermediateSpatialData;
|
||||
|
||||
public BoneSpatialData RightHandMiddleDistalSpatialData;
|
||||
|
||||
public BoneSpatialData RightHandRingSpatialData;
|
||||
|
||||
public BoneSpatialData RightHandRingProximalSpatialData;
|
||||
|
||||
public BoneSpatialData RightHandRingIntermediateSpatialData;
|
||||
|
||||
public BoneSpatialData RightHandRingDistalSpatialData;
|
||||
|
||||
public BoneSpatialData RightHandLittleSpatialData;
|
||||
|
||||
public BoneSpatialData RightHandLittleProximalSpatialData;
|
||||
|
||||
public BoneSpatialData RightHandLittleIntermediateSpatialData;
|
||||
|
||||
public BoneSpatialData RightHandLittleDistalSpatialData;
|
||||
|
||||
public int boneRootId;
|
||||
|
||||
public List<BoneData> bones;
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d62ebbd77f472fd4bb8abf3546d9d12a
|
||||
@@ -1,280 +0,0 @@
|
||||
// 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.
|
||||
// EdenAutoMorpher_ProfileSaver_Script, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||
// Eden.AutoMorpher.profile.ProfileUtil_IndexUtil
|
||||
using UnityEngine;
|
||||
|
||||
public class ProfileUtil_IndexUtil
|
||||
{
|
||||
public class BlockPermutations
|
||||
{
|
||||
private struct XorShift32
|
||||
{
|
||||
private uint _state;
|
||||
|
||||
public XorShift32(uint seed)
|
||||
{
|
||||
this._state = ((seed != 0) ? seed : 1831565813u);
|
||||
}
|
||||
|
||||
public uint NextUInt()
|
||||
{
|
||||
uint state = this._state;
|
||||
state ^= state << 13;
|
||||
state ^= state >> 17;
|
||||
return this._state = state ^ (state << 5);
|
||||
}
|
||||
|
||||
public int NextInt(int maxExclusive)
|
||||
{
|
||||
return (int)(this.NextUInt() % (uint)maxExclusive);
|
||||
}
|
||||
}
|
||||
|
||||
private readonly int _blockSize;
|
||||
|
||||
private int[] _px;
|
||||
|
||||
private int[] _py;
|
||||
|
||||
private int[] _pz;
|
||||
|
||||
private int[] _pall;
|
||||
|
||||
private uint _checksum;
|
||||
|
||||
private int _cachedLen = -1;
|
||||
|
||||
private int[] _pxLen;
|
||||
|
||||
private int[] _pyLen;
|
||||
|
||||
private int[] _pzLen;
|
||||
|
||||
private int[] _pallLen;
|
||||
|
||||
public BlockPermutations(int blockSize)
|
||||
{
|
||||
this._blockSize = blockSize;
|
||||
}
|
||||
|
||||
public void Build(int seed)
|
||||
{
|
||||
if (this._blockSize <= 1)
|
||||
{
|
||||
Debug.LogError((object)"[ProfileUtil_IndexUtil] BlockPermutations.Build - invalid blockSize");
|
||||
return;
|
||||
}
|
||||
XorShift32 rng = new XorShift32((uint)(seed ^ -1556008596));
|
||||
XorShift32 rng2 = new XorShift32((uint)(seed ^ -939442524));
|
||||
XorShift32 rng3 = new XorShift32((uint)(seed ^ -1383041155));
|
||||
XorShift32 rng4 = new XorShift32((uint)(seed ^ 0x7E95761E));
|
||||
this._px = this.MakePermutation(this._blockSize, ref rng);
|
||||
this._py = this.MakePermutation(this._blockSize, ref rng2);
|
||||
this._pz = this.MakePermutation(this._blockSize, ref rng3);
|
||||
this._pall = this.MakePermutation(this._blockSize, ref rng4);
|
||||
this._checksum = this.ComputeChecksum(this._px, this._py, this._pz, this._pall);
|
||||
this._cachedLen = -1;
|
||||
this._pxLen = (this._pyLen = (this._pzLen = (this._pallLen = null)));
|
||||
}
|
||||
|
||||
public bool ValidateRebuild(int seed)
|
||||
{
|
||||
uint checksum = this._checksum;
|
||||
BlockPermutations blockPermutations = new BlockPermutations(this._blockSize);
|
||||
blockPermutations.Build(seed);
|
||||
return blockPermutations._checksum == checksum;
|
||||
}
|
||||
|
||||
public void GetPermutationsForLen(int len, out int[] pxUse, out int[] pyUse, out int[] pzUse, out int[] pallUse)
|
||||
{
|
||||
if (len == this._blockSize)
|
||||
{
|
||||
pxUse = this._px;
|
||||
pyUse = this._py;
|
||||
pzUse = this._pz;
|
||||
pallUse = this._pall;
|
||||
return;
|
||||
}
|
||||
if (this._cachedLen != len)
|
||||
{
|
||||
this._cachedLen = len;
|
||||
this._pxLen = this.MakeSubPermutation(this._px, len);
|
||||
this._pyLen = this.MakeSubPermutation(this._py, len);
|
||||
this._pzLen = this.MakeSubPermutation(this._pz, len);
|
||||
this._pallLen = this.MakeSubPermutation(this._pall, len);
|
||||
}
|
||||
pxUse = this._pxLen;
|
||||
pyUse = this._pyLen;
|
||||
pzUse = this._pzLen;
|
||||
pallUse = this._pallLen;
|
||||
}
|
||||
|
||||
private int[] MakeSubPermutation(int[] fullPerm, int len)
|
||||
{
|
||||
int[] array = new int[len];
|
||||
int num = 0;
|
||||
for (int i = 0; i < fullPerm.Length; i++)
|
||||
{
|
||||
if (num >= len)
|
||||
{
|
||||
break;
|
||||
}
|
||||
int num2 = fullPerm[i];
|
||||
if (num2 < len)
|
||||
{
|
||||
array[num++] = num2;
|
||||
}
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
private int[] MakePermutation(int n, ref XorShift32 rng)
|
||||
{
|
||||
int[] array = new int[n];
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
array[i] = i;
|
||||
}
|
||||
for (int num = n - 1; num > 0; num--)
|
||||
{
|
||||
int num2 = rng.NextInt(num + 1);
|
||||
ref int reference = ref array[num];
|
||||
ref int reference2 = ref array[num2];
|
||||
int num3 = array[num2];
|
||||
int num4 = array[num];
|
||||
reference = num3;
|
||||
reference2 = num4;
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
private uint ComputeChecksum(int[] a, int[] b, int[] c, int[] d)
|
||||
{
|
||||
uint h = 2166136261u;
|
||||
this.MixArray(ref h, a);
|
||||
this.MixArray(ref h, b);
|
||||
this.MixArray(ref h, c);
|
||||
this.MixArray(ref h, d);
|
||||
return h;
|
||||
}
|
||||
|
||||
private void MixArray(ref uint h, int[] arr)
|
||||
{
|
||||
for (int i = 0; i < arr.Length; i++)
|
||||
{
|
||||
uint num = (uint)arr[i];
|
||||
h ^= num;
|
||||
h *= 16777619u;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public readonly int blockSize = 9783;
|
||||
|
||||
private readonly BlockPermutations _perm;
|
||||
|
||||
private float[] _xTmp;
|
||||
|
||||
private float[] _yTmp;
|
||||
|
||||
private float[] _zTmp;
|
||||
|
||||
public ProfileUtil_IndexUtil(int blockSize = 9783)
|
||||
{
|
||||
this.blockSize = blockSize;
|
||||
this._perm = new BlockPermutations(blockSize);
|
||||
this._xTmp = new float[blockSize];
|
||||
this._yTmp = new float[blockSize];
|
||||
this._zTmp = new float[blockSize];
|
||||
}
|
||||
|
||||
public void Build(int seed)
|
||||
{
|
||||
this._perm.Build(seed);
|
||||
}
|
||||
|
||||
public void EncodeInto(Vector3[] input, Vector3[] output)
|
||||
{
|
||||
//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_0081: 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_00a7: 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)
|
||||
if (input == null || output == null)
|
||||
{
|
||||
Debug.LogError((object)"[ProfileUtil_IndexUtil] EncodeInto - null args");
|
||||
return;
|
||||
}
|
||||
if (output.Length < input.Length)
|
||||
{
|
||||
Debug.LogError((object)"[ProfileUtil_IndexUtil] EncodeInto - output too small");
|
||||
return;
|
||||
}
|
||||
int num = input.Length;
|
||||
int num2 = this.blockSize;
|
||||
int num3 = (num + num2 - 1) / num2;
|
||||
for (int i = 0; i < num3; i++)
|
||||
{
|
||||
int num4 = i * num2;
|
||||
int num5 = Mathf.Min(num2, num - num4);
|
||||
this._perm.GetPermutationsForLen(num5, out var pxUse, out var pyUse, out var pzUse, out var pallUse);
|
||||
for (int j = 0; j < num5; j++)
|
||||
{
|
||||
Vector3 val = input[num4 + j];
|
||||
this._xTmp[pxUse[j]] = val.x;
|
||||
this._yTmp[pyUse[j]] = val.y;
|
||||
this._zTmp[pzUse[j]] = val.z;
|
||||
}
|
||||
for (int k = 0; k < num5; k++)
|
||||
{
|
||||
int num6 = pallUse[k];
|
||||
output[num4 + num6] = new Vector3(this._xTmp[k], this._yTmp[k], this._zTmp[k]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void DecodeInto(Vector3[] encoded, Vector3[] output)
|
||||
{
|
||||
//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_0085: 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_00a5: 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)
|
||||
if (encoded == null || output == null)
|
||||
{
|
||||
Debug.LogError((object)"[ProfileUtil_IndexUtil] DecodeInto - null args");
|
||||
return;
|
||||
}
|
||||
if (output.Length < encoded.Length)
|
||||
{
|
||||
Debug.LogError((object)"[ProfileUtil_IndexUtil] DecodeInto - output too small");
|
||||
return;
|
||||
}
|
||||
int num = encoded.Length;
|
||||
int num2 = this.blockSize;
|
||||
int num3 = (num + num2 - 1) / num2;
|
||||
for (int i = 0; i < num3; i++)
|
||||
{
|
||||
int num4 = i * num2;
|
||||
int num5 = Mathf.Min(num2, num - num4);
|
||||
this._perm.GetPermutationsForLen(num5, out var pxUse, out var pyUse, out var pzUse, out var pallUse);
|
||||
for (int j = 0; j < num5; j++)
|
||||
{
|
||||
int num6 = pallUse[j];
|
||||
Vector3 val = encoded[num4 + num6];
|
||||
this._xTmp[j] = val.x;
|
||||
this._yTmp[j] = val.y;
|
||||
this._zTmp[j] = val.z;
|
||||
}
|
||||
for (int k = 0; k < num5; k++)
|
||||
{
|
||||
output[num4 + k] = new Vector3(this._xTmp[pxUse[k]], this._yTmp[pyUse[k]], this._zTmp[pzUse[k]]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 08f2754ac23e3bd419413380289a1d1f
|
||||
@@ -1,75 +0,0 @@
|
||||
// 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.
|
||||
// EdenAutoMorpher_ProfileSaver_Script, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||
// Eden.AutoMorpher.profile.ProfileUtils
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class ProfileUtils
|
||||
{
|
||||
private ProfileUtils_BoneUtil boneUtil;
|
||||
|
||||
private ProfileUtils_PoseUtil poseUtil;
|
||||
|
||||
private string profileBasePath = "@Eden_Tools\\Eden_AutoMorpher\\Profiles";
|
||||
|
||||
private string baseDataPath = "@Eden_Tools\\Eden_AutoMorpher\\ProfileSaver\\BaseData\\base.vb";
|
||||
|
||||
private int profileVersion = 1;
|
||||
|
||||
private string profileMagic = "PBVH";
|
||||
|
||||
private string baseMagic = "PVTB";
|
||||
|
||||
public ProfileUtils()
|
||||
{
|
||||
this.boneUtil = new ProfileUtils_BoneUtil();
|
||||
this.poseUtil = new ProfileUtils_PoseUtil();
|
||||
}
|
||||
|
||||
public string GetProfileBasePath()
|
||||
{
|
||||
return this.profileBasePath;
|
||||
}
|
||||
|
||||
public string GetBaseDataPath()
|
||||
{
|
||||
return this.baseDataPath;
|
||||
}
|
||||
|
||||
public int GetProfileVersion()
|
||||
{
|
||||
return this.profileVersion;
|
||||
}
|
||||
|
||||
public string GetProfileMagic()
|
||||
{
|
||||
return this.profileMagic;
|
||||
}
|
||||
|
||||
public string GetBaseMagic()
|
||||
{
|
||||
return this.baseMagic;
|
||||
}
|
||||
|
||||
public Dictionary<HumanBodyBones, HashSet<Transform>> GetHumanoidMeshBoneMap(Animator animator, IReadOnlyList<SkinnedMeshRenderer> bodyMeshes, float posTolerance = 0.0001f, float weightThreshold = 0.0001f)
|
||||
{
|
||||
return this.boneUtil.GetHumanoidMeshBoneMap(animator, bodyMeshes, posTolerance, weightThreshold);
|
||||
}
|
||||
|
||||
public BoneSpatialData GetBoneSpatialData(HumanBodyBones refBone, HumanBodyBones[] influencedBones, Dictionary<HumanBodyBones, HashSet<Transform>> boneMap, List<ProfileBakedBodyMesh> sourceBodyBakedMeshes, bool addChildBones = false)
|
||||
{
|
||||
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
|
||||
return this.poseUtil.GetBoneSpatialData(refBone, influencedBones, boneMap, sourceBodyBakedMeshes, addChildBones);
|
||||
}
|
||||
|
||||
public HashSet<Transform> GetBodyMeshBones(SkinnedMeshRenderer smr, float weightThreshold = 0.0001f)
|
||||
{
|
||||
return this.boneUtil.GetBodyMeshBones(smr, weightThreshold);
|
||||
}
|
||||
|
||||
public List<BoneData> GetBoneDatas(Transform rootTransform, HashSet<Transform> avatarBones, Dictionary<HumanBodyBones, HashSet<Transform>> sourceBoneMap)
|
||||
{
|
||||
return this.boneUtil.GetBoneDatas(rootTransform, avatarBones, sourceBoneMap);
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0575b5a00bd94c64d96d49da0465ee70
|
||||
@@ -1,354 +0,0 @@
|
||||
// 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.
|
||||
// EdenAutoMorpher_ProfileSaver_Script, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||
// Eden.AutoMorpher.profile.ProfileUtils_BVHUtil
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
|
||||
public class ProfileUtils_BVHUtil
|
||||
{
|
||||
private const int LeafMaxTriangles = 4;
|
||||
|
||||
public ProfileBVH GetBVHData(Transform rootTransform, List<ProfileBakedBodyMesh> bakedBodyMeshes)
|
||||
{
|
||||
return this.BuildFromSkinnedMeshes(rootTransform, bakedBodyMeshes);
|
||||
}
|
||||
|
||||
public ProfileBVH BuildFromSkinnedMeshes(Transform rootTransform, List<ProfileBakedBodyMesh> bakedBodyMeshes)
|
||||
{
|
||||
//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_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)
|
||||
//IL_010a: 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)
|
||||
ProfileBVH profileBVH = new ProfileBVH
|
||||
{
|
||||
vertices = new List<Vector3>(1024)
|
||||
};
|
||||
int num = 0;
|
||||
foreach (ProfileBakedBodyMesh bakedBodyMesh in bakedBodyMeshes)
|
||||
{
|
||||
if (bakedBodyMesh != null && !(bakedBodyMesh.smr == null) && !(bakedBodyMesh.smr.sharedMesh == null))
|
||||
{
|
||||
num += bakedBodyMesh.smr.sharedMesh.triangles.Length / 3;
|
||||
}
|
||||
}
|
||||
if (num == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
profileBVH.datas = new profileBVHData[num];
|
||||
Matrix4x4 worldToLocalMatrix = rootTransform.worldToLocalMatrix;
|
||||
int num2 = 0;
|
||||
foreach (ProfileBakedBodyMesh bakedBodyMesh2 in bakedBodyMeshes)
|
||||
{
|
||||
if (bakedBodyMesh2 != null && !(bakedBodyMesh2.smr == null) && !(bakedBodyMesh2.smr.sharedMesh == null))
|
||||
{
|
||||
int count = profileBVH.vertices.Count;
|
||||
for (int i = 0; i < bakedBodyMesh2.worldVertices.Length; i++)
|
||||
{
|
||||
Vector3 item = worldToLocalMatrix.MultiplyPoint3x4(bakedBodyMesh2.worldVertices[i]);
|
||||
profileBVH.vertices.Add(item);
|
||||
}
|
||||
int[] triangles = bakedBodyMesh2.smr.sharedMesh.triangles;
|
||||
int num3 = triangles.Length / 3;
|
||||
for (int j = 0; j < num3; j++)
|
||||
{
|
||||
int num4 = triangles[j * 3];
|
||||
int num5 = triangles[j * 3 + 1];
|
||||
int num6 = triangles[j * 3 + 2];
|
||||
profileBVH.datas[num2++] = new profileBVHData
|
||||
{
|
||||
verA = count + num4,
|
||||
verB = count + num5,
|
||||
verC = count + num6
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
int num7 = num;
|
||||
int[] array = new int[num7];
|
||||
for (int k = 0; k < num7; k++)
|
||||
{
|
||||
array[k] = k;
|
||||
}
|
||||
profileBVH.dataIndices = array;
|
||||
List<profileBVHNode> list = new List<profileBVHNode>();
|
||||
this.BuildRecursive(profileBVH, array, 0, num7, list);
|
||||
profileBVH.nodes = list.ToArray();
|
||||
return profileBVH;
|
||||
}
|
||||
|
||||
private int BuildRecursive(ProfileBVH bvh, int[] triIndices, int start, int count, List<profileBVHNode> outNodes)
|
||||
{
|
||||
//IL_0010: 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_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_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_00bd: 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_0092: 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_00a4: 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_007c: 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_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_0109: 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_0112: 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_0137: 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_0170: 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_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_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_01b0: 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)
|
||||
int count2 = outNodes.Count;
|
||||
profileBVHNode profileBVHNode2 = new profileBVHNode();
|
||||
Bounds bounds = default(Bounds);
|
||||
bool flag = true;
|
||||
for (int i = start; i < start + count; i++)
|
||||
{
|
||||
profileBVHData profileBVHData2 = bvh.datas[triIndices[i]];
|
||||
Vector3 val = bvh.vertices[profileBVHData2.verA];
|
||||
Vector3 val2 = bvh.vertices[profileBVHData2.verB];
|
||||
Vector3 val3 = bvh.vertices[profileBVHData2.verC];
|
||||
if (flag)
|
||||
{
|
||||
bounds = new Bounds(val, Vector3.zero);
|
||||
bounds.Encapsulate(val2);
|
||||
bounds.Encapsulate(val3);
|
||||
flag = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
bounds.Encapsulate(val);
|
||||
bounds.Encapsulate(val2);
|
||||
bounds.Encapsulate(val3);
|
||||
}
|
||||
}
|
||||
profileBVHNode2.bounds = bounds;
|
||||
if (count <= 4)
|
||||
{
|
||||
profileBVHNode2.isLeaf = true;
|
||||
profileBVHNode2.start = start;
|
||||
profileBVHNode2.count = count;
|
||||
profileBVHNode2.leftChild = -1;
|
||||
profileBVHNode2.rightChild = -1;
|
||||
outNodes.Add(profileBVHNode2);
|
||||
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++)
|
||||
{
|
||||
profileBVHData profileBVHData3 = bvh.datas[triIndices[j]];
|
||||
Vector3 val4 = bvh.vertices[profileBVHData3.verA];
|
||||
Vector3 val5 = bvh.vertices[profileBVHData3.verB];
|
||||
Vector3 val6 = bvh.vertices[profileBVHData3.verC];
|
||||
Vector3 val7 = (val4 + val5 + val6) / 3f;
|
||||
num2 += val7[num];
|
||||
}
|
||||
num2 /= (float)count;
|
||||
int num3 = this.Partition(bvh, triIndices, start, count, num, num2);
|
||||
if (num3 == start || num3 == start + count)
|
||||
{
|
||||
num3 = start + count / 2;
|
||||
}
|
||||
profileBVHNode2.isLeaf = false;
|
||||
profileBVHNode2.start = -1;
|
||||
profileBVHNode2.count = 0;
|
||||
outNodes.Add(profileBVHNode2);
|
||||
int leftChild = this.BuildRecursive(bvh, triIndices, start, num3 - start, outNodes);
|
||||
int rightChild = this.BuildRecursive(bvh, triIndices, num3, start + count - num3, outNodes);
|
||||
profileBVHNode2.leftChild = leftChild;
|
||||
profileBVHNode2.rightChild = rightChild;
|
||||
outNodes[count2] = profileBVHNode2;
|
||||
return count2;
|
||||
}
|
||||
|
||||
private int Partition(ProfileBVH bvh, int[] triIndices, int start, int count, int axis, float splitPos)
|
||||
{
|
||||
//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_0043: 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_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_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_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_008f: 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)
|
||||
int num = start;
|
||||
int num2 = start + count - 1;
|
||||
while (num <= num2)
|
||||
{
|
||||
profileBVHData profileBVHData2 = bvh.datas[triIndices[num]];
|
||||
profileBVHData profileBVHData3 = bvh.datas[triIndices[num2]];
|
||||
Vector3 val = bvh.vertices[profileBVHData2.verA];
|
||||
Vector3 val2 = bvh.vertices[profileBVHData2.verB];
|
||||
Vector3 val3 = bvh.vertices[profileBVHData2.verC];
|
||||
Vector3 val4 = bvh.vertices[profileBVHData3.verA];
|
||||
Vector3 val5 = bvh.vertices[profileBVHData3.verB];
|
||||
Vector3 val6 = bvh.vertices[profileBVHData3.verC];
|
||||
float num3 = (val[axis] + val2[axis] + val3[axis]) / 3f;
|
||||
_ = (val4[axis] + val5[axis] + val6[axis]) / 3f;
|
||||
if (num3 < splitPos)
|
||||
{
|
||||
num++;
|
||||
continue;
|
||||
}
|
||||
ref int reference = ref triIndices[num];
|
||||
ref int reference2 = ref triIndices[num2];
|
||||
int num4 = triIndices[num2];
|
||||
int num5 = triIndices[num];
|
||||
reference = num4;
|
||||
reference2 = num5;
|
||||
num2--;
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
public void SaveProfileBVH(ProfileBVH bvh, string savePath, string profileName)
|
||||
{
|
||||
//IL_009a: 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_0160: 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_01f8: Unknown result type (might be due to invalid IL or missing references)
|
||||
if (bvh == null || bvh.vertices == null || bvh.datas == null || bvh.nodes == null || bvh.dataIndices == null)
|
||||
{
|
||||
Debug.LogError((object)"[ProfileUtils_BVHUtil] SaveProfileBVH - bvh or fields are null");
|
||||
return;
|
||||
}
|
||||
ProfileUtils profileUtils = new ProfileUtils();
|
||||
int num = new System.Random().Next(int.MinValue, int.MaxValue);
|
||||
int count = bvh.vertices.Count;
|
||||
int version;
|
||||
int countInFile;
|
||||
BaseKey3[] array = new ProfileUtils_VertexUtil().LoadTable(profileUtils.GetBaseDataPath(), out version, out countInFile);
|
||||
if (array == null || array.Length == 0)
|
||||
{
|
||||
Debug.LogError((object)"[ProfileUtils_BVHUtil] SaveProfileBVH - failed to load base vertex table");
|
||||
return;
|
||||
}
|
||||
Vector3[] array2 = bvh.vertices.ToArray();
|
||||
for (int i = 0; i < array2.Length; i++)
|
||||
{
|
||||
array2[i] = this.TransformVec3(array2[i], array[i % array.Length]);
|
||||
}
|
||||
ProfileUtil_IndexUtil profileUtil_IndexUtil = new ProfileUtil_IndexUtil();
|
||||
profileUtil_IndexUtil.Build(num);
|
||||
Vector3[] array3 = (Vector3[])(object)new Vector3[array2.Length];
|
||||
profileUtil_IndexUtil.EncodeInto(array2, array3);
|
||||
StringBuilder stringBuilder = new StringBuilder(1024);
|
||||
stringBuilder.Append(profileUtils.GetProfileMagic());
|
||||
this.AppendHexInt(stringBuilder, profileUtils.GetProfileVersion());
|
||||
this.AppendHexInt(stringBuilder, num);
|
||||
this.AppendHexInt(stringBuilder, count);
|
||||
this.AppendHexInt(stringBuilder, bvh.datas.Length);
|
||||
this.AppendHexInt(stringBuilder, bvh.nodes.Length);
|
||||
this.AppendHexInt(stringBuilder, bvh.dataIndices.Length);
|
||||
for (int j = 0; j < array3.Length; j++)
|
||||
{
|
||||
this.AppendHexVec3(stringBuilder, array3[j]);
|
||||
}
|
||||
for (int k = 0; k < bvh.datas.Length; k++)
|
||||
{
|
||||
profileBVHData profileBVHData2 = bvh.datas[k];
|
||||
this.AppendHexInt(stringBuilder, profileBVHData2.verA);
|
||||
this.AppendHexInt(stringBuilder, profileBVHData2.verB);
|
||||
this.AppendHexInt(stringBuilder, profileBVHData2.verC);
|
||||
}
|
||||
for (int l = 0; l < bvh.nodes.Length; l++)
|
||||
{
|
||||
profileBVHNode profileBVHNode2 = bvh.nodes[l];
|
||||
this.AppendHexVec3(stringBuilder, profileBVHNode2.bounds.center);
|
||||
this.AppendHexVec3(stringBuilder, profileBVHNode2.bounds.extents);
|
||||
this.AppendHexInt(stringBuilder, profileBVHNode2.leftChild);
|
||||
this.AppendHexInt(stringBuilder, profileBVHNode2.rightChild);
|
||||
this.AppendHexInt(stringBuilder, profileBVHNode2.start);
|
||||
this.AppendHexInt(stringBuilder, profileBVHNode2.count);
|
||||
stringBuilder.Append(profileBVHNode2.isLeaf ? '1' : '0');
|
||||
}
|
||||
for (int m = 0; m < bvh.dataIndices.Length; m++)
|
||||
{
|
||||
this.AppendHexInt(stringBuilder, bvh.dataIndices[m]);
|
||||
}
|
||||
string path = (profileName.EndsWith(".eb") ? profileName : (profileName + ".eb"));
|
||||
string text = Path.Combine(Application.dataPath, savePath ?? string.Empty);
|
||||
if (!Directory.Exists(text))
|
||||
{
|
||||
Directory.CreateDirectory(text);
|
||||
}
|
||||
File.WriteAllText(Path.Combine(text, path), stringBuilder.ToString(), Encoding.UTF8);
|
||||
}
|
||||
|
||||
private void AppendHexVec3(StringBuilder sb, Vector3 v)
|
||||
{
|
||||
//IL_0002: 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_001c: Unknown result type (might be due to invalid IL or missing references)
|
||||
this.AppendHexFloat(sb, v.x);
|
||||
this.AppendHexFloat(sb, v.y);
|
||||
this.AppendHexFloat(sb, v.z);
|
||||
}
|
||||
|
||||
private void AppendHexFloat(StringBuilder sb, float v)
|
||||
{
|
||||
int num = BitConverter.SingleToInt32Bits(v);
|
||||
uint num2 = (uint)num;
|
||||
sb.Append(num2.ToString("X8"));
|
||||
}
|
||||
|
||||
private void AppendHexInt(StringBuilder sb, int v)
|
||||
{
|
||||
uint num = (uint)v;
|
||||
sb.Append(num.ToString("X8"));
|
||||
}
|
||||
|
||||
private Vector3 TransformVec3(Vector3 v, BaseKey3 k)
|
||||
{
|
||||
//IL_0001: 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_0025: 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);
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c2016668835db4f418cb2b3ef14bd00e
|
||||
@@ -1,403 +0,0 @@
|
||||
// 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.
|
||||
// EdenAutoMorpher_ProfileSaver_Script, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||
// Eden.AutoMorpher.profile.ProfileUtils_BoneUtil
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
public class ProfileUtils_BoneUtil
|
||||
{
|
||||
public HashSet<Transform> GetBodyMeshBones(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.LogError("[ProfileUtils_BoneUtil] SkinnedMeshRenderer에 연결된 Mesh가 없습니다.");
|
||||
return new HashSet<Transform>();
|
||||
}
|
||||
Transform[] bones = smr.bones;
|
||||
BoneWeight[] boneWeights = sharedMesh.boneWeights;
|
||||
HashSet<int> hashSet = new HashSet<int>();
|
||||
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<Transform> hashSet2 = new HashSet<Transform>();
|
||||
foreach (int item in hashSet)
|
||||
{
|
||||
if (item >= 0 && item < bones.Length)
|
||||
{
|
||||
hashSet2.Add(bones[item]);
|
||||
}
|
||||
}
|
||||
return hashSet2;
|
||||
}
|
||||
|
||||
public Dictionary<HumanBodyBones, HashSet<Transform>> GetHumanoidMeshBoneMap(Animator animator, IReadOnlyList<SkinnedMeshRenderer> bodyMeshes, float posTolerance = 0.0001f, float weightThreshold = 0.0001f)
|
||||
{
|
||||
//IL_009f: 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_0106: Unknown result type (might be due to invalid IL or missing references)
|
||||
Dictionary<HumanBodyBones, HashSet<Transform>> dictionary = new Dictionary<HumanBodyBones, HashSet<Transform>>();
|
||||
if (animator == null)
|
||||
{
|
||||
Debug.LogError("[MeshHumanoidBoneMatcher] Animator is Empty");
|
||||
return dictionary;
|
||||
}
|
||||
HashSet<Transform> hashSet = new HashSet<Transform>();
|
||||
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<Transform> hashSet2 = new HashSet<Transform>();
|
||||
hashSet2.Add(boneTransform);
|
||||
foreach (Transform item in this.FindBonesByPosition(boneTransform, hashSet, posTolerance))
|
||||
{
|
||||
hashSet2.Add(item);
|
||||
}
|
||||
dictionary[val] = hashSet2;
|
||||
}
|
||||
return dictionary;
|
||||
}
|
||||
|
||||
public HashSet<Transform> 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.LogError((object)"SkinnedMeshRenderer에 연결된 Mesh가 없습니다.");
|
||||
return new HashSet<Transform>();
|
||||
}
|
||||
Transform[] bones = smr.bones;
|
||||
BoneWeight[] boneWeights = sharedMesh.boneWeights;
|
||||
HashSet<int> hashSet = new HashSet<int>();
|
||||
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<Transform> hashSet2 = new HashSet<Transform>();
|
||||
foreach (int item in hashSet)
|
||||
{
|
||||
if (item >= 0 && item < bones.Length)
|
||||
{
|
||||
hashSet2.Add(bones[item]);
|
||||
}
|
||||
}
|
||||
return hashSet2;
|
||||
}
|
||||
|
||||
private List<Transform> FindBonesByPosition(Transform boneToCheck, HashSet<Transform> 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<Transform> list = new List<Transform>();
|
||||
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(item.gameObject.name, 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<string>();
|
||||
}
|
||||
char[] separator = new char[5] { '-', '_', ':', '.', '|' };
|
||||
name = name.Trim();
|
||||
return name.Split(separator, StringSplitOptions.RemoveEmptyEntries);
|
||||
}
|
||||
|
||||
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 List<BoneData> GetBoneDatas(Transform rootTransform, HashSet<Transform> avatarBones, Dictionary<HumanBodyBones, HashSet<Transform>> sourceBoneMap)
|
||||
{
|
||||
//IL_002f: 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_00f4: 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_0117: 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_0122: 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_006e: 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_01d7: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_01f8: 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)
|
||||
//IL_01e9: 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_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)
|
||||
//IL_022d: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0232: 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_0237: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_023b: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0240: 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_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_0267: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0274: 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_0288: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_028f: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_02f3: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_02f5: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_030d: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_030f: 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_0317: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_031d: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_031f: Unknown result type (might be due to invalid IL or missing references)
|
||||
Dictionary<Transform, HumanBodyBones> dictionary = new Dictionary<Transform, HumanBodyBones>();
|
||||
foreach (KeyValuePair<HumanBodyBones, HashSet<Transform>> item2 in sourceBoneMap)
|
||||
{
|
||||
HumanBodyBones key = item2.Key;
|
||||
HashSet<Transform> value = item2.Value;
|
||||
if (value == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
foreach (Transform item3 in value)
|
||||
{
|
||||
if (!(item3 == null) && !dictionary.ContainsKey(item3))
|
||||
{
|
||||
dictionary[item3] = key;
|
||||
}
|
||||
}
|
||||
}
|
||||
List<BoneData> list = new List<BoneData>();
|
||||
BoneData item = new BoneData
|
||||
{
|
||||
id = 0,
|
||||
boneName = rootTransform != null ? rootTransform.name : "Root",
|
||||
parentName = null,
|
||||
hierarchyPath = "",
|
||||
hBone = (HumanBodyBones)55,
|
||||
parentId = -1,
|
||||
childrenIds = new List<int>(),
|
||||
rootLocalPosition = Vector3.zero,
|
||||
rootLocalRotation = Quaternion.identity,
|
||||
rootLocalScale = Vector3.one
|
||||
};
|
||||
list.Add(item);
|
||||
List<Transform> list2 = (from t in avatarBones
|
||||
where t != null
|
||||
orderby this.GetDepthFromSkeletonRoot(rootTransform, t), this.GetHierarchyPath(rootTransform, t)
|
||||
select t).ToList();
|
||||
Dictionary<Transform, int> dictionary2 = new Dictionary<Transform, int>(list2.Count);
|
||||
int num = 1;
|
||||
foreach (Transform item4 in list2)
|
||||
{
|
||||
dictionary2[item4] = num++;
|
||||
string hierarchyPath = this.GetHierarchyPath(rootTransform, item4);
|
||||
HumanBodyBones value2;
|
||||
HumanBodyBones hBone = (HumanBodyBones)((!dictionary.TryGetValue(item4, out value2)) ? 55 : ((int)value2));
|
||||
Vector3 rootLocalPosition = (rootTransform != null) ? rootTransform.InverseTransformPoint(item4.position) : item4.position;
|
||||
Quaternion rootLocalRotation = (rootTransform != null) ? (Quaternion.Inverse(rootTransform.rotation) * item4.rotation) : item4.rotation;
|
||||
Vector3 lossyScale = item4.lossyScale;
|
||||
if (rootTransform != null)
|
||||
{
|
||||
Vector3 lossyScale2 = rootTransform.lossyScale;
|
||||
lossyScale = new Vector3(this.SafeDiv(lossyScale.x, lossyScale2.x), this.SafeDiv(lossyScale.y, lossyScale2.y), this.SafeDiv(lossyScale.z, lossyScale2.z));
|
||||
}
|
||||
list.Add(new BoneData
|
||||
{
|
||||
id = dictionary2[item4],
|
||||
boneName = item4.name,
|
||||
parentName = (item4.parent != null) ? (item4.parent).name : "",
|
||||
hierarchyPath = hierarchyPath,
|
||||
hBone = hBone,
|
||||
parentId = -1,
|
||||
childrenIds = new List<int>(),
|
||||
rootLocalPosition = rootLocalPosition,
|
||||
rootLocalRotation = rootLocalRotation,
|
||||
rootLocalScale = lossyScale
|
||||
});
|
||||
}
|
||||
Dictionary<int, List<int>> dictionary3 = new Dictionary<int, List<int>>();
|
||||
foreach (BoneData item5 in list)
|
||||
{
|
||||
dictionary3[item5.id] = new List<int>();
|
||||
}
|
||||
foreach (BoneData node in list.Where((BoneData n) => n.id != 0))
|
||||
{
|
||||
Transform key2 = dictionary2.FirstOrDefault((KeyValuePair<Transform, int> kv) => kv.Value == node.id).Key;
|
||||
int num2 = 0;
|
||||
if (key2 != null)
|
||||
{
|
||||
Transform parent = key2.parent;
|
||||
while (parent != null)
|
||||
{
|
||||
if (dictionary2.TryGetValue(parent, out var value3))
|
||||
{
|
||||
num2 = value3;
|
||||
break;
|
||||
}
|
||||
if (parent == rootTransform)
|
||||
{
|
||||
num2 = 0;
|
||||
break;
|
||||
}
|
||||
parent = parent.parent;
|
||||
}
|
||||
}
|
||||
node.parentId = num2;
|
||||
dictionary3[num2].Add(node.id);
|
||||
}
|
||||
foreach (BoneData item6 in list)
|
||||
{
|
||||
item6.childrenIds = dictionary3[item6.id];
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private float SafeDiv(float a, float b)
|
||||
{
|
||||
if (!(Mathf.Abs(b) < 1E-08f))
|
||||
{
|
||||
return a / b;
|
||||
}
|
||||
return 0f;
|
||||
}
|
||||
|
||||
private int GetDepthFromSkeletonRoot(Transform root, Transform t)
|
||||
{
|
||||
int num = 0;
|
||||
Transform val = t;
|
||||
while (val != null && val != root)
|
||||
{
|
||||
num++;
|
||||
val = val.parent;
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
private string GetHierarchyPath(Transform root, Transform t)
|
||||
{
|
||||
if (t == null)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
if (root == null)
|
||||
{
|
||||
return t.name;
|
||||
}
|
||||
if (!t.IsChildOf(root) && t != root)
|
||||
{
|
||||
Debug.LogError((object)("[ProfileUtils_BoneUtil] GetHierarchyPath - bone " + t.name + " is not child of root " + root.name));
|
||||
return "";
|
||||
}
|
||||
if (t == root)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
Stack<string> stack = new Stack<string>();
|
||||
Transform val = t;
|
||||
while (val != null && val != root)
|
||||
{
|
||||
stack.Push(val.name);
|
||||
val = val.parent;
|
||||
}
|
||||
return string.Join("/", stack);
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b987b9b34807b3b48b843afcb2aefa28
|
||||
@@ -1,212 +0,0 @@
|
||||
// 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.
|
||||
// EdenAutoMorpher_ProfileSaver_Script, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||
// Eden.AutoMorpher.profile.ProfileUtils_PCAUtil
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class ProfileUtils_PCAUtil
|
||||
{
|
||||
public PCAData ComputeRegionStats(IList<Vector3> points)
|
||||
{
|
||||
//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_0025: 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_002e: 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_003f: 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)
|
||||
//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_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_008a: 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_009d: 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_00b8: 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_00cc: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_00d9: 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_00ed: 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_017c: 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_01a0: 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_01a6: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_01ab: 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_0207: 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_020f: 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_01c9: 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_01d7: 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_01e3: 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)
|
||||
PCAData pCAData = new PCAData();
|
||||
if (points == null || points.Count == 0)
|
||||
{
|
||||
return pCAData;
|
||||
}
|
||||
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;
|
||||
}
|
||||
pCAData.pcaCenter = val;
|
||||
pCAData.pcaPrincipalAxis = normalized;
|
||||
pCAData.pcaLength = num10 - num9;
|
||||
pCAData.pcaAvgRadius = num11 / (float)count;
|
||||
return pCAData;
|
||||
}
|
||||
|
||||
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]);
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 404cff939caffe44bbb6cfbb33580445
|
||||
@@ -1,165 +0,0 @@
|
||||
// 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.
|
||||
// EdenAutoMorpher_ProfileSaver_Script, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||
// Eden.AutoMorpher.profile.ProfileUtils_PoseUtil
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
public class ProfileUtils_PoseUtil
|
||||
{
|
||||
public BoneSpatialData GetBoneSpatialData(HumanBodyBones refBone, HumanBodyBones[] influencedBones, Dictionary<HumanBodyBones, HashSet<Transform>> boneMap, List<ProfileBakedBodyMesh> sourceBodyBakedMeshes, bool addChildBones = false)
|
||||
{
|
||||
//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_000f: Unknown result type (might be due to invalid IL or missing references)
|
||||
BoneSpatialData boneSpatialData = new BoneSpatialData();
|
||||
boneSpatialData.refBone = refBone;
|
||||
Transform baseBoneFromBoneMap = this.GetBaseBoneFromBoneMap(boneMap, refBone);
|
||||
if ((Object)(object)baseBoneFromBoneMap == (Object)null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
List<Vector3> refVertices = this.GetRefVertices(influencedBones, boneMap, sourceBodyBakedMeshes, addChildBones);
|
||||
boneSpatialData.pcaData = this.GetPCAData(baseBoneFromBoneMap, refVertices);
|
||||
Transform baseBoneFromBoneMap2 = this.GetBaseBoneFromBoneMap(boneMap, (HumanBodyBones)0);
|
||||
boneSpatialData.volumeData = this.GetVolumeData(baseBoneFromBoneMap, baseBoneFromBoneMap2, refVertices);
|
||||
return boneSpatialData;
|
||||
}
|
||||
|
||||
private List<Vector3> GetRefVertices(HumanBodyBones[] influencedBones, Dictionary<HumanBodyBones, HashSet<Transform>> boneMap, List<ProfileBakedBodyMesh> sourceBodyBakedMeshes, bool addChildBones = false, float weightThreshold = 0.15f, int sampleStep = 1)
|
||||
{
|
||||
//IL_001b: 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_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_0212: Unknown result type (might be due to invalid IL or missing references)
|
||||
List<Vector3> list = new List<Vector3>();
|
||||
HashSet<Transform> targetBoneSet = new HashSet<Transform>();
|
||||
foreach (HumanBodyBones key in influencedBones)
|
||||
{
|
||||
if (!boneMap.TryGetValue(key, out var value) || value == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
foreach (Transform item in value)
|
||||
{
|
||||
if ((Object)(object)item != (Object)null)
|
||||
{
|
||||
targetBoneSet.Add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (targetBoneSet.Count == 0)
|
||||
{
|
||||
string text = string.Join(", ", influencedBones.Select((HumanBodyBones b) => b.ToString()));
|
||||
Debug.LogError((object)("[ProfileSaver_PoseUtil] CollectBodyPartVerticesWorld: targetBoneSet is empty.\nMissing Humanoid Set : " + text));
|
||||
return list;
|
||||
}
|
||||
if (addChildBones)
|
||||
{
|
||||
Transform[] array = targetBoneSet.ToArray();
|
||||
targetBoneSet.Clear();
|
||||
Transform[] array2 = array;
|
||||
for (int i = 0; i < array2.Length; i++)
|
||||
{
|
||||
AddDescendants(array2[i]);
|
||||
}
|
||||
}
|
||||
foreach (ProfileBakedBodyMesh sourceBodyBakedMesh in sourceBodyBakedMeshes)
|
||||
{
|
||||
BoneWeight[] boneWeights = sourceBodyBakedMesh.boneWeights;
|
||||
Transform[] bones = sourceBodyBakedMesh.bones;
|
||||
if (boneWeights == null || boneWeights.Length == 0 || bones == null || bones.Length == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
Vector3[] worldVertices = sourceBodyBakedMesh.worldVertices;
|
||||
if (worldVertices == null || worldVertices.Length == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
int num = Mathf.Min(worldVertices.Length, boneWeights.Length);
|
||||
for (int num2 = 0; num2 < num; num2 += sampleStep)
|
||||
{
|
||||
BoneWeight val = boneWeights[num2];
|
||||
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(worldVertices[num2]);
|
||||
}
|
||||
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;
|
||||
void AddDescendants(Transform t)
|
||||
{
|
||||
if (!((Object)(object)t == (Object)null) && targetBoneSet.Add(t))
|
||||
{
|
||||
for (int j = 0; j < t.childCount; j++)
|
||||
{
|
||||
AddDescendants(t.GetChild(j));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private PCAData GetPCAData(Transform originTransform, List<Vector3> points)
|
||||
{
|
||||
//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)
|
||||
//IL_0029: 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_0036: 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_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)
|
||||
PCAData pCAData = new ProfileUtils_PCAUtil().ComputeRegionStats(points);
|
||||
if ((Object)(object)originTransform == (Object)null)
|
||||
{
|
||||
return pCAData;
|
||||
}
|
||||
PCAData obj = new PCAData
|
||||
{
|
||||
pcaCenter = originTransform.InverseTransformPoint(pCAData.pcaCenter)
|
||||
};
|
||||
Vector3 val = originTransform.InverseTransformDirection(pCAData.pcaPrincipalAxis);
|
||||
obj.pcaPrincipalAxis = val.normalized;
|
||||
obj.pcaLength = pCAData.pcaLength;
|
||||
obj.pcaAvgRadius = pCAData.pcaAvgRadius;
|
||||
if (Mathf.Abs(pCAData.pcaLength) < 0.0001f)
|
||||
{
|
||||
Debug.LogWarning((object)("[ProfileUtils_PoseUtil] GetPCAData - " + ((Object)originTransform).name + " Pca Length is to Small"));
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
private VolumeData GetVolumeData(Transform originTransform, Transform axisTransform, List<Vector3> points)
|
||||
{
|
||||
return new ProfileUtils_VolumeUtil().GetVolumeData(originTransform, axisTransform, points);
|
||||
}
|
||||
|
||||
private Transform GetBaseBoneFromBoneMap(Dictionary<HumanBodyBones, HashSet<Transform>> 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();
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 094b9fc668fbf684aa9bd5db84b2aaad
|
||||
@@ -1,79 +0,0 @@
|
||||
// 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.
|
||||
// EdenAutoMorpher_ProfileSaver_Script, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||
// Eden.AutoMorpher.profile.ProfileUtils_VertexUtil
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
|
||||
public class ProfileUtils_VertexUtil
|
||||
{
|
||||
public BaseKey3[] LoadTable(string path, out int version, out int countInFile)
|
||||
{
|
||||
version = 0;
|
||||
countInFile = 0;
|
||||
if (string.IsNullOrEmpty(path))
|
||||
{
|
||||
Debug.LogError((object)"[ProfileUtil_VertexUtil] LoadTable - path is null or empty");
|
||||
return null;
|
||||
}
|
||||
path = Path.Combine(Application.dataPath, path);
|
||||
if (!File.Exists(path))
|
||||
{
|
||||
Debug.LogError((object)"[ProfileUtil_VertexUtil] LoadTable - file not found");
|
||||
return null;
|
||||
}
|
||||
string text;
|
||||
try
|
||||
{
|
||||
text = File.ReadAllText(path, Encoding.UTF8);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogError((object)("[ProfileUtil_VertexUtil] LoadTable - read failed: " + ex.Message));
|
||||
return null;
|
||||
}
|
||||
int num = 0;
|
||||
string baseMagic = new ProfileUtils().GetBaseMagic();
|
||||
if (text.Length < 4 || text.Substring(0, 4) != baseMagic)
|
||||
{
|
||||
Debug.LogError((object)"[ProfileUtil_VertexUtil] LoadTable - MAGIC mismatch");
|
||||
return null;
|
||||
}
|
||||
num += 4;
|
||||
version = this.ReadHexIntSafe(text, ref num);
|
||||
countInFile = this.ReadHexIntSafe(text, ref num);
|
||||
if (countInFile <= 0)
|
||||
{
|
||||
Debug.LogError((object)"[ProfileUtil_VertexUtil] LoadTable - invalid count");
|
||||
return null;
|
||||
}
|
||||
BaseKey3[] array = new BaseKey3[countInFile];
|
||||
for (int i = 0; i < countInFile; i++)
|
||||
{
|
||||
array[i] = this.ReadHexKey3Safe(text, ref num);
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
private int ReadHexIntSafe(string s, ref int p)
|
||||
{
|
||||
if (p + 8 > s.Length)
|
||||
{
|
||||
Debug.LogError((object)"[ProfileUtil_VertexUtil] ReadHexIntSafe - out of range");
|
||||
return 0;
|
||||
}
|
||||
string value = s.Substring(p, 8);
|
||||
p += 8;
|
||||
return (int)Convert.ToUInt32(value, 16);
|
||||
}
|
||||
|
||||
private BaseKey3 ReadHexKey3Safe(string s, ref int p)
|
||||
{
|
||||
int x = this.ReadHexIntSafe(s, ref p);
|
||||
uint y = (uint)this.ReadHexIntSafe(s, ref p);
|
||||
uint z = (uint)this.ReadHexIntSafe(s, ref p);
|
||||
return new BaseKey3((uint)x, y, z);
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 26eb8c4f9b6a08e4abb70a33d9b81ccf
|
||||
@@ -1,135 +0,0 @@
|
||||
// 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.
|
||||
// EdenAutoMorpher_ProfileSaver_Script, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||
// Eden.AutoMorpher.profile.ProfileUtils_VolumeUtil
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class ProfileUtils_VolumeUtil
|
||||
{
|
||||
public VolumeData GetVolumeData(Transform originTransform, Transform axisTransform, List<Vector3> points, int sampleStep = 1)
|
||||
{
|
||||
//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_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_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_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_0106: 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_010e: 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_0115: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_011d: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0122: 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_012a: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_012f: 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_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_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_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_015b: 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_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_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_017a: 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_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_01a1: 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_01ab: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_01b0: 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_01c0: 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_01ca: 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_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_00d8: Unknown result type (might be due to invalid IL or missing references)
|
||||
if ((Object)(object)originTransform == (Object)null)
|
||||
{
|
||||
Debug.LogError((object)"[ProfileUtils_VolumeUtil] originTransform is null");
|
||||
return null;
|
||||
}
|
||||
if ((Object)(object)axisTransform == (Object)null)
|
||||
{
|
||||
Debug.LogError((object)"[ProfileUtils_VolumeUtil] axisTransform is null");
|
||||
return null;
|
||||
}
|
||||
if (points == null || points.Count == 0)
|
||||
{
|
||||
Debug.LogError((object)"[ProfileUtils_VolumeUtil] There is No Points to calculate volume");
|
||||
return null;
|
||||
}
|
||||
VolumeData volumeData = new VolumeData();
|
||||
Vector3 forward = axisTransform.forward;
|
||||
Vector3 right = axisTransform.right;
|
||||
Vector3 up = axisTransform.up;
|
||||
float num = float.PositiveInfinity;
|
||||
float num2 = float.NegativeInfinity;
|
||||
float num3 = float.PositiveInfinity;
|
||||
float num4 = float.NegativeInfinity;
|
||||
float num5 = float.PositiveInfinity;
|
||||
float num6 = float.NegativeInfinity;
|
||||
for (int i = 0; i < points.Count; i += sampleStep)
|
||||
{
|
||||
Vector3 val = points[i] - originTransform.position;
|
||||
float num7 = Vector3.Dot(val, up);
|
||||
if (num7 < num)
|
||||
{
|
||||
num = num7;
|
||||
}
|
||||
if (num7 > num2)
|
||||
{
|
||||
num2 = num7;
|
||||
}
|
||||
float num8 = Vector3.Dot(val, forward);
|
||||
if (num8 < num3)
|
||||
{
|
||||
num3 = num8;
|
||||
}
|
||||
if (num8 > num4)
|
||||
{
|
||||
num4 = num8;
|
||||
}
|
||||
float num9 = Vector3.Dot(val, right);
|
||||
if (num9 < num5)
|
||||
{
|
||||
num5 = num9;
|
||||
}
|
||||
if (num9 > num6)
|
||||
{
|
||||
num6 = num9;
|
||||
}
|
||||
}
|
||||
volumeData.forwardDir = forward;
|
||||
volumeData.rightDir = right;
|
||||
volumeData.upDir = up;
|
||||
volumeData.fMaxLocalPos = originTransform.InverseTransformPoint(originTransform.position + forward * num4);
|
||||
volumeData.fMinLocalPos = originTransform.InverseTransformPoint(originTransform.position + forward * num3);
|
||||
volumeData.rMaxLocalPos = originTransform.InverseTransformPoint(originTransform.position + right * num6);
|
||||
volumeData.rMinLocalPos = originTransform.InverseTransformPoint(originTransform.position + right * num5);
|
||||
volumeData.uMaxLocalPos = originTransform.InverseTransformPoint(originTransform.position + up * num2);
|
||||
volumeData.uMinLocalPos = originTransform.InverseTransformPoint(originTransform.position + up * num);
|
||||
return volumeData;
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b1bc4188262eb1140b111907361dfc56
|
||||
@@ -1,28 +0,0 @@
|
||||
// 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.
|
||||
// EdenAutoMorpher_ProfileSaver_Script, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||
// Eden.AutoMorpher.profile.VolumeData
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
[Serializable]
|
||||
public class VolumeData
|
||||
{
|
||||
public Vector3 forwardDir;
|
||||
|
||||
public Vector3 rightDir;
|
||||
|
||||
public Vector3 upDir;
|
||||
|
||||
public Vector3 fMaxLocalPos;
|
||||
|
||||
public Vector3 fMinLocalPos;
|
||||
|
||||
public Vector3 rMaxLocalPos;
|
||||
|
||||
public Vector3 rMinLocalPos;
|
||||
|
||||
public Vector3 uMaxLocalPos;
|
||||
|
||||
public Vector3 uMinLocalPos;
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c9990806ed64171428cb56bac9d781fa
|
||||
@@ -1,12 +0,0 @@
|
||||
// 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.
|
||||
// EdenAutoMorpher_ProfileSaver_Script, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||
// Eden.AutoMorpher.profile.profileBVHData
|
||||
public class profileBVHData
|
||||
{
|
||||
public int verA;
|
||||
|
||||
public int verB;
|
||||
|
||||
public int verC;
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3e693ae64a726864a88a172c17d13af9
|
||||
@@ -1,20 +0,0 @@
|
||||
// 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.
|
||||
// EdenAutoMorpher_ProfileSaver_Script, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||
// Eden.AutoMorpher.profile.profileBVHNode
|
||||
using UnityEngine;
|
||||
|
||||
public class profileBVHNode
|
||||
{
|
||||
public Bounds bounds;
|
||||
|
||||
public int leftChild;
|
||||
|
||||
public int rightChild;
|
||||
|
||||
public int start;
|
||||
|
||||
public int count;
|
||||
|
||||
public bool isLeaf;
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d1647fc2736619c4fbf9804e952bf2c6
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: abb5e5470d1cf564b81643da236b85dc
|
||||
guid: c4603c2167fca184b81e3c38f3c116c0
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
|
||||
@@ -1,18 +1,34 @@
|
||||
// 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
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: Eden.AutoMorpher.AutoMorpherDev
|
||||
// Assembly: EdenAutoMorpherScript, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: D39968B3-E151-4276-BDB4-E82752BBAFF0
|
||||
// Assembly location: D:\dev\AutoMorpher\Assets\@Eden_Tools\Eden_AutoMorpher\Script\EdenAutoMorpherScript.dll
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Eden.AutoMorpher
|
||||
{
|
||||
public static class AutoMorpherDev
|
||||
{
|
||||
public static bool isDeveloperMode;
|
||||
|
||||
public static void Log(string message)
|
||||
{
|
||||
if (!AutoMorpherDev.isDeveloperMode)
|
||||
return;
|
||||
UnityEngine.Debug.Log((object)message);
|
||||
}
|
||||
|
||||
public static AutoMorpherDev.ScopeTimer Profile(string label)
|
||||
{
|
||||
return new AutoMorpherDev.ScopeTimer(AutoMorpherDev.isDeveloperMode, label);
|
||||
}
|
||||
|
||||
public readonly struct ScopeTimer : IDisposable
|
||||
{
|
||||
private readonly bool _enabled;
|
||||
|
||||
private readonly string _label;
|
||||
|
||||
private readonly Stopwatch _sw;
|
||||
|
||||
public ScopeTimer(bool enabled, string label)
|
||||
@@ -20,37 +36,18 @@ public static class AutoMorpherDev
|
||||
this._enabled = enabled;
|
||||
this._label = label;
|
||||
if (enabled)
|
||||
{
|
||||
this._sw = Stopwatch.StartNew();
|
||||
}
|
||||
else
|
||||
{
|
||||
this._sw = null;
|
||||
}
|
||||
this._sw = (Stopwatch)null;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (this._enabled && this._sw != null)
|
||||
{
|
||||
if (!this._enabled || this._sw == null)
|
||||
return;
|
||||
this._sw.Stop();
|
||||
UnityEngine.Debug.Log((object)$"[DevTimer] {this._label}: {this._sw.ElapsedMilliseconds} ms");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static bool isDeveloperMode;
|
||||
|
||||
public static void Log(string message)
|
||||
{
|
||||
if (isDeveloperMode)
|
||||
{
|
||||
UnityEngine.Debug.Log((object)message);
|
||||
}
|
||||
}
|
||||
|
||||
public static ScopeTimer Profile(string label)
|
||||
{
|
||||
return new ScopeTimer(isDeveloperMode, label);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 02c908beb489bb147953e501aad66b8a
|
||||
guid: 74e149c92cc858147bcd96dbf83bfce5
|
||||
@@ -1,9 +1,13 @@
|
||||
// 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
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: Eden.AutoMorpher.AutoMorpherException
|
||||
// Assembly: EdenAutoMorpherScript, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: D39968B3-E151-4276-BDB4-E82752BBAFF0
|
||||
// Assembly location: D:\dev\AutoMorpher\Assets\@Eden_Tools\Eden_AutoMorpher\Script\EdenAutoMorpherScript.dll
|
||||
|
||||
using System;
|
||||
|
||||
namespace Eden.AutoMorpher
|
||||
{
|
||||
public class AutoMorpherException : Exception
|
||||
{
|
||||
public string title;
|
||||
@@ -14,3 +18,4 @@ public class AutoMorpherException : Exception
|
||||
this.title = title;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 563e2675ec324394ea6a384adbe69d10
|
||||
guid: c3893985c83ce4847ba97b12c88c7792
|
||||
@@ -1,32 +1,32 @@
|
||||
// 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
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: Eden.AutoMorpher.BakedBodyMesh
|
||||
// Assembly: EdenAutoMorpherScript, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: D39968B3-E151-4276-BDB4-E82752BBAFF0
|
||||
// Assembly location: D:\dev\AutoMorpher\Assets\@Eden_Tools\Eden_AutoMorpher\Script\EdenAutoMorpherScript.dll
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace Eden.AutoMorpher
|
||||
{
|
||||
public class BakedBodyMesh
|
||||
{
|
||||
public SkinnedMeshRenderer smr;
|
||||
|
||||
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
|
||||
this.smr = _smr;
|
||||
this.bakedMesh = new Mesh();
|
||||
this.smr.BakeMesh(this.bakedMesh);
|
||||
}
|
||||
|
||||
public void ReBakeMesh()
|
||||
{
|
||||
this.smr.BakeMesh(this.bakedMesh);
|
||||
}
|
||||
public void ReBakeMesh() => this.smr.BakeMesh(this.bakedMesh);
|
||||
|
||||
~BakedBodyMesh()
|
||||
{
|
||||
this.smr = null;
|
||||
this.bakedMesh = null;
|
||||
this.smr = (SkinnedMeshRenderer)null;
|
||||
this.bakedMesh = (Mesh)null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b42afbd87f7e5804da861a01f62524d1
|
||||
guid: 83084f45d44ba1c4088b9c47d504847d
|
||||
@@ -1,235 +1,191 @@
|
||||
// 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
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: Eden.AutoMorpher.BodyPoseMatchSetupUtil
|
||||
// Assembly: EdenAutoMorpherScript, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: D39968B3-E151-4276-BDB4-E82752BBAFF0
|
||||
// Assembly location: D:\dev\AutoMorpher\Assets\@Eden_Tools\Eden_AutoMorpher\Script\EdenAutoMorpherScript.dll
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Eden.AutoMorpher
|
||||
{
|
||||
public class BodyPoseMatchSetupUtil
|
||||
{
|
||||
public void AdjustAvatarScaleByNeck(Transform avatarRoot, Dictionary<HumanBodyBones, HashSet<Transform>> humanBoneMap, float targetHeight)
|
||||
public void AdjustAvatarScaleByNeck(
|
||||
Transform avatarRoot,
|
||||
Dictionary<HumanBodyBones, HashSet<Transform>> 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)
|
||||
if (Object.op_Equality((Object)avatarRoot, (Object)null))
|
||||
{
|
||||
Debug.LogWarning((object)"[AvatarBodyMatchUtil] NormalizeAvatarScaleByNeck: avatar == null");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
Transform boneFromBoneMap = new BodyPoseMatch_CommonUtil().GetBoneFromBoneMap(humanBoneMap, (HumanBodyBones)9);
|
||||
if ((Object)(object)boneFromBoneMap == (Object)null)
|
||||
if (Object.op_Equality((Object)boneFromBoneMap, (Object)null))
|
||||
{
|
||||
Debug.LogWarning((object)("[AvatarBodyMatchUtil] " + ((Object)avatarRoot).name + " 에서 Neck 본을 찾지 못했습니다. 스케일 정규화를 건너뜁니다."));
|
||||
return;
|
||||
Debug.LogWarning((object)$"[AvatarBodyMatchUtil] {((Object)avatarRoot).name} 에서 Neck 본을 찾지 못했습니다. 스케일 정규화를 건너뜁니다.");
|
||||
}
|
||||
else
|
||||
{
|
||||
Transform transform = ((Component)avatarRoot).transform;
|
||||
float num = boneFromBoneMap.position.y - transform.position.y;
|
||||
if (Mathf.Approximately(num, 0f))
|
||||
float num1 = boneFromBoneMap.position.y - transform.position.y;
|
||||
if (Mathf.Approximately(num1, 0.0f))
|
||||
{
|
||||
Debug.LogWarning((object)$"[AvatarBodyMatchUtil] {((Object)avatarRoot).name} Neck Y가 0에 가까워 스케일 계산을 건너뜁니다. (neckY = {num})");
|
||||
return;
|
||||
Debug.LogWarning((object)$"[AvatarBodyMatchUtil] {((Object)avatarRoot).name} Neck Y가 0에 가까워 스케일 계산을 건너뜁니다. (neckY = {num1})");
|
||||
}
|
||||
else
|
||||
{
|
||||
float num2 = targetHeight / num1;
|
||||
Vector3 vector3 = Vector3.op_Multiply(transform.localScale, num2);
|
||||
transform.localScale = vector3;
|
||||
}
|
||||
}
|
||||
}
|
||||
float num2 = targetHeight / num;
|
||||
Vector3 localScale = transform.localScale;
|
||||
localScale *= num2;
|
||||
transform.localScale = localScale;
|
||||
}
|
||||
|
||||
public GameObject CreateBodyProxy(Animator sourceAvatar, IReadOnlyList<SkinnedMeshRenderer> sourceBodyMeshes, out List<SkinnedMeshRenderer> proxyBodyMeshes, out Dictionary<Transform, Transform> sourceToProxy)
|
||||
public GameObject CreateBodyProxy(
|
||||
Animator sourceAvatar,
|
||||
IReadOnlyList<SkinnedMeshRenderer> sourceBodyMeshes,
|
||||
out List<SkinnedMeshRenderer> proxyBodyMeshes,
|
||||
out Dictionary<Transform, Transform> 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)
|
||||
proxyBodyMeshes = (List<SkinnedMeshRenderer>)null;
|
||||
if (Object.op_Equality((Object)sourceAvatar, (Object)null))
|
||||
{
|
||||
Debug.LogError((object)"[AvatarBodyMatchUtil] CreateSourceBodyProxy: sourceAvatar == null");
|
||||
sourceToProxy = new Dictionary<Transform, Transform>();
|
||||
return null;
|
||||
return (GameObject)null;
|
||||
}
|
||||
GameObject clone = Object.Instantiate<GameObject>(((Component)sourceAvatar).gameObject);
|
||||
((Object)clone).name = ((Object)sourceAvatar).name + "_BodyProxy";
|
||||
HashSet<Transform> remainTransforms = new HashSet<Transform>();
|
||||
remainTransforms.Add(clone.transform);
|
||||
Animator component = clone.GetComponent<Animator>();
|
||||
if ((Object)(object)component != (Object)null)
|
||||
if (Object.op_Inequality((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)
|
||||
if (Object.op_Inequality((Object)component, (Object)null) && Object.op_Inequality((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)
|
||||
for (int index = 0; index < 55; ++index)
|
||||
{
|
||||
HumanBodyBones humanBodyBones = (HumanBodyBones)index;
|
||||
Transform boneTransform = component.GetBoneTransform(humanBodyBones);
|
||||
if (Object.op_Inequality((Object)boneTransform, (Object)null))
|
||||
remainTransforms.Add(boneTransform);
|
||||
}
|
||||
}
|
||||
}
|
||||
HashSet<Mesh> hashSet = new HashSet<Mesh>();
|
||||
HashSet<Mesh> meshSet = new HashSet<Mesh>();
|
||||
if (sourceBodyMeshes != null)
|
||||
{
|
||||
foreach (SkinnedMeshRenderer sourceBodyMesh in sourceBodyMeshes)
|
||||
foreach (SkinnedMeshRenderer sourceBodyMesh in (IEnumerable<SkinnedMeshRenderer>)sourceBodyMeshes)
|
||||
{
|
||||
if (!((Object)(object)sourceBodyMesh == (Object)null) && !((Object)(object)sourceBodyMesh.sharedMesh == (Object)null))
|
||||
{
|
||||
hashSet.Add(sourceBodyMesh.sharedMesh);
|
||||
if (!Object.op_Equality((Object)sourceBodyMesh, (Object)null) && !Object.op_Equality((Object)sourceBodyMesh.sharedMesh, (Object)null))
|
||||
meshSet.Add(sourceBodyMesh.sharedMesh);
|
||||
}
|
||||
}
|
||||
}
|
||||
SkinnedMeshRenderer[] componentsInChildren = clone.GetComponentsInChildren<SkinnedMeshRenderer>(true);
|
||||
List<SkinnedMeshRenderer> list = new List<SkinnedMeshRenderer>();
|
||||
SkinnedMeshRenderer[] array = componentsInChildren;
|
||||
foreach (SkinnedMeshRenderer val2 in array)
|
||||
SkinnedMeshRenderer[] componentsInChildren1 = clone.GetComponentsInChildren<SkinnedMeshRenderer>(true);
|
||||
List<SkinnedMeshRenderer> skinnedMeshRendererList = new List<SkinnedMeshRenderer>();
|
||||
foreach (SkinnedMeshRenderer skinnedMeshRenderer in componentsInChildren1)
|
||||
{
|
||||
if (!((Object)(object)val2 == (Object)null))
|
||||
if (!Object.op_Equality((Object)skinnedMeshRenderer, (Object)null))
|
||||
{
|
||||
Mesh sharedMesh = val2.sharedMesh;
|
||||
if (!((Object)(object)sharedMesh == (Object)null) && hashSet.Contains(sharedMesh))
|
||||
{
|
||||
list.Add(val2);
|
||||
Mesh sharedMesh = skinnedMeshRenderer.sharedMesh;
|
||||
if (!Object.op_Equality((Object)sharedMesh, (Object)null) && meshSet.Contains(sharedMesh))
|
||||
skinnedMeshRendererList.Add(skinnedMeshRenderer);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (list.Count == 0)
|
||||
{
|
||||
if (skinnedMeshRendererList.Count == 0)
|
||||
Debug.LogWarning((object)"[AvatarBodyMatchUtil] CreateSourceBodyProxy: clone에서 동일 sharedMesh를 가진 BodyMesh를 찾지 못했습니다.");
|
||||
}
|
||||
if (list.Count > 0)
|
||||
if (skinnedMeshRendererList.Count > 0)
|
||||
{
|
||||
MeshClassifier meshClassifier = new MeshClassifier();
|
||||
foreach (SkinnedMeshRenderer item in list)
|
||||
foreach (SkinnedMeshRenderer smr in skinnedMeshRendererList)
|
||||
{
|
||||
if ((Object)(object)item == (Object)null)
|
||||
if (!Object.op_Equality((Object)smr, (Object)null))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
remainTransforms.Add(((Component)item).transform);
|
||||
HashSet<Transform> activeBones = meshClassifier.GetActiveBones(item);
|
||||
remainTransforms.Add(((Component)smr).transform);
|
||||
HashSet<Transform> activeBones = meshClassifier.GetActiveBones(smr);
|
||||
if (activeBones == null)
|
||||
{
|
||||
string[] obj = new string[5]
|
||||
Debug.LogWarning((object)$"[AvatarBodyMatchUtil] CreateSourceBodyProxy: clone smr '{((Object)smr).name}' has null bones array (mesh='{((Object)smr.sharedMesh)?.name}')");
|
||||
}
|
||||
else
|
||||
{
|
||||
"[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)
|
||||
foreach (Transform transform in activeBones)
|
||||
{
|
||||
if (!((Object)(object)item2 == (Object)null))
|
||||
{
|
||||
remainTransforms.Add(item2);
|
||||
if (!Object.op_Equality((Object)transform, (Object)null))
|
||||
remainTransforms.Add(transform);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach (Transform item3 in remainTransforms.ToList())
|
||||
{
|
||||
AddWithParents(item3);
|
||||
}
|
||||
foreach (Transform t in remainTransforms.ToList<Transform>())
|
||||
AddWithParents(t);
|
||||
Transform[] componentsInChildren2 = clone.GetComponentsInChildren<Transform>(true);
|
||||
for (int num = componentsInChildren2.Length - 1; num >= 0; num--)
|
||||
for (int index = componentsInChildren2.Length - 1; index >= 0; --index)
|
||||
{
|
||||
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);
|
||||
Transform transform = componentsInChildren2[index];
|
||||
if (!Object.op_Equality((Object)transform, (Object)null) && !Object.op_Equality((Object)transform, (Object)clone.transform) && !remainTransforms.Contains(transform))
|
||||
Object.DestroyImmediate((Object)((Component)transform).gameObject);
|
||||
}
|
||||
}
|
||||
proxyBodyMeshes = list;
|
||||
proxyBodyMeshes = skinnedMeshRendererList;
|
||||
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)
|
||||
{
|
||||
for (; Object.op_Inequality((Object)t, (Object)null) && Object.op_Inequality((Object)t, (Object)clone.transform); t = t.parent)
|
||||
remainTransforms.Add(t);
|
||||
t = t.parent;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Vector3 GetComprehensiveScale(Transform rootT, Dictionary<HumanBodyBones, HashSet<Transform>> 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)
|
||||
public Vector3 GetComprehensiveScale(
|
||||
Transform rootT,
|
||||
Dictionary<HumanBodyBones, HashSet<Transform>> clothHumanoidBoneMap,
|
||||
ProfileData profileData)
|
||||
{
|
||||
if (Object.op_Equality((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)
|
||||
Transform transform1 = (Transform)null;
|
||||
HashSet<Transform> transformSet;
|
||||
if (clothHumanoidBoneMap.TryGetValue((HumanBodyBones)0, out transformSet) && transformSet != null && transformSet.Count > 0)
|
||||
{
|
||||
foreach (Transform item in value)
|
||||
foreach (Transform transform2 in transformSet)
|
||||
{
|
||||
if ((Object)(object)item != (Object)null)
|
||||
if (Object.op_Inequality((Object)transform2, (Object)null))
|
||||
{
|
||||
val = item;
|
||||
transform1 = transform2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((Object)(object)val == (Object)null)
|
||||
{
|
||||
if (Object.op_Equality((Object)transform1, (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 boneData = (BoneData)null;
|
||||
for (int index = 0; index < profileData.bones.Count; ++index)
|
||||
{
|
||||
BoneData val3 = profileData.bones[i];
|
||||
if (val3 != null && (int)val3.hBone == 0)
|
||||
BoneData bone = profileData.bones[index];
|
||||
if (bone != null && bone.hBone == null)
|
||||
{
|
||||
val2 = val3;
|
||||
boneData = bone;
|
||||
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);
|
||||
Vector3 vector3_1 = boneData != null ? boneData.rootLocalScale : throw new AutoMorpherException("Hip Bone Data is Missing in Profile", "[BodyPoseMatch_CommonUtil] GetComprehensiveScale\n - profileData bones does not contain Hips");
|
||||
Vector3 lossyScale1 = rootT.lossyScale;
|
||||
Vector3 lossyScale2 = transform1.lossyScale;
|
||||
Vector3 vector3_2;
|
||||
// ISSUE: explicit constructor call
|
||||
((Vector3)ref vector3_2).\u002Ector(lossyScale2.x / lossyScale1.x, lossyScale2.y / lossyScale1.y, lossyScale2.z / lossyScale1.z);
|
||||
return new Vector3(vector3_2.x / vector3_1.x, vector3_2.y / vector3_1.y, vector3_2.z / vector3_1.z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b0c593c395e8c7540bbabeda94629b05
|
||||
guid: feba191d9b996fb4f92fb50b0bdc9c66
|
||||
@@ -1,18 +1,19 @@
|
||||
// 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
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: Eden.AutoMorpher.BodyPoseMatchUtil
|
||||
// Assembly: EdenAutoMorpherScript, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: D39968B3-E151-4276-BDB4-E82752BBAFF0
|
||||
// Assembly location: D:\dev\AutoMorpher\Assets\@Eden_Tools\Eden_AutoMorpher\Script\EdenAutoMorpherScript.dll
|
||||
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Eden.AutoMorpher
|
||||
{
|
||||
public class BodyPoseMatchUtil
|
||||
{
|
||||
private WorldVertexUtil _worldVertexUtil;
|
||||
|
||||
private MeshClassifier meshClassifier;
|
||||
|
||||
private BodyPoseMatch_CommonUtil poseMatchCommonUtil;
|
||||
|
||||
private bool doDebug;
|
||||
|
||||
public BodyPoseMatchUtil()
|
||||
@@ -22,111 +23,85 @@ public class BodyPoseMatchUtil
|
||||
this.poseMatchCommonUtil = new BodyPoseMatch_CommonUtil();
|
||||
}
|
||||
|
||||
public GameObject AutoAdjustBodyPose(GameObject sourceAvatar, IReadOnlyList<SkinnedMeshRenderer> sourceBodyMeshes, GameObject targetAvatar, IReadOnlyList<SkinnedMeshRenderer> targetBodyMeshes, out Dictionary<Transform, Transform> sourceToProxy, float neckTargetHeight = 1.5f, bool onlyScaling = false)
|
||||
public GameObject AutoAdjustBodyPose(
|
||||
GameObject sourceAvatar,
|
||||
IReadOnlyList<SkinnedMeshRenderer> sourceBodyMeshes,
|
||||
GameObject targetAvatar,
|
||||
IReadOnlyList<SkinnedMeshRenderer> targetBodyMeshes,
|
||||
out Dictionary<Transform, Transform> 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>();
|
||||
Animator component1 = sourceAvatar.GetComponent<Animator>();
|
||||
Animator component2 = targetAvatar.GetComponent<Animator>();
|
||||
if ((Object)(object)component == (Object)null || (Object)(object)component2 == (Object)null)
|
||||
if (Object.op_Equality((Object)component1, (Object)null) || Object.op_Equality((Object)component2, (Object)null))
|
||||
{
|
||||
Debug.LogError((object)"[AvatarBodyMatchUtil] sourceAvatar 또는 targetAvatar가 null입니다.");
|
||||
sourceToProxy = new Dictionary<Transform, Transform>();
|
||||
return null;
|
||||
return (GameObject)null;
|
||||
}
|
||||
Dictionary<HumanBodyBones, HashSet<Transform>> humanBoneMap = this.meshClassifier.MeshHumanoidBoneMatcher(component, sourceBodyMeshes);
|
||||
Dictionary<HumanBodyBones, HashSet<Transform>> dictionary = this.meshClassifier.MeshHumanoidBoneMatcher(component2, targetBodyMeshes);
|
||||
BodyPoseMatchSetupUtil bodyPoseMatchSetupUtil = new BodyPoseMatchSetupUtil();
|
||||
bodyPoseMatchSetupUtil.AdjustAvatarScaleByNeck(sourceAvatar.transform, humanBoneMap, neckTargetHeight);
|
||||
bodyPoseMatchSetupUtil.AdjustAvatarScaleByNeck(targetAvatar.transform, dictionary, neckTargetHeight);
|
||||
Dictionary<HumanBodyBones, HashSet<Transform>> humanBoneMap = this.meshClassifier.MeshHumanoidBoneMatcher(component1, sourceBodyMeshes);
|
||||
Dictionary<HumanBodyBones, HashSet<Transform>> dictionary1 = this.meshClassifier.MeshHumanoidBoneMatcher(component2, targetBodyMeshes);
|
||||
BodyPoseMatchSetupUtil poseMatchSetupUtil = new BodyPoseMatchSetupUtil();
|
||||
poseMatchSetupUtil.AdjustAvatarScaleByNeck(sourceAvatar.transform, humanBoneMap, neckTargetHeight);
|
||||
poseMatchSetupUtil.AdjustAvatarScaleByNeck(targetAvatar.transform, dictionary1, neckTargetHeight);
|
||||
List<SkinnedMeshRenderer> proxyBodyMeshes;
|
||||
GameObject val = bodyPoseMatchSetupUtil.CreateBodyProxy(component, sourceBodyMeshes, out proxyBodyMeshes, out sourceToProxy);
|
||||
Animator component3 = val.GetComponent<Animator>();
|
||||
GameObject bodyProxy = poseMatchSetupUtil.CreateBodyProxy(component1, sourceBodyMeshes, out proxyBodyMeshes, out sourceToProxy);
|
||||
Animator component3 = bodyProxy.GetComponent<Animator>();
|
||||
if (onlyScaling)
|
||||
{
|
||||
val.transform.SetParent(targetAvatar.transform);
|
||||
val.transform.localPosition = Vector3.zero;
|
||||
return val;
|
||||
bodyProxy.transform.SetParent(targetAvatar.transform);
|
||||
bodyProxy.transform.localPosition = Vector3.zero;
|
||||
return bodyProxy;
|
||||
}
|
||||
Dictionary<HumanBodyBones, HashSet<Transform>> dictionary2 = this.meshClassifier.MeshHumanoidBoneMatcher(component3, proxyBodyMeshes);
|
||||
Dictionary<HumanBodyBones, HashSet<Transform>> dictionary2 = this.meshClassifier.MeshHumanoidBoneMatcher(component3, (IReadOnlyList<SkinnedMeshRenderer>)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<BakedBodyMesh> list = new List<BakedBodyMesh>();
|
||||
foreach (SkinnedMeshRenderer item in proxyBodyMeshes)
|
||||
{
|
||||
list.Add(new BakedBodyMesh(item));
|
||||
}
|
||||
List<BakedBodyMesh> list2 = new List<BakedBodyMesh>();
|
||||
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);
|
||||
bodyProxy.transform.SetParent(targetAvatar.transform);
|
||||
bodyProxy.transform.localPosition = Vector3.zero;
|
||||
List<BakedBodyMesh> bakedBodyMeshList1 = new List<BakedBodyMesh>();
|
||||
foreach (SkinnedMeshRenderer _smr in proxyBodyMeshes)
|
||||
bakedBodyMeshList1.Add(new BakedBodyMesh(_smr));
|
||||
List<BakedBodyMesh> bakedBodyMeshList2 = new List<BakedBodyMesh>();
|
||||
foreach (SkinnedMeshRenderer targetBodyMesh in (IEnumerable<SkinnedMeshRenderer>)targetBodyMeshes)
|
||||
bakedBodyMeshList2.Add(new BakedBodyMesh(targetBodyMesh));
|
||||
BodyPoseMatch_Torso bodyPoseMatchTorso = new BodyPoseMatch_Torso();
|
||||
bodyPoseMatchTorso.AlignTorsoByNeck(bodyProxy, (IReadOnlyList<BakedBodyMesh>)bakedBodyMeshList1, dictionary2, targetAvatar, (IReadOnlyList<BakedBodyMesh>)bakedBodyMeshList2, dictionary1);
|
||||
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);
|
||||
bodyPoseMatchTorso.DrawTorsoPcaDebug(bodyProxy, (IReadOnlyList<BakedBodyMesh>)bakedBodyMeshList1, dictionary2, Color.yellow, Color.cyan, duration: 20f);
|
||||
bodyPoseMatchTorso.DrawTorsoPcaDebug(targetAvatar, (IReadOnlyList<BakedBodyMesh>)bakedBodyMeshList2, dictionary1, Color.red, Color.green, duration: 20f);
|
||||
}
|
||||
foreach (BakedBodyMesh item2 in list)
|
||||
{
|
||||
item2.ReBakeMesh();
|
||||
}
|
||||
BodyPoseMatch_Arm bodyPoseMatch_Arm = new BodyPoseMatch_Arm();
|
||||
bodyPoseMatch_Arm.AlignUpperArmByArmPcaCenters(list, dictionary2, list2, dictionary);
|
||||
foreach (BakedBodyMesh bakedBodyMesh in bakedBodyMeshList1)
|
||||
bakedBodyMesh.ReBakeMesh();
|
||||
BodyPoseMatch_Arm bodyPoseMatchArm = new BodyPoseMatch_Arm();
|
||||
bodyPoseMatchArm.AlignUpperArmByArmPcaCenters((IReadOnlyList<BakedBodyMesh>)bakedBodyMeshList1, dictionary2, (IReadOnlyList<BakedBodyMesh>)bakedBodyMeshList2, dictionary1);
|
||||
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);
|
||||
bodyPoseMatchArm.DrawArmPcaDebug(bodyProxy, (IReadOnlyList<BakedBodyMesh>)bakedBodyMeshList1, dictionary2, true, Color.yellow, Color.cyan, duration: 20f);
|
||||
bodyPoseMatchArm.DrawArmPcaDebug(targetAvatar, (IReadOnlyList<BakedBodyMesh>)bakedBodyMeshList2, dictionary1, true, Color.red, Color.green, duration: 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);
|
||||
foreach (BakedBodyMesh bakedBodyMesh in bakedBodyMeshList1)
|
||||
bakedBodyMesh.ReBakeMesh();
|
||||
bodyPoseMatchArm.ScalingBothArmsLength((IReadOnlyList<BakedBodyMesh>)bakedBodyMeshList1, dictionary2, (IReadOnlyList<BakedBodyMesh>)bakedBodyMeshList2, dictionary1);
|
||||
foreach (BakedBodyMesh bakedBodyMesh in bakedBodyMeshList1)
|
||||
bakedBodyMesh.ReBakeMesh();
|
||||
BodyPoseMatch_Leg bodyPoseMatchLeg = new BodyPoseMatch_Leg();
|
||||
bodyPoseMatchLeg.AlignBothUpperLegs(bodyProxy, (IReadOnlyList<BakedBodyMesh>)bakedBodyMeshList1, dictionary2, targetAvatar, (IReadOnlyList<BakedBodyMesh>)bakedBodyMeshList2, dictionary1);
|
||||
foreach (BakedBodyMesh bakedBodyMesh in bakedBodyMeshList1)
|
||||
bakedBodyMesh.ReBakeMesh();
|
||||
bodyPoseMatchLeg.ScalingBothLegsAndFoots(bodyProxy, (IReadOnlyList<BakedBodyMesh>)bakedBodyMeshList1, dictionary2, targetAvatar, (IReadOnlyList<BakedBodyMesh>)bakedBodyMeshList2, dictionary1);
|
||||
if (this.doDebug)
|
||||
{
|
||||
foreach (BakedBodyMesh item6 in list)
|
||||
{
|
||||
item6.ReBakeMesh();
|
||||
foreach (BakedBodyMesh bakedBodyMesh in bakedBodyMeshList1)
|
||||
bakedBodyMesh.ReBakeMesh();
|
||||
bodyPoseMatchLeg.DrawLegPcaDebug(bodyProxy, (IReadOnlyList<BakedBodyMesh>)bakedBodyMeshList1, dictionary2, true, Color.yellow, Color.cyan, duration: 5f);
|
||||
bodyPoseMatchLeg.DrawLegPcaDebug(bodyProxy, (IReadOnlyList<BakedBodyMesh>)bakedBodyMeshList1, dictionary2, false, Color.yellow, Color.cyan, duration: 5f);
|
||||
bodyPoseMatchLeg.DrawLegPcaDebug(targetAvatar, (IReadOnlyList<BakedBodyMesh>)bakedBodyMeshList2, dictionary1, true, Color.magenta, Color.green, duration: 5f);
|
||||
bodyPoseMatchLeg.DrawLegPcaDebug(targetAvatar, (IReadOnlyList<BakedBodyMesh>)bakedBodyMeshList2, dictionary1, false, Color.magenta, Color.green, duration: 5f);
|
||||
bodyPoseMatchArm.DrawForearmExtremeDebugPair(bodyProxy.gameObject, (IReadOnlyList<SkinnedMeshRenderer>)proxyBodyMeshes, targetAvatar, targetBodyMeshes, true, 1f, 5f);
|
||||
}
|
||||
return bodyProxy;
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ad33ffa29854c5841ba95a68e56e6c51
|
||||
guid: a85962b0b9eb9ec4094079c0f62db81d
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,2 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 06c51e8c5c4e47242a901129c827880b
|
||||
guid: 5e4304e521b929546b171b5c3eedf84b
|
||||
@@ -1,266 +1,220 @@
|
||||
// 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
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: Eden.AutoMorpher.BodyPoseMatch_CommonUtil
|
||||
// Assembly: EdenAutoMorpherScript, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: D39968B3-E151-4276-BDB4-E82752BBAFF0
|
||||
// Assembly location: D:\dev\AutoMorpher\Assets\@Eden_Tools\Eden_AutoMorpher\Script\EdenAutoMorpherScript.dll
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Eden.AutoMorpher
|
||||
{
|
||||
public class BodyPoseMatch_CommonUtil
|
||||
{
|
||||
public Transform GetBoneFromBoneMap(Dictionary<HumanBodyBones, HashSet<Transform>> boneMap, HumanBodyBones bone)
|
||||
public Transform GetBoneFromBoneMap(
|
||||
Dictionary<HumanBodyBones, HashSet<Transform>> 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();
|
||||
HashSet<Transform> source;
|
||||
return boneMap == null || !boneMap.TryGetValue(bone, out source) || source == null ? (Transform)null : source.FirstOrDefault<Transform>();
|
||||
}
|
||||
|
||||
public Vector3 GetProfilePcaCenterWorld(Dictionary<HumanBodyBones, HashSet<Transform>> clothBoneMap, BoneSpatialData boneSpatialData, Vector3 comprehensiveScale, string errorContext = "")
|
||||
public Vector3 GetProfilePcaCenterWorld(
|
||||
Dictionary<HumanBodyBones, HashSet<Transform>> 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 + ")");
|
||||
}
|
||||
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 + ")");
|
||||
}
|
||||
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)
|
||||
{
|
||||
if (Object.op_Equality((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 + ")");
|
||||
}
|
||||
if (Object.op_Equality((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);
|
||||
Vector3 vector3;
|
||||
// ISSUE: explicit constructor call
|
||||
((Vector3)ref vector3).\u002Ector(pcaCenter.x / comprehensiveScale.x, pcaCenter.y / comprehensiveScale.y, pcaCenter.z / comprehensiveScale.z);
|
||||
return boneFromBoneMap.TransformPoint(vector3);
|
||||
}
|
||||
|
||||
public Vector3 GetProfileVolumeMinWorld(Dictionary<HumanBodyBones, HashSet<Transform>> clothBoneMap, BoneSpatialData spatialData, int axis, Vector3 comprehensiveScale)
|
||||
public Vector3 GetProfileVolumeMinWorld(
|
||||
Dictionary<HumanBodyBones, HashSet<Transform>> 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);
|
||||
return this.GetProfileVolumeWorld(clothBoneMap, spatialData, axis, comprehensiveScale, true);
|
||||
}
|
||||
|
||||
public Vector3 GetProfileVolumeMaxWorld(Dictionary<HumanBodyBones, HashSet<Transform>> clothBoneMap, BoneSpatialData spatialData, int axis, Vector3 comprehensiveScale)
|
||||
public Vector3 GetProfileVolumeMaxWorld(
|
||||
Dictionary<HumanBodyBones, HashSet<Transform>> 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);
|
||||
return this.GetProfileVolumeWorld(clothBoneMap, spatialData, axis, comprehensiveScale, false);
|
||||
}
|
||||
|
||||
public Vector3 GetProfileVolumeWorld(Dictionary<HumanBodyBones, HashSet<Transform>> clothBoneMap, BoneSpatialData spatialData, int axisIndex, Vector3 comprehensiveScale, bool isMin)
|
||||
public Vector3 GetProfileVolumeWorld(
|
||||
Dictionary<HumanBodyBones, HashSet<Transform>> 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)
|
||||
{
|
||||
if (Object.op_Equality((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;
|
||||
Vector3 vector3_1;
|
||||
switch (axisIndex)
|
||||
{
|
||||
case 0:
|
||||
val = (isMin ? spatialData.volumeData.fMinLocalPos : spatialData.volumeData.fMaxLocalPos);
|
||||
vector3_1 = isMin ? spatialData.volumeData.fMinLocalPos : spatialData.volumeData.fMaxLocalPos;
|
||||
break;
|
||||
case 1:
|
||||
val = (isMin ? spatialData.volumeData.rMinLocalPos : spatialData.volumeData.rMaxLocalPos);
|
||||
vector3_1 = isMin ? spatialData.volumeData.rMinLocalPos : spatialData.volumeData.rMaxLocalPos;
|
||||
break;
|
||||
case 2:
|
||||
val = (isMin ? spatialData.volumeData.uMinLocalPos : spatialData.volumeData.uMaxLocalPos);
|
||||
vector3_1 = 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);
|
||||
Vector3 vector3_2;
|
||||
// ISSUE: explicit constructor call
|
||||
((Vector3)ref vector3_2).\u002Ector(vector3_1.x / comprehensiveScale.x, vector3_1.y / comprehensiveScale.y, vector3_1.z / comprehensiveScale.z);
|
||||
return boneFromBoneMap.TransformPoint(vector3_2);
|
||||
}
|
||||
|
||||
public List<Vector3> CollectWeightedVerticesWorld(IReadOnlyList<BakedBodyMesh> bakedBodyMeshes, HashSet<Transform> targetBoneSet, float weightThreshold = 0.15f, int sampleStep = 1)
|
||||
public List<Vector3> CollectWeightedVerticesWorld(
|
||||
IReadOnlyList<BakedBodyMesh> bakedBodyMeshes,
|
||||
HashSet<Transform> 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<Vector3> list = new List<Vector3>();
|
||||
List<Vector3> vector3List = new List<Vector3>();
|
||||
if (bakedBodyMeshes == null || targetBoneSet == null || targetBoneSet.Count == 0)
|
||||
return vector3List;
|
||||
foreach (BakedBodyMesh bakedBodyMesh in (IEnumerable<BakedBodyMesh>)bakedBodyMeshes)
|
||||
{
|
||||
return list;
|
||||
}
|
||||
foreach (BakedBodyMesh bakedBodyMesh in bakedBodyMeshes)
|
||||
if (bakedBodyMesh != null && !Object.op_Equality((Object)bakedBodyMesh.smr, (Object)null))
|
||||
{
|
||||
if (bakedBodyMesh == null || (Object)(object)bakedBodyMesh.smr == (Object)null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
Mesh sharedMesh = bakedBodyMesh.smr.sharedMesh;
|
||||
if ((Object)(object)sharedMesh == (Object)null)
|
||||
if (!Object.op_Equality((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)
|
||||
if (boneWeights != null && boneWeights.Length != 0 && bones != null && bones.Length != 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
Vector3[] worldVerticesWithBakedMesh = new WorldVertexUtil().GetWorldVerticesWithBakedMesh(bakedBodyMesh.smr, bakedBodyMesh.bakedMesh);
|
||||
if (worldVerticesWithBakedMesh == null)
|
||||
Vector3[] verticesWithBakedMesh = new WorldVertexUtil().GetWorldVerticesWithBakedMesh(bakedBodyMesh.smr, bakedBodyMesh.bakedMesh);
|
||||
if (verticesWithBakedMesh != null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
int num = Mathf.Min(worldVerticesWithBakedMesh.Length, boneWeights.Length);
|
||||
for (int i = 0; i < num; i += sampleStep)
|
||||
int num = Mathf.Min(verticesWithBakedMesh.Length, boneWeights.Length);
|
||||
for (int index = 0; index < num; index += 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]);
|
||||
}
|
||||
BoneWeight boneWeight = boneWeights[index];
|
||||
float wSum = 0.0f;
|
||||
Acc(((BoneWeight)ref boneWeight).boneIndex0, ((BoneWeight)ref boneWeight).weight0);
|
||||
Acc(((BoneWeight)ref boneWeight).boneIndex1, ((BoneWeight)ref boneWeight).weight1);
|
||||
Acc(((BoneWeight)ref boneWeight).boneIndex2, ((BoneWeight)ref boneWeight).weight2);
|
||||
Acc(((BoneWeight)ref boneWeight).boneIndex3, ((BoneWeight)ref boneWeight).weight3);
|
||||
if ((double)wSum >= (double)weightThreshold)
|
||||
vector3List.Add(verticesWithBakedMesh[index]);
|
||||
|
||||
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))
|
||||
{
|
||||
if (index < 0 || index >= bones.Length || (double)w <= 0.0)
|
||||
return;
|
||||
Transform bone = bones[index];
|
||||
if (!Object.op_Inequality((Object)bone, (Object)null) || !targetBoneSet.Contains(bone))
|
||||
return;
|
||||
wSum += w;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
return vector3List;
|
||||
}
|
||||
|
||||
public List<Vector3> CollectHumanoidVerticesWorld(IReadOnlyList<HumanBodyBones> targetHumanBones, IReadOnlyList<BakedBodyMesh> bakedBodyMeshes, Dictionary<HumanBodyBones, HashSet<Transform>> boneMap, float weightThreshold = 0.15f, int sampleStep = 1)
|
||||
public List<Vector3> CollectHumanoidVerticesWorld(
|
||||
IReadOnlyList<HumanBodyBones> targetHumanBones,
|
||||
IReadOnlyList<BakedBodyMesh> bakedBodyMeshes,
|
||||
Dictionary<HumanBodyBones, HashSet<Transform>> 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<Vector3> result = new List<Vector3>();
|
||||
List<Vector3> vector3List = new List<Vector3>();
|
||||
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<Transform> hashSet = new HashSet<Transform>();
|
||||
foreach (HumanBodyBones targetHumanBone in targetHumanBones)
|
||||
HashSet<Transform> targetBoneSet = new HashSet<Transform>();
|
||||
foreach (HumanBodyBones targetHumanBone in (IEnumerable<HumanBodyBones>)targetHumanBones)
|
||||
{
|
||||
if (!boneMap.TryGetValue(targetHumanBone, out var value) || value == null)
|
||||
HashSet<Transform> transformSet;
|
||||
if (boneMap.TryGetValue(targetHumanBone, out transformSet) && transformSet != null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
foreach (Transform item in value)
|
||||
foreach (Transform transform in transformSet)
|
||||
{
|
||||
if ((Object)(object)item != (Object)null)
|
||||
{
|
||||
hashSet.Add(item);
|
||||
if (Object.op_Inequality((Object)transform, (Object)null))
|
||||
targetBoneSet.Add(transform);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (hashSet.Count == 0)
|
||||
{
|
||||
if (targetBoneSet.Count != 0)
|
||||
return this.CollectWeightedVerticesWorld(bakedBodyMeshes, targetBoneSet, weightThreshold, sampleStep);
|
||||
Debug.Log((object)"[AvatarBodyMatchUtil] CollectBodyPartVerticesWorld: targetBoneSet is empty.");
|
||||
return result;
|
||||
}
|
||||
return this.CollectWeightedVerticesWorld(bakedBodyMeshes, hashSet, weightThreshold, sampleStep);
|
||||
return vector3List;
|
||||
}
|
||||
|
||||
public void BoneLengthAdjust(Transform proxyParent, Transform proxyChild, Transform targetParent, Transform targetChild, HashSet<Transform> proxyParentSet, bool autoDetectAxis = true, int forceAxisIndex = 1)
|
||||
public void BoneLengthAdjust(
|
||||
Transform proxyParent,
|
||||
Transform proxyChild,
|
||||
Transform targetParent,
|
||||
Transform targetChild,
|
||||
HashSet<Transform> 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)
|
||||
if (Object.op_Equality((Object)proxyParent, (Object)null) || Object.op_Equality((Object)proxyChild, (Object)null) || Object.op_Equality((Object)targetParent, (Object)null) || Object.op_Equality((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);
|
||||
float num1 = Vector3.Distance(proxyParent.position, proxyChild.position);
|
||||
float num2 = Vector3.Distance(targetParent.position, targetChild.position);
|
||||
if ((double)num1 < 9.9999999747524271E-07 || (double)num2 < 9.9999999747524271E-07)
|
||||
{
|
||||
Debug.LogWarning((object)$"[AvatarBodyMatchUtil] MatchBoneSegmentLength: too small length. proxy={num1}, target={num2}");
|
||||
}
|
||||
else
|
||||
{
|
||||
float num3 = num2 / num1;
|
||||
int num4;
|
||||
if (autoDetectAxis)
|
||||
{
|
||||
Vector3 vector3_1 = Vector3.op_Subtraction(proxyChild.position, proxyParent.position);
|
||||
Vector3 vector3_2 = proxyParent.InverseTransformDirection(vector3_1);
|
||||
float num5 = Mathf.Abs(vector3_2.x);
|
||||
float num6 = Mathf.Abs(vector3_2.y);
|
||||
float num7 = Mathf.Abs(vector3_2.z);
|
||||
num4 = (double)num6 < (double)num5 || (double)num6 < (double)num7 ? ((double)num5 < (double)num7 ? 2 : 0) : 1;
|
||||
}
|
||||
else
|
||||
num4 = Mathf.Clamp(forceAxisIndex, 0, 2);
|
||||
Vector3 localScale = proxyParent.localScale;
|
||||
switch (num7)
|
||||
switch (num4)
|
||||
{
|
||||
case 0:
|
||||
localScale.x *= num3;
|
||||
@@ -272,26 +226,25 @@ public class BodyPoseMatch_CommonUtil
|
||||
localScale.z *= num3;
|
||||
break;
|
||||
}
|
||||
foreach (Transform item in proxyParentSet)
|
||||
{
|
||||
item.localScale = localScale;
|
||||
foreach (Transform proxyParent1 in proxyParentSet)
|
||||
proxyParent1.localScale = localScale;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Transform CreateTempMarker(string markerObjectName, Transform parentTransform, IReadOnlyList<Transform> 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)
|
||||
public Transform CreateTempMarker(
|
||||
string markerObjectName,
|
||||
Transform parentTransform,
|
||||
IReadOnlyList<Transform> childTransforms,
|
||||
Vector3 markerWorldPosition,
|
||||
Quaternion markerWorldRotation,
|
||||
Vector3 markerLocalScale,
|
||||
out TempBoneMarker tempBoneMarker)
|
||||
{
|
||||
if (Object.op_Equality((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;
|
||||
@@ -301,15 +254,16 @@ public class BodyPoseMatch_CommonUtil
|
||||
tempBoneMarker.originalParent = parentTransform;
|
||||
tempBoneMarker.additionalInfo = "";
|
||||
tempBoneMarker.wrappedChildNames = new List<string>();
|
||||
for (int i = 0; i < childTransforms.Count; i++)
|
||||
for (int index = 0; index < childTransforms.Count; ++index)
|
||||
{
|
||||
Transform val = childTransforms[i];
|
||||
if (!((Object)(object)val == (Object)null))
|
||||
Transform childTransform = childTransforms[index];
|
||||
if (!Object.op_Equality((Object)childTransform, (Object)null))
|
||||
{
|
||||
tempBoneMarker.wrappedChildNames.Add(((Object)val).name);
|
||||
val.SetParent(transform, true);
|
||||
tempBoneMarker.wrappedChildNames.Add(((Object)childTransform).name);
|
||||
childTransform.SetParent(transform, true);
|
||||
}
|
||||
}
|
||||
return transform;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 572f8fbf842bcaa45a437b3bf23c5542
|
||||
guid: e11035ab0ef1a734eae6c759861df3b3
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,2 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 017928fc2466b8148b073c3a55333355
|
||||
guid: 7326179703ed48e489335a16b7d53a33
|
||||
@@ -1,211 +1,158 @@
|
||||
// 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
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: Eden.AutoMorpher.BodyPoseMatch_Torso
|
||||
// Assembly: EdenAutoMorpherScript, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: D39968B3-E151-4276-BDB4-E82752BBAFF0
|
||||
// Assembly location: D:\dev\AutoMorpher\Assets\@Eden_Tools\Eden_AutoMorpher\Script\EdenAutoMorpherScript.dll
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Eden.AutoMorpher
|
||||
{
|
||||
public class BodyPoseMatch_Torso
|
||||
{
|
||||
private readonly BodyPoseMatch_CommonUtil poseMatchCommonUtil;
|
||||
|
||||
public BodyPoseMatch_Torso()
|
||||
{
|
||||
this.poseMatchCommonUtil = new BodyPoseMatch_CommonUtil();
|
||||
}
|
||||
public BodyPoseMatch_Torso() => this.poseMatchCommonUtil = new BodyPoseMatch_CommonUtil();
|
||||
|
||||
public void AlignTorsoByNeck(IReadOnlyCollection<Transform> 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)
|
||||
public void AlignTorsoByNeck(
|
||||
IReadOnlyCollection<Transform> sourceHipSet,
|
||||
Vector3 sourceNeckCenterWorld,
|
||||
Vector3 targetNeckCenterWorld)
|
||||
{
|
||||
Transform transform1 = sourceHipSet != null && sourceHipSet.Count != 0 ? sourceHipSet.FirstOrDefault<Transform>((Func<Transform, bool>)(t => Object.op_Inequality((Object)t, (Object)null))) : throw new AutoMorpherException("Source Hip Set is Missing", "[BodyPoseMatch_Torso] AlignTorsoByNeck\n - sourceHipSet is null or empty");
|
||||
if (Object.op_Equality((Object)transform1, (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)
|
||||
Vector3 vector3_1 = Vector3.op_Subtraction(targetNeckCenterWorld, sourceNeckCenterWorld);
|
||||
Vector3 forward = transform1.forward;
|
||||
Vector3 vector3_2 = forward;
|
||||
float num = Vector3.Dot(vector3_1, vector3_2);
|
||||
Vector3 vector3_3 = Vector3.op_Multiply(forward, num);
|
||||
foreach (Transform sourceHip in (IEnumerable<Transform>)sourceHipSet)
|
||||
{
|
||||
if (!((Object)(object)item == (Object)null))
|
||||
if (!Object.op_Equality((Object)sourceHip, (Object)null))
|
||||
{
|
||||
item.position += val3;
|
||||
Transform transform2 = sourceHip;
|
||||
transform2.position = Vector3.op_Addition(transform2.position, vector3_3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void AlignTorsoByNeck(GameObject proxyObject, IReadOnlyList<BakedBodyMesh> proxyBakedBodyMeshes, Dictionary<HumanBodyBones, HashSet<Transform>> proxyBoneMap, GameObject targetObject, IReadOnlyList<BakedBodyMesh> targetBakedBodyMeshes, Dictionary<HumanBodyBones, HashSet<Transform>> 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)
|
||||
public void AlignTorsoByNeck(
|
||||
GameObject proxyObject,
|
||||
IReadOnlyList<BakedBodyMesh> proxyBakedBodyMeshes,
|
||||
Dictionary<HumanBodyBones, HashSet<Transform>> proxyBoneMap,
|
||||
GameObject targetObject,
|
||||
IReadOnlyList<BakedBodyMesh> targetBakedBodyMeshes,
|
||||
Dictionary<HumanBodyBones, HashSet<Transform>> targetBoneMap)
|
||||
{
|
||||
if (Object.op_Equality((Object)proxyObject, (Object)null) || Object.op_Equality((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)
|
||||
RegionStats neckRegionStats1 = this.ComputeNeckRegionStats(proxyObject.transform, proxyBakedBodyMeshes, proxyBoneMap);
|
||||
RegionStats neckRegionStats2 = this.ComputeNeckRegionStats(targetObject.transform, targetBakedBodyMeshes, targetBoneMap);
|
||||
if ((double)neckRegionStats1.length < 9.9999997473787516E-05 || (double)neckRegionStats2.length < 9.9999997473787516E-05)
|
||||
{
|
||||
Debug.LogWarning((object)"[BodyPoseMatch_Torso] AlignTorsoByNeck: Neck PCA 통계가 비정상입니다.");
|
||||
return;
|
||||
}
|
||||
if (proxyBoneMap == null || !proxyBoneMap.TryGetValue((HumanBodyBones)0, out var value) || value == null || value.Count == 0)
|
||||
else
|
||||
{
|
||||
HashSet<Transform> sourceHipSet;
|
||||
if (proxyBoneMap == null || !proxyBoneMap.TryGetValue((HumanBodyBones)0, out sourceHipSet) || sourceHipSet == null || sourceHipSet.Count == 0)
|
||||
throw new AutoMorpherException("Proxy Hip Set is Missing", "[BodyPoseMatch_Torso] AlignTorsoByNeck\n - proxyBoneMap has no Hips bone set");
|
||||
this.AlignTorsoByNeck((IReadOnlyCollection<Transform>)sourceHipSet, neckRegionStats1.center, neckRegionStats2.center);
|
||||
}
|
||||
this.AlignTorsoByNeck(value, regionStats.center, regionStats2.center);
|
||||
}
|
||||
|
||||
public void AlignTorsoByNeck(Transform targetTransform, IReadOnlyList<BakedBodyMesh> targetBakedBodyMeshes, Dictionary<HumanBodyBones, HashSet<Transform>> targetBoneMap, Dictionary<HumanBodyBones, HashSet<Transform>> 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)
|
||||
public void AlignTorsoByNeck(
|
||||
Transform targetTransform,
|
||||
IReadOnlyList<BakedBodyMesh> targetBakedBodyMeshes,
|
||||
Dictionary<HumanBodyBones, HashSet<Transform>> targetBoneMap,
|
||||
Dictionary<HumanBodyBones, HashSet<Transform>> clothBoneMap,
|
||||
Transform clothesTransform,
|
||||
ProfileData profileData,
|
||||
Vector3 comprehensiveScale)
|
||||
{
|
||||
if (Object.op_Equality((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)
|
||||
RegionStats neckRegionStats = this.ComputeNeckRegionStats(targetTransform, targetBakedBodyMeshes, targetBoneMap);
|
||||
if ((double)neckRegionStats.length < 9.9999997473787516E-05)
|
||||
{
|
||||
Debug.LogWarning((object)"[BodyPoseMatch_Torso] AlignTorsoByNeck: Neck PCA 통계가 비정상입니다.");
|
||||
return;
|
||||
}
|
||||
if (clothBoneMap == null || !clothBoneMap.TryGetValue((HumanBodyBones)0, out var value) || value == null || value.Count == 0)
|
||||
else
|
||||
{
|
||||
HashSet<Transform> sourceHipSet;
|
||||
if (clothBoneMap == null || !clothBoneMap.TryGetValue((HumanBodyBones)0, out sourceHipSet) || sourceHipSet == null || sourceHipSet.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);
|
||||
this.AlignTorsoByNeck((IReadOnlyCollection<Transform>)sourceHipSet, profilePcaCenterWorld, neckRegionStats.center);
|
||||
}
|
||||
}
|
||||
|
||||
public RegionStats ComputeNeckRegionStats(Transform avatarTransform, IReadOnlyList<BakedBodyMesh> avatarBakedBodyMeshes, Dictionary<HumanBodyBones, HashSet<Transform>> avatarBoneMap)
|
||||
public RegionStats ComputeNeckRegionStats(
|
||||
Transform avatarTransform,
|
||||
IReadOnlyList<BakedBodyMesh> avatarBakedBodyMeshes,
|
||||
Dictionary<HumanBodyBones, HashSet<Transform>> 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<Vector3> list = this.poseMatchCommonUtil.CollectHumanoidVerticesWorld(targetHumanBones, avatarBakedBodyMeshes, avatarBoneMap);
|
||||
if (list == null || list.Count == 0)
|
||||
List<Vector3> points = this.poseMatchCommonUtil.CollectHumanoidVerticesWorld((IReadOnlyList<HumanBodyBones>)new HumanBodyBones[1]
|
||||
{
|
||||
Debug.LogWarning((object)("[AvatarBodyMatchUtil] ComputeNeckRegionStats: neck vertices 0개. avatar=" + ((avatarTransform != null) ? ((Object)avatarTransform).name : null)));
|
||||
return default(RegionStats);
|
||||
(HumanBodyBones) 9
|
||||
}, avatarBakedBodyMeshes, avatarBoneMap);
|
||||
if (points == null || points.Count == 0)
|
||||
{
|
||||
Debug.LogWarning((object)("[AvatarBodyMatchUtil] ComputeNeckRegionStats: neck vertices 0개. avatar=" + ((Object)avatarTransform)?.name));
|
||||
return new RegionStats();
|
||||
}
|
||||
RegionStats result = new PcaUtil().ComputeRegionStats(list);
|
||||
Vector3 val = avatarTransform.up;
|
||||
Transform boneFromBoneMap = this.poseMatchCommonUtil.GetBoneFromBoneMap(avatarBoneMap, (HumanBodyBones)10);
|
||||
RegionStats regionStats = new PcaUtil().ComputeRegionStats((IList<Vector3>)points);
|
||||
Vector3 vector3 = avatarTransform.up;
|
||||
Transform boneFromBoneMap1 = 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;
|
||||
Transform transform = Object.op_Inequality((Object)boneFromBoneMap2, (Object)null) ? boneFromBoneMap2 : boneFromBoneMap3;
|
||||
if (Object.op_Inequality((Object)boneFromBoneMap1, (Object)null) && Object.op_Inequality((Object)transform, (Object)null))
|
||||
vector3 = Vector3.op_Subtraction(boneFromBoneMap1.position, transform.position);
|
||||
else if (Object.op_Inequality((Object)boneFromBoneMap1, (Object)null) && Object.op_Inequality((Object)boneFromBoneMap4, (Object)null))
|
||||
vector3 = Vector3.op_Subtraction(boneFromBoneMap1.position, boneFromBoneMap4.position);
|
||||
if ((double)((Vector3)ref vector3).sqrMagnitude > 9.99999993922529E-09)
|
||||
((Vector3)ref vector3).Normalize();
|
||||
if ((double)Vector3.Dot(vector3, ((Component)avatarTransform).transform.up) < 0.0)
|
||||
vector3 = Vector3.op_UnaryNegation(vector3);
|
||||
regionStats.principalAxis = vector3;
|
||||
return regionStats;
|
||||
}
|
||||
|
||||
public void DrawTorsoPcaDebug(GameObject avatarObject, IReadOnlyList<BakedBodyMesh> avatarBakedBodyMeshes, Dictionary<HumanBodyBones, HashSet<Transform>> avatarBoneMap, Color centerColor, Color axisColor, float axisScale = 1f, float duration = 0.1f)
|
||||
public void DrawTorsoPcaDebug(
|
||||
GameObject avatarObject,
|
||||
IReadOnlyList<BakedBodyMesh> avatarBakedBodyMeshes,
|
||||
Dictionary<HumanBodyBones, HashSet<Transform>> 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}");
|
||||
if (Object.op_Equality((Object)avatarObject, (Object)null))
|
||||
return;
|
||||
RegionStats neckRegionStats = this.ComputeNeckRegionStats(avatarObject.transform, avatarBakedBodyMeshes, avatarBoneMap);
|
||||
if ((double)neckRegionStats.length < 9.9999997473787516E-05)
|
||||
{
|
||||
Debug.LogWarning((object)$"[AvatarBodyMatchUtil] DrawNeckPcaDebug: neck.length가 너무 작음. avatar={((Object)avatarObject).name}, length={neckRegionStats.length}");
|
||||
}
|
||||
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);
|
||||
else
|
||||
{
|
||||
Vector3 center = neckRegionStats.center;
|
||||
Vector3 normalized = ((Vector3)ref neckRegionStats.principalAxis).normalized;
|
||||
float num1 = 0.02f * axisScale;
|
||||
Debug.DrawLine(Vector3.op_Addition(center, Vector3.op_Multiply(Vector3.up, num1)), Vector3.op_Subtraction(center, Vector3.op_Multiply(Vector3.up, num1)), centerColor, duration);
|
||||
Debug.DrawLine(Vector3.op_Addition(center, Vector3.op_Multiply(Vector3.right, num1)), Vector3.op_Subtraction(center, Vector3.op_Multiply(Vector3.right, num1)), centerColor, duration);
|
||||
float num2 = neckRegionStats.length * 0.5f * axisScale;
|
||||
Debug.DrawLine(center, Vector3.op_Addition(center, Vector3.op_Multiply(normalized, num2)), axisColor, duration);
|
||||
Debug.Log((object)$"[AvatarBodyMatchUtil] DrawNeckPcaDebug: avatar={((Object)avatarObject).name}, center={center}, axis={normalized}, halfLen={num2}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d1a6c91cb56b3a34783a85387746e795
|
||||
guid: 7d84554c6dcbe7b42b908fabb48c3d66
|
||||
@@ -1,116 +1,83 @@
|
||||
// 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
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: Eden.AutoMorpher.BodyPoseToClothApplier
|
||||
// Assembly: EdenAutoMorpherScript, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: D39968B3-E151-4276-BDB4-E82752BBAFF0
|
||||
// Assembly location: D:\dev\AutoMorpher\Assets\@Eden_Tools\Eden_AutoMorpher\Script\EdenAutoMorpherScript.dll
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Eden.AutoMorpher
|
||||
{
|
||||
public class BodyPoseToClothApplier
|
||||
{
|
||||
private class BoneMapping
|
||||
{
|
||||
public Transform proxyBone;
|
||||
|
||||
public Transform clothBone;
|
||||
|
||||
public int depth;
|
||||
|
||||
public HumanBodyBones? humanBone;
|
||||
}
|
||||
|
||||
public void ApplyBodyPoseToClothes(Transform bodyProxyRoot, Transform clothesRoot, Dictionary<Transform, BoneMatchUtil.BoneRootLocalData> clothToBodyMatched, Dictionary<Transform, Transform> 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)
|
||||
public void ApplyBodyPoseToClothes(
|
||||
Transform bodyProxyRoot,
|
||||
Transform clothesRoot,
|
||||
Dictionary<Transform, BoneMatchUtil.BoneRootLocalData> clothToBodyMatched,
|
||||
Dictionary<Transform, Transform> sourceToProxy,
|
||||
bool copyPosition = true,
|
||||
bool copyRotation = false,
|
||||
bool copyScale = true)
|
||||
{
|
||||
if (Object.op_Equality((Object)bodyProxyRoot, (Object)null))
|
||||
throw new AutoMorpherException("Body Proxy Root is Missing", "[BodyToClothPoseApplier] ApplyDeformedProxyPoseToCloth\n - bodyProxyRoot is null");
|
||||
}
|
||||
if ((Object)(object)clothesRoot == (Object)null)
|
||||
{
|
||||
if (Object.op_Equality((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<Animator>();
|
||||
if ((Object)(object)component == (Object)null)
|
||||
Transform transform = !Object.op_Equality((Object)component, (Object)null) ? ((Component)component).transform : throw new AutoMorpherException("Body Proxy Animator is Missing", "[BodyToClothPoseApplier] ApplyDeformedProxyPoseToCloth\n - bodyProxyRoot has no Animator");
|
||||
Dictionary<Transform, int> proxyDepthMap = this.BuildDepthMap(transform);
|
||||
Dictionary<Transform, Transform> proxyToCloth = new Dictionary<Transform, Transform>();
|
||||
List<BodyPoseToClothApplier.BoneMapping> boneMappingList = new List<BodyPoseToClothApplier.BoneMapping>();
|
||||
HashSet<Transform> transformSet = new HashSet<Transform>();
|
||||
foreach (KeyValuePair<Transform, BoneMatchUtil.BoneRootLocalData> keyValuePair in clothToBodyMatched)
|
||||
{
|
||||
throw new AutoMorpherException("Body Proxy Animator is Missing", "[BodyToClothPoseApplier] ApplyDeformedProxyPoseToCloth\n - bodyProxyRoot has no Animator");
|
||||
}
|
||||
Transform transform = ((Component)component).transform;
|
||||
Dictionary<Transform, int> dictionary = this.BuildDepthMap(transform);
|
||||
Dictionary<Transform, Transform> dictionary2 = new Dictionary<Transform, Transform>();
|
||||
List<BoneMapping> list = new List<BoneMapping>();
|
||||
HashSet<Transform> hashSet = new HashSet<Transform>();
|
||||
foreach (KeyValuePair<Transform, BoneMatchUtil.BoneRootLocalData> item in clothToBodyMatched)
|
||||
Transform key1 = keyValuePair.Key;
|
||||
BoneMatchUtil.BoneRootLocalData boneRootLocalData = keyValuePair.Value;
|
||||
if (!Object.op_Equality((Object)key1, (Object)null) && boneRootLocalData != null)
|
||||
{
|
||||
Transform key = item.Key;
|
||||
BoneMatchUtil.BoneRootLocalData value = item.Value;
|
||||
if ((Object)(object)key == (Object)null || value == null)
|
||||
Transform t = boneRootLocalData.t;
|
||||
Transform key2;
|
||||
if (!Object.op_Equality((Object)t, (Object)null) && sourceToProxy.TryGetValue(t, out key2) && !Object.op_Equality((Object)key2, (Object)null))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
Transform t = value.t;
|
||||
if ((Object)(object)t == (Object)null || !sourceToProxy.TryGetValue(t, out var value2) || (Object)(object)value2 == (Object)null)
|
||||
HumanBodyBones hBone = boneRootLocalData.hBone;
|
||||
if (transformSet.Add(key1))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
HumanBodyBones hBone = value.hBone;
|
||||
if (hashSet.Add(key))
|
||||
int num1 = 999;
|
||||
int num2;
|
||||
if (proxyDepthMap != null && proxyDepthMap.TryGetValue(key2, out num2))
|
||||
num1 = num2;
|
||||
boneMappingList.Add(new BodyPoseToClothApplier.BoneMapping()
|
||||
{
|
||||
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))
|
||||
proxyBone = key2,
|
||||
clothBone = key1,
|
||||
depth = num1,
|
||||
humanBone = hBone != 55 ? new HumanBodyBones?(hBone) : new HumanBodyBones?()
|
||||
});
|
||||
}
|
||||
if (!dictionary2.ContainsKey(value2))
|
||||
{
|
||||
dictionary2.Add(value2, key);
|
||||
if (!proxyToCloth.ContainsKey(key2))
|
||||
proxyToCloth.Add(key2, key1);
|
||||
}
|
||||
}
|
||||
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())
|
||||
}
|
||||
this.MirrorBoneMarkers(transform, proxyToCloth, proxyDepthMap, boneMappingList);
|
||||
foreach (BodyPoseToClothApplier.BoneMapping boneMapping in boneMappingList.Where<BodyPoseToClothApplier.BoneMapping>((Func<BodyPoseToClothApplier.BoneMapping, bool>)(m => m != null && Object.op_Inequality((Object)m.proxyBone, (Object)null) && Object.op_Inequality((Object)m.clothBone, (Object)null))).OrderBy<BodyPoseToClothApplier.BoneMapping, int>((Func<BodyPoseToClothApplier.BoneMapping, int>)(m => m.depth)).ToList<BodyPoseToClothApplier.BoneMapping>())
|
||||
{
|
||||
if (!((Object)(object)item2.proxyBone == (Object)null) && !((Object)(object)item2.clothBone == (Object)null))
|
||||
if (!Object.op_Equality((Object)boneMapping.proxyBone, (Object)null) && !Object.op_Equality((Object)boneMapping.clothBone, (Object)null))
|
||||
{
|
||||
if (copyPosition)
|
||||
{
|
||||
item2.clothBone.position = item2.proxyBone.position;
|
||||
}
|
||||
boneMapping.clothBone.position = boneMapping.proxyBone.position;
|
||||
if (copyRotation)
|
||||
{
|
||||
item2.clothBone.rotation = item2.proxyBone.rotation;
|
||||
}
|
||||
boneMapping.clothBone.rotation = boneMapping.proxyBone.rotation;
|
||||
if (copyScale)
|
||||
{
|
||||
item2.clothBone.localScale = item2.proxyBone.localScale;
|
||||
}
|
||||
boneMapping.clothBone.localScale = boneMapping.proxyBone.localScale;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -118,147 +85,124 @@ public class BodyPoseToClothApplier
|
||||
private Dictionary<Transform, int> BuildDepthMap(Transform root)
|
||||
{
|
||||
Dictionary<Transform, int> dictionary = new Dictionary<Transform, int>();
|
||||
if ((Object)(object)root == (Object)null)
|
||||
{
|
||||
if (Object.op_Equality((Object)root, (Object)null))
|
||||
return dictionary;
|
||||
}
|
||||
Transform[] componentsInChildren = ((Component)root).GetComponentsInChildren<Transform>(true);
|
||||
foreach (Transform val in componentsInChildren)
|
||||
foreach (Transform componentsInChild in ((Component)root).GetComponentsInChildren<Transform>(true))
|
||||
{
|
||||
if (!((Object)(object)val == (Object)null))
|
||||
{
|
||||
dictionary[val] = this.GetDepthFromRoot(val, root);
|
||||
}
|
||||
if (!Object.op_Equality((Object)componentsInChild, (Object)null))
|
||||
dictionary[componentsInChild] = this.GetDepthFromRoot(componentsInChild, 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;
|
||||
int depthFromRoot = 0;
|
||||
for (Transform transform = t; Object.op_Inequality((Object)transform, (Object)null) && Object.op_Inequality((Object)transform, (Object)root); transform = transform.parent)
|
||||
++depthFromRoot;
|
||||
return depthFromRoot;
|
||||
}
|
||||
|
||||
private void MirrorBoneMarkers(Transform proxyArmature, Dictionary<Transform, Transform> proxyToCloth, Dictionary<Transform, int> proxyDepthMap, List<BoneMapping> 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)
|
||||
private void MirrorBoneMarkers(
|
||||
Transform proxyArmature,
|
||||
Dictionary<Transform, Transform> proxyToCloth,
|
||||
Dictionary<Transform, int> proxyDepthMap,
|
||||
List<BodyPoseToClothApplier.BoneMapping> mappings)
|
||||
{
|
||||
if (Object.op_Equality((Object)proxyArmature, (Object)null) || proxyToCloth == null || mappings == null)
|
||||
return;
|
||||
}
|
||||
TempBoneMarker[] componentsInChildren = ((Component)proxyArmature).GetComponentsInChildren<TempBoneMarker>(true);
|
||||
if (componentsInChildren == null || componentsInChildren.Length == 0)
|
||||
{
|
||||
return;
|
||||
HashSet<Transform> transformSet = new HashSet<Transform>();
|
||||
for (int index = 0; index < mappings.Count; ++index)
|
||||
{
|
||||
BodyPoseToClothApplier.BoneMapping mapping = mappings[index];
|
||||
if (mapping != null && Object.op_Inequality((Object)mapping.proxyBone, (Object)null))
|
||||
transformSet.Add(mapping.proxyBone);
|
||||
}
|
||||
HashSet<Transform> hashSet = new HashSet<Transform>();
|
||||
for (int i = 0; i < mappings.Count; i++)
|
||||
int num1;
|
||||
foreach (TempBoneMarker tempBoneMarker1 in ((IEnumerable<TempBoneMarker>)componentsInChildren).Where<TempBoneMarker>((Func<TempBoneMarker, bool>)(bm => Object.op_Inequality((Object)bm, (Object)null) && Object.op_Inequality((Object)((Component)bm).transform, (Object)null))).OrderBy<TempBoneMarker, int>((Func<TempBoneMarker, int>)(bm => proxyDepthMap != null && proxyDepthMap.TryGetValue(((Component)bm).transform, out num1) ? num1 : int.MaxValue)).ToList<TempBoneMarker>())
|
||||
{
|
||||
BoneMapping boneMapping = mappings[i];
|
||||
if (boneMapping != null && (Object)(object)boneMapping.proxyBone != (Object)null)
|
||||
Transform transform1 = ((Component)tempBoneMarker1).transform;
|
||||
if (!Object.op_Equality((Object)transform1, (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 originalParent = tempBoneMarker1.originalParent;
|
||||
Transform transform2;
|
||||
if (!Object.op_Equality((Object)originalParent, (Object)null) && proxyToCloth.TryGetValue(originalParent, out transform2) && !Object.op_Equality((Object)transform2, (Object)null))
|
||||
{
|
||||
Transform transform = ((Component)item).transform;
|
||||
if ((Object)(object)transform == (Object)null)
|
||||
List<Transform> transformList = this.CollectDirectChilds(transform2);
|
||||
Transform transform3 = this.FindMarkerInChild(transform2);
|
||||
TempBoneMarker tempBoneMarker2;
|
||||
if (Object.op_Equality((Object)transform3, (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<Transform> 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<TempBoneMarker>();
|
||||
transform3 = new GameObject(((Object)transform1).name).transform;
|
||||
transform3.SetParent(transform2, true);
|
||||
tempBoneMarker2 = ((Component)transform3).gameObject.AddComponent<TempBoneMarker>();
|
||||
}
|
||||
else
|
||||
tempBoneMarker2 = ((Component)transform3).GetComponent<TempBoneMarker>();
|
||||
transform3.position = transform1.position;
|
||||
transform3.rotation = transform1.rotation;
|
||||
transform3.localScale = transform1.localScale;
|
||||
tempBoneMarker2.originalParent = transform2;
|
||||
tempBoneMarker2.additionalInfo = tempBoneMarker1.additionalInfo;
|
||||
tempBoneMarker2.wrappedChildNames = tempBoneMarker1.wrappedChildNames;
|
||||
for (int index = 0; index < transformList.Count; ++index)
|
||||
{
|
||||
tempBoneMarker = ((Component)val).GetComponent<TempBoneMarker>();
|
||||
Transform transform4 = transformList[index];
|
||||
if (!Object.op_Equality((Object)transform4, (Object)null) && !Object.op_Equality((Object)transform4, (Object)transform3))
|
||||
transform4.SetParent(transform3, true);
|
||||
}
|
||||
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++)
|
||||
if (!proxyToCloth.ContainsKey(transform1))
|
||||
proxyToCloth.Add(transform1, transform3);
|
||||
if (transformSet.Add(transform1))
|
||||
{
|
||||
Transform val2 = list[num];
|
||||
if (!((Object)(object)val2 == (Object)null) && !((Object)(object)val2 == (Object)(object)val))
|
||||
int num2 = 999;
|
||||
int num3;
|
||||
if (proxyDepthMap != null && proxyDepthMap.TryGetValue(transform1, out num3))
|
||||
num2 = num3;
|
||||
mappings.Add(new BodyPoseToClothApplier.BoneMapping()
|
||||
{
|
||||
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
|
||||
proxyBone = transform1,
|
||||
clothBone = transform3,
|
||||
depth = num2,
|
||||
humanBone = new HumanBodyBones?()
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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<TempBoneMarker>() != (Object)null)
|
||||
if (Object.op_Equality((Object)parent, (Object)null))
|
||||
return (Transform)null;
|
||||
for (int index = 0; index < parent.childCount; ++index)
|
||||
{
|
||||
Transform child = parent.GetChild(index);
|
||||
if (!Object.op_Equality((Object)child, (Object)null) && Object.op_Inequality((Object)((Component)child).GetComponent<TempBoneMarker>(), (Object)null))
|
||||
return child;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return (Transform)null;
|
||||
}
|
||||
|
||||
private List<Transform> CollectDirectChilds(Transform parentTransform)
|
||||
{
|
||||
int childCount = parentTransform.childCount;
|
||||
List<Transform> list = new List<Transform>(childCount);
|
||||
for (int i = 0; i < childCount; i++)
|
||||
List<Transform> transformList = new List<Transform>(childCount);
|
||||
for (int index = 0; index < childCount; ++index)
|
||||
transformList.Add(parentTransform.GetChild(index));
|
||||
return transformList;
|
||||
}
|
||||
|
||||
private class BoneMapping
|
||||
{
|
||||
list.Add(parentTransform.GetChild(i));
|
||||
}
|
||||
return list;
|
||||
public Transform proxyBone;
|
||||
public Transform clothBone;
|
||||
public int depth;
|
||||
public HumanBodyBones? humanBone;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3fd7263ca727f7d4aaea10382583c7f2
|
||||
guid: 95106b6438eaf82418391056865c4a34
|
||||
@@ -1,38 +1,40 @@
|
||||
// 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
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: Eden.AutoMorpher.BoneAlignmentUtil
|
||||
// Assembly: EdenAutoMorpherScript, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: D39968B3-E151-4276-BDB4-E82752BBAFF0
|
||||
// Assembly location: D:\dev\AutoMorpher\Assets\@Eden_Tools\Eden_AutoMorpher\Script\EdenAutoMorpherScript.dll
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Eden.AutoMorpher
|
||||
{
|
||||
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)
|
||||
if (cloth == null || Object.op_Equality((Object)targetAvatarAnimator, (Object)null))
|
||||
{
|
||||
Debug.LogWarning((object)"[BoneAlignmentUtil] cloth 또는 targetAvatarAnimator 가 null.");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (KeyValuePair<HumanBodyBones, HashSet<Transform>> humanoidMatchedBone in cloth.humanoidMatchedBones)
|
||||
{
|
||||
HumanBodyBones key = humanoidMatchedBone.Key;
|
||||
foreach (Transform item in humanoidMatchedBone.Value)
|
||||
foreach (Transform transform in humanoidMatchedBone.Value)
|
||||
{
|
||||
if (!((Object)(object)item == (Object)null))
|
||||
if (!Object.op_Equality((Object)transform, (Object)null))
|
||||
{
|
||||
Transform boneTransform = targetAvatarAnimator.GetBoneTransform(key);
|
||||
if (!((Object)(object)boneTransform == (Object)null))
|
||||
if (!Object.op_Equality((Object)boneTransform, (Object)null))
|
||||
{
|
||||
item.position = boneTransform.position;
|
||||
item.localScale = Vector3.one;
|
||||
((Object)item).name = ((Object)boneTransform).name;
|
||||
transform.position = boneTransform.position;
|
||||
transform.localScale = Vector3.one;
|
||||
((Object)transform).name = ((Object)boneTransform).name;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -41,82 +43,62 @@ public class BoneAlignmentUtil
|
||||
|
||||
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)
|
||||
{
|
||||
if (config.clothBoneTypeMap == null || Object.op_Equality((Object)config.targetAvatarObject, (Object)null))
|
||||
return;
|
||||
}
|
||||
Animator component = config.targetAvatarObject.GetComponent<Animator>();
|
||||
if ((Object)(object)component == (Object)null || !component.isHuman)
|
||||
{
|
||||
if (Object.op_Equality((Object)component, (Object)null) || !component.isHuman)
|
||||
return;
|
||||
}
|
||||
Dictionary<Transform, Transform> dictionary = new Dictionary<Transform, Transform>();
|
||||
if (config.clothesHumanoidMatchedBones != null)
|
||||
{
|
||||
foreach (KeyValuePair<HumanBodyBones, HashSet<Transform>> clothesHumanoidMatchedBone in config.clothesHumanoidMatchedBones)
|
||||
foreach (KeyValuePair<HumanBodyBones, HashSet<Transform>> humanoidMatchedBone in config.clothesHumanoidMatchedBones)
|
||||
{
|
||||
HumanBodyBones key = clothesHumanoidMatchedBone.Key;
|
||||
foreach (Transform item2 in clothesHumanoidMatchedBone.Value)
|
||||
HumanBodyBones key1 = humanoidMatchedBone.Key;
|
||||
foreach (Transform key2 in humanoidMatchedBone.Value)
|
||||
{
|
||||
Transform boneTransform = component.GetBoneTransform(key);
|
||||
if ((Object)(object)item2 != (Object)null && (Object)(object)boneTransform != (Object)null)
|
||||
{
|
||||
dictionary[item2] = boneTransform;
|
||||
Transform boneTransform = component.GetBoneTransform(key1);
|
||||
if (Object.op_Inequality((Object)key2, (Object)null) && Object.op_Inequality((Object)boneTransform, (Object)null))
|
||||
dictionary[key2] = boneTransform;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach (KeyValuePair<Transform, ClothBoneType> item3 in config.clothBoneTypeMap)
|
||||
foreach (KeyValuePair<Transform, ClothBoneType> clothBoneType1 in config.clothBoneTypeMap)
|
||||
{
|
||||
if (item3.Value != ClothBoneType.Accessory)
|
||||
if (clothBoneType1.Value == ClothBoneType.Accessory)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
Transform key2 = item3.Key;
|
||||
if ((Object)(object)key2 == (Object)null || !key2.IsChildOf(config.targetClothesObject.transform))
|
||||
Transform key3 = clothBoneType1.Key;
|
||||
if (!Object.op_Equality((Object)key3, (Object)null) && key3.IsChildOf(config.targetClothesObject.transform))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
Transform parent = key2.parent;
|
||||
Transform val = null;
|
||||
while ((Object)(object)parent != (Object)null)
|
||||
Transform parent = key3.parent;
|
||||
Transform key4 = (Transform)null;
|
||||
for (; Object.op_Inequality((Object)parent, (Object)null); parent = parent.parent)
|
||||
{
|
||||
if (config.clothBoneTypeMap.TryGetValue(parent, out var value) && value == ClothBoneType.Body)
|
||||
ClothBoneType clothBoneType2;
|
||||
if (config.clothBoneTypeMap.TryGetValue(parent, out clothBoneType2) && clothBoneType2 == ClothBoneType.Body)
|
||||
{
|
||||
val = parent;
|
||||
key4 = parent;
|
||||
break;
|
||||
}
|
||||
parent = parent.parent;
|
||||
}
|
||||
if (!((Object)(object)val == (Object)null) && dictionary.TryGetValue(val, out var value2))
|
||||
{
|
||||
key2.SetParent(value2, true);
|
||||
Transform transform;
|
||||
if (!Object.op_Equality((Object)key4, (Object)null) && dictionary.TryGetValue(key4, out transform))
|
||||
key3.SetParent(transform, true);
|
||||
}
|
||||
}
|
||||
foreach (KeyValuePair<Transform, Transform> item4 in dictionary)
|
||||
{
|
||||
Transform key3 = item4.Key;
|
||||
Transform value3 = item4.Value;
|
||||
if ((Object)(object)key3 == (Object)null || (Object)(object)value3 == (Object)null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
List<Transform> list = new List<Transform>();
|
||||
foreach (Transform item5 in key3)
|
||||
foreach (KeyValuePair<Transform, Transform> keyValuePair in dictionary)
|
||||
{
|
||||
Transform item = item5;
|
||||
list.Add(item);
|
||||
}
|
||||
foreach (Transform item6 in list)
|
||||
Transform key5 = keyValuePair.Key;
|
||||
Transform transform1 = keyValuePair.Value;
|
||||
if (!Object.op_Equality((Object)key5, (Object)null) && !Object.op_Equality((Object)transform1, (Object)null))
|
||||
{
|
||||
if (!((Object)(object)item6 == (Object)null) && !config.clothBoneTypeMap.ContainsKey(item6))
|
||||
List<Transform> transformList = new List<Transform>();
|
||||
foreach (Transform transform2 in key5)
|
||||
transformList.Add(transform2);
|
||||
foreach (Transform key6 in transformList)
|
||||
{
|
||||
item6.SetParent(value3, true);
|
||||
if (!Object.op_Equality((Object)key6, (Object)null) && !config.clothBoneTypeMap.ContainsKey(key6))
|
||||
key6.SetParent(transform1, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -124,56 +106,38 @@ public class BoneAlignmentUtil
|
||||
|
||||
public void CleanupTempBones(Transform root)
|
||||
{
|
||||
if ((Object)(object)root == (Object)null)
|
||||
{
|
||||
if (Object.op_Equality((Object)root, (Object)null))
|
||||
return;
|
||||
}
|
||||
TempBoneMarker[] componentsInChildren = ((Component)root).GetComponentsInChildren<TempBoneMarker>(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)
|
||||
foreach (TempBoneMarker tempBoneMarker in ((IEnumerable<TempBoneMarker>)componentsInChildren).Where<TempBoneMarker>((Func<TempBoneMarker, bool>)(m => Object.op_Inequality((Object)m, (Object)null))).OrderByDescending<TempBoneMarker, int>((Func<TempBoneMarker, int>)(m => GetDepth(((Component)m).transform))).ToArray<TempBoneMarker>())
|
||||
{
|
||||
if ((Object)(object)tempBoneMarker == (Object)null)
|
||||
if (!Object.op_Equality((Object)tempBoneMarker, (Object)null))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
Transform transform = ((Component)tempBoneMarker).transform;
|
||||
Transform val = tempBoneMarker.originalParent;
|
||||
if ((Object)(object)val == (Object)null)
|
||||
Transform transform1 = ((Component)tempBoneMarker).transform;
|
||||
Transform transform2 = tempBoneMarker.originalParent;
|
||||
if (Object.op_Equality((Object)transform2, (Object)null))
|
||||
transform2 = transform1.parent;
|
||||
if (Object.op_Inequality((Object)transform2, (Object)null))
|
||||
{
|
||||
val = transform.parent;
|
||||
}
|
||||
if ((Object)(object)val != (Object)null)
|
||||
{
|
||||
while (transform.childCount > 0)
|
||||
{
|
||||
transform.GetChild(0).SetParent(val, true);
|
||||
}
|
||||
while (transform1.childCount > 0)
|
||||
transform1.GetChild(0).SetParent(transform2, true);
|
||||
}
|
||||
if (!Application.isPlaying)
|
||||
{
|
||||
Object.DestroyImmediate((Object)(object)((Component)transform).gameObject);
|
||||
}
|
||||
Object.DestroyImmediate((Object)((Component)transform1).gameObject);
|
||||
else
|
||||
Object.Destroy((Object)((Component)transform1).gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
static int GetDepth(Transform t)
|
||||
{
|
||||
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;
|
||||
int depth = 0;
|
||||
for (; Object.op_Inequality((Object)t, (Object)null); t = t.parent)
|
||||
++depth;
|
||||
return depth;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 43763a44e7c2a8e44a4fd8a6a6436db3
|
||||
guid: 51afb8fce54e96444b9da90ac17f1983
|
||||
@@ -1,195 +1,158 @@
|
||||
// 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
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: Eden.AutoMorpher.BoneCorrespondenceUtil
|
||||
// Assembly: EdenAutoMorpherScript, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: D39968B3-E151-4276-BDB4-E82752BBAFF0
|
||||
// Assembly location: D:\dev\AutoMorpher\Assets\@Eden_Tools\Eden_AutoMorpher\Script\EdenAutoMorpherScript.dll
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Eden.AutoMorpher
|
||||
{
|
||||
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)
|
||||
{
|
||||
if ((double)d < (double)near)
|
||||
return 120f;
|
||||
}
|
||||
if (d < mid)
|
||||
{
|
||||
if ((double)d < (double)mid)
|
||||
return 90f;
|
||||
}
|
||||
if (d < far)
|
||||
{
|
||||
return 50f;
|
||||
}
|
||||
return 0f;
|
||||
return (double)d < (double)far ? 50f : 0.0f;
|
||||
}
|
||||
|
||||
public float ComputeRotationScore(float ang, float RotTolDeg)
|
||||
{
|
||||
return Mathf.Clamp01(1f - ang / RotTolDeg);
|
||||
return Mathf.Clamp01((float)(1.0 - (double)ang / (double)RotTolDeg));
|
||||
}
|
||||
|
||||
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)
|
||||
public float ComputeNameScore(
|
||||
string bodyName,
|
||||
string bodyPath,
|
||||
string clothesName,
|
||||
string clothesPath)
|
||||
{
|
||||
string str1 = this.StripDigits(this.NormalizeName(bodyName));
|
||||
string str2 = this.StripDigits(this.NormalizeName(clothesName));
|
||||
string str3 = this.StripDigits(this.NormalizePath(bodyPath));
|
||||
string str4 = this.StripDigits(this.NormalizePath(clothesPath));
|
||||
if (!string.IsNullOrEmpty(str3) && str3 == str4)
|
||||
return 80f;
|
||||
}
|
||||
if (!string.IsNullOrEmpty(text) && text == text2)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(str1) && str1 == str2)
|
||||
return 70f;
|
||||
}
|
||||
if (!string.IsNullOrEmpty(text) && !string.IsNullOrEmpty(text2) && (text.Contains(text2) || text2.Contains(text)))
|
||||
{
|
||||
return 40f;
|
||||
}
|
||||
return this.SubsequenceCoverage(bodyName, clothesName) * 10f;
|
||||
return !string.IsNullOrEmpty(str1) && !string.IsNullOrEmpty(str2) && (str1.Contains(str2) || str2.Contains(str1)) ? 40f : this.SubsequenceCoverage(bodyName, clothesName) * 10f;
|
||||
}
|
||||
|
||||
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;
|
||||
string a = this.StripDigits(this.NormalizeName(bodyRaw));
|
||||
string b = this.StripDigits(this.NormalizeName(clothesRaw));
|
||||
return string.IsNullOrEmpty(a) || string.IsNullOrEmpty(b) ? 0.0f : (float)this.SubNameMatchBest(a, b) / (float)a.Length;
|
||||
}
|
||||
|
||||
private int SubNameMatchBest(string a, string b, int minMatchCount = 3)
|
||||
{
|
||||
if (string.IsNullOrEmpty(a) || string.IsNullOrEmpty(b))
|
||||
{
|
||||
if (string.IsNullOrEmpty(a) || string.IsNullOrEmpty(b) || a.Length < minMatchCount || b.Length < minMatchCount)
|
||||
return 0;
|
||||
}
|
||||
if (a.Length < minMatchCount || b.Length < minMatchCount)
|
||||
int num1 = 0;
|
||||
for (int startA = 0; startA <= a.Length - minMatchCount; ++startA)
|
||||
{
|
||||
return 0;
|
||||
int num2 = this.SubNameMatch(a, startA, b, minMatchCount);
|
||||
if (num2 > num1)
|
||||
num1 = num2;
|
||||
}
|
||||
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;
|
||||
return num1;
|
||||
}
|
||||
|
||||
private int SubNameMatch(string a, int startA, string b, int minMatchCount = 3)
|
||||
{
|
||||
int length = a.Length;
|
||||
int length1 = a.Length;
|
||||
int length2 = b.Length;
|
||||
int num = 0;
|
||||
int num1 = 0;
|
||||
int num2 = 0;
|
||||
int num3 = 0;
|
||||
int num4 = 0;
|
||||
for (int i = startA; i < length; i++)
|
||||
for (int index1 = startA; index1 < length1; ++index1)
|
||||
{
|
||||
for (int j = num3; j < length2; j++)
|
||||
for (int index2 = num3; index2 < length2; ++index2)
|
||||
{
|
||||
num3 = j + 1;
|
||||
if (a[i] == b[j])
|
||||
num3 = index2 + 1;
|
||||
if ((int)a[index1] == (int)b[index2])
|
||||
{
|
||||
num4 = i + 1;
|
||||
num2++;
|
||||
if (num2 > num)
|
||||
num4 = index1 + 1;
|
||||
++num2;
|
||||
if (num2 > num1)
|
||||
{
|
||||
num = num2;
|
||||
num1 = num2;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (num2 > num)
|
||||
{
|
||||
num = num2;
|
||||
}
|
||||
if (num2 > num1)
|
||||
num1 = num2;
|
||||
num2 = 0;
|
||||
}
|
||||
if (num3 >= length2)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (num2 > num)
|
||||
{
|
||||
num = num2;
|
||||
}
|
||||
if (num < minMatchCount)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return num4 - startA;
|
||||
if (num2 > num1)
|
||||
num1 = num2;
|
||||
return num1 < minMatchCount ? 0 : num4 - startA;
|
||||
}
|
||||
|
||||
public string GetHierarchyPath(Transform root, Transform t)
|
||||
{
|
||||
if ((Object)(object)t == (Object)null)
|
||||
{
|
||||
if (Object.op_Equality((Object)t, (Object)null))
|
||||
return "";
|
||||
}
|
||||
Stack<string> stack = new Stack<string>();
|
||||
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);
|
||||
Stack<string> values = new Stack<string>();
|
||||
for (Transform transform = t; Object.op_Inequality((Object)transform, (Object)null) && Object.op_Inequality((Object)transform, (Object)root); transform = transform.parent)
|
||||
values.Push(((Object)transform).name);
|
||||
return string.Join("/", (IEnumerable<string>)values);
|
||||
}
|
||||
|
||||
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(), "");
|
||||
}
|
||||
foreach (char nameDelim in this.nameDelims)
|
||||
s = s.Replace(nameDelim.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(this.NormalizeName));
|
||||
return string.IsNullOrEmpty(p) ? "" : string.Join("/", ((IEnumerable<string>)p.Split('/', StringSplitOptions.None)).Where<string>((Func<string, bool>)(x => !string.IsNullOrEmpty(x))).Select<string, string>(new Func<string, string>(this.NormalizeName)));
|
||||
}
|
||||
|
||||
public string StripDigits(string s)
|
||||
{
|
||||
if (string.IsNullOrEmpty(s))
|
||||
{
|
||||
return "";
|
||||
}
|
||||
StringBuilder stringBuilder = new StringBuilder(s.Length);
|
||||
foreach (char c in s)
|
||||
for (int index = 0; index < s.Length; ++index)
|
||||
{
|
||||
char c = s[index];
|
||||
if (!char.IsDigit(c))
|
||||
{
|
||||
stringBuilder.Append(c);
|
||||
}
|
||||
}
|
||||
return stringBuilder.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 675a70ff79a4c1d43820074163c01b90
|
||||
guid: 5e62c972f6f7fb242aaf2e7182fc85bb
|
||||
@@ -1,206 +1,144 @@
|
||||
// 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
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: Eden.AutoMorpher.BoneMatchUtil
|
||||
// Assembly: EdenAutoMorpherScript, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: D39968B3-E151-4276-BDB4-E82752BBAFF0
|
||||
// Assembly location: D:\git\Spy\Assets\@Eden_Tools\Eden_AutoMorpher\Script\EdenAutoMorpherScript.dll
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Eden.AutoMorpher
|
||||
{
|
||||
public class BoneMatchUtil
|
||||
{
|
||||
public class BoneRootLocalData
|
||||
{
|
||||
public Transform t;
|
||||
|
||||
public string name;
|
||||
|
||||
public string path;
|
||||
|
||||
public Vector3 rootLocalPos;
|
||||
|
||||
public Quaternion rootLocalRot;
|
||||
|
||||
public HumanBodyBones hBone = (HumanBodyBones)55;
|
||||
}
|
||||
|
||||
private const float PosTolNear = 0.0001f;
|
||||
|
||||
private const float PosTolMid = 0.0005f;
|
||||
|
||||
private const float PosTolFar = 0.002f;
|
||||
|
||||
private const float RotTolDeg = 30f;
|
||||
|
||||
private const float eps = 1E-06f;
|
||||
|
||||
public List<BoneRootLocalData> ConvertProfileBoneDataToRootLocalData(List<BoneData> boneDataList)
|
||||
public List<BoneMatchUtil.BoneRootLocalData> ConvertProfileBoneDataToRootLocalData(
|
||||
List<BoneData> 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<BoneRootLocalData> list = new List<BoneRootLocalData>(boneDataList.Count);
|
||||
List<BoneMatchUtil.BoneRootLocalData> rootLocalData = boneDataList != null && boneDataList.Count != 0 ? new List<BoneMatchUtil.BoneRootLocalData>(boneDataList.Count) : throw new AutoMorpherException("Profile Bone Data is Missing", "[BoneMatchUtil] ConvertProfileBoneDataToRootLocalData\n - boneDataList is null or empty");
|
||||
foreach (BoneData boneData in boneDataList)
|
||||
{
|
||||
if (boneData != null)
|
||||
{
|
||||
BoneRootLocalData item = new BoneRootLocalData
|
||||
BoneMatchUtil.BoneRootLocalData boneRootLocalData = new BoneMatchUtil.BoneRootLocalData()
|
||||
{
|
||||
t = null,
|
||||
name = (boneData.boneName ?? string.Empty),
|
||||
path = (boneData.hierarchyPath ?? string.Empty),
|
||||
t = (Transform)null,
|
||||
name = boneData.boneName ?? string.Empty,
|
||||
path = boneData.hierarchyPath ?? string.Empty,
|
||||
rootLocalPos = boneData.rootLocalPosition,
|
||||
rootLocalRot = boneData.rootLocalRotation,
|
||||
hBone = boneData.hBone
|
||||
};
|
||||
list.Add(item);
|
||||
rootLocalData.Add(boneRootLocalData);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
return rootLocalData;
|
||||
}
|
||||
|
||||
public HashSet<Transform> GetMeshBones(List<SkinnedMeshRenderer> meshRenderers)
|
||||
{
|
||||
HashSet<Transform> hashSet = new HashSet<Transform>();
|
||||
HashSet<Transform> meshBones = new HashSet<Transform>();
|
||||
if (meshRenderers != null)
|
||||
{
|
||||
foreach (SkinnedMeshRenderer meshRenderer in meshRenderers)
|
||||
{
|
||||
if (meshRenderer == null || meshRenderer.bones == null)
|
||||
if (!Object.op_Equality((Object)meshRenderer, (Object)null) && meshRenderer.bones != null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
Transform[] bones = meshRenderer.bones;
|
||||
foreach (Transform val in bones)
|
||||
foreach (Transform bone in meshRenderer.bones)
|
||||
{
|
||||
if (val != null)
|
||||
{
|
||||
hashSet.Add(val);
|
||||
if (Object.op_Inequality((Object)bone, (Object)null))
|
||||
meshBones.Add(bone);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return hashSet;
|
||||
return meshBones;
|
||||
}
|
||||
|
||||
public List<BoneRootLocalData> GetRootLocalBones(Transform rootT, HashSet<Transform> boneList)
|
||||
public List<BoneMatchUtil.BoneRootLocalData> GetRootLocalBones(
|
||||
Transform rootT,
|
||||
HashSet<Transform> boneList)
|
||||
{
|
||||
BoneCorrespondenceUtil correspondenceUtil = new BoneCorrespondenceUtil();
|
||||
return (from t in boneList.Where((Transform t) => t != null).Distinct()
|
||||
select new BoneRootLocalData
|
||||
return boneList.Where<Transform>((Func<Transform, bool>)(t => Object.op_Inequality((Object)t, (Object)null))).Distinct<Transform>().Select<Transform, BoneMatchUtil.BoneRootLocalData>((Func<Transform, BoneMatchUtil.BoneRootLocalData>)(t => new BoneMatchUtil.BoneRootLocalData()
|
||||
{
|
||||
t = t,
|
||||
name = t.name,
|
||||
name = ((Object)t).name,
|
||||
path = correspondenceUtil.GetHierarchyPath(rootT, t),
|
||||
rootLocalPos = rootT.InverseTransformPoint(t.position),
|
||||
rootLocalRot = Quaternion.Inverse(rootT.rotation) * t.rotation
|
||||
}).ToList();
|
||||
rootLocalRot = Quaternion.op_Multiply(Quaternion.Inverse(rootT.rotation), t.rotation)
|
||||
})).ToList<BoneMatchUtil.BoneRootLocalData>();
|
||||
}
|
||||
|
||||
public List<BoneRootLocalData> GetBodyRootLocalBones(Transform bodyTransform, Animator bodyAnimator, List<SkinnedMeshRenderer> 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)
|
||||
public List<BoneMatchUtil.BoneRootLocalData> GetBodyRootLocalBones(
|
||||
Transform bodyTransform,
|
||||
Animator bodyAnimator,
|
||||
List<SkinnedMeshRenderer> bodyMeshes)
|
||||
{
|
||||
if (Object.op_Equality((Object)bodyTransform, (Object)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<Transform, HumanBodyBones> humanoidBoneList = this.GetHumanoidBoneList(bodyAnimator);
|
||||
if (humanoidBoneList == null || humanoidBoneList.Count == 0)
|
||||
{
|
||||
Dictionary<Transform, HumanBodyBones> dictionary1 = !Object.op_Equality((Object)bodyAnimator, (Object)null) ? this.GetHumanoidBoneList(bodyAnimator) : throw new AutoMorpherException("Body Animator is Missing", "[BoneMatchUtil] GetBodyRootLocalBones\n - animator is null");
|
||||
if (dictionary1 == null || dictionary1.Count == 0)
|
||||
throw new AutoMorpherException("Humanoid Bone Map is Missing", "[BoneMatchUtil] GetBodyRootLocalBones\n - Can't find Humanoid Bone List");
|
||||
HashSet<Transform> transformSet1 = bodyMeshes != null && bodyMeshes.Count != 0 ? this.GetMeshBones(bodyMeshes) : throw new AutoMorpherException("Body Meshes are Missing", "[BoneMatchUtil] GetBodyRootLocalBones\n - bodyMeshes is null or empty");
|
||||
Dictionary<HumanBodyBones, HashSet<Transform>> dictionary2 = new MeshClassifier().MeshHumanoidBoneMatcher(bodyAnimator, (IReadOnlyList<SkinnedMeshRenderer>)bodyMeshes);
|
||||
HashSet<Transform> boneList = new HashSet<Transform>();
|
||||
HashSet<Transform> transformSet2 = new HashSet<Transform>();
|
||||
foreach (KeyValuePair<Transform, HumanBodyBones> keyValuePair in dictionary1)
|
||||
{
|
||||
if (keyValuePair.Value != 55 && !Object.op_Equality((Object)keyValuePair.Key, (Object)null))
|
||||
{
|
||||
HashSet<Transform> transformSet3;
|
||||
if (!dictionary2.TryGetValue(keyValuePair.Value, out transformSet3) || transformSet3 == null)
|
||||
{
|
||||
transformSet3 = new HashSet<Transform>();
|
||||
dictionary2[keyValuePair.Value] = transformSet3;
|
||||
}
|
||||
if (bodyMeshes == null || bodyMeshes.Count == 0)
|
||||
{
|
||||
throw new AutoMorpherException("Body Meshes are Missing", "[BoneMatchUtil] GetBodyRootLocalBones\n - bodyMeshes is null or empty");
|
||||
}
|
||||
HashSet<Transform> meshBones = this.GetMeshBones(bodyMeshes);
|
||||
Dictionary<HumanBodyBones, HashSet<Transform>> dictionary = new MeshClassifier().MeshHumanoidBoneMatcher(bodyAnimator, bodyMeshes);
|
||||
HashSet<Transform> hashSet = new HashSet<Transform>();
|
||||
HashSet<Transform> hashSet2 = new HashSet<Transform>();
|
||||
foreach (KeyValuePair<Transform, HumanBodyBones> item in humanoidBoneList)
|
||||
{
|
||||
if ((int)item.Value != 55 && !(item.Key == null))
|
||||
{
|
||||
if (!dictionary.TryGetValue(item.Value, out var value) || value == null)
|
||||
{
|
||||
value = new HashSet<Transform>();
|
||||
dictionary[item.Value] = value;
|
||||
}
|
||||
value.Add(item.Key);
|
||||
transformSet3.Add(keyValuePair.Key);
|
||||
}
|
||||
}
|
||||
foreach (KeyValuePair<HumanBodyBones, HashSet<Transform>> item2 in dictionary)
|
||||
foreach (KeyValuePair<HumanBodyBones, HashSet<Transform>> keyValuePair in dictionary2)
|
||||
{
|
||||
HumanBodyBones key = item2.Key;
|
||||
if ((int)key == 55)
|
||||
HumanBodyBones key = keyValuePair.Key;
|
||||
if (key != 55)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
HashSet<Transform> value2 = item2.Value;
|
||||
if (value2 == null || value2.Count == 0)
|
||||
HashSet<Transform> source = keyValuePair.Value;
|
||||
if (source != null && source.Count != 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
Transform val = bodyAnimator.GetBoneTransform(key);
|
||||
if (val == null)
|
||||
Transform transform1 = bodyAnimator.GetBoneTransform(key);
|
||||
if (Object.op_Equality((Object)transform1, (Object)null))
|
||||
transform1 = source.First<Transform>();
|
||||
if (!Object.op_Equality((Object)transform1, (Object)null))
|
||||
{
|
||||
val = value2.First();
|
||||
}
|
||||
if (val == null)
|
||||
boneList.Add(transform1);
|
||||
foreach (Transform transform2 in source)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
hashSet.Add(val);
|
||||
foreach (Transform item3 in value2)
|
||||
{
|
||||
if (!(item3 == val) && !(item3 == null))
|
||||
{
|
||||
hashSet2.Add(item3);
|
||||
if (!Object.op_Equality((Object)transform2, (Object)transform1) && !Object.op_Equality((Object)transform2, (Object)null))
|
||||
transformSet2.Add(transform2);
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach (Transform item4 in meshBones)
|
||||
{
|
||||
if (!(item4 == null) && !hashSet2.Contains(item4))
|
||||
{
|
||||
hashSet.Add(item4);
|
||||
}
|
||||
}
|
||||
List<BoneRootLocalData> rootLocalBones = this.GetRootLocalBones(bodyTransform, hashSet);
|
||||
foreach (BoneRootLocalData item5 in rootLocalBones)
|
||||
foreach (Transform transform in transformSet1)
|
||||
{
|
||||
if (item5 != null && !(item5.t == null))
|
||||
{
|
||||
if (humanoidBoneList.TryGetValue(item5.t, out var value3))
|
||||
{
|
||||
item5.hBone = value3;
|
||||
if (!Object.op_Equality((Object)transform, (Object)null) && !transformSet2.Contains(transform))
|
||||
boneList.Add(transform);
|
||||
}
|
||||
else
|
||||
List<BoneMatchUtil.BoneRootLocalData> rootLocalBones = this.GetRootLocalBones(bodyTransform, boneList);
|
||||
foreach (BoneMatchUtil.BoneRootLocalData boneRootLocalData in rootLocalBones)
|
||||
{
|
||||
item5.hBone = (HumanBodyBones)55;
|
||||
}
|
||||
if (boneRootLocalData != null && !Object.op_Equality((Object)boneRootLocalData.t, (Object)null))
|
||||
{
|
||||
HumanBodyBones humanBodyBones;
|
||||
boneRootLocalData.hBone = !dictionary1.TryGetValue(boneRootLocalData.t, out humanBodyBones) ? (HumanBodyBones)55 : humanBodyBones;
|
||||
}
|
||||
}
|
||||
return rootLocalBones;
|
||||
@@ -208,444 +146,371 @@ public class BoneMatchUtil
|
||||
|
||||
private Dictionary<Transform, HumanBodyBones> 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<Transform, HumanBodyBones> dictionary = new Dictionary<Transform, HumanBodyBones>();
|
||||
if (bodyAnimator == null || bodyAnimator.avatar == null || !bodyAnimator.avatar.isHuman)
|
||||
Dictionary<Transform, HumanBodyBones> humanoidBoneList = new Dictionary<Transform, HumanBodyBones>();
|
||||
if (Object.op_Equality((Object)bodyAnimator, (Object)null) || Object.op_Equality((Object)bodyAnimator.avatar, (Object)null) || !bodyAnimator.avatar.isHuman)
|
||||
return humanoidBoneList;
|
||||
foreach (HumanBodyBones humanBodyBones in Enum.GetValues(typeof(HumanBodyBones)))
|
||||
{
|
||||
return dictionary;
|
||||
}
|
||||
foreach (HumanBodyBones value in Enum.GetValues(typeof(HumanBodyBones)))
|
||||
if (humanBodyBones != 55)
|
||||
{
|
||||
if ((int)value != 55)
|
||||
{
|
||||
Transform boneTransform = bodyAnimator.GetBoneTransform(value);
|
||||
if (!(boneTransform == null))
|
||||
{
|
||||
dictionary.TryAdd(boneTransform, value);
|
||||
Transform boneTransform = bodyAnimator.GetBoneTransform(humanBodyBones);
|
||||
if (!Object.op_Equality((Object)boneTransform, (Object)null))
|
||||
humanoidBoneList.TryAdd(boneTransform, humanBodyBones);
|
||||
}
|
||||
}
|
||||
}
|
||||
return dictionary;
|
||||
return humanoidBoneList;
|
||||
}
|
||||
|
||||
public void MatchClothesToBodyBones(List<BoneRootLocalData> bodyBones, List<BoneRootLocalData> clothesBones, out Dictionary<HumanBodyBones, HashSet<Transform>> clothHumanBones, out Dictionary<Transform, ClothBoneType> clothBoneTypeMap, out Dictionary<Transform, BoneRootLocalData> clothToBodyMatched)
|
||||
public void MatchClothesToBodyBones(
|
||||
List<BoneMatchUtil.BoneRootLocalData> bodyBones,
|
||||
List<BoneMatchUtil.BoneRootLocalData> clothesBones,
|
||||
out Dictionary<HumanBodyBones, HashSet<Transform>> clothHumanBones,
|
||||
out Dictionary<Transform, ClothBoneType> clothBoneTypeMap,
|
||||
out Dictionary<Transform, BoneMatchUtil.BoneRootLocalData> 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<HumanBodyBones, HashSet<Transform>>();
|
||||
clothBoneTypeMap = new Dictionary<Transform, ClothBoneType>();
|
||||
clothToBodyMatched = new Dictionary<Transform, BoneRootLocalData>();
|
||||
clothToBodyMatched = new Dictionary<Transform, BoneMatchUtil.BoneRootLocalData>();
|
||||
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)
|
||||
List<(BoneMatchUtil.BoneRootLocalData, BoneMatchUtil.BoneRootLocalData, float, float, float, float, float)> source1 = new List<(BoneMatchUtil.BoneRootLocalData, BoneMatchUtil.BoneRootLocalData, float, float, float, float, float)>();
|
||||
BoneCorrespondenceUtil correspondenceUtil = new BoneCorrespondenceUtil();
|
||||
foreach (BoneMatchUtil.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)
|
||||
BoneMatchUtil.BoneRootLocalData boneRootLocalData = (BoneMatchUtil.BoneRootLocalData)null;
|
||||
float bestDistScore = float.NegativeInfinity;
|
||||
float bestRotScore = float.NegativeInfinity;
|
||||
float bestNameScore = float.NegativeInfinity;
|
||||
float bestD = float.PositiveInfinity;
|
||||
float bestAng = float.PositiveInfinity;
|
||||
foreach (BoneMatchUtil.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)
|
||||
float num1 = Vector3.Distance(clothesBone.rootLocalPos, bodyBone.rootLocalPos);
|
||||
float distanceScore = correspondenceUtil.ComputeDistanceScore(num1, 0.0001f, 0.0005f, 1f / 500f);
|
||||
if ((double)distanceScore != 0.0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
float num8 = boneCorrespondenceUtil.ComputeNameScore(bodyBone.name, bodyBone.path, clothesBone.name, clothesBone.path);
|
||||
if (num8 != 0f)
|
||||
float nameScore = correspondenceUtil.ComputeNameScore(bodyBone.name, bodyBone.path, clothesBone.name, clothesBone.path);
|
||||
if ((double)nameScore != 0.0)
|
||||
{
|
||||
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))
|
||||
float num2 = Quaternion.Angle(bodyBone.rootLocalRot, clothesBone.rootLocalRot);
|
||||
float candRotScore = correspondenceUtil.ComputeRotationScore(num2, 30f) * 1f;
|
||||
if (this.IsBetterCandidate(distanceScore, bestDistScore, candRotScore, bestRotScore, nameScore, bestNameScore, num1, bestD, num2, bestAng))
|
||||
{
|
||||
boneRootLocalData = bodyBone;
|
||||
num = num7;
|
||||
num2 = num10;
|
||||
num3 = num8;
|
||||
num4 = num6;
|
||||
num5 = num9;
|
||||
bestDistScore = distanceScore;
|
||||
bestRotScore = candRotScore;
|
||||
bestNameScore = nameScore;
|
||||
bestD = num1;
|
||||
bestAng = num2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (boneRootLocalData != null)
|
||||
source1.Add((clothesBone, boneRootLocalData, bestDistScore, bestRotScore, bestNameScore, bestD, bestAng));
|
||||
}
|
||||
Dictionary<Transform, BoneMatchUtil.BoneRootLocalData> dictionary = new Dictionary<Transform, BoneMatchUtil.BoneRootLocalData>();
|
||||
foreach (IGrouping<BoneMatchUtil.BoneRootLocalData, (BoneMatchUtil.BoneRootLocalData, BoneMatchUtil.BoneRootLocalData, float, float, float, float, float)> source2 in source1.GroupBy<(BoneMatchUtil.BoneRootLocalData, BoneMatchUtil.BoneRootLocalData, float, float, float, float, float), BoneMatchUtil.BoneRootLocalData>((Func<(BoneMatchUtil.BoneRootLocalData, BoneMatchUtil.BoneRootLocalData, float, float, float, float, float), BoneMatchUtil.BoneRootLocalData>)(x => x.body)))
|
||||
{
|
||||
list.Add((clothesBone, boneRootLocalData, num, num2, num3, num4, num5));
|
||||
if (source2.Key != null)
|
||||
{
|
||||
List<(BoneMatchUtil.BoneRootLocalData, BoneMatchUtil.BoneRootLocalData, float, float, float, float, float)> list = source2.ToList<(BoneMatchUtil.BoneRootLocalData, BoneMatchUtil.BoneRootLocalData, float, float, float, float, float)>();
|
||||
if (list.Count != 0)
|
||||
{
|
||||
(BoneMatchUtil.BoneRootLocalData, BoneMatchUtil.BoneRootLocalData, float, float, float, float, float) valueTuple = list[0];
|
||||
for (int index = 1; index < list.Count; ++index)
|
||||
{
|
||||
(BoneMatchUtil.BoneRootLocalData, BoneMatchUtil.BoneRootLocalData, float, float, float, float, float) tuple = list[index];
|
||||
if (this.IsBetterCandidate(tuple.Item3, valueTuple.Item3, tuple.Item4, valueTuple.Item4, tuple.Item5, valueTuple.Item5, tuple.Item6, valueTuple.Item6, tuple.Item7, valueTuple.Item7))
|
||||
valueTuple = tuple;
|
||||
}
|
||||
if (valueTuple.Item1 != null && Object.op_Inequality((Object)valueTuple.Item1.t, (Object)null) && valueTuple.Item2 != null)
|
||||
dictionary[valueTuple.Item1.t] = valueTuple.Item2;
|
||||
}
|
||||
}
|
||||
Dictionary<Transform, BoneRootLocalData> dictionary = new Dictionary<Transform, BoneRootLocalData>();
|
||||
foreach (IGrouping<BoneRootLocalData, (BoneRootLocalData, BoneRootLocalData, float, float, float, float, float)> 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)
|
||||
foreach (BoneMatchUtil.BoneRootLocalData clothesBone in clothesBones)
|
||||
{
|
||||
continue;
|
||||
if (!Object.op_Equality((Object)clothesBone?.t, (Object)null))
|
||||
{
|
||||
BoneMatchUtil.BoneRootLocalData boneRootLocalData;
|
||||
if (dictionary.TryGetValue(clothesBone.t, out boneRootLocalData))
|
||||
{
|
||||
clothBoneTypeMap[clothesBone.t] = ClothBoneType.Body;
|
||||
clothToBodyMatched[clothesBone.t] = boneRootLocalData;
|
||||
HumanBodyBones hBone = boneRootLocalData.hBone;
|
||||
if (hBone != 55)
|
||||
{
|
||||
HashSet<Transform> transformSet;
|
||||
if (!clothHumanBones.TryGetValue(hBone, out transformSet))
|
||||
{
|
||||
transformSet = new HashSet<Transform>();
|
||||
clothHumanBones[hBone] = transformSet;
|
||||
}
|
||||
(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<Transform>();
|
||||
clothHumanBones[hBone] = value2;
|
||||
}
|
||||
value2.Add(clothesBone2.t);
|
||||
transformSet.Add(clothesBone.t);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
clothBoneTypeMap[clothesBone2.t] = ClothBoneType.Accessory;
|
||||
clothBoneTypeMap[clothesBone.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)
|
||||
private bool IsBetterCandidate(
|
||||
float candDistScore,
|
||||
float bestDistScore,
|
||||
float candRotScore,
|
||||
float bestRotScore,
|
||||
float candNameScore,
|
||||
float bestNameScore,
|
||||
float candD,
|
||||
float bestD,
|
||||
float candAng,
|
||||
float bestAng)
|
||||
{
|
||||
if ((double)candDistScore > (double)bestDistScore)
|
||||
return true;
|
||||
}
|
||||
if (candDistScore < bestDistScore)
|
||||
if ((double)candDistScore < (double)bestDistScore)
|
||||
return false;
|
||||
if ((double)candNameScore > (double)bestNameScore)
|
||||
return true;
|
||||
if ((double)candNameScore < (double)bestNameScore)
|
||||
return false;
|
||||
if ((double)Mathf.Abs(candRotScore - bestRotScore) > 9.9999999747524271E-07)
|
||||
{
|
||||
if ((double)candRotScore > (double)bestRotScore)
|
||||
return true;
|
||||
if ((double)candRotScore < (double)bestRotScore)
|
||||
return false;
|
||||
}
|
||||
if (candNameScore > bestNameScore)
|
||||
if ((double)Mathf.Abs(candD - bestD) > 9.9999999747524271E-07)
|
||||
{
|
||||
if ((double)candD < (double)bestD)
|
||||
return true;
|
||||
}
|
||||
if (candNameScore < bestNameScore)
|
||||
{
|
||||
if ((double)candD > (double)bestD)
|
||||
return false;
|
||||
}
|
||||
if (Mathf.Abs(candRotScore - bestRotScore) > 1E-06f)
|
||||
{
|
||||
if (candRotScore > bestRotScore)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (candRotScore < bestRotScore)
|
||||
{
|
||||
if ((double)Mathf.Abs(candAng - bestAng) <= 9.9999999747524271E-07)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (Mathf.Abs(candD - bestD) > 1E-06f)
|
||||
{
|
||||
if (candD < bestD)
|
||||
{
|
||||
if ((double)candAng < (double)bestAng)
|
||||
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<Transform, Transform> BuildTransformMatchMap(List<BoneRootLocalData> sourceBones, List<BoneRootLocalData> destBones, bool resultReverse = false)
|
||||
public Dictionary<Transform, Transform> BuildTransformMatchMap(
|
||||
List<BoneMatchUtil.BoneRootLocalData> sourceBones,
|
||||
List<BoneMatchUtil.BoneRootLocalData> 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 correspondenceUtil = new BoneCorrespondenceUtil();
|
||||
Dictionary<Transform, Transform> dictionary1 = new Dictionary<Transform, Transform>();
|
||||
Dictionary<string, BoneMatchUtil.BoneRootLocalData> dictionary2 = new Dictionary<string, BoneMatchUtil.BoneRootLocalData>();
|
||||
Dictionary<string, BoneMatchUtil.BoneRootLocalData> dictionary3 = new Dictionary<string, BoneMatchUtil.BoneRootLocalData>();
|
||||
Dictionary<string, List<BoneMatchUtil.BoneRootLocalData>> dictionary4 = new Dictionary<string, List<BoneMatchUtil.BoneRootLocalData>>();
|
||||
foreach (BoneMatchUtil.BoneRootLocalData destBone in destBones)
|
||||
{
|
||||
if (destBone != null && !Object.op_Equality((Object)destBone.t, (Object)null))
|
||||
{
|
||||
string str = destBone.path ?? "";
|
||||
if (str.Length > 0 && !dictionary2.ContainsKey(str))
|
||||
dictionary2.Add(str, destBone);
|
||||
if (str.Length > 0)
|
||||
{
|
||||
string key = correspondenceUtil.NormalizePath(str);
|
||||
if (key.Length > 0 && !dictionary3.ContainsKey(key))
|
||||
dictionary3.Add(key, destBone);
|
||||
}
|
||||
BoneCorrespondenceUtil boneCorrespondenceUtil = new BoneCorrespondenceUtil();
|
||||
Dictionary<Transform, Transform> dictionary = new Dictionary<Transform, Transform>();
|
||||
Dictionary<string, BoneRootLocalData> dictionary2 = new Dictionary<string, BoneRootLocalData>();
|
||||
Dictionary<string, BoneRootLocalData> dictionary3 = new Dictionary<string, BoneRootLocalData>();
|
||||
Dictionary<string, List<BoneRootLocalData>> dictionary4 = new Dictionary<string, List<BoneRootLocalData>>();
|
||||
foreach (BoneRootLocalData destBone in destBones)
|
||||
string key1 = destBone.name ?? ((Object)destBone.t).name;
|
||||
if (!string.IsNullOrEmpty(key1))
|
||||
{
|
||||
if (destBone == null || destBone.t == null)
|
||||
List<BoneMatchUtil.BoneRootLocalData> boneRootLocalDataList;
|
||||
if (!dictionary4.TryGetValue(key1, out boneRootLocalDataList))
|
||||
{
|
||||
continue;
|
||||
boneRootLocalDataList = new List<BoneMatchUtil.BoneRootLocalData>();
|
||||
dictionary4[key1] = boneRootLocalDataList;
|
||||
}
|
||||
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<BoneRootLocalData>());
|
||||
}
|
||||
value.Add(destBone);
|
||||
}
|
||||
}
|
||||
HashSet<Transform> hashSet = new HashSet<Transform>();
|
||||
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;
|
||||
boneRootLocalDataList.Add(destBone);
|
||||
}
|
||||
}
|
||||
}
|
||||
val = val2;
|
||||
HashSet<Transform> transformSet = new HashSet<Transform>();
|
||||
foreach (BoneMatchUtil.BoneRootLocalData sourceBone in sourceBones)
|
||||
{
|
||||
if (sourceBone != null && !Object.op_Equality((Object)sourceBone.t, (Object)null))
|
||||
{
|
||||
Transform key2 = (Transform)null;
|
||||
string str = sourceBone.path ?? "";
|
||||
BoneMatchUtil.BoneRootLocalData boneRootLocalData1;
|
||||
if (str.Length > 0 && dictionary2.TryGetValue(str, out boneRootLocalData1) && boneRootLocalData1 != null && Object.op_Inequality((Object)boneRootLocalData1.t, (Object)null) && !transformSet.Contains(boneRootLocalData1.t))
|
||||
key2 = boneRootLocalData1.t;
|
||||
if (Object.op_Equality((Object)key2, (Object)null) && str.Length > 0)
|
||||
{
|
||||
string key3 = correspondenceUtil.NormalizePath(str);
|
||||
BoneMatchUtil.BoneRootLocalData boneRootLocalData2;
|
||||
if (key3.Length > 0 && dictionary3.TryGetValue(key3, out boneRootLocalData2) && boneRootLocalData2 != null && Object.op_Inequality((Object)boneRootLocalData2.t, (Object)null) && !transformSet.Contains(boneRootLocalData2.t))
|
||||
key2 = boneRootLocalData2.t;
|
||||
}
|
||||
if (Object.op_Equality((Object)key2, (Object)null))
|
||||
{
|
||||
string key4 = sourceBone.name ?? ((Object)sourceBone.t).name;
|
||||
List<BoneMatchUtil.BoneRootLocalData> boneRootLocalDataList;
|
||||
if (!string.IsNullOrEmpty(key4) && dictionary4.TryGetValue(key4, out boneRootLocalDataList))
|
||||
{
|
||||
float num1 = float.PositiveInfinity;
|
||||
Transform transform = (Transform)null;
|
||||
for (int index = 0; index < boneRootLocalDataList.Count; ++index)
|
||||
{
|
||||
BoneMatchUtil.BoneRootLocalData boneRootLocalData3 = boneRootLocalDataList[index];
|
||||
if (boneRootLocalData3 != null && !Object.op_Equality((Object)boneRootLocalData3.t, (Object)null) && !transformSet.Contains(boneRootLocalData3.t))
|
||||
{
|
||||
float num2 = Vector3.SqrMagnitude(Vector3.op_Subtraction(boneRootLocalData3.rootLocalPos, sourceBone.rootLocalPos));
|
||||
if ((double)num2 < (double)num1)
|
||||
{
|
||||
num1 = num2;
|
||||
transform = boneRootLocalData3.t;
|
||||
}
|
||||
}
|
||||
if (val != null)
|
||||
}
|
||||
key2 = transform;
|
||||
}
|
||||
}
|
||||
if (Object.op_Inequality((Object)key2, (Object)null))
|
||||
{
|
||||
if (resultReverse)
|
||||
{
|
||||
dictionary[val] = sourceBone.t;
|
||||
}
|
||||
dictionary1[key2] = sourceBone.t;
|
||||
else
|
||||
{
|
||||
dictionary[sourceBone.t] = val;
|
||||
}
|
||||
hashSet.Add(val);
|
||||
dictionary1[sourceBone.t] = key2;
|
||||
transformSet.Add(key2);
|
||||
}
|
||||
}
|
||||
return dictionary;
|
||||
}
|
||||
return dictionary1;
|
||||
}
|
||||
|
||||
public void RemapSourceClothMatchToTargetCloth(Transform sourceClothRoot, Transform targetClothRoot, Dictionary<HumanBodyBones, HashSet<Transform>> sourceClothHumanBones, Dictionary<Transform, ClothBoneType> sourceClothBoneTypeMap, out Dictionary<HumanBodyBones, HashSet<Transform>> targetClothHumanBones, out Dictionary<Transform, ClothBoneType> targetClothBoneTypeMap)
|
||||
public void RemapSourceClothMatchToTargetCloth(
|
||||
Transform sourceClothRoot,
|
||||
Transform targetClothRoot,
|
||||
Dictionary<HumanBodyBones, HashSet<Transform>> sourceClothHumanBones,
|
||||
Dictionary<Transform, ClothBoneType> sourceClothBoneTypeMap,
|
||||
out Dictionary<HumanBodyBones, HashSet<Transform>> targetClothHumanBones,
|
||||
out Dictionary<Transform, ClothBoneType> 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<HumanBodyBones, HashSet<Transform>>();
|
||||
targetClothBoneTypeMap = new Dictionary<Transform, ClothBoneType>();
|
||||
if (sourceClothRoot == null || targetClothRoot == null)
|
||||
{
|
||||
if (Object.op_Equality((Object)sourceClothRoot, (Object)null) || Object.op_Equality((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<Transform> boneList = new HashSet<Transform>();
|
||||
foreach (KeyValuePair<Transform, ClothBoneType> sourceClothBoneType in sourceClothBoneTypeMap)
|
||||
{
|
||||
if (Object.op_Inequality((Object)sourceClothBoneType.Key, (Object)null))
|
||||
boneList.Add(sourceClothBoneType.Key);
|
||||
}
|
||||
HashSet<Transform> hashSet = new HashSet<Transform>();
|
||||
foreach (KeyValuePair<Transform, ClothBoneType> item in sourceClothBoneTypeMap)
|
||||
foreach (KeyValuePair<HumanBodyBones, HashSet<Transform>> sourceClothHumanBone in sourceClothHumanBones)
|
||||
{
|
||||
if (item.Key != null)
|
||||
HashSet<Transform> transformSet = sourceClothHumanBone.Value;
|
||||
if (transformSet != null && transformSet.Count != 0)
|
||||
{
|
||||
hashSet.Add(item.Key);
|
||||
foreach (Transform transform in transformSet)
|
||||
{
|
||||
if (Object.op_Inequality((Object)transform, (Object)null))
|
||||
boneList.Add(transform);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (boneList.Count == 0)
|
||||
throw new AutoMorpherException("Source Cloth Bone Candidates are Missing", "[BoneMatchUtil] RemapClothMatchResultToTargetCloth\n - sourceBoneSet is empty (no bones found in sourceClothBoneTypeMap/sourceClothHumanBones)");
|
||||
HashSet<Transform> meshBones = this.GetMeshBones(((IEnumerable<SkinnedMeshRenderer>)((Component)targetClothRoot).GetComponentsInChildren<SkinnedMeshRenderer>(true)).ToList<SkinnedMeshRenderer>());
|
||||
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<BoneMatchUtil.BoneRootLocalData> rootLocalBones1 = this.GetRootLocalBones(sourceClothRoot, boneList);
|
||||
List<BoneMatchUtil.BoneRootLocalData> rootLocalBones2 = this.GetRootLocalBones(targetClothRoot, meshBones);
|
||||
if (rootLocalBones1 == null || rootLocalBones1.Count == 0)
|
||||
throw new AutoMorpherException("Source RootLocal Bones are Missing", "[BoneMatchUtil] RemapClothMatchResultToTargetCloth\n - sourceRootLocalBones is null or empty");
|
||||
Dictionary<Transform, Transform> dictionary = rootLocalBones2 != null && rootLocalBones2.Count != 0 ? this.BuildTransformMatchMap(rootLocalBones1, rootLocalBones2) : throw new AutoMorpherException("Target RootLocal Bones are Missing", "[BoneMatchUtil] RemapClothMatchResultToTargetCloth\n - targetRootLocalBones is null or empty");
|
||||
foreach (KeyValuePair<Transform, ClothBoneType> sourceClothBoneType in sourceClothBoneTypeMap)
|
||||
{
|
||||
Transform key1 = sourceClothBoneType.Key;
|
||||
ClothBoneType clothBoneType1 = sourceClothBoneType.Value;
|
||||
Transform key2;
|
||||
if (!Object.op_Equality((Object)key1, (Object)null) && dictionary.TryGetValue(key1, out key2) && !Object.op_Equality((Object)key2, (Object)null))
|
||||
{
|
||||
ClothBoneType clothBoneType2;
|
||||
if (targetClothBoneTypeMap.TryGetValue(key2, out clothBoneType2))
|
||||
{
|
||||
if (clothBoneType2 == ClothBoneType.Accessory && clothBoneType1 == ClothBoneType.Body)
|
||||
targetClothBoneTypeMap[key2] = ClothBoneType.Body;
|
||||
}
|
||||
else
|
||||
targetClothBoneTypeMap.Add(key2, clothBoneType1);
|
||||
}
|
||||
}
|
||||
foreach (KeyValuePair<HumanBodyBones, HashSet<Transform>> sourceClothHumanBone in sourceClothHumanBones)
|
||||
{
|
||||
HashSet<Transform> value = sourceClothHumanBone.Value;
|
||||
if (value == null || value.Count == 0)
|
||||
HumanBodyBones key3 = sourceClothHumanBone.Key;
|
||||
HashSet<Transform> transformSet1 = sourceClothHumanBone.Value;
|
||||
if (transformSet1 != null && transformSet1.Count != 0)
|
||||
{
|
||||
continue;
|
||||
foreach (Transform key4 in transformSet1)
|
||||
{
|
||||
Transform transform;
|
||||
if (!Object.op_Equality((Object)key4, (Object)null) && dictionary.TryGetValue(key4, out transform) && !Object.op_Equality((Object)transform, (Object)null))
|
||||
{
|
||||
HashSet<Transform> transformSet2;
|
||||
if (!targetClothHumanBones.TryGetValue(key3, out transformSet2))
|
||||
{
|
||||
transformSet2 = new HashSet<Transform>();
|
||||
targetClothHumanBones[key3] = transformSet2;
|
||||
}
|
||||
foreach (Transform item2 in value)
|
||||
{
|
||||
if (item2 != null)
|
||||
{
|
||||
hashSet.Add(item2);
|
||||
transformSet2.Add(transform);
|
||||
}
|
||||
}
|
||||
}
|
||||
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<Transform> meshBones = this.GetMeshBones(((Component)targetClothRoot).GetComponentsInChildren<SkinnedMeshRenderer>(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<BoneRootLocalData> rootLocalBones = this.GetRootLocalBones(sourceClothRoot, hashSet);
|
||||
List<BoneRootLocalData> 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<Transform, Transform> dictionary = this.BuildTransformMatchMap(rootLocalBones, rootLocalBones2);
|
||||
foreach (KeyValuePair<Transform, ClothBoneType> 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<HumanBodyBones, HashSet<Transform>> sourceClothHumanBone2 in sourceClothHumanBones)
|
||||
{
|
||||
HumanBodyBones key2 = sourceClothHumanBone2.Key;
|
||||
HashSet<Transform> 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<Transform>();
|
||||
targetClothHumanBones[key2] = value7;
|
||||
}
|
||||
value7.Add(value6);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void BuildSourceToProxyBoneMap(Animator sourceAvatar, Animator proxyAvatar, out Dictionary<Transform, Transform> sourceToProxy)
|
||||
public void BuildSourceToProxyBoneMap(
|
||||
Animator sourceAvatar,
|
||||
Animator proxyAvatar,
|
||||
out Dictionary<Transform, Transform> sourceToProxy)
|
||||
{
|
||||
sourceToProxy = new Dictionary<Transform, Transform>();
|
||||
if (sourceAvatar == null)
|
||||
{
|
||||
if (Object.op_Equality((Object)sourceAvatar, (Object)null))
|
||||
throw new AutoMorpherException("Source Avatar is Missing", "[AvatarBodyMatchUtil] BuildSourceToProxyBoneMap\n - sourceAvatar is null");
|
||||
}
|
||||
if (proxyAvatar == null)
|
||||
{
|
||||
if (Object.op_Equality((Object)proxyAvatar, (Object)null))
|
||||
throw new AutoMorpherException("Proxy Avatar is Missing", "[AvatarBodyMatchUtil] BuildSourceToProxyBoneMap\n - proxyAvatar is null");
|
||||
}
|
||||
Transform transform = ((Component)sourceAvatar).transform;
|
||||
Transform transform1 = ((Component)sourceAvatar).transform;
|
||||
Transform transform2 = ((Component)proxyAvatar).transform;
|
||||
HashSet<Transform> meshBones = this.GetMeshBones(((Component)transform2).GetComponentsInChildren<SkinnedMeshRenderer>(true).ToList());
|
||||
if (meshBones == null || meshBones.Count == 0)
|
||||
{
|
||||
HashSet<Transform> meshBones1 = this.GetMeshBones(((IEnumerable<SkinnedMeshRenderer>)((Component)transform2).GetComponentsInChildren<SkinnedMeshRenderer>(true)).ToList<SkinnedMeshRenderer>());
|
||||
if (meshBones1 == null || meshBones1.Count == 0)
|
||||
throw new AutoMorpherException("Proxy Body Bone Candidates are Missing", "[AvatarBodyMatchUtil] BuildSourceToProxyBoneMap\n - proxyBoneSet is null or empty (GetMeshBones returned no bones)");
|
||||
}
|
||||
HashSet<Transform> meshBones2 = this.GetMeshBones(((Component)transform).GetComponentsInChildren<SkinnedMeshRenderer>(true).ToList());
|
||||
HashSet<Transform> meshBones2 = this.GetMeshBones(((IEnumerable<SkinnedMeshRenderer>)((Component)transform1).GetComponentsInChildren<SkinnedMeshRenderer>(true)).ToList<SkinnedMeshRenderer>());
|
||||
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<BoneRootLocalData> rootLocalBones = this.GetRootLocalBones(transform2, meshBones);
|
||||
List<BoneRootLocalData> rootLocalBones2 = this.GetRootLocalBones(transform, meshBones2);
|
||||
if (rootLocalBones == null || rootLocalBones.Count == 0)
|
||||
{
|
||||
List<BoneMatchUtil.BoneRootLocalData> rootLocalBones1 = this.GetRootLocalBones(transform2, meshBones1);
|
||||
List<BoneMatchUtil.BoneRootLocalData> rootLocalBones2 = this.GetRootLocalBones(transform1, meshBones2);
|
||||
if (rootLocalBones1 == null || rootLocalBones1.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);
|
||||
sourceToProxy = rootLocalBones2 != null && rootLocalBones2.Count != 0 ? this.BuildTransformMatchMap(rootLocalBones1, rootLocalBones2, true) : throw new AutoMorpherException("Source RootLocal Bones are Missing", "[AvatarBodyMatchUtil] BuildSourceToProxyBoneMap\n - sourceRootLocalBones is null or empty");
|
||||
if (sourceToProxy == null)
|
||||
{
|
||||
throw new AutoMorpherException("Source To Proxy Map Build Failed", "[AvatarBodyMatchUtil] BuildSourceToProxyBoneMap\n - BuildTransformMatchMap returned null");
|
||||
}
|
||||
|
||||
public class BoneRootLocalData
|
||||
{
|
||||
public Transform t;
|
||||
public string name;
|
||||
public string path;
|
||||
public Vector3 rootLocalPos;
|
||||
public Quaternion rootLocalRot;
|
||||
public HumanBodyBones hBone = (HumanBodyBones)55;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f86c83d34b8a02f43957580934fc99d5
|
||||
guid: 39ce956a348f7e24095c2239c465fb1e
|
||||
@@ -1,20 +1,20 @@
|
||||
// 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
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: Eden.AutoMorpher.BvhNode
|
||||
// Assembly: EdenAutoMorpherScript, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: D39968B3-E151-4276-BDB4-E82752BBAFF0
|
||||
// Assembly location: D:\dev\AutoMorpher\Assets\@Eden_Tools\Eden_AutoMorpher\Script\EdenAutoMorpherScript.dll
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace Eden.AutoMorpher
|
||||
{
|
||||
public struct BvhNode
|
||||
{
|
||||
public Bounds bounds;
|
||||
|
||||
public int leftChild;
|
||||
|
||||
public int rightChild;
|
||||
|
||||
public int start;
|
||||
|
||||
public int count;
|
||||
|
||||
public bool isLeaf;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9b5eed04003cc164caea2b92431ac42e
|
||||
guid: 10c3a2ab07ede5146a5d92236e6735b6
|
||||
@@ -1,18 +1,19 @@
|
||||
// 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
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: Eden.AutoMorpher.BvhTriangle
|
||||
// Assembly: EdenAutoMorpherScript, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: D39968B3-E151-4276-BDB4-E82752BBAFF0
|
||||
// Assembly location: D:\dev\AutoMorpher\Assets\@Eden_Tools\Eden_AutoMorpher\Script\EdenAutoMorpherScript.dll
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace Eden.AutoMorpher
|
||||
{
|
||||
public struct BvhTriangle
|
||||
{
|
||||
public Vector3 a;
|
||||
|
||||
public Vector3 b;
|
||||
|
||||
public Vector3 c;
|
||||
|
||||
public Vector3 normal;
|
||||
|
||||
public HumanBodyBones mainHumanBone;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 44ba3839eef03a64c9c499a67dc02420
|
||||
guid: 4947000410991e449b49bad5e74aec76
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,2 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b11038f4c94c79a419d6d3b4c5bf1810
|
||||
guid: feac9ce49c744e7458ea3f9a49d761d9
|
||||
@@ -1,9 +1,14 @@
|
||||
// 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
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: Eden.AutoMorpher.ClothBoneType
|
||||
// Assembly: EdenAutoMorpherScript, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: D39968B3-E151-4276-BDB4-E82752BBAFF0
|
||||
// Assembly location: D:\dev\AutoMorpher\Assets\@Eden_Tools\Eden_AutoMorpher\Script\EdenAutoMorpherScript.dll
|
||||
|
||||
namespace Eden.AutoMorpher
|
||||
{
|
||||
public enum ClothBoneType
|
||||
{
|
||||
Body,
|
||||
Accessory
|
||||
Accessory,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7a85f954ffdaea34ba8dd2b70733ae6a
|
||||
guid: 5d1467eb46bc3ce4abdcee64c9422a25
|
||||
@@ -1,164 +1,155 @@
|
||||
// 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
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: Eden.AutoMorpher.ClothHumanoidMaskUtil
|
||||
// Assembly: EdenAutoMorpherScript, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: D39968B3-E151-4276-BDB4-E82752BBAFF0
|
||||
// Assembly location: D:\dev\AutoMorpher\Assets\@Eden_Tools\Eden_AutoMorpher\Script\EdenAutoMorpherScript.dll
|
||||
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Eden.AutoMorpher
|
||||
{
|
||||
public class ClothHumanoidMaskUtil
|
||||
{
|
||||
public void BuildExcludedVertexMaskForHandsAndHead(ClothInstance clothInstance, bool excludeHandRoot = false, bool excludeThumbRoot = false)
|
||||
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)
|
||||
if (clothInstance == null || Object.op_Equality((Object)clothInstance.smr, (Object)null))
|
||||
{
|
||||
Debug.LogWarning((object)"[ClothHumanoidMaskUtil] clothInstance / smr 가 null");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
SkinnedMeshRenderer smr = clothInstance.smr;
|
||||
Mesh val = clothInstance.editableMesh ?? smr.sharedMesh;
|
||||
if ((Object)(object)val == (Object)null)
|
||||
Mesh mesh = clothInstance.editableMesh ?? smr.sharedMesh;
|
||||
if (Object.op_Equality((Object)mesh, (Object)null))
|
||||
{
|
||||
Debug.LogWarning((object)"[ClothHumanoidMaskUtil] mesh 가 null");
|
||||
return;
|
||||
}
|
||||
BoneWeight[] boneWeights = val.boneWeights;
|
||||
else
|
||||
{
|
||||
BoneWeight[] boneWeights = mesh.boneWeights;
|
||||
Transform[] bones = smr.bones;
|
||||
if (boneWeights == null || boneWeights.Length == 0 || bones == null || bones.Length == 0)
|
||||
{
|
||||
Debug.LogWarning((object)"[ClothHumanoidMaskUtil] boneWeights 또는 bones 비어있음");
|
||||
return;
|
||||
}
|
||||
if (clothInstance.humanoidMatchedBones == null || clothInstance.humanoidMatchedBones.Count == 0)
|
||||
else if (clothInstance.humanoidMatchedBones == null || clothInstance.humanoidMatchedBones.Count == 0)
|
||||
{
|
||||
Debug.LogWarning((object)"[ClothHumanoidMaskUtil] humanoidMatchedBones 가 비어있음 (BodyToClothPoseApplier에서 매칭 안 되었을 가능성)");
|
||||
return;
|
||||
}
|
||||
int num = val.vertexCount;
|
||||
if (boneWeights.Length != num)
|
||||
else
|
||||
{
|
||||
num = Mathf.Min(num, boneWeights.Length);
|
||||
}
|
||||
int length = mesh.vertexCount;
|
||||
if (boneWeights.Length != length)
|
||||
length = Mathf.Min(length, boneWeights.Length);
|
||||
HashSet<Transform> excludedBones = new HashSet<Transform>();
|
||||
Dictionary<HumanBodyBones, HashSet<Transform>> humanoidMatchedBones = clothInstance.humanoidMatchedBones;
|
||||
if (humanoidMatchedBones.TryGetValue((HumanBodyBones)10, out var value) && value != null)
|
||||
HashSet<Transform> transformSet1;
|
||||
if (humanoidMatchedBones.TryGetValue((HumanBodyBones)10, out transformSet1) && transformSet1 != null)
|
||||
{
|
||||
foreach (Transform item in value)
|
||||
foreach (Transform root in transformSet1)
|
||||
{
|
||||
if (!((Object)(object)item == (Object)null))
|
||||
{
|
||||
AddHierarchy(item, includeRoot: true);
|
||||
if (!Object.op_Equality((Object)root, (Object)null))
|
||||
AddHierarchy(root, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (humanoidMatchedBones.TryGetValue((HumanBodyBones)17, out var value2) && value2 != null)
|
||||
HashSet<Transform> transformSet2;
|
||||
if (humanoidMatchedBones.TryGetValue((HumanBodyBones)17, out transformSet2) && transformSet2 != null)
|
||||
{
|
||||
foreach (Transform item2 in value2)
|
||||
foreach (Transform root in transformSet2)
|
||||
{
|
||||
if (!((Object)(object)item2 == (Object)null))
|
||||
{
|
||||
AddHierarchy(item2, excludeHandRoot);
|
||||
if (!Object.op_Equality((Object)root, (Object)null))
|
||||
AddHierarchy(root, excludeHandRoot);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (humanoidMatchedBones.TryGetValue((HumanBodyBones)18, out var value3) && value3 != null)
|
||||
HashSet<Transform> transformSet3;
|
||||
if (humanoidMatchedBones.TryGetValue((HumanBodyBones)18, out transformSet3) && transformSet3 != null)
|
||||
{
|
||||
foreach (Transform item3 in value3)
|
||||
foreach (Transform root in transformSet3)
|
||||
{
|
||||
if (!((Object)(object)item3 == (Object)null))
|
||||
{
|
||||
AddHierarchy(item3, excludeHandRoot);
|
||||
if (!Object.op_Equality((Object)root, (Object)null))
|
||||
AddHierarchy(root, excludeHandRoot);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (humanoidMatchedBones.TryGetValue((HumanBodyBones)24, out var value4) && value4 != null)
|
||||
HashSet<Transform> transformSet4;
|
||||
if (humanoidMatchedBones.TryGetValue((HumanBodyBones)24, out transformSet4) && transformSet4 != null)
|
||||
{
|
||||
foreach (Transform item4 in value4)
|
||||
foreach (Transform transform in transformSet4)
|
||||
{
|
||||
if (!((Object)(object)item4 == (Object)null))
|
||||
if (!Object.op_Equality((Object)transform, (Object)null))
|
||||
{
|
||||
if (excludeThumbRoot)
|
||||
{
|
||||
excludedBones.Add(item4);
|
||||
}
|
||||
excludedBones.Add(transform);
|
||||
else
|
||||
excludedBones.Remove(transform);
|
||||
}
|
||||
}
|
||||
}
|
||||
HashSet<Transform> transformSet5;
|
||||
if (humanoidMatchedBones.TryGetValue((HumanBodyBones)39, out transformSet5) && transformSet5 != null)
|
||||
{
|
||||
excludedBones.Remove(item4);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (humanoidMatchedBones.TryGetValue((HumanBodyBones)39, out var value5) && value5 != null)
|
||||
foreach (Transform transform in transformSet5)
|
||||
{
|
||||
foreach (Transform item5 in value5)
|
||||
{
|
||||
if (!((Object)(object)item5 == (Object)null))
|
||||
if (!Object.op_Equality((Object)transform, (Object)null))
|
||||
{
|
||||
if (excludeThumbRoot)
|
||||
{
|
||||
excludedBones.Add(item5);
|
||||
}
|
||||
excludedBones.Add(transform);
|
||||
else
|
||||
{
|
||||
excludedBones.Remove(item5);
|
||||
}
|
||||
excludedBones.Remove(transform);
|
||||
}
|
||||
}
|
||||
}
|
||||
bool[] boneIndexExcluded = new bool[bones.Length];
|
||||
for (int i = 0; i < bones.Length; i++)
|
||||
for (int index = 0; index < bones.Length; ++index)
|
||||
{
|
||||
Transform val2 = bones[i];
|
||||
if ((Object)(object)val2 != (Object)null && excludedBones.Contains(val2))
|
||||
{
|
||||
boneIndexExcluded[i] = true;
|
||||
Transform transform = bones[index];
|
||||
if (Object.op_Inequality((Object)transform, (Object)null) && excludedBones.Contains(transform))
|
||||
boneIndexExcluded[index] = true;
|
||||
}
|
||||
}
|
||||
bool[] array = new bool[num];
|
||||
for (int j = 0; j < num; j++)
|
||||
bool[] flagArray = new bool[length];
|
||||
for (int index = 0; index < length; ++index)
|
||||
{
|
||||
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;
|
||||
BoneWeight boneWeight = boneWeights[index];
|
||||
float excludedWeightSum = 0.0f;
|
||||
AddExcludedWeight(((BoneWeight)ref boneWeight).weight0, ((BoneWeight)ref boneWeight).boneIndex0);
|
||||
AddExcludedWeight(((BoneWeight)ref boneWeight).weight1, ((BoneWeight)ref boneWeight).boneIndex1);
|
||||
AddExcludedWeight(((BoneWeight)ref boneWeight).weight2, ((BoneWeight)ref boneWeight).boneIndex2);
|
||||
AddExcludedWeight(((BoneWeight)ref boneWeight).weight3, ((BoneWeight)ref boneWeight).boneIndex3);
|
||||
flagArray[index] = (double)excludedWeightSum >= 0.800000011920929;
|
||||
|
||||
void AddExcludedWeight(float w, int bi)
|
||||
{
|
||||
if (!(w <= 0f) && bi >= 0 && bi < boneIndexExcluded.Length && boneIndexExcluded[bi])
|
||||
{
|
||||
if ((double)w <= 0.0 || bi < 0 || bi >= boneIndexExcluded.Length || !boneIndexExcluded[bi])
|
||||
return;
|
||||
excludedWeightSum += w;
|
||||
}
|
||||
}
|
||||
}
|
||||
clothInstance.excludedVertices = array;
|
||||
clothInstance.excludedVertices = flagArray;
|
||||
this.BuildLegVertexMasks(clothInstance);
|
||||
|
||||
void AddHierarchy(Transform root, bool includeRoot)
|
||||
{
|
||||
if (!((Object)(object)root == (Object)null))
|
||||
{
|
||||
Stack<Transform> stack = new Stack<Transform>();
|
||||
if (Object.op_Equality((Object)root, (Object)null))
|
||||
return;
|
||||
Stack<Transform> transformStack = new Stack<Transform>();
|
||||
if (includeRoot)
|
||||
{
|
||||
stack.Push(root);
|
||||
transformStack.Push(root);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int k = 0; k < root.childCount; k++)
|
||||
{
|
||||
stack.Push(root.GetChild(k));
|
||||
for (int index = 0; index < root.childCount; ++index)
|
||||
transformStack.Push(root.GetChild(index));
|
||||
}
|
||||
while (transformStack.Count > 0)
|
||||
{
|
||||
Transform transform = transformStack.Pop();
|
||||
if (!Object.op_Equality((Object)transform, (Object)null) && excludedBones.Add(transform))
|
||||
{
|
||||
for (int index = 0; index < transform.childCount; ++index)
|
||||
transformStack.Push(transform.GetChild(index));
|
||||
}
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -168,135 +159,124 @@ public class ClothHumanoidMaskUtil
|
||||
|
||||
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)
|
||||
if (clothInstance == null || Object.op_Equality((Object)clothInstance.smr, (Object)null))
|
||||
{
|
||||
Debug.LogWarning((object)"[ClothHumanoidMaskUtil] clothInstance / smr 가 null");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
SkinnedMeshRenderer smr = clothInstance.smr;
|
||||
Mesh val = clothInstance.editableMesh ?? smr.sharedMesh;
|
||||
if ((Object)(object)val == (Object)null)
|
||||
Mesh mesh = clothInstance.editableMesh ?? smr.sharedMesh;
|
||||
if (Object.op_Equality((Object)mesh, (Object)null))
|
||||
{
|
||||
Debug.LogWarning((object)"[ClothHumanoidMaskUtil] mesh 가 null");
|
||||
return;
|
||||
}
|
||||
BoneWeight[] boneWeights = val.boneWeights;
|
||||
else
|
||||
{
|
||||
BoneWeight[] boneWeights = mesh.boneWeights;
|
||||
Transform[] bones = smr.bones;
|
||||
if (boneWeights == null || boneWeights.Length == 0 || bones == null || bones.Length == 0)
|
||||
{
|
||||
Debug.LogWarning((object)"[ClothHumanoidMaskUtil] boneWeights 또는 bones 비어있음");
|
||||
return;
|
||||
}
|
||||
if (clothInstance.humanoidMatchedBones == null || clothInstance.humanoidMatchedBones.Count == 0)
|
||||
else if (clothInstance.humanoidMatchedBones == null || clothInstance.humanoidMatchedBones.Count == 0)
|
||||
{
|
||||
Debug.LogWarning((object)"[ClothHumanoidMaskUtil] humanoidMatchedBones 가 비어있음 (BodyToClothPoseApplier에서 매칭 필요)");
|
||||
return;
|
||||
}
|
||||
int num = val.vertexCount;
|
||||
if (boneWeights.Length != num)
|
||||
else
|
||||
{
|
||||
num = Mathf.Min(num, boneWeights.Length);
|
||||
}
|
||||
int length = mesh.vertexCount;
|
||||
if (boneWeights.Length != length)
|
||||
length = Mathf.Min(length, boneWeights.Length);
|
||||
Dictionary<HumanBodyBones, HashSet<Transform>> humanoidMatchedBones = clothInstance.humanoidMatchedBones;
|
||||
HashSet<Transform> hashSet = new HashSet<Transform>();
|
||||
HashSet<Transform> hashSet2 = new HashSet<Transform>();
|
||||
if (humanoidMatchedBones.TryGetValue((HumanBodyBones)1, out var value) && value != null)
|
||||
HashSet<Transform> set1 = new HashSet<Transform>();
|
||||
HashSet<Transform> set2 = new HashSet<Transform>();
|
||||
HashSet<Transform> transformSet1;
|
||||
if (humanoidMatchedBones.TryGetValue((HumanBodyBones)1, out transformSet1) && transformSet1 != null)
|
||||
{
|
||||
foreach (Transform item in value)
|
||||
foreach (Transform root in transformSet1)
|
||||
{
|
||||
if (!((Object)(object)item == (Object)null))
|
||||
{
|
||||
CollectHierarchy(item, hashSet);
|
||||
if (!Object.op_Equality((Object)root, (Object)null))
|
||||
CollectHierarchy(root, set1);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (humanoidMatchedBones.TryGetValue((HumanBodyBones)2, out var value2) && value2 != null)
|
||||
HashSet<Transform> transformSet2;
|
||||
if (humanoidMatchedBones.TryGetValue((HumanBodyBones)2, out transformSet2) && transformSet2 != null)
|
||||
{
|
||||
foreach (Transform item2 in value2)
|
||||
foreach (Transform root in transformSet2)
|
||||
{
|
||||
if (!((Object)(object)item2 == (Object)null))
|
||||
{
|
||||
CollectHierarchy(item2, hashSet2);
|
||||
}
|
||||
if (!Object.op_Equality((Object)root, (Object)null))
|
||||
CollectHierarchy(root, set2);
|
||||
}
|
||||
}
|
||||
bool[] boneIsLeftLeg = new bool[bones.Length];
|
||||
bool[] boneIsRightLeg = new bool[bones.Length];
|
||||
for (int i = 0; i < bones.Length; i++)
|
||||
for (int index = 0; index < bones.Length; ++index)
|
||||
{
|
||||
Transform val2 = bones[i];
|
||||
if (!((Object)(object)val2 == (Object)null))
|
||||
Transform transform = bones[index];
|
||||
if (!Object.op_Equality((Object)transform, (Object)null))
|
||||
{
|
||||
if (hashSet.Contains(val2))
|
||||
{
|
||||
boneIsLeftLeg[i] = true;
|
||||
}
|
||||
if (hashSet2.Contains(val2))
|
||||
{
|
||||
boneIsRightLeg[i] = true;
|
||||
if (set1.Contains(transform))
|
||||
boneIsLeftLeg[index] = true;
|
||||
if (set2.Contains(transform))
|
||||
boneIsRightLeg[index] = true;
|
||||
}
|
||||
}
|
||||
bool[] flagArray1 = new bool[length];
|
||||
bool[] flagArray2 = new bool[length];
|
||||
for (int index = 0; index < length; ++index)
|
||||
{
|
||||
BoneWeight boneWeight = boneWeights[index];
|
||||
float leftWeight = 0.0f;
|
||||
float rightWeight = 0.0f;
|
||||
Check(((BoneWeight)ref boneWeight).boneIndex0, ((BoneWeight)ref boneWeight).weight0);
|
||||
Check(((BoneWeight)ref boneWeight).boneIndex1, ((BoneWeight)ref boneWeight).weight1);
|
||||
Check(((BoneWeight)ref boneWeight).boneIndex2, ((BoneWeight)ref boneWeight).weight2);
|
||||
Check(((BoneWeight)ref boneWeight).boneIndex3, ((BoneWeight)ref boneWeight).weight3);
|
||||
if ((double)leftWeight > 0.800000011920929)
|
||||
{
|
||||
flagArray1[index] = true;
|
||||
flagArray2[index] = false;
|
||||
}
|
||||
bool[] array = new bool[num];
|
||||
bool[] array2 = new bool[num];
|
||||
for (int j = 0; j < num; j++)
|
||||
else if ((double)rightWeight > 0.800000011920929)
|
||||
{
|
||||
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;
|
||||
flagArray1[index] = false;
|
||||
flagArray2[index] = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
array[j] = false;
|
||||
array2[j] = false;
|
||||
flagArray1[index] = false;
|
||||
flagArray2[index] = false;
|
||||
}
|
||||
|
||||
void Check(int bi, float w)
|
||||
{
|
||||
if (bi >= 0 && bi < bones.Length && !(w <= 0f))
|
||||
{
|
||||
if (bi < 0 || bi >= bones.Length || (double)w <= 0.0)
|
||||
return;
|
||||
if (boneIsLeftLeg[bi])
|
||||
{
|
||||
leftWeight += w;
|
||||
}
|
||||
if (boneIsRightLeg[bi])
|
||||
{
|
||||
if (!boneIsRightLeg[bi])
|
||||
return;
|
||||
rightWeight += w;
|
||||
}
|
||||
}
|
||||
clothInstance.isLeftLegVertex = flagArray1;
|
||||
clothInstance.isRightLegVertex = flagArray2;
|
||||
}
|
||||
}
|
||||
clothInstance.isLeftLegVertex = array;
|
||||
clothInstance.isRightLegVertex = array2;
|
||||
void CollectHierarchy(Transform root, HashSet<Transform> set)
|
||||
}
|
||||
|
||||
static void CollectHierarchy(Transform root, HashSet<Transform> set)
|
||||
{
|
||||
if (!((Object)(object)root == (Object)null))
|
||||
if (Object.op_Equality((Object)root, (Object)null))
|
||||
return;
|
||||
Stack<Transform> transformStack = new Stack<Transform>();
|
||||
transformStack.Push(root);
|
||||
while (transformStack.Count > 0)
|
||||
{
|
||||
Stack<Transform> stack = new Stack<Transform>();
|
||||
stack.Push(root);
|
||||
while (stack.Count > 0)
|
||||
Transform transform = transformStack.Pop();
|
||||
if (!Object.op_Equality((Object)transform, (Object)null) && set.Add(transform))
|
||||
{
|
||||
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));
|
||||
}
|
||||
for (int index = 0; index < transform.childCount; ++index)
|
||||
transformStack.Push(transform.GetChild(index));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9a879c7a5d70cc44d91ba2a65259927d
|
||||
guid: 4e30cb89b417c4648ab8278d89cce772
|
||||
@@ -1,48 +1,35 @@
|
||||
// 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
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: Eden.AutoMorpher.ClothInstance
|
||||
// Assembly: EdenAutoMorpherScript, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: D39968B3-E151-4276-BDB4-E82752BBAFF0
|
||||
// Assembly location: D:\dev\AutoMorpher\Assets\@Eden_Tools\Eden_AutoMorpher\Script\EdenAutoMorpherScript.dll
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Eden.AutoMorpher
|
||||
{
|
||||
[Serializable]
|
||||
public class ClothInstance
|
||||
{
|
||||
public SkinnedMeshRenderer smr;
|
||||
|
||||
public Mesh editableMesh;
|
||||
|
||||
public Mesh bakedMesh;
|
||||
|
||||
public Matrix4x4 worldNoScale;
|
||||
|
||||
public Vector3[] worldVertices;
|
||||
|
||||
public Vector3[] minDistanceVector;
|
||||
|
||||
public float[] minDistance;
|
||||
|
||||
public Vector3[] deltas;
|
||||
|
||||
public Vector3[] deltasLocal;
|
||||
|
||||
public List<int>[] vertexAdjacency;
|
||||
|
||||
public List<List<int>> equivalentVertices;
|
||||
|
||||
public bool[] isInsideVertex;
|
||||
|
||||
public bool[] excludedVertices;
|
||||
|
||||
public bool[] isLeftLegVertex;
|
||||
|
||||
public bool[] isRightLegVertex;
|
||||
|
||||
public Vector3[] bakedWorldNormals;
|
||||
|
||||
public Vector4[] bakedWorldTangents;
|
||||
|
||||
public Dictionary<HumanBodyBones, HashSet<Transform>> humanoidMatchedBones;
|
||||
|
||||
public ClothInstance(SkinnedMeshRenderer clotheSMR, bool duplicateMesh = true)
|
||||
@@ -50,19 +37,17 @@ public class ClothInstance
|
||||
this.smr = clotheSMR;
|
||||
if (duplicateMesh)
|
||||
{
|
||||
string name = this.smr.sharedMesh.name;
|
||||
this.editableMesh = UnityEngine.Object.Instantiate<Mesh>(clotheSMR.sharedMesh);
|
||||
this.editableMesh.name = name + "_EditableMesh";
|
||||
string name = ((Object)this.smr.sharedMesh).name;
|
||||
this.editableMesh = Object.Instantiate<Mesh>(clotheSMR.sharedMesh);
|
||||
((Object)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.minDistanceVector = new Vector3[vertexCount];
|
||||
this.deltas = new Vector3[vertexCount];
|
||||
this.minDistance = new float[vertexCount];
|
||||
this.isInsideVertex = new bool[vertexCount];
|
||||
this.excludedVertices = new bool[vertexCount];
|
||||
@@ -75,227 +60,135 @@ public class ClothInstance
|
||||
|
||||
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)
|
||||
{
|
||||
if (Object.op_Equality((Object)this.bakedMesh, (Object)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++)
|
||||
Vector3 vector3_1;
|
||||
// ISSUE: explicit constructor call
|
||||
((Vector3)ref vector3_1).\u002Ector(1f / Mathf.Max(lossyScale.x, 1E-08f), 1f / Mathf.Max(lossyScale.y, 1E-08f), 1f / Mathf.Max(lossyScale.z, 1E-08f));
|
||||
this.worldNoScale = Matrix4x4.op_Multiply(((Component)this.smr).transform.localToWorldMatrix, Matrix4x4.Scale(vector3_1));
|
||||
this.worldVertices = new Vector3[vertexCount];
|
||||
this.deltasLocal = new Vector3[vertexCount];
|
||||
for (int index = 0; index < vertexCount; ++index)
|
||||
{
|
||||
this.worldVertices[i] = this.worldNoScale.MultiplyPoint3x4(this.bakedMesh.vertices[i]);
|
||||
this.deltasLocal[i] = Vector3.zero;
|
||||
this.worldVertices[index] = ((Matrix4x4)ref this.worldNoScale).MultiplyPoint3x4(this.bakedMesh.vertices[index]);
|
||||
this.deltasLocal[index] = 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.bakedWorldNormals = new Vector3[vertexCount];
|
||||
this.bakedWorldTangents = tangents == null || tangents.Length != vertexCount ? (Vector4[])null : new Vector4[vertexCount];
|
||||
for (int index1 = 0; index1 < vertexCount; ++index1)
|
||||
{
|
||||
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;
|
||||
Vector3[] bakedWorldNormals = this.bakedWorldNormals;
|
||||
int index2 = index1;
|
||||
Vector3 vector3_2 = ((Component)this.smr).transform.TransformDirection(normals[index1]);
|
||||
Vector3 normalized1 = ((Vector3)ref vector3_2).normalized;
|
||||
bakedWorldNormals[index2] = normalized1;
|
||||
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);
|
||||
vector3_2 = ((Component)this.smr).transform.TransformDirection(new Vector3(tangents[index1].x, tangents[index1].y, tangents[index1].z));
|
||||
Vector3 normalized2 = ((Vector3)ref vector3_2).normalized;
|
||||
this.bakedWorldTangents[index1] = new Vector4(normalized2.x, normalized2.y, normalized2.z, tangents[index1].w);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<int>[] BuildVertexAdjacency(Mesh mesh, float seamThreshold = 0.0001f, float proximityThreshold = 0f)
|
||||
public List<int>[] BuildVertexAdjacency(Mesh mesh, float seamThreshold = 0.0001f, float proximityThreshold = 0.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 length = !Object.op_Equality((Object)mesh, (Object)null) ? mesh.vertexCount : throw new AutoMorpherException("Mesh is Missing", "[VertexAdjacencyUtil] BuildVertexAdjacency\n - mesh is null");
|
||||
int[] triangles = mesh.triangles;
|
||||
Vector3[] vertices = mesh.vertices;
|
||||
List<int>[] array = new List<int>[vertexCount];
|
||||
for (int i = 0; i < vertexCount; i++)
|
||||
List<int>[] adj = new List<int>[length];
|
||||
for (int index = 0; index < length; ++index)
|
||||
adj[index] = new List<int>();
|
||||
int num1 = triangles.Length / 3;
|
||||
for (int index = 0; index < num1; ++index)
|
||||
{
|
||||
array[i] = new List<int>();
|
||||
int num2 = triangles[index * 3];
|
||||
int num3 = triangles[index * 3 + 1];
|
||||
int num4 = triangles[index * 3 + 2];
|
||||
AddNeighbor(adj, num2, num3);
|
||||
AddNeighbor(adj, num3, num2);
|
||||
AddNeighbor(adj, num3, num4);
|
||||
AddNeighbor(adj, num4, num3);
|
||||
AddNeighbor(adj, num4, num2);
|
||||
AddNeighbor(adj, num2, num4);
|
||||
}
|
||||
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)
|
||||
if ((double)seamThreshold > 0.0)
|
||||
{
|
||||
float num5 = seamThreshold * 2f;
|
||||
float num6 = seamThreshold * seamThreshold;
|
||||
Dictionary<Vector3Int, List<int>> dictionary = new Dictionary<Vector3Int, List<int>>();
|
||||
Vector3Int key = default(Vector3Int);
|
||||
for (int k = 0; k < vertexCount; k++)
|
||||
for (int index = 0; index < length; ++index)
|
||||
{
|
||||
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))
|
||||
Vector3 vector3 = vertices[index];
|
||||
Vector3Int key;
|
||||
// ISSUE: explicit constructor call
|
||||
((Vector3Int)ref key).\u002Ector(Mathf.FloorToInt(vector3.x / num5), Mathf.FloorToInt(vector3.y / num5), Mathf.FloorToInt(vector3.z / num5));
|
||||
List<int> intList;
|
||||
if (!dictionary.TryGetValue(key, out intList))
|
||||
{
|
||||
value = (dictionary[key] = new List<int>());
|
||||
intList = new List<int>();
|
||||
dictionary[key] = intList;
|
||||
}
|
||||
value.Add(k);
|
||||
intList.Add(index);
|
||||
}
|
||||
Vector3Int val2 = default(Vector3Int);
|
||||
foreach (KeyValuePair<Vector3Int, List<int>> item in dictionary)
|
||||
foreach (KeyValuePair<Vector3Int, List<int>> keyValuePair in dictionary)
|
||||
{
|
||||
Vector3Int key2 = item.Key;
|
||||
List<int> value2 = item.Value;
|
||||
for (int l = -1; l <= 1; l++)
|
||||
Vector3Int key1 = keyValuePair.Key;
|
||||
List<int> intList1 = keyValuePair.Value;
|
||||
for (int index1 = -1; index1 <= 1; ++index1)
|
||||
{
|
||||
for (int m = -1; m <= 1; m++)
|
||||
for (int index2 = -1; index2 <= 1; ++index2)
|
||||
{
|
||||
for (int n = -1; n <= 1; n++)
|
||||
for (int index3 = -1; index3 <= 1; ++index3)
|
||||
{
|
||||
if (l < 0 || (l == 0 && m < 0) || (l == 0 && m == 0 && n < 0))
|
||||
if (index1 >= 0 && (index1 != 0 || index2 >= 0) && (index1 != 0 || index2 != 0 || index3 >= 0))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
val2 = new(key2.x + l, key2.y + m, key2.z + n);
|
||||
if (!dictionary.TryGetValue(val2, out var value3))
|
||||
Vector3Int key2;
|
||||
// ISSUE: explicit constructor call
|
||||
((Vector3Int)ref key2).\u002Ector(((Vector3Int)ref key1).x + index1, ((Vector3Int)ref key1).y + index2, ((Vector3Int)ref key1).z + index3);
|
||||
List<int> intList2;
|
||||
Vector3 vector3_1;
|
||||
if (dictionary.TryGetValue(key2, out intList2))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (val2 == key2)
|
||||
if (Vector3Int.op_Equality(key2, key1))
|
||||
{
|
||||
for (int num7 = 0; num7 < value2.Count; num7++)
|
||||
for (int index4 = 0; index4 < intList1.Count; ++index4)
|
||||
{
|
||||
int num8 = value2[num7];
|
||||
Vector3 val3 = vertices[num8];
|
||||
for (int num9 = num7 + 1; num9 < value2.Count; num9++)
|
||||
int index5 = intList1[index4];
|
||||
Vector3 vector3_2 = vertices[index5];
|
||||
for (int index6 = index4 + 1; index6 < intList1.Count; ++index6)
|
||||
{
|
||||
int num10 = value2[num9];
|
||||
val4 = vertices[num10] - val3;
|
||||
if (val4.sqrMagnitude <= num6)
|
||||
int index7 = intList1[index6];
|
||||
vector3_1 = Vector3.op_Subtraction(vertices[index7], vector3_2);
|
||||
if ((double)((Vector3)ref vector3_1).sqrMagnitude <= (double)num6)
|
||||
{
|
||||
AddNeighbor(array, num8, num10);
|
||||
AddNeighbor(array, num10, num8);
|
||||
AddNeighbor(adj, index5, index7);
|
||||
AddNeighbor(adj, index7, index5);
|
||||
}
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
for (int num11 = 0; num11 < value2.Count; num11++)
|
||||
else
|
||||
{
|
||||
int num12 = value2[num11];
|
||||
Vector3 val5 = vertices[num12];
|
||||
for (int num13 = 0; num13 < value3.Count; num13++)
|
||||
for (int index8 = 0; index8 < intList1.Count; ++index8)
|
||||
{
|
||||
int num14 = value3[num13];
|
||||
val4 = vertices[num14] - val5;
|
||||
if (val4.sqrMagnitude <= num6)
|
||||
int index9 = intList1[index8];
|
||||
Vector3 vector3_3 = vertices[index9];
|
||||
for (int index10 = 0; index10 < intList2.Count; ++index10)
|
||||
{
|
||||
AddNeighbor(array, num12, num14);
|
||||
AddNeighbor(array, num14, num12);
|
||||
int index11 = intList2[index10];
|
||||
vector3_1 = Vector3.op_Subtraction(vertices[index11], vector3_3);
|
||||
if ((double)((Vector3)ref vector3_1).sqrMagnitude <= (double)num6)
|
||||
{
|
||||
AddNeighbor(adj, index9, index11);
|
||||
AddNeighbor(adj, index11, index9);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -304,73 +197,79 @@ public class ClothInstance
|
||||
}
|
||||
}
|
||||
}
|
||||
if (proximityThreshold > 0f)
|
||||
{
|
||||
float num15 = proximityThreshold * 2f;
|
||||
float num16 = proximityThreshold * proximityThreshold;
|
||||
Dictionary<Vector3Int, List<int>> dictionary2 = new Dictionary<Vector3Int, List<int>>();
|
||||
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<int>());
|
||||
}
|
||||
value4.Add(num17);
|
||||
}
|
||||
Vector3Int val7 = default(Vector3Int);
|
||||
foreach (KeyValuePair<Vector3Int, List<int>> item2 in dictionary2)
|
||||
{
|
||||
Vector3Int key4 = item2.Key;
|
||||
List<int> 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;
|
||||
if ((double)proximityThreshold > 0.0)
|
||||
{
|
||||
float num7 = proximityThreshold * 2f;
|
||||
float num8 = proximityThreshold * proximityThreshold;
|
||||
Dictionary<Vector3Int, List<int>> dictionary = new Dictionary<Vector3Int, List<int>>();
|
||||
for (int index = 0; index < length; ++index)
|
||||
{
|
||||
Vector3 vector3 = vertices[index];
|
||||
Vector3Int key;
|
||||
// ISSUE: explicit constructor call
|
||||
((Vector3Int)ref key).\u002Ector(Mathf.FloorToInt(vector3.x / num7), Mathf.FloorToInt(vector3.y / num7), Mathf.FloorToInt(vector3.z / num7));
|
||||
List<int> intList;
|
||||
if (!dictionary.TryGetValue(key, out intList))
|
||||
{
|
||||
intList = new List<int>();
|
||||
dictionary[key] = intList;
|
||||
}
|
||||
for (int num25 = 0; num25 < value5.Count; num25++)
|
||||
intList.Add(index);
|
||||
}
|
||||
foreach (KeyValuePair<Vector3Int, List<int>> keyValuePair in dictionary)
|
||||
{
|
||||
int num26 = value5[num25];
|
||||
Vector3 val9 = vertices[num26];
|
||||
for (int num27 = 0; num27 < value6.Count; num27++)
|
||||
Vector3Int key3 = keyValuePair.Key;
|
||||
List<int> intList3 = keyValuePair.Value;
|
||||
for (int index12 = -1; index12 <= 1; ++index12)
|
||||
{
|
||||
int num28 = value6[num27];
|
||||
val4 = vertices[num28] - val9;
|
||||
if (val4.sqrMagnitude <= num16)
|
||||
for (int index13 = -1; index13 <= 1; ++index13)
|
||||
{
|
||||
AddNeighbor(array, num26, num28);
|
||||
AddNeighbor(array, num28, num26);
|
||||
for (int index14 = -1; index14 <= 1; ++index14)
|
||||
{
|
||||
if (index12 >= 0 && (index12 != 0 || index13 >= 0) && (index12 != 0 || index13 != 0 || index14 >= 0))
|
||||
{
|
||||
Vector3Int key4;
|
||||
// ISSUE: explicit constructor call
|
||||
((Vector3Int)ref key4).\u002Ector(((Vector3Int)ref key3).x + index12, ((Vector3Int)ref key3).y + index13, ((Vector3Int)ref key3).z + index14);
|
||||
List<int> intList4;
|
||||
Vector3 vector3_4;
|
||||
if (dictionary.TryGetValue(key4, out intList4))
|
||||
{
|
||||
if (Vector3Int.op_Equality(key4, key3))
|
||||
{
|
||||
for (int index15 = 0; index15 < intList3.Count; ++index15)
|
||||
{
|
||||
int index16 = intList3[index15];
|
||||
Vector3 vector3_5 = vertices[index16];
|
||||
for (int index17 = index15 + 1; index17 < intList3.Count; ++index17)
|
||||
{
|
||||
int index18 = intList3[index17];
|
||||
vector3_4 = Vector3.op_Subtraction(vertices[index18], vector3_5);
|
||||
if ((double)((Vector3)ref vector3_4).sqrMagnitude <= (double)num8)
|
||||
{
|
||||
AddNeighbor(adj, index16, index18);
|
||||
AddNeighbor(adj, index18, index16);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int index19 = 0; index19 < intList3.Count; ++index19)
|
||||
{
|
||||
int index20 = intList3[index19];
|
||||
Vector3 vector3_6 = vertices[index20];
|
||||
for (int index21 = 0; index21 < intList4.Count; ++index21)
|
||||
{
|
||||
int index22 = intList4[index21];
|
||||
vector3_4 = Vector3.op_Subtraction(vertices[index22], vector3_6);
|
||||
if ((double)((Vector3)ref vector3_4).sqrMagnitude <= (double)num8)
|
||||
{
|
||||
AddNeighbor(adj, index20, index22);
|
||||
AddNeighbor(adj, index22, index20);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -379,322 +278,241 @@ public class ClothInstance
|
||||
}
|
||||
}
|
||||
}
|
||||
return array;
|
||||
void AddNeighbor(List<int>[] adj, int from, int to)
|
||||
{
|
||||
List<int> list3 = adj[from];
|
||||
if (!list3.Contains(to))
|
||||
{
|
||||
list3.Add(to);
|
||||
}
|
||||
}
|
||||
}
|
||||
return adj;
|
||||
|
||||
static void AddNeighbor(List<int>[] adj, int from, int to)
|
||||
{
|
||||
List<int> intList = adj[from];
|
||||
if (intList.Contains(to))
|
||||
return;
|
||||
intList.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 (this.editableMesh == null || this.smr == null || this.worldVertices == null)
|
||||
{
|
||||
if (Object.op_Equality((Object)this.editableMesh, (Object)null) || Object.op_Equality((Object)this.smr, (Object)null) || this.worldVertices == null)
|
||||
return;
|
||||
}
|
||||
Mesh val = this.editableMesh;
|
||||
int vertexCount = val.vertexCount;
|
||||
Vector3[] vertices = val.vertices;
|
||||
Mesh editableMesh = this.editableMesh;
|
||||
int vertexCount = editableMesh.vertexCount;
|
||||
Vector3[] vertices = editableMesh.vertices;
|
||||
SkinningUtil skinningUtil = new SkinningUtil();
|
||||
Vector3[] array = null;
|
||||
int blendShapeCount = val.blendShapeCount;
|
||||
Vector3[] vector3Array1 = (Vector3[])null;
|
||||
int blendShapeCount = editableMesh.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++)
|
||||
vector3Array1 = new Vector3[vertexCount];
|
||||
Vector3[] vector3Array2 = new Vector3[vertexCount];
|
||||
Vector3[] vector3Array3 = new Vector3[vertexCount];
|
||||
Vector3[] vector3Array4 = new Vector3[vertexCount];
|
||||
for (int index1 = 0; index1 < blendShapeCount; ++index1)
|
||||
{
|
||||
float blendShapeWeight = this.smr.GetBlendShapeWeight(i);
|
||||
if (Mathf.Approximately(blendShapeWeight, 0f))
|
||||
float blendShapeWeight = this.smr.GetBlendShapeWeight(index1);
|
||||
if (!Mathf.Approximately(blendShapeWeight, 0.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))
|
||||
int num1 = editableMesh.GetBlendShapeFrameCount(index1) - 1;
|
||||
float shapeFrameWeight = editableMesh.GetBlendShapeFrameWeight(index1, num1);
|
||||
editableMesh.GetBlendShapeFrameVertices(index1, num1, vector3Array2, vector3Array3, vector3Array4);
|
||||
float num2 = (double)shapeFrameWeight != 0.0 ? blendShapeWeight / shapeFrameWeight : 0.0f;
|
||||
if (!Mathf.Approximately(num2, 0.0f))
|
||||
{
|
||||
for (int j = 0; j < vertexCount; j++)
|
||||
for (int index2 = 0; index2 < vertexCount; ++index2)
|
||||
{
|
||||
ref Vector3 reference = ref array[j];
|
||||
reference += array2[j] * num2;
|
||||
ref Vector3 local = ref vector3Array1[index2];
|
||||
local = Vector3.op_Addition(local, Vector3.op_Multiply(vector3Array2[index2], num2));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int k = 0; k < vertexCount; k++)
|
||||
}
|
||||
for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
|
||||
{
|
||||
Vector3 val2 = skinningUtil.WorldPosToBindPos_Full(this.smr, val, k, this.worldVertices[k]);
|
||||
if (array != null)
|
||||
{
|
||||
val2 -= array[k];
|
||||
Vector3 vector3 = skinningUtil.WorldPosToBindPos_Full(this.smr, editableMesh, vertexIndex, this.worldVertices[vertexIndex]);
|
||||
if (vector3Array1 != null)
|
||||
vector3 = Vector3.op_Subtraction(vector3, vector3Array1[vertexIndex]);
|
||||
vertices[vertexIndex] = vector3;
|
||||
}
|
||||
vertices[k] = val2;
|
||||
}
|
||||
val.vertices = vertices;
|
||||
Vector3[] array5 = null;
|
||||
Vector3[] array6 = null;
|
||||
editableMesh.vertices = vertices;
|
||||
Vector3[] vector3Array5 = (Vector3[])null;
|
||||
Vector3[] vector3Array6 = (Vector3[])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++)
|
||||
vector3Array5 = new Vector3[vertexCount];
|
||||
vector3Array6 = new Vector3[vertexCount];
|
||||
Vector3[] vector3Array7 = new Vector3[vertexCount];
|
||||
Vector3[] vector3Array8 = new Vector3[vertexCount];
|
||||
Vector3[] vector3Array9 = new Vector3[vertexCount];
|
||||
for (int index3 = 0; index3 < blendShapeCount; ++index3)
|
||||
{
|
||||
float blendShapeWeight2 = this.smr.GetBlendShapeWeight(l);
|
||||
if (Mathf.Approximately(blendShapeWeight2, 0f))
|
||||
float blendShapeWeight = this.smr.GetBlendShapeWeight(index3);
|
||||
if (!Mathf.Approximately(blendShapeWeight, 0.0f))
|
||||
{
|
||||
continue;
|
||||
int num3 = editableMesh.GetBlendShapeFrameCount(index3) - 1;
|
||||
float shapeFrameWeight = editableMesh.GetBlendShapeFrameWeight(index3, num3);
|
||||
editableMesh.GetBlendShapeFrameVertices(index3, num3, vector3Array7, vector3Array8, vector3Array9);
|
||||
float num4 = (double)shapeFrameWeight != 0.0 ? blendShapeWeight / shapeFrameWeight : 0.0f;
|
||||
if (!Mathf.Approximately(num4, 0.0f))
|
||||
{
|
||||
for (int index4 = 0; index4 < vertexCount; ++index4)
|
||||
{
|
||||
ref Vector3 local1 = ref vector3Array5[index4];
|
||||
local1 = Vector3.op_Addition(local1, Vector3.op_Multiply(vector3Array8[index4], num4));
|
||||
ref Vector3 local2 = ref vector3Array6[index4];
|
||||
local2 = Vector3.op_Addition(local2, Vector3.op_Multiply(vector3Array9[index4], num4));
|
||||
}
|
||||
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];
|
||||
Vector3[] vector3Array10 = 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++)
|
||||
Vector4[] vector4Array = flag ? new Vector4[vertexCount] : (Vector4[])null;
|
||||
for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
|
||||
{
|
||||
Vector3 val3 = skinningUtil.WorldDirToBindDir_Full(this.smr, val, n, this.bakedWorldNormals[n]);
|
||||
if (array5 != null)
|
||||
{
|
||||
val3 -= array5[n];
|
||||
}
|
||||
array10[n] = val3.normalized;
|
||||
Vector3 vector3_1 = skinningUtil.WorldDirToBindDir_Full(this.smr, editableMesh, vertexIndex, this.bakedWorldNormals[vertexIndex]);
|
||||
if (vector3Array5 != null)
|
||||
vector3_1 = Vector3.op_Subtraction(vector3_1, vector3Array5[vertexIndex]);
|
||||
vector3Array10[vertexIndex] = ((Vector3)ref vector3_1).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);
|
||||
Vector3 targetWorldDir;
|
||||
// ISSUE: explicit constructor call
|
||||
((Vector3)ref targetWorldDir).\u002Ector(this.bakedWorldTangents[vertexIndex].x, this.bakedWorldTangents[vertexIndex].y, this.bakedWorldTangents[vertexIndex].z);
|
||||
Vector3 vector3_2 = skinningUtil.WorldDirToBindDir_Full(this.smr, editableMesh, vertexIndex, targetWorldDir);
|
||||
if (vector3Array6 != null)
|
||||
vector3_2 = Vector3.op_Subtraction(vector3_2, vector3Array6[vertexIndex]);
|
||||
vector3_2 = ((Vector3)ref vector3_2).normalized;
|
||||
vector4Array[vertexIndex] = new Vector4(vector3_2.x, vector3_2.y, vector3_2.z, this.bakedWorldTangents[vertexIndex].w);
|
||||
}
|
||||
}
|
||||
val.normals = array10;
|
||||
if (array11 != null)
|
||||
{
|
||||
val.tangents = array11;
|
||||
}
|
||||
editableMesh.normals = vector3Array10;
|
||||
if (vector4Array == null)
|
||||
return;
|
||||
editableMesh.tangents = vector4Array;
|
||||
}
|
||||
|
||||
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<List<int>>();
|
||||
}
|
||||
else
|
||||
{
|
||||
int length = this.worldVertices.Length;
|
||||
if (this.equivalentVertices == null)
|
||||
this.equivalentVertices = new List<List<int>>();
|
||||
else
|
||||
this.equivalentVertices.Clear();
|
||||
}
|
||||
float num1 = maxDistance;
|
||||
float num2 = maxDistance * maxDistance;
|
||||
Dictionary<Vector3Int, List<int>> dictionary = new Dictionary<Vector3Int, List<int>>();
|
||||
Vector3Int key = default(Vector3Int);
|
||||
for (int i = 0; i < num; i++)
|
||||
Dictionary<Vector3Int, List<int>> dictionary1 = new Dictionary<Vector3Int, List<int>>();
|
||||
for (int index = 0; index < length; ++index)
|
||||
{
|
||||
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))
|
||||
Vector3 worldVertex = this.worldVertices[index];
|
||||
Vector3Int key;
|
||||
// ISSUE: explicit constructor call
|
||||
((Vector3Int)ref key).\u002Ector(Mathf.FloorToInt(worldVertex.x / num1), Mathf.FloorToInt(worldVertex.y / num1), Mathf.FloorToInt(worldVertex.z / num1));
|
||||
List<int> intList;
|
||||
if (!dictionary1.TryGetValue(key, out intList))
|
||||
{
|
||||
value = (dictionary[key] = new List<int>());
|
||||
intList = new List<int>();
|
||||
dictionary1[key] = intList;
|
||||
}
|
||||
value.Add(i);
|
||||
intList.Add(index);
|
||||
}
|
||||
foreach (KeyValuePair<Vector3Int, List<int>> item in dictionary)
|
||||
foreach (KeyValuePair<Vector3Int, List<int>> keyValuePair in dictionary1)
|
||||
{
|
||||
List<int> value2 = item.Value;
|
||||
int count = value2.Count;
|
||||
if (count < 2)
|
||||
List<int> intList1 = keyValuePair.Value;
|
||||
int count = intList1.Count;
|
||||
if (count >= 2)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
int[] parent = new int[count];
|
||||
for (int j = 0; j < count; j++)
|
||||
for (int index = 0; index < count; ++index)
|
||||
parent[index] = index;
|
||||
for (int index1 = 0; index1 < count; ++index1)
|
||||
{
|
||||
parent[j] = j;
|
||||
}
|
||||
for (int k = 0; k < count; k++)
|
||||
Vector3 worldVertex1 = this.worldVertices[intList1[index1]];
|
||||
for (int index2 = index1 + 1; index2 < count; ++index2)
|
||||
{
|
||||
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);
|
||||
}
|
||||
Vector3 worldVertex2 = this.worldVertices[intList1[index2]];
|
||||
Vector3 vector3 = Vector3.op_Subtraction(worldVertex1, worldVertex2);
|
||||
if ((double)((Vector3)ref vector3).sqrMagnitude <= (double)num2)
|
||||
Union(index1, index2);
|
||||
}
|
||||
}
|
||||
Dictionary<int, List<int>> dictionary2 = new Dictionary<int, List<int>>();
|
||||
for (int m = 0; m < count; m++)
|
||||
for (int index = 0; index < count; ++index)
|
||||
{
|
||||
int key2 = Find(m);
|
||||
if (!dictionary2.TryGetValue(key2, out var value3))
|
||||
int key = Find(index);
|
||||
List<int> intList2;
|
||||
if (!dictionary2.TryGetValue(key, out intList2))
|
||||
{
|
||||
value3 = (dictionary2[key2] = new List<int>());
|
||||
intList2 = new List<int>();
|
||||
dictionary2[key] = intList2;
|
||||
}
|
||||
value3.Add(value2[m]);
|
||||
intList2.Add(intList1[index]);
|
||||
}
|
||||
foreach (List<int> value4 in dictionary2.Values)
|
||||
foreach (List<int> intList3 in dictionary2.Values)
|
||||
{
|
||||
if (value4.Count >= 2)
|
||||
{
|
||||
this.equivalentVertices.Add(value4);
|
||||
}
|
||||
if (intList3.Count >= 2)
|
||||
this.equivalentVertices.Add(intList3);
|
||||
}
|
||||
|
||||
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;
|
||||
int num = Find(a);
|
||||
int index = Find(b);
|
||||
if (num == index)
|
||||
return;
|
||||
parent[index] = num;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
~ClothInstance()
|
||||
{
|
||||
this.Dispose();
|
||||
}
|
||||
~ClothInstance() => this.Dispose();
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (this.bakedMesh != null)
|
||||
if (Object.op_Inequality((Object)this.bakedMesh, (Object)null))
|
||||
{
|
||||
UnityEngine.Object.DestroyImmediate(this.bakedMesh);
|
||||
this.bakedMesh = null;
|
||||
Object.DestroyImmediate((Object)this.bakedMesh);
|
||||
this.bakedMesh = (Mesh)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;
|
||||
this.worldVertices = (Vector3[])null;
|
||||
this.minDistanceVector = (Vector3[])null;
|
||||
this.minDistance = (float[])null;
|
||||
this.deltas = (Vector3[])null;
|
||||
this.deltasLocal = (Vector3[])null;
|
||||
this.isInsideVertex = (bool[])null;
|
||||
this.excludedVertices = (bool[])null;
|
||||
this.isLeftLegVertex = (bool[])null;
|
||||
this.isRightLegVertex = (bool[])null;
|
||||
this.vertexAdjacency = (List<int>[])null;
|
||||
if (this.equivalentVertices != null)
|
||||
{
|
||||
for (int i = 0; i < this.equivalentVertices.Count; i++)
|
||||
{
|
||||
this.equivalentVertices[i]?.Clear();
|
||||
}
|
||||
for (int index = 0; index < this.equivalentVertices.Count; ++index)
|
||||
this.equivalentVertices[index]?.Clear();
|
||||
this.equivalentVertices.Clear();
|
||||
this.equivalentVertices = null;
|
||||
this.equivalentVertices = (List<List<int>>)null;
|
||||
}
|
||||
this.humanoidMatchedBones = (Dictionary<HumanBodyBones, HashSet<Transform>>)null;
|
||||
this.smr = (SkinnedMeshRenderer)null;
|
||||
this.editableMesh = (Mesh)null;
|
||||
}
|
||||
this.humanoidMatchedBones = null;
|
||||
this.smr = null;
|
||||
this.editableMesh = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bbcb7e551afcb6b42899d57659e00ff2
|
||||
guid: 7baaee02374c83c47924c148c233808f
|
||||
@@ -1,10 +1,14 @@
|
||||
// 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
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: Eden.AutoMorpher.ClothInstanceTotal
|
||||
// Assembly: EdenAutoMorpherScript, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: D39968B3-E151-4276-BDB4-E82752BBAFF0
|
||||
// Assembly location: D:\dev\AutoMorpher\Assets\@Eden_Tools\Eden_AutoMorpher\Script\EdenAutoMorpherScript.dll
|
||||
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Eden.AutoMorpher
|
||||
{
|
||||
public class ClothInstanceTotal
|
||||
{
|
||||
private readonly List<ClothInstance> clothInstances;
|
||||
@@ -23,16 +27,15 @@ public class ClothInstanceTotal
|
||||
|
||||
public int[] VertexOffsets { get; private set; }
|
||||
|
||||
public ClothInstanceTotal(List<ClothInstance> clothInstances, float distanceBuildRadius, int maxNeighborsPerVertex = 0)
|
||||
public ClothInstanceTotal(
|
||||
List<ClothInstance> 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)
|
||||
{
|
||||
if ((double)distanceBuildRadius <= 0.0)
|
||||
throw new AutoMorpherException("Distance Build Radius is Invalid", "[ClothInstanceTotal] ClothInstanceTotal\n - distanceBuildRadius must be > 0");
|
||||
}
|
||||
this.clothInstances = clothInstances;
|
||||
this.BuildTopologyCache();
|
||||
this.BuildDistanceAdjacencyCandidates(distanceBuildRadius, maxNeighborsPerVertex);
|
||||
@@ -42,38 +45,28 @@ public class ClothInstanceTotal
|
||||
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)
|
||||
this.ValidateGlobalBufferReady("[ClothInstanceTotal] UpdateGlobalBuffersFromClothInstances");
|
||||
for (int i = 0; i < this.clothInstances.Count; i++)
|
||||
for (int index1 = 0; index1 < this.clothInstances.Count; ++index1)
|
||||
{
|
||||
ClothInstance clothInstance = this.clothInstances[i];
|
||||
ClothInstance clothInstance = this.clothInstances[index1];
|
||||
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)
|
||||
{
|
||||
int vertexOffset = this.VertexOffsets[index1];
|
||||
int length = clothInstance.worldVertices.Length;
|
||||
if (length != 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++)
|
||||
for (int index2 = 0; index2 < length; ++index2)
|
||||
{
|
||||
this.GlobalPositions[num + j] = clothInstance.worldVertices[j];
|
||||
this.GlobalDeltas[num + j] = clothInstance.deltasLocal[j];
|
||||
this.GlobalPositions[vertexOffset + index2] = clothInstance.worldVertices[index2];
|
||||
this.GlobalDeltas[vertexOffset + index2] = clothInstance.deltasLocal[index2];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -81,24 +74,18 @@ public class ClothInstanceTotal
|
||||
|
||||
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++)
|
||||
for (int index1 = 0; index1 < this.clothInstances.Count; ++index1)
|
||||
{
|
||||
ClothInstance clothInstance = this.clothInstances[i];
|
||||
ClothInstance clothInstance = this.clothInstances[index1];
|
||||
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];
|
||||
}
|
||||
int vertexOffset = this.VertexOffsets[index1];
|
||||
int length = clothInstance.deltasLocal.Length;
|
||||
for (int index2 = 0; index2 < length; ++index2)
|
||||
clothInstance.deltasLocal[index2] = this.GlobalDeltas[vertexOffset + index2];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -106,236 +93,191 @@ public class ClothInstanceTotal
|
||||
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)
|
||||
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.GlobalPositions = this.TotalVertexCount > 0 ? new Vector3[this.TotalVertexCount] : throw new AutoMorpherException("Total Vertex Count is Zero", "[ClothInstanceTotal] BuildTopologyCache\n - TotalVertexCount <= 0");
|
||||
this.GlobalDeltas = new Vector3[this.TotalVertexCount];
|
||||
this.GlobalAdjacencyTopology = new List<int>[this.TotalVertexCount];
|
||||
this.VertexOffsets = new int[this.clothInstances.Count];
|
||||
int num = 0;
|
||||
for (int i = 0; i < this.clothInstances.Count; i++)
|
||||
int num1 = 0;
|
||||
for (int index1 = 0; index1 < this.clothInstances.Count; ++index1)
|
||||
{
|
||||
ClothInstance clothInstance = this.clothInstances[i];
|
||||
this.VertexOffsets[i] = num;
|
||||
if (clothInstance == null)
|
||||
ClothInstance clothInstance = this.clothInstances[index1];
|
||||
this.VertexOffsets[index1] = num1;
|
||||
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)
|
||||
{
|
||||
int length = clothInstance.worldVertices.Length;
|
||||
if (length != clothInstance.deltasLocal.Length || length != clothInstance.vertexAdjacency.Length)
|
||||
throw new AutoMorpherException("Cloth Instance Array Length Mismatch", "[ClothInstanceTotal] BuildTopologyCache\n - worldVertices/deltasLocal/vertexAdjacency lengths differ");
|
||||
for (int index2 = 0; index2 < length; ++index2)
|
||||
{
|
||||
this.GlobalPositions[num1 + index2] = clothInstance.worldVertices[index2];
|
||||
this.GlobalDeltas[num1 + index2] = clothInstance.deltasLocal[index2];
|
||||
List<int> intList = clothInstance.vertexAdjacency[index2];
|
||||
// ISSUE: explicit non-virtual call
|
||||
int count = intList != null ? __nonvirtual(intList.Count) : 0;
|
||||
this.GlobalAdjacencyTopology[num1 + index2] = new List<int>(count);
|
||||
}
|
||||
for (int j = 0; j < num2; j++)
|
||||
for (int index3 = 0; index3 < length; ++index3)
|
||||
{
|
||||
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<int>(capacity);
|
||||
}
|
||||
for (int k = 0; k < num2; k++)
|
||||
List<int> intList1 = clothInstance.vertexAdjacency[index3];
|
||||
if (intList1 != null)
|
||||
{
|
||||
List<int> list = clothInstance.vertexAdjacency[k];
|
||||
if (list == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
int num3 = num + k;
|
||||
List<int> list2 = this.GlobalAdjacencyTopology[num3];
|
||||
for (int l = 0; l < list.Count; l++)
|
||||
{
|
||||
int num4 = list[l];
|
||||
if ((uint)num4 >= (uint)num2)
|
||||
List<int> intList2 = this.GlobalAdjacencyTopology[num1 + index3];
|
||||
for (int index4 = 0; index4 < intList1.Count; ++index4)
|
||||
{
|
||||
int num2 = intList1[index4];
|
||||
if ((uint)num2 >= (uint)length)
|
||||
throw new AutoMorpherException("Vertex Adjacency Index is Out of Range", "[ClothInstanceTotal] BuildTopologyCache\n - vertexAdjacency contains invalid neighbor index");
|
||||
}
|
||||
list2.Add(num + num4);
|
||||
intList2.Add(num1 + num2);
|
||||
}
|
||||
}
|
||||
num += num2;
|
||||
}
|
||||
num1 += length;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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 (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<int>[num];
|
||||
for (int i = 0; i < num; i++)
|
||||
int length = this.GlobalAdjacencyTopology.Length;
|
||||
this.GlobalAdjacencyMerged = new List<int>[length];
|
||||
for (int index1 = 0; index1 < length; ++index1)
|
||||
{
|
||||
List<int> list = new List<int>((this.GlobalAdjacencyTopology[i]?.Count ?? 0) + (this.GlobalAdjacencyDistance[i]?.Count ?? 0));
|
||||
HashSet<int> hashSet = new HashSet<int>();
|
||||
List<int> list2 = this.GlobalAdjacencyTopology[i];
|
||||
if (list2 != null)
|
||||
List<int> intList1 = this.GlobalAdjacencyTopology[index1];
|
||||
// ISSUE: explicit non-virtual call
|
||||
int count1 = intList1 != null ? __nonvirtual(intList1.Count) : 0;
|
||||
List<int> intList2 = this.GlobalAdjacencyDistance[index1];
|
||||
// ISSUE: explicit non-virtual call
|
||||
int count2 = intList2 != null ? __nonvirtual(intList2.Count) : 0;
|
||||
List<int> intList3 = new List<int>(count1 + count2);
|
||||
HashSet<int> intSet = new HashSet<int>();
|
||||
List<int> intList4 = this.GlobalAdjacencyTopology[index1];
|
||||
if (intList4 != null)
|
||||
{
|
||||
for (int j = 0; j < list2.Count; j++)
|
||||
for (int index2 = 0; index2 < intList4.Count; ++index2)
|
||||
{
|
||||
int num2 = list2[j];
|
||||
if (num2 != i && hashSet.Add(num2))
|
||||
{
|
||||
list.Add(num2);
|
||||
int num = intList4[index2];
|
||||
if (num != index1 && intSet.Add(num))
|
||||
intList3.Add(num);
|
||||
}
|
||||
}
|
||||
}
|
||||
List<int> list3 = this.GlobalAdjacencyDistance[i];
|
||||
if (list3 != null)
|
||||
List<int> intList5 = this.GlobalAdjacencyDistance[index1];
|
||||
if (intList5 != null)
|
||||
{
|
||||
for (int k = 0; k < list3.Count; k++)
|
||||
for (int index3 = 0; index3 < intList5.Count; ++index3)
|
||||
{
|
||||
int num3 = list3[k];
|
||||
if (num3 != i && hashSet.Add(num3))
|
||||
{
|
||||
list.Add(num3);
|
||||
int num = intList5[index3];
|
||||
if (num != index1 && intSet.Add(num))
|
||||
intList3.Add(num);
|
||||
}
|
||||
}
|
||||
}
|
||||
this.GlobalAdjacencyMerged[i] = list;
|
||||
this.GlobalAdjacencyMerged[index1] = intList3;
|
||||
}
|
||||
}
|
||||
|
||||
private int CalculateTotalVertexCount(List<ClothInstance> clothInstances)
|
||||
{
|
||||
int num = 0;
|
||||
for (int i = 0; i < clothInstances.Count; i++)
|
||||
int totalVertexCount = 0;
|
||||
for (int index = 0; index < clothInstances.Count; ++index)
|
||||
{
|
||||
ClothInstance clothInstance = clothInstances[i];
|
||||
ClothInstance clothInstance = clothInstances[index];
|
||||
if (clothInstance != null && clothInstance.worldVertices != null)
|
||||
{
|
||||
num += clothInstance.worldVertices.Length;
|
||||
totalVertexCount += clothInstance.worldVertices.Length;
|
||||
}
|
||||
}
|
||||
return num;
|
||||
return totalVertexCount;
|
||||
}
|
||||
|
||||
private List<int>[] BuildDistanceAdjacencyCandidatesInternal(Vector3[] referencePositions, float radius, int maxNeighborsPerVertex)
|
||||
private List<int>[] 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)
|
||||
{
|
||||
if ((double)radius <= 0.0)
|
||||
throw new AutoMorpherException("Radius is Invalid", "[ClothInstanceTotal] BuildDistanceAdjacencyCandidatesInternal\n - radius must be > 0");
|
||||
int length = referencePositions.Length;
|
||||
List<int>[] intListArray = new List<int>[length];
|
||||
for (int index = 0; index < length; ++index)
|
||||
intListArray[index] = new List<int>(8);
|
||||
float num1 = 1f / Mathf.Max(radius, 1E-12f);
|
||||
float num2 = radius * radius;
|
||||
Dictionary<Vector3Int, List<int>> dictionary = new Dictionary<Vector3Int, List<int>>(length);
|
||||
for (int index = 0; index < length; ++index)
|
||||
{
|
||||
Vector3 referencePosition = referencePositions[index];
|
||||
Vector3Int key;
|
||||
// ISSUE: explicit constructor call
|
||||
((Vector3Int)ref key).\u002Ector(Mathf.FloorToInt(referencePosition.x * num1), Mathf.FloorToInt(referencePosition.y * num1), Mathf.FloorToInt(referencePosition.z * num1));
|
||||
List<int> intList;
|
||||
if (!dictionary.TryGetValue(key, out intList))
|
||||
{
|
||||
intList = new List<int>(16 /*0x10*/);
|
||||
dictionary.Add(key, intList);
|
||||
}
|
||||
int num = referencePositions.Length;
|
||||
List<int>[] array = new List<int>[num];
|
||||
for (int i = 0; i < num; i++)
|
||||
{
|
||||
array[i] = new List<int>(8);
|
||||
intList.Add(index);
|
||||
}
|
||||
float num2 = 1f / Mathf.Max(radius, 1E-12f);
|
||||
float num3 = radius * radius;
|
||||
Dictionary<Vector3Int, List<int>> dictionary = new Dictionary<Vector3Int, List<int>>(num);
|
||||
Vector3Int key = default(Vector3Int);
|
||||
for (int j = 0; j < num; j++)
|
||||
for (int index1 = 0; index1 < length; ++index1)
|
||||
{
|
||||
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))
|
||||
Vector3 referencePosition = referencePositions[index1];
|
||||
Vector3Int vector3Int;
|
||||
// ISSUE: explicit constructor call
|
||||
((Vector3Int)ref vector3Int).\u002Ector(Mathf.FloorToInt(referencePosition.x * num1), Mathf.FloorToInt(referencePosition.y * num1), Mathf.FloorToInt(referencePosition.z * num1));
|
||||
List<int> intList1 = intListArray[index1];
|
||||
for (int index2 = -1; index2 <= 1; ++index2)
|
||||
{
|
||||
value = new List<int>(16);
|
||||
dictionary.Add(key, value);
|
||||
}
|
||||
value.Add(j);
|
||||
}
|
||||
Vector3Int val3 = default(Vector3Int);
|
||||
Vector3Int key2 = default(Vector3Int);
|
||||
for (int k = 0; k < num; k++)
|
||||
for (int index3 = -1; index3 <= 1; ++index3)
|
||||
{
|
||||
Vector3 val2 = referencePositions[k];
|
||||
val3 = new Vector3Int(Mathf.FloorToInt(val2.x * num2), Mathf.FloorToInt(val2.y * num2), Mathf.FloorToInt(val2.z * num2));
|
||||
List<int> list = array[k];
|
||||
for (int l = -1; l <= 1; l++)
|
||||
for (int index4 = -1; index4 <= 1; ++index4)
|
||||
{
|
||||
for (int m = -1; m <= 1; m++)
|
||||
Vector3Int key;
|
||||
// ISSUE: explicit constructor call
|
||||
((Vector3Int)ref key).\u002Ector(((Vector3Int)ref vector3Int).x + index2, ((Vector3Int)ref vector3Int).y + index3, ((Vector3Int)ref vector3Int).z + index4);
|
||||
List<int> intList2;
|
||||
if (dictionary.TryGetValue(key, out intList2))
|
||||
{
|
||||
for (int n = -1; n <= 1; n++)
|
||||
for (int index5 = 0; index5 < intList2.Count; ++index5)
|
||||
{
|
||||
key2 = new Vector3Int(val3.x + l, val3.y + m, val3.z + n);
|
||||
if (!dictionary.TryGetValue(key2, out var value2))
|
||||
int index6 = intList2[index5];
|
||||
if (index6 != index1)
|
||||
{
|
||||
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)
|
||||
Vector3 vector3 = Vector3.op_Subtraction(referencePositions[index6], referencePosition);
|
||||
if ((double)((Vector3)ref vector3).sqrMagnitude <= (double)num2)
|
||||
{
|
||||
intList1.Add(index6);
|
||||
if (maxNeighborsPerVertex > 0 && intList1.Count >= maxNeighborsPerVertex)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (maxNeighborsPerVertex > 0 && list.Count >= maxNeighborsPerVertex)
|
||||
{
|
||||
if (maxNeighborsPerVertex > 0 && intList1.Count >= maxNeighborsPerVertex)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return array;
|
||||
return intListArray;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f9343c3cb8e18224385a0b0d1c5723bf
|
||||
guid: c3515d0fa4131c9439e99aec94e163bb
|
||||
@@ -1,107 +1,76 @@
|
||||
// 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
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: Eden.AutoMorpher.EdenAutoMorpher
|
||||
// Assembly: EdenAutoMorpherScript, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: D39968B3-E151-4276-BDB4-E82752BBAFF0
|
||||
// Assembly location: D:\dev\AutoMorpher\Assets\@Eden_Tools\Eden_AutoMorpher\Script\EdenAutoMorpherScript.dll
|
||||
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Eden.AutoMorpher
|
||||
{
|
||||
public class EdenAutoMorpher : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
public GameObject sourceAvatarObject;
|
||||
|
||||
[SerializeField]
|
||||
public GameObject sourceClothesObject;
|
||||
|
||||
[SerializeField]
|
||||
private List<SkinnedMeshRenderer> sourceBodyMeshes = new List<SkinnedMeshRenderer>();
|
||||
|
||||
[SerializeField]
|
||||
private IReadOnlyList<SkinnedMeshRenderer> sourceBodyMeshesReadOnly = new List<SkinnedMeshRenderer>();
|
||||
|
||||
private IReadOnlyList<SkinnedMeshRenderer> sourceBodyMeshesReadOnly = (IReadOnlyList<SkinnedMeshRenderer>)new List<SkinnedMeshRenderer>();
|
||||
[SerializeField]
|
||||
public string profileName;
|
||||
|
||||
[SerializeField]
|
||||
public GameObject targetAvatarObject;
|
||||
|
||||
[SerializeField]
|
||||
private GameObject targetClothesObject;
|
||||
|
||||
[SerializeField]
|
||||
private GameObject targetClothesObjectOriginal;
|
||||
|
||||
[SerializeField]
|
||||
private List<SkinnedMeshRenderer> targetBodyMeshes = new List<SkinnedMeshRenderer>();
|
||||
|
||||
[SerializeField]
|
||||
private IReadOnlyList<SkinnedMeshRenderer> targetBodyMeshesReadOnly = new List<SkinnedMeshRenderer>();
|
||||
|
||||
private IReadOnlyList<SkinnedMeshRenderer> targetBodyMeshesReadOnly = (IReadOnlyList<SkinnedMeshRenderer>)new List<SkinnedMeshRenderer>();
|
||||
[SerializeField]
|
||||
private float minMargin = 0.003f;
|
||||
|
||||
private float minMargin = 3f / 1000f;
|
||||
[SerializeField]
|
||||
private float worldRadius = 0.1f;
|
||||
|
||||
[SerializeField]
|
||||
private float sigma = 0.85f;
|
||||
|
||||
[SerializeField]
|
||||
private int smoothingIteration = 1;
|
||||
|
||||
[SerializeField]
|
||||
private int fittingExpandIteration = 10;
|
||||
|
||||
[SerializeField]
|
||||
private int fittingShrinkIteration = 12;
|
||||
|
||||
[SerializeField]
|
||||
public bool isBodyAutoSetup = true;
|
||||
|
||||
[SerializeField]
|
||||
public bool isReparentAccessoryBonesToTargetAvatar = true;
|
||||
|
||||
[SerializeField]
|
||||
public bool skipFootFitting;
|
||||
|
||||
[SerializeField]
|
||||
public bool transferWeightToAvatar;
|
||||
|
||||
[SerializeField]
|
||||
public bool addAnchorBone = true;
|
||||
|
||||
[SerializeField]
|
||||
public bool armatureBoneScaleCopy;
|
||||
|
||||
[SerializeField]
|
||||
public bool isRemoveAutoMorphedClothes = true;
|
||||
|
||||
private Dictionary<HumanBodyBones, HashSet<Transform>> clothesHumanoidMatchedBones;
|
||||
|
||||
private Dictionary<Transform, ClothBoneType> clothBoneTypeMap;
|
||||
|
||||
private GameObject fittedTargetAvatar;
|
||||
|
||||
private GameObject fittedTargetClothes;
|
||||
|
||||
private const string EditedMeshRootFolder = "Assets/@Eden_Mesh";
|
||||
|
||||
private string tagEdenMorpehrCloth = "EDENAutoMorpher_EditedCloth";
|
||||
|
||||
private bool doProcess;
|
||||
|
||||
private MorpherMode morpherMode;
|
||||
|
||||
private MorpherState morpherState;
|
||||
|
||||
private ProcessInfo processInfo;
|
||||
|
||||
public ProcessInfo GetProcessInfo()
|
||||
{
|
||||
return this.processInfo;
|
||||
}
|
||||
public ProcessInfo GetProcessInfo() => this.processInfo;
|
||||
|
||||
public void ChangeMode(MorpherMode newMode)
|
||||
{
|
||||
@@ -128,62 +97,60 @@ public class EdenAutoMorpher : MonoBehaviour
|
||||
|
||||
private EdenAutoMorpherConfig SetupConfigData(MorpherMode morpherMode)
|
||||
{
|
||||
EdenAutoMorpherConfig result = default(EdenAutoMorpherConfig);
|
||||
EdenAutoMorpherConfig autoMorpherConfig = new 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;
|
||||
autoMorpherConfig.sourceAvatarObject = this.sourceAvatarObject;
|
||||
autoMorpherConfig.sourceClothesObject = this.sourceClothesObject;
|
||||
autoMorpherConfig.sourceBodyMeshes = this.sourceBodyMeshesReadOnly;
|
||||
autoMorpherConfig.profileName = string.Empty;
|
||||
break;
|
||||
case MorpherMode.ProfileMorpher:
|
||||
result.sourceAvatarObject = null;
|
||||
result.sourceClothesObject = this.sourceClothesObject;
|
||||
result.sourceBodyMeshes = null;
|
||||
result.profileName = this.profileName;
|
||||
autoMorpherConfig.sourceAvatarObject = (GameObject)null;
|
||||
autoMorpherConfig.sourceClothesObject = this.sourceClothesObject;
|
||||
autoMorpherConfig.sourceBodyMeshes = (IReadOnlyList<SkinnedMeshRenderer>)null;
|
||||
autoMorpherConfig.profileName = this.profileName;
|
||||
break;
|
||||
default:
|
||||
result.sourceAvatarObject = null;
|
||||
result.sourceClothesObject = null;
|
||||
result.sourceBodyMeshes = null;
|
||||
result.profileName = string.Empty;
|
||||
autoMorpherConfig.sourceAvatarObject = (GameObject)null;
|
||||
autoMorpherConfig.sourceClothesObject = (GameObject)null;
|
||||
autoMorpherConfig.sourceBodyMeshes = (IReadOnlyList<SkinnedMeshRenderer>)null;
|
||||
autoMorpherConfig.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;
|
||||
autoMorpherConfig.targetAvatarObject = this.targetAvatarObject;
|
||||
autoMorpherConfig.targetClothesObject = this.targetClothesObject;
|
||||
autoMorpherConfig.targetBodyMeshes = this.targetBodyMeshesReadOnly;
|
||||
autoMorpherConfig.minMargin = this.minMargin;
|
||||
autoMorpherConfig.worldRadius = this.worldRadius;
|
||||
autoMorpherConfig.sigma = this.sigma;
|
||||
autoMorpherConfig.smoothingIteration = this.smoothingIteration;
|
||||
autoMorpherConfig.fittingExpandIteration = this.fittingExpandIteration;
|
||||
autoMorpherConfig.fittingShrinkIteration = this.fittingShrinkIteration;
|
||||
autoMorpherConfig.isBodyAutoSetup = this.isBodyAutoSetup;
|
||||
autoMorpherConfig.isReparentAccessoryBonesToTargetAvatar = this.isReparentAccessoryBonesToTargetAvatar;
|
||||
autoMorpherConfig.skipFootFitting = this.skipFootFitting;
|
||||
autoMorpherConfig.clothesHumanoidMatchedBones = this.clothesHumanoidMatchedBones;
|
||||
autoMorpherConfig.clothBoneTypeMap = this.clothBoneTypeMap;
|
||||
autoMorpherConfig.tagEdenMorpehrCloth = this.tagEdenMorpehrCloth;
|
||||
autoMorpherConfig.transferWeightToAvatar = this.transferWeightToAvatar;
|
||||
autoMorpherConfig.addAnchorBone = this.addAnchorBone;
|
||||
autoMorpherConfig.armatureBoneScaleCopy = this.armatureBoneScaleCopy;
|
||||
autoMorpherConfig.isRemoveAutoMorphedClothes = this.isRemoveAutoMorphedClothes;
|
||||
return autoMorpherConfig;
|
||||
}
|
||||
|
||||
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 transformInfo1 = 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();
|
||||
EdenAutoMorpher_SetUpUtil morpherSetUpUtil = new EdenAutoMorpher_SetUpUtil();
|
||||
this.sourceBodyMeshesReadOnly = (IReadOnlyList<SkinnedMeshRenderer>)morpherSetUpUtil.SetupBodyMeshes(this.sourceAvatarObject, this.isBodyAutoSetup, this.sourceBodyMeshes, "Source ").AsReadOnly();
|
||||
this.targetBodyMeshesReadOnly = (IReadOnlyList<SkinnedMeshRenderer>)morpherSetUpUtil.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);
|
||||
@@ -195,22 +162,18 @@ public class EdenAutoMorpher : MonoBehaviour
|
||||
}
|
||||
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);
|
||||
transformInfo1.ApplyToTransform(this.sourceAvatarObject.transform, true, false, true, true);
|
||||
transformInfo2.ApplyToTransform(this.targetAvatarObject.transform, true, false, true, 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 transformInfo1 = 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.targetBodyMeshesReadOnly = (IReadOnlyList<SkinnedMeshRenderer>)new 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);
|
||||
@@ -223,20 +186,20 @@ public class EdenAutoMorpher : MonoBehaviour
|
||||
}
|
||||
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);
|
||||
transformInfo1.ApplyToTransform(this.sourceClothesObject.transform, true, false, true, true);
|
||||
transformInfo2.ApplyToTransform(this.targetAvatarObject.transform, true, false, true, true);
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerator AutoMorphingEnumerator(MorpherMode morpherMode)
|
||||
{
|
||||
this.doProcess = true;
|
||||
yield return null;
|
||||
yield return (object)null;
|
||||
this.ProcessInfoDebug(morpherMode, "Run ALL");
|
||||
this.morpherState = MorpherState.Fitting_Doing;
|
||||
IEnumerator fitEnum = null;
|
||||
IEnumerator fitEnum = (IEnumerator)null;
|
||||
this.morpherMode = morpherMode;
|
||||
yield return null;
|
||||
yield return (object)null;
|
||||
Debug.Log((object)"[Eden Auto Morpher] Run ALL - Start Fitting");
|
||||
switch (morpherMode)
|
||||
{
|
||||
@@ -254,50 +217,52 @@ public class EdenAutoMorpher : MonoBehaviour
|
||||
break;
|
||||
}
|
||||
while (fitEnum != null && fitEnum.MoveNext() && this.doProcess)
|
||||
{
|
||||
yield return fitEnum.Current;
|
||||
}
|
||||
this.morpherState = MorpherState.Fitting_End;
|
||||
yield return null;
|
||||
yield return (object)null;
|
||||
this.morpherState = MorpherState.Weighting_Doing;
|
||||
yield return null;
|
||||
yield return (object)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);
|
||||
IEnumerator eamFitting = eamManager.WeightingEnumerator(this.SetupConfigData(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();
|
||||
ref string local1 = ref this.processInfo.title;
|
||||
ref string local2 = ref this.processInfo.text;
|
||||
ref float local3 = ref this.processInfo.progress;
|
||||
(string, string, float) progressInfo = eamManager.GetProgressInfo();
|
||||
local1 = progressInfo.Item1;
|
||||
local2 = progressInfo.Item2;
|
||||
double num = (double)progressInfo.Item3;
|
||||
local3 = (float)num;
|
||||
yield return eamFitting.Current;
|
||||
}
|
||||
eamFitting = (IEnumerator)null;
|
||||
}
|
||||
yield return null;
|
||||
yield return (object)null;
|
||||
this.doProcess = false;
|
||||
this.morpherState = MorpherState.Idle;
|
||||
Debug.Log((object)"[Eden Auto Morpher] Ended Run ALL");
|
||||
yield return null;
|
||||
yield return (object)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;
|
||||
ref string local1 = ref this.processInfo.title;
|
||||
ref string local2 = ref this.processInfo.text;
|
||||
ref float local3 = ref this.processInfo.progress;
|
||||
local1 = "Setup Avatar Pose";
|
||||
local2 = "Calculating avatar shape and skeletal data.";
|
||||
local3 = 0.0f;
|
||||
yield return (object)null;
|
||||
this.ProcessInfoDebug(morpherMode, "Fitting");
|
||||
yield return null;
|
||||
yield return (object)null;
|
||||
this.morpherState = MorpherState.Fitting_Doing;
|
||||
IEnumerator fitEnum = null;
|
||||
IEnumerator fitEnum = (IEnumerator)null;
|
||||
this.morpherMode = morpherMode;
|
||||
yield return null;
|
||||
yield return (object)null;
|
||||
switch (morpherMode)
|
||||
{
|
||||
case MorpherMode.AutoMorpher:
|
||||
@@ -314,40 +279,42 @@ public class EdenAutoMorpher : MonoBehaviour
|
||||
break;
|
||||
}
|
||||
while (fitEnum != null && fitEnum.MoveNext() && this.doProcess)
|
||||
{
|
||||
yield return null;
|
||||
}
|
||||
yield return (object)null;
|
||||
this.morpherState = MorpherState.Fitting_End;
|
||||
yield return null;
|
||||
yield return (object)null;
|
||||
this.doProcess = false;
|
||||
Debug.Log((object)"[Eden Auto Morpher] Ended Fitting");
|
||||
yield return null;
|
||||
yield return (object)null;
|
||||
}
|
||||
|
||||
public IEnumerator WeightingEnumerator()
|
||||
{
|
||||
this.morpherState = MorpherState.Weighting_Doing;
|
||||
this.doProcess = true;
|
||||
yield return null;
|
||||
yield return (object)null;
|
||||
this.ProcessInfoDebug(this.morpherMode, "Weighting");
|
||||
using (EdenAutoMorpherManager eamManager = new EdenAutoMorpherManager())
|
||||
{
|
||||
EdenAutoMorpherConfig config = this.SetupConfigData(MorpherMode.ETC);
|
||||
IEnumerator eamFitting = eamManager.WeightingEnumerator(config);
|
||||
IEnumerator eamFitting = eamManager.WeightingEnumerator(this.SetupConfigData(MorpherMode.ETC));
|
||||
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();
|
||||
ref string local1 = ref this.processInfo.title;
|
||||
ref string local2 = ref this.processInfo.text;
|
||||
ref float local3 = ref this.processInfo.progress;
|
||||
(string, string, float) progressInfo = eamManager.GetProgressInfo();
|
||||
local1 = progressInfo.Item1;
|
||||
local2 = progressInfo.Item2;
|
||||
double num = (double)progressInfo.Item3;
|
||||
local3 = (float)num;
|
||||
yield return eamFitting.Current;
|
||||
}
|
||||
eamFitting = (IEnumerator)null;
|
||||
}
|
||||
yield return null;
|
||||
yield return (object)null;
|
||||
this.doProcess = false;
|
||||
this.morpherState = MorpherState.Idle;
|
||||
Debug.Log((object)"[Eden Auto Morpher] Ended Weighting");
|
||||
yield return null;
|
||||
yield return (object)null;
|
||||
}
|
||||
|
||||
public IEnumerator AutoFitting(MorpherMode morpherMode)
|
||||
@@ -356,9 +323,9 @@ public class EdenAutoMorpher : MonoBehaviour
|
||||
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();
|
||||
EdenAutoMorpher_SetUpUtil morpherSetUpUtil = new EdenAutoMorpher_SetUpUtil();
|
||||
this.sourceBodyMeshesReadOnly = (IReadOnlyList<SkinnedMeshRenderer>)morpherSetUpUtil.SetupBodyMeshes(this.sourceAvatarObject, this.isBodyAutoSetup, this.sourceBodyMeshes, "Source ").AsReadOnly();
|
||||
this.targetBodyMeshesReadOnly = (IReadOnlyList<SkinnedMeshRenderer>)morpherSetUpUtil.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);
|
||||
@@ -367,33 +334,38 @@ public class EdenAutoMorpher : MonoBehaviour
|
||||
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;
|
||||
yield return (object)null;
|
||||
this.fittedTargetAvatar = (GameObject)null;
|
||||
this.fittedTargetClothes = (GameObject)null;
|
||||
yield return (object)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();
|
||||
ref string local1 = ref this.processInfo.title;
|
||||
ref string local2 = ref this.processInfo.text;
|
||||
ref float local3 = ref this.processInfo.progress;
|
||||
(string, string, float) progressInfo = eamManager.GetProgressInfo();
|
||||
local1 = progressInfo.Item1;
|
||||
local2 = progressInfo.Item2;
|
||||
double num = (double)progressInfo.Item3;
|
||||
local3 = (float)num;
|
||||
yield return eamFitting.Current;
|
||||
}
|
||||
eamFitting = (IEnumerator)null;
|
||||
}
|
||||
this.fittedTargetAvatar = configData.targetAvatarObject;
|
||||
this.fittedTargetClothes = configData.targetClothesObject;
|
||||
configData = new EdenAutoMorpherConfig();
|
||||
}
|
||||
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);
|
||||
sourceAvatarInfo.ApplyToTransform(this.sourceAvatarObject.transform, true, false, true, true);
|
||||
targetAvatarInfo.ApplyToTransform(this.targetAvatarObject.transform, true, false, true, true);
|
||||
}
|
||||
yield return null;
|
||||
yield return (object)null;
|
||||
}
|
||||
|
||||
public IEnumerator ManualFitting(MorpherMode morpherMode)
|
||||
@@ -402,38 +374,43 @@ public class EdenAutoMorpher : MonoBehaviour
|
||||
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();
|
||||
EdenAutoMorpher_SetUpUtil morpherSetUpUtil = new EdenAutoMorpher_SetUpUtil();
|
||||
this.sourceBodyMeshesReadOnly = (IReadOnlyList<SkinnedMeshRenderer>)morpherSetUpUtil.SetupBodyMeshes(this.sourceAvatarObject, this.isBodyAutoSetup, this.sourceBodyMeshes, "Source ").AsReadOnly();
|
||||
this.targetBodyMeshesReadOnly = (IReadOnlyList<SkinnedMeshRenderer>)morpherSetUpUtil.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;
|
||||
yield return (object)null;
|
||||
this.fittedTargetAvatar = (GameObject)null;
|
||||
this.fittedTargetClothes = (GameObject)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();
|
||||
ref string local1 = ref this.processInfo.title;
|
||||
ref string local2 = ref this.processInfo.text;
|
||||
ref float local3 = ref this.processInfo.progress;
|
||||
(string, string, float) progressInfo = eamManager.GetProgressInfo();
|
||||
local1 = progressInfo.Item1;
|
||||
local2 = progressInfo.Item2;
|
||||
double num = (double)progressInfo.Item3;
|
||||
local3 = (float)num;
|
||||
yield return eamFitting.Current;
|
||||
}
|
||||
eamFitting = (IEnumerator)null;
|
||||
}
|
||||
this.fittedTargetAvatar = configData.targetAvatarObject;
|
||||
this.fittedTargetClothes = configData.targetClothesObject;
|
||||
configData = new EdenAutoMorpherConfig();
|
||||
}
|
||||
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);
|
||||
sourceAvatarInfo.ApplyToTransform(this.sourceAvatarObject.transform, true, false, true, true);
|
||||
targetAvatarInfo.ApplyToTransform(this.targetAvatarObject.transform, true, false, true, true);
|
||||
}
|
||||
yield return null;
|
||||
yield return (object)null;
|
||||
}
|
||||
|
||||
public IEnumerator ProfileFitting(MorpherMode morpherMode)
|
||||
@@ -442,8 +419,7 @@ public class EdenAutoMorpher : MonoBehaviour
|
||||
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.targetBodyMeshesReadOnly = (IReadOnlyList<SkinnedMeshRenderer>)new 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);
|
||||
@@ -453,42 +429,45 @@ public class EdenAutoMorpher : MonoBehaviour
|
||||
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;
|
||||
yield return (object)null;
|
||||
this.fittedTargetAvatar = (GameObject)null;
|
||||
this.fittedTargetClothes = (GameObject)null;
|
||||
yield return (object)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();
|
||||
ref string local1 = ref this.processInfo.title;
|
||||
ref string local2 = ref this.processInfo.text;
|
||||
ref float local3 = ref this.processInfo.progress;
|
||||
(string, string, float) progressInfo = eamManager.GetProgressInfo();
|
||||
local1 = progressInfo.Item1;
|
||||
local2 = progressInfo.Item2;
|
||||
double num = (double)progressInfo.Item3;
|
||||
local3 = (float)num;
|
||||
yield return eamFitting.Current;
|
||||
}
|
||||
eamFitting = (IEnumerator)null;
|
||||
}
|
||||
this.fittedTargetAvatar = configData.targetAvatarObject;
|
||||
this.fittedTargetClothes = configData.targetClothesObject;
|
||||
yield return null;
|
||||
yield return (object)null;
|
||||
configData = new EdenAutoMorpherConfig();
|
||||
}
|
||||
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);
|
||||
sourceClothesInfo.ApplyToTransform(this.sourceClothesObject.transform, true, false, true, true);
|
||||
targetAvatarInfo.ApplyToTransform(this.targetAvatarObject.transform, true, false, true, true);
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
bool flag = this.morpherState == MorpherState.Fitting_End && Object.op_Inequality((Object)this.fittedTargetAvatar, (Object)null) && Object.op_Equality((Object)this.fittedTargetAvatar, (Object)this.targetAvatarObject);
|
||||
if (!isAutoMode)
|
||||
{
|
||||
flag = flag && (Object)(object)this.fittedTargetClothes == (Object)(object)this.targetClothesObjectOriginal;
|
||||
}
|
||||
flag = flag && Object.op_Equality((Object)this.fittedTargetClothes, (Object)this.targetClothesObjectOriginal);
|
||||
return flag;
|
||||
}
|
||||
|
||||
@@ -496,75 +475,69 @@ public class EdenAutoMorpher : MonoBehaviour
|
||||
{
|
||||
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");
|
||||
EdenAutoMorpherConfig autoMorpherConfig = this.SetupConfigData(morpherMode);
|
||||
string str1 = Object.op_Inequality((Object)autoMorpherConfig.sourceAvatarObject, (Object)null) ? ((Object)autoMorpherConfig.sourceAvatarObject).name : "null";
|
||||
string str2 = Object.op_Inequality((Object)autoMorpherConfig.sourceClothesObject, (Object)null) ? ((Object)autoMorpherConfig.sourceClothesObject).name : "null";
|
||||
string str3 = Object.op_Inequality((Object)autoMorpherConfig.targetAvatarObject, (Object)null) ? ((Object)autoMorpherConfig.targetAvatarObject).name : "null";
|
||||
string str4 = Object.op_Inequality((Object)autoMorpherConfig.targetClothesObject, (Object)null) ? ((Object)autoMorpherConfig.targetClothesObject).name : "null";
|
||||
stringBuilder.AppendLine("[Objects]");
|
||||
if (morpherMode == MorpherMode.ProfileMorpher)
|
||||
stringBuilder.AppendLine("- profileName: " + (string.IsNullOrEmpty(autoMorpherConfig.profileName) ? "null/empty" : autoMorpherConfig.profileName));
|
||||
stringBuilder.AppendLine("- sourceAvatarObject: " + str1);
|
||||
stringBuilder.AppendLine("- sourceClothesObject: " + str2);
|
||||
if (Object.op_Inequality((Object)autoMorpherConfig.sourceClothesObject, (Object)null))
|
||||
{
|
||||
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<SkinnedMeshRenderer>(true);
|
||||
SkinnedMeshRenderer[] componentsInChildren = autoMorpherConfig.sourceClothesObject.GetComponentsInChildren<SkinnedMeshRenderer>(true);
|
||||
stringBuilder.AppendLine($" - sourceClothes SkinnedMeshRenderers Count: {componentsInChildren.Length}");
|
||||
int num = Mathf.Min(componentsInChildren.Length, 10);
|
||||
for (int i = 0; i < num; i++)
|
||||
for (int index = 0; index < num; ++index)
|
||||
{
|
||||
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}");
|
||||
SkinnedMeshRenderer skinnedMeshRenderer = componentsInChildren[index];
|
||||
string str5 = Object.op_Inequality((Object)skinnedMeshRenderer, (Object)null) ? ((Object)skinnedMeshRenderer).name : "null";
|
||||
string str6 = !Object.op_Inequality((Object)skinnedMeshRenderer, (Object)null) || !Object.op_Inequality((Object)skinnedMeshRenderer.rootBone, (Object)null) ? "null" : ((Object)skinnedMeshRenderer.rootBone).name;
|
||||
string str7 = !Object.op_Inequality((Object)skinnedMeshRenderer, (Object)null) || !Object.op_Inequality((Object)skinnedMeshRenderer.sharedMesh, (Object)null) ? "null" : ((Object)skinnedMeshRenderer.sharedMesh).name;
|
||||
stringBuilder.AppendLine($" - [{index}] SMR: {str5} / rootBone: {str6} / mesh: {str7}");
|
||||
}
|
||||
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)
|
||||
stringBuilder.AppendLine("- targetAvatarObject: " + str3);
|
||||
stringBuilder.AppendLine("- targetClothesObject: " + str4);
|
||||
if (Object.op_Inequality((Object)autoMorpherConfig.targetClothesObject, (Object)null))
|
||||
{
|
||||
SkinnedMeshRenderer[] componentsInChildren2 = edenAutoMorpherConfig.targetClothesObject.GetComponentsInChildren<SkinnedMeshRenderer>(true);
|
||||
stringBuilder.AppendLine($" - targetClothes SkinnedMeshRenderers Count: {componentsInChildren2.Length}");
|
||||
int num2 = Mathf.Min(componentsInChildren2.Length, 10);
|
||||
for (int j = 0; j < num2; j++)
|
||||
SkinnedMeshRenderer[] componentsInChildren = autoMorpherConfig.targetClothesObject.GetComponentsInChildren<SkinnedMeshRenderer>(true);
|
||||
stringBuilder.AppendLine($" - targetClothes SkinnedMeshRenderers Count: {componentsInChildren.Length}");
|
||||
int num = Mathf.Min(componentsInChildren.Length, 10);
|
||||
for (int index = 0; index < num; ++index)
|
||||
{
|
||||
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)");
|
||||
SkinnedMeshRenderer skinnedMeshRenderer = componentsInChildren[index];
|
||||
string str8 = Object.op_Inequality((Object)skinnedMeshRenderer, (Object)null) ? ((Object)skinnedMeshRenderer).name : "null";
|
||||
string str9 = !Object.op_Inequality((Object)skinnedMeshRenderer, (Object)null) || !Object.op_Inequality((Object)skinnedMeshRenderer.rootBone, (Object)null) ? "null" : ((Object)skinnedMeshRenderer.rootBone).name;
|
||||
string str10 = !Object.op_Inequality((Object)skinnedMeshRenderer, (Object)null) || !Object.op_Inequality((Object)skinnedMeshRenderer.sharedMesh, (Object)null) ? "null" : ((Object)skinnedMeshRenderer.sharedMesh).name;
|
||||
stringBuilder.AppendLine($" - [{index}] SMR: {str8} / rootBone: {str9} / mesh: {str10}");
|
||||
}
|
||||
if (componentsInChildren.Length > num)
|
||||
stringBuilder.AppendLine($" - ... ({componentsInChildren.Length - num} more)");
|
||||
}
|
||||
stringBuilder.AppendLine();
|
||||
stringBuilder.AppendLine("[Body Meshes]");
|
||||
stringBuilder.AppendLine($"- isBodyAutoSetup: {edenAutoMorpherConfig.isBodyAutoSetup}");
|
||||
if (!edenAutoMorpherConfig.isBodyAutoSetup)
|
||||
stringBuilder.AppendLine($"- isBodyAutoSetup: {autoMorpherConfig.isBodyAutoSetup}");
|
||||
if (!autoMorpherConfig.isBodyAutoSetup)
|
||||
{
|
||||
if (edenAutoMorpherConfig.sourceBodyMeshes == null)
|
||||
if (autoMorpherConfig.sourceBodyMeshes == null)
|
||||
{
|
||||
stringBuilder.AppendLine("- sourceBodyMeshes: null");
|
||||
}
|
||||
else
|
||||
{
|
||||
stringBuilder.AppendLine($"- sourceBodyMeshes Count: {this.sourceBodyMeshes.Count}");
|
||||
for (int k = 0; k < this.sourceBodyMeshes.Count; k++)
|
||||
for (int index = 0; index < this.sourceBodyMeshes.Count; ++index)
|
||||
{
|
||||
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}");
|
||||
SkinnedMeshRenderer sourceBodyMesh = this.sourceBodyMeshes[index];
|
||||
string str11 = Object.op_Inequality((Object)sourceBodyMesh, (Object)null) ? ((Object)sourceBodyMesh).name : "null";
|
||||
string str12 = !Object.op_Inequality((Object)sourceBodyMesh, (Object)null) || !Object.op_Inequality((Object)sourceBodyMesh.rootBone, (Object)null) ? "null" : ((Object)sourceBodyMesh.rootBone).name;
|
||||
string str13 = !Object.op_Inequality((Object)sourceBodyMesh, (Object)null) || !Object.op_Inequality((Object)sourceBodyMesh.sharedMesh, (Object)null) ? "null" : ((Object)sourceBodyMesh.sharedMesh).name;
|
||||
stringBuilder.AppendLine($" - [{index}] SMR: {str11} / rootBone: {str12} / mesh: {str13}");
|
||||
}
|
||||
}
|
||||
if (this.targetBodyMeshes == null)
|
||||
@@ -574,28 +547,29 @@ public class EdenAutoMorpher : MonoBehaviour
|
||||
else
|
||||
{
|
||||
stringBuilder.AppendLine($"- targetBodyMeshes Count: {this.targetBodyMeshes.Count}");
|
||||
for (int l = 0; l < this.targetBodyMeshes.Count; l++)
|
||||
for (int index = 0; index < this.targetBodyMeshes.Count; ++index)
|
||||
{
|
||||
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}");
|
||||
SkinnedMeshRenderer targetBodyMesh = this.targetBodyMeshes[index];
|
||||
string str14 = Object.op_Inequality((Object)targetBodyMesh, (Object)null) ? ((Object)targetBodyMesh).name : "null";
|
||||
string str15 = !Object.op_Inequality((Object)targetBodyMesh, (Object)null) || !Object.op_Inequality((Object)targetBodyMesh.rootBone, (Object)null) ? "null" : ((Object)targetBodyMesh.rootBone).name;
|
||||
string str16 = !Object.op_Inequality((Object)targetBodyMesh, (Object)null) || !Object.op_Inequality((Object)targetBodyMesh.sharedMesh, (Object)null) ? "null" : ((Object)targetBodyMesh.sharedMesh).name;
|
||||
stringBuilder.AppendLine($" - [{index}] SMR: {str14} / rootBone: {str15} / mesh: {str16}");
|
||||
}
|
||||
}
|
||||
}
|
||||
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($"- minMargin: {autoMorpherConfig.minMargin}");
|
||||
stringBuilder.AppendLine($"- worldRadius: {autoMorpherConfig.worldRadius}");
|
||||
stringBuilder.AppendLine($"- sigma: {autoMorpherConfig.sigma}");
|
||||
stringBuilder.AppendLine($"- smoothingIteration: {autoMorpherConfig.smoothingIteration}");
|
||||
stringBuilder.AppendLine($"- fittingExpandIteration: {autoMorpherConfig.fittingExpandIteration}");
|
||||
stringBuilder.AppendLine($"- fittingShrinkIteration: {autoMorpherConfig.fittingShrinkIteration}");
|
||||
stringBuilder.AppendLine();
|
||||
stringBuilder.AppendLine("[Options]");
|
||||
stringBuilder.AppendLine($"- isReparentAccessoryBonesToTargetAvatar: {edenAutoMorpherConfig.isReparentAccessoryBonesToTargetAvatar}");
|
||||
stringBuilder.AppendLine($"- skipFootFitting: {edenAutoMorpherConfig.skipFootFitting}");
|
||||
stringBuilder.AppendLine($"- isReparentAccessoryBonesToTargetAvatar: {autoMorpherConfig.isReparentAccessoryBonesToTargetAvatar}");
|
||||
stringBuilder.AppendLine($"- skipFootFitting: {autoMorpherConfig.skipFootFitting}");
|
||||
Debug.Log((object)stringBuilder.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 036fbcf460e6d274db05499e9c3cfa70
|
||||
guid: eaae26efe7cd8314ab19e85cd1c4c1fa
|
||||
@@ -1,55 +1,38 @@
|
||||
// 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
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: Eden.AutoMorpher.EdenAutoMorpherConfig
|
||||
// Assembly: EdenAutoMorpherScript, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: D39968B3-E151-4276-BDB4-E82752BBAFF0
|
||||
// Assembly location: D:\dev\AutoMorpher\Assets\@Eden_Tools\Eden_AutoMorpher\Script\EdenAutoMorpherScript.dll
|
||||
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Eden.AutoMorpher
|
||||
{
|
||||
public struct EdenAutoMorpherConfig
|
||||
{
|
||||
public GameObject sourceAvatarObject;
|
||||
|
||||
public GameObject sourceClothesObject;
|
||||
|
||||
public IReadOnlyList<SkinnedMeshRenderer> sourceBodyMeshes;
|
||||
|
||||
public GameObject targetAvatarObject;
|
||||
|
||||
public GameObject targetClothesObject;
|
||||
|
||||
public IReadOnlyList<SkinnedMeshRenderer> targetBodyMeshes;
|
||||
|
||||
public string profileName;
|
||||
|
||||
public float minMargin;
|
||||
|
||||
public float worldRadius;
|
||||
|
||||
public float sigma;
|
||||
|
||||
public int smoothingIteration;
|
||||
|
||||
public int fittingExpandIteration;
|
||||
|
||||
public int fittingShrinkIteration;
|
||||
|
||||
public bool isBodyAutoSetup;
|
||||
|
||||
public bool isReparentAccessoryBonesToTargetAvatar;
|
||||
|
||||
public bool skipFootFitting;
|
||||
|
||||
public bool isRemoveAutoMorphedClothes;
|
||||
|
||||
public bool transferWeightToAvatar;
|
||||
|
||||
public bool addAnchorBone;
|
||||
|
||||
public bool armatureBoneScaleCopy;
|
||||
|
||||
public Dictionary<HumanBodyBones, HashSet<Transform>> clothesHumanoidMatchedBones;
|
||||
|
||||
public Dictionary<Transform, ClothBoneType> clothBoneTypeMap;
|
||||
|
||||
public string tagEdenMorpehrCloth;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aa8bd605c6ebdef4dac9c03b09ac0c8c
|
||||
guid: 5a6e56a2e3d0f314a96d690af08d87a9
|
||||
@@ -1,8 +1,10 @@
|
||||
// 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;
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: Eden.AutoMorpher.EdenAutoMorpherManager
|
||||
// Assembly: EdenAutoMorpherScript, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: D39968B3-E151-4276-BDB4-E82752BBAFF0
|
||||
// Assembly location: D:\dev\AutoMorpher\Assets\@Eden_Tools\Eden_AutoMorpher\Script\EdenAutoMorpherScript.dll
|
||||
|
||||
using Eden.AutoMorpher.profile;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
@@ -10,14 +12,13 @@ using System.IO;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Eden.AutoMorpher
|
||||
{
|
||||
public class EdenAutoMorpherManager : IDisposable
|
||||
{
|
||||
private string displayTitle;
|
||||
|
||||
private string displayText;
|
||||
|
||||
private float displayProgress;
|
||||
|
||||
private List<ClothInstance> clothInstances;
|
||||
|
||||
public (string, string, float) GetProgressInfo()
|
||||
@@ -32,75 +33,66 @@ public class EdenAutoMorpherManager : IDisposable
|
||||
this.displayProgress = progress;
|
||||
}
|
||||
|
||||
private IEnumerator SetupClothInstances(GameObject targetClothesObject, Dictionary<HumanBodyBones, HashSet<Transform>> clothesHumanoidMatchedBones, bool duplicateMesh = true)
|
||||
private IEnumerator SetupClothInstances(
|
||||
GameObject targetClothesObject,
|
||||
Dictionary<HumanBodyBones, HashSet<Transform>> clothesHumanoidMatchedBones,
|
||||
bool duplicateMesh = true)
|
||||
{
|
||||
this.clothInstances = new List<ClothInstance>();
|
||||
SkinnedMeshRenderer[] targetClothesSMRs = targetClothesObject.GetComponentsInChildren<SkinnedMeshRenderer>(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++)
|
||||
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;
|
||||
this.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 (object)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<HumanBodyBones, HashSet<Transform>> clothesHumanoidMatchedBones, GameObject sourceClothesObject, MeshMatcher meshMatcher)
|
||||
private IEnumerator SetupClothInstances(
|
||||
GameObject targetClothesObject,
|
||||
Dictionary<HumanBodyBones, HashSet<Transform>> clothesHumanoidMatchedBones,
|
||||
GameObject sourceClothesObject,
|
||||
MeshMatcher meshMatcher)
|
||||
{
|
||||
this.clothInstances = new List<ClothInstance>();
|
||||
SkinnedMeshRenderer[] targetClothesSMRs = targetClothesObject.GetComponentsInChildren<SkinnedMeshRenderer>(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<SkinnedMeshRenderer>(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++)
|
||||
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);
|
||||
this.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 (object)null;
|
||||
ClothInstance clothInstance = setupUtil.SetupClothInstance(targetClothesSMRs[rendereri], sourceClothesSMRs[rendereri], meshMatcher, clothesHumanoidMatchedBones, 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)
|
||||
{
|
||||
this.SetupProgress("Set Up", "Setup Target Avatar Info", 0.03f);
|
||||
yield return null;
|
||||
yield return (object)null;
|
||||
MeshMatcher meshMatcher = new MeshMatcher();
|
||||
BvhTriangleMesh targetBodyBVH = meshMatcher.BuildBvhMulti(config.targetBodyMeshes, config.targetAvatarObject.GetComponent<Animator>());
|
||||
if (targetBodyBVH == null)
|
||||
{
|
||||
throw new AutoMorpherException("targetBodyBVH is Null", "[EdenAutoMorpherManater] FittingIteration\n - targetBodyBVH is null");
|
||||
}
|
||||
yield return null;
|
||||
yield return (object)null;
|
||||
this.SetupProgress("Set Up", "Setup Source Avatar Info", 0.05f);
|
||||
yield return null;
|
||||
BvhTriangleMesh sourceBodyBVH = null;
|
||||
yield return (object)null;
|
||||
BvhTriangleMesh sourceBodyBVH = (BvhTriangleMesh)null;
|
||||
switch (morpherMode)
|
||||
{
|
||||
case MorpherMode.AutoMorpher:
|
||||
@@ -108,156 +100,143 @@ public class EdenAutoMorpherManager : IDisposable
|
||||
sourceBodyBVH = meshMatcher.BuildBvhMulti(config.sourceBodyMeshes, config.sourceAvatarObject.GetComponent<Animator>());
|
||||
break;
|
||||
case MorpherMode.ProfileMorpher:
|
||||
{
|
||||
ProfileLoader profileLoader = new ProfileLoader();
|
||||
sourceBodyBVH = profileLoader.LoadBvhWithRootTransform(config.sourceClothesObject.transform, config.profileName);
|
||||
sourceBodyBVH = new 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;
|
||||
yield return (object)null;
|
||||
meshMatcher.bodyBVH = sourceBodyBVH != null ? sourceBodyBVH : throw new AutoMorpherException("sourceBodyBVH is Null", "[EdenAutoMorpherManater] FittingIteration\n - sourceBodyBVH is null");
|
||||
this.SetupProgress("Set Up", "Setup Clothes Info", 0.07f);
|
||||
yield return null;
|
||||
yield return (object)null;
|
||||
IEnumerator setupClothEnum = this.SetupClothInstances(config.targetClothesObject, config.clothesHumanoidMatchedBones, config.sourceClothesObject, meshMatcher);
|
||||
while (setupClothEnum.MoveNext())
|
||||
{
|
||||
yield return setupClothEnum.Current;
|
||||
}
|
||||
yield return null;
|
||||
yield return (object)null;
|
||||
float fittingRadius = config.worldRadius;
|
||||
meshMatcher.bodyBVH = targetBodyBVH;
|
||||
VertexFittingUtil vertexFittingUtil = new VertexFittingUtil();
|
||||
int fittingI;
|
||||
for (fittingI = 0; fittingI < config.fittingExpandIteration; fittingI++)
|
||||
ClothInstance clothInstance;
|
||||
for (fittingI = 0; fittingI < config.fittingExpandIteration; ++fittingI)
|
||||
{
|
||||
foreach (ClothInstance clothInstance in this.clothInstances)
|
||||
foreach (ClothInstance clothInstance1 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;
|
||||
clothInstance = clothInstance1;
|
||||
this.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 (object)null;
|
||||
vertexFittingUtil.ExpandClothes_World(clothInstance, this.clothInstances, meshMatcher, config, fittingRadius);
|
||||
yield return null;
|
||||
yield return (object)null;
|
||||
clothInstance = (ClothInstance)null;
|
||||
}
|
||||
if (fittingI % 2 == 0)
|
||||
{
|
||||
fittingRadius *= 0.97f;
|
||||
}
|
||||
}
|
||||
fittingRadius = config.worldRadius;
|
||||
for (fittingI = 0; fittingI < config.fittingShrinkIteration; fittingI++)
|
||||
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<Animator>());
|
||||
}
|
||||
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();
|
||||
clothInstance = clothInstance2;
|
||||
this.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 (object)null;
|
||||
vertexFittingUtil.ShrinkClothes_World(clothInstance, this.clothInstances, meshMatcher, config, fittingRadius);
|
||||
yield return (object)null;
|
||||
vertexFittingUtil.ExpandClothes_World(clothInstance, this.clothInstances, meshMatcher, config, fittingRadius);
|
||||
yield return (object)null;
|
||||
clothInstance = (ClothInstance)null;
|
||||
}
|
||||
this.clothInstances = null;
|
||||
yield return null;
|
||||
if (fittingI % 2 == 0)
|
||||
fittingRadius *= 0.97f;
|
||||
}
|
||||
fittingRadius = config.worldRadius / 2f;
|
||||
for (fittingI = 0; fittingI < config.fittingExpandIteration; ++fittingI)
|
||||
{
|
||||
foreach (ClothInstance clothInstance3 in this.clothInstances)
|
||||
{
|
||||
clothInstance = clothInstance3;
|
||||
this.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 (object)null;
|
||||
vertexFittingUtil.ExpandClothes_World(clothInstance, this.clothInstances, meshMatcher, config, fittingRadius);
|
||||
yield return (object)null;
|
||||
clothInstance = (ClothInstance)null;
|
||||
}
|
||||
if (fittingI % 2 == 0)
|
||||
fittingRadius *= 0.97f;
|
||||
}
|
||||
yield return (object)null;
|
||||
this.SetupProgress("Fitting", "Apply Transform Bone", 0.93f);
|
||||
yield return (object)null;
|
||||
BoneAlignmentUtil boneAlignmentUtil = new BoneAlignmentUtil();
|
||||
boneAlignmentUtil.CleanupTempBones(config.targetClothesObject.transform);
|
||||
switch (morpherMode)
|
||||
{
|
||||
case MorpherMode.AutoMorpher:
|
||||
case MorpherMode.ProfileMorpher:
|
||||
config.targetClothesObject.transform.localScale = Vector3.one;
|
||||
boneAlignmentUtil.AlignClothBonesToAvatar(this.clothInstances[0], config.targetAvatarObject.GetComponent<Animator>());
|
||||
break;
|
||||
}
|
||||
yield return (object)null;
|
||||
this.SetupProgress("Fitting", "Apply Transform Mesh", 0.99f);
|
||||
yield return (object)null;
|
||||
for (fittingI = 0; fittingI < this.clothInstances.Count; ++fittingI)
|
||||
{
|
||||
clothInstance = this.clothInstances[fittingI];
|
||||
this.SetupProgress("Fitting", $"Apply to Mesh [{fittingI + 1}/{this.clothInstances.Count}] - {((Object)((Component)clothInstance.smr).transform).name}", Mathf.Lerp(0.93f, 0.98f, (float)fittingI / (float)this.clothInstances.Count));
|
||||
yield return (object)null;
|
||||
clothInstance.ApplyWorldVerticesToMesh();
|
||||
((Renderer)clothInstance.smr).localBounds = new Bounds(Vector3.zero, Vector3.op_Multiply(Vector3.one, 2f));
|
||||
EditorUtility.SetDirty((Object)clothInstance.smr.sharedMesh);
|
||||
EditorUtility.SetDirty((Object)clothInstance.smr);
|
||||
yield return (object)null;
|
||||
clothInstance = (ClothInstance)null;
|
||||
}
|
||||
yield return (object)null;
|
||||
this.SetupProgress("Saving", "Saving Mesh Data", 0.99f);
|
||||
yield return (object)null;
|
||||
this.SaveEditedMeshesToAssets(this.clothInstances, config);
|
||||
yield return (object)null;
|
||||
this.SetupProgress("Finishing", "Finishing", 1f);
|
||||
foreach (ClothInstance clothInstance4 in this.clothInstances)
|
||||
clothInstance4.Dispose();
|
||||
this.clothInstances = (List<ClothInstance>)null;
|
||||
sourceBodyBVH = (BvhTriangleMesh)null;
|
||||
targetBodyBVH = (BvhTriangleMesh)null;
|
||||
yield return (object)null;
|
||||
}
|
||||
|
||||
public IEnumerator WeightingEnumerator(EdenAutoMorpherConfig config)
|
||||
{
|
||||
this.SetupProgress("Set Up", "Setup Target Avatar Info", 0f);
|
||||
yield return null;
|
||||
EdenAutoMorpherManager autoMorpherManager = this;
|
||||
autoMorpherManager.SetupProgress("Set Up", "Setup Target Avatar Info", 0.0f);
|
||||
yield return (object)null;
|
||||
if (new MeshMatcher().BuildBvhMulti(config.targetBodyMeshes, config.targetAvatarObject.GetComponent<Animator>()) == null)
|
||||
{
|
||||
throw new AutoMorpherException("targetBodyBVH is Null", "[EdenAutoMorpherManater] FittingIteration\n - targetBodyBVH is null");
|
||||
}
|
||||
yield return null;
|
||||
yield return (object)null;
|
||||
List<Mesh> bakedTargetBodyMeshes = new List<Mesh>();
|
||||
foreach (SkinnedMeshRenderer bodyMesh in config.targetBodyMeshes)
|
||||
foreach (SkinnedMeshRenderer bodyMesh in (IEnumerable<SkinnedMeshRenderer>)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);
|
||||
autoMorpherManager.SetupProgress("Set Up", "Setup Target Avatar BodyMesh Info", Mathf.Lerp(0.02f, 0.05f, (float)(bakedTargetBodyMeshes.Count / config.targetBodyMeshes.Count)));
|
||||
yield return (object)null;
|
||||
Mesh mesh = new Mesh();
|
||||
bodyMesh.BakeMesh(mesh);
|
||||
mesh.triangles = bodyMesh.sharedMesh.triangles;
|
||||
mesh.boneWeights = bodyMesh.sharedMesh.boneWeights;
|
||||
bakedTargetBodyMeshes.Add(mesh);
|
||||
}
|
||||
yield return null;
|
||||
IEnumerator setupClothEnum = this.SetupClothInstances(config.targetClothesObject, config.clothesHumanoidMatchedBones, duplicateMesh: false);
|
||||
yield return (object)null;
|
||||
IEnumerator setupClothEnum = autoMorpherManager.SetupClothInstances(config.targetClothesObject, config.clothesHumanoidMatchedBones, false);
|
||||
while (setupClothEnum.MoveNext())
|
||||
{
|
||||
yield return setupClothEnum.Current;
|
||||
}
|
||||
yield return null;
|
||||
Dictionary<Transform, Transform> clonedBoneMap = null;
|
||||
yield return (object)null;
|
||||
Dictionary<Transform, Transform> clonedBoneMap = (Dictionary<Transform, Transform>)null;
|
||||
if (!config.transferWeightToAvatar)
|
||||
{
|
||||
new EdenAutoMorpher_SetUpUtil().CreateClothesArmature(config, out clonedBoneMap);
|
||||
}
|
||||
yield return null;
|
||||
yield return (object)null;
|
||||
WeightTransferUtil weightTransferUtil = new WeightTransferUtil();
|
||||
WeightTransferUtil.Settings wtSettings = new WeightTransferUtil.Settings
|
||||
WeightTransferUtil.Settings wtSettings = new WeightTransferUtil.Settings()
|
||||
{
|
||||
maxDistance = 0.07f,
|
||||
maxNormalAngleDeg = 35f,
|
||||
@@ -268,126 +247,110 @@ public class EdenAutoMorpherManager : IDisposable
|
||||
enforceFourBoneLimit = true,
|
||||
weightInClothes = !config.transferWeightToAvatar
|
||||
};
|
||||
yield return null;
|
||||
int weightingI = 0;
|
||||
while (weightingI < this.clothInstances.Count)
|
||||
yield return (object)null;
|
||||
for (int weightingI = 0; weightingI < autoMorpherManager.clothInstances.Count; ++weightingI)
|
||||
{
|
||||
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;
|
||||
ClothInstance clothInstance = autoMorpherManager.clothInstances[weightingI];
|
||||
float num1 = 0.1f;
|
||||
float num2 = (0.95f - num1) / (float)Mathf.Max(1, autoMorpherManager.clothInstances.Count);
|
||||
float num3 = num1 + 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<Animator>(), config.targetBodyMeshes, bakedTargetBodyMeshes, 0, wtSettings, config.clothBoneTypeMap, clonedBoneMap);
|
||||
autoMorpherManager.SetupProgress("Weighting", $"Weighting | Step {step} [{weightingI + 1}/{autoMorpherManager.clothInstances.Count}] - {((Object)((Component)clothInstance.smr).transform).name}", weightingStart);
|
||||
yield return (object)null;
|
||||
IEnumerator weightingEnum = weightTransferUtil.RetargetAndTransfer(clothInstance, config.targetAvatarObject.GetComponent<Animator>(), config.targetBodyMeshes, (IReadOnlyList<Mesh>)bakedTargetBodyMeshes, settings: wtSettings, boneTypeMap: config.clothBoneTypeMap, bodyToClothesMap: 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 (object)null;
|
||||
++step;
|
||||
float progress = Mathf.Lerp(weightingStart, weightingEnd, (float)(1.0 - 1.0 / ((double)step + 1.0)));
|
||||
autoMorpherManager.SetupProgress("Weighting", $"Weighting | Step {step} [{weightingI + 1}/{autoMorpherManager.clothInstances.Count}] - {((Object)((Component)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;
|
||||
yield return (object)null;
|
||||
++step;
|
||||
autoMorpherManager.SetupProgress("Weighting", $"Weighting | Step {step} - Apply to Mesh [{weightingI + 1}/{autoMorpherManager.clothInstances.Count}] - {((Object)((Component)clothInstance.smr).transform).name}", applyStart);
|
||||
yield return (object)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;
|
||||
((Renderer)clothInstance.smr).localBounds = new Bounds(Vector3.zero, Vector3.op_Multiply(Vector3.one, 2f));
|
||||
EditorUtility.SetDirty((Object)clothInstance.smr.sharedMesh);
|
||||
EditorUtility.SetDirty((Object)clothInstance.smr);
|
||||
yield return (object)null;
|
||||
clothInstance = (ClothInstance)null;
|
||||
weightingEnum = (IEnumerator)null;
|
||||
}
|
||||
this.SetupProgress("Weighting", "Allocate Bones", 0.95f);
|
||||
yield return null;
|
||||
autoMorpherManager.SetupProgress("Weighting", "Allocate Bones", 0.95f);
|
||||
yield return (object)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;
|
||||
autoMorpherManager.SetupProgress("Finishing", "Finishing", 1f);
|
||||
yield return (object)null;
|
||||
foreach (ClothInstance clothInstance in autoMorpherManager.clothInstances)
|
||||
clothInstance.Dispose();
|
||||
autoMorpherManager.clothInstances = (List<ClothInstance>)null;
|
||||
yield return (object)null;
|
||||
}
|
||||
|
||||
private void SaveEditedMeshesToAssets(List<ClothInstance> clothInstances, EdenAutoMorpherConfig config)
|
||||
private void SaveEditedMeshesToAssets(
|
||||
List<ClothInstance> 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)
|
||||
if (Object.op_Equality((Object)config.targetClothesObject, (Object)null) || Object.op_Equality((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))
|
||||
{
|
||||
string str1 = "Assets/@Eden_Mesh";
|
||||
if (!AssetDatabase.IsValidFolder(str1))
|
||||
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");
|
||||
string str2 = SanitizeForAssetName(((Object)config.targetAvatarObject).name);
|
||||
string str3 = $"{str1}/{str2}";
|
||||
if (!AssetDatabase.IsValidFolder(str3))
|
||||
AssetDatabase.CreateFolder(str1, str2);
|
||||
string str4 = SanitizeForAssetName(((Object)config.targetClothesObject).name);
|
||||
string str5 = $"{str3}/{str4}";
|
||||
if (!AssetDatabase.IsValidFolder(str5))
|
||||
AssetDatabase.CreateFolder(str3, str4);
|
||||
string uniqueAssetPath = AssetDatabase.GenerateUniqueAssetPath($"{str5}/{str4}_Meshes.asset");
|
||||
int num = 0;
|
||||
AssetDatabase.CreateAsset(new Mesh
|
||||
{
|
||||
name = text4 + "_RootMesh"
|
||||
}, text6);
|
||||
Mesh mesh1 = new Mesh();
|
||||
((Object)mesh1).name = str4 + "_RootMesh";
|
||||
AssetDatabase.CreateAsset((Object)mesh1, uniqueAssetPath);
|
||||
foreach (ClothInstance clothInstance in clothInstances)
|
||||
{
|
||||
if (clothInstance != null && !(clothInstance.smr == null))
|
||||
if (clothInstance != null && !Object.op_Equality((Object)clothInstance.smr, (Object)null))
|
||||
{
|
||||
Mesh sharedMesh = clothInstance.smr.sharedMesh;
|
||||
if (!(sharedMesh == null))
|
||||
if (!Object.op_Equality((Object)sharedMesh, (Object)null))
|
||||
{
|
||||
Mesh val = UnityEngine.Object.Instantiate<Mesh>(sharedMesh);
|
||||
val.name = SanitizeForAssetName(clothInstance.smr.gameObject.name + "_EditedMesh");
|
||||
AssetDatabase.AddObjectToAsset(val, text6);
|
||||
clothInstance.smr.sharedMesh = val;
|
||||
Mesh mesh2 = Object.Instantiate<Mesh>(sharedMesh);
|
||||
((Object)mesh2).name = SanitizeForAssetName(((Object)((Component)clothInstance.smr).gameObject).name + "_EditedMesh");
|
||||
AssetDatabase.AddObjectToAsset((Object)mesh2, uniqueAssetPath);
|
||||
clothInstance.smr.sharedMesh = mesh2;
|
||||
clothInstance.editableMesh = clothInstance.smr.sharedMesh;
|
||||
EditorUtility.SetDirty(clothInstance.smr);
|
||||
EditorUtility.SetDirty(clothInstance.smr.sharedMesh);
|
||||
EditorUtility.SetDirty(clothInstance.smr.gameObject);
|
||||
num++;
|
||||
EditorUtility.SetDirty((Object)clothInstance.smr);
|
||||
EditorUtility.SetDirty((Object)clothInstance.smr.sharedMesh);
|
||||
EditorUtility.SetDirty((Object)((Component)clothInstance.smr).gameObject);
|
||||
++num;
|
||||
}
|
||||
}
|
||||
}
|
||||
AssetDatabase.SaveAssets();
|
||||
AssetDatabase.Refresh();
|
||||
Debug.Log((object)($"[EdenAutoMorpher] 편집된 메쉬 {num}개를 " + "'" + text6 + "' 에 서브 에셋으로 저장했습니다. (원본 프리팹은 변경하지 않음)"));
|
||||
string SanitizeForAssetName(string rawName)
|
||||
Debug.Log((object)$"{$"[EdenAutoMorpher] 편집된 메쉬 {num}개를 "}'{uniqueAssetPath}' 에 서브 에셋으로 저장했습니다. (원본 프리팹은 변경하지 않음)");
|
||||
|
||||
static string SanitizeForAssetName(string rawName)
|
||||
{
|
||||
char[] invalidFileNameChars = Path.GetInvalidFileNameChars();
|
||||
foreach (char oldChar in invalidFileNameChars)
|
||||
{
|
||||
rawName = rawName.Replace(oldChar, '_');
|
||||
}
|
||||
foreach (char invalidFileNameChar in Path.GetInvalidFileNameChars())
|
||||
rawName = rawName.Replace(invalidFileNameChar, '_');
|
||||
return rawName.Trim();
|
||||
}
|
||||
}
|
||||
@@ -396,3 +359,4 @@ public class EdenAutoMorpherManager : IDisposable
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e0340c83a1a3e004c872bca551da7361
|
||||
guid: db28ab8ea782f894bb3ca3288606e842
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,2 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1db8e97e7f1e5484b9e4f10fe266c6f8
|
||||
guid: 084d635978a925d4caec9538d24f3114
|
||||
@@ -1,79 +1,66 @@
|
||||
// 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
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: Eden.AutoMorpher.MeshClassifier
|
||||
// Assembly: EdenAutoMorpherScript, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: D39968B3-E151-4276-BDB4-E82752BBAFF0
|
||||
// Assembly location: D:\dev\AutoMorpher\Assets\@Eden_Tools\Eden_AutoMorpher\Script\EdenAutoMorpherScript.dll
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Eden.AutoMorpher
|
||||
{
|
||||
public class MeshClassifier
|
||||
{
|
||||
private HumanBodyBones[] bodyBones;
|
||||
|
||||
private HumanBodyBones[] headBones;
|
||||
|
||||
public SkinnedMeshRenderer GetBodyMesh(Transform root, Animator animator)
|
||||
{
|
||||
List<Transform> list = this.HumanBodyBonesTrsnforms(this.bodyBones, animator);
|
||||
if (list.Count != this.bodyBones.Length)
|
||||
{
|
||||
List<Transform> humanBoneTransforms = this.HumanBodyBonesTrsnforms(this.bodyBones, animator);
|
||||
if (humanBoneTransforms.Count == this.bodyBones.Length)
|
||||
return this.GetBoneMatchedMesh(root, humanBoneTransforms);
|
||||
if (AutoMorpherDev.isDeveloperMode)
|
||||
{
|
||||
Debug.LogWarning("[Body Mesh] Animator Bone is not enough");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return this.GetBoneMatchedMesh(root, list);
|
||||
Debug.LogWarning((object)"[Body Mesh] Animator Bone is not enough");
|
||||
return (SkinnedMeshRenderer)null;
|
||||
}
|
||||
|
||||
public SkinnedMeshRenderer GetHeadMesh(Transform root, Animator animator)
|
||||
{
|
||||
List<Transform> list = this.HumanBodyBonesTrsnforms(this.headBones, animator);
|
||||
if (list.Count != this.headBones.Length)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return this.GetBoneMatchedMesh(root, list);
|
||||
List<Transform> humanBoneTransforms = this.HumanBodyBonesTrsnforms(this.headBones, animator);
|
||||
return humanBoneTransforms.Count != this.headBones.Length ? (SkinnedMeshRenderer)null : this.GetBoneMatchedMesh(root, humanBoneTransforms);
|
||||
}
|
||||
|
||||
private List<Transform> HumanBodyBonesTrsnforms(HumanBodyBones[] humanBonesList, Animator animator)
|
||||
private List<Transform> 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<Transform> list = new List<Transform>();
|
||||
List<HumanBodyBones> list2 = new List<HumanBodyBones>();
|
||||
foreach (HumanBodyBones val in humanBonesList)
|
||||
List<Transform> transformList = new List<Transform>();
|
||||
List<HumanBodyBones> values = new List<HumanBodyBones>();
|
||||
foreach (int humanBones in humanBonesList)
|
||||
{
|
||||
Transform boneTransform = animator.GetBoneTransform(val);
|
||||
if (boneTransform == null)
|
||||
{
|
||||
list2.Add(val);
|
||||
}
|
||||
HumanBodyBones humanBodyBones = (HumanBodyBones)humanBones;
|
||||
Transform boneTransform = animator.GetBoneTransform(humanBodyBones);
|
||||
if (Object.op_Equality((Object)boneTransform, (Object)null))
|
||||
values.Add(humanBodyBones);
|
||||
else
|
||||
{
|
||||
list.Add(boneTransform);
|
||||
transformList.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;
|
||||
if (values.Count > 0)
|
||||
throw new AutoMorpherException("[Body Mesh Finding] Required Humanoid Bones are Missing", $"[BodyMeshUtil] HumanBodyBonesTrsnforms\n - Missing Humanoid Bones: [{string.Join<HumanBodyBones>(", ", (IEnumerable<HumanBodyBones>)values)}]\n - Animator Humanoid mapping may be broken\n - Please check whether the missing humanoid bones are correctly assigned in [Animator → Avatar → Configure].");
|
||||
return transformList;
|
||||
}
|
||||
|
||||
private SkinnedMeshRenderer GetBoneMatchedMesh(Transform root, List<Transform> humanBoneTransforms)
|
||||
private SkinnedMeshRenderer GetBoneMatchedMesh(
|
||||
Transform root,
|
||||
List<Transform> humanBoneTransforms)
|
||||
{
|
||||
SkinnedMeshRenderer[] componentsInChildren = ((Component)root).GetComponentsInChildren<SkinnedMeshRenderer>(false);
|
||||
foreach (SkinnedMeshRenderer val in componentsInChildren)
|
||||
foreach (SkinnedMeshRenderer componentsInChild in ((Component)root).GetComponentsInChildren<SkinnedMeshRenderer>(false))
|
||||
{
|
||||
bool flag = true;
|
||||
HashSet<Transform> activeBones = this.GetActiveBones(val);
|
||||
HashSet<Transform> activeBones = this.GetActiveBones(componentsInChild);
|
||||
if (AutoMorpherDev.isDeveloperMode)
|
||||
{
|
||||
Debug.Log($"[Body Mesh] {val.gameObject.name} have bone Set {activeBones.Count}");
|
||||
}
|
||||
Debug.Log((object)$"[Body Mesh] {((Object)((Component)componentsInChild).gameObject).name} have bone Set {activeBones.Count}");
|
||||
foreach (Transform humanBoneTransform in humanBoneTransforms)
|
||||
{
|
||||
if (!activeBones.Contains(humanBoneTransform) && !this.BoneExistsByPosition(humanBoneTransform, activeBones))
|
||||
@@ -81,226 +68,151 @@ public class MeshClassifier
|
||||
flag = false;
|
||||
if (AutoMorpherDev.isDeveloperMode)
|
||||
{
|
||||
Debug.Log(("[Body Mesh] " + val.gameObject.name + " Doesn't hav bone " + humanBoneTransform.name));
|
||||
Debug.Log((object)$"[Body Mesh] {((Object)((Component)componentsInChild).gameObject).name} Doesn't hav bone {((Object)humanBoneTransform).name}");
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (flag)
|
||||
{
|
||||
return val;
|
||||
return componentsInChild;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
return (SkinnedMeshRenderer)null;
|
||||
}
|
||||
|
||||
private bool BoneExistsByPosition(Transform boneToCheck, HashSet<Transform> smrBoneSet, float posTolerance = 0.0001f)
|
||||
private bool BoneExistsByPosition(
|
||||
Transform boneToCheck,
|
||||
HashSet<Transform> 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)
|
||||
foreach (Transform smrBone in smrBoneSet)
|
||||
{
|
||||
Vector3 vector3 = Vector3.op_Subtraction(smrBone.position, boneToCheck.position);
|
||||
if ((double)((Vector3)ref vector3).sqrMagnitude <= (double)posTolerance * (double)posTolerance)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public HashSet<Transform> 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)
|
||||
if (Object.op_Equality((Object)sharedMesh, (Object)null))
|
||||
{
|
||||
Debug.LogWarning("SkinnedMeshRenderer에 연결된 Mesh가 없습니다.");
|
||||
Debug.LogWarning((object)"SkinnedMeshRenderer에 연결된 Mesh가 없습니다.");
|
||||
return new HashSet<Transform>();
|
||||
}
|
||||
Transform[] bones = smr.bones;
|
||||
BoneWeight[] boneWeights = sharedMesh.boneWeights;
|
||||
HashSet<int> hashSet = new HashSet<int>();
|
||||
BoneWeight[] array = boneWeights;
|
||||
for (int i = 0; i < array.Length; i++)
|
||||
HashSet<int> intSet = new HashSet<int>();
|
||||
foreach (BoneWeight boneWeight in boneWeights)
|
||||
{
|
||||
BoneWeight val = array[i];
|
||||
if (val.weight0 > weightThreshold)
|
||||
if ((double)((BoneWeight)ref boneWeight).weight0 > (double)weightThreshold)
|
||||
intSet.Add(((BoneWeight)ref boneWeight).boneIndex0);
|
||||
if ((double)((BoneWeight)ref boneWeight).weight1 > (double)weightThreshold)
|
||||
intSet.Add(((BoneWeight)ref boneWeight).boneIndex1);
|
||||
if ((double)((BoneWeight)ref boneWeight).weight2 > (double)weightThreshold)
|
||||
intSet.Add(((BoneWeight)ref boneWeight).boneIndex2);
|
||||
if ((double)((BoneWeight)ref boneWeight).weight3 > (double)weightThreshold)
|
||||
intSet.Add(((BoneWeight)ref boneWeight).boneIndex3);
|
||||
}
|
||||
HashSet<Transform> activeBones = new HashSet<Transform>();
|
||||
foreach (int index in intSet)
|
||||
{
|
||||
hashSet.Add(val.boneIndex0);
|
||||
if (index >= 0 && index < bones.Length)
|
||||
activeBones.Add(bones[index]);
|
||||
}
|
||||
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<Transform> hashSet2 = new HashSet<Transform>();
|
||||
foreach (int item in hashSet)
|
||||
{
|
||||
if (item >= 0 && item < bones.Length)
|
||||
{
|
||||
hashSet2.Add(bones[item]);
|
||||
}
|
||||
}
|
||||
return hashSet2;
|
||||
return activeBones;
|
||||
}
|
||||
|
||||
public Dictionary<HumanBodyBones, HashSet<Transform>> MeshHumanoidBoneMatcher(Animator animator, IReadOnlyList<SkinnedMeshRenderer> bodyMeshes, float posTolerance = 0.0001f, float weightThreshold = 0.0001f)
|
||||
public Dictionary<HumanBodyBones, HashSet<Transform>> MeshHumanoidBoneMatcher(
|
||||
Animator animator,
|
||||
IReadOnlyList<SkinnedMeshRenderer> 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<HumanBodyBones, HashSet<Transform>> dictionary = new Dictionary<HumanBodyBones, HashSet<Transform>>();
|
||||
if (animator == null)
|
||||
{
|
||||
if (Object.op_Equality((Object)animator, (Object)null))
|
||||
throw new AutoMorpherException("Animator is Missing", "[MeshHumanoidBoneMatcher] MeshHumanoidBoneMatcher\n - animator is null");
|
||||
}
|
||||
HashSet<Transform> hashSet = new HashSet<Transform>();
|
||||
HashSet<Transform> smrBoneSet = new HashSet<Transform>();
|
||||
if (bodyMeshes != null)
|
||||
{
|
||||
foreach (SkinnedMeshRenderer bodyMesh in bodyMeshes)
|
||||
foreach (SkinnedMeshRenderer bodyMesh in (IEnumerable<SkinnedMeshRenderer>)bodyMeshes)
|
||||
{
|
||||
if (bodyMesh == null)
|
||||
if (!Object.op_Equality((Object)bodyMesh, (Object)null))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
foreach (Transform activeBone in this.GetActiveBones(bodyMesh, weightThreshold))
|
||||
{
|
||||
if (activeBone != null)
|
||||
if (Object.op_Inequality((Object)activeBone, (Object)null))
|
||||
smrBoneSet.Add(activeBone);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int index = 0; index < 55; ++index)
|
||||
{
|
||||
hashSet.Add(activeBone);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < 55; i++)
|
||||
HumanBodyBones key = (HumanBodyBones)index;
|
||||
Transform boneTransform = animator.GetBoneTransform(key);
|
||||
if (!Object.op_Equality((Object)boneTransform, (Object)null))
|
||||
{
|
||||
HumanBodyBones val = (HumanBodyBones)i;
|
||||
Transform boneTransform = animator.GetBoneTransform(val);
|
||||
if (boneTransform == null)
|
||||
{
|
||||
continue;
|
||||
HashSet<Transform> transformSet = new HashSet<Transform>();
|
||||
transformSet.Add(boneTransform);
|
||||
foreach (Transform transform in this.FindBonesByPosition(boneTransform, smrBoneSet, posTolerance))
|
||||
transformSet.Add(transform);
|
||||
dictionary[key] = transformSet;
|
||||
}
|
||||
HashSet<Transform> hashSet2 = new HashSet<Transform>();
|
||||
hashSet2.Add(boneTransform);
|
||||
foreach (Transform item in this.FindBonesByPosition(boneTransform, hashSet, posTolerance))
|
||||
{
|
||||
hashSet2.Add(item);
|
||||
}
|
||||
dictionary[val] = hashSet2;
|
||||
}
|
||||
return dictionary;
|
||||
}
|
||||
|
||||
private List<Transform> FindBonesByPosition(Transform boneToCheck, HashSet<Transform> smrBoneSet, float posTolerance = 0.0001f)
|
||||
private List<Transform> FindBonesByPosition(
|
||||
Transform boneToCheck,
|
||||
HashSet<Transform> 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<Transform> list = new List<Transform>();
|
||||
if (boneToCheck == null)
|
||||
{
|
||||
return list;
|
||||
}
|
||||
List<Transform> bonesByPosition = new List<Transform>();
|
||||
if (Object.op_Equality((Object)boneToCheck, (Object)null))
|
||||
return bonesByPosition;
|
||||
float num = posTolerance * posTolerance;
|
||||
Vector3 position = boneToCheck.position;
|
||||
foreach (Transform item in smrBoneSet)
|
||||
foreach (Transform smrBone in smrBoneSet)
|
||||
{
|
||||
if (!(item == null) && !(item == boneToCheck) && this.NameMatches((((Component)item).gameObject).name, (((Component)boneToCheck).gameObject).name))
|
||||
if (!Object.op_Equality((Object)smrBone, (Object)null) && !Object.op_Equality((Object)smrBone, (Object)boneToCheck) && this.NameMatches(((Object)((Component)smrBone).gameObject).name, ((Object)((Component)boneToCheck).gameObject).name))
|
||||
{
|
||||
Vector3 val = item.position - position;
|
||||
if (val.sqrMagnitude <= num)
|
||||
{
|
||||
list.Add(item);
|
||||
Vector3 vector3 = Vector3.op_Subtraction(smrBone.position, position);
|
||||
if ((double)((Vector3)ref vector3).sqrMagnitude <= (double)num)
|
||||
bonesByPosition.Add(smrBone);
|
||||
}
|
||||
}
|
||||
}
|
||||
return list;
|
||||
return bonesByPosition;
|
||||
}
|
||||
|
||||
private string[] TokenizeBoneName(string name)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(name))
|
||||
{
|
||||
return Array.Empty<string>();
|
||||
}
|
||||
char[] separator = new char[5] { '-', '_', ':', '.', '|' };
|
||||
char[] separator = new char[5]
|
||||
{
|
||||
'-',
|
||||
'_',
|
||||
':',
|
||||
'.',
|
||||
'|'
|
||||
};
|
||||
name = name.Trim();
|
||||
return name.Split(separator, StringSplitOptions.RemoveEmptyEntries);
|
||||
}
|
||||
|
||||
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;
|
||||
string[] strArray1 = this.TokenizeBoneName(boneToCheckName);
|
||||
string[] strArray2 = this.TokenizeBoneName(candidateName);
|
||||
return strArray1.Length != 0 && strArray2.Length != 0 && strArray1[0].Equals(strArray2[0], StringComparison.OrdinalIgnoreCase) && (strArray1.Length <= 1 || strArray2.Length <= 1 || strArray1[1].Equals(strArray2[1], StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
|
||||
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
|
||||
};
|
||||
// ISSUE: unable to decompile the method.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f991af22c535af544ba5652d9ba5f408
|
||||
guid: d30a49a0209cbf44282af1dc59c279df
|
||||
@@ -1,35 +1,25 @@
|
||||
// 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 Eden.AutoMorpher;
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: Eden.AutoMorpher.MeshMatcher
|
||||
// Assembly: EdenAutoMorpherScript, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: D39968B3-E151-4276-BDB4-E82752BBAFF0
|
||||
// Assembly location: D:\dev\AutoMorpher\Assets\@Eden_Tools\Eden_AutoMorpher\Script\EdenAutoMorpherScript.dll
|
||||
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Eden.AutoMorpher
|
||||
{
|
||||
public class MeshMatcher
|
||||
{
|
||||
public struct ClosestHit
|
||||
{
|
||||
public Vector3 closestP;
|
||||
|
||||
public Vector3 direction;
|
||||
|
||||
public Vector3 moveVector;
|
||||
|
||||
public float distance;
|
||||
}
|
||||
|
||||
public BvhTriangleMesh bodyBVH;
|
||||
|
||||
private readonly HashSet<HumanBodyBones> LeftLegBones = new HashSet<HumanBodyBones>
|
||||
private readonly HashSet<HumanBodyBones> LeftLegBones = new HashSet<HumanBodyBones>()
|
||||
{
|
||||
(HumanBodyBones) 1,
|
||||
(HumanBodyBones) 3,
|
||||
(HumanBodyBones) 5,
|
||||
(HumanBodyBones) 19
|
||||
};
|
||||
|
||||
private readonly HashSet<HumanBodyBones> RightLegBones = new HashSet<HumanBodyBones>
|
||||
private readonly HashSet<HumanBodyBones> RightLegBones = new HashSet<HumanBodyBones>()
|
||||
{
|
||||
(HumanBodyBones) 2,
|
||||
(HumanBodyBones) 4,
|
||||
@@ -37,315 +27,182 @@ public class MeshMatcher
|
||||
(HumanBodyBones) 20
|
||||
};
|
||||
|
||||
public BvhTriangleMesh BuildBvhMulti(IReadOnlyList<SkinnedMeshRenderer> bodies, Animator bodyAnimator)
|
||||
public BvhTriangleMesh BuildBvhMulti(
|
||||
IReadOnlyList<SkinnedMeshRenderer> 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);
|
||||
BvhTriangleMesh bvhTriangleMesh = bodies != null && bodies.Count != 0 ? new BvhTriangleMesh().BuildFromSkinnedMeshes(bodies, bodyAnimator) : throw new AutoMorpherException("Body Meshes are Missing", "[BuildBvhMulti] BuildBvhMulti\n - bodies is null or empty");
|
||||
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
|
||||
}));
|
||||
throw new AutoMorpherException(LanguageManager.Get("UI.Exception.title.BodyBVHFail"), LanguageManager.GetFormat("UI.Exception.message.BodyBVHFail", (object)((Object)((Component)bodyAnimator).gameObject).name, (object)(bvhTriangleMesh == null), (object)(bvhTriangleMesh.triangles == null)));
|
||||
}
|
||||
return bvhTriangleMesh;
|
||||
}
|
||||
|
||||
public Vector3[] ExpandVertexMatch(ClothInstance clothInstance, float defaultMinDist = 0.005f, bool skipFootFitting = false, float maxMatchDistance = 0.1f)
|
||||
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;
|
||||
return (Vector3[])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++)
|
||||
Vector3[] vector3Array = new Vector3[worldVertices.Length];
|
||||
float num1 = maxMatchDistance * maxMatchDistance;
|
||||
for (int index = 0; index < worldVertices.Length; ++index)
|
||||
{
|
||||
if (clothInstance.excludedVertices[i])
|
||||
if (clothInstance.excludedVertices[index])
|
||||
vector3Array[index] = Vector3.zero;
|
||||
else if (clothInstance.isInsideVertex[index])
|
||||
{
|
||||
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];
|
||||
}
|
||||
vector3Array[index] = Vector3.zero;
|
||||
}
|
||||
else
|
||||
{
|
||||
array[i] = Vector3.zero;
|
||||
float num2 = minDistance[index] + defaultMinDist;
|
||||
BvhTriangleMesh.ClosestHit closestHit = !clothInstance.isLeftLegVertex[index] ? (!clothInstance.isRightLegVertex[index] ? this.bodyBVH.QueryClosest(worldVertices[index]) : this.bodyBVH.QueryClosest(worldVertices[index], this.RightLegBones)) : this.bodyBVH.QueryClosest(worldVertices[index], this.LeftLegBones);
|
||||
if (skipFootFitting && (closestHit.mainHumanBone == 5 || closestHit.mainHumanBone == 6 || closestHit.mainHumanBone == 20 || closestHit.mainHumanBone == 19))
|
||||
vector3Array[index] = Vector3.zero;
|
||||
else if ((double)closestHit.sqrDistance > (double)num1)
|
||||
{
|
||||
vector3Array[index] = Vector3.zero;
|
||||
}
|
||||
else
|
||||
{
|
||||
Vector3 vector3 = Vector3.op_Subtraction(closestHit.closestPoint, worldVertices[index]);
|
||||
Vector3 normalized = ((Vector3)ref vector3).normalized;
|
||||
float num3 = Vector3.Dot(normalized, ((Vector3)ref closestHit.normal).normalized);
|
||||
if ((double)num3 > 0.699999988079071)
|
||||
vector3Array[index] = Vector3.op_Subtraction(Vector3.op_Addition(closestHit.closestPoint, Vector3.op_Multiply(normalized, num2)), worldVertices[index]);
|
||||
else if ((double)num3 < -0.699999988079071)
|
||||
{
|
||||
if ((double)closestHit.sqrDistance < (double)num2 * (double)num2)
|
||||
vector3Array[index] = Vector3.op_Subtraction(Vector3.op_Subtraction(closestHit.closestPoint, Vector3.op_Multiply(normalized, num2)), worldVertices[index]);
|
||||
}
|
||||
else
|
||||
vector3Array[index] = Vector3.zero;
|
||||
}
|
||||
}
|
||||
return array;
|
||||
}
|
||||
return vector3Array;
|
||||
}
|
||||
|
||||
public Vector3[] ShrinkVertexMatch(ClothInstance clothInstance, float defaultMinDist = 0.005f, float maxMatchDistance = 0.1f)
|
||||
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;
|
||||
return (Vector3[])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++)
|
||||
Vector3[] vector3Array = new Vector3[worldVertices.Length];
|
||||
float num1 = maxMatchDistance * maxMatchDistance;
|
||||
bool[] isLeftLegVertex = clothInstance.isLeftLegVertex;
|
||||
bool[] isRightLegVertex = clothInstance.isRightLegVertex;
|
||||
for (int index = 0; index < worldVertices.Length; ++index)
|
||||
{
|
||||
if (clothInstance.excludedVertices[i])
|
||||
if (clothInstance.excludedVertices[index])
|
||||
vector3Array[index] = Vector3.zero;
|
||||
else if (clothInstance.isInsideVertex[index])
|
||||
{
|
||||
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];
|
||||
}
|
||||
vector3Array[index] = Vector3.zero;
|
||||
}
|
||||
else
|
||||
{
|
||||
array[i] = Vector3.zero;
|
||||
float num2 = minDistance[index] + defaultMinDist;
|
||||
BvhTriangleMesh.ClosestHit closestHit = !clothInstance.isLeftLegVertex[index] ? (!clothInstance.isRightLegVertex[index] ? this.bodyBVH.QueryClosest(worldVertices[index]) : this.bodyBVH.QueryClosest(worldVertices[index], this.RightLegBones)) : this.bodyBVH.QueryClosest(worldVertices[index], this.LeftLegBones);
|
||||
if ((double)closestHit.sqrDistance > (double)num1)
|
||||
vector3Array[index] = Vector3.zero;
|
||||
else if (closestHit.mainHumanBone == 5 || closestHit.mainHumanBone == 6 || closestHit.mainHumanBone == 20 || closestHit.mainHumanBone == 19)
|
||||
{
|
||||
vector3Array[index] = Vector3.zero;
|
||||
}
|
||||
else
|
||||
{
|
||||
Vector3 vector3 = Vector3.op_Subtraction(closestHit.closestPoint, worldVertices[index]);
|
||||
Vector3 normalized = ((Vector3)ref vector3).normalized;
|
||||
float num3 = Vector3.Dot(normalized, ((Vector3)ref closestHit.normal).normalized);
|
||||
if ((double)num3 < -0.699999988079071)
|
||||
vector3Array[index] = Vector3.op_Subtraction(Vector3.op_Subtraction(closestHit.closestPoint, Vector3.op_Multiply(normalized, num2)), worldVertices[index]);
|
||||
else if ((double)num3 < -0.699999988079071)
|
||||
{
|
||||
if ((double)closestHit.sqrDistance < (double)num2 * (double)num2)
|
||||
vector3Array[index] = Vector3.op_Subtraction(Vector3.op_Addition(closestHit.closestPoint, Vector3.op_Multiply(normalized, num2)), worldVertices[index]);
|
||||
}
|
||||
else
|
||||
vector3Array[index] = Vector3.zero;
|
||||
}
|
||||
}
|
||||
return array;
|
||||
}
|
||||
return vector3Array;
|
||||
}
|
||||
|
||||
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)
|
||||
Vector3[] minDistanceToBody = clothesVertices != null && clothesVertices.Length != 0 ? new Vector3[clothesVertices.Length] : throw new AutoMorpherException("Source Vertices is null", "[MeshMatcher] GetMinDistanceToBodySource Vertices is null or no vertices");
|
||||
for (int index = 0; index < clothesVertices.Length; ++index)
|
||||
{
|
||||
throw new AutoMorpherException("Source Vertices is null", "[MeshMatcher] GetMinDistanceToBodySource Vertices is null or no vertices");
|
||||
Vector3 clothesVertex = clothesVertices[index];
|
||||
Vector3 vector3 = Vector3.op_Subtraction(this.bodyBVH.QueryClosest(clothesVertex).closestPoint, clothesVertex);
|
||||
minDistanceToBody[index] = vector3;
|
||||
}
|
||||
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;
|
||||
return minDistanceToBody;
|
||||
}
|
||||
|
||||
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++)
|
||||
bool[] bodyInsideFlags = new bool[worldVertices.Length];
|
||||
for (int index = 0; index < worldVertices.Length; ++index)
|
||||
{
|
||||
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;
|
||||
BvhTriangleMesh.ClosestHit closestHit = this.bodyBVH.QueryClosest(worldVertices[index]);
|
||||
Vector3 vector3 = Vector3.op_Subtraction(closestHit.closestPoint, worldVertices[index]);
|
||||
float num = Vector3.Dot(((Vector3)ref vector3).normalized, ((Vector3)ref closestHit.normal).normalized);
|
||||
bodyInsideFlags[index] = (double)num > 0.0;
|
||||
}
|
||||
return bodyInsideFlags;
|
||||
}
|
||||
|
||||
public struct ClosestHit
|
||||
{
|
||||
public Vector3 closestP;
|
||||
public Vector3 direction;
|
||||
public Vector3 moveVector;
|
||||
public float distance;
|
||||
}
|
||||
return array;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 418eea2f0ad202a45a8bdb4f4ec77b2b
|
||||
guid: d8f0e392696b1cc4b84a811342b1c9a4
|
||||
@@ -1,11 +1,16 @@
|
||||
// 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
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: Eden.AutoMorpher.MorpherMode
|
||||
// Assembly: EdenAutoMorpherScript, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: D39968B3-E151-4276-BDB4-E82752BBAFF0
|
||||
// Assembly location: D:\dev\AutoMorpher\Assets\@Eden_Tools\Eden_AutoMorpher\Script\EdenAutoMorpherScript.dll
|
||||
|
||||
namespace Eden.AutoMorpher
|
||||
{
|
||||
public enum MorpherMode
|
||||
{
|
||||
AutoMorpher = 0,
|
||||
ManualMorpher = 1,
|
||||
ProfileMorpher = 2,
|
||||
ETC = 99
|
||||
ETC = 99, // 0x00000063
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b1f6c2c3a41c0334b837ba300e8680e3
|
||||
guid: 051a6a1f505d3684eaff6e056eb3daf5
|
||||
@@ -1,12 +1,17 @@
|
||||
// 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
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: Eden.AutoMorpher.MorpherState
|
||||
// Assembly: EdenAutoMorpherScript, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: D39968B3-E151-4276-BDB4-E82752BBAFF0
|
||||
// Assembly location: D:\dev\AutoMorpher\Assets\@Eden_Tools\Eden_AutoMorpher\Script\EdenAutoMorpherScript.dll
|
||||
|
||||
namespace Eden.AutoMorpher
|
||||
{
|
||||
public enum MorpherState
|
||||
{
|
||||
Idle,
|
||||
Fitting_Doing,
|
||||
Fitting_End,
|
||||
Weighting_Doing,
|
||||
Weighting_End
|
||||
Weighting_End,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a7ddfac124d756d47a695db1966c6710
|
||||
guid: e2cbda2228845b345bd4473f31dbbf7f
|
||||
@@ -1,212 +1,184 @@
|
||||
// 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
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: Eden.AutoMorpher.PcaUtil
|
||||
// Assembly: EdenAutoMorpherScript, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: D39968B3-E151-4276-BDB4-E82752BBAFF0
|
||||
// Assembly location: D:\dev\AutoMorpher\Assets\@Eden_Tools\Eden_AutoMorpher\Script\EdenAutoMorpherScript.dll
|
||||
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Eden.AutoMorpher
|
||||
{
|
||||
public class PcaUtil
|
||||
{
|
||||
public RegionStats ComputeRegionStats(IList<Vector3> 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);
|
||||
RegionStats regionStats = new RegionStats();
|
||||
if (points == null || points.Count == 0)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
return regionStats;
|
||||
int count = points.Count;
|
||||
Vector3 val = Vector3.zero;
|
||||
for (int i = 0; i < count; i++)
|
||||
Vector3 vector3_1 = Vector3.zero;
|
||||
for (int index = 0; index < count; ++index)
|
||||
vector3_1 = Vector3.op_Addition(vector3_1, points[index]);
|
||||
Vector3 vector3_2 = Vector3.op_Division(vector3_1, (float)count);
|
||||
float num1 = 0.0f;
|
||||
float num2 = 0.0f;
|
||||
float num3 = 0.0f;
|
||||
float num4 = 0.0f;
|
||||
float num5 = 0.0f;
|
||||
float num6 = 0.0f;
|
||||
for (int index = 0; index < count; ++index)
|
||||
{
|
||||
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;
|
||||
Vector3 vector3_3 = Vector3.op_Subtraction(points[index], vector3_2);
|
||||
num1 += vector3_3.x * vector3_3.x;
|
||||
num2 += vector3_3.x * vector3_3.y;
|
||||
num3 += vector3_3.x * vector3_3.z;
|
||||
num4 += vector3_3.y * vector3_3.y;
|
||||
num5 += vector3_3.y * vector3_3.z;
|
||||
num6 += vector3_3.z * vector3_3.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])
|
||||
float[] eigenValues;
|
||||
Vector3[] eigenVectors;
|
||||
this.JacobiEigenDecomposition3x3(num1 * num7, num2 * num7, num3 * num7, num4 * num7, num5 * num7, num6 * num7, out eigenValues, out eigenVectors);
|
||||
int index1 = 0;
|
||||
if ((double)eigenValues[1] > (double)eigenValues[index1])
|
||||
index1 = 1;
|
||||
if ((double)eigenValues[2] > (double)eigenValues[index1])
|
||||
index1 = 2;
|
||||
Vector3 normalized = ((Vector3)ref eigenVectors[index1]).normalized;
|
||||
float num8 = float.PositiveInfinity;
|
||||
float num9 = float.NegativeInfinity;
|
||||
float num10 = 0.0f;
|
||||
for (int index2 = 0; index2 < count; ++index2)
|
||||
{
|
||||
num8 = 1;
|
||||
float num11 = Vector3.Dot(Vector3.op_Subtraction(points[index2], vector3_2), normalized);
|
||||
if ((double)num11 < (double)num8)
|
||||
num8 = num11;
|
||||
if ((double)num11 > (double)num9)
|
||||
num9 = num11;
|
||||
Vector3 vector3_4 = Vector3.op_Addition(vector3_2, Vector3.op_Multiply(normalized, num11));
|
||||
Vector3 vector3_5 = Vector3.op_Subtraction(points[index2], vector3_4);
|
||||
float magnitude = ((Vector3)ref vector3_5).magnitude;
|
||||
num10 += magnitude;
|
||||
}
|
||||
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;
|
||||
regionStats.center = vector3_2;
|
||||
regionStats.principalAxis = normalized;
|
||||
regionStats.length = num9 - num8;
|
||||
regionStats.avgRadius = num10 / (float)count;
|
||||
return regionStats;
|
||||
}
|
||||
|
||||
private void JacobiEigenDecomposition3x3(float c00, float c01, float c02, float c11, float c12, float c22, out float[] eigenValues, out Vector3[] eigenVectors)
|
||||
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]
|
||||
float[,] numArray1 = 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++)
|
||||
c00,
|
||||
c01,
|
||||
c02
|
||||
},
|
||||
{
|
||||
int num = 0;
|
||||
int num2 = 1;
|
||||
float num3 = Mathf.Abs(array[0, 1]);
|
||||
float num4 = Mathf.Abs(array[0, 2]);
|
||||
if (num4 > num3)
|
||||
c01,
|
||||
c11,
|
||||
c12
|
||||
},
|
||||
{
|
||||
num3 = num4;
|
||||
num = 0;
|
||||
num2 = 2;
|
||||
c02,
|
||||
c12,
|
||||
c22
|
||||
}
|
||||
float num5 = Mathf.Abs(array[1, 2]);
|
||||
if (num5 > num3)
|
||||
};
|
||||
float[,] numArray2 = new float[3, 3]
|
||||
{
|
||||
num3 = num5;
|
||||
num = 1;
|
||||
num2 = 2;
|
||||
{
|
||||
1f,
|
||||
0.0f,
|
||||
0.0f
|
||||
},
|
||||
{
|
||||
0.0f,
|
||||
1f,
|
||||
0.0f
|
||||
},
|
||||
{
|
||||
0.0f,
|
||||
0.0f,
|
||||
1f
|
||||
}
|
||||
if (num3 < 1E-10f)
|
||||
};
|
||||
for (int index1 = 0; index1 < 32 /*0x20*/; ++index1)
|
||||
{
|
||||
int index2 = 0;
|
||||
int index3 = 1;
|
||||
float num1 = Mathf.Abs(numArray1[0, 1]);
|
||||
float num2 = Mathf.Abs(numArray1[0, 2]);
|
||||
if ((double)num2 > (double)num1)
|
||||
{
|
||||
num1 = num2;
|
||||
index2 = 0;
|
||||
index3 = 2;
|
||||
}
|
||||
float num3 = Mathf.Abs(numArray1[1, 2]);
|
||||
if ((double)num3 > (double)num1)
|
||||
{
|
||||
num1 = num3;
|
||||
index2 = 1;
|
||||
index3 = 2;
|
||||
}
|
||||
if ((double)num1 >= 1.000000013351432E-10)
|
||||
{
|
||||
float num4 = numArray1[index2, index2];
|
||||
float num5 = numArray1[index3, index3];
|
||||
float num6 = numArray1[index2, index3];
|
||||
double num7 = 0.5 * (double)Mathf.Atan2(2f * num6, num5 - num4);
|
||||
float num8 = Mathf.Cos((float)num7);
|
||||
float num9 = Mathf.Sin((float)num7);
|
||||
for (int index4 = 0; index4 < 3; ++index4)
|
||||
{
|
||||
if (index4 != index2 && index4 != index3)
|
||||
{
|
||||
float num10 = numArray1[index4, index2];
|
||||
float num11 = numArray1[index4, index3];
|
||||
numArray1[index4, index2] = (float)((double)num8 * (double)num10 - (double)num9 * (double)num11);
|
||||
numArray1[index2, index4] = numArray1[index4, index2];
|
||||
numArray1[index4, index3] = (float)((double)num9 * (double)num10 + (double)num8 * (double)num11);
|
||||
numArray1[index3, index4] = numArray1[index4, index3];
|
||||
}
|
||||
}
|
||||
float num12 = (float)((double)num8 * (double)num8 * (double)num4 - 2.0 * (double)num9 * (double)num8 * (double)num6 + (double)num9 * (double)num9 * (double)num5);
|
||||
float num13 = (float)((double)num9 * (double)num9 * (double)num4 + 2.0 * (double)num9 * (double)num8 * (double)num6 + (double)num8 * (double)num8 * (double)num5);
|
||||
numArray1[index2, index2] = num12;
|
||||
numArray1[index3, index3] = num13;
|
||||
numArray1[index2, index3] = 0.0f;
|
||||
numArray1[index3, index2] = 0.0f;
|
||||
for (int index5 = 0; index5 < 3; ++index5)
|
||||
{
|
||||
float num14 = numArray2[index5, index2];
|
||||
float num15 = numArray2[index5, index3];
|
||||
numArray2[index5, index2] = (float)((double)num8 * (double)num14 - (double)num9 * (double)num15);
|
||||
numArray2[index5, index3] = (float)((double)num9 * (double)num14 + (double)num8 * (double)num15);
|
||||
}
|
||||
}
|
||||
else
|
||||
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]);
|
||||
eigenVectors = new Vector3[3];
|
||||
eigenValues[0] = numArray1[0, 0];
|
||||
eigenValues[1] = numArray1[1, 1];
|
||||
eigenValues[2] = numArray1[2, 2];
|
||||
eigenVectors[0] = new Vector3(numArray2[0, 0], numArray2[1, 0], numArray2[2, 0]);
|
||||
eigenVectors[1] = new Vector3(numArray2[0, 1], numArray2[1, 1], numArray2[2, 1]);
|
||||
eigenVectors[2] = new Vector3(numArray2[0, 2], numArray2[1, 2], numArray2[2, 2]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 16f14c8f4290f7f4dbe5bd00ac634a53
|
||||
guid: 19d0bd017b9aa7f4681275eda30241ed
|
||||
@@ -1,12 +1,15 @@
|
||||
// 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
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: Eden.AutoMorpher.ProcessInfo
|
||||
// Assembly: EdenAutoMorpherScript, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||
// MVID: D39968B3-E151-4276-BDB4-E82752BBAFF0
|
||||
// Assembly location: D:\dev\AutoMorpher\Assets\@Eden_Tools\Eden_AutoMorpher\Script\EdenAutoMorpherScript.dll
|
||||
|
||||
namespace Eden.AutoMorpher
|
||||
{
|
||||
public struct ProcessInfo
|
||||
{
|
||||
public string title;
|
||||
|
||||
public string text;
|
||||
|
||||
public float progress;
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user