diff options
author | Joseph Eagar <joeedh@gmail.com> | 2021-07-30 02:08:14 +0300 |
---|---|---|
committer | Joseph Eagar <joeedh@gmail.com> | 2021-07-30 02:08:14 +0300 |
commit | b243eb2646f69a236b65ade05281f0571f341ee1 (patch) | |
tree | 5c35a9fb9a81dcdbfce4c919cf369a942a8f628b /source/blender/gpencil_modifiers/intern | |
parent | af7198494265c9dd9f98ba5a8231a5b6ef857653 (diff) | |
parent | 0f1c84f171520d03ded669565fa7548584fcc724 (diff) |
Merge branch 'master' into temp_bmesh_multires
Also:
* added BMLog function to save mesh IDs.
- Used by SCULPT_UNDO_DYNTOPO_BEGIN/END instead of
saving the whole mesh, which was the previous behavior.
* SCULPT_UNDO_DYNTOPO_BEGIN no longer pushes a non-dyntopo
geomtry undo node, as this is no longer necassary.
This greatly speeds up going into/out of sculpt mode
with dyntopo enabled, as before it was copying
the mesh twice.
Diffstat (limited to 'source/blender/gpencil_modifiers/intern')
4 files changed, 67 insertions, 48 deletions
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencil_ui_common.c b/source/blender/gpencil_modifiers/intern/MOD_gpencil_ui_common.c index a156fca5b7b..e750c22f0e8 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencil_ui_common.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencil_ui_common.c @@ -9,7 +9,7 @@ * 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, + * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ @@ -346,7 +346,7 @@ static void gpencil_modifier_panel_header(const bContext *UNUSED(C), Panel *pane uiItemMenuF(row, "", ICON_DOWNARROW_HLT, gpencil_modifier_ops_extra_draw, md); /* Remove button. */ - sub = uiLayoutRow(row, true); + sub = uiLayoutRow(row, false); uiLayoutSetEmboss(sub, UI_EMBOSS_NONE); uiItemO(sub, "", ICON_X, "OBJECT_OT_gpencil_modifier_remove"); diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c b/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c index fcc44aab583..ac458041ca3 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c @@ -320,13 +320,8 @@ static void panel_draw(const bContext *UNUSED(C), Panel *panel) } uiLayout *row = uiLayoutRow(layout, true); uiLayoutSetRedAlert(row, !material_valid); - uiItemPointerR(row, - ptr, - "target_material", - &obj_data_ptr, - "materials", - NULL, - material_valid ? ICON_SHADING_TEXTURE : ICON_ERROR); + uiItemPointerR( + row, ptr, "target_material", &obj_data_ptr, "materials", NULL, ICON_SHADING_TEXTURE); gpencil_modifier_panel_end(layout, ptr); } @@ -385,6 +380,8 @@ static void options_panel_draw(const bContext *UNUSED(C), Panel *panel) return; } + uiItemR(layout, ptr, "overscan", 0, NULL, ICON_NONE); + uiLayout *col = uiLayoutColumn(layout, true); uiItemR(col, ptr, "use_remove_doubles", 0, NULL, ICON_NONE); @@ -432,6 +429,17 @@ static void occlusion_panel_draw(const bContext *UNUSED(C), Panel *panel) } } +static bool anything_showing_through(PointerRNA *ptr) +{ + const bool use_multiple_levels = RNA_boolean_get(ptr, "use_multiple_levels"); + const int level_start = RNA_int_get(ptr, "level_start"); + const int level_end = RNA_int_get(ptr, "level_end"); + if (use_multiple_levels) { + return (MAX2(level_start, level_end) > 0); + } + return (level_start > 0); +} + static void material_mask_panel_draw_header(const bContext *UNUSED(C), Panel *panel) { uiLayout *layout = panel->layout; @@ -439,6 +447,7 @@ static void material_mask_panel_draw_header(const bContext *UNUSED(C), Panel *pa const bool is_baked = RNA_boolean_get(ptr, "is_baked"); uiLayoutSetEnabled(layout, !is_baked); + uiLayoutSetActive(layout, anything_showing_through(ptr)); uiItemR(layout, ptr, "use_material_mask", 0, IFACE_("Material Mask"), ICON_NONE); } @@ -450,24 +459,24 @@ static void material_mask_panel_draw(const bContext *UNUSED(C), Panel *panel) const bool is_baked = RNA_boolean_get(ptr, "is_baked"); uiLayoutSetEnabled(layout, !is_baked); + uiLayoutSetActive(layout, anything_showing_through(ptr)); uiLayoutSetPropSep(layout, true); uiLayoutSetEnabled(layout, RNA_boolean_get(ptr, "use_material_mask")); - uiLayout *row = uiLayoutRow(layout, true); - uiLayoutSetPropDecorate(row, false); - uiLayout *sub = uiLayoutRowWithHeading(row, true, IFACE_("Masks")); - char text[2] = "0"; + uiLayout *col = uiLayoutColumn(layout, true); + uiLayout *sub = uiLayoutRowWithHeading(col, true, IFACE_("Masks")); PropertyRNA *prop = RNA_struct_find_property(ptr, "use_material_mask_bits"); - for (int i = 0; i < 8; i++, text[0]++) { - uiItemFullR(sub, ptr, prop, i, 0, UI_ITEM_R_TOGGLE, text, ICON_NONE); + for (int i = 0; i < 8; i++) { + uiItemFullR(sub, ptr, prop, i, 0, UI_ITEM_R_TOGGLE, " ", ICON_NONE); + if (i == 3) { + sub = uiLayoutRow(col, true); + } } - uiItemL(row, "", ICON_BLANK1); /* Space for decorator. */ - uiLayout *col = uiLayoutColumn(layout, true); - uiItemR(col, ptr, "use_material_mask_match", 0, IFACE_("Match All Masks"), ICON_NONE); + uiItemR(layout, ptr, "use_material_mask_match", 0, IFACE_("Exact Match"), ICON_NONE); } static void intersection_panel_draw(const bContext *UNUSED(C), Panel *panel) @@ -482,19 +491,18 @@ static void intersection_panel_draw(const bContext *UNUSED(C), Panel *panel) uiLayoutSetActive(layout, RNA_boolean_get(ptr, "use_intersection")); - uiLayout *row = uiLayoutRow(layout, true); - uiLayoutSetPropDecorate(row, false); - uiLayout *sub = uiLayoutRowWithHeading(row, true, IFACE_("Masks")); - char text[2] = "0"; + uiLayout *col = uiLayoutColumn(layout, true); + uiLayout *sub = uiLayoutRowWithHeading(col, true, IFACE_("Collection Masks")); PropertyRNA *prop = RNA_struct_find_property(ptr, "use_intersection_mask"); - for (int i = 0; i < 8; i++, text[0]++) { - uiItemFullR(sub, ptr, prop, i, 0, UI_ITEM_R_TOGGLE, text, ICON_NONE); + for (int i = 0; i < 8; i++) { + uiItemFullR(sub, ptr, prop, i, 0, UI_ITEM_R_TOGGLE, " ", ICON_NONE); + if (i == 3) { + sub = uiLayoutRow(col, true); + } } - uiItemL(row, "", ICON_BLANK1); /* Space for decorator. */ - uiLayout *col = uiLayoutColumn(layout, true); - uiItemR(col, ptr, "use_intersection_match", 0, IFACE_("Match All Masks"), ICON_NONE); + uiItemR(layout, ptr, "use_intersection_match", 0, IFACE_("Exact Match"), ICON_NONE); } static void face_mark_panel_draw_header(const bContext *UNUSED(C), Panel *panel) { @@ -566,7 +574,7 @@ static void chaining_panel_draw(const bContext *UNUSED(C), Panel *panel) uiItemR(col, ptr, "use_fuzzy_all", 0, NULL, ICON_NONE); uiItemR(col, ptr, "use_loose_edge_chain", 0, IFACE_("Loose Edges"), ICON_NONE); uiItemR(col, ptr, "use_loose_as_contour", 0, NULL, ICON_NONE); - uiItemR(col, ptr, "use_geometry_space_chain", 0, NULL, ICON_NONE); + uiItemR(col, ptr, "use_geometry_space_chain", 0, IFACE_("Geometry Space"), ICON_NONE); uiItemR(layout, ptr, @@ -613,7 +621,7 @@ static void vgroup_panel_draw(const bContext *UNUSED(C), Panel *panel) } } -static void baking_panel_draw(const bContext *UNUSED(C), Panel *panel) +static void bake_panel_draw(const bContext *UNUSED(C), Panel *panel) { uiLayout *layout = panel->layout; PointerRNA ob_ptr; @@ -669,7 +677,7 @@ static void panelRegister(ARegionType *region_type) gpencil_modifier_subpanel_register( region_type, "vgroup", "Vertex Weight Transfer", NULL, vgroup_panel_draw, panel_type); gpencil_modifier_subpanel_register( - region_type, "baking", "Baking", NULL, baking_panel_draw, panel_type); + region_type, "bake", "Bake", NULL, bake_panel_draw, panel_type); } GpencilModifierTypeInfo modifierType_Gpencil_Lineart = { diff --git a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h index 1d4370ed3a9..8eed2e705e8 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h +++ b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h @@ -228,6 +228,8 @@ typedef struct LineartRenderBuffer { double view_projection[4][4]; double view[4][4]; + float overscan; + struct LineartBoundingArea *initial_bounding_areas; unsigned int bounding_area_count; @@ -473,7 +475,8 @@ typedef struct LineartBoundingArea { BLI_INLINE int lineart_LineIntersectTest2d( const double *a1, const double *a2, const double *b1, const double *b2, double *aRatio) { -#define USE_VECTOR_LINE_INTERSECTION +/* Legacy intersection math aligns better with occlusion function quirks. */ +/* #define USE_VECTOR_LINE_INTERSECTION */ #ifdef USE_VECTOR_LINE_INTERSECTION /* from isect_line_line_v2_point() */ diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c index 30ac08c3f9d..97bfb2d197a 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c @@ -1804,10 +1804,7 @@ static void lineart_geometry_object_load(LineartObjectInfo *obi, LineartRenderBu tri->material_mask_bits |= ((mat && (mat->lineart.flags & LRT_MATERIAL_MASK_ENABLED)) ? mat->lineart.material_mask_bits : 0); - tri->mat_occlusion |= ((mat && - (mat->lineart.flags & LRT_MATERIAL_CUSTOM_OCCLUSION_EFFECTIVENESS)) ? - mat->lineart.mat_occlusion : - 1); + tri->mat_occlusion |= (mat ? mat->lineart.mat_occlusion : 1); tri->intersection_mask = obi->override_intersection_mask; @@ -2017,7 +2014,10 @@ static void lineart_geometry_load_assign_thread(LineartObjectLoadTaskInfo *olti_ use_olti->pending = obi; } -static bool lineart_geometry_check_visible(double (*model_view_proj)[4], Object *use_ob) +static bool lineart_geometry_check_visible(double (*model_view_proj)[4], + double shift_x, + double shift_y, + Object *use_ob) { BoundBox *bb = BKE_object_boundbox_get(use_ob); if (!bb) { @@ -2031,6 +2031,8 @@ static bool lineart_geometry_check_visible(double (*model_view_proj)[4], Object copy_v3db_v3fl(co[i], bb->vec[i]); copy_v3_v3_db(tmp, co[i]); mul_v4_m4v3_db(co[i], model_view_proj, tmp); + co[i][0] -= shift_x * 2 * co[i][3]; + co[i][1] -= shift_y * 2 * co[i][3]; } bool cond[6] = {true, true, true, true, true, true}; @@ -2066,11 +2068,6 @@ static void lineart_main_load_geometries( int fit = BKE_camera_sensor_fit(cam->sensor_fit, rb->w, rb->h); double asp = ((double)rb->w / (double)rb->h); - double t_start; - - if (G.debug_value == 4000) { - t_start = PIL_check_seconds_timer(); - } int bound_box_discard_count = 0; if (cam->type == CAM_PERSP) { @@ -2080,14 +2077,20 @@ static void lineart_main_load_geometries( if (fit == CAMERA_SENSOR_FIT_HOR && asp < 1) { sensor /= asp; } - double fov = focallength_to_fov(cam->lens, sensor); + const double fov = focallength_to_fov(cam->lens / (1 + rb->overscan), sensor); lineart_matrix_perspective_44d(proj, fov, asp, cam->clip_start, cam->clip_end); } else if (cam->type == CAM_ORTHO) { - double w = cam->ortho_scale / 2; + const double w = cam->ortho_scale / 2; lineart_matrix_ortho_44d(proj, -w, w, -w / asp, w / asp, cam->clip_start, cam->clip_end); } + double t_start; + + if (G.debug_value == 4000) { + t_start = PIL_check_seconds_timer(); + } + invert_m4_m4(inv, rb->cam_obmat); mul_m4db_m4db_m4fl_uniq(result, proj, inv); copy_m4_m4_db(proj, result); @@ -2126,7 +2129,7 @@ static void lineart_main_load_geometries( Object *use_ob = DEG_get_evaluated_object(depsgraph, ob); /* Prepare the matrix used for transforming this specific object (instance). This has to be - * done before mesh boundbox check because the function needs that. */ + * done before mesh boundbox check because the function needs that. */ mul_m4db_m4db_m4fl_uniq(obi->model_view_proj, rb->view_projection, ob->obmat); mul_m4db_m4db_m4fl_uniq(obi->model_view, rb->view, ob->obmat); @@ -2134,7 +2137,7 @@ static void lineart_main_load_geometries( continue; } - if (!lineart_geometry_check_visible(obi->model_view_proj, use_ob)) { + if (!lineart_geometry_check_visible(obi->model_view_proj, rb->shift_x, rb->shift_y, use_ob)) { if (G.debug_value == 4000) { bound_box_discard_count++; } @@ -2157,7 +2160,7 @@ static void lineart_main_load_geometries( obi->free_use_mesh = true; } - /* Make normal matrix. */ + /* Make normal matrix. */ float imat[4][4]; invert_m4_m4(imat, ob->obmat); transpose_m4(imat); @@ -2479,8 +2482,8 @@ static bool lineart_triangle_edge_image_space_occlusion(SpinLock *UNUSED(spl), } } else if (st_r == 0) { - INTERSECT_JUST_GREATER(is, order, 0, LCross); - if (LRT_ABC(LCross) && is[LCross] > 0) { + INTERSECT_JUST_GREATER(is, order, DBL_TRIANGLE_LIM, LCross); + if (LRT_ABC(LCross) && is[LCross] > DBL_TRIANGLE_LIM) { INTERSECT_JUST_GREATER(is, order, is[LCross], RCross); } else { @@ -3027,6 +3030,11 @@ static LineartRenderBuffer *lineart_create_render_buffer(Scene *scene, rb->shift_x = fit == CAMERA_SENSOR_FIT_HOR ? c->shiftx : c->shiftx / asp; rb->shift_y = fit == CAMERA_SENSOR_FIT_VERT ? c->shifty : c->shifty * asp; + rb->overscan = lmd->overscan; + + rb->shift_x /= (1 + rb->overscan); + rb->shift_y /= (1 + rb->overscan); + rb->crease_threshold = cos(M_PI - lmd->crease_threshold); rb->angle_splitting_threshold = lmd->angle_splitting_threshold; rb->chaining_image_threshold = lmd->chaining_image_threshold; |