multitheftauto / mtasa-resources

This project maintains a list of up-to-date resources that come with Multi Theft Auto.
https://multitheftauto.com
MIT License
151 stars 151 forks source link

Editor: rotation #515

Closed Nico8340 closed 1 month ago

Nico8340 commented 2 months ago

Description

This pull request improves the logic of converting from quaternion to Euler, thus eliminating previously discovered rotation issues. Thus fixes #496

Explanation

The issue originates from the logic of the getEulerFromQuat function, which was fixed by handling euler singularities. The function has been refactored above for easier readability.

Fernando-A-Rocha commented 2 months ago

Congrats 🎉!

chris1384 commented 2 months ago

It works for the most part, but the object gets flipped at -90 on Y axis if treshold returns values near -0.5. Probably an oversight, unsure if it's a definite fix.

    elseif treshold < -0.499 then
        return {math.deg(2 * math.atan2(q1, q0)), -90, 0}

Great job anyways!!

Nico8340 commented 1 month ago

It works for the most part, but the object gets flipped at -90 on Y axis if treshold returns values near -0.5. Probably an oversight, unsure if it's a definite fix.

    elseif treshold < -0.499 then
        return {math.deg(2 * math.atan2(q1, q0)), -90, 0}

Great job anyways!!

It was done this way on purpose, to deal with problems caused by gimbal lock. If you want, you can make a fork of my fork (pun intended) and test it yourself.