From ddd9f2259c0f0987b9f91589eba3d489dca060aa Mon Sep 17 00:00:00 2001 From: Anuken Date: Sun, 13 Dec 2020 10:27:44 -0500 Subject: [PATCH] Fixed #3960 --- core/src/mindustry/entities/Damage.java | 13 +++++++++---- core/src/mindustry/world/Tile.java | 4 ++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/core/src/mindustry/entities/Damage.java b/core/src/mindustry/entities/Damage.java index f3f50d9107..8e0eba7b58 100644 --- a/core/src/mindustry/entities/Damage.java +++ b/core/src/mindustry/entities/Damage.java @@ -23,7 +23,7 @@ public class Damage{ private static Tile furthest; private static Rect rect = new Rect(); private static Rect hitrect = new Rect(); - private static Vec2 tr = new Vec2(); + private static Vec2 tr = new Vec2(), seg1 = new Vec2(), seg2 = new Vec2(); private static Seq units = new Seq<>(); private static GridBits bits = new GridBits(30, 30); private static IntQueue propagation = new IntQueue(); @@ -120,6 +120,7 @@ public class Damage{ collidedBlocks.clear(); tr.trns(angle, length); + Intc2 collider = (cx, cy) -> { Building tile = world.build(cx, cy); boolean collide = tile != null && collidedBlocks.add(tile.pos()); @@ -138,10 +139,14 @@ public class Damage{ }; if(hitter.type.collidesGround){ - world.raycastEachWorld(x, y, x + tr.x, y + tr.y, (cx, cy) -> { + seg1.set(x, y); + seg2.set(seg1).add(tr); + world.raycastEachWorld(x, y, seg2.x, seg2.y, (cx, cy) -> { collider.get(cx, cy); - if(large){ - for(Point2 p : Geometry.d4){ + + for(Point2 p : Geometry.d4){ + Tile other = world.tile(p.x + cx, p.y + cy); + if(other != null && (large || Intersector.intersectSegmentRectangle(seg1, seg2, other.getBounds(Tmp.r1)))){ collider.get(cx + p.x, cy + p.y); } } diff --git a/core/src/mindustry/world/Tile.java b/core/src/mindustry/world/Tile.java index 421e5b21e1..d4556fd60f 100644 --- a/core/src/mindustry/world/Tile.java +++ b/core/src/mindustry/world/Tile.java @@ -441,6 +441,10 @@ public class Tile implements Position, QuadTreeObject, Displayable{ return rect.setCentered(drawx(), drawy(), block.size * tilesize, block.size * tilesize); } + public Rect getBounds(Rect rect){ + return rect.set(x * tilesize - tilesize/2f, y * tilesize - tilesize/2f, tilesize, tilesize); + } + @Override public void hitbox(Rect rect){ getHitbox(rect);