Manipulator: de-duplicate flags and scale option
This commit is contained in:
@@ -285,11 +285,11 @@ class USERPREF_PT_interface(Panel):
|
||||
#col.prop(view, "open_left_mouse_delay", text="Hold LMB")
|
||||
#col.prop(view, "open_right_mouse_delay", text="Hold RMB")
|
||||
col.prop(view, "show_manipulator")
|
||||
## Currently not working
|
||||
# col.prop(view, "show_manipulator_shaded")
|
||||
sub = col.column()
|
||||
sub.active = view.show_manipulator
|
||||
sub.prop(view, "manipulator_size", text="Size")
|
||||
sub.prop(view, "manipulator_handle_size", text="Handle Size")
|
||||
sub.prop(view, "manipulator_hotspot", text="Hotspot")
|
||||
|
||||
col.separator()
|
||||
col.separator()
|
||||
|
||||
@@ -1798,14 +1798,10 @@ void init_userdef_do_versions(void)
|
||||
U.savetime = 1;
|
||||
// XXX error(STRINGIFY(BLENDER_STARTUP_FILE)" is buggy, please consider removing it.\n");
|
||||
}
|
||||
/* transform widget settings */
|
||||
if (U.tw_hotspot == 0) {
|
||||
U.tw_hotspot = 14;
|
||||
U.tw_size = 25; /* percentage of window size */
|
||||
U.tw_handlesize = 16; /* percentage of widget radius */
|
||||
if (U.manipulator_size == 0) {
|
||||
U.manipulator_size = 75;
|
||||
U.manipulator_flag |= USER_MANIPULATOR_DRAW;
|
||||
}
|
||||
if (U.manipulator_scale == 0)
|
||||
U.manipulator_scale = 75;
|
||||
if (U.pad_rot_angle == 0.0f)
|
||||
U.pad_rot_angle = 15.0f;
|
||||
|
||||
@@ -2642,9 +2638,6 @@ void init_userdef_do_versions(void)
|
||||
|
||||
if (!USER_VERSION_ATLEAST(269, 9)) {
|
||||
bTheme *btheme;
|
||||
|
||||
U.tw_size = U.tw_size * 5.0f;
|
||||
|
||||
/* Action Editor (and NLA Editor) - Keyframe Colors */
|
||||
/* Graph Editor - larger vertex size defaults */
|
||||
for (btheme = U.themes.first; btheme; btheme = btheme->next) {
|
||||
|
||||
@@ -163,7 +163,7 @@ static void arrow_draw_geom(const ArrowManipulator3D *arrow, const bool select,
|
||||
else {
|
||||
const float len = 0.25f;
|
||||
const float width = 0.06f;
|
||||
const bool use_lighting = select == false && ((U.manipulator_flag & V3D_SHADED_MANIPULATORS) != 0);
|
||||
const bool use_lighting = (!select && ((U.manipulator_flag & USER_MANIPULATOR_SHADED) != 0));
|
||||
|
||||
/* translate to line end */
|
||||
gpuTranslate3f(0.0f, 0.0f, arrow->len);
|
||||
|
||||
@@ -187,7 +187,7 @@ static void dial_ghostarc_draw_helpline(const float angle, const float co_outer[
|
||||
static void dial_ghostarc_draw(
|
||||
const DialManipulator *dial, const float angle_ofs, const float angle_delta, const float color[4])
|
||||
{
|
||||
const float width_inner = DIAL_WIDTH - dial->manipulator.line_width * 0.5f / U.manipulator_scale;
|
||||
const float width_inner = DIAL_WIDTH - dial->manipulator.line_width * 0.5f / U.manipulator_size;
|
||||
|
||||
VertexFormat *format = immVertexFormat();
|
||||
uint pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
|
||||
|
||||
@@ -63,7 +63,7 @@ void wm_manipulator_geometryinfo_draw(const ManipulatorGeomInfo *info, const boo
|
||||
/* TODO store the Batches inside the ManipulatorGeomInfo and updated it when geom changes
|
||||
* So we don't need to re-created and discard it every time */
|
||||
|
||||
const bool use_lighting = true || (!select && ((U.manipulator_flag & V3D_SHADED_MANIPULATORS) != 0));
|
||||
const bool use_lighting = true || (!select && ((U.manipulator_flag & USER_MANIPULATOR_SHADED) != 0));
|
||||
VertexBuffer *vbo;
|
||||
ElementList *el;
|
||||
Batch *batch;
|
||||
|
||||
@@ -197,7 +197,7 @@ static int mesh_bisect_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
/* Setup manipulators */
|
||||
{
|
||||
View3D *v3d = CTX_wm_view3d(C);
|
||||
if (v3d && (v3d->twtype & V3D_USE_MANIPULATOR)) {
|
||||
if (v3d && (v3d->twtype & V3D_MANIPULATOR_DRAW)) {
|
||||
WM_manipulator_group_add("MESH_WGT_bisect");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -758,7 +758,7 @@ static int edbm_spin_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(e
|
||||
#ifdef USE_MANIPULATOR
|
||||
if (ret & OPERATOR_FINISHED) {
|
||||
/* Setup manipulators */
|
||||
if (v3d && (v3d->twtype & V3D_USE_MANIPULATOR)) {
|
||||
if (v3d && (v3d->twtype & V3D_MANIPULATOR_DRAW)) {
|
||||
WM_manipulator_group_add("MESH_WGT_spin");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -344,7 +344,7 @@ static SpaceLink *view3d_new(const bContext *C)
|
||||
v3d->near = 0.01f;
|
||||
v3d->far = 1000.0f;
|
||||
|
||||
v3d->twflag |= U.manipulator_flag & V3D_USE_MANIPULATOR;
|
||||
v3d->twflag |= U.manipulator_flag & V3D_MANIPULATOR_DRAW;
|
||||
v3d->twtype = V3D_MANIP_TRANSLATE;
|
||||
v3d->around = V3D_AROUND_CENTER_MEAN;
|
||||
|
||||
|
||||
@@ -328,7 +328,7 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C)
|
||||
/* Transform widget / manipulators */
|
||||
row = uiLayoutRow(layout, true);
|
||||
uiItemR(row, &v3dptr, "show_manipulator", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
|
||||
if (v3d->twflag & V3D_USE_MANIPULATOR) {
|
||||
if (v3d->twflag & V3D_MANIPULATOR_DRAW) {
|
||||
uiItemR(row, &v3dptr, "transform_manipulators", UI_ITEM_R_ICON_ONLY, "", ICON_NONE);
|
||||
}
|
||||
uiItemR(row, &v3dptr, "transform_orientation", 0, "", ICON_NONE);
|
||||
|
||||
@@ -1360,7 +1360,7 @@ static bool WIDGETGROUP_manipulator_poll(const struct bContext *C, struct wmMani
|
||||
const ScrArea *sa = CTX_wm_area(C);
|
||||
const View3D *v3d = sa->spacedata.first;
|
||||
|
||||
return (((v3d->twflag & V3D_USE_MANIPULATOR) != 0) &&
|
||||
return (((v3d->twflag & V3D_MANIPULATOR_DRAW) != 0) &&
|
||||
((v3d->twtype & (V3D_MANIP_TRANSLATE | V3D_MANIP_ROTATE | V3D_MANIP_SCALE)) != 0));
|
||||
}
|
||||
|
||||
|
||||
@@ -199,7 +199,7 @@ void ED_widgetgroup_manipulator2d_setup(const bContext *UNUSED(C), wmManipulator
|
||||
ED_manipulator_arrow2d_set_line_len(axis, 0.8f);
|
||||
WM_manipulator_set_matrix_offset_location(axis, offset);
|
||||
WM_manipulator_set_line_width(axis, MANIPULATOR_AXIS_LINE_WIDTH);
|
||||
WM_manipulator_set_scale(axis, U.manipulator_scale);
|
||||
WM_manipulator_set_scale(axis, U.manipulator_size);
|
||||
WM_manipulator_set_color(axis, col);
|
||||
WM_manipulator_set_color_highlight(axis, col_hi);
|
||||
|
||||
|
||||
@@ -494,8 +494,7 @@ typedef struct UserDef {
|
||||
short gp_settings;
|
||||
short tb_leftmouse, tb_rightmouse;
|
||||
struct SolidLight light[3];
|
||||
short tw_hotspot, tw_flag, tw_handlesize, tw_size;
|
||||
short manipulator_flag, manipulator_scale;
|
||||
short manipulator_flag, manipulator_size;
|
||||
int pad3;
|
||||
short textimeout, texcollectrate;
|
||||
short wmdrawmethod; /* removed wmpad */
|
||||
@@ -796,6 +795,11 @@ typedef enum eGP_UserdefSettings {
|
||||
GP_PAINT_DOSIMPLIFY = (1 << 1),
|
||||
} eGP_UserdefSettings;
|
||||
|
||||
enum {
|
||||
USER_MANIPULATOR_DRAW = (1 << 0),
|
||||
USER_MANIPULATOR_SHADED = (1 << 1),
|
||||
};
|
||||
|
||||
/* color picker types */
|
||||
typedef enum eColorPicker_Types {
|
||||
USER_CP_CIRCLE_HSV = 0,
|
||||
|
||||
@@ -380,11 +380,10 @@ enum {
|
||||
#define V3D_MANIP_GIMBAL 4
|
||||
#define V3D_MANIP_CUSTOM 5
|
||||
|
||||
/* View3d->twflag */
|
||||
/* USE = user setting, DRAW = based on selection */
|
||||
#define V3D_USE_MANIPULATOR 1
|
||||
#define V3D_DRAW_MANIPULATOR (1 << 1)
|
||||
#define V3D_SHADED_MANIPULATORS (1 << 2)
|
||||
/* View3d->twflag (also) */
|
||||
enum {
|
||||
V3D_MANIPULATOR_DRAW = (1 << 0),
|
||||
};
|
||||
|
||||
/* BGPic->flag */
|
||||
/* may want to use 1 for select ? */
|
||||
|
||||
@@ -2678,7 +2678,7 @@ static void rna_def_space_view3d(BlenderRNA *brna)
|
||||
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_SpaceView3D_pivot_update");
|
||||
|
||||
prop = RNA_def_property(srna, "show_manipulator", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "twflag", V3D_USE_MANIPULATOR);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "twflag", V3D_MANIPULATOR_DRAW);
|
||||
RNA_def_property_ui_text(prop, "Manipulator", "Use a 3D manipulator widget for controlling transforms");
|
||||
RNA_def_property_ui_icon(prop, ICON_MANIPUL, 0);
|
||||
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
|
||||
|
||||
@@ -176,10 +176,12 @@ static void rna_userdef_show_manipulator_update(Main *bmain, Scene *scene, Point
|
||||
for (sl = sa->spacedata.first; sl; sl = sl->next) {
|
||||
if (sl->spacetype == SPACE_VIEW3D) {
|
||||
View3D *v3d = (View3D *)sl;
|
||||
if (userdef->tw_flag & V3D_USE_MANIPULATOR)
|
||||
v3d->twflag |= V3D_USE_MANIPULATOR;
|
||||
else
|
||||
v3d->twflag &= ~V3D_USE_MANIPULATOR;
|
||||
if (userdef->manipulator_flag & USER_MANIPULATOR_DRAW) {
|
||||
v3d->twflag |= V3D_MANIPULATOR_DRAW;
|
||||
}
|
||||
else {
|
||||
v3d->twflag &= ~V3D_MANIPULATOR_DRAW;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3496,30 +3498,25 @@ static void rna_def_userdef_view(BlenderRNA *brna)
|
||||
|
||||
/* 3D transform widget */
|
||||
prop = RNA_def_property(srna, "show_manipulator", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "tw_flag", V3D_USE_MANIPULATOR);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "manipulator_flag", USER_MANIPULATOR_DRAW);
|
||||
RNA_def_property_ui_text(prop, "Manipulator", "Use 3D transform manipulator");
|
||||
RNA_def_property_update(prop, 0, "rna_userdef_show_manipulator_update");
|
||||
|
||||
/* TODO, expose once it's working. */
|
||||
#if 0
|
||||
prop = RNA_def_property(srna, "show_manipulator_shaded", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "manipulator_flag", USER_MANIPULATOR_SHADED);
|
||||
RNA_def_property_ui_text(prop, "Manipulator Shaded", "Use 3D transform manipulator");
|
||||
RNA_def_property_update(prop, 0, "rna_userdef_update");
|
||||
#endif
|
||||
|
||||
prop = RNA_def_property(srna, "manipulator_size", PROP_INT, PROP_PIXEL);
|
||||
RNA_def_property_int_sdna(prop, NULL, "tw_size");
|
||||
RNA_def_property_int_sdna(prop, NULL, "manipulator_size");
|
||||
RNA_def_property_range(prop, 10, 200);
|
||||
RNA_def_property_int_default(prop, 75);
|
||||
RNA_def_property_ui_text(prop, "Manipulator Size", "Diameter of the manipulator");
|
||||
RNA_def_property_update(prop, 0, "rna_userdef_update");
|
||||
|
||||
prop = RNA_def_property(srna, "manipulator_handle_size", PROP_INT, PROP_PERCENTAGE);
|
||||
RNA_def_property_int_sdna(prop, NULL, "tw_handlesize");
|
||||
RNA_def_property_range(prop, 2, 40);
|
||||
RNA_def_property_int_default(prop, 25);
|
||||
RNA_def_property_ui_text(prop, "Manipulator Handle Size", "Size of manipulator handles as percentage of the radius");
|
||||
RNA_def_property_update(prop, 0, "rna_userdef_update");
|
||||
|
||||
prop = RNA_def_property(srna, "manipulator_hotspot", PROP_INT, PROP_PIXEL);
|
||||
RNA_def_property_int_sdna(prop, NULL, "tw_hotspot");
|
||||
RNA_def_property_range(prop, 4, 40);
|
||||
RNA_def_property_int_default(prop, 14);
|
||||
RNA_def_property_ui_text(prop, "Manipulator Hotspot", "Distance around the handles to accept mouse clicks");
|
||||
|
||||
prop = RNA_def_property(srna, "object_origin_size", PROP_INT, PROP_PIXEL);
|
||||
RNA_def_property_int_sdna(prop, NULL, "obcenter_dia");
|
||||
RNA_def_property_range(prop, 4, 10);
|
||||
|
||||
@@ -418,19 +418,19 @@ void wm_manipulator_calculate_scale(wmManipulator *mpr, const bContext *C)
|
||||
float scale = 1.0f;
|
||||
|
||||
if (mpr->parent_mgroup->type->flag & WM_MANIPULATORGROUPTYPE_SCALE_3D) {
|
||||
if (rv3d /*&& (U.manipulator_flag & V3D_DRAW_MANIPULATOR) == 0*/) { /* UserPref flag might be useful for later */
|
||||
if (rv3d) {
|
||||
if (mpr->type->matrix_world_get) {
|
||||
float matrix_world[4][4];
|
||||
|
||||
mpr->type->matrix_world_get(mpr, matrix_world);
|
||||
scale = ED_view3d_pixel_size(rv3d, matrix_world[3]) * (float)U.manipulator_scale;
|
||||
scale = ED_view3d_pixel_size(rv3d, matrix_world[3]) * (float)U.manipulator_size;
|
||||
}
|
||||
else {
|
||||
scale = ED_view3d_pixel_size(rv3d, mpr->matrix[3]) * (float)U.manipulator_scale;
|
||||
scale = ED_view3d_pixel_size(rv3d, mpr->matrix[3]) * (float)U.manipulator_size;
|
||||
}
|
||||
}
|
||||
else {
|
||||
scale = U.manipulator_scale * 0.02f;
|
||||
scale = U.manipulator_size * 0.02f;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -248,7 +248,7 @@ static void manipulators_draw_list(const wmManipulatorMap *mmap, const bContext
|
||||
const bool draw_multisample = (U.ogl_multisamples != USER_MULTISAMPLE_NONE);
|
||||
|
||||
/* TODO this will need it own shader probably? don't think it can be handled from that point though. */
|
||||
/* const bool use_lighting = (U.manipulator_flag & V3D_SHADED_MANIPULATORS) != 0; */
|
||||
/* const bool use_lighting = (U.manipulator_flag & V3D_MANIPULATOR_SHADED) != 0; */
|
||||
|
||||
/* enable multisampling */
|
||||
if (draw_multisample) {
|
||||
|
||||
Reference in New Issue
Block a user