AllHitsRayResultCallback return order

User avatar
SynapticBytes
Posts: 74
Joined: Thu Feb 10, 2011 8:27 pm

AllHitsRayResultCallback return order

Post by SynapticBytes »

I'm just trying to implement an AllHitRayResult callback interface.

After the rayTest, I'm iterating through all of the btAlignedObjectArrays for the collision objects, hit point and normals and reporting them back to the user.

What I have just found out is that it seems the arrays are being populated in a random order. Is that correct? If I do the same rayTest twice in a row, the order in which the hits are being returned is not necessarily closest to furtherest.

Does that sound right? If not, I've got something weird happening.

Thanks.
User avatar
SynapticBytes
Posts: 74
Joined: Thu Feb 10, 2011 8:27 pm

Re: AllHitsRayResultCallback return order

Post by SynapticBytes »

Well since I couldn't find anything wrong with what I was doing, and lacking advice to the contrary, I've had to just go ahead and implement some sorting and indexing algorithms so I can pass on the results in a sorted manner.
cgripeos
Posts: 20
Joined: Mon Sep 24, 2007 5:45 am

Re: AllHitsRayResultCallback return order

Post by cgripeos »

You are correct, the order of the ray contacts are in "random" order.

If you're curious, this is also the case for other Physics engines (like Havok). The physics engine will try to get you the results are quickly as possible, without making assumptions on how the data should be organized.

I just collect all contacts and sort them all at the end.
User avatar
SynapticBytes
Posts: 74
Joined: Thu Feb 10, 2011 8:27 pm

Re: AllHitsRayResultCallback return order

Post by SynapticBytes »

Thanks for confirming that. At least I now know I don't have redundant sort code int here for nothing.