diff options
author | Jacques Lucke <jacques@blender.org> | 2021-05-19 11:23:09 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2021-05-19 11:23:09 +0300 |
commit | 1a81d268a19f2f1402f408ad1dadf92c7a399607 (patch) | |
tree | d3f1b657efc1676b6b1f4b1cc34b4623529c379c /source/blender/draw/engines/workbench/workbench_materials.c | |
parent | d373b43f07f5403826035b5dee71b09f433b0540 (diff) |
Materials: support changing materials during evaluation
This commit allows that the evaluated geometry of an object has
different materials from the original geometry. This is needed
for geometry nodes.
The main thing that changes for render engines and exporters
is that the number of material slots on an object and its geometry
might not match anymore. For original data, the slot counts are
still equal, but not for evaluated data.
Accessing material slots though rna stays the same. The behavior
adapts automatically depending on whether the object is evaluated.
When accessing materials of an object through `BKE_object_material_*`
one has to use a new api for evaluated objects:
`BKE_object_material_get_eval` and `BKE_object_material_count_eval`.
In the future, the different behavior might be hidden behind a more
general C api, but that would require quite a few more changes.
The ground truth for the number of materials is the number of materials
on the geometry now. This is important in the current design, because
Eevee needs to know the number of materials just based on the mesh in
`mesh_render_mat_len_get` and similar places.
In a few places I had to add a special case for mesh edit mode to get it
to work properly. This is unfortunate, but I don't see a way around that
for now.
Differential Revision: https://developer.blender.org/D11236
Diffstat (limited to 'source/blender/draw/engines/workbench/workbench_materials.c')
-rw-r--r-- | source/blender/draw/engines/workbench/workbench_materials.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/source/blender/draw/engines/workbench/workbench_materials.c b/source/blender/draw/engines/workbench/workbench_materials.c index 6e9118bfe46..800d1085505 100644 --- a/source/blender/draw/engines/workbench/workbench_materials.c +++ b/source/blender/draw/engines/workbench/workbench_materials.c @@ -93,7 +93,7 @@ void workbench_material_ubo_data(WORKBENCH_PrivateData *wpd, /* Return correct material or empty default material if slot is empty. */ BLI_INLINE Material *workbench_object_material_get(Object *ob, int mat_nr) { - Material *ma = BKE_object_material_get(ob, mat_nr); + Material *ma = BKE_object_material_get_eval(ob, mat_nr); if (ma == NULL) { ma = BKE_material_default_empty(); } |