BGE: Fix T44448: LOD will display wrong LOD level object if zoomed out
authorJorge Bernal <jbernalmartinez@gmail.com>
Wed, 28 Oct 2015 00:21:36 +0000 (01:21 +0100)
committerJorge Bernal <jbernalmartinez@gmail.com>
Wed, 28 Oct 2015 00:22:16 +0000 (01:22 +0100)
then in

Current object distance hasn't to be cached.

source/blender/blenkernel/intern/object.c

index 4ec413731163b40fbcc3896efc55dec752fe17d0..b6fcb04f616dc4efef4e916a7afbf5e793ce0506 100644 (file)
@@ -1156,16 +1156,15 @@ bool BKE_object_lod_remove(Object *ob, int level)
 static LodLevel *lod_level_select(Object *ob, const float camera_position[3])
 {
        LodLevel *current = ob->currentlod;
-       float dist_sq, dist_sq_curr;
+       float dist_sq;
 
        if (!current) return NULL;
 
        dist_sq = len_squared_v3v3(ob->obmat[3], camera_position);
-       dist_sq_curr = current->distance * current->distance;
 
-       if (dist_sq < dist_sq_curr) {
+       if (dist_sq < SQUARE(current->distance)) {
                /* check for higher LoD */
-               while (current->prev && dist_sq < dist_sq_curr) {
+               while (current->prev && dist_sq < SQUARE(current->distance)) {
                        current = current->prev;
                }
        }