Commit: aef01c47e6334b214520f14c72b01de99387f122 Author: Howard Trickey Date: Thu Jan 3 13:39:52 2019 -0500 Branches: master https://developer.blender.org/rBaef01c47e6334b214520f14c72b01de99387f122
Fix T58113 Multiple problems with bevel harden normals. Move the bevel hardening code all into bmesh_bevel.c. Based on user feedback, rewrote the bevel hardening algorithm to be more what users want. Based on user feedback, changed the UI, removing some not-useful options. Now hardening normals while beveling is enabled by a simple checkbox. Now setting face strength gives options for which faces get their face strength set. =================================================================== M release/datafiles/locale M release/scripts/addons M release/scripts/startup/bl_ui/properties_data_modifier.py M source/blender/bmesh/intern/bmesh_opdefines.c M source/blender/bmesh/intern/bmesh_operators.h M source/blender/bmesh/operators/bmo_bevel.c M source/blender/bmesh/tools/bmesh_bevel.c M source/blender/bmesh/tools/bmesh_bevel.h M source/blender/editors/mesh/editmesh_bevel.c M source/blender/makesdna/DNA_modifier_types.h M source/blender/makesrna/intern/rna_modifier.c M source/blender/modifiers/intern/MOD_bevel.c =================================================================== diff --git a/release/datafiles/locale b/release/datafiles/locale index fec9a7e88c8..345b7d27872 160000 --- a/release/datafiles/locale +++ b/release/datafiles/locale @@ -1 +1 @@ -Subproject commit fec9a7e88c8686830e9210099818a61489e699e4 +Subproject commit 345b7d27872d87ae5074a83d8b9995b37bc56f1b diff --git a/release/scripts/addons b/release/scripts/addons index e3c9be92624..25ae9e13447 160000 --- a/release/scripts/addons +++ b/release/scripts/addons @@ -1 +1 @@ -Subproject commit e3c9be92624d93ba3eb78731887455fbf41040d6 +Subproject commit 25ae9e134472c5bca62add0a1db3cdfc2d86aaa7 diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py index 3d4f3037a84..52af0512a0c 100644 --- a/release/scripts/startup/bl_ui/properties_data_modifier.py +++ b/release/scripts/startup/bl_ui/properties_data_modifier.py @@ -147,6 +147,7 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel): col.prop(md, "loop_slide") col.prop(md, "mark_seam") col.prop(md, "mark_sharp") + col.prop(md, "harden_normals") layout.label(text="Limit Method:") layout.row().prop(md, "limit_method", expand=True) @@ -159,10 +160,8 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel): layout.label(text="Width Method:") layout.row().prop(md, "offset_type", expand=True) - layout.label(text="Normal Mode") - layout.row().prop(md, "hnmode", expand=True) - layout.prop(md, "hn_strength") - layout.prop(md, "set_wn_strength") + layout.label(text="Set Face Strength Mode") + layout.row().prop(md, "face_strength_mode", expand=True) def BOOLEAN(self, layout, ob, md): split = layout.split() diff --git a/source/blender/bmesh/intern/bmesh_opdefines.c b/source/blender/bmesh/intern/bmesh_opdefines.c index 519ffa5ed59..7a6cb814cc9 100644 --- a/source/blender/bmesh/intern/bmesh_opdefines.c +++ b/source/blender/bmesh/intern/bmesh_opdefines.c @@ -1734,11 +1734,11 @@ static BMO_FlagSet bmo_enum_bevel_offset_type[] = { {0, NULL}, }; -static BMO_FlagSet bmo_enum_bevel_harden_normal_type[] = { - {BEVEL_HN_NONE, "NONE"}, - {BEVEL_HN_FACE, "FACE"}, - {BEVEL_HN_ADJ, "ADJACENT"}, - {BEVEL_HN_FIX_SHA, "FIXED_NORMAL_SHADING"}, +static BMO_FlagSet bmo_enum_bevel_face_strength_type[] = { + {BEVEL_FACE_STRENGTH_NONE, "NONE"}, + {BEVEL_FACE_STRENGTH_NEW, "NEW"}, + {BEVEL_FACE_STRENGTH_AFFECTED, "AFFECTED"}, + {BEVEL_FACE_STRENGTH_ALL, "ALL"}, {0, NULL}, }; @@ -1761,15 +1761,15 @@ static BMOpDefine bmo_bevel_def = { {"loop_slide", BMO_OP_SLOT_BOOL}, /* prefer to slide along edges to having even widths */ {"mark_seam", BMO_OP_SLOT_BOOL}, /* extend edge data to allow seams to run across bevels */ {"mark_sharp", BMO_OP_SLOT_BOOL}, /* extend edge data to allow sharp edges to run across bevels */ - {"strength", BMO_OP_SLOT_FLT}, /* strength of calculated normal in range (0, 1) for custom clnors */ - {"hnmode", BMO_OP_SLOT_INT, {(int)BMO_OP_SLOT_SUBTYPE_INT_ENUM}, bmo_enum_bevel_harden_normal_type}, /* harden normals mode used in bevel, if enabled */ + {"harden_normals", BMO_OP_SLOT_BOOL}, /* harden normals */ + {"face_strength_mode", BMO_OP_SLOT_INT, {(int)BMO_OP_SLOT_SUBTYPE_INT_ENUM}, + bmo_enum_bevel_face_strength_type}, /* whether to set face strength, and which faces to set if so */ {{'\0'}}, }, /* slots_out */ {{"faces.out", BMO_OP_SLOT_ELEMENT_BUF, {BM_FACE}}, /* output faces */ {"edges.out", BMO_OP_SLOT_ELEMENT_BUF, {BM_EDGE}}, /* output edges */ {"verts.out", BMO_OP_SLOT_ELEMENT_BUF, {BM_VERT}}, /* output verts */ - {"normals.out", BMO_OP_SLOT_MAPPING, {(int)BMO_OP_SLOT_SUBTYPE_MAP_INTERNAL}}, /* output normals per vertex for beveled edges */ {{'\0'}}, }, diff --git a/source/blender/bmesh/intern/bmesh_operators.h b/source/blender/bmesh/intern/bmesh_operators.h index 21b356155ed..365b5eb4681 100644 --- a/source/blender/bmesh/intern/bmesh_operators.h +++ b/source/blender/bmesh/intern/bmesh_operators.h @@ -117,11 +117,12 @@ enum { BEVEL_AMT_PERCENT }; +/* Bevel face_strength_mode values: should match face_str mode enum in DNA_modifer_types.h */ enum { - BEVEL_HN_NONE, /* Disable harden normals */ - BEVEL_HN_FACE, /* harden normals according to face area */ - BEVEL_HN_ADJ, /* harden normals according to adjacent 'beveled' faces */ - BEVEL_HN_FIX_SHA, /* Special mode to fix normal shading continuity */ + BEVEL_FACE_STRENGTH_NONE, + BEVEL_FACE_STRENGTH_NEW, + BEVEL_FACE_STRENGTH_AFFECTED, + BEVEL_FACE_STRENGTH_ALL, }; extern const BMOpDefine *bmo_opdefines[]; diff --git a/source/blender/bmesh/operators/bmo_bevel.c b/source/blender/bmesh/operators/bmo_bevel.c index 656a446d5ab..1ef8531397f 100644 --- a/source/blender/bmesh/operators/bmo_bevel.c +++ b/source/blender/bmesh/operators/bmo_bevel.c @@ -45,7 +45,8 @@ void bmo_bevel_exec(BMesh *bm, BMOperator *op) const bool loop_slide = BMO_slot_bool_get(op->slots_in, "loop_slide"); const bool mark_seam = BMO_slot_bool_get(op->slots_in, "mark_seam"); const bool mark_sharp = BMO_slot_bool_get(op->slots_in, "mark_sharp"); - const int hnmode = BMO_slot_int_get(op->slots_in, "hnmode"); + const bool harden_normals = BMO_slot_bool_get(op->slots_in, "harden_normals"); + const int face_strength_mode = BMO_slot_int_get(op->slots_in, "face_strength_mode"); if (offset > 0) { BMOIter siter; @@ -71,7 +72,7 @@ void bmo_bevel_exec(BMesh *bm, BMOperator *op) BM_mesh_bevel( bm, offset, offset_type, seg, profile, vonly, false, clamp_overlap, NULL, -1, material, - loop_slide, mark_seam, mark_sharp, hnmode, op); + loop_slide, mark_seam, mark_sharp, harden_normals, face_strength_mode); BMO_slot_buffer_from_enabled_hflag(bm, op, op->slots_out, "faces.out", BM_FACE, BM_ELEM_TAG); BMO_slot_buffer_from_enabled_hflag(bm, op, op->slots_out, "edges.out", BM_EDGE, BM_ELEM_TAG); diff --git a/source/blender/bmesh/tools/bmesh_bevel.c b/source/blender/bmesh/tools/bmesh_bevel.c index e48616ea231..7149df7dc4e 100644 --- a/source/blender/bmesh/tools/bmesh_bevel.c +++ b/source/blender/bmesh/tools/bmesh_bevel.c @@ -34,12 +34,15 @@ #include "DNA_meshdata_types.h" #include "DNA_modifier_types.h" +#include "DNA_scene_types.h" #include "BLI_array.h" #include "BLI_alloca.h" #include "BLI_gsqueue.h" +#include "BLI_linklist_stack.h" #include "BLI_math.h" #include "BLI_memarena.h" +#include "BLI_utildefines.h" #include "BKE_customdata.h" #include "BKE_deform.h" @@ -167,7 +170,6 @@ typedef struct VMesh { M_POLY, /* a simple polygon */ M_ADJ, /* "adjacent edges" mesh pattern */ M_TRI_FAN, /* a simple polygon - fan filled */ - M_QUAD_STRIP, /* a simple polygon - cut into parallel strips */ } mesh_kind; // int _pad; } VMesh; @@ -186,13 +188,21 @@ typedef struct BevVert { VMesh *vmesh; /* mesh structure for replacing vertex */ } BevVert; +/* face classification: note depend on F_RECON > F_EDGE > F_VERT */ +typedef enum { + F_NONE, /* used when there is no face at all */ + F_ORIG, /* original face, not touched */ + F_VERT, /* face for construction aroun a vert */ + F_EDGE, /* face for a beveled edge */ + F_RECON, /* reconstructed original face with some new verts */ +} FKind; + +// static const char* fkind_names[] = {"F_NONE", "F_ORIG", "F_VERT", "F_EDGE", "F_RECON"}; /* DEBUG */ + /* Bevel parameters and state */ typedef struct BevelParams { - /* hash of BevVert for each vertex involved in bevel - * GHash: (key=(BMVert *), value=(BevVert *)) */ - GHash *vert_hash; - /* Hash set used to store resultant beveled faces for VMesh when poly is ring */ - GHash *faceHash; + GHash *vert_hash; /* records BevVerts made: key BMVert*, value BevVert* */ + GHash *face_hash; /* records new faces: key BMFace*, value one of {VERT/EDGE/RECON}_POLY */ MemArena *mem_arena; /* use for all allocs while bevel runs, if we need to free we can switch to mempool */ ProfileSpacing pro_spacing; /* parameter values for evenly spaced profiles */ @@ -205,12 +215,13 @@ typedef struct BevelParams { bool loop_slide; /* should bevel prefer to slide along edges rather than keep widths spec? */ bool limit_offset; /* should offsets be limited by collisions? */ bool offset_adjust; /* should offsets be adjusted to try to get even widths? */ - bool mark_seam; - bool mark_sharp; + bool mark_seam; /* should we propagate seam edge markings? */ + bool mark_sharp; /* should we propagate sharp edge markings? */ + bool harden_normals; /* should we harden normals? */ const struct MDeformVert *dvert; /* vertex group array, maybe set if vertex_only */ int vertex_group; /* vertex group index, maybe set if vertex_only */ int mat_nr; /* if >= 0, material number for bevel; else material comes from adjacent faces */ - int hnmode; + int face_strength_mode; /* setting face strength if > 0 */ } BevelParams; // #pragma GCC diagnostic ignored "-Wpadded" @@ -223,8 +234,10 @@ static int bev_debug_flags = 0; #define DEBUG_OLD_PROJ_TO_PERP_PLANE (bev_debug_flags & 2) #define DEBUG_OLD_FLAT_MID (bev_debug_flags & 4) +/* use the unused _BM_ELEM_TAG_ALT flag to flag the 'long' loops (parallel to beveled edge) of edge-polygons */ +#define BM_ELEM_LONG_TAG (1<<6) -/* this flag values will get set on geom we want to return in 'out' slots for edges and verts */ +/* these flag values will get set on geom we want to return in 'out' slots for edges and verts */ #define EDGE_OUT 4 #define VERT_OUT 8 @@ -247,6 +260,18 @@ static void disable_flag_out_edge(BMesh *bm, BMEdge *bme) BMO_edge_flag_disable(bm, bme, EDGE_OUT); } +static void record_face_kind(BevelParams *bp, BMFace *f, FKind fkind) +{ + if (bp->face_hash) + BLI_ghash_insert(bp->face_hash, f, POINTER_FROM_INT(fkind)); +} + +static FKind get_face_kind(BevelParams *bp, BMFace *f) +{ + void *val = BLI_ghash_lookup(bp->face_hash, f); + return val ? (FKind)POINTER_AS_INT(val) : F_ORIG; +} + /* Are d1 and d2 parallel or nearly so? */ static bool nearly_parallel(const float d1[3], const float d2[3]) { @@ -1678,76 +1703,166 @@ s @@ Diff output truncated at 10240 characters. @@ _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs