WIP unification and cleanup of rendering in editor
This commit is contained in:
BIN
core/assets-raw/sprites/blocks/environment/clear-editor.png
Normal file
BIN
core/assets-raw/sprites/blocks/environment/clear-editor.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 91 B |
Binary file not shown.
|
Before Width: | Height: | Size: 146 B |
Binary file not shown.
|
Before Width: | Height: | Size: 68 B |
@@ -1,9 +0,0 @@
|
||||
{
|
||||
duplicatePadding: true,
|
||||
combineSubdirectories: true,
|
||||
flattenPaths: true,
|
||||
maxWidth: 2048,
|
||||
maxHeight: 2048,
|
||||
fast: true,
|
||||
stripWhitespaceCenter: true
|
||||
}
|
||||
@@ -40,7 +40,7 @@ public class Renderer implements ApplicationListener{
|
||||
public @Nullable Bloom bloom;
|
||||
public @Nullable FrameBuffer backgroundBuffer;
|
||||
public FrameBuffer effectBuffer = new FrameBuffer();
|
||||
public boolean animateShields, drawWeather = true, drawStatus, enableEffects, drawDisplays = true, drawLight = true, pixelate = false;
|
||||
public boolean animateShields, animateWater, drawWeather = true, drawStatus, enableEffects, drawDisplays = true, drawLight = true, pixelate = false;
|
||||
public float weatherAlpha;
|
||||
/** minZoom = zooming out, maxZoom = zooming in, used by cutscenes */
|
||||
public float minZoom = 1.5f, maxZoom = 6f;
|
||||
@@ -167,6 +167,7 @@ public class Renderer implements ApplicationListener{
|
||||
laserOpacity = settings.getInt("lasersopacity") / 100f;
|
||||
bridgeOpacity = settings.getInt("bridgeopacity") / 100f;
|
||||
animateShields = settings.getBool("animatedshields");
|
||||
animateWater = settings.getBool("animatewater");
|
||||
drawStatus = settings.getBool("blockstatus");
|
||||
enableEffects = settings.getBool("effects");
|
||||
drawDisplays = !settings.getBool("hidedisplays");
|
||||
@@ -310,7 +311,7 @@ public class Renderer implements ApplicationListener{
|
||||
graphics.clear(clearColor);
|
||||
Draw.reset();
|
||||
|
||||
if(settings.getBool("animatedwater") || animateShields){
|
||||
if(animateWater || animateShields){
|
||||
effectBuffer.resize(graphics.getWidth(), graphics.getHeight());
|
||||
}
|
||||
|
||||
|
||||
@@ -66,10 +66,11 @@ public class EditorTile extends Tile{
|
||||
if(build != null) op(DrawOperation.opRotation, (byte)build.rotation);
|
||||
if(build != null) op(DrawOperation.opTeam, (byte)build.team.id);
|
||||
op(DrawOperation.opBlock, block.id);
|
||||
|
||||
}
|
||||
|
||||
super.setBlock(type, team, rotation, entityprov);
|
||||
|
||||
renderer.blocks.updateShadowTile(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -153,6 +154,11 @@ public class EditorTile extends Tile{
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDarkened(){
|
||||
return skip() && super.isDarkened();
|
||||
}
|
||||
|
||||
private void update(){
|
||||
editor.renderer.updatePoint(x, y);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ import arc.math.*;
|
||||
import arc.struct.*;
|
||||
import arc.util.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.game.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.environment.*;
|
||||
@@ -15,7 +14,7 @@ import mindustry.world.blocks.environment.*;
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class MapRenderer implements Disposable{
|
||||
private static final int chunkSize = 64;
|
||||
private static final int chunkSize = 62;
|
||||
private IndexedRenderer[][] chunks;
|
||||
private IntSet updates = new IntSet();
|
||||
private IntSet delayedUpdates = new IntSet();
|
||||
@@ -43,10 +42,56 @@ public class MapRenderer implements Disposable{
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
updateAll();
|
||||
|
||||
renderer.blocks.floor.clearTiles();
|
||||
renderer.blocks.reload();
|
||||
}
|
||||
|
||||
public void draw(float tx, float ty, float tw, float th){
|
||||
public void draw(float tx, float ty, float tw, float th, float zoom){
|
||||
Draw.flush();
|
||||
|
||||
//TODO properly integrate this later
|
||||
if(true){
|
||||
updates.each(i -> renderer.blocks.floor.recacheTile(i % width, i / width));
|
||||
updates.clear();
|
||||
|
||||
updates.addAll(delayedUpdates);
|
||||
delayedUpdates.clear();
|
||||
|
||||
renderer.blocks.floor.checkChanges();
|
||||
|
||||
boolean prev = renderer.animateWater;
|
||||
renderer.animateWater = false;
|
||||
|
||||
Core.camera.position.set(world.width()/2f * tilesize, world.height()/2f * tilesize);
|
||||
Core.camera.width = 999999f;
|
||||
Core.camera.height = 999999f;
|
||||
Core.camera.mat.set(Draw.proj()).mul(Tmp.m3.setToTranslation(tx, ty).scale(tw / (width * tilesize), th / (height * tilesize)).translate(4f, 4f));
|
||||
renderer.blocks.floor.drawFloor();
|
||||
|
||||
Tmp.m2.set(Draw.proj());
|
||||
|
||||
//this sure is awful!
|
||||
Gl.disable(Gl.scissorTest);
|
||||
|
||||
renderer.blocks.processShadows();
|
||||
|
||||
Gl.enable(Gl.scissorTest);
|
||||
|
||||
Draw.proj(Core.camera.mat);
|
||||
|
||||
Draw.shader(Shaders.darkness);
|
||||
Draw.rect(Draw.wrap(renderer.blocks.getShadowBuffer().getTexture()), world.width() * tilesize/2f - tilesize/2f, world.height() * tilesize/2f - tilesize/2f, world.width() * tilesize, -world.height() * tilesize);
|
||||
Draw.shader();
|
||||
|
||||
Draw.proj(Tmp.m2);
|
||||
|
||||
renderer.blocks.floor.beginDraw();
|
||||
renderer.blocks.floor.drawLayer(CacheLayer.walls);
|
||||
renderer.animateWater = prev;
|
||||
return;
|
||||
}
|
||||
|
||||
clearEditor = Core.atlas.find("clear-editor");
|
||||
|
||||
updates.each(i -> render(i % width, i / width));
|
||||
@@ -60,7 +105,7 @@ public class MapRenderer implements Disposable{
|
||||
return;
|
||||
}
|
||||
|
||||
var texture = Core.atlas.find("clear-editor").texture;
|
||||
var texture = clearEditor.texture;
|
||||
|
||||
for(int x = 0; x < chunks.length; x++){
|
||||
for(int y = 0; y < chunks[0].length; y++){
|
||||
@@ -92,10 +137,10 @@ public class MapRenderer implements Disposable{
|
||||
}
|
||||
|
||||
private TextureRegion getIcon(Block wall, int index){
|
||||
return !wall.editorIcon().found() ?
|
||||
return !wall.fullIcon.found() ?
|
||||
clearEditor : wall.variants > 0 ?
|
||||
wall.editorVariantRegions()[Mathf.randomSeed(index, 0, wall.editorVariantRegions().length - 1)] :
|
||||
wall.editorIcon();
|
||||
wall.variantRegions()[Mathf.randomSeed(index, 0, wall.variantRegions().length - 1)] :
|
||||
wall.fullIcon;
|
||||
}
|
||||
|
||||
private void render(int wx, int wy){
|
||||
@@ -104,7 +149,6 @@ public class MapRenderer implements Disposable{
|
||||
IndexedRenderer mesh = chunks[x][y];
|
||||
Tile tile = editor.tiles().getn(wx, wy);
|
||||
|
||||
Team team = tile.team();
|
||||
Floor floor = tile.floor();
|
||||
Floor overlay = tile.overlay();
|
||||
Block wall = tile.block();
|
||||
@@ -113,12 +157,11 @@ public class MapRenderer implements Disposable{
|
||||
|
||||
int idxWall = (wx % chunkSize) + (wy % chunkSize) * chunkSize;
|
||||
int idxDecal = (wx % chunkSize) + (wy % chunkSize) * chunkSize + chunkSize * chunkSize;
|
||||
boolean center = tile.isCenter();
|
||||
boolean useSyntheticWall = wall.synthetic() || overlay.wallOre;
|
||||
boolean useSyntheticWall = overlay.wallOre;
|
||||
|
||||
//draw synthetic wall or floor OR standard wall if wall ore
|
||||
if(wall != Blocks.air && useSyntheticWall){
|
||||
region = !center ? clearEditor : getIcon(wall, idxWall);
|
||||
region = getIcon(wall, idxWall);
|
||||
|
||||
float width = region.width * region.scl(), height = region.height * region.scl(), ox = wall.offset + (tilesize - width) / 2f, oy = wall.offset + (tilesize - height) / 2f;
|
||||
|
||||
@@ -138,7 +181,7 @@ public class MapRenderer implements Disposable{
|
||||
mesh.setColor(Tmp.c1.set(tile.extraData | 0xff));
|
||||
}
|
||||
|
||||
region = floor.editorVariantRegions()[Mathf.randomSeed(idxWall, 0, floor.editorVariantRegions().length - 1)];
|
||||
region = floor.variantRegions()[Mathf.randomSeed(idxWall, 0, floor.variantRegions().length - 1)];
|
||||
|
||||
mesh.draw(idxWall, region, wx * tilesize, wy * tilesize, 8, 8);
|
||||
}
|
||||
@@ -146,14 +189,7 @@ public class MapRenderer implements Disposable{
|
||||
float offsetX = -((wall.size + 1) / 3) * tilesize, offsetY = -((wall.size + 1) / 3) * tilesize;
|
||||
|
||||
//draw non-synthetic wall or ore
|
||||
if((wall.update || wall.destructible) && center){
|
||||
mesh.setColor(team.color);
|
||||
region = Core.atlas.find("block-border-editor");
|
||||
if(wall.size == 2){
|
||||
offsetX += tilesize;
|
||||
offsetY += tilesize;
|
||||
}
|
||||
}else if(!useSyntheticWall && wall != Blocks.air && center){
|
||||
if(!(wall.update || wall.destructible) && !useSyntheticWall && wall != Blocks.air){
|
||||
region = getIcon(wall, idxWall);
|
||||
|
||||
if(wall == Blocks.cliff){
|
||||
@@ -169,7 +205,7 @@ public class MapRenderer implements Disposable{
|
||||
if(floor.isLiquid){
|
||||
mesh.setColor(Tmp.c1.set(1f, 1f, 1f, floor.overlayAlpha));
|
||||
}
|
||||
region = overlay.editorVariantRegions()[Mathf.randomSeed(idxWall, 0, tile.overlay().editorVariantRegions().length - 1)];
|
||||
region = overlay.variantRegions()[Mathf.randomSeed(idxWall, 0, tile.overlay().variantRegions().length - 1)];
|
||||
}else{
|
||||
region = clearEditor;
|
||||
}
|
||||
|
||||
@@ -248,7 +248,7 @@ public class MapView extends Element implements GestureListener{
|
||||
Draw.color(Pal.remove);
|
||||
Lines.stroke(2f);
|
||||
Lines.rect(centerx - sclwidth / 2 - 1, centery - sclheight / 2 - 1, sclwidth + 2, sclheight + 2);
|
||||
editor.renderer.draw(centerx - sclwidth / 2 + Core.scene.marginLeft, centery - sclheight / 2 + Core.scene.marginBottom, sclwidth, sclheight);
|
||||
editor.renderer.draw(centerx - sclwidth / 2 + Core.scene.marginLeft, centery - sclheight / 2 + Core.scene.marginBottom, sclwidth, sclheight, zoom);
|
||||
Draw.reset();
|
||||
|
||||
if(grid){
|
||||
|
||||
@@ -64,48 +64,7 @@ public class BlockRenderer{
|
||||
});
|
||||
|
||||
Events.on(WorldLoadEvent.class, event -> {
|
||||
blockTree = new BlockQuadtree(new Rect(0, 0, world.unitWidth(), world.unitHeight()));
|
||||
blockLightTree = new BlockLightQuadtree(new Rect(0, 0, world.unitWidth(), world.unitHeight()));
|
||||
floorTree = new FloorQuadtree(new Rect(0, 0, world.unitWidth(), world.unitHeight()));
|
||||
|
||||
shadowEvents.clear();
|
||||
updateFloors.clear();
|
||||
lastCamY = lastCamX = -99; //invalidate camera position so blocks get updated
|
||||
hadMapLimit = state.rules.limitMapArea;
|
||||
|
||||
shadows.getTexture().setFilter(TextureFilter.linear, TextureFilter.linear);
|
||||
shadows.resize(world.width(), world.height());
|
||||
shadows.begin();
|
||||
Core.graphics.clear(Color.white);
|
||||
Draw.proj().setOrtho(0, 0, shadows.getWidth(), shadows.getHeight());
|
||||
|
||||
Draw.color(blendShadowColor);
|
||||
|
||||
for(Tile tile : world.tiles){
|
||||
recordIndex(tile);
|
||||
|
||||
if(tile.floor().updateRender(tile)){
|
||||
updateFloors.add(new UpdateRenderState(tile, tile.floor()));
|
||||
}
|
||||
|
||||
if(tile.overlay().updateRender(tile)){
|
||||
updateFloors.add(new UpdateRenderState(tile, tile.overlay()));
|
||||
}
|
||||
|
||||
if(tile.build != null && (tile.team() == player.team() || !state.rules.fog || (tile.build.visibleFlags & (1L << player.team().id)) != 0)){
|
||||
tile.build.wasVisible = true;
|
||||
}
|
||||
|
||||
if(tile.block().displayShadow(tile) && (tile.build == null || tile.build.wasVisible)){
|
||||
Fill.rect(tile.x + 0.5f, tile.y + 0.5f, 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
Draw.flush();
|
||||
Draw.color();
|
||||
shadows.end();
|
||||
|
||||
updateDarkness();
|
||||
reload();
|
||||
});
|
||||
|
||||
//sometimes darkness gets disabled.
|
||||
@@ -150,6 +109,51 @@ public class BlockRenderer{
|
||||
});
|
||||
}
|
||||
|
||||
public void reload(){
|
||||
blockTree = new BlockQuadtree(new Rect(0, 0, world.unitWidth(), world.unitHeight()));
|
||||
blockLightTree = new BlockLightQuadtree(new Rect(0, 0, world.unitWidth(), world.unitHeight()));
|
||||
floorTree = new FloorQuadtree(new Rect(0, 0, world.unitWidth(), world.unitHeight()));
|
||||
|
||||
shadowEvents.clear();
|
||||
updateFloors.clear();
|
||||
lastCamY = lastCamX = -99; //invalidate camera position so blocks get updated
|
||||
hadMapLimit = state.rules.limitMapArea;
|
||||
|
||||
shadows.getTexture().setFilter(TextureFilter.linear, TextureFilter.linear);
|
||||
shadows.resize(world.width(), world.height());
|
||||
shadows.begin();
|
||||
Core.graphics.clear(Color.white);
|
||||
Draw.proj().setOrtho(0, 0, shadows.getWidth(), shadows.getHeight());
|
||||
|
||||
Draw.color(blendShadowColor);
|
||||
|
||||
for(Tile tile : world.tiles){
|
||||
recordIndex(tile);
|
||||
|
||||
if(tile.floor().updateRender(tile)){
|
||||
updateFloors.add(new UpdateRenderState(tile, tile.floor()));
|
||||
}
|
||||
|
||||
if(tile.overlay().updateRender(tile)){
|
||||
updateFloors.add(new UpdateRenderState(tile, tile.overlay()));
|
||||
}
|
||||
|
||||
if(tile.build != null && (tile.team() == player.team() || !state.rules.fog || (tile.build.visibleFlags & (1L << player.team().id)) != 0)){
|
||||
tile.build.wasVisible = true;
|
||||
}
|
||||
|
||||
if(tile.block().displayShadow(tile) && (tile.build == null || tile.build.wasVisible)){
|
||||
Fill.rect(tile.x + 0.5f, tile.y + 0.5f, 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
Draw.flush();
|
||||
Draw.color();
|
||||
shadows.end();
|
||||
|
||||
updateDarkness();
|
||||
}
|
||||
|
||||
public void updateDarkness(){
|
||||
darkEvents.clear();
|
||||
dark.getTexture().setFilter(TextureFilter.linear);
|
||||
@@ -197,6 +201,10 @@ public class BlockRenderer{
|
||||
}
|
||||
}
|
||||
|
||||
public FrameBuffer getShadowBuffer(){
|
||||
return shadows;
|
||||
}
|
||||
|
||||
public void removeFloorIndex(Tile tile){
|
||||
if(indexFloor(tile)) floorTree.remove(tile);
|
||||
}
|
||||
@@ -294,7 +302,7 @@ public class BlockRenderer{
|
||||
}
|
||||
}
|
||||
|
||||
public void drawShadows(){
|
||||
public void processShadows(){
|
||||
if(!shadowEvents.isEmpty()){
|
||||
Draw.flush();
|
||||
|
||||
@@ -315,6 +323,10 @@ public class BlockRenderer{
|
||||
|
||||
Draw.proj(camera);
|
||||
}
|
||||
}
|
||||
|
||||
public void drawShadows(){
|
||||
processShadows();
|
||||
|
||||
float ww = world.width() * tilesize, wh = world.height() * tilesize;
|
||||
float x = camera.position.x + tilesize / 2f, y = camera.position.y + tilesize / 2f;
|
||||
@@ -511,6 +523,10 @@ public class BlockRenderer{
|
||||
}
|
||||
}
|
||||
|
||||
public void updateShadowTile(Tile tile){
|
||||
shadowEvents.add(tile);
|
||||
}
|
||||
|
||||
static class BlockQuadtree extends QuadTree<Tile>{
|
||||
|
||||
public BlockQuadtree(Rect bounds){
|
||||
|
||||
@@ -97,7 +97,7 @@ public class CacheLayer{
|
||||
|
||||
@Override
|
||||
public void begin(){
|
||||
if(!Core.settings.getBool("animatedwater")) return;
|
||||
if(!renderer.animateWater) return;
|
||||
|
||||
renderer.effectBuffer.begin();
|
||||
Core.graphics.clear(Color.clear);
|
||||
@@ -106,7 +106,7 @@ public class CacheLayer{
|
||||
|
||||
@Override
|
||||
public void end(){
|
||||
if(!Core.settings.getBool("animatedwater")) return;
|
||||
if(!renderer.animateWater) return;
|
||||
|
||||
renderer.effectBuffer.end();
|
||||
renderer.effectBuffer.blit(shader);
|
||||
|
||||
@@ -111,10 +111,17 @@ public class FloorRenderer{
|
||||
Events.on(WorldLoadEvent.class, event -> clearTiles());
|
||||
}
|
||||
|
||||
public IndexData getIndexData(){
|
||||
return indexData;
|
||||
}
|
||||
|
||||
/** Queues up a cache change for a tile. Only runs in render loop. */
|
||||
public void recacheTile(Tile tile){
|
||||
//recaching all layers may not be necessary
|
||||
recacheSet.add(Point2.pack(tile.x / chunksize, tile.y / chunksize));
|
||||
recacheTile(tile.x, tile.y);
|
||||
}
|
||||
|
||||
public void recacheTile(int x, int y){
|
||||
recacheSet.add(Point2.pack(x / chunksize, y / chunksize));
|
||||
}
|
||||
|
||||
public void drawFloor(){
|
||||
@@ -127,10 +134,10 @@ public class FloorRenderer{
|
||||
float pad = tilesize/2f;
|
||||
|
||||
int
|
||||
minx = (int)((camera.position.x - camera.width/2f - pad) / chunkunits),
|
||||
miny = (int)((camera.position.y - camera.height/2f - pad) / chunkunits),
|
||||
maxx = Mathf.ceil((camera.position.x + camera.width/2f + pad) / chunkunits),
|
||||
maxy = Mathf.ceil((camera.position.y + camera.height/2f + pad) / chunkunits);
|
||||
minx = Math.max((int)((camera.position.x - camera.width/2f - pad) / chunkunits), 0),
|
||||
miny = Math.max((int)((camera.position.y - camera.height/2f - pad) / chunkunits), 0),
|
||||
maxx = Math.min(Mathf.ceil((camera.position.x + camera.width/2f + pad) / chunkunits), cache.length),
|
||||
maxy = Math.min(Mathf.ceil((camera.position.y + camera.height/2f + pad) / chunkunits), cache[0].length);
|
||||
|
||||
int layers = CacheLayer.all.length;
|
||||
|
||||
@@ -221,10 +228,10 @@ public class FloorRenderer{
|
||||
Camera camera = Core.camera;
|
||||
|
||||
int
|
||||
minx = (int)((camera.position.x - camera.width/2f - pad) / chunkunits),
|
||||
miny = (int)((camera.position.y - camera.height/2f - pad) / chunkunits),
|
||||
maxx = Mathf.ceil((camera.position.x + camera.width/2f + pad) / chunkunits),
|
||||
maxy = Mathf.ceil((camera.position.y + camera.height/2f + pad) / chunkunits);
|
||||
minx = Math.max((int)((camera.position.x - camera.width/2f - pad) / chunkunits), 0),
|
||||
miny = Math.max((int)((camera.position.y - camera.height/2f - pad) / chunkunits), 0),
|
||||
maxx = Math.min(Mathf.ceil((camera.position.x + camera.width/2f + pad) / chunkunits), cache.length),
|
||||
maxy = Math.min(Mathf.ceil((camera.position.y + camera.height/2f + pad) / chunkunits), cache[0].length);
|
||||
|
||||
layer.begin();
|
||||
|
||||
|
||||
@@ -5,6 +5,9 @@ import arc.graphics.g2d.*;
|
||||
import arc.graphics.gl.*;
|
||||
import arc.math.*;
|
||||
import arc.util.*;
|
||||
import mindustry.*;
|
||||
|
||||
import java.nio.*;
|
||||
|
||||
public class IndexedRenderer implements Disposable{
|
||||
private static final int vsize = 5;
|
||||
@@ -34,9 +37,10 @@ public class IndexedRenderer implements Disposable{
|
||||
}
|
||||
"""
|
||||
);
|
||||
private static final float[] tmpVerts = new float[vsize * 6];
|
||||
private static final float[] tmpVerts = new float[vsize * 4];
|
||||
|
||||
private Mesh mesh;
|
||||
private FloatBuffer buffer;
|
||||
|
||||
private Mat projMatrix = new Mat();
|
||||
private Mat transMatrix = new Mat();
|
||||
@@ -57,7 +61,7 @@ public class IndexedRenderer implements Disposable{
|
||||
|
||||
program.setUniformMatrix4("u_projTrans", combined);
|
||||
|
||||
mesh.render(program, Gl.triangles, 0, mesh.getMaxVertices());
|
||||
mesh.render(program, Gl.triangles, 0, mesh.getMaxVertices() * 6 / 4);
|
||||
}
|
||||
|
||||
public void setColor(Color color){
|
||||
@@ -94,26 +98,19 @@ public class IndexedRenderer implements Disposable{
|
||||
vertices[idx++] = u2;
|
||||
vertices[idx++] = v2;
|
||||
|
||||
//tri2
|
||||
vertices[idx++] = fx2;
|
||||
vertices[idx++] = fy2;
|
||||
vertices[idx++] = color;
|
||||
vertices[idx++] = u2;
|
||||
vertices[idx++] = v2;
|
||||
|
||||
vertices[idx++] = fx2;
|
||||
vertices[idx++] = y;
|
||||
vertices[idx++] = color;
|
||||
vertices[idx++] = u2;
|
||||
vertices[idx++] = v;
|
||||
|
||||
vertices[idx++] = x;
|
||||
vertices[idx++] = y;
|
||||
vertices[idx++] = color;
|
||||
vertices[idx++] = u;
|
||||
vertices[idx++] = v;
|
||||
int dest = index * vsize * 4;
|
||||
|
||||
mesh.updateVertices(index * vsize * 6, vertices);
|
||||
buffer.position(dest);
|
||||
buffer.put(vertices);
|
||||
|
||||
//mark dirty
|
||||
mesh.getVerticesBuffer();
|
||||
}
|
||||
|
||||
public void draw(int index, TextureRegion region, float x, float y, float w, float h, float rotation){
|
||||
@@ -166,26 +163,19 @@ public class IndexedRenderer implements Disposable{
|
||||
vertices[idx++] = u2;
|
||||
vertices[idx++] = v2;
|
||||
|
||||
//tri2
|
||||
vertices[idx++] = x3;
|
||||
vertices[idx++] = y3;
|
||||
vertices[idx++] = color;
|
||||
vertices[idx++] = u2;
|
||||
vertices[idx++] = v2;
|
||||
|
||||
vertices[idx++] = x4;
|
||||
vertices[idx++] = y4;
|
||||
vertices[idx++] = color;
|
||||
vertices[idx++] = u2;
|
||||
vertices[idx++] = v;
|
||||
|
||||
vertices[idx++] = x1;
|
||||
vertices[idx++] = y1;
|
||||
vertices[idx++] = color;
|
||||
vertices[idx++] = u;
|
||||
vertices[idx++] = v;
|
||||
int dest = index * vsize * 4;
|
||||
|
||||
mesh.updateVertices(index * vsize * 6, vertices);
|
||||
buffer.position(dest);
|
||||
buffer.put(vertices);
|
||||
|
||||
//mark dirty
|
||||
mesh.getVerticesBuffer();
|
||||
}
|
||||
|
||||
public Mat getTransformMatrix(){
|
||||
@@ -199,13 +189,15 @@ public class IndexedRenderer implements Disposable{
|
||||
public void resize(int sprites){
|
||||
if(mesh != null) mesh.dispose();
|
||||
|
||||
mesh = new Mesh(true, 6 * sprites, 0,
|
||||
mesh = new Mesh(true, 4 * sprites, 0,
|
||||
VertexAttribute.position,
|
||||
VertexAttribute.color,
|
||||
VertexAttribute.texCoords);
|
||||
|
||||
//TODO why is this the only way to get it working properly? it should not need an array
|
||||
mesh.setVertices(new float[6 * sprites * vsize]);
|
||||
buffer = mesh.getVerticesBuffer();
|
||||
buffer.limit(buffer.capacity());
|
||||
|
||||
mesh.indices = Vars.renderer.blocks.floor.getIndexData();
|
||||
}
|
||||
|
||||
private void updateMatrix(){
|
||||
|
||||
@@ -118,8 +118,7 @@ public class MultiPacker implements Disposable{
|
||||
|
||||
environment(4096),
|
||||
ui(4096),
|
||||
rubble(4096, 2048),
|
||||
editor(4096, 2048);
|
||||
rubble(4096, 2048);
|
||||
|
||||
public static final PageType[] all = values();
|
||||
|
||||
|
||||
@@ -273,7 +273,6 @@ public class Mods implements Loadable{
|
||||
ObjectMap<Texture, PageType> pageTypes = ObjectMap.of(
|
||||
Core.atlas.find("white").texture, PageType.main,
|
||||
Core.atlas.find("stone1").texture, PageType.environment,
|
||||
Core.atlas.find("clear-editor").texture, PageType.editor,
|
||||
Core.atlas.find("whiteui").texture, PageType.ui,
|
||||
Core.atlas.find("rubble-1-0").texture, PageType.rubble
|
||||
);
|
||||
@@ -405,7 +404,6 @@ public class Mods implements Loadable{
|
||||
String path = file.path();
|
||||
return
|
||||
path.contains("sprites/blocks/environment") || path.contains("sprites-override/blocks/environment") ? PageType.environment :
|
||||
path.contains("sprites/editor") || path.contains("sprites-override/editor") ? PageType.editor :
|
||||
path.contains("sprites/rubble") || path.contains("sprites-override/rubble") ? PageType.rubble :
|
||||
path.contains("sprites/ui") || path.contains("sprites-override/ui") ? PageType.ui :
|
||||
PageType.main;
|
||||
|
||||
@@ -382,11 +382,10 @@ public class Block extends UnlockableContent implements Senseable{
|
||||
protected Seq<Consume> consumeBuilder = new Seq<>();
|
||||
|
||||
protected TextureRegion[] generatedIcons;
|
||||
protected TextureRegion[] editorVariantRegions;
|
||||
|
||||
/** Regions indexes from icons() that are rotated. If either of these is not -1, other regions won't be rotated in ConstructBlocks. */
|
||||
public int regionRotated1 = -1, regionRotated2 = -1;
|
||||
public TextureRegion region, editorIcon;
|
||||
public TextureRegion region;
|
||||
public @Load("@-shadow") TextureRegion customShadowRegion;
|
||||
public @Load("@-team") TextureRegion teamRegion;
|
||||
public TextureRegion[] teamRegions, variantRegions, variantShadowRegions;
|
||||
@@ -864,24 +863,6 @@ public class Block extends UnlockableContent implements Senseable{
|
||||
}
|
||||
}
|
||||
|
||||
/** Never use outside of the editor! */
|
||||
public TextureRegion editorIcon(){
|
||||
return editorIcon == null ? (editorIcon = Core.atlas.find(name + "-icon-editor")) : editorIcon;
|
||||
}
|
||||
|
||||
/** Never use outside of the editor! */
|
||||
public TextureRegion[] editorVariantRegions(){
|
||||
if(editorVariantRegions == null){
|
||||
variantRegions();
|
||||
editorVariantRegions = new TextureRegion[variantRegions.length];
|
||||
for(int i = 0; i < variantRegions.length; i++){
|
||||
AtlasRegion region = (AtlasRegion)variantRegions[i];
|
||||
editorVariantRegions[i] = Core.atlas.find("editor-" + region.name);
|
||||
}
|
||||
}
|
||||
return editorVariantRegions;
|
||||
}
|
||||
|
||||
/** @return special icons to outline and save with an -outline variant. Vanilla only. */
|
||||
public TextureRegion[] makeIconRegions(){
|
||||
return new TextureRegion[0];
|
||||
@@ -1388,13 +1369,6 @@ public class Block extends UnlockableContent implements Senseable{
|
||||
mapColor.set(image.get(image.width/2, image.height/2));
|
||||
}
|
||||
|
||||
if(variants > 0){
|
||||
for(int i = 0; i < variants; i++){
|
||||
String rname = name + (i + 1);
|
||||
packer.add(PageType.editor, "editor-" + rname, Core.atlas.getPixmap(rname));
|
||||
}
|
||||
}
|
||||
|
||||
Seq<Pixmap> toDispose = new Seq<>();
|
||||
|
||||
//generate paletted team regions
|
||||
@@ -1459,8 +1433,6 @@ public class Block extends UnlockableContent implements Senseable{
|
||||
}
|
||||
}
|
||||
|
||||
PixmapRegion editorBase;
|
||||
|
||||
if(gen.length > 1){
|
||||
Pixmap base = Core.atlas.getPixmap(gen[0]).crop();
|
||||
for(int i = 1; i < gen.length; i++){
|
||||
@@ -1472,15 +1444,11 @@ public class Block extends UnlockableContent implements Senseable{
|
||||
}
|
||||
packer.add(PageType.main, "block-" + name + "-full", base);
|
||||
|
||||
editorBase = new PixmapRegion(base);
|
||||
toDispose.add(base);
|
||||
}else{
|
||||
if(gen[0] != null) packer.add(PageType.main, "block-" + name + "-full", Core.atlas.getPixmap(gen[0]));
|
||||
editorBase = gen[0] == null ? Core.atlas.getPixmap(fullIcon) : Core.atlas.getPixmap(gen[0]);
|
||||
}
|
||||
|
||||
packer.add(PageType.editor, name + "-icon-editor", editorBase);
|
||||
|
||||
toDispose.each(Pixmap::dispose);
|
||||
}
|
||||
|
||||
|
||||
@@ -210,7 +210,6 @@ public class Floor extends Block{
|
||||
@Override
|
||||
public void createIcons(MultiPacker packer){
|
||||
super.createIcons(packer);
|
||||
packer.add(PageType.editor, "editor-" + name, Core.atlas.getPixmap(fullIcon));
|
||||
|
||||
if(blendGroup != this){
|
||||
return;
|
||||
|
||||
@@ -63,10 +63,8 @@ public class OreBlock extends OverlayFloor{
|
||||
}
|
||||
|
||||
packer.add(PageType.environment, name + (i + 1), image);
|
||||
packer.add(PageType.editor, "editor-" + name + (i + 1), image);
|
||||
|
||||
if(i == 0){
|
||||
packer.add(PageType.editor, "editor-block-" + name + "-full", image);
|
||||
packer.add(PageType.main, "block-" + name + "-full", image);
|
||||
}
|
||||
|
||||
|
||||
@@ -47,9 +47,8 @@ public class ShallowLiquid extends Floor{
|
||||
}
|
||||
}
|
||||
|
||||
String baseName = this.name + "" + (++index);
|
||||
String baseName = this.name + (++index);
|
||||
packer.add(PageType.environment, baseName, res);
|
||||
packer.add(PageType.editor, "editor-" + baseName, res);
|
||||
|
||||
res.dispose();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user