From c2cab1c68c2688f577b19491771c2fef49e0df2d Mon Sep 17 00:00:00 2001 From: ousttrue Date: Fri, 29 Nov 2024 22:23:54 +0900 Subject: [PATCH] ArrayRange --- .../ClothSample/ClothWarp/Runtime/ClothWarpRuntime.cs | 4 +++- .../ClothWarp/Runtime/Jobs/ClothWarpJobRuntime.cs | 9 ++++++--- .../ClothSample/ClothWarp/Runtime/Jobs/Constraint.cs | 4 ++-- .../ClothSample/ClothWarp/Runtime/Jobs/Warp.cs | 10 ++++++++-- 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/Assets/VRM10_Samples/ClothSample/ClothWarp/Runtime/ClothWarpRuntime.cs b/Assets/VRM10_Samples/ClothSample/ClothWarp/Runtime/ClothWarpRuntime.cs index ed13969c8..edcffc23a 100644 --- a/Assets/VRM10_Samples/ClothSample/ClothWarp/Runtime/ClothWarpRuntime.cs +++ b/Assets/VRM10_Samples/ClothSample/ClothWarp/Runtime/ClothWarpRuntime.cs @@ -61,7 +61,7 @@ namespace UniVRM10.ClothWarp return Color.gray; } - public async Task InitializeAsync(Vrm10Instance vrm, IAwaitCaller awaitCaller) + public Task InitializeAsync(Vrm10Instance vrm, IAwaitCaller awaitCaller) { _building = true; _vrm = vrm; @@ -115,6 +115,8 @@ namespace UniVRM10.ClothWarp _initialized = true; _building = false; + + return Task.CompletedTask; } /// diff --git a/Assets/VRM10_Samples/ClothSample/ClothWarp/Runtime/Jobs/ClothWarpJobRuntime.cs b/Assets/VRM10_Samples/ClothSample/ClothWarp/Runtime/Jobs/ClothWarpJobRuntime.cs index 237d880be..33c2d17f5 100644 --- a/Assets/VRM10_Samples/ClothSample/ClothWarp/Runtime/Jobs/ClothWarpJobRuntime.cs +++ b/Assets/VRM10_Samples/ClothSample/ClothWarp/Runtime/Jobs/ClothWarpJobRuntime.cs @@ -196,8 +196,11 @@ namespace UniVRM10.ClothWarp.Jobs warps.Add(new WarpInfo { - StartIndex = start, - EndIndex = _transforms.Count, + PrticleRange = new ArrayRange + { + Start = start, + End = _transforms.Count, + }, }); await awaitCaller.NextFrame(); @@ -376,7 +379,7 @@ namespace UniVRM10.ClothWarp.Jobs { foreach (var warp in _warps) { - for (int i = warp.StartIndex; i < warp.EndIndex; ++i) + for (int i = warp.PrticleRange.Start; i < warp.PrticleRange.End; ++i) { var p = _info[i]; var t = _transforms[i]; diff --git a/Assets/VRM10_Samples/ClothSample/ClothWarp/Runtime/Jobs/Constraint.cs b/Assets/VRM10_Samples/ClothSample/ClothWarp/Runtime/Jobs/Constraint.cs index f6704d852..187e15e1d 100644 --- a/Assets/VRM10_Samples/ClothSample/ClothWarp/Runtime/Jobs/Constraint.cs +++ b/Assets/VRM10_Samples/ClothSample/ClothWarp/Runtime/Jobs/Constraint.cs @@ -16,7 +16,7 @@ namespace UniVRM10.ClothWarp.Jobs public void Execute(int warpIndex) { var warp = Warps[warpIndex]; - for (int particleIndex = warp.StartIndex; particleIndex < warp.EndIndex - 1; ++particleIndex) + for (int particleIndex = warp.PrticleRange.Start; particleIndex < warp.PrticleRange.End - 1; ++particleIndex) { // 位置を長さで拘束 NextPositions[particleIndex + 1] = NextPositions[particleIndex] + @@ -60,7 +60,7 @@ namespace UniVRM10.ClothWarp.Jobs public void Execute(int warpIndex) { var warp = Warps[warpIndex]; - for (int particleIndex = warp.StartIndex; particleIndex < warp.EndIndex - 1; ++particleIndex) + for (int particleIndex = warp.PrticleRange.Start; particleIndex < warp.PrticleRange.End - 1; ++particleIndex) { //回転を適用 var p = Info[particleIndex]; diff --git a/Assets/VRM10_Samples/ClothSample/ClothWarp/Runtime/Jobs/Warp.cs b/Assets/VRM10_Samples/ClothSample/ClothWarp/Runtime/Jobs/Warp.cs index 53a2e5128..ec6ebbf50 100644 --- a/Assets/VRM10_Samples/ClothSample/ClothWarp/Runtime/Jobs/Warp.cs +++ b/Assets/VRM10_Samples/ClothSample/ClothWarp/Runtime/Jobs/Warp.cs @@ -1,8 +1,14 @@ namespace UniVRM10.ClothWarp.Jobs { + public struct ArrayRange + { + public int Start; + public int End; + } + public struct WarpInfo { - public int StartIndex; - public int EndIndex; + public ArrayRange PrticleRange; + public ArrayRange ColliderGroupRange; } }