EdenAutoMorpherScript를 ILSpy로 디컴파일한 결과를 수정없이 가져옴
This commit is contained in:
464
Assets/@Eden_Tools/Eden_AutoMorpher/Script/SkinningUtil.cs
Normal file
464
Assets/@Eden_Tools/Eden_AutoMorpher/Script/SkinningUtil.cs
Normal file
@@ -0,0 +1,464 @@
|
||||
// Warning: Some assembly references could not be resolved automatically. This might lead to incorrect decompilation of some parts,
|
||||
// for ex. property getter/setter access. To get optimal decompilation results, please manually add the missing references to the list of loaded assemblies.
|
||||
// EdenAutoMorpherScript, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
|
||||
// Eden.AutoMorpher.SkinningUtil
|
||||
using UnityEngine;
|
||||
|
||||
public class SkinningUtil
|
||||
{
|
||||
public Vector3 WorldPosToBindPos(SkinnedMeshRenderer smr, Mesh bindMesh, int vertexIndex, Vector3 targetWorld)
|
||||
{
|
||||
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_023a: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_023c: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0241: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_024b: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0250: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0255: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_025a: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0210: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0212: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_02c8: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_02cf: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_02d6: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_02de: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_02ef: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_02f6: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0305: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_030c: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0317: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_031e: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0325: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_032d: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0334: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_035a: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_035c: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0361: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0365: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0367: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_036c: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0379: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_037b: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0380: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0382: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0396: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_034b: Unknown result type (might be due to invalid IL or missing references)
|
||||
if ((Object)(object)smr == (Object)null || (Object)(object)bindMesh == (Object)null)
|
||||
{
|
||||
return Vector3.zero;
|
||||
}
|
||||
BoneWeight[] boneWeights = bindMesh.boneWeights;
|
||||
Matrix4x4[] bindposes = bindMesh.bindposes;
|
||||
Transform[] bones = smr.bones;
|
||||
if (boneWeights == null || bindposes == null || bones == null)
|
||||
{
|
||||
return ((Component)smr).transform.InverseTransformPoint(targetWorld);
|
||||
}
|
||||
if (vertexIndex < 0 || vertexIndex >= boneWeights.Length)
|
||||
{
|
||||
return ((Component)smr).transform.InverseTransformPoint(targetWorld);
|
||||
}
|
||||
if (bindposes.Length != bones.Length)
|
||||
{
|
||||
return ((Component)smr).transform.InverseTransformPoint(targetWorld);
|
||||
}
|
||||
BoneWeight val = boneWeights[vertexIndex];
|
||||
bool flag = ((BoneWeight)(ref val)).boneIndex0 >= 0 && ((BoneWeight)(ref val)).boneIndex0 < bones.Length && (Object)(object)bones[((BoneWeight)(ref val)).boneIndex0] != (Object)null && ((BoneWeight)(ref val)).weight0 > 0f;
|
||||
bool flag2 = ((BoneWeight)(ref val)).boneIndex1 >= 0 && ((BoneWeight)(ref val)).boneIndex1 < bones.Length && (Object)(object)bones[((BoneWeight)(ref val)).boneIndex1] != (Object)null && ((BoneWeight)(ref val)).weight1 > 0f;
|
||||
bool flag3 = ((BoneWeight)(ref val)).boneIndex2 >= 0 && ((BoneWeight)(ref val)).boneIndex2 < bones.Length && (Object)(object)bones[((BoneWeight)(ref val)).boneIndex2] != (Object)null && ((BoneWeight)(ref val)).weight2 > 0f;
|
||||
bool num = ((BoneWeight)(ref val)).boneIndex3 >= 0 && ((BoneWeight)(ref val)).boneIndex3 < bones.Length && (Object)(object)bones[((BoneWeight)(ref val)).boneIndex3] != (Object)null && ((BoneWeight)(ref val)).weight3 > 0f;
|
||||
float num2 = (flag ? ((BoneWeight)(ref val)).weight0 : 0f);
|
||||
float num3 = (flag2 ? ((BoneWeight)(ref val)).weight1 : 0f);
|
||||
float num4 = (flag3 ? ((BoneWeight)(ref val)).weight2 : 0f);
|
||||
float num5 = (num ? ((BoneWeight)(ref val)).weight3 : 0f);
|
||||
float num6 = num2 + num3 + num4 + num5;
|
||||
if (num6 <= 1E-08f)
|
||||
{
|
||||
return ((Component)smr).transform.InverseTransformPoint(targetWorld);
|
||||
}
|
||||
num2 /= num6;
|
||||
num3 /= num6;
|
||||
num4 /= num6;
|
||||
num5 /= num6;
|
||||
Vector3 val2 = ((Component)smr).transform.InverseTransformPoint(targetWorld);
|
||||
Matrix4x4 objWorldInv = ((Component)smr).transform.worldToLocalMatrix;
|
||||
Matrix4x4 acc = Matrix4x4.zero;
|
||||
if (num2 > 0f)
|
||||
{
|
||||
Acc(ref acc, ((BoneWeight)(ref val)).boneIndex0, num2);
|
||||
}
|
||||
if (num3 > 0f)
|
||||
{
|
||||
Acc(ref acc, ((BoneWeight)(ref val)).boneIndex1, num3);
|
||||
}
|
||||
if (num4 > 0f)
|
||||
{
|
||||
Acc(ref acc, ((BoneWeight)(ref val)).boneIndex2, num4);
|
||||
}
|
||||
if (num5 > 0f)
|
||||
{
|
||||
Acc(ref acc, ((BoneWeight)(ref val)).boneIndex3, num5);
|
||||
}
|
||||
if (Mathf.Abs(acc.m00 * (acc.m11 * acc.m22 - acc.m12 * acc.m21) - acc.m01 * (acc.m10 * acc.m22 - acc.m12 * acc.m20) + acc.m02 * (acc.m10 * acc.m21 - acc.m11 * acc.m20)) < 1E-12f)
|
||||
{
|
||||
return val2;
|
||||
}
|
||||
acc.m33 = 1f;
|
||||
Matrix4x4 val3 = Matrix4x4.Inverse(acc);
|
||||
Vector3 val4 = ((Matrix4x4)(ref val3)).MultiplyPoint3x4(val2);
|
||||
Debug.Log((object)$"Diff{((Component)smr).transform.TransformPoint(val4) - targetWorld}");
|
||||
return val4;
|
||||
void Acc(ref Matrix4x4 reference, int boneIndex, float w)
|
||||
{
|
||||
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
|
||||
if (!(w <= 0f))
|
||||
{
|
||||
Matrix4x4 val5 = objWorldInv * bones[boneIndex].localToWorldMatrix * bindposes[boneIndex];
|
||||
reference.m00 += val5.m00 * w;
|
||||
reference.m01 += val5.m01 * w;
|
||||
reference.m02 += val5.m02 * w;
|
||||
reference.m10 += val5.m10 * w;
|
||||
reference.m11 += val5.m11 * w;
|
||||
reference.m12 += val5.m12 * w;
|
||||
reference.m20 += val5.m20 * w;
|
||||
reference.m21 += val5.m21 * w;
|
||||
reference.m22 += val5.m22 * w;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Vector3 WorldPosToBindPos_Full(SkinnedMeshRenderer smr, Mesh bindMesh, int vertexIndex, Vector3 targetWorld)
|
||||
{
|
||||
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0157: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0159: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0183: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0185: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_018a: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_018e: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0195: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_019c: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_020a: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0211: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0218: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0220: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0227: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0231: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0238: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_023f: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0247: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_024e: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0259: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0260: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0267: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_026f: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0276: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0290: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0292: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0297: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_029b: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_029d: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_028d: Unknown result type (might be due to invalid IL or missing references)
|
||||
if ((Object)(object)smr == (Object)null || (Object)(object)bindMesh == (Object)null)
|
||||
{
|
||||
return Vector3.zero;
|
||||
}
|
||||
BoneWeight[] boneWeights = bindMesh.boneWeights;
|
||||
Matrix4x4[] bindposes = bindMesh.bindposes;
|
||||
Transform[] bones = smr.bones;
|
||||
if (boneWeights == null || bindposes == null || bones == null)
|
||||
{
|
||||
return ((Component)smr).transform.InverseTransformPoint(targetWorld);
|
||||
}
|
||||
if (vertexIndex < 0 || vertexIndex >= boneWeights.Length)
|
||||
{
|
||||
return ((Component)smr).transform.InverseTransformPoint(targetWorld);
|
||||
}
|
||||
if (bindposes.Length != bones.Length)
|
||||
{
|
||||
return ((Component)smr).transform.InverseTransformPoint(targetWorld);
|
||||
}
|
||||
BoneWeight val = boneWeights[vertexIndex];
|
||||
float[] array = new float[4];
|
||||
int[] array2 = new int[4];
|
||||
array[0] = ((BoneWeight)(ref val)).weight0;
|
||||
array2[0] = ((BoneWeight)(ref val)).boneIndex0;
|
||||
array[1] = ((BoneWeight)(ref val)).weight1;
|
||||
array2[1] = ((BoneWeight)(ref val)).boneIndex1;
|
||||
array[2] = ((BoneWeight)(ref val)).weight2;
|
||||
array2[2] = ((BoneWeight)(ref val)).boneIndex2;
|
||||
array[3] = ((BoneWeight)(ref val)).weight3;
|
||||
array2[3] = ((BoneWeight)(ref val)).boneIndex3;
|
||||
float num = 0f;
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
if (array2[i] >= 0 && array2[i] < bones.Length && (Object)(object)bones[array2[i]] != (Object)null)
|
||||
{
|
||||
num += array[i];
|
||||
}
|
||||
}
|
||||
if (num < 1E-08f)
|
||||
{
|
||||
return ((Component)smr).transform.InverseTransformPoint(targetWorld);
|
||||
}
|
||||
for (int j = 0; j < 4; j++)
|
||||
{
|
||||
array[j] /= num;
|
||||
}
|
||||
Vector3 val2 = ((Component)smr).transform.InverseTransformPoint(targetWorld);
|
||||
Vector4 val3 = default(Vector4);
|
||||
((Vector4)(ref val3))._002Ector(val2.x, val2.y, val2.z, 1f);
|
||||
Matrix4x4 objWorldInv = ((Component)smr).transform.worldToLocalMatrix;
|
||||
Matrix4x4 acc = Matrix4x4.zero;
|
||||
for (int k = 0; k < 4; k++)
|
||||
{
|
||||
if (array[k] > 0f && array2[k] >= 0 && array2[k] < bones.Length)
|
||||
{
|
||||
Accumulate(ref acc, array2[k], array[k]);
|
||||
}
|
||||
}
|
||||
if (Mathf.Abs(acc.m00 * (acc.m11 * acc.m22 - acc.m12 * acc.m21) - acc.m01 * (acc.m10 * acc.m22 - acc.m12 * acc.m20) + acc.m02 * (acc.m10 * acc.m21 - acc.m11 * acc.m20)) < 1E-12f)
|
||||
{
|
||||
return val2;
|
||||
}
|
||||
Matrix4x4 val4 = Matrix4x4.Inverse(acc);
|
||||
return ((Matrix4x4)(ref val4)).MultiplyPoint3x4(Vector4.op_Implicit(val3));
|
||||
void Accumulate(ref Matrix4x4 reference, int bi, float w)
|
||||
{
|
||||
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0101: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0113: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0125: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0137: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0149: Unknown result type (might be due to invalid IL or missing references)
|
||||
if (!(w <= 0f))
|
||||
{
|
||||
Matrix4x4 val5 = objWorldInv * bones[bi].localToWorldMatrix * bindposes[bi];
|
||||
reference.m00 += val5.m00 * w;
|
||||
reference.m01 += val5.m01 * w;
|
||||
reference.m02 += val5.m02 * w;
|
||||
reference.m03 += val5.m03 * w;
|
||||
reference.m10 += val5.m10 * w;
|
||||
reference.m11 += val5.m11 * w;
|
||||
reference.m12 += val5.m12 * w;
|
||||
reference.m13 += val5.m13 * w;
|
||||
reference.m20 += val5.m20 * w;
|
||||
reference.m21 += val5.m21 * w;
|
||||
reference.m22 += val5.m22 * w;
|
||||
reference.m23 += val5.m23 * w;
|
||||
reference.m30 += val5.m30 * w;
|
||||
reference.m31 += val5.m31 * w;
|
||||
reference.m32 += val5.m32 * w;
|
||||
reference.m33 += val5.m33 * w;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Vector3 WorldDirToBindDir_Full(SkinnedMeshRenderer smr, Mesh bindMesh, int vertexIndex, Vector3 targetWorldDir)
|
||||
{
|
||||
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_00af: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0172: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0174: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0179: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_017d: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_01db: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_01be: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0223: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0228: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_022c: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_022e: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0233: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_024d: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0245: Unknown result type (might be due to invalid IL or missing references)
|
||||
if ((Object)(object)smr == (Object)null || (Object)(object)bindMesh == (Object)null)
|
||||
{
|
||||
return Vector3.zero;
|
||||
}
|
||||
BoneWeight[] boneWeights = bindMesh.boneWeights;
|
||||
Matrix4x4[] bindposes = bindMesh.bindposes;
|
||||
Transform[] bones = smr.bones;
|
||||
Vector3 val;
|
||||
if (boneWeights == null || bindposes == null || bones == null)
|
||||
{
|
||||
val = ((Component)smr).transform.InverseTransformDirection(targetWorldDir);
|
||||
return ((Vector3)(ref val)).normalized;
|
||||
}
|
||||
if (vertexIndex < 0 || vertexIndex >= boneWeights.Length)
|
||||
{
|
||||
val = ((Component)smr).transform.InverseTransformDirection(targetWorldDir);
|
||||
return ((Vector3)(ref val)).normalized;
|
||||
}
|
||||
if (bindposes.Length != bones.Length)
|
||||
{
|
||||
val = ((Component)smr).transform.InverseTransformDirection(targetWorldDir);
|
||||
return ((Vector3)(ref val)).normalized;
|
||||
}
|
||||
BoneWeight val2 = boneWeights[vertexIndex];
|
||||
float[] array = new float[4];
|
||||
int[] array2 = new int[4];
|
||||
array[0] = ((BoneWeight)(ref val2)).weight0;
|
||||
array2[0] = ((BoneWeight)(ref val2)).boneIndex0;
|
||||
array[1] = ((BoneWeight)(ref val2)).weight1;
|
||||
array2[1] = ((BoneWeight)(ref val2)).boneIndex1;
|
||||
array[2] = ((BoneWeight)(ref val2)).weight2;
|
||||
array2[2] = ((BoneWeight)(ref val2)).boneIndex2;
|
||||
array[3] = ((BoneWeight)(ref val2)).weight3;
|
||||
array2[3] = ((BoneWeight)(ref val2)).boneIndex3;
|
||||
float num = 0f;
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
if (array2[i] >= 0 && array2[i] < bones.Length && (Object)(object)bones[array2[i]] != (Object)null)
|
||||
{
|
||||
num += array[i];
|
||||
}
|
||||
}
|
||||
if (num < 1E-08f)
|
||||
{
|
||||
val = ((Component)smr).transform.InverseTransformDirection(targetWorldDir);
|
||||
return ((Vector3)(ref val)).normalized;
|
||||
}
|
||||
for (int j = 0; j < 4; j++)
|
||||
{
|
||||
array[j] /= num;
|
||||
}
|
||||
Vector3 val3 = ((Component)smr).transform.InverseTransformDirection(targetWorldDir);
|
||||
if (((Vector3)(ref val3)).sqrMagnitude < 1E-12f)
|
||||
{
|
||||
return Vector3.up;
|
||||
}
|
||||
Matrix4x4 objWorldInv = ((Component)smr).transform.worldToLocalMatrix;
|
||||
Matrix4x4 acc = Matrix4x4.zero;
|
||||
for (int k = 0; k < 4; k++)
|
||||
{
|
||||
if (array[k] > 0f && array2[k] >= 0 && array2[k] < bones.Length)
|
||||
{
|
||||
Accumulate(ref acc, array2[k], array[k]);
|
||||
}
|
||||
}
|
||||
Matrix4x4 transpose = ((Matrix4x4)(ref acc)).transpose;
|
||||
Vector3 val4 = ((Matrix4x4)(ref transpose)).MultiplyVector(val3);
|
||||
if (((Vector3)(ref val4)).sqrMagnitude < 1E-12f)
|
||||
{
|
||||
return ((Vector3)(ref val3)).normalized;
|
||||
}
|
||||
return ((Vector3)(ref val4)).normalized;
|
||||
void Accumulate(ref Matrix4x4 reference, int bi, float w)
|
||||
{
|
||||
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0101: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0113: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0125: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0137: Unknown result type (might be due to invalid IL or missing references)
|
||||
//IL_0149: Unknown result type (might be due to invalid IL or missing references)
|
||||
if (!(w <= 0f))
|
||||
{
|
||||
Matrix4x4 val5 = objWorldInv * bones[bi].localToWorldMatrix * bindposes[bi];
|
||||
reference.m00 += val5.m00 * w;
|
||||
reference.m01 += val5.m01 * w;
|
||||
reference.m02 += val5.m02 * w;
|
||||
reference.m03 += val5.m03 * w;
|
||||
reference.m10 += val5.m10 * w;
|
||||
reference.m11 += val5.m11 * w;
|
||||
reference.m12 += val5.m12 * w;
|
||||
reference.m13 += val5.m13 * w;
|
||||
reference.m20 += val5.m20 * w;
|
||||
reference.m21 += val5.m21 * w;
|
||||
reference.m22 += val5.m22 * w;
|
||||
reference.m23 += val5.m23 * w;
|
||||
reference.m30 += val5.m30 * w;
|
||||
reference.m31 += val5.m31 * w;
|
||||
reference.m32 += val5.m32 * w;
|
||||
reference.m33 += val5.m33 * w;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user