diff options
author | Bastien Montagne <bastien@blender.org> | 2020-12-23 18:01:24 +0300 |
---|---|---|
committer | Bastien Montagne <bastien@blender.org> | 2020-12-23 18:03:42 +0300 |
commit | 8a9dedf829544e30f822bcb016a9c134af6979e5 (patch) | |
tree | 5959d13d613511e9c50857fcd10e8b0a64f6a771 /source | |
parent | d29a720c45e55047e4f0e02df4652ba03a49c528 (diff) |
Workaround T84084: Assert/crash when undoing from Sculpt mode to Object one.
Disclaimer: This workaround avoids crashing with current state of the
code and is only committed as temporary band-aid until we can assess the
full issue and decide if/how it needs to be adressed.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/intern/multires_reshape_ccg.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/source/blender/blenkernel/intern/multires_reshape_ccg.c b/source/blender/blenkernel/intern/multires_reshape_ccg.c index 55f7766c878..aa003909bb0 100644 --- a/source/blender/blenkernel/intern/multires_reshape_ccg.c +++ b/source/blender/blenkernel/intern/multires_reshape_ccg.c @@ -61,8 +61,24 @@ bool multires_reshape_assign_final_coords_from_ccg(const MultiresReshapeContext sizeof(float[3])); if (reshape_level_key.has_mask) { - BLI_assert(grid_element.mask != NULL); - *grid_element.mask = *CCG_grid_elem_mask(&reshape_level_key, ccg_grid, x, y); + /* Assert about a non-NULL `grid_element.mask` may fail here, this code may be called + * from cleanup code during COW evaluation phase by depsgraph (e.g. + * `object_update_from_subsurf_ccg` call in `BKE_object_free_derived_caches`). + * + * `reshape_level_key.has_mask` is ultimately set from MultiRes modifier apply code + * (through `multires_as_ccg` -> `multires_ccg_settings_init`), when object is in sculpt + * mode only, and there is matching loop cdlayer. + * + * `grid_element.mask` is directly set from existing matching loop cdlayer during + * initialization of `MultiresReshapeContext` struct. + * + * Since ccg data is preserved during undos, we may end up with a state where there is no + * mask data in mesh loops' cdlayer, while ccg's `has_mask` is still set to true. + */ + // BLI_assert(grid_element.mask != NULL); + if (grid_element.mask != NULL) { + *grid_element.mask = *CCG_grid_elem_mask(&reshape_level_key, ccg_grid, x, y); + } } } } |