示例#1
0
        private static void satisfyConstraints()
        {
            int n = 0;

            //While n < constraints.Count()
            //DirectCast(constraints.Item(n), AbstractConstraint).resolve()
            //System.Math.Max(System.Threading.Interlocked.Increment(n), n - 1)
            for (n = 0; n <= constraints.Count - 1; n++)
            {
                //CType(constraints[n], SpringConstraint).resolve();

                SpringConstraint objSpringConstrain = (SpringConstraint)constraints[n];

                objSpringConstrain.resolve();
            }

            //End While
        }
示例#2
0
        private static void checkCollisions()
        {
            for (int j = 0; j <= particles.Count - 1; j++)
            {
                AbstractParticle pa = (AbstractParticle)particles[j];
                //DirectCast(particles.Item(j), AbstractParticle)

                int i = 0;

                for (i = j + 1; i <= particles.Count - 1; i++)
                {
                    AbstractParticle pb = (AbstractParticle)particles[i];
                    //DirectCast(particles.Item(i), AbstractParticle)
                    if ((pa.getCollidable() & pb.getCollidable()))
                    {
                        CollisionDetector.test(pa, pb);
                    }
                }

                for (int n = 0; n <= constraints.Count - 1; n++)
                {
                    if (constraints[n] is AngularConstraint)
                    {
                        //Do nothing
                    }
                    else
                    {
                        SpringConstraint c = (SpringConstraint)constraints[n];
                        if ((pa.getCollidable() & c.getCollidable() & (!c.isConnectedTo(pa))))
                        {
                            CollisionDetector.test(pa, c.getCollisionRect());
                        }
                    }
                }
                pa.isColliding = false;
            }
        }