Optimizations
This commit is contained in:
@@ -27,7 +27,7 @@ allprojects {
|
|||||||
gdxVersion = '1.9.8'
|
gdxVersion = '1.9.8'
|
||||||
roboVMVersion = '2.3.0'
|
roboVMVersion = '2.3.0'
|
||||||
aiVersion = '1.8.1'
|
aiVersion = '1.8.1'
|
||||||
uCoreVersion = 'e1749b8798'
|
uCoreVersion = '7673041e62'
|
||||||
|
|
||||||
getVersionString = {
|
getVersionString = {
|
||||||
String buildVersion = getBuildVersion()
|
String buildVersion = getBuildVersion()
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ precision mediump float;
|
|||||||
precision mediump int;
|
precision mediump int;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define SPACE 1.0
|
||||||
|
|
||||||
uniform sampler2D u_texture;
|
uniform sampler2D u_texture;
|
||||||
|
|
||||||
uniform vec4 u_color;
|
uniform vec4 u_color;
|
||||||
@@ -11,30 +13,15 @@ uniform vec2 u_texsize;
|
|||||||
varying vec4 v_color;
|
varying vec4 v_color;
|
||||||
varying vec2 v_texCoord;
|
varying vec2 v_texCoord;
|
||||||
|
|
||||||
bool id(vec4 v){
|
|
||||||
return v.a > 0.1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
|
|
||||||
vec2 T = v_texCoord.xy;
|
|
||||||
|
|
||||||
vec2 v = vec2(1.0/u_texsize.x, 1.0/u_texsize.y);
|
vec2 v = vec2(1.0/u_texsize.x, 1.0/u_texsize.y);
|
||||||
|
|
||||||
bool any = false;
|
vec4 c = texture2D(u_texture, v_texCoord.xy);
|
||||||
|
|
||||||
float step = 1.0;
|
gl_FragColor = mix(c * v_color, u_color,
|
||||||
|
(1.0-step(0.1, texture2D(u_texture, v_texCoord.xy).a)) *
|
||||||
vec4 c = texture2D(u_texture, T);
|
step(0.1, texture2D(u_texture, v_texCoord.xy + vec2(0, SPACE) * v).a +
|
||||||
|
texture2D(u_texture, v_texCoord.xy + vec2(0, -SPACE) * v).a +
|
||||||
if(texture2D(u_texture, T).a < 0.1 &&
|
texture2D(u_texture, v_texCoord.xy + vec2(SPACE, 0) * v).a +
|
||||||
(id(texture2D(u_texture, T + vec2(0, step) * v)) || id(texture2D(u_texture, T + vec2(0, -step) * v)) ||
|
texture2D(u_texture, v_texCoord.xy + vec2(-SPACE, 0) * v).a));
|
||||||
id(texture2D(u_texture, T + vec2(step, 0) * v)) || id(texture2D(u_texture, T + vec2(-step, 0) * v))))
|
|
||||||
any = true;
|
|
||||||
|
|
||||||
if(any){
|
|
||||||
gl_FragColor = u_color;
|
|
||||||
}else{
|
|
||||||
gl_FragColor = c * v_color;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -253,7 +253,7 @@ public class Renderer extends RendererModule{
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void drawFlyerShadows(){
|
private void drawFlyerShadows(){
|
||||||
Graphics.surface(effectSurface);
|
Graphics.surface(effectSurface, true, false);
|
||||||
|
|
||||||
float trnsX = 12, trnsY = -13;
|
float trnsX = 12, trnsY = -13;
|
||||||
|
|
||||||
@@ -263,12 +263,12 @@ public class Renderer extends RendererModule{
|
|||||||
|
|
||||||
for(EntityGroup<? extends BaseUnit> group : unitGroups){
|
for(EntityGroup<? extends BaseUnit> group : unitGroups){
|
||||||
if(!group.isEmpty()){
|
if(!group.isEmpty()){
|
||||||
drawAndInterpolate(group, Unit::isFlying, Unit::drawShadow);
|
drawAndInterpolate(group, unit -> unit.isFlying() && !unit.isDead(), Unit::drawShadow);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!playerGroup.isEmpty()){
|
if(!playerGroup.isEmpty()){
|
||||||
drawAndInterpolate(playerGroup, Unit::isFlying, Unit::drawShadow);
|
drawAndInterpolate(playerGroup, unit -> unit.isFlying() && !unit.isDead(), Unit::drawShadow);
|
||||||
}
|
}
|
||||||
|
|
||||||
Graphics.end();
|
Graphics.end();
|
||||||
|
|||||||
@@ -4,10 +4,6 @@ import com.badlogic.gdx.Gdx;
|
|||||||
import com.badlogic.gdx.utils.Array;
|
import com.badlogic.gdx.utils.Array;
|
||||||
import com.badlogic.gdx.utils.TimeUtils;
|
import com.badlogic.gdx.utils.TimeUtils;
|
||||||
import io.anuke.ucore.core.Timers;
|
import io.anuke.ucore.core.Timers;
|
||||||
import io.anuke.ucore.entities.Entities;
|
|
||||||
import io.anuke.ucore.entities.EntityGroup;
|
|
||||||
import io.anuke.ucore.entities.EntityGroup.ArrayContainer;
|
|
||||||
import io.anuke.ucore.entities.trait.Entity;
|
|
||||||
import io.anuke.ucore.util.Log;
|
import io.anuke.ucore.util.Log;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.control;
|
import static io.anuke.mindustry.Vars.control;
|
||||||
@@ -89,9 +85,6 @@ public class ThreadHandler {
|
|||||||
public void setEnabled(boolean enabled){
|
public void setEnabled(boolean enabled){
|
||||||
if(enabled){
|
if(enabled){
|
||||||
logic.doUpdate = false;
|
logic.doUpdate = false;
|
||||||
for(EntityGroup<?> group : Entities.getAllGroups()){
|
|
||||||
impl.switchContainer(group);
|
|
||||||
}
|
|
||||||
Timers.runTask(2f, () -> {
|
Timers.runTask(2f, () -> {
|
||||||
impl.start(this::runLogic);
|
impl.start(this::runLogic);
|
||||||
this.enabled = true;
|
this.enabled = true;
|
||||||
@@ -99,9 +92,6 @@ public class ThreadHandler {
|
|||||||
}else{
|
}else{
|
||||||
this.enabled = false;
|
this.enabled = false;
|
||||||
impl.stop();
|
impl.stop();
|
||||||
for(EntityGroup<?> group : Entities.getAllGroups()){
|
|
||||||
group.setContainer(new ArrayContainer<>());
|
|
||||||
}
|
|
||||||
Timers.runTask(2f, () -> {
|
Timers.runTask(2f, () -> {
|
||||||
logic.doUpdate = true;
|
logic.doUpdate = true;
|
||||||
});
|
});
|
||||||
@@ -175,6 +165,5 @@ public class ThreadHandler {
|
|||||||
void stop();
|
void stop();
|
||||||
void wait(Object object) throws InterruptedException;
|
void wait(Object object) throws InterruptedException;
|
||||||
void notify(Object object);
|
void notify(Object object);
|
||||||
<T extends Entity> void switchContainer(EntityGroup<T> group);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -374,7 +374,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
|||||||
float wobblyness = 0.6f;
|
float wobblyness = 0.6f;
|
||||||
trail.update(x + Angles.trnsx(rotation + 180f, 5f) + Mathf.range(wobblyness),
|
trail.update(x + Angles.trnsx(rotation + 180f, 5f) + Mathf.range(wobblyness),
|
||||||
y + Angles.trnsy(rotation + 180f, 5f) + Mathf.range(wobblyness));
|
y + Angles.trnsy(rotation + 180f, 5f) + Mathf.range(wobblyness));
|
||||||
trail.draw(mech.trailColor, mech.trailColor, 5f * (isFlying() ? 1f : boostHeat));
|
trail.draw(mech.trailColor, 5f * (isFlying() ? 1f : boostHeat));
|
||||||
}else{
|
}else{
|
||||||
trail.clear();
|
trail.clear();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ public abstract class FlyingUnit extends BaseUnit implements CarryTrait{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void drawOver() {
|
public void drawOver() {
|
||||||
trail.draw(Palette.lightTrail, Palette.lightTrail, 5f);
|
trail.draw(Palette.lightTrail, 5f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ public class Drone extends FlyingUnit implements BuilderTrait {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void drawOver() {
|
public void drawOver() {
|
||||||
trail.draw(Palette.lightTrail, Palette.lightTrail, 3f);
|
trail.draw(Palette.lightTrail, 3f);
|
||||||
|
|
||||||
TargetTrait entity = target;
|
TargetTrait entity = target;
|
||||||
|
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ public class BlockRenderer{
|
|||||||
|
|
||||||
int expandr = 4;
|
int expandr = 4;
|
||||||
|
|
||||||
Graphics.surface(renderer.effectSurface);
|
Graphics.surface(renderer.effectSurface, true, false);
|
||||||
|
|
||||||
int avgx = Mathf.scl(camera.position.x, tilesize);
|
int avgx = Mathf.scl(camera.position.x, tilesize);
|
||||||
int avgy = Mathf.scl(camera.position.y, tilesize);
|
int avgy = Mathf.scl(camera.position.y, tilesize);
|
||||||
|
|||||||
@@ -40,7 +40,8 @@ public class Trail {
|
|||||||
points.clear();
|
points.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void draw(Color start, Color end, float stroke){
|
public synchronized void draw(Color color, float stroke){
|
||||||
|
Draw.color(color);
|
||||||
|
|
||||||
for(int i = 0; i < points.size - 2; i += 2){
|
for(int i = 0; i < points.size - 2; i += 2){
|
||||||
float x = points.get(i);
|
float x = points.get(i);
|
||||||
@@ -49,8 +50,6 @@ public class Trail {
|
|||||||
float y2 = points.get(i + 3);
|
float y2 = points.get(i + 3);
|
||||||
float s = Mathf.clamp((float)(i) / points.size);
|
float s = Mathf.clamp((float)(i) / points.size);
|
||||||
|
|
||||||
Draw.color(start, end, s);
|
|
||||||
|
|
||||||
Lines.stroke(s * stroke);
|
Lines.stroke(s * stroke);
|
||||||
Lines.line(x, y, x2, y2);
|
Lines.line(x, y, x2, y2);
|
||||||
}
|
}
|
||||||
@@ -59,8 +58,6 @@ public class Trail {
|
|||||||
Fill.circle(points.get(points.size-2), points.get(points.size-1), stroke/2f);
|
Fill.circle(points.get(points.size-2), points.get(points.size-1), stroke/2f);
|
||||||
}
|
}
|
||||||
|
|
||||||
Draw.color(start);
|
|
||||||
|
|
||||||
Draw.reset();
|
Draw.reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package io.anuke.mindustry.ui;
|
package io.anuke.mindustry.ui;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.utils.Align;
|
||||||
import io.anuke.ucore.function.Listenable;
|
import io.anuke.ucore.function.Listenable;
|
||||||
import io.anuke.ucore.scene.ui.ImageButton;
|
import io.anuke.ucore.scene.ui.ImageButton;
|
||||||
|
|
||||||
@@ -10,6 +11,6 @@ public class MobileButton extends ImageButton {
|
|||||||
resizeImage(isize);
|
resizeImage(isize);
|
||||||
clicked(listener);
|
clicked(listener);
|
||||||
row();
|
row();
|
||||||
add(text).growX().wrap();
|
add(text).growX().wrap().center().get().setAlignment(Align.center, Align.center);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,8 @@
|
|||||||
package io.anuke.kryonet;
|
package io.anuke.kryonet;
|
||||||
|
|
||||||
import io.anuke.mindustry.core.ThreadHandler.ThreadProvider;
|
import io.anuke.mindustry.core.ThreadHandler.ThreadProvider;
|
||||||
import io.anuke.ucore.entities.EntityGroup;
|
|
||||||
import io.anuke.ucore.entities.EntityGroup.EntityContainer;
|
|
||||||
import io.anuke.ucore.entities.trait.Entity;
|
|
||||||
import io.anuke.ucore.util.Log;
|
import io.anuke.ucore.util.Log;
|
||||||
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
|
||||||
|
|
||||||
public class DefaultThreadImpl implements ThreadProvider {
|
public class DefaultThreadImpl implements ThreadProvider {
|
||||||
private Thread thread;
|
private Thread thread;
|
||||||
|
|
||||||
@@ -54,42 +48,4 @@ public class DefaultThreadImpl implements ThreadProvider {
|
|||||||
object.notify();
|
object.notify();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public <T extends Entity> void switchContainer(EntityGroup<T> group) {
|
|
||||||
group.setContainer(new ConcurrentContainer<>());
|
|
||||||
}
|
|
||||||
|
|
||||||
static class ConcurrentContainer<T> implements EntityContainer<T>{
|
|
||||||
private CopyOnWriteArrayList<T> list = new CopyOnWriteArrayList<>();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int size() {
|
|
||||||
return list.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void add(T item) {
|
|
||||||
list.add(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void clear() {
|
|
||||||
list.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void remove(T item) {
|
|
||||||
list.remove(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public T get(int index) {
|
|
||||||
return list.get(index);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Iterator<T> iterator() {
|
|
||||||
return list.iterator();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user