[Bf-blender-cvs] [7d5e1f61bc2] tmp-batch-cache-cleanup: Cleanup: Mesh Batch Cache: Remove old unused code

Clément Foucault noreply at git.blender.org
Mon Jul 22 12:53:13 CEST 2019


Commit: 7d5e1f61bc239af12465c5a87b8f70534d1a89fd
Author: Clément Foucault
Date:   Sun Jul 21 15:03:11 2019 +0200
Branches: tmp-batch-cache-cleanup
https://developer.blender.org/rB7d5e1f61bc239af12465c5a87b8f70534d1a89fd

Cleanup: Mesh Batch Cache: Remove old unused code

===================================================================

M	source/blender/draw/intern/draw_cache_impl_mesh.c

===================================================================

diff --git a/source/blender/draw/intern/draw_cache_impl_mesh.c b/source/blender/draw/intern/draw_cache_impl_mesh.c
index a46113c0bfc..9a48325cd84 100644
--- a/source/blender/draw/intern/draw_cache_impl_mesh.c
+++ b/source/blender/draw/intern/draw_cache_impl_mesh.c
@@ -97,6 +97,12 @@ typedef enum eMRIterType {
   MR_ITER_LVERT = 1 << 3,
 } eMRIterType;
 
+typedef enum eMRDataType {
+  MR_DATA_POLY_NOR = 1 << 1,
+  MR_DATA_LOOP_NOR = 1 << 2,
+  MR_DATA_LOOPTRI = 1 << 3,
+} eMRDataType;
+
 typedef enum eMRExtractType {
   MR_EXTRACT_BMESH,
   MR_EXTRACT_MAPPED,
@@ -109,267 +115,53 @@ enum {
   DRW_MESH_WEIGHT_STATE_AUTO_NORMALIZE = (1 << 1),
 };
 
-/* ---------------------------------------------------------------------- */
-/** \name BMesh Inline Wrappers
- * \{ */
-
-/**
- * Wrapper for #BM_vert_find_first_loop_visible
- * since most of the time this can be accessed directly without a function call.
- */
-BLI_INLINE BMLoop *bm_vert_find_first_loop_visible_inline(BMVert *v)
-{
-  if (v->e) {
-    BMLoop *l = v->e->l;
-    if (l && !BM_elem_flag_test(l->f, BM_ELEM_HIDDEN)) {
-      return l->v == v ? l : l->next;
-    }
-    return BM_vert_find_first_loop_visible(v);
-  }
-  return NULL;
-}
-
-BLI_INLINE BMLoop *bm_edge_find_first_loop_visible_inline(BMEdge *e)
-{
-  if (e->l) {
-    BMLoop *l = e->l;
-    if (!BM_elem_flag_test(l->f, BM_ELEM_HIDDEN)) {
-      return l;
-    }
-    return BM_edge_find_first_loop_visible(e);
-  }
-  return NULL;
-}
-
-/** \} */
-
-/* ---------------------------------------------------------------------- */
-/** \name Mesh/BMesh Interface (direct access to basic data).
- * \{ */
-
-static int mesh_render_verts_len_get(Mesh *me)
-{
-  return me->edit_mesh ? me->edit_mesh->bm->totvert : me->totvert;
-}
-
-static int mesh_render_edges_len_get(Mesh *me)
-{
-  return me->edit_mesh ? me->edit_mesh->bm->totedge : me->totedge;
-}
-
-static int mesh_render_looptri_len_get(Mesh *me)
-{
-  return me->edit_mesh ? me->edit_mesh->tottri : poly_to_tri_count(me->totpoly, me->totloop);
-}
-
-static int mesh_render_polys_len_get(Mesh *me)
-{
-  return me->edit_mesh ? me->edit_mesh->bm->totface : me->totpoly;
-}
-
-static int mesh_render_mat_len_get(Mesh *me)
-{
-  return MAX2(1, me->totcol);
-}
-
-static int UNUSED_FUNCTION(mesh_render_loops_len_get)(Mesh *me)
-{
-  return me->edit_mesh ? me->edit_mesh->bm->totloop : me->totloop;
-}
-
-/** \} */
-
 /* ---------------------------------------------------------------------- */
 /** \name Mesh/BMesh Interface (indirect, partially cached access to complex data).
  * \{ */
 
-typedef struct EdgeAdjacentPolys {
-  int count;
-  int face_index[2];
-} EdgeAdjacentPolys;
-
-typedef struct EdgeAdjacentVerts {
-  int vert_index[2]; /* -1 if none */
-} EdgeAdjacentVerts;
-
-typedef struct EdgeDrawAttr {
-  uchar v_flag;
-  uchar e_flag;
-  uchar crease;
-  uchar bweight;
-} EdgeDrawAttr;
-
 typedef struct MeshRenderData {
-  int types;
+  eMRExtractType extract_type;
 
-  int vert_len;
-  int edge_len;
-  int tri_len;
-  int loop_len;
-  int loop_loose_len;
+  int poly_len, edge_len, vert_len, loop_len;
   int edge_loose_len;
   int vert_loose_len;
-  int poly_len;
+  int loop_loose_len;
+  int tri_len;
   int mat_len;
-  int loose_vert_len; /* Obsolete */
-  int loose_edge_len; /* Obsolete */
-
-  int *lverts;
-  int *ledges;
 
   bool use_mapped;
   bool use_hide;
   bool use_subsurf_fdots;
 
+  const ToolSettings *toolsettings;
   /* HACK not supposed to be there but it's needed. */
   struct MeshBatchCache *cache;
-
-  /* Support for mapped mesh data. */
-  struct {
-    /* Must be set if we want to get mapped data. */
-    bool use;
-    bool supported;
-
-    Mesh *me_cage;
-
-    int vert_len;
-    int edge_len;
-    int tri_len;
-    int loop_len;
-    int poly_len;
-
-    int *loose_verts;
-    int loose_vert_len;
-
-    int *loose_edges;
-    int loose_edge_len;
-
-    /* origindex layers */
-    int *v_origindex;
-    int *e_origindex;
-    int *l_origindex;
-    int *p_origindex;
-  } mapped;
-
-  int *v_origindex;
-  int *e_origindex;
-  int *l_origindex;
-  int *p_origindex;
-
+  /** Edit Mesh */
   BMEditMesh *edit_bmesh;
   BMesh *bm;
-  struct EditMeshData *edit_data;
-  const ToolSettings *toolsettings;
-
-  eMRExtractType iter;
-
+  EditMeshData *edit_data;
+  int *v_origindex, *e_origindex, *p_origindex;
+  int crease_ofs;
+  int bweight_ofs;
+  int freestyle_edge_ofs;
+  int freestyle_face_ofs;
+  /** Mesh */
   Mesh *me;
-
-  MVert *mvert;
+  const MVert *mvert;
   const MEdge *medge;
   const MLoop *mloop;
   const MPoly *mpoly;
-  float (*orco)[3]; /* vertex coordinates normalized to bounding box */
-  bool is_orco_allocated;
-  MDeformVert *dvert;
-  MLoopUV *mloopuv;
-  MLoopCol *mloopcol;
-  float (*loop_normals)[3];
-
-  /* CustomData 'cd' cache for efficient access. */
-  struct {
-    struct {
-      MLoopUV **uv;
-      MLoopCol **vcol;
-      float (**tangent)[4];
-
-      int uv_len;
-      int uv_active;
-      int uv_render;
-      int uv_mask_active;
-
-      int vcol_len;
-      int vcol_active;
-      int vcol_render;
-
-      int tangent_len;
-      int tangent_active;
-      int tangent_render;
-
-      bool *auto_vcol;
-    } layers;
-
-    /* Custom-data offsets (only needed for BMesh access) */
-    struct {
-      int crease;
-      int bweight;
-      int *uv;
-      int *vcol;
-#ifdef WITH_FREESTYLE
-      int freestyle_edge;
-      int freestyle_face;
-#endif
-    } offset;
-
-    struct {
-      char (*auto_mix)[32];
-      char (*uv)[32];
-      char (*vcol)[32];
-      char (*tangent)[32];
-    } uuid;
-
-    /* for certain cases we need an output loop-data storage (bmesh tangents) */
-    struct {
-      CustomData ldata;
-      /* grr, special case variable (use in place of 'dm->tangent_mask') */
-      short tangent_mask;
-    } output;
-  } cd;
-
   BMVert *eve_act;
   BMEdge *eed_act;
   BMFace *efa_act;
   BMFace *efa_act_uv;
-
   /* Data created on-demand (usually not for bmesh-based data). */
-  EdgeAdjacentPolys *edges_adjacent_polys;
   MLoopTri *mlooptri;
-  int *loose_edges;
-  int *loose_verts;
-
+  float (*loop_normals)[3];
   float (*poly_normals)[3];
-  float *vert_weight;
-  char (*vert_color)[3];
-  GPUPackedNormal *poly_normals_pack;
-  GPUPackedNormal *vert_normals_pack;
-  bool *edge_select_bool;
-  bool *edge_visible_bool;
+  int *lverts, *ledges;
 } MeshRenderData;
 
-typedef enum eMRDataType {
-  MR_DATATYPE_VERT = 1 << 0,
-  MR_DATATYPE_EDGE = 1 << 1,
-  MR_DATATYPE_LOOPTRI = 1 << 2,
-  MR_DATATYPE_LOOP = 1 << 3,
-  MR_DATATYPE_POLY = 1 << 4,
-  MR_DATATYPE_OVERLAY = 1 << 5,
-  MR_DATATYPE_SHADING = 1 << 6,
-  MR_DATATYPE_DVERT = 1 << 7,
-  MR_DATATYPE_LOOPCOL = 1 << 8,
-  MR_DATATYPE_LOOPUV = 1 << 9,
-  MR_DATATYPE_LOOSE_VERT = 1 << 10,
-  MR_DATATYPE_LOOSE_EDGE = 1 << 11,
-  MR_DATATYPE_LOOP_NORMALS = 1 << 12,
-  /* New data types to replace all above */
-  MR_DATA_POLY_NOR = 1 << 13,
-  MR_DATA_LOOP_NOR = 1 << 14,
-  MR_DATA_LOOPTRI = 1 << 15,
-} eMRDataType;
-
-#define MR_DATATYPE_VERT_LOOP_POLY (MR_DATATYPE_VERT | MR_DATATYPE_POLY | MR_DATATYPE_LOOP)
-#define MR_DATATYPE_VERT_LOOP_TRI_POLY (MR_DATATYPE_VERT_LOOP_POLY | MR_DATATYPE_LOOPTRI)
-#define MR_DATATYPE_LOOSE_VERT_EGDE (MR_DATATYPE_LOOSE_VERT | MR_DATATYPE_LOOSE_EDGE)
-
 /**
  * These functions look like they would be slow but they will typically return true on the first
  * iteration. Only false when all attached elements are hidden.
@@ -420,6 +212,11 @@ BLI_INLINE bool mesh_cd_layers_type_equal(DRW_MeshCDMask a, DRW_MeshCDMask b)
   return *((uint32_t *)&a) == *((uint32_t *)&b);
 }
 
+BLI_INLINE int mesh_render_mat_len_get(Mesh *me)
+{
+  return MAX2(1, me->totcol);
+}
+
 BLI_INLINE void mesh_cd_layers_type_merge(DRW_MeshCDMask *a, DRW_MeshCDMask b)
 {
   atomic_fetch_and_or_uint32((uint32_t *)a, *(uint32_t *)&b);
@@ -561,43 +358,6 @@ static DRW_MeshCDMask mesh_cd_calc_used_gpu_layers(const Mesh *me,
   return cd_used;
 }
 
-static void mesh_render_calc_normals_loop_and_poly(const Mesh *me,
-                                                   const float split_angle,
-                                                   MeshRenderData *rdata)
-{
-  BLI_assert((me->flag & ME_AUTOSMOOTH) != 0);
-
-  int totloop = me->totloop;
-  int totpoly = me->totpoly;
-  float(*loop_normals)[3] = MEM_mallocN(sizeof(*loop_normals) * totloop, __func__);
-  float(*poly_normals)[3] = MEM_mallocN(sizeof(*poly_normals) * totpoly, __func__);
-  short(*clnors)[2] = CustomData_get_layer(&me->ldata, CD_CUSTOMLOOPNORMAL);
-
-  BKE_mesh_calc_normals_poly(
-      me->mvert, NULL, me->totvert, me->mloop, me->mpoly, totloop, totpoly, poly_normals, false);
-
-  BKE_mesh_normals_loop_split(me->mvert,
-                              me->totvert,
-                              me->medge,
-                              me->totedge,
-                              me->mloop,
-                              loop_normals,
-                              totloop,
-                              me->mpoly,
-                              poly_normals,
-                              totpoly,
-                              true,
-                              split_angle,
-                              NULL,
-                              clnors,
-                              NULL);
-
-  rdata->loop_len = totloop;
-  rdata->poly_len = totpoly;
-  rdata->loop_normals = loop_normals;
-  rdata->poly_normals = poly_normals;
-}
-
 static void mesh_cd_extract_auto_layers_names_and_srgb(Mesh *me,
                                                        DRW_MeshCDMask cd_used,
                                                        char **r_auto_layers_names,
@@ -655,775 +415,164 @@ static void mesh_cd_extract_auto_layers_names_and_srgb(Mesh *me,
   *r_auto_layers_len = auto_is_srgb_ofs;
 }
 
-/**
- * TODO(campbell): 'gpumat_array' may include materials linked to the object.
- * While not default, object materials should be supported.
- * Although this only impacts the data that's generated, not the materials that display.
- */
-static void UNUSED_FUNCTION(mesh_render_data_create_ex)(Mesh *me,
-                                                        const int types,
-                                                  

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list