[Bf-blender-cvs] [a22590a62ce] master: Fix T52537: Dyntopo "detail flood fill" doesn't work in some cases

Sergey Sharybin noreply at git.blender.org
Thu Sep 14 15:56:20 CEST 2017


Commit: a22590a62ce513752d1ca08b532ad66e36d35898
Author: Sergey Sharybin
Date:   Thu Sep 14 18:55:08 2017 +0500
Branches: master
https://developer.blender.org/rBa22590a62ce513752d1ca08b532ad66e36d35898

Fix T52537: Dyntopo "detail flood fill" doesn't work in some cases

Mainly when object origin is not at the geometry bounding box center.

Seems to be straightforward to fix, hopefully it doesn't break some obscure case
where this was a desired behavior.

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

M	source/blender/editors/sculpt_paint/sculpt.c

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

diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index f0c1203004e..c415e6b007e 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -5530,7 +5530,7 @@ static int sculpt_detail_flood_fill_exec(bContext *C, wmOperator *UNUSED(op))
 	Object *ob = CTX_data_active_object(C);
 	SculptSession *ss = ob->sculpt;
 	float size;
-	float bb_min[3], bb_max[3];
+	float bb_min[3], bb_max[3], center[3], dim[3];
 	int i, totnodes;
 	PBVHNode **nodes;
 
@@ -5542,11 +5542,12 @@ static int sculpt_detail_flood_fill_exec(bContext *C, wmOperator *UNUSED(op))
 	for (i = 0; i < totnodes; i++) {
 		BKE_pbvh_node_mark_topology_update(nodes[i]);
 	}
-	/* get the bounding box, store the size to bb_max and center (zero) to bb_min */
+	/* get the bounding box, it's center and size */
 	BKE_pbvh_bounding_box(ob->sculpt->pbvh, bb_min, bb_max);
-	sub_v3_v3(bb_max, bb_min);
-	zero_v3(bb_min);
-	size = max_fff(bb_max[0], bb_max[1], bb_max[2]);
+	add_v3_v3v3(center, bb_min, bb_max);
+	mul_v3_fl(center, 0.5f);
+	sub_v3_v3v3(dim, bb_max, bb_min);
+	size = max_fff(dim[0], dim[1], dim[2]);
 
 	/* update topology size */
 	BKE_pbvh_bmesh_detail_size_set(ss->pbvh, 1.0f / sd->constant_detail);
@@ -5556,7 +5557,7 @@ static int sculpt_detail_flood_fill_exec(bContext *C, wmOperator *UNUSED(op))
 
 	while (BKE_pbvh_bmesh_update_topology(
 	               ss->pbvh, PBVH_Collapse | PBVH_Subdivide,
-	               bb_min, NULL, size))
+	               center, NULL, size))
 	{
 		for (i = 0; i < totnodes; i++)
 			BKE_pbvh_node_mark_topology_update(nodes[i]);



More information about the Bf-blender-cvs mailing list