From 135b87fdb20747e32df00b77748fe8514be634cf Mon Sep 17 00:00:00 2001 From: Anuken Date: Fri, 1 May 2020 16:35:18 -0400 Subject: [PATCH] Cleanup, optimization --- .../mindustry/annotations/Annotations.java | 2 +- .../annotations/entity/EntityProcess.java | 11 ++- core/src/mindustry/Vars.java | 1 + core/src/mindustry/ai/NewBlockIndexer.java | 50 -------------- core/src/mindustry/async/AsyncLogic.java | 10 ++- core/src/mindustry/async/AsyncProcess.java | 14 ++-- .../src/mindustry/async/CollisionProcess.java | 67 +++++-------------- .../src/mindustry/async/TeamIndexProcess.java | 50 ++++++++++++++ core/src/mindustry/core/World.java | 4 ++ .../mindustry/entities/EntityCollisions.java | 8 ++- core/src/mindustry/entities/EntityGroup.java | 8 +-- .../entities/{AllDefs.java => GroupDefs.java} | 4 +- core/src/mindustry/entities/Units.java | 21 +++--- .../mindustry/entities/def/BulletComp.java | 14 +++- .../mindustry/entities/def/CollisionComp.java | 12 ---- .../mindustry/entities/def/HitboxComp.java | 5 ++ core/src/mindustry/entities/def/UnitComp.java | 4 +- core/src/mindustry/game/Team.java | 2 + .../mindustry/graphics/OverlayRenderer.java | 2 +- core/src/mindustry/ui/Minimap.java | 3 + 20 files changed, 138 insertions(+), 154 deletions(-) delete mode 100644 core/src/mindustry/ai/NewBlockIndexer.java create mode 100644 core/src/mindustry/async/TeamIndexProcess.java rename core/src/mindustry/entities/{AllDefs.java => GroupDefs.java} (86%) delete mode 100644 core/src/mindustry/entities/def/CollisionComp.java diff --git a/annotations/src/main/java/mindustry/annotations/Annotations.java b/annotations/src/main/java/mindustry/annotations/Annotations.java index d15a137378..38b48a25a7 100644 --- a/annotations/src/main/java/mindustry/annotations/Annotations.java +++ b/annotations/src/main/java/mindustry/annotations/Annotations.java @@ -58,7 +58,7 @@ public class Annotations{ @Retention(RetentionPolicy.SOURCE) public @interface GroupDef{ Class[] value(); - Class[] collide() default {}; + boolean collide() default false; boolean spatial() default false; boolean mapping() default false; } diff --git a/annotations/src/main/java/mindustry/annotations/entity/EntityProcess.java b/annotations/src/main/java/mindustry/annotations/entity/EntityProcess.java index e0cc24ebf6..9045e32c20 100644 --- a/annotations/src/main/java/mindustry/annotations/entity/EntityProcess.java +++ b/annotations/src/main/java/mindustry/annotations/entity/EntityProcess.java @@ -172,7 +172,7 @@ public class EntityProcess extends BaseProcessor{ for(Selement group : allGroups){ GroupDef an = group.annotation(GroupDef.class); Array types = types(an, GroupDef::value).map(this::interfaceToComp); - Array collides = types(an, GroupDef::collide); + boolean collides = an.collide(); groupDefs.add(new GroupDefinition(group.name().startsWith("g") ? group.name().substring(1) : group.name(), ClassName.bestGuess(packageName + "." + interfaceName(types.first())), types, an.spatial(), an.mapping(), collides)); } @@ -436,8 +436,8 @@ public class EntityProcess extends BaseProcessor{ groupUpdate.addStatement("all.update()"); for(GroupDefinition group : groupDefs){ - for(Stype collide : group.collides){ - groupUpdate.addStatement("$L.collide($L)", group.name, collide.name().startsWith("g") ? collide.name().substring(1) : collide.name()); + if(group.collides){ + groupUpdate.addStatement("$L.collide()", group.name); } } @@ -692,11 +692,10 @@ public class EntityProcess extends BaseProcessor{ final String name; final ClassName baseType; final Array components; - final Array collides; - final boolean spatial, mapping; + final boolean spatial, mapping, collides; final ObjectSet manualInclusions = new ObjectSet<>(); - public GroupDefinition(String name, ClassName bestType, Array components, boolean spatial, boolean mapping, Array collides){ + public GroupDefinition(String name, ClassName bestType, Array components, boolean spatial, boolean mapping, boolean collides){ this.baseType = bestType; this.components = components; this.name = name; diff --git a/core/src/mindustry/Vars.java b/core/src/mindustry/Vars.java index 1c06b4c4ba..b982ade0fd 100644 --- a/core/src/mindustry/Vars.java +++ b/core/src/mindustry/Vars.java @@ -169,6 +169,7 @@ public class Vars implements Loadable{ public static Schematics schematics = new Schematics(); public static BeControl becontrol; public static AsyncLogic asyncLogic; + public static TeamIndexProcess teamIndex; public static Universe universe; public static World world; diff --git a/core/src/mindustry/ai/NewBlockIndexer.java b/core/src/mindustry/ai/NewBlockIndexer.java deleted file mode 100644 index bd1dc00f78..0000000000 --- a/core/src/mindustry/ai/NewBlockIndexer.java +++ /dev/null @@ -1,50 +0,0 @@ -package mindustry.ai; - -//new indexer implementation, uses quadtrees -public class NewBlockIndexer{ - - /* - public ObjectSet getOrePositions(Item item){ - - } - - public Tile findClosestOre(float xp, float yp, Item item){ - - } - - public ObjectSet getDamaged(Team team){ - - } - - public ObjectSet getAllied(Team team, BlockFlag type){ - - } - - public boolean eachBlock(Teamc team, float range, Boolf pred, Cons cons){ - return eachBlock(team.team(), team.getX(), team.getY(), range, pred, cons); - } - - public boolean eachBlock(Team team, float wx, float wy, float range, Boolf pred, Cons cons){ - - } - - public Array getEnemy(Team team, BlockFlag type){ - - } - - public void notifyTileDamaged(Tilec entity){ - - } - - public Tilec findEnemyTile(Team team, float x, float y, float range, Boolf pred){ - - } - - public Tilec findTile(Team team, float x, float y, float range, Boolf pred, boolean usePriority){ - - } - - public Tilec findTile(Team team, float x, float y, float range, Boolf pred){ - return findTile(team, x, y, range, pred, false); - }*/ -} diff --git a/core/src/mindustry/async/AsyncLogic.java b/core/src/mindustry/async/AsyncLogic.java index d8ced55084..fac5784cc9 100644 --- a/core/src/mindustry/async/AsyncLogic.java +++ b/core/src/mindustry/async/AsyncLogic.java @@ -2,13 +2,17 @@ package mindustry.async; import arc.*; import arc.struct.*; +import mindustry.*; import mindustry.game.EventType.*; import java.util.concurrent.*; public class AsyncLogic{ //all processes to be executed each frame - private Array processes = Array.with(new PhysicsProcess(), new CollisionProcess()); + private Array processes = Array.with( + new PhysicsProcess(), + Vars.teamIndex = new TeamIndexProcess() + ); //futures to be awaited private Array> futures = new Array<>(); @@ -46,7 +50,9 @@ public class AsyncLogic{ //submit all tasks for(AsyncProcess p : processes){ - futures.add(executor.submit(p::process)); + if(p.shouldProcess()){ + futures.add(executor.submit(p::process)); + } } } diff --git a/core/src/mindustry/async/AsyncProcess.java b/core/src/mindustry/async/AsyncProcess.java index 08c6d86a53..97c0fbc505 100644 --- a/core/src/mindustry/async/AsyncProcess.java +++ b/core/src/mindustry/async/AsyncProcess.java @@ -3,17 +3,21 @@ package mindustry.async; public interface AsyncProcess{ /** Sync. Called when the world loads. */ - void init(); + default void init(){} /** Sync. Called when the world resets. */ - void reset(); + default void reset(){} /** Sync. Called at the beginning of the main loop. */ - void begin(); + default void begin(){} /** Async. Called in a separate thread. */ - void process(); + default void process(){} /** Sync. Called in the end of the main loop. */ - void end(); + default void end(){} + + default boolean shouldProcess(){ + return true; + } } diff --git a/core/src/mindustry/async/CollisionProcess.java b/core/src/mindustry/async/CollisionProcess.java index 5023096415..493d525fa7 100644 --- a/core/src/mindustry/async/CollisionProcess.java +++ b/core/src/mindustry/async/CollisionProcess.java @@ -1,35 +1,21 @@ package mindustry.async; -import arc.box2d.*; import arc.math.geom.*; import arc.struct.*; import arc.util.*; -import arc.util.pooling.*; -import arc.util.pooling.Pool.*; import mindustry.entities.*; import mindustry.gen.*; import static mindustry.Vars.*; -/** - * Processes collisions. - * - * Each entity is assigned a final filter layer, then given a body and inserted into a physics world. - * - * Async: - * The body's position is set to its entity position, and the body velocity is set to the entity delta. - * Collisions are resolved and stored in a list, then processed synchronously. - * - */ +//TODO remove public class CollisionProcess implements AsyncProcess{ - private Pool pool = Pools.get(CollisionRef.class, CollisionRef::new); - //private Physics physics; - private QuadTree tree; - private Array insertEntities = new Array<>(); - private Array checkEntities = new Array<>(); + private QuadTree tree; + private Array insertEntities = new Array<>(); + private Array checkEntities = new Array<>(); - private Array arrOut = new Array<>(); + private Array arrOut = new Array<>(); private Vec2 l1 = new Vec2(); private Rect r1 = new Rect(); @@ -38,9 +24,9 @@ public class CollisionProcess implements AsyncProcess{ //private BodyDef def; //private FixtureDef fdef; - private EntityGroup inserted = Groups.unit; - private EntityGroup checked = Groups.bullet; - private Array collisions = new Array<>(Collisionc.class); + private EntityGroup inserted = Groups.unit; + private EntityGroup checked = Groups.bullet; + private Array collisions = new Array<>(Hitboxc.class); @Override public void begin(){ @@ -65,11 +51,11 @@ public class CollisionProcess implements AsyncProcess{ tree.clear(); //insert targets - for(Collisionc ins : insertEntities){ + for(Hitboxc ins : insertEntities){ tree.insert(ins); } - for(Collisionc solid : checked){ + for(Hitboxc solid : checked){ solid.hitbox(r1); r1.x += (solid.lastX() - solid.getX()); r1.y += (solid.lastY() - solid.getY()); @@ -78,9 +64,9 @@ public class CollisionProcess implements AsyncProcess{ r2.merge(r1); arrOut.clear(); - tree.getIntersect(arrOut, r2); + tree.intersect(r2, arrOut); - for(Collisionc sc : arrOut){ + for(Hitboxc sc : arrOut){ sc.hitbox(r1); if(r2.overlaps(r1)){ checkCollide(solid, sc); @@ -99,8 +85,8 @@ public class CollisionProcess implements AsyncProcess{ //processes anything that happened for(int i = 0; i < collisions.size; i += 2){ - Collisionc a = collisions.items[i]; - Collisionc b = collisions.items[i + 1]; + Hitboxc a = collisions.items[i]; + Hitboxc b = collisions.items[i + 1]; //TODO incorrect float cx = (a.x() + b.x())/2f, cy = (a.y() + b.y())/2f; @@ -124,7 +110,7 @@ public class CollisionProcess implements AsyncProcess{ tree = new QuadTree<>(new Rect(-finalWorldBounds, -finalWorldBounds, world.width() * tilesize + finalWorldBounds * 2, world.height() * tilesize + finalWorldBounds * 2)); } - private void checkCollide(Collisionc a, Collisionc b){ + private void checkCollide(Hitboxc a, Hitboxc b){ a.hitbox(this.r1); b.hitbox(this.r2); @@ -201,27 +187,4 @@ public class CollisionProcess implements AsyncProcess{ return true; } } - - public static class CollisionRef implements Poolable{ - Collisionc entity; - Body body; - Vec2 velocity = new Vec2(), position = new Vec2(); - - public CollisionRef set(Collisionc entity, Body body){ - this.entity = entity; - this.body = body; - - position.set(entity); - return this; - } - - @Override - public void reset(){ - entity = null; - body = null; - - velocity.setZero(); - position.setZero(); - } - } } diff --git a/core/src/mindustry/async/TeamIndexProcess.java b/core/src/mindustry/async/TeamIndexProcess.java new file mode 100644 index 0000000000..35dfd55907 --- /dev/null +++ b/core/src/mindustry/async/TeamIndexProcess.java @@ -0,0 +1,50 @@ +package mindustry.async; + +import arc.math.geom.*; +import arc.struct.*; +import mindustry.*; +import mindustry.game.*; +import mindustry.game.Teams.*; +import mindustry.gen.*; + +/** Creates quadtrees per unit team. */ +public class TeamIndexProcess implements AsyncProcess{ + private QuadTree[] trees = new QuadTree[Team.all().length]; + private Array active = new Array<>(); + + public QuadTree tree(Team team){ + if(trees[team.uid] == null) trees[team.uid] = new QuadTree<>(Vars.world.getQuadBounds(new Rect())); + + return trees[team.uid]; + } + + @Override + public void reset(){ + active.clear(); + trees = new QuadTree[Team.all().length]; + } + + @Override + public void begin(){ + for(TeamData data : Vars.state.teams.getActive()){ + if(!active.contains(data.team)){ + active.add(data.team); + } + } + + for(Team team : active){ + if(trees[team.uid] != null){ + trees[team.uid].clear(); + } + } + + for(Unitc unit : Groups.unit){ + tree(unit.team()).insert(unit); + } + } + + @Override + public boolean shouldProcess(){ + return false; + } +} diff --git a/core/src/mindustry/core/World.java b/core/src/mindustry/core/World.java index 8591eed25a..f19178cee7 100644 --- a/core/src/mindustry/core/World.java +++ b/core/src/mindustry/core/World.java @@ -186,6 +186,10 @@ public class World{ Events.fire(new WorldLoadEvent()); } + public Rect getQuadBounds(Rect in){ + return in.set(-finalWorldBounds, -finalWorldBounds, world.width() * tilesize + finalWorldBounds * 2, world.height() * tilesize + finalWorldBounds * 2); + } + public void setGenerating(boolean gen){ this.generating = gen; } diff --git a/core/src/mindustry/entities/EntityCollisions.java b/core/src/mindustry/entities/EntityCollisions.java index 79356ecc91..533f33521f 100644 --- a/core/src/mindustry/entities/EntityCollisions.java +++ b/core/src/mindustry/entities/EntityCollisions.java @@ -114,7 +114,7 @@ public class EntityCollisions{ group.each(s -> { s.updateLastPosition(); - //tree.insert(s); + tree.insert(s); }); } @@ -205,7 +205,7 @@ public class EntityCollisions{ } @SuppressWarnings("unchecked") - public void collideGroups(EntityGroup groupa, EntityGroup groupb){ + public void collide(EntityGroup groupa){ groupa.each(solid -> { solid.hitbox(r1); @@ -216,7 +216,9 @@ public class EntityCollisions{ r2.merge(r1); arrOut.clear(); - groupb.tree().getIntersect(arrOut, r2); + + //get all targets based on what entity wants to collide with + solid.getCollisions(tree -> tree.intersect(r2, arrOut)); for(Hitboxc sc : arrOut){ sc.hitbox(r1); diff --git a/core/src/mindustry/entities/EntityGroup.java b/core/src/mindustry/entities/EntityGroup.java index 3ee50a3af5..088f782349 100644 --- a/core/src/mindustry/entities/EntityGroup.java +++ b/core/src/mindustry/entities/EntityGroup.java @@ -45,8 +45,8 @@ public class EntityGroup implements Iterable{ array.sort(comp); } - public void collide(EntityGroup other){ - collisions.collideGroups((EntityGroup)this, other); + public void collide(){ + collisions.collide((EntityGroup)this); } public void updatePhysics(){ @@ -108,14 +108,14 @@ public class EntityGroup implements Iterable{ public void intersect(float x, float y, float width, float height, Cons out){ //don't waste time for empty groups if(isEmpty()) return; - tree.getIntersect(out, x, y, width, height); + tree.intersect(height, x, y, width, out); } public Array intersect(float x, float y, float width, float height){ intersectArray.clear(); //don't waste time for empty groups if(isEmpty()) return intersectArray; - tree.getIntersect(intersectArray, intersectRect.set(x, y, width, height)); + tree.intersect(intersectRect.set(x, y, width, height), intersectArray); return intersectArray; } diff --git a/core/src/mindustry/entities/AllDefs.java b/core/src/mindustry/entities/GroupDefs.java similarity index 86% rename from core/src/mindustry/entities/AllDefs.java rename to core/src/mindustry/entities/GroupDefs.java index 4036c3003c..979fb1aa24 100644 --- a/core/src/mindustry/entities/AllDefs.java +++ b/core/src/mindustry/entities/GroupDefs.java @@ -3,7 +3,7 @@ package mindustry.entities; import mindustry.annotations.Annotations.*; import mindustry.gen.*; -class AllDefs{ +class GroupDefs{ @GroupDef(value = Entityc.class, mapping = true) class gall{ @@ -15,7 +15,7 @@ class AllDefs{ } - @GroupDef(value = Bulletc.class, spatial = true) + @GroupDef(value = Bulletc.class, spatial = true, collide = true) class gbullet{ } diff --git a/core/src/mindustry/entities/Units.java b/core/src/mindustry/entities/Units.java index 354efb576a..c931c0f44f 100644 --- a/core/src/mindustry/entities/Units.java +++ b/core/src/mindustry/entities/Units.java @@ -30,7 +30,7 @@ public class Units{ * @return whether the target is invalid */ public static boolean invalidateTarget(Posc target, Team team, float x, float y, float range){ - return target == null || !target.isAdded() || (range != Float.MAX_VALUE && !target.withinDst(x, y, range)) || (target instanceof Teamc && ((Teamc)target).team() == team) || (target instanceof Healthc && !((Healthc)target).isValid()); + return target == null || !target.isAdded() || (range != Float.MAX_VALUE && !target.within(x, y, range)) || (target instanceof Teamc && ((Teamc)target).team() == team) || (target instanceof Healthc && !((Healthc)target).isValid()); } /** See {@link #invalidateTarget(Posc, Team, float, float, float)} */ @@ -131,6 +131,7 @@ public class Units{ result = null; cdist = 0f; + //TODO optimize for(Unitc e : Groups.unit){ if(!predicate.get(e) || e.team() != team) continue; @@ -164,17 +165,13 @@ public class Units{ /** Iterates over all units in a rectangle. */ public static void nearby(Team team, float x, float y, float width, float height, Cons cons){ - Groups.unit.intersect(x, y, width, height, u -> { - if(u.team() == team){ - cons.get(u); - } - }); + teamIndex.tree(team).intersect(height, x, y, width, cons); } /** Iterates over all units in a circle around this position. */ public static void nearby(Team team, float x, float y, float radius, Cons cons){ - Groups.unit.intersect(x - radius, y - radius, radius*2f, radius*2f, unit -> { - if(unit.team() == team && unit.withinDst(x, y, radius)){ + nearby(team, x - radius, y - radius, radius*2f, radius*2f, unit -> { + if(unit.within(x, y, radius)){ cons.get(unit); } }); @@ -192,11 +189,9 @@ public class Units{ /** Iterates over all units that are enemies of this team. */ public static void nearbyEnemies(Team team, float x, float y, float width, float height, Cons cons){ - Groups.unit.intersect(x, y, width, height, u -> { - if(team.isEnemy(u.team())){ - cons.get(u); - } - }); + for(Team enemy : state.teams.enemiesOf(team)){ + nearby(enemy, x, y, width, height, cons); + } } /** Iterates over all units that are enemies of this team. */ diff --git a/core/src/mindustry/entities/def/BulletComp.java b/core/src/mindustry/entities/def/BulletComp.java index 6aa5106a64..38b4df9ce4 100644 --- a/core/src/mindustry/entities/def/BulletComp.java +++ b/core/src/mindustry/entities/def/BulletComp.java @@ -1,10 +1,13 @@ package mindustry.entities.def; +import arc.func.*; import arc.graphics.g2d.*; import arc.math.*; +import arc.math.geom.*; import arc.util.*; import mindustry.annotations.Annotations.*; import mindustry.entities.bullet.*; +import mindustry.game.*; import mindustry.gen.*; import mindustry.graphics.*; @@ -12,11 +15,20 @@ import static mindustry.Vars.*; @EntityDef(value = {Bulletc.class}, pooled = true) @Component -abstract class BulletComp implements Timedc, Damagec, Collisionc, Teamc, Posc, Drawc, Shielderc, Ownerc, Velc, Bulletc, Timerc{ +abstract class BulletComp implements Timedc, Damagec, Hitboxc, Teamc, Posc, Drawc, Shielderc, Ownerc, Velc, Bulletc, Timerc{ + @Import Team team; + Object data; BulletType type; float damage; + @Override + public void getCollisions(Cons consumer){ + for(Team team : state.teams.enemiesOf(team)){ + consumer.get(teamIndex.tree(team)); + } + } + @Override public void drawBullets(){ type.draw(this); diff --git a/core/src/mindustry/entities/def/CollisionComp.java b/core/src/mindustry/entities/def/CollisionComp.java deleted file mode 100644 index 1814177d2a..0000000000 --- a/core/src/mindustry/entities/def/CollisionComp.java +++ /dev/null @@ -1,12 +0,0 @@ -package mindustry.entities.def; - -import mindustry.annotations.Annotations.*; -import mindustry.async.CollisionProcess.*; -import mindustry.gen.*; - -/** Can be collided with. Collision elibility depends on team. - * TODO merge with hitboxcomp?*/ -@Component -abstract class CollisionComp implements Hitboxc{ - transient CollisionRef colref; -} diff --git a/core/src/mindustry/entities/def/HitboxComp.java b/core/src/mindustry/entities/def/HitboxComp.java index 8e33766f93..500e98198e 100644 --- a/core/src/mindustry/entities/def/HitboxComp.java +++ b/core/src/mindustry/entities/def/HitboxComp.java @@ -1,5 +1,6 @@ package mindustry.entities.def; +import arc.func.*; import arc.math.geom.QuadTree.*; import arc.math.geom.*; import mindustry.annotations.Annotations.*; @@ -26,6 +27,10 @@ abstract class HitboxComp implements Posc, QuadTreeObject{ updateLastPosition(); } + void getCollisions(Cons consumer){ + + } + void updateLastPosition(){ lastX = x; lastY = y; diff --git a/core/src/mindustry/entities/def/UnitComp.java b/core/src/mindustry/entities/def/UnitComp.java index 9e14eff1d1..19da7b24de 100644 --- a/core/src/mindustry/entities/def/UnitComp.java +++ b/core/src/mindustry/entities/def/UnitComp.java @@ -18,7 +18,7 @@ import mindustry.world.blocks.environment.*; import static mindustry.Vars.*; @Component -abstract class UnitComp implements Healthc, Physicsc, Collisionc, Statusc, Teamc, Itemsc, Rotc, Unitc, Weaponsc, Drawc, Boundedc, Syncc, Shieldc{ +abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, Itemsc, Rotc, Unitc, Weaponsc, Drawc, Boundedc, Syncc, Shieldc{ @Import float x, y, rotation, elevation, maxHealth; private UnitController controller; @@ -122,7 +122,7 @@ abstract class UnitComp implements Healthc, Physicsc, Collisionc, Statusc, Teamc if(team() != state.rules.waveTeam){ float relativeSize = state.rules.dropZoneRadius + bounds()/2f + 1f; for(Tile spawn : spawner.getSpawns()){ - if(withinDst(spawn.worldx(), spawn.worldy(), relativeSize)){ + if(within(spawn.worldx(), spawn.worldy(), relativeSize)){ vel().add(Tmp.v1.set(this).sub(spawn.worldx(), spawn.worldy()).setLength(0.1f + 1f - dst(spawn) / relativeSize).scl(0.45f * Time.delta())); } } diff --git a/core/src/mindustry/game/Team.java b/core/src/mindustry/game/Team.java index 465fb7d556..b3da5045ad 100644 --- a/core/src/mindustry/game/Team.java +++ b/core/src/mindustry/game/Team.java @@ -13,6 +13,7 @@ import static mindustry.Vars.*; public class Team implements Comparable{ public final byte id; + public final int uid; public final Color color; public String name; @@ -58,6 +59,7 @@ public class Team implements Comparable{ this.id = (byte)id; int us = Pack.u(this.id); + uid = us; if(us < 6) baseTeams[us] = this; all[us] = this; } diff --git a/core/src/mindustry/graphics/OverlayRenderer.java b/core/src/mindustry/graphics/OverlayRenderer.java index 3a697ea21e..7f1916eca7 100644 --- a/core/src/mindustry/graphics/OverlayRenderer.java +++ b/core/src/mindustry/graphics/OverlayRenderer.java @@ -111,7 +111,7 @@ public class OverlayRenderer{ Draw.color(Color.gray, Color.lightGray, Mathf.absin(Time.time(), 8f, 1f)); for(Tile tile : spawner.getSpawns()){ - if(tile.withinDst(player.x(), player.y(), state.rules.dropZoneRadius + spawnerMargin)){ + if(tile.within(player.x(), player.y(), state.rules.dropZoneRadius + spawnerMargin)){ Draw.alpha(Mathf.clamp(1f - (player.dst(tile) - state.rules.dropZoneRadius) / spawnerMargin)); Lines.dashCircle(tile.worldx(), tile.worldy(), state.rules.dropZoneRadius); } diff --git a/core/src/mindustry/ui/Minimap.java b/core/src/mindustry/ui/Minimap.java index bbb81a7f00..cac2f08993 100644 --- a/core/src/mindustry/ui/Minimap.java +++ b/core/src/mindustry/ui/Minimap.java @@ -32,12 +32,15 @@ public class Minimap extends Table{ @Override public void draw(){ if(renderer.minimap.getRegion() == null) return; + if(!clipBegin()) return; Draw.rect(renderer.minimap.getRegion(), x + width / 2f, y + height / 2f, width, height); if(renderer.minimap.getTexture() != null){ renderer.minimap.drawEntities(x, y, width, height, 0.75f, false); } + + clipEnd(); } }).size(140f);