diff --git a/core/src/mindustry/graphics/PlanetMesh.java b/core/src/mindustry/graphics/PlanetMesh.java index 2200ecd243..c5b3e97799 100644 --- a/core/src/mindustry/graphics/PlanetMesh.java +++ b/core/src/mindustry/graphics/PlanetMesh.java @@ -9,6 +9,8 @@ import arc.util.*; import mindustry.graphics.PlanetGrid.*; public class PlanetMesh{ + private static final Vec3 v1 = new Vec3(), v2 = new Vec3(), v3 = new Vec3(), v4 = new Vec3(); + private float[] floats = new float[3 + 3 + 1]; private Vec3 vec = new Vec3(); private Mesh mesh; @@ -68,11 +70,11 @@ public class PlanetMesh{ shader.end(); } - private void generateMesh(){ + private void generateMesh(){ for(Ptile tile : grid.tiles){ - Vec3 nor = Tmp.v31.setZero(); + Vec3 nor = v1.setZero(); Corner[] c = tile.corners; for(Corner corner : c){ @@ -117,6 +119,21 @@ public class PlanetMesh{ } } + //unused, but functional + private void createIcosphere(){ + MeshResult result = Icosphere.create(5); + for(int i = 0; i < result.indices.size; i+= 3){ + v1.set(result.vertices.items, result.indices.items[i] * 3).setLength(radius).setLength(radius + elevation(v1)*intensity); + v2.set(result.vertices.items, result.indices.items[i + 1] * 3).setLength(radius).setLength(radius + elevation(v2)*intensity); + v3.set(result.vertices.items, result.indices.items[i + 2] * 3).setLength(radius).setLength(radius + elevation(v3)*intensity); + + verts(v1, v3, v2, + normal(v1, v2, v3).scl(-1f), + color(v4.set(v1).add(v2).add(v3).scl(1f / 3f)) + ); + } + } + private Vec3 normal(Vec3 v1, Vec3 v2, Vec3 v3){ return Tmp.v32.set(v2).sub(v1).crs(v3.x - v1.x, v3.y - v1.y, v3.z - v1.z).nor(); }