diff --git a/Assets/VRM10_Samples/ClothSample/RotateParticle/Runtime/Jobs/Particle.cs b/Assets/VRM10_Samples/ClothSample/RotateParticle/Runtime/Jobs/Particle.cs
index 38b8d05a3..e64eead76 100644
--- a/Assets/VRM10_Samples/ClothSample/RotateParticle/Runtime/Jobs/Particle.cs
+++ b/Assets/VRM10_Samples/ClothSample/RotateParticle/Runtime/Jobs/Particle.cs
@@ -83,9 +83,6 @@ namespace RotateParticle.Jobs
+ external
;
- // 位置を長さで拘束
- newPosition = parentPosition + (newPosition - parentPosition).normalized * particle.InitLocalPosition.magnitude;
-
NextPositions[index] = newPosition;
}
else
@@ -98,16 +95,39 @@ namespace RotateParticle.Jobs
}
}
+ ///
+ /// 親の位置に依存。再帰
+ ///
+ public struct ParentLengthConstraintJob : IJobParallelFor
+ {
+ [ReadOnly] public NativeArray Warps;
+ [ReadOnly] public NativeArray Info;
+ [NativeDisableParallelForRestriction] public NativeArray NextPositions;
+ public void Execute(int index)
+ {
+ var warp = Warps[index];
+ for (int i = warp.StartIndex; i < warp.EndIndex - 1; ++i)
+ {
+ // 位置を長さで拘束
+ NextPositions[i + 1] = NextPositions[i] +
+ (NextPositions[i + 1] - NextPositions[i]).normalized
+ * Info[i + 1].InitLocalPosition.magnitude;
+ }
+ }
+ }
+
+ ///
+ /// 親の回転に依存。再帰
+ ///
public struct ApplyRotationJob : IJobParallelFor
{
[ReadOnly] public NativeArray Warps;
[ReadOnly] public NativeArray Info;
[ReadOnly] public NativeArray CurrentTransforms;
- [ReadOnly] public NativeArray NextPositions;
+ [NativeDisableParallelForRestriction] public NativeArray NextPositions;
[NativeDisableParallelForRestriction] public NativeArray NextRotations;
public void Execute(int index)
{
- // warp 一本を親から子に再帰的に実行して回転を確定させる
var warp = Warps[index];
for (int i = warp.StartIndex; i < warp.EndIndex - 1; ++i)
{
diff --git a/Assets/VRM10_Samples/ClothSample/RotateParticle/Runtime/Jobs/RotateParticleJobSystem.cs b/Assets/VRM10_Samples/ClothSample/RotateParticle/Runtime/Jobs/RotateParticleJobSystem.cs
index ef5fd41b7..dca1527fa 100644
--- a/Assets/VRM10_Samples/ClothSample/RotateParticle/Runtime/Jobs/RotateParticleJobSystem.cs
+++ b/Assets/VRM10_Samples/ClothSample/RotateParticle/Runtime/Jobs/RotateParticleJobSystem.cs
@@ -219,10 +219,18 @@ namespace RotateParticle.Jobs
NextRotations = _nextRotations,
}.Schedule(_info.Length, 128, handle);
+ // 親子の長さで拘束
+ handle = new ParentLengthConstraintJob
+ {
+ Warps = _warps,
+ Info = _info,
+ NextPositions = _nextPositions,
+ }.Schedule(_warps.Length, 1, handle);
+
// collision
handle = new CollisionJob
{
- Colliders = _colliders,
+ Colliders = _colliders,
CurrentColliders = _currentColliders,
Info = _info,
NextPositions = _nextPositions,