Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/transform/transform_gizmo_3d.c
| Show First 20 Lines • Show All 992 Lines • ▼ Show 20 Lines | |||||
| WM_gizmo_set_matrix_location(widget, rv3d->twmat[3]); | WM_gizmo_set_matrix_location(widget, rv3d->twmat[3]); | ||||
| } | } | ||||
| ED_region_tag_redraw_editor_overlays(region); | ED_region_tag_redraw_editor_overlays(region); | ||||
| return OPERATOR_RUNNING_MODAL; | return OPERATOR_RUNNING_MODAL; | ||||
| } | } | ||||
| static void gizmogroup_init_properties_from_twtype(wmGizmoGroup *gzgroup) | static void gizmogroup_init_properties_from_twtype(const bContext *C, wmGizmoGroup *gzgroup) | ||||
| { | { | ||||
| struct { | struct { | ||||
| wmOperatorType *translate, *rotate, *trackball, *resize; | wmOperatorType *translate, *rotate, *trackball, *resize; | ||||
| wmOperatorType *extra_translate, *extra_rotate, *extra_trackball, *extra_resize; | |||||
| } ot_store = {NULL}; | } ot_store = {NULL}; | ||||
| GizmoGroup *ggd = gzgroup->customdata; | GizmoGroup *ggd = gzgroup->customdata; | ||||
| const eContextObjectMode mode = CTX_data_mode_enum(C); | |||||
| MAN_ITER_AXES_BEGIN (axis, axis_idx) { | MAN_ITER_AXES_BEGIN (axis, axis_idx) { | ||||
| const short axis_type = gizmo_get_axis_type(axis_idx); | const short axis_type = gizmo_get_axis_type(axis_idx); | ||||
| bool constraint_axis[3] = {1, 0, 0}; | bool constraint_axis[3] = {1, 0, 0}; | ||||
| PointerRNA *ptr = NULL; | PointerRNA *ptr = NULL; | ||||
| PointerRNA *ptr_extra = NULL; | |||||
| gizmo_get_axis_constraint(axis_idx, constraint_axis); | gizmo_get_axis_constraint(axis_idx, constraint_axis); | ||||
| /* custom handler! */ | /* custom handler! */ | ||||
| WM_gizmo_set_fn_custom_modal(axis, gizmo_modal); | WM_gizmo_set_fn_custom_modal(axis, gizmo_modal); | ||||
| switch (axis_idx) { | switch (axis_idx) { | ||||
| case MAN_AXIS_TRANS_X: | case MAN_AXIS_TRANS_X: | ||||
| ▲ Show 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | |||||
| break; | break; | ||||
| } | } | ||||
| switch (axis_type) { | switch (axis_type) { | ||||
| case MAN_AXES_TRANSLATE: | case MAN_AXES_TRANSLATE: | ||||
| if (ot_store.translate == NULL) { | if (ot_store.translate == NULL) { | ||||
| ot_store.translate = WM_operatortype_find("TRANSFORM_OT_translate", true); | ot_store.translate = WM_operatortype_find("TRANSFORM_OT_translate", true); | ||||
| } | } | ||||
| if (ot_store.extra_translate == NULL) { | |||||
| switch (mode) { | |||||
| default: break; | |||||
| case CTX_MODE_OBJECT: | |||||
| ot_store.extra_translate = WM_operatortype_find("OBJECT_OT_duplicate_move", true); | |||||
| break; | |||||
| case CTX_MODE_EDIT_MESH: | |||||
| ot_store.extra_translate = WM_operatortype_find("MESH_OT_extrude_context_move", true); | |||||
| break; | |||||
| } | |||||
| } | |||||
| if (ot_store.extra_translate) { | |||||
| ptr_extra = WM_gizmo_operator_set(axis, 16, ot_store.extra_translate, NULL); | |||||
| } | |||||
| ptr = WM_gizmo_operator_set(axis, 0, ot_store.translate, NULL); | ptr = WM_gizmo_operator_set(axis, 0, ot_store.translate, NULL); | ||||
| break; | break; | ||||
| case MAN_AXES_ROTATE: { | case MAN_AXES_ROTATE: { | ||||
| wmOperatorType *ot_rotate; | wmOperatorType *ot_rotate; | ||||
| wmOperatorType *ot_rotate_extra; | |||||
| if (axis_idx == MAN_AXIS_ROT_T) { | if (axis_idx == MAN_AXIS_ROT_T) { | ||||
| if (ot_store.trackball == NULL) { | if (ot_store.trackball == NULL) { | ||||
| ot_store.trackball = WM_operatortype_find("TRANSFORM_OT_trackball", true); | ot_store.trackball = WM_operatortype_find("TRANSFORM_OT_trackball", true); | ||||
| } | } | ||||
| if (ot_store.extra_trackball == NULL) { | |||||
| switch (mode) { | |||||
| default: break; | |||||
| case CTX_MODE_OBJECT: | |||||
| ot_store.extra_trackball = WM_operatortype_find("OBJECT_OT_duplicate_trackball", true); | |||||
| break; | |||||
| case CTX_MODE_EDIT_MESH: | |||||
| ot_store.extra_trackball = WM_operatortype_find("MESH_OT_extrude_context_trackball", true); | |||||
| break; | |||||
| } | |||||
| } | |||||
| ot_rotate = ot_store.trackball; | ot_rotate = ot_store.trackball; | ||||
| ot_rotate_extra = ot_store.extra_trackball; | |||||
| } | } | ||||
| else { | else { | ||||
| if (ot_store.rotate == NULL) { | if (ot_store.rotate == NULL) { | ||||
| ot_store.rotate = WM_operatortype_find("TRANSFORM_OT_rotate", true); | ot_store.rotate = WM_operatortype_find("TRANSFORM_OT_rotate", true); | ||||
| } | } | ||||
| if (ot_store.extra_rotate == NULL) { | |||||
| switch (mode) { | |||||
| default: break; | |||||
| case CTX_MODE_OBJECT: | |||||
| ot_store.extra_rotate = WM_operatortype_find("OBJECT_OT_duplicate_rotate", true); | |||||
| break; | |||||
| case CTX_MODE_EDIT_MESH: | |||||
| ot_store.extra_rotate = WM_operatortype_find("MESH_OT_extrude_context_rotate", true); | |||||
| break; | |||||
| } | |||||
| } | |||||
| ot_rotate = ot_store.rotate; | ot_rotate = ot_store.rotate; | ||||
| ot_rotate_extra = ot_store.extra_rotate; | |||||
| } | |||||
| if (ot_rotate_extra) { | |||||
| ptr_extra = WM_gizmo_operator_set(axis, 16, ot_rotate_extra, NULL); | |||||
| } | } | ||||
| ptr = WM_gizmo_operator_set(axis, 0, ot_rotate, NULL); | ptr = WM_gizmo_operator_set(axis, 0, ot_rotate, NULL); | ||||
| break; | break; | ||||
| } | } | ||||
| case MAN_AXES_SCALE: { | case MAN_AXES_SCALE: { | ||||
| if (ot_store.resize == NULL) { | if (ot_store.resize == NULL) { | ||||
| ot_store.resize = WM_operatortype_find("TRANSFORM_OT_resize", true); | ot_store.resize = WM_operatortype_find("TRANSFORM_OT_resize", true); | ||||
| } | } | ||||
| if (ot_store.extra_resize == NULL) { | |||||
| switch (mode) { | |||||
| default: break; | |||||
| case CTX_MODE_OBJECT: | |||||
| ot_store.extra_resize = WM_operatortype_find("OBJECT_OT_duplicate_resize", true); | |||||
| break; | |||||
| case CTX_MODE_EDIT_MESH: | |||||
| ot_store.extra_resize = WM_operatortype_find("MESH_OT_extrude_context_resize", true); | |||||
| break; | |||||
| } | |||||
| } | |||||
| if (ot_store.extra_resize) { | |||||
| ptr_extra = WM_gizmo_operator_set(axis, 16, ot_store.extra_resize, NULL); | |||||
| } | |||||
| ptr = WM_gizmo_operator_set(axis, 0, ot_store.resize, NULL); | ptr = WM_gizmo_operator_set(axis, 0, ot_store.resize, NULL); | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| if (ptr_extra) { | |||||
| RNA_STRUCT_BEGIN(ptr_extra, prop) { | |||||
| if (RNA_property_type(prop) != PROP_POINTER) | |||||
| continue; | |||||
| PointerRNA propptr = RNA_property_pointer_get(ptr_extra, prop); | |||||
| if (!propptr.data || !RNA_struct_is_a(propptr.type, &RNA_OperatorProperties)) | |||||
| continue; | |||||
| PropertyRNA *constr = NULL; | |||||
| if (ELEM(true, UNPACK3(constraint_axis))) { | |||||
| if ((constr = RNA_struct_find_property(&propptr, "constraint_axis"))) { | |||||
| RNA_property_boolean_set_array(&propptr, constr, constraint_axis); | |||||
| } | |||||
| } | |||||
| if (constr) | |||||
| RNA_boolean_set(&propptr, "release_confirm", 1); | |||||
| } | |||||
| RNA_STRUCT_END; | |||||
| } | |||||
| if (ptr) { | if (ptr) { | ||||
| PropertyRNA *prop; | PropertyRNA *prop; | ||||
| if (ELEM(true, UNPACK3(constraint_axis))) { | if (ELEM(true, UNPACK3(constraint_axis))) { | ||||
| if ((prop = RNA_struct_find_property(ptr, "constraint_axis"))) { | if ((prop = RNA_struct_find_property(ptr, "constraint_axis"))) { | ||||
| RNA_property_boolean_set_array(ptr, prop, constraint_axis); | RNA_property_boolean_set_array(ptr, prop, constraint_axis); | ||||
| } | } | ||||
| } | } | ||||
| RNA_boolean_set(ptr, "release_confirm", 1); | RNA_boolean_set(ptr, "release_confirm", 1); | ||||
| } | } | ||||
| } | } | ||||
| MAN_ITER_AXES_END; | MAN_ITER_AXES_END; | ||||
| } | } | ||||
| static void WIDGETGROUP_gizmo_setup(const bContext *C, wmGizmoGroup *gzgroup) | static void WIDGETGROUP_gizmo_setup(const bContext *C, wmGizmoGroup *gzgroup) | ||||
| { | { | ||||
| GizmoGroup *ggd = gizmogroup_init(gzgroup); | GizmoGroup *ggd = gizmogroup_init(gzgroup); | ||||
| Show All 24 Lines | |||||
| V3D_GIZMO_SHOW_OBJECT_SCALE; | V3D_GIZMO_SHOW_OBJECT_SCALE; | ||||
| ggd->use_twtype_refresh = true; | ggd->use_twtype_refresh = true; | ||||
| } | } | ||||
| BLI_assert(ggd->twtype != 0); | BLI_assert(ggd->twtype != 0); | ||||
| ggd->twtype_init = ggd->twtype; | ggd->twtype_init = ggd->twtype; | ||||
| } | } | ||||
| /* *** set properties for axes *** */ | /* *** set properties for axes *** */ | ||||
| gizmogroup_init_properties_from_twtype(gzgroup); | gizmogroup_init_properties_from_twtype(C, gzgroup); | ||||
| } | } | ||||
| static void WIDGETGROUP_gizmo_refresh(const bContext *C, wmGizmoGroup *gzgroup) | static void WIDGETGROUP_gizmo_refresh(const bContext *C, wmGizmoGroup *gzgroup) | ||||
| { | { | ||||
| GizmoGroup *ggd = gzgroup->customdata; | GizmoGroup *ggd = gzgroup->customdata; | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| ScrArea *area = CTX_wm_area(C); | ScrArea *area = CTX_wm_area(C); | ||||
| View3D *v3d = area->spacedata.first; | View3D *v3d = area->spacedata.first; | ||||
| ARegion *region = CTX_wm_region(C); | ARegion *region = CTX_wm_region(C); | ||||
| RegionView3D *rv3d = region->regiondata; | RegionView3D *rv3d = region->regiondata; | ||||
| struct TransformBounds tbounds; | struct TransformBounds tbounds; | ||||
| if (scene->toolsettings->workspace_tool_type == SCE_WORKSPACE_TOOL_FALLBACK) { | if (scene->toolsettings->workspace_tool_type == SCE_WORKSPACE_TOOL_FALLBACK) { | ||||
| gzgroup->use_fallback_keymap = true; | gzgroup->use_fallback_keymap = true; | ||||
| } | } | ||||
| else { | else { | ||||
| gzgroup->use_fallback_keymap = false; | gzgroup->use_fallback_keymap = false; | ||||
| } | } | ||||
| if (ggd->use_twtype_refresh) { | if (ggd->use_twtype_refresh) { | ||||
| ggd->twtype = v3d->gizmo_show_object & ggd->twtype_init; | ggd->twtype = v3d->gizmo_show_object & ggd->twtype_init; | ||||
| if (ggd->twtype != ggd->twtype_prev) { | if (ggd->twtype != ggd->twtype_prev) { | ||||
| ggd->twtype_prev = ggd->twtype; | ggd->twtype_prev = ggd->twtype; | ||||
| gizmogroup_init_properties_from_twtype(gzgroup); | gizmogroup_init_properties_from_twtype(C, gzgroup); | ||||
| } | } | ||||
| } | } | ||||
| const TransformOrientationSlot *orient_slot = BKE_scene_orientation_slot_get_from_flag( | const TransformOrientationSlot *orient_slot = BKE_scene_orientation_slot_get_from_flag( | ||||
| scene, ggd->twtype_init); | scene, ggd->twtype_init); | ||||
| /* skip, we don't draw anything anyway */ | /* skip, we don't draw anything anyway */ | ||||
| if ((ggd->all_hidden = (ED_transform_calc_gizmo_stats( | if ((ggd->all_hidden = (ED_transform_calc_gizmo_stats( | ||||
| ▲ Show 20 Lines • Show All 786 Lines • Show Last 20 Lines | |||||