apparent bug in DistanceLodBoxStrategy
Posted: Sat Nov 02, 2013 9:14 am
from OgreDistanceLodStrategy.cpp:
This can't be right! The bounding box it's getting is in LOCAL coordinates, and for that matter, the camera position is not in world coordinates either.
That's a nonsensical calculation. Surely what was intended is something more like this:
I noticed this as I was looking into how Ogre computes bounding boxes of things. It seems that the method MovingObject::getBoundingBox() is only ever called by MovingObject (or in a couple of cases, by classes derived from MovingObject)--except in that case above where it's called by mistake. It seems to be more of an internal utility method, and not really intended for public use. Maybe it should be "protected".
Code: Select all
Real DistanceLodBoxStrategy::getSquaredDepth(const MovableObject *movableObject, const Ogre::Camera *camera) const
{
[color=#FF0000] return Math::Sqr(movableObject->getBoundingBox().distance(camera->getPosition()));
[/color] }
That's a nonsensical calculation. Surely what was intended is something more like this:
Code: Select all
Real DistanceLodBoxStrategy::getSquaredDepth(const MovableObject *movableObject, const Ogre::Camera *camera) const
{
return movableObject->getWorldBoundingBox().squaredDistance(camera->_getDerivedPosition());
}