Improved glitchy interpolation / Updated uCore

This commit is contained in:
Anuken
2018-07-12 11:38:09 -04:00
parent b5e8e54107
commit 1f18e7beed
5 changed files with 21 additions and 19 deletions

View File

@ -27,7 +27,7 @@ allprojects {
gdxVersion = '1.9.8'
roboVMVersion = '2.3.0'
aiVersion = '1.8.1'
uCoreVersion = '7673041e62'
uCoreVersion = '05f51b183e'
getVersionString = {
String buildVersion = getBuildVersion()

View File

@ -1,5 +1,6 @@
package io.anuke.mindustry.core;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.utils.Base64Coder;
import com.badlogic.gdx.utils.IntSet;
@ -175,7 +176,7 @@ public class NetClient extends Module {
ui.loadfrag.hide();
ui.join.hide();
Net.setClientLoaded(true);
Call.connectConfirm();
Gdx.app.postRunnable(Call::connectConfirm);
Timers.runTask(40f, Platform.instance::updateRPC);
}

View File

@ -1,7 +1,7 @@
package io.anuke.mindustry.core;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.Queue;
import com.badlogic.gdx.utils.TimeUtils;
import io.anuke.ucore.core.Timers;
import io.anuke.ucore.util.Log;
@ -10,7 +10,7 @@ import static io.anuke.mindustry.Vars.control;
import static io.anuke.mindustry.Vars.logic;
public class ThreadHandler {
private final Array<Runnable> toRun = new Array<>();
private final Queue<Runnable> toRun = new Queue<>();
private final ThreadProvider impl;
private float delta = 1f;
private float smoothDelta = 1f;
@ -33,7 +33,7 @@ public class ThreadHandler {
public void run(Runnable r){
if(enabled) {
synchronized (toRun) {
toRun.add(r);
toRun.addLast(r);
}
}else{
r.run();
@ -51,7 +51,7 @@ public class ThreadHandler {
public void runDelay(Runnable r){
if(enabled) {
synchronized (toRun) {
toRun.add(r);
toRun.addLast(r);
}
}else{
Gdx.app.postRunnable(r);
@ -103,7 +103,7 @@ public class ThreadHandler {
}
public boolean doInterpolate(){
return enabled && Math.abs(Gdx.graphics.getFramesPerSecond() - getTPS()) > 15;
return enabled && Gdx.graphics.getFramesPerSecond() - getTPS() > 20 && getTPS() < 30;
}
public boolean isOnThread(){
@ -119,13 +119,12 @@ public class ThreadHandler {
Runnable r;
synchronized (toRun){
if(toRun.size > 0){
r = toRun.pop();
r = toRun.removeFirst();
}else{
r = null;
break;
}
}
if(r == null) break;
r.run();
}

View File

@ -542,7 +542,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
pointerY = vec.y;
updateShooting();
movement.limit(speed);
movement.limit(speed * Timers.delta());
if(getCarrier() == null){
velocity.add(movement);
@ -751,13 +751,12 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
public void write(DataOutput buffer) throws IOException {
super.writeSave(buffer, !isLocal);
buffer.writeUTF(name); //TODO writing strings is very inefficient
buffer.writeBoolean(isAdmin);
buffer.writeByte(Bits.toByte(isAdmin) | (Bits.toByte(dead) << 1) | (Bits.toByte(isBoosting) << 2));
buffer.writeInt(Color.rgba8888(color));
buffer.writeBoolean(dead);
buffer.writeByte(mech.id);
buffer.writeBoolean(isBoosting);
buffer.writeInt(mining == null ? -1 : mining.packedPosition());
buffer.writeInt(spawner);
buffer.writeShort((short)(baseRotation * 2));
writeBuilding(buffer);
}
@ -767,17 +766,19 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
float lastx = x, lasty = y, lastrot = rotation;
super.readSave(buffer);
name = buffer.readUTF();
isAdmin = buffer.readBoolean();
byte bools = buffer.readByte();
isAdmin = (bools & 1) != 0;
dead = (bools & 2) != 0;
boolean boosting = (bools & 4) != 0;
color.set(buffer.readInt());
dead = buffer.readBoolean();
mech = Upgrade.getByID(buffer.readByte());
boolean boosting = buffer.readBoolean();
int mine = buffer.readInt();
spawner = buffer.readInt();
float baseRotation = buffer.readShort()/2f;
readBuilding(buffer, !isLocal);
interpolator.read(lastx, lasty, x, y, time, rotation);
interpolator.read(lastx, lasty, x, y, time, rotation, baseRotation);
rotation = lastrot;
if(isLocal){

View File

@ -38,11 +38,12 @@ public class Interpolator {
public void update(){
/*
if(pos.dst(target) > 128){
pos.set(target);
lastUpdated = 0;
updateSpacing = 16;
}
}*/
if(lastUpdated != 0 && updateSpacing != 0){
float timeSinceUpdate = TimeUtils.timeSinceMillis(lastUpdated);