mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-04-23 07:28:55 -05:00
parent
b2f342d7e1
commit
e3ffffbd6f
|
|
@ -45,34 +45,5 @@ namespace UniVRM10
|
|||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
public void Process(Transform center, float deltaTime, List<SpringBoneLogic.InternalCollider> colliders, VRM10SpringBoneJoint tail)
|
||||
{
|
||||
if (m_logic == null)
|
||||
{
|
||||
// 初期化
|
||||
if (tail != null)
|
||||
{
|
||||
var localPosition = tail.transform.localPosition;
|
||||
var scale = tail.transform.lossyScale;
|
||||
m_logic = new SpringBoneLogic(center, transform,
|
||||
new Vector3(
|
||||
localPosition.x * scale.x,
|
||||
localPosition.y * scale.y,
|
||||
localPosition.z * scale.z
|
||||
));
|
||||
}
|
||||
else
|
||||
{
|
||||
// 親からまっすぐの位置に tail を作成
|
||||
var delta = transform.position - transform.parent.position;
|
||||
var childPosition = transform.position + delta.normalized * 0.07f;
|
||||
m_logic = new SpringBoneLogic(center, transform, transform.worldToLocalMatrix.MultiplyPoint(childPosition));
|
||||
}
|
||||
}
|
||||
|
||||
m_logic.Update(center, m_stiffnessForce * deltaTime, m_dragForce, m_gravityDir * (m_gravityPower * deltaTime), colliders, m_jointRadius);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -89,15 +89,28 @@ namespace UniVRM10
|
|||
}
|
||||
}
|
||||
|
||||
if (m_logics == null)
|
||||
{
|
||||
// udpate joints
|
||||
VRM10SpringBoneJoint lastJoint = Joints.FirstOrDefault(x => x != null);
|
||||
foreach (var joint in Joints.Where(x => x != null).Skip(1))
|
||||
m_logics = Enumerable.Zip(Joints, Joints.Skip(1), (head, tail) =>
|
||||
{
|
||||
lastJoint.Process(center, Time.deltaTime, m_colliderList, joint);
|
||||
lastJoint = joint;
|
||||
}
|
||||
lastJoint.Process(center, Time.deltaTime, m_colliderList, null);
|
||||
var localPosition = tail.transform.localPosition;
|
||||
var scale = tail.transform.lossyScale;
|
||||
var logic = new SpringBoneLogic(center, head.transform,
|
||||
new Vector3(
|
||||
localPosition.x * scale.x,
|
||||
localPosition.y * scale.y,
|
||||
localPosition.z * scale.z
|
||||
));
|
||||
return (head, logic);
|
||||
}).ToList();
|
||||
}
|
||||
foreach (var (head, logic) in m_logics)
|
||||
{
|
||||
logic.Update(center,
|
||||
head.m_stiffnessForce * Time.deltaTime,
|
||||
head.m_dragForce,
|
||||
head.m_gravityDir * (head.m_gravityPower * Time.deltaTime),
|
||||
m_colliderList, head.m_jointRadius);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user