From 26c328ae341385b7a3e7c214f236acd07f51e073 Mon Sep 17 00:00:00 2001 From: Anuken Date: Sat, 29 Feb 2020 12:43:37 -0500 Subject: [PATCH] Bugfixes and cleanup --- .../mindustry/graphics/g3d/MeshBuilder.java | 32 ++++++------------- .../mindustry/graphics/g3d/PlanetGrid.java | 7 ++-- core/src/mindustry/type/Planet.java | 2 +- .../mindustry/ui/dialogs/PlanetDialog.java | 11 +++++-- gradle.properties | 2 +- 5 files changed, 22 insertions(+), 32 deletions(-) diff --git a/core/src/mindustry/graphics/g3d/MeshBuilder.java b/core/src/mindustry/graphics/g3d/MeshBuilder.java index b51acea09b..4c6a8a8314 100644 --- a/core/src/mindustry/graphics/g3d/MeshBuilder.java +++ b/core/src/mindustry/graphics/g3d/MeshBuilder.java @@ -34,26 +34,14 @@ public class MeshBuilder{ for(Ptile tile : grid.tiles){ - Vec3 nor = v1.setZero(); Corner[] c = tile.corners; for(Corner corner : c){ - corner.bv.set(corner.v).setLength(radius); + corner.v.setLength((1f + mesher.getHeight(v2.set(corner.v)) * intensity) * radius); } - for(Corner corner : c){ - corner.v.setLength(radius + hexElevation(corner.bv, mesher, radius)*intensity); - } - - for(Corner corner : c){ - nor.add(corner.v); - } - nor.nor(); - - Vec3 realNormal = normal(c[0].v, c[2].v, c[4].v); - nor.set(realNormal); - - Color color = hexColor(tile.v, mesher, radius); + Vec3 nor = normal(c[0].v, c[2].v, c[4].v); + Color color = mesher.getColor(v2.set(tile.v)); if(lines){ nor.set(1f, 1f, 1f); @@ -76,19 +64,17 @@ public class MeshBuilder{ verts(c[0].v, c[3].v, c[4].v, nor, color); } } + + //restore mutated corners + for(Corner corner : c){ + corner.v.nor(); + } + } return end(); } - private static float hexElevation(Vec3 v, HexMesher mesher, float radius){ - return mesher.getHeight(v2.set(v).scl(1f / radius)); - } - - private static Color hexColor(Vec3 v, HexMesher mesher, float radius){ - return mesher.getColor(v2.set(v).scl(1f / radius)); - } - private static void begin(int count){ mesh = new Mesh(true, count, 0, new VertexAttribute(Usage.position, 3, Shader.positionAttribute), diff --git a/core/src/mindustry/graphics/g3d/PlanetGrid.java b/core/src/mindustry/graphics/g3d/PlanetGrid.java index 3758ec61ab..37a4d1ab15 100644 --- a/core/src/mindustry/graphics/g3d/PlanetGrid.java +++ b/core/src/mindustry/graphics/g3d/PlanetGrid.java @@ -2,7 +2,6 @@ package mindustry.graphics.g3d; import arc.math.*; import arc.math.geom.*; -import arc.util.*; //TODO clean this up somehow public class PlanetGrid{ @@ -166,7 +165,7 @@ public class PlanetGrid{ static void addCorner(int id, PlanetGrid grid, int t1, int t2, int t3){ Corner c = grid.corners[id]; Ptile[] t = {grid.tiles[t1], grid.tiles[t2], grid.tiles[t3]}; - c.v = Tmp.v31.set(t[0].v).add(t[1].v).add(t[2].v).cpy().nor(); + c.v.set(t[0].v).add(t[1].v).add(t[2].v).nor(); for(int i = 0; i < 3; i++){ t[i].corners[pos(t[i], t[(i + 2) % 3])] = c; c.tiles[i] = t[i]; @@ -245,9 +244,7 @@ public class PlanetGrid{ public final Ptile[] tiles = new Ptile[3]; public final Corner[] corners = new Corner[3]; public final Edge[] edges = new Edge[3]; - - public Vec3 v = new Vec3(); - public Vec3 bv = new Vec3(); + public final Vec3 v = new Vec3(); public Corner(int id){ this.id = id; diff --git a/core/src/mindustry/type/Planet.java b/core/src/mindustry/type/Planet.java index 4d1328c2b5..6b2783e5ce 100644 --- a/core/src/mindustry/type/Planet.java +++ b/core/src/mindustry/type/Planet.java @@ -20,7 +20,7 @@ import static mindustry.Vars.universe; public class Planet extends UnlockableContent{ /** Default spacing between planet orbits in world units. */ - private static final float orbitSpacing = 5f; + private static final float orbitSpacing = 6f; /** intersect() temp var. */ private static final Vec3 intersectResult = new Vec3(); /** Mesh used for rendering. Created on load() - will be null on the server! */ diff --git a/core/src/mindustry/ui/dialogs/PlanetDialog.java b/core/src/mindustry/ui/dialogs/PlanetDialog.java index ccdda8221c..8f58f24eac 100644 --- a/core/src/mindustry/ui/dialogs/PlanetDialog.java +++ b/core/src/mindustry/ui/dialogs/PlanetDialog.java @@ -136,6 +136,7 @@ public class PlanetDialog extends FloatingDialog{ cam.up.set(Vec3.Y); cam.resize(Core.graphics.getWidth(), Core.graphics.getHeight()); + camRelative.setLength(planet.radius * camLength); cam.position.set(planet.position).add(camRelative); cam.lookAt(planet.position); cam.update(); @@ -147,7 +148,6 @@ public class PlanetDialog extends FloatingDialog{ renderPlanet(solarSystem); if(planet.isLandable()){ - //TODO renderSectors(planet); } @@ -335,13 +335,20 @@ public class PlanetDialog extends FloatingDialog{ for(int i = 0; i < sector.tile.corners.length; i++){ Corner next = sector.tile.corners[(i + 1) % sector.tile.corners.length]; Corner curr = sector.tile.corners[i]; + + next.v.scl(arad); + curr.v.scl(arad); sector.tile.v.scl(arad); + Tmp.v31.set(curr.v).sub(sector.tile.v).setLength(length).add(sector.tile.v); Tmp.v32.set(next.v).sub(sector.tile.v).setLength(length).add(sector.tile.v); - sector.tile.v.scl(1f / arad); batch.tri(curr.v, next.v, Tmp.v31, Pal.accent); batch.tri(Tmp.v31, next.v, Tmp.v32, Pal.accent); + + sector.tile.v.scl(1f / arad); + next.v.scl(1f / arad); + curr.v.scl(1f /arad); } } diff --git a/gradle.properties b/gradle.properties index 9141b274a4..ad952b61d9 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,3 @@ org.gradle.daemon=true org.gradle.jvmargs=-Xms256m -Xmx1024m -archash=17caa50a75e98000d6e7bd1568a932a087dc09c3 +archash=7287b37c2a36408da69c156014e96850acd0a4f0