diff options
author | Joseph Eagar <joeedh@gmail.com> | 2022-10-05 22:37:35 +0300 |
---|---|---|
committer | Joseph Eagar <joeedh@gmail.com> | 2022-10-05 22:38:26 +0300 |
commit | 38af785dba0989871b5c6c258c7e748a462e2f9a (patch) | |
tree | fa4769a3dd26990c281c96056258c4739ec60299 | |
parent | a096248d1253e5a4436fbc4c2fc1d51539183fc0 (diff) |
Sculpt: Fix crash in dyntopo draw
-rw-r--r-- | source/blender/draw/intern/draw_pbvh.cc | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/source/blender/draw/intern/draw_pbvh.cc b/source/blender/draw/intern/draw_pbvh.cc index 4170285e1d9..6b807222079 100644 --- a/source/blender/draw/intern/draw_pbvh.cc +++ b/source/blender/draw/intern/draw_pbvh.cc @@ -860,10 +860,30 @@ struct PBVHBatches { const char *prefix = "a"; if (ELEM(type, CD_PROP_COLOR, CD_PROP_BYTE_COLOR)) { + Mesh query_mesh; + + /* Check if we have args->me; if not use get_cdata to build something we + * can query for color attributes. + */ + if (args->me) { + memcpy(static_cast<void *>(&query_mesh), + static_cast<const void *>(args->me), + sizeof(Mesh)); + } + else { + BKE_id_attribute_copy_domains_temp(ID_ME, + get_cdata(ATTR_DOMAIN_POINT, args), + nullptr, + get_cdata(ATTR_DOMAIN_CORNER, args), + nullptr, + nullptr, + &query_mesh.id); + } + prefix = "c"; - CustomDataLayer *render = BKE_id_attributes_render_color_get(&args->me->id); - CustomDataLayer *active = BKE_id_attributes_active_color_get(&args->me->id); + CustomDataLayer *render = BKE_id_attributes_render_color_get(&query_mesh.id); + CustomDataLayer *active = BKE_id_attributes_active_color_get(&query_mesh.id); is_render = render && layer && STREQ(render->name, layer->name); is_active = active && layer && STREQ(active->name, layer->name); |