public void Execute(int i)
            {
                float3 pos = predPositions[i].Value;

                if (pos.x < minBounds.x + radius)
                {
                    pos.x = minBounds.x + radius;
                }
                else if (pos.x > maxBounds.x - radius)
                {
                    pos.x = maxBounds.x - radius;
                }

                if (pos.y < minBounds.y + radius)
                {
                    pos.y = minBounds.y + radius;
                }
                else if (pos.y > maxBounds.y - radius)
                {
                    pos.y = maxBounds.y - radius;
                }

                if (pos.z < minBounds.z + radius)
                {
                    pos.z = minBounds.z + radius;
                }
                else if (pos.z > maxBounds.z - radius)
                {
                    pos.z = maxBounds.z - radius;
                }

                predPositions[i] = new PredictedPositions {
                    Value = pos
                };
            }
            public void Execute()
            {
                float radiusSum   = radius + radius;
                float radiusSumSq = radiusSum * radiusSum;

                for (int idA = 0; idA < length; idA++)
                {
                    float3 posA = positions[idA].Value;

                    for (int idB = idA + 1; idB < length; idB++)
                    {
                        float3 posB = positions[idB].Value;

                        float3 dir = posA - posB;

                        float distanceSq = math.lengthSquared(dir);

                        if (distanceSq > radiusSumSq || distanceSq <= float.Epsilon)
                        {
                            continue;
                        }

                        float  distance = math.sqrt(distanceSq);
                        float  massCorr = 0.5f;
                        float3 dP       = (distance - radiusSum) * (dir / distance) * stiffness * massCorr;

                        positions[idA] = new PredictedPositions {
                            Value = posA - dP
                        };
                        positions[idB] = new PredictedPositions {
                            Value = posB + dP
                        };
                    }
                }
            }
            public void Execute(int i)
            {
                float3 pos = predPositions[i].Value + deltaPositions[i].Delta;

                predPositions[i] = new PredictedPositions {
                    Value = pos
                };
            }
 public void Execute(int i)
 {
     if (deltaPositions[i].ConstraintsCount > 0)
     {
         float3 pos = predPositions[i].Value + (deltaPositions[i].Delta / deltaPositions[i].ConstraintsCount);
         predPositions[i] = new PredictedPositions {
             Value = pos
         };
     }
 }
            public void Execute(int i)
            {
                if (massesInv[i].Value != 0.0)
                {
                    float3 vel = velocities[i].Value + acceleration * dt;
                    vel *= damping;
                    float3 predPos = positions[i].Value + vel * dt;

                    velocities[i] = new Velocity {
                        Value = vel
                    };
                    predPositions[i] = new PredictedPositions {
                        Value = predPos
                    };
                }
            }
            public void Execute()
            {
                float radiusSum   = radius + radius;
                float radiusSumSq = radiusSum * radiusSum;

                for (int idA = 0; idA < length; idA++)
                {
                    float3 posA = positions[idA].Value;
                    int3   pos  = GridHash.Quantize(posA, cellRadius);
                    int    hash = GridHash.Hash(pos);

                    NativeMultiHashMapIterator <int> iterator;
                    int idB; // neighbourId
                    var found = hashMap.TryGetFirstValue(hash, out idB, out iterator);

                    while (found)
                    {
                        float3 posB = positions[idB].Value;

                        float3 dir = posA - posB;

                        float distanceSq = math.lengthSquared(dir);

                        if (idA == idB || distanceSq > radiusSumSq || distanceSq <= float.Epsilon)
                        {
                            found = hashMap.TryGetNextValue(out idB, ref iterator);
                            continue;
                        }

                        float  distance = math.sqrt(distanceSq);
                        float  massCorr = 0.5f;
                        float3 dP       = (distance - radiusSum) * (dir / distance) * stiffness * massCorr;

                        positions[idA] = new PredictedPositions {
                            Value = posA - dP
                        };
                        positions[idB] = new PredictedPositions {
                            Value = posB + dP
                        };

                        found = hashMap.TryGetNextValue(out idB, ref iterator);
                    }
                }
            }
            public void Execute()
            {
                for (int idA = 0; idA < length; idA++)
                {
                    float3 predPosA = predPositions[idA].Value;
                    float  massInvA = massesInv[idA].Value;

                    NativeArray <DistanceConstraintUni> cnstrsA = distanceConstraints[idA];
                    float3 delta      = new float3(0, 0, 0);
                    int    cnstrCount = 0;
                    for (int i = 0; i < 34; i++)
                    {
                        DistanceConstraintUni cnstr = cnstrsA[i];
                        if (cnstr.otherId == -1)
                        {
                            break;
                        }

                        float3 predPosB = predPositions[cnstr.otherId].Value;
                        float  massInvB = massesInv[cnstr.otherId].Value;

                        float3 normal = predPosA - predPosB;
                        float  length = math.length(normal.xyz);

                        float invMass = massInvA + massInvB;
                        if (invMass <= math.epsilon_normal || length <= math.epsilon_normal)
                        {
                            continue;
                        }

                        float3 dP = (1.0f / invMass) * (length - cnstr.restLength) * (normal / length) * stiffness;
                        delta -= dP * massInvA;
                        cnstrCount++;
                    }
                    predPositions[idA] = new PredictedPositions {
                        Value = predPosA + delta / cnstrCount
                    };
                }
            }