normalize touch camera and do this minor inlining

This commit is contained in:
RandomityGuy 2026-03-30 17:41:19 +01:00
parent e4039cc16c
commit b6e42ce9c6
3 changed files with 22 additions and 22 deletions

View file

@ -16,7 +16,7 @@ class InputBitStream {
this.shift = 0;
}
function readBits(bits:Int = 8) {
inline function readBits(bits:Int = 8) {
if (this.shift + bits >= 8) {
var extra = (this.shift + bits) % 8;
var remain = bits - extra;
@ -37,7 +37,7 @@ class InputBitStream {
}
}
public function readInt(bits:Int = 32) {
public inline function readInt(bits:Int = 32) {
var value = 0;
var shift = 0;
while (bits > 0) {
@ -48,33 +48,33 @@ class InputBitStream {
return value;
}
public function readFlag() {
public inline function readFlag() {
return readInt(1) != 0;
}
public function readByte() {
public inline function readByte() {
return readInt(8);
}
public function readUInt16() {
public inline function readUInt16() {
return readInt(16);
}
public function readInt32() {
public inline function readInt32() {
return readInt(32);
}
public function readFloat() {
public inline function readFloat() {
return FPHelper.i32ToFloat(readInt32());
}
public function readDouble() {
public inline function readDouble() {
var lo = readInt32();
var hi = readInt32();
return FPHelper.i64ToDouble(lo, hi);
}
public function readString() {
public inline function readString() {
var length = readUInt16();
var str = "";
var buf = new StringBuf();
@ -100,7 +100,7 @@ class OutputBitStream {
this.lastByte = 0;
}
function writeBits(value:Int, bits:Int) {
inline function writeBits(value:Int, bits:Int) {
value = value & (0xFF >> (8 - bits));
if (this.shift + bits >= 8) {
var extra = (shift + bits) % 8;
@ -119,7 +119,7 @@ class OutputBitStream {
}
}
public function writeInt(value:Int, bits:Int = 32) {
public inline function writeInt(value:Int, bits:Int = 32) {
while (bits > 0) {
this.writeBits(value & 0xFF, bits < 8 ? bits : 8);
value >>= 8;
@ -127,39 +127,39 @@ class OutputBitStream {
}
}
public function writeFlag(value:Bool) {
public inline function writeFlag(value:Bool) {
writeInt(value ? 1 : 0, 1);
}
public function writeByte(value:Int) {
public inline function writeByte(value:Int) {
writeInt(value, 8);
}
public function writeUInt16(value:Int) {
public inline function writeUInt16(value:Int) {
writeInt(value, 16);
}
public function writeInt32(value:Int) {
public inline function writeInt32(value:Int) {
writeInt(value, 32);
}
public function getBytes() {
public inline function getBytes() {
this.data.writeByte(this.lastByte);
return this.data.getBytes();
}
public function writeFloat(value:Float) {
public inline function writeFloat(value:Float) {
writeInt(FPHelper.floatToI32(value), 32);
}
public function writeString(value:String) {
public inline function writeString(value:String) {
writeUInt16(value.length);
for (i in 0...value.length) {
writeByte(StringTools.fastCodeAt(value, i));
}
}
public function writeDouble(value:Float) {
public inline function writeDouble(value:Float) {
var i64 = FPHelper.doubleToI64(value);
writeInt32(i64.low);
writeInt32(i64.high);

View file

@ -147,7 +147,7 @@ class MoveManager {
return netMove;
}
function copyMove(to:Int, from:Int) {
inline function copyMove(to:Int, from:Int) {
queuedMoves[to].move = queuedMoves[from].move;
queuedMoves[to].motionDir.load(queuedMoves[from].motionDir);
}

View file

@ -101,8 +101,8 @@ class CameraInput {
var dt = MarbleGame.instance.world.timeState.dt;
MarbleGame.instance.world.marble.camera.orbit(applyNonlinearScale((inpX / dt) * (1 / 60.0)) * (1 / 60.0) * 20,
applyNonlinearScale((inpY / dt) * (1 / 60.0)) * (1 / 60.0) * 20, true);
MarbleGame.instance.world.marble.camera.orbit(applyNonlinearScale((inpX / dt) * (1 / 60.0)) * (1 / 60.0) * 35,
applyNonlinearScale((inpY / dt) * (1 / 60.0)) * (1 / 60.0) * 35, true);
if (inpX != 0)
prevMouse.x = e.relX;