public static void FillVertices(/* final */ RectangularShape pRectangularShape, /* final */ float[] pVertices) { /* final */ float left = pRectangularShape.GetX(); /* final */ float top = pRectangularShape.GetY(); /* final */ float right = pRectangularShape.GetWidth() + left; /* final */ float bottom = pRectangularShape.GetHeight() + top; pVertices[0 + Constants.VERTEX_INDEX_X] = left; pVertices[0 + Constants.VERTEX_INDEX_Y] = top; pVertices[2 + Constants.VERTEX_INDEX_X] = right; pVertices[2 + Constants.VERTEX_INDEX_Y] = top; pVertices[4 + Constants.VERTEX_INDEX_X] = right; pVertices[4 + Constants.VERTEX_INDEX_Y] = bottom; pVertices[6 + Constants.VERTEX_INDEX_X] = left; pVertices[6 + Constants.VERTEX_INDEX_Y] = bottom; MathUtil.RotateAndScaleAroundCenter(pVertices, pRectangularShape.GetRotation(), left + pRectangularShape.GetRotationCenterX(), top + pRectangularShape.GetRotationCenterY(), pRectangularShape.GetScaleX(), pRectangularShape.GetScaleY(), left + pRectangularShape.GetScaleCenterX(), top + pRectangularShape.GetScaleCenterY()); }
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); } }
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)); } }