FIx crash in LOD

This commit is contained in:
Marianne Gagnon 2014-10-04 19:05:27 -04:00
parent 78b21eb840
commit 5a07fd0fa4

View File

@ -80,7 +80,11 @@ int LODNode::getLevel()
if (camera == NULL)
return (int)m_detail.size() - 1;
AbstractKart* kart = camera->getKart();
const Vec3 &pos = kart->getFrontXYZ();
// use kart position and not camera position when a kart is available,
// because for some effects the camera will be moved to various locations
// (for instance shadows), so using camera position for LOD may result
// in objects being culled when they shouldn't
const Vec3 &pos = (kart != NULL ? kart->getFrontXYZ() : camera->getCameraSceneNode()->getAbsolutePosition());
const int dist =
(int)((m_nodes[0]->getAbsolutePosition()).getDistanceFromSQ(pos.toIrrVector() ));