Пример #1
0
        public void Execute(int index)
        {
            // Cache
            int    colliderCount = copyColliders.Length;
            float3 position      = particlesPosition[index].Value;
            float3 velocity      = particlesVelocity[index].Value;

            // Process
            for (int i = 0; i < colliderCount; i++)
            {
                float3 penetrationNormal;
                float3 penetrationPosition;
                float  penetrationLength;
                if (Intersect(copyColliders[i], position, settings.radius, out penetrationNormal, out penetrationPosition, out penetrationLength))
                {
                    velocity = DampVelocity(copyColliders[i], velocity, penetrationNormal, 1.0f - settings.drag);
                    position = penetrationPosition - penetrationNormal * math.abs(penetrationLength);
                }
            }

            // Apply
            particlesVelocity[index] = new SMBVelocity {
                Value = velocity
            };
            particlesPosition[index] = new Position {
                Value = position
            };
        }
Пример #2
0
        public void Execute(int index)
        {
            // Cache
            float3 velocity = particlesVelocity[index].Value;
            float3 position = particlesPosition[index].Value;

            // Process
            velocity += DT * particlesForces[index] / particlesDensity[index];
            position += DT * velocity;

            // Apply
            particlesVelocity[index] = new SMBVelocity {
                Value = velocity
            };
            particlesPosition[index] = new Position {
                Value = position
            };
        }