Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/sculpt_paint/sculpt_multiplane_scrape.c
| Show First 20 Lines • Show All 63 Lines • ▼ Show 20 Lines | SculptBrushTestFn sculpt_brush_test_sq_fn = SCULPT_brush_test_init_with_falloff_shape( | ||||
| ss, &test, brush->falloff_shape); | ss, &test, brush->falloff_shape); | ||||
| const int thread_id = BLI_task_parallel_thread_id(tls); | const int thread_id = BLI_task_parallel_thread_id(tls); | ||||
| /* Apply the brush normal radius to the test before sampling. */ | /* Apply the brush normal radius to the test before sampling. */ | ||||
| float test_radius = sqrtf(test.radius_squared); | float test_radius = sqrtf(test.radius_squared); | ||||
| test_radius *= brush->normal_radius_factor; | test_radius *= brush->normal_radius_factor; | ||||
| test.radius_squared = test_radius * test_radius; | test.radius_squared = test_radius * test_radius; | ||||
| AutomaskingNodeData automask_data; | |||||
| SCULPT_automasking_node_begin( | |||||
| data->ob, ss, ss->cache->automasking, &automask_data, data->nodes[n]); | |||||
| BKE_pbvh_vertex_iter_begin (ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE) { | BKE_pbvh_vertex_iter_begin (ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE) { | ||||
| if (!sculpt_brush_test_sq_fn(&test, vd.co)) { | if (!sculpt_brush_test_sq_fn(&test, vd.co)) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| float local_co[3]; | float local_co[3]; | ||||
| float normal[3]; | float normal[3]; | ||||
| copy_v3_v3(normal, vd.no ? vd.no : vd.fno); | copy_v3_v3(normal, vd.no ? vd.no : vd.fno); | ||||
| mul_v3_m4v3(local_co, mat, vd.co); | mul_v3_m4v3(local_co, mat, vd.co); | ||||
| SCULPT_automasking_node_update(ss, &automask_data, &vd); | |||||
| /* Use the brush falloff to weight the sampled normals. */ | /* Use the brush falloff to weight the sampled normals. */ | ||||
| const float fade = SCULPT_brush_strength_factor(ss, | const float fade = SCULPT_brush_strength_factor(ss, | ||||
| brush, | brush, | ||||
| vd.co, | vd.co, | ||||
| sqrtf(test.dist), | sqrtf(test.dist), | ||||
| vd.no, | vd.no, | ||||
| vd.fno, | vd.fno, | ||||
| vd.mask ? *vd.mask : 0.0f, | vd.mask ? *vd.mask : 0.0f, | ||||
| vd.vertex, | vd.vertex, | ||||
| thread_id); | thread_id, | ||||
| &automask_data); | |||||
| /* Sample the normal and area of the +X and -X axis individually. */ | /* Sample the normal and area of the +X and -X axis individually. */ | ||||
| if (local_co[0] > 0.0f) { | if (local_co[0] > 0.0f) { | ||||
| madd_v3_v3fl(mssd->area_nos[0], normal, fade); | madd_v3_v3fl(mssd->area_nos[0], normal, fade); | ||||
| add_v3_v3(mssd->area_cos[0], vd.co); | add_v3_v3(mssd->area_cos[0], vd.co); | ||||
| mssd->area_count[0]++; | mssd->area_count[0]++; | ||||
| } | } | ||||
| else { | else { | ||||
| Show All 40 Lines | static void do_multiplane_scrape_brush_task_cb_ex(void *__restrict userdata, | ||||
| proxy = BKE_pbvh_node_add_proxy(ss->pbvh, data->nodes[n])->co; | proxy = BKE_pbvh_node_add_proxy(ss->pbvh, data->nodes[n])->co; | ||||
| SculptBrushTest test; | SculptBrushTest test; | ||||
| SculptBrushTestFn sculpt_brush_test_sq_fn = SCULPT_brush_test_init_with_falloff_shape( | SculptBrushTestFn sculpt_brush_test_sq_fn = SCULPT_brush_test_init_with_falloff_shape( | ||||
| ss, &test, data->brush->falloff_shape); | ss, &test, data->brush->falloff_shape); | ||||
| const int thread_id = BLI_task_parallel_thread_id(tls); | const int thread_id = BLI_task_parallel_thread_id(tls); | ||||
| AutomaskingNodeData automask_data; | |||||
| SCULPT_automasking_node_begin( | |||||
| data->ob, ss, ss->cache->automasking, &automask_data, data->nodes[n]); | |||||
| BKE_pbvh_vertex_iter_begin (ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE) { | BKE_pbvh_vertex_iter_begin (ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE) { | ||||
| if (!sculpt_brush_test_sq_fn(&test, vd.co)) { | if (!sculpt_brush_test_sq_fn(&test, vd.co)) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| float local_co[3]; | float local_co[3]; | ||||
| bool deform = false; | bool deform = false; | ||||
| Show All 24 Lines | BKE_pbvh_vertex_iter_begin (ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE) { | ||||
| else { | else { | ||||
| closest_to_plane_normalized_v3(intr, scrape_planes[1], vd.co); | closest_to_plane_normalized_v3(intr, scrape_planes[1], vd.co); | ||||
| } | } | ||||
| sub_v3_v3v3(val, intr, vd.co); | sub_v3_v3v3(val, intr, vd.co); | ||||
| if (!SCULPT_plane_trim(ss->cache, brush, val)) { | if (!SCULPT_plane_trim(ss->cache, brush, val)) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| SCULPT_automasking_node_update(ss, &automask_data, &vd); | |||||
| /* Deform the local space along the Y axis to avoid artifacts on curved strokes. */ | /* Deform the local space along the Y axis to avoid artifacts on curved strokes. */ | ||||
| /* This produces a not round brush tip. */ | /* This produces a not round brush tip. */ | ||||
| local_co[1] *= 2.0f; | local_co[1] *= 2.0f; | ||||
| const float fade = bstrength * SCULPT_brush_strength_factor(ss, | const float fade = bstrength * SCULPT_brush_strength_factor(ss, | ||||
| brush, | brush, | ||||
| vd.co, | vd.co, | ||||
| len_v3(local_co), | len_v3(local_co), | ||||
| vd.no, | vd.no, | ||||
| vd.fno, | vd.fno, | ||||
| vd.mask ? *vd.mask : 0.0f, | vd.mask ? *vd.mask : 0.0f, | ||||
| vd.vertex, | vd.vertex, | ||||
| thread_id); | thread_id, | ||||
| &automask_data); | |||||
| mul_v3_v3fl(proxy[vd.i], val, fade); | mul_v3_v3fl(proxy[vd.i], val, fade); | ||||
| if (vd.mvert) { | if (vd.mvert) { | ||||
| BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.vertex); | BKE_pbvh_vert_tag_update_normal(ss->pbvh, vd.vertex); | ||||
| } | } | ||||
| } | } | ||||
| BKE_pbvh_vertex_iter_end; | BKE_pbvh_vertex_iter_end; | ||||
| ▲ Show 20 Lines • Show All 244 Lines • Show Last 20 Lines | |||||