mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-01-10 07:07:03 +07:00
Bugfixes and cleanup
This commit is contained in:
parent
7a01719816
commit
26c328ae34
@ -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;
|
||||
|
@ -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! */
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,3 @@
|
||||
org.gradle.daemon=true
|
||||
org.gradle.jvmargs=-Xms256m -Xmx1024m
|
||||
archash=17caa50a75e98000d6e7bd1568a932a087dc09c3
|
||||
archash=7287b37c2a36408da69c156014e96850acd0a4f0
|
||||
|
Loading…
Reference in New Issue
Block a user