• Advertisement
Sign in to follow this  

Camera Rotation dependend on FPS?

This topic is 3654 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, in my application I use a first person camera class and the rotation is performed by moving the mouse. Every frame I do this:
g_mouseBufferX->add(g_mouseState.lX * fElapsedTime);
g_mouseBufferY->add(g_mouseState.lY * fElapsedTime);

double x = g_mouseBufferX->getWeightedMean();
double y = g_mouseBufferY->getWeightedMean() ;
	
g_camera->yaw(x);
g_camera->pitch(y);
g_mouseState holds the current relative mouse movement and fElapsedTime is the elapsed time since the last frame. g_mouseBuffer is just a buffer that holds the last 10 mouse movements and calculates the average to smooth jerky mouse movements. The problem is now: I have to techniques - technique A has 200fps on my machine and technique B about 1400fps. If I run technique B the rotation speed is fine, but if I run technique B the rotation of the camera is really slow. Its obvious that since technique B is faster the B values of fElapsedTime are much smaller and the rotation in every frame is smaller. But since B also performes more frames the total rotation every second should be the same, shoudlnt it? I mean its the same if I rotate 4 times 0.25 Degrees or 1 time 1 degree. Does anyone have an idea why my rotation is slower if I have more fps?

Share this post


Link to post
Share on other sites
Advertisement
I would assume your implementation of getWeightedMean() compensates for different fElapsedTime per entry, but your Add() call suggests otherwise.

Just because you have 1400hz doesn't mean each sample in that 10-entry buffer is uniformly 712 microseconds apart. Some could be 600 microseconds and others 800 microseconds. Consequently your 10 frame average could well be the average X coordinate from 8 milliseconds or 6 milliseconds...


Jack

Share this post


Link to post
Share on other sites
The buffer just exists to smooth the mouse movement so I guess the true problem has nothing to do with the buffer itself.

Even if I use this simple code per frame:
g_camera->yaw(g_mouseState.lX * fElapsedTime);
g_camera->pitch(g_mouseState.lY * fElapsedTime);

then rotations are still much slower with high fps. Of course you are right that with a framerate of 1400Hz I wont get fElapsedTime values of exactly 1/1400s but the average amount per second should indeed be 1/1400s.
I thought the whole "multiply all changes by elapsed time" just exists to make movments independend on framerate?

Share this post


Link to post
Share on other sites
Hehe, my mousebuffer is based on excatly this article :D
Now my camerarotation is smooth but the rotation speed still depends on the fps :/

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement