[Bf-blender-cvs] [fb3b2ab709b] master: Cleanup: Remove unused code in sculpt_mode, workbench and draw manager

Clément Foucault noreply at git.blender.org
Sat May 4 14:11:39 CEST 2019


Commit: fb3b2ab709bfd3aa1e9a1c9db9d3ce05ed4e6c13
Author: Clément Foucault
Date:   Sat May 4 01:41:39 2019 +0200
Branches: master
https://developer.blender.org/rBfb3b2ab709bfd3aa1e9a1c9db9d3ce05ed4e6c13

Cleanup: Remove unused code in sculpt_mode, workbench and draw manager

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

M	source/blender/draw/engines/workbench/workbench_deferred.c
M	source/blender/draw/intern/DRW_render.h
M	source/blender/draw/intern/draw_cache.c
M	source/blender/draw/intern/draw_cache_impl.h
M	source/blender/draw/intern/draw_cache_impl_mesh.c
M	source/blender/draw/intern/draw_manager.h
M	source/blender/draw/intern/draw_manager_data.c
M	source/blender/draw/intern/draw_manager_exec.c
M	source/blender/draw/modes/sculpt_mode.c

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

diff --git a/source/blender/draw/engines/workbench/workbench_deferred.c b/source/blender/draw/engines/workbench/workbench_deferred.c
index 343ad26b802..abf167d53b0 100644
--- a/source/blender/draw/engines/workbench/workbench_deferred.c
+++ b/source/blender/draw/engines/workbench/workbench_deferred.c
@@ -941,7 +941,7 @@ void workbench_deferred_solid_cache_populate(WORKBENCH_Data *vedata, Object *ob)
     const Mesh *me = (ob->type == OB_MESH) ? ob->data : NULL;
     bool has_transp_mat = false;
 
-    if (!is_sculpt_mode && me && me->mloopuv && TEXTURE_DRAWING_ENABLED(wpd)) {
+    if (!is_sculpt_mode && TEXTURE_DRAWING_ENABLED(wpd) && me && me->mloopuv) {
       /* Draw textured */
       struct GPUBatch **geom_array = DRW_cache_mesh_surface_texpaint_get(ob);
       for (int i = 0; i < materials_len; i++) {
diff --git a/source/blender/draw/intern/DRW_render.h b/source/blender/draw/intern/DRW_render.h
index 363cf67623a..82584ebbb8d 100644
--- a/source/blender/draw/intern/DRW_render.h
+++ b/source/blender/draw/intern/DRW_render.h
@@ -401,10 +401,6 @@ DRWShadingGroup *DRW_shgroup_transform_feedback_create(struct GPUShader *shader,
                                                        DRWPass *pass,
                                                        struct GPUVertBuf *tf_target);
 
-typedef void(DRWCallGenerateFn)(DRWShadingGroup *shgroup,
-                                void (*draw_fn)(DRWShadingGroup *shgroup, struct GPUBatch *geom),
-                                void *user_data);
-
 /* return final visibility */
 typedef bool(DRWCallVisibilityFn)(bool vis_in, void *user_data);
 
@@ -422,9 +418,6 @@ void DRW_shgroup_call_procedural_lines_add(DRWShadingGroup *shgroup,
 void DRW_shgroup_call_procedural_triangles_add(DRWShadingGroup *shgroup,
                                                uint tria_count,
                                                float (*obmat)[4]);
-void DRW_shgroup_call_object_procedural_triangles_culled_add(DRWShadingGroup *shgroup,
-                                                             uint tria_count,
-                                                             struct Object *ob);
 void DRW_shgroup_call_object_add_ex(DRWShadingGroup *shgroup,
                                     struct GPUBatch *geom,
                                     struct Object *ob,
diff --git a/source/blender/draw/intern/draw_cache.c b/source/blender/draw/intern/draw_cache.c
index 6b4c4cef9c8..08cf56982ea 100644
--- a/source/blender/draw/intern/draw_cache.c
+++ b/source/blender/draw/intern/draw_cache.c
@@ -3290,14 +3290,6 @@ GPUBatch *DRW_cache_mesh_surface_mesh_analysis_get(Object *ob)
   return DRW_mesh_batch_cache_get_edit_mesh_analysis(ob->data);
 }
 
-void DRW_cache_mesh_sculpt_coords_ensure(Object *ob)
-{
-  BLI_assert(ob->type == OB_MESH);
-
-  Mesh *me = ob->data;
-  DRW_mesh_cache_sculpt_coords_ensure(me);
-}
-
 /** \} */
 
 /* -------------------------------------------------------------------- */
diff --git a/source/blender/draw/intern/draw_cache_impl.h b/source/blender/draw/intern/draw_cache_impl.h
index 4ef8f5a9326..508ae678778 100644
--- a/source/blender/draw/intern/draw_cache_impl.h
+++ b/source/blender/draw/intern/draw_cache_impl.h
@@ -159,8 +159,6 @@ 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);
 
-void DRW_mesh_cache_sculpt_coords_ensure(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_mesh.c b/source/blender/draw/intern/draw_cache_impl_mesh.c
index 1d8c7f0e5a7..f3b7e7adff0 100644
--- a/source/blender/draw/intern/draw_cache_impl_mesh.c
+++ b/source/blender/draw/intern/draw_cache_impl_mesh.c
@@ -4455,25 +4455,6 @@ GPUBatch *DRW_mesh_batch_cache_get_surface_edges(Mesh *me)
   return DRW_batch_request(&cache->batch.wire_loops);
 }
 
-/**
- * Needed for when we draw with shaded data.
- */
-void DRW_mesh_cache_sculpt_coords_ensure(Mesh *UNUSED(me))
-{
-#if 0 /* Unused for now */
-  if (me->runtime.batch_cache) {
-    MeshBatchCache *cache = mesh_batch_cache_get(me);
-    if (cache && cache->pos_with_normals && cache->is_sculpt_points_tag) {
-      /* XXX Force update of all the batches that contains the pos_with_normals buffer.
-       * TODO(fclem): Ideally, Gawain should provide a way to update a buffer without destroying it. */
-      mesh_batch_cache_clear_selective(me, cache->pos_with_normals);
-      GPU_VERTBUF_DISCARD_SAFE(cache->pos_with_normals);
-    }
-    cache->is_sculpt_points_tag = false;
-  }
-#endif
-}
-
 /* Compute 3D & 2D areas and their sum. */
 BLI_INLINE void edit_uv_preprocess_stretch_area(BMFace *efa,
                                                 const int cd_loop_uv_offset,
diff --git a/source/blender/draw/intern/draw_manager.h b/source/blender/draw/intern/draw_manager.h
index a70438a2d37..77cf6d20117 100644
--- a/source/blender/draw/intern/draw_manager.h
+++ b/source/blender/draw/intern/draw_manager.h
@@ -142,8 +142,6 @@ typedef enum {
   DRW_CALL_RANGE,
   /** Draw instances without any instancing attributes. */
   DRW_CALL_INSTANCES,
-  /** Uses a callback to draw with any number of batches. */
-  DRW_CALL_GENERATE,
   /** Generate a drawcall without any #GPUBatch. */
   DRW_CALL_PROCEDURAL,
 } DRWCallType;
@@ -166,10 +164,6 @@ typedef struct DRWCall {
       /* Count can be adjusted between redraw. If needed, we can add fixed count. */
       uint *count;
     } instances;
-    struct { /* type == DRW_CALL_GENERATE */
-      DRWCallGenerateFn *geometry_fn;
-      void *user_data;
-    } generate;
     struct { /* type == DRW_CALL_PROCEDURAL */
       uint vert_count;
       GPUPrimType prim_type;
diff --git a/source/blender/draw/intern/draw_manager_data.c b/source/blender/draw/intern/draw_manager_data.c
index c63e30e65d7..8f324cf08cb 100644
--- a/source/blender/draw/intern/draw_manager_data.c
+++ b/source/blender/draw/intern/draw_manager_data.c
@@ -522,15 +522,6 @@ void DRW_shgroup_call_procedural_triangles_add(DRWShadingGroup *shgroup,
   drw_shgroup_call_procedural_add_ex(shgroup, GPU_PRIM_TRIS, tria_count * 3, obmat, NULL);
 }
 
-/* TODO (fclem): this is a sign that the api is starting to be limiting.
- * Maybe add special function that general purpose for special cases. */
-void DRW_shgroup_call_object_procedural_triangles_culled_add(DRWShadingGroup *shgroup,
-                                                             uint tria_count,
-                                                             Object *ob)
-{
-  drw_shgroup_call_procedural_add_ex(shgroup, GPU_PRIM_TRIS, tria_count * 3, NULL, ob);
-}
-
 /* These calls can be culled and are optimized for redraw */
 void DRW_shgroup_call_object_add_ex(
     DRWShadingGroup *shgroup, GPUBatch *geom, Object *ob, Material *ma, bool bypass_culling)
diff --git a/source/blender/draw/intern/draw_manager_exec.c b/source/blender/draw/intern/draw_manager_exec.c
index bfbb7af49dd..46f4d0620c8 100644
--- a/source/blender/draw/intern/draw_manager_exec.c
+++ b/source/blender/draw/intern/draw_manager_exec.c
@@ -680,12 +680,16 @@ bool DRW_culling_sphere_test(BoundSphere *bsphere)
 
   /* Do a rough test first: Sphere VS Sphere intersect. */
   BoundSphere *frustum_bsphere = &DST.clipping.frustum_bsphere;
-  float center_dist = len_squared_v3v3(bsphere->center, frustum_bsphere->center);
-  if (center_dist > SQUARE(bsphere->radius + frustum_bsphere->radius)) {
+  float center_dist_sq = len_squared_v3v3(bsphere->center, frustum_bsphere->center);
+  float radius_sum = bsphere->radius + frustum_bsphere->radius;
+  if (center_dist_sq > SQUARE(radius_sum)) {
     return false;
   }
+  /* TODO we could test against the inscribed sphere of the frustum to early out positively. */
 
   /* Test against the 6 frustum planes. */
+  /* TODO order planes with sides first then far then near clip. Should be better culling heuristic
+   * when sculpting. */
   for (int p = 0; p < 6; p++) {
     float dist = plane_point_side_v3(DST.clipping.frustum_planes[p], bsphere->center);
     if (dist < -bsphere->radius) {
@@ -1319,9 +1323,6 @@ static void draw_shgroup(DRWShadingGroup *shgroup, DRWState pass_state)
           draw_geometry_execute_ex(
               shgroup, call->instances.geometry, 0, *call->instances.count, true);
           break;
-        case DRW_CALL_GENERATE:
-          call->generate.geometry_fn(shgroup, draw_geometry_execute, call->generate.user_data);
-          break;
         case DRW_CALL_PROCEDURAL:
           GPU_draw_primitive(call->procedural.prim_type, call->procedural.vert_count);
           break;
diff --git a/source/blender/draw/modes/sculpt_mode.c b/source/blender/draw/modes/sculpt_mode.c
index fb2619ce768..053e73e4068 100644
--- a/source/blender/draw/modes/sculpt_mode.c
+++ b/source/blender/draw/modes/sculpt_mode.c
@@ -90,19 +90,11 @@ typedef struct SCULPT_Data {
 /* *********** STATIC *********** */
 
 static struct {
-  /* Custom shaders :
-   * Add sources to source/blender/draw/modes/shaders
-   * init in SCULPT_engine_init();
-   * free in SCULPT_engine_free(); */
-  struct GPUShader *shader_smooth;
+  struct GPUShader *shader_mask;
 } e_data = {NULL}; /* Engine data */
 
 typedef struct SCULPT_PrivateData {
   DRWShadingGroup *mask_overlay_grp;
-  /* This keeps the references of the shading groups for
-   * easy access in SCULPT_cache_populate() */
-  DRWShadingGroup *group_flat;
-  DRWShadingGroup *group_smooth;
 } SCULPT_PrivateData; /* Transient data */
 
 /* *********** FUNCTIONS *********** */
@@ -118,8 +110,8 @@ static void SCULPT_engine_init(void *vedata)
 
   UNUSED_VARS(txl, fbl, stl);
 
-  if (!e_data.shader_smooth) {
-    e_data.shader_smooth = DRW_shader_create(
+  if (!e_data.shader_mask) {
+    e_data.shader_mask = DRW_shader_create(
         datatoc_sculpt_mask_vert_glsl, NULL, datatoc_gpu_shader_3D_smooth_color_frag_glsl, NULL);
   }
 }
@@ -142,50 +134,12 @@ static void SCULPT_cache_init(void *vedata)
     DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL | DRW_STATE_MULTIPLY;
     psl->pass = DRW_pass_creat

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list