Skip to content

Commit

Permalink
VRMMetaEditor に仮置きしていた UseRuntimeScalingSupport を Vrm0XSpringBoneRunt…
Browse files Browse the repository at this point in the history
…imeController に移動
  • Loading branch information
ousttrue committed Sep 25, 2024
1 parent c6a5599 commit 512d235
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 24 deletions.
11 changes: 0 additions & 11 deletions Assets/VRM/Editor/Meta/VRMMetaEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,6 @@ public override void OnInspectorGUI()
{
m_Inspector.OnInspectorGUI();
}

GUILayout.Space(16);
var current = m_target.GetComponentsInChildren<VRMSpringBone>().Any(x => x.UseRuntimeScalingSupport);
var newValue = GUILayout.Toggle(current, "[experimental] SpringBone scaling params");
if (current != newValue)
{
foreach (var sb in m_target.GetComponentsInChildren<VRMSpringBone>())
{
sb.UseRuntimeScalingSupport = newValue;
}
}
}
}
}
8 changes: 7 additions & 1 deletion Assets/VRM/Runtime/SpringBone/IVrm0XSpringBoneRuntime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,18 @@

namespace VRM
{
public struct SpringRuntimeFrameInfo
{
public float DeltaTime;
public bool UseRuntimeScalingSupport;
}

public interface IVrm0XSpringBoneRuntime
{
Task InitializeAsync(GameObject vrm, IAwaitCaller awaitCaller);

void Reset();

void Process(float deltaTime);
void Process(SpringRuntimeFrameInfo frame);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void Reset()
// TODO
}

public void Process(float deltaTime)
public void Process(SpringRuntimeFrameInfo frame)
{
// FastSpringBoneService(Singleton) が自力で Update するので何もしない
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,15 @@ public void Reset()
}
}

public void Process(float deltaTime)
public void Process(SpringRuntimeFrameInfo frame)
{
#if VRM0X_SPRING_UPDATE_SELF
// 各 VrmSpringBone が自力で Update するので何もしない
#else
foreach (VRMSpringBone sb in m_springs)
{
sb.ManualUpdate(deltaTime);
sb.UseRuntimeScalingSupport = frame.UseRuntimeScalingSupport;
sb.ManualUpdate(frame.DeltaTime);
}
#endif
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ namespace VRM
[DefaultExecutionOrder(11000)]
public class Vrm0XSpringBoneRuntimeController : MonoBehaviour
{
public bool UseRuntimeScalingSupport = false;

IVrm0XSpringBoneRuntime m_springboneRuntime;
public void SetSpringRuntime(IVrm0XSpringBoneRuntime runtime)
{
Expand Down Expand Up @@ -55,28 +57,25 @@ void LateUpdate()
{
if (UpdateType == SpringBoneUpdateType.LateUpdate)
{
Runtime.Process(Time.deltaTime);
ManualUpdate(Time.deltaTime);
}
}

void FixedUpdate()
{
if (UpdateType == SpringBoneUpdateType.FixedUpdate)
{
Runtime.Process(Time.fixedDeltaTime);
ManualUpdate(Time.fixedDeltaTime);
}
}

public void ManualUpdate(float deltaTime)
{
if (UpdateType == SpringBoneUpdateType.Manual)
{
Runtime.Process(deltaTime);
}
else
Runtime.Process(new SpringRuntimeFrameInfo
{
throw new System.ArgumentException("require SpringBoneUpdateType.Manual");
}
DeltaTime = deltaTime,
UseRuntimeScalingSupport = UseRuntimeScalingSupport,
});
}
}
}

0 comments on commit 512d235

Please sign in to comment.