Nez.Portable/Physics/Verlet/Composites/Composite.cs
/// <summary>
/// applies gravity to each Particle and does the verlet integration
/// </summary>
/// <param name="deltaTimeSquared">Delta time.</param>
/// <param name="gravity">Gravity.</param>
applies gravity to each Particle and does the verlet integration
applies gravity to each Particle and does the verlet integration
[MethodImpl(MethodImplOptions.AggressiveInlining)]
        public void updateParticles(float deltaTimeSquared, Vector2 gravity)
        {
            for (var j = 0; j < particles.length; j++)
            {
                var p = particles.buffer[j];
                if (p.isPinned)
                {
                    p.position = p.pinnedPosition;
                    continue;
                }
                p.applyForce(p.mass * gravity);
                var vel = (p.position - p.lastPosition) * friction;
                var nextPos = p.position + vel + 0.5f * p.acceleration * deltaTimeSquared;
                p.lastPosition = p.position;
                p.position = nextPos;
                p.acceleration.X = p.acceleration.Y = 0;
            }
        }
[ MethodImpl ( MethodImplOptions . AggressiveInlining ) ] public void updateParticles ( float deltaTimeSquared , Vector2 gravity ) { for ( var j = 0 ; j < particles . length ; j ++ ) { var p = particles . buffer [ j ] ; if ( p . isPinned ) { p . position = p . pinnedPosition ; continue ; } p . applyForce ( p . mass * gravity ) ; var vel = ( p . position - p . lastPosition ) * friction ; var nextPos = p . position + vel + 0.5f * p . acceleration * deltaTimeSquared ; p . lastPosition = p . position ; p . position = nextPos ; p . acceleration . X = p . acceleration . Y = 0 ; } }
applies gravity to each Particle and does the verlet integration
applies gravity to each Particle and does the verlet integration
// calculate velocity and dampen it with friction // calculate the next position using Verlet Integration // reset variables
deltaTimeSquared
float
None
gravity
Vector2
None