From 44c87179a9837629d5cecded75feb9fdd6cefac7 Mon Sep 17 00:00:00 2001 From: Miguel Pozo Date: Wed, 1 Oct 2025 17:50:33 +0200 Subject: [PATCH] Draw: Re-enable Handle Ranges optimizations Re-enable the optimizations from #140378, which were reverted in f8303efd573192fc1b30eb6e4e5c6fdcd8ff47b6 until I could fix the regressions. Disable handle ranges for bounding boxes. Take into account DupliObject and parent Object overrides in `supports_handle_ranges`. Fix #145446 Fix #145420 Pull Request: https://projects.blender.org/blender/blender/pulls/147069 --- source/blender/draw/intern/draw_context.cc | 24 ++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/source/blender/draw/intern/draw_context.cc b/source/blender/draw/intern/draw_context.cc index 43ed2ea72b0..ed0c1527265 100644 --- a/source/blender/draw/intern/draw_context.cc +++ b/source/blender/draw/intern/draw_context.cc @@ -679,9 +679,20 @@ ObjectRef::ObjectRef(Object &ob, Object *dupli_parent, const VectorListtype == OB_MESH) { + int ob_type = dupli->ob_data ? BKE_object_obdata_to_type(dupli->ob_data) : OB_EMPTY; + if (!ELEM(ob_type, OB_MESH, OB_CURVES_LEGACY, OB_SURF, OB_FONT, OB_POINTCLOUD, OB_GREASE_PENCIL)) + { + return false; + } + + Object *ob = dupli->ob; + if (min(ob->dt, parent->dt) == OB_BOUNDBOX) { + return false; + } + + if (ob_type == OB_MESH) { /* Hair drawing doesn't support handle ranges. */ LISTBASE_FOREACH (ParticleSystem *, psys, &ob->particlesystem) { const int draw_as = (psys->part->draw_as == PART_DRAW_REND) ? psys->part->ren_as : @@ -693,7 +704,8 @@ static bool supports_handle_ranges(Object *ob) /* Smoke drawing doesn't support handle ranges. */ return !BKE_modifiers_findby_type(ob, eModifierType_Fluid); } - return ELEM(ob->type, OB_CURVES_LEGACY, OB_SURF, OB_FONT, OB_POINTCLOUD, OB_GREASE_PENCIL); + + return true; } enum class InstancesFlags : uint8_t { @@ -771,13 +783,9 @@ static void foreach_obref_in_scene(DRWContext &draw_ctx, eEvaluationMode eval_mode = DEG_get_mode(depsgraph); View3D *v3d = draw_ctx.v3d; -#if 0 /* Temporary disabled until we can fix all the issues that it causes. */ /* EEVEE is not supported for now. */ const bool engines_support_handle_ranges = (v3d && v3d->shading.type <= OB_SOLID) || BKE_scene_uses_blender_workbench(draw_ctx.scene); -#else - const bool engines_support_handle_ranges = false; -#endif DEGObjectIterSettings deg_iter_settings = {nullptr}; deg_iter_settings.depsgraph = depsgraph; @@ -842,7 +850,7 @@ static void foreach_obref_in_scene(DRWContext &draw_ctx, } #endif - if (!engines_support_handle_ranges || !supports_handle_ranges(dupli.ob)) { + if (!engines_support_handle_ranges || !supports_handle_ranges(&dupli, ob)) { /* Sync the dupli as a single object. */ if (!evil::DEG_iterator_temp_object_from_dupli( ob, &dupli, eval_mode, false, &tmp_object, &tmp_runtime) ||