diff --git a/Assets/VRM10_Samples/ClothSample/RotateParticle/Runtime/Jobs/Collision.cs b/Assets/VRM10_Samples/ClothSample/RotateParticle/Runtime/Jobs/Collision.cs index 111890ffa..b2e7893c2 100644 --- a/Assets/VRM10_Samples/ClothSample/RotateParticle/Runtime/Jobs/Collision.cs +++ b/Assets/VRM10_Samples/ClothSample/RotateParticle/Runtime/Jobs/Collision.cs @@ -21,16 +21,29 @@ namespace RotateParticle.Jobs { [ReadOnly] public NativeArray Colliders; [ReadOnly] public NativeArray CurrentColliders; - [WriteOnly] public NativeArray NextPositions; + [ReadOnly] public NativeArray Info; + [NativeDisableParallelForRestriction] public NativeArray NextPositions; public void Execute(int index) { + var info = Info[index]; + var pos = NextPositions[index]; for (int i = 0; i < Colliders.Length; ++i) { var c = Colliders[i]; switch (c.colliderType) { case BlittableColliderType.Sphere: + { + var col_pos = CurrentColliders[i].MultiplyPoint(c.offset); + var d = Vector3.Distance(pos, col_pos); + var min_d = info.Settings.radius + c.radius; + if (d < min_d) + { + Vector3 normal = (pos - col_pos).normalized; + pos += normal * (min_d - d); + } + } break; default: @@ -38,15 +51,7 @@ namespace RotateParticle.Jobs break; } } - // var d = Vector3.Distance(from, to); - // if (d > (ra + rb)) - // { - // resolved = default; - // return false; - // } - // Vector3 normal = (to - from).normalized; - // resolved = new(from, from + normal * (d - rb)); - // return true; + NextPositions[index] = pos; } } } \ No newline at end of file diff --git a/Assets/VRM10_Samples/ClothSample/RotateParticle/Runtime/Jobs/RotateParticleJobSystem.cs b/Assets/VRM10_Samples/ClothSample/RotateParticle/Runtime/Jobs/RotateParticleJobSystem.cs index ecaadbeda..ef5fd41b7 100644 --- a/Assets/VRM10_Samples/ClothSample/RotateParticle/Runtime/Jobs/RotateParticleJobSystem.cs +++ b/Assets/VRM10_Samples/ClothSample/RotateParticle/Runtime/Jobs/RotateParticleJobSystem.cs @@ -222,8 +222,9 @@ namespace RotateParticle.Jobs // collision handle = new CollisionJob { - Colliders = _colliders, + Colliders = _colliders, CurrentColliders = _currentColliders, + Info = _info, NextPositions = _nextPositions, }.Schedule(_info.Length, 128, handle); diff --git a/Assets/VRM10_Samples/ClothSample/RotateParticle/Runtime/RotateParticleSystem.cs b/Assets/VRM10_Samples/ClothSample/RotateParticle/Runtime/RotateParticleSystem.cs index 2b1bcdc6b..97ff35657 100644 --- a/Assets/VRM10_Samples/ClothSample/RotateParticle/Runtime/RotateParticleSystem.cs +++ b/Assets/VRM10_Samples/ClothSample/RotateParticle/Runtime/RotateParticleSystem.cs @@ -173,6 +173,8 @@ namespace RotateParticle { c.InitializeColliderSide(_newPos, _colliderGroups); } + + await awaitCaller.NextFrame(); } ///