Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/transform/transform_manipulator.c
| Show First 20 Lines • Show All 59 Lines • ▼ Show 20 Lines | |||||
| #include "BKE_lattice.h" | #include "BKE_lattice.h" | ||||
| #include "BKE_gpencil.h" | #include "BKE_gpencil.h" | ||||
| #include "BKE_workspace.h" | #include "BKE_workspace.h" | ||||
| #include "BIF_gl.h" | #include "BIF_gl.h" | ||||
| #include "WM_api.h" | #include "WM_api.h" | ||||
| #include "WM_types.h" | #include "WM_types.h" | ||||
| #include "WM_message.h" | |||||
| #include "ED_armature.h" | #include "ED_armature.h" | ||||
| #include "ED_curve.h" | #include "ED_curve.h" | ||||
| #include "ED_object.h" | #include "ED_object.h" | ||||
| #include "ED_particle.h" | #include "ED_particle.h" | ||||
| #include "ED_view3d.h" | #include "ED_view3d.h" | ||||
| #include "ED_gpencil.h" | #include "ED_gpencil.h" | ||||
| #include "ED_screen.h" | #include "ED_screen.h" | ||||
| ▲ Show 20 Lines • Show All 1,034 Lines • ▼ Show 20 Lines | case MAN_AXES_SCALE: | ||||
| *r_len -= ofs + 0.025f; | *r_len -= ofs + 0.025f; | ||||
| } | } | ||||
| break; | break; | ||||
| } | } | ||||
| *r_len -= *r_start; | *r_len -= *r_start; | ||||
| } | } | ||||
| static void manipulator_xform_msg_subscribe( | |||||
| const bContext *C, wmManipulatorGroup *mgroup, | |||||
| bScreen *screen, ScrArea *sa, ARegion *ar, const void *type_fn) | |||||
| { | |||||
| /* Subscribe to view properties */ | |||||
| struct wmMsgBus *mbus = CTX_wm_message_bus(C); | |||||
| wmMsgSubscribeValue msg_sub_value_mpr_tag_refresh = { | |||||
| .owner = ar, | |||||
| .user_data = mgroup->parent_mmap, | |||||
| .notify = WM_manipulator_do_msg_notify_tag_refresh, | |||||
| }; | |||||
| PointerRNA space_ptr; | |||||
| RNA_pointer_create(&screen->id, &RNA_SpaceView3D, sa->spacedata.first, &space_ptr); | |||||
| { | |||||
| extern PropertyRNA rna_SpaceView3D_transform_orientation; | |||||
| const PropertyRNA *props[] = { | |||||
| &rna_SpaceView3D_transform_orientation, | |||||
| }; | |||||
| for (int i = 0; i < ARRAY_SIZE(props); i++) { | |||||
| WM_msg_subscribe_rna(mbus, &space_ptr, props[i], &msg_sub_value_mpr_tag_refresh, __func__); | |||||
| } | |||||
| } | |||||
| if (type_fn == TRANSFORM_WGT_manipulator) { | |||||
| extern PropertyRNA rna_SpaceView3D_pivot_point; | |||||
| const PropertyRNA *props[] = { | |||||
| &rna_SpaceView3D_pivot_point | |||||
| }; | |||||
| for (int i = 0; i < ARRAY_SIZE(props); i++) { | |||||
| WM_msg_subscribe_rna(mbus, &space_ptr, props[i], &msg_sub_value_mpr_tag_refresh, __func__); | |||||
| } | |||||
| } | |||||
| else if (type_fn == VIEW3D_WGT_xform_cage) { | |||||
| /* pass */ | |||||
| } | |||||
| else { | |||||
| BLI_assert(0); | |||||
| } | |||||
| } | |||||
| /** \} */ | /** \} */ | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Transform Manipulator | /** \name Transform Manipulator | ||||
| * \{ */ | * \{ */ | ||||
| static ManipulatorGroup *manipulatorgroup_init(wmManipulatorGroup *mgroup) | static ManipulatorGroup *manipulatorgroup_init(wmManipulatorGroup *mgroup) | ||||
| ▲ Show 20 Lines • Show All 255 Lines • ▼ Show 20 Lines | MAN_ITER_AXES_BEGIN(axis, axis_idx) | ||||
| } | } | ||||
| } | } | ||||
| MAN_ITER_AXES_END; | MAN_ITER_AXES_END; | ||||
| } | } | ||||
| static void WIDGETGROUP_manipulator_draw_prepare(const bContext *C, wmManipulatorGroup *mgroup) | static void WIDGETGROUP_manipulator_draw_prepare(const bContext *C, wmManipulatorGroup *mgroup) | ||||
| { | { | ||||
| ManipulatorGroup *man = mgroup->customdata; | ManipulatorGroup *man = mgroup->customdata; | ||||
| bScreen *screen = CTX_wm_screen(C); | |||||
| ScrArea *sa = CTX_wm_area(C); | ScrArea *sa = CTX_wm_area(C); | ||||
| ARegion *ar = CTX_wm_region(C); | ARegion *ar = CTX_wm_region(C); | ||||
| View3D *v3d = sa->spacedata.first; | View3D *v3d = sa->spacedata.first; | ||||
| RegionView3D *rv3d = ar->regiondata; | RegionView3D *rv3d = ar->regiondata; | ||||
| float idot[3]; | float idot[3]; | ||||
| /* when looking through a selected camera, the manipulator can be at the | /* when looking through a selected camera, the manipulator can be at the | ||||
| * exact same position as the view, skip so we don't break selection */ | * exact same position as the view, skip so we don't break selection */ | ||||
| Show All 31 Lines | switch (axis_idx) { | ||||
| case MAN_AXIS_ROT_C: | case MAN_AXIS_ROT_C: | ||||
| case MAN_AXIS_SCALE_C: | case MAN_AXIS_SCALE_C: | ||||
| case MAN_AXIS_ROT_T: | case MAN_AXIS_ROT_T: | ||||
| WM_manipulator_set_matrix_rotation_from_z_axis(axis, rv3d->viewinv[2]); | WM_manipulator_set_matrix_rotation_from_z_axis(axis, rv3d->viewinv[2]); | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| MAN_ITER_AXES_END; | MAN_ITER_AXES_END; | ||||
| manipulator_xform_msg_subscribe(C, mgroup, screen, sa, ar, TRANSFORM_WGT_manipulator); | |||||
| } | } | ||||
| static bool WIDGETGROUP_manipulator_poll(const struct bContext *C, struct wmManipulatorGroupType *UNUSED(wgt)) | static bool WIDGETGROUP_manipulator_poll(const struct bContext *C, struct wmManipulatorGroupType *UNUSED(wgt)) | ||||
| { | { | ||||
| /* it's a given we only use this in 3D view */ | /* it's a given we only use this in 3D view */ | ||||
| const ScrArea *sa = CTX_wm_area(C); | const ScrArea *sa = CTX_wm_area(C); | ||||
| const View3D *v3d = sa->spacedata.first; | const View3D *v3d = sa->spacedata.first; | ||||
| ▲ Show 20 Lines • Show All 138 Lines • ▼ Show 20 Lines | for (int x = 0; x < 3; x++) { | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| static void WIDGETGROUP_xform_cage_draw_prepare(const bContext *C, wmManipulatorGroup *mgroup) | static void WIDGETGROUP_xform_cage_draw_prepare(const bContext *C, wmManipulatorGroup *mgroup) | ||||
| { | { | ||||
| bScreen *screen = CTX_wm_screen(C); | |||||
| ScrArea *sa = CTX_wm_area(C); | |||||
| ARegion *ar = CTX_wm_region(C); | |||||
| struct XFormCageWidgetGroup *xmgroup = mgroup->customdata; | struct XFormCageWidgetGroup *xmgroup = mgroup->customdata; | ||||
| wmManipulator *mpr = xmgroup->manipulator; | wmManipulator *mpr = xmgroup->manipulator; | ||||
| ViewLayer *view_layer = CTX_data_view_layer(C); | ViewLayer *view_layer = CTX_data_view_layer(C); | ||||
| Object *ob = OBACT(view_layer); | Object *ob = OBACT(view_layer); | ||||
| if (ob && ob->mode & OB_MODE_EDIT) { | if (ob && ob->mode & OB_MODE_EDIT) { | ||||
| copy_m4_m4(mpr->matrix_space, ob->obmat); | copy_m4_m4(mpr->matrix_space, ob->obmat); | ||||
| } | } | ||||
| else { | else { | ||||
| unit_m4(mpr->matrix_space); | unit_m4(mpr->matrix_space); | ||||
| } | } | ||||
| manipulator_xform_msg_subscribe(C, mgroup, screen, sa, ar, VIEW3D_WGT_xform_cage); | |||||
| } | } | ||||
| void VIEW3D_WGT_xform_cage(wmManipulatorGroupType *wgt) | void VIEW3D_WGT_xform_cage(wmManipulatorGroupType *wgt) | ||||
| { | { | ||||
| wgt->name = "Transform Cage"; | wgt->name = "Transform Cage"; | ||||
| wgt->idname = "VIEW3D_WGT_xform_cage"; | wgt->idname = "VIEW3D_WGT_xform_cage"; | ||||
| wgt->flag |= WM_MANIPULATORGROUPTYPE_3D; | wgt->flag |= WM_MANIPULATORGROUPTYPE_3D; | ||||
| Show All 11 Lines | |||||