Fixed #5369
This commit is contained in:
@@ -201,6 +201,7 @@ public class Renderer implements ApplicationListener{
|
|||||||
|
|
||||||
Draw.proj(camera);
|
Draw.proj(camera);
|
||||||
|
|
||||||
|
blocks.checkChanges();
|
||||||
blocks.floor.checkChanges();
|
blocks.floor.checkChanges();
|
||||||
blocks.processBlocks();
|
blocks.processBlocks();
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ import mindustry.content.*;
|
|||||||
import mindustry.game.EventType.*;
|
import mindustry.game.EventType.*;
|
||||||
import mindustry.game.Teams.*;
|
import mindustry.game.Teams.*;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.ui.*;
|
|
||||||
import mindustry.world.*;
|
import mindustry.world.*;
|
||||||
import mindustry.world.blocks.power.*;
|
import mindustry.world.blocks.power.*;
|
||||||
|
|
||||||
@@ -142,11 +141,21 @@ public class BlockRenderer{
|
|||||||
Tile other = world.tile(cx, cy);
|
Tile other = world.tile(cx, cy);
|
||||||
if(other != null){
|
if(other != null){
|
||||||
darkEvents.add(other.pos());
|
darkEvents.add(other.pos());
|
||||||
|
floor.recacheTile(other);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void checkChanges(){
|
||||||
|
darkEvents.each(pos -> {
|
||||||
|
var tile = world.tile(pos);
|
||||||
|
if(tile != null){
|
||||||
|
tile.data = world.getWallDarkness(tile);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public void drawDarkness(){
|
public void drawDarkness(){
|
||||||
if(!darkEvents.isEmpty()){
|
if(!darkEvents.isEmpty()){
|
||||||
Draw.flush();
|
Draw.flush();
|
||||||
@@ -156,10 +165,9 @@ public class BlockRenderer{
|
|||||||
|
|
||||||
darkEvents.each(pos -> {
|
darkEvents.each(pos -> {
|
||||||
var tile = world.tile(pos);
|
var tile = world.tile(pos);
|
||||||
tile.data = world.getWallDarkness(tile);
|
|
||||||
float darkness = world.getDarkness(tile.x, tile.y);
|
float darkness = world.getDarkness(tile.x, tile.y);
|
||||||
//then draw the shadow
|
//then draw the shadow
|
||||||
Draw.colorl(!tile.isDarkened() || darkness <= 0f ? 1f : 1f - Math.min((darkness + 0.5f) / 4f, 1f));
|
Draw.colorl(darkness <= 0f ? 1f : 1f - Math.min((darkness + 0.5f) / 4f, 1f));
|
||||||
Fill.rect(tile.x + 0.5f, tile.y + 0.5f, 1, 1);
|
Fill.rect(tile.x + 0.5f, tile.y + 0.5f, 1, 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -97,7 +97,6 @@ public class FloorRenderer{
|
|||||||
|
|
||||||
/** Queues up a cache change for a tile. Only runs in render loop. */
|
/** Queues up a cache change for a tile. Only runs in render loop. */
|
||||||
public void recacheTile(Tile tile){
|
public void recacheTile(Tile tile){
|
||||||
//TODO will be faster it the position also specified the layer to be recached
|
|
||||||
//recaching all layers may not be necessary
|
//recaching all layers may not be necessary
|
||||||
recacheSet.add(Point2.pack(tile.x / chunksize, tile.y / chunksize));
|
recacheSet.add(Point2.pack(tile.x / chunksize, tile.y / chunksize));
|
||||||
}
|
}
|
||||||
@@ -168,7 +167,6 @@ public class FloorRenderer{
|
|||||||
shader.setUniformi("u_texture", 0);
|
shader.setUniformi("u_texture", 0);
|
||||||
|
|
||||||
//only ever use the base environment texture
|
//only ever use the base environment texture
|
||||||
//TODO show error texture for anything else
|
|
||||||
texture.bind(0);
|
texture.bind(0);
|
||||||
|
|
||||||
//enable all mesh attributes
|
//enable all mesh attributes
|
||||||
|
|||||||
Reference in New Issue
Block a user