From 905097617796be94815eafdaee891f6936360258 Mon Sep 17 00:00:00 2001 From: Anton Dorozhkin Date: Thu, 26 Mar 2026 19:56:34 +0700 Subject: [PATCH] Fix applyTorque world matrix mismatch `PhysObj:ApplyTorqueCenter` expects input multiplied by `q_world_f_core_last_psi`, but `PhysObj:LocalToWorldVector` multiplies input by a matrix interpolated between `q_world_f_core_last_psi` and `q_world_f_core_next_psi`. `AddAngleVelocity` expects local space input which matches the Wiremod `applyTorque` input. We only need to convert torque to velocity dividing it by `rot_inertia`. --- lua/entities/gmod_wire_expression2/core/entity.lua | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lua/entities/gmod_wire_expression2/core/entity.lua b/lua/entities/gmod_wire_expression2/core/entity.lua index ef6c0583ce..9b1d8cb705 100644 --- a/lua/entities/gmod_wire_expression2/core/entity.lua +++ b/lua/entities/gmod_wire_expression2/core/entity.lua @@ -737,10 +737,8 @@ e2function void entity:applyTorque(vector torque) local phys = this:GetPhysicsObject() - -- Convert torque from local to world axis - torque = phys:LocalToWorldVector( clamp(torque) ) - -- Convert rad*in^2 to deg*m^2 - phys:ApplyTorqueCenter( torque * (180 / math.pi / 39.3701^2) ) + -- Convert rad*in^2 to deg*m^2 and torque to velocity + phys:AddAngleVelocity( torque * (180 / math.pi / 39.3701^2) * phys:GetInvInertia() ) end e2function vector entity:inertia()