Fix T69363 EEVEE: Blender crash when using Edit mode for Ocean
authorClément Foucault <foucault.clem@gmail.com>
Tue, 8 Oct 2019 14:59:29 +0000 (16:59 +0200)
committerClément Foucault <foucault.clem@gmail.com>
Tue, 8 Oct 2019 16:37:38 +0000 (18:37 +0200)
Use same Mesh* as extraction. We always use the final mesh for shaded geom.

source/blender/draw/intern/draw_cache_impl_mesh.c

index 422271dbf62a55f015f030ddce1af1f892e49988..b4b6554f20d4317c9cf835ef150321f5b2cf409d 100644 (file)
@@ -124,7 +124,8 @@ static DRW_MeshCDMask mesh_cd_calc_used_gpu_layers(const Mesh *me,
                                                    struct GPUMaterial **gpumat_array,
                                                    int gpumat_array_len)
 {
-  const CustomData *cd_ldata = (me->edit_mesh) ? &me->edit_mesh->bm->ldata : &me->ldata;
+  const Mesh *me_final = (me->edit_mesh) ? me->edit_mesh->mesh_eval_final : me;
+  const CustomData *cd_ldata = &me_final->ldata;
 
   /* See: DM_vertex_attributes_from_gpu for similar logic */
   DRW_MeshCDMask cd_used;
@@ -227,7 +228,8 @@ static void mesh_cd_extract_auto_layers_names_and_srgb(Mesh *me,
                                                        int **r_auto_layers_srgb,
                                                        int *r_auto_layers_len)
 {
-  const CustomData *cd_ldata = (me->edit_mesh) ? &me->edit_mesh->bm->ldata : &me->ldata;
+  const Mesh *me_final = (me->edit_mesh) ? me->edit_mesh->mesh_eval_final : me;
+  const CustomData *cd_ldata = &me_final->ldata;
 
   int uv_len_used = count_bits_i(cd_used.uv);
   int vcol_len_used = count_bits_i(cd_used.vcol);