-
-
Notifications
You must be signed in to change notification settings - Fork 92
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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.
src/game/game.cpp
Outdated
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) |
There was a problem hiding this comment.
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.
The |
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.
1a4529a
to
0804cc2
Compare
What's the status on this PR? I see no problems with this, other than the previously mentioned issue not being addressed. |
@@ -1276,15 +1276,19 @@ namespace game | |||
} | |||
if(crouching || d->crouching(true)) | |||
{ | |||
float zamt = zoff*curtime/float(PHYSMILLIS); | |||
float crouchanimspeedscale = 0.35f; |
There was a problem hiding this comment.
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
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