mirror of
https://github.com/bdunderscore/modular-avatar.git
synced 2025-01-01 20:25:07 +08:00
parent
e6ffd04110
commit
93aa4db3e8
@ -50,7 +50,7 @@ namespace nadena.dev.modular_avatar.core.armature_lock
|
||||
}
|
||||
}
|
||||
|
||||
//[BurstCompile]
|
||||
[BurstCompile]
|
||||
struct ComputePosition : IJobParallelFor
|
||||
{
|
||||
[ReadOnly] public NativeArray<BoneStaticData> _boneStatic;
|
||||
@ -115,6 +115,8 @@ namespace nadena.dev.modular_avatar.core.armature_lock
|
||||
_baseParentBones = new Transform[mergeToBase.Count];
|
||||
_mergeParentBones = new Transform[mergeToBase.Count];
|
||||
|
||||
try
|
||||
{
|
||||
for (int i = 0; i < mergeToBase.Count; i++)
|
||||
{
|
||||
var (mergeBone, baseBone) = mergeToBase[i];
|
||||
@ -126,6 +128,12 @@ namespace nadena.dev.modular_avatar.core.armature_lock
|
||||
throw new Exception("Can't handle root objects");
|
||||
}
|
||||
|
||||
if (SmallScale(mergeParent.localScale) || SmallScale(mergeBone.localScale) ||
|
||||
SmallScale(baseBone.localScale))
|
||||
{
|
||||
throw new Exception("Can't handle near-zero scale bones");
|
||||
}
|
||||
|
||||
_baseBones[i] = baseBone;
|
||||
_mergeBones[i] = mergeBone;
|
||||
_baseParentBones[i] = baseParent;
|
||||
@ -161,6 +169,18 @@ namespace nadena.dev.modular_avatar.core.armature_lock
|
||||
_mat_r = mat_l
|
||||
};
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_boneStaticData.Dispose();
|
||||
_mergeSavedState.Dispose();
|
||||
_baseState.Dispose();
|
||||
_mergeState.Dispose();
|
||||
_fault.Dispose();
|
||||
_wroteAny.Dispose();
|
||||
|
||||
throw e;
|
||||
}
|
||||
|
||||
_baseBonesAccessor = new TransformAccessArray(_baseBones);
|
||||
_mergeBonesAccessor = new TransformAccessArray(_mergeBones);
|
||||
@ -170,6 +190,13 @@ namespace nadena.dev.modular_avatar.core.armature_lock
|
||||
#endif
|
||||
}
|
||||
|
||||
private bool SmallScale(Vector3 scale)
|
||||
{
|
||||
var epsilon = 0.000001f;
|
||||
|
||||
return (scale.x < epsilon || scale.y < epsilon || scale.z < epsilon);
|
||||
}
|
||||
|
||||
private bool DoCompute(out JobHandle handle)
|
||||
{
|
||||
handle = default;
|
||||
|
Loading…
Reference in New Issue
Block a user