Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_view3d/view3d_gizmo_armature.c
| Show First 20 Lines • Show All 128 Lines • ▼ Show 20 Lines | static bool WIDGETGROUP_armature_spline_poll(const bContext *C, wmGizmoGroupType *UNUSED(gzgt)) | ||||
| ViewLayer *view_layer = CTX_data_view_layer(C); | ViewLayer *view_layer = CTX_data_view_layer(C); | ||||
| Base *base = BASACT(view_layer); | Base *base = BASACT(view_layer); | ||||
| if (base && BASE_SELECTABLE(v3d, base)) { | if (base && BASE_SELECTABLE(v3d, base)) { | ||||
| Object *ob = BKE_object_pose_armature_get(base->object); | Object *ob = BKE_object_pose_armature_get(base->object); | ||||
| if (ob) { | if (ob) { | ||||
| const bArmature *arm = ob->data; | const bArmature *arm = ob->data; | ||||
| if (arm->drawtype == ARM_B_BONE) { | if (arm->drawtype == ARM_B_BONE) { | ||||
| bPoseChannel *pchan = BKE_pose_channel_active(ob); | bPoseChannel *pchan = BKE_pose_channel_active_if_layer_visible(ob); | ||||
| if (pchan && pchan->bone->segments > 1) { | if (pchan && pchan->bone->segments > 1) { | ||||
| return true; | return true; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| return false; | return false; | ||||
| } | } | ||||
| static void WIDGETGROUP_armature_spline_setup(const bContext *C, wmGizmoGroup *gzgroup) | static void WIDGETGROUP_armature_spline_setup(const bContext *C, wmGizmoGroup *gzgroup) | ||||
| { | { | ||||
| ViewLayer *view_layer = CTX_data_view_layer(C); | ViewLayer *view_layer = CTX_data_view_layer(C); | ||||
| Object *ob = BKE_object_pose_armature_get(OBACT(view_layer)); | Object *ob = BKE_object_pose_armature_get(OBACT(view_layer)); | ||||
| bPoseChannel *pchan = BKE_pose_channel_active(ob); | bPoseChannel *pchan = BKE_pose_channel_active_if_layer_visible(ob); | ||||
| const wmGizmoType *gzt_move = WM_gizmotype_find("GIZMO_GT_move_3d", true); | const wmGizmoType *gzt_move = WM_gizmotype_find("GIZMO_GT_move_3d", true); | ||||
| struct BoneSplineWidgetGroup *bspline_group = MEM_callocN(sizeof(struct BoneSplineWidgetGroup), | struct BoneSplineWidgetGroup *bspline_group = MEM_callocN(sizeof(struct BoneSplineWidgetGroup), | ||||
| __func__); | __func__); | ||||
| gzgroup->customdata = bspline_group; | gzgroup->customdata = bspline_group; | ||||
| /* Handles */ | /* Handles */ | ||||
| Show All 22 Lines | static void WIDGETGROUP_armature_spline_refresh(const bContext *C, wmGizmoGroup *gzgroup) | ||||
| ViewLayer *view_layer = CTX_data_view_layer(C); | ViewLayer *view_layer = CTX_data_view_layer(C); | ||||
| Object *ob = BKE_object_pose_armature_get(OBACT(view_layer)); | Object *ob = BKE_object_pose_armature_get(OBACT(view_layer)); | ||||
| if (!gzgroup->customdata) { | if (!gzgroup->customdata) { | ||||
| return; | return; | ||||
| } | } | ||||
| struct BoneSplineWidgetGroup *bspline_group = gzgroup->customdata; | struct BoneSplineWidgetGroup *bspline_group = gzgroup->customdata; | ||||
| bPoseChannel *pchan = BKE_pose_channel_active(ob); | bPoseChannel *pchan = BKE_pose_channel_active_if_layer_visible(ob); | ||||
| /* Handles */ | /* Handles */ | ||||
| for (int i = 0; i < ARRAY_SIZE(bspline_group->handles); i++) { | for (int i = 0; i < ARRAY_SIZE(bspline_group->handles); i++) { | ||||
| wmGizmo *gz = bspline_group->handles[i].gizmo; | wmGizmo *gz = bspline_group->handles[i].gizmo; | ||||
| bspline_group->handles[i].pchan = pchan; | bspline_group->handles[i].pchan = pchan; | ||||
| bspline_group->handles[i].index = i; | bspline_group->handles[i].index = i; | ||||
| float mat[4][4]; | float mat[4][4]; | ||||
| Show All 29 Lines | |||||