diff options
author | Sybren A. Stüvel <sybren@blender.org> | 2020-01-28 20:24:17 +0300 |
---|---|---|
committer | Sybren A. Stüvel <sybren@blender.org> | 2020-01-28 20:24:17 +0300 |
commit | 49403a676b81b0d6ca3d13c277af6de312153d3b (patch) | |
tree | a38a7c88de53a6a323d6c8030b9caa9ecf9c5aa2 /source/blender/draw/intern | |
parent | 1af8e0cc6c47b43bf9c94a3f845961f4d22cb34e (diff) | |
parent | 12865caf4f3dd48f343db7167b20e303160004a3 (diff) |
Merge remote-tracking branch 'origin/blender-v2.82-release'
Diffstat (limited to 'source/blender/draw/intern')
-rw-r--r-- | source/blender/draw/intern/draw_cache.c | 19 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_cache.h | 3 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_cache_impl.h | 7 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_cache_impl_curve.c | 7 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_cache_impl_mesh.c | 5 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_cache_impl_metaball.c | 8 |
6 files changed, 46 insertions, 3 deletions
diff --git a/source/blender/draw/intern/draw_cache.c b/source/blender/draw/intern/draw_cache.c index bfb74a9576f..f2764753a51 100644 --- a/source/blender/draw/intern/draw_cache.c +++ b/source/blender/draw/intern/draw_cache.c @@ -824,6 +824,25 @@ GPUBatch *DRW_cache_object_surface_get(Object *ob) } } +int DRW_cache_object_material_count_get(struct Object *ob) +{ + short type = (ob->runtime.mesh_eval != NULL) ? OB_MESH : ob->type; + + switch (type) { + case OB_MESH: + return DRW_mesh_material_count_get(ob->data); + case OB_CURVE: + case OB_SURF: + case OB_FONT: + return DRW_curve_material_count_get(ob->data); + case OB_MBALL: + return DRW_metaball_material_count_get(ob->data); + default: + BLI_assert(0); + return 0; + } +} + GPUBatch **DRW_cache_object_surface_material_get(struct Object *ob, struct GPUMaterial **gpumat_array, uint gpumat_array_len) diff --git a/source/blender/draw/intern/draw_cache.h b/source/blender/draw/intern/draw_cache.h index 3759654931a..508a6f2c46d 100644 --- a/source/blender/draw/intern/draw_cache.h +++ b/source/blender/draw/intern/draw_cache.h @@ -56,6 +56,7 @@ struct GPUBatch **DRW_cache_object_surface_material_get(struct Object *ob, struct GPUMaterial **gpumat_array, uint gpumat_array_len); struct GPUBatch *DRW_cache_object_face_wireframe_get(struct Object *ob); +int DRW_cache_object_material_count_get(struct Object *ob); /* Empties */ struct GPUBatch *DRW_cache_plain_axes_get(void); @@ -132,8 +133,6 @@ struct GPUBatch *DRW_cache_mesh_surface_weights_get(struct Object *ob); struct GPUBatch *DRW_cache_mesh_surface_mesh_analysis_get(struct Object *ob); struct GPUBatch *DRW_cache_mesh_face_wireframe_get(struct Object *ob); -void DRW_cache_mesh_sculpt_coords_ensure(struct Object *ob); - /* Curve */ struct GPUBatch *DRW_cache_curve_surface_get(struct Object *ob); struct GPUBatch **DRW_cache_curve_surface_shaded_get(struct Object *ob, diff --git a/source/blender/draw/intern/draw_cache_impl.h b/source/blender/draw/intern/draw_cache_impl.h index bf056d7444d..ffc8c2c8e56 100644 --- a/source/blender/draw/intern/draw_cache_impl.h +++ b/source/blender/draw/intern/draw_cache_impl.h @@ -69,6 +69,8 @@ void DRW_mesh_batch_cache_free_old(struct Mesh *me, int ctime); /* Curve */ void DRW_curve_batch_cache_create_requested(struct Object *ob); +int DRW_curve_material_count_get(struct Curve *cu); + struct GPUBatch *DRW_curve_batch_cache_get_wire_edge(struct Curve *cu); struct GPUBatch *DRW_curve_batch_cache_get_normal_edge(struct Curve *cu); struct GPUBatch *DRW_curve_batch_cache_get_edge_detection(struct Curve *cu, bool *r_is_manifold); @@ -80,7 +82,10 @@ struct GPUBatch **DRW_curve_batch_cache_get_surface_shaded(struct Curve *cu, struct GPUMaterial **gpumat_array, uint gpumat_array_len); struct GPUBatch *DRW_curve_batch_cache_get_wireframes_face(struct Curve *cu); + /* Metaball */ +int DRW_metaball_material_count_get(struct MetaBall *mb); + struct GPUBatch *DRW_metaball_batch_cache_get_triangles_with_normals(struct Object *ob); struct GPUBatch **DRW_metaball_batch_cache_get_surface_shaded(struct Object *ob, struct MetaBall *mb, @@ -160,6 +165,8 @@ struct GPUBatch *DRW_mesh_batch_cache_get_edituv_facedots(struct Mesh *me); struct GPUBatch *DRW_mesh_batch_cache_get_uv_edges(struct Mesh *me); struct GPUBatch *DRW_mesh_batch_cache_get_edit_mesh_analysis(struct Mesh *me); +int DRW_mesh_material_count_get(struct Mesh *me); + /* Edit mesh bitflags (is this the right place?) */ enum { VFLAG_VERT_ACTIVE = 1 << 0, diff --git a/source/blender/draw/intern/draw_cache_impl_curve.c b/source/blender/draw/intern/draw_cache_impl_curve.c index ab800e42cc0..05ec9bda642 100644 --- a/source/blender/draw/intern/draw_cache_impl_curve.c +++ b/source/blender/draw/intern/draw_cache_impl_curve.c @@ -414,7 +414,7 @@ static bool curve_batch_cache_valid(Curve *cu) return false; } - if (cache->mat_len != max_ii(1, cu->totcol)) { + if (cache->mat_len != DRW_curve_material_count_get(cu)) { return false; } @@ -914,6 +914,11 @@ GPUBatch *DRW_curve_batch_cache_get_edge_detection(Curve *cu, bool *r_is_manifol return DRW_batch_request(&cache->batch.edge_detection); } +int DRW_curve_material_count_get(Curve *cu) +{ + return max_ii(1, cu->totcol); +} + /** \} */ /* -------------------------------------------------------------------- */ diff --git a/source/blender/draw/intern/draw_cache_impl_mesh.c b/source/blender/draw/intern/draw_cache_impl_mesh.c index 458029c2580..87f93bf6fd6 100644 --- a/source/blender/draw/intern/draw_cache_impl_mesh.c +++ b/source/blender/draw/intern/draw_cache_impl_mesh.c @@ -751,6 +751,11 @@ GPUBatch *DRW_mesh_batch_cache_get_surface_vertpaint(Mesh *me) return DRW_batch_request(&cache->batch.surface); } +int DRW_mesh_material_count_get(Mesh *me) +{ + return mesh_render_mat_len_get(me); +} + /** \} */ /* ---------------------------------------------------------------------- */ diff --git a/source/blender/draw/intern/draw_cache_impl_metaball.c b/source/blender/draw/intern/draw_cache_impl_metaball.c index e3bfcbde3ef..c14e66c2b47 100644 --- a/source/blender/draw/intern/draw_cache_impl_metaball.c +++ b/source/blender/draw/intern/draw_cache_impl_metaball.c @@ -25,6 +25,7 @@ #include "MEM_guardedalloc.h" +#include "BLI_math_base.h" #include "BLI_utildefines.h" #include "DNA_meta_types.h" @@ -206,6 +207,8 @@ GPUBatch **DRW_metaball_batch_cache_get_surface_shaded(Object *ob, return NULL; } + BLI_assert(gpumat_array_len == DRW_metaball_material_count_get(mb)); + MetaBallBatchCache *cache = metaball_batch_cache_get(mb); if (cache->shaded_triangles == NULL) { cache->mat_len = gpumat_array_len; @@ -270,3 +273,8 @@ struct GPUBatch *DRW_metaball_batch_cache_get_edge_detection(struct Object *ob, return cache->edge_detection; } + +int DRW_metaball_material_count_get(MetaBall *mb) +{ + return max_ii(1, mb->totcol); +} |