From 5a07fd0fa46f6c6c23286ce835ec4ac806067376 Mon Sep 17 00:00:00 2001 From: Marianne Gagnon Date: Sat, 4 Oct 2014 19:05:27 -0400 Subject: [PATCH] FIx crash in LOD --- src/graphics/lod_node.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/graphics/lod_node.cpp b/src/graphics/lod_node.cpp index 1fea813a6..31ab6d731 100644 --- a/src/graphics/lod_node.cpp +++ b/src/graphics/lod_node.cpp @@ -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() ));