mirror of
https://github.com/PixelGuys/Cubyz.git
synced 2025-09-09 03:59:53 -04:00
I forgot to update the itemdrops...
This commit is contained in:
parent
be52c1054d
commit
4769e9cb52
@ -17,6 +17,8 @@ const Vec4f = vec.Vec4f;
|
||||
|
||||
pub const ClientEntity = struct {
|
||||
interpolatedValues: utils.GenericInterpolation(6) = undefined,
|
||||
_interpolationPos: [6]f64 = undefined,
|
||||
_interpolationVel: [6]f64 = undefined,
|
||||
|
||||
width: f64,
|
||||
height: f64,
|
||||
@ -30,7 +32,7 @@ pub const ClientEntity = struct {
|
||||
name: []const u8,
|
||||
|
||||
pub fn init(self: *ClientEntity) void {
|
||||
const pos = [_]f64 {
|
||||
self._interpolationPos = [_]f64 {
|
||||
self.pos[0],
|
||||
self.pos[1],
|
||||
self.pos[2],
|
||||
@ -38,7 +40,8 @@ pub const ClientEntity = struct {
|
||||
@floatCast(f64, self.rot[1]),
|
||||
@floatCast(f64, self.rot[2]),
|
||||
};
|
||||
self.interpolatedValues.initPosition(&pos);
|
||||
self._interpolationVel = [_]f64{0} ** 6;
|
||||
self.interpolatedValues.init(&self._interpolationPos, &self._interpolationVel);
|
||||
}
|
||||
|
||||
pub fn getRenderPosition(self: *const ClientEntity) Vec3d {
|
||||
|
@ -499,7 +499,7 @@ pub const ClientItemDropManager = struct {
|
||||
pub fn updateInterpolationData(self: *ClientItemDropManager) void {
|
||||
var time = @truncate(i16, std.time.milliTimestamp()) -% settings.entityLookback;
|
||||
time -%= self.timeDifference.difference;
|
||||
self.interpolation.updateIndexed(time, self.lastTime, &self.super.indices, 3);
|
||||
self.interpolation.updateIndexed(time, self.lastTime, &self.super.indices, 4);
|
||||
self.lastTime = time;
|
||||
}
|
||||
|
||||
@ -719,6 +719,7 @@ pub const ItemDropRenderer = struct {
|
||||
}
|
||||
|
||||
pub fn renderItemDrops(projMatrix: Mat4f, ambientLight: Vec3f, playerPos: Vec3d, time: u32) !void {
|
||||
game.world.?.itemDrops.updateInterpolationData();
|
||||
itemShader.bind();
|
||||
c.glUniform1i(itemUniforms.texture_sampler, 0);
|
||||
c.glUniform1i(itemUniforms.emissionSampler, 1);
|
||||
|
@ -457,23 +457,14 @@ pub fn GenericInterpolation(comptime elements: comptime_int) type {
|
||||
lastTimes: [frames]i16,
|
||||
frontIndex: u32,
|
||||
currentPoint: ?u31,
|
||||
outPos: [elements]f64,
|
||||
outVel: [elements]f64,
|
||||
outPos: *[elements]f64,
|
||||
outVel: *[elements]f64,
|
||||
|
||||
pub fn initPosition(self: *@This(), initialPosition: *const [elements]f64) void {
|
||||
std.mem.copy(f64, &self.outPos, initialPosition);
|
||||
std.mem.set([elements]f64, &self.lastPos, self.outPos);
|
||||
std.mem.set(f64, &self.outVel, 0);
|
||||
std.mem.set([elements]f64, &self.lastVel, self.outVel);
|
||||
self.frontIndex = 0;
|
||||
self.currentPoint = null;
|
||||
}
|
||||
|
||||
pub fn init(self: *@This(), initialPosition: *const [elements]f64, initialVelocity: *const [elements]f64) void {
|
||||
std.mem.copy(f64, &self.outPos, initialPosition);
|
||||
std.mem.set([elements]f64, &self.lastPos, self.outPos);
|
||||
std.mem.copy(f64, &self.outVel, initialVelocity);
|
||||
std.mem.set([elements]f64, &self.lastVel, self.outVel);
|
||||
pub fn init(self: *@This(), initialPosition: *[elements]f64, initialVelocity: *[elements]f64) void {
|
||||
self.outPos = initialPosition;
|
||||
self.outVel = initialVelocity;
|
||||
std.mem.set([elements]f64, &self.lastPos, self.outPos.*);
|
||||
std.mem.set([elements]f64, &self.lastVel, self.outVel.*);
|
||||
self.frontIndex = 0;
|
||||
self.currentPoint = null;
|
||||
}
|
||||
@ -517,8 +508,8 @@ pub fn GenericInterpolation(comptime elements: comptime_int) type {
|
||||
if(self.currentPoint != null and self.lastTimes[self.currentPoint.?] -% time <= 0) {
|
||||
// Jump to the last used value and adjust the time to start at that point.
|
||||
lastTime.* = self.lastTimes[self.currentPoint.?];
|
||||
std.mem.copy(f64, &self.outPos, &self.lastPos[self.currentPoint.?]);
|
||||
std.mem.copy(f64, &self.outVel, &self.lastVel[self.currentPoint.?]);
|
||||
std.mem.copy(f64, self.outPos, &self.lastPos[self.currentPoint.?]);
|
||||
std.mem.copy(f64, self.outVel, &self.lastVel[self.currentPoint.?]);
|
||||
self.currentPoint = null;
|
||||
}
|
||||
|
||||
@ -563,7 +554,7 @@ pub fn GenericInterpolation(comptime elements: comptime_int) type {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn updateIndexed(self: *@This(), time: i16, _lastTime: i16, indices: []u16, coordinatesPerIndex: comptime_int) void {
|
||||
pub fn updateIndexed(self: *@This(), time: i16, _lastTime: i16, indices: []u16, comptime coordinatesPerIndex: comptime_int) void {
|
||||
var lastTime = _lastTime;
|
||||
self.determineNextDataPoint(time, &lastTime);
|
||||
|
||||
@ -575,7 +566,7 @@ pub fn GenericInterpolation(comptime elements: comptime_int) type {
|
||||
|
||||
if(self.currentPoint == null) {
|
||||
for(indices) |i| {
|
||||
const index = i*coordinatesPerIndex;
|
||||
const index = @as(usize, i)*coordinatesPerIndex;
|
||||
var j: u32 = 0;
|
||||
while(j < coordinatesPerIndex): (j += 1) {
|
||||
// Just move on with the current velocity.
|
||||
@ -588,7 +579,7 @@ pub fn GenericInterpolation(comptime elements: comptime_int) type {
|
||||
const tScale = @intToFloat(f64, self.lastTimes[self.currentPoint.?] -% lastTime)/1000;
|
||||
const t = deltaTime;
|
||||
for(indices) |i| {
|
||||
const index = i*coordinatesPerIndex;
|
||||
const index = @as(usize, i)*coordinatesPerIndex;
|
||||
var j: u32 = 0;
|
||||
while(j < coordinatesPerIndex): (j += 1) {
|
||||
self.interpolateCoordinate(index + j, t, tScale);
|
||||
|
Loading…
x
Reference in New Issue
Block a user