Removing CacheBatch due to performance issues
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
#Autogenerated file. Do not modify.
|
#Autogenerated file. Do not modify.
|
||||||
#Mon Mar 19 23:08:29 EDT 2018
|
#Tue Mar 20 19:27:20 EDT 2018
|
||||||
version=release
|
version=release
|
||||||
androidBuildCode=540
|
androidBuildCode=553
|
||||||
name=Mindustry
|
name=Mindustry
|
||||||
code=3.4
|
code=3.4
|
||||||
build=custom build
|
build=custom build
|
||||||
|
|||||||
@@ -16,12 +16,10 @@ import io.anuke.ucore.core.Timers;
|
|||||||
import io.anuke.ucore.scene.Element;
|
import io.anuke.ucore.scene.Element;
|
||||||
import io.anuke.ucore.scene.actions.Actions;
|
import io.anuke.ucore.scene.actions.Actions;
|
||||||
import io.anuke.ucore.scene.builders.build;
|
import io.anuke.ucore.scene.builders.build;
|
||||||
import io.anuke.ucore.scene.builders.label;
|
|
||||||
import io.anuke.ucore.scene.builders.table;
|
import io.anuke.ucore.scene.builders.table;
|
||||||
import io.anuke.ucore.scene.ui.*;
|
import io.anuke.ucore.scene.ui.*;
|
||||||
import io.anuke.ucore.scene.ui.layout.Stack;
|
import io.anuke.ucore.scene.ui.layout.Stack;
|
||||||
import io.anuke.ucore.scene.ui.layout.Table;
|
import io.anuke.ucore.scene.ui.layout.Table;
|
||||||
import io.anuke.ucore.util.Bundles;
|
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.gwt;
|
import static io.anuke.mindustry.Vars.gwt;
|
||||||
import static io.anuke.mindustry.Vars.ui;
|
import static io.anuke.mindustry.Vars.ui;
|
||||||
@@ -205,77 +203,23 @@ public class MapEditorDialog extends Dialog{
|
|||||||
public void build(){
|
public void build(){
|
||||||
|
|
||||||
new table(){{
|
new table(){{
|
||||||
float isize = 16*2f;
|
|
||||||
aleft();
|
aleft();
|
||||||
/*
|
|
||||||
new table(){{
|
|
||||||
|
|
||||||
defaults().growY().width(130f).padBottom(-6);
|
|
||||||
|
|
||||||
new imagebutton("icon-terrain", isize, () ->
|
|
||||||
dialog.show()
|
|
||||||
).text("$text.editor.generate");
|
|
||||||
|
|
||||||
row();
|
|
||||||
|
|
||||||
new imagebutton("icon-resize", isize, () ->
|
|
||||||
resizeDialog.show()
|
|
||||||
).text("$text.editor.resize").padTop(4f);
|
|
||||||
|
|
||||||
row();
|
|
||||||
|
|
||||||
new imagebutton("icon-load-map", isize, () ->
|
|
||||||
loadDialog.show()
|
|
||||||
).text("$text.editor.loadmap");
|
|
||||||
|
|
||||||
row();
|
|
||||||
|
|
||||||
new imagebutton("icon-save-map", isize, ()->
|
|
||||||
saveDialog.show()
|
|
||||||
).text("$text.editor.savemap");
|
|
||||||
|
|
||||||
row();
|
|
||||||
/*
|
|
||||||
new imagebutton("icon-load-image", isize, () ->
|
|
||||||
openFile.show()
|
|
||||||
).text("$text.editor.loadimage");
|
|
||||||
|
|
||||||
row();
|
|
||||||
|
|
||||||
new imagebutton("icon-save-image", isize, () ->
|
|
||||||
saveFile.show()
|
|
||||||
).text("$text.editor.saveimage");
|
|
||||||
|
|
||||||
row();
|
|
||||||
|
|
||||||
new imagebutton("icon-back", isize, () -> {
|
|
||||||
if(!saved){
|
|
||||||
ui.showConfirm("$text.confirm", "$text.editor.unsaved",
|
|
||||||
MapEditorDialog.this::hide);
|
|
||||||
}else{
|
|
||||||
hide();
|
|
||||||
}
|
|
||||||
}).padBottom(0).text("$text.back");
|
|
||||||
|
|
||||||
}}.left().growY().end();
|
|
||||||
*/
|
|
||||||
|
|
||||||
new table("button"){{
|
new table("button"){{
|
||||||
add(view).grow();
|
margin(0);
|
||||||
}}.grow().end();
|
Table tools = new Table();
|
||||||
|
|
||||||
new table(){{
|
|
||||||
Table tools = new Table("button");
|
|
||||||
tools.top();
|
tools.top();
|
||||||
tools.marginTop(0).marginBottom(6);
|
|
||||||
|
|
||||||
ButtonGroup<ImageButton> group = new ButtonGroup<>();
|
ButtonGroup<ImageButton> group = new ButtonGroup<>();
|
||||||
int i = 1;
|
int i = 1;
|
||||||
|
|
||||||
tools.defaults().size(53f, 58f).padBottom(-6);
|
tools.defaults().size(60f, 64f).padBottom(-5.1f);
|
||||||
|
|
||||||
ImageButton undo = tools.addImageButton("icon-undo", 16*2f, () -> view.undo()).get();
|
ImageButton undo = tools.addImageButton("icon-undo", 16*2f, () -> view.undo()).get();
|
||||||
ImageButton redo = tools.addImageButton("icon-redo", 16*2f, () -> view.redo()).get();
|
ImageButton redo = tools.addImageButton("icon-redo", 16*2f, () -> view.redo()).get();
|
||||||
|
|
||||||
|
tools.row();
|
||||||
|
|
||||||
ImageButton grid = tools.addImageButton("icon-grid", "toggle", 16*2f, () -> view.setGrid(!view.isGrid())).get();
|
ImageButton grid = tools.addImageButton("icon-grid", "toggle", 16*2f, () -> view.setGrid(!view.isGrid())).get();
|
||||||
|
|
||||||
undo.setDisabled(() -> !view.getStack().canUndo());
|
undo.setDisabled(() -> !view.getStack().canUndo());
|
||||||
@@ -295,30 +239,32 @@ public class MapEditorDialog extends Dialog{
|
|||||||
button.setChecked(true);
|
button.setChecked(true);
|
||||||
|
|
||||||
tools.add(button).padBottom(-6f);
|
tools.add(button).padBottom(-6f);
|
||||||
if(i++ % 4 == 1) tools.row();
|
if(i++ % 2 == 1) tools.row();
|
||||||
}
|
}
|
||||||
|
|
||||||
add(tools).width(53*4).padBottom(-6);
|
add(tools).growY().top().padBottom(-6);
|
||||||
|
|
||||||
row();
|
row();
|
||||||
|
/*
|
||||||
new table("button"){{
|
new table("button"){{
|
||||||
margin(10f);
|
Slider slider = new Slider(0, MapEditor.brushSizes.length-1, 1, true);
|
||||||
Slider slider = new Slider(0, MapEditor.brushSizes.length-1, 1, false);
|
|
||||||
slider.moved(f -> editor.setBrushSize(MapEditor.brushSizes[(int)(float)f]));
|
slider.moved(f -> editor.setBrushSize(MapEditor.brushSizes[(int)(float)f]));
|
||||||
new label(() -> Bundles.format("text.editor.brushsize", MapEditor.brushSizes[(int)slider.getValue()])).left();
|
new label(() -> Bundles.format("text.editor.brushsize", MapEditor.brushSizes[(int)slider.getValue()])).left();
|
||||||
row();
|
row();
|
||||||
add(slider).growX().padTop(4f);
|
add(slider).growX().padTop(4f);
|
||||||
}}.growX().padBottom(-6).end();
|
|
||||||
|
|
||||||
row();
|
|
||||||
|
|
||||||
/*
|
|
||||||
new table("button"){{
|
|
||||||
get().addCheck("$text.oregen", b -> editor.getMap().oreGen = b)
|
|
||||||
.update(c -> c.setChecked(editor.getMap().oreGen)).padTop(3).padBottom(3);
|
|
||||||
}}.growX().padBottom(-6).end();*/
|
}}.growX().padBottom(-6).end();*/
|
||||||
|
|
||||||
|
}}.left().growY().end();
|
||||||
|
|
||||||
|
|
||||||
|
new table("button"){{
|
||||||
|
margin(5);
|
||||||
|
marginBottom(10);
|
||||||
|
add(view).grow();
|
||||||
|
}}.grow().end();
|
||||||
|
|
||||||
|
new table(){{
|
||||||
|
|
||||||
row();
|
row();
|
||||||
|
|
||||||
addBlockSelection(get());
|
addBlockSelection(get());
|
||||||
@@ -427,7 +373,7 @@ public class MapEditorDialog extends Dialog{
|
|||||||
group.add(button);
|
group.add(button);
|
||||||
content.add(button).pad(4f).size(53f, 58f);
|
content.add(button).pad(4f).size(53f, 58f);
|
||||||
|
|
||||||
if(i++ % 2 == 1){
|
if(i++ % 3 == 2){
|
||||||
content.row();
|
content.row();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -435,8 +381,8 @@ public class MapEditorDialog extends Dialog{
|
|||||||
group.getButtons().get(2).setChecked(true);
|
group.getButtons().get(2).setChecked(true);
|
||||||
|
|
||||||
Table extra = new Table("button");
|
Table extra = new Table("button");
|
||||||
extra.labelWrap(() -> editor.getDrawBlock().formalName).width(180f).center();
|
extra.labelWrap(() -> editor.getDrawBlock().formalName).width(220f).center();
|
||||||
table.add(extra).padBottom(-6).growX();
|
table.add(extra).growX();
|
||||||
table.row();
|
table.row();
|
||||||
table.add(pane).growY().fillX();
|
table.add(pane).growY().fillX();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package io.anuke.mindustry.editor;
|
|||||||
|
|
||||||
import com.badlogic.gdx.Gdx;
|
import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.graphics.GL20;
|
import com.badlogic.gdx.graphics.GL20;
|
||||||
|
import com.badlogic.gdx.math.Matrix4;
|
||||||
import com.badlogic.gdx.utils.IntSet;
|
import com.badlogic.gdx.utils.IntSet;
|
||||||
import com.badlogic.gdx.utils.IntSet.IntSetIterator;
|
import com.badlogic.gdx.utils.IntSet.IntSetIterator;
|
||||||
import io.anuke.mindustry.io.MapTileData.TileDataWriter;
|
import io.anuke.mindustry.io.MapTileData.TileDataWriter;
|
||||||
@@ -9,8 +10,10 @@ import io.anuke.mindustry.world.Block;
|
|||||||
import io.anuke.mindustry.world.blocks.Blocks;
|
import io.anuke.mindustry.world.blocks.Blocks;
|
||||||
import io.anuke.ucore.core.Core;
|
import io.anuke.ucore.core.Core;
|
||||||
import io.anuke.ucore.core.Graphics;
|
import io.anuke.ucore.core.Graphics;
|
||||||
|
import io.anuke.ucore.core.Timers;
|
||||||
import io.anuke.ucore.graphics.CacheBatch;
|
import io.anuke.ucore.graphics.CacheBatch;
|
||||||
import io.anuke.ucore.graphics.Draw;
|
import io.anuke.ucore.graphics.Draw;
|
||||||
|
import io.anuke.ucore.util.Log;
|
||||||
import io.anuke.ucore.util.Mathf;
|
import io.anuke.ucore.util.Mathf;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.tilesize;
|
import static io.anuke.mindustry.Vars.tilesize;
|
||||||
@@ -21,6 +24,7 @@ public class MapRenderer {
|
|||||||
private int[][] chunks;
|
private int[][] chunks;
|
||||||
private IntSet updates = new IntSet();
|
private IntSet updates = new IntSet();
|
||||||
private MapEditor editor;
|
private MapEditor editor;
|
||||||
|
private Matrix4 matrix = new Matrix4();
|
||||||
|
|
||||||
public MapRenderer(MapEditor editor){
|
public MapRenderer(MapEditor editor){
|
||||||
this.editor = editor;
|
this.editor = editor;
|
||||||
@@ -41,6 +45,7 @@ public class MapRenderer {
|
|||||||
updateAll();
|
updateAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void draw(float tx, float ty, float tw, float th){
|
public void draw(float tx, float ty, float tw, float th){
|
||||||
Graphics.end();
|
Graphics.end();
|
||||||
Graphics.useBatch(batch);
|
Graphics.useBatch(batch);
|
||||||
@@ -58,8 +63,6 @@ public class MapRenderer {
|
|||||||
|
|
||||||
Gdx.gl.glEnable(GL20.GL_BLEND);
|
Gdx.gl.glEnable(GL20.GL_BLEND);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
batch.getTransformMatrix().setToTranslation(tx, ty, 0).scl(tw / (chunks.length * chunksize * tilesize),
|
batch.getTransformMatrix().setToTranslation(tx, ty, 0).scl(tw / (chunks.length * chunksize * tilesize),
|
||||||
th / (chunks[0].length * chunksize * tilesize), 1f);
|
th / (chunks[0].length * chunksize * tilesize), 1f);
|
||||||
batch.setProjectionMatrix(Core.batch.getProjectionMatrix());
|
batch.setProjectionMatrix(Core.batch.getProjectionMatrix());
|
||||||
@@ -99,6 +102,7 @@ public class MapRenderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void render(int chunkx, int chunky, int previousID){
|
private void render(int chunkx, int chunky, int previousID){
|
||||||
|
Timers.mark();
|
||||||
if(previousID == -1){
|
if(previousID == -1){
|
||||||
batch.begin();
|
batch.begin();
|
||||||
}else{
|
}else{
|
||||||
@@ -140,5 +144,6 @@ public class MapRenderer {
|
|||||||
|
|
||||||
batch.end();
|
batch.end();
|
||||||
if(previousID == -1) chunks[chunkx][chunky] = batch.getLastCache();
|
if(previousID == -1) chunks[chunkx][chunky] = batch.getLastCache();
|
||||||
|
Log.info("Time to render cache: {0}", Timers.elapsed());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -206,7 +206,7 @@ public class MapView extends Element implements GestureListener{
|
|||||||
image.setImageSize(editor.getMap().width(), editor.getMap().height());
|
image.setImageSize(editor.getMap().width(), editor.getMap().height());
|
||||||
|
|
||||||
batch.flush();
|
batch.flush();
|
||||||
boolean pop = ScissorStack.pushScissors(rect.set(x + width/2 - size/2, y + height/2 - size/2, size, size));
|
boolean pop = ScissorStack.pushScissors(rect.set(x, y, width, height));
|
||||||
|
|
||||||
//batch.draw(editor.texture(), centerx - sclwidth/2, centery - sclheight/2, sclwidth, sclheight);
|
//batch.draw(editor.texture(), centerx - sclwidth/2, centery - sclheight/2, sclwidth, sclheight);
|
||||||
//TODO actually render the map here?
|
//TODO actually render the map here?
|
||||||
@@ -243,7 +243,7 @@ public class MapView extends Element implements GestureListener{
|
|||||||
|
|
||||||
Draw.color(Colors.get("accent"));
|
Draw.color(Colors.get("accent"));
|
||||||
Lines.stroke(Unit.dp.scl(3f));
|
Lines.stroke(Unit.dp.scl(3f));
|
||||||
Lines.rect(x + width/2 - size/2, y + height/2 - size/2, size, size);
|
Lines.rect(x, y, width, height);
|
||||||
Draw.reset();
|
Draw.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user