diff --git a/echo/Shape.hx b/echo/Shape.hx index 30b0875..1938a1f 100644 --- a/echo/Shape.hx +++ b/echo/Shape.hx @@ -206,11 +206,11 @@ class Shape #if cog implements cog.IComponent #end { public function collides(s:Shape):Null return null; - function collide_rect(r:Rect, flip:Bool = false):Null return null; + function collide_rect(r:Rect):Null return null; - function collide_circle(c:Circle, flip:Bool = false):Null return null; + function collide_circle(c:Circle):Null return null; - function collide_polygon(p:Polygon, flip:Bool = false):Null return null; + function collide_polygon(p:Polygon):Null return null; function toString() { var s = switch (type) { diff --git a/echo/shape/Circle.hx b/echo/shape/Circle.hx index a52237e..833e6e3 100644 --- a/echo/shape/Circle.hx +++ b/echo/shape/Circle.hx @@ -87,16 +87,13 @@ class Circle extends Shape implements Poolable { return false; } - // collision calculated as s against this. So flip result - override inline function collides(s:Shape):Null return s.collide_circle(this, true); + override inline function collides(s:Shape):Null return s.collide_circle(this); - // collision calculated as r against this. So invert flip value - override inline function collide_rect(r:Rect, flip:Bool = false):Null return r.rect_and_circle(this, !flip); + override inline function collide_rect(r:Rect):Null return r.rect_and_circle(this, true); - // collision calculated as c against this. So invert flip value - override inline function collide_circle(c:Circle, flip:Bool = false):Null return c.circle_and_circle(this, !flip); + override inline function collide_circle(c:Circle):Null return c.circle_and_circle(this); - override inline function collide_polygon(p:Polygon, flip:Bool = false):Null return this.circle_and_polygon(p, flip); + override inline function collide_polygon(p:Polygon):Null return this.circle_and_polygon(p, true); // getters inline function get_radius():Float return local_radius * scale_x; diff --git a/echo/shape/Polygon.hx b/echo/shape/Polygon.hx index 285653b..add301f 100644 --- a/echo/shape/Polygon.hx +++ b/echo/shape/Polygon.hx @@ -5,8 +5,8 @@ import echo.shape.*; import echo.util.AABB; import echo.util.Poolable; -using echo.math.Vector2; using echo.util.SAT; +using echo.math.Vector2; class Polygon extends Shape implements Poolable { /** @@ -197,16 +197,13 @@ class Polygon extends Shape implements Poolable { return false; } - // collision calculated as s against this. So flip result - override inline function collides(s:Shape):Null return s.collide_polygon(this, true); + override inline function collides(s:Shape):Null return s.collide_polygon(this); - // collision calculated as r against this. So invert flip value - override inline function collide_rect(r:Rect, flip:Bool = false):Null return r.rect_and_polygon(this, !flip); + override inline function collide_rect(r:Rect):Null return r.rect_and_polygon(this, true); - // collision calculated as c against this. So invert flip value - override inline function collide_circle(c:Circle, flip:Bool = false):Null return c.circle_and_polygon(this, !flip); + override inline function collide_circle(c:Circle):Null return c.circle_and_polygon(this); - override inline function collide_polygon(p:Polygon, flip:Bool = false):Null return this.polygon_and_polygon(p, flip); + override inline function collide_polygon(p:Polygon):Null return p.polygon_and_polygon(this, true); override inline function get_top():Float { if (count == 0 || vertices[0] == null) return y; diff --git a/echo/shape/Rect.hx b/echo/shape/Rect.hx index ff16511..7d5ba23 100644 --- a/echo/shape/Rect.hx +++ b/echo/shape/Rect.hx @@ -1,10 +1,10 @@ package echo.shape; -import echo.data.Data; -import echo.math.Vector2; -import echo.shape.*; import echo.util.AABB; +import echo.shape.*; import echo.util.Poolable; +import echo.data.Data; +import echo.math.Vector2; using echo.util.SAT; @@ -174,14 +174,13 @@ class Rect extends Shape implements Poolable { return false; } - // collision calculated as s against this. So flip result - override inline function collides(s:Shape):Null return s.collide_rect(this, true); + override inline function collides(s:Shape):Null return s.collide_rect(this); - override inline function collide_rect(r:Rect, flip:Bool = false):Null return this.rect_and_rect(r, flip); + override inline function collide_rect(r:Rect):Null return r.rect_and_rect(this); - override inline function collide_circle(c:Circle, flip:Bool = false):Null return this.rect_and_circle(c, flip); + override inline function collide_circle(c:Circle):Null return this.rect_and_circle(c); - override inline function collide_polygon(p:Polygon, flip:Bool = false):Null return this.rect_and_polygon(p, flip); + override inline function collide_polygon(p:Polygon):Null return this.rect_and_polygon(p); override function set_parent(?body:Body) { super.set_parent(body);