Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[0.x][springbone][center] fix center coordinate conversion #2470

Merged
merged 2 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions Assets/VRM/Runtime/SpringBone/Logic/SpringBoneJointInit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,9 @@ public Quaternion WorldRotationFromTailPosition(Transform m_transform, Vector3 n
/// <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 // 親の回転による子ボーンの移動目標
Expand Down
5 changes: 3 additions & 2 deletions Assets/VRM/Runtime/SpringBone/Logic/SpringBoneSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@ SpringBoneSettings settings

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;
Expand All @@ -166,7 +167,7 @@ SpringBoneSettings settings
// 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に強制
Expand Down