Fix applyTorque world matrix mismatch#3561
Open
Doliman100 wants to merge 1 commit intowiremod:masterfrom
Open
Conversation
`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`.
thegrb93
approved these changes
Mar 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix issue #3560.
PhysObj:ApplyTorqueCenterreplaced withPhysObj:AddAngleVelocitysince it accepts a local space input and doesn't convert it to world space internally. No more world matrix mismatch problem. Here is a full inlined code of both functions for comparison. As you can see, there is no difference but an ApplyTorqueCenter input is world space and an AddAngleVelocity input is local space. Another small difference isApplyTorqueCentermultiplies a local space input byinv_rot_inertiaandAddAngleVelocitydoesn't, but this can be easily fixed in Lua.I tested it with the default tickrate and
-tickrate 33, it works fine in both cases. The sample chip code is located at the initial issue message. After applying this fix, the sample works in an opposite way. Now the bad case provides right behavior and the good case provides wrong behavior.