Fix #106558: Add Primitive tool options not saving
Since a generic snap cursor was implemented (which can be used by Tools and by DragDrop), the Placement Settings are no longer a settings of the "VIEW3D_OT_interactive_add" Operator. With that implementation, those properties started to be defined in a static struct, filled in at runtime and accessed in the UI through workarrounds. As they are properties initialized at runtime, they are not saved in the file. The solution is to move the Placement Settings to `ToolSettings`. Co-authored-by: Germano Cavalcante <germano.costa@ig.com.br> Pull Request: https://projects.blender.org/blender/blender/pulls/107951
This commit is contained in:
@@ -500,23 +500,21 @@ class _defs_view3d_add:
|
||||
# Layout tweaks here would be good to avoid,
|
||||
# this shows limits in layout engine, as buttons are using a lot of space.
|
||||
@staticmethod
|
||||
def draw_settings_interactive_add(layout, tool, extra):
|
||||
def draw_settings_interactive_add(layout, tool_settings, tool, extra):
|
||||
show_extra = False
|
||||
props = tool.operator_properties("view3d.interactive_add")
|
||||
if not extra:
|
||||
row = layout.row()
|
||||
row.label(text="Depth:")
|
||||
row = layout.row()
|
||||
row.prop(props, "plane_depth", text="")
|
||||
row.prop(tool_settings, "plane_depth", text="")
|
||||
row = layout.row()
|
||||
row.label(text="Orientation:")
|
||||
row = layout.row()
|
||||
row.prop(props, "plane_orientation", text="")
|
||||
row.prop(tool_settings, "plane_orientation", text="")
|
||||
row = layout.row()
|
||||
row.prop(props, "snap_target")
|
||||
row.prop(tool_settings, "snap_elements_tool")
|
||||
|
||||
region_is_header = bpy.context.region.type == 'TOOL_HEADER'
|
||||
|
||||
if region_is_header:
|
||||
# Don't draw the "extra" popover here as we might have other settings & this should be last.
|
||||
show_extra = True
|
||||
@@ -524,9 +522,10 @@ class _defs_view3d_add:
|
||||
extra = True
|
||||
|
||||
if extra:
|
||||
props = tool.operator_properties("view3d.interactive_add")
|
||||
layout.use_property_split = True
|
||||
layout.row().prop(props, "plane_axis", expand=True)
|
||||
layout.row().prop(props, "plane_axis_auto")
|
||||
layout.row().prop(tool_settings, "plane_axis", expand=True)
|
||||
layout.row().prop(tool_settings, "plane_axis_auto")
|
||||
|
||||
layout.label(text="Base")
|
||||
layout.row().prop(props, "plane_origin_base", expand=True)
|
||||
@@ -538,8 +537,8 @@ class _defs_view3d_add:
|
||||
|
||||
@ToolDef.from_fn
|
||||
def cube_add():
|
||||
def draw_settings(_context, layout, tool, *, extra=False):
|
||||
show_extra = _defs_view3d_add.draw_settings_interactive_add(layout, tool, extra)
|
||||
def draw_settings(context, layout, tool, *, extra=False):
|
||||
show_extra = _defs_view3d_add.draw_settings_interactive_add(layout, context.tool_settings, tool, extra)
|
||||
if show_extra:
|
||||
layout.popover("TOPBAR_PT_tool_settings_extra", text="...")
|
||||
|
||||
@@ -557,8 +556,8 @@ class _defs_view3d_add:
|
||||
|
||||
@ToolDef.from_fn
|
||||
def cone_add():
|
||||
def draw_settings(_context, layout, tool, *, extra=False):
|
||||
show_extra = _defs_view3d_add.draw_settings_interactive_add(layout, tool, extra)
|
||||
def draw_settings(context, layout, tool, *, extra=False):
|
||||
show_extra = _defs_view3d_add.draw_settings_interactive_add(layout, context.tool_settings, tool, extra)
|
||||
if extra:
|
||||
return
|
||||
|
||||
@@ -583,8 +582,8 @@ class _defs_view3d_add:
|
||||
|
||||
@ToolDef.from_fn
|
||||
def cylinder_add():
|
||||
def draw_settings(_context, layout, tool, *, extra=False):
|
||||
show_extra = _defs_view3d_add.draw_settings_interactive_add(layout, tool, extra)
|
||||
def draw_settings(context, layout, tool, *, extra=False):
|
||||
show_extra = _defs_view3d_add.draw_settings_interactive_add(layout, context.tool_settings, tool, extra)
|
||||
if extra:
|
||||
return
|
||||
|
||||
@@ -608,8 +607,8 @@ class _defs_view3d_add:
|
||||
|
||||
@ToolDef.from_fn
|
||||
def uv_sphere_add():
|
||||
def draw_settings(_context, layout, tool, *, extra=False):
|
||||
show_extra = _defs_view3d_add.draw_settings_interactive_add(layout, tool, extra)
|
||||
def draw_settings(context, layout, tool, *, extra=False):
|
||||
show_extra = _defs_view3d_add.draw_settings_interactive_add(layout, context.tool_settings, tool, extra)
|
||||
if extra:
|
||||
return
|
||||
|
||||
@@ -633,8 +632,8 @@ class _defs_view3d_add:
|
||||
|
||||
@ToolDef.from_fn
|
||||
def ico_sphere_add():
|
||||
def draw_settings(_context, layout, tool, *, extra=False):
|
||||
show_extra = _defs_view3d_add.draw_settings_interactive_add(layout, tool, extra)
|
||||
def draw_settings(context, layout, tool, *, extra=False):
|
||||
show_extra = _defs_view3d_add.draw_settings_interactive_add(layout, context.tool_settings, tool, extra)
|
||||
if extra:
|
||||
return
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ extern "C" {
|
||||
|
||||
/* Blender file format version. */
|
||||
#define BLENDER_FILE_VERSION BLENDER_VERSION
|
||||
#define BLENDER_FILE_SUBVERSION 9
|
||||
#define BLENDER_FILE_SUBVERSION 10
|
||||
|
||||
/* Minimum Blender version that supports reading file written with the current
|
||||
* version. Older Blender versions will test this and show a warning if the file
|
||||
|
||||
@@ -4390,6 +4390,14 @@ void blo_do_versions_300(FileData *fd, Library * /*lib*/, Main *bmain)
|
||||
}
|
||||
}
|
||||
|
||||
if (!MAIN_VERSION_ATLEAST(bmain, 306, 10)) {
|
||||
LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
|
||||
/* Set default values for new members. */
|
||||
scene->toolsettings->snap_mode_tools = SCE_SNAP_MODE_GEOM;
|
||||
scene->toolsettings->plane_axis = 2;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Versioning code until next subversion bump goes here.
|
||||
*
|
||||
|
||||
@@ -120,21 +120,6 @@ static V3DSnapCursorState *gizmo_snap_state_from_rna_get(struct PointerRNA *ptr)
|
||||
return ED_view3d_cursor_snap_state_active_get();
|
||||
}
|
||||
|
||||
static int gizmo_snap_rna_snap_elements_force_get_fn(struct PointerRNA *ptr,
|
||||
struct PropertyRNA *UNUSED(prop))
|
||||
{
|
||||
V3DSnapCursorState *snap_state = gizmo_snap_state_from_rna_get(ptr);
|
||||
return snap_state->snap_elem_force;
|
||||
}
|
||||
|
||||
static void gizmo_snap_rna_snap_elements_force_set_fn(struct PointerRNA *ptr,
|
||||
struct PropertyRNA *UNUSED(prop),
|
||||
int value)
|
||||
{
|
||||
V3DSnapCursorState *snap_state = gizmo_snap_state_from_rna_get(ptr);
|
||||
snap_state->snap_elem_force = (short)value;
|
||||
}
|
||||
|
||||
static void gizmo_snap_rna_prevpoint_get_fn(struct PointerRNA *ptr,
|
||||
struct PropertyRNA *UNUSED(prop),
|
||||
float *values)
|
||||
@@ -336,17 +321,6 @@ static void GIZMO_GT_snap_3d(wmGizmoType *gzt)
|
||||
|
||||
/* Setup. */
|
||||
PropertyRNA *prop;
|
||||
prop = RNA_def_enum_flag(gzt->srna,
|
||||
"snap_elements_force",
|
||||
rna_enum_snap_element_items,
|
||||
SCE_SNAP_MODE_VERTEX | SCE_SNAP_MODE_EDGE | SCE_SNAP_MODE_FACE_RAYCAST,
|
||||
"Snap Elements",
|
||||
"");
|
||||
RNA_def_property_enum_funcs_runtime(prop,
|
||||
gizmo_snap_rna_snap_elements_force_get_fn,
|
||||
gizmo_snap_rna_snap_elements_force_set_fn,
|
||||
NULL);
|
||||
|
||||
prop = RNA_def_float_array(gzt->srna,
|
||||
"prev_point",
|
||||
3,
|
||||
|
||||
@@ -290,17 +290,6 @@ typedef enum {
|
||||
V3D_SNAPCURSOR_SNAP_EDIT_GEOM_CAGE = 1 << 4,
|
||||
} eV3DSnapCursor;
|
||||
|
||||
typedef enum {
|
||||
V3D_PLACE_DEPTH_SURFACE = 0,
|
||||
V3D_PLACE_DEPTH_CURSOR_PLANE = 1,
|
||||
V3D_PLACE_DEPTH_CURSOR_VIEW = 2,
|
||||
} eV3DPlaceDepth;
|
||||
|
||||
typedef enum {
|
||||
V3D_PLACE_ORIENT_SURFACE = 0,
|
||||
V3D_PLACE_ORIENT_DEFAULT = 1,
|
||||
} eV3DPlaceOrient;
|
||||
|
||||
typedef struct V3DSnapCursorData {
|
||||
eSnapMode snap_elem;
|
||||
float loc[3];
|
||||
@@ -317,16 +306,11 @@ typedef struct V3DSnapCursorData {
|
||||
typedef struct V3DSnapCursorState {
|
||||
/* Setup. */
|
||||
eV3DSnapCursor flag;
|
||||
eV3DPlaceDepth plane_depth;
|
||||
eV3DPlaceOrient plane_orient;
|
||||
uchar color_line[4];
|
||||
uchar color_point[4];
|
||||
uchar color_box[4];
|
||||
float *prevpoint;
|
||||
float box_dimensions[3];
|
||||
eSnapMode snap_elem_force; /* If SCE_SNAP_MODE_NONE, use scene settings. */
|
||||
short plane_axis;
|
||||
bool use_plane_axis_auto;
|
||||
bool draw_point;
|
||||
bool draw_plane;
|
||||
bool draw_box;
|
||||
|
||||
@@ -78,8 +78,6 @@ typedef struct SnapCursorDataIntern {
|
||||
|
||||
static SnapCursorDataIntern g_data_intern = {
|
||||
.state_default = {.flag = V3D_SNAPCURSOR_SNAP_EDIT_GEOM_FINAL,
|
||||
.snap_elem_force = SCE_SNAP_MODE_GEOM,
|
||||
.plane_axis = 2,
|
||||
.color_point = {255, 255, 255, 255},
|
||||
.color_line = {255, 255, 255, 128},
|
||||
.color_box = {255, 255, 255, 128},
|
||||
@@ -549,13 +547,10 @@ static bool v3d_cursor_is_snap_invert(SnapCursorDataIntern *data_intern, const w
|
||||
/** \name Update
|
||||
* \{ */
|
||||
|
||||
static eSnapMode v3d_cursor_snap_elements(V3DSnapCursorState *snap_state, Scene *scene)
|
||||
static eSnapMode v3d_cursor_snap_elements(ToolSettings *tool_settings)
|
||||
{
|
||||
eSnapMode snap_elements = snap_state->snap_elem_force;
|
||||
if (!snap_elements) {
|
||||
return scene->toolsettings->snap_mode;
|
||||
}
|
||||
return snap_elements;
|
||||
return tool_settings->snap_mode_tools == SCE_SNAP_MODE_NONE ? tool_settings->snap_mode :
|
||||
tool_settings->snap_mode_tools;
|
||||
}
|
||||
|
||||
static void v3d_cursor_snap_context_ensure(Scene *scene)
|
||||
@@ -594,14 +589,15 @@ static void v3d_cursor_snap_update(V3DSnapCursorState *state,
|
||||
{
|
||||
SnapCursorDataIntern *data_intern = &g_data_intern;
|
||||
V3DSnapCursorData *snap_data = &data_intern->snap_data;
|
||||
ToolSettings *tool_settings = scene->toolsettings;
|
||||
|
||||
const bool use_surface_nor = state->plane_orient == V3D_PLACE_ORIENT_SURFACE;
|
||||
const bool use_surface_co = state->plane_depth == V3D_PLACE_DEPTH_SURFACE;
|
||||
const bool use_surface_nor = tool_settings->plane_orient == V3D_PLACE_ORIENT_SURFACE;
|
||||
const bool use_surface_co = tool_settings->plane_depth == V3D_PLACE_DEPTH_SURFACE;
|
||||
const bool calc_plane_omat = v3d_cursor_snap_calc_plane();
|
||||
|
||||
float co[3], no[3], face_nor[3], obmat[4][4], omat[3][3];
|
||||
eSnapMode snap_elem = SCE_SNAP_MODE_NONE;
|
||||
eSnapMode snap_elements = v3d_cursor_snap_elements(state, scene);
|
||||
eSnapMode snap_elements = v3d_cursor_snap_elements(tool_settings);
|
||||
int snap_elem_index[3] = {-1, -1, -1};
|
||||
int index = -1;
|
||||
|
||||
@@ -700,8 +696,8 @@ static void v3d_cursor_snap_update(V3DSnapCursorState *state,
|
||||
ED_transform_calc_orientation_from_type_ex(
|
||||
scene, view_layer, v3d, rv3d, ob, NULL, orient_index, pivot_point, omat);
|
||||
|
||||
if (state->use_plane_axis_auto) {
|
||||
mat3_align_axis_to_v3(omat, state->plane_axis, rv3d->viewinv[2]);
|
||||
if (tool_settings->use_plane_axis_auto) {
|
||||
mat3_align_axis_to_v3(omat, tool_settings->plane_axis, rv3d->viewinv[2]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -709,7 +705,7 @@ static void v3d_cursor_snap_update(V3DSnapCursorState *state,
|
||||
*
|
||||
* While making orthogonal doesn't always work well (especially with gimbal orientation for
|
||||
* e.g.) it's a corner case, without better alternatives as objects don't support shear. */
|
||||
orthogonalize_m3(omat, state->plane_axis);
|
||||
orthogonalize_m3(omat, tool_settings->plane_axis);
|
||||
|
||||
if (orient_surface) {
|
||||
if (!is_zero_v3(face_nor)) {
|
||||
@@ -733,7 +729,7 @@ static void v3d_cursor_snap_update(V3DSnapCursorState *state,
|
||||
copy_v3_v3(face_nor, no);
|
||||
}
|
||||
else {
|
||||
face_nor[state->plane_axis] = 1.0f;
|
||||
face_nor[tool_settings->plane_axis] = 1.0f;
|
||||
}
|
||||
v3d_cursor_poject_surface_normal(face_nor, obmat, omat);
|
||||
}
|
||||
@@ -747,8 +743,8 @@ static void v3d_cursor_snap_update(V3DSnapCursorState *state,
|
||||
snap_elem &= ~data_intern->snap_elem_hidden;
|
||||
if (snap_elem == SCE_SNAP_MODE_NONE) {
|
||||
RegionView3D *rv3d = region->regiondata;
|
||||
const float *plane_normal = omat[state->plane_axis];
|
||||
bool do_plane_isect = (state->plane_depth != V3D_PLACE_DEPTH_CURSOR_VIEW) &&
|
||||
const float *plane_normal = omat[tool_settings->plane_axis];
|
||||
bool do_plane_isect = (tool_settings->plane_depth != V3D_PLACE_DEPTH_CURSOR_VIEW) &&
|
||||
(rv3d->is_persp ||
|
||||
(fabsf(dot_v3v3(plane_normal, rv3d->viewinv[2])) > eps_view_align));
|
||||
|
||||
@@ -842,6 +838,8 @@ static void v3d_cursor_snap_draw_fn(bContext *C, int x, int y, void *UNUSED(cust
|
||||
SnapCursorDataIntern *data_intern = &g_data_intern;
|
||||
V3DSnapCursorState *state = ED_view3d_cursor_snap_state_active_get();
|
||||
V3DSnapCursorData *snap_data = &data_intern->snap_data;
|
||||
Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
|
||||
Scene *scene = DEG_get_input_scene(depsgraph);
|
||||
|
||||
wmWindowManager *wm = CTX_wm_manager(C);
|
||||
ScrArea *area = CTX_wm_area(C);
|
||||
@@ -849,8 +847,6 @@ static void v3d_cursor_snap_draw_fn(bContext *C, int x, int y, void *UNUSED(cust
|
||||
x -= region->winrct.xmin;
|
||||
y -= region->winrct.ymin;
|
||||
if (v3d_cursor_eventstate_has_changed(data_intern, state, wm, x, y)) {
|
||||
Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
|
||||
Scene *scene = DEG_get_input_scene(depsgraph);
|
||||
View3D *v3d = CTX_wm_view3d(C);
|
||||
v3d_cursor_snap_update(state, C, wm, depsgraph, scene, region, v3d, x, y);
|
||||
}
|
||||
@@ -871,7 +867,7 @@ static void v3d_cursor_snap_draw_fn(bContext *C, int x, int y, void *UNUSED(cust
|
||||
copy_m4_m3(matrix, snap_data->plane_omat);
|
||||
copy_v3_v3(matrix[3], snap_data->loc);
|
||||
|
||||
v3d_cursor_plane_draw(rv3d, state->plane_axis, matrix);
|
||||
v3d_cursor_plane_draw(rv3d, scene->toolsettings->plane_axis, matrix);
|
||||
}
|
||||
|
||||
if (snap_data->snap_elem != SCE_SNAP_MODE_NONE && (state->draw_point || state->draw_box)) {
|
||||
|
||||
@@ -421,7 +421,8 @@ static bool view3d_ruler_item_mousemove(const bContext *C,
|
||||
|
||||
#ifdef USE_AXIS_CONSTRAINTS
|
||||
if (!(ruler_item->flag & RULERITEM_USE_ANGLE) &&
|
||||
ruler_info->constrain_mode != CONSTRAIN_MODE_OFF) {
|
||||
ruler_info->constrain_mode != CONSTRAIN_MODE_OFF)
|
||||
{
|
||||
|
||||
Scene *scene = DEG_get_input_scene(depsgraph);
|
||||
ViewLayer *view_layer = DEG_get_input_view_layer(depsgraph);
|
||||
@@ -1234,7 +1235,6 @@ static void WIDGETGROUP_ruler_setup(const bContext *C, wmGizmoGroup *gzgroup)
|
||||
gzt_snap = WM_gizmotype_find("GIZMO_GT_snap_3d", true);
|
||||
gizmo = WM_gizmo_new_ptr(gzt_snap, gzgroup, nullptr);
|
||||
|
||||
RNA_enum_set(gizmo->ptr, "snap_elements_force", SCE_SNAP_MODE_GEOM);
|
||||
ED_gizmotypes_snap_3d_flag_set(gizmo, V3D_SNAPCURSOR_SNAP_EDIT_GEOM_CAGE);
|
||||
WM_gizmo_set_color(gizmo, blender::float4(1.0f));
|
||||
|
||||
@@ -1386,7 +1386,8 @@ static int view3d_ruler_remove_invoke(bContext *C, wmOperator *op, const wmEvent
|
||||
if (ruler_info->item_active) {
|
||||
RulerItem *ruler_item = ruler_info->item_active;
|
||||
if ((ruler_item->flag & RULERITEM_USE_ANGLE) &&
|
||||
(ruler_item->flag & RULERITEM_USE_ANGLE_ACTIVE)) {
|
||||
(ruler_item->flag & RULERITEM_USE_ANGLE_ACTIVE))
|
||||
{
|
||||
ruler_item->flag &= ~(RULERITEM_USE_ANGLE | RULERITEM_USE_ANGLE_ACTIVE);
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -62,11 +62,6 @@ enum ePlace_Aspect {
|
||||
PLACE_ASPECT_FIXED = 2,
|
||||
};
|
||||
|
||||
enum ePlace_SnapTo {
|
||||
PLACE_SNAP_TO_GEOMETRY = 1,
|
||||
PLACE_SNAP_TO_DEFAULT = 2,
|
||||
};
|
||||
|
||||
struct InteractivePlaceData {
|
||||
/* Window manager variables (set these even when waiting for input). */
|
||||
Scene *scene;
|
||||
@@ -154,7 +149,7 @@ struct InteractivePlaceData {
|
||||
/** When activated without a tool. */
|
||||
bool wait_for_input;
|
||||
|
||||
enum ePlace_SnapTo snap_to;
|
||||
eSnapMode snap_to;
|
||||
};
|
||||
|
||||
/** \} */
|
||||
@@ -219,10 +214,6 @@ static UNUSED_FUNCTION_WITH_RETURN_TYPE(wmGizmoGroup *,
|
||||
static bool idp_snap_calc_incremental(
|
||||
Scene *scene, View3D *v3d, ARegion *region, const float co_relative[3], float co[3])
|
||||
{
|
||||
if ((scene->toolsettings->snap_mode & SCE_SNAP_MODE_INCREMENT) == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const float grid_size = ED_view3d_grid_view_scale(scene, v3d, region, NULL);
|
||||
if (UNLIKELY(grid_size == 0.0f)) {
|
||||
return false;
|
||||
@@ -709,9 +700,9 @@ static bool view3d_interactive_add_calc_snap(bContext *UNUSED(C),
|
||||
static void view3d_interactive_add_begin(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
{
|
||||
V3DSnapCursorState *snap_state = ED_view3d_cursor_snap_state_active_get();
|
||||
ToolSettings *tool_settings = CTX_data_tool_settings(C);
|
||||
|
||||
const int plane_axis = snap_state->plane_axis;
|
||||
const enum ePlace_SnapTo snap_to = RNA_enum_get(op->ptr, "snap_target");
|
||||
const int plane_axis = tool_settings->plane_axis;
|
||||
|
||||
const enum ePlace_Origin plane_origin[2] = {
|
||||
RNA_enum_get(op->ptr, "plane_origin_base"),
|
||||
@@ -767,7 +758,11 @@ static void view3d_interactive_add_begin(bContext *C, wmOperator *op, const wmEv
|
||||
}
|
||||
|
||||
ipd->step_index = STEP_BASE;
|
||||
ipd->snap_to = snap_to;
|
||||
|
||||
ipd->snap_to = tool_settings->snap_mode_tools;
|
||||
if (ipd->snap_to == SCE_SNAP_MODE_NONE) {
|
||||
ipd->snap_to = tool_settings->snap_mode;
|
||||
}
|
||||
|
||||
plane_from_point_normal_v3(ipd->step[0].plane, ipd->co_src, ipd->matrix_orient[plane_axis]);
|
||||
|
||||
@@ -1207,7 +1202,7 @@ static int view3d_interactive_add_modal(bContext *C, wmOperator *op, const wmEve
|
||||
/* pass */
|
||||
}
|
||||
|
||||
if (ipd->use_snap && (ipd->snap_to == PLACE_SNAP_TO_DEFAULT)) {
|
||||
if (ipd->use_snap && (ipd->snap_to & SCE_SNAP_MODE_INCREMENT)) {
|
||||
if (idp_snap_calc_incremental(
|
||||
ipd->scene, ipd->v3d, ipd->region, ipd->co_src, ipd->step[STEP_BASE].co_dst))
|
||||
{
|
||||
@@ -1231,7 +1226,7 @@ static int view3d_interactive_add_modal(bContext *C, wmOperator *op, const wmEve
|
||||
/* pass */
|
||||
}
|
||||
|
||||
if (ipd->use_snap && (ipd->snap_to == PLACE_SNAP_TO_DEFAULT)) {
|
||||
if (ipd->use_snap && (ipd->snap_to & SCE_SNAP_MODE_INCREMENT)) {
|
||||
if (idp_snap_calc_incremental(
|
||||
ipd->scene, ipd->v3d, ipd->region, ipd->co_src, ipd->step[STEP_DEPTH].co_dst))
|
||||
{
|
||||
@@ -1262,98 +1257,6 @@ static bool view3d_interactive_add_poll(bContext *C)
|
||||
return ELEM(mode, CTX_MODE_OBJECT, CTX_MODE_EDIT_MESH);
|
||||
}
|
||||
|
||||
static int idp_rna_plane_axis_get_fn(struct PointerRNA *UNUSED(ptr),
|
||||
struct PropertyRNA *UNUSED(prop))
|
||||
{
|
||||
V3DSnapCursorState *snap_state = ED_view3d_cursor_snap_state_active_get();
|
||||
return snap_state->plane_axis;
|
||||
}
|
||||
|
||||
static void idp_rna_plane_axis_set_fn(struct PointerRNA *UNUSED(ptr),
|
||||
struct PropertyRNA *UNUSED(prop),
|
||||
int value)
|
||||
{
|
||||
V3DSnapCursorState *snap_state = ED_view3d_cursor_snap_state_active_get();
|
||||
snap_state->plane_axis = (short)value;
|
||||
ED_view3d_cursor_snap_state_default_set(snap_state);
|
||||
}
|
||||
|
||||
static int idp_rna_plane_depth_get_fn(struct PointerRNA *UNUSED(ptr),
|
||||
struct PropertyRNA *UNUSED(prop))
|
||||
{
|
||||
V3DSnapCursorState *snap_state = ED_view3d_cursor_snap_state_active_get();
|
||||
return snap_state->plane_depth;
|
||||
}
|
||||
|
||||
static void idp_rna_plane_depth_set_fn(struct PointerRNA *UNUSED(ptr),
|
||||
struct PropertyRNA *UNUSED(prop),
|
||||
int value)
|
||||
{
|
||||
V3DSnapCursorState *snap_state = ED_view3d_cursor_snap_state_active_get();
|
||||
snap_state->plane_depth = value;
|
||||
ED_view3d_cursor_snap_state_default_set(snap_state);
|
||||
}
|
||||
|
||||
static int idp_rna_plane_orient_get_fn(struct PointerRNA *UNUSED(ptr),
|
||||
struct PropertyRNA *UNUSED(prop))
|
||||
{
|
||||
V3DSnapCursorState *snap_state = ED_view3d_cursor_snap_state_active_get();
|
||||
return snap_state->plane_orient;
|
||||
}
|
||||
|
||||
static void idp_rna_plane_orient_set_fn(struct PointerRNA *UNUSED(ptr),
|
||||
struct PropertyRNA *UNUSED(prop),
|
||||
int value)
|
||||
{
|
||||
V3DSnapCursorState *snap_state = ED_view3d_cursor_snap_state_active_get();
|
||||
snap_state->plane_orient = value;
|
||||
ED_view3d_cursor_snap_state_default_set(snap_state);
|
||||
}
|
||||
|
||||
static int idp_rna_snap_target_get_fn(struct PointerRNA *UNUSED(ptr),
|
||||
struct PropertyRNA *UNUSED(prop))
|
||||
{
|
||||
V3DSnapCursorState *snap_state = ED_view3d_cursor_snap_state_active_get();
|
||||
if (snap_state->snap_elem_force == SCE_SNAP_MODE_NONE) {
|
||||
return PLACE_SNAP_TO_DEFAULT;
|
||||
}
|
||||
|
||||
/* Make sure you keep a consistent #snap_mode. */
|
||||
snap_state->snap_elem_force = SCE_SNAP_MODE_GEOM;
|
||||
return PLACE_SNAP_TO_GEOMETRY;
|
||||
}
|
||||
|
||||
static void idp_rna_snap_target_set_fn(struct PointerRNA *UNUSED(ptr),
|
||||
struct PropertyRNA *UNUSED(prop),
|
||||
int value)
|
||||
{
|
||||
eSnapMode snap_mode = SCE_SNAP_MODE_NONE; /* #toolsettings->snap_mode. */
|
||||
const enum ePlace_SnapTo snap_to = value;
|
||||
if (snap_to == PLACE_SNAP_TO_GEOMETRY) {
|
||||
snap_mode = SCE_SNAP_MODE_GEOM;
|
||||
}
|
||||
|
||||
V3DSnapCursorState *snap_state = ED_view3d_cursor_snap_state_active_get();
|
||||
snap_state->snap_elem_force = snap_mode;
|
||||
ED_view3d_cursor_snap_state_default_set(snap_state);
|
||||
}
|
||||
|
||||
static bool idp_rna_use_plane_axis_auto_get_fn(struct PointerRNA *UNUSED(ptr),
|
||||
struct PropertyRNA *UNUSED(prop))
|
||||
{
|
||||
V3DSnapCursorState *snap_state = ED_view3d_cursor_snap_state_active_get();
|
||||
return snap_state->use_plane_axis_auto;
|
||||
}
|
||||
|
||||
static void idp_rna_use_plane_axis_auto_set_fn(struct PointerRNA *UNUSED(ptr),
|
||||
struct PropertyRNA *UNUSED(prop),
|
||||
bool value)
|
||||
{
|
||||
V3DSnapCursorState *snap_state = ED_view3d_cursor_snap_state_active_get();
|
||||
snap_state->use_plane_axis_auto = value;
|
||||
ED_view3d_cursor_snap_state_default_set(snap_state);
|
||||
}
|
||||
|
||||
void VIEW3D_OT_interactive_add(struct wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
@@ -1374,12 +1277,6 @@ void VIEW3D_OT_interactive_add(struct wmOperatorType *ot)
|
||||
/* properties */
|
||||
PropertyRNA *prop;
|
||||
|
||||
/* WORKAROUND: properties with `_funcs_runtime` should not be saved in keymaps.
|
||||
* So reassign the #PROP_IDPROPERTY flag to trick the property as not being set.
|
||||
* (See #RNA_property_is_set). */
|
||||
PropertyFlag unsalvageable = PROP_SKIP_SAVE | PROP_HIDDEN | PROP_PTR_NO_OWNERSHIP |
|
||||
PROP_IDPROPERTY;
|
||||
|
||||
/* Normally not accessed directly, leave unset and check the active tool. */
|
||||
static const EnumPropertyItem primitive_type[] = {
|
||||
{PLACE_PRIMITIVE_TYPE_CUBE, "CUBE", 0, "Cube", ""},
|
||||
@@ -1395,85 +1292,6 @@ void VIEW3D_OT_interactive_add(struct wmOperatorType *ot)
|
||||
RNA_def_property_enum_items(prop, primitive_type);
|
||||
RNA_def_property_flag(prop, PROP_SKIP_SAVE);
|
||||
|
||||
prop = RNA_def_property(ot->srna, "plane_axis", PROP_ENUM, PROP_NONE);
|
||||
RNA_def_property_ui_text(prop, "Plane Axis", "The axis used for placing the base region");
|
||||
RNA_def_property_enum_default(prop, 2);
|
||||
RNA_def_property_enum_items(prop, rna_enum_axis_xyz_items);
|
||||
RNA_def_property_enum_funcs_runtime(
|
||||
prop, idp_rna_plane_axis_get_fn, idp_rna_plane_axis_set_fn, NULL);
|
||||
RNA_def_property_flag(prop, unsalvageable);
|
||||
|
||||
prop = RNA_def_boolean(ot->srna,
|
||||
"plane_axis_auto",
|
||||
false,
|
||||
"Auto Axis",
|
||||
"Select the closest axis when placing objects "
|
||||
"(surface overrides)");
|
||||
RNA_def_property_boolean_funcs_runtime(
|
||||
prop, idp_rna_use_plane_axis_auto_get_fn, idp_rna_use_plane_axis_auto_set_fn);
|
||||
RNA_def_property_flag(prop, unsalvageable);
|
||||
|
||||
static const EnumPropertyItem plane_depth_items[] = {
|
||||
{V3D_PLACE_DEPTH_SURFACE,
|
||||
"SURFACE",
|
||||
0,
|
||||
"Surface",
|
||||
"Start placing on the surface, using the 3D cursor position as a fallback"},
|
||||
{V3D_PLACE_DEPTH_CURSOR_PLANE,
|
||||
"CURSOR_PLANE",
|
||||
0,
|
||||
"Cursor Plane",
|
||||
"Start placement using a point projected onto the orientation axis "
|
||||
"at the 3D cursor position"},
|
||||
{V3D_PLACE_DEPTH_CURSOR_VIEW,
|
||||
"CURSOR_VIEW",
|
||||
0,
|
||||
"Cursor View",
|
||||
"Start placement using a point projected onto the view plane at the 3D cursor position"},
|
||||
{0, NULL, 0, NULL, NULL},
|
||||
};
|
||||
prop = RNA_def_property(ot->srna, "plane_depth", PROP_ENUM, PROP_NONE);
|
||||
RNA_def_property_ui_text(prop, "Position", "The initial depth used when placing the cursor");
|
||||
RNA_def_property_enum_default(prop, V3D_PLACE_DEPTH_SURFACE);
|
||||
RNA_def_property_enum_items(prop, plane_depth_items);
|
||||
RNA_def_property_enum_funcs_runtime(
|
||||
prop, idp_rna_plane_depth_get_fn, idp_rna_plane_depth_set_fn, NULL);
|
||||
RNA_def_property_flag(prop, unsalvageable);
|
||||
|
||||
static const EnumPropertyItem plane_orientation_items[] = {
|
||||
{V3D_PLACE_ORIENT_SURFACE,
|
||||
"SURFACE",
|
||||
ICON_SNAP_NORMAL,
|
||||
"Surface",
|
||||
"Use the surface normal (using the transform orientation as a fallback)"},
|
||||
{V3D_PLACE_ORIENT_DEFAULT,
|
||||
"DEFAULT",
|
||||
ICON_ORIENTATION_GLOBAL,
|
||||
"Default",
|
||||
"Use the current transform orientation"},
|
||||
{0, NULL, 0, NULL, NULL},
|
||||
};
|
||||
prop = RNA_def_property(ot->srna, "plane_orientation", PROP_ENUM, PROP_NONE);
|
||||
RNA_def_property_ui_text(prop, "Orientation", "The initial depth used when placing the cursor");
|
||||
RNA_def_property_enum_default(prop, V3D_PLACE_ORIENT_SURFACE);
|
||||
RNA_def_property_enum_items(prop, plane_orientation_items);
|
||||
RNA_def_property_enum_funcs_runtime(
|
||||
prop, idp_rna_plane_orient_get_fn, idp_rna_plane_orient_set_fn, NULL);
|
||||
RNA_def_property_flag(prop, unsalvageable);
|
||||
|
||||
static const EnumPropertyItem snap_to_items[] = {
|
||||
{PLACE_SNAP_TO_GEOMETRY, "GEOMETRY", 0, "Geometry", "Snap to all geometry"},
|
||||
{PLACE_SNAP_TO_DEFAULT, "DEFAULT", 0, "Default", "Use the current snap settings"},
|
||||
{0, NULL, 0, NULL, NULL},
|
||||
};
|
||||
prop = RNA_def_property(ot->srna, "snap_target", PROP_ENUM, PROP_NONE);
|
||||
RNA_def_property_ui_text(prop, "Snap to", "The target to use while snapping");
|
||||
RNA_def_property_enum_default(prop, PLACE_SNAP_TO_GEOMETRY);
|
||||
RNA_def_property_enum_items(prop, snap_to_items);
|
||||
RNA_def_property_enum_funcs_runtime(
|
||||
prop, idp_rna_snap_target_get_fn, idp_rna_snap_target_set_fn, NULL);
|
||||
RNA_def_property_flag(prop, unsalvageable);
|
||||
|
||||
{ /* Plane Origin. */
|
||||
static const EnumPropertyItem items[] = {
|
||||
{PLACE_ORIGIN_BASE, "EDGE", 0, "Edge", "Start placing the edge position"},
|
||||
|
||||
@@ -366,6 +366,10 @@
|
||||
/* UV painting */ \
|
||||
.uv_sculpt_settings = 0, \
|
||||
.uv_relax_method = UV_SCULPT_TOOL_RELAX_LAPLACIAN, \
|
||||
\
|
||||
/* Placement */ \
|
||||
.snap_mode_tools = SCE_SNAP_MODE_GEOM,\
|
||||
.plane_axis = 2,\
|
||||
}
|
||||
|
||||
/* clang-format off */
|
||||
|
||||
@@ -1695,6 +1695,13 @@ typedef struct ToolSettings {
|
||||
|
||||
struct SequencerToolSettings *sequencer_tool_settings;
|
||||
|
||||
short snap_mode_tools; /* If SCE_SNAP_MODE_NONE, use #ToolSettings::snap_mode. #eSnapMode. */
|
||||
char plane_axis; /* X, Y or Z. */
|
||||
char plane_depth; /* #eV3DPlaceDepth. */
|
||||
char plane_orient; /* #eV3DPlaceOrient. */
|
||||
char use_plane_axis_auto;
|
||||
char _pad7[2];
|
||||
|
||||
} ToolSettings;
|
||||
|
||||
/** \} */
|
||||
|
||||
@@ -676,6 +676,18 @@ enum {
|
||||
V3D_GIZMO_SHOW_CAMERA_DOF_DIST = (1 << 2),
|
||||
};
|
||||
|
||||
/** #ToolSettings.plane_depth */
|
||||
typedef enum {
|
||||
V3D_PLACE_DEPTH_SURFACE = 0,
|
||||
V3D_PLACE_DEPTH_CURSOR_PLANE = 1,
|
||||
V3D_PLACE_DEPTH_CURSOR_VIEW = 2,
|
||||
} eV3DPlaceDepth;
|
||||
/** #ToolSettings.plane_orient */
|
||||
typedef enum {
|
||||
V3D_PLACE_ORIENT_SURFACE = 0,
|
||||
V3D_PLACE_ORIENT_DEFAULT = 1,
|
||||
} eV3DPlaceOrient;
|
||||
|
||||
#define RV3D_CAMZOOM_MIN -30
|
||||
#define RV3D_CAMZOOM_MAX 600
|
||||
|
||||
|
||||
@@ -637,6 +637,46 @@ const EnumPropertyItem rna_enum_transform_orientation_items[] = {
|
||||
{0, NULL, 0, NULL, NULL},
|
||||
};
|
||||
|
||||
static const EnumPropertyItem plane_depth_items[] = {
|
||||
{V3D_PLACE_DEPTH_SURFACE,
|
||||
"SURFACE",
|
||||
0,
|
||||
"Surface",
|
||||
"Start placing on the surface, using the 3D cursor position as a fallback"},
|
||||
{V3D_PLACE_DEPTH_CURSOR_PLANE,
|
||||
"CURSOR_PLANE",
|
||||
0,
|
||||
"Cursor Plane",
|
||||
"Start placement using a point projected onto the orientation axis "
|
||||
"at the 3D cursor position"},
|
||||
{V3D_PLACE_DEPTH_CURSOR_VIEW,
|
||||
"CURSOR_VIEW",
|
||||
0,
|
||||
"Cursor View",
|
||||
"Start placement using a point projected onto the view plane at the 3D cursor position"},
|
||||
{0, NULL, 0, NULL, NULL},
|
||||
};
|
||||
|
||||
static const EnumPropertyItem plane_orientation_items[] = {
|
||||
{V3D_PLACE_ORIENT_SURFACE,
|
||||
"SURFACE",
|
||||
ICON_SNAP_NORMAL,
|
||||
"Surface",
|
||||
"Use the surface normal (using the transform orientation as a fallback)"},
|
||||
{V3D_PLACE_ORIENT_DEFAULT,
|
||||
"DEFAULT",
|
||||
ICON_ORIENTATION_GLOBAL,
|
||||
"Default",
|
||||
"Use the current transform orientation"},
|
||||
{0, NULL, 0, NULL, NULL},
|
||||
};
|
||||
|
||||
static const EnumPropertyItem snap_to_items[] = {
|
||||
{SCE_SNAP_MODE_GEOM, "GEOMETRY", 0, "Geometry", "Snap to all geometry"},
|
||||
{SCE_SNAP_MODE_NONE, "DEFAULT", 0, "Default", "Use the current snap settings"},
|
||||
{0, NULL, 0, NULL, NULL},
|
||||
};
|
||||
|
||||
#ifdef RNA_RUNTIME
|
||||
|
||||
# include "BLI_string_utils.h"
|
||||
@@ -3471,6 +3511,38 @@ static void rna_def_tool_settings(BlenderRNA *brna)
|
||||
RNA_def_property_ui_text(prop, "Use Snap for Scale", "Scale is affected by snapping settings");
|
||||
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); /* header redraw */
|
||||
|
||||
prop = RNA_def_property(srna, "plane_axis", PROP_ENUM, PROP_NONE);
|
||||
RNA_def_property_enum_sdna(prop, NULL, "plane_axis");
|
||||
RNA_def_property_enum_items(prop, rna_enum_axis_xyz_items);
|
||||
RNA_def_property_enum_default(prop, 2);
|
||||
RNA_def_property_ui_text(prop, "Plane Axis", "The axis used for placing the base region");
|
||||
|
||||
prop = RNA_def_property(srna, "plane_axis_auto", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "use_plane_axis_auto", 1);
|
||||
RNA_def_property_boolean_default(prop, true);
|
||||
RNA_def_property_ui_text(prop,
|
||||
"Auto Axis",
|
||||
"Select the closest axis when placing objects "
|
||||
"(surface overrides)");
|
||||
|
||||
prop = RNA_def_property(srna, "plane_depth", PROP_ENUM, PROP_NONE);
|
||||
RNA_def_property_enum_sdna(prop, NULL, "plane_depth");
|
||||
RNA_def_property_enum_items(prop, plane_depth_items);
|
||||
RNA_def_property_enum_default(prop, V3D_PLACE_DEPTH_SURFACE);
|
||||
RNA_def_property_ui_text(prop, "Position", "The initial depth used when placing the cursor");
|
||||
|
||||
prop = RNA_def_property(srna, "plane_orientation", PROP_ENUM, PROP_NONE);
|
||||
RNA_def_property_enum_sdna(prop, NULL, "plane_orient");
|
||||
RNA_def_property_enum_items(prop, plane_orientation_items);
|
||||
RNA_def_property_enum_default(prop, V3D_PLACE_ORIENT_SURFACE);
|
||||
RNA_def_property_ui_text(prop, "Orientation", "The initial depth used when placing the cursor");
|
||||
|
||||
prop = RNA_def_property(srna, "snap_elements_tool", PROP_ENUM, PROP_NONE);
|
||||
RNA_def_property_enum_sdna(prop, NULL, "snap_mode_tools");
|
||||
RNA_def_property_enum_items(prop, snap_to_items);
|
||||
RNA_def_property_enum_default(prop, SCE_SNAP_MODE_GEOM);
|
||||
RNA_def_property_ui_text(prop, "Snap to", "The target to use while snapping");
|
||||
|
||||
/* Grease Pencil */
|
||||
prop = RNA_def_property(srna, "use_gpencil_draw_additive", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "gpencil_flags", GP_TOOL_FLAG_RETAIN_LAST);
|
||||
|
||||
Reference in New Issue
Block a user