Skip to content

Commit

Permalink
Vrm10FastSpringboneRuntimeStandalone
Browse files Browse the repository at this point in the history
  • Loading branch information
ousttrue committed Sep 20, 2024
1 parent e53ff87 commit c2e203b
Show file tree
Hide file tree
Showing 4 changed files with 434 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ namespace UniVRM10
/// <summary>
/// FastSpringbone(job) で動作します。
/// FastSpringBoneService(Singleton)を経由せずに直接実行します。
///
/// シーンに2体以上の vrm-1.0 モデルがある場合は FastSpringBoneService でバッチングする方が効率的です。
/// </summary>
public class Vrm10FastSpringboneRuntimeStandalone : IVrm10SpringBoneRuntime
{
Expand Down Expand Up @@ -56,6 +58,8 @@ public void Dispose()
{
m_bufferCombiner.Unregister(m_fastSpringBoneBuffer);
m_fastSpringBoneBuffer.Dispose();

m_fastSpringBoneScheduler.Dispose();
m_bufferCombiner.Dispose();
}

Expand Down
33 changes: 22 additions & 11 deletions Assets/VRM10/Runtime/IO/Vrm10.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ public static async Task<Vrm10Instance> LoadPathAsync(
IMaterialDescriptorGenerator materialGenerator = null,
VrmMetaInformationCallback vrmMetaInformationCallback = null,
CancellationToken ct = default,
ImporterContextSettings importerContextSettings = null)
ImporterContextSettings importerContextSettings = null,
IVrm10SpringBoneRuntime springboneRuntime = null)
{
awaitCaller ??= Application.isPlaying
? new RuntimeOnlyAwaitCaller()
Expand All @@ -67,7 +68,8 @@ public static async Task<Vrm10Instance> LoadPathAsync(
materialGenerator,
vrmMetaInformationCallback,
ct,
importerContextSettings);
importerContextSettings,
springboneRuntime);
}

/// <summary>
Expand Down Expand Up @@ -174,7 +176,8 @@ private static async Task<Vrm10Instance> LoadAsync(
IMaterialDescriptorGenerator materialGenerator,
VrmMetaInformationCallback vrmMetaInformationCallback,
CancellationToken ct,
ImporterContextSettings importerContextSettings = null)
ImporterContextSettings importerContextSettings = null,
IVrm10SpringBoneRuntime springboneRuntime = null)
{
ct.ThrowIfCancellationRequested();
if (awaitCaller == null)
Expand All @@ -192,7 +195,8 @@ private static async Task<Vrm10Instance> LoadAsync(
materialGenerator,
vrmMetaInformationCallback,
ct,
importerContextSettings);
importerContextSettings,
springboneRuntime);
if (instance != null)
{
if (ct.IsCancellationRequested)
Expand All @@ -218,7 +222,8 @@ private static async Task<Vrm10Instance> LoadAsync(
textureDeserializer,
materialGenerator,
vrmMetaInformationCallback,
ct);
ct,
springboneRuntime);
if (migratedInstance != null)
{
if (ct.IsCancellationRequested)
Expand All @@ -242,7 +247,8 @@ private static async Task<Vrm10Instance> TryLoadingAsVrm10Async(
IMaterialDescriptorGenerator materialGenerator,
VrmMetaInformationCallback vrmMetaInformationCallback,
CancellationToken ct,
ImporterContextSettings importerContextSettings = null)
ImporterContextSettings importerContextSettings = null,
IVrm10SpringBoneRuntime springboneRuntime = null)
{
ct.ThrowIfCancellationRequested();
if (awaitCaller == null)
Expand All @@ -269,7 +275,8 @@ private static async Task<Vrm10Instance> TryLoadingAsVrm10Async(
materialGenerator,
vrmMetaInformationCallback,
ct,
importerContextSettings);
importerContextSettings,
springboneRuntime);
}

private static async Task<Vrm10Instance> TryMigratingFromVrm0XAsync(
Expand All @@ -280,7 +287,8 @@ private static async Task<Vrm10Instance> TryMigratingFromVrm0XAsync(
ITextureDeserializer textureDeserializer,
IMaterialDescriptorGenerator materialGenerator,
VrmMetaInformationCallback vrmMetaInformationCallback,
CancellationToken ct)
CancellationToken ct,
IVrm10SpringBoneRuntime springboneRuntime)
{
ct.ThrowIfCancellationRequested();
if (awaitCaller == null)
Expand Down Expand Up @@ -308,7 +316,8 @@ private static async Task<Vrm10Instance> TryMigratingFromVrm0XAsync(
textureDeserializer,
materialGenerator,
vrmMetaInformationCallback,
ct);
ct,
springboneRuntime: springboneRuntime);
if (migratedVrm10Instance == null)
{
throw new Exception(migrationData?.Message ?? "Failed to load migrated.");
Expand All @@ -327,7 +336,8 @@ private static async Task<Vrm10Instance> LoadVrm10DataAsync(
IMaterialDescriptorGenerator materialGenerator,
VrmMetaInformationCallback vrmMetaInformationCallback,
CancellationToken ct,
ImporterContextSettings importerContextSettings = null)
ImporterContextSettings importerContextSettings = null,
IVrm10SpringBoneRuntime springboneRuntime = null)
{
ct.ThrowIfCancellationRequested();
if (awaitCaller == null)
Expand All @@ -345,7 +355,8 @@ private static async Task<Vrm10Instance> LoadVrm10DataAsync(
textureDeserializer: textureDeserializer,
materialGenerator: materialGenerator,
useControlRig: controlRigGenerationOption != ControlRigGenerationOption.None,
settings: importerContextSettings))
settings: importerContextSettings,
springboneRuntime: springboneRuntime))
{
// 1. Load meta information if callback was available.
if (vrmMetaInformationCallback != null)
Expand Down
Loading

0 comments on commit c2e203b

Please sign in to comment.