Inheritance: BaseCollisionChecker
Example #1
0
 public static bool CheckCollision(/* final */ int pVerticesALength, /* final */ int pVerticesBLength, /* final */ float[] pVerticesA, /* final */ float[] pVerticesB)
 {
     /* Check all the lines of A ... */
     for (int a = pVerticesALength - 4; a >= 0; a -= 2)
     {
         /* ... against all lines in B. */
         if (CheckCollisionSub(a, a + 2, pVerticesA, pVerticesB, pVerticesBLength))
         {
             return(true);
         }
     }
     /* Also check the 'around the corner of the array' line of A against all lines in B. */
     if (CheckCollisionSub(pVerticesALength - 2, 0, pVerticesA, pVerticesB, pVerticesBLength))
     {
         return(true);
     }
     else
     {
         /* At last check if one polygon 'contains' the other one by checking
          * if one vertex of the one vertices is contained by all of the other vertices. */
         if (ShapeCollisionChecker.CheckContains(pVerticesA, pVerticesALength, pVerticesB[Constants.VERTEX_INDEX_X], pVerticesB[Constants.VERTEX_INDEX_Y]))
         {
             return(true);
         }
         else if (ShapeCollisionChecker.CheckContains(pVerticesB, pVerticesBLength, pVerticesA[Constants.VERTEX_INDEX_X], pVerticesA[Constants.VERTEX_INDEX_Y]))
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }
Example #2
0
        public static bool CheckCollision(/* final */ RectangularShape pRectangularShapeA, /* final */ RectangularShape pRectangularShapeB)
        {
            if (pRectangularShapeA.GetRotation() == 0 && pRectangularShapeB.GetRotation() == 0 && pRectangularShapeA.IsScaled() == false && pRectangularShapeB.IsScaled() == false)
            {
                /* final */ float aLeft = pRectangularShapeA.GetX();
                /* final */ float aTop  = pRectangularShapeA.GetY();
                /* final */ float bLeft = pRectangularShapeB.GetX();
                /* final */ float bTop  = pRectangularShapeB.GetY();
                return(BaseCollisionChecker.CheckAxisAlignedRectangleCollision(aLeft, aTop, aLeft + pRectangularShapeA.GetWidth(), aTop + pRectangularShapeA.GetHeight(),
                                                                               bLeft, bTop, bLeft + pRectangularShapeB.GetWidth(), bTop + pRectangularShapeB.GetHeight()));
            }
            else
            {
                RectangularShapeCollisionChecker.FillVertices(pRectangularShapeA, VERTICES_COLLISION_TMP_A);
                RectangularShapeCollisionChecker.FillVertices(pRectangularShapeB, VERTICES_COLLISION_TMP_B);

                return(ShapeCollisionChecker.CheckCollision(2 * RECTANGULARSHAPE_VERTEX_COUNT, 2 * RECTANGULARSHAPE_VERTEX_COUNT, VERTICES_COLLISION_TMP_A, VERTICES_COLLISION_TMP_B));
            }
        }
Example #3
0
        // ===========================================================
        // Fields
        // ===========================================================

        // ===========================================================
        // Constructors
        // ===========================================================

        // ===========================================================
        // Getter & Setter
        // ===========================================================

        // ===========================================================
        // Methods for/from SuperClass/Interfaces
        // ===========================================================

        // ===========================================================
        // Methods
        // ===========================================================

        public static bool CheckContains(/* final */ RectangularShape pRectangularShape, /* final */ float pX, /* final */ float pY)
        {
            RectangularShapeCollisionChecker.FillVertices(pRectangularShape, VERTICES_CONTAINS_TMP);
            return(ShapeCollisionChecker.CheckContains(VERTICES_CONTAINS_TMP, 2 * RECTANGULARSHAPE_VERTEX_COUNT, pX, pY));
        }