From ba6977cb8b8125e1fdebb3f876910ceaeadbe103 Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Tue, 3 Nov 2020 22:03:08 -0600 Subject: Fix assert on mouseover of blocks not using the layout system When there was an active button in the "old" block from the last redraw, this code tried to replace its pointer in the new block's button groups. But in cases like the outliner or file browser, there are no groups because the block doesn't use the layout system at all. This commit just tweaks the assert to check whether there are any button groups. --- source/blender/editors/interface/interface_button_group.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source') diff --git a/source/blender/editors/interface/interface_button_group.c b/source/blender/editors/interface/interface_button_group.c index 1f544831982..3d82b84399c 100644 --- a/source/blender/editors/interface/interface_button_group.c +++ b/source/blender/editors/interface/interface_button_group.c @@ -87,8 +87,8 @@ void ui_button_group_replace_but_ptr(uiBlock *block, const void *old_but_ptr, ui } } - /* The button should be in a group. */ - BLI_assert(false); + /* The button should be in a group, otherwise there are no button groups at all. */ + BLI_assert(BLI_listbase_is_empty(&block->button_groups)); } /** \} */ -- cgit v1.2.3 From cfcdae5549f37198fa8e66ee512f1093764ef022 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Wed, 4 Nov 2020 13:21:43 +0100 Subject: Fix T82393: Volume to Mesh modifier with sequence fails during rendering The issue was that the volume for the current frame might not have been loaded already by the time the modifier runs. The solution is simply to make sure that the volume is loaded. This is similar to the Volume Displace modifier. --- source/blender/blenkernel/intern/volume.cc | 1 + source/blender/modifiers/intern/MOD_volume_to_mesh.cc | 3 +++ 2 files changed, 4 insertions(+) (limited to 'source') diff --git a/source/blender/blenkernel/intern/volume.cc b/source/blender/blenkernel/intern/volume.cc index 5e6f0bb42ef..87993695486 100644 --- a/source/blender/blenkernel/intern/volume.cc +++ b/source/blender/blenkernel/intern/volume.cc @@ -1154,6 +1154,7 @@ VolumeGrid *BKE_volume_grid_active_get(const Volume *volume) return BKE_volume_grid_get(volume, index); } +/* Tries to find a grid with the given name. Make sure that that the volume has been loaded. */ VolumeGrid *BKE_volume_grid_find(const Volume *volume, const char *name) { int num_grids = BKE_volume_num_grids(volume); diff --git a/source/blender/modifiers/intern/MOD_volume_to_mesh.cc b/source/blender/modifiers/intern/MOD_volume_to_mesh.cc index 8146c4ca84a..11d30c1f173 100644 --- a/source/blender/modifiers/intern/MOD_volume_to_mesh.cc +++ b/source/blender/modifiers/intern/MOD_volume_to_mesh.cc @@ -45,6 +45,8 @@ #include "BLI_span.hh" #include "BLI_timeit.hh" +#include "DEG_depsgraph_query.h" + #ifdef WITH_OPENVDB # include # include @@ -281,6 +283,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * Volume *volume = static_cast(vmmd->object->data); + BKE_volume_load(volume, DEG_get_bmain(ctx->depsgraph)); VolumeGrid *volume_grid = BKE_volume_grid_find(volume, vmmd->grid_name); if (volume_grid == nullptr) { BKE_modifier_set_error(md, "Cannot find '%s' grid", vmmd->grid_name); -- cgit v1.2.3 From 27648ed53788bf03cb803dd4d7c7397dce1c4cac Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Wed, 4 Nov 2020 13:31:23 +0100 Subject: Modifiers: return empty mesh in case of error in Volume to Mesh modifier Passing on the original mesh does not really make sense. For that one should simply disable the modifier. --- .../blender/modifiers/intern/MOD_volume_to_mesh.cc | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'source') diff --git a/source/blender/modifiers/intern/MOD_volume_to_mesh.cc b/source/blender/modifiers/intern/MOD_volume_to_mesh.cc index 11d30c1f173..913a457c38d 100644 --- a/source/blender/modifiers/intern/MOD_volume_to_mesh.cc +++ b/source/blender/modifiers/intern/MOD_volume_to_mesh.cc @@ -262,23 +262,30 @@ static Mesh *new_mesh_from_openvdb_data(Span verts, } #endif +static Mesh *create_empty_mesh(const Mesh *input_mesh) +{ + Mesh *new_mesh = BKE_mesh_new_nomain(0, 0, 0, 0, 0); + BKE_mesh_copy_settings(new_mesh, input_mesh); + return new_mesh; +} + static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *input_mesh) { #ifdef WITH_OPENVDB VolumeToMeshModifierData *vmmd = reinterpret_cast(md); if (vmmd->object == nullptr) { - return input_mesh; + return create_empty_mesh(input_mesh); } if (vmmd->object->type != OB_VOLUME) { - return input_mesh; + return create_empty_mesh(input_mesh); } if (vmmd->resolution_mode == VOLUME_TO_MESH_RESOLUTION_MODE_VOXEL_SIZE && vmmd->voxel_size == 0.0f) { - return input_mesh; + return create_empty_mesh(input_mesh); } if (vmmd->resolution_mode == VOLUME_TO_MESH_RESOLUTION_MODE_VOXEL_AMOUNT && vmmd->voxel_amount == 0) { - return input_mesh; + return create_empty_mesh(input_mesh); } Volume *volume = static_cast(vmmd->object->data); @@ -287,7 +294,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * VolumeGrid *volume_grid = BKE_volume_grid_find(volume, vmmd->grid_name); if (volume_grid == nullptr) { BKE_modifier_set_error(md, "Cannot find '%s' grid", vmmd->grid_name); - return input_mesh; + return create_empty_mesh(input_mesh); } const openvdb::GridBase::ConstPtr grid = BKE_volume_grid_openvdb_for_read(volume, volume_grid); @@ -296,7 +303,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * VolumeToMeshOp to_mesh_op{*grid, *vmmd, *ctx}; if (!BKE_volume_grid_type_operation(grid_type, to_mesh_op)) { BKE_modifier_set_error(md, "Expected a scalar grid"); - return input_mesh; + return create_empty_mesh(input_mesh); } Mesh *mesh = new_mesh_from_openvdb_data(to_mesh_op.verts, to_mesh_op.tris, to_mesh_op.quads); @@ -308,7 +315,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * #else UNUSED_VARS(md, ctx); BKE_modifier_set_error(md, "Compiled without OpenVDB"); - return input_mesh; + return create_empty_mesh(input_mesh); #endif } -- cgit v1.2.3