mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-09-09 04:19:42 -05:00
use cached local rotation for spring bone calculation
This commit is contained in:
@@ -112,11 +112,21 @@ namespace UniVRM10
|
||||
gravityDir = joint.m_gravityDir,
|
||||
gravityPower = joint.m_gravityPower,
|
||||
stiffnessForce = joint.m_stiffnessForce
|
||||
}
|
||||
},
|
||||
DefaultLocalRotation = GetOrAddDefaultTransformState(joint.transform).rotation
|
||||
}).ToArray(),
|
||||
}).ToArray());
|
||||
}
|
||||
|
||||
private (Vector3 position, Quaternion rotation) GetOrAddDefaultTransformState(Transform tf)
|
||||
{
|
||||
if (m_defaultTransformStates.TryGetValue(tf, out var defaultTransformState))
|
||||
{
|
||||
return defaultTransformState;
|
||||
}
|
||||
return m_defaultTransformStates[tf] = (tf.position, tf.rotation);
|
||||
}
|
||||
|
||||
private static BlittableColliderType TranslateColliderType(VRM10SpringBoneColliderTypes colliderType)
|
||||
{
|
||||
switch (colliderType)
|
||||
|
||||
@@ -108,7 +108,7 @@ namespace UniVRM10.FastSpringBones.System
|
||||
parentTransformIndex = parent != null ? transformIndexDictionary[parent] : -1,
|
||||
currentTail = currentTail,
|
||||
prevTail = currentTail,
|
||||
localRotation = joint.Transform.localRotation,
|
||||
localRotation = joint.DefaultLocalRotation,
|
||||
boneAxis = localChildPosition.normalized,
|
||||
length = localChildPosition.magnitude
|
||||
});
|
||||
|
||||
@@ -9,5 +9,6 @@ namespace UniVRM10.FastSpringBones.System
|
||||
{
|
||||
public Transform Transform;
|
||||
public BlittableJoint Joint;
|
||||
public Quaternion DefaultLocalRotation;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user