Merge branch 'master' into planetdraw
This commit is contained in:
@@ -38,7 +38,7 @@ public class BlockRenderer implements Disposable{
|
||||
private FrameBuffer dark = new FrameBuffer();
|
||||
private Seq<Building> outArray2 = new Seq<>();
|
||||
private Seq<Tile> shadowEvents = new Seq<>();
|
||||
private IntSet processedEntities = new IntSet(), processedLinks = new IntSet();
|
||||
private IntSet procEntities = new IntSet(), procLinks = new IntSet(), procLights = new IntSet();
|
||||
private boolean displayStatus = false;
|
||||
|
||||
public BlockRenderer(){
|
||||
@@ -191,8 +191,9 @@ public class BlockRenderer implements Disposable{
|
||||
|
||||
tileview.clear();
|
||||
lightview.clear();
|
||||
processedEntities.clear();
|
||||
processedLinks.clear();
|
||||
procEntities.clear();
|
||||
procLinks.clear();
|
||||
procLights.clear();
|
||||
|
||||
int minx = Math.max(avgx - rangex - expandr, 0);
|
||||
int miny = Math.max(avgy - rangey - expandr, 0);
|
||||
@@ -209,25 +210,25 @@ public class BlockRenderer implements Disposable{
|
||||
tile = tile.build.tile;
|
||||
}
|
||||
|
||||
if(block != Blocks.air && block.cacheLayer == CacheLayer.normal && (tile.build == null || !processedEntities.contains(tile.build.id))){
|
||||
if(block != Blocks.air && block.cacheLayer == CacheLayer.normal && (tile.build == null || !procEntities.contains(tile.build.id))){
|
||||
if(block.expanded || !expanded){
|
||||
if(tile.build == null || processedLinks.add(tile.build.id)){
|
||||
if(tile.build == null || procLinks.add(tile.build.id)){
|
||||
tileview.add(tile);
|
||||
if(tile.build != null){
|
||||
processedEntities.add(tile.build.id);
|
||||
processedLinks.add(tile.build.id);
|
||||
procEntities.add(tile.build.id);
|
||||
procLinks.add(tile.build.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//lights are drawn even in the expanded range
|
||||
if(tile.build != null || tile.block().emitLight){
|
||||
if(((tile.build != null && procLights.add(tile.build.pos())) || tile.block().emitLight)){
|
||||
lightview.add(tile);
|
||||
}
|
||||
|
||||
if(tile.build != null && tile.build.power != null && tile.build.power.links.size > 0){
|
||||
for(Building other : tile.build.getPowerConnections(outArray2)){
|
||||
if(other.block instanceof PowerNode && processedLinks.add(other.id)){ //TODO need a generic way to render connections!
|
||||
if(other.block instanceof PowerNode && procLinks.add(other.id)){ //TODO need a generic way to render connections!
|
||||
tileview.add(other.tile);
|
||||
}
|
||||
}
|
||||
@@ -235,7 +236,7 @@ public class BlockRenderer implements Disposable{
|
||||
}
|
||||
|
||||
//special case for floors
|
||||
if(block == Blocks.air && tile.floor().emitLight){
|
||||
if((block == Blocks.air && tile.floor().emitLight) && procLights.add(tile.pos())){
|
||||
lightview.add(tile);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,7 +100,6 @@ public class LightRenderer{
|
||||
|
||||
Draw.vert(ledge.texture, vertices, 0, vertices.length);
|
||||
|
||||
|
||||
Vec2 v3 = Tmp.v2.trnsExact(rot, stroke);
|
||||
|
||||
u = ledge.u;
|
||||
|
||||
@@ -96,7 +96,7 @@ public class MinimapRenderer implements Disposable{
|
||||
|
||||
Draw.mixcol(unit.team().color, 1f);
|
||||
float scale = Scl.scl(1f) / 2f * scaling * 32f;
|
||||
Draw.rect(unit.type().icon(Cicon.full), x + rx, y + ry, scale, scale, unit.rotation() - 90);
|
||||
Draw.rect(unit.type.icon(Cicon.full), x + rx, y + ry, scale, scale, unit.rotation() - 90);
|
||||
Draw.reset();
|
||||
|
||||
//only disable player names in multiplayer
|
||||
|
||||
@@ -85,7 +85,7 @@ public class OverlayRenderer{
|
||||
//special selection for block "units"
|
||||
Fill.square(select.x, select.y, ((BlockUnitc)select).tile().block.size * tilesize/2f);
|
||||
}else{
|
||||
Draw.rect(select.type().icon(Cicon.full), select.x(), select.y(), select.rotation() - 90);
|
||||
Draw.rect(select.type.icon(Cicon.full), select.x(), select.y(), select.rotation() - 90);
|
||||
}
|
||||
|
||||
Lines.stroke(unitFade);
|
||||
@@ -121,10 +121,12 @@ public class OverlayRenderer{
|
||||
Lines.stroke(2f);
|
||||
Draw.color(Color.gray, Color.lightGray, Mathf.absin(Time.time(), 8f, 1f));
|
||||
|
||||
for(Tile tile : spawner.getSpawns()){
|
||||
if(tile.within(player.x, player.y, state.rules.dropZoneRadius + spawnerMargin)){
|
||||
Draw.alpha(Mathf.clamp(1f - (player.dst(tile) - state.rules.dropZoneRadius) / spawnerMargin));
|
||||
Lines.dashCircle(tile.worldx(), tile.worldy(), state.rules.dropZoneRadius);
|
||||
if(state.rules.waves){
|
||||
for(Tile tile : spawner.getSpawns()){
|
||||
if(tile.within(player.x, player.y, state.rules.dropZoneRadius + spawnerMargin)){
|
||||
Draw.alpha(Mathf.clamp(1f - (player.dst(tile) - state.rules.dropZoneRadius) / spawnerMargin));
|
||||
Lines.dashCircle(tile.worldx(), tile.worldy(), state.rules.dropZoneRadius);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,15 +22,16 @@ public class PlanetGrid{
|
||||
{5, 3, 10, 1, 4}, {2, 5, 4, 0, 11}, {3, 7, 6, 1, 8}, {7, 2, 9, 0, 6}
|
||||
};
|
||||
|
||||
public final int size;
|
||||
public final Ptile[] tiles;
|
||||
public final Corner[] corners;
|
||||
public final Edge[] edges;
|
||||
public int size;
|
||||
public Ptile[] tiles;
|
||||
public Corner[] corners;
|
||||
public Edge[] edges;
|
||||
|
||||
PlanetGrid(int size){
|
||||
//this is protected so if you want to make strange grids you should know what you're doing.
|
||||
protected PlanetGrid(int size){
|
||||
this.size = size;
|
||||
|
||||
tiles = new Ptile[Buildingount(size)];
|
||||
tiles = new Ptile[tileCount(size)];
|
||||
for(int i = 0; i < tiles.length; i++){
|
||||
tiles[i] = new Ptile(i, i < 12 ? 5 : 6);
|
||||
}
|
||||
@@ -67,7 +68,7 @@ public class PlanetGrid{
|
||||
return result;
|
||||
}
|
||||
|
||||
static PlanetGrid initialGrid(){
|
||||
public static PlanetGrid initialGrid(){
|
||||
PlanetGrid grid = new PlanetGrid(0);
|
||||
|
||||
for(Ptile t : grid.tiles){
|
||||
@@ -111,7 +112,7 @@ public class PlanetGrid{
|
||||
return grid;
|
||||
}
|
||||
|
||||
static PlanetGrid subdividedGrid(PlanetGrid prev){
|
||||
public static PlanetGrid subdividedGrid(PlanetGrid prev){
|
||||
PlanetGrid grid = new PlanetGrid(prev.size + 1);
|
||||
|
||||
int prevTiles = prev.tiles.length;
|
||||
@@ -207,7 +208,7 @@ public class PlanetGrid{
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int Buildingount(int size){
|
||||
static int tileCount(int size){
|
||||
return 10 * Mathf.pow(3, size) + 2;
|
||||
}
|
||||
|
||||
@@ -220,12 +221,12 @@ public class PlanetGrid{
|
||||
}
|
||||
|
||||
public static class Ptile{
|
||||
public final int id;
|
||||
public final int edgeCount;
|
||||
public int id;
|
||||
public int edgeCount;
|
||||
|
||||
public final Ptile[] tiles;
|
||||
public final Corner[] corners;
|
||||
public final Edge[] edges;
|
||||
public Ptile[] tiles;
|
||||
public Corner[] corners;
|
||||
public Edge[] edges;
|
||||
|
||||
public Vec3 v = new Vec3();
|
||||
|
||||
@@ -240,11 +241,11 @@ public class PlanetGrid{
|
||||
}
|
||||
|
||||
public static class Corner{
|
||||
public final int id;
|
||||
public final Ptile[] tiles = new Ptile[3];
|
||||
public final Corner[] corners = new Corner[3];
|
||||
public final Edge[] edges = new Edge[3];
|
||||
public final Vec3 v = new Vec3();
|
||||
public int id;
|
||||
public Ptile[] tiles = new Ptile[3];
|
||||
public Corner[] corners = new Corner[3];
|
||||
public Edge[] edges = new Edge[3];
|
||||
public Vec3 v = new Vec3();
|
||||
|
||||
public Corner(int id){
|
||||
this.id = id;
|
||||
@@ -252,9 +253,9 @@ public class PlanetGrid{
|
||||
}
|
||||
|
||||
public static class Edge{
|
||||
public final int id;
|
||||
public final Ptile[] tiles = new Ptile[2];
|
||||
public final Corner[] corners = new Corner[2];
|
||||
public int id;
|
||||
public Ptile[] tiles = new Ptile[2];
|
||||
public Corner[] corners = new Corner[2];
|
||||
|
||||
public Edge(int id){
|
||||
this.id = id;
|
||||
|
||||
@@ -10,6 +10,7 @@ import arc.math.geom.*;
|
||||
import arc.struct.*;
|
||||
import arc.util.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.game.EventType.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.graphics.g3d.PlanetGrid.*;
|
||||
import mindustry.type.*;
|
||||
@@ -38,19 +39,19 @@ public class PlanetRenderer implements Disposable{
|
||||
public float zoom = 1f;
|
||||
|
||||
private final Mesh[] outlines = new Mesh[10];
|
||||
private final PlaneBatch3D projector = new PlaneBatch3D();
|
||||
private final Mat3D mat = new Mat3D();
|
||||
private final FrameBuffer buffer = new FrameBuffer(2, 2, true);
|
||||
private PlanetInterfaceRenderer irenderer;
|
||||
public final PlaneBatch3D projector = new PlaneBatch3D();
|
||||
public final Mat3D mat = new Mat3D();
|
||||
public final FrameBuffer buffer = new FrameBuffer(2, 2, true);
|
||||
public PlanetInterfaceRenderer irenderer;
|
||||
|
||||
private final Bloom bloom = new Bloom(Core.graphics.getWidth()/4, Core.graphics.getHeight()/4, true, false){{
|
||||
public final Bloom bloom = new Bloom(Core.graphics.getWidth()/4, Core.graphics.getHeight()/4, true, false){{
|
||||
setThreshold(0.8f);
|
||||
blurPasses = 6;
|
||||
}};
|
||||
private final Mesh atmosphere = MeshBuilder.buildHex(Color.white, 2, false, 1.5f);
|
||||
public final Mesh atmosphere = MeshBuilder.buildHex(Color.white, 2, false, 1.5f);
|
||||
|
||||
//seed: 8kmfuix03fw
|
||||
private final CubemapMesh skybox = new CubemapMesh(new Cubemap("cubemaps/stars/"));
|
||||
public final CubemapMesh skybox = new CubemapMesh(new Cubemap("cubemaps/stars/"));
|
||||
|
||||
public PlanetRenderer(){
|
||||
camPos.set(0, 0f, camLength);
|
||||
@@ -82,14 +83,20 @@ public class PlanetRenderer implements Disposable{
|
||||
projector.proj(cam.combined);
|
||||
batch.proj(cam.combined);
|
||||
|
||||
Events.fire(Trigger.universeDrawBegin);
|
||||
|
||||
beginBloom();
|
||||
|
||||
skybox.render(cam.combined);
|
||||
|
||||
Events.fire(Trigger.universeDraw);
|
||||
|
||||
renderPlanet(solarSystem);
|
||||
|
||||
endBloom();
|
||||
|
||||
Events.fire(Trigger.universeDrawEnd);
|
||||
|
||||
Gl.enable(Gl.blend);
|
||||
|
||||
irenderer.renderProjections();
|
||||
@@ -100,18 +107,19 @@ public class PlanetRenderer implements Disposable{
|
||||
cam.update();
|
||||
}
|
||||
|
||||
private void beginBloom(){
|
||||
public void beginBloom(){
|
||||
bloom.resize(Core.graphics.getWidth() / 4, Core.graphics.getHeight() / 4);
|
||||
bloom.capture();
|
||||
}
|
||||
|
||||
private void endBloom(){
|
||||
public void endBloom(){
|
||||
bloom.render();
|
||||
}
|
||||
|
||||
private void renderPlanet(Planet planet){
|
||||
if(!planet.visible()) return;
|
||||
|
||||
public void renderPlanet(Planet planet){
|
||||
if(!planet.visible()) return;
|
||||
|
||||
//render planet at offsetted position in the world
|
||||
planet.draw(cam.combined, planet.getTransform(mat));
|
||||
|
||||
@@ -139,7 +147,7 @@ public class PlanetRenderer implements Disposable{
|
||||
}
|
||||
}
|
||||
|
||||
private void renderOrbit(Planet planet){
|
||||
public void renderOrbit(Planet planet){
|
||||
if(planet.parent == null || !planet.visible()) return;
|
||||
|
||||
Vec3 center = planet.parent.position;
|
||||
@@ -149,7 +157,7 @@ public class PlanetRenderer implements Disposable{
|
||||
batch.flush(Gl.lineLoop);
|
||||
}
|
||||
|
||||
private void renderSectors(Planet planet){
|
||||
public void renderSectors(Planet planet){
|
||||
//apply transformed position
|
||||
batch.proj().mul(planet.getTransform(mat));
|
||||
|
||||
@@ -270,7 +278,7 @@ public class PlanetRenderer implements Disposable{
|
||||
}
|
||||
}
|
||||
|
||||
private Mesh outline(int size){
|
||||
public Mesh outline(int size){
|
||||
if(outlines[size] == null){
|
||||
outlines[size] = MeshBuilder.buildHex(new HexMesher(){
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user