[Bf-blender-cvs] [657806691b9] master: Fix T58438: wrong display of brush angle rotation preview.
Commit: 657806691b99f1e6f0f297f273e5ff9c1085564c Author: Pablo Dobarro Date: Wed Jan 23 20:25:37 2019 +0100 Branches: master https://developer.blender.org/rB657806691b99f1e6f0f297f273e5ff9c1085564c Fix T58438: wrong display of brush angle rotation preview. Differential Revision: https://developer.blender.org/D4017 === M source/blender/windowmanager/intern/wm_operators.c === diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 0f2e6a18af4..8351a62b760 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -2192,14 +2192,14 @@ static void radial_control_paint_cursor(bContext *UNUSED(C), int x, int y, void GPU_matrix_push(); /* draw original angle line */ - GPU_matrix_rotate_2d(RAD2DEGF(rc->initial_value)); + GPU_matrix_rotate_3f(RAD2DEGF(rc->initial_value), 0.0f, 0.0f, 1.0f); immBegin(GPU_PRIM_LINES, 2); immVertex2f(pos, (float)WM_RADIAL_CONTROL_DISPLAY_MIN_SIZE, 0.0f); immVertex2f(pos, (float)WM_RADIAL_CONTROL_DISPLAY_SIZE, 0.0f); immEnd(); /* draw new angle line */ - GPU_matrix_rotate_2d(RAD2DEGF(rc->current_value - rc->initial_value)); + GPU_matrix_rotate_3f(RAD2DEGF(rc->current_value - rc->initial_value), 0.0f, 0.0f, 1.0f); immBegin(GPU_PRIM_LINES, 2); immVertex2f(pos, (float)WM_RADIAL_CONTROL_DISPLAY_MIN_SIZE, 0.0f); immVertex2f(pos, (float)WM_RADIAL_CONTROL_DISPLAY_SIZE, 0.0f); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [b0169056dfe] sculpt-mode-features: Ignore normal radius on vertex and weight paint
Commit: b0169056dfe6c01791359adf34feaae3e4206762 Author: Pablo Dobarro Date: Wed Apr 3 00:54:29 2019 +0200 Branches: sculpt-mode-features https://developer.blender.org/rBb0169056dfe6c01791359adf34feaae3e4206762 Ignore normal radius on vertex and weight paint === M 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 d78dbaa31d2..c337623fa2f 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -843,7 +843,9 @@ static void calc_area_normal_and_center_task_cb( sculpt_brush_test_init_with_falloff_shape(ss, , data->brush->falloff_shape); /* Add the normal radius factor to the test */ - test.radius_factor = data->brush->normal_radius_factor; + if (data->brush->ob_mode == OB_MODE_SCULPT) { + test.radius_factor = data->brush->normal_radius_factor; + } /* when the mesh is edited we can't rely on original coords * (original mesh may not even have verts in brush radius) */ ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [097997c015b] sculpt-mode-features: Fix pad error after merge
Commit: 097997c015b18dd478b26167e92f2a50fde6bdeb Author: Pablo Dobarro Date: Wed Apr 3 01:15:22 2019 +0200 Branches: sculpt-mode-features https://developer.blender.org/rB097997c015b18dd478b26167e92f2a50fde6bdeb Fix pad error after merge === M source/blender/makesdna/DNA_mesh_types.h === diff --git a/source/blender/makesdna/DNA_mesh_types.h b/source/blender/makesdna/DNA_mesh_types.h index a3632412d82..098337b6431 100644 --- a/source/blender/makesdna/DNA_mesh_types.h +++ b/source/blender/makesdna/DNA_mesh_types.h @@ -191,7 +191,6 @@ typedef struct Mesh { char _pad1[4]; /** Deprecated multiresolution modeling data, only keep for loading old files. */ struct Multires *mr DNA_DEPRECATED; - void *_pad1; Mesh_Runtime runtime; } Mesh; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [b4902ccc24c] sculpt-mode-features: Fix crash on vertex and weight paint
Commit: b4902ccc24c1ab60507402fc967f6390916d588c Author: Pablo Dobarro Date: Wed Apr 3 01:21:45 2019 +0200 Branches: sculpt-mode-features https://developer.blender.org/rBb4902ccc24c1ab60507402fc967f6390916d588c Fix crash on vertex and weight paint I think the crash was related to the new viewport navigation. I'm not sure if this is the correct way to fix this, but now vertex and weight paint are working again. === M source/blender/editors/sculpt_paint/paint_vertex.c === diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index 241eb38f7de..4fd4ecab9d8 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -2178,6 +2178,7 @@ static void wpaint_do_symmetrical_brush_actions( static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, PointerRNA *itemptr) { Scene *scene = CTX_data_scene(C); + Depsgraph *depsgraph = CTX_data_depsgraph(C); ToolSettings *ts = CTX_data_tool_settings(C); VPaint *wp = ts->wpaint; Brush *brush = BKE_paint_brush(>paint); @@ -2242,6 +2243,7 @@ static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P /* calculate pivot for rotation around seletion if needed */ /* also needed for "View Selected" on last stroke */ + ED_view3d_autodist_init(depsgraph, vc->ar, vc->v3d, 0); paint_last_stroke_update(scene, vc->ar, mval); BKE_mesh_batch_cache_dirty_tag(ob->data, BKE_MESH_BATCH_DIRTY_ALL); @@ -3146,6 +3148,7 @@ static void vpaint_do_symmetrical_brush_actions( static void vpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, PointerRNA *itemptr) { Scene *scene = CTX_data_scene(C); + Depsgraph *depsgraph = CTX_data_depsgraph(C); ToolSettings *ts = CTX_data_tool_settings(C); struct VPaintData *vpd = paint_stroke_mode_data(stroke); VPaint *vp = ts->vpaint; @@ -3177,6 +3180,7 @@ static void vpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P /* calculate pivot for rotation around seletion if needed */ /* also needed for "View Selected" on last stroke */ + ED_view3d_autodist_init(depsgraph, vc->ar, vc->v3d, 0); paint_last_stroke_update(scene, vc->ar, mval); ED_region_tag_redraw(vc->ar); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [8b54c524bea] sculpt-mode-features: Merge branch 'master' into sculpt-mode-features
Commit: 8b54c524beaf6517450675d954c3a00e4956ebdf Author: Pablo Dobarro Date: Wed Apr 3 01:03:31 2019 +0200 Branches: sculpt-mode-features https://developer.blender.org/rB8b54c524beaf6517450675d954c3a00e4956ebdf Merge branch 'master' into sculpt-mode-features === === diff --cc source/blender/editors/space_view3d/view3d_edit.c index 9c57975ba8b,19008ebd122..4cbed2b3861 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@@ -507,13 -505,12 +507,14 @@@ static void viewops_data_create negate_v3_v3(tvec, rv3d->ofs); vod->init.zfac = ED_view3d_calc_zfac(rv3d, tvec, NULL); } - + vod->C = C; vod->reverse = 1.0f; - if (rv3d->persmat[2][1] < 0.0f) + if (rv3d->persmat[2][1] < 0.0f) { vod->reverse = -1.0f; + } + copy_v3_v3(vod->init.viewpos, rv3d->viewinv[3]); + rv3d->rflag |= RV3D_NAVIGATING; } diff --cc source/blender/makesdna/DNA_mesh_types.h index 098337b6431,0d43b14e252..a3632412d82 --- a/source/blender/makesdna/DNA_mesh_types.h +++ b/source/blender/makesdna/DNA_mesh_types.h @@@ -187,10 -187,9 +187,11 @@@ typedef struct Mesh short totcol; + float voxel_size; + char _pad1[4]; /** Deprecated multiresolution modeling data, only keep for loading old files. */ struct Multires *mr DNA_DEPRECATED; + void *_pad1; Mesh_Runtime runtime; } Mesh; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [159bbb7755d] sculpt-mode-features: Enable OpenVDB by default
Commit: 159bbb7755d74d3a962fad68c334f6f83670 Author: Pablo Dobarro Date: Wed Apr 3 01:28:07 2019 +0200 Branches: sculpt-mode-features https://developer.blender.org/rB159bbb7755d74d3a962fad68c334f6f83670 Enable OpenVDB by default The voxel remesher needs OpenVDB to work. Maybe I should add an option to disable building the voxel remesher in the future. Patch by Jun Mizutani (@jmztn). === M CMakeLists.txt === diff --git a/CMakeLists.txt b/CMakeLists.txt index 6a8a7a7fcfa..b7441174e23 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -240,7 +240,7 @@ option(WITH_COMPOSITOR "Enable the tile based nodal compositor" ON) option(WITH_OPENSUBDIV"Enable OpenSubdiv for surface subdivision" ${_init_OPENSUBDIV}) -option(WITH_OPENVDB "Enable features relying on OpenVDB" OFF) +option(WITH_OPENVDB "Enable features relying on OpenVDB" ON) option(WITH_OPENVDB_BLOSC "Enable blosc compression for OpenVDB, only enable if OpenVDB was built with blosc support" OFF) option(WITH_OPENVDB_3_ABI_COMPATIBLE "Assume OpenVDB library has been compiled with version 3 ABI compatibility" OFF) mark_as_advanced(WITH_OPENVDB_3_ABI_COMPATIBLE) ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [6e81e5c7095] sculpt-mode-features: Sculpt vertex colors: Initial implementation
Commit: 6e81e5c70952004f6d24f58d2047227f2e73f1e9 Author: Pablo Dobarro Date: Fri Apr 5 17:56:58 2019 +0200 Branches: sculpt-mode-features https://developer.blender.org/rB6e81e5c70952004f6d24f58d2047227f2e73f1e9 Sculpt vertex colors: Initial implementation This adds a new CustomDataLayer to store per vertex color data in a way that can be used from sculpt mode. This vertex paint mode uses the same brush, pbvh, undo and rendering code as sculpt mode, so it has much better performance. It also enables other features like sculpting and painting at the same time. I also added some extra features that are needed to start testing this paint mode, such as: - New paint brush optimized for painting. It doesn't modify any vertex position data. - Sculpt mode sample color operator that uses the active vertex from the cursor - Remesh reprojection support: sculpt vertex colors are reprojected into the new mesh when using the remesh operator if the mesh has that option enabled. - Store and load sculpt vertex colors into the regular vertex color layers to keep compatibility. - Use the single color display mode to disable sculpt vertex colors in sculpt mode. A lot of decisions needs to be made to integrate this in Blender, so I decided to keep the implementation as unintrusive as possible to start working on the tools. This has the following limitations: - Sculpt and paint at the same time is only enabled in the draw brush. You need to set the Color Mode to Mix in the brush options. - Dyntopo and multires modes and viewport display are broken - Only mix as a color blend mode - No brush texture support - Sculpt and color share the same strength - Limited to one layer per object - No rendering support. You will need to copy the sculpt vertex colors to the old color layers first. All of these issues should be addressed once the main workflow, final UI and behavior are decided. === M release/scripts/startup/bl_ui/properties_data_mesh.py M release/scripts/startup/bl_ui/space_topbar.py M release/scripts/startup/bl_ui/space_view3d_toolbar.py M source/blender/blenkernel/BKE_paint.h M source/blender/blenkernel/BKE_pbvh.h M source/blender/blenkernel/intern/customdata.c M source/blender/blenkernel/intern/paint.c M source/blender/blenkernel/intern/pbvh.c M source/blender/draw/engines/workbench/shaders/workbench_prepass_frag.glsl M source/blender/draw/engines/workbench/shaders/workbench_prepass_vert.glsl M source/blender/draw/engines/workbench/workbench_materials.c M source/blender/editors/object/object_edit.c M source/blender/editors/object/object_intern.h M source/blender/editors/object/object_ops.c M source/blender/editors/sculpt_paint/sculpt.c M source/blender/editors/sculpt_paint/sculpt_intern.h M source/blender/editors/sculpt_paint/sculpt_undo.c M source/blender/gpu/GPU_buffers.h M source/blender/gpu/intern/gpu_buffers.c M source/blender/makesdna/DNA_brush_types.h M source/blender/makesdna/DNA_customdata_types.h M source/blender/makesdna/DNA_mesh_types.h M source/blender/makesdna/DNA_meshdata_types.h M source/blender/makesrna/intern/rna_brush.c M source/blender/makesrna/intern/rna_mesh.c === diff --git a/release/scripts/startup/bl_ui/properties_data_mesh.py b/release/scripts/startup/bl_ui/properties_data_mesh.py index de178496c56..bf2a1d00d20 100644 --- a/release/scripts/startup/bl_ui/properties_data_mesh.py +++ b/release/scripts/startup/bl_ui/properties_data_mesh.py @@ -453,6 +453,10 @@ class DATA_PT_vertex_colors(MeshButtonsPanel, Panel): col.operator("mesh.vertex_color_add", icon='ADD', text="") col.operator("mesh.vertex_color_remove", icon='REMOVE', text="") +row = layout.row() +col = row.column() +col.operator("object.vertex_to_loop_colors", text="Store sculpt color") +col.operator("object.loop_to_vertex_colors", text="Load sculpt color") class DATA_PT_remesh(MeshButtonsPanel, Panel): bl_label = "Remesh" @@ -467,6 +471,7 @@ class DATA_PT_remesh(MeshButtonsPanel, Panel): mesh = context.mesh col.prop(mesh, "voxel_size") col.prop(mesh, "smooth_normals") +col.prop(mesh, "reproject_vertex_paint") col.operator("object.remesh", text="Remesh") diff --git a/release/scripts/startup/bl_ui/space_topbar.py b/release/scripts/startup/bl_ui/space_topbar.py index 7b9b324066a..71c46b2f931 100644 --- a/release/scripts/startup/bl_ui/space_topbar.py +++ b/release/scripts/startup/bl_ui/space_topbar.py @@ -229,8 +229,10 @@ class _draw_left_context_mode: r
[Bf-blender-cvs] [d14017cdcba] sculpt-mode-features: View Navigation: 2D viewport zooming
Commit: d14017cdcba43df7bfb5b5ef52145e2ed60b60cc Author: Pablo Dobarro Date: Sat Mar 30 21:27:56 2019 +0100 Branches: sculpt-mode-features https://developer.blender.org/rBd14017cdcba43df7bfb5b5ef52145e2ed60b60cc View Navigation: 2D viewport zooming This implements the same concept of 2D viewport panning but for zooming. It prevents unexpected zoom speeds when working with a pen tablet. Zoom speed is constant and it is based on the initial distance to the working area. Speed parameters are hardcoded for now, but they can be exposed as options or replaced by a variable zoom speed. I also reduced the rotation speed when 2D viewport panning is enabled for consistency. This navigation mode is enabled by activating 2D viewport panning in the navigation preferences. That option should be renamed in the future. Enabling and disabling perspective is broken most of the time, but it also happens in master. I'm not sure if these changes are making the problem worse. === M source/blender/editors/space_view3d/view3d_edit.c === diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 30756b671ae..9c57975ba8b 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -162,6 +162,7 @@ typedef struct ViewOpsData { float trackvec[3]; /** Dolly only. */ float mousevec[3]; + float viewpos[3]; } init; /** Previous state (previous modal event handled). */ @@ -511,6 +512,8 @@ static void viewops_data_create( if (rv3d->persmat[2][1] < 0.0f) vod->reverse = -1.0f; + copy_v3_v3(vod->init.viewpos, rv3d->viewinv[3]); + rv3d->rflag |= RV3D_NAVIGATING; } @@ -728,6 +731,10 @@ static void viewrotate_apply(ViewOpsData *vod, const int event_xy[2]) angle = (len_v3(dvec) / (2.0f * TRACKBALLSIZE)) * (float)M_PI; + if (U.uiflag2 & USER_2D_VIEWPORT_PANNING) { + angle *= 0.6f; + } + /* Allow for rotation beyond the interval [-pi, pi] */ angle = angle_wrap_rad(angle); @@ -2051,25 +2058,61 @@ static void viewzoom_apply_3d( float zfac; float dist_range[2]; - ED_view3d_dist_range_get(vod->v3d, dist_range); + float center[3], new_ofs[3], vt[3], view_dir[3]; + float center_dist, event_dist, zf, new_dist, ft; - zfac = viewzoom_scale_value_offset( - >ar->winrct, viewzoom, zoom_invert, false, - xy, vod->init.event_xy, vod->init.event_xy_offset, - vod->rv3d->dist, vod->init.dist, - >prev.time); + ED_view3d_dist_range_get(vod->v3d, dist_range); - if (zfac != 1.0f) { - const float zfac_min = dist_range[0] / vod->rv3d->dist; - const float zfac_max = dist_range[1] / vod->rv3d->dist; - CLAMP(zfac, zfac_min, zfac_max); + if (U.uiflag2 & USER_2D_VIEWPORT_PANNING) { + view3d_orbit_calc_center(vod->C, center); + center_dist = len_v3v3(center, vod->init.viewpos); - view_zoom_to_window_xy_3d( - vod->ar, zfac, zoom_to_pos ? vod->prev.event_xy : NULL); + if (U.uiflag & USER_ZOOM_HORIZ) { + event_dist = vod->init.event_xy[0] - xy[0]; + event_dist = event_dist / vod->ar->sizex; + } + else { + event_dist = vod->init.event_xy[1] - xy[1]; + event_dist = event_dist / vod->ar->sizey; + } + event_dist = event_dist * 400; + + copy_v3_v3(view_dir, vod->rv3d->viewinv[2]); + mul_v3_fl(view_dir, -1.0f); + normalize_v3(view_dir); + zf = 0.005f * center_dist; + CLAMP(zf, 0, 0.05f); + if (vod->rv3d->is_persp) { + mul_v3_v3fl(vt, view_dir, event_dist * zf); + copy_v3_v3(new_ofs, vod->init.ofs); + add_v3_v3(new_ofs, vt); + copy_v3_v3(vod->rv3d->ofs, new_ofs); + } + else { + ft = event_dist * zf * 2.0f; + new_dist = vod->init.dist + ft; + vod->rv3d->dist = new_dist; + } } + else { + zfac = viewzoom_scale_value_offset( + >ar->winrct, viewzoom, zoom_invert, false, + xy, vod->init.event_xy, vod->init.event_xy_offset, +
[Bf-blender-cvs] [4c0c29a29ec] sculpt-mode-features: Enable topology automasking for the snake hook brush
Commit: 4c0c29a29ec92439904f9f0a8a75f8e63b2bcc95 Author: Pablo Dobarro Date: Sun Apr 7 21:25:22 2019 +0200 Branches: sculpt-mode-features https://developer.blender.org/rB4c0c29a29ec92439904f9f0a8a75f8e63b2bcc95 Enable topology automasking for the snake hook brush === M 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 1bdb8378db6..a78f1b62c24 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -2880,8 +2880,12 @@ static void do_snake_hook_brush_task_cb_ex( const float fade = bstrength * tex_strength( ss, brush, vd.co, sqrtf(test.dist), vd.no, vd.fno, vd.mask ? *vd.mask : 0.0f, tls->thread_id); + float automasking = 1.0f; + if (sculpt_automasking_compatible(ss)){ + automasking = sculpt_automasking_value_get(ss, brush, >mvert[vd.vert_indices[vd.i]]); + } - mul_v3_v3fl(proxy[vd.i], grab_delta, fade); + mul_v3_v3fl(proxy[vd.i], grab_delta, fade * automasking); /* negative pinch will inflate, helps maintain volume */ if (do_pinch) { @@ -2914,7 +2918,7 @@ static void do_snake_hook_brush_task_cb_ex( if (do_rake_rotation) { float delta_rotate[3]; - sculpt_rake_rotate(ss, test.location, vd.co, fade, delta_rotate); + sculpt_rake_rotate(ss, test.location, vd.co, fade * automasking, delta_rotate); add_v3_v3(proxy[vd.i], delta_rotate); } @@ -4041,7 +4045,7 @@ static bool find_connected_set(SculptSession *ss, int init_vert, GSet *influence } static bool sculpt_topology_automasking_needs_updates(const Brush *br) { - if (br->sculpt_tool == SCULPT_TOOL_GRAB) { + if (br->sculpt_tool == SCULPT_TOOL_GRAB || br->sculpt_tool == SCULPT_TOOL_SNAKE_HOOK) { return false; } return true; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [deaa664cc0b] sculpt-mode-features: OpenVDB: Replace dilate and erode with offset on level set
Commit: deaa664cc0b8e93f17628f0048775b65f6688582 Author: Pablo Dobarro Date: Mon Apr 8 02:25:11 2019 +0200 Branches: sculpt-mode-features https://developer.blender.org/rBdeaa664cc0b8e93f17628f0048775b65f6688582 OpenVDB: Replace dilate and erode with offset on level set Dilate and erode filters are now working === M intern/openvdb/intern/openvdb_level_set.cc M source/blender/makesrna/intern/rna_modifier.c === diff --git a/intern/openvdb/intern/openvdb_level_set.cc b/intern/openvdb/intern/openvdb_level_set.cc index c6eb8e6f122..bd2772f027c 100644 --- a/intern/openvdb/intern/openvdb_level_set.cc +++ b/intern/openvdb/intern/openvdb_level_set.cc @@ -110,10 +110,10 @@ void OpenVDBLevelSet::OpenVDB_level_set_filter(OpenVDBLevelSet_FilterType filter filter.laplacian(); break; case OPENVDB_LEVELSET_FILTER_DILATE: - filter.dilate(iterations); + filter.offset(-iterations/100.0); break; case OPENVDB_LEVELSET_FILTER_ERODE: - filter.erode(iterations); + filter.offset(iterations/100.0); break; } } diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index d54f2714120..913628cc6de 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -4075,8 +4075,8 @@ static void rna_def_modifier_remesh(BlenderRNA *brna) {VOXEL_FILTER_MEDIAN, "MEDIAN", 0, "Median", "Median Filter"}, {VOXEL_FILTER_MEAN_CURVATURE, "MEAN_CURVATURE", 0, "Mean Curvature", "Mean Curvature Filter"}, {VOXEL_FILTER_LAPLACIAN, "LAPLACIAN", 0, "Laplacian", "Laplacian Filter"}, - //{VOXEL_FILTER_DILATE, "DILATE", 0, "Dilate", "Dilate Filter"}, - //{VOXEL_FILTER_ERODE, "ERODE", 0, "Erode", "Erode Filter"}, + {VOXEL_FILTER_DILATE, "DILATE", 0, "Dilate", "Dilate Filter"}, + {VOXEL_FILTER_ERODE, "ERODE", 0, "Erode", "Erode Filter"}, {0, NULL, 0, NULL, NULL}, }; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [7f9b00bd464] sculpt-mode-features: Refactor: Move remesher functions to blenderkernel
Commit: 7f9b00bd464df2f2abbeaf016fe6dc633a034691 Author: Pablo Dobarro Date: Mon Apr 8 01:22:39 2019 +0200 Branches: sculpt-mode-features https://developer.blender.org/rB7f9b00bd464df2f2abbeaf016fe6dc633a034691 Refactor: Move remesher functions to blenderkernel === A source/blender/blenkernel/BKE_remesh.h M source/blender/blenkernel/CMakeLists.txt A source/blender/blenkernel/intern/remesh_voxel.c M source/blender/editors/object/object_edit.c === diff --git a/source/blender/blenkernel/BKE_remesh.h b/source/blender/blenkernel/BKE_remesh.h new file mode 100644 index 000..e51d92237ca --- /dev/null +++ b/source/blender/blenkernel/BKE_remesh.h @@ -0,0 +1,39 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + */ +#ifndef __BKE_REMESH_H__ +#define __BKE_REMESH_H__ + +/** \file + * \ingroup bke + */ + +#include "DNA_mesh_types.h" + +#include "openvdb_capi.h" + +/* OpenVDB Voxel Remesher */ +struct OpenVDBLevelSet *BKE_remesh_voxel_ovdb_mesh_to_level_set_create(Mesh *mesh, struct OpenVDBTransform *transform); +Mesh *BKE_remesh_voxel_ovdb_volume_to_mesh_nomain(struct OpenVDBLevelSet *level_set, double isovalue, double adaptivity, + bool relax_disoriented_triangles); + +/* Reprojection */ +void BKE_remesh_voxel_init_empty_vertex_color_layer(Mesh *mesh); +void BKE_remesh_voxel_reproject_vertex_paint(Mesh *target, Mesh *source); + +#endif /* __BKE_REMESH_H__ */ diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt index c882be972f5..86b403d1f1f 100644 --- a/source/blender/blenkernel/CMakeLists.txt +++ b/source/blender/blenkernel/CMakeLists.txt @@ -220,6 +220,7 @@ set(SRC intern/workspace.c intern/world.c intern/writeavi.c + intern/remesh_voxel.c BKE_DerivedMesh.h BKE_action.h @@ -341,6 +342,7 @@ set(SRC BKE_workspace.h BKE_world.h BKE_writeavi.h + BKE_remesh.h nla_private.h particle_private.h diff --git a/source/blender/blenkernel/intern/remesh_voxel.c b/source/blender/blenkernel/intern/remesh_voxel.c new file mode 100644 index 000..78de777493f --- /dev/null +++ b/source/blender/blenkernel/intern/remesh_voxel.c @@ -0,0 +1,152 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + */ + +/** \file + * \ingroup bke + */ + +#include +#include +#include +#include +#include +#include + +#include "MEM_guardedalloc.h" + +#include "BLI_blenlib.h" +#include "BLI_math.h" +#include "BLI_utildefines.h" + +#include "DNA_object_types.h" +#include "DNA_mesh_types.h" +#include "DNA_meshdata_types.h" + +#include "BKE_mesh.h" +#include "BKE_mesh_runtime.h" +#include "BKE_library.h" +#include "BKE_customdata.h" +#include "BKE_bvhutils.h" +#include "BKE_remesh.h" + +#ifdef WITH_OPENVDB + #include "openvdb_capi.h" +#endif + + +struct OpenVDBLevelSet *BKE_remesh_voxel_ovdb_mesh_to_level_set_create(Mesh *mesh, struct OpenVDBTransform *transform) +{ + BKE_mesh_runtime_looptri_recalc(mesh); + const MLoopTri *
[Bf-blender-cvs] [1df1337dcbb] sculpt-mode-features: Merge branch 'master' into sculpt-mode-features
Commit: 1df1337dcbbd4643ec984ff15bb9271eeafa9516 Author: Pablo Dobarro Date: Sun Mar 24 04:02:07 2019 +0100 Branches: sculpt-mode-features https://developer.blender.org/rB1df1337dcbbd4643ec984ff15bb9271eeafa9516 Merge branch 'master' into sculpt-mode-features === === diff --cc release/scripts/startup/bl_ui/space_view3d_toolbar.py index f6825668b0d,212427dead9..da187af8c77 --- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py +++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py @@@ -268,26 -300,11 +300,24 @@@ class VIEW3D_PT_tools_brush(Panel, View if not self.is_popover: brush_basic_sculpt_settings(col, context, brush) +# normal_radius_factor +col.separator() +row = col.row() +row.prop(brush, "normal_radius_factor", slider=True) + +col.separator() +row = col.row() +row.prop(brush, "curve_preset") + +col.separator() +row = col.row() +row.prop(brush, "automasking_mode") + # topology_rake_factor - if (capabilities.has_topology_rake and - context.sculpt_object.use_dynamic_topology_sculpting + if ( + capabilities.has_topology_rake and + context.sculpt_object.use_dynamic_topology_sculpting ): - col.separator() row = col.row() row.prop(brush, "topology_rake_factor", slider=True) diff --cc source/blender/blenloader/intern/versioning_280.c index ff95e094ea4,6c5eb269c5c..6f8bbfb5c34 --- a/source/blender/blenloader/intern/versioning_280.c +++ b/source/blender/blenloader/intern/versioning_280.c @@@ -2928,10 -2921,15 +2928,21 @@@ void blo_do_versions_280(FileData *fd, } } + if (!DNA_struct_elem_find(fd->filesdna, "Mesh", "float", "voxel_size")) { + for (Mesh *me = bmain->meshes.first; me; me = me->id.next) { + me->voxel_size = 0.1f; + } + } ++ + if (!DNA_struct_elem_find(fd->filesdna, "TriangulateModifierData", "int", "min_vertices")) { + for (Object *ob = bmain->objects.first; ob; ob = ob->id.next) { + for (ModifierData *md = ob->modifiers.first; md; md = md->next) { + if (md->type == eModifierType_Triangulate) { + TriangulateModifierData *smd = (TriangulateModifierData *)md; + smd->min_vertices = 4; + } + } + } + } } } diff --cc source/blender/makesrna/intern/rna_brush.c index a77faf01ece,7e4482790af..e1075028934 --- a/source/blender/makesrna/intern/rna_brush.c +++ b/source/blender/makesrna/intern/rna_brush.c @@@ -1425,26 -1434,12 +1436,32 @@@ static void rna_def_brush(BlenderRNA *b {0, NULL, 0, NULL, NULL}, }; + static const EnumPropertyItem brush_curve_preset_items[] = { + {BRUSH_CURVE_CUSTOM, "CUSTOM", 0, "Custom", ""}, + {BRUSH_CURVE_SMOOTH, "SMOOTH", 0, "Smooth", ""}, + {BRUSH_CURVE_SPHERE, "SPHERE", 0, "Sphere", ""}, + {BRUSH_CURVE_ROOT, "ROOT", 0, "Root", ""}, + {BRUSH_CURVE_SHARP, "SHARP", 0, "Sharp", ""}, + {BRUSH_CURVE_LIN, "LIN", 0, "Linear", ""}, + {BRUSH_CURVE_POW4, "POW4", 0, "Sharper", ""}, + {BRUSH_CURVE_INVSQUARE, "INVSQUARE", 0, "Inverse square", ""}, + {BRUSH_CURVE_CONSTANT, "CONSTANT", 0, "Constant", ""}, + {0, NULL, 0, NULL, NULL}, + }; + + static const EnumPropertyItem brush_automasking_mode_items[] = { + {BRUSH_AUTOMASKING_NONE, "NONE", 0, "Disabled", ""}, + {BRUSH_AUTOMASKING_TOPOLOGY, "TOPOLOGY", 0, "Topology", ""}, + {0, NULL, 0, NULL, NULL}, + }; + + + static const EnumPropertyItem brush_size_unit_items[] = { + {0, "VIEW", 0, "View", "Measure brush size relateve to the view"}, + {BRUSH_LOCK_SIZE, "SCENE"
[Bf-blender-cvs] [45dbf1835f9] sculpt-mode-features: Brush cursor: Fix crash with 2D falloff
Commit: 45dbf1835f91fcc5aaca473360392f1918893c7c Author: Pablo Dobarro Date: Sat Mar 16 19:27:10 2019 +0100 Branches: sculpt-mode-features https://developer.blender.org/rB45dbf1835f91fcc5aaca473360392f1918893c7c Brush cursor: Fix crash with 2D falloff Disable the normal preview when 2D falloff is enabled. === M source/blender/editors/sculpt_paint/paint_cursor.c === diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c index 317e037ad95..a570600d9cb 100644 --- a/source/blender/editors/sculpt_paint/paint_cursor.c +++ b/source/blender/editors/sculpt_paint/paint_cursor.c @@ -1236,7 +1236,7 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused)) } /* Only sculpt cursor for now */ - if ((mode == PAINT_MODE_SCULPT) && vc.obact->sculpt) { + if ((mode == PAINT_MODE_SCULPT) && vc.obact->sculpt && !(brush->falloff_shape & BRUSH_AIRBRUSH)) { Sculpt *sd = CTX_data_tool_settings(C)->sculpt; wmWindow *win = CTX_wm_window(C); if (sd->paint.brush->overlay_flags & BRUSH_OVERLAY_CURSOR) { ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [e2f23d91b98] sculpt-mode-features: OpenVDB Voxel remesher: Initial implementation
Commit: e2f23d91b989e05ff743260d18c85a17f78439a9 Author: Pablo Dobarro Date: Thu Mar 14 21:54:27 2019 +0100 Branches: sculpt-mode-features https://developer.blender.org/rBe2f23d91b989e05ff743260d18c85a17f78439a9 OpenVDB Voxel remesher: Initial implementation This introduces a new workflow for sculpting. The voxel remesher works with Dyntopo disabled. The user needs to run it manually once he/she considers that the topology is too stretched to continue sculpting normally. OpenVDB evaluates the mesh volume as a level set with a given voxel size and it always outputs an all quads manifold mesh. It automatically solves self-intersections and geometry errors produced by booleans, which Dyntopo can't solve right now. Once the new mesh is calculated, the user can continue sculpting without the overhead of having Dyntopo enabled. It still needs a proper UI and it has some issues. Undo is not working on a remeshed object. === M intern/openvdb/CMakeLists.txt A intern/openvdb/intern/openvdb_level_set.cc A intern/openvdb/intern/openvdb_level_set.h M intern/openvdb/openvdb_capi.cc M intern/openvdb/openvdb_capi.h M source/blender/editors/object/CMakeLists.txt M source/blender/editors/object/object_edit.c M source/blender/editors/object/object_intern.h M source/blender/editors/object/object_ops.c === diff --git a/intern/openvdb/CMakeLists.txt b/intern/openvdb/CMakeLists.txt index ddec43f30a3..c231099bb03 100644 --- a/intern/openvdb/CMakeLists.txt +++ b/intern/openvdb/CMakeLists.txt @@ -21,6 +21,7 @@ set(INC . intern + ../guardedalloc ) set(INC_SYS @@ -53,12 +54,14 @@ if(WITH_OPENVDB) intern/openvdb_dense_convert.cc intern/openvdb_reader.cc intern/openvdb_writer.cc + intern/openvdb_level_set.cc openvdb_capi.cc openvdb_util.cc intern/openvdb_dense_convert.h intern/openvdb_reader.h intern/openvdb_writer.h + intern/openvdb_level_set.h openvdb_util.h ) diff --git a/intern/openvdb/intern/openvdb_level_set.cc b/intern/openvdb/intern/openvdb_level_set.cc new file mode 100644 index 000..068148f4e04 --- /dev/null +++ b/intern/openvdb/intern/openvdb_level_set.cc @@ -0,0 +1,66 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2015 Blender Foundation. + * All rights reserved. + */ + + +#include "openvdb_level_set.h" +#include "openvdb_util.h" +#include "openvdb_capi.h" +#include "MEM_guardedalloc.h" + +void OpenVDB_level_set_remesh(struct OpenVDBRemeshData *rmd){ + + std::vector points; + std::vector triangles; + std::vector quads; + std::vector out_points; + std::vector out_quads; + const openvdb::math::Transform xform; + + for(int i = 0; i < rmd->totverts; i++) { + openvdb::Vec3s v(rmd->verts[i * 3 ], rmd->verts[i * 3 + 1], rmd->verts[i * 3 + 2]); + points.push_back(v); + } + + for(int i = 0; i < rmd->totfaces; i++) { + openvdb::Vec3I f(rmd->faces[i * 3 ], rmd->faces[i * 3 + 1], rmd->faces[i * 3 + 2]); + triangles.push_back(f); + } + + openvdb::initialize(); + openvdb::math::Transform::Ptr transform = openvdb::math::Transform::createLinearTransform((double)rmd->voxel_size); + const openvdb::FloatGrid::Ptr grid = openvdb::tools::meshToLevelSet(*transform, points, triangles, quads, 1); + openvdb::tools::volumeToMesh(*grid, out_points, out_quads, (double)rmd->isovalue); + rmd->out_verts = (float *)MEM_malloc_arrayN(out_points.size(), 3 * sizeof (float), "openvdb remesher out verts"); + rmd->out_faces = (unsigned int*)MEM_malloc_arrayN(out_quads.size(), 4 * sizeof (unsigned int), "openvdb remesh out quads"); + rmd->out_totverts = out_points.size(); + rmd->out_totfaces = out_quads.size(); + + for(int i = 0; i < out_points.siz
[Bf-blender-cvs] [0f1c86542ea] sculpt-mode-features: Brush cursor: Fix smooth stroke line position
Commit: 0f1c86542ea2ae42f9136af43899f648a2c74fa5 Author: Pablo Dobarro Date: Mon Mar 18 02:31:04 2019 +0100 Branches: sculpt-mode-features https://developer.blender.org/rB0f1c86542ea2ae42f9136af43899f648a2c74fa5 Brush cursor: Fix smooth stroke line position Reset the viewport to its original state after drawing the vertex preview. === M source/blender/editors/sculpt_paint/paint_cursor.c === diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c index a570600d9cb..90010693222 100644 --- a/source/blender/editors/sculpt_paint/paint_cursor.c +++ b/source/blender/editors/sculpt_paint/paint_cursor.c @@ -1259,8 +1259,8 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused)) else { rds = BKE_brush_unprojected_radius_get(scene, brush); } + wmViewport(>winrct); - wmOrtho2_pixelspace(ar->winx, ar->winy); /* draw 3D vertex preview */ if (len_v3v3(gi.nearest_vertex_co, gi.location) < rds) { @@ -1286,6 +1286,7 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused)) GPU_matrix_pop(); GPU_matrix_pop_projection(); + wmWindowViewport(win); } else { @@ -1293,16 +1294,16 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused)) imm_draw_circle_wire_3d(pos3d, translation[0], translation[1], final_radius, 40); } } else { - if (vc.obact->sculpt->cache) { + if (vc.obact->sculpt->cache && !vc.obact->sculpt->cache->first_time) { SculptSession *ss = vc.obact->sculpt; wmViewport(>winrct); - wmOrtho2_pixelspace(ar->winx, ar->winy); float cursor_location[3]; copy_v3_v3(cursor_location, ss->cache->true_location); if (ss->cache->brush->sculpt_tool == SCULPT_TOOL_GRAB) { add_v3_v3(cursor_location, ss->cache->grab_delta); } cursor_draw_point_with_symmetry(pos3d, ar, cursor_location, sd, vc.obact, vc.rv3d->persmat, ss->cache->radius); + wmWindowViewport(win); } } } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [378baee4986] sculpt-mode-features: Dam brush: Initial implementation
Commit: 378baee4986e3ce27dae6d348a6111ec041f6b20 Author: Pablo Dobarro Date: Mon Mar 18 04:36:35 2019 +0100 Branches: sculpt-mode-features https://developer.blender.org/rB378baee4986e3ce27dae6d348a6111ec041f6b20 Dam brush: Initial implementation The purpose of this brush is to create sharp edges without creasing or pinching the geometry. It is useful when sculpting cloth wrinkles, hard surface objects or small cavities. To avoid artifacts, set the stroke spacing to a lower value than 10 and enable symmetry feather. This affects performance, so I am not adding it to the defaults for now. It does not create new geometry in dyntopo, so you will need to create the geometry with another tool or switch to the voxel remesher workflow. I'm not quite happy with the deformation as it is now (maybe it is too smooth). I also need to try the brush with different pen tablets to properly calibrate the pressure. === M source/blender/blenkernel/intern/brush.c M source/blender/editors/sculpt_paint/sculpt.c M source/blender/makesdna/DNA_brush_types.h M source/blender/makesrna/intern/rna_brush.c === diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index 0c9ecc55c0b..c284f7ed5d1 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -1190,7 +1190,7 @@ bool BKE_brush_sculpt_has_secondary_color(const Brush *brush) SCULPT_TOOL_INFLATE, SCULPT_TOOL_CLAY, SCULPT_TOOL_CLAY_STRIPS, SCULPT_TOOL_PINCH, SCULPT_TOOL_CREASE, SCULPT_TOOL_LAYER, SCULPT_TOOL_FLATTEN, SCULPT_TOOL_FILL, SCULPT_TOOL_SCRAPE, - SCULPT_TOOL_MASK); + SCULPT_TOOL_MASK, SCULPT_TOOL_DAM); } void BKE_brush_unprojected_radius_set(Scene *scene, Brush *brush, float unprojected_radius) diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 927012f6062..3c626380289 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -154,6 +154,7 @@ static int sculpt_brush_needs_normal( SCULPT_TOOL_BLOB, SCULPT_TOOL_CREASE, SCULPT_TOOL_DRAW, +SCULPT_TOOL_DAM, SCULPT_TOOL_LAYER, SCULPT_TOOL_NUDGE, SCULPT_TOOL_ROTATE, @@ -1155,7 +1156,8 @@ static float brush_strength( case SCULPT_TOOL_DRAW: case SCULPT_TOOL_LAYER: return alpha * flip * pressure * overlap * feather; - + case SCULPT_TOOL_DAM: + return alpha * flip * 4 * pressure * overlap * feather; case SCULPT_TOOL_MASK: overlap = (1 + overlap) / 2; switch ((BrushMaskTool)brush->mask_tool) { @@ -1301,6 +1303,13 @@ float tex_strength(SculptSession *ss, const Brush *br, avg *= (1 - factor); avg *= 0.5f; break; + case SCULPT_TOOL_DAM: + dist_nrm = len/cache->radius; + dist_nrm = 1 - dist_nrm; + factor = dist_nrm * dist_nrm * dist_nrm * dist_nrm; + factor = 1 - factor; + avg *= (1 - factor); + avg *= -2; default: avg *= BKE_brush_curve_strength(br, len, cache->radius); break; @@ -2347,6 +2356,78 @@ static void do_draw_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode) ); } +static void do_dam_brush_task_cb_ex( +void *__restrict userdata, +const int n, +const ParallelRangeTLS *__restrict tls) +{ + SculptThreadedTaskData *data = userdata; + SculptSession *ss = data->ob->sculpt; + const Brush *brush = data->brush; + const float *offset = data->offset; + + PBVHVertexIter vd; + float (*proxy)[3]; + + proxy = BKE_pbvh_node_add_proxy(ss->pbvh, data->nodes[n])->co; + + SculptOrigVertData orig_data; + sculpt_orig_vert_data_init(_data, data->ob, data->nodes[n]); + + SculptBrushTest test; + SculptBrushTestFn sculpt_brush_test_sq_fn = + sculpt_brush_test_init_with_falloff_shape(ss, , data->brush->falloff_shape); + + BKE_pbvh_vertex_iter_begin(ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE) + { + sculpt_orig_vert_data_update(_data, ); + if (sculpt_brush_test_sq_fn(, orig_data.co)) { + /* offset vertex */ + const float fade = tex_strength( +
[Bf-blender-cvs] [d55ea7bf811] sculpt-mode-features: New sculpt brush cursor with normal radius
Commit: d55ea7bf8115f7b14a384d69729a6cade94174e4 Author: Pablo Dobarro Date: Wed Mar 13 16:18:30 2019 +0100 Branches: sculpt-mode-features https://developer.blender.org/rBd55ea7bf8115f7b14a384d69729a6cade94174e4 New sculpt brush cursor with normal radius >From D3594 === M release/scripts/startup/bl_ui/space_view3d_toolbar.py M source/blender/blenkernel/BKE_paint.h M source/blender/blenkernel/BKE_pbvh.h M source/blender/blenkernel/intern/pbvh.c M source/blender/blenkernel/intern/pbvh_bmesh.c M source/blender/blenkernel/intern/pbvh_intern.h M source/blender/editors/sculpt_paint/paint_cursor.c M source/blender/editors/sculpt_paint/paint_vertex.c M source/blender/editors/sculpt_paint/sculpt.c M source/blender/editors/sculpt_paint/sculpt_intern.h M source/blender/makesdna/DNA_brush_types.h M source/blender/makesrna/intern/rna_brush.c === diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py index 22571080628..8ae36617c03 100644 --- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py +++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py @@ -270,6 +270,11 @@ class VIEW3D_PT_tools_brush(Panel, View3DPaintPanel): if not self.is_popover: brush_basic_sculpt_settings(col, context, brush) +# normal_radius_factor +col.separator() +row = col.row() +row.prop(brush, "normal_radius_factor", slider=True) + # topology_rake_factor if (capabilities.has_topology_rake and context.sculpt_object.use_dynamic_topology_sculpting diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h index cc445413f61..e297240157b 100644 --- a/source/blender/blenkernel/BKE_paint.h +++ b/source/blender/blenkernel/BKE_paint.h @@ -61,6 +61,7 @@ struct SubdivCCG; enum eOverlayFlags; #include "DNA_object_enums.h" +#include "DNA_view3d_types.h" extern const char PAINT_CURSOR_SCULPT[3]; extern const char PAINT_CURSOR_VERTEX_PAINT[3]; @@ -246,6 +247,13 @@ typedef struct SculptSession { struct StrokeCache *cache; + float cursor_radius; + float cursor_location[3]; + float cursor_view_normal[3]; + float cursor_normal[3]; + + RegionView3D *rv3d; + union { struct { struct SculptVertexPaintGeomMap gmap; diff --git a/source/blender/blenkernel/BKE_pbvh.h b/source/blender/blenkernel/BKE_pbvh.h index 87d1a6c6915..73803df30ef 100644 --- a/source/blender/blenkernel/BKE_pbvh.h +++ b/source/blender/blenkernel/BKE_pbvh.h @@ -99,7 +99,7 @@ void BKE_pbvh_raycast( bool BKE_pbvh_node_raycast( PBVH *bvh, PBVHNode *node, float (*origco)[3], bool use_origco, const float ray_start[3], const float ray_normal[3], -float *depth); +float *depth, float* normal, float *nearest_vertex_co); bool BKE_pbvh_bmesh_node_raycast_detail( PBVHNode *node, diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.c index 7dc772576c5..a8ce32d6d77 100644 --- a/source/blender/blenkernel/intern/pbvh.c +++ b/source/blender/blenkernel/intern/pbvh.c @@ -1544,9 +1544,9 @@ bool ray_face_intersection_quad( float depth_test; if ((isect_ray_tri_epsilon_v3( -ray_start, ray_normal, t0, t1, t2, _test, NULL, 0.1f) && (depth_test < *depth)) || +ray_start, ray_normal, t0, t1, t2, _test, NULL, 0.0f) && (depth_test < *depth)) || (isect_ray_tri_epsilon_v3( -ray_start, ray_normal, t0, t2, t3, _test, NULL, 0.1f) && (depth_test < *depth))) +ray_start, ray_normal, t0, t2, t3, _test, NULL, 0.0f) && (depth_test < *depth))) { *depth = depth_test; return true; @@ -1564,7 +1564,7 @@ bool ray_face_intersection_tri( float depth_test; if ((isect_ray_tri_epsilon_v3( -ray_start, ray_normal, t0, t1, t2, _test, NULL, 0.1f) && (depth_test < *depth))) +ray_start, ray_normal, t0, t1, t2, _test, NULL, 0.0f) && (depth_test < *depth))) { *depth = depth_test; return true; @@ -1646,14 +1646,16 @@ static bool pbvh_faces_node_raycast( PBVH *bvh, const PBVHNode *node, float (*origco)[3], const float ray_start[3], const float ray_normal[3], -float *depth) +float *depth, float *normal, float *nearest_vertex_co) { const MVert *vert = bvh->verts; const MLoop *mloop = bvh->mloop; const int *faces = node->prim_indices; int i, to
[Bf-blender-cvs] [93366949165] sculpt-mode-features: Add defaults and versioning to normal radius
Commit: 93366949165394a2309c5bc2d8c6204326727716 Author: Pablo Dobarro Date: Wed Mar 13 16:32:25 2019 +0100 Branches: sculpt-mode-features https://developer.blender.org/rB93366949165394a2309c5bc2d8c6204326727716 Add defaults and versioning to normal radius Patch by @jmztn === M source/blender/blenkernel/intern/brush.c M source/blender/blenloader/intern/versioning_280.c === diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index e0823e98207..0c9ecc55c0b 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -71,6 +71,7 @@ static void brush_defaults(Brush *brush) brush->size = 35; /* radius of the brush in pixels */ brush->alpha = 0.5f; /* brush strength/intensity probably variable should be renamed? */ brush->autosmooth_factor = 0.0f; + brush->normal_radius_factor = 0.2f; brush->topology_rake_factor = 0.0f; brush->crease_pinch_factor = 0.5f; brush->sculpt_plane = SCULPT_DISP_DIR_AREA; diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c index 98277bab2a3..c46b8fa2518 100644 --- a/source/blender/blenloader/intern/versioning_280.c +++ b/source/blender/blenloader/intern/versioning_280.c @@ -2892,6 +2892,13 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) "Filmic"); } } + + Brush *br; + for (br = bmain->brushes.first; br; br = br->id.next) { + if (br->ob_mode & OB_MODE_SCULPT) { + br->normal_radius_factor = 0.2f; + } + } } { ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [72c42642776] sculpt-mode-features: Brush Cursor: show minimal mouse cursor by default
Commit: 72c42642776f1f09746bf5c7fbd3a4654ad97207 Author: Pablo Dobarro Date: Wed Mar 13 17:34:04 2019 +0100 Branches: sculpt-mode-features https://developer.blender.org/rB72c42642776f1f09746bf5c7fbd3a4654ad97207 Brush Cursor: show minimal mouse cursor by default The brush cursor is disabled when manipulating the viewport, so you would not have any mouse feedback if the mouse cursor is completely disabled. This also displays the cursor position without relying on internal brush updates when the stroke is active. === M source/blender/editors/sculpt_paint/paint_cursor.c === diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c index b39cac8ff05..c9880ae3af1 100644 --- a/source/blender/editors/sculpt_paint/paint_cursor.c +++ b/source/blender/editors/sculpt_paint/paint_cursor.c @@ -1187,10 +1187,10 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused)) wmWindow *win = CTX_wm_window(C); if (sd->paint.brush->overlay_flags & BRUSH_OVERLAY_CURSOR) { - WM_cursor_set(win, CURSOR_EDIT); + WM_cursor_set(win, CURSOR_STD); } else { - WM_cursor_set(win, CURSOR_NONE); + WM_cursor_set(win, CURSOR_EDIT); } if (!ups->stroke_active) { StrokeGeometryInfo gi; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [91d16ceb56a] sculpt-mode-features: View Navigation: 2D viewport panning
Commit: 91d16ceb56aa6a1d04111424bc18c902b23d5a44 Author: Pablo Dobarro Date: Wed Mar 13 17:26:54 2019 +0100 Branches: sculpt-mode-features https://developer.blender.org/rB91d16ceb56aa6a1d04111424bc18c902b23d5a44 View Navigation: 2D viewport panning This option helps to keep the working area under control when working with brushes, especially if this feature is used with rotate around selection enabled. Now, panning speed does not depend on zoom level and it behaves more similarly to a 2D environment. The option certainly needs a better name and description, and it could be a good idea to hide and disable it if rotate around selection is disabled. Mode info: D3931 === M release/scripts/startup/bl_ui/space_userpref.py M source/blender/editors/space_view3d/view3d_edit.c M source/blender/makesdna/DNA_userdef_types.h M source/blender/makesrna/intern/rna_userdef.c === diff --git a/release/scripts/startup/bl_ui/space_userpref.py b/release/scripts/startup/bl_ui/space_userpref.py index c11a802c90f..812b1590400 100644 --- a/release/scripts/startup/bl_ui/space_userpref.py +++ b/release/scripts/startup/bl_ui/space_userpref.py @@ -1405,6 +1405,7 @@ class USERPREF_PT_navigation_orbit(PreferencePanel, Panel): flow.prop(inputs, "use_rotate_around_active") flow.prop(inputs, "use_auto_perspective") flow.prop(inputs, "use_mouse_depth_navigate") +flow.prop(inputs, "use_2d_viewport_panning") if sys.platform == "darwin": flow.prop(inputs, "use_trackpad_natural", text="Natural Trackpad Direction") diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 005e78fbc1a..b9a2be2d6ef 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -125,6 +125,7 @@ static void view3d_operator_properties_common(wmOperatorType *ot, const enum eV3 typedef struct ViewOpsData { /** Context pointers (assigned by #viewops_data_alloc). */ Main *bmain; + bContext *C; Scene *scene; ScrArea *sa; ARegion *ar; @@ -499,7 +500,7 @@ static void viewops_data_create( negate_v3_v3(tvec, rv3d->ofs); vod->init.zfac = ED_view3d_calc_zfac(rv3d, tvec, NULL); } - + vod->C = C; vod->reverse = 1.0f; if (rv3d->persmat[2][1] < 0.0f) vod->reverse = -1.0f; @@ -1615,11 +1616,26 @@ static void viewmove_apply(ViewOpsData *vod, int x, int y) } else { float dvec[3]; - float mval_f[2]; - mval_f[0] = x - vod->prev.event_xy[0]; - mval_f[1] = y - vod->prev.event_xy[1]; - ED_view3d_win_to_delta(vod->ar, mval_f, dvec, vod->init.zfac); + if (U.uiflag2 & USER_2D_VIEWPORT_PANNING) { + float nvec[3]; + float center[3]; + float ssdp[3]; + + view3d_orbit_calc_center(vod->C,center); + ED_view3d_project(vod->ar, center, ssdp); + ssdp[0] = ssdp[0] + x - vod->prev.event_xy[0]; + ssdp[1] = ssdp[1] + y - vod->prev.event_xy[1]; + ED_view3d_win_to_3d(vod->v3d, vod->ar, center, ssdp, nvec); + sub_v3_v3v3(dvec, nvec, center); + } + else { + float mval_f[2]; + + mval_f[0] = x - vod->prev.event_xy[0]; + mval_f[1] = y - vod->prev.event_xy[1]; + ED_view3d_win_to_delta(vod->ar, mval_f, dvec, vod->init.zfac); + } add_v3_v3(vod->rv3d->ofs, dvec); diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index 048b7e60d57..5950ceac41b 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -900,6 +900,7 @@ typedef enum eUserpref_UI_Flag2 { USER_REGION_OVERLAP = (1 << 1), USER_TRACKPAD_NATURAL = (1 << 2), USER_EDIT_MODE_SMOOTH_WIRE = (1 << 3), + USER_2D_VIEWPORT_PANNING= (1 << 4), } eUserpref_UI_Flag2; /** #UserDef.tablet_api */ diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index dda36d89eb1..3d57837babe 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -4679,6 +4679,11 @@ static void rna_def_userdef_input(BlenderRNA *brna)
[Bf-blender-cvs] [b342c293a93] sculpt-mode-features: Grab Brush: Use smooth curve deformation
Commit: b342c293a93fcd572f20a62803bedc3323ccb496 Author: Pablo Dobarro Date: Wed Mar 13 18:09:37 2019 +0100 Branches: sculpt-mode-features https://developer.blender.org/rBb342c293a93fcd572f20a62803bedc3323ccb496 Grab Brush: Use smooth curve deformation For now, this ignores the brush curve. The brush curve does't make sense in some brushes and in other ones it should be optional (like in the grab brush). This needs design to integrate with the UI. === M 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 792defa27fa..927012f6062 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -1293,7 +1293,18 @@ float tex_strength(SculptSession *ss, const Brush *br, } /* Falloff curve */ - avg *= BKE_brush_curve_strength(br, len, cache->radius); + float dist_nrm, factor; + switch (br->sculpt_tool) { + case SCULPT_TOOL_GRAB: + dist_nrm = len/cache->radius; + factor = 3.0f * dist_nrm * dist_nrm - 2.0f * dist_nrm * dist_nrm * dist_nrm; + avg *= (1 - factor); + avg *= 0.5f; + break; + default: + avg *= BKE_brush_curve_strength(br, len, cache->radius); + break; + } avg *= frontface(br, cache->view_normal, vno, fno); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [00f2700b751] sculpt-mode-features: Merge branch 'master' into sculpt-mode-features
Commit: 00f2700b75128bee352572d6f34e096b5c26ddab Author: Pablo Dobarro Date: Mon Mar 18 17:30:19 2019 +0100 Branches: sculpt-mode-features https://developer.blender.org/rB00f2700b75128bee352572d6f34e096b5c26ddab Merge branch 'master' into sculpt-mode-features === === diff --cc source/blender/blenloader/intern/versioning_280.c index c46b8fa2518,986f35008bd..47a69ff7f63 --- a/source/blender/blenloader/intern/versioning_280.c +++ b/source/blender/blenloader/intern/versioning_280.c @@@ -2892,16 -2897,28 +2897,35 @@@ void blo_do_versions_280(FileData *fd, "Filmic"); } } + + Brush *br; + for (br = bmain->brushes.first; br; br = br->id.next) { + if (br->ob_mode & OB_MODE_SCULPT) { + br->normal_radius_factor = 0.2f; + } + } } + if (!MAIN_VERSION_ATLEAST(bmain, 280, 49)) { + /* All tool names changed, reset to defaults. */ + for (WorkSpace *workspace = bmain->workspaces.first; workspace; workspace = workspace->id.next) { + while (!BLI_listbase_is_empty(>tools)) { + BKE_workspace_tool_remove(workspace, workspace->tools.first); + } + } + } + { /* Versioning code until next subversion bump goes here. */ + + LISTBASE_FOREACH (ParticleSettings *, part, >particles) { + /* Replace deprecated PART_DRAW_BB by PART_DRAW_NOT */ + if (part->ren_as == PART_DRAW_BB) { + part->ren_as = PART_DRAW_NOT; + } + if (part->draw_as == PART_DRAW_BB) { + part->draw_as = PART_DRAW_NOT; + } + } } } diff --cc source/blender/editors/object/object_edit.c index aacd694f530,1964cd53cc7..7a807206bda --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@@ -78,9 -77,8 +78,10 @@@ #include "BKE_softbody.h" #include "BKE_editmesh.h" #include "BKE_report.h" + #include "BKE_scene.h" #include "BKE_workspace.h" +#include "BKE_mesh_runtime.h" +#include "BKE_library.h" #include "DEG_depsgraph.h" #include "DEG_depsgraph_build.h" diff --cc source/blender/makesdna/DNA_userdef_types.h index 5950ceac41b,1da28b4aa2d..6d4a4158f87 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@@ -894,15 -897,21 +897,22 @@@ typedef enum eUserpref_UI_Flag USER_HIDE_SYSTEM_BOOKMARKS = (1u << 31), } eUserpref_UI_Flag; - /** #UserDef.uiflag2 */ + /** #UserDef.uiflag2 + * + * \note don't add new flags here, use 'uiflag' which has flags free. */ typedef enum eUserpref_UI_Flag2 { - USER_UIFLAG2_DEPRECATED_0 = (1 << 0), - USER_REGION_OVERLAP = (1 << 1), - USER_TRACKPAD_NATURAL = (1 << 2), - USER_EDIT_MODE_SMOOTH_WIRE = (1 << 3), - USER_2D_VIEWPORT_PANNING= (1 << 4), - USER_UIFLAG2_UNUSED_0 = (1 << 0), /* cleared */ ++ USER_UIFLAG2_UNUSED_0 = (1 << 0), + USER_REGION_OVERLAP = (1 << 1), + USER_TRACKPAD_NATURAL = (1 << 2), - USER_UIFLAG2_UNUSED_3 = (1 << 3), /* dirty */ ++ USER_UIFLAG2_UNUSED_3 = (1 << 3), ++ USER_2D_VIEWPORT_PANNING= (1 << 4), } eUserpref_UI_Flag2; + typedef enum eUserpref_GPU_Flag { + USER_GPU_FLAG_NO_DEPT_PICK = (1 << 0), + USER_GPU_FLAG_NO_EDIT_MODE_SMOOTH_WIRE = (1 << 1), + } eUserpref_GPU_Flag; + /** #UserDef.tablet_api */ typedef enum eUserpref_TableAPI { USER_TABLET_AUTOMATIC = 0, ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [af8fe4e94e7] sculpt-mode-features: Voxel remesher: Add support for undo from sculpt mode
Commit: af8fe4e94e79baf2830a6766781d21fe60bc06c2 Author: Pablo Dobarro Date: Tue Mar 19 23:07:22 2019 +0100 Branches: sculpt-mode-features https://developer.blender.org/rBaf8fe4e94e79baf2830a6766781d21fe60bc06c2 Voxel remesher: Add support for undo from sculpt mode Only undo for now, no redo. This will need a lot of work and refactoring in the future (it has a lot of bugs), but now it is safer to test new features without losing work. === M source/blender/editors/object/CMakeLists.txt M source/blender/editors/object/object_edit.c M source/blender/editors/sculpt_paint/sculpt_intern.h M source/blender/editors/sculpt_paint/sculpt_undo.c === diff --git a/source/blender/editors/object/CMakeLists.txt b/source/blender/editors/object/CMakeLists.txt index 3211784e126..90294bc6f67 100644 --- a/source/blender/editors/object/CMakeLists.txt +++ b/source/blender/editors/object/CMakeLists.txt @@ -33,6 +33,7 @@ set(INC ../../python ../../render/extern/include ../../windowmanager + ../sculpt_paint ../../../../intern/guardedalloc ../../../../intern/glew-mx ) diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 7a807206bda..ba1c07c24b6 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -113,6 +113,7 @@ #include "WM_toolsystem.h" #include "object_intern.h" // own include +#include "sculpt_intern.h" #ifdef WITH_OPENVDB #include "openvdb_capi.h" @@ -1764,6 +1765,20 @@ static int remesh_exec(bContext *C, wmOperator *op) } if (ob->type == OB_MESH) { + + if (ob->mode == OB_MODE_SCULPT) { + Depsgraph *depsgraph = CTX_data_depsgraph(C); + struct Scene *scene = CTX_data_scene(C); + Sculpt *sd = CTX_data_tool_settings(C)->sculpt; + BKE_sculpt_update_mesh_elements(depsgraph, scene, sd, ob, true, true); + PBVH *pbvh; + PBVHNode **nodes; + int totnode; + pbvh = ob->sculpt->pbvh; + BKE_pbvh_search_gather(pbvh, NULL, NULL, , ); + sculpt_undo_push_begin("voxel remesh"); + sculpt_undo_push_node(ob, nodes[0], SCULPT_UNDO_REMESH); + } Mesh *mesh = ob->data; BKE_mesh_runtime_looptri_recalc(mesh); const MLoopTri *looptri = BKE_mesh_runtime_looptri_ensure(mesh); @@ -1816,6 +1831,9 @@ static int remesh_exec(bContext *C, wmOperator *op) if (RNA_boolean_get(op->ptr, "smooth_normals")) { BKE_mesh_smooth_flag_set(ob, true); } + if (ob->mode == OB_MODE_SCULPT) { + sculpt_undo_push_end(); + } BKE_mesh_batch_cache_dirty_tag(ob->data, BKE_MESH_BATCH_DIRTY_ALL); DEG_relations_tag_update(bmain); @@ -1828,7 +1846,6 @@ static int remesh_exec(bContext *C, wmOperator *op) MEM_freeN(verttri); MEM_freeN(rmd.out_verts); MEM_freeN(rmd.out_faces); - return OPERATOR_FINISHED; } return OPERATOR_CANCELLED; diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h b/source/blender/editors/sculpt_paint/sculpt_intern.h index bc1462cbb7e..acc5d60df20 100644 --- a/source/blender/editors/sculpt_paint/sculpt_intern.h +++ b/source/blender/editors/sculpt_paint/sculpt_intern.h @@ -28,11 +28,13 @@ #include "DNA_listBase.h" #include "DNA_vec_types.h" #include "DNA_key_types.h" +#include "DNA_mesh_types.h" #include "BLI_bitmap.h" #include "BLI_threads.h" #include "BKE_pbvh.h" +#include "BKE_mesh.h" struct KeyBlock; struct Object; @@ -83,6 +85,7 @@ typedef enum { SCULPT_UNDO_DYNTOPO_BEGIN, SCULPT_UNDO_DYNTOPO_END, SCULPT_UNDO_DYNTOPO_SYMMETRIZE, + SCULPT_UNDO_REMESH, } SculptUndoType; typedef struct SculptUndoNode { @@ -126,6 +129,17 @@ typedef struct SculptUndoNode { /* shape keys */ char shapeName[sizeof(((KeyBlock *)0))->name]; + /* remesh operations */ + bool remesh_applied; + CustomData remesh_vdata; + CustomData remesh_edata; + CustomData remesh_ldata; + CustomData remesh_pdata; + int remesh_totvert; + int remesh_totedge; + int remesh_totloop; + int remesh_totpoly; + size_t undo_size; } SculptUndoNode; diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/
[Bf-blender-cvs] [726773588cc] sculpt-mode-features: Voxel Remesher: Add remesher parameters to mesh datablock
Commit: 726773588cc15be80f9298bd7f0e4039dddea995 Author: Pablo Dobarro Date: Wed Mar 20 03:34:07 2019 +0100 Branches: sculpt-mode-features https://developer.blender.org/rB726773588cc15be80f9298bd7f0e4039dddea995 Voxel Remesher: Add remesher parameters to mesh datablock I tested several UI integrations: -Running the remesher from an operator and adjusting the parameters with the redo panel freezes the interface with high-res meshes. It looks cool, but it is not that useful. -Integrating it into a tool does not store per object remesh configurations. It also forces the user to switch the tool when he/she is sculpting just to recalculate the topology. Storing the remesher options per mesh is the best option I found. Now, the remesher is found in the properties panel under the mesh tab. The user can assign it to the quick favorites menu or add a keyboard shortcut. Remesher parameters can be adjusted there. They are stored per mesh. This way, remesher parameters of each mesh are preserved when sculpting different objects at different levels of details. In the future, the user will be able to choose different remeshing algorithms (triangulation, quadriflow...) from there and assign them to the mesh. All of them will be executed by the same remesh operator and some of them will share some options (like smooth normals). === M release/scripts/startup/bl_ui/properties_data_mesh.py M source/blender/blenloader/intern/versioning_280.c M source/blender/editors/mesh/editmesh_add.c M source/blender/editors/object/object_edit.c M source/blender/makesdna/DNA_mesh_types.h M source/blender/makesrna/intern/rna_mesh.c === diff --git a/release/scripts/startup/bl_ui/properties_data_mesh.py b/release/scripts/startup/bl_ui/properties_data_mesh.py index eacf027c491..de178496c56 100644 --- a/release/scripts/startup/bl_ui/properties_data_mesh.py +++ b/release/scripts/startup/bl_ui/properties_data_mesh.py @@ -454,6 +454,22 @@ class DATA_PT_vertex_colors(MeshButtonsPanel, Panel): col.operator("mesh.vertex_color_remove", icon='REMOVE', text="") +class DATA_PT_remesh(MeshButtonsPanel, Panel): +bl_label = "Remesh" +bl_options = {'DEFAULT_CLOSED'} +COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'} + +def draw(self, context): +layout = self.layout +layout.use_property_split = True +col = layout.column() + +mesh = context.mesh +col.prop(mesh, "voxel_size") +col.prop(mesh, "smooth_normals") +col.operator("object.remesh", text="Remesh") + + class DATA_PT_customdata(MeshButtonsPanel, Panel): bl_label = "Geometry Data" bl_options = {'DEFAULT_CLOSED'} @@ -503,6 +519,7 @@ classes = ( DATA_PT_uv_texture, DATA_PT_vertex_colors, DATA_PT_face_maps, +DATA_PT_remesh, DATA_PT_normals, DATA_PT_normals_auto_smooth, DATA_PT_texture_space, diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c index 47a69ff7f63..ff95e094ea4 100644 --- a/source/blender/blenloader/intern/versioning_280.c +++ b/source/blender/blenloader/intern/versioning_280.c @@ -2927,5 +2927,11 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) part->draw_as = PART_DRAW_NOT; } } + + if (!DNA_struct_elem_find(fd->filesdna, "Mesh", "float", "voxel_size")) { + for (Mesh *me = bmain->meshes.first; me; me = me->id.next) { + me->voxel_size = 0.1f; + } + } } } diff --git a/source/blender/editors/mesh/editmesh_add.c b/source/blender/editors/mesh/editmesh_add.c index aca8fac8bf7..7cbd17c0aa7 100644 --- a/source/blender/editors/mesh/editmesh_add.c +++ b/source/blender/editors/mesh/editmesh_add.c @@ -27,11 +27,13 @@ #include "DNA_meshdata_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" +#include "DNA_mesh_types.h" #include "BLT_translation.h" #include "BKE_context.h" #include "BKE_editmesh.h" +#include "BKE_mesh.h" #include "RNA_define.h" #include "RNA_access.h" @@ -94,6 +96,10 @@ static void make_prim_finish(bContext *C, Object *obedit, const MakePrimitiveDat /* userdef */ if (exit_editmode) { ED_object_editmode_exit(C, EM_FREEDATA); + //TODO: Find a better place to init this + Mesh *me; + me = obedit->data; + me->voxel_size = 0.1f; } WM_e
[Bf-blender-cvs] [55d482bf405] sculpt-mode-features: Mask tools: Fix crash with dyntopo and lasso mask
Commit: 55d482bf405076bb2715072f67e5c15edf5bee92 Author: Pablo Dobarro Date: Wed Mar 20 20:35:28 2019 +0100 Branches: sculpt-mode-features https://developer.blender.org/rB55d482bf405076bb2715072f67e5c15edf5bee92 Mask tools: Fix crash with dyntopo and lasso mask Ignore the front facing option with dyntopo. I will properly fix this later. === M source/blender/editors/sculpt_paint/paint_mask.c === diff --git a/source/blender/editors/sculpt_paint/paint_mask.c b/source/blender/editors/sculpt_paint/paint_mask.c index c08ae425395..19be5da7aa3 100644 --- a/source/blender/editors/sculpt_paint/paint_mask.c +++ b/source/blender/editors/sculpt_paint/paint_mask.c @@ -394,13 +394,15 @@ static void mask_gesture_lasso_task_cb( const float value = data->value; PBVHVertexIter vi; - float vertex_normal[3]; + float vertex_normal[3], dp = 1; bool any_masked = false; BKE_pbvh_vertex_iter_begin(data->pbvh, node, vi, PBVH_ITER_UNIQUE) { - normal_short_to_float_v3(vertex_normal, vi.no); - float dp = dot_v3v3(lasso_data->task_data.viewDir, vertex_normal); - if (!lasso_data->task_data.front_faces_only) dp = 1; + if (BKE_pbvh_type(data->pbvh) == PBVH_FACES){ + normal_short_to_float_v3(vertex_normal, vi.no); + dp = dot_v3v3(lasso_data->task_data.viewDir, vertex_normal); + if (!lasso_data->task_data.front_faces_only) dp = 1; + } if (is_effected_lasso(lasso_data, vi.co) && dp > 0) { if (!any_masked) { any_masked = true; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [75b1f625dd6] sculpt-mode-features: Mask tools: Option to mask only front faces with lasso mask
Commit: 75b1f625dd684c2a04d0b647a6e866f052b3fb90 Author: Pablo Dobarro Date: Tue Mar 19 02:13:59 2019 +0100 Branches: sculpt-mode-features https://developer.blender.org/rB75b1f625dd684c2a04d0b647a6e866f052b3fb90 Mask tools: Option to mask only front faces with lasso mask It still needs to be added to the keymap or as a tool setting. === M source/blender/editors/sculpt_paint/paint_mask.c === diff --git a/source/blender/editors/sculpt_paint/paint_mask.c b/source/blender/editors/sculpt_paint/paint_mask.c index 2f9706db636..c08ae425395 100644 --- a/source/blender/editors/sculpt_paint/paint_mask.c +++ b/source/blender/editors/sculpt_paint/paint_mask.c @@ -93,6 +93,9 @@ typedef struct MaskTaskData { PaintMaskFloodMode mode; float value; float (*clip_planes_final)[4]; + bool front_faces_only; + float trueViewDir[3]; + float viewDir[3]; } MaskTaskData; static void mask_flood_fill_task_cb( @@ -391,10 +394,14 @@ static void mask_gesture_lasso_task_cb( const float value = data->value; PBVHVertexIter vi; + float vertex_normal[3]; bool any_masked = false; BKE_pbvh_vertex_iter_begin(data->pbvh, node, vi, PBVH_ITER_UNIQUE) { - if (is_effected_lasso(lasso_data, vi.co)) { + normal_short_to_float_v3(vertex_normal, vi.no); + float dp = dot_v3v3(lasso_data->task_data.viewDir, vertex_normal); + if (!lasso_data->task_data.front_faces_only) dp = 1; + if (is_effected_lasso(lasso_data, vi.co) && dp > 0) { if (!any_masked) { any_masked = true; @@ -460,6 +467,20 @@ static int paint_mask_gesture_lasso_exec(bContext *C, wmOperator *op) sculpt_undo_push_begin("Mask lasso fill"); + data.task_data.front_faces_only = RNA_boolean_get(op->ptr, "front_faces_only"); + float imat[4][4]; + float mat[4][4]; + float viewDir[3] = {0.0f, 0.0f, 1.0f}; + if (data.task_data.front_faces_only) { + invert_m4_m4(imat, ob->obmat); + copy_m3_m4(mat, vc.rv3d->viewinv); + mul_m3_v3(mat, viewDir); + copy_m3_m4(mat, ob->imat); + mul_m3_v3(mat, viewDir); + normalize_v3_v3(data.task_data.viewDir, viewDir); + copy_v3_v3(data.task_data.trueViewDir, data.task_data.viewDir); + } + for (symmpass = 0; symmpass <= symm; ++symmpass) { if ((symmpass == 0) || (symm & symmpass && @@ -471,6 +492,7 @@ static int paint_mask_gesture_lasso_exec(bContext *C, wmOperator *op) /* flip the planes symmetrically as needed */ for (; j < 4; j++) { flip_plane(clip_planes_final[j], clip_planes[j], symmpass); + flip_v3_v3(data.task_data.viewDir, data.task_data.trueViewDir, symmpass); } data.symmpass = symmpass; @@ -534,4 +556,5 @@ void PAINT_OT_mask_lasso_gesture(wmOperatorType *ot) RNA_def_enum(ot->srna, "mode", mode_items, PAINT_MASK_FLOOD_VALUE, "Mode", NULL); RNA_def_float(ot->srna, "value", 1.0, 0, 1.0, "Value", "Mask level to use when mode is 'Value'; zero means no masking and one is fully masked", 0, 1); + RNA_def_boolean(ot->srna, "front_faces_only", true, "Front faces only", "Affect only faces facing towards the view"); } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [2bf0495d5cd] sculpt-mode-features: Voxel remesher: add option to smooth normals when remeshing
Commit: 2bf0495d5cd263206c9016e94c259a5707488441 Author: Pablo Dobarro Date: Fri Mar 15 00:35:31 2019 +0100 Branches: sculpt-mode-features https://developer.blender.org/rB2bf0495d5cd263206c9016e94c259a5707488441 Voxel remesher: add option to smooth normals when remeshing === M source/blender/editors/object/object_edit.c === diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 88cdb74ac71..aacd694f530 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -1808,6 +1808,11 @@ static int remesh_exec(bContext *C, wmOperator *op) BKE_mesh_convert_mfaces_to_mpolys(newMesh); BKE_mesh_calc_normals(newMesh); BKE_mesh_nomain_to_mesh(newMesh, ob->data, ob, _MASK_EVERYTHING, true); + + if (RNA_boolean_get(op->ptr, "smooth_normals")) { + BKE_mesh_smooth_flag_set(ob, true); + } + BKE_mesh_batch_cache_dirty_tag(ob->data, BKE_MESH_BATCH_DIRTY_ALL); DEG_relations_tag_update(bmain); DEG_id_tag_update(>id, ID_RECALC_GEOMETRY); @@ -1845,4 +1850,6 @@ void OBJECT_OT_remesh(wmOperatorType *ot) RNA_def_property_float_default(prop, 0.1f); RNA_def_property_ui_range(prop, 0.0001, 1, 0.01, 4); RNA_def_property_ui_text(prop, "Voxel Size", "Voxel size used for volume evaluation"); + + prop = RNA_def_boolean(ot->srna, "smooth_normals", false, "Shade smooth", "Smooth normals on the resulting mesh"); } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [b88ba401830] sculpt-mode-features: Brush cursor: Fix bug in tiling preview
Commit: b88ba401830f506bb5d526c7ddbbada94185d7fd Author: Pablo Dobarro Date: Sat Mar 16 03:05:03 2019 +0100 Branches: sculpt-mode-features https://developer.blender.org/rBb88ba401830f506bb5d526c7ddbbada94185d7fd Brush cursor: Fix bug in tiling preview === M source/blender/editors/sculpt_paint/paint_cursor.c === diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c index b4633a0a3fd..317e037ad95 100644 --- a/source/blender/editors/sculpt_paint/paint_cursor.c +++ b/source/blender/editors/sculpt_paint/paint_cursor.c @@ -1045,12 +1045,13 @@ static bool ommit_cursor_drawing(Paint *paint, ePaintMode mode, Brush *brush) return true; } -void cursor_draw_point_screen_space(const uint gpuattr, const ARegion *ar, float location[3], +void cursor_draw_point_screen_space(const uint gpuattr, const ARegion *ar, float true_location[3], float obmat[4][4], float persmat[4][4]) { float ar_width = ar->winrct.xmax - ar->winrct.xmin; float ar_height = ar->winrct.ymax - ar->winrct.ymin; - float pv4[4], translation_vertex_cursor[2]; + float pv4[4], translation_vertex_cursor[2], location[3]; + copy_v3_v3(location, true_location); mul_m4_v3(obmat, location); copy_v3_v3(pv4, location); pv4[3] = 1.0f; @@ -1107,7 +1108,6 @@ void cursor_draw_point_with_symmetry(const uint gpuattr, const ARegion *ar,const const char symm = sd->paint.symmetry_flags & PAINT_SYMM_AXIS_ALL; float location[3], pv4[4], translation_vertex_cursor[2], symm_rot_mat[4][4]; - copy_v3_v3(location, true_location); for (int i = 0; i <= symm; ++i) { if (i == 0 || (symm & i && (symm != 5 || i != 3) && (symm != 6 || (i != 3 && i != 5 { @@ -1116,7 +1116,6 @@ void cursor_draw_point_with_symmetry(const uint gpuattr, const ARegion *ar,const cursor_draw_point_screen_space(gpuattr, ar, location, ob->obmat, persmat); /* Tiling */ - copy_v3_v3(location, true_location); cursor_draw_tiling_preview(gpuattr, ar, location, sd, ob, persmat, radius); /* Radial Symmetry */ ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [dc1a17501d6] sculpt-mode-features: Brush cursor: Radial symmetry and tiling preview support
Commit: dc1a17501d6be4a74a9ac49b5c25960861ccfe94 Author: Pablo Dobarro Date: Sat Mar 16 02:09:04 2019 +0100 Branches: sculpt-mode-features https://developer.blender.org/rBdc1a17501d6be4a74a9ac49b5c25960861ccfe94 Brush cursor: Radial symmetry and tiling preview support === M source/blender/editors/sculpt_paint/paint_cursor.c === diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c index c9880ae3af1..b4633a0a3fd 100644 --- a/source/blender/editors/sculpt_paint/paint_cursor.c +++ b/source/blender/editors/sculpt_paint/paint_cursor.c @@ -45,6 +45,7 @@ #include "BKE_node.h" #include "BKE_paint.h" #include "BKE_colortools.h" +#include "BKE_object.h" #include "WM_api.h" #include "wm_cursors.h" @@ -1044,37 +1045,93 @@ static bool ommit_cursor_drawing(Paint *paint, ePaintMode mode, Brush *brush) return true; } -void cursor_draw_point_with_symmetry(const uint gpuatrr, const ARegion *ar,const float pos[3], const char symm, const float obmat[4][4], const float persmat[4][4]){ +void cursor_draw_point_screen_space(const uint gpuattr, const ARegion *ar, float location[3], +float obmat[4][4], float persmat[4][4]) +{ float ar_width = ar->winrct.xmax - ar->winrct.xmin; float ar_height = ar->winrct.ymax - ar->winrct.ymin; - int i = 0; - for (i = 0; i <= symm; ++i) { - if (i == 0 || (symm & i && (symm != 5 || i != 3) && (symm != 6 || (i != 3 && i != 5 { - float vertex_pos[3] = { - pos[0], - pos[1], - pos[2], - }; - flip_v3_v3(vertex_pos, vertex_pos, (char)i); - - float translation_vertex_cursor[2]; - mul_m4_v3(obmat, vertex_pos); - float pv4[4] = { - vertex_pos[0], - vertex_pos[1], - vertex_pos[2], - 1.0f, - }; - mul_m4_v4(persmat, pv4); - - if (pv4[3] > 0.0f) { - float width_half = ar_width * 0.5f; - float height_half = ar_height * 0.5f; - translation_vertex_cursor[0] = width_half + width_half * (pv4[0] / pv4[3]); - translation_vertex_cursor[1] = height_half + height_half * (pv4[1] / pv4[3]); + float pv4[4], translation_vertex_cursor[2]; + mul_m4_v3(obmat, location); + copy_v3_v3(pv4, location); + pv4[3] = 1.0f; + mul_m4_v4(persmat, pv4); + if (pv4[3] > 0.0f) { + float width_half = ar_width * 0.5f; + float height_half = ar_height * 0.5f; + translation_vertex_cursor[0] = width_half + width_half * (pv4[0] / pv4[3]); + translation_vertex_cursor[1] = height_half + height_half * (pv4[1] / pv4[3]); + } + imm_draw_circle_fill_3d(gpuattr, translation_vertex_cursor[0], translation_vertex_cursor[1], 3, 10); +} + +void cursor_draw_tiling_preview(const uint gpuattr, const ARegion *ar, float true_location[3], + Sculpt *sd, Object *ob, float persmat[4][4], float radius) +{ + BoundBox *bb = BKE_object_boundbox_get(ob); + float orgLoc[3], location[3], pv4[4], translation_vertex_cursor[2]; + int dim, tile_pass = 0; + int start[3]; + int end[3]; + int cur[3]; + const float *bbMin = bb->vec[0]; + const float *bbMax = bb->vec[6]; + const float *step = sd->paint.tile_offset; + + copy_v3_v3(orgLoc, true_location); + for (dim = 0; dim < 3; ++dim) { + if ((sd->paint.symmetry_flags & (PAINT_TILE_X << dim)) && step[dim] > 0) { + start[dim] = (bbMin[dim] - orgLoc[dim] - radius) / step[dim]; + end[dim] = (bbMax[dim] - orgLoc[dim] + radius) / step[dim]; + } + else + start[dim] = end[dim] = 0; + } + copy_v3_v3_int(cur, start); + for (cur[0] = start[0]; cur[0] <= end[0]; ++cur[0]) { + for (cur[1] = start[1]; cur[1] <= end[1]; ++cur[1]) { + for (cur[2] = start[2]; cur[2] <= end[2]; ++cur[2]) { + if (!cur[0] && !cur[1] && !cur[2]) + continue; /* skip tile at orgLoc, this was already handled before all others */ +
[Bf-blender-cvs] [7c194b367e3] sculpt-mode-features: Automasking System: Topology automasking initial implementation
Commit: 7c194b367e353d36e1e0daec0542d712669b7698 Author: Pablo Dobarro Date: Fri Mar 22 16:16:51 2019 +0100 Branches: sculpt-mode-features https://developer.blender.org/rB7c194b367e353d36e1e0daec0542d712669b7698 Automasking System: Topology automasking initial implementation This commit adds a general automasking system and the topology automasking option (not topology falloff, that can be added later). It should be faster and with fewer memory errors that the last version I made. It is designed to work with every brush and every stroke mode, but for now, I only added support for draw and grab to avoid changing every brush until the system is more polished. The main purpose of adding this in such an early stage of development is to check if the cursor is working correctly. The purpose of the vertex preview in the cursor was to show the active vertex for automasking, so now I can test if the whole system is behaving as it should. Limitations: - Only meshes for now (no dyntopo or multires). I still need to think about what to do with dyntopo. I don't know if brushes that generate new topology are going to work with this. - It only stores a binary mask (a vertex can be active or not). This could be changed if the future to support topological falloff or other more complex types of automasking. - As it is now, brushes that use stroke space update the active vertex dynamically, setting it to the closest vertex to the brush location each sample. This often causes masking errors with small brushes. I'm considering changing it to always check topology using the initial active vertex, but it is going to be much slower. === M release/scripts/startup/bl_ui/space_view3d_toolbar.py M source/blender/blenkernel/BKE_paint.h M source/blender/blenkernel/BKE_pbvh.h M source/blender/blenkernel/intern/pbvh.c M source/blender/blenkernel/intern/pbvh_bmesh.c M source/blender/blenkernel/intern/pbvh_intern.h M source/blender/editors/sculpt_paint/sculpt.c M source/blender/editors/sculpt_paint/sculpt_intern.h M source/blender/makesdna/DNA_brush_types.h M source/blender/makesrna/intern/rna_brush.c === diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py index 7e3855bbb44..f6825668b0d 100644 --- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py +++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py @@ -279,6 +279,10 @@ class VIEW3D_PT_tools_brush(Panel, View3DPaintPanel): row = col.row() row.prop(brush, "curve_preset") +col.separator() +row = col.row() +row.prop(brush, "automasking_mode") + # topology_rake_factor if (capabilities.has_topology_rake and context.sculpt_object.use_dynamic_topology_sculpting diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h index e297240157b..0ef03b1bea6 100644 --- a/source/blender/blenkernel/BKE_paint.h +++ b/source/blender/blenkernel/BKE_paint.h @@ -62,6 +62,7 @@ enum eOverlayFlags; #include "DNA_object_enums.h" #include "DNA_view3d_types.h" +#include "DNA_meshdata_types.h" extern const char PAINT_CURSOR_SCULPT[3]; extern const char PAINT_CURSOR_VERTEX_PAINT[3]; @@ -252,6 +253,10 @@ typedef struct SculptSession { float cursor_view_normal[3]; float cursor_normal[3]; + /* Automasking active vertex */ + MVert *active_vertex_mesh; + int active_vertex_mesh_index; + RegionView3D *rv3d; union { diff --git a/source/blender/blenkernel/BKE_pbvh.h b/source/blender/blenkernel/BKE_pbvh.h index 73803df30ef..f71e0af178c 100644 --- a/source/blender/blenkernel/BKE_pbvh.h +++ b/source/blender/blenkernel/BKE_pbvh.h @@ -21,6 +21,7 @@ * \ingroup bke * \brief A BVH for high poly meshes. */ +#include "DNA_meshdata_types.h" #include "BLI_bitmap.h" #include "BLI_ghash.h" @@ -48,6 +49,13 @@ typedef struct { float (*co)[3]; } PBVHProxyNode; +typedef struct { + float normal[3]; + float nearest_vertex_co[3]; + MVert *active_vertex_mesh; + int active_vertex_mesh_index; +} RaycastOutputData; + /* Callbacks */ /* returns 1 if the search should continue from this node, 0 otherwise */ @@ -99,7 +107,7 @@ void BKE_pbvh_raycast( bool BKE_pbvh_node_raycast( PBVH *bvh, PBVHNode *node, float (*origco)[3], bool use_origco, const float ray_start[3], const float ray_normal[3], -float *depth, float* normal, float *nearest_vertex_co); +float *depth, RaycastOutputData *output_data); bool BKE_pbvh_bmesh_node_raycast_detail( PBVHNode *node, diff --git a/source/blender/blenkernel/intern/pbvh.c
[Bf-blender-cvs] [a92fb8a0456] sculpt-mode-features: Add proportional editing presets to sculpt brushes
Commit: a92fb8a04569a1faf19d97b2f07ca10f9f2ee6ef Author: Pablo Dobarro Date: Wed Mar 20 23:17:19 2019 +0100 Branches: sculpt-mode-features https://developer.blender.org/rBa92fb8a04569a1faf19d97b2f07ca10f9f2ee6ef Add proportional editing presets to sculpt brushes When sculpting, I always found that the behavior of the current curve falloff system is not correct, so I added the same curves that proportional editing uses to the brush falloff calculation. Now, curves are easier to set up and they produce a much better result. You can easily compare it against the old method by changing the curve preset option from custom to smooth in the grab brush. To make the new dam brush behave correctly, you need to select the sharper curve preset. You can also use it to insert shapes using the stroke anchored option and changing the curve preset. === M release/scripts/startup/bl_ui/space_view3d_toolbar.py M source/blender/editors/sculpt_paint/sculpt.c M source/blender/makesdna/DNA_brush_types.h M source/blender/makesrna/intern/rna_brush.c === diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py index 0ce68526e80..7e3855bbb44 100644 --- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py +++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py @@ -275,6 +275,10 @@ class VIEW3D_PT_tools_brush(Panel, View3DPaintPanel): row = col.row() row.prop(brush, "normal_radius_factor", slider=True) +col.separator() +row = col.row() +row.prop(brush, "curve_preset") + # topology_rake_factor if (capabilities.has_topology_rake and context.sculpt_object.use_dynamic_topology_sculpting diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 0f53d61a86b..bb1ec336979 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -1295,26 +1295,42 @@ float tex_strength(SculptSession *ss, const Brush *br, } /* Falloff curve */ - float dist_nrm, factor; - switch (br->sculpt_tool) { - case SCULPT_TOOL_GRAB: - dist_nrm = len/cache->radius; - factor = 3.0f * dist_nrm * dist_nrm - 2.0f * dist_nrm * dist_nrm * dist_nrm; - avg *= (1 - factor); - avg *= 0.5f; + float dist, factor; + dist = len/cache->radius; + dist = 1 - dist; + + switch (br->curve_preset) { + case BRUSH_CURVE_CUSTOM: + factor = BKE_brush_curve_strength(br, len, cache->radius); break; - case SCULPT_TOOL_DAM: - dist_nrm = len/cache->radius; - dist_nrm = 1 - dist_nrm; - factor = dist_nrm * dist_nrm * dist_nrm * dist_nrm; - factor = 1 - factor; - avg *= (1 - factor); - avg *= -2; - default: - avg *= BKE_brush_curve_strength(br, len, cache->radius); + case BRUSH_CURVE_SHARP: + factor = dist * dist; + break; + case BRUSH_CURVE_SMOOTH: + factor = 3.0f * dist * dist - 2.0f * dist * dist * dist; + break; + case BRUSH_CURVE_ROOT: + factor = sqrtf(dist); + break; + case BRUSH_CURVE_LIN: + factor = dist; + break; + case BRUSH_CURVE_CONSTANT: + factor = 1.0f; + break; + case BRUSH_CURVE_SPHERE: + factor = sqrtf(2 * dist - dist * dist); + break; + case BRUSH_CURVE_POW4: + factor = dist * dist * dist * dist; + break; + case BRUSH_CURVE_INVSQUARE: + factor = dist * (2.0f - dist); break; } + avg *= factor; + avg *= frontface(br, cache->view_normal, vno, fno); /* Paint mask */ diff --git a/source/blender/makesdna/DNA_brush_types.h b/source/blender/makesdna/DNA_brush_types.h index a6b471a4842..72bc07518e4 100644 --- a/source/blender/makesdna/DNA_brush_types.h +++ b/source/blender/makesdna/DNA_brush_types.h @@ -182,6 +182,18 @@ typedef enum eGP_BrushIcons { GP_BRUSH_ICON_ERASE_STROKE = 10, } eGP_BrushIcons; +typedef enum eBrushCurvePreset { + BRUSH_CURVE_CUSTOM = 0, + BRUSH_CURVE_SMOOTH = 1, + BRUSH_CU
[Bf-blender-cvs] [d050badf122] sculpt-mode-features: Fix naming
Commit: d050badf122b6d14a5b90ca4013bb15593011d15 Author: Pablo Dobarro Date: Wed Apr 10 01:25:00 2019 +0200 Branches: sculpt-mode-features https://developer.blender.org/rBd050badf122b6d14a5b90ca4013bb15593011d15 Fix naming === M 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 db3b4af1d9c..7f57cc883aa 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -6995,7 +6995,7 @@ EnumPropertyItem prop_mask_filter_types[] = { {0, NULL, 0, NULL, NULL}, }; -static void smooth_flood_fill_task_cb( +static void mask_filter_task_cb( void *__restrict userdata, const int i, const ParallelRangeTLS *__restrict UNUSED(tls)) @@ -7084,7 +7084,7 @@ static int sculpt_mask_filter_exec(bContext *C, wmOperator *op) BLI_task_parallel_range( 0, totnode, , - smooth_flood_fill_task_cb, + mask_filter_task_cb, ); sculpt_undo_push_end(); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [42876e5f2de] sculpt-mode-features: OpenVDB: Add Filters and CSG operations to the Level Set C API
Commit: 42876e5f2de1f12796ec9d091fc6c5c9e0765f6c Author: Pablo Dobarro Date: Sun Apr 7 04:08:45 2019 +0200 Branches: sculpt-mode-features https://developer.blender.org/rB42876e5f2de1f12796ec9d091fc6c5c9e0765f6c OpenVDB: Add Filters and CSG operations to the Level Set C API I also refactored the voxel remesher code to use the new API. === M intern/openvdb/intern/openvdb_level_set.cc M intern/openvdb/intern/openvdb_level_set.h M intern/openvdb/openvdb_capi.cc M intern/openvdb/openvdb_capi.h M source/blender/editors/object/object_edit.c === diff --git a/intern/openvdb/intern/openvdb_level_set.cc b/intern/openvdb/intern/openvdb_level_set.cc index dad164e6f85..77dc76dd785 100644 --- a/intern/openvdb/intern/openvdb_level_set.cc +++ b/intern/openvdb/intern/openvdb_level_set.cc @@ -22,6 +22,136 @@ #include "openvdb_util.h" #include "openvdb_capi.h" #include "MEM_guardedalloc.h" +#include "openvdb/tools/Composite.h" + +OpenVDBLevelSet::OpenVDBLevelSet() +{ + openvdb::initialize(); +} + +OpenVDBLevelSet::~OpenVDBLevelSet() +{} + +void OpenVDBLevelSet::OpenVDB_mesh_to_level_set(const float *vertices, const unsigned int *faces, const unsigned int totvertices, + const unsigned int totfaces, const double voxel_size) +{ + std::vector points; + std::vector triangles; + std::vector quads; + std::vector out_points; + std::vector out_quads; + std::vector out_tris; + const openvdb::math::Transform xform; + + for(unsigned int i = 0; i < totvertices; i++) { + openvdb::Vec3s v(vertices[i * 3 ], vertices[i * 3 + 1], vertices[i * 3 + 2]); + points.push_back(v); + } + + for(unsigned int i = 0; i < totfaces; i++) { + openvdb::Vec3I f(faces[i * 3 ], faces[i * 3 + 1], faces[i * 3 + 2]); + triangles.push_back(f); + } + + openvdb::math::Transform::Ptr transform = openvdb::math::Transform::createLinearTransform(voxel_size); + this->grid = openvdb::tools::meshToLevelSet(*transform, points, triangles, quads, 1); +} + +void OpenVDBLevelSet::OpenVDB_volume_to_mesh(OpenVDBVolumeToMeshData *mesh, const double isovalue, const double adaptivity, const bool relax_disoriented_triangles) +{ + std::vector out_points; + std::vector out_quads; + std::vector out_tris; + openvdb::tools::volumeToMesh(*this->grid, out_points, out_tris, out_quads, isovalue, + adaptivity, relax_disoriented_triangles); + mesh->vertices = (float *)MEM_malloc_arrayN(out_points.size(), 3 * sizeof (float), "openvdb remesher out verts"); + mesh->quads = (unsigned int*)MEM_malloc_arrayN(out_quads.size(), 4 * sizeof (unsigned int), "openvdb remesh out quads"); + mesh->triangles = NULL; + if (out_tris.size() > 0) { + mesh->triangles = (unsigned int*)MEM_malloc_arrayN(out_tris.size(), 3 * sizeof (unsigned int), "openvdb remesh out tris"); + } + + mesh->totvertices = out_points.size(); + mesh->tottriangles = out_tris.size(); + mesh->totquads = out_quads.size(); + + for(unsigned int i = 0; i < out_points.size(); i++) { + mesh->vertices[i * 3] = out_points[i].x(); + mesh->vertices[i * 3 + 1] = out_points[i].y(); + mesh->vertices[i * 3 + 2] = out_points[i].z(); + } + + for(unsigned int i = 0; i < out_quads.size(); i++) { + mesh->quads[i * 4] = out_quads[i].x(); + mesh->quads[i * 4 + 1] = out_quads[i].y(); + mesh->quads[i * 4 + 2] = out_quads[i].z(); + mesh->quads[i * 4 + 3] = out_quads[i].w(); + } + + for(unsigned int i = 0; i < out_tris.size(); i++) { + mesh->triangles[i * 3] = out_tris[i].x(); + mesh->triangles[i * 3 + 1] = out_tris[i].y(); + mesh->triangles[i * 3 + 2] = out_tris[i].z(); + } +} + +void OpenVDBLevelSet::OpenVDB_level_set_filter(OpenVDBLevelSet_FilterType filter_type, int width, int iterations, int filter_bias){ + openvdb::tools::LevelSetFilter filter(*this->grid); + filter.setSpatialScheme((openvdb::math::BiasedGradientScheme)filter_bias); + switch (filter_type) { + case OPENVDB_LEVELSET_FILTER_GAUSSIAN: + filter.gaussian(width); + break; + case OPENVDB_LEVELSET_FILTER_MEDIAN: + filter.median(width); + break; + case OPENVDB_LEVELSET_FILTER_MEAN: + filter.mean(width); +
[Bf-blender-cvs] [c3c265a1019] sculpt-mode-features: Sculpt mode: Mask filter operator
Commit: c3c265a101960aa0247c432f817fa2ae3b528d16 Author: Pablo Dobarro Date: Tue Apr 9 00:14:41 2019 +0200 Branches: sculpt-mode-features https://developer.blender.org/rBc3c265a101960aa0247c432f817fa2ae3b528d16 Sculpt mode: Mask filter operator It includes blur and sharpen mask filters. It is not enabled for multires yet. === M source/blender/editors/sculpt_paint/sculpt.c M source/blender/editors/sculpt_paint/sculpt_intern.h === diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index a78f1b62c24..80213293c02 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -6984,6 +6984,141 @@ static void SCULPT_OT_set_detail_size(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } +typedef enum eSculptMaskFilterTypes { + MASK_FILTER_BLUR = 0, + MASK_FILTER_SHARPEN =1, +} eObClearParentTypes; + +EnumPropertyItem prop_mask_filter_types[] = { + {MASK_FILTER_BLUR, "BLUR", 0, "Blur Mask", "Blur mask"}, + {MASK_FILTER_SHARPEN, "SHARPEN", 0, "Sharpen Mask", "Sharpen mask"}, + {0, NULL, 0, NULL, NULL}, +}; + +static void smooth_flood_fill_task_cb( +void *__restrict userdata, +const int i, +const ParallelRangeTLS *__restrict UNUSED(tls)) +{ + SculptThreadedTaskData *data = userdata; + SculptSession *ss = data->ob->sculpt; + PBVHNode *node = data->nodes[i]; + + const int mode = data->smooth_mode; + + PBVHVertexIter vd; + + sculpt_undo_push_node(data->ob, node, SCULPT_UNDO_MASK); + + BKE_pbvh_vertex_iter_begin(ss->pbvh, node, vd, PBVH_ITER_UNIQUE) { + float val; + switch (mode) { + case MASK_FILTER_BLUR: + if (BKE_pbvh_type(ss->pbvh) == PBVH_FACES){ + val = neighbor_average_mask(ss, vd.vert_indices[vd.i]) - *vd.mask; + } + else { + val = bmesh_neighbor_average_mask(vd.bm_vert, vd.cd_vert_mask_offset) - *vd.mask; + } + *vd.mask += val; + CLAMP(*vd.mask, 0.0f, 1.0f); + break; + case MASK_FILTER_SHARPEN: + if (BKE_pbvh_type(ss->pbvh) == PBVH_FACES){ + val = neighbor_average_mask(ss, vd.vert_indices[vd.i]) - *vd.mask; + } + else { + val = bmesh_neighbor_average_mask(vd.bm_vert, vd.cd_vert_mask_offset) - *vd.mask; + } + if (*vd.mask > 0.5f) { + *vd.mask += 0.05f; + } else { + *vd.mask -= 0.05f; + } + *vd.mask += val/2; + CLAMP(*vd.mask, 0.0f, 1.0f); + break; + } + if (vd.mvert) + vd.mvert->flag |= ME_VERT_PBVH_UPDATE; + } BKE_pbvh_vertex_iter_end; + + BKE_pbvh_node_mark_redraw(node); + if (BKE_pbvh_type(ss->pbvh) == PBVH_GRIDS) + BKE_pbvh_node_mark_normals_update(node); +} + +static int sculpt_mask_filter_exec(bContext *C, wmOperator *op) +{ + ARegion *ar = CTX_wm_region(C); + struct Scene *scene = CTX_data_scene(C); + Object *ob = CTX_data_active_object(C); + Depsgraph *depsgraph = CTX_data_depsgraph(C); + PBVH *pbvh = ob->sculpt->pbvh; + PBVHNode **nodes; + int totnode; + Sculpt *sd = CTX_data_tool_settings(C)->sculpt; + int mode = RNA_enum_get(op->ptr, "type"); + + /* Disable for multires for now */ + if (BKE_pbvh_type(pbvh) == PBVH_GRIDS) { + return OPERATOR_CANCELLED; + } + + BKE_sculpt_update_mesh_elements(depsgraph, scene, sd, ob, true, true); + if (BKE_pbvh_type(pbvh) == PBVH_FACES && !ob->sculpt->pmap) { + return OPERATOR_CANCELLED; + } + + BKE_pbvh_search_gather(pbvh, NULL, NULL, , ); + + sculpt_undo_push_begin("Mask blur fill"); + + SculptThreadedTaskData data = { + .sd = sd, .ob = ob, .nodes = nodes, .smooth_value = 0.5f, .smooth_mode = mode, + }; + + ParallelRangeSettings settings; + BLI_parallel_range_settings_defaults(); + settings.use_thre
[Bf-blender-cvs] [a1713328876] sculpt-mode-features: Sculpt vertex colors: Color fill operator
Commit: a1713328876e9cf7e1b717b90918bad605ef36cd Author: Pablo Dobarro Date: Tue Apr 9 01:18:08 2019 +0200 Branches: sculpt-mode-features https://developer.blender.org/rBa1713328876e9cf7e1b717b90918bad605ef36cd Sculpt vertex colors: Color fill operator === M 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 80213293c02..db3b4af1d9c 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -2330,7 +2330,7 @@ static void do_mask_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode) } static void apply_color(SculptSession *ss, PBVHVertexIter *vd, const Brush *brush, float fade) { - float factor = fade * fabs(ss->cache->bstrength); + float factor = ss->cache? fade * fabs(ss->cache->bstrength) : fade; factor *= 2; CLAMP(factor, 0.0f, 1.0f); char r = brush->rgb[0] * 255; @@ -7117,6 +7117,94 @@ void SCULPT_OT_mask_filter(struct wmOperatorType *ot) ot->prop = RNA_def_enum(ot->srna, "type", prop_mask_filter_types, MASK_FILTER_BLUR, "Type", ""); } +static void do_color_fill_task_cb( +void *__restrict userdata, +const int i, +const ParallelRangeTLS *__restrict UNUSED(tls)) +{ + SculptThreadedTaskData *data = userdata; + SculptSession *ss = data->ob->sculpt; + PBVHNode *node = data->nodes[i]; + + PBVHVertexIter vd; + + sculpt_undo_push_node(data->ob, node, SCULPT_UNDO_COLOR); + + BKE_pbvh_vertex_iter_begin(ss->pbvh, node, vd, PBVH_ITER_UNIQUE) { + float fade = vd.mask ? 1 - *vd.mask : 1.0f; + apply_color(ss, , data->brush, fade); + if (vd.mvert) + vd.mvert->flag |= ME_VERT_PBVH_UPDATE; + } BKE_pbvh_vertex_iter_end; + + BKE_pbvh_node_mark_redraw(node); +} + +static int sculpt_color_fill_exec(bContext *C, wmOperator *op) +{ + ARegion *ar = CTX_wm_region(C); + struct Scene *scene = CTX_data_scene(C); + Object *ob = CTX_data_active_object(C); + Depsgraph *depsgraph = CTX_data_depsgraph(C); + PBVH *pbvh = ob->sculpt->pbvh; + PBVHNode **nodes; + int totnode; + Sculpt *sd = CTX_data_tool_settings(C)->sculpt; + Brush *brush = BKE_paint_brush(>paint); + + /* Sculpt vertex colors only work with faces */ + if (BKE_pbvh_type(pbvh) != PBVH_FACES) { + return OPERATOR_CANCELLED; + } + if (!brush){ + return OPERATOR_CANCELLED; + } + + BKE_sculpt_update_mesh_elements(depsgraph, scene, sd, ob, false, true); + + BKE_pbvh_search_gather(pbvh, NULL, NULL, , ); + + sculpt_undo_push_begin("Color fill"); + + SculptThreadedTaskData data = { + .sd = sd, .ob = ob, .nodes = nodes, .brush = brush, + }; + + ParallelRangeSettings settings; + BLI_parallel_range_settings_defaults(); + settings.use_threading = ((sd->flags & SCULPT_USE_OPENMP) && totnode > SCULPT_THREADED_LIMIT); + BLI_task_parallel_range( + 0, totnode, + , + do_color_fill_task_cb, + ); + + sculpt_undo_push_end(); + + if (nodes) + MEM_freeN(nodes); + + ED_region_tag_redraw(ar); + + WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); + + return OPERATOR_FINISHED; +} + +void SCULPT_OT_color_fill(struct wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Color fill"; + ot->idname = "SCULPT_OT_color_fill"; + ot->description = "Fills the mesh with the current brush color"; + + /* api callbacks */ + ot->exec = sculpt_color_fill_exec; + ot->poll = sculpt_mode_poll; + + ot->flag = OPTYPE_REGISTER; +} + void ED_operatortypes_sculpt(void) @@ -7132,4 +7220,5 @@ void ED_operatortypes_sculpt(void) WM_operatortype_append(SCULPT_OT_set_detail_size); WM_operatortype_append(SCULPT_OT_sample_color); WM_operatortype_append(SCULPT_OT_mask_filter); + WM_operatortype_append(SCULPT_OT_color_fill); } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [4cd1941bb7d] sculpt-mode-features: Mesh Filter tool: Initial implementation
Commit: 4cd1941bb7dc9e13de803ee2c697b2182c9f93ad Author: Pablo Dobarro Date: Thu Apr 11 15:18:44 2019 +0200 Branches: sculpt-mode-features https://developer.blender.org/rB4cd1941bb7dc9e13de803ee2c697b2182c9f93ad Mesh Filter tool: Initial implementation This tool applies a deformation to all vertices in the sculpt taking the mask into account. It is useful for creating surface detail or hard surface sculpts. It is also the base for the implementation of the transform tool. Notes: - The smooth filter needs multiple iterations. Right now it only applies one iteration per tool action, so it is unusable in most cases. I don't know if adding this is possible with the current smooth code while supporting real-time preview. - I'm not sure if it is properly integrated with the tool system and the keymap (probably not). - Only works with mesh, no dyntopo or multires. - It still needs to ignore nodes with all vertices fully masked. Adding this basic optimization will increase performance a lot when working with high-resolution meshes. - Previewing the deformation in real time is not the best option for performance, I could add an operator that applies the filter without preview. === M release/scripts/presets/keyconfig/keymap_data/blender_default.py M release/scripts/startup/bl_ui/space_toolsystem_toolbar.py M source/blender/blenkernel/BKE_paint.h M source/blender/editors/sculpt_paint/sculpt.c M source/blender/editors/sculpt_paint/sculpt_intern.h === diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py b/release/scripts/presets/keyconfig/keymap_data/blender_default.py index 84e97d5b764..68454456b42 100644 --- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py +++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py @@ -5783,6 +5783,17 @@ def km_3d_view_tool_sculpt_box_mask(params): ) +def km_3d_view_tool_sculpt_mesh_filter(params): +return ( +"3D View Tool: Sculpt, Mesh Filter", +{"space_type": 'VIEW_3D', "region_type": 'WINDOW'}, +{"items": [ +("sculpt.mesh_filter", {"type": params.tool_tweak, "value": 'ANY'}, + None) +]}, +) + + def km_3d_view_tool_paint_weight_sample_weight(params): return ( "3D View Tool: Paint Weight, Sample Weight", @@ -6222,6 +6233,7 @@ def generate_keymaps(params=None): km_3d_view_tool_edit_curve_extrude_cursor(params), km_3d_view_tool_sculpt_box_hide(params), km_3d_view_tool_sculpt_box_mask(params), +km_3d_view_tool_sculpt_mesh_filter(params), km_3d_view_tool_paint_weight_sample_weight(params), km_3d_view_tool_paint_weight_sample_vertex_group(params), km_3d_view_tool_paint_weight_gradient(params), diff --git a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py index 42953a05ca6..cb267549b05 100644 --- a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py +++ b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py @@ -976,6 +976,24 @@ class _defs_sculpt: keymap=(), ) +@ToolDef.from_fn +def mesh_filter(): +def draw_settings(context, layout, tool): +props = tool.operator_properties("sculpt.mesh_filter") +sub = layout.row() +sub.use_property_split = False +sub.prop(props, "type", expand=False) +sub.prop(props, "strength") + +return dict( +idname="builtin.mesh_filter", +label="Mesh Filter", +icon="ops.sculpt.mesh_filter", +widget=None, +keymap= (), +draw_settings=draw_settings, +) + class _defs_vertex_paint: @@ -1856,6 +1874,7 @@ class VIEW3D_PT_tools_active(ToolSelectPanelHelper, Panel): None, _defs_sculpt.hide_border, _defs_sculpt.mask_border, +_defs_sculpt.mesh_filter, ], 'PAINT_TEXTURE': [ _defs_texture_paint.generate_from_brushes, diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h index 991f47e6366..3f6b2835c16 100644 --- a/source/blender/blenkernel/BKE_paint.h +++ b/source/blender/blenkernel/BKE_paint.h @@ -253,6 +253,7 @@ typedef struct SculptSession { float cursor_location[3]; float cursor_view_normal[3]; float cursor_normal[3]; + bool use_orco; /* Automasking active vertex */ MVert *active_vertex_mesh; diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 7f57cc883aa..882cd0fb090 10
[Bf-blender-cvs] [73da0bdf64c] sculpt-mode-features: Voxel remesher: Reproject mask option
Commit: 73da0bdf64ca94355d425fadd873aeec087160d9 Author: Pablo Dobarro Date: Fri Apr 12 16:49:51 2019 +0200 Branches: sculpt-mode-features https://developer.blender.org/rB73da0bdf64ca94355d425fadd873aeec087160d9 Voxel remesher: Reproject mask option === M release/scripts/startup/bl_ui/properties_data_mesh.py M source/blender/blenkernel/BKE_remesh.h M source/blender/blenkernel/intern/remesh_voxel.c M source/blender/editors/object/object_edit.c M source/blender/makesdna/DNA_mesh_types.h M source/blender/makesrna/intern/rna_mesh.c === diff --git a/release/scripts/startup/bl_ui/properties_data_mesh.py b/release/scripts/startup/bl_ui/properties_data_mesh.py index bf2a1d00d20..8c9e46e7b7f 100644 --- a/release/scripts/startup/bl_ui/properties_data_mesh.py +++ b/release/scripts/startup/bl_ui/properties_data_mesh.py @@ -472,6 +472,7 @@ class DATA_PT_remesh(MeshButtonsPanel, Panel): col.prop(mesh, "voxel_size") col.prop(mesh, "smooth_normals") col.prop(mesh, "reproject_vertex_paint") +col.prop(mesh, "reproject_paint_mask") col.operator("object.remesh", text="Remesh") diff --git a/source/blender/blenkernel/BKE_remesh.h b/source/blender/blenkernel/BKE_remesh.h index d3ea0a1c928..a58e7baae9a 100644 --- a/source/blender/blenkernel/BKE_remesh.h +++ b/source/blender/blenkernel/BKE_remesh.h @@ -34,7 +34,9 @@ Mesh *BKE_remesh_voxel_ovdb_volume_to_mesh_nomain(struct OpenVDBLevelSet *level_ /* MVertCol based Reprojection for remesh operator */ void BKE_remesh_voxel_init_empty_vertex_color_layer(Mesh *mesh); +void BKE_remesh_voxel_reproject(Mesh *target, Mesh *source, const int flag); void BKE_remesh_voxel_reproject_vertex_paint(Mesh *target, Mesh *source); +void BKE_remesh_voxel_reproject_paint_mask(Mesh *target, Mesh *source); /* MLoopCol remapping based Reprojection for remesh modifier */ MLoopCol* BKE_remesh_remap_loop_vertex_color_layer(Mesh *mesh); diff --git a/source/blender/blenkernel/intern/remesh_voxel.c b/source/blender/blenkernel/intern/remesh_voxel.c index f79bb783238..479a6891a88 100644 --- a/source/blender/blenkernel/intern/remesh_voxel.c +++ b/source/blender/blenkernel/intern/remesh_voxel.c @@ -163,6 +163,89 @@ void BKE_remesh_voxel_reproject_vertex_paint(Mesh *target, Mesh *source) free_bvhtree_from_mesh(); } +void BKE_remesh_voxel_reproject_paint_mask(Mesh *target, Mesh *source) +{ + BVHTreeFromMesh bvhtree = {NULL}; + BKE_bvhtree_from_mesh_get(, source, BVHTREE_FROM_VERTS, 2); + MVert *target_verts = CustomData_get_layer(>vdata, CD_MVERT); + + float *target_mask; + if (CustomData_has_layer(>vdata, CD_PAINT_MASK)) { + target_mask = CustomData_get_layer(>vdata, CD_PAINT_MASK); + } + else { + target_mask = CustomData_add_layer(>vdata, CD_PAINT_MASK, CD_CALLOC, NULL, target->totvert); + } + + float *source_mask; + if (CustomData_has_layer(>vdata, CD_PAINT_MASK)) { + source_mask = CustomData_get_layer(>vdata, CD_PAINT_MASK); + } + else { + source_mask = CustomData_add_layer(>vdata, CD_PAINT_MASK, CD_CALLOC, NULL, source->totvert); + } + + for(int i = 0; i < target->totvert; i++) { + float from_co[3]; + BVHTreeNearest nearest; + nearest.index = -1; + nearest.dist_sq = FLT_MAX; + copy_v3_v3(from_co, target_verts[i].co); + BLI_bvhtree_find_nearest(bvhtree.tree, from_co, , bvhtree.nearest_callback, ); + if (nearest.index != -1) { + target_mask[i] = source_mask[nearest.index]; + } + } + free_bvhtree_from_mesh(); +} + +void BKE_remesh_voxel_reproject(Mesh *target, Mesh *source, const int flag) +{ + BVHTreeFromMesh bvhtree = {NULL}; + BKE_bvhtree_from_mesh_get(, source, BVHTREE_FROM_VERTS, 2); + MVert *target_verts = CustomData_get_layer(>vdata, CD_MVERT); + + MVertCol *target_color = CustomData_get_layer(>vdata, CD_MVERTCOL); + MVertCol *source_color = CustomData_get_layer(>vdata, CD_MVERTCOL); + + float *target_mask; + if (CustomData_has_layer(>vdata, CD_PAINT_MASK)) { + target_mask = CustomData_get_layer(>vdata, CD_PAINT_MASK); + } + else { + target_mask = CustomData_add_layer(>vdata, CD_PAINT_MASK, CD_CALLOC, NULL, target->totvert); + } + + float *source_mask; + if (CustomData_has_layer(>vdata, CD_PAINT_MASK)) { + source_mask = CustomData_get_layer(>vdata, CD_PAINT_MASK); + } + else { + source_mask = CustomData_add_la
[Bf-blender-cvs] [d6acac5af89] sculpt-mode-features: Automasking: Open edges automasking and refactor
Commit: d6acac5af89525ee483da58af5aa153cb46b0b44 Author: Pablo Dobarro Date: Tue Apr 16 20:16:51 2019 +0200 Branches: sculpt-mode-features https://developer.blender.org/rBd6acac5af89525ee483da58af5aa153cb46b0b44 Automasking: Open edges automasking and refactor This new version should allow us to stack multiple automasking operations in one brush. The UI still needs to be done for supporting that. This is still a binary mask, it does not have falloff, but now the code was done with that in mind. === M source/blender/editors/sculpt_paint/sculpt.c M source/blender/editors/sculpt_paint/sculpt_intern.h M source/blender/makesdna/DNA_brush_types.h M source/blender/makesrna/intern/rna_brush.c === diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 9934b835350..d7ded4e6995 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -1558,24 +1558,24 @@ static void calc_brush_local_mat(const Brush *brush, Object *ob, invert_m4_m4(local_mat, tmat); } -static bool sculpt_automasking_compatible(SculptSession *ss){ - if (BKE_pbvh_type(ss->pbvh)==PBVH_FACES) { +static bool sculpt_automasking_enabled(SculptSession *ss, const Brush *br){ + if (!BKE_pbvh_type(ss->pbvh)==PBVH_FACES) { + return false; + } + if (br->automasking_mode != BRUSH_AUTOMASKING_NONE) { return true; } return false; } -static float sculpt_automasking_value_get(SculptSession *ss, const Brush *br, MVert *vert) { - if (!sculpt_automasking_compatible(ss)) return 1.0f; - if (br->automasking_mode & BRUSH_AUTOMASKING_TOPOLOGY) { - if (BLI_gset_haskey(ss->cache->topo_connected_set[ss->cache->mirror_symmetry_pass], vert)){ - return 1.0f; - } - else { - return 0.0f; - } +static float sculpt_automasking_value_get(SculptSession *ss, const Brush *br,int vert) { + if (!sculpt_automasking_enabled(ss, br)) return 1.0f; + if (ss->cache->automask[ss->cache->mirror_symmetry_pass]){ + return ss->cache->automask[ss->cache->mirror_symmetry_pass][vert]; + } + else { + return 1.0f; } - return 1.0f; } static void update_brush_local_mat(Sculpt *sd, Object *ob) @@ -2480,8 +2480,8 @@ static void do_draw_brush_task_cb_ex( ss, brush, vd.co, sqrtf(test.dist), vd.no, vd.fno, vd.mask ? *vd.mask : 0.0f, tls->thread_id); - if (sculpt_automasking_compatible(ss)){ - fade *= sculpt_automasking_value_get(ss, brush, >mvert[vd.vert_indices[vd.i]]); + if (sculpt_automasking_enabled(ss, brush)){ + fade *= sculpt_automasking_value_get(ss, brush, vd.vert_indices[vd.i]); } if (brush->sculpt_color_mix_mode & BRUSH_SCULPT_COLOR_MIX) { @@ -2794,8 +2794,8 @@ static void do_grab_brush_task_cb_ex( float fade = bstrength * tex_strength( ss, brush, orig_data.co, sqrtf(test.dist), orig_data.no, NULL, vd.mask ? *vd.mask : 0.0f, tls->thread_id); - if (sculpt_automasking_compatible(ss)){ - fade *= sculpt_automasking_value_get(ss, brush, >mvert[vd.vert_indices[vd.i]]); + if (sculpt_automasking_enabled(ss, brush)){ + fade *= sculpt_automasking_value_get(ss, brush, vd.vert_indices[vd.i]); } mul_v3_v3fl(proxy[vd.i], grab_delta, fade); @@ -2929,8 +2929,8 @@ static void do_snake_hook_brush_task_cb_ex( ss, brush, vd.co, sqrtf(test.dist), vd.no, vd.fno, vd.mask ? *vd.mask : 0.0f, tls->thread_id); float automasking = 1.0f; - if (sculpt_automasking_compatible(ss)){ - automasking = sculpt_automasking_value_get(ss, brush, >mvert[vd.vert_indices[vd.i]]); + if (sculpt_automasking_enabled(ss, brush)){ + automasking = sculpt_automasking_value_get(ss, brush, vd.vert_indices[vd.i]); } mul_v3_v3fl(proxy[vd.i], grab_delta, fade * automasking); @@ -4053,7 +4053,72 @@ static void sculpt_topology_update(Sculpt *sd, Object *ob, Brush *brush, Unified } } -static bool find_connected_set(SculptSessi
[Bf-blender-cvs] [538669942a7] sculpt-mode-features: Merge branch 'sculpt-mode-features' of git.blender.org:blender into sculpt-mode-features
Commit: 538669942a742c6a62d94c924b3be1678ef20245 Author: Pablo Dobarro Date: Tue Apr 16 20:18:01 2019 +0200 Branches: sculpt-mode-features https://developer.blender.org/rB538669942a742c6a62d94c924b3be1678ef20245 Merge branch 'sculpt-mode-features' of git.blender.org:blender into sculpt-mode-features === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [0d3501725c9] sculpt-mode-features: Fix build with QEX disabled
Commit: 0d3501725c9790a54b02337ca4033428fcc3c390 Author: Pablo Dobarro Date: Tue Apr 16 20:35:40 2019 +0200 Branches: sculpt-mode-features https://developer.blender.org/rB0d3501725c9790a54b02337ca4033428fcc3c390 Fix build with QEX disabled === M source/blender/blenkernel/intern/remesh_quad.c === diff --git a/source/blender/blenkernel/intern/remesh_quad.c b/source/blender/blenkernel/intern/remesh_quad.c index 344588066df..bff76f37306 100644 --- a/source/blender/blenkernel/intern/remesh_quad.c +++ b/source/blender/blenkernel/intern/remesh_quad.c @@ -45,8 +45,10 @@ #include "BKE_bvhutils.h" #include "BKE_remesh.h" +#ifdef WITH_QEX #include "igl_capi.h" #include "qex_capi.h" +#endif Mesh* BKE_remesh_quad(Mesh* mesh, float gradient_size, float stiffness, int iter, bool direct_round) { ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [6e558c84e49] sculpt-mode-features: Sculpt: Mask by color operator
Commit: 6e558c84e495c107a6a0bffce48144ee0371408e Author: Pablo Dobarro Date: Wed May 15 16:28:55 2019 +0200 Branches: sculpt-mode-features https://developer.blender.org/rB6e558c84e495c107a6a0bffce48144ee0371408e Sculpt: Mask by color operator Similar to mask by normal, this operator generates a mask based on the color of the active vertex. === M 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 66a9fdf389b..d7c389967da 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -8240,6 +8240,88 @@ static void SCULPT_OT_mask_by_normal(wmOperatorType *ot) ot->prop = RNA_def_boolean(ot->srna, "invert", false, "Invert", ""); } +static int sculpt_mask_by_color_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(e)) +{ + Sculpt *sd = CTX_data_tool_settings(C)->sculpt; + Object *ob = CTX_data_active_object(C); + SculptSession *ss = ob->sculpt; + ARegion *ar = CTX_wm_region(C); + PBVH *pbvh = ob->sculpt->pbvh; + struct Scene *scene = CTX_data_scene(C); + Depsgraph *depsgraph = CTX_data_depsgraph(C); + PBVHNode **nodes; + int totnode; + + /* Disable for multires and dyntopo for now */ + if (BKE_pbvh_type(pbvh) != PBVH_FACES) { +return OPERATOR_CANCELLED; + } + + if (!ss->vcol) { +return OPERATOR_CANCELLED; + } + + /* Initial setup */ + BKE_sculpt_update_mesh_elements(depsgraph, scene, sd, ob, false, true); + + BKE_pbvh_search_gather(pbvh, NULL, NULL, , ); + sculpt_undo_push_begin("Mask by color"); + for (int i = 0; i < totnode; i++) { +sculpt_undo_push_node(ob, nodes[i], SCULPT_UNDO_MASK); +BKE_pbvh_node_mark_redraw(nodes[i]); + } + + bool invert = RNA_boolean_get(op->ptr, "invert"); + + float active_col[3] = { + (float)ss->vcol[ss->active_vertex_mesh_index].r / 255.0f, + (float)ss->vcol[ss->active_vertex_mesh_index].g / 255.0f, + (float)ss->vcol[ss->active_vertex_mesh_index].b / 255.0f, + }; + + /* Mask generation */ + float threshold = RNA_float_get(op->ptr, "threshold"); + for (int i = 0; i < ss->totvert; i++) { +float col[3] = { +(float)ss->vcol[i].r / 255.0f, +(float)ss->vcol[i].g / 255.0f, +(float)ss->vcol[i].b / 255.0f, +}; +float len = len_v3v3(active_col, col); +if (len < threshold) { + len = len / 1.73205f; + ss->vmask[i] = 1.0f - len; + ss->mvert[i].flag |= ME_VERT_PBVH_UPDATE; +} +if (invert) { + ss->vmask[i] = 1.0f - ss->vmask[i]; +} + } + + sculpt_undo_push_end(); + ED_region_tag_redraw(ar); + + WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); + return OPERATOR_FINISHED; +} + +static void SCULPT_OT_mask_by_color(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Mask by color"; + ot->idname = "SCULPT_OT_mask_by_color"; + ot->description = "Creates a mask based on the color of the active vertex"; + + /* api callbacks */ + ot->invoke = sculpt_mask_by_color_invoke; + ot->poll = sculpt_mode_poll; + + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; + + ot->prop = RNA_def_float(ot->srna, "threshold", 0.5f, 0.0f, 1.0f, "Threshold", "", 0.0f, 1.0f); + ot->prop = RNA_def_boolean(ot->srna, "invert", false, "Invert", ""); +} + void ED_operatortypes_sculpt(void) { WM_operatortype_append(SCULPT_OT_brush_stroke); @@ -8256,4 +8338,5 @@ void ED_operatortypes_sculpt(void) WM_operatortype_append(SCULPT_OT_mask_filter); WM_operatortype_append(SCULPT_OT_color_fill); WM_operatortype_append(SCULPT_OT_mask_by_normal); + WM_operatortype_append(SCULPT_OT_mask_by_color); } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [5fde4ab1c2f] sculpt-mode-features: Fix build after last commit
Commit: 5fde4ab1c2f7306c75e0aee3226cd88d0a1473ea Author: Pablo Dobarro Date: Sun Jun 2 23:01:53 2019 +0200 Branches: sculpt-mode-features https://developer.blender.org/rB5fde4ab1c2f7306c75e0aee3226cd88d0a1473ea Fix build after last commit I forgot to add a couple of files === M source/blender/editors/object/object_edit.c M source/blender/editors/sculpt_paint/sculpt_undo.c === diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index a70a48a2c5a..32d6abd8ce6 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -1827,9 +1827,7 @@ static int remesh_exec(bContext *C, wmOperator *op) if (ob->mode == OB_MODE_SCULPT) { Depsgraph *depsgraph = CTX_data_depsgraph(C); - struct Scene *scene = CTX_data_scene(C); - Sculpt *sd = CTX_data_tool_settings(C)->sculpt; - BKE_sculpt_update_mesh_elements(depsgraph, scene, sd, ob, true, true); + BKE_sculpt_update_object_for_edit(depsgraph, ob, true, true); PBVH *pbvh; PBVHNode **nodes; int totnode; diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c index 72cc91d83ab..9c378bf264b 100644 --- a/source/blender/editors/sculpt_paint/sculpt_undo.c +++ b/source/blender/editors/sculpt_paint/sculpt_undo.c @@ -622,7 +622,7 @@ static void sculpt_undo_restore_list(bContext *C, ListBase *lb) BKE_ptcache_object_reset(scene, ob, PTCACHE_RESET_OUTDATED); DEG_relations_tag_update(bmain); DEG_id_tag_update(>id, ID_RECALC_GEOMETRY); -BKE_sculpt_update_mesh_elements(depsgraph, scene, sd, ob, false, false); +BKE_sculpt_update_object_for_edit(depsgraph, ob, false, true); WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data); WM_main_add_notifier(NC_OBJECT | ND_DRAW, ob); } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [c6a3009b15d] sculpt-mode-features: Merge branch 'master' into sculpt-mode-features
Commit: c6a3009b15dcb6601aa7843839f84e56c3feac13 Author: Pablo Dobarro Date: Fri May 31 16:02:26 2019 +0200 Branches: sculpt-mode-features https://developer.blender.org/rBc6a3009b15dcb6601aa7843839f84e56c3feac13 Merge branch 'master' into sculpt-mode-features === === diff --cc source/blender/editors/sculpt_paint/sculpt_intern.h index e6932cc35e4,b29ca1b4dd7..2c34112dd9e --- a/source/blender/editors/sculpt_paint/sculpt_intern.h +++ b/source/blender/editors/sculpt_paint/sculpt_intern.h @@@ -33,9 -32,8 +33,10 @@@ #include "BLI_threads.h" #include "BKE_pbvh.h" +#include "BKE_mesh.h" +#include "BKE_paint.h" + struct Main; struct KeyBlock; struct Object; struct SculptOrigVertData; diff --cc source/blender/modifiers/intern/MOD_remesh.c index 8edb0ef7b0c,23da1ec2754..1703a545fb9 --- a/source/blender/modifiers/intern/MOD_remesh.c +++ b/source/blender/modifiers/intern/MOD_remesh.c @@@ -282,95 -144,11 +283,96 @@@ static Mesh *applyModifier(ModifierDat rmd = (RemeshModifierData *)md; + if (rmd->mode == MOD_REMESH_QUAD) { +# ifdef WITH_QEX +Object *ob_orig = DEG_get_original_object(ctx->object); +RemeshModifierData *rmd_orig = (RemeshModifierData *)modifiers_findByName(ob_orig, md->name); + +if (((rmd->flag & MOD_REMESH_LIVE_REMESH) == 0)) { + // access mesh cache on ORIGINAL object, cow should not copy / free this over and over again + if (rmd_orig->mesh_cached) { +return copy_mesh(rmd_orig->mesh_cached); + } +} + +result = BKE_remesh_quad( +mesh, rmd->gradient_size, rmd->stiffness, rmd->iter, rmd->flag & MOD_REMESH_DIRECT_ROUND); + +if (result) { + // update cache + if (rmd_orig->mesh_cached) { +BKE_mesh_free(rmd_orig->mesh_cached); +rmd_orig->mesh_cached = NULL; + } + + // save a copy + rmd_orig->mesh_cached = copy_mesh(result); +} + +return result; +# else +modifier_setError((ModifierData *)rmd, "Built without QEx support, cant execute quad remesh"); +return mesh; +# endif + } + else if (rmd->mode == MOD_REMESH_VOXEL) { +# if defined WITH_OPENVDB +CSGVolume_Object *vcob; +struct OpenVDBLevelSet *level_set; + +Object *ob_orig = DEG_get_original_object(ctx->object); +RemeshModifierData *rmd_orig = (RemeshModifierData *)modifiers_findByName(ob_orig, md->name); + +if (((rmd->flag & MOD_REMESH_LIVE_REMESH) == 0)) { + // access mesh cache on ORIGINAL object, cow should not copy / free this over and over again + if (rmd_orig->mesh_cached) { +return copy_mesh(rmd_orig->mesh_cached); + } +} + +if (rmd->voxel_size > 0.0f) { + + struct OpenVDBTransform *xform = OpenVDBTransform_create(); + OpenVDBTransform_create_linear_transform(xform, rmd->voxel_size); + level_set = BKE_remesh_voxel_ovdb_mesh_to_level_set_create(mesh, xform); + OpenVDBTransform_free(xform); + + for (vcob = rmd->csg_operands.first; vcob; vcob = vcob->next) { +if (vcob->object && (vcob->flag & MOD_REMESH_CSG_OBJECT_ENABLED)) { + level_set = csgOperation(level_set, vcob, ctx->object, rmd); +} + } + + result = voxel_remesh(rmd, mesh, level_set); + + if (result) { +// update cache +if (rmd_orig->mesh_cached) { + BKE_mesh_free(rmd_orig->mesh_cached); + rmd_orig->mesh_cached = NULL; +} + +// save a copy +rmd_orig->mesh_cached = copy_mesh(result); + } + + return result; +} +else { + return mesh; +} +# else +modifier_setError((ModifierData *)rmd, + "Built without OpenVDB support, cant execute voxel remesh"); +return mesh; +# endif + } + init_dualcon_mesh(, mesh); - if (rmd->flag & MOD_REMESH_FLOOD_FILL) + if (rmd->flag & MOD_REMESH_FLOOD_FILL) { flags |= DUALCON_FLOOD_FILL; + } switch (rmd->mode) { case MOD_REMESH_CENTROID: ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [d79427986bc] sculpt-mode-features: Sculpt vertex colors: Color filter tool
Commit: d79427986bcd272925660c91a3498a7d2c237848 Author: Pablo Dobarro Date: Fri May 31 22:46:29 2019 +0200 Branches: sculpt-mode-features https://developer.blender.org/rBd79427986bcd272925660c91a3498a7d2c237848 Sculpt vertex colors: Color filter tool This tool allows the manipulation of all the colors stored in the vertices at once. Behavior and implementation are similar to the mesh filter tool. Sculpt vertex colors are not connected to the renderer, so the viewport does not update when EEVEE/Cycles is enabled. I also added some separators to the toolbar to separate brushes from filters. === M release/scripts/presets/keyconfig/keymap_data/blender_default.py M release/scripts/startup/bl_ui/space_toolsystem_toolbar.py M source/blender/editors/sculpt_paint/sculpt.c M source/blender/editors/sculpt_paint/sculpt_intern.h === diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py b/release/scripts/presets/keyconfig/keymap_data/blender_default.py index 2cc1c3a9178..63b9875c116 100644 --- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py +++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py @@ -5531,6 +5531,16 @@ def km_3d_view_tool_sculpt_mesh_filter(params): ]}, ) +def km_3d_view_tool_sculpt_color_filter(params): +return ( +"3D View Tool: Sculpt, Color Filter", +{"space_type": 'VIEW_3D', "region_type": 'WINDOW'}, +{"items": [ +("sculpt.color_filter", {"type": params.tool_tweak, "value": 'ANY'}, + None) +]}, +) + def km_3d_view_tool_sculpt_mask_filter(params): return ( @@ -5963,6 +5973,7 @@ def generate_keymaps(params=None): km_3d_view_tool_sculpt_box_hide(params), km_3d_view_tool_sculpt_box_mask(params), km_3d_view_tool_sculpt_mesh_filter(params), +km_3d_view_tool_sculpt_color_filter(params), km_3d_view_tool_sculpt_mask_filter(params), km_3d_view_tool_paint_weight_sample_weight(params), km_3d_view_tool_paint_weight_sample_vertex_group(params), diff --git a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py index 426e6ac0cd6..a1a0f7cd636 100644 --- a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py +++ b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py @@ -1007,6 +1007,24 @@ class _defs_sculpt: draw_settings=draw_settings, ) +@ToolDef.from_fn +def color_filter(): +def draw_settings(context, layout, tool): +props = tool.operator_properties("sculpt.color_filter") +sub = layout.row() +sub.use_property_split = False +sub.prop(props, "type", expand=False) +sub.prop(props, "strength") + +return dict( +idname="builtin.color_filter", +label="Color Filter", +icon="ops.sculpt.color_filter", +widget=None, +keymap= (), +draw_settings=draw_settings, +) + @ToolDef.from_fn def translate(): def draw_settings(context, layout, tool): @@ -1950,8 +1968,11 @@ class VIEW3D_PT_tools_active(ToolSelectPanelHelper, Panel): None, _defs_sculpt.hide_border, _defs_sculpt.mask_border, +None, _defs_sculpt.mesh_filter, +_defs_sculpt.color_filter, _defs_sculpt.mask_filter, +None, _defs_sculpt.translate, _defs_transform.rotate, *_tools_annotate, diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 872c4c29cb6..975889c7498 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -1722,6 +1722,43 @@ static float neighbor_max_mask(SculptSession *ss, const int vert, float *prev_ma return max; } +static void neighbor_average_color(SculptSession *ss, float avg[3], unsigned vert) +{ + const MeshElemMap *vert_map = >pmap[vert]; + const MVert *mvert = ss->mvert; + const float f = 0.00392156862; + + /* Don't modify corner vertices */ + if (vert_map->count > 1) { +int i, total = 0; + +zero_v3(avg); + +for (i = 0; i < vert_map->count; i++) { + const MPoly *p = >mpoly[vert_map->indices[i]]; + unsigned f_adj_v[2]; + + if (poly_get_adj_loops_from_vert(p, ss->mloop, vert, f_adj_v) != -1) { +int j; +for (j = 0; j < ARRAY_SIZE(f_adj_v); j += 1) { + if (vert_map->count != 2 || ss->pmap[f_adj_v[j]].count <= 2) { +
[Bf-blender-cvs] [e36ae3c1e44] sculpt-mode-features: Merge branch 'master' into sculpt-mode-features
Commit: e36ae3c1e44a34f91f166839ead58bb5420b50e0 Author: Pablo Dobarro Date: Fri May 31 23:10:45 2019 +0200 Branches: sculpt-mode-features https://developer.blender.org/rBe36ae3c1e44a34f91f166839ead58bb5420b50e0 Merge branch 'master' into sculpt-mode-features === === diff --cc source/blender/editors/sculpt_paint/sculpt.c index 975889c7498,4e5c2a74023..131424ff592 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@@ -7054,33 -6021,7 +7054,33 @@@ static void sculpt_init_session(Depsgra ob->sculpt = MEM_callocN(sizeof(SculptSession), "sculpt session"); ob->sculpt->mode_type = OB_MODE_SCULPT; + + /* Create the customdalayer for vcol for testing */ + Mesh *me = ob->data; + if (!CustomData_has_layer(>vdata, CD_MVERTCOL)) { +ob->sculpt->vcol = CustomData_add_layer_named( +>vdata, CD_MVERTCOL, CD_CALLOC, NULL, me->totvert, "vcols"); +for (int i = 0; i < me->totvert; i++) { + ob->sculpt->vcol[i].r = 255; + ob->sculpt->vcol[i].g = 255; + ob->sculpt->vcol[i].b = 255; + ob->sculpt->vcol[i].a = 255; +} + } + else { +ob->sculpt->vcol = CustomData_get_layer(>vdata, CD_MVERTCOL); + } + + /* init sculpt pivot */ + zero_v3(ob->sculpt->pivot_pos); + zero_v4(ob->sculpt->pivot_rot); + ob->sculpt->pivot_rot[3] = 1.0f; + + zero_v3(ob->sculpt->init_pivot_pos); + zero_v4(ob->sculpt->init_pivot_rot); + ob->sculpt->init_pivot_rot[3] = 1.0f; + - BKE_sculpt_update_mesh_elements(depsgraph, scene, scene->toolsettings->sculpt, ob, false, false); + BKE_sculpt_update_object_for_edit(depsgraph, ob, false, false); } static int ed_object_sculptmode_flush_recalc_flag(Scene *scene, @@@ -7599,1436 -6513,6 +7599,1436 @@@ static void SCULPT_OT_set_detail_size(w ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } +#define MESH_FILTER_RANDOM_MOD 50 + +static void filter_cache_init_task_cb(void *__restrict userdata, + const int i, + const ParallelRangeTLS *__restrict UNUSED(tls)) +{ + SculptThreadedTaskData *data = userdata; + SculptSession *ss = data->ob->sculpt; + PBVHNode *node = data->nodes[i]; + + PBVHVertexIter vd; + BKE_pbvh_vertex_iter_begin(ss->pbvh, node, vd, PBVH_ITER_UNIQUE) + { +int vi = vd.vert_indices[vd.i]; +if (vd.mask && (*vd.mask) < 1.0f) { + data->node_mask[i] = 1; +} +copy_v3_v3(ss->filter_cache->orco[vi], ss->mvert[vi].co); +if (data->filter_type && vi < MESH_FILTER_RANDOM_MOD) { + data->random_disp[vi % MESH_FILTER_RANDOM_MOD] = (float)rand() / (float)(RAND_MAX); +} + } + BKE_pbvh_vertex_iter_end; + + if (data->node_mask[i] == 1) { +if (data->init_colors) { + sculpt_undo_push_node(data->ob, node, SCULPT_UNDO_COLOR); +} +else { + sculpt_undo_push_node(data->ob, node, SCULPT_UNDO_COORDS); +} + } +} + +static void sculpt_filter_cache_init(Object *ob, Sculpt *sd, bool init_random, bool init_colors) +{ + SculptSession *ss = ob->sculpt; + PBVH *pbvh = ob->sculpt->pbvh; + PBVHNode **nodes; + int totnode; + + ss->filter_cache = MEM_callocN(sizeof(FilterCache), "filter cache"); + ss->filter_cache->orco = MEM_mallocN(3 * ss->totvert * sizeof(float), "orco"); + if (init_random) { +ss->filter_cache->random_disp = MEM_mallocN(MESH_FILTER_RANDOM_MOD * sizeof(float), +"random_disp"); + } + + if (init_colors && ss->vcol) { +ss->filter_cache->orvcol = MEM_dupallocN(ss->vcol); + } + + SculptSearchSphereData searchdata = { + .ss = ss, + .sd = sd, + .radius_squared = FLT_MAX, + }; + BKE_pbvh_search_gather(pbvh, sculpt_search_sphere_cb, , , ); + + int *node_mask = MEM_callocN(totnode * sizeof(int), "node mask"); + for (int i = 0; i < totnode; i++) { +node_mask[i] = 0; + } + + int filter_type; + if (init_random) { +filter_type = 1; + } + else { +filter_type = 0; + } + + SculptThreadedTaskData data = { + .sd = sd, + .ob = ob, + .nodes = nodes, + .filter_type = filter_type, + .init_colors = init_colors, + .random_disp = ss->filter_cache->random_disp, + .node_mask = node_mask, + }; + + ParallelRangeSettings settings; + BLI_parallel_range_settings_defaults(); + settings.use_threading = ((sd->flags & SCULPT_USE_OPENMP) && totnode > SCULPT_THREADED_LIMIT); + BLI_task_parallel_range(0, t
[Bf-blender-cvs] [ad5ac8c833c] sculpt-mode-features: Mask filter: Dirty and constrast mask filters
Commit: ad5ac8c833caa0c902054ba7e7dddf926769cd82 Author: Pablo Dobarro Date: Fri Jun 7 16:27:59 2019 +0200 Branches: sculpt-mode-features https://developer.blender.org/rBad5ac8c833caa0c902054ba7e7dddf926769cd82 Mask filter: Dirty and constrast mask filters The funcionality should be the same as the dirty vertex colors operator. This filter can be used to generate cavity mask for sculpting and painting. I also added a contrast filter to control the cavity mask. The contrast filter can be implemented with a real time preview in a future version instead of incrementing the contrast with fixed steps. === M release/scripts/startup/bl_ui/space_toolsystem_toolbar.py M source/blender/editors/sculpt_paint/sculpt.c M source/blender/editors/sculpt_paint/sculpt_intern.h === diff --git a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py index a1a0f7cd636..5ce53e3990d 100644 --- a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py +++ b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py @@ -979,6 +979,7 @@ class _defs_sculpt: sub.use_property_split = False sub.prop(props, "type", expand=False) sub.prop(props, "iterations") +sub.prop(props, "dirty_only") return dict( idname="builtin.mask_filter", diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 9dc592c51f5..d22750c1f89 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -1674,6 +1674,43 @@ static float neighbor_average_mask(SculptSession *ss, unsigned vert) } } +static float neighbor_dirty_mask(SculptSession *ss, const int vert) +{ + const MeshElemMap *vert_map = >pmap[vert]; + const MVert *mvert = ss->mvert; + + int i = 0; + int total = 0; + float avg[3]; + zero_v3(avg); + for (i = 0; i < vert_map->count; i++) { +const MPoly *p = >mpoly[vert_map->indices[i]]; +unsigned f_adj_v[2]; +if (poly_get_adj_loops_from_vert(p, ss->mloop, vert, f_adj_v) != -1) { + int j; + for (j = 0; j < ARRAY_SIZE(f_adj_v); j += 1) { +float normalized[3]; +sub_v3_v3v3(normalized, mvert[f_adj_v[j]].co, mvert[vert].co); +normalize_v3(normalized); +add_v3_v3(avg, normalized); +total++; + } +} + } + if (total > 0) { +mul_v3_fl(avg, 1.0f / total); +float normal[3]; +normal_short_to_float_v3(normal, mvert[vert].no); +float dot = dot_v3v3(avg, normal); +float ang = acos(dot); +if (ang < DEG2RAD(0)) { + ang = DEG2RAD(0); +} +return ang; + } + return 0; +} + static float neighbor_min_mask(SculptSession *ss, const int vert, float *prev_mask) { const MeshElemMap *vert_map = >pmap[vert]; @@ -8221,6 +8258,8 @@ typedef enum eSculptMaskFilterTypes { MASK_FILTER_SHARPEN = 1, MASK_FILTER_GROW = 2, MASK_FILTER_SHRINK = 3, + MASK_FILTER_DIRTY = 4, + MASK_FILTER_CONTRAST = 5, } eSculptMaskFilterTypes; EnumPropertyItem prop_mask_filter_types[] = { @@ -8228,6 +8267,8 @@ EnumPropertyItem prop_mask_filter_types[] = { {MASK_FILTER_SHARPEN, "SHARPEN", 0, "Sharpen Mask", "Sharpen mask"}, {MASK_FILTER_GROW, "GROW", 0, "Grow Mask", "Grow mask"}, {MASK_FILTER_SHRINK, "SHRINK", 0, "Shrink Mask", "Shrink mask"}, +{MASK_FILTER_DIRTY, "DIRTY", 0, "Dirty Mask", "Dirty mask"}, +{MASK_FILTER_CONTRAST, "CONTRAST", 0, "Contrast Mask", "Contrast mask"}, {0, NULL, 0, NULL, NULL}, }; @@ -8246,6 +8287,7 @@ static void mask_filter_task_cb(void *__restrict userdata, BKE_pbvh_vertex_iter_begin(ss->pbvh, node, vd, PBVH_ITER_UNIQUE) { float val; +float contrast, delta, gain, offset; switch (mode) { case MASK_FILTER_BLUR: if (BKE_pbvh_type(ss->pbvh) == PBVH_FACES) { @@ -8287,6 +8329,28 @@ static void mask_filter_task_cb(void *__restrict userdata, CLAMP(*vd.mask, 0.0f, 1.0f); } break; + case MASK_FILTER_DIRTY: +if (BKE_pbvh_type(ss->pbvh) == PBVH_FACES) { + val = neighbor_dirty_mask(ss, vd.vert_indices[vd.i]); + data->prev_mask[vd.vert_indices[vd.i]] = val; +} +break; + case MASK_FILTER_CONTRAST: +if (BKE_pbvh_type(ss->pbvh) == PBVH_FACES) { + contrast = 0.1; + delta = contrast / 2.0f; + gain = 1.0f - delta * 2.0f; + if (contrast > 0) { +gain = 1.0f / ((gain != 0.0f) ? gain : FLT_EPSILON); +offset = gain * (
[Bf-blender-cvs] [097157c8819] sculpt-mode-features: Fix EEVEE/LookDev viewport updates with filter tools
Commit: 097157c8819fc898969a51abcc97e4c83d02b7d5 Author: Pablo Dobarro Date: Wed Jun 5 16:09:49 2019 +0200 Branches: sculpt-mode-features https://developer.blender.org/rB097157c8819fc898969a51abcc97e4c83d02b7d5 Fix EEVEE/LookDev viewport updates with filter tools === M 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 131424ff592..9dc592c51f5 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -7842,7 +7842,6 @@ static void mesh_filter_task_cb(void *__restrict userdata, int sculpt_mesh_filter_modal(bContext *C, wmOperator *op, const wmEvent *event) { - ARegion *ar = CTX_wm_region(C); Object *ob = CTX_data_active_object(C); SculptSession *ss = ob->sculpt; Sculpt *sd = CTX_data_tool_settings(C)->sculpt; @@ -7852,6 +7851,10 @@ int sculpt_mesh_filter_modal(bContext *C, wmOperator *op, const wmEvent *event) float len = event->prevclickx - event->mval[0]; filter_strength = filter_strength * -len * 0.001f; + if (!ss->pbvh) { +return OPERATOR_RUNNING_MODAL; + } + SculptThreadedTaskData data = { .sd = sd, .ob = ob, @@ -7881,11 +7884,11 @@ int sculpt_mesh_filter_modal(bContext *C, wmOperator *op, const wmEvent *event) sculpt_update_keyblock(ob); } - ED_region_tag_redraw(ar); + sculpt_flush_update_step(C); - WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); if (event->type == 1 && event->val == 2) { sculpt_undo_push_end(); +sculpt_flush_update_done(C, ob); sculpt_filter_cache_free(ss); return OPERATOR_FINISHED; } @@ -7898,7 +7901,6 @@ int sculpt_mesh_filter_invoke(bContext *C, wmOperator *op, const wmEvent *event) Object *ob = CTX_data_active_object(C); Depsgraph *depsgraph = CTX_data_depsgraph(C); Sculpt *sd = CTX_data_tool_settings(C)->sculpt; - struct Scene *scene = CTX_data_scene(C); int mode = RNA_enum_get(op->ptr, "type"); PBVH *pbvh = ob->sculpt->pbvh; @@ -8864,10 +8866,7 @@ void ED_sculpt_update_modal_transform(const struct bContext *C, bool transform_p else if (ss->kb) { sculpt_update_keyblock(ob); } - - ED_region_tag_redraw(ar); - - WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); + sculpt_flush_update_step(C); } void ED_sculpt_end_transform(const struct bContext *C, bool transform_pivot_only) @@ -8875,6 +8874,7 @@ void ED_sculpt_end_transform(const struct bContext *C, bool transform_pivot_only sculpt_undo_push_end(); Object *ob = CTX_data_active_object(C); SculptSession *ss = ob->sculpt; + sculpt_flush_update_done(C, ob); if (ss->filter_cache) { sculpt_filter_cache_free(ss); } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [450e5472985] sculpt-mode-features: Merge branch 'master' into sculpt-mode-features
Commit: 450e5472985dd6dd6574a553f7d2547700aea2f6 Author: Pablo Dobarro Date: Sun Jun 16 23:01:16 2019 +0200 Branches: sculpt-mode-features https://developer.blender.org/rB450e5472985dd6dd6574a553f7d2547700aea2f6 Merge branch 'master' into sculpt-mode-features === === diff --cc build_files/cmake/macros.cmake index 098792d4be6,5b995763111..d645b87e836 --- a/build_files/cmake/macros.cmake +++ b/build_files/cmake/macros.cmake @@@ -218,42 -233,42 +233,41 @@@ endmacro( # only MSVC uses SOURCE_GROUP function(blender_add_lib__impl - name - sources - includes - includes_sys - library_deps - ) - - # message(STATUS "Configuring library ${name}") + name + sources + includes + includes_sys + library_deps + ) - # include_directories(${includes}) - # include_directories(SYSTEM ${includes_sys}) - blender_include_dirs("${includes}") - blender_include_dirs_sys("${includes_sys}") + # message(STATUS "Configuring library ${name}") - add_library(${name} ${sources}) + # include_directories(${includes}) + # include_directories(SYSTEM ${includes_sys}) + blender_include_dirs("${includes}") + blender_include_dirs_sys("${includes_sys}") - if (NOT "${library_deps}" STREQUAL "") - target_link_libraries(${name} "${library_deps}") - endif() + add_library(${name} ${sources}) - # works fine without having the includes - # listed is helpful for IDE's (QtCreator/MSVC) - blender_source_group("${sources}") + if (NOT "${library_deps}" STREQUAL "") + target_link_libraries(${name} INTERFACE "${library_deps}") + endif() - #if enabled, set the FOLDER property for visual studio projects - if(WINDOWS_USE_VISUAL_STUDIO_FOLDERS) - get_filename_component(FolderDir ${CMAKE_CURRENT_SOURCE_DIR} DIRECTORY) - string(REPLACE ${CMAKE_SOURCE_DIR} "" FolderDir ${FolderDir}) - set_target_properties(${name} PROPERTIES FOLDER ${FolderDir}) - endif() + # works fine without having the includes + # listed is helpful for IDE's (QtCreator/MSVC) + blender_source_group("${sources}") - list_assert_duplicates("${sources}") - list_assert_duplicates("${includes}") - # Not for system includes because they can resolve to the same path - # list_assert_duplicates("${includes_sys}") + #if enabled, set the FOLDER property for visual studio projects + if(WINDOWS_USE_VISUAL_STUDIO_PROJECT_FOLDERS) + get_filename_component(FolderDir ${CMAKE_CURRENT_SOURCE_DIR} DIRECTORY) + string(REPLACE ${CMAKE_SOURCE_DIR} "" FolderDir ${FolderDir}) + set_target_properties(${name} PROPERTIES FOLDER ${FolderDir}) + endif() + list_assert_duplicates("${sources}") + list_assert_duplicates("${includes}") + # Not for system includes because they can resolve to the same path + # list_assert_duplicates("${includes_sys}") - endfunction() @@@ -1477,24 -1214,47 +1491,47 @@@ macro(openmp_delayloa endmacro() macro(WINDOWS_SIGN_TARGET target) - if(WITH_WINDOWS_CODESIGN) -if(!SIGNTOOL_EXE) - error("Codesigning is enabled, but signtool is not found") -else() - if(WINDOWS_CODESIGN_PFX_PASSWORD) -set(CODESIGNPASSWORD /p ${WINDOWS_CODESIGN_PFX_PASSWORD}) - else() -if($ENV{PFXPASSWORD}) - set(CODESIGNPASSWORD /p $ENV{PFXPASSWORD}) -else() - message(FATAL_ERROR "WITH_WINDOWS_CODESIGN is on but WINDOWS_CODESIGN_PFX_PASSWORD not set, and environment variable PFXPASSWORD not found, unable to sign code.") -endif() - endif() - add_custom_command(TARGET ${target} -POST_BUILD -COMMAND ${SIGNTOOL_EXE} sign /f ${WINDOWS_CODESIGN_PFX} ${CODESIGNPASSWORD} $ -VERBATIM - ) -endif() - endif() + if(WITH_WINDOWS_CODESIGN) + if(!SIGNTOOL_EXE) + error("Codesigning is enabled, but signtool is not found") + else() + if(WINDOWS_CODESIGN_PFX_PASSWORD) + set(CODESIGNPASSWORD /p ${WINDOWS_CODESIGN_PFX_PASSWORD}) + else() + if($ENV{PFXPASSWORD}) + set(CODESIGNPASSWORD /p $ENV{PFXPASSWORD}) + else() + message(FATAL_ERROR "WITH_WINDOWS_CODESIGN is on but WINDOWS_CODESIGN_PFX_PASSWORD not set, and environment variable PFXPASSWORD not found, unable
[Bf-blender-cvs] [5b19ecdc6bf] sculpt-mode-features: Add remesh panel to the topbar
Commit: 5b19ecdc6bfe875a952731d5d2a79bb0be2e9e7e Author: Pablo Dobarro Date: Sun Jun 16 23:16:07 2019 +0200 Branches: sculpt-mode-features https://developer.blender.org/rB5b19ecdc6bfe875a952731d5d2a79bb0be2e9e7e Add remesh panel to the topbar This panel has the same options as the mesh properties remesh panel. === M release/scripts/startup/bl_ui/space_view3d_toolbar.py === diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py index 7fe0888e6e4..bb289c23970 100644 --- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py +++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py @@ -1127,6 +1127,38 @@ class VIEW3D_PT_sculpt_dyntopo_remesh(Panel, View3DPaintPanel): col = flow.column() col.operator("sculpt.detail_flood_fill") +class VIEW3D_PT_sculpt_remesh(Panel, View3DPaintPanel): +bl_context = ".sculpt_mode" # dot on purpose (access from topbar) +bl_label = "Remesh" +bl_options = {'DEFAULT_CLOSED'} +bl_ui_units_x = 12 + +@classmethod +def poll(cls, context): +return (context.sculpt_object and context.tool_settings.sculpt) + +def draw_header(self, context): +is_popover = self.is_popover +layout = self.layout +layout.operator( +"object.remesh", +text="", +emboss=is_popover, +) + +def draw(self, context): +layout = self.layout +layout.use_property_split = True +layout.use_property_decorate = False + +col = layout.column() +mesh = context.active_object.data +col.prop(mesh, "voxel_size") +col.prop(mesh, "smooth_normals") +col.prop(mesh, "reproject_vertex_paint") +col.prop(mesh, "reproject_paint_mask") +col.operator("object.remesh", text="Remesh") + # TODO, move to space_view3d.py @@ -2140,6 +2172,7 @@ classes = ( VIEW3D_PT_tools_brush_display_custom_icon, VIEW3D_PT_sculpt_dyntopo, VIEW3D_PT_sculpt_dyntopo_remesh, +VIEW3D_PT_sculpt_remesh, VIEW3D_PT_sculpt_symmetry, VIEW3D_PT_sculpt_symmetry_for_topbar, VIEW3D_PT_sculpt_options, ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [80b4987139e] sculpt-mode-features: Fix crash with mesh filters and EEVEE
Commit: 80b4987139ed6c0eec6bc01d09954021d7b5 Author: Pablo Dobarro Date: Sun Jun 16 23:11:24 2019 +0200 Branches: sculpt-mode-features https://developer.blender.org/rB80b4987139ed6c0eec6bc01d09954021d7b5 Fix crash with mesh filters and EEVEE === M 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 4096dcef384..d398f113c81 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -7893,6 +7893,7 @@ int sculpt_mesh_filter_modal(bContext *C, wmOperator *op, const wmEvent *event) Object *ob = CTX_data_active_object(C); SculptSession *ss = ob->sculpt; Sculpt *sd = CTX_data_tool_settings(C)->sculpt; + View3D *v3d = CTX_wm_view3d(C); int mode = RNA_enum_get(op->ptr, "type"); float filter_strength = RNA_float_get(op->ptr, "strength"); @@ -7903,6 +7904,22 @@ int sculpt_mesh_filter_modal(bContext *C, wmOperator *op, const wmEvent *event) return OPERATOR_RUNNING_MODAL; } + if (!BKE_sculptsession_use_pbvh_draw(ob, v3d)) { +if (ss->filter_cache->nodes) { + MEM_freeN(ss->filter_cache->nodes); +} +SculptSearchSphereData searchdata = { +.ss = ss, +.sd = sd, +.radius_squared = FLT_MAX, +}; +BKE_pbvh_search_gather(ss->pbvh, + sculpt_search_sphere_cb, + , + >filter_cache->nodes, + >filter_cache->totnode); + } + SculptThreadedTaskData data = { .sd = sd, .ob = ob, ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [184b8d2bb3c] sculpt-mode-features: Add front faces only option to the mask lasso tool
Commit: 184b8d2bb3c47a9afc10ee5dccd82ce2a9e5d294 Author: Pablo Dobarro Date: Sun Jun 16 23:05:15 2019 +0200 Branches: sculpt-mode-features https://developer.blender.org/rB184b8d2bb3c47a9afc10ee5dccd82ce2a9e5d294 Add front faces only option to the mask lasso tool === M release/scripts/startup/bl_ui/space_toolsystem_toolbar.py === diff --git a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py index d596791df95..d0dae4f081d 100644 --- a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py +++ b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py @@ -973,12 +973,18 @@ class _defs_sculpt: @ToolDef.from_fn def mask_lasso(): +def draw_settings(context, layout, tool): +props = tool.operator_properties("paint.mask_lasso_gesture") +sub = layout.row() +sub.use_property_split = False +sub.prop(props, "front_faces_only") return dict( idname="builtin.lasso_mask", label="Lasso Mask", icon="ops.sculpt.lasso_mask", widget=None, keymap=(), +draw_settings=draw_settings, ) @ToolDef.from_fn ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [d9fd3be084f] sculpt-mode-features: Pose tool: Mask expand operator
Commit: d9fd3be084fa9dabb3d73b8e3b24d5394acb2483 Author: Pablo Dobarro Date: Tue Jun 11 15:28:10 2019 +0200 Branches: sculpt-mode-features https://developer.blender.org/rBd9fd3be084fa9dabb3d73b8e3b24d5394acb2483 Pose tool: Mask expand operator This operator is designed to use with the transform.rotate tool to create a pose tool. It generates a mask from the active vertex, following the topology of the mesh. The operator has two modes. It can expand the mask to the vertex under the cursor or to a certain number of iterations. All the iterations are cached when the operator is invoked, so it should be usable with high poly meshes. I also included some hardcoded mask operations when the operator finishes. In the future, this could be included as an operator macro if it does not have a significant performance penalty (like redrawing all nodes each time a new operator is invoked). It does not support symmetry and it only works with meshes (no dyntopo or multires). I also fixed some bugs in the transform code that were breaking EEVEE compatibility. Undo system still fails sometimes. === M source/blender/draw/modes/sculpt_mode.c M source/blender/editors/sculpt_paint/sculpt.c M source/blender/editors/sculpt_paint/sculpt_intern.h === diff --git a/source/blender/draw/modes/sculpt_mode.c b/source/blender/draw/modes/sculpt_mode.c index 42a2333f305..18deddb04ae 100644 --- a/source/blender/draw/modes/sculpt_mode.c +++ b/source/blender/draw/modes/sculpt_mode.c @@ -155,7 +155,7 @@ static void SCULPT_cache_populate(void *vedata, Object *ob) if (ob->sculpt) { const DRWContextState *draw_ctx = DRW_context_state_get(); -if ((ob == draw_ctx->obact) && BKE_sculptsession_use_pbvh_draw(ob, draw_ctx->v3d)) { +if (ob == draw_ctx->obact) { PBVH *pbvh = ob->sculpt->pbvh; if (pbvh && pbvh_has_mask(pbvh)) { DRW_shgroup_call_sculpt(stl->g_data->mask_overlay_grp, ob, false, true, false); diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index d22750c1f89..266279e688b 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -31,6 +31,7 @@ #include "BLI_utildefines.h" #include "BLI_ghash.h" #include "BLI_stack.h" +#include "BLI_gsqueue.h" #include "BLT_translation.h" @@ -7756,14 +7757,21 @@ static void sculpt_filter_cache_init(Object *ob, Sculpt *sd, bool init_random, b static void sculpt_filter_cache_free(SculptSession *ss) { - MEM_freeN(ss->filter_cache->orco); - MEM_freeN(ss->filter_cache->nodes); + if (ss->filter_cache->orco) { +MEM_freeN(ss->filter_cache->orco); + } + if (ss->filter_cache->nodes) { +MEM_freeN(ss->filter_cache->nodes); + } if (ss->filter_cache->random_disp) { MEM_freeN(ss->filter_cache->random_disp); } if (ss->filter_cache->orvcol) { MEM_freeN(ss->filter_cache->orvcol); } + if (ss->filter_cache->mask_update_it) { +MEM_freeN(ss->filter_cache->mask_update_it); + } MEM_freeN(ss->filter_cache); } @@ -8788,7 +8796,6 @@ void ED_sculpt_init_transform(const struct bContext *C, bool transform_pivot_onl Sculpt *sd = CTX_data_tool_settings(C)->sculpt; Object *ob = CTX_data_active_object(C); SculptSession *ss = ob->sculpt; - struct Scene *scene = CTX_data_scene(C); Depsgraph *depsgraph = CTX_data_depsgraph(C); copy_v3_v3(ss->init_pivot_pos, ss->pivot_pos); @@ -8938,16 +8945,36 @@ void ED_sculpt_update_modal_transform(const struct bContext *C, bool transform_p Sculpt *sd = CTX_data_tool_settings(C)->sculpt; Object *ob = CTX_data_active_object(C); SculptSession *ss = ob->sculpt; - ARegion *ar = CTX_wm_region(C); - struct Scene *scene = CTX_data_scene(C); + View3D *v3d = CTX_wm_view3d(C); Depsgraph *depsgraph = CTX_data_depsgraph(C); if (transform_pivot_only) { return; } + if (!ss->pbvh) { +return; + } + BKE_sculpt_update_object_for_edit(depsgraph, ob, false, true); + if (!BKE_sculptsession_use_pbvh_draw(ob, v3d)) { + +if (ss->filter_cache->nodes) { + MEM_freeN(ss->filter_cache->nodes); +} +SculptSearchSphereData searchdata = { +.ss = ss, +.sd = sd, +.radius_squared = FLT_MAX, +}; +BKE_pbvh_search_gather(ss->pbvh, + sculpt_search_sphere_cb, + , + >filter_cache->nodes, + >filter_cache->totnode); + } + SculptThreadedTaskData data = { .sd = sd, .ob = ob, @@ -9038,7 +9065,6 @@ static int sculpt_set_pivot_position_invoke(bCont
[Bf-blender-cvs] [8d17efaf7b7] sculpt-mode-features: Merge branch 'master' into sculpt-mode-features
Commit: 8d17efaf7b71afa6cee252fa81b9e49016dbc118 Author: Pablo Dobarro Date: Sat Jun 22 18:30:34 2019 +0200 Branches: sculpt-mode-features https://developer.blender.org/rB8d17efaf7b71afa6cee252fa81b9e49016dbc118 Merge branch 'master' into sculpt-mode-features === === diff --cc source/blender/blenkernel/BKE_pbvh.h index 2e096991eeb,4779a27853e..01c8091e7b0 --- a/source/blender/blenkernel/BKE_pbvh.h +++ b/source/blender/blenkernel/BKE_pbvh.h @@@ -141,9 -134,8 +142,10 @@@ bool BKE_pbvh_node_raycast(PBVH *bvh float (*origco)[3], bool use_origco, const float ray_start[3], + const float ray_normal[3], -float *depth, -RaycastOutputData *output_data); ++ RaycastOutputData *output_data, +struct IsectRayPrecalc *isect_precalc, +float *depth); bool BKE_pbvh_bmesh_node_raycast_detail(PBVHNode *node, const float ray_start[3], diff --cc source/blender/blenkernel/intern/pbvh.c index b13ba9ddc20,ffc4ec65d4d..540489e38fe --- a/source/blender/blenkernel/intern/pbvh.c +++ b/source/blender/blenkernel/intern/pbvh.c @@@ -1755,9 -1753,8 +1754,10 @@@ static bool pbvh_faces_node_raycast(PBV const PBVHNode *node, float (*origco)[3], const float ray_start[3], +const float ray_normal[3], - float *depth, - RaycastOutputData *output_data) ++RaycastOutputData *output_data, + struct IsectRayPrecalc *isect_precalc, + float *depth) { const MVert *vert = bvh->verts; const MLoop *mloop = bvh->mloop; @@@ -1818,9 -1797,8 +1818,10 @@@ static bool pbvh_grids_node_raycast(PBV PBVHNode *node, float (*origco)[3], const float ray_start[3], +const float ray_normal[3], - float *depth, - RaycastOutputData *output_data) ++RaycastOutputData *output_data, + struct IsectRayPrecalc *isect_precalc, + float *depth) { const int totgrid = node->totprim; const int gridsize = bvh->gridkey.grid_size; @@@ -1899,9 -1857,8 +1900,10 @@@ bool BKE_pbvh_node_raycast(PBVH *bvh float (*origco)[3], bool use_origco, const float ray_start[3], + const float ray_normal[3], -float *depth, -RaycastOutputData *output_data) ++ RaycastOutputData *output_data, +struct IsectRayPrecalc *isect_precalc, +float *depth) { bool hit = false; @@@ -1911,13 -1868,13 +1913,16 @@@ switch (bvh->type) { case PBVH_FACES: - hit |= pbvh_faces_node_raycast(bvh, node, origco, ray_start, ray_normal, depth, output_data); - hit |= pbvh_faces_node_raycast(bvh, node, origco, ray_start, isect_precalc, depth); ++ hit |= pbvh_faces_node_raycast( ++ bvh, node, origco, ray_start, ray_normal, output_data, isect_precalc, depth); break; case PBVH_GRIDS: - hit |= pbvh_grids_node_raycast(bvh, node, origco, ray_start, ray_normal, depth, output_data); - hit |= pbvh_grids_node_raycast(bvh, node, origco, ray_start, isect_precalc, depth); ++ hit |= pbvh_grids_node_raycast( ++ bvh, node, origco, ray_start, ray_normal, output_data, isect_precalc, depth); break; case PBVH_BMESH: - hit = pbvh_bmesh_node_raycast(node, ray_start, ray_normal, depth, use_origco, output_data); - hit = pbvh_bmesh_node_raycast(node, ray_start, isect_precalc, depth, use_origco); ++ hit = pbvh_bmesh_node_raycast( ++ node, ray_start, ray_normal, isect_precalc, depth, use_origco, output_data); break; } diff --cc source/blender/blenkernel/intern/pbvh_bmesh.c index b1414fe290b,1d8088c6605..e58d95d86b4 --- a/source/blender/blenkernel/intern/pbvh_bmesh.c +++ b/source/blender/blenkernel/intern/pbvh_bmesh.c @@@ -1508,10 -1508,9 +1508,11 @@@ static bool pbvh_bmesh_collapse_short_e bool pbvh_bmesh_node_raycast(PBVHNode *node,
[Bf-blender-cvs] [d30f72dfd8a] master: Fix sculpt not updating on undo with EEVEE enabled
Commit: d30f72dfd8acdac26e7888dbb2f4628f6baac707 Author: Pablo Dobarro Date: Wed Jun 19 20:29:25 2019 +0200 Branches: master https://developer.blender.org/rBd30f72dfd8acdac26e7888dbb2f4628f6baac707 Fix sculpt not updating on undo with EEVEE enabled === M source/blender/editors/sculpt_paint/sculpt_undo.c === diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c index 75a2af4526f..8c8d4487ada 100644 --- a/source/blender/editors/sculpt_paint/sculpt_undo.c +++ b/source/blender/editors/sculpt_paint/sculpt_undo.c @@ -459,6 +459,7 @@ static void sculpt_undo_restore_list(bContext *C, ListBase *lb) { Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); + View3D *v3d = CTX_wm_view3d(C); Object *ob = OBACT(view_layer); Depsgraph *depsgraph = CTX_data_depsgraph(C); SculptSession *ss = ob->sculpt; @@ -560,7 +561,7 @@ static void sculpt_undo_restore_list(bContext *C, ListBase *lb) } } -tag_update |= ((Mesh *)ob->data)->id.us > 1; +tag_update |= ((Mesh *)ob->data)->id.us > 1 || !BKE_sculptsession_use_pbvh_draw(ob, v3d); if (ss->kb || ss->modifiers_active) { Mesh *mesh = ob->data; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [2f77175fecc] master: Fix sculpt mask not visible in EEVEE
Commit: 2f77175fecc7fa444d351d47000209e248611ee6 Author: Pablo Dobarro Date: Thu Jun 20 17:03:04 2019 +0200 Branches: master https://developer.blender.org/rB2f77175fecc7fa444d351d47000209e248611ee6 Fix sculpt mask not visible in EEVEE Differential Revision: https://developer.blender.org/D5092 === M source/blender/draw/modes/sculpt_mode.c === diff --git a/source/blender/draw/modes/sculpt_mode.c b/source/blender/draw/modes/sculpt_mode.c index 42a2333f305..1b196cd8bb7 100644 --- a/source/blender/draw/modes/sculpt_mode.c +++ b/source/blender/draw/modes/sculpt_mode.c @@ -155,7 +155,8 @@ static void SCULPT_cache_populate(void *vedata, Object *ob) if (ob->sculpt) { const DRWContextState *draw_ctx = DRW_context_state_get(); -if ((ob == draw_ctx->obact) && BKE_sculptsession_use_pbvh_draw(ob, draw_ctx->v3d)) { +if ((ob == draw_ctx->obact) && +(BKE_sculptsession_use_pbvh_draw(ob, draw_ctx->v3d) || !ob->sculpt->modifiers_active)) { PBVH *pbvh = ob->sculpt->pbvh; if (pbvh && pbvh_has_mask(pbvh)) { DRW_shgroup_call_sculpt(stl->g_data->mask_overlay_grp, ob, false, true, false); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [303cee750ed] sculpt-mode-features: Mesh Filter: Initial work for relax mesh filter
Commit: 303cee750ed91240d3838b03e1cef1c8e455870a Author: Pablo Dobarro Date: Tue May 14 19:25:35 2019 +0200 Branches: sculpt-mode-features https://developer.blender.org/rB303cee750ed91240d3838b03e1cef1c8e455870a Mesh Filter: Initial work for relax mesh filter The mesh filter tool now manages its own orco cache, so there is no need for a global orco mode using the pbvh proxies. The tool should be much faster than before. The code for the relax mesh filter is there, but it is disabled in the interface until the algorithm is finished. === M source/blender/blenkernel/BKE_paint.h M source/blender/editors/sculpt_paint/sculpt.c === diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h index 6b47eb4f246..a492158c50e 100644 --- a/source/blender/blenkernel/BKE_paint.h +++ b/source/blender/blenkernel/BKE_paint.h @@ -269,7 +269,8 @@ typedef struct SculptSession { float cursor_location[3]; float cursor_view_normal[3]; float cursor_normal[3]; - bool use_orco; + + float (*orco)[3]; /* Automasking active vertex */ MVert *active_vertex_mesh; diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 11e7bf5ab70..2dc2bb5e18a 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -2338,6 +2338,112 @@ static void do_smooth_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod smooth(sd, ob, nodes, totnode, ss->cache->bstrength, false); } +static void relax_vertex(float final_dp[3], PBVHVertexIter vd, SculptSession *ss, bool use_ss_orco) +{ + MVert *mvert = ss->mvert; + float final_disp[2][3]; + int vert = vd.vert_indices[vd.i]; + const MeshElemMap *vert_map = >pmap[vert]; + GSet *vert_gset[2]; + vert_gset[0] = BLI_gset_new(BLI_ghashutil_uinthash, BLI_ghashutil_intcmp, "verts sets"); + vert_gset[1] = BLI_gset_new(BLI_ghashutil_uinthash, BLI_ghashutil_intcmp, "verts sets"); + BLI_gset_clear(vert_gset[0], NULL); + BLI_gset_clear(vert_gset[1], NULL); + float len_avg[2] = {0.0f}; + + for (int i = 0; i < vert_map->count; i++) { +const MPoly *p = >mpoly[vert_map->indices[i]]; +unsigned f_adj_v[2]; +if (poly_get_adj_loops_from_vert(p, ss->mloop, vert, f_adj_v) != -1) { + if (vert_map->count > 1) { +if (i == 0) { + BLI_gset_add(vert_gset[0], f_adj_v[0]); + BLI_gset_add(vert_gset[1], f_adj_v[1]); +} +else if (BLI_gset_haskey(vert_gset[0], f_adj_v[0])) { + BLI_gset_add(vert_gset[1], f_adj_v[1]); +} +else if (BLI_gset_haskey(vert_gset[1], f_adj_v[0])) { + BLI_gset_add(vert_gset[0], f_adj_v[1]); +} +else if (BLI_gset_haskey(vert_gset[0], f_adj_v[1])) { + BLI_gset_add(vert_gset[1], f_adj_v[0]); +} +else if (BLI_gset_haskey(vert_gset[1], f_adj_v[1])) { + BLI_gset_add(vert_gset[0], f_adj_v[0]); +} + } +} + } + + for (int vs = 0; vs < 2; vs++) { +int total = 0; +GSetIterator *gsi = BLI_gsetIterator_new(vert_gset[vs]); + +for (BLI_gsetIterator_init(gsi, (GHash *)vert_gset[vs]); !BLI_gsetIterator_done(gsi); + BLI_gsetIterator_step(gsi)) { + int vin = BLI_gsetIterator_getKey(gsi); + MVert *c_vert = >mvert[vin]; + float connected_vert_co[3]; + if (use_ss_orco) { +copy_v3_v3(connected_vert_co, ss->orco[vin]); + } + else { +copy_v3_v3(connected_vert_co, c_vert->co); + } + len_avg[vs] += len_v3v3(vd.co, connected_vert_co); + total++; +} + +BLI_gsetIterator_free(gsi); +if (total > 0) { + len_avg[vs] = len_avg[vs] / (float)total; +} +zero_v3(final_disp[vs]); + +gsi = BLI_gsetIterator_new(vert_gset[vs]); + +for (BLI_gsetIterator_init(gsi, (GHash *)vert_gset[vs]); !BLI_gsetIterator_done(gsi); + BLI_gsetIterator_step(gsi)) { + int vin = BLI_gsetIterator_getKey(gsi); + MVert *c_vert = >mvert[vin]; + float connected_vert_co[3]; + float connected_vert_disp[3]; + if (use_ss_orco) { +copy_v3_v3(connected_vert_co, ss->orco[vin]); + } + else { +copy_v3_v3(connected_vert_co, c_vert->co); + } + float len = len_v3v3(vd.co, connected_vert_co); + float len_difference = len_avg[vs] - len; + sub_v3_v3v3(connected_vert_disp, vd.co, connected_vert_co); + normalize_v3(connected_vert_disp); + mul_v3_fl(connected_vert_disp, len_difference); + add_v3_v3(final_disp[vs], connected_vert_disp); +} +BLI_gsetIterator_free(gsi); +if (total > 0) { + mul_v3_fl(final_disp[vs], 1.0f / total); +} + } + + BLI_gset_free(vert_gset[0], NULL); + BLI_gset_free(vert_gset[1], NULL); + +
[Bf-blender-cvs] [66f6bd0c248] sculpt-mode-features: Relax Brush: Initial implementation
Commit: 66f6bd0c24833de8331a178691f2b2f308de384f Author: Pablo Dobarro Date: Tue May 14 00:35:31 2019 +0200 Branches: sculpt-mode-features https://developer.blender.org/rB66f6bd0c24833de8331a178691f2b2f308de384f Relax Brush: Initial implementation Work in progress. This still has a lot of bugs and I'm not sure if this approach is the best for this kind of smoothing. The current implementation can't handle poles with 5 vertices or more, so it doesn't work properly with the result of the voxel remesher. It does not support multires. Also, I'm using gsets to store the smoothing groups. I'm sure that there is a better way to do it. If for some reason someone enters sculpt mode and touches a pole with 30 vertices it should not crash, but it adds an unnecessary overhead when working with properly constructed quad meshes. === M source/blender/editors/sculpt_paint/sculpt.c M source/blender/makesdna/DNA_brush_types.h M source/blender/makesrna/intern/rna_brush.c === diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index bfc20dd8210..11e7bf5ab70 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -126,7 +126,7 @@ static bool sculpt_tool_needs_original(const char sculpt_tool) static bool sculpt_tool_is_proxy_used(const char sculpt_tool) { - return ELEM(sculpt_tool, SCULPT_TOOL_SMOOTH, SCULPT_TOOL_LAYER); + return ELEM(sculpt_tool, SCULPT_TOOL_SMOOTH, SCULPT_TOOL_LAYER, SCULPT_TOOL_RELAX); } static bool sculpt_brush_use_topology_rake(const SculptSession *ss, const Brush *brush) @@ -1198,6 +1198,8 @@ static float brush_strength(const Sculpt *sd, case SCULPT_TOOL_SMOOTH: return alpha * pressure * feather; +case SCULPT_TOOL_RELAX: + return alpha * pressure * feather; case SCULPT_TOOL_PINCH: if (flip > 0) { @@ -2336,6 +2338,184 @@ static void do_smooth_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod smooth(sd, ob, nodes, totnode, ss->cache->bstrength, false); } +static void do_relax_brush_task_cb_ex(void *__restrict userdata, + const int n, + const ParallelRangeTLS *__restrict tls) +{ + SculptThreadedTaskData *data = userdata; + SculptSession *ss = data->ob->sculpt; + Sculpt *sd = data->sd; + const Brush *brush = data->brush; + const bool smooth_mask = data->smooth_mask; + float bstrength = data->strength; + + PBVHVertexIter vd; + + CLAMP(bstrength, 0.0f, 1.0f); + + SculptBrushTest test; + SculptBrushTestFn sculpt_brush_test_sq_fn = sculpt_brush_test_init_with_falloff_shape( + ss, , data->brush->falloff_shape); + + MVert *mvert = ss->mvert; + BKE_pbvh_vertex_iter_begin(ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE) + { + +if (sculpt_brush_test_sq_fn(, vd.co)) { + float fade = bstrength * tex_strength(ss, +brush, +vd.co, +sqrtf(test.dist), +vd.no, +vd.fno, +smooth_mask ? 0.0f : (vd.mask ? *vd.mask : 0.0f), +tls->thread_id); + + float final_disp[2][3]; + float final_pos[3]; + int vert = vd.vert_indices[vd.i]; + const MeshElemMap *vert_map = >pmap[vert]; + GSet *vert_gset[2]; + vert_gset[0] = BLI_gset_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "verts sets"); + vert_gset[1] = BLI_gset_new(BLI_ghashutil_ptrhash, BLI_ghashutil_ptrcmp, "verts sets"); + BLI_gset_clear(vert_gset[0], NULL); + BLI_gset_clear(vert_gset[1], NULL); + float len_avg[2] = {0.0f}; + + for (int i = 0; i < vert_map->count; i++) { +const MPoly *p = >mpoly[vert_map->indices[i]]; +unsigned f_adj_v[2]; +if (poly_get_adj_loops_from_vert(p, ss->mloop, vert, f_adj_v) != -1) { + if (vert_map->count > 1) { +if (i == 0) { + BLI_gset_add(vert_gset[0], [f_adj_v[0]]); + BLI_gset_add(vert_gset[1], [f_adj_v[1]]); +} +else if (BLI_gset_haskey(vert_gset[0], [f_adj_v[0]])) { + BLI_gset_add(vert_gset[1], [f_adj_v[1]]); +} +else if (BLI_gset_haskey(vert_gset[1], [f_adj_v[0]])) { + BLI_gset_add(vert_gset[0], [f_adj_v[1]]); +} +else if (BLI_gset_haskey(vert_gset[0], [f_adj_v[1]])) { + BLI_gset_add(vert_gset[1], [f_adj_v[0]]); +} +else if (BLI_gset_h
[Bf-blender-cvs] [01b0d4bf315] sculpt-mode-features: Cleanup: comments formatting
Commit: 01b0d4bf3158fe3d7db5d2988630a772a14584d5 Author: Pablo Dobarro Date: Tue May 14 00:38:51 2019 +0200 Branches: sculpt-mode-features https://developer.blender.org/rB01b0d4bf3158fe3d7db5d2988630a772a14584d5 Cleanup: comments formatting === M intern/openvdb/openvdb_capi.cc M source/blender/blenkernel/intern/remesh_quad.c M source/blender/blenkernel/intern/remesh_voxel.c M source/blender/editors/mesh/editmesh_add.c M source/blender/editors/transform/transform_conversions.c M source/blender/makesdna/DNA_modifier_types.h M source/blender/modifiers/intern/MOD_remesh.c === diff --git a/intern/openvdb/openvdb_capi.cc b/intern/openvdb/openvdb_capi.cc index fea1f6034f0..0bee45934d1 100644 --- a/intern/openvdb/openvdb_capi.cc +++ b/intern/openvdb/openvdb_capi.cc @@ -368,7 +368,7 @@ OpenVDBLevelSet *OpenVDBLevelSet_transform_and_resample(struct OpenVDBLevelSet * break; case OPENVDB_LEVELSET_GRIDSAMPLER_NONE: - //targetGrid = sourceGrid->deepCopy(); + // targetGrid = sourceGrid->deepCopy(); break; } diff --git a/source/blender/blenkernel/intern/remesh_quad.c b/source/blender/blenkernel/intern/remesh_quad.c index bd5863b34bc..606023840bf 100644 --- a/source/blender/blenkernel/intern/remesh_quad.c +++ b/source/blender/blenkernel/intern/remesh_quad.c @@ -63,7 +63,7 @@ Mesh *BKE_remesh_quad( int num_verts = mesh->totvert; qex_TriMesh *trimesh = MEM_callocN(sizeof(qex_TriMesh), "trimesh"); qex_QuadMesh quadmesh; //= MEM_callocN(sizeof(qex_QuadMesh), "quadmesh"); - //qex_Valence *valence; + // qex_Valence *valence; MVertTri *verttri = MEM_callocN(sizeof(*verttri) * (size_t)num_tris, "remesh_looptri"); BKE_mesh_runtime_verttri_from_looptri( @@ -73,7 +73,7 @@ Mesh *BKE_remesh_quad( int(*tris)[3] = MEM_calloc_arrayN((size_t)num_tris, sizeof(int) * 3, "tris"); float(*uv_tris)[3][2] = MEM_calloc_arrayN((size_t)num_tris, sizeof(float) * 3 * 2, "uv_tris"); - //fill data + // fill data for (int i = 0; i < num_verts; i++) { copy_v3_v3(verts[i], mesh->mvert[i].co); } @@ -84,13 +84,13 @@ Mesh *BKE_remesh_quad( tris[i][2] = verttri[i].tri[2]; } - //mixed integer quadrangulation - //double stiffness = 5.0; - //double gradient_size = 50.0; - //double iter = 0; - //bool direct_round = false; + // mixed integer quadrangulation + // double stiffness = 5.0; + // double gradient_size = 50.0; + // double iter = 0; + // bool direct_round = false; - //find pairs of verts of original edges (= marked with seam) + // find pairs of verts of original edges (= marked with seam) bool *hard_edges = MEM_callocN(sizeof(bool) * 3 * num_tris, "hard edges"); // int *hard_verts = MEM_mallocN(sizeof(int) * mesh->totvert, "hard_verts"); @@ -121,7 +121,7 @@ Mesh *BKE_remesh_quad( direct_round, hard_edges); - //build trimesh + // build trimesh trimesh->tri_count = (unsigned int)num_tris; trimesh->vertex_count = (unsigned int)num_verts; trimesh->vertices = MEM_calloc_arrayN(sizeof(qex_Point3), (size_t)num_verts, "trimesh vertices"); @@ -152,10 +152,10 @@ Mesh *BKE_remesh_quad( trimesh->uvTris[i].uvs[2].x[1] = uv_tris[i][2][1]; } - //quad extraction + // quad extraction extractQuadMesh(trimesh, NULL, ); - //rebuild mesh + // rebuild mesh if (quadmesh.quad_count > 0) { result = BKE_mesh_new_nomain(quadmesh.vertex_count, 0, quadmesh.quad_count, 0, 0); for (int i = 0; i < quadmesh.vertex_count; i++) { @@ -172,14 +172,14 @@ Mesh *BKE_remesh_quad( result->mface->mat_nr = 0; } -//build edges, tessfaces, normals +// build edges, tessfaces, normals BKE_mesh_calc_edges_tessface(result); BKE_mesh_convert_mfaces_to_mpolys(result); BKE_mesh_calc_normals(result); BKE_mesh_update_customdata_pointers(result, true); } - //free stuff + // free stuff MEM_freeN(verts); MEM_freeN(tris); MEM_freeN(uv_tris); @@ -190,14 +190,14 @@ Mesh *BKE_remesh_quad( MEM_freeN(trimesh); MEM_freeN(verttri); - //if (quadmesh->vertices) + // if (quadmesh->vertices) //free(quadmesh->vertices); - //if (quadmesh->quads) + // if (quadmesh->quads) //free(quadmesh->quads); - //MEM_freeN(quadmesh); + // MEM_freeN(quadmesh); return result; - //remap customdata (reproject) + // remap customdata (reproject) // BVH... #else return mesh; diff --git a/source/blender/blenkernel/intern/remesh_voxel.c b/source/blender/blenkernel/intern/remesh_voxel.c index 5102be6dd96..23408bb8a05 100644 --- a/source/blender/blenkernel/intern/remesh_voxel.c +++ b/source/blender/blenkernel/intern/remesh_voxel.c @@ -271,7 +271,7 @@ MLoopC
[Bf-blender-cvs] [485ea73b2bf] sculpt-mode-features: Mesh Filter: Init random displacement only once
Commit: 485ea73b2bf849aae9077abb953f1f4b2f20e9f7 Author: Pablo Dobarro Date: Tue May 14 23:42:54 2019 +0200 Branches: sculpt-mode-features https://developer.blender.org/rB485ea73b2bf849aae9077abb953f1f4b2f20e9f7 Mesh Filter: Init random displacement only once The random mesh filter should be much faster now, and it should not do weird things when adjusting the strength. === M source/blender/editors/sculpt_paint/sculpt.c M source/blender/editors/sculpt_paint/sculpt_intern.h === diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 2dc2bb5e18a..51c01f25929 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -7566,6 +7566,10 @@ EnumPropertyItem prop_mesh_filter_types[] = { {0, NULL, 0, NULL, NULL}, }; +typedef struct MeshFilterData { + float *random_disp; +} MeshFilterData; + static void mesh_filter_task_cb(void *__restrict userdata, const int i, const ParallelRangeTLS *__restrict UNUSED(tls)) @@ -7643,8 +7647,7 @@ static void mesh_filter_task_cb(void *__restrict userdata, break; case MESH_FILTER_RANDOM: normal_short_to_float_v3(normal, vd.no); -float random = (float)rand() / (float)(RAND_MAX); -mul_v3_fl(normal, random - 0.5f); +mul_v3_fl(normal, data->random_disp[vd.vert_indices[vd.i]] - 0.5f); mul_v3_v3fl(disp, normal, fade); add_v3_v3v3(ss->mvert[vd.vert_indices[vd.i]].co, orig_co, disp); break; @@ -7668,6 +7671,7 @@ int sculpt_mesh_filter_modal(bContext *C, wmOperator *op, const wmEvent *event) Sculpt *sd = CTX_data_tool_settings(C)->sculpt; int mode = RNA_enum_get(op->ptr, "type"); float filter_strength = RNA_float_get(op->ptr, "strength"); + MeshFilterData *mfd = op->customdata; SculptSearchSphereData searchdata = { .ss = ss, @@ -7686,6 +7690,7 @@ int sculpt_mesh_filter_modal(bContext *C, wmOperator *op, const wmEvent *event) .smooth_value = 0.5f, .filter_type = mode, .filter_strength = filter_strength, + .random_disp = mfd->random_disp, }; ParallelRangeSettings settings; @@ -7714,6 +7719,10 @@ int sculpt_mesh_filter_modal(bContext *C, wmOperator *op, const wmEvent *event) WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); if (event->type == 1 && event->val == 2) { sculpt_undo_push_end(); +if (mfd->random_disp) { + MEM_freeN(mfd->random_disp); +} +MEM_freeN(mfd); return OPERATOR_FINISHED; } @@ -7740,13 +7749,25 @@ int sculpt_mesh_filter_invoke(bContext *C, wmOperator *op, const wmEvent *event) if (BKE_pbvh_type(pbvh) == PBVH_FACES && needs_pmap && !ob->sculpt->pmap) { return OPERATOR_CANCELLED; } + + MeshFilterData *mfd = MEM_callocN(sizeof(MeshFilterData), "mesh filter data"); if (ss->orco == NULL) { ss->orco = MEM_mallocN(3 * ss->totvert * sizeof(float), "orco"); } + + if (mode == MESH_FILTER_RANDOM && mfd->random_disp == NULL) { +mfd->random_disp = MEM_mallocN(ss->totvert * sizeof(float), "random_disp"); + } + for (int i = 0; i < ss->totvert; i++) { copy_v3_v3(ss->orco[i], ss->mvert[i].co); +if (mode == MESH_FILTER_RANDOM) { + mfd->random_disp[i] = (float)rand() / (float)(RAND_MAX); +} } + op->customdata = mfd; + sculpt_undo_push_begin("mesh filter fill"); WM_event_add_modal_handler(C, op); diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h b/source/blender/editors/sculpt_paint/sculpt_intern.h index 97122ebe1a5..7a5232d0dc3 100644 --- a/source/blender/editors/sculpt_paint/sculpt_intern.h +++ b/source/blender/editors/sculpt_paint/sculpt_intern.h @@ -209,6 +209,7 @@ typedef struct SculptThreadedTaskData { float smooth_value; float filter_strength; int filter_type; + float *random_disp; float *automask; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [08c0e2a35d0] sculpt-mode-features: Sculpt mode transform tool: Initial implementation
Commit: 08c0e2a35d0159d8d771a24be1c452b0e700e4a3 Author: Pablo Dobarro Date: Sun May 19 18:10:41 2019 +0200 Branches: sculpt-mode-features https://developer.blender.org/rB08c0e2a35d0159d8d771a24be1c452b0e700e4a3 Sculpt mode transform tool: Initial implementation Work in progress... - Scaling and orientations are not implemented yet. - The "move pivot only" option is ignored when the tool is used from the gizmo. - Only meshes, no multires or dyntopo. This commit also includes the operator to set the pivot point position automatically as well as a refactor of the mesh filter cache to be shared with the transform tool. === M release/scripts/startup/bl_ui/space_toolsystem_toolbar.py M source/blender/blenkernel/BKE_paint.h M source/blender/editors/include/ED_sculpt.h M source/blender/editors/include/ED_transform.h M source/blender/editors/sculpt_paint/CMakeLists.txt M source/blender/editors/sculpt_paint/sculpt.c M source/blender/editors/sculpt_paint/sculpt_intern.h M source/blender/editors/sculpt_paint/sculpt_undo.c M source/blender/editors/transform/transform.c M source/blender/editors/transform/transform_conversions.c M source/blender/editors/transform/transform_generics.c M source/blender/editors/transform/transform_gizmo_3d.c M source/blender/editors/transform/transform_ops.c === diff --git a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py index 7f85bc4b50a..63850a63ad4 100644 --- a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py +++ b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py @@ -966,6 +966,25 @@ class _defs_sculpt: draw_settings=draw_settings, ) +@ToolDef.from_fn +def translate(): +def draw_settings(context, layout, tool): + _template_widget.VIEW3D_GGT_xform_gizmo.draw_settings_with_index(context, layout, 1) +props = tool.operator_properties("transform.translate") +sub = layout.row() +sub.prop(props, "move_pivot_only") +return dict( +idname="builtin.move", +label="Move", +# cursor='SCROLL_XY', +icon="ops.transform.translate", +widget="VIEW3D_GGT_xform_gizmo", +operator="transform.translate", +keymap="3D View Tool: Move", +draw_settings=draw_settings, +) + + class _defs_vertex_paint: @@ -1868,6 +1887,8 @@ class VIEW3D_PT_tools_active(ToolSelectPanelHelper, Panel): _defs_sculpt.hide_border, _defs_sculpt.mask_border, _defs_sculpt.mesh_filter, +_defs_sculpt.translate, +_defs_transform.rotate, *_tools_annotate, None, ], diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h index a492158c50e..7d8fd1f8beb 100644 --- a/source/blender/blenkernel/BKE_paint.h +++ b/source/blender/blenkernel/BKE_paint.h @@ -264,18 +264,25 @@ typedef struct SculptSession { float (*layer_co)[3]; /* Copy of the mesh vertices' locations */ struct StrokeCache *cache; + struct FilterCache *filter_cache; float cursor_radius; float cursor_location[3]; float cursor_view_normal[3]; float cursor_normal[3]; - float (*orco)[3]; - /* Automasking active vertex */ MVert *active_vertex_mesh; int active_vertex_mesh_index; + float pivot_pos[3]; + float pivot_rot[4]; + float pivot_scale[3]; + + float init_pivot_pos[3]; + float init_pivot_rot[4]; + float init_pivot_scale[3]; + RegionView3D *rv3d; union { diff --git a/source/blender/editors/include/ED_sculpt.h b/source/blender/editors/include/ED_sculpt.h index 86e108a26c6..7c72e06c791 100644 --- a/source/blender/editors/include/ED_sculpt.h +++ b/source/blender/editors/include/ED_sculpt.h @@ -42,6 +42,11 @@ bool ED_sculpt_mask_box_select(struct bContext *C, const struct rcti *rect, bool select); +/* transform */ +void ED_sculpt_update_modal_transform(const struct bContext *C, bool transform_pivot_only); +void ED_sculpt_init_transform(const struct bContext *C, bool transform_pivot_only); +void ED_sculpt_end_transform(const struct bContext *C, bool transform_pivot_only); + /* sculpt_undo.c */ void ED_sculpt_undosys_type(struct UndoType *ut); diff --git a/source/blender/editors/include/ED_transform.h b/source/blender/editors/include/ED_transform.h index 3605a245187..1931ad8d39d 100644 --- a/source/blender/editors/include/ED_transform.h +++ b/source/blender/editors/include/ED_transform.h @@ -97,6 +97,8 @@ enum TfmMode { #define CTX_PAINT_CURVE (1 <&l
[Bf-blender-cvs] [839adc73878] sculpt-mode-features: Fix Windows build
Commit: 839adc738788662d42dfc2bc5ecaa1cffc583827 Author: Pablo Dobarro Date: Mon May 20 18:49:16 2019 +0200 Branches: sculpt-mode-features https://developer.blender.org/rB839adc738788662d42dfc2bc5ecaa1cffc583827 Fix Windows build === M 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 415201ec9f5..fbe99191fbe 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -2380,7 +2380,7 @@ static void relax_vertex(float final_dp[3], PBVHVertexIter vd, SculptSession *ss int total = 0; GSetIterator *gsi = BLI_gsetIterator_new(vert_gset[vs]); -for (BLI_gsetIterator_init(gsi, (GHash *)vert_gset[vs]); !BLI_gsetIterator_done(gsi); +for (BLI_gsetIterator_init(gsi, vert_gset[vs]); !BLI_gsetIterator_done(gsi); BLI_gsetIterator_step(gsi)) { int vin = BLI_gsetIterator_getKey(gsi); MVert *c_vert = >mvert[vin]; @@ -2403,7 +2403,7 @@ static void relax_vertex(float final_dp[3], PBVHVertexIter vd, SculptSession *ss gsi = BLI_gsetIterator_new(vert_gset[vs]); -for (BLI_gsetIterator_init(gsi, (GHash *)vert_gset[vs]); !BLI_gsetIterator_done(gsi); +for (BLI_gsetIterator_init(gsi, vert_gset[vs]); !BLI_gsetIterator_done(gsi); BLI_gsetIterator_step(gsi)) { int vin = BLI_gsetIterator_getKey(gsi); MVert *c_vert = >mvert[vin]; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [c8ce96b1a27] sculpt-mode-features: Mesh Filter: Multithreaded initialization and masked node filtering
Commit: c8ce96b1a2793eff885d6ed833bc76e5f364b773 Author: Pablo Dobarro Date: Wed May 15 14:46:28 2019 +0200 Branches: sculpt-mode-features https://developer.blender.org/rBc8ce96b1a2793eff885d6ed833bc76e5f364b773 Mesh Filter: Multithreaded initialization and masked node filtering This should improve performance a lot, making the tool usable on several millions of vertices. If the mesh is partially masked, only the unmasked nodes are going to be processed, so it is possible to isolate parts of a high poly mesh using the mask and work with them in real time. I also changed the random displacement initialization to avoid allocating a huge amount of memory (it wasn't really necessary) === M source/blender/editors/sculpt_paint/sculpt.c M source/blender/editors/sculpt_paint/sculpt_intern.h === diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 51c01f25929..66a9fdf389b 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -7568,8 +7568,12 @@ EnumPropertyItem prop_mesh_filter_types[] = { typedef struct MeshFilterData { float *random_disp; + PBVHNode **nodes; + int totnode; } MeshFilterData; +#define MESH_FILTER_RANDOM_MOD 50 + static void mesh_filter_task_cb(void *__restrict userdata, const int i, const ParallelRangeTLS *__restrict UNUSED(tls)) @@ -7581,8 +7585,6 @@ static void mesh_filter_task_cb(void *__restrict userdata, const int mode = data->filter_type; PBVHVertexIter vd; - sculpt_undo_push_node(data->ob, node, SCULPT_UNDO_COORDS); - BKE_pbvh_vertex_iter_begin(ss->pbvh, node, vd, PBVH_ITER_UNIQUE) { float orig_co[3], val[3], avg[3], normal[3], disp[3], disp2[3], transform[3][3]; @@ -7647,7 +7649,8 @@ static void mesh_filter_task_cb(void *__restrict userdata, break; case MESH_FILTER_RANDOM: normal_short_to_float_v3(normal, vd.no); -mul_v3_fl(normal, data->random_disp[vd.vert_indices[vd.i]] - 0.5f); +mul_v3_fl(normal, + data->random_disp[vd.vert_indices[vd.i] % MESH_FILTER_RANDOM_MOD] - 0.5f); mul_v3_v3fl(disp, normal, fade); add_v3_v3v3(ss->mvert[vd.vert_indices[vd.i]].co, orig_co, disp); break; @@ -7664,29 +7667,19 @@ int sculpt_mesh_filter_modal(bContext *C, wmOperator *op, const wmEvent *event) { ARegion *ar = CTX_wm_region(C); Object *ob = CTX_data_active_object(C); - PBVH *pbvh = ob->sculpt->pbvh; SculptSession *ss = ob->sculpt; - PBVHNode **nodes; - int totnode; Sculpt *sd = CTX_data_tool_settings(C)->sculpt; int mode = RNA_enum_get(op->ptr, "type"); float filter_strength = RNA_float_get(op->ptr, "strength"); MeshFilterData *mfd = op->customdata; - SculptSearchSphereData searchdata = { - .ss = ss, - .sd = sd, - .radius_squared = FLT_MAX, - }; - BKE_pbvh_search_gather(pbvh, sculpt_search_sphere_cb, , , ); - float len = event->prevclickx - event->mval[0]; filter_strength = filter_strength * -len * 0.001f; SculptThreadedTaskData data = { .sd = sd, .ob = ob, - .nodes = nodes, + .nodes = mfd->nodes, .smooth_value = 0.5f, .filter_type = mode, .filter_strength = filter_strength, @@ -7695,8 +7688,9 @@ int sculpt_mesh_filter_modal(bContext *C, wmOperator *op, const wmEvent *event) ParallelRangeSettings settings; BLI_parallel_range_settings_defaults(); - settings.use_threading = ((sd->flags & SCULPT_USE_OPENMP) && totnode > SCULPT_THREADED_LIMIT); - BLI_task_parallel_range(0, totnode, , mesh_filter_task_cb, ); + settings.use_threading = ((sd->flags & SCULPT_USE_OPENMP) && +mfd->totnode > SCULPT_THREADED_LIMIT); + BLI_task_parallel_range(0, mfd->totnode, , mesh_filter_task_cb, ); if (mode == MESH_FILTER_RELAX) { for (int i = 0; i < ss->totvert; i++) { @@ -7711,9 +7705,6 @@ int sculpt_mesh_filter_modal(bContext *C, wmOperator *op, const wmEvent *event) sculpt_update_keyblock(ob); } - if (nodes) -MEM_freeN(nodes); - ED_region_tag_redraw(ar); WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); @@ -7722,6 +7713,9 @@ int sculpt_mesh_filter_modal(bContext *C, wmOperator *op, const wmEvent *event) if (mfd->random_disp) { MEM_freeN(mfd->random_disp); } +if (mfd->nodes) { + MEM_freeN(mfd->nodes); +} MEM_freeN(mfd); return OPERATOR_FINISHED; } @@ -7729,6 +7723,33 @@ int sculpt_mesh_filter_modal(bContext *C, wmOperator *op, const wmEvent *event) return OPERATOR_RUNNING_MODAL; } +static void mesh_filter_init_task_cb(void *__re
[Bf-blender-cvs] [42c0bd2e90a] sculpt-mode-features: Mask filter: add mask filter tool with iterations
Commit: 42c0bd2e90a4f4a21152495ba2742eb33629ade4 Author: Pablo Dobarro Date: Tue May 21 00:29:46 2019 +0200 Branches: sculpt-mode-features https://developer.blender.org/rB42c0bd2e90a4f4a21152495ba2742eb33629ade4 Mask filter: add mask filter tool with iterations Now it is possible to test the operator without editing the keymap. By changing the iterations of the filter it should be possible to avoid adding an unnecessary amount of undo steps when working with high poly meshes. === M release/scripts/presets/keyconfig/keymap_data/blender_default.py M release/scripts/startup/bl_ui/space_toolsystem_toolbar.py M source/blender/editors/sculpt_paint/sculpt.c === diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py b/release/scripts/presets/keyconfig/keymap_data/blender_default.py index fbf5ff9f823..819269ff129 100644 --- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py +++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py @@ -5854,6 +5854,17 @@ def km_3d_view_tool_sculpt_mesh_filter(params): ) +def km_3d_view_tool_sculpt_mask_filter(params): +return ( +"3D View Tool: Sculpt, Mask Filter", +{"space_type": 'VIEW_3D', "region_type": 'WINDOW'}, +{"items": [ +("sculpt.mask_filter", {"type": params.tool_mouse, "value": 'PRESS'}, + None) +]}, +) + + def km_3d_view_tool_paint_weight_sample_weight(params): return ( "3D View Tool: Paint Weight, Sample Weight", @@ -6295,6 +6306,7 @@ def generate_keymaps(params=None): km_3d_view_tool_sculpt_box_hide(params), km_3d_view_tool_sculpt_box_mask(params), km_3d_view_tool_sculpt_mesh_filter(params), +km_3d_view_tool_sculpt_mask_filter(params), km_3d_view_tool_paint_weight_sample_weight(params), km_3d_view_tool_paint_weight_sample_vertex_group(params), km_3d_view_tool_paint_weight_gradient(params), diff --git a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py index 63850a63ad4..02353cd9991 100644 --- a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py +++ b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py @@ -948,6 +948,24 @@ class _defs_sculpt: keymap=(), ) +@ToolDef.from_fn +def mask_filter(): +def draw_settings(context, layout, tool): +props = tool.operator_properties("sculpt.mask_filter") +sub = layout.row() +sub.use_property_split = False +sub.prop(props, "type", expand=False) +sub.prop(props, "iterations") + +return dict( +idname="builtin.mask_filter", +label="Mask Filter", +icon="ops.sculpt.mask_filter", +widget=None, +keymap= (), +draw_settings=draw_settings, +) + @ToolDef.from_fn def mesh_filter(): def draw_settings(context, layout, tool): @@ -1887,6 +1905,7 @@ class VIEW3D_PT_tools_active(ToolSelectPanelHelper, Panel): _defs_sculpt.hide_border, _defs_sculpt.mask_border, _defs_sculpt.mesh_filter, +_defs_sculpt.mask_filter, _defs_sculpt.translate, _defs_transform.rotate, *_tools_annotate, diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index fbe99191fbe..413bb7ab902 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -7911,8 +7911,6 @@ static void mask_filter_task_cb(void *__restrict userdata, PBVHVertexIter vd; - sculpt_undo_push_node(data->ob, node, SCULPT_UNDO_MASK); - BKE_pbvh_vertex_iter_begin(ss->pbvh, node, vd, PBVH_ITER_UNIQUE) { float val; @@ -7995,27 +7993,35 @@ static int sculpt_mask_filter_exec(bContext *C, wmOperator *op) sculpt_undo_push_begin("Mask blur fill"); - float *prev_mask; - if (ELEM(mode, MASK_FILTER_GROW, MASK_FILTER_SHRINK)) { -prev_mask = MEM_dupallocN(ss->vmask); + float *prev_mask = NULL; + int iterations = RNA_int_get(op->ptr, "iterations"); + + for (int i = 0; i < totnode; i++) { +sculpt_undo_push_node(ob, nodes[i], SCULPT_UNDO_MASK); } - SculptThreadedTaskData data = { - .sd = sd, - .ob = ob, - .nodes = nodes, - .smooth_value = 0.5f, - .filter_type = mode, - .prev_mask = prev_mask, - }; + for (int i = 0; i < iterations; i++) { +if (ELEM(mode, MASK_FILTER_GROW, MASK_FILTER_SHRINK)) { + prev_mask = MEM_dupallocN(ss->vmask); +
[Bf-blender-cvs] [711d1f7591a] sculpt-mode-features: Merge branch 'master' into sculpt-mode-features
Commit: 711d1f7591adb07456380ceaef61c5e3d4666e19 Author: Pablo Dobarro Date: Tue May 21 00:45:41 2019 +0200 Branches: sculpt-mode-features https://developer.blender.org/rB711d1f7591adb07456380ceaef61c5e3d4666e19 Merge branch 'master' into sculpt-mode-features === === diff --cc build_files/cmake/macros.cmake index 90f07e7edc7,10b293c64b4..098792d4be6 --- a/build_files/cmake/macros.cmake +++ b/build_files/cmake/macros.cmake @@@ -271,20 -271,40 +271,40 @@@ function(blender_add_lib_nolis endfunction() function(blender_add_lib - name - sources - includes - includes_sys - library_deps - ) + name + sources + includes + includes_sys + library_deps + ) - add_cc_flags_custom_test(${name} PARENT_SCOPE) + add_cc_flags_custom_test(${name} PARENT_SCOPE) - blender_add_lib__impl(${name} "${sources}" "${includes}" "${includes_sys}" "${library_deps}") + blender_add_lib__impl(${name} "${sources}" "${includes}" "${includes_sys}" "${library_deps}") - set_property(GLOBAL APPEND PROPERTY BLENDER_LINK_LIBS ${name}) + set_property(GLOBAL APPEND PROPERTY BLENDER_LINK_LIBS ${name}) endfunction() + # Ninja only: assign 'heavy pool' to some targets that are especially RAM-consuming to build. + function(setup_heavy_lib_pool) + if(WITH_NINJA_POOL_JOBS AND NINJA_MAX_NUM_PARALLEL_COMPILE_HEAVY_JOBS) + if(WITH_CYCLES) + list(APPEND _HEAVY_LIBS "cycles_device" "cycles_kernel") + endif() + if(WITH_LIBMV) + list(APPEND _HEAVY_LIBS "bf_intern_libmv") + endif() + if(WITH_OPENVDB) + list(APPEND _HEAVY_LIBS "bf_intern_openvdb") + endif() + + foreach(TARGET ${_HEAVY_LIBS}) + if(TARGET ${TARGET}) + set_property(TARGET ${TARGET} PROPERTY JOB_POOL_COMPILE compile_heavy_job_pool) + endif() + endforeach() + endif() + endfunction() function(SETUP_LIBDIRS) diff --cc source/blender/blenkernel/intern/editmesh.c index 130f4ae88f1,264054266eb..b8234ccc5bb --- a/source/blender/blenkernel/intern/editmesh.c +++ b/source/blender/blenkernel/intern/editmesh.c @@@ -248,3 -248,13 +248,13 @@@ void BKE_editmesh_lnorspace_update(BMEd BM_lnorspace_update(bm); } + + /* If autosmooth not already set, set it */ + void BKE_editmesh_ensure_autosmooth(BMEditMesh *em) + { + Mesh *me = em->ob->data; + if (!(me->flag & ME_AUTOSMOOTH)) { + me->flag |= ME_AUTOSMOOTH; -BKE_editmesh_lnorspace_update (em); ++BKE_editmesh_lnorspace_update(em); + } + } diff --cc source/blender/draw/engines/workbench/shaders/workbench_prepass_frag.glsl index 4b65acac9d1,af9f1d14f4a..eb4ccd66f54 --- a/source/blender/draw/engines/workbench/shaders/workbench_prepass_frag.glsl +++ b/source/blender/draw/engines/workbench/shaders/workbench_prepass_frag.glsl @@@ -6,9 -6,7 +6,8 @@@ uniform float materialRoughness uniform sampler2D image; uniform float ImageTransparencyCutoff = 0.1; - uniform bool imageSrgb; uniform bool imageNearest; +uniform bool useVertexPaint; #ifdef NORMAL_VIEWPORT_PASS_ENABLED in vec3 normal_viewport; diff --cc source/blender/editors/object/object_edit.c index e079afc5253,a542911f4d4..a70a48a2c5a --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@@ -1790,245 -1779,5 +1790,246 @@@ void OBJECT_OT_link_to_collection(wmOpe "Name", "Name of the newly added collection"); RNA_def_property_flag(prop, PROP_SKIP_SAVE); + ot->prop = prop; } + +static int remesh_exec(bContext *C, wmOperator *op) +{ + bool linked_data = false; + + Object *ob = CTX_data_active_object(C); + Main *bmain = CTX_data_main(C); + + ID *data; + data = ob->data; + if (data && ID_IS_LINKED(data)) { +linked_data = true; +return OPERATOR_CANCELLED; + } + + if (ID_REAL_USERS(data) != 1) { +BKE_report(op->reports, RPT_ERROR, "Remesh cannot run on mesh data with multiple users"); +return OPERATOR_CANCELLED; + } + + if (BKE_object_is_in_editmode(ob)) { +BKE_report(op->reports, RPT_ERROR, "Remesh cannot run from edit mode"); +return OPERATOR_CANCELLED; + } + + if (ob->type == OB_MESH) { +Mesh *mesh = ob->data; +Mesh *newMesh; + +if (mesh->voxel_size <= 0.0f) { + return OPERATOR_CANCELLED; +} + +if (ob->mode == OB_MODE_SCULPT) { + Depsgraph *depsgraph = CTX_data_depsgraph(C); + struct Scene *scene = CTX_data_scene(C); + Sculpt *sd = CTX_data_tool_settings(C)->sculpt; + BKE_sculpt_update_mesh_elements(depsgraph, scene, sd, o
[Bf-blender-cvs] [bc7068c4b91] sculpt-mode-features: Add option to control de opacity of the sculpt mask
Commit: bc7068c4b9130a00116cef52fd5cc27926a63717 Author: Pablo Dobarro Date: Sat Apr 20 00:09:10 2019 +0200 Branches: sculpt-mode-features https://developer.blender.org/rBbc7068c4b9130a00116cef52fd5cc27926a63717 Add option to control de opacity of the sculpt mask === M release/scripts/startup/bl_ui/space_view3d_toolbar.py M source/blender/draw/modes/sculpt_mode.c M source/blender/draw/modes/shaders/sculpt_mask_vert.glsl M source/blender/makesdna/DNA_scene_types.h M source/blender/makesrna/intern/rna_sculpt_paint.c === diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py index 73021097218..b8fe0204abd 100644 --- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py +++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py @@ -1139,6 +1139,8 @@ class VIEW3D_PT_sculpt_options(Panel, View3DPaintPanel): col.prop(sculpt, "show_diffuse_color") col = flow.column() col.prop(sculpt, "show_mask") +col = flow.column() +col.prop(sculpt, "mask_opacity") class VIEW3D_PT_sculpt_options_unified(Panel, View3DPaintPanel): diff --git a/source/blender/draw/modes/sculpt_mode.c b/source/blender/draw/modes/sculpt_mode.c index ead539bc30f..4542790a3ef 100644 --- a/source/blender/draw/modes/sculpt_mode.c +++ b/source/blender/draw/modes/sculpt_mode.c @@ -138,6 +138,9 @@ static void SCULPT_cache_init(void *vedata) DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL | DRW_STATE_MULTIPLY; psl->pass = DRW_pass_create("Sculpt Pass", state); stl->g_data->group_smooth = DRW_shgroup_create(e_data.shader_smooth, psl->pass); + const DRWContextState *drwctx = DRW_context_state_get(); + Sculpt *sd = drwctx->scene->toolsettings->sculpt; + DRW_shgroup_uniform_float_copy(stl->g_data->group_smooth, "maskOpacity", sd->mask_opacity); } } diff --git a/source/blender/draw/modes/shaders/sculpt_mask_vert.glsl b/source/blender/draw/modes/shaders/sculpt_mask_vert.glsl index 553a49f38df..d21ab846054 100644 --- a/source/blender/draw/modes/shaders/sculpt_mask_vert.glsl +++ b/source/blender/draw/modes/shaders/sculpt_mask_vert.glsl @@ -1,5 +1,6 @@ uniform mat4 ModelViewProjectionMatrix; +uniform float maskOpacity; in vec3 pos; in float msk; @@ -10,6 +11,6 @@ void main() { gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0); - float mask = 1.0 - msk * 0.75; + float mask = 1.0 - msk * 0.75 * maskOpacity; finalColor = vec4(mask, mask, mask, 1.0); } diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index 75dda608975..cabdf244e44 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -987,11 +987,13 @@ typedef struct Sculpt { /* gravity factor for sculpting */ float gravity_factor; + /* mask opacity */ + float mask_opacity; + /* scale for constant detail size */ /** Constant detail resolution (Blender unit / constant_detail). */ float constant_detail; float detail_percent; - char _pad[4]; struct Object *gravity_object; } Sculpt; diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c index 6d805639940..c4681a33daa 100644 --- a/source/blender/makesrna/intern/rna_sculpt_paint.c +++ b/source/blender/makesrna/intern/rna_sculpt_paint.c @@ -750,6 +750,14 @@ static void rna_def_sculpt(BlenderRNA *brna) RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Sculpt_ShowMask_update"); + prop = RNA_def_property(srna, "mask_opacity", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_sdna(prop, NULL, "mask_opacity"); + RNA_def_property_ui_range(prop, 0.0, 1.0, 0.01, 2); + RNA_def_property_float_default(prop, 1.0f); + RNA_def_property_ui_text(prop, "Mask Opacity", "Opacitiy of the sculpt mask"); + RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); + RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Sculpt_update"); + prop = RNA_def_property(srna, "detail_size", PROP_FLOAT, PROP_PIXEL); RNA_def_property_ui_range(prop, 0.5, 40.0, 10, 2); RNA_def_property_ui_text(prop, "Detail Size", "Maximum edge length for dynamic topology sculpting (in pixels)"); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [f2792e91f03] master: 3D View: add opacity for sculpt mask display
Commit: f2792e91f034ed01469aa025503a4352a1e4455c Author: Pablo Dobarro Date: Sat Apr 20 11:58:44 2019 +0200 Branches: master https://developer.blender.org/rBf2792e91f034ed01469aa025503a4352a1e4455c 3D View: add opacity for sculpt mask display This matches vertex/texture paint opacity options. Useful because 0.75 is sometimes too dark to see the surface shading. Resolves T63746 === M release/scripts/startup/bl_ui/space_view3d.py M source/blender/blenloader/intern/versioning_280.c M source/blender/draw/modes/sculpt_mode.c M source/blender/draw/modes/shaders/sculpt_mask_vert.glsl M source/blender/editors/space_view3d/space_view3d.c M source/blender/makesdna/DNA_view3d_types.h M source/blender/makesrna/intern/rna_space.c === diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index f572362b02b..bb56946e154 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -5572,8 +5572,14 @@ class VIEW3D_PT_overlay_sculpt(Panel): tool_settings = context.tool_settings sculpt = tool_settings.sculpt +view = context.space_data +overlay = view.overlay + layout.prop(sculpt, "show_diffuse_color") layout.prop(sculpt, "show_mask") +row = layout.row() +row.active = sculpt.show_mask +row.prop(overlay, "sculpt_mode_mask_opacity", text="Opacity") class VIEW3D_PT_overlay_pose(Panel): diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c index e43553cd64f..5f13bea1c28 100644 --- a/source/blender/blenloader/intern/versioning_280.c +++ b/source/blender/blenloader/intern/versioning_280.c @@ -3177,6 +3177,20 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) } } +if (!DNA_struct_elem_find( +fd->filesdna, "View3DOverlay", "float", "sculpt_mode_mask_opacity")) { + for (bScreen *screen = bmain->screens.first; screen; screen = screen->id.next) { +for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) { + for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { +if (sl->spacetype == SPACE_VIEW3D) { + View3D *v3d = (View3D *)sl; + v3d->overlay.sculpt_mode_mask_opacity = 0.75f; +} + } +} + } +} + /* Versioning code until next subversion bump goes here. */ } } diff --git a/source/blender/draw/modes/sculpt_mode.c b/source/blender/draw/modes/sculpt_mode.c index b25a8af795b..e2b73a0fac7 100644 --- a/source/blender/draw/modes/sculpt_mode.c +++ b/source/blender/draw/modes/sculpt_mode.c @@ -135,9 +135,15 @@ static void SCULPT_cache_init(void *vedata) } { +const DRWContextState *draw_ctx = DRW_context_state_get(); +View3D *v3d = draw_ctx->v3d; + DRWState state = DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_EQUAL | DRW_STATE_MULTIPLY; psl->pass = DRW_pass_create("Sculpt Pass", state); -stl->g_data->group_smooth = DRW_shgroup_create(e_data.shader_smooth, psl->pass); + +DRWShadingGroup *shgrp = DRW_shgroup_create(e_data.shader_smooth, psl->pass); +DRW_shgroup_uniform_float(shgrp, "maskOpacity", >overlay.sculpt_mode_mask_opacity, 1); +stl->g_data->group_smooth = shgrp; } } diff --git a/source/blender/draw/modes/shaders/sculpt_mask_vert.glsl b/source/blender/draw/modes/shaders/sculpt_mask_vert.glsl index 5ae97ec5cb9..e5e34fee57e 100644 --- a/source/blender/draw/modes/shaders/sculpt_mask_vert.glsl +++ b/source/blender/draw/modes/shaders/sculpt_mask_vert.glsl @@ -1,5 +1,6 @@ uniform mat4 ModelViewProjectionMatrix; +uniform float maskOpacity; in vec3 pos; in float msk; @@ -10,6 +11,6 @@ void main() { gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0); - float mask = 1.0 - msk * 0.75; + float mask = 1.0 - (msk * maskOpacity); finalColor = vec4(mask, mask, mask, 1.0); } diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index 0b98ad3cacd..456a012020f 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -262,6 +262,10 @@ static SpaceLink *view3d_new(const ScrArea *UNUSED(sa), const Scene *scene) v3d->overlay.texture_paint_mode_opacity = 1.0f; v3d->overlay.weight_paint_mode_opacity = 1.0f; v3d->overlay.vertex_paint_mode_opacity = 1.0f; + /* Intentionally different to vertex/paint mode, + * we typically want to see shading too. */ + v3d->overlay.sculpt_m
[Bf-blender-cvs] [5be901f3445] sculpt-mode-features: Merge branch 'master' into sculpt-mode-features
Commit: 5be901f344573182adb0c953a238b669b8e945eb Author: Pablo Dobarro Date: Mon May 6 18:19:53 2019 +0200 Branches: sculpt-mode-features https://developer.blender.org/rB5be901f344573182adb0c953a238b669b8e945eb Merge branch 'master' into sculpt-mode-features === === diff --cc release/scripts/startup/bl_ui/space_toolsystem_toolbar.py index 2f48a90b89b,6423c7eb6cd..7f85bc4b50a --- a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py +++ b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py @@@ -1821,7 -1849,8 +1867,9 @@@ class VIEW3D_PT_tools_active(ToolSelect None, _defs_sculpt.hide_border, _defs_sculpt.mask_border, -None, +_defs_sculpt.mesh_filter, + *_tools_annotate, ++None, ], 'PAINT_TEXTURE': [ _defs_texture_paint.generate_from_brushes, diff --cc source/blender/blenkernel/BKE_pbvh.h index ce9fda460d3,9b15462de6b..cddf2efda71 --- a/source/blender/blenkernel/BKE_pbvh.h +++ b/source/blender/blenkernel/BKE_pbvh.h @@@ -49,13 -49,21 +50,28 @@@ typedef struct float (*co)[3]; } PBVHProxyNode; +typedef struct { + float normal[3]; + float nearest_vertex_co[3]; + MVert *active_vertex_mesh; + int active_vertex_mesh_index; +} RaycastOutputData; + + typedef enum { + PBVH_Leaf = 1, + + PBVH_UpdateNormals = 2, + PBVH_UpdateBB = 4, + PBVH_UpdateOriginalBB = 8, + PBVH_UpdateDrawBuffers = 16, + PBVH_UpdateRedraw = 32, + + PBVH_RebuildDrawBuffers = 64, + PBVH_FullyHidden = 128, + + PBVH_UpdateTopology = 256, + } PBVHNodeFlags; + /* Callbacks */ /* returns 1 if the search should continue from this node, 0 otherwise */ diff --cc source/blender/editors/object/CMakeLists.txt index d4d0ddd9d8d,eaef9313431..48c8c8cee08 --- a/source/blender/editors/object/CMakeLists.txt +++ b/source/blender/editors/object/CMakeLists.txt @@@ -28,14 -29,12 +29,13 @@@ set(IN ../../makesdna ../../makesrna ../../modifiers - ../../gpencil_modifiers - ../../shader_fx ../../python + ../../shader_fx ../../render/extern/include ../../windowmanager - ../../../../intern/glew-mx + ../sculpt_paint ../../../../intern/guardedalloc + ../../../../intern/glew-mx ) set(INC_SYS diff --cc source/blender/editors/sculpt_paint/paint_cursor.c index 4a71180e7d8,65e24cecf82..29d73b1c61d --- a/source/blender/editors/sculpt_paint/paint_cursor.c +++ b/source/blender/editors/sculpt_paint/paint_cursor.c @@@ -842,16 -833,16 +842,16 @@@ static bool paint_draw_alpha_overlay(Un x -= vc->ar->winrct.xmin; y -= vc->ar->winrct.ymin; - /* coloured overlay should be drawn separately */ + /* Colored overlay should be drawn separately. */ if (col) { if (!(flags & PAINT_OVERLAY_OVERRIDE_PRIMARY)) { - paint_draw_tex_overlay(ups, brush, vc, x, y, zoom, true, true); + alpha_active = paint_draw_tex_overlay(ups, brush, vc, x, y, zoom, true, true); } if (!(flags & PAINT_OVERLAY_OVERRIDE_SECONDARY)) { - paint_draw_tex_overlay(ups, brush, vc, x, y, zoom, false, false); + alpha_active = paint_draw_tex_overlay(ups, brush, vc, x, y, zoom, false, false); } if (!(flags & PAINT_OVERLAY_OVERRIDE_CURSOR)) { - paint_draw_cursor_overlay(ups, brush, vc, x, y, zoom); + alpha_active = paint_draw_cursor_overlay(ups, brush, vc, x, y, zoom); } } else { diff --cc source/blender/makesdna/DNA_brush_types.h index 75423cd9ee7,6f775e48d58..64c5e1ad477 --- a/source/blender/makesdna/DNA_brush_types.h +++ b/source/blender/makesdna/DNA_brush_types.h @@@ -297,7 -275,7 +299,8 @@@ typedef struct Brush char mask_tool; /** Active grease pencil tool. */ char gpencil_tool; - char _pad0[6]; - char _pad0[1]; ++ ++ char _pad0[5]; float autosmooth_factor; @@@ -470,10 -437,15 +473,17 @@@ typedef enum eBrushSculptTool SCULPT_TOOL_BLOB = 17, SCULPT_TOOL_CLAY_STRIPS = 18, SCULPT_TOOL_MASK = 19, + SCULPT_TOOL_DAM = 20, + SCULPT_TOOL_PAINT = 21, } eBrushSculptTool; + /* Brush.uv_sculpt_tool */ + typedef enum eBrushUVSculptTool { + UV_SCULPT_TOOL_GRAB = 0, + UV_SCULPT_TOOL_RELAX = 1, + UV_SCULPT_TOOL_PINCH = 2, + } eBrushUVSculptTool; + /** When #BRUSH_ACCUMULATE is used */ #define SCULPT_TOOL_HAS_ACCUMULATE(t) \ ELEM(t, \ ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [2b32296e178] sculpt-mode-features: Fix crash on remesh operator with a multi user mesh data.
Commit: 2b32296e178262109f3d927a60b9068c8d632cc2 Author: Pablo Dobarro Date: Sun Apr 28 18:53:05 2019 +0200 Branches: sculpt-mode-features https://developer.blender.org/rB2b32296e178262109f3d927a60b9068c8d632cc2 Fix crash on remesh operator with a multi user mesh data. I also added some error messages. === M source/blender/editors/object/object_edit.c === diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 2cd870cfb24..122bd9208ee 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -1807,6 +1807,17 @@ static int remesh_exec(bContext *C, wmOperator *op) linked_data = true; return OPERATOR_CANCELLED; } + + if (ID_REAL_USERS(data) != 1) { +BKE_report(op->reports, RPT_ERROR, "Remesh cannot run on mesh data with multiple users"); +return OPERATOR_CANCELLED; + } + + if (BKE_object_is_in_editmode(ob)) { +BKE_report(op->reports, RPT_ERROR, "Remesh cannot run from edit mode"); +return OPERATOR_CANCELLED; + } + if (ob->type == OB_MESH) { Mesh *mesh = ob->data; Mesh *newMesh; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [b66ecaf40cb] sculpt-mode-features: Fix crash on mesh filters
Commit: b66ecaf40cb867c3ba344fc6becb8a3e40b0a13b Author: Pablo Dobarro Date: Mon Apr 29 03:48:34 2019 +0200 Branches: sculpt-mode-features https://developer.blender.org/rBb66ecaf40cb867c3ba344fc6becb8a3e40b0a13b Fix crash on mesh filters === M 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 8f6e1f3af41..03e65635e07 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -7476,7 +7476,6 @@ int sculpt_mesh_filter_modal(bContext *C, wmOperator *op, const wmEvent *event) } BKE_sculpt_update_mesh_elements(depsgraph, scene, sd, ob, mode == MESH_FILTER_SMOOTH, true); - sculpt_restore_mesh(sd, ob); if (BKE_pbvh_type(pbvh) == PBVH_FACES && mode == MESH_FILTER_SMOOTH && !ob->sculpt->pmap) { ss->use_orco = false; return OPERATOR_CANCELLED; @@ -7494,6 +7493,8 @@ int sculpt_mesh_filter_modal(bContext *C, wmOperator *op, const wmEvent *event) sculpt_undo_push_begin("mesh filter fill"); } + paint_mesh_restore_co(sd, ob); + float len = event->prevclickx - event->mval[0]; filter_strength = filter_strength * -len * 0.001f; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [fa916b74706] sculpt-mode-features: Merge branch 'master' into sculpt-mode-features
Commit: fa916b74706dd6c09b90848f7930567c3e1c8216 Author: Pablo Dobarro Date: Fri Jun 28 01:31:04 2019 +0200 Branches: sculpt-mode-features https://developer.blender.org/rBfa916b74706dd6c09b90848f7930567c3e1c8216 Merge branch 'master' into sculpt-mode-features === === ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [cf701b0d2a4] sculpt-mode-features: Fix normal radius versioning
Commit: cf701b0d2a427164649c0ba48921e0b535f4601a Author: Pablo Dobarro Date: Tue Jul 9 15:24:00 2019 +0200 Branches: sculpt-mode-features https://developer.blender.org/rBcf701b0d2a427164649c0ba48921e0b535f4601a Fix normal radius versioning === M source/blender/blenloader/intern/versioning_280.c === diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c index 9ccf9b4a7fc..e73d85b982c 100644 --- a/source/blender/blenloader/intern/versioning_280.c +++ b/source/blender/blenloader/intern/versioning_280.c @@ -3094,13 +3094,6 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) "Filmic"); } } - -Brush *br; -for (br = bmain->brushes.first; br; br = br->id.next) { - if (br->ob_mode & OB_MODE_SCULPT) { -br->normal_radius_factor = 0.2f; - } -} } if (!MAIN_VERSION_ATLEAST(bmain, 280, 49)) { @@ -3523,5 +3516,12 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) LISTBASE_FOREACH (bArmature *, arm, >armatures) { arm->flag &= ~(ARM_FLAG_UNUSED_6); } + +Brush *br; +for (br = bmain->brushes.first; br; br = br->id.next) { + if (br->ob_mode & OB_MODE_SCULPT) { +br->normal_radius_factor = 0.2f; + } +} } } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [9895675b9bc] sculpt-mode-features: Fix formatting
Commit: 9895675b9bccd3821a2bdb505b89796717cd47d5 Author: Pablo Dobarro Date: Tue Jul 9 15:20:29 2019 +0200 Branches: sculpt-mode-features https://developer.blender.org/rB9895675b9bccd3821a2bdb505b89796717cd47d5 Fix formatting === M source/blender/editors/object/object_blueprint.c M source/blender/editors/object/object_edit.c === diff --git a/source/blender/editors/object/object_blueprint.c b/source/blender/editors/object/object_blueprint.c index 874ea86d085..1ffca8fbcb6 100644 --- a/source/blender/editors/object/object_blueprint.c +++ b/source/blender/editors/object/object_blueprint.c @@ -131,7 +131,6 @@ EnumPropertyItem prop_blueprint_draw_tool_types[] = { {0, NULL, 0, NULL, NULL}, }; - typedef struct BlueprintPolyPoint { struct BlueprintPolyPoint *next, *prev; @@ -160,8 +159,6 @@ typedef struct BlueprintCache { /* geometry creation context */ Object *ob; - - float plane_offset; int grid_snap; @@ -254,34 +251,34 @@ void blueprint_draw_poly_volume(uint pos3d, BlueprintCache *cache, float z) int point_count = cache->point_count; GPU_depth_test(true); immUniformColor4ubv(cache->color.geom_fill); -float z_base = 0.0f; -if (cache->flags & BLUEPRINT_SYMMETRICAL_EXTRUDE) { - z_base = -cache->extrudedist; -} + float z_base = 0.0f; + if (cache->flags & BLUEPRINT_SYMMETRICAL_EXTRUDE) { +z_base = -cache->extrudedist; + } - bool draw_fill = cache->flags & BLUEPRINT_ENABLE_GEOMETRY_FILL; + bool draw_fill = cache->flags & BLUEPRINT_ENABLE_GEOMETRY_FILL; if (point_count >= 3) { if (draw_fill) { -immBegin(GPU_PRIM_TRIS, point_count * 6); -LISTBASE_FOREACH (BlueprintPolyPoint *, p, >poly) { - BlueprintPolyPoint *np; - if (p->next) { -np = p->next; - } - else { -np = cache->poly.first; - } + immBegin(GPU_PRIM_TRIS, point_count * 6); + LISTBASE_FOREACH (BlueprintPolyPoint *, p, >poly) { +BlueprintPolyPoint *np; +if (p->next) { + np = p->next; +} +else { + np = cache->poly.first; +} - immVertex3f(pos3d, p->co[0], p->co[1], z_base); - immVertex3f(pos3d, p->co[0], p->co[1], z); - immVertex3f(pos3d, np->co[0], np->co[1], z); +immVertex3f(pos3d, p->co[0], p->co[1], z_base); +immVertex3f(pos3d, p->co[0], p->co[1], z); +immVertex3f(pos3d, np->co[0], np->co[1], z); - immVertex3f(pos3d, np->co[0], np->co[1], z_base); - immVertex3f(pos3d, p->co[0], p->co[1], z_base); - immVertex3f(pos3d, np->co[0], np->co[1], z); -} +immVertex3f(pos3d, np->co[0], np->co[1], z_base); +immVertex3f(pos3d, p->co[0], p->co[1], z_base); +immVertex3f(pos3d, np->co[0], np->co[1], z); + } -immEnd(); + immEnd(); } immUniformColor4ubv(cache->color.geom_stroke); @@ -372,51 +369,51 @@ void blueprint_draw_grid(uint pos3d, BlueprintCache *cache) /* backgroud */ if (cache->flags & BLUEPRINT_ENABLE_GRID_BACKGROUD) { - if (cache->state != BLUEPRINT_STATE_PLANE) { -immUniformColor4ubv(cache->color.bg); -immBegin(GPU_PRIM_TRIS, 6); -immVertex3f(pos3d, cache->grid_extends_min[0], cache->grid_extends_min[1], 0.0f); -immVertex3f(pos3d, cache->grid_extends_min[0], cache->grid_extends_max[1], 0.0f); -immVertex3f(pos3d, cache->grid_extends_max[0], cache->grid_extends_max[1], 0.0f); - -immVertex3f(pos3d, cache->grid_extends_min[0], cache->grid_extends_min[1], 0.0f); -immVertex3f(pos3d, cache->grid_extends_max[0], cache->grid_extends_min[1], 0.0f); -immVertex3f(pos3d, cache->grid_extends_max[0], cache->grid_extends_max[1], 0.0f); -immEnd(); - } +if (cache->state != BLUEPRINT_STATE_PLANE) { + immUniformColor4ubv(cache->color.bg); + immBegin(GPU_PRIM_TRIS, 6); + immVertex3f(pos3d, cache->grid_extends_min[0], cache->grid_extends_min[1], 0.0f); + immVertex3f(pos3d, cache->grid_extends_min[0], cache->grid_extends_max[1], 0.0f); + immVertex3f(pos3d, cache->grid_extends_max[0], cache->grid_extends_max[1], 0.0f); + + immVertex3f(pos3d, cache->grid_extends_min[0], cache->grid_extends_min[1], 0.0f); + immVertex3f(pos3d, cache->grid_extends_max[0], cache->grid_extends_min[1], 0.0f); + immVertex3f(pos3d, cache->grid_extends_max[0], cache->grid_extends_max[1], 0.0f); + immEnd(); +} } /* GRID */ if (cache->flags & BLUEPRINT_ENABLE_GRID) { - GPU_line_wid
[Bf-blender-cvs] [0997eff30c4] sculpt-mode-features: Sculpt vertex colors: add color blend modes to the paint brush
Commit: 0997eff30c4583ede4b38f73b0978e5aaa924ee0 Author: Pablo Dobarro Date: Tue Jul 2 15:32:47 2019 +0200 Branches: sculpt-mode-features https://developer.blender.org/rB0997eff30c4583ede4b38f73b0978e5aaa924ee0 Sculpt vertex colors: add color blend modes to the paint brush This makes all color blend modes available from the paint mode dropdown. Source alpha is currently hardcoded to 1 to avoid confusion. The viewport can't display it properly. === M source/blender/editors/sculpt_paint/sculpt.c M source/blender/makesdna/DNA_brush_types.h M source/blender/makesrna/intern/rna_brush.c === diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 549bcbd505e..43d4f837b0b 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -32,6 +32,7 @@ #include "BLI_ghash.h" #include "BLI_stack.h" #include "BLI_gsqueue.h" +#include "BLI_math_color_blend.h" #include "BLT_translation.h" @@ -2684,15 +2685,83 @@ static void apply_color(SculptSession *ss, PBVHVertexIter *vd, const Brush *brus { float factor = ss->cache ? fade * fabs(ss->cache->bstrength) : fade; CLAMP(factor, 0.0f, 1.0f); - char r = brush->rgb[0] * 255; - char g = brush->rgb[1] * 255; - char b = brush->rgb[2] * 255; - - char brushColor[4] = {r, g, b, 0}; - /* TODO (Pablo): Implement proper blend modes */ - vd->col->r = vd->col->r * (1 - factor) + brushColor[0] * factor; - vd->col->g = vd->col->g * (1 - factor) + brushColor[1] * factor; - vd->col->b = vd->col->b * (1 - factor) + brushColor[2] * factor; + unsigned char r = brush->rgb[0] * 255; + unsigned char g = brush->rgb[1] * 255; + unsigned char b = brush->rgb[2] * 255; + unsigned char a = factor * 255; + unsigned char brushColor[4] = {r, g, b, a}; + unsigned char *col = (unsigned char *)vd->col; + switch (brush->sculpt_color_mix_mode) { +case BRUSH_SCULPT_COLOR_MIX: + blend_color_mix_byte(col, col, brushColor); + break; +case BRUSH_SCULPT_COLOR_ADD: + blend_color_add_byte(col, col, brushColor); + break; +case BRUSH_SCULPT_COLOR_SUB: + blend_color_sub_byte(col, col, brushColor); + break; +case BRUSH_SCULPT_COLOR_MUL: + blend_color_mul_byte(col, col, brushColor); + break; +case BRUSH_SCULPT_COLOR_LIGHTEN: + blend_color_lighten_byte(col, col, brushColor); + break; +case BRUSH_SCULPT_COLOR_DARKEN: + blend_color_darken_byte(col, col, brushColor); + break; +case BRUSH_SCULPT_COLOR_ERASE_ALPHA: + blend_color_erase_alpha_byte(col, col, brushColor); + break; +case BRUSH_SCULPT_COLOR_ADD_ALPHA: + blend_color_add_alpha_byte(col, col, brushColor); + break; +case BRUSH_SCULPT_COLOR_OVERLAY: + blend_color_overlay_byte(col, col, brushColor); + break; +case BRUSH_SCULPT_COLOR_HARDLIGHT: + blend_color_hardlight_byte(col, col, brushColor); + break; +case BRUSH_SCULPT_COLOR_BURN: + blend_color_burn_byte(col, col, brushColor); + break; +case BRUSH_SCULPT_COLOR_LINEARBURN: + blend_color_linearburn_byte(col, col, brushColor); + break; +case BRUSH_SCULPT_COLOR_DODGE: + blend_color_dodge_byte(col, col, brushColor); + break; +case BRUSH_SCULPT_COLOR_SCREEN: + blend_color_screen_byte(col, col, brushColor); + break; +case BRUSH_SCULPT_COLOR_SOFTLIGHT: + blend_color_softlight_byte(col, col, brushColor); + break; +case BRUSH_SCULPT_COLOR_PINLIGHT: + blend_color_pinlight_byte(col, col, brushColor); + break; +case BRUSH_SCULPT_COLOR_LINEARLIGHT: + blend_color_linearlight_byte(col, col, brushColor); + break; +case BRUSH_SCULPT_COLOR_VIVIDLIGHT: + blend_color_vividlight_byte(col, col, brushColor); + break; +case BRUSH_SCULPT_COLOR_DIFFERENCE: + blend_color_difference_byte(col, col, brushColor); + break; +case BRUSH_SCULPT_COLOR_EXCLUSION: + blend_color_exclusion_byte(col, col, brushColor); + break; +case BRUSH_SCULPT_COLOR_COLOR: + blend_color_color_byte(col, col, brushColor); + break; +case BRUSH_SCULPT_COLOR_HUE: + blend_color_hue_byte(col, col, brushColor); + break; +case BRUSH_SCULPT_COLOR_LUMINOSITY: + blend_color_luminosity_byte(col, col, brushColor); + break; + } } static void do_paint_brush_task_cb_ex(void *__restrict userdata, diff --git a/source/blender/makesdna/DNA_brush_types.h b/source/blender/makesdna/DNA_brush_types.h index ed415edea44..395407ca2e1 100644 --- a/source/blender/makesdna/DNA_brush_types.h +++ b/source/blender/makesdna/DNA_brush_types.h @@ -207,6 +207,28 @@ typedef
[Bf-blender-cvs] [81e9011f577] sculpt-mode-features: Fix color fill mask intensity
Commit: 81e9011f577000ca00827c6bb7b6eb9203840a0e Author: Pablo Dobarro Date: Sun Jun 30 00:36:43 2019 +0200 Branches: sculpt-mode-features https://developer.blender.org/rB81e9011f577000ca00827c6bb7b6eb9203840a0e Fix color fill mask intensity I added this multiplication to fix the pressure sensitivity of my broken wacom pen while testing the paint brush. I should add separate sculpt and paint strength factors. === M 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 c9ea21c6315..549bcbd505e 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -2683,7 +2683,6 @@ static void do_mask_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode) static void apply_color(SculptSession *ss, PBVHVertexIter *vd, const Brush *brush, float fade) { float factor = ss->cache ? fade * fabs(ss->cache->bstrength) : fade; - factor *= 2; CLAMP(factor, 0.0f, 1.0f); char r = brush->rgb[0] * 255; char g = brush->rgb[1] * 255; ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [4ef1b6e7170] sculpt-mode-features: Remove old mask opacity control and property
Commit: 4ef1b6e71707c8977fe15a3a2ed60ac8505f3f46 Author: Pablo Dobarro Date: Sun Jun 30 01:13:41 2019 +0200 Branches: sculpt-mode-features https://developer.blender.org/rB4ef1b6e71707c8977fe15a3a2ed60ac8505f3f46 Remove old mask opacity control and property === M release/scripts/startup/bl_ui/space_view3d_toolbar.py M source/blender/makesdna/DNA_scene_types.h M source/blender/makesrna/intern/rna_sculpt_paint.c === diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py index bb289c23970..ae658a8c29d 100644 --- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py +++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py @@ -1191,8 +1191,6 @@ class VIEW3D_PT_sculpt_options(Panel, View3DPaintPanel): col.prop(sculpt, "show_diffuse_color") col = flow.column() col.prop(sculpt, "show_mask") -col = flow.column() -col.prop(sculpt, "mask_opacity") class VIEW3D_PT_sculpt_options_unified(Panel, View3DPaintPanel): diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index b9669473161..b96b34a88b7 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -969,12 +969,11 @@ typedef struct Sculpt { /* Direction used for SCULPT_OT_symmetrize operator */ int symmetrize_direction; + char _pad[4]; + /* gravity factor for sculpting */ float gravity_factor; - /* mask opacity */ - float mask_opacity; - /* scale for constant detail size */ /** Constant detail resolution (Blender unit / constant_detail). */ float constant_detail; diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c index c6dbb9c7ea8..221d4375970 100644 --- a/source/blender/makesrna/intern/rna_sculpt_paint.c +++ b/source/blender/makesrna/intern/rna_sculpt_paint.c @@ -840,14 +840,6 @@ static void rna_def_sculpt(BlenderRNA *brna) RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Sculpt_ShowMask_update"); - prop = RNA_def_property(srna, "mask_opacity", PROP_FLOAT, PROP_FACTOR); - RNA_def_property_float_sdna(prop, NULL, "mask_opacity"); - RNA_def_property_ui_range(prop, 0.0, 1.0, 0.01, 2); - RNA_def_property_float_default(prop, 1.0f); - RNA_def_property_ui_text(prop, "Mask Opacity", "Opacitiy of the sculpt mask"); - RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE); - RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Sculpt_update"); - prop = RNA_def_property(srna, "detail_size", PROP_FLOAT, PROP_PIXEL); RNA_def_property_ui_range(prop, 0.5, 40.0, 10, 2); RNA_def_property_ui_text( ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [3539cd38a45] sculpt-mode-features: Fix mask extract Windows build
Commit: 3539cd38a45480e2d4b6642cd79ce76e21ec617f Author: Pablo Dobarro Date: Mon Jul 8 16:21:54 2019 +0200 Branches: sculpt-mode-features https://developer.blender.org/rB3539cd38a45480e2d4b6642cd79ce76e21ec617f Fix mask extract Windows build === M source/blender/editors/object/object_edit.c === diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 16af8d92b53..8d9b4da89b2 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -2128,7 +2128,9 @@ static int paint_mask_extract_exec(bContext *C, wmOperator *op) BM_mesh_delete_hflag_context(bm, BM_ELEM_TAG, DEL_VERTS); BKE_editmesh_free_derivedmesh(em); BKE_mesh_free(newMesh); -newMesh = BKE_mesh_from_bmesh_nomain(bm, (&(struct BMeshToMeshParams){})); +newMesh = BKE_mesh_from_bmesh_nomain(bm, (&(struct BMeshToMeshParams){ +.calc_object_remap = true, + })); ushort local_view_bits = 0; View3D *v3d = CTX_wm_view3d(C); if (v3d && v3d->localvd) { ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [66cdb4df51d] sculpt-mode-features: Blueprint tool: Initial implementation
Commit: 66cdb4df51d4768f6408564dca033d450170955d Author: Pablo Dobarro Date: Mon Jul 8 16:15:00 2019 +0200 Branches: sculpt-mode-features https://developer.blender.org/rB66cdb4df51d4768f6408564dca033d450170955d Blueprint tool: Initial implementation Work in progress - Geometry generation code is only for testing the operator. It will triangulate any generated ngon and the normal calculation can fail. - Snapping options are not integrated with scene settings - Gird alignment is forced to global X axis. This can cause problems with rotated objects. - The tool only works from object mode. It crashes in other modes. - Some internal grid default values are not set up properly and can make the operator crash - The grid preview is not integrated with the gizmo system, you need to start the operator in order to see it === M release/scripts/presets/keyconfig/keymap_data/blender_default.py M release/scripts/startup/bl_ui/space_toolsystem_toolbar.py M source/blender/editors/object/CMakeLists.txt A source/blender/editors/object/object_blueprint.c M source/blender/editors/object/object_intern.h M source/blender/editors/object/object_ops.c === diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py b/release/scripts/presets/keyconfig/keymap_data/blender_default.py index 17b1b874dec..acc4c8c173d 100644 --- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py +++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py @@ -5916,6 +5916,15 @@ def km_3d_view_tool_sculpt_gpencil_select_lasso(params): ) +def km_3d_view_tool_object_blueprint(params): +return ( +"Object: Blueprint", +{"space_type": 'VIEW_3D', "region_type": 'WINDOW'}, +{"items": [ +("object.blueprint", {"type": params.tool_mouse, "value": 'PRESS'}, + None) +]}, +) # -- # Full Configuration @@ -6128,6 +6137,7 @@ def generate_keymaps(params=None): km_3d_view_tool_sculpt_gpencil_select_box(params), km_3d_view_tool_sculpt_gpencil_select_circle(params), km_3d_view_tool_sculpt_gpencil_select_lasso(params), +km_3d_view_tool_object_blueprint(params), ] # -- diff --git a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py index 77945702e2a..1dce523402c 100644 --- a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py +++ b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py @@ -140,6 +140,28 @@ class _defs_view3d_generic: keymap="3D View Tool: Measure", ) +@ToolDef.from_fn +def blueprint(): +def draw_settings(context, layout, tool): +props = tool.operator_properties("object.blueprint") +sub = layout.row() +sub.use_property_split = False +sub.prop(props, "draw_tool", expand=False) +sub.prop(props, "plane_offset", expand=False) +sub.prop(props, "grid_snap", expand=False) +sub.prop(props, "grid_size", expand=False) +sub.prop(props, "floor_grid_snap", expand=False) +sub.prop(props, "vertex_snap", expand=False) +sub.prop(props, "symmetrical_extrude", expand=False) +sub.prop(props, "ellipse_nsegments", expand=False) +return dict( +idname="object.blueprint", +label="Bluerprint", +icon="object.blueprint", +keymap="Object: Blueprint", +draw_settings=draw_settings, +) + class _defs_annotate: @@ -1911,6 +1933,8 @@ class VIEW3D_PT_tools_active(ToolSelectPanelHelper, Panel): None, *_tools_annotate, _defs_view3d_generic.ruler, +None, +_defs_view3d_generic.blueprint, ) _tools = { diff --git a/source/blender/editors/object/CMakeLists.txt b/source/blender/editors/object/CMakeLists.txt index 48c8c8cee08..43323a939ed 100644 --- a/source/blender/editors/object/CMakeLists.txt +++ b/source/blender/editors/object/CMakeLists.txt @@ -46,6 +46,7 @@ set(SRC object_add.c object_bake.c object_bake_api.c + object_blueprint.c object_collection.c object_constraint.c object_data_transfer.c diff --git a/source/blender/editors/object/object_blueprint.c b/source/blender/editors/object/object_blueprint.c new file mode 100644 index 000..874ea86d085 --- /dev/null +++ b/source/blender/editors/object
[Bf-blender-cvs] [bfff8c8bf5a] sculpt-mode-features: Fix qex cmake
Commit: bfff8c8bf5a1706d521d57627d5cd3046408eb75 Author: Pablo Dobarro Date: Mon Jul 8 16:19:00 2019 +0200 Branches: sculpt-mode-features https://developer.blender.org/rBbfff8c8bf5a1706d521d57627d5cd3046408eb75 Fix qex cmake === M intern/qex/CMakeLists.txt === diff --git a/intern/qex/CMakeLists.txt b/intern/qex/CMakeLists.txt index 1eadb019867..6d7dbdf2e65 100644 --- a/intern/qex/CMakeLists.txt +++ b/intern/qex/CMakeLists.txt @@ -31,6 +31,9 @@ set(SRC igl_capi.h ) +set(LIB +) + if(WITH_QEX) add_definitions( -DWITH_QEX @@ -50,4 +53,4 @@ if(WITH_QEX) ) endif() -blender_add_lib(bf_intern_qex "${SRC}" "${INC}" "${INC_SYS}") +blender_add_lib(bf_intern_qex "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [bad96e5c7c7] sculpt-mode-features: Sculpt mask: Mask by normal operator
Commit: bad96e5c7c7ed721941e7bf0d96f4b2481052349 Author: Pablo Dobarro Date: Mon Apr 22 01:09:47 2019 +0200 Branches: sculpt-mode-features https://developer.blender.org/rBbad96e5c7c7ed721941e7bf0d96f4b2481052349 Sculpt mask: Mask by normal operator This is an experimental operator that can be used to generate mask for faces in hard surface sculpts. It does not have UI and without undo support the behaviour is unpredictable, but this code can be used to add another automasking mode to the automasking system. === M 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 d7ded4e6995..129d191a924 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -7606,6 +7606,134 @@ void SCULPT_OT_color_fill(struct wmOperatorType *ot) ot->flag = OPTYPE_REGISTER; } +static int sculpt_mask_by_normal_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(e)) +{ + Sculpt *sd = CTX_data_tool_settings(C)->sculpt; + Object *ob = CTX_data_active_object(C); + SculptSession *ss = ob->sculpt; + ARegion *ar = CTX_wm_region(C); + PBVH *pbvh = ob->sculpt->pbvh; + struct Scene *scene = CTX_data_scene(C); + Depsgraph *depsgraph = CTX_data_depsgraph(C); + PBVHNode **nodes; + int totnode; + + /* Disable for multires and dyntopo for now */ + if (BKE_pbvh_type(pbvh) != PBVH_FACES) { + ss->use_orco = false; + return OPERATOR_CANCELLED; + } + + /* Initial setup */ + BKE_sculpt_update_mesh_elements(depsgraph, scene, sd, ob, true, true); + + BKE_pbvh_search_gather(pbvh, NULL, NULL, , ); + sculpt_undo_push_begin("Mask Coplanar"); + for (int i = 0; i < totnode; i++) { + sculpt_undo_push_node(ob, nodes[i], SCULPT_UNDO_MASK); + BKE_pbvh_node_mark_redraw(nodes[i]); + } + + /* Mask generation */ + int init_vert = ss->active_vertex_mesh_index; + + BLI_Stack *stack; + MVert *mvert = ss->mvert; + float threshold; + int *mvert_visited = MEM_callocN(ss->totvert * sizeof (int), "visited vertices"); + + threshold = RNA_float_get(op->ptr, "threshold"); + + stack = BLI_stack_new(sizeof(int), "verts stack"); + BLI_stack_push(stack, _vert); + + while(!BLI_stack_is_empty(stack)){ + int vert; + BLI_stack_pop(stack, ); + MeshElemMap *vert_map = >pmap[vert]; + if(mvert_visited[vert] == 0) { + ss->vmask[vert] = 1.0f; + mvert[vert].flag |= ME_VERT_PBVH_UPDATE; + mvert_visited[vert] = 1; + } + int i = 0; + for (i = 0; i < ss->pmap[vert].count; i++) { + const MPoly *p = >mpoly[vert_map->indices[i]]; + unsigned f_adj_v[2]; + if (poly_get_adj_loops_from_vert(p, ss->mloop, vert, f_adj_v) != -1) { + int j; + for (j = 0; j < ARRAY_SIZE(f_adj_v); j += 1) { + if (vert_map->count != 2 || ss->pmap[f_adj_v[j]].count <= 2) { + if(mvert_visited[f_adj_v[j]] == 0){ + mvert_visited[f_adj_v[j]] = 1; + float original_normal[3]; + float new_normal[3]; + normal_short_to_float_v3(original_normal, mvert[vert].no); + normal_short_to_float_v3(new_normal, mvert[f_adj_v[j]].no); + if (dot_v3v3(original_normal, new_normal) > threshold) { + ss->vmask[f_adj_v[j]] = dot_v3v3(original_normal, new_normal); + mvert[f_adj_v[j]].flag |= ME_VERT_PBVH_UPDATE; + BLI_stack_push(stack, _adj_v[j]); + } + } + } + } + } + } + } + + MEM_freeN(mvert_visited); + + /* Smooth iterations */ + SculptThreadedTaskData data = { + .sd = sd, .ob = ob, .no
[Bf-blender-cvs] [ab0be1b7208] sculpt-mode-features: Merge commit 'e12c08e8d170b7ca40f204a5b0423c23a9fbc2c1' into sculpt-mode-features
Commit: ab0be1b72084010f853060cce4b39bd8de94dfa4 Author: Pablo Dobarro Date: Tue Apr 23 17:51:51 2019 +0200 Branches: sculpt-mode-features https://developer.blender.org/rBab0be1b72084010f853060cce4b39bd8de94dfa4 Merge commit 'e12c08e8d170b7ca40f204a5b0423c23a9fbc2c1' into sculpt-mode-features === === diff --cc CMakeLists.txt index bc0e0023cfb,2f5b8240c88..ff9a06730e7 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@@ -24,20 -24,20 +24,20 @@@ # build the libs and objects in it. if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR}) -- if(NOT DEFINED WITH_IN_SOURCE_BUILD) -- message(FATAL_ERROR -- "CMake generation for blender is not allowed within the source directory!" -- "\n Remove \"${CMAKE_SOURCE_DIR}/CMakeCache.txt\" and try again from another folder, e.g.:" -- "\n " -- "\n rm CMakeCache.txt" -- "\n cd .." -- "\n mkdir cmake-make" -- "\n cd cmake-make" -- "\n cmake ../blender" -- "\n " -- "\n Alternately define WITH_IN_SOURCE_BUILD to force this option (not recommended!)" -- ) -- endif() ++ if(NOT DEFINED WITH_IN_SOURCE_BUILD) ++message(FATAL_ERROR ++ "CMake generation for blender is not allowed within the source directory!" ++ "\n Remove \"${CMAKE_SOURCE_DIR}/CMakeCache.txt\" and try again from another folder, e.g.:" ++ "\n " ++ "\n rm CMakeCache.txt" ++ "\n cd .." ++ "\n mkdir cmake-make" ++ "\n cd cmake-make" ++ "\n cmake ../blender" ++ "\n " ++ "\n Alternately define WITH_IN_SOURCE_BUILD to force this option (not recommended!)" ++) ++ endif() endif() cmake_minimum_required(VERSION 3.5) @@@ -46,13 -46,13 +46,13 @@@ # platforms which don't hare GLVND yet. Only do it if preference was not set # externally. if(NOT DEFINED OpenGL_GL_PREFERENCE) -- set(OpenGL_GL_PREFERENCE "LEGACY") ++ set(OpenGL_GL_PREFERENCE "LEGACY") endif() if(NOT EXECUTABLE_OUTPUT_PATH) -- set(FIRST_RUN TRUE) ++ set(FIRST_RUN TRUE) else() -- set(FIRST_RUN FALSE) ++ set(FIRST_RUN FALSE) endif() # this starts out unset @@@ -61,12 -61,12 +61,12 @@@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_ # avoid having empty buildtype if(NOT DEFINED CMAKE_BUILD_TYPE_INIT) -- set(CMAKE_BUILD_TYPE_INIT "Release") ++ set(CMAKE_BUILD_TYPE_INIT "Release") endif() # Omit superfluous "Up-to-date" messages. if(NOT DEFINED CMAKE_INSTALL_MESSAGE) -- set(CMAKE_INSTALL_MESSAGE "LAZY") ++ set(CMAKE_INSTALL_MESSAGE "LAZY") endif() # quiet output for Makefiles, 'make -s' helps too @@@ -74,10 -74,10 +74,10 @@@ # global compile definitions since add_definitions() adds for all. set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS -- $<$:DEBUG;_DEBUG> -- $<$:NDEBUG> -- $<$:NDEBUG> -- $<$:NDEBUG> ++ $<$:DEBUG;_DEBUG> ++ $<$:NDEBUG> ++ $<$:NDEBUG> ++ $<$:NDEBUG> ) #- @@@ -118,9 -118,9 +118,9 @@@ enable_testing( set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin CACHE INTERNAL "" FORCE) set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib CACHE INTERNAL "" FORCE) if(MSVC) -- set(TESTS_OUTPUT_DIR ${EXECUTABLE_OUTPUT_PATH}/tests/$/ CACHE INTERNAL "" FORCE) ++ set(TESTS_OUTPUT_DIR ${EXECUTABLE_OUTPUT_PATH}/tests/$/ CACHE INTERNAL "" FORCE) else() -- set(TESTS_OUTPUT_DIR ${EXECUTABLE_OUTPUT_PATH}/tests/ CACHE INTERNAL "" FORCE) ++ set(TESTS_OUTPUT_DIR ${EXECUTABLE_OUTPUT_PATH}/tests/ CACHE INTERNAL "" FORCE) endif() #- @@@ -137,55 -137,55 +137,55 @@@ set(_init_vars # initialize to ON macro(option_defaults_init) -- foreach(_var ${ARGV}) -- set(${_var} ON) -- list(APPEND _init_vars "${_var}") -- endforeach() -- unset(_var) ++ foreach(_var ${ARGV}) ++set(${_var} ON) ++list(APPEND _init_vars "${_var}") ++ endforeach() ++ unset(_var) endmacro() # remove from namespace macro(option_defaults_clear) -- foreach(_var ${_init_vars}) -- unset(${_var}) -- endforeach() -- unset(_var) -- unset(_init_vars) ++ foreach(_var ${_init_
[Bf-blender-cvs] [c47ca6adab4] sculpt-mode-features: Merge branch 'master' into sculpt-mode-features
Commit: c47ca6adab4d3a726f5dd942d625a270188e8043 Author: Pablo Dobarro Date: Tue Apr 23 20:24:54 2019 +0200 Branches: sculpt-mode-features https://developer.blender.org/rBc47ca6adab4d3a726f5dd942d625a270188e8043 Merge branch 'master' into sculpt-mode-features === === diff --cc build_files/cmake/macros.cmake index fdbb610338f,56d9117e560..90f07e7edc7 --- a/build_files/cmake/macros.cmake +++ b/build_files/cmake/macros.cmake @@@ -19,175 -19,175 +19,175 @@@ # * END GPL LICENSE BLOCK * macro(list_insert_after -- list_id item_check item_add -- ) -- set(_index) -- list(FIND "${list_id}" "${item_check}" _index) -- if("${_index}" MATCHES "-1") --message(FATAL_ERROR "'${list_id}' doesn't contain '${item_check}'") -- endif() -- math(EXPR _index "${_index} + 1") -- list(INSERT ${list_id} "${_index}" ${item_add}) -- unset(_index) ++ list_id item_check item_add ++ ) ++ set(_index) ++ list(FIND "${list_id}" "${item_check}" _index) ++ if("${_index}" MATCHES "-1") ++ message(FATAL_ERROR "'${list_id}' doesn't contain '${item_check}'") ++ endif() ++ math(EXPR _index "${_index} + 1") ++ list(INSERT ${list_id} "${_index}" ${item_add}) ++ unset(_index) endmacro() macro(list_insert_before -- list_id item_check item_add -- ) -- set(_index) -- list(FIND "${list_id}" "${item_check}" _index) -- if("${_index}" MATCHES "-1") --message(FATAL_ERROR "'${list_id}' doesn't contain '${item_check}'") -- endif() -- list(INSERT ${list_id} "${_index}" ${item_add}) -- unset(_index) ++ list_id item_check item_add ++ ) ++ set(_index) ++ list(FIND "${list_id}" "${item_check}" _index) ++ if("${_index}" MATCHES "-1") ++ message(FATAL_ERROR "'${list_id}' doesn't contain '${item_check}'") ++ endif() ++ list(INSERT ${list_id} "${_index}" ${item_add}) ++ unset(_index) endmacro() function(list_assert_duplicates -- list_id -- ) -- -- # message(STATUS "list data: ${list_id}") -- -- list(LENGTH list_id _len_before) -- list(REMOVE_DUPLICATES list_id) -- list(LENGTH list_id _len_after) -- # message(STATUS "list size ${_len_before} -> ${_len_after}") -- if(NOT _len_before EQUAL _len_after) --message(FATAL_ERROR "duplicate found in list which should not contain duplicates: ${list_id}") -- endif() -- unset(_len_before) -- unset(_len_after) ++ list_id ++ ) ++ ++ # message(STATUS "list data: ${list_id}") ++ ++ list(LENGTH list_id _len_before) ++ list(REMOVE_DUPLICATES list_id) ++ list(LENGTH list_id _len_after) ++ # message(STATUS "list size ${_len_before} -> ${_len_after}") ++ if(NOT _len_before EQUAL _len_after) ++ message(FATAL_ERROR "duplicate found in list which should not contain duplicates: ${list_id}") ++ endif() ++ unset(_len_before) ++ unset(_len_after) endfunction() # foo_bar.spam --> foo_barMySuffix.spam macro(file_suffix -- file_name_new file_name file_suffix -- ) ++ file_name_new file_name file_suffix ++ ) -- get_filename_component(_file_name_PATH ${file_name} PATH) -- get_filename_component(_file_name_NAME_WE ${file_name} NAME_WE) -- get_filename_component(_file_name_EXT ${file_name} EXT) -- set(${file_name_new} "${_file_name_PATH}/${_file_name_NAME_WE}${file_suffix}${_file_name_EXT}") ++ get_filename_component(_file_name_PATH ${file_name} PATH) ++ get_filename_component(_file_name_NAME_WE ${file_name} NAME_WE) ++ get_filename_component(_file_name_EXT ${file_name} EXT) ++ set(${file_name_new} "${_file_name_PATH}/${_file_name_NAME_WE}${file_suffix}${_file_name_EXT}") -- unset(_file_name_PATH) -- unset(_file_name_NAME_WE) -- unset(_file_name_EXT) ++ unset(_file_name_PATH) ++ unset(_file_name_NAME_WE) ++ unset(_file_name_EXT) endmacro() # useful for adding debug suffix to library lists: # /somepath/foo.lib --> /somepath/foo_d.lib macro(file_list_suffix -- fp_list_new fp_list fn_suffix -- ) ++ fp_list_new fp_list fn_suffix ++ ) -- # incase of empty list -- set(_fp) -- set(_fp_suffixed) ++ # incase of empty list ++ set(_fp) ++ set(_fp_suffixed) -- set(fp_list_new) ++ set(fp_list_new) -- foreach(_fp ${fp_list}) --file_suffix(_fp_suffixed "${_fp}" "${fn_suffix}") --list(APPEND "${fp_list_new}" "${_fp_suffixed}") -- endforeach(
[Bf-blender-cvs] [eab72c52429] sculpt-mode-features: Merge commit 'e12c08e8d170b7ca40f204a5b0423c23a9fbc2c1^1' into sculpt-mode-features
Commit: eab72c52429596df978e5af4a9975079c1854848 Author: Pablo Dobarro Date: Tue Apr 23 17:50:58 2019 +0200 Branches: sculpt-mode-features https://developer.blender.org/rBeab72c52429596df978e5af4a9975079c1854848 Merge commit 'e12c08e8d170b7ca40f204a5b0423c23a9fbc2c1^1' into sculpt-mode-features === === diff --cc build_files/cmake/macros.cmake index d88b5c04ce2,22e53fecf50..90f07e7edc7 --- a/build_files/cmake/macros.cmake +++ b/build_files/cmake/macros.cmake @@@ -539,270 -539,6 +546,269 @@@ function(setup_liblink target_link_libraries(${target} ${PLATFORM_LINKLIBS}) endfunction() - +function(SETUP_BLENDER_SORTED_LIBS) + + get_property(BLENDER_LINK_LIBS GLOBAL PROPERTY BLENDER_LINK_LIBS) + + list(APPEND BLENDER_LINK_LIBS + bf_windowmanager + bf_render + ) + + if(WITH_MOD_FLUID) + list(APPEND BLENDER_LINK_LIBS bf_intern_elbeem) + endif() + + if(WITH_CYCLES) + list(APPEND BLENDER_LINK_LIBS + cycles_render + cycles_graph + cycles_bvh + cycles_device + cycles_kernel + cycles_util + cycles_subd) + if(WITH_CYCLES_OSL) + list(APPEND BLENDER_LINK_LIBS cycles_kernel_osl) + endif() + endif() + + if(WITH_AUDASPACE AND NOT WITH_SYSTEM_AUDASPACE) + list(APPEND BLENDER_LINK_LIBS + audaspace + audaspace-py) + endif() + + # Sort libraries + set(BLENDER_SORTED_LIBS + bf_windowmanager + + bf_editor_undo + + bf_editor_space_api + bf_editor_space_action + bf_editor_space_buttons + bf_editor_space_console + bf_editor_space_file + bf_editor_space_graph + bf_editor_space_image + bf_editor_space_info + bf_editor_space_logic + bf_editor_space_nla + bf_editor_space_node + bf_editor_space_outliner + bf_editor_space_script + bf_editor_space_sequencer + bf_editor_space_statusbar + bf_editor_space_text + bf_editor_space_time + bf_editor_space_topbar + bf_editor_space_userpref + bf_editor_space_view3d + bf_editor_space_clip + + bf_editor_transform + bf_editor_uvedit + bf_editor_curve + bf_editor_interface + bf_editor_gizmo_library + bf_editor_mesh + bf_editor_metaball + bf_editor_object + bf_editor_gpencil + bf_editor_lattice + bf_editor_armature + bf_editor_physics + bf_editor_render + bf_editor_scene + bf_editor_screen + bf_editor_sculpt_paint + bf_editor_sound + bf_editor_animation + bf_editor_datafiles + bf_editor_mask + bf_editor_io + bf_editor_util + + bf_render + bf_python + bf_python_ext + bf_python_mathutils + bf_python_gpu + bf_python_bmesh + bf_freestyle + bf_ikplugin + bf_modifiers + bf_gpencil_modifiers + bf_alembic + bf_bmesh + bf_gpu + bf_draw + bf_blenloader + bf_blenkernel + bf_shader_fx + bf_gpencil_modifiers + bf_physics + bf_nodes + bf_rna + bf_editor_gizmo_library # rna -> gizmo bad-level calls + bf_python + bf_imbuf + bf_blenlib + bf_depsgraph + bf_intern_ghost + bf_intern_string + bf_avi + bf_imbuf_cineon + bf_imbuf_openexr + bf_imbuf_openimageio + bf_imbuf_dds + bf_collada + bf_intern_elbeem + bf_intern_memutil + bf_intern_guardedalloc + bf_intern_ctr + bf_intern_utfconv + bf_intern_smoke + extern_lzma + extern_curve_fit_nd + bf_intern_moto + extern_openjpeg + bf_dna + + bf_blenfont + bf_gpu # duplicate for blenfont + bf_blentranslation + bf_intern_audaspace + audasp
[Bf-blender-cvs] [e27ab0790f8] sculpt-mode-features: Fix crash when sculpting with EEVEE/LookDev enabled
Commit: e27ab0790f87c3b3f5bd0b1a36bfd011397d2281 Author: Pablo Dobarro Date: Wed Apr 24 17:19:52 2019 +0200 Branches: sculpt-mode-features https://developer.blender.org/rBe27ab0790f87c3b3f5bd0b1a36bfd011397d2281 Fix crash when sculpting with EEVEE/LookDev enabled === M 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 4244b2596a5..8f6e1f3af41 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -5740,6 +5740,13 @@ bool sculpt_stroke_get_geometry_info(bContext *C, StrokeGeometryInfo *out, const ob = vc.obact; ss = ob->sculpt; + if (!ss->pbvh) { +copy_v3_fl(out->location, 0.0f); +copy_v3_fl(out->normal, 0.0f); +copy_v3_fl(out->nearest_vertex_co, 0.0f); +return false; + } + depth = sculpt_raycast_init(, mouse, ray_start, ray_end, ray_normal, original); sculpt_stroke_modifiers_check(C, ob, brush); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [9408023a818] master: Fix T63344: broken topology after sculpting with clay strips brush
Commit: 9408023a81843f0c034bab117c654e11d2b7343f Author: Pablo Dobarro Date: Thu Apr 25 14:07:30 2019 +0200 Branches: master https://developer.blender.org/rB9408023a81843f0c034bab117c654e11d2b7343f Fix T63344: broken topology after sculpting with clay strips brush Differential Revision: https://developer.blender.org/D4710 === M 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 5ae004fde5f..9ba7561b18b 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -3455,6 +3455,10 @@ static void do_clay_strips_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int t return; } + if (is_zero_v3(ss->cache->grab_delta_symmetry)) { +return; + } + mul_v3_v3v3(temp, area_no_sp, ss->cache->scale); mul_v3_fl(temp, displace); add_v3_v3(area_co, temp); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [51582bf565b] sculpt-mode-features: Sculpt mode: Grow and shrink mask filters
Commit: 51582bf565b874fa5ff434c74fa4fb422462dcb6 Author: Pablo Dobarro Date: Fri Apr 12 00:35:38 2019 +0200 Branches: sculpt-mode-features https://developer.blender.org/rB51582bf565b874fa5ff434c74fa4fb422462dcb6 Sculpt mode: Grow and shrink mask filters === M source/blender/editors/sculpt_paint/sculpt.c M source/blender/editors/sculpt_paint/sculpt_intern.h === diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 882cd0fb090..9934b835350 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -1659,6 +1659,54 @@ static float neighbor_average_mask(SculptSession *ss, unsigned vert) return vmask[vert]; } +static float neighbor_min_mask(SculptSession *ss, const int vert, float *prev_mask) +{ + const MeshElemMap *vert_map = >pmap[vert]; + const float *vmask = prev_mask; + + int i = 0; + float min = 1.0f; + for (i = 0; i < vert_map->count; i++) { + const MPoly *p = >mpoly[vert_map->indices[i]]; + unsigned f_adj_v[2]; + + if (poly_get_adj_loops_from_vert(p, ss->mloop, vert, f_adj_v) != -1) { + int j; + for (j = 0; j < ARRAY_SIZE(f_adj_v); j += 1) { + float vmask_f = vmask[f_adj_v[j]]; + if (vmask_f < min) { + min = vmask_f; + } + } + } + } + return min; +} + +static float neighbor_max_mask(SculptSession *ss, const int vert, float *prev_mask) +{ + const MeshElemMap *vert_map = >pmap[vert]; + const float *vmask = prev_mask; + + int i = 0; + float max = 0.0f; + for (i = 0; i < vert_map->count; i++) { + const MPoly *p = >mpoly[vert_map->indices[i]]; + unsigned f_adj_v[2]; + + if (poly_get_adj_loops_from_vert(p, ss->mloop, vert, f_adj_v) != -1) { + int j; + for (j = 0; j < ARRAY_SIZE(f_adj_v); j += 1) { + float vmask_f = vmask[f_adj_v[j]]; + if (vmask_f > max) { + max = vmask_f; + } + } + } + } + return max; +} + /* Same logic as neighbor_average(), but for bmesh rather than mesh */ static void bmesh_neighbor_average(float avg[3], BMVert *v) { @@ -7210,12 +7258,16 @@ void SCULPT_OT_mesh_filter(struct wmOperatorType *ot) typedef enum eSculptMaskFilterTypes { MASK_FILTER_BLUR = 0, - MASK_FILTER_SHARPEN =1, + MASK_FILTER_SHARPEN = 1, + MASK_FILTER_GROW = 2, + MASK_FILTER_SHRINK = 3, } eSculptMaskFilterTypes; EnumPropertyItem prop_mask_filter_types[] = { {MASK_FILTER_BLUR, "BLUR", 0, "Blur Mask", "Blur mask"}, {MASK_FILTER_SHARPEN, "SHARPEN", 0, "Sharpen Mask", "Sharpen mask"}, + {MASK_FILTER_GROW, "GROW", 0, "Grow Mask", "Grow mask"}, + {MASK_FILTER_SHRINK, "SHRINK", 0, "Shrink Mask", "Shrink mask"}, {0, NULL, 0, NULL, NULL}, }; @@ -7262,6 +7314,20 @@ static void mask_filter_task_cb( *vd.mask += val/2; CLAMP(*vd.mask, 0.0f, 1.0f); break; + case MASK_FILTER_GROW: + if (BKE_pbvh_type(ss->pbvh) == PBVH_FACES){ + val = neighbor_max_mask(ss, vd.vert_indices[vd.i], data->prev_mask); + *vd.mask = val; + CLAMP(*vd.mask, 0.0f, 1.0f); + } + break; + case MASK_FILTER_SHRINK: + if (BKE_pbvh_type(ss->pbvh) == PBVH_FACES){ + val = neighbor_min_mask(ss, vd.vert_indices[vd.i], data->prev_mask); + *vd.mask = val; + CLAMP(*vd.mask, 0.0f, 1.0f); + } + break; } if (vd.mvert) vd.mvert->flag |= ME_VERT_PBVH_UPDATE; @@ -7277,6 +7343,7 @@ static int sculpt_mask_filter_exec(bContext *C, wmOperator *op) ARegion *ar = CTX_wm_region(C); struct Scene *scene = CTX_data_scene(C); Object *ob = CTX_data_active_object
[Bf-blender-cvs] [1a1152cb1ba] sculpt-mode-features: Brush Stroke: Use world spacing option
Commit: 1a1152cb1ba4cc357bacd83698edd50c8350ff51 Author: Pablo Dobarro Date: Mon Apr 22 19:37:49 2019 +0200 Branches: sculpt-mode-features https://developer.blender.org/rB1a1152cb1ba4cc357bacd83698edd50c8350ff51 Brush Stroke: Use world spacing option Quick hack to compute the stroke step using the world space location of the brush over the mesh instead of the screen space distance, so the user can avoid a lot of artifacts when sculpting across curved surfaces. This would need to be implemented for texture/vertex/weight paint in the future to keep the stroke system consistent. It still has some problems with brushes that use original coordinates. === M release/scripts/startup/bl_ui/space_view3d_toolbar.py M source/blender/editors/sculpt_paint/paint_stroke.c M source/blender/editors/sculpt_paint/sculpt.c M source/blender/makesdna/DNA_brush_types.h M source/blender/makesrna/intern/rna_brush.c === diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py index b8fe0204abd..042ee00f038 100644 --- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py +++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py @@ -885,6 +885,8 @@ class VIEW3D_PT_tools_brush_stroke(Panel, View3DPaintPanel): if brush.sculpt_capabilities.has_space_attenuation: col.prop(brush, "use_space_attenuation") +col.prop(brush, "use_world_spacing") + if brush.sculpt_capabilities.has_jitter: row = col.row(align=True) diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c index d66224034eb..e03ec6ec035 100644 --- a/source/blender/editors/sculpt_paint/paint_stroke.c +++ b/source/blender/editors/sculpt_paint/paint_stroke.c @@ -59,6 +59,7 @@ #include "IMB_imbuf_types.h" #include "paint_intern.h" +#include "sculpt_intern.h" #include #include @@ -686,22 +687,39 @@ static int paint_space_stroke(bContext *C, wmOperator *op, const float final_mou float pressure, dpressure; float mouse[2], dmouse[2]; + float p_final_mouse[3], p_dmouse[3], p_last_mouse_position[3]; float length; float no_pressure_spacing = paint_space_stroke_spacing(scene, stroke, 1.0f, 1.0f); - - sub_v2_v2v2(dmouse, final_mouse, stroke->last_mouse_position); - pressure = stroke->last_pressure; dpressure = final_pressure - stroke->last_pressure; - + sub_v2_v2v2(dmouse, final_mouse, stroke->last_mouse_position); length = normalize_v2(dmouse); + if (stroke->brush->flag2 & BRUSH_WORLD_SPACING) { + sculpt_stroke_get_location(C, p_last_mouse_position, stroke->last_mouse_position); + bool hit = sculpt_stroke_get_location(C, p_final_mouse, final_mouse); + if (hit) { + sub_v3_v3v3(p_dmouse, p_final_mouse, p_last_mouse_position); + length = len_v3(p_dmouse); + length = length * 400; + } + else { + length = 0.0f; + } + } + while (length > 0.0f) { float spacing = paint_space_stroke_spacing_variable(scene, stroke, pressure, dpressure, length); if (length >= spacing) { - mouse[0] = stroke->last_mouse_position[0] + dmouse[0] * spacing; - mouse[1] = stroke->last_mouse_position[1] + dmouse[1] * spacing; + if (stroke->brush->flag2 & BRUSH_WORLD_SPACING) { + mouse[0] = final_mouse[0]; + mouse[1] = final_mouse[1]; + } + else { + mouse[0] = stroke->last_mouse_position[0] + dmouse[0] * spacing; + mouse[1] = stroke->last_mouse_position[1] + dmouse[1] * spacing; + } pressure = stroke->last_pressure + (spacing / length) * dpressure; ups->overlap_factor = paint_stroke_integrate_overlap(stroke->brush, spacing / no_pressure_spacing); diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 129d191a924..14e831af0ec 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -3677,6 +3677,9 @@ static void do_clay_strips_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int t if (ss->cache->first_time) return; + if (is_zero_v3(ss->cache->grab_delta_symmetry)) + ret
[Bf-blender-cvs] [ce83be4832c] sculpt-mode-features: Cleanup and variable renaming
Commit: ce83be4832c1e64fa5a8a8f644bbdbe614b2dc5a Author: Pablo Dobarro Date: Sat Jun 29 17:35:19 2019 +0200 Branches: sculpt-mode-features https://developer.blender.org/rBce83be4832c1e64fa5a8a8f644bbdbe614b2dc5a Cleanup and variable renaming === M source/blender/blenkernel/intern/brush.c M source/blender/editors/object/object_edit.c M source/blender/editors/sculpt_paint/sculpt.c M source/blender/editors/sculpt_paint/sculpt_intern.h M source/blender/editors/sculpt_paint/sculpt_undo.c M source/blender/makesdna/DNA_brush_types.h M source/blender/makesrna/intern/rna_brush.c === diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index f325e4fb72e..326cd20c570 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -1273,7 +1273,7 @@ bool BKE_brush_sculpt_has_secondary_color(const Brush *brush) SCULPT_TOOL_FILL, SCULPT_TOOL_SCRAPE, SCULPT_TOOL_MASK, - SCULPT_TOOL_DAM); + SCULPT_TOOL_ORCO); } void BKE_brush_unprojected_radius_set(Scene *scene, Brush *brush, float unprojected_radius) diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 8b3ed406ada..696cf2e9972 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -1796,15 +1796,12 @@ void OBJECT_OT_link_to_collection(wmOperatorType *ot) static int remesh_exec(bContext *C, wmOperator *op) { - bool linked_data = false; - Object *ob = CTX_data_active_object(C); Main *bmain = CTX_data_main(C); ID *data; data = ob->data; if (data && ID_IS_LINKED(data)) { -linked_data = true; return OPERATOR_CANCELLED; } @@ -1835,7 +1832,7 @@ static int remesh_exec(bContext *C, wmOperator *op) pbvh = ob->sculpt->pbvh; BKE_pbvh_search_gather(pbvh, NULL, NULL, , ); sculpt_undo_push_begin("voxel remesh"); - sculpt_undo_push_node(ob, nodes[0], SCULPT_UNDO_REMESH); + sculpt_undo_push_node(ob, nodes[0], SCULPT_UNDO_GEOMETRY); } struct OpenVDBLevelSet *level_set; diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 56c6c9e6382..c9ea21c6315 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -149,7 +149,7 @@ static int sculpt_brush_needs_normal(const SculptSession *ss, const Brush *brush SCULPT_TOOL_BLOB, SCULPT_TOOL_CREASE, SCULPT_TOOL_DRAW, - SCULPT_TOOL_DAM, + SCULPT_TOOL_ORCO, SCULPT_TOOL_LAYER, SCULPT_TOOL_NUDGE, SCULPT_TOOL_ROTATE, @@ -1161,7 +1161,7 @@ static float brush_strength(const Sculpt *sd, case SCULPT_TOOL_PAINT: case SCULPT_TOOL_LAYER: return alpha * flip * pressure * overlap * feather; -case SCULPT_TOOL_DAM: +case SCULPT_TOOL_ORCO: return alpha * flip * 4 * pressure * overlap * feather; case SCULPT_TOOL_MASK: overlap = (1 + overlap) / 2; @@ -2839,9 +2839,9 @@ static void do_draw_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode) BLI_task_parallel_range(0, totnode, , do_draw_brush_task_cb_ex, ); } -static void do_dam_brush_task_cb_ex(void *__restrict userdata, -const int n, -const ParallelRangeTLS *__restrict tls) +static void do_orco_brush_task_cb_ex(void *__restrict userdata, + const int n, + const ParallelRangeTLS *__restrict tls) { SculptThreadedTaskData *data = userdata; SculptSession *ss = data->ob->sculpt; @@ -2884,7 +2884,7 @@ static void do_dam_brush_task_cb_ex(void *__restrict userdata, BKE_pbvh_vertex_iter_end; } -static void do_dam_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode) +static void do_orco_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode) { SculptSession *ss = ob->sculpt; Brush *brush = BKE_paint_brush(>paint); @@ -2912,7 +2912,7 @@ static void do_dam_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode) ParallelRangeSettings settings; BLI_parallel_range_settings_defaults(); settings.use_threading = ((sd->flags & SCULPT_USE_OPENMP) && totnode > SCULPT_THREADED_LIMIT); - BLI_task_parallel_range(0, totnode, , do_dam_brush_task_cb_ex, ); + BLI_task_parallel_range(0, totnode, , do_orco_brush_task_cb_ex, ); } /** @@ -4887,8 +4887,8 @@ static void do_brush_action(Sculpt *sd, Object *ob, Brush *brush, UnifiedPaintSe case SCULPT_TOOL_SCRAPE:
[Bf-blender-cvs] [3a7b5693d1f] sculpt-mode-features: Sculpt: Paint mask extract operator [WIP]
Commit: 3a7b5693d1f2c709e55fdd90cf847c84238aa4ae Author: Pablo Dobarro Date: Sat Jun 29 18:05:00 2019 +0200 Branches: sculpt-mode-features https://developer.blender.org/rB3a7b5693d1f2c709e55fdd90cf847c84238aa4ae Sculpt: Paint mask extract operator [WIP] Currently the operator extracts a triangulated mesh from the mask and applies a solidify modifier. I would like to avoid using a shrinkwrap or duplicating the sculpt to create the external edge loop. I think it should be possible to do something similar to the relax brush to shrink the geometry to fit the external loop within the mask. === M source/blender/editors/object/object_edit.c M source/blender/editors/object/object_intern.h M source/blender/editors/object/object_ops.c === diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 696cf2e9972..16af8d92b53 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -2029,3 +2029,140 @@ void OBJECT_OT_loop_to_vertex_colors(wmOperatorType *ot) ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } + +static int paint_mask_extract_exec(bContext *C, wmOperator *op) +{ + Object *ob = CTX_data_active_object(C); + + ID *data; + data = ob->data; + if (data && ID_IS_LINKED(data)) { +return OPERATOR_CANCELLED; + } + + if (ob->type == OB_MESH) { +Mesh *mesh = ob->data; +Main *bmain = CTX_data_main(C); +CustomData *vdata = GET_CD_DATA(mesh, vdata); +float *paint_mask = CustomData_get_layer(vdata, CD_PAINT_MASK); +if (!paint_mask) { + return OPERATOR_CANCELLED; +} +BKE_mesh_runtime_looptri_recalc(mesh); +const MLoopTri *looptri = BKE_mesh_runtime_looptri_ensure(mesh); +MVertTri *verttri = MEM_callocN(sizeof(*verttri) * BKE_mesh_runtime_looptri_len(mesh), +"remesh_looptri"); +BKE_mesh_runtime_verttri_from_looptri( +verttri, mesh->mloop, looptri, BKE_mesh_runtime_looptri_len(mesh)); + +int totfaces = BKE_mesh_runtime_looptri_len(mesh); +unsigned int totverts = mesh->totvert; +float *verts = (float *)MEM_calloc_arrayN(totverts * 3, sizeof(float), "remesh_input_verts"); +unsigned int *faces = (unsigned int *)MEM_calloc_arrayN( +totfaces * 3, sizeof(unsigned int), "remesh_intput_faces"); + +for (int i = 0; i < totverts; i++) { + MVert mvert = mesh->mvert[i]; + verts[i * 3] = mvert.co[0]; + verts[i * 3 + 1] = mvert.co[1]; + verts[i * 3 + 2] = mvert.co[2]; +} + +int current_valid_face = 0; +float mask_threshold = 0.7; +for (int i = 0; i < totfaces; i++) { + MVertTri vt = verttri[i]; + if (paint_mask[vt.tri[0]] > mask_threshold && paint_mask[vt.tri[1]] > mask_threshold && + paint_mask[vt.tri[2]] > mask_threshold) { +faces[current_valid_face * 3] = vt.tri[0]; +faces[current_valid_face * 3 + 1] = vt.tri[1]; +faces[current_valid_face * 3 + 2] = vt.tri[2]; +current_valid_face++; + } +} + +Mesh *newMesh = BKE_mesh_new_nomain(mesh->totvert, 0, current_valid_face, 0, 0); + +for (int i = 0; i < mesh->totvert; i++) { + float vco[3] = {verts[i * 3], verts[i * 3 + 1], verts[i * 3 + 2]}; + copy_v3_v3(newMesh->mvert[i].co, vco); +} + +for (int i = 0; i < current_valid_face; i++) { + newMesh->mface[i].v4 = 0; + newMesh->mface[i].v3 = faces[i * 3]; + newMesh->mface[i].v2 = faces[i * 3 + 1]; + newMesh->mface[i].v1 = faces[i * 3 + 2]; +} + +MEM_freeN(faces); +MEM_freeN(verts); + +BKE_mesh_calc_edges_tessface(newMesh); +BKE_mesh_convert_mfaces_to_mpolys(newMesh); +BKE_mesh_calc_normals(newMesh); +BKE_mesh_strip_loose_edges(newMesh); +BKE_mesh_strip_loose_polysloops(newMesh); +BKE_mesh_strip_loose_faces(newMesh); + +const BMAllocTemplate allocsize = BMALLOC_TEMPLATE_FROM_ME(newMesh); +BMesh *bm; +bm = BM_mesh_create(, +&((struct BMeshCreateParams){ +.use_toolflags = false, +})); + +BM_mesh_bm_from_me(bm, + newMesh, + (&(struct BMeshFromMeshParams){ + .calc_face_normal = true, + })); + +BMEditMesh *em = BKE_editmesh_create(bm, false); +BMVert *v; +BMIter iter; +BM_mesh_elem_hflag_disable_all(bm, BM_VERT | BM_EDGE | BM_FACE, BM_ELEM_TAG, false); +BM_ITER_MESH (v, , bm, BM_VERTS_OF_MESH) { + BM_elem_flag_set(v, BM_ELEM_TAG, (v->e == NULL)); +} +BM_mesh_delete_hflag_context(bm, BM_ELEM_TAG, DEL_VERTS); +BKE_editmesh_free_derivedmesh(em); +BKE_mes
[Bf-blender-cvs] [ca9698b8e0d] master: Sculpt/Paint: Ignore INBETWEEN_MOUSEMOVE events on certain brush tools
Commit: ca9698b8e0d4f5748a4730bfff154a05eb8cc44c Author: Pablo Dobarro Date: Wed Aug 7 01:36:17 2019 +0200 Branches: master https://developer.blender.org/rBca9698b8e0d4f5748a4730bfff154a05eb8cc44c Sculpt/Paint: Ignore INBETWEEN_MOUSEMOVE events on certain brush tools Some brush tools were being executed too often when using devices with high polling rates, causing performance issues. This should improve the performance of brushes that don't need those updates. Reviewed By: brecht Differential Revision: https://developer.blender.org/D5429 === M source/blender/editors/sculpt_paint/paint_stroke.c === diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c index 6144f5751f2..694dae49d30 100644 --- a/source/blender/editors/sculpt_paint/paint_stroke.c +++ b/source/blender/editors/sculpt_paint/paint_stroke.c @@ -233,6 +233,23 @@ static bool paint_tool_require_location(Brush *brush, ePaintMode mode) return true; } +static bool paint_tool_require_inbetween_mouse_events(Brush *brush, ePaintMode mode) +{ + switch (mode) { +case PAINT_MODE_SCULPT: + if (ELEM(brush->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_ROTATE, SCULPT_TOOL_THUMB)) { +return false; + } + else { +return true; + } +default: + break; + } + + return true; +} + /* Initialize the stroke cache variants from operator properties */ static bool paint_brush_update(bContext *C, Brush *brush, @@ -1188,6 +1205,10 @@ int paint_stroke_modal(bContext *C, wmOperator *op, const wmEvent *event) bool redraw = false; float pressure; + if (event->type == INBETWEEN_MOUSEMOVE && !paint_tool_require_inbetween_mouse_events(br, mode)) { +return OPERATOR_RUNNING_MODAL; + } + /* see if tablet affects event. Line, anchored and drag dot strokes do not support pressure */ pressure = ((br->flag & (BRUSH_LINE | BRUSH_ANCHORED | BRUSH_DRAG_DOT)) ? 1.0f : ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [f4cf8193cbd] sculpt-mode-features: Changes to intern/openvdb
Commit: f4cf8193cbdb43312e8d229ca9aa0f871f765ee1 Author: Pablo Dobarro Date: Wed Jul 31 16:06:15 2019 +0200 Branches: sculpt-mode-features https://developer.blender.org/rBf4cf8193cbdb43312e8d229ca9aa0f871f765ee1 Changes to intern/openvdb === M intern/openvdb/intern/openvdb_level_set.cc M intern/openvdb/intern/openvdb_level_set.h M intern/openvdb/intern/openvdb_transform.cc M intern/openvdb/intern/openvdb_transform.h M intern/openvdb/openvdb_capi.cc M intern/openvdb/openvdb_capi.h M release/scripts/startup/bl_ui/properties_data_modifier.py M source/blender/makesdna/DNA_modifier_types.h M source/blender/makesrna/intern/rna_modifier.c M source/blender/modifiers/intern/MOD_remesh.c === diff --git a/intern/openvdb/intern/openvdb_level_set.cc b/intern/openvdb/intern/openvdb_level_set.cc index ac4a041c193..fbfb0bf2280 100644 --- a/intern/openvdb/intern/openvdb_level_set.cc +++ b/intern/openvdb/intern/openvdb_level_set.cc @@ -32,34 +32,32 @@ OpenVDBLevelSet::~OpenVDBLevelSet() { } -void OpenVDBLevelSet::OpenVDB_mesh_to_level_set(const float *vertices, -const unsigned int *faces, -const unsigned int totvertices, -const unsigned int totfaces, -openvdb::math::Transform::Ptr xform) +void OpenVDBLevelSet::mesh_to_level_set(const float *vertices, +const unsigned int *faces, +const unsigned int totvertices, +const unsigned int totfaces, +openvdb::math::Transform::Ptr ) { - std::vector points; - std::vector triangles; + std::vector points(totvertices); + std::vector triangles(totfaces); std::vector quads; for (unsigned int i = 0; i < totvertices; i++) { -openvdb::Vec3s v(vertices[i * 3], vertices[i * 3 + 1], vertices[i * 3 + 2]); -points.push_back(v); +points[i] = openvdb::Vec3s(vertices[i * 3], vertices[i * 3 + 1], vertices[i * 3 + 2]); } for (unsigned int i = 0; i < totfaces; i++) { -openvdb::Vec3I f(faces[i * 3], faces[i * 3 + 1], faces[i * 3 + 2]); -triangles.push_back(f); +triangles[i] = openvdb::Vec3I(faces[i * 3], faces[i * 3 + 1], faces[i * 3 + 2]); } this->grid = openvdb::tools::meshToLevelSet( *xform, points, triangles, quads, 1); } -void OpenVDBLevelSet::OpenVDB_volume_to_mesh(OpenVDBVolumeToMeshData *mesh, - const double isovalue, - const double adaptivity, - const bool relax_disoriented_triangles) +void OpenVDBLevelSet::volume_to_mesh(OpenVDBVolumeToMeshData *mesh, + const double isovalue, + const double adaptivity, + const bool relax_disoriented_triangles) { std::vector out_points; std::vector out_quads; @@ -85,37 +83,37 @@ void OpenVDBLevelSet::OpenVDB_volume_to_mesh(OpenVDBVolumeToMeshData *mesh, mesh->tottriangles = out_tris.size(); mesh->totquads = out_quads.size(); - for (unsigned int i = 0; i < out_points.size(); i++) { + for (size_t i = 0; i < out_points.size(); i++) { mesh->vertices[i * 3] = out_points[i].x(); mesh->vertices[i * 3 + 1] = out_points[i].y(); mesh->vertices[i * 3 + 2] = out_points[i].z(); } - for (unsigned int i = 0; i < out_quads.size(); i++) { + for (size_t i = 0; i < out_quads.size(); i++) { mesh->quads[i * 4] = out_quads[i].x(); mesh->quads[i * 4 + 1] = out_quads[i].y(); mesh->quads[i * 4 + 2] = out_quads[i].z(); mesh->quads[i * 4 + 3] = out_quads[i].w(); } - for (unsigned int i = 0; i < out_tris.size(); i++) { + for (size_t i = 0; i < out_tris.size(); i++) { mesh->triangles[i * 3] = out_tris[i].x(); mesh->triangles[i * 3 + 1] = out_tris[i].y(); mesh->triangles[i * 3 + 2] = out_tris[i].z(); } } -void OpenVDBLevelSet::OpenVDB_level_set_filter(OpenVDBLevelSet_FilterType filter_type, - int width, - int iterations, - int filter_bias) +void OpenVDBLevelSet::filter(OpenVDBLevelSet_FilterType filter_type, + int width, + float distance, + OpenVDBLevelSet_FilterBias filter_bias) { if (!this->grid) { return; } - if (this->grid && this->gr
[Bf-blender-cvs] [881eb3f8669] sculpt-mode-features: Avoid allocating memory in neighbour iteration
Commit: 881eb3f8669becf6247f4d8ab9dae50c66036b20 Author: Pablo Dobarro Date: Wed Jul 31 16:28:44 2019 +0200 Branches: sculpt-mode-features https://developer.blender.org/rB881eb3f8669becf6247f4d8ab9dae50c66036b20 Avoid allocating memory in neighbour iteration === M 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 25ef711aecd..33d3604e5ad 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -97,9 +97,7 @@ /* Sculpt PBVH abstraction API */ -typedef int VertexHandle; - -VertexHandle sculpt_active_vertex_get(SculptSession *ss) +int sculpt_active_vertex_get(SculptSession *ss) { switch (BKE_pbvh_type(ss->pbvh)) { case PBVH_FACES: @@ -123,7 +121,7 @@ unsigned int sculpt_vertex_count_get(SculptSession *ss) } } -void sculpt_vertex_normal_get(SculptSession *ss, VertexHandle index, float no[3]) +void sculpt_vertex_normal_get(SculptSession *ss, int index, float no[3]) { switch (BKE_pbvh_type(ss->pbvh)) { case PBVH_FACES: @@ -136,7 +134,7 @@ void sculpt_vertex_normal_get(SculptSession *ss, VertexHandle index, float no[3] } } -float *sculpt_vertex_co_get(SculptSession *ss, VertexHandle index) +float *sculpt_vertex_co_get(SculptSession *ss, int index) { switch (BKE_pbvh_type(ss->pbvh)) { case PBVH_FACES: @@ -162,7 +160,7 @@ void sculpt_vertex_co_set(SculptSession *ss, int index, float co[3]) } } -void sculpt_vertex_mask_set(SculptSession *ss, VertexHandle index, float mask) +void sculpt_vertex_mask_set(SculptSession *ss, int index, float mask) { BMVert *v; float *mask_p; @@ -208,45 +206,55 @@ void sculpt_vertex_tag_update(SculptSession *ss, int index) } } +#define SCULPT_VERTEX_NEIGHBOUR_FIXED_CAPACITY 256 + typedef struct SculptVertexNeighbourIter { - VertexHandle *neighbours; - int count; - VertexHandle index; + int *neighbours; + int size; + int capacity; + + int neighbours_fixed[SCULPT_VERTEX_NEIGHBOUR_FIXED_CAPACITY]; + + int index; int i; } SculptVertexNeighbourIter; -#define SCULPT_VERTEX_NEIGHBOUR_MAX 256 - -void sculpt_vertex_neighbour_add(SculptVertexNeighbourIter *iter, int neighbour_index) +static void sculpt_vertex_neighbour_add(SculptVertexNeighbourIter *iter, int neighbour_index) { - if (iter->count >= SCULPT_VERTEX_NEIGHBOUR_MAX) { -iter->neighbours = MEM_reallocN_id(iter->neighbours, - (iter->count + SCULPT_VERTEX_NEIGHBOUR_MAX) * - sizeof(VertexHandle), - "neighbour array"); - } - - for (int i = 0; i < iter->count; i++) { + for (int i = 0; i < iter->size; i++) { if (iter->neighbours[i] == neighbour_index) { return; } } - iter->neighbours[iter->count] = neighbour_index; - iter->count++; - return; + if (iter->size >= iter->capacity) { +iter->capacity += SCULPT_VERTEX_NEIGHBOUR_FIXED_CAPACITY; + +if (iter->neighbours == iter->neighbours_fixed) { + iter->neighbours = MEM_mallocN(iter->capacity * sizeof(int), "neighbour array"); + memcpy(iter->neighbours, iter->neighbours_fixed, sizeof(int) * iter->size); +} +else { + iter->neighbours = MEM_reallocN_id( + iter->neighbours, iter->capacity * sizeof(int), "neighbour array"); +} + } + + iter->neighbours[iter->size] = neighbour_index; + iter->size++; } void sculpt_vertex_neighbours_get_bmesh(SculptSession *ss, -VertexHandle index, +int index, SculptVertexNeighbourIter *iter) { BMVert *v = BM_vert_at_index(ss->bm, index); BMIter liter; BMLoop *l; - iter->count = 0; - iter->neighbours = MEM_mallocN(SCULPT_VERTEX_NEIGHBOUR_MAX * sizeof(VertexHandle), - "neighbour array"); + iter->size = 0; + iter->capacity = SCULPT_VERTEX_NEIGHBOUR_FIXED_CAPACITY; + iter->neighbours = iter->neighbours_fixed; + int i = 0; BM_ITER_ELEM (l, , v, BM_LOOPS_OF_VERT) { const BMVert *adj_v[2] = {l->prev->v, l->next->v}; @@ -260,14 +268,14 @@ void sculpt_vertex_neighbours_get_bmesh(SculptSession *ss, } void sculpt_vertex_neighbours_get_faces(SculptSession *ss, -VertexHandle index, +int index, SculptVertexNeighbourIter *iter) { int i; MeshElemMap *vert_map = >pmap[(int)index]; - iter->count = 0;
[Bf-blender-cvs] [037cf920b42] master: Sculpt: mesh abstraction API
Commit: 037cf920b42d9b3404687235c524516e50a31561 Author: Pablo Dobarro Date: Wed Aug 14 22:54:23 2019 +0200 Branches: master https://developer.blender.org/rB037cf920b42d9b3404687235c524516e50a31561 Sculpt: mesh abstraction API These functions make possible porting the tools from the sculpt branch, making them compatible with PBVH_FACES and PBVH_BMESH without duplicating the code. They can also help to simplify some existing code. These functions should not be used when working with PBVH_GRIDS data in SculptSession. PBVH_GRIDS needs to be removed from the sculpt code and converted to PBVH_FACES to be compatible with this API. Reviewed By: brecht Differential Revision: https://developer.blender.org/D5352 === M source/blender/blenkernel/BKE_paint.h M source/blender/blenkernel/BKE_pbvh.h M source/blender/editors/sculpt_paint/sculpt.c === diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h index cbe250d0ac8..37667599488 100644 --- a/source/blender/blenkernel/BKE_paint.h +++ b/source/blender/blenkernel/BKE_paint.h @@ -259,6 +259,8 @@ typedef struct SculptSession { struct StrokeCache *cache; + int active_vertex_index; + union { struct { struct SculptVertexPaintGeomMap gmap; diff --git a/source/blender/blenkernel/BKE_pbvh.h b/source/blender/blenkernel/BKE_pbvh.h index 3806868e060..62544efad2c 100644 --- a/source/blender/blenkernel/BKE_pbvh.h +++ b/source/blender/blenkernel/BKE_pbvh.h @@ -301,6 +301,7 @@ typedef struct PBVHVertexIter { int gx; int gy; int i; + int index; /* grid */ struct CCGElem **grids; @@ -369,6 +370,7 @@ void pbvh_vertex_iter_init(PBVH *bvh, PBVHNode *node, PBVHVertexIter *vi, int mo continue; \ vi.co = vi.mvert->co; \ vi.no = vi.mvert->no; \ + vi.index = vi.vert_indices[vi.i]; \ if (vi.vmask) \ vi.mask = [vi.vert_indices[vi.gx]]; \ } \ @@ -385,6 +387,7 @@ void pbvh_vertex_iter_init(PBVH *bvh, PBVHNode *node, PBVHVertexIter *vi, int mo continue; \ vi.co = vi.bm_vert->co; \ vi.fno = vi.bm_vert->no; \ + vi.index = BM_elem_index_get(vi.bm_vert); \ vi.mask = BM_ELEM_CD_GET_VOID_P(vi.bm_vert, vi.cd_vert_mask_offset); \ } diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index efaac6e97cf..cdd82b8ced3 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -92,6 +92,235 @@ #include #include +/* Sculpt PBVH abstraction API */ + +/* Do not use these functions while working with PBVH_GRIDS data in SculptSession */ + +static int sculpt_active_vertex_get(SculptSession *ss) +{ + switch (BKE_pbvh_type(ss->pbvh)) { +case PBVH_FACES: + return ss->active_vertex_index; +case PBVH_BMESH: + return ss->active_vertex_index; +default: + return 0; + } +} + +static int sculpt_vertex_count_get(SculptSession *ss) +{ + switch (BKE_pbvh_type(ss->pbvh)) { +case PBVH_FACES: + return ss->totvert; +case PBVH_BMESH: + return BM_mesh_elem_count(BKE_pbvh_get_bmesh(ss->pbvh), BM_VERT); +default: + return 0; + } +} + +static void sculpt_vertex_normal_get(SculptSession *ss, int index, float no[3]) +{ + switch (BKE_pbvh_type(ss->pbvh)) { +case PBVH_FACES: + normal_short_to_float_v3(no, ss->mvert[index].no); + return; +case PBVH_BMESH: + copy_v3_v3(no, BM_vert_at_index(BKE_pbvh_get_bmesh(ss->pbvh), index)->no); +default: + return; + } +} + +static float *sculpt_vertex_co_get(SculptSession *ss, int index) +{ + switch (BKE_pbvh_type(ss->pbvh)) { +case PBVH_FACES: + return ss->mvert[index].co; +case PBVH_BMESH: + return BM_vert_at_index(BKE_pbvh_get_bmesh(ss->pbvh), index)->co; +default: + return NULL; + } +} + +static void sculpt_vertex_co_set(SculptSession *ss, int index, float co[3]) +{ + switch (BKE_pbvh_type(ss->pbvh)) { +case PBVH_FACES: + copy_v3_v3(ss->mvert[index].co, co); + return; +case PBVH_BMESH: + copy_v3_v3(BM_vert_at_index(BKE_pbvh_get_bmesh(ss->pbvh), index)->co, co); + return; +default: + return; + } +} + +static void sculpt_vertex_mask_set(SculptSession *ss, int index, float mask) +{ + BMVert *v; + float *mask_p; + switch (BKE_pbvh_type(ss->pbvh)) { +case PBVH_FACES: + ss->vmask[index] = mask; + return; +case PBVH_BMESH: + v = BM_vert_at_index(BKE_pbvh_get_bmesh(ss->pbvh), index); + mask_p = BM_ELEM_CD_GET_VOID_P(v, CustomData_get_offset(>bm->vdata, CD_PAINT_MASK)); + *(mask_p) = mask; + return; +default: + return; + } +} + +
[Bf-blender-cvs] [d6d51674a2f] sculpt-mode-features: Sculpt: Pose brush
Commit: d6d51674a2fee3a1110d241b96d31480ce440cf1 Author: Pablo Dobarro Date: Fri Aug 16 00:12:43 2019 +0200 Branches: sculpt-mode-features https://developer.blender.org/rBd6d51674a2fee3a1110d241b96d31480ce440cf1 Sculpt: Pose brush This commit also includes the MOUSE_INBETWEEN events fix for other brushes. === M source/blender/blenkernel/intern/brush.c M source/blender/editors/sculpt_paint/paint_stroke.c M source/blender/editors/sculpt_paint/sculpt.c M source/blender/editors/sculpt_paint/sculpt_intern.h M source/blender/makesdna/DNA_brush_types.h M source/blender/makesrna/intern/rna_brush.c === diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index 56ebfe72162..262f47655f6 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -895,6 +895,7 @@ void BKE_brush_sculpt_reset(Brush *br) br->add_col[2] = 0.75; break; case SCULPT_TOOL_GRAB: +case SCULPT_TOOL_POSE: case SCULPT_TOOL_SNAKE_HOOK: case SCULPT_TOOL_THUMB: br->size = 75; diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c index 5f3075b12f5..7df06d99509 100644 --- a/source/blender/editors/sculpt_paint/paint_stroke.c +++ b/source/blender/editors/sculpt_paint/paint_stroke.c @@ -219,6 +219,7 @@ static bool paint_tool_require_location(Brush *brush, ePaintMode mode) case PAINT_MODE_SCULPT: if (ELEM(brush->sculpt_tool, SCULPT_TOOL_GRAB, + SCULPT_TOOL_POSE, SCULPT_TOOL_ROTATE, SCULPT_TOOL_SNAKE_HOOK, SCULPT_TOOL_THUMB)) { @@ -234,6 +235,27 @@ static bool paint_tool_require_location(Brush *brush, ePaintMode mode) return true; } +static bool paint_tool_require_inbetween_mouse_events(Brush *brush, ePaintMode mode) +{ + switch (mode) { +case PAINT_MODE_SCULPT: + if (ELEM(brush->sculpt_tool, + SCULPT_TOOL_GRAB, + SCULPT_TOOL_ROTATE, + SCULPT_TOOL_THUMB, + SCULPT_TOOL_POSE)) { +return false; + } + else { +return true; + } +default: + break; + } + + return true; +} + /* Initialize the stroke cache variants from operator properties */ static bool paint_brush_update(bContext *C, Brush *brush, @@ -872,6 +894,7 @@ static bool sculpt_is_grab_tool(Brush *br) { return ELEM(br->sculpt_tool, SCULPT_TOOL_GRAB, + SCULPT_TOOL_POSE, SCULPT_TOOL_THUMB, SCULPT_TOOL_ROTATE, SCULPT_TOOL_SNAKE_HOOK); @@ -1206,6 +1229,10 @@ int paint_stroke_modal(bContext *C, wmOperator *op, const wmEvent *event) bool redraw = false; float pressure; + if (event->type == INBETWEEN_MOUSEMOVE && !paint_tool_require_inbetween_mouse_events(br, mode)) { +return OPERATOR_RUNNING_MODAL; + } + /* see if tablet affects event. Line, anchored and drag dot strokes do not support pressure */ pressure = ((br->flag & (BRUSH_LINE | BRUSH_ANCHORED | BRUSH_DRAG_DOT)) ? 1.0f : diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 6803f01a26c..701ccb799d0 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -426,8 +426,12 @@ static bool sculpt_has_active_modifiers(Scene *scene, Object *ob) static bool sculpt_tool_needs_original(const char sculpt_tool) { - return ELEM( - sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_ROTATE, SCULPT_TOOL_THUMB, SCULPT_TOOL_LAYER); + return ELEM(sculpt_tool, + SCULPT_TOOL_GRAB, + SCULPT_TOOL_ROTATE, + SCULPT_TOOL_THUMB, + SCULPT_TOOL_LAYER, + SCULPT_TOOL_POSE); } static bool sculpt_tool_is_proxy_used(const char sculpt_tool) @@ -1528,6 +1532,9 @@ static float brush_strength(const Sculpt *sd, case SCULPT_TOOL_GRAB: return root_alpha * feather; +case SCULPT_TOOL_POSE: + return root_alpha * feather; + case SCULPT_TOOL_ROTATE: return alpha * pressure * feather; @@ -3420,6 +3427,94 @@ static void do_pinch_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode BLI_task_parallel_range(0, totnode, , do_pinch_brush_task_cb_ex, ); } +static bool check_vertex_pivot_symmetry(float vco[3], float pco[3], char symm); +static void do_pose_brush_task_cb_ex(void *__restrict userdata, + const int n, + const ParallelRangeTLS *__restrict tls) +{ + SculptThreadedTaskData *data = userdata; + SculptSession *ss = data->ob->sculpt; + + PBV
[Bf-blender-cvs] [9ac3964be19] master: OpenVDB: mesh/level set conversion, filters and CSG operations
Commit: 9ac3964be198a9bcbbcf2cda2ecd99047eae560f Author: Pablo Dobarro Date: Wed Aug 14 17:46:20 2019 +0200 Branches: master https://developer.blender.org/rB9ac3964be198a9bcbbcf2cda2ecd99047eae560f OpenVDB: mesh/level set conversion, filters and CSG operations This code is needed to implement the Voxel Remesher as well as other features like a better remesh modifier with filters and CSG operations. Done by Martin Felke and Pablo Dobarro Reviewed By: brecht Differential Revision: https://developer.blender.org/D5364 === M intern/openvdb/CMakeLists.txt A intern/openvdb/intern/openvdb_level_set.cc A intern/openvdb/intern/openvdb_level_set.h A intern/openvdb/intern/openvdb_transform.cc A intern/openvdb/intern/openvdb_transform.h M intern/openvdb/openvdb_capi.cc M intern/openvdb/openvdb_capi.h === diff --git a/intern/openvdb/CMakeLists.txt b/intern/openvdb/CMakeLists.txt index bcb1d545c94..412dade0f1a 100644 --- a/intern/openvdb/CMakeLists.txt +++ b/intern/openvdb/CMakeLists.txt @@ -21,6 +21,7 @@ set(INC . intern + ../guardedalloc ) set(INC_SYS @@ -56,12 +57,16 @@ if(WITH_OPENVDB) intern/openvdb_dense_convert.cc intern/openvdb_reader.cc intern/openvdb_writer.cc +intern/openvdb_level_set.cc +intern/openvdb_transform.cc openvdb_capi.cc openvdb_util.cc intern/openvdb_dense_convert.h intern/openvdb_reader.h intern/openvdb_writer.h +intern/openvdb_level_set.h +intern/openvdb_transform.h openvdb_util.h ) diff --git a/intern/openvdb/intern/openvdb_level_set.cc b/intern/openvdb/intern/openvdb_level_set.cc new file mode 100644 index 000..a850aae2be5 --- /dev/null +++ b/intern/openvdb/intern/openvdb_level_set.cc @@ -0,0 +1,176 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2015 Blender Foundation. + * All rights reserved. + */ + +#include "openvdb_level_set.h" +#include "openvdb_util.h" +#include "openvdb_capi.h" +#include "MEM_guardedalloc.h" +#include "openvdb/tools/Composite.h" + +OpenVDBLevelSet::OpenVDBLevelSet() +{ + openvdb::initialize(); +} + +OpenVDBLevelSet::~OpenVDBLevelSet() +{ +} + +void OpenVDBLevelSet::mesh_to_level_set(const float *vertices, +const unsigned int *faces, +const unsigned int totvertices, +const unsigned int totfaces, +const openvdb::math::Transform::Ptr ) +{ + std::vector points(totvertices); + std::vector triangles(totfaces); + std::vector quads; + + for (unsigned int i = 0; i < totvertices; i++) { +points[i] = openvdb::Vec3s(vertices[i * 3], vertices[i * 3 + 1], vertices[i * 3 + 2]); + } + + for (unsigned int i = 0; i < totfaces; i++) { +triangles[i] = openvdb::Vec3I(faces[i * 3], faces[i * 3 + 1], faces[i * 3 + 2]); + } + + this->grid = openvdb::tools::meshToLevelSet( + *xform, points, triangles, quads, 1); +} + +void OpenVDBLevelSet::volume_to_mesh(OpenVDBVolumeToMeshData *mesh, + const double isovalue, + const double adaptivity, + const bool relax_disoriented_triangles) +{ + std::vector out_points; + std::vector out_quads; + std::vector out_tris; + openvdb::tools::volumeToMesh(*this->grid, + out_points, + out_tris, + out_quads, + isovalue, + adaptivity, + relax_disoriented_triangles); + mesh->vertices = (float *)MEM_malloc_arrayN( + out_points.size(), 3 * sizeof(float), "openvdb remesher out verts"); + mesh->quads = (unsigned int *)MEM_malloc_arrayN( + out_quads.size(), 4 * sizeof(unsigned int), "openvdb remesh out qua
[Bf-blender-cvs] [45a45f7d662] master: OpenVDB: Voxel Remesher
Commit: 45a45f7d66211e82a3a3288782ad9523e8fdc516 Author: Pablo Dobarro Date: Wed Aug 14 18:37:46 2019 +0200 Branches: master https://developer.blender.org/rB45a45f7d66211e82a3a3288782ad9523e8fdc516 OpenVDB: Voxel Remesher The voxel remesher introduces a new workflow for sculpting without any of the limitations of Dyntopo (no geometry errors or performance penalty when blocking shapes). It is also useful for simulations and 3D printing. This commit includes: - Voxel remesh operator, voxel size mesh property and general remesh flags. - Paint mask reprojection. - Geometry undo/redo for sculpt mode. This should support remesh operations as well as future tools that modify the topology of the sculpt in a single step, like trimming tools or mesh insert brushes. - UI changes in the sculpt topbar and the mesh properties pannel. Reviewed By: brecht Differential Revision: https://developer.blender.org/D5407 === M release/scripts/startup/bl_ui/properties_data_mesh.py M release/scripts/startup/bl_ui/space_view3d_toolbar.py A source/blender/blenkernel/BKE_remesh.h M source/blender/blenkernel/CMakeLists.txt M source/blender/blenkernel/intern/mesh.c A source/blender/blenkernel/intern/remesh.c M source/blender/blenloader/intern/versioning_280.c M source/blender/editors/include/ED_sculpt.h M source/blender/editors/object/CMakeLists.txt M source/blender/editors/object/object_intern.h M source/blender/editors/object/object_ops.c A source/blender/editors/object/object_remesh.c M source/blender/editors/sculpt_paint/sculpt.c M source/blender/editors/sculpt_paint/sculpt_intern.h M source/blender/editors/sculpt_paint/sculpt_undo.c M source/blender/makesdna/DNA_mesh_types.h M source/blender/makesrna/intern/rna_mesh.c === diff --git a/release/scripts/startup/bl_ui/properties_data_mesh.py b/release/scripts/startup/bl_ui/properties_data_mesh.py index 63e4d44eada..47c90199031 100644 --- a/release/scripts/startup/bl_ui/properties_data_mesh.py +++ b/release/scripts/startup/bl_ui/properties_data_mesh.py @@ -459,6 +459,22 @@ class DATA_PT_vertex_colors(MeshButtonsPanel, Panel): col.operator("mesh.vertex_color_add", icon='ADD', text="") col.operator("mesh.vertex_color_remove", icon='REMOVE', text="") +class DATA_PT_remesh(MeshButtonsPanel, Panel): +bl_label = "Remesh" +bl_options = {'DEFAULT_CLOSED'} +COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'} + +def draw(self, context): +layout = self.layout +layout.use_property_split = True +col = layout.column() + +mesh = context.mesh +col.prop(mesh, "remesh_voxel_size") +col.prop(mesh, "remesh_smooth_normals") +col.prop(mesh, "remesh_preserve_paint_mask") +col.operator("object.voxel_remesh", text="Voxel Remesh") + class DATA_PT_customdata(MeshButtonsPanel, Panel): bl_label = "Geometry Data" @@ -512,6 +528,7 @@ classes = ( DATA_PT_normals, DATA_PT_normals_auto_smooth, DATA_PT_texture_space, +DATA_PT_remesh, DATA_PT_customdata, DATA_PT_custom_props_mesh, ) diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py index cd18d857242..5246d8fa864 100644 --- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py +++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py @@ -1139,8 +1139,38 @@ class VIEW3D_PT_sculpt_dyntopo_remesh(Panel, View3DPaintPanel): col = flow.column() col.operator("sculpt.detail_flood_fill") -# TODO, move to space_view3d.py +class VIEW3D_PT_sculpt_voxel_remesh(Panel, View3DPaintPanel): +bl_context = ".sculpt_mode" # dot on purpose (access from topbar) +bl_label = "Remesh" +bl_options = {'DEFAULT_CLOSED'} +bl_ui_units_x = 12 +@classmethod +def poll(cls, context): +return (context.sculpt_object and context.tool_settings.sculpt) + +def draw_header(self, context): +is_popover = self.is_popover +layout = self.layout +layout.operator( +"object.voxel_remesh", +text="", +emboss=is_popover, +) + +def draw(self, context): +layout = self.layout +layout.use_property_split = True +layout.use_property_decorate = False + +col = layout.column() +mesh = context.active_object.data +col.prop(mesh, "remesh_voxel_size") +col.prop(mesh, "remesh_smooth_normals") +col.prop(mesh, "remesh_preserve_paint_mask") +col.operator("object.
[Bf-blender-cvs] [12dca31682c] sculpt-mode-features: Grab active vertex and dynamic mesh preview
Commit: 12dca31682cee168a96eb006865d20902be62966 Author: Pablo Dobarro Date: Mon Aug 12 03:35:13 2019 +0200 Branches: sculpt-mode-features https://developer.blender.org/rB12dca31682cee168a96eb006865d20902be62966 Grab active vertex and dynamic mesh preview === M release/scripts/startup/bl_ui/space_view3d_toolbar.py M source/blender/blenkernel/BKE_paint.h M source/blender/editors/sculpt_paint/paint_cursor.c M source/blender/editors/sculpt_paint/paint_vertex.c M source/blender/editors/sculpt_paint/sculpt.c M source/blender/editors/sculpt_paint/sculpt_intern.h M source/blender/makesdna/DNA_brush_types.h M source/blender/makesrna/intern/rna_brush.c === diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py index f644ba8d516..71a0a5925ce 100644 --- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py +++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py @@ -332,6 +332,11 @@ class VIEW3D_PT_tools_brush(Panel, View3DPaintPanel): row = col.row() row.prop(brush, "sculpt_color_mix_mode") +if brush.sculpt_tool == 'GRAB': +col.separator() +row = col.row() +row.prop(brush, "grab_active_vertex") + # topology_rake_factor if ( capabilities.has_topology_rake and diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h index caa4570cd5e..54cd51b3bff 100644 --- a/source/blender/blenkernel/BKE_paint.h +++ b/source/blender/blenkernel/BKE_paint.h @@ -283,6 +283,9 @@ typedef struct SculptSession { RegionView3D *rv3d; + int *preview_vert_index_list; + int preview_vert_index_count; + union { struct { struct SculptVertexPaintGeomMap gmap; diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c index 8a834446326..480b180ccc3 100644 --- a/source/blender/editors/sculpt_paint/paint_cursor.c +++ b/source/blender/editors/sculpt_paint/paint_cursor.c @@ -1188,6 +1188,24 @@ void cursor_draw_point_with_symmetry(const uint gpuattr, } } +static void sculpt_geometry_preview_lines_draw(const uint gpuattr, + SculptSession *ss, + float obmat[4][4]) +{ + immUniformColor4f(1.0f, 1.0f, 1.0f, 0.7f); + GPU_depth_test(true); + GPU_line_width(2.0f); + if (ss->preview_vert_index_count > 0) { +immBegin(GPU_PRIM_LINES, ss->preview_vert_index_count); +for (int i = 0; i < ss->preview_vert_index_count; i++) { + float v[3]; + mul_v3_m4v3(v, obmat, sculpt_vertex_co_get(ss, ss->preview_vert_index_list[i])); + immVertex3fv(gpuattr, v); +} +immEnd(); + } +} + static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused)) { Scene *scene = CTX_data_scene(C); @@ -1326,6 +1344,16 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused)) } /* draw brush cursor */ + +float cursor_mat4[4][4], cursor_rot_mat4[4][4]; +float z_axis[4] = {0.0f, 0.0f, 1.0f, 0.0f}; +float quat[4]; + +copy_m4_m4(cursor_mat4, vc.obact->obmat); +translate_m4(cursor_mat4, gi.location[0], gi.location[1], gi.location[2]); +rotation_between_vecs_to_quat(quat, z_axis, gi.normal); +quat_to_mat4(cursor_rot_mat4, quat); + GPU_matrix_push_projection(); GPU_matrix_push(); ED_view3d_draw_setup_view(CTX_wm_window(C), @@ -1337,20 +1365,24 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused)) NULL, NULL); -float cursor_mat4[4][4], cursor_rot_mat4[4][4]; -float z_axis[4] = {0.0f, 0.0f, 1.0f, 0.0f}; -float quat[4]; +if (brush->sculpt_tool == SCULPT_TOOL_GRAB && brush->flag2 & BRUSH_GRAB_ACTIVE_VERTEX) { + if (vc.obact->sculpt) { +SculptSession *ss = vc.obact->sculpt; +if (BKE_pbvh_type(ss->pbvh) == PBVH_FACES) { + sculpt_geometry_preview_lines_update(C, ss, rds); + sculpt_geometry_preview_lines_draw(pos3d, ss, vc.obact->obmat); +} + } +} -copy_m4_m4(cursor_mat4, vc.obact->obmat); -translate_m4(cursor_mat4, gi.location[0], gi.location[1], gi.location[2]); -rotation_between_vecs_to_quat(quat, z_axis, gi.normal); -quat_to_mat4(cursor_rot_mat4, quat); +GPU_line_width(4.0f); GPU_matrix_mul(cursor_mat4); GPU_matrix_mul(cursor_rot_mat4); +immUniformColor3fvAlpha(outline_
[Bf-blender-cvs] [ba17acf8f41] sculpt-mode-features: Tweak mesh preview and cursor line width
Commit: ba17acf8f41620b1198ea7845970d70a595d9d2b Author: Pablo Dobarro Date: Mon Aug 12 03:36:59 2019 +0200 Branches: sculpt-mode-features https://developer.blender.org/rBba17acf8f41620b1198ea7845970d70a595d9d2b Tweak mesh preview and cursor line width === M source/blender/editors/sculpt_paint/paint_cursor.c === diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c index 480b180ccc3..e5a3354d29b 100644 --- a/source/blender/editors/sculpt_paint/paint_cursor.c +++ b/source/blender/editors/sculpt_paint/paint_cursor.c @@ -1192,9 +1192,9 @@ static void sculpt_geometry_preview_lines_draw(const uint gpuattr, SculptSession *ss, float obmat[4][4]) { - immUniformColor4f(1.0f, 1.0f, 1.0f, 0.7f); + immUniformColor4f(1.0f, 1.0f, 1.0f, 0.6f); GPU_depth_test(true); - GPU_line_width(2.0f); + GPU_line_width(1.0f); if (ss->preview_vert_index_count > 0) { immBegin(GPU_PRIM_LINES, ss->preview_vert_index_count); for (int i = 0; i < ss->preview_vert_index_count; i++) { @@ -1375,7 +1375,7 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused)) } } -GPU_line_width(4.0f); +GPU_line_width(3.0f); GPU_matrix_mul(cursor_mat4); GPU_matrix_mul(cursor_rot_mat4); immUniformColor3fvAlpha(outline_col, outline_alpha); ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs
[Bf-blender-cvs] [2ecb4540f37] sculpt-mode-features: Fix merge errors
Commit: 2ecb4540f37ea7b21fe6c360b97a360c92c5e36c Author: Pablo Dobarro Date: Tue Aug 20 19:19:26 2019 +0200 Branches: sculpt-mode-features https://developer.blender.org/rB2ecb4540f37ea7b21fe6c360b97a360c92c5e36c Fix merge errors === M source/blender/blenloader/intern/versioning_280.c M source/blender/editors/mesh/editmesh_add.c M source/blender/editors/object/object_blueprint.c M source/blender/editors/object/object_edit.c M source/blender/editors/object/object_modifier.c M source/blender/editors/sculpt_paint/paint_cursor.c M source/blender/editors/sculpt_paint/paint_vertex.c === diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c index c88bdd7ee9d..482b705a21d 100644 --- a/source/blender/blenloader/intern/versioning_280.c +++ b/source/blender/blenloader/intern/versioning_280.c @@ -3231,7 +3231,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) if (!DNA_struct_elem_find(fd->filesdna, "Mesh", "float", "voxel_size")) { for (Mesh *me = bmain->meshes.first; me; me = me->id.next) { -me->voxel_size = 0.1f; +me->remesh_voxel_size = 0.1f; } } diff --git a/source/blender/editors/mesh/editmesh_add.c b/source/blender/editors/mesh/editmesh_add.c index 452557f9d66..0bdd170f500 100644 --- a/source/blender/editors/mesh/editmesh_add.c +++ b/source/blender/editors/mesh/editmesh_add.c @@ -102,7 +102,6 @@ static void make_prim_finish(bContext *C, // TODO: Find a better place to init this Mesh *me; me = obedit->data; -me->voxel_size = 0.1f; } WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, obedit); } diff --git a/source/blender/editors/object/object_blueprint.c b/source/blender/editors/object/object_blueprint.c index c5ccc053f94..c34d4102fcb 100644 --- a/source/blender/editors/object/object_blueprint.c +++ b/source/blender/editors/object/object_blueprint.c @@ -1000,7 +1000,7 @@ int blueprint_update_step(bContext *C, Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); if (event->type == ESCKEY && event->val == KM_PRESS) { blueprint_end(C, op); diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 0f94bb50983..d9fcb4894ba 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -1838,12 +1838,12 @@ static int remesh_exec(bContext *C, wmOperator *op) Mesh *mesh = ob->data; Mesh *newMesh; -if (mesh->voxel_size <= 0.0f) { +if (mesh->remesh_voxel_size <= 0.0f) { return OPERATOR_CANCELLED; } if (ob->mode == OB_MODE_SCULPT) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); BKE_sculpt_update_object_for_edit(depsgraph, ob, true, true); PBVH *pbvh; PBVHNode **nodes; @@ -1856,7 +1856,7 @@ static int remesh_exec(bContext *C, wmOperator *op) struct OpenVDBLevelSet *level_set; struct OpenVDBTransform *xform = OpenVDBTransform_create(); -OpenVDBTransform_create_linear_transform(xform, (double)mesh->voxel_size); +OpenVDBTransform_create_linear_transform(xform, (double)mesh->remesh_voxel_size); level_set = BKE_remesh_voxel_ovdb_mesh_to_level_set_create(mesh, xform); newMesh = BKE_remesh_voxel_ovdb_volume_to_mesh_nomain(level_set, 0.0, 0.0, false); OpenVDBLevelSet_free(level_set); diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index 54bb5698331..b85a50b4cb2 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -2551,7 +2551,7 @@ static bool remesh_update_check(bContext *C, wmOperator *op) static bool remesh_csg_poll(bContext *C) { - return edit_modifier_poll_generic(C, _RemeshModifier, 0); + return edit_modifier_poll_generic(C, _RemeshModifier, 0, false); } static int remesh_csg_add_exec(bContext *C, wmOperator *op) diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c index 7224fab0f3a..8b010991e65 100644 --- a/source/blender/editors/sculpt_paint/paint_cursor.c +++ b/source/blender/editors/sculpt_paint/paint_cursor.c @@ -1357,7 +1357,7 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused)) GPU_matrix_push_projection(); GPU_matrix_push(); ED_view3d_draw_setup_view(CTX_wm_window(C), - CTX_data_depsgraph(C), +
[Bf-blender-cvs] [8c509bb69cc] sculpt-mode-features: Merge branch 'master' into sculpt-mode-features
Commit: 8c509bb69cc9d473236e51b1ba51b74176286223 Author: Pablo Dobarro Date: Tue Aug 20 19:13:25 2019 +0200 Branches: sculpt-mode-features https://developer.blender.org/rB8c509bb69cc9d473236e51b1ba51b74176286223 Merge branch 'master' into sculpt-mode-features === === diff --cc build_files/build_environment/cmake/versions.cmake index 54f903535f3,c3b713096d6..9d2c9a2f172 --- a/build_files/build_environment/cmake/versions.cmake +++ b/build_files/build_environment/cmake/versions.cmake @@@ -303,23 -303,6 +303,29 @@@ set(EMBREE_VERSION 3.2.4 set(EMBREE_URI https://github.com/embree/embree/archive/v${EMBREE_VERSION}.zip) set(EMBREE_HASH 3d4a1147002ff43939d45140aa9d6fb8) ++<<<<<<< HEAD +set(IGL_VERSION 2.0.0) +set(IGL_URI https://github.com/libigl/libigl/archive/v${IGL_VERSION}.tar.gz) +set(IGL_HASH 42518e6b106c7209c73435fd260ed5d34edeb254852495b4c95dce2d95401328) + +#should match qex, but what about comiso ? +set(OPENMESH_VERSION 8.0) +set(OPENMESH_URI http://www.openmesh.org/media/Releases/${OPENMESH_VERSION}/OpenMesh-${OPENMESH_VERSION}.tar.gz) +#set(OPENMESH_HASH 96c595c1683b1ad950e80464ae5fc1f3c8dc45c31c8a211122a23e16a076ab23) #3.0 +set(OPENMESH_HASH 8974d44026cacaa37b171945b5c96a284bfd32c9df9d671d62931050d057ec82) + +#latest uid in git as of 2016-10-25 +set(QEX_GIT_UID 1d33e0d6700dd3d00df984aad776d9537fcf16af) +set(QEX_URI https://github.com/hcebke/libQEx/archive/${QEX_GIT_UID}.tar.gz) +set(QEX_HASH a29cf440c7b83c9e803d1f55247cd18e9c277b3845edce5d381c4c91daa90452) + +#latest uid in release branch 3.8.0 +set(LAPACK_GIT_UID ba3779a6813d84d329b73aac86afc4e041170609) +set(LAPACK_URI https://github.com/Reference-LAPACK/lapack-release/archive/${LAPACK_GIT_UID}.tar.gz) +set(LAPACK_HASH 4bd7a3014ee2b5c7cdcdc8960c9476b689f21796715aa03fd719c92c43faee31) + ++=== + set(OIDN_VERSION 1.0.0) + set(OIDN_URI https://github.com/OpenImageDenoise/oidn/releases/download/v${OIDN_VERSION}/oidn-${OIDN_VERSION}.src.zip) + set(OIDN_HASH 19fe67b0164e8f020ac8a4f520defe60) ++>>>>>>> master diff --cc build_files/cmake/platform/platform_win32.cmake index 1cde41599d0,42ac285f88d..7691942a15f --- a/build_files/cmake/platform/platform_win32.cmake +++ b/build_files/cmake/platform/platform_win32.cmake @@@ -343,16 -347,16 +347,16 @@@ if(WITH_PYTHON set(PYTHON_VERSION 3.7) # CACHE STRING) string(REPLACE "." "" _PYTHON_VERSION_NO_DOTS ${PYTHON_VERSION}) - # Use shared libs for vc2008 and vc2010 until we actually have vc2010 libs - set(PYTHON_LIBRARY ${LIBDIR}/python/lib/python${_PYTHON_VERSION_NO_DOTS}.lib) - unset(_PYTHON_VERSION_NO_DOTS) - - # Shared includes for both vc2008 and vc2010 - set(PYTHON_INCLUDE_DIR ${LIBDIR}/python/include/python${PYTHON_VERSION}) + set(PYTHON_LIBRARY ${LIBDIR}/python/${_PYTHON_VERSION_NO_DOTS}/libs/python${_PYTHON_VERSION_NO_DOTS}.lib) + set(PYTHON_LIBRARY_DEBUG ${LIBDIR}/python/${_PYTHON_VERSION_NO_DOTS}/libs/python${_PYTHON_VERSION_NO_DOTS}_d.lib) + set(PYTHON_INCLUDE_DIR ${LIBDIR}/python/${_PYTHON_VERSION_NO_DOTS}/include) + set(PYTHON_NUMPY_INCLUDE_DIRS ${LIBDIR}/python/${_PYTHON_VERSION_NO_DOTS}/lib/site-packages/numpy/core/include) + set(NUMPY_FOUND On) + unset(_PYTHON_VERSION_NO_DOTS) # uncached vars set(PYTHON_INCLUDE_DIRS "${PYTHON_INCLUDE_DIR}") - set(PYTHON_LIBRARIES debug "${PYTHON_LIBRARY_DEBUG}" optimized "${PYTHON_LIBRARY}" ) + set(PYTHON_LIBRARIES "${PYTHON_LIBRARY}") endif() if(WITH_BOOST) diff --cc release/scripts/startup/bl_ui/properties_data_mesh.py index 26a0e261c00,47c90199031..ebb9be9a2a4 --- a/release/scripts/startup/bl_ui/properties_data_mesh.py +++ b/release/scripts/startup/bl_ui/properties_data_mesh.py @@@ -457,13 -457,8 +457,14 @@@ class DATA_PT_vertex_colors(MeshButtons col = row.column(align=True) col.operator("mesh.vertex_color_add", icon='ADD', text="") --col.operator("mesh.vertex_color_remove", icon='REMOVE', text="") - ++col.operator("mesh.vertex_color_remove", icon='REMOVE', text="") ++ +row = layout.row() +col = row.column() +col.operator("object.vertex_to_loop_colors", text="Store sculpt color") +col.operator("object.loop_to_vertex_colors", text="Load sculpt color") + + class DATA_PT_remesh(MeshButtonsPanel, Panel): bl_label = "Remesh" bl_options = {'DEFAULT_CLOSED'} @@@ -475,11 -470,10 +476,11 @@@ col = layout.column() mesh = context.mesh - col.prop(mesh, "voxel_size") - col.prop(mesh, "smooth_normals") + col.prop(mesh, "remesh_voxel_size") + col.p
[Bf-blender-cvs] [8e4f3b2bb07] master: Fix T68763: Smooth Brush not working in LookDev or Rendered Mode
Commit: 8e4f3b2bb070a5022200c43866e81b6d5b8d3d1a Author: Pablo Dobarro Date: Sun Aug 25 16:33:52 2019 +0200 Branches: master https://developer.blender.org/rB8e4f3b2bb070a5022200c43866e81b6d5b8d3d1a Fix T68763: Smooth Brush not working in LookDev or Rendered Mode Reviewed By: brecht Differential Revision: https://developer.blender.org/D5585 === M 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 08febfcc470..ea2f38139a4 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -5154,10 +5154,11 @@ static bool sculpt_any_smooth_mode(const Brush *brush, StrokeCache *cache, int s static void sculpt_stroke_modifiers_check(const bContext *C, Object *ob, const Brush *brush) { SculptSession *ss = ob->sculpt; + View3D *v3d = CTX_wm_view3d(C); - if (ss->kb || ss->modifiers_active) { + bool need_pmap = sculpt_any_smooth_mode(brush, ss->cache, 0); + if (ss->kb || ss->modifiers_active || (!BKE_sculptsession_use_pbvh_draw(ob, v3d) && need_pmap)) { Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); -bool need_pmap = sculpt_any_smooth_mode(brush, ss->cache, 0); BKE_sculpt_update_object_for_edit(depsgraph, ob, need_pmap, false); } } ___ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs