@@ -1879,25 +1879,27 @@ void RenderForwardMobile::_fill_render_list(RenderListType p_render_list, const
18791879 // LOD
18801880
18811881 if (p_render_data->scene_data ->screen_mesh_lod_threshold > 0.0 && mesh_storage->mesh_surface_has_lod (surf->surface )) {
1882- // Get the LOD support points on the mesh AABB.
1883- Vector3 lod_support_min = inst->transformed_aabb .get_support (p_render_data->scene_data ->cam_transform .basis .get_column (Vector3::AXIS_Z));
1884- Vector3 lod_support_max = inst->transformed_aabb .get_support (-p_render_data->scene_data ->cam_transform .basis .get_column (Vector3::AXIS_Z));
1885-
1886- // Get the distances to those points on the AABB from the camera origin.
1887- float distance_min = (float )p_render_data->scene_data ->cam_transform .origin .distance_to (lod_support_min);
1888- float distance_max = (float )p_render_data->scene_data ->cam_transform .origin .distance_to (lod_support_max);
1889-
18901882 float distance = 0.0 ;
18911883
1892- if (distance_min * distance_max < 0.0 ) {
1893- // crossing plane
1894- distance = 0.0 ;
1895- } else if (distance_min >= 0.0 ) {
1896- distance = distance_min;
1897- } else if (distance_max <= 0.0 ) {
1898- distance = -distance_max;
1884+ // Check if camera is NOT inside the mesh AABB.
1885+ if (!inst->transformed_aabb .has_point (p_render_data->scene_data ->cam_transform .origin )) {
1886+ // Get the LOD support points on the mesh AABB.
1887+ Vector3 lod_support_min = inst->transformed_aabb .get_support (p_render_data->scene_data ->cam_transform .basis .get_column (Vector3::AXIS_Z));
1888+ Vector3 lod_support_max = inst->transformed_aabb .get_support (-p_render_data->scene_data ->cam_transform .basis .get_column (Vector3::AXIS_Z));
1889+
1890+ // Get the distances to those points on the AABB from the camera origin.
1891+ float distance_min = (float )p_render_data->scene_data ->cam_transform .origin .distance_to (lod_support_min);
1892+ float distance_max = (float )p_render_data->scene_data ->cam_transform .origin .distance_to (lod_support_max);
1893+
1894+ if (distance_min * distance_max < 0.0 ) {
1895+ // crossing plane
1896+ distance = 0.0 ;
1897+ } else if (distance_min >= 0.0 ) {
1898+ distance = distance_min;
1899+ } else if (distance_max <= 0.0 ) {
1900+ distance = -distance_max;
1901+ }
18991902 }
1900-
19011903 if (p_render_data->scene_data ->cam_orthogonal ) {
19021904 distance = 1.0 ;
19031905 }
0 commit comments