Merge pull request #2470 from ousttrue/fix/springbone0x_center

[0.x][springbone][center] fix center coordinate conversion
This commit is contained in:
ousttrue 2024-10-23 00:12:23 +09:00 committed by GitHub
commit 675bb7be41
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 6 deletions

View File

@ -34,11 +34,9 @@ namespace VRM.SpringBone
/// <summary>
/// Verlet積分で次の位置を計算する
/// </summary>
public Vector3 VerletIntegration(float deltaTime, Transform center, Quaternion parentRotation,
SpringBoneSettings settings, SpringBoneJointState _state, float scalingFactor, Vector3 externalForce)
public Vector3 VerletIntegration(float deltaTime, Quaternion parentRotation,
SpringBoneSettings settings, SpringBoneJointState state, float scalingFactor, Vector3 externalForce)
{
var state = _state.ToWorld(center);
var nextTail = state.CurrentTail
+ (state.CurrentTail - state.PrevTail) * (1.0f - settings.DragForce) // 前フレームの移動を継続する(減衰もあるよ)
+ parentRotation * LocalRotation * BoneAxis * settings.StiffnessForce * deltaTime * scalingFactor // 親の回転による子ボーンの移動目標

View File

@ -157,7 +157,8 @@ namespace VRM.SpringBone
for (int i = 0; i < m_joints.Count; ++i)
{
var (transform, init, state) = m_joints[i];
var (transform, init, _state) = m_joints[i];
var state = _state.ToWorld(scene.Center);
// Spring処理
var parentRotation = transform.parent != null ? transform.parent.rotation : Quaternion.identity;
@ -166,7 +167,7 @@ namespace VRM.SpringBone
// false の場合
// 拡大すると移動速度はだいたい同じ => SpringBone の角速度が遅くなる
var scalingFactor = settings.UseRuntimeScalingSupport ? transform.UniformedLossyScale() : 1.0f;
var nextTail = init.VerletIntegration(deltaTime, scene.Center, parentRotation, settings, state,
var nextTail = init.VerletIntegration(deltaTime, parentRotation, settings, state,
scalingFactor, scene.ExternalForce);
// 長さをboneLengthに強制