sfncook wrote:I assume that getSceneNodeFromScreenCoordinatesBB does this in a more efficient manner than just checking every mesh with a for loop.
That would be a mistaken assumption. You have the code available. See CSceneCollisionManager.cpp, getSceneNodeFromScreenCoordinatesBB(), getSceneNodeFromRayBB() and getPickedNodeBB().
Code: Select all
const core::list<ISceneNode*>& children = root->getChildren();
core::list<ISceneNode*>::ConstIterator it = children.begin();
for (; it != children.end(); ++it)
...
Where 'root' is initially the scene manager's root scene node, and then it recurses through every node in the scene.
You can make it a
little more efficient by specifying a bitmask, which will allow quick rejection of objects, but it still remains a Big Dumb Loop over every single scene node.
If you want something more efficient, I'd strongly suggest implementing your own test, perhaps based on the implementation of getPickedNodeBB() but using a smarter algorithm for selecting candidate nodes.
Without knowing more about your scene, I can't suggest anything specific, although in general you could consider dividing your objects into tiles/zones, or - depending if you rotate the camera - holding them in a list ordered by (e.g.) X co-ordinate, which will allow you to check only a subset of them.