Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the calculation of the angular velocity #63190

Merged

Conversation

fabriceci
Copy link
Contributor

Fix #63004

before this patch:

before.fix.mp4

after this patch:

after_fix.mp4

Description

The angular speed calculation was wrong when the rotation speed was not enough.

In Basis::get_axis_angle, the first condition tested an epsilon of 0.01.

For example, by rotating on Y by 0.005 radians per frame (which is not that slow as you can see in the video) which correspond to an angular velocity of (0, 0.600408, 0), you end up with a difference for Math::abs(rows[2][0] + rows[0][2] of 00999993085861 (and sometime 0019999993965 which explain with in this speed, the cube is moving a bit), so when the value is lower than the epsilon, the function don't return an angular velocity.

test project: bug-rotation.zip

@fabriceci fabriceci added this to the 4.0 milestone Jul 19, 2022
@fabriceci fabriceci requested review from reduz and a team July 19, 2022 08:56
@fabriceci fabriceci requested a review from a team as a code owner July 19, 2022 08:56
@reduz
Copy link
Member

reduz commented Jul 19, 2022

looks ok to me, @aaronfranke what do you think?

@akien-mga
Copy link
Member

I assume this might be needed for 3.x too? It has the same code.

@akien-mga akien-mga added cherrypick:3.x Considered for cherry-picking into a future 3.x release cherrypick:3.5 Considered for cherry-picking into a future 3.5.x release labels Jul 19, 2022
@fabriceci
Copy link
Contributor Author

@akien-mga indeed, the bug is also present in 3.x.

core/math/basis.cpp Show resolved Hide resolved
core/math/basis.cpp Show resolved Hide resolved
@akien-mga akien-mga merged commit e375258 into godotengine:master Jul 19, 2022
@akien-mga
Copy link
Member

Thanks!

@akien-mga
Copy link
Member

Cherry-picked for 3.5.

@akien-mga akien-mga removed cherrypick:3.x Considered for cherry-picking into a future 3.x release cherrypick:3.5 Considered for cherry-picking into a future 3.5.x release labels Jul 19, 2022
@and-rad
Copy link
Contributor

and-rad commented Jul 20, 2022

Is what we see in the "after_fix" video expected behavior? The cube doesn't rotate with the platform and is always facing the same world-space direction.

@fabriceci
Copy link
Contributor Author

@and-rad Yes, currently only rotation velocity (displacement) is taken into account. I proposed to add the rotation (angle) as well in the near future.

@fabriceci fabriceci deleted the fix-calculation-angular-velocity branch August 26, 2022 14:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Player's "CharacterBody3D" doesn't rotate with Platforms
7 participants