Various rendering improvements
This commit is contained in:
@@ -93,7 +93,6 @@ public class Vars{
|
||||
public static boolean headless = false;
|
||||
public static float controllerMin = 0.25f;
|
||||
public static float baseControllerSpeed = 11f;
|
||||
public static boolean snapCamera = true;
|
||||
|
||||
public static ContentLoader content;
|
||||
public static GameState state;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package io.anuke.mindustry.core;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
||||
import com.badlogic.gdx.math.Rectangle;
|
||||
@@ -53,6 +52,7 @@ public class Renderer extends RendererModule{
|
||||
|
||||
public Renderer(){
|
||||
Core.batch = new SpriteBatch(4096);
|
||||
Graphics.setScaleEffects(false);
|
||||
|
||||
Lines.setCircleVertices(14);
|
||||
|
||||
@@ -109,7 +109,7 @@ public class Renderer extends RendererModule{
|
||||
|
||||
clearColor = new Color(0f, 0f, 0f, 1f);
|
||||
|
||||
effectSurface = Graphics.createSurface(Core.cameraScale);
|
||||
effectSurface = Graphics.createSurface(1);
|
||||
pixelSurface = Graphics.createSurface(Core.cameraScale);
|
||||
}
|
||||
|
||||
@@ -147,35 +147,17 @@ public class Renderer extends RendererModule{
|
||||
if(core != null && players[0].spawner == -1){
|
||||
smoothCamera(core.x, core.y, 0.08f);
|
||||
}else{
|
||||
smoothCamera(position.x + 0.0001f, position.y + 0.0001f, 0.08f);
|
||||
smoothCamera(position.x, position.y, 0.08f);
|
||||
}
|
||||
}else if(!mobile){
|
||||
setCamera(position.x + 0.0001f, position.y + 0.0001f);
|
||||
smoothCamera(position.x, position.y, 0.08f);
|
||||
}
|
||||
camera.position.x = Mathf.clamp(camera.position.x, -tilesize / 2f, world.width() * tilesize - tilesize / 2f);
|
||||
camera.position.y = Mathf.clamp(camera.position.y, -tilesize / 2f, world.height() * tilesize - tilesize / 2f);
|
||||
|
||||
float prex = camera.position.x, prey = camera.position.y;
|
||||
updateShake(0.75f);
|
||||
|
||||
float deltax = camera.position.x - prex, deltay = camera.position.y - prey;
|
||||
float lastx = camera.position.x, lasty = camera.position.y;
|
||||
|
||||
if(snapCamera){
|
||||
camera.position.set((int) camera.position.x, (int) camera.position.y, 0);
|
||||
}
|
||||
|
||||
if(Gdx.graphics.getHeight() / Core.cameraScale % 2 == 1){
|
||||
camera.position.add(0, -0.5f, 0);
|
||||
}
|
||||
|
||||
if(Gdx.graphics.getWidth() / Core.cameraScale % 2 == 1){
|
||||
camera.position.add(-0.5f, 0, 0);
|
||||
}
|
||||
|
||||
draw();
|
||||
|
||||
camera.position.set(lastx - deltax, lasty - deltay, 0);
|
||||
}
|
||||
|
||||
if(!ui.chatfrag.chatOpen()){
|
||||
@@ -310,10 +292,10 @@ public class Renderer extends RendererModule{
|
||||
Shaders.mix.color.set(Color.WHITE);
|
||||
|
||||
//Graphics.beginShaders(Shaders.outline);
|
||||
//Graphics.shader(Shaders.mix, true);
|
||||
Graphics.shader(Shaders.mix, true);
|
||||
drawAndInterpolate(unitGroups[team.ordinal()], u -> u.isFlying() == flying && !u.isDead(), Unit::drawAll);
|
||||
drawAndInterpolate(playerGroup, p -> p.isFlying() == flying && p.getTeam() == team, Unit::drawAll);
|
||||
//Graphics.shader();
|
||||
Graphics.shader();
|
||||
blocks.drawTeamBlocks(Layer.turret, team);
|
||||
// Graphics.endShaders();
|
||||
|
||||
@@ -362,10 +344,6 @@ public class Renderer extends RendererModule{
|
||||
public void setCameraScale(int amount){
|
||||
targetscale = amount;
|
||||
clampScale();
|
||||
//scale up all surfaces in preparation for the zoom
|
||||
for(Surface surface : Graphics.getSurfaces()){
|
||||
surface.setScale(targetscale);
|
||||
}
|
||||
}
|
||||
|
||||
public void scaleCamera(int amount){
|
||||
|
||||
@@ -30,6 +30,7 @@ import io.anuke.ucore.core.*;
|
||||
import io.anuke.ucore.entities.EntityGroup;
|
||||
import io.anuke.ucore.entities.EntityQuery;
|
||||
import io.anuke.ucore.graphics.Draw;
|
||||
import io.anuke.ucore.graphics.Fill;
|
||||
import io.anuke.ucore.graphics.Hue;
|
||||
import io.anuke.ucore.graphics.Lines;
|
||||
import io.anuke.ucore.util.*;
|
||||
@@ -385,11 +386,11 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
||||
}
|
||||
|
||||
public float snappedX(){
|
||||
return snapCamera && isLocal ? (int) (x + 0.0001f) : x;
|
||||
return x;
|
||||
}
|
||||
|
||||
public float snappedY(){
|
||||
return snapCamera && isLocal ? (int) (y + 0.0001f) : y;
|
||||
return y;
|
||||
}
|
||||
|
||||
public void drawName(){
|
||||
|
||||
@@ -34,12 +34,7 @@ public class OverlayRenderer{
|
||||
|
||||
if(!input.isDrawing() || player.isDead()) continue;
|
||||
|
||||
Shaders.outline.color.set(Palette.accent);
|
||||
Graphics.beginShaders(Shaders.outline);
|
||||
|
||||
input.drawOutlined();
|
||||
|
||||
Graphics.endShaders();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -257,15 +257,16 @@ public class PowerNode extends PowerBlock{
|
||||
Draw.color(Palette.power, Palette.powerLight, Mathf.absin(Timers.time(), 5f, 1f));
|
||||
Lines.stroke(1f);
|
||||
|
||||
for(int i = 0; i < segments; i++){
|
||||
float f1 = (float)i / segments;
|
||||
float f2 = (float)(i+1) / segments;
|
||||
t1.trns(angle1 + 90f, Mathf.lerp(Mathf.sin(tile.entity.id * 124f + Timers.time()/tscl + f1 * space, scl, mag), 0f, Math.abs(f1 - 0.5f)*2f));
|
||||
t2.trns(angle1 + 90f, Mathf.lerp(Mathf.sin(tile.entity.id * 124f + Timers.time()/tscl + f2 * space, scl, mag), 0f, Math.abs(f2 - 0.5f)*2f));
|
||||
Lines.beginLine();
|
||||
|
||||
Lines.line(x1 + (x2 - x1) * f1 + t1.x, y1 + (y2 - y1) * f1 + t1.y,
|
||||
x1 + (x2 - x1) * f2 + t2.x, y1 + (y2 - y1) * f2 + t2.y);
|
||||
for(int i = 0; i < segments + 1; i++){
|
||||
float f1 = (float)i / segments;
|
||||
t1.trns(angle1 + 90f, Mathf.lerp(Mathf.sin(tile.entity.id * 124f + Timers.time()/tscl + f1 * space, scl, mag), 0f, Math.abs(f1 - 0.5f)*2f));
|
||||
|
||||
Lines.linePoint(x1 + (x2 - x1) * f1 + t1.x, y1 + (y2 - y1) * f1 + t1.y);
|
||||
}
|
||||
|
||||
Lines.endLine();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,17 +1,12 @@
|
||||
package io.anuke.mindustry.world.blocks.storage;
|
||||
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import io.anuke.mindustry.entities.TileEntity;
|
||||
import io.anuke.mindustry.entities.Unit;
|
||||
import io.anuke.mindustry.graphics.Palette;
|
||||
import io.anuke.mindustry.graphics.Shaders;
|
||||
import io.anuke.mindustry.type.Item;
|
||||
import io.anuke.mindustry.world.BarType;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.ucore.core.Graphics;
|
||||
import io.anuke.ucore.graphics.Draw;
|
||||
import io.anuke.ucore.graphics.Fill;
|
||||
|
||||
import static io.anuke.mindustry.Vars.tilesize;
|
||||
@@ -60,16 +55,16 @@ public abstract class StorageBlock extends Block{
|
||||
|
||||
if(entity.graph.getTiles().size > 1){
|
||||
|
||||
Shaders.outline.color.set(Palette.accent);
|
||||
Graphics.beginShaders(Shaders.outline);
|
||||
//Shaders.outline.color.set(Palette.accent);
|
||||
//Graphics.beginShaders(Shaders.outline);
|
||||
|
||||
for(Tile other : entity.graph.getTiles()){
|
||||
Fill.square(other.drawx(), other.drawy(), other.block().size * tilesize);
|
||||
}
|
||||
|
||||
Draw.color(Color.CLEAR);
|
||||
Graphics.endShaders();
|
||||
Draw.color();
|
||||
// Draw.color(Color.CLEAR);
|
||||
//Graphics.endShaders();
|
||||
//Draw.color();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user