Fixed shadow rendering
This commit is contained in:
@@ -1,9 +1,11 @@
|
|||||||
package io.anuke.mindustry.graphics;
|
package io.anuke.mindustry.graphics;
|
||||||
|
|
||||||
|
import io.anuke.arc.Core;
|
||||||
import io.anuke.arc.Events;
|
import io.anuke.arc.Events;
|
||||||
import io.anuke.arc.collection.Array;
|
import io.anuke.arc.collection.Array;
|
||||||
import io.anuke.arc.collection.IntSet;
|
import io.anuke.arc.collection.IntSet;
|
||||||
import io.anuke.arc.collection.Sort;
|
import io.anuke.arc.collection.Sort;
|
||||||
|
import io.anuke.arc.graphics.Color;
|
||||||
import io.anuke.arc.graphics.g2d.Draw;
|
import io.anuke.arc.graphics.g2d.Draw;
|
||||||
import io.anuke.arc.graphics.glutils.FrameBuffer;
|
import io.anuke.arc.graphics.glutils.FrameBuffer;
|
||||||
import io.anuke.arc.math.Mathf;
|
import io.anuke.arc.math.Mathf;
|
||||||
@@ -27,7 +29,6 @@ public class BlockRenderer{
|
|||||||
private Array<BlockRequest> requests = new Array<>(true, initialRequests, BlockRequest.class);
|
private Array<BlockRequest> requests = new Array<>(true, initialRequests, BlockRequest.class);
|
||||||
private IntSet teamChecks = new IntSet();
|
private IntSet teamChecks = new IntSet();
|
||||||
private int lastCamX, lastCamY, lastRangeX, lastRangeY;
|
private int lastCamX, lastCamY, lastRangeX, lastRangeY;
|
||||||
private Layer lastLayer;
|
|
||||||
private int requestidx = 0;
|
private int requestidx = 0;
|
||||||
private int iterateidx = 0;
|
private int iterateidx = 0;
|
||||||
private FrameBuffer shadows = new FrameBuffer(1, 1);
|
private FrameBuffer shadows = new FrameBuffer(1, 1);
|
||||||
@@ -71,7 +72,6 @@ public class BlockRenderer{
|
|||||||
/**Process all blocks to draw, simultaneously updating the block shadow framebuffer.*/
|
/**Process all blocks to draw, simultaneously updating the block shadow framebuffer.*/
|
||||||
public void processBlocks(){
|
public void processBlocks(){
|
||||||
iterateidx = 0;
|
iterateidx = 0;
|
||||||
lastLayer = null;
|
|
||||||
|
|
||||||
int avgx = (int)(camera.position.x / tilesize);
|
int avgx = (int)(camera.position.x / tilesize);
|
||||||
int avgy = (int)(camera.position.y / tilesize);
|
int avgy = (int)(camera.position.y / tilesize);
|
||||||
@@ -89,8 +89,7 @@ public class BlockRenderer{
|
|||||||
requestidx = 0;
|
requestidx = 0;
|
||||||
|
|
||||||
Draw.flush();
|
Draw.flush();
|
||||||
Draw.proj()
|
Draw.proj().setOrtho(Mathf.round(camera.position.x, tilesize)-shadowW/2f, Mathf.round(camera.position.y, tilesize)-shadowH/2f,
|
||||||
.setOrtho(Mathf.round(camera.position.x, tilesize)-shadowW/2f, Mathf.round(camera.position.y, tilesize)-shadowH/2f,
|
|
||||||
shadowW, shadowH);
|
shadowW, shadowH);
|
||||||
|
|
||||||
if(shadows.getWidth() != shadowW || shadows.getHeight() != shadowH){
|
if(shadows.getWidth() != shadowW || shadows.getHeight() != shadowH){
|
||||||
@@ -98,6 +97,7 @@ public class BlockRenderer{
|
|||||||
}
|
}
|
||||||
|
|
||||||
shadows.begin();
|
shadows.begin();
|
||||||
|
Core.graphics.clear(Color.CLEAR);
|
||||||
|
|
||||||
int minx = Math.max(avgx - rangex - expandr, 0);
|
int minx = Math.max(avgx - rangex - expandr, 0);
|
||||||
int miny = Math.max(avgy - rangey - expandr, 0);
|
int miny = Math.max(avgy - rangey - expandr, 0);
|
||||||
@@ -137,9 +137,9 @@ public class BlockRenderer{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Draw.flush();
|
||||||
shadows.end();
|
shadows.end();
|
||||||
|
|
||||||
Draw.flush();
|
|
||||||
Draw.proj(camera.projection());
|
Draw.proj(camera.projection());
|
||||||
|
|
||||||
Sort.instance().sort(requests.items, 0, requestidx);
|
Sort.instance().sort(requests.items, 0, requestidx);
|
||||||
@@ -172,8 +172,6 @@ public class BlockRenderer{
|
|||||||
}else if(req.layer == block.layer2){
|
}else if(req.layer == block.layer2){
|
||||||
block.drawLayer2(req.tile);
|
block.drawLayer2(req.tile);
|
||||||
}
|
}
|
||||||
|
|
||||||
lastLayer = req.layer;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -135,6 +135,7 @@ public abstract class Turret extends Block{
|
|||||||
Draw.rect(baseRegion, tile.drawx(), tile.drawy());
|
Draw.rect(baseRegion, tile.drawx(), tile.drawy());
|
||||||
Draw.color(tile.getTeam().color, Color.WHITE, 0.45f);
|
Draw.color(tile.getTeam().color, Color.WHITE, 0.45f);
|
||||||
Draw.rect(baseTopRegion, tile.drawx(), tile.drawy());
|
Draw.rect(baseTopRegion, tile.drawx(), tile.drawy());
|
||||||
|
Draw.color();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -177,6 +178,7 @@ public abstract class Turret extends Block{
|
|||||||
public void drawPlace(int x, int y, int rotation, boolean valid){
|
public void drawPlace(int x, int y, int rotation, boolean valid){
|
||||||
Lines.stroke(1f, Palette.placing);
|
Lines.stroke(1f, Palette.placing);
|
||||||
Lines.dashCircle(x * tilesize + offset(), y * tilesize + offset(), range);
|
Lines.dashCircle(x * tilesize + offset(), y * tilesize + offset(), range);
|
||||||
|
Draw.color();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user