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("");
}
/*
//generate special render layer interfaces
for(DrawLayer layer : DrawLayer.values()){
//create the DrawLayer interface that entities need to implement
@@ -171,7 +172,7 @@ public class EntityProcess extends BaseProcessor{
.addModifiers(Modifier.PUBLIC).addAnnotation(EntityInterface.class);
inter.addMethod(MethodSpec.methodBuilder("draw" + Strings.capitalize(layer.name())).addModifiers(Modifier.PUBLIC, Modifier.ABSTRACT).build());
write(inter);
}
}*/
}else if(round == 2){ //round 2: get component classes and generate interfaces for them
//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));
}
/*
//add special generated groups
for(DrawLayer layer : DrawLayer.values()){
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
def.manualInclusions.addAll(allDefs.select(s -> allComponents(s).contains(comp -> comp.interfaces().contains(in -> in.name().equals(name)))));
groupDefs.add(def);
}
}*/
ObjectMap<String, Selement> usedNames = new ObjectMap<>();
ObjectMap<Selement, ObjectSet<String>> extraNames = new ObjectMap<>();
@@ -457,12 +459,13 @@ public class EntityProcess extends BaseProcessor{
}
}
/*
for(DrawLayer layer : DrawLayer.values()){
MethodSpec.Builder groupDraw = MethodSpec.methodBuilder("draw" + Strings.capitalize(layer.name()))
.addModifiers(Modifier.PUBLIC, Modifier.STATIC);
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(groupResize.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 Pixelator pixelator = new Pixelator();
public FrameBuffer effectBuffer = new FrameBuffer(2, 2);
public FrameBuffer effectBuffer = new FrameBuffer();
private Bloom bloom;
private FxProcessor fx = new FxProcessor();
private Color clearColor = new Color(0f, 0f, 0f, 1f);
@@ -181,21 +181,22 @@ public class Renderer implements ApplicationListener{
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());
}
Draw.proj(camera);
beginFx();
//beginFx();
drawBackground();
blocks.floor.checkChanges();
blocks.floor.drawFloor();
Groups.drawFloor();
Groups.drawFloorOver();
//Groups.drawFloor();
//Groups.drawFloorOver();
blocks.processBlocks();
blocks.drawShadows();
@@ -334,8 +335,6 @@ public class Renderer implements ApplicationListener{
}
public void takeMapScreenshot(){
Groups.drawGroundShadows();
int w = world.width() * tilesize, h = world.height() * tilesize;
int memory = w * h * 4 / 1024 / 1024;
+5
View File
@@ -34,4 +34,9 @@ class AllDefs{
class sync{
}
@GroupDef(Drawc.class)
class draw{
}
}
@@ -8,14 +8,14 @@ import mindustry.gen.*;
@EntityDef(value = {Decalc.class}, pooled = true)
@Component
abstract class DecalComp implements Drawc, Timedc, Rotc, Posc, DrawLayerFloorc{
abstract class DecalComp implements Drawc, Timedc, Rotc, Posc{
@Import float x, y, rotation;
Color color = new Color(1, 1, 1, 1);
TextureRegion region;
@Override
public void drawFloor(){
public void draw(){
Draw.color(color);
Draw.alpha(1f - Mathf.curve(fin(), 0.98f));
Draw.rect(region, x, y, rotation);
@@ -6,4 +6,8 @@ import mindustry.gen.*;
@Component
abstract class DrawComp implements Posc{
abstract float clipSize();
void draw(){
}
}
@@ -6,7 +6,7 @@ import mindustry.annotations.Annotations.*;
import mindustry.gen.*;
@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;
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));
walkTime += Time.delta()*len/1f;
}
@Override
public void drawGroundUnder(){
type().drawLegs(this);
}
}
@@ -17,7 +17,7 @@ import mindustry.world.*;
import static mindustry.Vars.*;
@Component
abstract class MinerComp implements Itemsc, Posc, Teamc, Rotc, DrawLayerGroundc{
abstract class MinerComp implements Itemsc, Posc, Teamc, Rotc, Drawc{
@Import float x, y, rotation;
transient float mineTimer;
@@ -80,7 +80,7 @@ abstract class MinerComp implements Itemsc, Posc, Teamc, Rotc, DrawLayerGroundc{
}
@Override
public void drawGround(){
public void draw(){
if(!mining()) return;
float focusLen = 4f + Mathf.absin(Time.time(), 1.1f, 0.5f);
float swingScl = 12f, swingMag = tilesize / 8f;
+2 -28
View File
@@ -18,8 +18,7 @@ import mindustry.world.blocks.environment.*;
import static mindustry.Vars.*;
@Component
abstract class UnitComp implements Healthc, Velc, Statusc, Teamc, Itemsc, Hitboxc, Rotc, Massc, Unitc, Weaponsc, Drawc, Boundedc,
DrawLayerGroundc, DrawLayerFlyingc, DrawLayerGroundShadowsc, DrawLayerFlyingShadowsc, Syncc{
abstract class UnitComp implements Healthc, Velc, Statusc, Teamc, Itemsc, Hitboxc, Rotc, Massc, Unitc, Weaponsc, Drawc, Boundedc, Syncc{
@Import float x, y, rotation, elevation;
private UnitController controller;
@@ -172,32 +171,7 @@ abstract class UnitComp implements Healthc, Velc, Statusc, Teamc, Itemsc, Hitbox
@Override
public void draw(){
type.drawEngine(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();
type.draw(this);
}
@Override
@@ -29,8 +29,8 @@ public class BlockRenderer implements Disposable{
private int lastCamX, lastCamY, lastRangeX, lastRangeY;
private float brokenFade = 0f;
private FrameBuffer shadows = new FrameBuffer(2, 2);
private FrameBuffer fog = new FrameBuffer(2, 2);
private FrameBuffer shadows = new FrameBuffer();
private FrameBuffer fog = new FrameBuffer();
private Array<Tilec> outArray2 = new Array<>();
private Array<Tile> shadowEvents = new Array<>();
private boolean displayStatus = false;
@@ -8,6 +8,7 @@ import arc.graphics.gl.*;
import static mindustry.Vars.renderer;
public enum CacheLayer{
//TODO water animation breaks when tar/slag is present
water{
@Override
public void begin(){
@@ -17,7 +17,7 @@ public class LightRenderer{
private static final int scaling = 4;
private float[] vertices = new float[24];
private FrameBuffer buffer = new FrameBuffer(2, 2);
private FrameBuffer buffer = new FrameBuffer();
private Array<Runnable> lights = new Array<>();
public void add(Runnable run){
@@ -185,9 +185,7 @@ public class LightRenderer{
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();
buffer.begin(Color.clear);
+2 -4
View File
@@ -12,7 +12,7 @@ import static arc.Core.*;
import static mindustry.Vars.renderer;
public class Pixelator implements Disposable{
private FrameBuffer buffer = new FrameBuffer(2, 2);
private FrameBuffer buffer = new FrameBuffer();
{
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 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();
renderer.draw();
+15
View File
@@ -114,6 +114,21 @@ public class UnitType extends UnlockableContent{
//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){
Draw.color(shadowColor);
Draw.rect(region, unit.x() + shadowTX * unit.elevation(), unit.y() + shadowTY * unit.elevation(), unit.rotation() - 90);