Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/sculpt_paint/sculpt_paint_image.cc
| Show First 20 Lines • Show All 506 Lines • ▼ Show 20 Lines | static void do_mark_dirty_regions(void *__restrict userdata, | ||||
| const int n, | const int n, | ||||
| const TaskParallelTLS *__restrict /*tls*/) | const TaskParallelTLS *__restrict /*tls*/) | ||||
| { | { | ||||
| TexturePaintingUserData *data = static_cast<TexturePaintingUserData *>(userdata); | TexturePaintingUserData *data = static_cast<TexturePaintingUserData *>(userdata); | ||||
| PBVHNode *node = data->nodes[n]; | PBVHNode *node = data->nodes[n]; | ||||
| BKE_pbvh_pixels_mark_image_dirty(*node, *data->image_data.image, *data->image_data.image_user); | BKE_pbvh_pixels_mark_image_dirty(*node, *data->image_data.image, *data->image_data.image_user); | ||||
| } | } | ||||
| /* -------------------------------------------------------------------- */ | |||||
| /** \name Fix non-manifold edge bleeding. | |||||
| * \{ */ | |||||
| static Vector<image::TileNumber> collect_dirty_tiles(Span<PBVHNode *> nodes) | |||||
| { | |||||
| Vector<image::TileNumber> dirty_tiles; | |||||
| for (PBVHNode *node : nodes) { | |||||
| BKE_pbvh_pixels_collect_dirty_tiles(*node, dirty_tiles); | |||||
| } | |||||
| return dirty_tiles; | |||||
| } | |||||
| static void fix_non_manifold_seam_bleeding(PBVH &pbvh, | |||||
| TexturePaintingUserData &user_data, | |||||
| Span<TileNumber> tile_numbers_to_fix) | |||||
| { | |||||
| for (image::TileNumber tile_number : tile_numbers_to_fix) { | |||||
| BKE_pbvh_pixels_copy_pixels( | |||||
| pbvh, *user_data.image_data.image, *user_data.image_data.image_user, tile_number); | |||||
| } | |||||
| } | |||||
| static void fix_non_manifold_seam_bleeding(Object &ob, | |||||
| const int totnode, | |||||
| TexturePaintingUserData &user_data) | |||||
| { | |||||
| Vector<image::TileNumber> dirty_tiles = collect_dirty_tiles( | |||||
| Span<PBVHNode *>(user_data.nodes, totnode)); | |||||
| fix_non_manifold_seam_bleeding(*ob.sculpt->pbvh, user_data, dirty_tiles); | |||||
| } | |||||
| /** \} */ | |||||
| } // namespace blender::ed::sculpt_paint::paint::image | } // namespace blender::ed::sculpt_paint::paint::image | ||||
| extern "C" { | extern "C" { | ||||
| using namespace blender::ed::sculpt_paint::paint::image; | using namespace blender::ed::sculpt_paint::paint::image; | ||||
| bool SCULPT_paint_image_canvas_get(PaintModeSettings *paint_mode_settings, | bool SCULPT_paint_image_canvas_get(PaintModeSettings *paint_mode_settings, | ||||
| Object *ob, | Object *ob, | ||||
| ▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | void SCULPT_do_paint_brush_image(PaintModeSettings *paint_mode_settings, | ||||
| if (!ImageData::init_active_image(ob, &data.image_data, paint_mode_settings)) { | if (!ImageData::init_active_image(ob, &data.image_data, paint_mode_settings)) { | ||||
| return; | return; | ||||
| } | } | ||||
| TaskParallelSettings settings; | TaskParallelSettings settings; | ||||
| BKE_pbvh_parallel_range_settings(&settings, true, texnodes_num); | BKE_pbvh_parallel_range_settings(&settings, true, texnodes_num); | ||||
| BLI_task_parallel_range(0, texnodes_num, &data, do_push_undo_tile, &settings); | BLI_task_parallel_range(0, texnodes_num, &data, do_push_undo_tile, &settings); | ||||
| BLI_task_parallel_range(0, texnodes_num, &data, do_paint_pixels, &settings); | BLI_task_parallel_range(0, texnodes_num, &data, do_paint_pixels, &settings); | ||||
| fix_non_manifold_seam_bleeding(*ob, texnodes_num, data); | |||||
| TaskParallelSettings settings_flush; | TaskParallelSettings settings_flush; | ||||
| BKE_pbvh_parallel_range_settings(&settings_flush, false, texnodes_num); | BKE_pbvh_parallel_range_settings(&settings_flush, false, texnodes_num); | ||||
| BLI_task_parallel_range(0, texnodes_num, &data, do_mark_dirty_regions, &settings_flush); | BLI_task_parallel_range(0, texnodes_num, &data, do_mark_dirty_regions, &settings_flush); | ||||
jbakker: Perhaps only when there are a certain amount of commands.
| |||||
| } | } | ||||
| } | } | ||||
Perhaps only when there are a certain amount of commands.