Terrain part disappears when moving backwards

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
ison
Posts: 42
Joined: Sun Mar 24, 2013 9:09 pm

Terrain part disappears when moving backwards

Post by ison »

Hello.

I'm using Irrlicht FPP camera, but I set camera position manually (because Bullet controlls player's position) via camera->setPosition(). When I move forward everything is fine, but when I move backwards, a part of terrain seems to be not updated properly and is just not rendered (probably some kind of frustum culling optimization). Here is how it looks: (I moved a little bit backwards and some part of terrain is not rendered):
Image
now when I'm in this position, I can move a little bit to the left, right, backward or forward and it stays like this. Missing terrain part appears when I move too much or move mouse even a tiny bit. I understand it's some kind of frustum optimization, so turning it off is not an option - since even a tiny mouse movement fixes this problem, so I guess it's not a big deal. I've tried using camera->updateAbsolutePosition() each frame but it doesn't help.
CuteAlien
Admin
Posts: 9670
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Terrain part disappears when moving backwards

Post by CuteAlien »

Try first if it's maybe the near- or farplane of the camera itself. You can change the value of those in the camera.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
ison
Posts: 42
Joined: Sun Mar 24, 2013 9:09 pm

Re: Terrain part disappears when moving backwards

Post by ison »

Thanks for the reply, but unfortunately it's not the problem. My znear is very small (like 5 cm), and here the distance from camera to terrain is like 2 meters. Usually if I move forward everything is fine, but when I move backwards sometimes a big part of terrain is not rendered.
CuteAlien
Admin
Posts: 9670
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Terrain part disappears when moving backwards

Post by CuteAlien »

Unfortunately I'm not familiar with the terrain-code itself. I remember it had some problems with scaling from a past thread. Aside from that I don't know. But we need concrete code to reproduce the bug if we should help hunting the problem.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
ison
Posts: 42
Joined: Sun Mar 24, 2013 9:09 pm

Re: Terrain part disappears when moving backwards

Post by ison »

Found the problem!
It was caused by too big, default camera movement delta.

Code: Select all

irr::scene::ITerrainSceneNode::setCameraMovementDelta
I guess there should be some kind of a formula which would give the maximum possible value for camera movement delta based on terrain scale.
Post Reply