Deployment dialog replaced

This commit is contained in:
Anuken
2020-01-12 20:01:32 -05:00
parent e6f1d194ae
commit c637ec15ff
13 changed files with 87 additions and 45 deletions

View File

@@ -4,7 +4,7 @@ import arc.math.*;
import arc.math.geom.*;
import arc.util.*;
class Pgrid{
class PlanetGrid{
private static final float x = -0.525731112119133606f;
private static final float z = -0.850650808352039932f;
@@ -14,18 +14,20 @@ class Pgrid{
new Vec3(z, x, 0), new Vec3(-z, x, 0), new Vec3(z, -x, 0), new Vec3(-z, -x, 0)
};
private static final int[][] iTilesP = {
private static final int[][] iTilesP = {
{9, 4, 1, 6, 11}, {4, 8, 10, 6, 0}, {11, 7, 3, 5, 9}, {2, 7, 10, 8, 5},
{9, 5, 8, 1, 0}, {2, 3, 8, 4, 9}, {0, 1, 10, 7, 11}, {11, 6, 10, 3, 2},
{5, 3, 10, 1, 4}, {2, 5, 4, 0, 11}, {3, 7, 6, 1, 8}, {7, 2, 9, 0, 6}
};
private static PlanetGrid[] cache = new PlanetGrid[10];
int size;
Ptile[] tiles;
Corner[] corners;
Edge[] edges;
Pgrid(int size){
PlanetGrid(int size){
this.size = size;
tiles = new Ptile[tileCount(size)];
@@ -44,16 +46,29 @@ class Pgrid{
}
}
static Pgrid newGrid(int size){
if(size == 0){
return initialGrid();
}else{
return subdividedGrid(newGrid(size - 1));
static PlanetGrid newGrid(int size){
//cache grids between calls, since only ~5 different grids total are needed
if(size < cache.length && cache[size] != null){
return cache[size];
}
PlanetGrid result;
if(size == 0){
result = initialGrid();
}else{
result = subdividedGrid(newGrid(size - 1));
}
//store grid in cache
if(size < cache.length){
cache[size] = result;
}
return result;
}
static Pgrid initialGrid(){
Pgrid grid = new Pgrid(0);
static PlanetGrid initialGrid(){
PlanetGrid grid = new PlanetGrid(0);
for(Ptile t : grid.tiles){
t.v = iTiles[t.id];
@@ -97,8 +112,8 @@ class Pgrid{
return grid;
}
static Pgrid subdividedGrid(Pgrid prev){
Pgrid grid = new Pgrid(prev.size + 1);
static PlanetGrid subdividedGrid(PlanetGrid prev){
PlanetGrid grid = new PlanetGrid(prev.size + 1);
int prevTiles = prev.tiles.length;
int prevCorners = prev.corners.length;
@@ -148,7 +163,7 @@ class Pgrid{
return grid;
}
static void addCorner(int id, Pgrid grid, int t1, int t2, int t3){
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();
@@ -158,7 +173,7 @@ class Pgrid{
}
}
static void addEdge(int id, Pgrid grid, int t1, int t2){
static void addEdge(int id, PlanetGrid grid, int t1, int t2){
Edge e = grid.edges[id];
Ptile[] t = {grid.tiles[t1], grid.tiles[t2]};
Corner[] c = {

View File

@@ -8,13 +8,13 @@ import arc.math.geom.*;
import arc.util.ArcAnnotate.*;
import arc.util.*;
import arc.util.noise.*;
import mindustry.graphics.Pgrid.*;
import mindustry.graphics.PlanetGrid.*;
public class PlanetMesh{
private float[] floats = new float[3 + 3 + 1];
private Vec3 center = new Vec3(0, 0, 0);
private Mesh mesh;
private Pgrid grid;
private PlanetGrid grid;
private float color;
private boolean lines;
@@ -27,7 +27,7 @@ public class PlanetMesh{
this.radius = radius;
this.lines = lines;
this.color = color.toFloatBits();
this.grid = Pgrid.newGrid(divisions);
this.grid = PlanetGrid.newGrid(divisions);
int vertices = grid.tiles.length * 12 * (3 + 3 + 1);

View File

@@ -7,13 +7,13 @@ import arc.graphics.g3d.*;
import arc.input.*;
import arc.math.geom.*;
import arc.util.*;
import mindustry.graphics.Pgrid.*;
import mindustry.graphics.PlanetGrid.*;
public class PlanetRenderer{
private Camera3D cam = new Camera3D();
private float lastX, lastY;
private PlanetMesh planet = new PlanetMesh(3, 1f, false, Color.royal);
private PlanetMesh planet = new PlanetMesh(4, 1f, false, Color.royal);
private PlanetMesh outline = new PlanetMesh(3, 1.01f, true, Pal.accent);
private VertexBatch3D batch = new VertexBatch3D(false, true, 0);
@@ -24,8 +24,7 @@ public class PlanetRenderer{
public void draw(){
Draw.flush();
Gl.clearColor(0, 0, 0, 1);
Gl.clear(Gl.depthBufferBit | Gl.colorBufferBit);
Gl.clear(Gl.depthBufferBit);
Gl.enable(Gl.depthTest);
input();
@@ -38,15 +37,13 @@ public class PlanetRenderer{
planet.render(cam.combined());
//outline.render(cam.combined());
//Log.info(cam.position + " " + cam.getPickRay(Core.input.mouseX(), Core.input.mouseY()));
Ptile tile = outline.getTile(cam.getPickRay(Core.input.mouseX(), Core.input.mouseY()));
if(tile != null){
for(int i = 0; i < tile.corners.length + 1; i++){
batch.color(Pal.accent);
batch.vertex(tile.corners[i % tile.corners.length].v);
for(int i = 0; i < tile.corners.length; i++){
batch.color(1f, 1f, 1f, 0.5f);
batch.vertex(tile.corners[i].v);
}
batch.flush(cam.combined(), Gl.lineStrip);
batch.flush(cam.combined(), Gl.triangleFan);
}
Gl.disable(Gl.depthTest);