2013-04-01 10:18:01 +00:00
|
|
|
/*
|
|
|
|
|
* 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.
|
|
|
|
|
*/
|
|
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
|
* \ingroup edmesh
|
2013-04-01 10:18:01 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
|
|
|
|
#include "DNA_object_types.h"
|
|
|
|
|
|
|
|
|
|
#include "BLI_math.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "BLI_string.h"
|
2013-04-01 10:18:01 +00:00
|
|
|
|
2015-08-16 17:32:01 +10:00
|
|
|
#include "BLT_translation.h"
|
2013-04-01 10:18:01 +00:00
|
|
|
|
|
|
|
|
#include "BKE_context.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "BKE_curveprofile.h"
|
2013-04-13 20:31:52 +00:00
|
|
|
#include "BKE_editmesh.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "BKE_global.h"
|
2018-05-16 13:11:50 +02:00
|
|
|
#include "BKE_layer.h"
|
2018-06-11 11:58:26 +05:30
|
|
|
#include "BKE_mesh.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "BKE_unit.h"
|
2013-04-01 10:18:01 +00:00
|
|
|
|
2019-11-20 16:12:32 -05:00
|
|
|
#include "DNA_curveprofile_types.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "DNA_mesh_types.h"
|
2019-01-06 18:12:00 -05:00
|
|
|
|
2013-04-01 10:18:01 +00:00
|
|
|
#include "RNA_access.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "RNA_define.h"
|
2013-04-01 10:18:01 +00:00
|
|
|
|
|
|
|
|
#include "WM_api.h"
|
|
|
|
|
#include "WM_types.h"
|
|
|
|
|
|
2016-05-14 10:00:52 +02:00
|
|
|
#include "UI_interface.h"
|
2019-11-20 16:12:32 -05:00
|
|
|
#include "UI_resources.h"
|
2016-05-14 10:00:52 +02:00
|
|
|
|
2013-04-01 10:18:01 +00:00
|
|
|
#include "ED_mesh.h"
|
|
|
|
|
#include "ED_numinput.h"
|
|
|
|
|
#include "ED_screen.h"
|
2013-04-02 10:48:11 +00:00
|
|
|
#include "ED_space_api.h"
|
2013-04-01 10:18:01 +00:00
|
|
|
#include "ED_transform.h"
|
|
|
|
|
#include "ED_view3d.h"
|
|
|
|
|
|
|
|
|
|
#include "mesh_intern.h" /* own include */
|
|
|
|
|
|
|
|
|
|
#define MVAL_PIXEL_MARGIN 5.0f
|
|
|
|
|
|
2017-12-04 09:30:40 -05:00
|
|
|
#define PROFILE_HARD_MIN 0.0f
|
2016-06-06 13:15:13 -04:00
|
|
|
|
2016-06-13 09:14:13 -04:00
|
|
|
#define SEGMENTS_HARD_MAX 1000
|
|
|
|
|
|
|
|
|
|
/* which value is mouse movement and numeric input controlling? */
|
|
|
|
|
#define OFFSET_VALUE 0
|
|
|
|
|
#define OFFSET_VALUE_PERCENT 1
|
|
|
|
|
#define PROFILE_VALUE 2
|
|
|
|
|
#define SEGMENTS_VALUE 3
|
|
|
|
|
#define NUM_VALUE_KINDS 4
|
|
|
|
|
|
2019-03-06 09:04:31 -05:00
|
|
|
static const char *value_rna_name[NUM_VALUE_KINDS] = {
|
|
|
|
|
"offset", "offset_pct", "profile", "segments"};
|
2016-06-13 09:14:13 -04:00
|
|
|
static const float value_clamp_min[NUM_VALUE_KINDS] = {0.0f, 0.0f, PROFILE_HARD_MIN, 1.0f};
|
|
|
|
|
static const float value_clamp_max[NUM_VALUE_KINDS] = {1e6, 100.0f, 1.0f, SEGMENTS_HARD_MAX};
|
|
|
|
|
static const float value_start[NUM_VALUE_KINDS] = {0.0f, 0.0f, 0.5f, 1.0f};
|
|
|
|
|
static const float value_scale_per_inch[NUM_VALUE_KINDS] = {0.0f, 100.0f, 1.0f, 4.0f};
|
|
|
|
|
|
2013-04-01 10:18:01 +00:00
|
|
|
typedef struct {
|
2020-01-07 13:22:15 +11:00
|
|
|
/** Every object must have a valid #BMEditMesh. */
|
|
|
|
|
Object *ob;
|
2018-05-16 13:11:50 +02:00
|
|
|
BMBackup mesh_backup;
|
|
|
|
|
} BevelObjectStore;
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
2016-06-13 09:14:13 -04:00
|
|
|
float initial_length[NUM_VALUE_KINDS];
|
|
|
|
|
float scale[NUM_VALUE_KINDS];
|
2018-06-04 09:31:30 +02:00
|
|
|
NumInput num_input[NUM_VALUE_KINDS];
|
2019-01-15 23:24:20 +11:00
|
|
|
/** The current value when shift is pressed. Negative when shift not active. */
|
|
|
|
|
float shift_value[NUM_VALUE_KINDS];
|
2019-03-06 09:04:31 -05:00
|
|
|
float max_obj_scale;
|
2013-04-02 10:48:11 +00:00
|
|
|
bool is_modal;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-05-16 13:11:50 +02:00
|
|
|
BevelObjectStore *ob_store;
|
|
|
|
|
uint ob_store_len;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-04-02 10:48:11 +00:00
|
|
|
/* modal only */
|
2020-01-21 02:52:20 +11:00
|
|
|
int launch_event;
|
2013-10-12 03:42:06 +00:00
|
|
|
float mcenter[2];
|
2013-04-02 10:48:11 +00:00
|
|
|
void *draw_handle_pixel;
|
2018-07-15 14:24:10 +02:00
|
|
|
short gizmo_flag;
|
2016-06-13 09:14:13 -04:00
|
|
|
short value_mode; /* Which value does mouse movement and numeric input affect? */
|
2016-05-08 18:14:44 +02:00
|
|
|
float segments; /* Segments as float so smooth mouse pan works in small increments */
|
2019-11-20 16:12:32 -05:00
|
|
|
|
|
|
|
|
CurveProfile *custom_profile;
|
2013-04-01 10:18:01 +00:00
|
|
|
} BevelData;
|
|
|
|
|
|
2019-02-10 16:08:25 -05:00
|
|
|
enum {
|
|
|
|
|
BEV_MODAL_CANCEL = 1,
|
|
|
|
|
BEV_MODAL_CONFIRM,
|
|
|
|
|
BEV_MODAL_VALUE_OFFSET,
|
|
|
|
|
BEV_MODAL_VALUE_PROFILE,
|
|
|
|
|
BEV_MODAL_VALUE_SEGMENTS,
|
|
|
|
|
BEV_MODAL_SEGMENTS_UP,
|
|
|
|
|
BEV_MODAL_SEGMENTS_DOWN,
|
|
|
|
|
BEV_MODAL_OFFSET_MODE_CHANGE,
|
|
|
|
|
BEV_MODAL_CLAMP_OVERLAP_TOGGLE,
|
2020-07-21 16:32:00 -04:00
|
|
|
BEV_MODAL_AFFECT_CHANGE,
|
2019-02-10 16:08:25 -05:00
|
|
|
BEV_MODAL_HARDEN_NORMALS_TOGGLE,
|
|
|
|
|
BEV_MODAL_MARK_SEAM_TOGGLE,
|
|
|
|
|
BEV_MODAL_MARK_SHARP_TOGGLE,
|
|
|
|
|
BEV_MODAL_OUTER_MITER_CHANGE,
|
|
|
|
|
BEV_MODAL_INNER_MITER_CHANGE,
|
2020-06-22 22:25:55 -04:00
|
|
|
BEV_MODAL_PROFILE_TYPE_CHANGE,
|
2019-11-20 16:12:32 -05:00
|
|
|
BEV_MODAL_VERTEX_MESH_CHANGE,
|
2019-02-10 16:08:25 -05:00
|
|
|
};
|
|
|
|
|
|
2019-03-06 09:04:31 -05:00
|
|
|
static float get_bevel_offset(wmOperator *op)
|
|
|
|
|
{
|
2019-04-22 09:19:45 +10:00
|
|
|
if (RNA_enum_get(op->ptr, "offset_type") == BEVEL_AMT_PERCENT) {
|
2020-11-03 13:57:20 -06:00
|
|
|
return RNA_float_get(op->ptr, "offset_pct");
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2020-11-03 13:57:20 -06:00
|
|
|
return RNA_float_get(op->ptr, "offset");
|
2019-03-06 09:04:31 -05:00
|
|
|
}
|
|
|
|
|
|
2019-11-20 16:12:32 -05:00
|
|
|
static void edbm_bevel_update_status_text(bContext *C, wmOperator *op)
|
2013-04-01 10:18:01 +00:00
|
|
|
{
|
2019-11-20 16:12:32 -05:00
|
|
|
char status_text[UI_MAX_DRAW_STR];
|
2019-02-10 16:08:25 -05:00
|
|
|
char buf[UI_MAX_DRAW_STR];
|
|
|
|
|
char *p = buf;
|
|
|
|
|
int available_len = sizeof(buf);
|
2014-06-30 10:57:39 +02:00
|
|
|
Scene *sce = CTX_data_scene(C);
|
2013-04-01 10:18:01 +00:00
|
|
|
|
2019-02-10 16:08:25 -05:00
|
|
|
#define WM_MODALKEY(_id) \
|
|
|
|
|
WM_modalkeymap_operator_items_to_string_buf( \
|
|
|
|
|
op->type, (_id), true, UI_MAX_SHORTCUT_STR, &available_len, &p)
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-11-03 13:57:20 -06:00
|
|
|
char offset_str[NUM_STR_REP_LEN];
|
2019-03-06 09:04:31 -05:00
|
|
|
if (RNA_enum_get(op->ptr, "offset_type") == BEVEL_AMT_PERCENT) {
|
|
|
|
|
BLI_snprintf(offset_str, NUM_STR_REP_LEN, "%.1f%%", RNA_float_get(op->ptr, "offset_pct"));
|
2019-02-10 16:08:25 -05:00
|
|
|
}
|
|
|
|
|
else {
|
2019-09-25 17:05:10 -03:00
|
|
|
double offset_val = (double)RNA_float_get(op->ptr, "offset");
|
2020-09-09 08:41:15 -05:00
|
|
|
BKE_unit_value_as_string(offset_str,
|
|
|
|
|
NUM_STR_REP_LEN,
|
|
|
|
|
offset_val * sce->unit.scale_length,
|
|
|
|
|
3,
|
|
|
|
|
B_UNIT_LENGTH,
|
|
|
|
|
&sce->unit,
|
|
|
|
|
true);
|
2013-04-01 10:18:01 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-11-03 13:57:20 -06:00
|
|
|
PropertyRNA *prop;
|
|
|
|
|
const char *mode_str, *omiter_str, *imiter_str, *vmesh_str, *profile_type_str, *affect_str;
|
2019-02-10 16:08:25 -05:00
|
|
|
prop = RNA_struct_find_property(op->ptr, "offset_type");
|
|
|
|
|
RNA_property_enum_name_gettexted(
|
|
|
|
|
C, op->ptr, prop, RNA_property_enum_get(op->ptr, prop), &mode_str);
|
2020-06-22 22:25:55 -04:00
|
|
|
prop = RNA_struct_find_property(op->ptr, "profile_type");
|
|
|
|
|
RNA_property_enum_name_gettexted(
|
|
|
|
|
C, op->ptr, prop, RNA_property_enum_get(op->ptr, prop), &profile_type_str);
|
2019-02-10 16:08:25 -05:00
|
|
|
prop = RNA_struct_find_property(op->ptr, "miter_outer");
|
|
|
|
|
RNA_property_enum_name_gettexted(
|
|
|
|
|
C, op->ptr, prop, RNA_property_enum_get(op->ptr, prop), &omiter_str);
|
|
|
|
|
prop = RNA_struct_find_property(op->ptr, "miter_inner");
|
|
|
|
|
RNA_property_enum_name_gettexted(
|
|
|
|
|
C, op->ptr, prop, RNA_property_enum_get(op->ptr, prop), &imiter_str);
|
2019-11-20 16:12:32 -05:00
|
|
|
prop = RNA_struct_find_property(op->ptr, "vmesh_method");
|
|
|
|
|
RNA_property_enum_name_gettexted(
|
|
|
|
|
C, op->ptr, prop, RNA_property_enum_get(op->ptr, prop), &vmesh_str);
|
2020-07-21 16:32:00 -04:00
|
|
|
prop = RNA_struct_find_property(op->ptr, "affect");
|
|
|
|
|
RNA_property_enum_name_gettexted(
|
|
|
|
|
C, op->ptr, prop, RNA_property_enum_get(op->ptr, prop), &affect_str);
|
2019-11-20 16:12:32 -05:00
|
|
|
|
|
|
|
|
BLI_snprintf(status_text,
|
|
|
|
|
sizeof(status_text),
|
|
|
|
|
TIP_("%s: Confirm, "
|
|
|
|
|
"%s: Cancel, "
|
|
|
|
|
"%s: Mode (%s), "
|
|
|
|
|
"%s: Width (%s), "
|
|
|
|
|
"%s: Segments (%d), "
|
|
|
|
|
"%s: Profile (%.3f), "
|
|
|
|
|
"%s: Clamp Overlap (%s), "
|
2020-07-21 16:32:00 -04:00
|
|
|
"%s: Affect (%s), "
|
2019-11-20 16:12:32 -05:00
|
|
|
"%s: Outer Miter (%s), "
|
|
|
|
|
"%s: Inner Miter (%s), "
|
|
|
|
|
"%s: Harden Normals (%s), "
|
|
|
|
|
"%s: Mark Seam (%s), "
|
|
|
|
|
"%s: Mark Sharp (%s), "
|
2020-06-22 22:25:55 -04:00
|
|
|
"%s: Profile Type (%s), "
|
2019-11-20 16:12:32 -05:00
|
|
|
"%s: Intersection (%s)"),
|
2019-03-15 08:53:22 +11:00
|
|
|
WM_MODALKEY(BEV_MODAL_CONFIRM),
|
|
|
|
|
WM_MODALKEY(BEV_MODAL_CANCEL),
|
|
|
|
|
WM_MODALKEY(BEV_MODAL_OFFSET_MODE_CHANGE),
|
|
|
|
|
mode_str,
|
|
|
|
|
WM_MODALKEY(BEV_MODAL_VALUE_OFFSET),
|
|
|
|
|
offset_str,
|
|
|
|
|
WM_MODALKEY(BEV_MODAL_VALUE_SEGMENTS),
|
|
|
|
|
RNA_int_get(op->ptr, "segments"),
|
|
|
|
|
WM_MODALKEY(BEV_MODAL_VALUE_PROFILE),
|
|
|
|
|
RNA_float_get(op->ptr, "profile"),
|
|
|
|
|
WM_MODALKEY(BEV_MODAL_CLAMP_OVERLAP_TOGGLE),
|
|
|
|
|
WM_bool_as_string(RNA_boolean_get(op->ptr, "clamp_overlap")),
|
2020-07-21 16:32:00 -04:00
|
|
|
WM_MODALKEY(BEV_MODAL_AFFECT_CHANGE),
|
|
|
|
|
affect_str,
|
2019-03-15 08:53:22 +11:00
|
|
|
WM_MODALKEY(BEV_MODAL_OUTER_MITER_CHANGE),
|
|
|
|
|
omiter_str,
|
|
|
|
|
WM_MODALKEY(BEV_MODAL_INNER_MITER_CHANGE),
|
|
|
|
|
imiter_str,
|
|
|
|
|
WM_MODALKEY(BEV_MODAL_HARDEN_NORMALS_TOGGLE),
|
|
|
|
|
WM_bool_as_string(RNA_boolean_get(op->ptr, "harden_normals")),
|
|
|
|
|
WM_MODALKEY(BEV_MODAL_MARK_SEAM_TOGGLE),
|
|
|
|
|
WM_bool_as_string(RNA_boolean_get(op->ptr, "mark_seam")),
|
|
|
|
|
WM_MODALKEY(BEV_MODAL_MARK_SHARP_TOGGLE),
|
2019-11-20 16:12:32 -05:00
|
|
|
WM_bool_as_string(RNA_boolean_get(op->ptr, "mark_sharp")),
|
2020-06-22 22:25:55 -04:00
|
|
|
WM_MODALKEY(BEV_MODAL_PROFILE_TYPE_CHANGE),
|
|
|
|
|
profile_type_str,
|
2019-11-20 16:12:32 -05:00
|
|
|
WM_MODALKEY(BEV_MODAL_VERTEX_MESH_CHANGE),
|
|
|
|
|
vmesh_str);
|
2019-02-10 16:08:25 -05:00
|
|
|
|
|
|
|
|
#undef WM_MODALKEY
|
|
|
|
|
|
2019-11-20 16:12:32 -05:00
|
|
|
ED_workspace_status_text(C, status_text);
|
2013-04-01 10:18:01 +00:00
|
|
|
}
|
|
|
|
|
|
2013-04-08 10:03:51 +00:00
|
|
|
static bool edbm_bevel_init(bContext *C, wmOperator *op, const bool is_modal)
|
2013-04-01 10:18:01 +00:00
|
|
|
{
|
Support units in modal numinput
Summary:
This completly changes the way modal numinput is handled. Now, edited expression is a string, which then gets unit- and py-evaluated to get a float value.
We gain many power and flexibility, but lose a few "shortcuts" like '-' to negate, or '/' to inverse (if they are really needed, we still can add them with modifiers, like e.g. ctrl-/ or so).
Features:
- units (cm, ", deg, etc.).
- basic operations from python/BKE_unit (+, *, **, etc.), and math constants and functions (pi, sin, etc.).
- you can navigate in edited value (left/right key, ctrl to move by block) and insert/delete chars, e.g. to fix a typo without having to rewrite everything.
- you can go to next/previous value with (ctrl-)TAB key.
- As before, hitting backspace after having deleted all leading chars will first reset the edited value to init state, and on second press, the whole "modal numinput" editing will be cancelled, going back to usual transform with mouse.
Notes:
- Did not touch to how values are shown in header when modal numinput is not enabled (would do that in another commit), so this is still quite inconsistent.
- Added back radian support in BKE_unit.
- Added arcminute/arcsecond to BKE_unit.
(those unit changes affect all angle UI controls, btw, so you can now enter radians or longitude/latitude values when in degrees units).
Related to T37600.
Reviewers: brecht, campbellbarton, carter2422
Reviewed By: brecht, campbellbarton, carter2422
Thanks everybody!
Differential Revision: http://developer.blender.org/D61
2013-12-21 17:11:43 +01:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
2020-11-03 13:57:20 -06:00
|
|
|
View3D *v3d = CTX_wm_view3d(C);
|
2019-11-20 16:12:32 -05:00
|
|
|
ToolSettings *ts = CTX_data_tool_settings(C);
|
2018-05-16 13:11:50 +02:00
|
|
|
ViewLayer *view_layer = CTX_data_view_layer(C);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-03-07 22:19:56 +01:00
|
|
|
if (is_modal) {
|
|
|
|
|
RNA_float_set(op->ptr, "offset", 0.0f);
|
2019-03-06 09:04:31 -05:00
|
|
|
RNA_float_set(op->ptr, "offset_pct", 0.0f);
|
2018-03-07 22:19:56 +01:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-11-03 13:57:20 -06:00
|
|
|
op->customdata = MEM_mallocN(sizeof(BevelData), "beveldata_mesh_operator");
|
|
|
|
|
BevelData *opdata = op->customdata;
|
2018-05-16 13:11:50 +02:00
|
|
|
uint objects_used_len = 0;
|
2019-03-06 09:04:31 -05:00
|
|
|
opdata->max_obj_scale = FLT_MIN;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-11-20 16:12:32 -05:00
|
|
|
/* Put the Curve Profile from the toolsettings into the opdata struct */
|
|
|
|
|
opdata->custom_profile = ts->custom_bevel_profile_preset;
|
|
|
|
|
|
2018-05-16 13:11:50 +02:00
|
|
|
{
|
|
|
|
|
uint ob_store_len = 0;
|
2019-01-18 12:54:10 -05:00
|
|
|
Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data(
|
2020-11-03 13:57:20 -06:00
|
|
|
view_layer, v3d, &ob_store_len);
|
2018-05-16 13:11:50 +02:00
|
|
|
opdata->ob_store = MEM_malloc_arrayN(ob_store_len, sizeof(*opdata->ob_store), __func__);
|
|
|
|
|
for (uint ob_index = 0; ob_index < ob_store_len; ob_index++) {
|
|
|
|
|
Object *obedit = objects[ob_index];
|
2019-03-06 09:04:31 -05:00
|
|
|
float scale = mat4_to_scale(obedit->obmat);
|
|
|
|
|
opdata->max_obj_scale = max_ff(opdata->max_obj_scale, scale);
|
2018-05-16 13:11:50 +02:00
|
|
|
BMEditMesh *em = BKE_editmesh_from_object(obedit);
|
|
|
|
|
if (em->bm->totvertsel > 0) {
|
2020-01-07 13:22:15 +11:00
|
|
|
opdata->ob_store[objects_used_len].ob = obedit;
|
2018-05-16 13:11:50 +02:00
|
|
|
objects_used_len++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
MEM_freeN(objects);
|
|
|
|
|
opdata->ob_store_len = objects_used_len;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-04-01 10:18:01 +00:00
|
|
|
opdata->is_modal = is_modal;
|
2020-11-03 13:57:20 -06:00
|
|
|
int otype = RNA_enum_get(op->ptr, "offset_type");
|
2019-03-08 07:42:16 -05:00
|
|
|
opdata->value_mode = (otype == BEVEL_AMT_PERCENT) ? OFFSET_VALUE_PERCENT : OFFSET_VALUE;
|
2016-08-29 08:51:04 -04:00
|
|
|
opdata->segments = (float)RNA_int_get(op->ptr, "segments");
|
2020-11-03 13:57:20 -06:00
|
|
|
float pixels_per_inch = U.dpi * U.pixelsize;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-11-03 13:57:20 -06:00
|
|
|
for (int i = 0; i < NUM_VALUE_KINDS; i++) {
|
2016-06-13 09:14:13 -04:00
|
|
|
opdata->shift_value[i] = -1.0f;
|
2017-09-19 09:38:17 -04:00
|
|
|
opdata->initial_length[i] = -1.0f;
|
2016-06-13 09:14:13 -04:00
|
|
|
/* note: scale for OFFSET_VALUE will get overwritten in edbm_bevel_invoke */
|
2018-06-04 09:31:30 +02:00
|
|
|
opdata->scale[i] = value_scale_per_inch[i] / pixels_per_inch;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-06-13 09:14:13 -04:00
|
|
|
initNumInput(&opdata->num_input[i]);
|
|
|
|
|
opdata->num_input[i].idx_max = 0;
|
|
|
|
|
opdata->num_input[i].val_flag[0] |= NUM_NO_NEGATIVE;
|
2019-06-30 11:31:45 -04:00
|
|
|
opdata->num_input[i].unit_type[0] = B_UNIT_NONE;
|
2016-06-13 09:14:13 -04:00
|
|
|
if (i == SEGMENTS_VALUE) {
|
|
|
|
|
opdata->num_input[i].val_flag[0] |= NUM_NO_FRACTION | NUM_NO_ZERO;
|
|
|
|
|
}
|
|
|
|
|
if (i == OFFSET_VALUE) {
|
|
|
|
|
opdata->num_input[i].unit_sys = scene->unit.system;
|
2019-06-30 11:31:45 -04:00
|
|
|
opdata->num_input[i].unit_type[0] = B_UNIT_LENGTH;
|
2016-06-13 09:14:13 -04:00
|
|
|
}
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-04-01 10:18:01 +00:00
|
|
|
/* avoid the cost of allocating a bm copy */
|
2013-04-02 10:48:11 +00:00
|
|
|
if (is_modal) {
|
2020-03-06 16:56:42 +01:00
|
|
|
ARegion *region = CTX_wm_region(C);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-05-16 13:11:50 +02:00
|
|
|
for (uint ob_index = 0; ob_index < opdata->ob_store_len; ob_index++) {
|
2020-01-07 13:22:15 +11:00
|
|
|
Object *obedit = opdata->ob_store[ob_index].ob;
|
|
|
|
|
BMEditMesh *em = BKE_editmesh_from_object(obedit);
|
|
|
|
|
opdata->ob_store[ob_index].mesh_backup = EDBM_redo_state_store(em);
|
2018-05-16 13:11:50 +02:00
|
|
|
}
|
2019-03-15 08:53:22 +11:00
|
|
|
opdata->draw_handle_pixel = ED_region_draw_cb_activate(
|
2020-03-06 16:56:42 +01:00
|
|
|
region->type, ED_region_draw_mouse_line_cb, opdata->mcenter, REGION_DRAW_POST_PIXEL);
|
2013-06-24 22:41:37 +00:00
|
|
|
G.moving = G_TRANSFORM_EDIT;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-04-29 00:00:43 +10:00
|
|
|
if (v3d) {
|
2018-07-15 14:24:10 +02:00
|
|
|
opdata->gizmo_flag = v3d->gizmo_flag;
|
|
|
|
|
v3d->gizmo_flag = V3D_GIZMO_HIDE;
|
2016-04-29 00:00:43 +10:00
|
|
|
}
|
2013-04-02 10:48:11 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-04-08 10:03:51 +00:00
|
|
|
return true;
|
2013-04-01 10:18:01 +00:00
|
|
|
}
|
|
|
|
|
|
2013-04-08 10:03:51 +00:00
|
|
|
static bool edbm_bevel_calc(wmOperator *op)
|
2013-04-01 10:18:01 +00:00
|
|
|
{
|
|
|
|
|
BevelData *opdata = op->customdata;
|
|
|
|
|
BMOperator bmop;
|
2018-05-16 13:11:50 +02:00
|
|
|
bool changed = false;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-03-06 09:04:31 -05:00
|
|
|
const float offset = get_bevel_offset(op);
|
2013-11-10 12:31:57 +00:00
|
|
|
const int offset_type = RNA_enum_get(op->ptr, "offset_type");
|
2020-06-22 22:25:55 -04:00
|
|
|
const int profile_type = RNA_enum_get(op->ptr, "profile_type");
|
2013-04-01 10:18:01 +00:00
|
|
|
const int segments = RNA_int_get(op->ptr, "segments");
|
2014-01-08 07:40:01 -05:00
|
|
|
const float profile = RNA_float_get(op->ptr, "profile");
|
2020-07-21 16:32:00 -04:00
|
|
|
const bool affect = RNA_enum_get(op->ptr, "affect");
|
2014-10-08 16:41:00 +02:00
|
|
|
const bool clamp_overlap = RNA_boolean_get(op->ptr, "clamp_overlap");
|
2020-01-07 13:22:15 +11:00
|
|
|
const int material_init = RNA_int_get(op->ptr, "material");
|
2015-07-05 09:53:17 -04:00
|
|
|
const bool loop_slide = RNA_boolean_get(op->ptr, "loop_slide");
|
2018-06-04 15:13:54 +05:30
|
|
|
const bool mark_seam = RNA_boolean_get(op->ptr, "mark_seam");
|
|
|
|
|
const bool mark_sharp = RNA_boolean_get(op->ptr, "mark_sharp");
|
2019-01-03 13:39:52 -05:00
|
|
|
const bool harden_normals = RNA_boolean_get(op->ptr, "harden_normals");
|
|
|
|
|
const int face_strength_mode = RNA_enum_get(op->ptr, "face_strength_mode");
|
2019-01-18 12:54:10 -05:00
|
|
|
const int miter_outer = RNA_enum_get(op->ptr, "miter_outer");
|
|
|
|
|
const int miter_inner = RNA_enum_get(op->ptr, "miter_inner");
|
|
|
|
|
const float spread = RNA_float_get(op->ptr, "spread");
|
2019-11-20 16:12:32 -05:00
|
|
|
const int vmesh_method = RNA_enum_get(op->ptr, "vmesh_method");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-05-16 13:11:50 +02:00
|
|
|
for (uint ob_index = 0; ob_index < opdata->ob_store_len; ob_index++) {
|
2020-01-07 13:22:15 +11:00
|
|
|
Object *obedit = opdata->ob_store[ob_index].ob;
|
|
|
|
|
BMEditMesh *em = BKE_editmesh_from_object(obedit);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-05-16 13:11:50 +02:00
|
|
|
/* revert to original mesh */
|
|
|
|
|
if (opdata->is_modal) {
|
|
|
|
|
EDBM_redo_state_restore(opdata->ob_store[ob_index].mesh_backup, em, false);
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-01-07 13:22:15 +11:00
|
|
|
const int material = CLAMPIS(material_init, -1, obedit->totcol - 1);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-01-07 13:22:15 +11:00
|
|
|
Mesh *me = obedit->data;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-01-06 18:12:00 -05:00
|
|
|
if (harden_normals && !(me->flag & ME_AUTOSMOOTH)) {
|
|
|
|
|
/* harden_normals only has a visible effect if autosmooth is on, so turn it on */
|
|
|
|
|
me->flag |= ME_AUTOSMOOTH;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-08-10 08:10:07 +10:00
|
|
|
EDBM_op_init(em,
|
|
|
|
|
&bmop,
|
|
|
|
|
op,
|
2020-07-21 16:32:00 -04:00
|
|
|
"bevel geom=%hev offset=%f segments=%i affect=%i offset_type=%i "
|
2020-06-22 22:25:55 -04:00
|
|
|
"profile_type=%i profile=%f clamp_overlap=%b material=%i loop_slide=%b "
|
|
|
|
|
"mark_seam=%b mark_sharp=%b harden_normals=%b face_strength_mode=%i "
|
|
|
|
|
"miter_outer=%i miter_inner=%i spread=%f smoothresh=%f custom_profile=%p "
|
|
|
|
|
"vmesh_method=%i",
|
2018-08-10 08:10:07 +10:00
|
|
|
BM_ELEM_SELECT,
|
|
|
|
|
offset,
|
|
|
|
|
segments,
|
2020-07-21 16:32:00 -04:00
|
|
|
affect,
|
2018-08-10 08:10:07 +10:00
|
|
|
offset_type,
|
2020-06-22 22:25:55 -04:00
|
|
|
profile_type,
|
2018-08-10 08:10:07 +10:00
|
|
|
profile,
|
2019-01-15 08:47:04 +11:00
|
|
|
clamp_overlap,
|
|
|
|
|
material,
|
|
|
|
|
loop_slide,
|
|
|
|
|
mark_seam,
|
|
|
|
|
mark_sharp,
|
|
|
|
|
harden_normals,
|
|
|
|
|
face_strength_mode,
|
2019-01-18 12:54:10 -05:00
|
|
|
miter_outer,
|
|
|
|
|
miter_inner,
|
|
|
|
|
spread,
|
2019-11-20 16:12:32 -05:00
|
|
|
me->smoothresh,
|
|
|
|
|
opdata->custom_profile,
|
|
|
|
|
vmesh_method);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-05-16 13:11:50 +02:00
|
|
|
BMO_op_exec(em->bm, &bmop);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-05-16 13:11:50 +02:00
|
|
|
if (offset != 0.0f) {
|
|
|
|
|
/* not essential, but we may have some loose geometry that
|
|
|
|
|
* won't get bevel'd and better not leave it selected */
|
|
|
|
|
EDBM_flag_disable_all(em, BM_ELEM_SELECT);
|
|
|
|
|
BMO_slot_buffer_hflag_enable(
|
|
|
|
|
em->bm, bmop.slots_out, "faces.out", BM_FACE, BM_ELEM_SELECT, true);
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-05-16 13:11:50 +02:00
|
|
|
/* no need to de-select existing geometry */
|
|
|
|
|
if (!EDBM_op_finish(em, &bmop, op, true)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-05-16 13:11:50 +02:00
|
|
|
EDBM_mesh_normals_update(em);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-01-07 22:11:19 +11:00
|
|
|
EDBM_update_generic(obedit->data, true, true);
|
2018-05-16 13:11:50 +02:00
|
|
|
changed = true;
|
|
|
|
|
}
|
|
|
|
|
return changed;
|
2013-04-01 10:18:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void edbm_bevel_exit(bContext *C, wmOperator *op)
|
|
|
|
|
{
|
|
|
|
|
BevelData *opdata = op->customdata;
|
2020-04-03 13:25:03 +02:00
|
|
|
ScrArea *area = CTX_wm_area(C);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-04-03 13:25:03 +02:00
|
|
|
if (area) {
|
|
|
|
|
ED_area_status_text(area, NULL);
|
2013-04-01 10:18:01 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-01-21 01:27:46 +11:00
|
|
|
for (uint ob_index = 0; ob_index < opdata->ob_store_len; ob_index++) {
|
|
|
|
|
Object *obedit = opdata->ob_store[ob_index].ob;
|
|
|
|
|
BMEditMesh *em = BKE_editmesh_from_object(obedit);
|
|
|
|
|
/* Without this, faces surrounded by selected edges/verts will be unselected. */
|
|
|
|
|
if ((em->selectmode & SCE_SELECT_FACE) == 0) {
|
|
|
|
|
EDBM_selectmode_flush(em);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-01 10:18:01 +00:00
|
|
|
if (opdata->is_modal) {
|
2013-04-02 10:48:11 +00:00
|
|
|
View3D *v3d = CTX_wm_view3d(C);
|
2020-03-06 16:56:42 +01:00
|
|
|
ARegion *region = CTX_wm_region(C);
|
2018-05-16 13:11:50 +02:00
|
|
|
for (uint ob_index = 0; ob_index < opdata->ob_store_len; ob_index++) {
|
|
|
|
|
EDBM_redo_state_free(&opdata->ob_store[ob_index].mesh_backup, NULL, false);
|
|
|
|
|
}
|
2020-03-06 16:56:42 +01:00
|
|
|
ED_region_draw_cb_exit(region->type, opdata->draw_handle_pixel);
|
2016-04-29 00:00:43 +10:00
|
|
|
if (v3d) {
|
2018-07-15 14:24:10 +02:00
|
|
|
v3d->gizmo_flag = opdata->gizmo_flag;
|
2016-04-29 00:00:43 +10:00
|
|
|
}
|
2013-06-24 22:41:37 +00:00
|
|
|
G.moving = 0;
|
2013-04-01 10:18:01 +00:00
|
|
|
}
|
2018-05-16 13:11:50 +02:00
|
|
|
MEM_SAFE_FREE(opdata->ob_store);
|
|
|
|
|
MEM_SAFE_FREE(op->customdata);
|
2013-04-01 10:18:01 +00:00
|
|
|
op->customdata = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2013-10-30 23:08:53 +00:00
|
|
|
static void edbm_bevel_cancel(bContext *C, wmOperator *op)
|
2013-04-01 10:18:01 +00:00
|
|
|
{
|
|
|
|
|
BevelData *opdata = op->customdata;
|
|
|
|
|
if (opdata->is_modal) {
|
2018-05-16 13:11:50 +02:00
|
|
|
for (uint ob_index = 0; ob_index < opdata->ob_store_len; ob_index++) {
|
2020-01-07 13:22:15 +11:00
|
|
|
Object *obedit = opdata->ob_store[ob_index].ob;
|
|
|
|
|
BMEditMesh *em = BKE_editmesh_from_object(obedit);
|
|
|
|
|
EDBM_redo_state_free(&opdata->ob_store[ob_index].mesh_backup, em, true);
|
2020-01-07 22:11:19 +11:00
|
|
|
EDBM_update_generic(obedit->data, false, true);
|
2013-04-01 10:18:01 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
2013-04-01 10:18:01 +00:00
|
|
|
edbm_bevel_exit(C, op);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-04-01 10:18:01 +00:00
|
|
|
/* need to force redisplay or we may still view the modified result */
|
|
|
|
|
ED_region_tag_redraw(CTX_wm_region(C));
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-20 16:12:32 -05:00
|
|
|
/* bevel! yay!! */
|
2013-04-01 10:18:01 +00:00
|
|
|
static int edbm_bevel_exec(bContext *C, wmOperator *op)
|
|
|
|
|
{
|
|
|
|
|
if (!edbm_bevel_init(C, op, false)) {
|
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!edbm_bevel_calc(op)) {
|
|
|
|
|
edbm_bevel_cancel(C, op);
|
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
edbm_bevel_exit(C, op);
|
|
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-13 09:14:13 -04:00
|
|
|
static void edbm_bevel_calc_initial_length(wmOperator *op, const wmEvent *event, bool mode_changed)
|
|
|
|
|
{
|
2020-11-03 13:57:20 -06:00
|
|
|
BevelData *opdata = op->customdata;
|
|
|
|
|
const float mlen[2] = {
|
|
|
|
|
opdata->mcenter[0] - event->mval[0],
|
|
|
|
|
opdata->mcenter[1] - event->mval[1],
|
|
|
|
|
};
|
|
|
|
|
float len = len_v2(mlen);
|
|
|
|
|
int vmode = opdata->value_mode;
|
2017-09-19 09:38:17 -04:00
|
|
|
if (mode_changed || opdata->initial_length[vmode] == -1.0f) {
|
2018-06-04 09:31:30 +02:00
|
|
|
/* If current value is not default start value, adjust len so that
|
2016-06-13 09:14:13 -04:00
|
|
|
* the scaling and offset in edbm_bevel_mouse_set_value will
|
|
|
|
|
* start at current value */
|
2020-11-03 13:57:20 -06:00
|
|
|
float value = (vmode == SEGMENTS_VALUE) ? opdata->segments :
|
|
|
|
|
RNA_float_get(op->ptr, value_rna_name[vmode]);
|
|
|
|
|
float sc = opdata->scale[vmode];
|
|
|
|
|
float st = value_start[vmode];
|
2016-06-13 09:14:13 -04:00
|
|
|
if (value != value_start[vmode]) {
|
|
|
|
|
len = (st + sc * (len - MVAL_PIXEL_MARGIN) - value) / sc;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
opdata->initial_length[opdata->value_mode] = len;
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-01 10:18:01 +00:00
|
|
|
static int edbm_bevel_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
|
|
|
|
{
|
|
|
|
|
RegionView3D *rv3d = CTX_wm_region_view3d(C);
|
|
|
|
|
|
|
|
|
|
if (!edbm_bevel_init(C, op, true)) {
|
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-03 13:57:20 -06:00
|
|
|
BevelData *opdata = op->customdata;
|
2013-04-01 10:18:01 +00:00
|
|
|
|
2020-01-21 02:52:20 +11:00
|
|
|
opdata->launch_event = WM_userdef_event_type_from_keymap_type(event->type);
|
|
|
|
|
|
2013-04-01 10:18:01 +00:00
|
|
|
/* initialize mouse values */
|
2020-11-03 13:57:20 -06:00
|
|
|
float center_3d[3];
|
2018-12-14 11:01:01 +11:00
|
|
|
if (!calculateTransformCenter(C, V3D_AROUND_CENTER_MEDIAN, center_3d, opdata->mcenter)) {
|
2013-04-01 10:18:01 +00:00
|
|
|
/* in this case the tool will likely do nothing,
|
|
|
|
|
* ideally this will never happen and should be checked for above */
|
|
|
|
|
opdata->mcenter[0] = opdata->mcenter[1] = 0;
|
|
|
|
|
}
|
2016-06-13 09:14:13 -04:00
|
|
|
|
|
|
|
|
/* for OFFSET_VALUE only, the scale is the size of a pixel under the mouse in 3d space */
|
|
|
|
|
opdata->scale[OFFSET_VALUE] = rv3d ? ED_view3d_pixel_size(rv3d, center_3d) : 1.0f;
|
2019-04-22 00:18:34 +10:00
|
|
|
/* since we are affecting untransformed object but seeing in transformed space,
|
|
|
|
|
* compensate for that */
|
2019-03-06 09:04:31 -05:00
|
|
|
opdata->scale[OFFSET_VALUE] /= opdata->max_obj_scale;
|
2013-04-01 10:18:01 +00:00
|
|
|
|
2017-11-23 20:14:31 +01:00
|
|
|
edbm_bevel_calc_initial_length(op, event, false);
|
|
|
|
|
|
2019-11-20 16:12:32 -05:00
|
|
|
edbm_bevel_update_status_text(C, op);
|
2013-04-01 10:18:01 +00:00
|
|
|
|
|
|
|
|
if (!edbm_bevel_calc(op)) {
|
|
|
|
|
edbm_bevel_cancel(C, op);
|
2019-02-15 09:15:32 -05:00
|
|
|
ED_workspace_status_text(C, NULL);
|
2013-04-01 10:18:01 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WM_event_add_modal_handler(C, op);
|
|
|
|
|
|
|
|
|
|
return OPERATOR_RUNNING_MODAL;
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-13 09:14:13 -04:00
|
|
|
static void edbm_bevel_mouse_set_value(wmOperator *op, const wmEvent *event)
|
2013-04-01 10:18:01 +00:00
|
|
|
{
|
|
|
|
|
BevelData *opdata = op->customdata;
|
2016-06-13 09:14:13 -04:00
|
|
|
int vmode = opdata->value_mode;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-11-03 13:57:20 -06:00
|
|
|
const float mdiff[2] = {
|
|
|
|
|
opdata->mcenter[0] - event->mval[0],
|
|
|
|
|
opdata->mcenter[1] - event->mval[1],
|
|
|
|
|
};
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-11-03 13:57:20 -06:00
|
|
|
float value = ((len_v2(mdiff) - MVAL_PIXEL_MARGIN) - opdata->initial_length[vmode]);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-06-13 09:14:13 -04:00
|
|
|
/* Scale according to value mode */
|
|
|
|
|
value = value_start[vmode] + value * opdata->scale[vmode];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-04-01 10:18:01 +00:00
|
|
|
/* Fake shift-transform... */
|
|
|
|
|
if (event->shift) {
|
2016-06-13 09:14:13 -04:00
|
|
|
if (opdata->shift_value[vmode] < 0.0f) {
|
|
|
|
|
opdata->shift_value[vmode] = (vmode == SEGMENTS_VALUE) ?
|
|
|
|
|
opdata->segments :
|
|
|
|
|
RNA_float_get(op->ptr, value_rna_name[vmode]);
|
2013-04-01 10:18:01 +00:00
|
|
|
}
|
2016-06-13 09:14:13 -04:00
|
|
|
value = (value - opdata->shift_value[vmode]) * 0.1f + opdata->shift_value[vmode];
|
2013-04-01 10:18:01 +00:00
|
|
|
}
|
2016-06-13 09:14:13 -04:00
|
|
|
else if (opdata->shift_value[vmode] >= 0.0f) {
|
|
|
|
|
opdata->shift_value[vmode] = -1.0f;
|
2014-08-25 16:31:47 +02:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-06-13 09:14:13 -04:00
|
|
|
/* clamp accordingto value mode, and store value back */
|
|
|
|
|
CLAMP(value, value_clamp_min[vmode], value_clamp_max[vmode]);
|
|
|
|
|
if (vmode == SEGMENTS_VALUE) {
|
|
|
|
|
opdata->segments = value;
|
|
|
|
|
RNA_int_set(op->ptr, "segments", (int)(value + 0.5f));
|
2013-04-01 10:18:01 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2016-06-13 09:14:13 -04:00
|
|
|
RNA_float_set(op->ptr, value_rna_name[vmode], value);
|
2013-04-01 10:18:01 +00:00
|
|
|
}
|
2016-06-13 09:14:13 -04:00
|
|
|
}
|
2013-04-01 10:18:01 +00:00
|
|
|
|
2016-06-13 09:14:13 -04:00
|
|
|
static void edbm_bevel_numinput_set_value(wmOperator *op)
|
|
|
|
|
{
|
|
|
|
|
BevelData *opdata = op->customdata;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-11-03 13:57:20 -06:00
|
|
|
int vmode = opdata->value_mode;
|
|
|
|
|
float value = (vmode == SEGMENTS_VALUE) ? opdata->segments :
|
|
|
|
|
RNA_float_get(op->ptr, value_rna_name[vmode]);
|
2016-06-13 09:14:13 -04:00
|
|
|
applyNumInput(&opdata->num_input[vmode], &value);
|
|
|
|
|
CLAMP(value, value_clamp_min[vmode], value_clamp_max[vmode]);
|
|
|
|
|
if (vmode == SEGMENTS_VALUE) {
|
|
|
|
|
opdata->segments = value;
|
|
|
|
|
RNA_int_set(op->ptr, "segments", (int)value);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
RNA_float_set(op->ptr, value_rna_name[vmode], value);
|
|
|
|
|
}
|
2013-04-01 10:18:01 +00:00
|
|
|
}
|
|
|
|
|
|
2019-02-10 16:08:25 -05:00
|
|
|
wmKeyMap *bevel_modal_keymap(wmKeyConfig *keyconf)
|
|
|
|
|
{
|
|
|
|
|
static const EnumPropertyItem modal_items[] = {
|
|
|
|
|
{BEV_MODAL_CANCEL, "CANCEL", 0, "Cancel", "Cancel bevel"},
|
|
|
|
|
{BEV_MODAL_CONFIRM, "CONFIRM", 0, "Confirm", "Confirm bevel"},
|
2020-10-24 11:42:17 -07:00
|
|
|
{BEV_MODAL_VALUE_OFFSET, "VALUE_OFFSET", 0, "Change Offset", "Value changes offset"},
|
|
|
|
|
{BEV_MODAL_VALUE_PROFILE, "VALUE_PROFILE", 0, "Change Profile", "Value changes profile"},
|
|
|
|
|
{BEV_MODAL_VALUE_SEGMENTS, "VALUE_SEGMENTS", 0, "Change Segments", "Value changes segments"},
|
|
|
|
|
{BEV_MODAL_SEGMENTS_UP, "SEGMENTS_UP", 0, "Increase Segments", "Increase segments"},
|
|
|
|
|
{BEV_MODAL_SEGMENTS_DOWN, "SEGMENTS_DOWN", 0, "Decrease Segments", "Decrease segments"},
|
2019-02-10 16:08:25 -05:00
|
|
|
{BEV_MODAL_OFFSET_MODE_CHANGE,
|
|
|
|
|
"OFFSET_MODE_CHANGE",
|
|
|
|
|
0,
|
2020-10-24 11:42:17 -07:00
|
|
|
"Change Offset Mode",
|
2019-03-15 08:53:22 +11:00
|
|
|
"Cycle through offset modes"},
|
2019-02-10 16:08:25 -05:00
|
|
|
{BEV_MODAL_CLAMP_OVERLAP_TOGGLE,
|
|
|
|
|
"CLAMP_OVERLAP_TOGGLE",
|
|
|
|
|
0,
|
2020-10-24 11:42:17 -07:00
|
|
|
"Toggle Clamp Overlap",
|
2019-03-15 08:53:22 +11:00
|
|
|
"Toggle clamp overlap flag"},
|
2020-07-21 16:32:00 -04:00
|
|
|
{BEV_MODAL_AFFECT_CHANGE,
|
|
|
|
|
"AFFECT_CHANGE",
|
2019-02-10 16:08:25 -05:00
|
|
|
0,
|
2020-10-24 11:42:17 -07:00
|
|
|
"Change Affect Type",
|
2020-07-21 16:32:00 -04:00
|
|
|
"Change which geometry type the operation affects, edges or vertices"},
|
2019-02-10 16:08:25 -05:00
|
|
|
{BEV_MODAL_HARDEN_NORMALS_TOGGLE,
|
|
|
|
|
"HARDEN_NORMALS_TOGGLE",
|
|
|
|
|
0,
|
2020-10-24 11:42:17 -07:00
|
|
|
"Toggle Harden Normals",
|
2019-03-15 08:53:22 +11:00
|
|
|
"Toggle harden normals flag"},
|
2019-02-10 16:08:25 -05:00
|
|
|
{BEV_MODAL_MARK_SEAM_TOGGLE,
|
|
|
|
|
"MARK_SEAM_TOGGLE",
|
|
|
|
|
0,
|
2020-10-24 11:42:17 -07:00
|
|
|
"Toggle Mark Seam",
|
2019-03-15 08:53:22 +11:00
|
|
|
"Toggle mark seam flag"},
|
2019-02-10 16:08:25 -05:00
|
|
|
{BEV_MODAL_MARK_SHARP_TOGGLE,
|
|
|
|
|
"MARK_SHARP_TOGGLE",
|
|
|
|
|
0,
|
2020-10-24 11:42:17 -07:00
|
|
|
"Toggle Mark Sharp",
|
2019-03-15 08:53:22 +11:00
|
|
|
"Toggle mark sharp flag"},
|
2019-02-10 16:08:25 -05:00
|
|
|
{BEV_MODAL_OUTER_MITER_CHANGE,
|
|
|
|
|
"OUTER_MITER_CHANGE",
|
|
|
|
|
0,
|
2020-10-24 11:42:17 -07:00
|
|
|
"Change Outer Miter",
|
2019-03-15 08:53:22 +11:00
|
|
|
"Cycle through outer miter kinds"},
|
2019-02-10 16:08:25 -05:00
|
|
|
{BEV_MODAL_INNER_MITER_CHANGE,
|
|
|
|
|
"INNER_MITER_CHANGE",
|
|
|
|
|
0,
|
2020-10-24 11:42:17 -07:00
|
|
|
"Change Inner Miter",
|
2019-03-15 08:53:22 +11:00
|
|
|
"Cycle through inner miter kinds"},
|
2020-06-22 22:25:55 -04:00
|
|
|
{BEV_MODAL_PROFILE_TYPE_CHANGE, "PROFILE_TYPE_CHANGE", 0, "Cycle through profile types", ""},
|
2019-11-20 16:12:32 -05:00
|
|
|
{BEV_MODAL_VERTEX_MESH_CHANGE,
|
|
|
|
|
"VERTEX_MESH_CHANGE",
|
|
|
|
|
0,
|
2020-10-24 11:42:17 -07:00
|
|
|
"Change Intersection Method",
|
2019-11-20 16:12:32 -05:00
|
|
|
"Cycle through intersection methods"},
|
2019-02-10 16:08:25 -05:00
|
|
|
{0, NULL, 0, NULL, NULL},
|
|
|
|
|
};
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-03-27 10:58:00 +11:00
|
|
|
wmKeyMap *keymap = WM_modalkeymap_find(keyconf, "Bevel Modal Map");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-11-20 16:12:32 -05:00
|
|
|
/* This function is called for each spacetype, only needs to add map once */
|
2019-04-22 09:19:45 +10:00
|
|
|
if (keymap && keymap->modal_items) {
|
2019-02-10 16:08:25 -05:00
|
|
|
return NULL;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-03-27 10:58:00 +11:00
|
|
|
keymap = WM_modalkeymap_ensure(keyconf, "Bevel Modal Map", modal_items);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-02-10 16:08:25 -05:00
|
|
|
WM_modalkeymap_assign(keymap, "MESH_OT_bevel");
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-02-10 16:08:25 -05:00
|
|
|
return keymap;
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-01 10:18:01 +00:00
|
|
|
static int edbm_bevel_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
|
|
|
|
{
|
|
|
|
|
BevelData *opdata = op->customdata;
|
2016-06-13 09:14:13 -04:00
|
|
|
const bool has_numinput = hasNumInput(&opdata->num_input[opdata->value_mode]);
|
2019-02-10 16:08:25 -05:00
|
|
|
bool handled = false;
|
2019-02-16 09:45:55 -05:00
|
|
|
short etype = event->type;
|
|
|
|
|
short eval = event->val;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-02-16 09:45:55 -05:00
|
|
|
/* When activated from toolbar, need to convert leftmouse release to confirm */
|
2020-01-21 02:52:20 +11:00
|
|
|
if (ELEM(etype, LEFTMOUSE, opdata->launch_event) && (eval == KM_RELEASE) &&
|
|
|
|
|
RNA_boolean_get(op->ptr, "release_confirm")) {
|
2019-02-16 09:45:55 -05:00
|
|
|
etype = EVT_MODAL_MAP;
|
|
|
|
|
eval = BEV_MODAL_CONFIRM;
|
|
|
|
|
}
|
2014-08-25 16:31:47 +02:00
|
|
|
/* Modal numinput active, try to handle numeric inputs first... */
|
2019-03-06 09:04:31 -05:00
|
|
|
if (etype != EVT_MODAL_MAP && eval == KM_PRESS && has_numinput &&
|
2019-03-12 08:21:13 +11:00
|
|
|
handleNumInput(C, &opdata->num_input[opdata->value_mode], event)) {
|
2016-06-13 09:14:13 -04:00
|
|
|
edbm_bevel_numinput_set_value(op);
|
2014-08-25 16:31:47 +02:00
|
|
|
edbm_bevel_calc(op);
|
2019-11-20 16:12:32 -05:00
|
|
|
edbm_bevel_update_status_text(C, op);
|
2014-08-25 16:31:47 +02:00
|
|
|
return OPERATOR_RUNNING_MODAL;
|
2013-04-01 10:18:01 +00:00
|
|
|
}
|
2020-07-03 15:19:52 +02:00
|
|
|
if (etype == MOUSEMOVE) {
|
2019-02-10 16:08:25 -05:00
|
|
|
if (!has_numinput) {
|
|
|
|
|
edbm_bevel_mouse_set_value(op, event);
|
|
|
|
|
edbm_bevel_calc(op);
|
2019-11-20 16:12:32 -05:00
|
|
|
edbm_bevel_update_status_text(C, op);
|
2019-02-10 16:08:25 -05:00
|
|
|
handled = true;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2019-02-10 16:08:25 -05:00
|
|
|
}
|
2019-02-16 09:45:55 -05:00
|
|
|
else if (etype == MOUSEPAN) {
|
2019-02-10 16:08:25 -05:00
|
|
|
float delta = 0.02f * (event->y - event->prevy);
|
2019-04-22 09:19:45 +10:00
|
|
|
if (opdata->segments >= 1 && opdata->segments + delta < 1) {
|
2019-02-10 16:08:25 -05:00
|
|
|
opdata->segments = 1;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
|
|
|
|
else {
|
2019-02-10 16:08:25 -05:00
|
|
|
opdata->segments += delta;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2019-02-10 16:08:25 -05:00
|
|
|
RNA_int_set(op->ptr, "segments", (int)opdata->segments);
|
|
|
|
|
edbm_bevel_calc(op);
|
2019-11-20 16:12:32 -05:00
|
|
|
edbm_bevel_update_status_text(C, op);
|
2019-02-10 16:08:25 -05:00
|
|
|
handled = true;
|
|
|
|
|
}
|
2019-02-16 09:45:55 -05:00
|
|
|
else if (etype == EVT_MODAL_MAP) {
|
|
|
|
|
switch (eval) {
|
2019-02-10 16:08:25 -05:00
|
|
|
case BEV_MODAL_CANCEL:
|
Support units in modal numinput
Summary:
This completly changes the way modal numinput is handled. Now, edited expression is a string, which then gets unit- and py-evaluated to get a float value.
We gain many power and flexibility, but lose a few "shortcuts" like '-' to negate, or '/' to inverse (if they are really needed, we still can add them with modifiers, like e.g. ctrl-/ or so).
Features:
- units (cm, ", deg, etc.).
- basic operations from python/BKE_unit (+, *, **, etc.), and math constants and functions (pi, sin, etc.).
- you can navigate in edited value (left/right key, ctrl to move by block) and insert/delete chars, e.g. to fix a typo without having to rewrite everything.
- you can go to next/previous value with (ctrl-)TAB key.
- As before, hitting backspace after having deleted all leading chars will first reset the edited value to init state, and on second press, the whole "modal numinput" editing will be cancelled, going back to usual transform with mouse.
Notes:
- Did not touch to how values are shown in header when modal numinput is not enabled (would do that in another commit), so this is still quite inconsistent.
- Added back radian support in BKE_unit.
- Added arcminute/arcsecond to BKE_unit.
(those unit changes affect all angle UI controls, btw, so you can now enter radians or longitude/latitude values when in degrees units).
Related to T37600.
Reviewers: brecht, campbellbarton, carter2422
Reviewed By: brecht, campbellbarton, carter2422
Thanks everybody!
Differential Revision: http://developer.blender.org/D61
2013-12-21 17:11:43 +01:00
|
|
|
edbm_bevel_cancel(C, op);
|
2019-02-15 09:15:32 -05:00
|
|
|
ED_workspace_status_text(C, NULL);
|
Support units in modal numinput
Summary:
This completly changes the way modal numinput is handled. Now, edited expression is a string, which then gets unit- and py-evaluated to get a float value.
We gain many power and flexibility, but lose a few "shortcuts" like '-' to negate, or '/' to inverse (if they are really needed, we still can add them with modifiers, like e.g. ctrl-/ or so).
Features:
- units (cm, ", deg, etc.).
- basic operations from python/BKE_unit (+, *, **, etc.), and math constants and functions (pi, sin, etc.).
- you can navigate in edited value (left/right key, ctrl to move by block) and insert/delete chars, e.g. to fix a typo without having to rewrite everything.
- you can go to next/previous value with (ctrl-)TAB key.
- As before, hitting backspace after having deleted all leading chars will first reset the edited value to init state, and on second press, the whole "modal numinput" editing will be cancelled, going back to usual transform with mouse.
Notes:
- Did not touch to how values are shown in header when modal numinput is not enabled (would do that in another commit), so this is still quite inconsistent.
- Added back radian support in BKE_unit.
- Added arcminute/arcsecond to BKE_unit.
(those unit changes affect all angle UI controls, btw, so you can now enter radians or longitude/latitude values when in degrees units).
Related to T37600.
Reviewers: brecht, campbellbarton, carter2422
Reviewed By: brecht, campbellbarton, carter2422
Thanks everybody!
Differential Revision: http://developer.blender.org/D61
2013-12-21 17:11:43 +01:00
|
|
|
return OPERATOR_CANCELLED;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-02-10 16:08:25 -05:00
|
|
|
case BEV_MODAL_CONFIRM:
|
2019-02-16 09:45:55 -05:00
|
|
|
edbm_bevel_calc(op);
|
|
|
|
|
edbm_bevel_exit(C, op);
|
|
|
|
|
ED_workspace_status_text(C, NULL);
|
|
|
|
|
return OPERATOR_FINISHED;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-02-10 16:08:25 -05:00
|
|
|
case BEV_MODAL_SEGMENTS_UP:
|
2016-05-08 18:14:44 +02:00
|
|
|
opdata->segments = opdata->segments + 1;
|
|
|
|
|
RNA_int_set(op->ptr, "segments", (int)opdata->segments);
|
2013-04-01 10:18:01 +00:00
|
|
|
edbm_bevel_calc(op);
|
2019-11-20 16:12:32 -05:00
|
|
|
edbm_bevel_update_status_text(C, op);
|
Support units in modal numinput
Summary:
This completly changes the way modal numinput is handled. Now, edited expression is a string, which then gets unit- and py-evaluated to get a float value.
We gain many power and flexibility, but lose a few "shortcuts" like '-' to negate, or '/' to inverse (if they are really needed, we still can add them with modifiers, like e.g. ctrl-/ or so).
Features:
- units (cm, ", deg, etc.).
- basic operations from python/BKE_unit (+, *, **, etc.), and math constants and functions (pi, sin, etc.).
- you can navigate in edited value (left/right key, ctrl to move by block) and insert/delete chars, e.g. to fix a typo without having to rewrite everything.
- you can go to next/previous value with (ctrl-)TAB key.
- As before, hitting backspace after having deleted all leading chars will first reset the edited value to init state, and on second press, the whole "modal numinput" editing will be cancelled, going back to usual transform with mouse.
Notes:
- Did not touch to how values are shown in header when modal numinput is not enabled (would do that in another commit), so this is still quite inconsistent.
- Added back radian support in BKE_unit.
- Added arcminute/arcsecond to BKE_unit.
(those unit changes affect all angle UI controls, btw, so you can now enter radians or longitude/latitude values when in degrees units).
Related to T37600.
Reviewers: brecht, campbellbarton, carter2422
Reviewed By: brecht, campbellbarton, carter2422
Thanks everybody!
Differential Revision: http://developer.blender.org/D61
2013-12-21 17:11:43 +01:00
|
|
|
handled = true;
|
2013-04-01 10:18:01 +00:00
|
|
|
break;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-02-10 16:08:25 -05:00
|
|
|
case BEV_MODAL_SEGMENTS_DOWN:
|
2016-05-08 18:14:44 +02:00
|
|
|
opdata->segments = max_ff(opdata->segments - 1, 1);
|
|
|
|
|
RNA_int_set(op->ptr, "segments", (int)opdata->segments);
|
Support units in modal numinput
Summary:
This completly changes the way modal numinput is handled. Now, edited expression is a string, which then gets unit- and py-evaluated to get a float value.
We gain many power and flexibility, but lose a few "shortcuts" like '-' to negate, or '/' to inverse (if they are really needed, we still can add them with modifiers, like e.g. ctrl-/ or so).
Features:
- units (cm, ", deg, etc.).
- basic operations from python/BKE_unit (+, *, **, etc.), and math constants and functions (pi, sin, etc.).
- you can navigate in edited value (left/right key, ctrl to move by block) and insert/delete chars, e.g. to fix a typo without having to rewrite everything.
- you can go to next/previous value with (ctrl-)TAB key.
- As before, hitting backspace after having deleted all leading chars will first reset the edited value to init state, and on second press, the whole "modal numinput" editing will be cancelled, going back to usual transform with mouse.
Notes:
- Did not touch to how values are shown in header when modal numinput is not enabled (would do that in another commit), so this is still quite inconsistent.
- Added back radian support in BKE_unit.
- Added arcminute/arcsecond to BKE_unit.
(those unit changes affect all angle UI controls, btw, so you can now enter radians or longitude/latitude values when in degrees units).
Related to T37600.
Reviewers: brecht, campbellbarton, carter2422
Reviewed By: brecht, campbellbarton, carter2422
Thanks everybody!
Differential Revision: http://developer.blender.org/D61
2013-12-21 17:11:43 +01:00
|
|
|
edbm_bevel_calc(op);
|
2019-11-20 16:12:32 -05:00
|
|
|
edbm_bevel_update_status_text(C, op);
|
Support units in modal numinput
Summary:
This completly changes the way modal numinput is handled. Now, edited expression is a string, which then gets unit- and py-evaluated to get a float value.
We gain many power and flexibility, but lose a few "shortcuts" like '-' to negate, or '/' to inverse (if they are really needed, we still can add them with modifiers, like e.g. ctrl-/ or so).
Features:
- units (cm, ", deg, etc.).
- basic operations from python/BKE_unit (+, *, **, etc.), and math constants and functions (pi, sin, etc.).
- you can navigate in edited value (left/right key, ctrl to move by block) and insert/delete chars, e.g. to fix a typo without having to rewrite everything.
- you can go to next/previous value with (ctrl-)TAB key.
- As before, hitting backspace after having deleted all leading chars will first reset the edited value to init state, and on second press, the whole "modal numinput" editing will be cancelled, going back to usual transform with mouse.
Notes:
- Did not touch to how values are shown in header when modal numinput is not enabled (would do that in another commit), so this is still quite inconsistent.
- Added back radian support in BKE_unit.
- Added arcminute/arcsecond to BKE_unit.
(those unit changes affect all angle UI controls, btw, so you can now enter radians or longitude/latitude values when in degrees units).
Related to T37600.
Reviewers: brecht, campbellbarton, carter2422
Reviewed By: brecht, campbellbarton, carter2422
Thanks everybody!
Differential Revision: http://developer.blender.org/D61
2013-12-21 17:11:43 +01:00
|
|
|
handled = true;
|
2013-04-01 10:18:01 +00:00
|
|
|
break;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-02-10 16:08:25 -05:00
|
|
|
case BEV_MODAL_OFFSET_MODE_CHANGE: {
|
|
|
|
|
int type = RNA_enum_get(op->ptr, "offset_type");
|
2014-08-25 16:31:47 +02:00
|
|
|
type++;
|
|
|
|
|
if (type > BEVEL_AMT_PERCENT) {
|
|
|
|
|
type = BEVEL_AMT_OFFSET;
|
|
|
|
|
}
|
2019-04-22 09:19:45 +10:00
|
|
|
if (opdata->value_mode == OFFSET_VALUE && type == BEVEL_AMT_PERCENT) {
|
2016-06-13 09:14:13 -04:00
|
|
|
opdata->value_mode = OFFSET_VALUE_PERCENT;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
|
|
|
|
else if (opdata->value_mode == OFFSET_VALUE_PERCENT && type != BEVEL_AMT_PERCENT) {
|
2016-06-13 09:14:13 -04:00
|
|
|
opdata->value_mode = OFFSET_VALUE;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2019-02-10 16:08:25 -05:00
|
|
|
RNA_enum_set(op->ptr, "offset_type", type);
|
2019-04-22 09:19:45 +10:00
|
|
|
if (opdata->initial_length[opdata->value_mode] == -1.0f) {
|
2017-09-19 09:38:17 -04:00
|
|
|
edbm_bevel_calc_initial_length(op, event, true);
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2014-08-25 16:31:47 +02:00
|
|
|
}
|
2016-06-13 09:14:13 -04:00
|
|
|
/* Update offset accordingly to new offset_type. */
|
|
|
|
|
if (!has_numinput &&
|
|
|
|
|
(opdata->value_mode == OFFSET_VALUE || opdata->value_mode == OFFSET_VALUE_PERCENT)) {
|
|
|
|
|
edbm_bevel_mouse_set_value(op, event);
|
2018-06-04 09:31:30 +02:00
|
|
|
}
|
Support units in modal numinput
Summary:
This completly changes the way modal numinput is handled. Now, edited expression is a string, which then gets unit- and py-evaluated to get a float value.
We gain many power and flexibility, but lose a few "shortcuts" like '-' to negate, or '/' to inverse (if they are really needed, we still can add them with modifiers, like e.g. ctrl-/ or so).
Features:
- units (cm, ", deg, etc.).
- basic operations from python/BKE_unit (+, *, **, etc.), and math constants and functions (pi, sin, etc.).
- you can navigate in edited value (left/right key, ctrl to move by block) and insert/delete chars, e.g. to fix a typo without having to rewrite everything.
- you can go to next/previous value with (ctrl-)TAB key.
- As before, hitting backspace after having deleted all leading chars will first reset the edited value to init state, and on second press, the whole "modal numinput" editing will be cancelled, going back to usual transform with mouse.
Notes:
- Did not touch to how values are shown in header when modal numinput is not enabled (would do that in another commit), so this is still quite inconsistent.
- Added back radian support in BKE_unit.
- Added arcminute/arcsecond to BKE_unit.
(those unit changes affect all angle UI controls, btw, so you can now enter radians or longitude/latitude values when in degrees units).
Related to T37600.
Reviewers: brecht, campbellbarton, carter2422
Reviewed By: brecht, campbellbarton, carter2422
Thanks everybody!
Differential Revision: http://developer.blender.org/D61
2013-12-21 17:11:43 +01:00
|
|
|
edbm_bevel_calc(op);
|
2019-11-20 16:12:32 -05:00
|
|
|
edbm_bevel_update_status_text(C, op);
|
2014-08-25 16:31:47 +02:00
|
|
|
handled = true;
|
|
|
|
|
break;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-02-10 16:08:25 -05:00
|
|
|
case BEV_MODAL_CLAMP_OVERLAP_TOGGLE: {
|
|
|
|
|
bool clamp_overlap = RNA_boolean_get(op->ptr, "clamp_overlap");
|
|
|
|
|
RNA_boolean_set(op->ptr, "clamp_overlap", !clamp_overlap);
|
|
|
|
|
edbm_bevel_calc(op);
|
2019-11-20 16:12:32 -05:00
|
|
|
edbm_bevel_update_status_text(C, op);
|
2019-02-10 16:08:25 -05:00
|
|
|
handled = true;
|
2016-06-06 13:15:13 -04:00
|
|
|
break;
|
2016-06-13 09:14:13 -04:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-02-10 16:08:25 -05:00
|
|
|
case BEV_MODAL_VALUE_OFFSET:
|
|
|
|
|
opdata->value_mode = OFFSET_VALUE;
|
2016-06-13 09:14:13 -04:00
|
|
|
edbm_bevel_calc_initial_length(op, event, true);
|
|
|
|
|
break;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-02-10 16:08:25 -05:00
|
|
|
case BEV_MODAL_VALUE_PROFILE:
|
|
|
|
|
opdata->value_mode = PROFILE_VALUE;
|
2016-06-13 09:14:13 -04:00
|
|
|
edbm_bevel_calc_initial_length(op, event, true);
|
2016-06-06 13:15:13 -04:00
|
|
|
break;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-02-10 16:08:25 -05:00
|
|
|
case BEV_MODAL_VALUE_SEGMENTS:
|
|
|
|
|
opdata->value_mode = SEGMENTS_VALUE;
|
|
|
|
|
edbm_bevel_calc_initial_length(op, event, true);
|
2015-07-04 10:14:47 -04:00
|
|
|
break;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-07-21 16:32:00 -04:00
|
|
|
case BEV_MODAL_AFFECT_CHANGE: {
|
|
|
|
|
int affect_type = RNA_enum_get(op->ptr, "affect");
|
|
|
|
|
affect_type++;
|
|
|
|
|
if (affect_type > BEVEL_AFFECT_EDGES) {
|
|
|
|
|
affect_type = BEVEL_AFFECT_VERTICES;
|
|
|
|
|
}
|
|
|
|
|
RNA_enum_set(op->ptr, "affect", affect_type);
|
2019-02-10 16:08:25 -05:00
|
|
|
edbm_bevel_calc(op);
|
2019-11-20 16:12:32 -05:00
|
|
|
edbm_bevel_update_status_text(C, op);
|
2019-02-10 16:08:25 -05:00
|
|
|
handled = true;
|
2018-06-04 15:13:54 +05:30
|
|
|
break;
|
2019-02-10 16:08:25 -05:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-02-10 16:08:25 -05:00
|
|
|
case BEV_MODAL_MARK_SEAM_TOGGLE: {
|
2018-06-04 15:13:54 +05:30
|
|
|
bool mark_seam = RNA_boolean_get(op->ptr, "mark_seam");
|
|
|
|
|
RNA_boolean_set(op->ptr, "mark_seam", !mark_seam);
|
|
|
|
|
edbm_bevel_calc(op);
|
2019-11-20 16:12:32 -05:00
|
|
|
edbm_bevel_update_status_text(C, op);
|
2018-06-04 15:13:54 +05:30
|
|
|
handled = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-02-10 16:08:25 -05:00
|
|
|
case BEV_MODAL_MARK_SHARP_TOGGLE: {
|
2018-06-04 15:13:54 +05:30
|
|
|
bool mark_sharp = RNA_boolean_get(op->ptr, "mark_sharp");
|
|
|
|
|
RNA_boolean_set(op->ptr, "mark_sharp", !mark_sharp);
|
|
|
|
|
edbm_bevel_calc(op);
|
2019-11-20 16:12:32 -05:00
|
|
|
edbm_bevel_update_status_text(C, op);
|
2018-06-04 15:13:54 +05:30
|
|
|
handled = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-02-10 16:08:25 -05:00
|
|
|
case BEV_MODAL_INNER_MITER_CHANGE: {
|
|
|
|
|
int miter_inner = RNA_enum_get(op->ptr, "miter_inner");
|
|
|
|
|
miter_inner++;
|
2019-04-22 09:19:45 +10:00
|
|
|
if (miter_inner == BEVEL_MITER_PATCH) {
|
2019-02-10 16:08:25 -05:00
|
|
|
miter_inner++; /* no patch option for inner miter */
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
|
|
|
|
if (miter_inner > BEVEL_MITER_ARC) {
|
2019-02-10 16:08:25 -05:00
|
|
|
miter_inner = BEVEL_MITER_SHARP;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2019-02-10 16:08:25 -05:00
|
|
|
RNA_enum_set(op->ptr, "miter_inner", miter_inner);
|
|
|
|
|
edbm_bevel_calc(op);
|
2019-11-20 16:12:32 -05:00
|
|
|
edbm_bevel_update_status_text(C, op);
|
2019-02-10 16:08:25 -05:00
|
|
|
handled = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-02-10 16:08:25 -05:00
|
|
|
case BEV_MODAL_OUTER_MITER_CHANGE: {
|
|
|
|
|
int miter_outer = RNA_enum_get(op->ptr, "miter_outer");
|
|
|
|
|
miter_outer++;
|
2019-04-22 09:19:45 +10:00
|
|
|
if (miter_outer > BEVEL_MITER_ARC) {
|
2019-02-10 16:08:25 -05:00
|
|
|
miter_outer = BEVEL_MITER_SHARP;
|
2019-04-22 09:19:45 +10:00
|
|
|
}
|
2019-02-10 16:08:25 -05:00
|
|
|
RNA_enum_set(op->ptr, "miter_outer", miter_outer);
|
|
|
|
|
edbm_bevel_calc(op);
|
2019-11-20 16:12:32 -05:00
|
|
|
edbm_bevel_update_status_text(C, op);
|
2019-02-10 16:08:25 -05:00
|
|
|
handled = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-02-10 16:08:25 -05:00
|
|
|
case BEV_MODAL_HARDEN_NORMALS_TOGGLE: {
|
|
|
|
|
bool harden_normals = RNA_boolean_get(op->ptr, "harden_normals");
|
|
|
|
|
RNA_boolean_set(op->ptr, "harden_normals", !harden_normals);
|
|
|
|
|
edbm_bevel_calc(op);
|
2019-11-20 16:12:32 -05:00
|
|
|
edbm_bevel_update_status_text(C, op);
|
|
|
|
|
handled = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-22 22:25:55 -04:00
|
|
|
case BEV_MODAL_PROFILE_TYPE_CHANGE: {
|
|
|
|
|
int profile_type = RNA_enum_get(op->ptr, "profile_type");
|
|
|
|
|
profile_type++;
|
|
|
|
|
if (profile_type > BEVEL_PROFILE_CUSTOM) {
|
|
|
|
|
profile_type = BEVEL_PROFILE_SUPERELLIPSE;
|
|
|
|
|
}
|
|
|
|
|
RNA_enum_set(op->ptr, "profile_type", profile_type);
|
2019-11-20 16:12:32 -05:00
|
|
|
edbm_bevel_calc(op);
|
|
|
|
|
edbm_bevel_update_status_text(C, op);
|
|
|
|
|
handled = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case BEV_MODAL_VERTEX_MESH_CHANGE: {
|
|
|
|
|
int vmesh_method = RNA_enum_get(op->ptr, "vmesh_method");
|
|
|
|
|
vmesh_method++;
|
|
|
|
|
if (vmesh_method > BEVEL_VMESH_CUTOFF) {
|
|
|
|
|
vmesh_method = BEVEL_VMESH_ADJ;
|
|
|
|
|
}
|
|
|
|
|
RNA_enum_set(op->ptr, "vmesh_method", vmesh_method);
|
|
|
|
|
edbm_bevel_calc(op);
|
|
|
|
|
edbm_bevel_update_status_text(C, op);
|
2019-02-10 16:08:25 -05:00
|
|
|
handled = true;
|
|
|
|
|
break;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
}
|
2019-02-10 16:08:25 -05:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-02-10 16:08:25 -05:00
|
|
|
/* Modal numinput inactive, try to handle numeric inputs last... */
|
2019-02-16 09:45:55 -05:00
|
|
|
if (!handled && eval == KM_PRESS &&
|
|
|
|
|
handleNumInput(C, &opdata->num_input[opdata->value_mode], event)) {
|
2019-02-10 16:08:25 -05:00
|
|
|
edbm_bevel_numinput_set_value(op);
|
|
|
|
|
edbm_bevel_calc(op);
|
2019-11-20 16:12:32 -05:00
|
|
|
edbm_bevel_update_status_text(C, op);
|
2019-02-10 16:08:25 -05:00
|
|
|
return OPERATOR_RUNNING_MODAL;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-04-01 10:18:01 +00:00
|
|
|
return OPERATOR_RUNNING_MODAL;
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-20 16:12:32 -05:00
|
|
|
static void edbm_bevel_ui(bContext *C, wmOperator *op)
|
|
|
|
|
{
|
|
|
|
|
uiLayout *layout = op->layout;
|
2020-07-21 11:13:18 -04:00
|
|
|
uiLayout *col, *row;
|
2019-11-20 16:12:32 -05:00
|
|
|
PointerRNA ptr, toolsettings_ptr;
|
|
|
|
|
|
|
|
|
|
RNA_pointer_create(NULL, op->type->srna, op->properties, &ptr);
|
|
|
|
|
|
2020-06-22 22:25:55 -04:00
|
|
|
int profile_type = RNA_enum_get(&ptr, "profile_type");
|
2020-07-21 11:13:18 -04:00
|
|
|
int offset_type = RNA_enum_get(&ptr, "offset_type");
|
2020-07-21 16:32:00 -04:00
|
|
|
bool affect_type = RNA_enum_get(&ptr, "affect");
|
2020-07-21 11:13:18 -04:00
|
|
|
|
|
|
|
|
uiLayoutSetPropSep(layout, true);
|
|
|
|
|
uiLayoutSetPropDecorate(layout, false);
|
2020-06-22 22:25:55 -04:00
|
|
|
|
2020-07-21 16:32:00 -04:00
|
|
|
row = uiLayoutRow(layout, false);
|
|
|
|
|
uiItemR(row, &ptr, "affect", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
|
|
|
|
|
|
|
|
|
|
uiItemS(layout);
|
|
|
|
|
|
2020-07-21 11:13:18 -04:00
|
|
|
uiItemR(layout, &ptr, "offset_type", 0, NULL, ICON_NONE);
|
|
|
|
|
|
|
|
|
|
if (offset_type == BEVEL_AMT_PERCENT) {
|
2019-11-20 16:12:32 -05:00
|
|
|
uiItemR(layout, &ptr, "offset_pct", 0, NULL, ICON_NONE);
|
|
|
|
|
}
|
|
|
|
|
else {
|
2020-07-21 11:13:18 -04:00
|
|
|
uiItemR(layout, &ptr, "offset", 0, NULL, ICON_NONE);
|
2019-11-20 16:12:32 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uiItemR(layout, &ptr, "segments", 0, NULL, ICON_NONE);
|
2020-06-22 22:25:55 -04:00
|
|
|
if (ELEM(profile_type, BEVEL_PROFILE_SUPERELLIPSE, BEVEL_PROFILE_CUSTOM)) {
|
|
|
|
|
uiItemR(layout,
|
|
|
|
|
&ptr,
|
|
|
|
|
"profile",
|
|
|
|
|
UI_ITEM_R_SLIDER,
|
|
|
|
|
(profile_type == BEVEL_PROFILE_SUPERELLIPSE) ? IFACE_("Shape") : IFACE_("Miter Shape"),
|
|
|
|
|
ICON_NONE);
|
|
|
|
|
}
|
2019-11-20 16:12:32 -05:00
|
|
|
uiItemR(layout, &ptr, "material", 0, NULL, ICON_NONE);
|
|
|
|
|
|
2020-07-21 11:13:18 -04:00
|
|
|
col = uiLayoutColumn(layout, true);
|
|
|
|
|
uiItemR(col, &ptr, "harden_normals", 0, NULL, ICON_NONE);
|
|
|
|
|
uiItemR(col, &ptr, "clamp_overlap", 0, NULL, ICON_NONE);
|
|
|
|
|
uiItemR(col, &ptr, "loop_slide", 0, NULL, ICON_NONE);
|
|
|
|
|
|
|
|
|
|
col = uiLayoutColumnWithHeading(layout, true, IFACE_("Mark"));
|
2020-07-21 16:32:00 -04:00
|
|
|
uiLayoutSetActive(col, affect_type == BEVEL_AFFECT_EDGES);
|
2020-07-21 11:13:18 -04:00
|
|
|
uiItemR(col, &ptr, "mark_seam", 0, IFACE_("Seams"), ICON_NONE);
|
|
|
|
|
uiItemR(col, &ptr, "mark_sharp", 0, IFACE_("Sharp"), ICON_NONE);
|
|
|
|
|
|
|
|
|
|
uiItemS(layout);
|
|
|
|
|
|
2020-07-21 16:32:00 -04:00
|
|
|
col = uiLayoutColumn(layout, false);
|
|
|
|
|
uiLayoutSetActive(col, affect_type == BEVEL_AFFECT_EDGES);
|
|
|
|
|
uiItemR(col, &ptr, "miter_outer", 0, IFACE_("Miter Outer"), ICON_NONE);
|
|
|
|
|
uiItemR(col, &ptr, "miter_inner", 0, IFACE_("Inner"), ICON_NONE);
|
2019-11-20 16:12:32 -05:00
|
|
|
if (RNA_enum_get(&ptr, "miter_inner") == BEVEL_MITER_ARC) {
|
2020-07-21 16:32:00 -04:00
|
|
|
uiItemR(col, &ptr, "spread", 0, NULL, ICON_NONE);
|
2019-11-20 16:12:32 -05:00
|
|
|
}
|
|
|
|
|
|
2020-07-21 11:13:18 -04:00
|
|
|
uiItemS(layout);
|
|
|
|
|
|
2020-07-21 16:32:00 -04:00
|
|
|
col = uiLayoutColumn(layout, false);
|
|
|
|
|
uiLayoutSetActive(col, affect_type == BEVEL_AFFECT_EDGES);
|
|
|
|
|
uiItemR(col, &ptr, "vmesh_method", 0, IFACE_("Intersection Type"), ICON_NONE);
|
|
|
|
|
|
2020-07-21 11:13:18 -04:00
|
|
|
uiItemR(layout, &ptr, "face_strength_mode", 0, IFACE_("Face Strength"), ICON_NONE);
|
2019-11-20 16:12:32 -05:00
|
|
|
|
2020-07-21 11:13:18 -04:00
|
|
|
uiItemS(layout);
|
2019-11-20 16:12:32 -05:00
|
|
|
|
2020-07-21 11:13:18 -04:00
|
|
|
row = uiLayoutRow(layout, false);
|
2020-06-22 22:25:55 -04:00
|
|
|
uiItemR(row, &ptr, "profile_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
|
|
|
|
|
if (profile_type == BEVEL_PROFILE_CUSTOM) {
|
|
|
|
|
/* Get an RNA pointer to ToolSettings to give to the curve profile template code. */
|
2019-11-20 16:12:32 -05:00
|
|
|
Scene *scene = CTX_data_scene(C);
|
|
|
|
|
RNA_pointer_create(&scene->id, &RNA_ToolSettings, scene->toolsettings, &toolsettings_ptr);
|
|
|
|
|
uiTemplateCurveProfile(layout, &toolsettings_ptr, "custom_bevel_profile_preset");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-01 10:18:01 +00:00
|
|
|
void MESH_OT_bevel(wmOperatorType *ot)
|
|
|
|
|
{
|
2014-06-16 09:03:26 +02:00
|
|
|
PropertyRNA *prop;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-10-18 15:07:26 +11:00
|
|
|
static const EnumPropertyItem offset_type_items[] = {
|
2013-11-10 12:31:57 +00:00
|
|
|
{BEVEL_AMT_OFFSET, "OFFSET", 0, "Offset", "Amount is offset of new edges from original"},
|
|
|
|
|
{BEVEL_AMT_WIDTH, "WIDTH", 0, "Width", "Amount is width of new face"},
|
|
|
|
|
{BEVEL_AMT_DEPTH,
|
|
|
|
|
"DEPTH",
|
|
|
|
|
0,
|
|
|
|
|
"Depth",
|
|
|
|
|
"Amount is perpendicular distance from original edge to bevel face"},
|
|
|
|
|
{BEVEL_AMT_PERCENT, "PERCENT", 0, "Percent", "Amount is percent of adjacent edge length"},
|
2020-06-19 17:56:01 -04:00
|
|
|
{BEVEL_AMT_ABSOLUTE,
|
|
|
|
|
"ABSOLUTE",
|
|
|
|
|
0,
|
|
|
|
|
"Absolute",
|
|
|
|
|
"Amount is absolute distance along adjacent edge"},
|
2013-11-10 12:31:57 +00:00
|
|
|
{0, NULL, 0, NULL, NULL},
|
|
|
|
|
};
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-06-22 22:25:55 -04:00
|
|
|
static const EnumPropertyItem prop_profile_type_items[] = {
|
|
|
|
|
{BEVEL_PROFILE_SUPERELLIPSE,
|
|
|
|
|
"SUPERELLIPSE",
|
|
|
|
|
0,
|
|
|
|
|
"Superellipse",
|
|
|
|
|
"The profile can be a concave or convex curve"},
|
|
|
|
|
{BEVEL_PROFILE_CUSTOM,
|
|
|
|
|
"CUSTOM",
|
|
|
|
|
0,
|
|
|
|
|
"Custom",
|
|
|
|
|
"The profile can be any arbitrary path between its endpoints"},
|
|
|
|
|
{0, NULL, 0, NULL, NULL},
|
|
|
|
|
};
|
|
|
|
|
|
2019-01-03 13:39:52 -05:00
|
|
|
static const EnumPropertyItem face_strength_mode_items[] = {
|
|
|
|
|
{BEVEL_FACE_STRENGTH_NONE, "NONE", 0, "None", "Do not set face strength"},
|
|
|
|
|
{BEVEL_FACE_STRENGTH_NEW, "NEW", 0, "New", "Set face strength on new faces only"},
|
|
|
|
|
{BEVEL_FACE_STRENGTH_AFFECTED,
|
|
|
|
|
"AFFECTED",
|
|
|
|
|
0,
|
|
|
|
|
"Affected",
|
|
|
|
|
"Set face strength on new and modified faces only"},
|
|
|
|
|
{BEVEL_FACE_STRENGTH_ALL, "ALL", 0, "All", "Set face strength on all faces"},
|
|
|
|
|
{0, NULL, 0, NULL, NULL},
|
2018-06-11 11:58:26 +05:30
|
|
|
};
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-01-18 12:54:10 -05:00
|
|
|
static const EnumPropertyItem miter_outer_items[] = {
|
|
|
|
|
{BEVEL_MITER_SHARP, "SHARP", 0, "Sharp", "Outside of miter is sharp"},
|
|
|
|
|
{BEVEL_MITER_PATCH, "PATCH", 0, "Patch", "Outside of miter is squared-off patch"},
|
|
|
|
|
{BEVEL_MITER_ARC, "ARC", 0, "Arc", "Outside of miter is arc"},
|
|
|
|
|
{0, NULL, 0, NULL, NULL},
|
|
|
|
|
};
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-01-18 12:54:10 -05:00
|
|
|
static const EnumPropertyItem miter_inner_items[] = {
|
|
|
|
|
{BEVEL_MITER_SHARP, "SHARP", 0, "Sharp", "Inside of miter is sharp"},
|
|
|
|
|
{BEVEL_MITER_ARC, "ARC", 0, "Arc", "Inside of miter is arc"},
|
|
|
|
|
{0, NULL, 0, NULL, NULL},
|
|
|
|
|
};
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-11-20 16:12:32 -05:00
|
|
|
static EnumPropertyItem vmesh_method_items[] = {
|
|
|
|
|
{BEVEL_VMESH_ADJ, "ADJ", 0, "Grid Fill", "Default patterned fill"},
|
|
|
|
|
{BEVEL_VMESH_CUTOFF,
|
|
|
|
|
"CUTOFF",
|
|
|
|
|
0,
|
|
|
|
|
"Cutoff",
|
|
|
|
|
"A cut-off at each profile's end before the intersection"},
|
|
|
|
|
{0, NULL, 0, NULL, NULL},
|
|
|
|
|
};
|
|
|
|
|
|
2020-07-21 16:32:00 -04:00
|
|
|
static const EnumPropertyItem prop_affect_items[] = {
|
|
|
|
|
{BEVEL_AFFECT_VERTICES, "VERTICES", 0, "Vertices", "Affect only vertices"},
|
|
|
|
|
{BEVEL_AFFECT_EDGES, "EDGES", 0, "Edges", "Affect only edges"},
|
|
|
|
|
{0, NULL, 0, NULL, NULL},
|
|
|
|
|
};
|
|
|
|
|
|
2013-04-01 10:18:01 +00:00
|
|
|
/* identifiers */
|
|
|
|
|
ot->name = "Bevel";
|
2019-11-20 16:12:32 -05:00
|
|
|
ot->description = "Cut into selected items at an angle to create bevel or chamfer";
|
2013-04-01 10:18:01 +00:00
|
|
|
ot->idname = "MESH_OT_bevel";
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-04-01 10:18:01 +00:00
|
|
|
/* api callbacks */
|
|
|
|
|
ot->exec = edbm_bevel_exec;
|
|
|
|
|
ot->invoke = edbm_bevel_invoke;
|
|
|
|
|
ot->modal = edbm_bevel_modal;
|
|
|
|
|
ot->cancel = edbm_bevel_cancel;
|
|
|
|
|
ot->poll = ED_operator_editmesh;
|
2019-11-20 16:12:32 -05:00
|
|
|
ot->ui = edbm_bevel_ui;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
|
/* flags */
|
2019-05-29 00:48:48 +10:00
|
|
|
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_GRAB_CURSOR_XY | OPTYPE_BLOCKING;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-11-20 16:12:32 -05:00
|
|
|
/* properties */
|
2020-06-22 22:25:55 -04:00
|
|
|
RNA_def_enum(ot->srna,
|
|
|
|
|
"offset_type",
|
|
|
|
|
offset_type_items,
|
|
|
|
|
0,
|
|
|
|
|
"Width Type",
|
|
|
|
|
"The method for determining the size of the bevel");
|
2019-03-06 09:04:31 -05:00
|
|
|
prop = RNA_def_property(ot->srna, "offset", PROP_FLOAT, PROP_DISTANCE);
|
|
|
|
|
RNA_def_property_range(prop, 0.0, 1e6);
|
2019-11-20 16:12:32 -05:00
|
|
|
RNA_def_property_ui_range(prop, 0.0, 100.0, 1, 3);
|
2019-03-06 09:04:31 -05:00
|
|
|
RNA_def_property_ui_text(prop, "Width", "Bevel amount");
|
2019-11-20 16:12:32 -05:00
|
|
|
|
2020-06-22 22:25:55 -04:00
|
|
|
RNA_def_enum(ot->srna,
|
|
|
|
|
"profile_type",
|
|
|
|
|
prop_profile_type_items,
|
|
|
|
|
0,
|
|
|
|
|
"Profile Type",
|
|
|
|
|
"The type of shape used to rebuild a beveled section");
|
|
|
|
|
|
2019-03-06 09:04:31 -05:00
|
|
|
prop = RNA_def_property(ot->srna, "offset_pct", PROP_FLOAT, PROP_PERCENTAGE);
|
|
|
|
|
RNA_def_property_range(prop, 0.0, 100);
|
|
|
|
|
RNA_def_property_ui_text(prop, "Width Percent", "Bevel amount for percentage method");
|
2019-11-20 16:12:32 -05:00
|
|
|
|
2019-03-06 09:04:31 -05:00
|
|
|
RNA_def_int(ot->srna,
|
|
|
|
|
"segments",
|
|
|
|
|
1,
|
|
|
|
|
1,
|
|
|
|
|
SEGMENTS_HARD_MAX,
|
|
|
|
|
"Segments",
|
|
|
|
|
"Segments for curved edge",
|
|
|
|
|
1,
|
|
|
|
|
100);
|
2019-11-20 16:12:32 -05:00
|
|
|
|
2019-03-06 09:04:31 -05:00
|
|
|
RNA_def_float(ot->srna,
|
2019-03-15 08:53:22 +11:00
|
|
|
"profile",
|
|
|
|
|
0.5f,
|
|
|
|
|
PROFILE_HARD_MIN,
|
|
|
|
|
1.0f,
|
|
|
|
|
"Profile",
|
|
|
|
|
"Controls profile shape (0.5 = round)",
|
|
|
|
|
PROFILE_HARD_MIN,
|
|
|
|
|
1.0f);
|
2019-11-20 16:12:32 -05:00
|
|
|
|
2020-08-03 17:40:07 -04:00
|
|
|
RNA_def_enum(ot->srna,
|
|
|
|
|
"affect",
|
|
|
|
|
prop_affect_items,
|
|
|
|
|
BEVEL_AFFECT_EDGES,
|
|
|
|
|
"Affect",
|
|
|
|
|
"Affect Edges or Vertices");
|
2019-11-20 16:12:32 -05:00
|
|
|
|
2019-03-15 08:53:22 +11:00
|
|
|
RNA_def_boolean(ot->srna,
|
|
|
|
|
"clamp_overlap",
|
|
|
|
|
false,
|
|
|
|
|
"Clamp Overlap",
|
|
|
|
|
"Do not allow beveled edges/vertices to overlap each other");
|
2019-11-20 16:12:32 -05:00
|
|
|
|
2015-07-05 13:31:26 -04:00
|
|
|
RNA_def_boolean(
|
2019-11-20 16:12:32 -05:00
|
|
|
ot->srna, "loop_slide", true, "Loop Slide", "Prefer sliding along edges to even widths");
|
|
|
|
|
|
2018-06-04 15:13:54 +05:30
|
|
|
RNA_def_boolean(ot->srna, "mark_seam", false, "Mark Seams", "Mark Seams along beveled edges");
|
2019-11-20 16:12:32 -05:00
|
|
|
|
2018-06-04 15:13:54 +05:30
|
|
|
RNA_def_boolean(ot->srna, "mark_sharp", false, "Mark Sharp", "Mark beveled edges as sharp");
|
2019-11-20 16:12:32 -05:00
|
|
|
|
2019-03-15 08:53:22 +11:00
|
|
|
RNA_def_int(ot->srna,
|
|
|
|
|
"material",
|
|
|
|
|
-1,
|
|
|
|
|
-1,
|
|
|
|
|
INT_MAX,
|
2020-07-21 11:13:18 -04:00
|
|
|
"Material Index",
|
2019-03-15 08:53:22 +11:00
|
|
|
"Material for bevel faces (-1 means use adjacent faces)",
|
|
|
|
|
-1,
|
|
|
|
|
100);
|
2019-11-20 16:12:32 -05:00
|
|
|
|
2019-03-15 08:53:22 +11:00
|
|
|
RNA_def_boolean(ot->srna,
|
|
|
|
|
"harden_normals",
|
|
|
|
|
false,
|
|
|
|
|
"Harden Normals",
|
|
|
|
|
"Match normals of new faces to adjacent faces");
|
2019-11-20 16:12:32 -05:00
|
|
|
|
2019-03-15 08:53:22 +11:00
|
|
|
RNA_def_enum(ot->srna,
|
|
|
|
|
"face_strength_mode",
|
|
|
|
|
face_strength_mode_items,
|
|
|
|
|
BEVEL_FACE_STRENGTH_NONE,
|
|
|
|
|
"Face Strength Mode",
|
|
|
|
|
"Whether to set face strength, and which faces to set face strength on");
|
2019-11-20 16:12:32 -05:00
|
|
|
|
2019-03-15 08:53:22 +11:00
|
|
|
RNA_def_enum(ot->srna,
|
|
|
|
|
"miter_outer",
|
|
|
|
|
miter_outer_items,
|
|
|
|
|
BEVEL_MITER_SHARP,
|
|
|
|
|
"Outer Miter",
|
|
|
|
|
"Pattern to use for outside of miters");
|
2019-11-20 16:12:32 -05:00
|
|
|
|
2019-03-15 08:53:22 +11:00
|
|
|
RNA_def_enum(ot->srna,
|
|
|
|
|
"miter_inner",
|
|
|
|
|
miter_inner_items,
|
|
|
|
|
BEVEL_MITER_SHARP,
|
|
|
|
|
"Inner Miter",
|
|
|
|
|
"Pattern to use for inside of miters");
|
2019-11-20 16:12:32 -05:00
|
|
|
|
2019-03-15 08:53:22 +11:00
|
|
|
RNA_def_float(ot->srna,
|
|
|
|
|
"spread",
|
|
|
|
|
0.1f,
|
|
|
|
|
0.0f,
|
|
|
|
|
1e6f,
|
|
|
|
|
"Spread",
|
|
|
|
|
"Amount to spread arcs for arc inner miters",
|
|
|
|
|
0.0f,
|
|
|
|
|
100.0f);
|
2019-11-20 16:12:32 -05:00
|
|
|
|
|
|
|
|
RNA_def_enum(ot->srna,
|
|
|
|
|
"vmesh_method",
|
|
|
|
|
vmesh_method_items,
|
|
|
|
|
BEVEL_VMESH_ADJ,
|
|
|
|
|
"Vertex Mesh Method",
|
|
|
|
|
"The method to use to create meshes at intersections");
|
|
|
|
|
|
2018-08-22 17:43:49 +10:00
|
|
|
prop = RNA_def_boolean(ot->srna, "release_confirm", 0, "Confirm on Release", "");
|
|
|
|
|
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
2013-04-01 10:18:01 +00:00
|
|
|
}
|