Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2022-06-07 18:07:04 +0300
committerClément Foucault <foucault.clem@gmail.com>2022-06-07 19:12:19 +0300
commit60442b0292bc8b48511656e4318baa7bbcbb0325 (patch)
tree893bc799542d36fa55398c6cf4ec1de00fce1827 /source
parent58d350b4892dcaabfcd730fbc0d8d90b90b55ccc (diff)
Fix T98091: EEVEE: Volume: Crash caused by non-present grid
This was caused by the `copy_m4_m4` trying to copy the `object_to_texture` from `drw_grid` which was `nullptr`. Fixing this also exposed that rendering such volumes (without any valid grid attributes) is not supported and we should follow what Cycles does. Differential Revision: https://developer.blender.org/D15147
Diffstat (limited to 'source')
-rw-r--r--source/blender/draw/intern/draw_common.h2
-rw-r--r--source/blender/draw/intern/draw_volume.cc12
2 files changed, 11 insertions, 3 deletions
diff --git a/source/blender/draw/intern/draw_common.h b/source/blender/draw/intern/draw_common.h
index 779ac43178c..c078a393b35 100644
--- a/source/blender/draw/intern/draw_common.h
+++ b/source/blender/draw/intern/draw_common.h
@@ -91,7 +91,7 @@ void DRW_curves_free(void);
/**
* Add attributes bindings of volume grids to an existing shading group.
* No draw call is added so the caller can decide how to use the data.
- * \return nullptr if there is something to draw.
+ * \return nullptr if there is nothing to draw.
*/
struct DRWShadingGroup *DRW_shgroup_volume_create_sub(struct Scene *scene,
struct Object *ob,
diff --git a/source/blender/draw/intern/draw_volume.cc b/source/blender/draw/intern/draw_volume.cc
index 8d9a6f486e2..c4e58ab24cb 100644
--- a/source/blender/draw/intern/draw_volume.cc
+++ b/source/blender/draw/intern/draw_volume.cc
@@ -129,12 +129,14 @@ static DRWShadingGroup *drw_volume_object_grids_init(Object *ob,
volume_infos.temperature_bias = 0.0f;
/* Bind volume grid textures. */
- int grid_id = 0;
+ int grid_id = 0, grids_len = 0;
LISTBASE_FOREACH (GPUMaterialAttribute *, attr, attrs) {
const VolumeGrid *volume_grid = BKE_volume_grid_find_for_read(volume, attr->name);
const DRWVolumeGrid *drw_grid = (volume_grid) ?
DRW_volume_batch_cache_get_grid(volume, volume_grid) :
nullptr;
+ /* Count number of valid attributes. */
+ grids_len += int(volume_grid != nullptr);
/* Handle 3 cases here:
* - Grid exists and texture was loaded -> use texture.
@@ -145,7 +147,13 @@ static DRWShadingGroup *drw_volume_object_grids_init(Object *ob,
grid_default_texture(attr->default_value);
DRW_shgroup_uniform_texture(grp, attr->input_name, grid_tex);
- copy_m4_m4(volume_infos.grids_xform[grid_id++].ptr(), drw_grid->object_to_texture);
+ copy_m4_m4(volume_infos.grids_xform[grid_id++].ptr(),
+ (drw_grid) ? drw_grid->object_to_texture : g_data.dummy_grid_mat);
+ }
+ /* Render nothing if there is no attribute for the shader to render.
+ * This also avoids an assert caused by the bounding box being zero in size. */
+ if (grids_len == 0) {
+ return nullptr;
}
volume_infos.push_update();