This commit is contained in:
Anuken
2020-04-22 16:06:26 -04:00
parent 9beb23b0e4
commit c5f93139bd
13 changed files with 50 additions and 58 deletions
@@ -161,6 +161,7 @@ public class EntityProcess extends BaseProcessor{
Log.debug(""); Log.debug("");
} }
/*
//generate special render layer interfaces //generate special render layer interfaces
for(DrawLayer layer : DrawLayer.values()){ for(DrawLayer layer : DrawLayer.values()){
//create the DrawLayer interface that entities need to implement //create the DrawLayer interface that entities need to implement
@@ -171,7 +172,7 @@ public class EntityProcess extends BaseProcessor{
.addModifiers(Modifier.PUBLIC).addAnnotation(EntityInterface.class); .addModifiers(Modifier.PUBLIC).addAnnotation(EntityInterface.class);
inter.addMethod(MethodSpec.methodBuilder("draw" + Strings.capitalize(layer.name())).addModifiers(Modifier.PUBLIC, Modifier.ABSTRACT).build()); inter.addMethod(MethodSpec.methodBuilder("draw" + Strings.capitalize(layer.name())).addModifiers(Modifier.PUBLIC, Modifier.ABSTRACT).build());
write(inter); write(inter);
} }*/
}else if(round == 2){ //round 2: get component classes and generate interfaces for them }else if(round == 2){ //round 2: get component classes and generate interfaces for them
//parse groups //parse groups
@@ -182,6 +183,7 @@ public class EntityProcess extends BaseProcessor{
groupDefs.add(new GroupDefinition(group.name(), ClassName.bestGuess(packageName + "." + interfaceName(types.first())), types, an.spatial(), an.mapping(), collides)); groupDefs.add(new GroupDefinition(group.name(), ClassName.bestGuess(packageName + "." + interfaceName(types.first())), types, an.spatial(), an.mapping(), collides));
} }
/*
//add special generated groups //add special generated groups
for(DrawLayer layer : DrawLayer.values()){ for(DrawLayer layer : DrawLayer.values()){
String name = "DrawLayer" + Strings.capitalize(layer.name()) + "c"; String name = "DrawLayer" + Strings.capitalize(layer.name()) + "c";
@@ -190,7 +192,7 @@ public class EntityProcess extends BaseProcessor{
//add manual inclusions of entities to be added to this group //add manual inclusions of entities to be added to this group
def.manualInclusions.addAll(allDefs.select(s -> allComponents(s).contains(comp -> comp.interfaces().contains(in -> in.name().equals(name))))); def.manualInclusions.addAll(allDefs.select(s -> allComponents(s).contains(comp -> comp.interfaces().contains(in -> in.name().equals(name)))));
groupDefs.add(def); groupDefs.add(def);
} }*/
ObjectMap<String, Selement> usedNames = new ObjectMap<>(); ObjectMap<String, Selement> usedNames = new ObjectMap<>();
ObjectMap<Selement, ObjectSet<String>> extraNames = new ObjectMap<>(); ObjectMap<Selement, ObjectSet<String>> extraNames = new ObjectMap<>();
@@ -457,12 +459,13 @@ public class EntityProcess extends BaseProcessor{
} }
} }
/*
for(DrawLayer layer : DrawLayer.values()){ for(DrawLayer layer : DrawLayer.values()){
MethodSpec.Builder groupDraw = MethodSpec.methodBuilder("draw" + Strings.capitalize(layer.name())) MethodSpec.Builder groupDraw = MethodSpec.methodBuilder("draw" + Strings.capitalize(layer.name()))
.addModifiers(Modifier.PUBLIC, Modifier.STATIC); .addModifiers(Modifier.PUBLIC, Modifier.STATIC);
groupDraw.addStatement("$L.draw($L::$L)", layer.name(), "DrawLayer" + Strings.capitalize(layer.name()) + "c", "draw" + Strings.capitalize(layer.name())); groupDraw.addStatement("$L.draw($L::$L)", layer.name(), "DrawLayer" + Strings.capitalize(layer.name()) + "c", "draw" + Strings.capitalize(layer.name()));
groupsBuilder.addMethod(groupDraw.build()); groupsBuilder.addMethod(groupDraw.build());
} }*/
groupsBuilder.addMethod(groupResize.build()); groupsBuilder.addMethod(groupResize.build());
groupsBuilder.addMethod(groupUpdate.build()); groupsBuilder.addMethod(groupUpdate.build());
+6 -7
View File
@@ -25,7 +25,7 @@ public class Renderer implements ApplicationListener{
public final LightRenderer lights = new LightRenderer(); public final LightRenderer lights = new LightRenderer();
public final Pixelator pixelator = new Pixelator(); public final Pixelator pixelator = new Pixelator();
public FrameBuffer effectBuffer = new FrameBuffer(2, 2); public FrameBuffer effectBuffer = new FrameBuffer();
private Bloom bloom; private Bloom bloom;
private FxProcessor fx = new FxProcessor(); private FxProcessor fx = new FxProcessor();
private Color clearColor = new Color(0f, 0f, 0f, 1f); private Color clearColor = new Color(0f, 0f, 0f, 1f);
@@ -181,21 +181,22 @@ public class Renderer implements ApplicationListener{
graphics.clear(clearColor); graphics.clear(clearColor);
if(!graphics.isHidden() && (Core.settings.getBool("animatedwater") || Core.settings.getBool("animatedshields")) && (effectBuffer.getWidth() != graphics.getWidth() || effectBuffer.getHeight() != graphics.getHeight())){ //TODO 'animated water' is a bad name for this etting
if(Core.settings.getBool("animatedwater") || Core.settings.getBool("animatedshields")){
effectBuffer.resize(graphics.getWidth(), graphics.getHeight()); effectBuffer.resize(graphics.getWidth(), graphics.getHeight());
} }
Draw.proj(camera); Draw.proj(camera);
beginFx(); //beginFx();
drawBackground(); drawBackground();
blocks.floor.checkChanges(); blocks.floor.checkChanges();
blocks.floor.drawFloor(); blocks.floor.drawFloor();
Groups.drawFloor(); //Groups.drawFloor();
Groups.drawFloorOver(); //Groups.drawFloorOver();
blocks.processBlocks(); blocks.processBlocks();
blocks.drawShadows(); blocks.drawShadows();
@@ -334,8 +335,6 @@ public class Renderer implements ApplicationListener{
} }
public void takeMapScreenshot(){ public void takeMapScreenshot(){
Groups.drawGroundShadows();
int w = world.width() * tilesize, h = world.height() * tilesize; int w = world.width() * tilesize, h = world.height() * tilesize;
int memory = w * h * 4 / 1024 / 1024; int memory = w * h * 4 / 1024 / 1024;
+5
View File
@@ -34,4 +34,9 @@ class AllDefs{
class sync{ class sync{
} }
@GroupDef(Drawc.class)
class draw{
}
} }
@@ -8,14 +8,14 @@ import mindustry.gen.*;
@EntityDef(value = {Decalc.class}, pooled = true) @EntityDef(value = {Decalc.class}, pooled = true)
@Component @Component
abstract class DecalComp implements Drawc, Timedc, Rotc, Posc, DrawLayerFloorc{ abstract class DecalComp implements Drawc, Timedc, Rotc, Posc{
@Import float x, y, rotation; @Import float x, y, rotation;
Color color = new Color(1, 1, 1, 1); Color color = new Color(1, 1, 1, 1);
TextureRegion region; TextureRegion region;
@Override @Override
public void drawFloor(){ public void draw(){
Draw.color(color); Draw.color(color);
Draw.alpha(1f - Mathf.curve(fin(), 0.98f)); Draw.alpha(1f - Mathf.curve(fin(), 0.98f));
Draw.rect(region, x, y, rotation); Draw.rect(region, x, y, rotation);
@@ -6,4 +6,8 @@ import mindustry.gen.*;
@Component @Component
abstract class DrawComp implements Posc{ abstract class DrawComp implements Posc{
abstract float clipSize(); abstract float clipSize();
void draw(){
}
} }
@@ -6,7 +6,7 @@ import mindustry.annotations.Annotations.*;
import mindustry.gen.*; import mindustry.gen.*;
@Component @Component
abstract class LegsComp implements Posc, Flyingc, Hitboxc, DrawLayerGroundUnderc, Unitc, Legsc, ElevationMovec{ abstract class LegsComp implements Posc, Flyingc, Hitboxc, Unitc, Legsc, ElevationMovec{
@Import float x, y; @Import float x, y;
float baseRotation; float baseRotation;
@@ -18,9 +18,4 @@ abstract class LegsComp implements Posc, Flyingc, Hitboxc, DrawLayerGroundUnderc
baseRotation = Angles.moveToward(baseRotation, vel().angle(), type().baseRotateSpeed * Mathf.clamp(len / type().speed)); baseRotation = Angles.moveToward(baseRotation, vel().angle(), type().baseRotateSpeed * Mathf.clamp(len / type().speed));
walkTime += Time.delta()*len/1f; walkTime += Time.delta()*len/1f;
} }
@Override
public void drawGroundUnder(){
type().drawLegs(this);
}
} }
@@ -17,7 +17,7 @@ import mindustry.world.*;
import static mindustry.Vars.*; import static mindustry.Vars.*;
@Component @Component
abstract class MinerComp implements Itemsc, Posc, Teamc, Rotc, DrawLayerGroundc{ abstract class MinerComp implements Itemsc, Posc, Teamc, Rotc, Drawc{
@Import float x, y, rotation; @Import float x, y, rotation;
transient float mineTimer; transient float mineTimer;
@@ -80,7 +80,7 @@ abstract class MinerComp implements Itemsc, Posc, Teamc, Rotc, DrawLayerGroundc{
} }
@Override @Override
public void drawGround(){ public void draw(){
if(!mining()) return; if(!mining()) return;
float focusLen = 4f + Mathf.absin(Time.time(), 1.1f, 0.5f); float focusLen = 4f + Mathf.absin(Time.time(), 1.1f, 0.5f);
float swingScl = 12f, swingMag = tilesize / 8f; float swingScl = 12f, swingMag = tilesize / 8f;
+2 -28
View File
@@ -18,8 +18,7 @@ import mindustry.world.blocks.environment.*;
import static mindustry.Vars.*; import static mindustry.Vars.*;
@Component @Component
abstract class UnitComp implements Healthc, Velc, Statusc, Teamc, Itemsc, Hitboxc, Rotc, Massc, Unitc, Weaponsc, Drawc, Boundedc, abstract class UnitComp implements Healthc, Velc, Statusc, Teamc, Itemsc, Hitboxc, Rotc, Massc, Unitc, Weaponsc, Drawc, Boundedc, Syncc{
DrawLayerGroundc, DrawLayerFlyingc, DrawLayerGroundShadowsc, DrawLayerFlyingShadowsc, Syncc{
@Import float x, y, rotation, elevation; @Import float x, y, rotation, elevation;
private UnitController controller; private UnitController controller;
@@ -172,32 +171,7 @@ abstract class UnitComp implements Healthc, Velc, Statusc, Teamc, Itemsc, Hitbox
@Override @Override
public void draw(){ public void draw(){
type.drawEngine(this); type.draw(this);
type.drawBody(this);
type.drawWeapons(this);
if(type.drawCell) type.drawCell(this);
if(type.drawItems) type.drawItems(this);
type.drawLight(this);
}
@Override
public void drawFlyingShadows(){
if(isFlying()) type.drawShadow(this);
}
@Override
public void drawGroundShadows(){
type.drawOcclusion(this);
}
@Override
public void drawFlying(){
if(isFlying()) draw();
}
@Override
public void drawGround(){
if(isGrounded()) draw();
} }
@Override @Override
@@ -29,8 +29,8 @@ public class BlockRenderer implements Disposable{
private int lastCamX, lastCamY, lastRangeX, lastRangeY; private int lastCamX, lastCamY, lastRangeX, lastRangeY;
private float brokenFade = 0f; private float brokenFade = 0f;
private FrameBuffer shadows = new FrameBuffer(2, 2); private FrameBuffer shadows = new FrameBuffer();
private FrameBuffer fog = new FrameBuffer(2, 2); private FrameBuffer fog = new FrameBuffer();
private Array<Tilec> outArray2 = new Array<>(); private Array<Tilec> outArray2 = new Array<>();
private Array<Tile> shadowEvents = new Array<>(); private Array<Tile> shadowEvents = new Array<>();
private boolean displayStatus = false; private boolean displayStatus = false;
@@ -8,6 +8,7 @@ import arc.graphics.gl.*;
import static mindustry.Vars.renderer; import static mindustry.Vars.renderer;
public enum CacheLayer{ public enum CacheLayer{
//TODO water animation breaks when tar/slag is present
water{ water{
@Override @Override
public void begin(){ public void begin(){
@@ -17,7 +17,7 @@ public class LightRenderer{
private static final int scaling = 4; private static final int scaling = 4;
private float[] vertices = new float[24]; private float[] vertices = new float[24];
private FrameBuffer buffer = new FrameBuffer(2, 2); private FrameBuffer buffer = new FrameBuffer();
private Array<Runnable> lights = new Array<>(); private Array<Runnable> lights = new Array<>();
public void add(Runnable run){ public void add(Runnable run){
@@ -185,9 +185,7 @@ public class LightRenderer{
return; return;
} }
if(buffer.getWidth() != Core.graphics.getWidth()/scaling || buffer.getHeight() != Core.graphics.getHeight()/scaling){ buffer.resize(Core.graphics.getWidth()/scaling, Core.graphics.getHeight()/scaling);
buffer.resize(Core.graphics.getWidth()/scaling, Core.graphics.getHeight()/scaling);
}
Draw.color(); Draw.color();
buffer.begin(Color.clear); buffer.begin(Color.clear);
+2 -4
View File
@@ -12,7 +12,7 @@ import static arc.Core.*;
import static mindustry.Vars.renderer; import static mindustry.Vars.renderer;
public class Pixelator implements Disposable{ public class Pixelator implements Disposable{
private FrameBuffer buffer = new FrameBuffer(2, 2); private FrameBuffer buffer = new FrameBuffer();
{ {
buffer.getTexture().setFilter(TextureFilter.Nearest, TextureFilter.Nearest); buffer.getTexture().setFilter(TextureFilter.Nearest, TextureFilter.Nearest);
@@ -34,9 +34,7 @@ public class Pixelator implements Disposable{
int w = (int)(Core.camera.width * renderer.landScale()); int w = (int)(Core.camera.width * renderer.landScale());
int h = (int)(Core.camera.height * renderer.landScale()); int h = (int)(Core.camera.height * renderer.landScale());
if(!graphics.isHidden() && (buffer.getWidth() != w || buffer.getHeight() != h)){ buffer.resize(w, h);
buffer.resize(w, h);
}
buffer.begin(); buffer.begin();
renderer.draw(); renderer.draw();
+15
View File
@@ -114,6 +114,21 @@ public class UnitType extends UnlockableContent{
//region drawing //region drawing
public void draw(Unitc unit){
//TODO set Z for these things
drawShadow(unit);
drawOcclusion(unit);
if(unit instanceof Legsc) drawLegs((Legsc)unit);
drawEngine(unit);
drawBody(unit);
drawWeapons(unit);
if(drawCell) drawCell(unit);
if(drawItems) drawItems(unit);
drawLight(unit);
}
public void drawShadow(Unitc unit){ public void drawShadow(Unitc unit){
Draw.color(shadowColor); Draw.color(shadowColor);
Draw.rect(region, unit.x() + shadowTX * unit.elevation(), unit.y() + shadowTY * unit.elevation(), unit.rotation() - 90); Draw.rect(region, unit.x() + shadowTX * unit.elevation(), unit.y() + shadowTY * unit.elevation(), unit.rotation() - 90);