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

Improve camera smoothing when crouching #1326

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Calinou
Copy link
Member

@Calinou Calinou commented Dec 28, 2021

Asymptoptic (ease-out) smoothing is now used instead of linear interpolation. This kind of smoothing is often used for camera crouching animations in modern FPS games (see Doom 3 or Xonotic for examples).

This smoothing has been tested to be FPS-independent. It works well in all common situations (crouching/uncrouching, moving while crouching, crouchsliding).

In the future, a similar kind of smoothing can be used for things such as the first-person model animation when crouchsliding, weapon scope FOV changes, etc.

Preview

smooth-crouch.mp4

Copy link
Member

@qreeves qreeves left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if I understand the point of this, the demonstration isn't really clear on what is going on, and I'm looking at this 0.35 and wondering what the hell it is for. Maybe I just haven't had enough coffee yet.

Looking at the cheat sheet provided, it makes me wonder if we should be using a more elastic easing method.

if(d->actiontime[AC_CROUCH] <= 0) d->actiontime[AC_CROUCH] = lastmillis;
if(d->height > zrad && ((d->height -= zamt) < zrad)) d->height = zrad;
else if(d->height < zrad && ((d->height += zamt) > zrad)) d->height = zrad;
}
else
{
// asymptoptic smoothing of crouch view height (smoother than linear interpolation)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In a codebase fairly devoid of comments where concise code is prioritized, having the same comment twice that takes up its own line is kind of a waste of space.

@Calinou
Copy link
Member Author

Calinou commented Dec 29, 2021

and I'm looking at this 0.35 and wondering what the hell it is for.

The 0.35f is a magic value that scales the animation speed (higher is faster). I should have made this clearer in the code 🙂

@qreeves
Copy link
Member

qreeves commented Dec 29, 2021

The 0.35f is a magic value that scales the animation speed (higher is faster). I should have made this clearer in the code 🙂

Should probably be a variable then 👍

Asymptoptic (ease-out) smoothing is now used instead of
linear interpolation. This kind of smoothing is often used for
camera crouching animations in modern FPS games.
@q009
Copy link
Member

q009 commented Jun 5, 2022

What's the status on this PR? I see no problems with this, other than the previously mentioned issue not being addressed.
Once there's a game variable for the easing of the animation, I think it'll be good to merge.

@@ -1276,15 +1276,19 @@ namespace game
}
if(crouching || d->crouching(true))
{
float zamt = zoff*curtime/float(PHYSMILLIS);
float crouchanimspeedscale = 0.35f;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make this a game variable as requested

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

None yet

3 participants