Пример #1
0
        public static void testCirclevsCircle(CircleParticle ca, CircleParticle cb)
        {
            double depthX = testIntervals(ca.getIntervalX(), cb.getIntervalX());

            if (depthX == 0)
            {
                return;

                return;
            }
            double depthY = testIntervals(ca.getIntervalY(), cb.getIntervalY());

            if (depthY == 0)
            {
                return;

                return;
            }
            Vector collisionNormal = ca.curr.minus(cb.curr);
            double mag             = collisionNormal.magnitude();
            double collisionDepth  = (ca.getRadius() + cb.getRadius()) - mag;

            if (collisionDepth > 0)
            {
                collisionNormal.divEquals(mag);
                CollisionResolver.resolveParticleParticle(ca, cb, collisionNormal, collisionDepth);

                //*************collision
                ModEnumConst.nofcollosions = ModEnumConst.nofcollosions + 1;
                //*************


                //If cb.myColor = ca.myColor Then
                //    'My.Computer.Audio.Play(System.AppDomain.CurrentDomain.BaseDirectory & "\score.wav")
                //    Totalscore = Totalscore + 1

                //End If
            }
        }
Пример #2
0
        private static void testOBBvsCircle(RectangleParticle ra, CircleParticle ca)
        {
            Vector    collisionNormal = new Vector(0, 0);
            double    collisionDepth  = ModEnumConst.POSITIVE_INFINITY;
            ArrayList depths          = new ArrayList(2);
            int       i = 0;

            //While i < 2
            for (i = 0; i <= 1; i++)
            {
                Vector boxAxis = (Vector)ra.getAxes()[i];
                double depth   = testIntervals(ra.getProjection(boxAxis), ca.getProjection(boxAxis));
                if (depth == 0)
                {
                    return;

                    return;
                }
                if (Math.Abs(depth) < Math.Abs(collisionDepth))
                {
                    collisionNormal = boxAxis;
                    collisionDepth  = depth;
                }
                depths.Insert(i, depth);
                // System.Math.Max(System.Threading.Interlocked.Increment(i), i - 1)
            }
            //End While
            double r = ca.getRadius();


            //SByte objSByte0 = (SByte)depths[0];
            int objSByte0 = Convert.ToInt32(depths[0]);



            //SByte objSByte1 = (SByte)depths[1];
            int objSByte1 = Convert.ToInt32(depths[1]);


            if (Math.Abs(objSByte0) < r && Math.Abs(objSByte1) < r)
            {
                Vector vertex = closestVertexOnOBB(ca.curr, ra);
                collisionNormal = vertex.minus(ca.curr);
                double mag = collisionNormal.magnitude();
                collisionDepth = r - mag;
                if (collisionDepth > 0)
                {
                    collisionNormal.divEquals(mag);


                    //*************collision
                    ModEnumConst.nofcollosions = ModEnumConst.nofcollosions + 1;
                    //*************


                    //If ra.myColor = ca.myColor Then

                    //    Totalscore = Totalscore + 1
                    //    'APEngine1.removeParticle(ca)
                    //    'APEngine1.removeParticle(ra)

                    //End If
                }
                else
                {
                    return;

                    return;
                }
            }
            CollisionResolver.resolveParticleParticle(ra, ca, collisionNormal, collisionDepth);
        }