hyades.physics.SpringBody.ApplyInternalForces C# (CSharp) Method

ApplyInternalForces() public method

public ApplyInternalForces ( double elapsed ) : void
elapsed double
return void
        public override void ApplyInternalForces(double elapsed)
        {
            // internal spring forces.
            Vector2 force = new Vector2();
            for (int i = 0; i < spring_list.Count; i++)
            {
                Spring s = spring_list[i];
                Spring.SpringForce(ref s, out force);

                s.pointmass_a.force.X += force.X;
                s.pointmass_a.force.Y += force.Y;

                s.pointmass_b.force.X -= force.X;
                s.pointmass_b.force.Y -= force.Y;
            }

            // shape matching forces.
            if (is_constrained)
            {
                for (int i = 0; i < count; i++)
                {
                    if (shape_k > 0)
                    {

                        Spring.SpringForce(ref pointmass_list[i].position, ref pointmass_list[i].velocity, ref curr_shape.points[i],
                                                        ref pointmass_list[i].velocity, 0.0f, shape_k, shape_damping, out force);

                        pointmass_list[i].force.X += force.X;
                        pointmass_list[i].force.Y += force.Y;
                    }
                }
            }

            for (int i = 0; i < spring_pointmass_list.Count; i++)
            {
                this.spring_pointmass_list[i].velocity.X *= damping;
                this.spring_pointmass_list[i].velocity.Y *= damping;
                this.spring_pointmass_list[i].Update(elapsed);
            }
        }