Skip to main content
GameDev.net gamedev.net
🔒 Locked

Sorting Raycasting All Hits Result

Started by Medo Mex Jan 6, 2013 at 9:44 PM 2 replies 2k views
Original Post
Medo Mex
Medo Mex

Hi guys,

I'm using Bullet Raytest to get all hits in AllHitsRayResultCallback.

How do I sort the results (from the closest hit to the farthest) so If the ray hit a wall first before a vehicle, the wall should be sorted first instead of random sorting?

Zaoshi Kaba
Zaoshi Kaba

I think hits are reported in the order they happened (from closest to farthest).
Just to be sure you can sort by hit fraction.

Medo Mex
Medo Mex

No, Bullet physics RayTest() returns the results randomly.

Krohm
Krohm

Don't store the result in a Bullet-provided structure. Instead, use one of them as a base class and provide an operator<.

Store those structures in a STL container, then just std::sort it.

Previously "Krohm"

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.