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

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

View File

@@ -0,0 +1,248 @@
// Decompiled with JetBrains decompiler
// Type: Eden.AutoMorpher.SkinningUtil
// 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 SkinningUtil
{
public Vector3 WorldPosToBindPos(
SkinnedMeshRenderer smr,
Mesh bindMesh,
int vertexIndex,
Vector3 targetWorld)
{
if (Object.op_Equality((Object)smr, (Object)null) || Object.op_Equality((Object)bindMesh, (Object)null))
return Vector3.zero;
BoneWeight[] boneWeights = bindMesh.boneWeights;
Matrix4x4[] bindposes = bindMesh.bindposes;
Transform[] bones = smr.bones;
if (boneWeights == null || bindposes == null || bones == null)
return ((Component)smr).transform.InverseTransformPoint(targetWorld);
if (vertexIndex < 0 || vertexIndex >= boneWeights.Length)
return ((Component)smr).transform.InverseTransformPoint(targetWorld);
if (bindposes.Length != bones.Length)
return ((Component)smr).transform.InverseTransformPoint(targetWorld);
BoneWeight boneWeight = boneWeights[vertexIndex];
bool flag1 = ((BoneWeight)ref boneWeight).boneIndex0 >= 0 && ((BoneWeight)ref boneWeight).boneIndex0 < bones.Length && Object.op_Inequality((Object)bones[((BoneWeight)ref boneWeight).boneIndex0], (Object)null) && (double)((BoneWeight)ref boneWeight).weight0 > 0.0;
bool flag2 = ((BoneWeight)ref boneWeight).boneIndex1 >= 0 && ((BoneWeight)ref boneWeight).boneIndex1 < bones.Length && Object.op_Inequality((Object)bones[((BoneWeight)ref boneWeight).boneIndex1], (Object)null) && (double)((BoneWeight)ref boneWeight).weight1 > 0.0;
bool flag3 = ((BoneWeight)ref boneWeight).boneIndex2 >= 0 && ((BoneWeight)ref boneWeight).boneIndex2 < bones.Length && Object.op_Inequality((Object)bones[((BoneWeight)ref boneWeight).boneIndex2], (Object)null) && (double)((BoneWeight)ref boneWeight).weight2 > 0.0;
int num1 = ((BoneWeight)ref boneWeight).boneIndex3 < 0 || ((BoneWeight)ref boneWeight).boneIndex3 >= bones.Length || !Object.op_Inequality((Object)bones[((BoneWeight)ref boneWeight).boneIndex3], (Object)null) ? 0 : ((double)((BoneWeight)ref boneWeight).weight3 > 0.0 ? 1 : 0);
float num2 = flag1 ? ((BoneWeight)ref boneWeight).weight0 : 0.0f;
float num3 = flag2 ? ((BoneWeight)ref boneWeight).weight1 : 0.0f;
float num4 = flag3 ? ((BoneWeight)ref boneWeight).weight2 : 0.0f;
float num5 = num1 != 0 ? ((BoneWeight)ref boneWeight).weight3 : 0.0f;
float num6 = num2 + num3 + num4 + num5;
if ((double)num6 <= 9.99999993922529E-09)
return ((Component)smr).transform.InverseTransformPoint(targetWorld);
float w1 = num2 / num6;
float w2 = num3 / num6;
float w3 = num4 / num6;
float w4 = num5 / num6;
Vector3 bindPos1 = ((Component)smr).transform.InverseTransformPoint(targetWorld);
Matrix4x4 objWorldInv = ((Component)smr).transform.worldToLocalMatrix;
Matrix4x4 zero = Matrix4x4.zero;
if ((double)w1 > 0.0)
Acc(ref zero, ((BoneWeight)ref boneWeight).boneIndex0, w1);
if ((double)w2 > 0.0)
Acc(ref zero, ((BoneWeight)ref boneWeight).boneIndex1, w2);
if ((double)w3 > 0.0)
Acc(ref zero, ((BoneWeight)ref boneWeight).boneIndex2, w3);
if ((double)w4 > 0.0)
Acc(ref zero, ((BoneWeight)ref boneWeight).boneIndex3, w4);
if ((double)Mathf.Abs((float)((double)zero.m00 * ((double)zero.m11 * (double)zero.m22 - (double)zero.m12 * (double)zero.m21) - (double)zero.m01 * ((double)zero.m10 * (double)zero.m22 - (double)zero.m12 * (double)zero.m20) + (double)zero.m02 * ((double)zero.m10 * (double)zero.m21 - (double)zero.m11 * (double)zero.m20))) < 9.999999960041972E-13)
return bindPos1;
zero.m33 = 1f;
Matrix4x4 matrix4x4 = Matrix4x4.Inverse(zero);
Vector3 bindPos2 = ((Matrix4x4)ref matrix4x4).MultiplyPoint3x4(bindPos1);
Debug.Log((object)$"Diff{Vector3.op_Subtraction(((Component)smr).transform.TransformPoint(bindPos2), targetWorld)}");
return bindPos2;
void Acc(ref Matrix4x4 acc, int boneIndex, float w)
{
if ((double)w <= 0.0)
return;
Matrix4x4 matrix4x4 = Matrix4x4.op_Multiply(Matrix4x4.op_Multiply(objWorldInv, bones[boneIndex].localToWorldMatrix), bindposes[boneIndex]);
acc.m00 += matrix4x4.m00 * w;
acc.m01 += matrix4x4.m01 * w;
acc.m02 += matrix4x4.m02 * w;
acc.m10 += matrix4x4.m10 * w;
acc.m11 += matrix4x4.m11 * w;
acc.m12 += matrix4x4.m12 * w;
acc.m20 += matrix4x4.m20 * w;
acc.m21 += matrix4x4.m21 * w;
acc.m22 += matrix4x4.m22 * w;
}
}
public Vector3 WorldPosToBindPos_Full(
SkinnedMeshRenderer smr,
Mesh bindMesh,
int vertexIndex,
Vector3 targetWorld)
{
if (Object.op_Equality((Object)smr, (Object)null) || Object.op_Equality((Object)bindMesh, (Object)null))
return Vector3.zero;
BoneWeight[] boneWeights = bindMesh.boneWeights;
Matrix4x4[] bindposes = bindMesh.bindposes;
Transform[] bones = smr.bones;
if (boneWeights == null || bindposes == null || bones == null)
return ((Component)smr).transform.InverseTransformPoint(targetWorld);
if (vertexIndex < 0 || vertexIndex >= boneWeights.Length)
return ((Component)smr).transform.InverseTransformPoint(targetWorld);
if (bindposes.Length != bones.Length)
return ((Component)smr).transform.InverseTransformPoint(targetWorld);
BoneWeight boneWeight = boneWeights[vertexIndex];
float[] numArray1 = new float[4];
int[] numArray2 = new int[4];
numArray1[0] = ((BoneWeight)ref boneWeight).weight0;
numArray2[0] = ((BoneWeight)ref boneWeight).boneIndex0;
numArray1[1] = ((BoneWeight)ref boneWeight).weight1;
numArray2[1] = ((BoneWeight)ref boneWeight).boneIndex1;
numArray1[2] = ((BoneWeight)ref boneWeight).weight2;
numArray2[2] = ((BoneWeight)ref boneWeight).boneIndex2;
numArray1[3] = ((BoneWeight)ref boneWeight).weight3;
numArray2[3] = ((BoneWeight)ref boneWeight).boneIndex3;
float num = 0.0f;
for (int index = 0; index < 4; ++index)
{
if (numArray2[index] >= 0 && numArray2[index] < bones.Length && Object.op_Inequality((Object)bones[numArray2[index]], (Object)null))
num += numArray1[index];
}
if ((double)num < 9.99999993922529E-09)
return ((Component)smr).transform.InverseTransformPoint(targetWorld);
for (int index = 0; index < 4; ++index)
numArray1[index] /= num;
Vector3 bindPosFull = ((Component)smr).transform.InverseTransformPoint(targetWorld);
Vector4 vector4;
// ISSUE: explicit constructor call
((Vector4)ref vector4).\u002Ector(bindPosFull.x, bindPosFull.y, bindPosFull.z, 1f);
Matrix4x4 objWorldInv = ((Component)smr).transform.worldToLocalMatrix;
Matrix4x4 zero = Matrix4x4.zero;
for (int index = 0; index < 4; ++index)
{
if ((double)numArray1[index] > 0.0 && numArray2[index] >= 0 && numArray2[index] < bones.Length)
Accumulate(ref zero, numArray2[index], numArray1[index]);
}
if ((double)Mathf.Abs((float)((double)zero.m00 * ((double)zero.m11 * (double)zero.m22 - (double)zero.m12 * (double)zero.m21) - (double)zero.m01 * ((double)zero.m10 * (double)zero.m22 - (double)zero.m12 * (double)zero.m20) + (double)zero.m02 * ((double)zero.m10 * (double)zero.m21 - (double)zero.m11 * (double)zero.m20))) < 9.999999960041972E-13)
return bindPosFull;
Matrix4x4 matrix4x4 = Matrix4x4.Inverse(zero);
return ((Matrix4x4)ref matrix4x4).MultiplyPoint3x4(Vector4.op_Implicit(vector4));
void Accumulate(ref Matrix4x4 acc, int bi, float w)
{
if ((double)w <= 0.0)
return;
Matrix4x4 matrix4x4 = Matrix4x4.op_Multiply(Matrix4x4.op_Multiply(objWorldInv, bones[bi].localToWorldMatrix), bindposes[bi]);
acc.m00 += matrix4x4.m00 * w;
acc.m01 += matrix4x4.m01 * w;
acc.m02 += matrix4x4.m02 * w;
acc.m03 += matrix4x4.m03 * w;
acc.m10 += matrix4x4.m10 * w;
acc.m11 += matrix4x4.m11 * w;
acc.m12 += matrix4x4.m12 * w;
acc.m13 += matrix4x4.m13 * w;
acc.m20 += matrix4x4.m20 * w;
acc.m21 += matrix4x4.m21 * w;
acc.m22 += matrix4x4.m22 * w;
acc.m23 += matrix4x4.m23 * w;
acc.m30 += matrix4x4.m30 * w;
acc.m31 += matrix4x4.m31 * w;
acc.m32 += matrix4x4.m32 * w;
acc.m33 += matrix4x4.m33 * w;
}
}
public Vector3 WorldDirToBindDir_Full(
SkinnedMeshRenderer smr,
Mesh bindMesh,
int vertexIndex,
Vector3 targetWorldDir)
{
if (Object.op_Equality((Object)smr, (Object)null) || Object.op_Equality((Object)bindMesh, (Object)null))
return Vector3.zero;
BoneWeight[] boneWeights = bindMesh.boneWeights;
Matrix4x4[] bindposes = bindMesh.bindposes;
Transform[] bones = smr.bones;
if (boneWeights == null || bindposes == null || bones == null)
{
Vector3 vector3 = ((Component)smr).transform.InverseTransformDirection(targetWorldDir);
return ((Vector3)ref vector3).normalized;
}
if (vertexIndex < 0 || vertexIndex >= boneWeights.Length)
{
Vector3 vector3 = ((Component)smr).transform.InverseTransformDirection(targetWorldDir);
return ((Vector3)ref vector3).normalized;
}
if (bindposes.Length != bones.Length)
{
Vector3 vector3 = ((Component)smr).transform.InverseTransformDirection(targetWorldDir);
return ((Vector3)ref vector3).normalized;
}
BoneWeight boneWeight = boneWeights[vertexIndex];
float[] numArray1 = new float[4];
int[] numArray2 = new int[4];
numArray1[0] = ((BoneWeight)ref boneWeight).weight0;
numArray2[0] = ((BoneWeight)ref boneWeight).boneIndex0;
numArray1[1] = ((BoneWeight)ref boneWeight).weight1;
numArray2[1] = ((BoneWeight)ref boneWeight).boneIndex1;
numArray1[2] = ((BoneWeight)ref boneWeight).weight2;
numArray2[2] = ((BoneWeight)ref boneWeight).boneIndex2;
numArray1[3] = ((BoneWeight)ref boneWeight).weight3;
numArray2[3] = ((BoneWeight)ref boneWeight).boneIndex3;
float num = 0.0f;
for (int index = 0; index < 4; ++index)
{
if (numArray2[index] >= 0 && numArray2[index] < bones.Length && Object.op_Inequality((Object)bones[numArray2[index]], (Object)null))
num += numArray1[index];
}
if ((double)num < 9.99999993922529E-09)
{
Vector3 vector3 = ((Component)smr).transform.InverseTransformDirection(targetWorldDir);
return ((Vector3)ref vector3).normalized;
}
for (int index = 0; index < 4; ++index)
numArray1[index] /= num;
Vector3 vector3_1 = ((Component)smr).transform.InverseTransformDirection(targetWorldDir);
if ((double)((Vector3)ref vector3_1).sqrMagnitude < 9.999999960041972E-13)
return Vector3.up;
Matrix4x4 objWorldInv = ((Component)smr).transform.worldToLocalMatrix;
Matrix4x4 zero = Matrix4x4.zero;
for (int index = 0; index < 4; ++index)
{
if ((double)numArray1[index] > 0.0 && numArray2[index] >= 0 && numArray2[index] < bones.Length)
Accumulate(ref zero, numArray2[index], numArray1[index]);
}
Matrix4x4 transpose = ((Matrix4x4)ref zero).transpose;
Vector3 vector3_2 = ((Matrix4x4)ref transpose).MultiplyVector(vector3_1);
return (double)((Vector3)ref vector3_2).sqrMagnitude < 9.999999960041972E-13 ? ((Vector3)ref vector3_1).normalized : ((Vector3)ref vector3_2).normalized;
void Accumulate(ref Matrix4x4 acc, int bi, float w)
{
if ((double)w <= 0.0)
return;
Matrix4x4 matrix4x4 = Matrix4x4.op_Multiply(Matrix4x4.op_Multiply(objWorldInv, bones[bi].localToWorldMatrix), bindposes[bi]);
acc.m00 += matrix4x4.m00 * w;
acc.m01 += matrix4x4.m01 * w;
acc.m02 += matrix4x4.m02 * w;
acc.m03 += matrix4x4.m03 * w;
acc.m10 += matrix4x4.m10 * w;
acc.m11 += matrix4x4.m11 * w;
acc.m12 += matrix4x4.m12 * w;
acc.m13 += matrix4x4.m13 * w;
acc.m20 += matrix4x4.m20 * w;
acc.m21 += matrix4x4.m21 * w;
acc.m22 += matrix4x4.m22 * w;
acc.m23 += matrix4x4.m23 * w;
acc.m30 += matrix4x4.m30 * w;
acc.m31 += matrix4x4.m31 * w;
acc.m32 += matrix4x4.m32 * w;
acc.m33 += matrix4x4.m33 * w;
}
}
}
}