FPS camera much smoother by commenting out 2 lines!?

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
jimbo

FPS camera much smoother by commenting out 2 lines!?

Post by jimbo »

Hi,

Looking at the TechDemo I've noticed the very unsmooth behaviour
of the camera, by moving the mouse a very small bit the camera jumps several pixels around.

Just by commenting out lines 156 and 157 of CCameraFPSSceneNode.cpp
the camera is so much better!

Why is this condition here in the first place? It almost made me scare away ;)

Code: Select all

if (InputReceiverEnabled)
	{
		core::position2d<f32> cursorpos = CursorControl->getRelativePosition();

	//	if (cursorpos.X < 0.49f || cursorpos.X > 0.51f ||
	//		cursorpos.Y < 0.49f || cursorpos.Y > 0.51f)
		{
			RelativeRotation.Y += (0.5f - cursorpos.X) * RotateSpeed;
			RelativeRotation.X += (0.5f - cursorpos.Y) * RotateSpeed;
			CursorControl->setPosition(0.5f, 0.5f);

			if (RelativeRotation.X > 89.0f) RelativeRotation.X = 89.0f;
			if (RelativeRotation.X < -89.0f) RelativeRotation.X = -89.0f;
		}
	}
Caecus
Posts: 36
Joined: Fri Aug 22, 2003 6:33 am
Location: California, USA

Post by Caecus »

Looks like it was there so that if you hadn't moved the mouse it wouldnt adjust the camera.... However niko seems to have choosen to inaccurate of a floating point representation to check against...

ie if 0.5 is truely unchanged then in say 1024x768 your cursor you be at 512,384.

then for niko's code to run it must be less than 0.49 on say the x coordinate... that means your cursor has to be at less than pixel 501.

Meaning you have to move your cursor roughly 12 (at a time I believe...) pixels before the view will be recalculated. This could easily lead to the jumpy behavoir you observed.

I'd advice uncommenting the lines but changing the values to say... .499 and .501, and see if that helps reduce jitter over the original.
Tels
Posts: 65
Joined: Fri Feb 27, 2004 7:56 pm
Location: Antarctica
Contact:

Post by Tels »

Caecus, i think you are (almost) correct:

"if (cursorpos.X < 0.49f || cursorpos.X > 0.51f || "

This represents roughly 2% of the space, and with 1024 pixels this is about 21 pixels. With 1600 this would be even more...

Cheers,

Tels :D
Perl + Irrlicht + Audiere = Game: http://bloodgate.com/perl/game
Caecus
Posts: 36
Joined: Fri Aug 22, 2003 6:33 am
Location: California, USA

Post by Caecus »

Well I was refering only to a single one directional movement of the mouse on the x axis. (hence my number is half yours). Also I completly agree its precentage based (which I believe is a bad idea?) and that it would get worse at higher resolutions....

Someone might want to check and see if it makes more sense to be fixed pixel number independent of resultion.
Post Reply