Page 1 of 1

Raycast in reverse

Posted: Wed Jun 16, 2010 3:30 pm
by imtrobin
I have a statictrianglegroup, I'm using it as a terrain and I'm doing raycast to get terrain height. So, I'm doing it from downwards

triangleStaticGroup.RayCast (new Vector3 (1000, -1, 1000), Vector.UnitY, 10000.0f ..)

instead of the usual top down.

triangleStaticGroup.RayCast (new Vector3 (1000, 10000, 1000), -Vector.UnitY, 10000.0f ..)

I find that it works on the edges (0,-1,0), but within the map, it returns 0. Would this be a bug?

Re: Raycast in reverse

Posted: Wed Jun 16, 2010 8:08 pm
by Norbo
There's definitely a bug somewhere. I'll look into it.

Re: Raycast in reverse

Posted: Wed Jun 16, 2010 8:28 pm
by Norbo
On second glance, it turns out my test was accidentally using the X coordinate of the camera for both the X and Z coordinate of the raycast, explaining the problem I observed :). I haven't found a bug yet.

If your triangle mesh ever drops below -1 on the y coordinate, that particular raycast will fail, but I assume that you have created the terrain so that it is always above that point.

Re: Raycast in reverse

Posted: Thu Jun 17, 2010 5:36 am
by imtrobin
Yes, my terrain is above 0

Re: Raycast in reverse

Posted: Thu Jun 17, 2010 5:13 pm
by imtrobin
I think it's my collision proxy, it has a additional plane at Y = 0 that got exported. Sorry for the false alarm.