h3r2tic / dolly

Composable camera rigs
Apache License 2.0
414 stars 31 forks source link

Using rotational smoothing causes snapping and camera roll #11

Open VZout opened 2 years ago

VZout commented 2 years ago

Very high rotational smoothing values in combination with high sensitivity causes the camera to snap (to the closest quat rotation) and roll which is mildly dizzying 😅

erwanvivien commented 1 year ago

Having the same issue.

@h3r2tic Do you have an idea where in the code the bug is ? I would like to have a look, thanks

erwanvivien commented 1 year ago

I think it's there: https://github.com/h3r2tic/dolly/blob/main/src/util.rs#L33-L55 ?

h3r2tic commented 1 year ago

Don't know how the issue looks, so it would be hard for me to guess :sweat_smile: I don't currently have much time to investigate, sorry. I've seen issues with the look-at transform still having some numerical trouble; I've also seen cases where exp with large numbers can give NaNs, and also cases of quats "overflowing", and then (s)lerp suddenly switching to the other direction.

erwanvivien commented 1 year ago

I'll take a look 👌

h3r2tic commented 1 year ago

That's awesome, thanks :D

erwanvivien commented 1 year ago

I've dig into it a bit:

Some possible tracks:

1: https://gamedevbeginner.com/the-right-way-to-lerp-in-unity-with-examples#lerp_slowing_down


In my tests, moving the mouse real fast, produced an interp_t of around 0.06f32 which is not much, and could cause the lerp to be wrong? I don't know much

h3r2tic commented 1 year ago

The whole point of ExpSmoothed however is to create exponential smoothing just as the article shows, where the slowing down is a feature :sweat_smile:

erwanvivien commented 1 year ago

Ohhh alright 🤔 Then maybe the problem is more around interp_t?

erwanvivien commented 1 year ago

I think there is less problem using the ExpSmoothed like you did, because in the article, it is using delta time, so it's always a small number, thus always on the slow part of the Lerp

Here the function is greatly helping the smoothing, I think ?

h3r2tic commented 1 year ago

The main difference is the framerate independence via the interp_t thing.