From 87518dec836d21a5b37a740f11c5d21507314180 Mon Sep 17 00:00:00 2001 From: cb3hjb Date: Thu, 2 Apr 2026 17:46:47 +0200 Subject: [PATCH 1/2] prediction of rotation added --- .../lua/vehicle/extensions/kiss_mp/kiss_transforms.lua | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/KISSMultiplayer/lua/vehicle/extensions/kiss_mp/kiss_transforms.lua b/KISSMultiplayer/lua/vehicle/extensions/kiss_mp/kiss_transforms.lua index 2b69cecd..bf7d0861 100644 --- a/KISSMultiplayer/lua/vehicle/extensions/kiss_mp/kiss_transforms.lua +++ b/KISSMultiplayer/lua/vehicle/extensions/kiss_mp/kiss_transforms.lua @@ -26,6 +26,7 @@ M.ang_force = 100 M.debug = false M.lerp_factor = 30.0 + local function predict(dt) M.target_transform.velocity = M.received_transform.velocity + M.received_transform.acceleration * M.received_transform.time_past local distance = M.target_transform.position:distance(vec3(obj:getPosition())) @@ -36,9 +37,11 @@ local function predict(dt) M.target_transform.position = p end - --M.target_transform.angular_velocity = M.received_transform.angular_velocity + M.received_transform.angular_acceleration * M.received_transform.time_past - --local rotation_delta = M.target_transform.angular_velocity * M.received_transform.time_past - M.target_transform.rotation = quat(M.received_transform.rotation)-- * quatFromEuler(rotation_delta.x, rotation_delta.y, rotation_delta.z) + local rotation_delta = (M.received_transform.angular_velocity + M.received_transform.angular_acceleration * M.received_transform.time_past) * M.received_transform.time_past + + if rotation_delta:length() > 0 then local axis = rotation_delta:normalized() local half_angle = rotation_delta:length() * 0.5 local q_delta = quat(axis.x * math.sin(half_angle), axis.y * math.sin(half_angle), axis.z * math.sin(half_angle), math.cos(half_angle)) + + M.target_transform.rotation = quat(M.received_transform.rotation) * q_delta end local function try_rude() From 6e7cfef8aacc082151d22d2999df203bdad8321a Mon Sep 17 00:00:00 2001 From: cb3hjb Date: Thu, 2 Apr 2026 21:55:26 +0200 Subject: [PATCH 2/2] prediction of rotation added but its maybe not broken --- .../vehicle/extensions/kiss_mp/kiss_transforms.lua | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/KISSMultiplayer/lua/vehicle/extensions/kiss_mp/kiss_transforms.lua b/KISSMultiplayer/lua/vehicle/extensions/kiss_mp/kiss_transforms.lua index bf7d0861..14bc99df 100644 --- a/KISSMultiplayer/lua/vehicle/extensions/kiss_mp/kiss_transforms.lua +++ b/KISSMultiplayer/lua/vehicle/extensions/kiss_mp/kiss_transforms.lua @@ -26,7 +26,6 @@ M.ang_force = 100 M.debug = false M.lerp_factor = 30.0 - local function predict(dt) M.target_transform.velocity = M.received_transform.velocity + M.received_transform.acceleration * M.received_transform.time_past local distance = M.target_transform.position:distance(vec3(obj:getPosition())) @@ -37,11 +36,17 @@ local function predict(dt) M.target_transform.position = p end + --M.target_transform.angular_velocity = M.received_transform.angular_velocity + M.received_transform.angular_acceleration * M.received_transform.time_past + --local rotation_delta = M.target_transform.angular_velocity * M.received_transform.time_past + local rotation_delta = (M.received_transform.angular_velocity + M.received_transform.angular_acceleration * M.received_transform.time_past) * M.received_transform.time_past - if rotation_delta:length() > 0 then local axis = rotation_delta:normalized() local half_angle = rotation_delta:length() * 0.5 local q_delta = quat(axis.x * math.sin(half_angle), axis.y * math.sin(half_angle), axis.z * math.sin(half_angle), math.cos(half_angle)) - - M.target_transform.rotation = quat(M.received_transform.rotation) * q_delta + if rotation_delta:length() > 0 then + local axis = rotation_delta:normalized() + local half_angle = rotation_delta:length() * 0.5 + local q_delta = quat(axis.x * math.sin(half_angle), axis.y * math.sin(half_angle), axis.z * math.sin(half_angle), math.cos(half_angle)) + M.target_transform.rotation = quat(M.received_transform.rotation) * q_delta + end end local function try_rude()