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 bool IsRectangularShapeVisible(/* final */ RectangularShape pRectangularShape) { // final float otherLeft = pRectangularShape.getX(); float otherLeft = pRectangularShape.X; // final float otherTop = pRectangularShape.getY(); float otherTop = pRectangularShape.Y; // final float otherRight = pRectangularShape.getWidthScaled() + otherLeft; float otherRight = pRectangularShape.WidthScaled + otherLeft; // final float otherBottom = pRectangularShape.getHeightScaled() + otherTop; float otherBottom = pRectangularShape.HeightScaled + otherTop; // TODO Should also use RectangularShapeCollisionChecker //return BaseCollisionChecker.checkAxisAlignedRectangleCollision(this.getMinX(), this.getMinY(), this.getMaxX(), this.getMaxY(), otherLeft, otherTop, otherRight, otherBottom); return(BaseCollisionChecker.CheckAxisAlignedRectangleCollision(this.MinX, this.MinY, this.MaxX, this.MaxY, otherLeft, otherTop, otherRight, otherBottom)); }
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)); } }
// =========================================================== // 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); }
// =========================================================== // 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)); }