[Bf-blender-cvs] [bcf390a6c3a] blender2.8: Mesh Batch Cache: Port weight paint surface to batch request

Clément Foucault noreply at git.blender.org
Tue Dec 18 02:20:02 CET 2018


Commit: bcf390a6c3a58e596faa24258cc20f1e7daeb8c2
Author: Clément Foucault
Date:   Mon Dec 17 23:00:05 2018 +0100
Branches: blender2.8
https://developer.blender.org/rBbcf390a6c3a58e596faa24258cc20f1e7daeb8c2

Mesh Batch Cache: Port weight paint surface to batch request

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

M	source/blender/draw/intern/draw_cache.c
M	source/blender/draw/intern/draw_cache.h
M	source/blender/draw/intern/draw_cache_impl.h
M	source/blender/draw/intern/draw_cache_impl_mesh.c
M	source/blender/draw/modes/edit_mesh_mode.c
M	source/blender/draw/modes/paint_weight_mode.c

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

diff --git a/source/blender/draw/intern/draw_cache.c b/source/blender/draw/intern/draw_cache.c
index c30362a044e..dc18ddb3351 100644
--- a/source/blender/draw/intern/draw_cache.c
+++ b/source/blender/draw/intern/draw_cache.c
@@ -3040,47 +3040,12 @@ GPUBatch *DRW_cache_mesh_loose_edges_get(Object *ob)
 	return DRW_mesh_batch_cache_get_loose_edges_with_normals(me);
 }
 
-GPUBatch *DRW_cache_mesh_surface_weights_get(Object *ob, ToolSettings *ts, bool paint_mode)
+GPUBatch *DRW_cache_mesh_surface_weights_get(Object *ob)
 {
 	BLI_assert(ob->type == OB_MESH);
 
 	Mesh *me = ob->data;
-
-	/* Extract complete vertex weight group selection state and mode flags. */
-	struct DRW_MeshWeightState wstate;
-	memset(&wstate, 0, sizeof(wstate));
-
-	wstate.defgroup_active = ob->actdef - 1;
-	wstate.defgroup_len = BLI_listbase_count(&ob->defbase);
-
-	wstate.alert_mode = ts->weightuser;
-
-	if (paint_mode && ts->multipaint) {
-		/* Multipaint needs to know all selected bones, not just the active group.
-		 * This is actually a relatively expensive operation, but caching would be difficult. */
-		wstate.defgroup_sel = BKE_object_defgroup_selected_get(ob, wstate.defgroup_len, &wstate.defgroup_sel_count);
-
-		if (wstate.defgroup_sel_count > 1) {
-			wstate.flags |= DRW_MESH_WEIGHT_STATE_MULTIPAINT | (ts->auto_normalize ? DRW_MESH_WEIGHT_STATE_AUTO_NORMALIZE : 0);
-
-			if (me->editflag & ME_EDIT_MIRROR_X) {
-				BKE_object_defgroup_mirror_selection(
-				        ob, wstate.defgroup_len, wstate.defgroup_sel, wstate.defgroup_sel, &wstate.defgroup_sel_count);
-			}
-		}
-		/* With only one selected bone Multipaint reverts to regular mode. */
-		else {
-			wstate.defgroup_sel_count = 0;
-			MEM_SAFE_FREE(wstate.defgroup_sel);
-		}
-	}
-
-	/* Generate the weight data using the selection. */
-	GPUBatch *batch = DRW_mesh_batch_cache_get_triangles_with_normals_and_weights(me, &wstate);
-
-	DRW_mesh_weight_state_clear(&wstate);
-
-	return batch;
+	return DRW_mesh_batch_cache_get_triangles_with_normals_and_weights(me);
 }
 
 GPUBatch *DRW_cache_mesh_surface_vert_colors_get(Object *ob)
@@ -3144,22 +3109,6 @@ GPUBatch *DRW_cache_mesh_verts_get(Object *ob)
 	return DRW_mesh_batch_cache_get_all_verts(me);
 }
 
-GPUBatch *DRW_cache_mesh_faces_weight_overlay_get(Object *ob)
-{
-	BLI_assert(ob->type == OB_MESH);
-
-	Mesh *me = ob->data;
-	return DRW_mesh_batch_cache_get_weight_overlay_faces(me);
-}
-
-GPUBatch *DRW_cache_mesh_verts_weight_overlay_get(Object *ob)
-{
-	BLI_assert(ob->type == OB_MESH);
-
-	Mesh *me = ob->data;
-	return DRW_mesh_batch_cache_get_weight_overlay_verts(me);
-}
-
 void DRW_cache_mesh_sculpt_coords_ensure(Object *ob)
 {
 	BLI_assert(ob->type == OB_MESH);
diff --git a/source/blender/draw/intern/draw_cache.h b/source/blender/draw/intern/draw_cache.h
index a4beb84f1f1..6387d9efaa2 100644
--- a/source/blender/draw/intern/draw_cache.h
+++ b/source/blender/draw/intern/draw_cache.h
@@ -129,14 +129,12 @@ struct GPUBatch *DRW_cache_mesh_edge_detection_get(struct Object *ob, bool *r_is
 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 ToolSettings *ts, bool paint_mode);
+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_faces_weight_overlay_get(struct Object *ob);
-struct GPUBatch *DRW_cache_mesh_verts_weight_overlay_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);
diff --git a/source/blender/draw/intern/draw_cache_impl.h b/source/blender/draw/intern/draw_cache_impl.h
index b5aa31f95a6..872f519e5fd 100644
--- a/source/blender/draw/intern/draw_cache_impl.h
+++ b/source/blender/draw/intern/draw_cache_impl.h
@@ -95,29 +95,6 @@ struct GPUBatch *DRW_lattice_batch_cache_get_all_edges(struct Lattice *lt, bool
 struct GPUBatch *DRW_lattice_batch_cache_get_all_verts(struct Lattice *lt);
 struct GPUBatch *DRW_lattice_batch_cache_get_edit_verts(struct Lattice *lt);
 
-/* Vertex Group Selection and display options */
-struct DRW_MeshWeightState {
-	int defgroup_active;
-	int defgroup_len;
-
-	short flags;
-	char alert_mode;
-
-	/* Set of all selected bones for Multipaint. */
-	bool *defgroup_sel; /* [defgroup_len] */
-	int   defgroup_sel_count;
-};
-
-/* DRW_MeshWeightState.flags */
-enum {
-	DRW_MESH_WEIGHT_STATE_MULTIPAINT          = (1 << 0),
-	DRW_MESH_WEIGHT_STATE_AUTO_NORMALIZE      = (1 << 1),
-};
-
-void DRW_mesh_weight_state_clear(struct DRW_MeshWeightState *wstate);
-void DRW_mesh_weight_state_copy(struct DRW_MeshWeightState *wstate_dst, const struct DRW_MeshWeightState *wstate_src);
-bool DRW_mesh_weight_state_compare(const struct DRW_MeshWeightState *a, const struct DRW_MeshWeightState *b);
-
 /* Mesh */
 void DRW_mesh_batch_cache_create_requested(struct Object *ob, struct Mesh *me);
 
@@ -127,11 +104,9 @@ struct GPUBatch **DRW_mesh_batch_cache_get_surface_shaded(
 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_wire_loops(struct Mesh *me);
-struct GPUBatch *DRW_mesh_batch_cache_get_weight_overlay_faces(struct Mesh *me);
-struct GPUBatch *DRW_mesh_batch_cache_get_weight_overlay_verts(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, const struct DRW_MeshWeightState *wstate);
+struct GPUBatch *DRW_mesh_batch_cache_get_triangles_with_normals_and_weights(struct Mesh *me);
 struct GPUBatch *DRW_mesh_batch_cache_get_triangles_with_normals_and_vert_colors(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);
diff --git a/source/blender/draw/intern/draw_cache_impl_mesh.c b/source/blender/draw/intern/draw_cache_impl_mesh.c
index 1d3b04b510c..b144ae2dedb 100644
--- a/source/blender/draw/intern/draw_cache_impl_mesh.c
+++ b/source/blender/draw/intern/draw_cache_impl_mesh.c
@@ -44,6 +44,7 @@
 #include "DNA_meshdata_types.h"
 #include "DNA_object_types.h"
 #include "DNA_space_types.h"
+#include "DNA_scene_types.h"
 
 #include "BKE_customdata.h"
 #include "BKE_deform.h"
@@ -54,6 +55,7 @@
 #include "BKE_mesh_tangent.h"
 #include "BKE_mesh_runtime.h"
 #include "BKE_object.h"
+#include "BKE_object_deform.h"
 #include "BKE_colorband.h"
 #include "BKE_cdderivedmesh.h"
 
@@ -77,6 +79,24 @@
 
 static void mesh_batch_cache_clear(Mesh *me);
 
+/* Vertex Group Selection and display options */
+typedef struct DRW_MeshWeightState {
+	int defgroup_active;
+	int defgroup_len;
+
+	short flags;
+	char alert_mode;
+
+	/* Set of all selected bones for Multipaint. */
+	bool *defgroup_sel; /* [defgroup_len] */
+	int   defgroup_sel_count;
+} DRW_MeshWeightState;
+
+/* DRW_MeshWeightState.flags */
+enum {
+	DRW_MESH_WEIGHT_STATE_MULTIPAINT          = (1 << 0),
+	DRW_MESH_WEIGHT_STATE_AUTO_NORMALIZE      = (1 << 1),
+};
 
 /* ---------------------------------------------------------------------- */
 
@@ -1346,7 +1366,7 @@ fallback:
 	}
 }
 
-static float evaluate_vertex_weight(const MDeformVert *dvert, const struct DRW_MeshWeightState *wstate)
+static float evaluate_vertex_weight(const MDeformVert *dvert, const DRW_MeshWeightState *wstate)
 {
 	float input = 0.0f;
 	bool show_alert_color = false;
@@ -1987,7 +2007,7 @@ static bool add_edit_facedot_mapped(
  * \{ */
 
 /** Reset the selection structure, deallocating heap memory as appropriate. */
-void DRW_mesh_weight_state_clear(struct DRW_MeshWeightState *wstate)
+static void drw_mesh_weight_state_clear(struct DRW_MeshWeightState *wstate)
 {
 	MEM_SAFE_FREE(wstate->defgroup_sel);
 
@@ -1997,7 +2017,8 @@ void DRW_mesh_weight_state_clear(struct DRW_MeshWeightState *wstate)
 }
 
 /** Copy selection data from one structure to another, including heap memory. */
-void DRW_mesh_weight_state_copy(struct DRW_MeshWeightState *wstate_dst, const struct DRW_MeshWeightState *wstate_src)
+static void drw_mesh_weight_state_copy(
+        struct DRW_MeshWeightState *wstate_dst, const struct DRW_MeshWeightState *wstate_src)
 {
 	MEM_SAFE_FREE(wstate_dst->defgroup_sel);
 
@@ -2009,7 +2030,7 @@ void DRW_mesh_weight_state_copy(struct DRW_MeshWeightState *wstate_dst, const st
 }
 
 /** Compare two selection structures. */
-bool DRW_mesh_weight_state_compare(const struct DRW_MeshWeightState *a, const struct DRW_MeshWeightState *b)
+static bool drw_mesh_weight_state_compare(const struct DRW_MeshWeightState *a, const struct DRW_MeshWeightState *b)
 {
 	return a->defgroup_active == b->defgroup_active &&
 	       a->defgroup_len == b->defgroup_len &&
@@ -2021,6 +2042,39 @@ bool DRW_mesh_weight_state_compare(const struct DRW_MeshWeightState *a, const st
 	         memcmp(a->defgroup_sel, b->defgroup_sel, a->defgroup_len * sizeof(bool)) == 0));
 }
 
+static void drw_mesh_weight_state_extract(
+        Object *ob, Mesh *me, ToolSettings *ts, bool paint_mode,
+        struct DRW_MeshWeightState *wstate)
+{
+	/* Extract complete vertex weight group selection state and mode flags. */
+	memset(wstate, 0, sizeof(*wstate));
+
+	wstate->defgroup_active = ob->actdef - 1;
+	wstate->defgroup_len = BLI_listbase_count(&ob->defbase);
+
+	wstate->alert_mode = ts->weightuser;
+
+	if (paint_mode && t

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list