From ba28c10199b363df469cf70f2e9436be90deb258 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dietrich?= Date: Wed, 30 Mar 2022 17:31:40 +0200 Subject: Fix T96344: edit mode GPU subdivision crashes with X-ray mode and modifiers The crash happens because the origindex layers created as part of the modifier stack evaluation are not set in the `MeshRenderData` when they should have been. This is because when selecting in X-ray mode, a subdivision wrapper is created to ensure that selection happens with a subdivided geometry, and this replaces the `MDATA` wrapper which is also used to setup the `MeshRenderData`. As we do not seemingly have an `MDATA` wrapper, the draw code decides that we can extract draw buffers directly from the BMesh, instead of the mapped Mesh with origin indices layers. To fix this, we should also consider to use mapped extraction if a subdivision wrapper exists on the mesh. Differential Revision: https://developer.blender.org/D14485 --- source/blender/draw/intern/draw_cache_extract_mesh_render_data.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'source/blender/draw/intern') diff --git a/source/blender/draw/intern/draw_cache_extract_mesh_render_data.c b/source/blender/draw/intern/draw_cache_extract_mesh_render_data.c index a2995d6cd3f..0a93f346b37 100644 --- a/source/blender/draw/intern/draw_cache_extract_mesh_render_data.c +++ b/source/blender/draw/intern/draw_cache_extract_mesh_render_data.c @@ -461,7 +461,14 @@ MeshRenderData *mesh_render_data_create(Object *object, mr->bm_poly_centers = mr->edit_data->polyCos; } - bool has_mdata = is_mode_active && (mr->me->runtime.wrapper_type == ME_WRAPPER_TYPE_MDATA); + /* A subdivision wrapper may be created in edit mode when X-ray is turned on to ensure that the + * topology seen by the user matches the one used for the selection routines. This wrapper + * seemingly takes precedence over the MDATA one, however the mesh we use for rendering is not + * the subdivided one, but the one where the MDATA wrapper would have been added. So consider + * the subdivision wrapper as well for the `has_mdata` case. */ + bool has_mdata = is_mode_active && ELEM(mr->me->runtime.wrapper_type, + ME_WRAPPER_TYPE_MDATA, + ME_WRAPPER_TYPE_SUBD); bool use_mapped = is_mode_active && (has_mdata && !do_uvedit && mr->me && !mr->me->runtime.is_original); -- cgit v1.2.3