Hi arnir, a few thoughts that might not be enough to completely solve your problem but would seem to me to be some things to consider. I think your conclusion about your first example is completely right so, looking at your second example, with canCull():
The second line...
Code: Select all
m_pNode->getTransformedBoundingBox().getEdges(edges);
doesn't actually transform your bounding box for you, rather it returns a bounding box. If you don't store the return value, you can't do anything with it. It would have to be:
Code: Select all
aabbox3df transformedBB = m_pNode->getTransformedBoundingBox().getEdges(edges);
to be available for usage. Although, I don't think the collision manager would use it unless you adapted the collision manager's code.
Also, the 8 "edges" of the bounding box are actually corners, so when you try to do collisions in your loop using getCollisionPoint() there may be some floating point round-off error that sometimes will miss the box (corners). That's not such a big problem, though, as you could instead use getSceneNodeAndCollisionPointFromRay() [or even getSceneNodeFromCameraBB() ] to find out if your ray hit the bounding box of an AI node. That alone, would do some culling for you, although, iirc it uses an axis-aligned bounding box, not a fully transformed one.
Testing collisions against bounding boxes will sometimes produce false positives. That is, your AI nodes
should show up when their bounding boxes are not completely blocked or obstructed by another node, but will also sometimes show up if they are
almost visible, depending on how much space or volume of their bounding boxes the node's triangles fill up.
There's more to say about further culling, if necessary/desired, but only if that was helpful. For instance, once you have the bounding box and collision point, you could do some further tests to see if the collision actually hit any of the AI node's triangles that are inside the bounding box. I don't want to confuse the issue, though, if that was of no good to you.
Also, like mentioned before, it looks like as soon as
any of the corners is missed, getCollision() returns false so (!getCollision())==true, causing the function to "return false;" as you've written. You want it to
completely miss the bounding box before the function returns false.