Mesh Batch Cache: Port Texture paint batches to new batch request
[blender.git] / source / blender / draw / engines / workbench / workbench_deferred.c
index 065efa4053ae4819763c601c43315a53bbfe19be..617108b1bde86ab11c28c49be9cc42419cff0235 100644 (file)
@@ -822,23 +822,16 @@ void workbench_deferred_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob)
                        const Mesh *me = ob->data;
                        if (me->mloopuv) {
                                const int materials_len = MAX2(1, (is_sculpt_mode ? 1 : ob->totcol));
-                               struct GPUMaterial **gpumat_array = BLI_array_alloca(gpumat_array, materials_len);
-                               struct GPUBatch **geom_array = me->totcol ? DRW_cache_mesh_surface_texpaint_get(ob) : NULL;
-                               if (materials_len > 0 && geom_array) {
-                                       for (int i = 0; i < materials_len; i++) {
-                                               if (geom_array[i] == NULL) {
-                                                       continue;
-                                               }
-
-                                               Material *mat = give_current_material(ob, i + 1);
-                                               Image *image;
-                                               ED_object_get_active_image(ob, i + 1, &image, NULL, NULL, NULL);
-                                               int color_type = workbench_material_determine_color_type(wpd, image, ob);
-                                               material = get_or_create_material_data(vedata, ob, mat, image, color_type);
-                                               DRW_shgroup_call_object_add(material->shgrp, geom_array[i], ob);
-                                       }
-                                       is_drawn = true;
+                               struct GPUBatch **geom_array = DRW_cache_mesh_surface_texpaint_get(ob);
+                               for (int i = 0; i < materials_len; i++) {
+                                       Material *mat = give_current_material(ob, i + 1);
+                                       Image *image;
+                                       ED_object_get_active_image(ob, i + 1, &image, NULL, NULL, NULL);
+                                       int color_type = workbench_material_determine_color_type(wpd, image, ob);
+                                       material = get_or_create_material_data(vedata, ob, mat, image, color_type);
+                                       DRW_shgroup_call_object_add(material->shgrp, geom_array[i], ob);
                                }
+                               is_drawn = true;
                        }
                }