Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/sculpt_paint/sculpt.c
- This file is larger than 256 KB, so syntax highlighting is disabled by default.
| Show First 20 Lines • Show All 3,923 Lines • ▼ Show 20 Lines | static void sculpt_pose_brush_init( | ||||
| SculptThreadedTaskData data = { | SculptThreadedTaskData data = { | ||||
| .sd = sd, | .sd = sd, | ||||
| .ob = ob, | .ob = ob, | ||||
| .brush = br, | .brush = br, | ||||
| .nodes = nodes, | .nodes = nodes, | ||||
| }; | }; | ||||
| /* Smooth the pose brush factor for cleaner deformation */ | /* Smooth the pose brush factor for cleaner deformation */ | ||||
| for (int i = 0; i < 4; i++) { | for (int i = 0; i < br->pose_smooth_iterations; i++) { | ||||
| PBVHParallelSettings settings; | PBVHParallelSettings settings; | ||||
| BKE_pbvh_parallel_range_settings(&settings, (sd->flags & SCULPT_USE_OPENMP), totnode); | BKE_pbvh_parallel_range_settings(&settings, (sd->flags & SCULPT_USE_OPENMP), totnode); | ||||
| BKE_pbvh_parallel_range(0, totnode, &data, pose_brush_init_task_cb_ex, &settings); | BKE_pbvh_parallel_range(0, totnode, &data, pose_brush_init_task_cb_ex, &settings); | ||||
| } | } | ||||
| MEM_SAFE_FREE(nodes); | MEM_SAFE_FREE(nodes); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 1,318 Lines • ▼ Show 20 Lines | static void do_brush_action(Sculpt *sd, Object *ob, Brush *brush, UnifiedPaintSettings *ups) | ||||
| /* Build a list of all nodes that are potentially within the brush's area of influence */ | /* Build a list of all nodes that are potentially within the brush's area of influence */ | ||||
| /* These brushes need to update all nodes as they are not constrained by the brush radius */ | /* These brushes need to update all nodes as they are not constrained by the brush radius */ | ||||
| if (brush->sculpt_tool == SCULPT_TOOL_ELASTIC_DEFORM) { | if (brush->sculpt_tool == SCULPT_TOOL_ELASTIC_DEFORM) { | ||||
| BKE_pbvh_search_gather(ss->pbvh, NULL, NULL, &nodes, &totnode); | BKE_pbvh_search_gather(ss->pbvh, NULL, NULL, &nodes, &totnode); | ||||
| } | } | ||||
| else if (brush->sculpt_tool == SCULPT_TOOL_POSE) { | else if (brush->sculpt_tool == SCULPT_TOOL_POSE) { | ||||
| float final_radius = ss->cache->radius * (1 + brush->pose_offset); | /* After smoothing the pose factor an arbitrary number of times, the pose factor values can | ||||
| * expand to nodes that are not inside the original radius of the brush. Using a slightly | |||||
| * bigger radius should prevent those artifacts. */ | |||||
| /* We can optimize this further by removing the nodes that have all 0 values in the pose factor | |||||
| * after calculating it. */ | |||||
| float final_radius = ss->cache->radius * 1.5f * (1.0f + brush->pose_offset); | |||||
jbakker: Where does the 1.5f come from. Please add comment | |||||
Done Inline ActionsUse float not integers when the rest is a float. Compilers might add an additional not needed conversion. jbakker: Use float not integers when the rest is a float. Compilers might add an additional not needed… | |||||
| SculptSearchSphereData data = { | SculptSearchSphereData data = { | ||||
| .ss = ss, | .ss = ss, | ||||
| .sd = sd, | .sd = sd, | ||||
| .radius_squared = final_radius * final_radius, | .radius_squared = final_radius * final_radius, | ||||
| .original = true, | .original = true, | ||||
| }; | }; | ||||
| BKE_pbvh_search_gather(ss->pbvh, sculpt_search_sphere_cb, &data, &nodes, &totnode); | BKE_pbvh_search_gather(ss->pbvh, sculpt_search_sphere_cb, &data, &nodes, &totnode); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 4,487 Lines • Show Last 20 Lines | |||||
Where does the 1.5f come from. Please add comment