From e5048dd4ca8b8b40dacda52b87fce642fa51e922 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 19 Apr 2015 19:51:02 +1000 Subject: Dyntopo: non-topology tool origdata support Brushes that don't change topology didn't have access to original data. --- source/blender/editors/sculpt_paint/sculpt.c | 52 +++++++++++++++++++--------- 1 file changed, 35 insertions(+), 17 deletions(-) (limited to '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 7ab80e8d791..0af93e625ac 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -389,10 +389,6 @@ static void paint_mesh_restore_co(Sculpt *sd, Object *ob) PBVHNode **nodes; int n, totnode; -#ifndef _OPENMP - (void)sd; /* quied unused warning */ -#endif - BKE_pbvh_search_gather(ss->pbvh, NULL, NULL, &nodes, &totnode); /* Disable OpenMP when dynamic-topology is enabled. Otherwise, new @@ -747,7 +743,9 @@ static void calc_area_center( PBVHNode **nodes, int totnode, float r_area_co[3]) { + const Brush *brush = BKE_paint_brush(&sd->paint); SculptSession *ss = ob->sculpt; + const bool has_bm_orco = ss->bm && sculpt_stroke_dynamic_topology(ss, brush); int n; /* 0=towards view, 1=flipped */ @@ -755,8 +753,6 @@ static void calc_area_center( int count[2] = {0}; - (void)sd; /* unused w/o openmp */ - #pragma omp parallel for schedule(guided) if ((sd->flags & SCULPT_USE_OPENMP) && totnode > SCULPT_OMP_LIMIT) for (n = 0; n < totnode; n++) { PBVHVertexIter vd; @@ -773,7 +769,7 @@ static void calc_area_center( /* when the mesh is edited we can't rely on original coords * (original mesh may not even have verts in brush radius) */ - if (use_original && unode->bm_entry) { + if (use_original && has_bm_orco) { float (*orco_coords)[3]; int (*orco_tris)[3]; int orco_tris_num; @@ -809,9 +805,16 @@ static void calc_area_center( BKE_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { const float *co; + const short *no_s; /* bm_vert only */ if (use_original) { - co = unode->co[vd.i]; + if (unode->bm_entry) { + BM_log_original_vert_data(ss->bm_log, vd.bm_vert, &co, &no_s); + } + else { + co = unode->co[vd.i]; + no_s = unode->no[vd.i]; + } } else { co = vd.co; @@ -823,7 +826,7 @@ static void calc_area_center( int flip_index; if (use_original) { - normal_short_to_float_v3(no_buf, unode->no[vd.i]); + normal_short_to_float_v3(no_buf, no_s); no = no_buf; } else { @@ -876,6 +879,7 @@ static void calc_area_normal( { const Brush *brush = BKE_paint_brush(&sd->paint); SculptSession *ss = ob->sculpt; + const bool has_bm_orco = ss->bm && sculpt_stroke_dynamic_topology(ss, brush); int n; /* 0=towards view, 1=flipped */ @@ -915,7 +919,7 @@ static void calc_area_normal( /* when the mesh is edited we can't rely on original coords * (original mesh may not even have verts in brush radius) */ - if (use_original && unode->bm_entry) { + if (use_original && has_bm_orco) { float (*orco_coords)[3]; int (*orco_tris)[3]; int orco_tris_num; @@ -951,9 +955,16 @@ static void calc_area_normal( BKE_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { const float *co; + const short *no_s; /* bm_vert only */ if (use_original) { - co = unode->co[vd.i]; + if (unode->bm_entry) { + BM_log_original_vert_data(ss->bm_log, vd.bm_vert, &co, &no_s); + } + else { + co = unode->co[vd.i]; + no_s = unode->no[vd.i]; + } } else { co = vd.co; @@ -965,7 +976,7 @@ static void calc_area_normal( int flip_index; if (use_original) { - normal_short_to_float_v3(no_buf, unode->no[vd.i]); + normal_short_to_float_v3(no_buf, no_s); no = no_buf; } else { @@ -1013,7 +1024,9 @@ static void calc_area_normal_and_center( PBVHNode **nodes, int totnode, float r_area_no[3], float r_area_co[3]) { + const Brush *brush = BKE_paint_brush(&sd->paint); SculptSession *ss = ob->sculpt; + const bool has_bm_orco = ss->bm && sculpt_stroke_dynamic_topology(ss, brush); int n; /* 0=towards view, 1=flipped */ @@ -1022,8 +1035,6 @@ static void calc_area_normal_and_center( int count[2] = {0}; - (void)sd; /* unused w/o openmp */ - #pragma omp parallel for schedule(guided) if ((sd->flags & SCULPT_USE_OPENMP) && totnode > SCULPT_OMP_LIMIT) for (n = 0; n < totnode; n++) { PBVHVertexIter vd; @@ -1041,7 +1052,7 @@ static void calc_area_normal_and_center( /* when the mesh is edited we can't rely on original coords * (original mesh may not even have verts in brush radius) */ - if (use_original && unode->bm_entry) { + if (use_original && has_bm_orco) { float (*orco_coords)[3]; int (*orco_tris)[3]; int orco_tris_num; @@ -1078,9 +1089,16 @@ static void calc_area_normal_and_center( BKE_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { const float *co; + const short *no_s; /* bm_vert only */ if (use_original) { - co = unode->co[vd.i]; + if (unode->bm_entry) { + BM_log_original_vert_data(ss->bm_log, vd.bm_vert, &co, &no_s); + } + else { + co = unode->co[vd.i]; + no_s = unode->no[vd.i]; + } } else { co = vd.co; @@ -1092,7 +1110,7 @@ static void calc_area_normal_and_center( int flip_index; if (use_original) { - normal_short_to_float_v3(no_buf, unode->no[vd.i]); + normal_short_to_float_v3(no_buf, no_s); no = no_buf; } else { -- cgit v1.2.3