do not panic when having a lod with invalid handle
@@ -57,8 +57,9 @@ impl VisibilityCache {
if let Some(lod_group) = node.lod_group() {
for level in lod_group.levels.iter() {
for &object in level.objects.iter() {
+ if let Some(object_ref) = graph.try_get(object) {
let distance =
- observer_position.metric_distance(&graph[object].global_position());
+ observer_position.metric_distance(&object_ref.global_position());
let z_range = z_far - z_near;
let normalized_distance = (distance - z_near) / z_range;
let visible = normalized_distance >= level.begin()
@@ -68,6 +69,7 @@ impl VisibilityCache {
}
}
}
+ }
// Fill rest of data from global visibility flag of nodes and check frustums (if any).
for (handle, node) in graph.pair_iter() {
