Specifically, this code snippet:
Code: Select all
Real squaredDepth = mParentNode->getSquaredViewDepth(cam);
// Do Mesh LOD
// Adjust this depth by the entity bias factor
Real tmp = squaredDepth * mMeshLodFactorInv;
// Now adjust it by the camera bias
tmp = tmp * cam->_getLodBiasInverse();
// Get the index at this biased depth
mMeshLodIndex = mMesh->getLodIndexSquaredDepth(tmp);
// Apply maximum detail restriction (remember lower = higher detail)
mMeshLodIndex = std::max(mMaxMeshLodIndex, mMeshLodIndex);
// Apply minimum detail restriction (remember higher = lower detail)
mMeshLodIndex = std::min(mMinMeshLodIndex, mMeshLodIndex);
Other distance functions could also be imagined, depending on the use. Maybe one based on the bounding sphere to camera distance, or based on the camera's distance to an arbitrary point.
I'd like to suggest either that measuring distance from the camera to the bounding box is the better metric to use, or that the user should be able to easily set alternate LOD measuring schemes.

