Ray<->Heightfield Collision

Apr 15, 2008 at 4:01 AM
Is there an algorithm built-in to do efficient/fast collision checks between rays and heightfields? Just curious.
Coordinator
Apr 15, 2008 at 11:16 PM
The simple answer is yes... the longer answer is that there is a line segment (non infinite ray) against heightfield, but its performance level hasn't really been looked at yet.

All primitives support SegmentIntersect, tho having a quick look at it for heightfield, I'm not convinced its working as specified... So consider it buggy, until i've had a chance to look at and test it.
Apr 23, 2008 at 4:51 AM
Even if it worked, how efficient would it be I wonder? Does it automatically separate the physics mesh in such a way that it doesn't even consider most the heightfield that isn't near the ray?

I'm fairly new to physics, so I'm just curious. I need a ray->heightfield raycast check for some camera functions I have planned. I'm fairly certain PhysX will work on the PC side of things, but we need something for the 360 also.
Coordinator
Apr 23, 2008 at 9:28 AM
In JigLibX a heighmap is stored as a 2D array with height information. So the access time is O(1) ... There is nothing which is faster than this :)
Coordinator
Apr 23, 2008 at 9:35 AM
Sorry, didn't see that you asked for ray collision with heightmap.... This is implemented in Primitives.Heightmap.SegmentIntersect... as you can see it should work pretty fast. (Calls the getheight() 2x)
Coordinator
Apr 23, 2008 at 10:04 PM
calling getheight() only twice is a bug... it should do a DDA across the field (start and end points only really work at vertical or near vertical casts).

As with most things use it and then worry about speed... Even a proper DDA raycast across a height field is fast enough for almost all uses. Unless your doing insane things with your camera like raytracing out an actual viewport, it will be fast enough.

May 7, 2008 at 6:13 PM
Ok, next question. If I create a ray, and pass it to JigLibX, is there a feature where it would return to me each thing that ray hit, in order, and the intersection point of each collision?

Also, do rays collide with the insides of shapes, or only the outsides?
Jan 8, 2012 at 4:59 AM
LordIkon wrote:
Ok, next question. If I create a ray, and pass it to JigLibX, is there a feature where it would return to me each thing that ray hit, in order, and the intersection point of each collision?

Also, do rays collide with the insides of shapes, or only the outsides?

Anyone know if JigLibX supports something like this? I don't want to check a line segment against all physics in my scene, I want to cast a line segment and have it return to me all collisions and details about those collisions.