[Bf-blender-cvs] [d8509b349d1] master: Sculpt Mode: 2D falloff option

Campbell Barton noreply at git.blender.org
Thu Oct 5 16:22:54 CEST 2017


Commit: d8509b349d1d6219923615e7af81267bb6f06b68
Author: Campbell Barton
Date:   Fri Oct 6 00:18:11 2017 +1100
Branches: master
https://developer.blender.org/rBd8509b349d1d6219923615e7af81267bb6f06b68

Sculpt Mode: 2D falloff option

This makes brush influence into a tube instead of a sphere.
It can be used along the outline of a mesh to adjust it's silhouette.

Note that all this takes advantage of changes from vertex paint,
from testing this seems useful so exposing from the brush options.

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

M	release/scripts/startup/bl_ui/space_view3d_toolbar.py
M	source/blender/blenkernel/BKE_pbvh.h
M	source/blender/blenkernel/intern/pbvh_bmesh.c
M	source/blender/blenloader/intern/versioning_270.c
M	source/blender/editors/sculpt_paint/paint_vertex.c
M	source/blender/editors/sculpt_paint/sculpt.c
M	source/blender/editors/sculpt_paint/sculpt_intern.h
M	source/blender/makesdna/DNA_brush_types.h
M	source/blender/makesdna/DNA_scene_types.h
M	source/blender/makesrna/intern/rna_brush.c
M	source/blender/makesrna/intern/rna_sculpt_paint.c

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

diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
index 5aca4c554d8..d795e09e435 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -1083,6 +1083,8 @@ class VIEW3D_PT_tools_brush(Panel, View3DPaintPanel):
             row = col.row()
             row.prop(brush, "use_frontface", text="Front Faces Only")
 
+            col.row().prop(brush, "use_projected", expand=True)
+
             # direction
             col.separator()
             col.row().prop(brush, "direction", expand=True)
@@ -1137,6 +1139,8 @@ class VIEW3D_PT_tools_brush(Panel, View3DPaintPanel):
                 col.prop(brush, "use_accumulate")
                 col.separator()
 
+            col.row().prop(brush, "use_projected")
+
             col = layout.column()
             col.prop(toolsettings, "use_auto_normalize", text="Auto Normalize")
             col.prop(toolsettings, "use_multipaint", text="Multi-Paint")
@@ -1168,9 +1172,12 @@ class VIEW3D_PT_tools_brush(Panel, View3DPaintPanel):
             # row.prop(brush, "use_pressure_jitter", toggle=True, text="")
             col.separator()
             col.prop(brush, "vertex_tool", text="Blend")
+
             col.prop(brush, "use_accumulate")
             col.prop(brush, "use_alpha")
 
+            col.row().prop("use_projected")
+
             col.separator()
             col.template_ID(settings, "palette", new="palette.new")
 
@@ -1763,8 +1770,6 @@ class VIEW3D_PT_tools_weightpaint_options(Panel, View3DPaintPanel):
         col = layout.column()
         col.label("Falloff:")
         row = col.row()
-        row.prop(wpaint, "falloff_shape", expand=True)
-        row = col.row()
         row.prop(wpaint, "use_backface_culling")
         row = col.row()
         row.prop(wpaint, "use_normal_falloff")
@@ -1806,8 +1811,6 @@ class VIEW3D_PT_tools_vertexpaint(Panel, View3DPaintPanel):
         col = layout.column()
         col.label("Falloff:")
         row = col.row()
-        row.prop(vpaint, "falloff_shape", expand=True)
-        row = col.row()
         row.prop(vpaint, "use_backface_culling")
         row = col.row()
         row.prop(vpaint, "use_normal_falloff")
diff --git a/source/blender/blenkernel/BKE_pbvh.h b/source/blender/blenkernel/BKE_pbvh.h
index c6b9b6a4de6..2daa2ef7182 100644
--- a/source/blender/blenkernel/BKE_pbvh.h
+++ b/source/blender/blenkernel/BKE_pbvh.h
@@ -168,7 +168,7 @@ typedef enum {
 bool BKE_pbvh_bmesh_update_topology(
         PBVH *bvh, PBVHTopologyUpdateMode mode,
         const float center[3], const float view_normal[3],
-        float radius);
+        float radius, const bool use_frontface, const bool use_projected);
 
 /* Node Access */
 
diff --git a/source/blender/blenkernel/intern/pbvh_bmesh.c b/source/blender/blenkernel/intern/pbvh_bmesh.c
index 4bfda8ebf28..187891e7210 100644
--- a/source/blender/blenkernel/intern/pbvh_bmesh.c
+++ b/source/blender/blenkernel/intern/pbvh_bmesh.c
@@ -718,20 +718,24 @@ static void pbvh_bmesh_node_drop_orig(PBVHNode *node)
 
 /****************************** EdgeQueue *****************************/
 
-typedef struct {
+struct EdgeQueue;
+
+typedef struct EdgeQueue {
 	Heap *heap;
 	const float *center;
+	float  center_proj[3];  /* for when we use projected coords. */
 	float radius_squared;
 	float limit_len_squared;
 #ifdef USE_EDGEQUEUE_EVEN_SUBDIV
 	float limit_len;
 #endif
 
-#ifdef USE_EDGEQUEUE_FRONTFACE
+	bool (*edge_queue_tri_in_range)(const struct EdgeQueue *q, BMFace *f);
+
 	const float *view_normal;
+#ifdef USE_EDGEQUEUE_FRONTFACE
 	unsigned int use_view_normal : 1;
 #endif
-
 } EdgeQueue;
 
 typedef struct {
@@ -785,7 +789,6 @@ static bool edge_queue_tri_in_sphere(const EdgeQueue *q, BMFace *f)
 	float c[3];
 
 	/* Get closest point in triangle to sphere center */
-	// BM_iter_as_array(NULL, BM_VERTS_OF_FACE, f, (void **)v_tri, 3);
 	BM_face_as_array_vert_tri(f, v_tri);
 
 	closest_on_tri_to_point_v3(c, q->center, v_tri[0]->co, v_tri[1]->co, v_tri[2]->co);
@@ -794,6 +797,25 @@ static bool edge_queue_tri_in_sphere(const EdgeQueue *q, BMFace *f)
 	return len_squared_v3v3(q->center, c) <= q->radius_squared;
 }
 
+static bool edge_queue_tri_in_circle(const EdgeQueue *q, BMFace *f)
+{
+	BMVert *v_tri[3];
+	float c[3];
+	float tri_proj[3][3];
+
+	/* Get closest point in triangle to sphere center */
+	BM_face_as_array_vert_tri(f, v_tri);
+
+	project_plane_normalized_v3_v3v3(tri_proj[0], v_tri[0]->co, q->view_normal);
+	project_plane_normalized_v3_v3v3(tri_proj[1], v_tri[1]->co, q->view_normal);
+	project_plane_normalized_v3_v3v3(tri_proj[2], v_tri[2]->co, q->view_normal);
+
+	closest_on_tri_to_point_v3(c, q->center_proj, tri_proj[0], tri_proj[1], tri_proj[2]);
+
+	/* Check if triangle intersects the sphere */
+	return len_squared_v3v3(q->center_proj, c) <= q->radius_squared;
+}
+
 /* Return true if the vertex mask is less than 1.0, false otherwise */
 static bool check_mask(EdgeQueueContext *eq_ctx, BMVert *v)
 {
@@ -929,7 +951,7 @@ static void long_edge_queue_face_add(
 	}
 #endif
 
-	if (edge_queue_tri_in_sphere(eq_ctx->q, f)) {
+	if (eq_ctx->q->edge_queue_tri_in_range(eq_ctx->q, f)) {
 		/* Check each edge of the face */
 		BMLoop *l_first = BM_FACE_FIRST_LOOP(f);
 		BMLoop *l_iter = l_first;
@@ -960,7 +982,7 @@ static void short_edge_queue_face_add(
 	}
 #endif
 
-	if (edge_queue_tri_in_sphere(eq_ctx->q, f)) {
+	if (eq_ctx->q->edge_queue_tri_in_range(eq_ctx->q, f)) {
 		BMLoop *l_iter;
 		BMLoop *l_first;
 
@@ -984,7 +1006,7 @@ static void short_edge_queue_face_add(
 static void long_edge_queue_create(
         EdgeQueueContext *eq_ctx,
         PBVH *bvh, const float center[3], const float view_normal[3],
-        float radius)
+        float radius, const bool use_frontface, const bool use_projected)
 {
 	eq_ctx->q->heap = BLI_heap_new();
 	eq_ctx->q->center = center;
@@ -994,13 +1016,22 @@ static void long_edge_queue_create(
 	eq_ctx->q->limit_len = bvh->bm_max_edge_len;
 #endif
 
-#ifdef USE_EDGEQUEUE_FRONTFACE
 	eq_ctx->q->view_normal = view_normal;
-	eq_ctx->q->use_view_normal = (view_normal != NULL);
+
+#ifdef USE_EDGEQUEUE_FRONTFACE
+	eq_ctx->q->use_view_normal = use_frontface;
 #else
-	UNUSED_VARS(view_normal);
+	UNUSED_VARS(use_frontface);
 #endif
 
+	if (use_projected) {
+		eq_ctx->q->edge_queue_tri_in_range = edge_queue_tri_in_circle;
+		project_plane_normalized_v3_v3v3(eq_ctx->q->center_proj, center, view_normal);
+	}
+	else {
+		eq_ctx->q->edge_queue_tri_in_range = edge_queue_tri_in_sphere;
+	}
+
 #ifdef USE_EDGEQUEUE_TAG_VERIFY
 	pbvh_bmesh_edge_tag_verify(bvh);
 #endif
@@ -1037,7 +1068,7 @@ static void long_edge_queue_create(
 static void short_edge_queue_create(
         EdgeQueueContext *eq_ctx,
         PBVH *bvh, const float center[3], const float view_normal[3],
-        float radius)
+        float radius, const bool use_frontface, const bool use_projected)
 {
 	eq_ctx->q->heap = BLI_heap_new();
 	eq_ctx->q->center = center;
@@ -1047,13 +1078,22 @@ static void short_edge_queue_create(
 	eq_ctx->q->limit_len = bvh->bm_min_edge_len;
 #endif
 
-#ifdef USE_EDGEQUEUE_FRONTFACE
 	eq_ctx->q->view_normal = view_normal;
-	eq_ctx->q->use_view_normal = (view_normal != NULL);
+
+#ifdef USE_EDGEQUEUE_FRONTFACE
+	eq_ctx->q->use_view_normal = use_frontface;
 #else
-	UNUSED_VARS(view_normal);
+	UNUSED_VARS(use_frontface);
 #endif
 
+	if (use_projected) {
+		eq_ctx->q->edge_queue_tri_in_range = edge_queue_tri_in_circle;
+		project_plane_normalized_v3_v3v3(eq_ctx->q->center_proj, center, view_normal);
+	}
+	else {
+		eq_ctx->q->edge_queue_tri_in_range = edge_queue_tri_in_sphere;
+	}
+
 	for (int n = 0; n < bvh->totnode; n++) {
 		PBVHNode *node = &bvh->nodes[n];
 
@@ -1895,7 +1935,7 @@ void BKE_pbvh_build_bmesh(
 bool BKE_pbvh_bmesh_update_topology(
         PBVH *bvh, PBVHTopologyUpdateMode mode,
         const float center[3], const float view_normal[3],
-        float radius)
+        float radius, const bool use_frontface, const bool use_projected)
 {
 	/* 2 is enough for edge faces - manifold edge */
 	BLI_buffer_declare_static(BMLoop *, edge_loops, BLI_BUFFER_NOP, 2);
@@ -1918,7 +1958,7 @@ bool BKE_pbvh_bmesh_update_topology(
 		    cd_vert_mask_offset, cd_vert_node_offset, cd_face_node_offset,
 		};
 
-		short_edge_queue_create(&eq_ctx, bvh, center, view_normal, radius);
+		short_edge_queue_create(&eq_ctx, bvh, center, view_normal, radius, use_frontface, use_projected);
 		modified |= pbvh_bmesh_collapse_short_edges(
 		        &eq_ctx, bvh, &deleted_faces);
 		BLI_heap_free(q.heap, NULL);
@@ -1933,7 +1973,7 @@ bool BKE_pbvh_bmesh_update_topology(
 		    cd_vert_mask_offset, cd_vert_node_offset, cd_face_node_offset,
 		};
 
-		long_edge_queue_create(&eq_ctx, bvh, center, view_normal, radius);
+		long_edge_queue_create(&eq_ctx, bvh, center, view_normal, radius, use_frontface, use_projected);
 		modified |= pbvh_bmesh_subdivide_long_edges(
 		        &eq_ctx, bvh, &edge_loops);
 		BLI_heap_free(q.heap, NULL);
diff --git a/source/blender/blenloader/intern/versioning_270.c b/source/blender/blenloader/intern/versioning_270.c
index e1a4137d069..08e8d904b88 100644
--- a/source/blender/blenloader/intern/versioning_270.c
+++ b/source/blender/blenloader/intern/versioning_270.c
@@ -1683,7 +1683,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
 			}
 		}
 
-		if (!DNA_struct_elem_find(fd->filesdna, "VPaint", "char", "falloff_shape")) {
+		if (!DNA_struct_elem_find(fd->filesdna, "VPaint", "char", "normal_angle")) {
 			for (Scene *scene = main->scene.first; scene; scene = scene->id.next) {
 				ToolSettings *ts = scene->toolsettings;
 				for (int i = 0; i < 2; i++) {
diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c
index a6b41b51ca6..7c54277639a 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex.c
@@ -1500,22 +1500,6 @@ static float wpaint_get_active_weight(const MDeformVert *dv, const WeightPaintIn
 	}
 }
 
-static SculptBrushTestFn sculpt_brush_test_init_with_falloff_shape(
-        SculptSession *ss, SculptBrushTest *test, char

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list