Fix T42613: Sculpt dyntopo's 'Set Detail Size' (Shift-D) was only always affecting relative size.

This commit is contained in:
Bastien Montagne 2014-11-16 10:54:03 +01:00
parent e5ad6348b9
commit 10813996e8
Notes: blender-bot 2023-02-14 09:49:30 +01:00
Referenced by issue #42613, Dyntopo, Constant Detail mode
Referenced by issue #42613, Dyntopo, Constant Detail mode
3 changed files with 61 additions and 14 deletions

View File

@ -245,6 +245,18 @@ typedef enum BrushStrokeMode {
BRUSH_STROKE_SMOOTH
} BrushStrokeMode;
/* paint_ops.c */
typedef enum {
RC_COLOR = 1,
RC_ROTATION = 2,
RC_ZOOM = 4,
RC_WEIGHT = 8,
RC_SECONDARY_ROTATION = 16
} RCFlags;
void set_brush_rc_props(struct PointerRNA *ptr, const char *paint, const char *prop, const char *secondary_prop,
RCFlags flags);
/* paint_undo.c */
struct ListBase *undo_paint_push_get_list(int type);
void undo_paint_push_count_alloc(int type, int size);

View File

@ -1149,14 +1149,6 @@ static void ed_keymap_paint_brush_size(wmKeyMap *keymap, const char *UNUSED(path
RNA_float_set(kmi->ptr, "scalar", 10.0 / 9.0); // 1.1111....
}
typedef enum {
RC_COLOR = 1,
RC_ROTATION = 2,
RC_ZOOM = 4,
RC_WEIGHT = 8,
RC_SECONDARY_ROTATION = 16
} RCFlags;
static void set_brush_rc_path(PointerRNA *ptr, const char *brush_path,
const char *output_name, const char *input_name)
{
@ -1167,9 +1159,9 @@ static void set_brush_rc_path(PointerRNA *ptr, const char *brush_path,
MEM_freeN(path);
}
static void set_brush_rc_props(PointerRNA *ptr, const char *paint,
const char *prop, const char *secondary_prop,
RCFlags flags)
void set_brush_rc_props(PointerRNA *ptr, const char *paint,
const char *prop, const char *secondary_prop,
RCFlags flags)
{
const char *ups_path = "tool_settings.unified_paint_settings";
char *brush_path;
@ -1325,9 +1317,7 @@ void ED_keymap_paint(wmKeyConfig *keyconf)
*
* This should be improved further, perhaps by showing a triangle
* grid rather than brush alpha */
kmi = WM_keymap_add_item(keymap, "WM_OT_radial_control", DKEY, KM_PRESS, KM_SHIFT, 0);
set_brush_rc_props(kmi->ptr, "sculpt", "detail_size", NULL, 0);
RNA_string_set(kmi->ptr, "data_path_primary", "tool_settings.sculpt.detail_size");
kmi = WM_keymap_add_item(keymap, "SCULPT_OT_set_detail_size", DKEY, KM_PRESS, KM_SHIFT, 0);
/* multires switch */
kmi = WM_keymap_add_item(keymap, "OBJECT_OT_subdivision_set", PAGEUPKEY, KM_PRESS, 0, 0);

View File

@ -5188,6 +5188,50 @@ static void SCULPT_OT_sample_detail_size(wmOperatorType *ot)
RNA_def_int_array(ot->srna, "location", 2, NULL, 0, SHRT_MAX, "Location", "Screen Coordinates of sampling", 0, SHRT_MAX);
}
static int sculpt_set_detail_size_exec(bContext *C, wmOperator *UNUSED(op))
{
Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
PointerRNA props_ptr;
wmOperatorType *ot = WM_operatortype_find("WM_OT_radial_control", true);
WM_operator_properties_create_ptr(&props_ptr, ot);
if (sd->flags & SCULPT_DYNTOPO_DETAIL_CONSTANT) {
set_brush_rc_props(&props_ptr, "sculpt", "constant_detail", NULL, 0);
RNA_string_set(&props_ptr, "data_path_primary", "tool_settings.sculpt.constant_detail");
}
else {
set_brush_rc_props(&props_ptr, "sculpt", "detail_size", NULL, 0);
RNA_string_set(&props_ptr, "data_path_primary", "tool_settings.sculpt.detail_size");
}
WM_operator_name_call_ptr(C, ot, WM_OP_INVOKE_DEFAULT, &props_ptr);
WM_operator_properties_free(&props_ptr);
return OPERATOR_FINISHED;
}
static void SCULPT_OT_set_detail_size(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Set Detail Size";
ot->idname = "SCULPT_OT_set_detail_size";
ot->description = "Set the mesh detail (either relative or constant one, depending on current dyntopo mode)";
/* api callbacks */
//ot->invoke = sculpt_set_detail_size_invoke;
ot->exec = sculpt_set_detail_size_exec;
//ot->modal = sculpt_set_detail_size_modal;
ot->poll = sculpt_and_dynamic_topology_poll;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
//RNA_def_int_array(ot->srna, "location", 2, NULL, 0, SHRT_MAX, "Location", "Screen Coordinates of sampling", 0, SHRT_MAX);
}
void ED_operatortypes_sculpt(void)
{
WM_operatortype_append(SCULPT_OT_brush_stroke);
@ -5198,4 +5242,5 @@ void ED_operatortypes_sculpt(void)
WM_operatortype_append(SCULPT_OT_symmetrize);
WM_operatortype_append(SCULPT_OT_detail_flood_fill);
WM_operatortype_append(SCULPT_OT_sample_detail_size);
WM_operatortype_append(SCULPT_OT_set_detail_size);
}