Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/sculpt_paint/sculpt_brush_types.c
| Show First 20 Lines • Show All 296 Lines • ▼ Show 20 Lines | static void do_draw_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; | ||||
| } | } | ||||
| SCULPT_automasking_node_update(ss, &automask_data, &vd); | |||||
| /* Offset vertex. */ | /* Offset vertex. */ | ||||
| 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); | |||||
| mul_v3_v3fl(proxy[vd.i], offset, fade); | mul_v3_v3fl(proxy[vd.i], offset, 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 55 Lines • ▼ Show 20 Lines | static void do_fill_brush_task_cb_ex(void *__restrict userdata, | ||||
| 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); | ||||
| plane_from_point_normal_v3(test.plane_tool, area_co, area_no); | plane_from_point_normal_v3(test.plane_tool, area_co, area_no); | ||||
| 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; | ||||
| } | } | ||||
| if (!SCULPT_plane_point_side(vd.co, test.plane_tool)) { | if (!SCULPT_plane_point_side(vd.co, test.plane_tool)) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| float intr[3]; | float intr[3]; | ||||
| float val[3]; | float val[3]; | ||||
| closest_to_plane_normalized_v3(intr, test.plane_tool, vd.co); | closest_to_plane_normalized_v3(intr, test.plane_tool, 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); | |||||
| const float fade = bstrength * SCULPT_brush_strength_factor(ss, | const float fade = bstrength * 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); | |||||
| 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 55 Lines • ▼ Show 20 Lines | static void do_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); | ||||
| plane_from_point_normal_v3(test.plane_tool, area_co, area_no); | plane_from_point_normal_v3(test.plane_tool, area_co, area_no); | ||||
| 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; | ||||
| } | } | ||||
| if (SCULPT_plane_point_side(vd.co, test.plane_tool)) { | if (SCULPT_plane_point_side(vd.co, test.plane_tool)) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| float intr[3]; | float intr[3]; | ||||
| float val[3]; | float val[3]; | ||||
| closest_to_plane_normalized_v3(intr, test.plane_tool, vd.co); | closest_to_plane_normalized_v3(intr, test.plane_tool, 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); | |||||
| const float fade = bstrength * SCULPT_brush_strength_factor(ss, | const float fade = bstrength * 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); | |||||
| 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 73 Lines • ▼ Show 20 Lines | static void do_clay_thumb_brush_task_cb_ex(void *__restrict userdata, | ||||
| invert_m4_m4(imat, mat); | invert_m4_m4(imat, mat); | ||||
| rotate_v3_v3v3fl(normal_tilt, area_no_sp, imat[0], DEG2RADF(-ss->cache->clay_thumb_front_angle)); | rotate_v3_v3v3fl(normal_tilt, area_no_sp, imat[0], DEG2RADF(-ss->cache->clay_thumb_front_angle)); | ||||
| /* Plane aligned to the geometry normal (back part of the brush). */ | /* Plane aligned to the geometry normal (back part of the brush). */ | ||||
| plane_from_point_normal_v3(test.plane_tool, area_co, area_no_sp); | plane_from_point_normal_v3(test.plane_tool, area_co, area_no_sp); | ||||
| /* Tilted plane (front part of the brush). */ | /* Tilted plane (front part of the brush). */ | ||||
| plane_from_point_normal_v3(plane_tilt, area_co, normal_tilt); | plane_from_point_normal_v3(plane_tilt, area_co, normal_tilt); | ||||
| 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]; | ||||
| mul_v3_m4v3(local_co, mat, vd.co); | mul_v3_m4v3(local_co, mat, vd.co); | ||||
| float intr[3], intr_tilt[3]; | float intr[3], intr_tilt[3]; | ||||
| float val[3]; | float val[3]; | ||||
| closest_to_plane_normalized_v3(intr, test.plane_tool, vd.co); | closest_to_plane_normalized_v3(intr, test.plane_tool, vd.co); | ||||
| closest_to_plane_normalized_v3(intr_tilt, plane_tilt, vd.co); | closest_to_plane_normalized_v3(intr_tilt, plane_tilt, vd.co); | ||||
| /* Mix the deformation of the aligned and the tilted plane based on the brush space vertex | /* Mix the deformation of the aligned and the tilted plane based on the brush space vertex | ||||
| * coordinates. */ | * coordinates. */ | ||||
| /* We can also control the mix with a curve if it produces noticeable artifacts in the center | /* We can also control the mix with a curve if it produces noticeable artifacts in the center | ||||
| * of the brush. */ | * of the brush. */ | ||||
| const float tilt_mix = local_co[1] > 0.0f ? 0.0f : 1.0f; | const float tilt_mix = local_co[1] > 0.0f ? 0.0f : 1.0f; | ||||
| interp_v3_v3v3(intr, intr, intr_tilt, tilt_mix); | interp_v3_v3v3(intr, intr, intr_tilt, tilt_mix); | ||||
| sub_v3_v3v3(val, intr_tilt, vd.co); | sub_v3_v3v3(val, intr_tilt, vd.co); | ||||
| SCULPT_automasking_node_update(ss, &automask_data, &vd); | |||||
| const float fade = bstrength * SCULPT_brush_strength_factor(ss, | const float fade = bstrength * 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); | |||||
| 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 118 Lines • ▼ Show 20 Lines | static void do_flatten_brush_task_cb_ex(void *__restrict userdata, | ||||
| 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); | ||||
| plane_from_point_normal_v3(test.plane_tool, area_co, area_no); | plane_from_point_normal_v3(test.plane_tool, area_co, area_no); | ||||
| 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 intr[3]; | float intr[3]; | ||||
| float val[3]; | float val[3]; | ||||
| closest_to_plane_normalized_v3(intr, test.plane_tool, vd.co); | closest_to_plane_normalized_v3(intr, test.plane_tool, 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)) { | ||||
| SCULPT_automasking_node_update(ss, &automask_data, &vd); | |||||
| const float fade = bstrength * SCULPT_brush_strength_factor(ss, | const float fade = bstrength * 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); | |||||
| 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); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 121 Lines • ▼ Show 20 Lines | static void do_clay_brush_task_cb_ex(void *__restrict userdata, | ||||
| 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); | ||||
| plane_from_point_normal_v3(test.plane_tool, area_co, area_no); | plane_from_point_normal_v3(test.plane_tool, area_co, area_no); | ||||
| 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 intr[3]; | float intr[3]; | ||||
| float val[3]; | float val[3]; | ||||
| closest_to_plane_normalized_v3(intr, test.plane_tool, vd.co); | closest_to_plane_normalized_v3(intr, test.plane_tool, vd.co); | ||||
| sub_v3_v3v3(val, intr, vd.co); | sub_v3_v3v3(val, intr, vd.co); | ||||
| SCULPT_automasking_node_update(ss, &automask_data, &vd); | |||||
| const float fade = bstrength * SCULPT_brush_strength_factor(ss, | const float fade = bstrength * 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); | |||||
| 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 83 Lines • ▼ Show 20 Lines | static void do_clay_strips_brush_task_cb_ex(void *__restrict userdata, | ||||
| const float bstrength = flip ? -ss->cache->bstrength : ss->cache->bstrength; | const float bstrength = flip ? -ss->cache->bstrength : ss->cache->bstrength; | ||||
| proxy = BKE_pbvh_node_add_proxy(ss->pbvh, data->nodes[n])->co; | proxy = BKE_pbvh_node_add_proxy(ss->pbvh, data->nodes[n])->co; | ||||
| SCULPT_brush_test_init(ss, &test); | SCULPT_brush_test_init(ss, &test); | ||||
| plane_from_point_normal_v3(test.plane_tool, area_co, area_no_sp); | plane_from_point_normal_v3(test.plane_tool, area_co, area_no_sp); | ||||
| 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_cube(&test, vd.co, mat, brush->tip_roundness)) { | if (!SCULPT_brush_test_cube(&test, vd.co, mat, brush->tip_roundness)) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| if (!plane_point_side_flip(vd.co, test.plane_tool, flip)) { | if (!plane_point_side_flip(vd.co, test.plane_tool, flip)) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| float intr[3]; | float intr[3]; | ||||
| float val[3]; | float val[3]; | ||||
| closest_to_plane_normalized_v3(intr, test.plane_tool, vd.co); | closest_to_plane_normalized_v3(intr, test.plane_tool, 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); | |||||
| /* The normal from the vertices is ignored, it causes glitch with planes, see: T44390. */ | /* The normal from the vertices is ignored, it causes glitch with planes, see: T44390. */ | ||||
| const float fade = bstrength * SCULPT_brush_strength_factor(ss, | const float fade = bstrength * SCULPT_brush_strength_factor(ss, | ||||
| brush, | brush, | ||||
| vd.co, | vd.co, | ||||
| ss->cache->radius * test.dist, | ss->cache->radius * 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); | |||||
| 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 118 Lines • ▼ Show 20 Lines | static void do_snake_hook_brush_task_cb_ex(void *__restrict userdata, | ||||
| 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); | ||||
| KelvinletParams params; | KelvinletParams params; | ||||
| BKE_kelvinlet_init_params(¶ms, ss->cache->radius, bstrength, 1.0f, 0.4f); | BKE_kelvinlet_init_params(¶ms, ss->cache->radius, bstrength, 1.0f, 0.4f); | ||||
| 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 (!do_elastic && !sculpt_brush_test_sq_fn(&test, vd.co)) { | if (!do_elastic && !sculpt_brush_test_sq_fn(&test, vd.co)) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| float fade; | float fade; | ||||
| if (do_elastic) { | if (do_elastic) { | ||||
| fade = 1.0f; | fade = 1.0f; | ||||
| } | } | ||||
| else { | else { | ||||
| SCULPT_automasking_node_update(ss, &automask_data, &vd); | |||||
| fade = bstrength * SCULPT_brush_strength_factor(ss, | fade = bstrength * 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); | |||||
| } | } | ||||
| mul_v3_v3fl(proxy[vd.i], grab_delta, fade); | mul_v3_v3fl(proxy[vd.i], grab_delta, fade); | ||||
| /* Negative pinch will inflate, helps maintain volume. */ | /* Negative pinch will inflate, helps maintain volume. */ | ||||
| if (do_pinch) { | if (do_pinch) { | ||||
| float delta_pinch_init[3], delta_pinch[3]; | float delta_pinch_init[3], delta_pinch[3]; | ||||
| Show All 30 Lines | BKE_pbvh_vertex_iter_begin (ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE) { | ||||
| if (do_elastic) { | if (do_elastic) { | ||||
| float disp[3]; | float disp[3]; | ||||
| BKE_kelvinlet_grab_triscale(disp, ¶ms, vd.co, ss->cache->location, proxy[vd.i]); | BKE_kelvinlet_grab_triscale(disp, ¶ms, vd.co, ss->cache->location, proxy[vd.i]); | ||||
| mul_v3_fl(disp, bstrength * 20.0f); | mul_v3_fl(disp, bstrength * 20.0f); | ||||
| if (vd.mask) { | if (vd.mask) { | ||||
| mul_v3_fl(disp, 1.0f - *vd.mask); | mul_v3_fl(disp, 1.0f - *vd.mask); | ||||
| } | } | ||||
| mul_v3_fl(disp, SCULPT_automasking_factor_get(ss->cache->automasking, ss, vd.vertex)); | mul_v3_fl( | ||||
| disp, | |||||
| SCULPT_automasking_factor_get(ss->cache->automasking, ss, vd.vertex, &automask_data)); | |||||
| copy_v3_v3(proxy[vd.i], disp); | copy_v3_v3(proxy[vd.i], disp); | ||||
| } | } | ||||
| 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 55 Lines • ▼ Show 20 Lines | static void do_thumb_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) { | ||||
| SCULPT_orig_vert_data_update(&orig_data, &vd); | SCULPT_orig_vert_data_update(&orig_data, &vd); | ||||
| if (!sculpt_brush_test_sq_fn(&test, orig_data.co)) { | if (!sculpt_brush_test_sq_fn(&test, orig_data.co)) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| SCULPT_automasking_node_update(ss, &automask_data, &vd); | |||||
| const float fade = bstrength * SCULPT_brush_strength_factor(ss, | const float fade = bstrength * SCULPT_brush_strength_factor(ss, | ||||
| brush, | brush, | ||||
| orig_data.co, | orig_data.co, | ||||
| sqrtf(test.dist), | sqrtf(test.dist), | ||||
| orig_data.no, | orig_data.no, | ||||
| NULL, | NULL, | ||||
| 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], cono, fade); | mul_v3_v3fl(proxy[vd.i], cono, 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 42 Lines • ▼ Show 20 Lines | static void do_rotate_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) { | ||||
| SCULPT_orig_vert_data_update(&orig_data, &vd); | SCULPT_orig_vert_data_update(&orig_data, &vd); | ||||
| if (!sculpt_brush_test_sq_fn(&test, orig_data.co)) { | if (!sculpt_brush_test_sq_fn(&test, orig_data.co)) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| float vec[3], rot[3][3]; | float vec[3], rot[3][3]; | ||||
| const float fade = bstrength * SCULPT_brush_strength_factor(ss, | const float fade = bstrength * SCULPT_brush_strength_factor(ss, | ||||
| brush, | brush, | ||||
| orig_data.co, | orig_data.co, | ||||
| sqrtf(test.dist), | sqrtf(test.dist), | ||||
| orig_data.no, | orig_data.no, | ||||
| NULL, | NULL, | ||||
| vd.mask ? *vd.mask : 0.0f, | vd.mask ? *vd.mask : 0.0f, | ||||
| vd.vertex, | vd.vertex, | ||||
| thread_id); | thread_id, | ||||
| &automask_data); | |||||
| sub_v3_v3v3(vec, orig_data.co, ss->cache->location); | sub_v3_v3v3(vec, orig_data.co, ss->cache->location); | ||||
| axis_angle_normalized_to_mat3(rot, ss->cache->sculpt_normal_symm, angle * fade); | axis_angle_normalized_to_mat3(rot, ss->cache->sculpt_normal_symm, angle * fade); | ||||
| mul_v3_m3v3(proxy[vd.i], rot, vec); | mul_v3_m3v3(proxy[vd.i], rot, vec); | ||||
| add_v3_v3(proxy[vd.i], ss->cache->location); | add_v3_v3(proxy[vd.i], ss->cache->location); | ||||
| sub_v3_v3(proxy[vd.i], orig_data.co); | sub_v3_v3(proxy[vd.i], orig_data.co); | ||||
| if (vd.mvert) { | if (vd.mvert) { | ||||
| ▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | static void do_layer_brush_task_cb_ex(void *__restrict userdata, | ||||
| const float bstrength = ss->cache->bstrength; | const float bstrength = ss->cache->bstrength; | ||||
| SCULPT_orig_vert_data_init(&orig_data, data->ob, data->nodes[n], SCULPT_UNDO_COORDS); | SCULPT_orig_vert_data_init(&orig_data, data->ob, data->nodes[n], SCULPT_UNDO_COORDS); | ||||
| 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) { | ||||
| SCULPT_orig_vert_data_update(&orig_data, &vd); | SCULPT_orig_vert_data_update(&orig_data, &vd); | ||||
| if (!sculpt_brush_test_sq_fn(&test, orig_data.co)) { | if (!sculpt_brush_test_sq_fn(&test, orig_data.co)) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| SCULPT_automasking_node_update(ss, &automask_data, &vd); | |||||
| 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); | |||||
| const int vi = vd.index; | const int vi = vd.index; | ||||
| float *disp_factor; | float *disp_factor; | ||||
| if (use_persistent_base) { | if (use_persistent_base) { | ||||
| disp_factor = (float *)SCULPT_vertex_attr_get(vd.vertex, ss->attrs.persistent_disp); | disp_factor = (float *)SCULPT_vertex_attr_get(vd.vertex, ss->attrs.persistent_disp); | ||||
| } | } | ||||
| else { | else { | ||||
| disp_factor = &ss->cache->layer_displacement_factor[vi]; | disp_factor = &ss->cache->layer_displacement_factor[vi]; | ||||
| ▲ Show 20 Lines • Show All 84 Lines • ▼ Show 20 Lines | static void do_inflate_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; | ||||
| } | } | ||||
| SCULPT_automasking_node_update(ss, &automask_data, &vd); | |||||
| const float fade = bstrength * SCULPT_brush_strength_factor(ss, | const float fade = bstrength * 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); | |||||
| float val[3]; | float val[3]; | ||||
| if (vd.fno) { | if (vd.fno) { | ||||
| copy_v3_v3(val, vd.fno); | copy_v3_v3(val, vd.fno); | ||||
| } | } | ||||
| else { | else { | ||||
| copy_v3_v3(val, vd.no); | copy_v3_v3(val, vd.no); | ||||
| } | } | ||||
| Show All 39 Lines | static void do_nudge_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; | ||||
| } | } | ||||
| SCULPT_automasking_node_update(ss, &automask_data, &vd); | |||||
| const float fade = bstrength * SCULPT_brush_strength_factor(ss, | const float fade = bstrength * 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); | |||||
| mul_v3_v3fl(proxy[vd.i], cono, fade); | mul_v3_v3fl(proxy[vd.i], cono, 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 49 Lines • ▼ Show 20 Lines | static void do_crease_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; | ||||
| } | } | ||||
| /* Offset vertex. */ | /* Offset vertex. */ | ||||
| SCULPT_automasking_node_update(ss, &automask_data, &vd); | |||||
| 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); | |||||
| float val1[3]; | float val1[3]; | ||||
| float val2[3]; | float val2[3]; | ||||
| /* First we pinch. */ | /* First we pinch. */ | ||||
| sub_v3_v3v3(val1, test.location, vd.co); | sub_v3_v3v3(val1, test.location, vd.co); | ||||
| if (brush->falloff_shape == PAINT_FALLOFF_SHAPE_TUBE) { | if (brush->falloff_shape == PAINT_FALLOFF_SHAPE_TUBE) { | ||||
| project_plane_v3_v3v3(val1, val1, ss->cache->view_normal); | project_plane_v3_v3v3(val1, val1, ss->cache->view_normal); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 87 Lines • ▼ Show 20 Lines | 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); | ||||
| float x_object_space[3]; | float x_object_space[3]; | ||||
| float z_object_space[3]; | float z_object_space[3]; | ||||
| copy_v3_v3(x_object_space, stroke_xz[0]); | copy_v3_v3(x_object_space, stroke_xz[0]); | ||||
| copy_v3_v3(z_object_space, stroke_xz[1]); | copy_v3_v3(z_object_space, stroke_xz[1]); | ||||
| 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; | ||||
| } | } | ||||
| SCULPT_automasking_node_update(ss, &automask_data, &vd); | |||||
| const float fade = bstrength * SCULPT_brush_strength_factor(ss, | const float fade = bstrength * 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); | |||||
| float disp_center[3]; | float disp_center[3]; | ||||
| float x_disp[3]; | float x_disp[3]; | ||||
| float z_disp[3]; | float z_disp[3]; | ||||
| /* Calculate displacement from the vertex to the brush center. */ | /* Calculate displacement from the vertex to the brush center. */ | ||||
| sub_v3_v3v3(disp_center, test.location, vd.co); | sub_v3_v3v3(disp_center, test.location, vd.co); | ||||
| /* Project the displacement into the X vector (aligned to the stroke). */ | /* Project the displacement into the X vector (aligned to the stroke). */ | ||||
| mul_v3_v3fl(x_disp, x_object_space, dot_v3v3(disp_center, x_object_space)); | mul_v3_v3fl(x_disp, x_object_space, dot_v3v3(disp_center, x_object_space)); | ||||
| ▲ Show 20 Lines • Show All 85 Lines • ▼ Show 20 Lines | static void do_grab_brush_task_cb_ex(void *__restrict userdata, | ||||
| 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); | ||||
| const bool grab_silhouette = brush->flag2 & BRUSH_GRAB_SILHOUETTE; | const bool grab_silhouette = brush->flag2 & BRUSH_GRAB_SILHOUETTE; | ||||
| 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) { | ||||
| SCULPT_orig_vert_data_update(&orig_data, &vd); | SCULPT_orig_vert_data_update(&orig_data, &vd); | ||||
| if (!sculpt_brush_test_sq_fn(&test, orig_data.co)) { | if (!sculpt_brush_test_sq_fn(&test, orig_data.co)) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| SCULPT_automasking_node_update(ss, &automask_data, &vd); | |||||
| float fade = bstrength * SCULPT_brush_strength_factor(ss, | float fade = bstrength * SCULPT_brush_strength_factor(ss, | ||||
| brush, | brush, | ||||
| orig_data.co, | orig_data.co, | ||||
| sqrtf(test.dist), | sqrtf(test.dist), | ||||
| orig_data.no, | orig_data.no, | ||||
| NULL, | NULL, | ||||
| vd.mask ? *vd.mask : 0.0f, | vd.mask ? *vd.mask : 0.0f, | ||||
| vd.vertex, | vd.vertex, | ||||
| thread_id); | thread_id, | ||||
| &automask_data); | |||||
| if (grab_silhouette) { | if (grab_silhouette) { | ||||
| float silhouette_test_dir[3]; | float silhouette_test_dir[3]; | ||||
| normalize_v3_v3(silhouette_test_dir, grab_delta); | normalize_v3_v3(silhouette_test_dir, grab_delta); | ||||
| if (dot_v3v3(ss->cache->initial_normal, ss->cache->grab_delta_symmetry) < 0.0f) { | if (dot_v3v3(ss->cache->initial_normal, ss->cache->grab_delta_symmetry) < 0.0f) { | ||||
| mul_v3_fl(silhouette_test_dir, -1.0f); | mul_v3_fl(silhouette_test_dir, -1.0f); | ||||
| } | } | ||||
| float vno[3]; | float vno[3]; | ||||
| ▲ Show 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | static void do_elastic_deform_brush_task_cb_ex(void *__restrict userdata, | ||||
| PBVHVertexIter vd; | PBVHVertexIter vd; | ||||
| SculptOrigVertData orig_data; | SculptOrigVertData orig_data; | ||||
| float(*proxy)[3]; | float(*proxy)[3]; | ||||
| const float bstrength = ss->cache->bstrength; | const float bstrength = ss->cache->bstrength; | ||||
| SCULPT_orig_vert_data_init(&orig_data, data->ob, data->nodes[n], SCULPT_UNDO_COORDS); | SCULPT_orig_vert_data_init(&orig_data, data->ob, data->nodes[n], SCULPT_UNDO_COORDS); | ||||
| AutomaskingNodeData automask_data; | |||||
| SCULPT_automasking_node_begin( | |||||
| data->ob, ss, ss->cache->automasking, &automask_data, data->nodes[n]); | |||||
| proxy = BKE_pbvh_node_add_proxy(ss->pbvh, data->nodes[n])->co; | proxy = BKE_pbvh_node_add_proxy(ss->pbvh, data->nodes[n])->co; | ||||
| float dir; | float dir; | ||||
| if (ss->cache->mouse[0] > ss->cache->initial_mouse[0]) { | if (ss->cache->mouse[0] > ss->cache->initial_mouse[0]) { | ||||
| dir = 1.0f; | dir = 1.0f; | ||||
| } | } | ||||
| else { | else { | ||||
| Show All 39 Lines | switch (brush->elastic_deform_type) { | ||||
| final_disp, ¶ms, orig_data.co, location, ss->cache->sculpt_normal_symm); | final_disp, ¶ms, orig_data.co, location, ss->cache->sculpt_normal_symm); | ||||
| break; | break; | ||||
| } | } | ||||
| if (vd.mask) { | if (vd.mask) { | ||||
| mul_v3_fl(final_disp, 1.0f - *vd.mask); | mul_v3_fl(final_disp, 1.0f - *vd.mask); | ||||
| } | } | ||||
| mul_v3_fl(final_disp, SCULPT_automasking_factor_get(ss->cache->automasking, ss, vd.vertex)); | mul_v3_fl( | ||||
| final_disp, | |||||
| SCULPT_automasking_factor_get(ss->cache->automasking, ss, vd.vertex, &automask_data)); | |||||
| copy_v3_v3(proxy[vd.i], final_disp); | copy_v3_v3(proxy[vd.i], final_disp); | ||||
| 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 47 Lines • ▼ Show 20 Lines | static void do_draw_sharp_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) { | ||||
| SCULPT_orig_vert_data_update(&orig_data, &vd); | SCULPT_orig_vert_data_update(&orig_data, &vd); | ||||
| if (!sculpt_brush_test_sq_fn(&test, orig_data.co)) { | if (!sculpt_brush_test_sq_fn(&test, orig_data.co)) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| /* Offset vertex. */ | /* Offset vertex. */ | ||||
| SCULPT_automasking_node_update(ss, &automask_data, &vd); | |||||
| const float fade = SCULPT_brush_strength_factor(ss, | const float fade = SCULPT_brush_strength_factor(ss, | ||||
| brush, | brush, | ||||
| orig_data.co, | orig_data.co, | ||||
| sqrtf(test.dist), | sqrtf(test.dist), | ||||
| orig_data.no, | orig_data.no, | ||||
| NULL, | NULL, | ||||
| 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], offset, fade); | mul_v3_v3fl(proxy[vd.i], offset, 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 53 Lines • ▼ Show 20 Lines | static void do_topology_slide_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) { | ||||
| SCULPT_orig_vert_data_update(&orig_data, &vd); | SCULPT_orig_vert_data_update(&orig_data, &vd); | ||||
| if (!sculpt_brush_test_sq_fn(&test, orig_data.co)) { | if (!sculpt_brush_test_sq_fn(&test, orig_data.co)) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| SCULPT_automasking_node_update(ss, &automask_data, &vd); | |||||
| const float fade = SCULPT_brush_strength_factor(ss, | const float fade = SCULPT_brush_strength_factor(ss, | ||||
| brush, | brush, | ||||
| orig_data.co, | orig_data.co, | ||||
| sqrtf(test.dist), | sqrtf(test.dist), | ||||
| orig_data.no, | orig_data.no, | ||||
| NULL, | NULL, | ||||
| vd.mask ? *vd.mask : 0.0f, | vd.mask ? *vd.mask : 0.0f, | ||||
| vd.vertex, | vd.vertex, | ||||
| thread_id); | thread_id, | ||||
| &automask_data); | |||||
| float current_disp[3]; | float current_disp[3]; | ||||
| float current_disp_norm[3]; | float current_disp_norm[3]; | ||||
| float final_disp[3] = {0.0f, 0.0f, 0.0f}; | float final_disp[3] = {0.0f, 0.0f, 0.0f}; | ||||
| switch (brush->slide_deform_type) { | switch (brush->slide_deform_type) { | ||||
| case BRUSH_SLIDE_DEFORM_DRAG: | case BRUSH_SLIDE_DEFORM_DRAG: | ||||
| sub_v3_v3v3(current_disp, ss->cache->location, ss->cache->last_location); | sub_v3_v3v3(current_disp, ss->cache->location, ss->cache->last_location); | ||||
| break; | break; | ||||
| ▲ Show 20 Lines • Show All 127 Lines • ▼ Show 20 Lines | static void do_topology_relax_task_cb_ex(void *__restrict userdata, | ||||
| BKE_pbvh_node_add_proxy(ss->pbvh, data->nodes[n]); | BKE_pbvh_node_add_proxy(ss->pbvh, data->nodes[n]); | ||||
| 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) { | ||||
| SCULPT_orig_vert_data_update(&orig_data, &vd); | SCULPT_orig_vert_data_update(&orig_data, &vd); | ||||
| if (!sculpt_brush_test_sq_fn(&test, orig_data.co)) { | if (!sculpt_brush_test_sq_fn(&test, orig_data.co)) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| SCULPT_automasking_node_update(ss, &automask_data, &vd); | |||||
| const float fade = SCULPT_brush_strength_factor(ss, | const float fade = SCULPT_brush_strength_factor(ss, | ||||
| brush, | brush, | ||||
| orig_data.co, | orig_data.co, | ||||
| sqrtf(test.dist), | sqrtf(test.dist), | ||||
| orig_data.no, | orig_data.no, | ||||
| NULL, | NULL, | ||||
| vd.mask ? *vd.mask : 0.0f, | vd.mask ? *vd.mask : 0.0f, | ||||
| vd.vertex, | vd.vertex, | ||||
| thread_id); | thread_id, | ||||
| &automask_data); | |||||
| SCULPT_relax_vertex(ss, &vd, fade * bstrength, false, vd.co); | SCULPT_relax_vertex(ss, &vd, fade * bstrength, false, vd.co); | ||||
| 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 46 Lines • ▼ Show 20 Lines | static void do_displacement_eraser_brush_task_cb_ex(void *__restrict userdata, | ||||
| float(*proxy)[3] = BKE_pbvh_node_add_proxy(ss->pbvh, data->nodes[n])->co; | float(*proxy)[3] = 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]); | |||||
| PBVHVertexIter vd; | PBVHVertexIter vd; | ||||
| 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; | ||||
| } | } | ||||
| SCULPT_automasking_node_update(ss, &automask_data, &vd); | |||||
| const float fade = bstrength * SCULPT_brush_strength_factor(ss, | const float fade = bstrength * 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); | |||||
| float limit_co[3]; | float limit_co[3]; | ||||
| float disp[3]; | float disp[3]; | ||||
| SCULPT_vertex_limit_surface_get(ss, vd.vertex, limit_co); | SCULPT_vertex_limit_surface_get(ss, vd.vertex, limit_co); | ||||
| sub_v3_v3v3(disp, limit_co, vd.co); | sub_v3_v3v3(disp, limit_co, vd.co); | ||||
| mul_v3_v3fl(proxy[vd.i], disp, fade); | mul_v3_v3fl(proxy[vd.i], disp, fade); | ||||
| if (vd.mvert) { | if (vd.mvert) { | ||||
| Show All 36 Lines | static void do_displacement_smear_brush_task_cb_ex(void *__restrict userdata, | ||||
| const Brush *brush = data->brush; | const Brush *brush = data->brush; | ||||
| const float bstrength = clamp_f(ss->cache->bstrength, 0.0f, 1.0f); | const float bstrength = clamp_f(ss->cache->bstrength, 0.0f, 1.0f); | ||||
| 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]); | |||||
| PBVHVertexIter vd; | PBVHVertexIter vd; | ||||
| 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; | ||||
| } | } | ||||
| SCULPT_automasking_node_update(ss, &automask_data, &vd); | |||||
| const float fade = bstrength * SCULPT_brush_strength_factor(ss, | const float fade = bstrength * 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); | |||||
| float current_disp[3]; | float current_disp[3]; | ||||
| float current_disp_norm[3]; | float current_disp_norm[3]; | ||||
| float interp_limit_surface_disp[3]; | float interp_limit_surface_disp[3]; | ||||
| copy_v3_v3(interp_limit_surface_disp, ss->cache->prev_displacement[vd.index]); | copy_v3_v3(interp_limit_surface_disp, ss->cache->prev_displacement[vd.index]); | ||||
| switch (brush->smear_deform_type) { | switch (brush->smear_deform_type) { | ||||
| ▲ Show 20 Lines • Show All 131 Lines • ▼ Show 20 Lines | static void do_topology_rake_bmesh_task_cb_ex(void *__restrict userdata, | ||||
| const float bstrength = clamp_f(data->strength, 0.0f, 1.0f); | const float bstrength = clamp_f(data->strength, 0.0f, 1.0f); | ||||
| 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]); | |||||
| PBVHVertexIter vd; | PBVHVertexIter vd; | ||||
| 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; | ||||
| } | } | ||||
| const float fade = | SCULPT_automasking_node_update(ss, &automask_data, &vd); | ||||
| bstrength * | |||||
| SCULPT_brush_strength_factor( | const float fade = bstrength * | ||||
| ss, brush, vd.co, sqrtf(test.dist), vd.no, vd.fno, *vd.mask, vd.vertex, thread_id) * | SCULPT_brush_strength_factor(ss, | ||||
| brush, | |||||
| vd.co, | |||||
| sqrtf(test.dist), | |||||
| vd.no, | |||||
| vd.fno, | |||||
| *vd.mask, | |||||
| vd.vertex, | |||||
| thread_id, | |||||
| &automask_data) * | |||||
| ss->cache->pressure; | ss->cache->pressure; | ||||
| float avg[3], val[3]; | float avg[3], val[3]; | ||||
| SCULPT_bmesh_four_neighbor_average(avg, direction, vd.bm_vert); | SCULPT_bmesh_four_neighbor_average(avg, direction, vd.bm_vert); | ||||
| sub_v3_v3v3(val, avg, vd.co); | sub_v3_v3v3(val, avg, vd.co); | ||||
| madd_v3_v3v3fl(val, vd.co, val, fade); | madd_v3_v3v3fl(val, vd.co, val, fade); | ||||
| ▲ Show 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | static void do_mask_brush_draw_task_cb_ex(void *__restrict userdata, | ||||
| PBVHVertexIter vd; | PBVHVertexIter vd; | ||||
| 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; | ||||
| } | } | ||||
| const float fade = SCULPT_brush_strength_factor( | SCULPT_automasking_node_update(ss, &automask_data, &vd); | ||||
| ss, brush, vd.co, sqrtf(test.dist), vd.no, vd.fno, 0.0f, vd.vertex, thread_id); | const float fade = SCULPT_brush_strength_factor(ss, | ||||
| brush, | |||||
| vd.co, | |||||
| sqrtf(test.dist), | |||||
| vd.no, | |||||
| vd.fno, | |||||
| 0.0f, | |||||
| vd.vertex, | |||||
| thread_id, | |||||
| &automask_data); | |||||
| if (bstrength > 0.0f) { | if (bstrength > 0.0f) { | ||||
| (*vd.mask) += fade * bstrength * (1.0f - *vd.mask); | (*vd.mask) += fade * bstrength * (1.0f - *vd.mask); | ||||
| } | } | ||||
| else { | else { | ||||
| (*vd.mask) += fade * bstrength * (*vd.mask); | (*vd.mask) += fade * bstrength * (*vd.mask); | ||||
| } | } | ||||
| *vd.mask = clamp_f(*vd.mask, 0.0f, 1.0f); | *vd.mask = clamp_f(*vd.mask, 0.0f, 1.0f); | ||||
| Show All 37 Lines | |||||