DRW: Cleanup / Renaming of mesh batch cache functions
authorClément Foucault <foucault.clem@gmail.com>
Tue, 18 Dec 2018 16:10:38 +0000 (17:10 +0100)
committerClément Foucault <foucault.clem@gmail.com>
Tue, 18 Dec 2018 19:51:52 +0000 (20:51 +0100)
THis is in order to avoid the jungle of names being different at each
step of the API.

Also removes some unused functions.

source/blender/draw/engines/basic/basic_engine.c
source/blender/draw/intern/draw_armature.c
source/blender/draw/intern/draw_cache.c
source/blender/draw/intern/draw_cache.h
source/blender/draw/intern/draw_cache_impl.h
source/blender/draw/intern/draw_cache_impl_mesh.c
source/blender/draw/modes/object_mode.c
source/blender/draw/modes/overlay_mode.c
source/blender/draw/modes/paint_texture_mode.c
source/blender/draw/modes/paint_vertex_mode.c
source/blender/draw/modes/paint_weight_mode.c

index eea41c9..f64d345 100644 (file)
@@ -152,7 +152,7 @@ static void basic_cache_populate(void *vedata, Object *ob)
 
                if (is_flat_object_viewed_from_side) {
                        /* Avoid losing flat objects when in ortho views (see T56549) */
-                       struct GPUBatch *geom = DRW_cache_object_wire_outline_get(ob);
+                       struct GPUBatch *geom = DRW_cache_object_all_edges_get(ob);
                        DRW_shgroup_call_object_add(stl->g_data->depth_shgrp, geom, ob);
                        return;
                }
index 8d0cae3..e5a15a9 100644 (file)
@@ -363,7 +363,7 @@ static void drw_shgroup_bone_custom_wire(
         const float color[4], Object *custom)
 {
        /* grr, not re-using instances! */
-       struct GPUBatch *geom = DRW_cache_object_wire_outline_get(custom);
+       struct GPUBatch *geom = DRW_cache_object_all_edges_get(custom);
 
        /* XXXXXXX needs to be moved elsewhere. */
        drw_batch_cache_generate_requested(custom);
index 945de6e..ff4fb0c 100644 (file)
@@ -670,11 +670,11 @@ GPUBatch *DRW_cache_gpencil_axes_get(void)
 /** \name Common Object API
 * \{ */
 
-GPUBatch *DRW_cache_object_wire_outline_get(Object *ob)
+GPUBatch *DRW_cache_object_all_edges_get(Object *ob)
 {
        switch (ob->type) {
                case OB_MESH:
-                       return DRW_cache_mesh_wire_outline_get(ob);
+                       return DRW_cache_mesh_all_edges_get(ob);
 
                /* TODO, should match 'DRW_cache_object_surface_get' */
                default:
@@ -694,7 +694,6 @@ GPUBatch *DRW_cache_object_edge_detection_get(Object *ob, bool *r_is_manifold)
        }
 }
 
-/* Returns a buffer texture. */
 GPUBatch *DRW_cache_object_face_wireframe_get(Object *ob)
 {
        switch (ob->type) {
@@ -2992,121 +2991,81 @@ GPUBatch *DRW_cache_single_vert_get(void)
 /** \name Meshes
  * \{ */
 
-GPUBatch *DRW_cache_mesh_wire_outline_get(Object *ob)
+GPUBatch *DRW_cache_mesh_all_verts_get(Object *ob)
 {
        BLI_assert(ob->type == OB_MESH);
-
-       Mesh *me = ob->data;
-       return DRW_mesh_batch_cache_get_fancy_edges(me);
-}
-
-GPUBatch *DRW_cache_mesh_edge_detection_get(Object *ob, bool *r_is_manifold)
-{
-       BLI_assert(ob->type == OB_MESH);
-
-       Mesh *me = ob->data;
-       return DRW_mesh_batch_cache_get_edge_detection(me, r_is_manifold);
-}
-
-GPUBatch *DRW_cache_mesh_surface_get(Object *ob)
-{
-       BLI_assert(ob->type == OB_MESH);
-
-       Mesh *me = ob->data;
-       return DRW_mesh_batch_cache_get_triangles_with_normals(me);
+       return DRW_mesh_batch_cache_get_all_verts(ob->data);
 }
 
-GPUBatch *DRW_cache_mesh_wire_get(Object *ob)
+GPUBatch *DRW_cache_mesh_all_edges_get(Object *ob)
 {
        BLI_assert(ob->type == OB_MESH);
-
-       Mesh *me = ob->data;
-       return DRW_mesh_batch_cache_get_wire_loops(me);
+       return DRW_mesh_batch_cache_get_all_edges(ob->data);
 }
 
-GPUBatch *DRW_cache_mesh_face_wireframe_get(Object *ob)
+GPUBatch *DRW_cache_mesh_loose_edges_get(Object *ob)
 {
        BLI_assert(ob->type == OB_MESH);
-
-       Mesh *me = ob->data;
-       return DRW_mesh_batch_cache_get_wireframes_face(me);
+       return DRW_mesh_batch_cache_get_loose_edges(ob->data);
 }
 
-GPUBatch *DRW_cache_mesh_loose_edges_get(Object *ob)
+GPUBatch *DRW_cache_mesh_edge_detection_get(Object *ob, bool *r_is_manifold)
 {
        BLI_assert(ob->type == OB_MESH);
-
-       Mesh *me = ob->data;
-       return DRW_mesh_batch_cache_get_loose_edges_with_normals(me);
+       return DRW_mesh_batch_cache_get_edge_detection(ob->data, r_is_manifold);
 }
 
-GPUBatch *DRW_cache_mesh_surface_weights_get(Object *ob)
+GPUBatch *DRW_cache_mesh_surface_get(Object *ob)
 {
        BLI_assert(ob->type == OB_MESH);
-
-       Mesh *me = ob->data;
-       return DRW_mesh_batch_cache_get_triangles_with_normals_and_weights(me);
+       return DRW_mesh_batch_cache_get_surface(ob->data);
 }
 
-GPUBatch *DRW_cache_mesh_surface_vert_colors_get(Object *ob)
+GPUBatch *DRW_cache_mesh_surface_edges_get(Object *ob)
 {
        BLI_assert(ob->type == OB_MESH);
-
-       Mesh *me = ob->data;
-       return DRW_mesh_batch_cache_get_surface_vertpaint(me);
+       return DRW_mesh_batch_cache_get_surface_edges(ob->data);
 }
 
-/* Return list of batches */
+/* Return list of batches with length equal to max(1, totcol). */
 GPUBatch **DRW_cache_mesh_surface_shaded_get(
         Object *ob, struct GPUMaterial **gpumat_array, uint gpumat_array_len,
         char **auto_layer_names, int **auto_layer_is_srgb, int *auto_layer_count)
 {
        BLI_assert(ob->type == OB_MESH);
-
-       Mesh *me = ob->data;
-       return DRW_mesh_batch_cache_get_surface_shaded(me, gpumat_array, gpumat_array_len,
+       return DRW_mesh_batch_cache_get_surface_shaded(ob->data, gpumat_array, gpumat_array_len,
                                                       auto_layer_names, auto_layer_is_srgb, auto_layer_count);
 }
 
-/* Return list of batches */
+/* Return list of batches with length equal to max(1, totcol). */
 GPUBatch **DRW_cache_mesh_surface_texpaint_get(Object *ob)
 {
        BLI_assert(ob->type == OB_MESH);
-
-       Mesh *me = ob->data;
-       return DRW_mesh_batch_cache_get_surface_texpaint(me);
+       return DRW_mesh_batch_cache_get_surface_texpaint(ob->data);
 }
 
 GPUBatch *DRW_cache_mesh_surface_texpaint_single_get(Object *ob)
 {
        BLI_assert(ob->type == OB_MESH);
-
-       Mesh *me = ob->data;
-       return DRW_mesh_batch_cache_get_surface_texpaint_single(me);
+       return DRW_mesh_batch_cache_get_surface_texpaint_single(ob->data);
 }
 
-GPUBatch *DRW_cache_mesh_surface_verts_get(Object *ob)
+GPUBatch *DRW_cache_mesh_surface_vertpaint_get(Object *ob)
 {
        BLI_assert(ob->type == OB_MESH);
-
-       Mesh *me = ob->data;
-       return DRW_mesh_batch_cache_get_points_with_normals(me);
+       return DRW_mesh_batch_cache_get_surface_vertpaint(ob->data);
 }
 
-GPUBatch *DRW_cache_mesh_edges_get(Object *ob)
+GPUBatch *DRW_cache_mesh_surface_weights_get(Object *ob)
 {
        BLI_assert(ob->type == OB_MESH);
-
-       Mesh *me = ob->data;
-       return DRW_mesh_batch_cache_get_all_edges(me);
+       return DRW_mesh_batch_cache_get_surface_weights(ob->data);
 }
 
-GPUBatch *DRW_cache_mesh_verts_get(Object *ob)
+GPUBatch *DRW_cache_mesh_face_wireframe_get(Object *ob)
 {
        BLI_assert(ob->type == OB_MESH);
-
-       Mesh *me = ob->data;
-       return DRW_mesh_batch_cache_get_all_verts(me);
+       return DRW_mesh_batch_cache_get_wireframes_face(ob->data);
 }
 
 void DRW_cache_mesh_sculpt_coords_ensure(Object *ob)
@@ -3163,7 +3122,7 @@ GPUBatch *DRW_cache_curve_surface_get(Object *ob)
        struct Curve *cu = ob->data;
        struct Mesh *mesh_eval = ob->runtime.mesh_eval;
        if (mesh_eval != NULL) {
-               return DRW_mesh_batch_cache_get_triangles_with_normals(mesh_eval);
+               return DRW_mesh_batch_cache_get_surface(mesh_eval);
        }
        else {
                return DRW_curve_batch_cache_get_triangles_with_normals(cu);
@@ -3177,7 +3136,7 @@ GPUBatch *DRW_cache_curve_loose_edges_get(Object *ob)
        struct Curve *cu = ob->data;
        struct Mesh *mesh_eval = ob->runtime.mesh_eval;
        if (mesh_eval != NULL) {
-               return DRW_mesh_batch_cache_get_loose_edges_with_normals(mesh_eval);
+               return DRW_mesh_batch_cache_get_loose_edges(mesh_eval);
        }
        else {
                /* TODO */
@@ -3267,7 +3226,7 @@ GPUBatch *DRW_cache_text_surface_get(Object *ob)
                return NULL;
        }
        if (mesh_eval != NULL) {
-               return DRW_mesh_batch_cache_get_triangles_with_normals(mesh_eval);
+               return DRW_mesh_batch_cache_get_surface(mesh_eval);
        }
        else {
                return DRW_curve_batch_cache_get_triangles_with_normals(cu);
@@ -3283,7 +3242,7 @@ GPUBatch *DRW_cache_text_loose_edges_get(Object *ob)
                return NULL;
        }
        if (mesh_eval != NULL) {
-               return DRW_mesh_batch_cache_get_loose_edges_with_normals(mesh_eval);
+               return DRW_mesh_batch_cache_get_loose_edges(mesh_eval);
        }
        else {
                /* TODO */
@@ -3338,7 +3297,7 @@ GPUBatch *DRW_cache_surf_surface_get(Object *ob)
        struct Curve *cu = ob->data;
        struct Mesh *mesh_eval = ob->runtime.mesh_eval;
        if (mesh_eval != NULL) {
-               return DRW_mesh_batch_cache_get_triangles_with_normals(mesh_eval);
+               return DRW_mesh_batch_cache_get_surface(mesh_eval);
        }
        else {
                return DRW_curve_batch_cache_get_triangles_with_normals(cu);
@@ -3374,7 +3333,7 @@ GPUBatch *DRW_cache_surf_loose_edges_get(Object *ob)
        struct Curve *cu = ob->data;
        struct Mesh *mesh_eval = ob->runtime.mesh_eval;
        if (mesh_eval != NULL) {
-               return DRW_mesh_batch_cache_get_loose_edges_with_normals(mesh_eval);
+               return DRW_mesh_batch_cache_get_loose_edges(mesh_eval);
        }
        else {
                /* TODO */
index 6387d9e..b2843ed 100644 (file)
@@ -50,7 +50,7 @@ struct GPUBatch *DRW_cache_single_line_endpoints_get(void);
 struct GPUBatch *DRW_cache_screenspace_circle_get(void);
 
 /* Common Object */
-struct GPUBatch *DRW_cache_object_wire_outline_get(struct Object *ob);
+struct GPUBatch *DRW_cache_object_all_edges_get(struct Object *ob);
 struct GPUBatch *DRW_cache_object_edge_detection_get(struct Object *ob, bool *r_is_manifold);
 struct GPUBatch *DRW_cache_object_surface_get(struct Object *ob);
 struct GPUBatch *DRW_cache_object_loose_edges_get(struct Object *ob);
@@ -124,22 +124,19 @@ struct GPUBatch *DRW_cache_bone_dof_sphere_get(void);
 struct GPUBatch *DRW_cache_bone_dof_lines_get(void);
 
 /* Meshes */
-struct GPUBatch *DRW_cache_mesh_wire_outline_get(struct Object *ob);
+struct GPUBatch *DRW_cache_mesh_all_verts_get(struct Object *ob);
+struct GPUBatch *DRW_cache_mesh_all_edges_get(struct Object *ob);
+struct GPUBatch *DRW_cache_mesh_loose_edges_get(struct Object *ob);
 struct GPUBatch *DRW_cache_mesh_edge_detection_get(struct Object *ob, bool *r_is_manifold);
 struct GPUBatch *DRW_cache_mesh_surface_get(struct Object *ob);
-struct GPUBatch *DRW_cache_mesh_wire_get(struct Object *ob);
-struct GPUBatch *DRW_cache_mesh_loose_edges_get(struct Object *ob);
-struct GPUBatch *DRW_cache_mesh_surface_weights_get(struct Object *ob);
-struct GPUBatch *DRW_cache_mesh_surface_vert_colors_get(struct Object *ob);
-struct GPUBatch *DRW_cache_mesh_surface_verts_get(struct Object *ob);
-struct GPUBatch *DRW_cache_mesh_edges_get(struct Object *ob);
-struct GPUBatch *DRW_cache_mesh_verts_get(struct Object *ob);
-struct GPUBatch *DRW_cache_mesh_edges_paint_overlay_get(struct Object *ob, bool use_wire, bool use_sel);
+struct GPUBatch *DRW_cache_mesh_surface_edges_get(struct Object *ob);
 struct GPUBatch **DRW_cache_mesh_surface_shaded_get(
         struct Object *ob, struct GPUMaterial **gpumat_array, uint gpumat_array_len,
         char **auto_layer_names, int **auto_layer_is_srgb, int *auto_layer_count);
 struct GPUBatch **DRW_cache_mesh_surface_texpaint_get(struct Object *ob);
 struct GPUBatch *DRW_cache_mesh_surface_texpaint_single_get(struct Object *ob);
+struct GPUBatch *DRW_cache_mesh_surface_vertpaint_get(struct Object *ob);
+struct GPUBatch *DRW_cache_mesh_surface_weights_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);
index d1c5afe..bd7260f 100644 (file)
@@ -98,23 +98,20 @@ struct GPUBatch *DRW_lattice_batch_cache_get_edit_verts(struct Lattice *lt);
 /* Mesh */
 void DRW_mesh_batch_cache_create_requested(struct Object *ob, struct Mesh *me);
 
+struct GPUBatch *DRW_mesh_batch_cache_get_all_verts(struct Mesh *me);
+struct GPUBatch *DRW_mesh_batch_cache_get_all_edges(struct Mesh *me);
+struct GPUBatch *DRW_mesh_batch_cache_get_loose_edges(struct Mesh *me);
+struct GPUBatch *DRW_mesh_batch_cache_get_edge_detection(struct Mesh *me, bool *r_is_manifold);
+struct GPUBatch *DRW_mesh_batch_cache_get_surface(struct Mesh *me);
+struct GPUBatch *DRW_mesh_batch_cache_get_surface_edges(struct Mesh *me);
 struct GPUBatch **DRW_mesh_batch_cache_get_surface_shaded(
         struct Mesh *me, struct GPUMaterial **gpumat_array, uint gpumat_array_len,
         char **auto_layer_names, int **auto_layer_is_srgb, int *auto_layer_count);
 struct GPUBatch **DRW_mesh_batch_cache_get_surface_texpaint(struct Mesh *me);
 struct GPUBatch *DRW_mesh_batch_cache_get_surface_texpaint_single(struct Mesh *me);
 struct GPUBatch *DRW_mesh_batch_cache_get_surface_vertpaint(struct Mesh *me);
-struct GPUBatch *DRW_mesh_batch_cache_get_wire_loops(struct Mesh *me);
-struct GPUBatch *DRW_mesh_batch_cache_get_all_edges(struct Mesh *me);
-struct GPUBatch *DRW_mesh_batch_cache_get_triangles_with_normals(struct Mesh *me);
-struct GPUBatch *DRW_mesh_batch_cache_get_triangles_with_normals_and_weights(struct Mesh *me);
-struct GPUBatch *DRW_mesh_batch_cache_get_triangles_with_select_id(struct Mesh *me, bool use_hide, uint select_id_offset);
-struct GPUBatch *DRW_mesh_batch_cache_get_triangles_with_select_mask(struct Mesh *me, bool use_hide);
-struct GPUBatch *DRW_mesh_batch_cache_get_loose_edges_with_normals(struct Mesh *me);
-struct GPUBatch *DRW_mesh_batch_cache_get_points_with_normals(struct Mesh *me);
-struct GPUBatch *DRW_mesh_batch_cache_get_all_verts(struct Mesh *me);
-struct GPUBatch *DRW_mesh_batch_cache_get_fancy_edges(struct Mesh *me);
-struct GPUBatch *DRW_mesh_batch_cache_get_edge_detection(struct Mesh *me, bool *r_is_manifold);
+struct GPUBatch *DRW_mesh_batch_cache_get_surface_weights(struct Mesh *me);
+/* edit-mesh drawing */
 struct GPUBatch *DRW_mesh_batch_cache_get_edit_triangles(struct Mesh *me);
 struct GPUBatch *DRW_mesh_batch_cache_get_edit_triangles_nor(struct Mesh *me);
 struct GPUBatch *DRW_mesh_batch_cache_get_edit_triangles_lnor(struct Mesh *me);
@@ -123,7 +120,9 @@ struct GPUBatch *DRW_mesh_batch_cache_get_edit_loose_edges(struct Mesh *me);
 struct GPUBatch *DRW_mesh_batch_cache_get_edit_loose_edges_nor(struct Mesh *me);
 struct GPUBatch *DRW_mesh_batch_cache_get_edit_loose_verts(struct Mesh *me);
 struct GPUBatch *DRW_mesh_batch_cache_get_edit_facedots(struct Mesh *me);
-/* edit-mesh selection (use generic function for faces) */
+/* edit-mesh selection */
+struct GPUBatch *DRW_mesh_batch_cache_get_triangles_with_select_id(struct Mesh *me, bool use_hide, uint select_id_offset);
+struct GPUBatch *DRW_mesh_batch_cache_get_triangles_with_select_mask(struct Mesh *me, bool use_hide);
 struct GPUBatch *DRW_mesh_batch_cache_get_facedots_with_select_id(struct Mesh *me, uint select_id_offset);
 struct GPUBatch *DRW_mesh_batch_cache_get_edges_with_select_id(struct Mesh *me, uint select_id_offset);
 struct GPUBatch *DRW_mesh_batch_cache_get_verts_with_select_id(struct Mesh *me, uint select_id_offset);
index 95438b9..5d3a856 100644 (file)
@@ -1186,7 +1186,7 @@ static int mesh_render_data_loose_verts_len_get_maybe_mapped(const MeshRenderDat
        return ((rdata->mapped.use == false) ? rdata->loose_vert_len : rdata->mapped.loose_vert_len);
 }
 
-static int mesh_render_data_edges_len_get(const MeshRenderData *rdata)
+static int UNUSED_FUNCTION(mesh_render_data_edges_len_get)(const MeshRenderData *rdata)
 {
        BLI_assert(rdata->types & MR_DATATYPE_EDGE);
        return rdata->edge_len;
@@ -1476,113 +1476,6 @@ fallback:
 /** \name Internal Cache Generation
  * \{ */
 
-static bool mesh_render_data_edge_vcos_manifold_pnors(
-        MeshRenderData *rdata, const int edge_index,
-        float **r_vco1, float **r_vco2, float **r_pnor1, float **r_pnor2, bool *r_is_manifold)
-{
-       BLI_assert(rdata->types & (MR_DATATYPE_VERT | MR_DATATYPE_EDGE | MR_DATATYPE_LOOP | MR_DATATYPE_POLY));
-
-       if (rdata->edit_bmesh) {
-               BMesh *bm = rdata->edit_bmesh->bm;
-               BMEdge *eed = BM_edge_at_index(bm, edge_index);
-               if (BM_elem_flag_test(eed, BM_ELEM_HIDDEN)) {
-                       return false;
-               }
-               *r_vco1 = eed->v1->co;
-               *r_vco2 = eed->v2->co;
-               if (BM_edge_is_manifold(eed)) {
-                       *r_pnor1 = eed->l->f->no;
-                       *r_pnor2 = eed->l->radial_next->f->no;
-                       *r_is_manifold = true;
-               }
-               else if (eed->l != NULL) {
-                       *r_pnor1 = eed->l->f->no;
-                       *r_pnor2 = eed->l->f->no;
-                       *r_is_manifold = false;
-               }
-               else {
-                       *r_pnor1 = eed->v1->no;
-                       *r_pnor2 = eed->v1->no;
-                       *r_is_manifold = false;
-               }
-       }
-       else {
-               MVert *mvert = rdata->mvert;
-               const MEdge *medge = rdata->medge;
-               EdgeAdjacentPolys *eap = rdata->edges_adjacent_polys;
-               float (*pnors)[3] = rdata->poly_normals;
-
-               if (!eap) {
-                       const MLoop *mloop = rdata->mloop;
-                       const MPoly *mpoly = rdata->mpoly;
-                       const int poly_len = rdata->poly_len;
-                       const bool do_pnors = (poly_len != 0 && pnors == NULL);
-
-                       eap = rdata->edges_adjacent_polys = MEM_mallocN(sizeof(*eap) * rdata->edge_len, __func__);
-                       for (int i = 0; i < rdata->edge_len; i++) {
-                               eap[i].count = 0;
-                               eap[i].face_index[0] = -1;
-                               eap[i].face_index[1] = -1;
-                       }
-                       if (do_pnors) {
-                               pnors = rdata->poly_normals = MEM_mallocN(sizeof(*pnors) * poly_len, __func__);
-                       }
-
-                       for (int i = 0; i < poly_len; i++, mpoly++) {
-                               if (do_pnors) {
-                                       BKE_mesh_calc_poly_normal(mpoly, mloop + mpoly->loopstart, mvert, pnors[i]);
-                               }
-
-                               const int loopend = mpoly->loopstart + mpoly->totloop;
-                               for (int j = mpoly->loopstart; j < loopend; j++) {
-                                       const int edge_idx = mloop[j].e;
-                                       if (eap[edge_idx].count < 2) {
-                                               eap[edge_idx].face_index[eap[edge_idx].count] = i;
-                                       }
-                                       eap[edge_idx].count++;
-                               }
-                       }
-               }
-               BLI_assert(eap && (rdata->poly_len == 0 || pnors != NULL));
-
-               *r_vco1 = mvert[medge[edge_index].v1].co;
-               *r_vco2 = mvert[medge[edge_index].v2].co;
-               if (eap[edge_index].face_index[0] == -1) {
-                       /* Edge has no poly... */
-                       *r_pnor1 = *r_pnor2 = mvert[medge[edge_index].v1].co; /* XXX mvert.no are shorts... :( */
-                       *r_is_manifold = false;
-               }
-               else {
-                       *r_pnor1 = pnors[eap[edge_index].face_index[0]];
-
-                       float nor[3], v1[3], v2[3], r_center[3];
-                       const MPoly *mpoly = rdata->mpoly + eap[edge_index].face_index[0];
-                       const MLoop *mloop = rdata->mloop + mpoly->loopstart;
-
-                       BKE_mesh_calc_poly_center(mpoly, mloop, mvert, r_center);
-                       sub_v3_v3v3(v1, *r_vco2, *r_vco1);
-                       sub_v3_v3v3(v2, r_center, *r_vco1);
-                       cross_v3_v3v3(nor, v1, v2);
-
-                       if (dot_v3v3(nor, *r_pnor1) < 0.0) {
-                               SWAP(float *, *r_vco1, *r_vco2);
-                       }
-
-                       if (eap[edge_index].count == 2) {
-                               BLI_assert(eap[edge_index].face_index[1] >= 0);
-                               *r_pnor2 = pnors[eap[edge_index].face_index[1]];
-                               *r_is_manifold = true;
-                       }
-                       else {
-                               *r_pnor2 = pnors[eap[edge_index].face_index[0]];
-                               *r_is_manifold = false;
-                       }
-               }
-       }
-
-       return true;
-}
-
 static uchar mesh_render_data_looptri_flag(MeshRenderData *rdata, const BMFace *efa)
 {
        uchar fflag = 0;
@@ -4530,13 +4423,13 @@ GPUBatch *DRW_mesh_batch_cache_get_all_edges(Mesh *me)
        return DRW_batch_request(&cache->batch.all_edges);
 }
 
-GPUBatch *DRW_mesh_batch_cache_get_triangles_with_normals(Mesh *me)
+GPUBatch *DRW_mesh_batch_cache_get_surface(Mesh *me)
 {
        MeshBatchCache *cache = mesh_batch_cache_get(me);
        return DRW_batch_request(&cache->batch.surface);
 }
 
-GPUBatch *DRW_mesh_batch_cache_get_loose_edges_with_normals(Mesh *me)
+GPUBatch *DRW_mesh_batch_cache_get_loose_edges(Mesh *me)
 {
        MeshBatchCache *cache = mesh_batch_cache_get(me);
 
@@ -4557,7 +4450,7 @@ GPUBatch *DRW_mesh_batch_cache_get_loose_edges_with_normals(Mesh *me)
        return cache->ledges_with_normals;
 }
 
-GPUBatch *DRW_mesh_batch_cache_get_triangles_with_normals_and_weights(Mesh *me)
+GPUBatch *DRW_mesh_batch_cache_get_surface_weights(Mesh *me)
 {
        MeshBatchCache *cache = mesh_batch_cache_get(me);
        return DRW_batch_request(&cache->batch.surface_weights);
@@ -4619,88 +4512,6 @@ struct GPUBatch *DRW_mesh_batch_cache_get_triangles_with_select_mask(struct Mesh
        return cache->triangles_with_select_mask;
 }
 
-GPUBatch *DRW_mesh_batch_cache_get_points_with_normals(Mesh *me)
-{
-       MeshBatchCache *cache = mesh_batch_cache_get(me);
-
-       if (cache->points_with_normals == NULL) {
-               const int datatype = MR_DATATYPE_VERT | MR_DATATYPE_LOOPTRI | MR_DATATYPE_LOOP | MR_DATATYPE_POLY;
-               MeshRenderData *rdata = mesh_render_data_create(me, datatype);
-
-               cache->points_with_normals = GPU_batch_create(
-                       GPU_PRIM_POINTS, mesh_batch_cache_get_tri_pos_and_normals_edit(rdata, cache, false), NULL);
-
-               mesh_render_data_free(rdata);
-       }
-
-       return cache->points_with_normals;
-}
-
-GPUBatch *DRW_mesh_batch_cache_get_fancy_edges(Mesh *me)
-{
-       MeshBatchCache *cache = mesh_batch_cache_get(me);
-
-       if (cache->fancy_edges == NULL) {
-               /* create batch from DM */
-               static GPUVertFormat format = { 0 };
-               static struct { uint pos, n1, n2; } attr_id;
-               if (format.attr_len == 0) {
-                       attr_id.pos = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
-
-                       attr_id.n1 = GPU_vertformat_attr_add(&format, "N1", GPU_COMP_I10, 3, GPU_FETCH_INT_TO_FLOAT_UNIT);
-                       attr_id.n2 = GPU_vertformat_attr_add(&format, "N2", GPU_COMP_I10, 3, GPU_FETCH_INT_TO_FLOAT_UNIT);
-               }
-               GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format);
-
-               MeshRenderData *rdata = mesh_render_data_create(
-                       me, MR_DATATYPE_VERT | MR_DATATYPE_EDGE | MR_DATATYPE_LOOP | MR_DATATYPE_POLY);
-
-               const int edge_len = mesh_render_data_edges_len_get(rdata);
-
-               const int vbo_len_capacity = edge_len * 2; /* these are PRIM_LINE verts, not mesh verts */
-               int vbo_len_used = 0;
-               GPU_vertbuf_data_alloc(vbo, vbo_len_capacity);
-               for (int i = 0; i < edge_len; i++) {
-                       float *vcos1, *vcos2;
-                       float *pnor1 = NULL, *pnor2 = NULL;
-                       bool is_manifold;
-
-                       if (mesh_render_data_edge_vcos_manifold_pnors(rdata, i, &vcos1, &vcos2, &pnor1, &pnor2, &is_manifold)) {
-
-                               GPUPackedNormal n1value = { .x = 0, .y = 0, .z = +511 };
-                               GPUPackedNormal n2value = { .x = 0, .y = 0, .z = -511 };
-
-                               if (is_manifold) {
-                                       n1value = GPU_normal_convert_i10_v3(pnor1);
-                                       n2value = GPU_normal_convert_i10_v3(pnor2);
-                               }
-
-                               const GPUPackedNormal *n1 = &n1value;
-                               const GPUPackedNormal *n2 = &n2value;
-
-                               GPU_vertbuf_attr_set(vbo, attr_id.pos, 2 * i, vcos1);
-                               GPU_vertbuf_attr_set(vbo, attr_id.n1, 2 * i, n1);
-                               GPU_vertbuf_attr_set(vbo, attr_id.n2, 2 * i, n2);
-
-                               GPU_vertbuf_attr_set(vbo, attr_id.pos, 2 * i + 1, vcos2);
-                               GPU_vertbuf_attr_set(vbo, attr_id.n1, 2 * i + 1, n1);
-                               GPU_vertbuf_attr_set(vbo, attr_id.n2, 2 * i + 1, n2);
-
-                               vbo_len_used += 2;
-                       }
-               }
-               if (vbo_len_used != vbo_len_capacity) {
-                       GPU_vertbuf_data_resize(vbo, vbo_len_used);
-               }
-
-               cache->fancy_edges = GPU_batch_create_ex(GPU_PRIM_LINES, vbo, NULL, GPU_BATCH_OWNS_VBO);
-
-               mesh_render_data_free(rdata);
-       }
-
-       return cache->fancy_edges;
-}
-
 GPUBatch *DRW_mesh_batch_cache_get_edge_detection(Mesh *me, bool *r_is_manifold)
 {
        MeshBatchCache *cache = mesh_batch_cache_get(me);
@@ -5009,7 +4820,7 @@ GPUBatch *DRW_mesh_batch_cache_get_texpaint_loop_wire(Mesh *me)
        return cache->texpaint_uv_loops;
 }
 
-GPUBatch *DRW_mesh_batch_cache_get_wire_loops(Mesh *me)
+GPUBatch *DRW_mesh_batch_cache_get_surface_edges(Mesh *me)
 {
        MeshBatchCache *cache = mesh_batch_cache_get(me);
        return DRW_batch_request(&cache->batch.wire_loops);
index 177c6c7..8f6b23e 100644 (file)
@@ -2657,7 +2657,7 @@ static void OBJECT_cache_populate(void *vedata, Object *ob)
                        if (ob != draw_ctx->object_edit) {
                                Mesh *me = ob->data;
                                if (me->totedge == 0) {
-                                       struct GPUBatch *geom = DRW_cache_mesh_verts_get(ob);
+                                       struct GPUBatch *geom = DRW_cache_mesh_all_verts_get(ob);
                                        if (geom) {
                                                if (theme_id == TH_UNDEFINED) {
                                                        theme_id = DRW_object_wire_theme_get(ob, view_layer, NULL);
index 7060c1c..2011597 100644 (file)
@@ -260,7 +260,7 @@ static void overlay_cache_populate(void *vedata, Object *ob)
 
                        if (is_flat_object_viewed_from_side && !is_sculpt_mode) {
                                /* Avoid losing flat objects when in ortho views (see T56549) */
-                               struct GPUBatch *geom = DRW_cache_object_wire_outline_get(ob);
+                               struct GPUBatch *geom = DRW_cache_object_all_edges_get(ob);
                                if (geom) {
                                        shgrp = pd->flat_wires;
                                        shgrp = DRW_shgroup_create_sub(shgrp);
index 3386c79..cf6f321 100644 (file)
@@ -305,7 +305,7 @@ static void PAINT_TEXTURE_cache_populate(void *vedata, Object *ob)
                /* Face Mask */
                if (use_face_sel) {
                        struct GPUBatch *geom;
-                       geom = DRW_cache_mesh_wire_get(ob);
+                       geom = DRW_cache_mesh_surface_edges_get(ob);
                        DRW_shgroup_call_add(stl->g_data->lwire_shgrp, geom, ob->obmat);
 
                        geom = DRW_cache_mesh_surface_get(ob);
index 7d3aa0f..d577776 100644 (file)
@@ -165,12 +165,12 @@ static void PAINT_VERTEX_cache_populate(void *vedata, Object *ob)
                }
 
                if (use_surface) {
-                       geom = DRW_cache_mesh_surface_vert_colors_get(ob);
+                       geom = DRW_cache_mesh_surface_vertpaint_get(ob);
                        DRW_shgroup_call_add(stl->g_data->fvcolor_shgrp, geom, ob->obmat);
                }
 
                if (use_face_sel || use_wire) {
-                       geom = DRW_cache_mesh_wire_get(ob);
+                       geom = DRW_cache_mesh_surface_edges_get(ob);
                        DRW_shgroup_call_add(stl->g_data->lwire_shgrp, geom, ob->obmat);
                }
 
index e3993ee..0d6b2ed 100644 (file)
@@ -196,7 +196,7 @@ static void PAINT_WEIGHT_cache_populate(void *vedata, Object *ob)
                }
 
                if (use_face_sel || use_wire) {
-                       geom = DRW_cache_mesh_wire_get(ob);
+                       geom = DRW_cache_mesh_surface_edges_get(ob);
                        DRW_shgroup_call_add(stl->g_data->lwire_shgrp, geom, ob->obmat);
                }
 
@@ -206,7 +206,7 @@ static void PAINT_WEIGHT_cache_populate(void *vedata, Object *ob)
                }
 
                if (use_vert_sel) {
-                       geom = DRW_cache_mesh_verts_get(ob);
+                       geom = DRW_cache_mesh_all_verts_get(ob);
                        DRW_shgroup_call_add(stl->g_data->vert_shgrp, geom, ob->obmat);
                }
        }