BGE: Fix T44448: LOD will display wrong LOD level object if zoomed out

then in

Current object distance hasn't to be cached.
This commit is contained in:
Jorge Bernal 2015-10-28 01:21:36 +01:00
parent fd1487977b
commit 9eb7eb5379
Notes: blender-bot 2023-02-14 11:21:40 +01:00
Referenced by issue #44448, LOD will display wrong LOD level object if zoomed out then in
1 changed files with 3 additions and 4 deletions

View 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;
}
}