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.
This commit is contained in:
Sergey Sharybin
2017-09-14 18:55:08 +05:00
parent fc7ac0bc49
commit a22590a62c

View File

@@ -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]);