Raycasting not accurate after manually altering mesh?

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
panto
Posts: 22
Joined: Thu Mar 17, 2011 5:44 pm

Raycasting not accurate after manually altering mesh?

Post by panto »

Hi,

I use a very simple raycast function to get the Y height of the collision point from the camera to the terrain (cast ray from camera->getPosition() to camera->getPosition() + vector3df( 0, -10000, 0 )). However, after manually moving the terrains vertices up/down, the Y position of the ray stays the same.

I'll break it down to explain it.
1. Cast ray.
2. Alter terrain vertices right below the camera.
3. Cast ray again.

The result is exactly the same UNTIL I re-create the Terrain mesh from the new heightmap, then it gets the correct results. How would one go about fixing it?
Thanks.
cobra
Posts: 371
Joined: Fri Jan 23, 2009 2:56 am
Location: United States
Contact:

Re: Raycasting not accurate after manually altering mesh?

Post by cobra »

Hi Panto,

The reason is probably because you haven't updated the terrain collision data (I'm not familiar with Irrlicht's collision system classes).
Josiah Hartzell
Image
panto
Posts: 22
Joined: Thu Mar 17, 2011 5:44 pm

Re: Raycasting not accurate after manually altering mesh?

Post by panto »

I thought that when "refreshing" the mesh (node->setPosition( node->getPosition() )) it would automatically recalculate the terrain triangle selector. But I'm probably wrong, I'll check it out, thanks.
Post Reply