Mouse Selection Sorting
Posted: Wed Apr 24, 2013 2:48 am
I am thinking of an algorithm to detect when an user selects an object with the mouse.
1. Using an AABB Octree store all objects, objects contain triangles, and triangles contain points.
2. Fire a ray from the camera to the mouse location, convert screen coords to a 3D ray.
3. Traverse the Octree, testing for existing leaf nodes, then testing for intersection with the ray.
This algorithm is not well optimum for overlaying items that are close together. The algorithm would need to sort all positive tests and return the intersection of minimum length. It would be better if the algorithm tested the closest object in the tree first.
Would sorting the nodes in the Octree for each ray cast be more efficient than checking for all intersections and then sorting the returned nodes?
Is there a better algorithm for this?
*edited grammar
1. Using an AABB Octree store all objects, objects contain triangles, and triangles contain points.
2. Fire a ray from the camera to the mouse location, convert screen coords to a 3D ray.
3. Traverse the Octree, testing for existing leaf nodes, then testing for intersection with the ray.
This algorithm is not well optimum for overlaying items that are close together. The algorithm would need to sort all positive tests and return the intersection of minimum length. It would be better if the algorithm tested the closest object in the tree first.
Would sorting the nodes in the Octree for each ray cast be more efficient than checking for all intersections and then sorting the returned nodes?
Is there a better algorithm for this?
*edited grammar