Bugfixes and cleanup
This commit is contained in:
@@ -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),
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user