29#include "RNA_prototypes.hh"
49#define MVAL_PIXEL_MARGIN 5.0f
51#define PROFILE_HARD_MIN 0.0f
53#define SEGMENTS_HARD_MAX 1000
57#define OFFSET_VALUE_PERCENT 1
58#define PROFILE_VALUE 2
59#define SEGMENTS_VALUE 3
60#define NUM_VALUE_KINDS 4
63 "offset",
"offset_pct",
"profile",
"segments"};
145 const char *mode_str, *omiter_str, *imiter_str, *vmesh_str, *profile_type_str, *affect_str;
152 const std::string header_status = fmt::format(
"{}: {}, {}: {}, {}: {}",
211 desc = fmt::format(
"{} ({}) ",
IFACE_(
"Affect"), affect_str);
214 desc = fmt::format(
"{} ({}) ",
IFACE_(
"Outer"), omiter_str);
217 desc = fmt::format(
"{} ({}) ",
IFACE_(
"Inner"), imiter_str);
220 desc = fmt::format(
"{} ({}) ",
IFACE_(
"Profile Type"), profile_type_str);
223 desc = fmt::format(
"{} ({}) ",
IFACE_(
"Intersection"), vmesh_str);
239 op->
customdata = MEM_new<BevelData>(__func__);
248 scene, view_layer, v3d);
249 for (
Object *obedit : objects) {
250 float scale =
mat4_to_scale(obedit->object_to_world().ptr());
263 float pixels_per_inch =
U.dpi;
289 Object *obedit = ob_store.ob;
305 bool changed =
false;
319 const int face_strength_mode =
RNA_enum_get(op->
ptr,
"face_strength_mode");
326 Object *obedit = ob_store.ob;
334 const int material = std::clamp(material_init, -1, obedit->
totcol - 1);
339 "bevel geom=%hev offset=%f segments=%i affect=%i offset_type=%i "
340 "profile_type=%i profile=%f clamp_overlap=%b material=%i loop_slide=%b "
341 "mark_seam=%b mark_sharp=%b harden_normals=%b face_strength_mode=%i "
342 "miter_outer=%i miter_inner=%i spread=%f custom_profile=%p "
366 if (offset != 0.0f) {
380 params.calc_looptris =
true;
381 params.calc_normals =
true;
382 params.is_destructive =
true;
423 Object *obedit = ob_store.ob;
428 params.calc_looptris =
false;
429 params.calc_normals =
true;
430 params.is_destructive =
true;
461 const float mlen[2] = {
462 opdata->
mcenter[0] -
event->mval[0],
463 opdata->
mcenter[1] -
event->mval[1],
473 float sc = opdata->
scale[vmode];
528 const float mdiff[2] = {
529 opdata->
mcenter[0] -
event->mval[0],
530 opdata->
mcenter[1] -
event->mval[1],
591 "OFFSET_MODE_CHANGE",
593 "Change Offset Mode",
594 "Cycle through offset modes"},
596 "CLAMP_OVERLAP_TOGGLE",
598 "Toggle Clamp Overlap",
599 "Toggle clamp overlap flag"},
603 "Change Affect Type",
604 "Change which geometry type the operation affects, edges or vertices"},
606 "HARDEN_NORMALS_TOGGLE",
608 "Toggle Harden Normals",
609 "Toggle harden normals flag"},
614 "Toggle mark seam flag"},
619 "Toggle mark sharp flag"},
621 "OUTER_MITER_CHANGE",
623 "Change Outer Miter",
624 "Cycle through outer miter kinds"},
626 "INNER_MITER_CHANGE",
628 "Change Inner Miter",
629 "Cycle through inner miter kinds"},
632 "VERTEX_MESH_CHANGE",
634 "Change Intersection Method",
635 "Cycle through intersection methods"},
636 {0,
nullptr, 0,
nullptr,
nullptr},
657 bool handled =
false;
658 short etype =
event->type;
659 short eval =
event->val;
686 float delta = 0.02f * (
event->xy[1] -
event->prev_xy[1]);
960 &scene->id, &RNA_ToolSettings, scene->toolsettings);
970 {
BEVEL_AMT_OFFSET,
"OFFSET", 0,
"Offset",
"Amount is offset of new edges from original"},
976 "Amount is perpendicular distance from original edge to bevel face"},
977 {
BEVEL_AMT_PERCENT,
"PERCENT", 0,
"Percent",
"Amount is percent of adjacent edge length"},
982 "Amount is absolute distance along adjacent edge"},
983 {0,
nullptr, 0,
nullptr,
nullptr},
991 "The profile can be a concave or convex curve"},
996 "The profile can be any arbitrary path between its endpoints"},
997 {0,
nullptr, 0,
nullptr,
nullptr},
1007 "Set face strength on new and modified faces only"},
1009 {0,
nullptr, 0,
nullptr,
nullptr},
1014 {
BEVEL_MITER_PATCH,
"PATCH", 0,
"Patch",
"Outside of miter is squared-off patch"},
1016 {0,
nullptr, 0,
nullptr,
nullptr},
1022 {0,
nullptr, 0,
nullptr,
nullptr},
1031 "A cutoff at each profile's end before the intersection"},
1032 {0,
nullptr, 0,
nullptr,
nullptr},
1038 {0,
nullptr, 0,
nullptr,
nullptr},
1043 ot->
description =
"Cut into selected items at an angle to create bevel or chamfer";
1063 "The method for determining the size of the bevel");
1071 prop_profile_type_items,
1074 "The type of shape used to rebuild a beveled section");
1086 "Segments for curved edge",
1096 "Controls profile shape (0.5 = round)",
1105 "Affect edges or vertices");
1111 "Do not allow beveled edges/vertices to overlap each other");
1114 ot->
srna,
"loop_slide",
true,
"Loop Slide",
"Prefer sliding along edges to even widths");
1126 "Material for bevel faces (-1 means use adjacent faces)",
1134 "Match normals of new faces to adjacent faces");
1137 "face_strength_mode",
1138 face_strength_mode_items,
1140 "Face Strength Mode",
1141 "Whether to set face strength, and which faces to set face strength on");
1148 "Pattern to use for outside of miters");
1155 "Pattern to use for inside of miters");
1163 "Amount to spread arcs for arc inner miters",
1171 "Vertex Mesh Method",
1172 "The method to use to create meshes at intersections");
ScrArea * CTX_wm_area(const bContext *C)
Scene * CTX_data_scene(const bContext *C)
ToolSettings * CTX_data_tool_settings(const bContext *C)
RegionView3D * CTX_wm_region_view3d(const bContext *C)
ARegion * CTX_wm_region(const bContext *C)
View3D * CTX_wm_view3d(const bContext *C)
ViewLayer * CTX_data_view_layer(const bContext *C)
BMEditMesh * BKE_editmesh_from_object(Object *ob)
Return the BMEditMesh for a given object.
blender::Vector< Object * > BKE_view_layer_array_from_objects_in_edit_mode_unique_data(const Scene *scene, ViewLayer *view_layer, const View3D *v3d)
size_t BKE_unit_value_as_string(char *str, int str_maxncpy, double value, int prec, int type, const UnitSettings *settings, bool pad)
MINLINE float max_ff(float a, float b)
float mat4_to_scale(const float mat[4][4])
MINLINE float len_v2(const float v[2]) ATTR_WARN_UNUSED_RESULT
#define SNPRINTF(dst, format,...)
typedef double(DMatrix)[4][4]
Object is a sort of wrapper for general info.
@ V3D_AROUND_CENTER_MEDIAN
void EDBM_flag_disable_all(BMEditMesh *em, char hflag)
void void EDBM_redo_state_restore_and_free(BMBackup *backup, BMEditMesh *em, bool recalc_looptris) ATTR_NONNULL(1
void EDBM_update(Mesh *mesh, const EDBMUpdate_Params *params)
void void void EDBM_redo_state_free(BMBackup *backup) ATTR_NONNULL(1)
void EDBM_selectmode_flush(BMEditMesh *em)
BMBackup EDBM_redo_state_store(BMEditMesh *em)
void EDBM_redo_state_restore(BMBackup *backup, BMEditMesh *em, bool recalc_looptris) ATTR_NONNULL(1
void ED_area_status_text(ScrArea *area, const char *str)
void ED_workspace_status_text(bContext *C, const char *str)
bool ED_operator_editmesh(bContext *C)
void ED_region_tag_redraw(ARegion *region)
void * ED_region_draw_cb_activate(ARegionType *art, void(*draw)(const bContext *, ARegion *, void *), void *customdata, int type)
bool ED_region_draw_cb_exit(ARegionType *art, void *handle)
#define REGION_DRAW_POST_PIXEL
void ED_region_draw_mouse_line_cb(const bContext *C, ARegion *region, void *arg_info)
float ED_view3d_pixel_size(const RegionView3D *rv3d, const float co[3])
Read Guarded memory(de)allocation.
void uiLayoutSetActive(uiLayout *layout, bool active)
uiLayout * uiLayoutRow(uiLayout *layout, bool align)
void uiLayoutSetPropSep(uiLayout *layout, bool is_sep)
void uiItemS(uiLayout *layout)
uiLayout * uiLayoutColumnWithHeading(uiLayout *layout, bool align, const char *heading)
void uiLayoutSetPropDecorate(uiLayout *layout, bool is_sep)
void uiTemplateCurveProfile(uiLayout *layout, PointerRNA *ptr, const char *propname)
uiLayout * uiLayoutColumn(uiLayout *layout, bool align)
void uiItemR(uiLayout *layout, PointerRNA *ptr, const char *propname, eUI_Item_Flag flag, const char *name, int icon)
void BMO_slot_buffer_hflag_enable(BMesh *bm, BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, char htype, char hflag, bool do_flush)
BMO_FLAG_BUFFER.
void BMO_op_exec(BMesh *bm, BMOperator *op)
BMESH OPSTACK EXEC OP.
@ BEVEL_PROFILE_SUPERELLIPSE
@ BEVEL_FACE_STRENGTH_NONE
@ BEVEL_FACE_STRENGTH_AFFECTED
@ BEVEL_FACE_STRENGTH_NEW
@ BEVEL_FACE_STRENGTH_ALL
void opmodal(std::string text, const wmOperatorType *ot, int propvalue, bool inverted=false)
static const float value_clamp_max[NUM_VALUE_KINDS]
static void edbm_bevel_cancel(bContext *C, wmOperator *op)
static void edbm_bevel_mouse_set_value(wmOperator *op, const wmEvent *event)
static void edbm_bevel_ui(bContext *C, wmOperator *op)
static void edbm_bevel_exit(bContext *C, wmOperator *op)
static void edbm_bevel_update_status_text(bContext *C, wmOperator *op)
static const float value_start[NUM_VALUE_KINDS]
static int edbm_bevel_exec(bContext *C, wmOperator *op)
static bool edbm_bevel_init(bContext *C, wmOperator *op, const bool is_modal)
static const float value_clamp_min[NUM_VALUE_KINDS]
#define OFFSET_VALUE_PERCENT
static float get_bevel_offset(wmOperator *op)
wmKeyMap * bevel_modal_keymap(wmKeyConfig *keyconf)
static int edbm_bevel_modal(bContext *C, wmOperator *op, const wmEvent *event)
static void edbm_bevel_numinput_set_value(wmOperator *op)
void MESH_OT_bevel(wmOperatorType *ot)
static const char * value_rna_name[NUM_VALUE_KINDS]
#define SEGMENTS_HARD_MAX
static void edbm_bevel_calc_initial_length(wmOperator *op, const wmEvent *event, bool mode_changed)
@ BEV_MODAL_PROFILE_TYPE_CHANGE
@ BEV_MODAL_MARK_SHARP_TOGGLE
@ BEV_MODAL_AFFECT_CHANGE
@ BEV_MODAL_HARDEN_NORMALS_TOGGLE
@ BEV_MODAL_VERTEX_MESH_CHANGE
@ BEV_MODAL_OFFSET_MODE_CHANGE
@ BEV_MODAL_SEGMENTS_DOWN
@ BEV_MODAL_INNER_MITER_CHANGE
@ BEV_MODAL_MARK_SEAM_TOGGLE
@ BEV_MODAL_VALUE_SEGMENTS
@ BEV_MODAL_OUTER_MITER_CHANGE
@ BEV_MODAL_CLAMP_OVERLAP_TOGGLE
@ BEV_MODAL_VALUE_PROFILE
static int edbm_bevel_invoke(bContext *C, wmOperator *op, const wmEvent *event)
#define MVAL_PIXEL_MARGIN
static bool edbm_bevel_calc(wmOperator *op)
static const float value_scale_per_inch[NUM_VALUE_KINDS]
bool EDBM_op_init(BMEditMesh *em, BMOperator *bmop, wmOperator *op, const char *fmt,...)
bool EDBM_op_finish(BMEditMesh *em, BMOperator *bmop, wmOperator *op, const bool do_report)
draw_view in_light_buf[] float
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
void RNA_boolean_set(PointerRNA *ptr, const char *name, bool value)
void RNA_int_set(PointerRNA *ptr, const char *name, int value)
bool RNA_property_enum_name_gettexted(bContext *C, PointerRNA *ptr, PropertyRNA *prop, const int value, const char **r_name)
int RNA_int_get(PointerRNA *ptr, const char *name)
float RNA_float_get(PointerRNA *ptr, const char *name)
void RNA_float_set(PointerRNA *ptr, const char *name, float value)
int RNA_property_enum_get(PointerRNA *ptr, PropertyRNA *prop)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
void RNA_enum_set(PointerRNA *ptr, const char *name, int value)
PointerRNA RNA_pointer_create(ID *id, StructRNA *type, void *data)
int RNA_enum_get(PointerRNA *ptr, const char *name)
void RNA_def_property_ui_text(PropertyRNA *prop, const char *name, const char *description)
PropertyRNA * RNA_def_float(StructOrFunctionRNA *cont_, const char *identifier, const float default_value, const float hardmin, const float hardmax, const char *ui_name, const char *ui_description, const float softmin, const float softmax)
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
void RNA_def_property_range(PropertyRNA *prop, double min, double max)
PropertyRNA * RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier, int type, int subtype)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
void RNA_def_property_ui_range(PropertyRNA *prop, double min, double max, double step, int precision)
PropertyRNA * RNA_def_int(StructOrFunctionRNA *cont_, const char *identifier, const int default_value, const int hardmin, const int hardmax, const char *ui_name, const char *ui_description, const int softmin, const int softmax)
struct BMOpSlot slots_out[BMO_OP_MAX_SLOTS]
float shift_value[NUM_VALUE_KINDS]
Vector< BevelObjectStore > ob_store
NumInput num_input[NUM_VALUE_KINDS]
CurveProfile * custom_profile
float scale[NUM_VALUE_KINDS]
float initial_length[NUM_VALUE_KINDS]
bool(* poll)(bContext *C) ATTR_WARN_UNUSED_RESULT
int(* modal)(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
int(* invoke)(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
int(* exec)(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
void(* ui)(bContext *C, wmOperator *op)
void(* cancel)(bContext *C, wmOperator *op)
struct wmOperatorType * type
int WM_userdef_event_type_from_keymap_type(int kmitype)
wmEventHandler_Op * WM_event_add_modal_handler(bContext *C, wmOperator *op)
wmKeyMap * WM_modalkeymap_ensure(wmKeyConfig *keyconf, const char *idname, const EnumPropertyItem *items)
void WM_modalkeymap_assign(wmKeyMap *km, const char *opname)
wmKeyMap * WM_modalkeymap_find(wmKeyConfig *keyconf, const char *idname)