Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/transform/transform_generics.c
| Show First 20 Lines • Show All 312 Lines • ▼ Show 20 Lines | static bool fcu_test_selected(FCurve *fcu) | ||||
| } | } | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| /* helper for recalcData() - for Action Editor transforms */ | /* helper for recalcData() - for Action Editor transforms */ | ||||
| static void recalcData_actedit(TransInfo *t) | static void recalcData_actedit(TransInfo *t) | ||||
| { | { | ||||
| SceneLayer *sl = t->scene_layer; | ViewLayer *sl = t->view_layer; | ||||
| SpaceAction *saction = (SpaceAction *)t->sa->spacedata.first; | SpaceAction *saction = (SpaceAction *)t->sa->spacedata.first; | ||||
| bAnimContext ac = {NULL}; | bAnimContext ac = {NULL}; | ||||
| ListBase anim_data = {NULL, NULL}; | ListBase anim_data = {NULL, NULL}; | ||||
| bAnimListElem *ale; | bAnimListElem *ale; | ||||
| int filter; | int filter; | ||||
| /* initialize relevant anim-context 'context' data from TransInfo data */ | /* initialize relevant anim-context 'context' data from TransInfo data */ | ||||
| /* NOTE: sync this with the code in ANIM_animdata_get_context() */ | /* NOTE: sync this with the code in ANIM_animdata_get_context() */ | ||||
| ac.scene = t->scene; | ac.scene = t->scene; | ||||
| ac.scene_layer = t->scene_layer; | ac.view_layer = t->view_layer; | ||||
| ac.obact = OBACT(sl); | ac.obact = OBACT(sl); | ||||
| ac.sa = t->sa; | ac.sa = t->sa; | ||||
| ac.ar = t->ar; | ac.ar = t->ar; | ||||
| ac.sl = (t->sa) ? t->sa->spacedata.first : NULL; | ac.sl = (t->sa) ? t->sa->spacedata.first : NULL; | ||||
| ac.spacetype = (t->sa) ? t->sa->spacetype : 0; | ac.spacetype = (t->sa) ? t->sa->spacetype : 0; | ||||
| ac.regiontype = (t->ar) ? t->ar->regiontype : 0; | ac.regiontype = (t->ar) ? t->ar->regiontype : 0; | ||||
| ANIM_animdata_context_getdata(&ac); | ANIM_animdata_context_getdata(&ac); | ||||
| Show All 21 Lines | else { | ||||
| /* now free temp channels */ | /* now free temp channels */ | ||||
| ANIM_animdata_freelist(&anim_data); | ANIM_animdata_freelist(&anim_data); | ||||
| } | } | ||||
| } | } | ||||
| /* helper for recalcData() - for Graph Editor transforms */ | /* helper for recalcData() - for Graph Editor transforms */ | ||||
| static void recalcData_graphedit(TransInfo *t) | static void recalcData_graphedit(TransInfo *t) | ||||
| { | { | ||||
| SpaceIpo *sipo = (SpaceIpo *)t->sa->spacedata.first; | SpaceIpo *sipo = (SpaceIpo *)t->sa->spacedata.first; | ||||
| SceneLayer *sl = t->scene_layer; | ViewLayer *sl = t->view_layer; | ||||
| ListBase anim_data = {NULL, NULL}; | ListBase anim_data = {NULL, NULL}; | ||||
| bAnimContext ac = {NULL}; | bAnimContext ac = {NULL}; | ||||
| int filter; | int filter; | ||||
| bAnimListElem *ale; | bAnimListElem *ale; | ||||
| int dosort = 0; | int dosort = 0; | ||||
| /* initialize relevant anim-context 'context' data from TransInfo data */ | /* initialize relevant anim-context 'context' data from TransInfo data */ | ||||
| /* NOTE: sync this with the code in ANIM_animdata_get_context() */ | /* NOTE: sync this with the code in ANIM_animdata_get_context() */ | ||||
| ac.scene = t->scene; | ac.scene = t->scene; | ||||
| ac.scene_layer = t->scene_layer; | ac.view_layer = t->view_layer; | ||||
| ac.obact = OBACT(sl); | ac.obact = OBACT(sl); | ||||
| ac.sa = t->sa; | ac.sa = t->sa; | ||||
| ac.ar = t->ar; | ac.ar = t->ar; | ||||
| ac.sl = (t->sa) ? t->sa->spacedata.first : NULL; | ac.sl = (t->sa) ? t->sa->spacedata.first : NULL; | ||||
| ac.spacetype = (t->sa) ? t->sa->spacetype : 0; | ac.spacetype = (t->sa) ? t->sa->spacetype : 0; | ||||
| ac.regiontype = (t->ar) ? t->ar->regiontype : 0; | ac.regiontype = (t->ar) ? t->ar->regiontype : 0; | ||||
| ANIM_animdata_context_getdata(&ac); | ANIM_animdata_context_getdata(&ac); | ||||
| ▲ Show 20 Lines • Show All 318 Lines • ▼ Show 20 Lines | static void recalcData_spaceclip(TransInfo *t) | ||||
| else if (t->options & CTX_MASK) { | else if (t->options & CTX_MASK) { | ||||
| recalcData_mask_common(t); | recalcData_mask_common(t); | ||||
| } | } | ||||
| } | } | ||||
| /* helper for recalcData() - for object transforms, typically in the 3D view */ | /* helper for recalcData() - for object transforms, typically in the 3D view */ | ||||
| static void recalcData_objects(TransInfo *t) | static void recalcData_objects(TransInfo *t) | ||||
| { | { | ||||
| Base *base = t->scene_layer->basact; | Base *base = t->view_layer->basact; | ||||
| EvaluationContext eval_ctx; | EvaluationContext eval_ctx; | ||||
| CTX_data_eval_ctx(t->context, &eval_ctx); | CTX_data_eval_ctx(t->context, &eval_ctx); | ||||
| if (t->obedit) { | if (t->obedit) { | ||||
| if (ELEM(t->obedit->type, OB_CURVE, OB_SURF)) { | if (ELEM(t->obedit->type, OB_CURVE, OB_SURF)) { | ||||
| Curve *cu = t->obedit->data; | Curve *cu = t->obedit->data; | ||||
| ListBase *nurbs = BKE_curve_editNurbs_get(cu); | ListBase *nurbs = BKE_curve_editNurbs_get(cu); | ||||
| ▲ Show 20 Lines • Show All 173 Lines • ▼ Show 20 Lines | else if ((t->flag & T_POSE) && t->poseobj) { | ||||
| if (!(arm->flag & ARM_DELAYDEFORM)) { | if (!(arm->flag & ARM_DELAYDEFORM)) { | ||||
| DEG_id_tag_update(&ob->id, OB_RECALC_DATA); /* sets recalc flags */ | DEG_id_tag_update(&ob->id, OB_RECALC_DATA); /* sets recalc flags */ | ||||
| /* transformation of pose may affect IK tree, make sure it is rebuilt */ | /* transformation of pose may affect IK tree, make sure it is rebuilt */ | ||||
| BIK_clear_data(ob->pose); | BIK_clear_data(ob->pose); | ||||
| } | } | ||||
| else | else | ||||
| BKE_pose_where_is(&eval_ctx, t->scene, ob); | BKE_pose_where_is(&eval_ctx, t->scene, ob); | ||||
| } | } | ||||
| else if (base && (base->object->mode & OB_MODE_PARTICLE_EDIT) && PE_get_current(t->scene, t->scene_layer, base->object)) { | else if (base && (base->object->mode & OB_MODE_PARTICLE_EDIT) && PE_get_current(t->scene, t->view_layer, base->object)) { | ||||
| if (t->state != TRANS_CANCEL) { | if (t->state != TRANS_CANCEL) { | ||||
| applyProject(t); | applyProject(t); | ||||
| } | } | ||||
| flushTransParticles(t); | flushTransParticles(t); | ||||
| } | } | ||||
| else { | else { | ||||
| int i; | int i; | ||||
| Show All 13 Lines | for (i = 0; i < t->total; i++) { | ||||
| /* if animtimer is running, and the object already has animation data, | /* if animtimer is running, and the object already has animation data, | ||||
| * check if the auto-record feature means that we should record 'samples' | * check if the auto-record feature means that we should record 'samples' | ||||
| * (i.e. uneditable animation values) | * (i.e. uneditable animation values) | ||||
| */ | */ | ||||
| // TODO: autokeyframe calls need some setting to specify to add samples (FPoints) instead of keyframes? | // TODO: autokeyframe calls need some setting to specify to add samples (FPoints) instead of keyframes? | ||||
| if ((t->animtimer) && IS_AUTOKEY_ON(t->scene)) { | if ((t->animtimer) && IS_AUTOKEY_ON(t->scene)) { | ||||
| animrecord_check_state(t->scene, &ob->id, t->animtimer); | animrecord_check_state(t->scene, &ob->id, t->animtimer); | ||||
| autokeyframe_ob_cb_func(t->context, t->scene, t->scene_layer, (View3D *)t->view, ob, t->mode); | autokeyframe_ob_cb_func(t->context, t->scene, t->view_layer, (View3D *)t->view, ob, t->mode); | ||||
| } | } | ||||
| /* sets recalc flags fully, instead of flushing existing ones | /* sets recalc flags fully, instead of flushing existing ones | ||||
| * otherwise proxies don't function correctly | * otherwise proxies don't function correctly | ||||
| */ | */ | ||||
| DEG_id_tag_update(&ob->id, OB_RECALC_OB); | DEG_id_tag_update(&ob->id, OB_RECALC_OB); | ||||
| if (t->flag & T_TEXTURE) | if (t->flag & T_TEXTURE) | ||||
| ▲ Show 20 Lines • Show All 165 Lines • ▼ Show 20 Lines | |||||
| * | * | ||||
| * \note \a op and \a event can be NULL | * \note \a op and \a event can be NULL | ||||
| * | * | ||||
| * \see #saveTransform does the reverse. | * \see #saveTransform does the reverse. | ||||
| */ | */ | ||||
| void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *event) | void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *event) | ||||
| { | { | ||||
| Scene *sce = CTX_data_scene(C); | Scene *sce = CTX_data_scene(C); | ||||
| SceneLayer *sl = CTX_data_scene_layer(C); | ViewLayer *sl = CTX_data_view_layer(C); | ||||
| ToolSettings *ts = CTX_data_tool_settings(C); | ToolSettings *ts = CTX_data_tool_settings(C); | ||||
| ARegion *ar = CTX_wm_region(C); | ARegion *ar = CTX_wm_region(C); | ||||
| ScrArea *sa = CTX_wm_area(C); | ScrArea *sa = CTX_wm_area(C); | ||||
| Object *obedit = CTX_data_edit_object(C); | Object *obedit = CTX_data_edit_object(C); | ||||
| Object *ob = CTX_data_active_object(C); | Object *ob = CTX_data_active_object(C); | ||||
| bGPdata *gpd = CTX_data_gpencil_data(C); | bGPdata *gpd = CTX_data_gpencil_data(C); | ||||
| RenderEngineType *engine = CTX_data_engine(C); | RenderEngineType *engine = CTX_data_engine(C); | ||||
| PropertyRNA *prop; | PropertyRNA *prop; | ||||
| t->scene = sce; | t->scene = sce; | ||||
| t->scene_layer = sl; | t->view_layer = sl; | ||||
| t->engine = engine; | t->engine = engine; | ||||
| t->sa = sa; | t->sa = sa; | ||||
| t->ar = ar; | t->ar = ar; | ||||
| t->obedit = obedit; | t->obedit = obedit; | ||||
| t->settings = ts; | t->settings = ts; | ||||
| t->reports = op ? op->reports : NULL; | t->reports = op ? op->reports : NULL; | ||||
| if (obedit) { | if (obedit) { | ||||
| ▲ Show 20 Lines • Show All 658 Lines • ▼ Show 20 Lines | bool calculateCenterActive(TransInfo *t, bool select_only, float r_center[3]) | ||||
| bool ok = false; | bool ok = false; | ||||
| if (t->obedit) { | if (t->obedit) { | ||||
| if (ED_object_editmode_calc_active_center(t->obedit, select_only, r_center)) { | if (ED_object_editmode_calc_active_center(t->obedit, select_only, r_center)) { | ||||
| ok = true; | ok = true; | ||||
| } | } | ||||
| } | } | ||||
| else if (t->flag & T_POSE) { | else if (t->flag & T_POSE) { | ||||
| SceneLayer *sl = t->scene_layer; | ViewLayer *sl = t->view_layer; | ||||
| Object *ob = OBACT(sl); | Object *ob = OBACT(sl); | ||||
| if (ob) { | if (ob) { | ||||
| bPoseChannel *pchan = BKE_pose_channel_active(ob); | bPoseChannel *pchan = BKE_pose_channel_active(ob); | ||||
| if (pchan && (!select_only || (pchan->bone->flag & BONE_SELECTED))) { | if (pchan && (!select_only || (pchan->bone->flag & BONE_SELECTED))) { | ||||
| copy_v3_v3(r_center, pchan->pose_head); | copy_v3_v3(r_center, pchan->pose_head); | ||||
| ok = true; | ok = true; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| else if (t->options & CTX_PAINT_CURVE) { | else if (t->options & CTX_PAINT_CURVE) { | ||||
| Paint *p = BKE_paint_get_active(t->scene, t->scene_layer); | Paint *p = BKE_paint_get_active(t->scene, t->view_layer); | ||||
| Brush *br = p->brush; | Brush *br = p->brush; | ||||
| PaintCurve *pc = br->paint_curve; | PaintCurve *pc = br->paint_curve; | ||||
| copy_v3_v3(r_center, pc->points[pc->add_index - 1].bez.vec[1]); | copy_v3_v3(r_center, pc->points[pc->add_index - 1].bez.vec[1]); | ||||
| r_center[2] = 0.0f; | r_center[2] = 0.0f; | ||||
| ok = true; | ok = true; | ||||
| } | } | ||||
| else { | else { | ||||
| /* object mode */ | /* object mode */ | ||||
| SceneLayer *sl = t->scene_layer; | ViewLayer *sl = t->view_layer; | ||||
| Object *ob = OBACT(sl); | Object *ob = OBACT(sl); | ||||
| Base *base = BASACT(sl); | Base *base = BASACT(sl); | ||||
| if (ob && ((!select_only) || ((base->flag & BASE_SELECTED) != 0))) { | if (ob && ((!select_only) || ((base->flag & BASE_SELECTED) != 0))) { | ||||
| copy_v3_v3(r_center, ob->obmat[3]); | copy_v3_v3(r_center, ob->obmat[3]); | ||||
| ok = true; | ok = true; | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 350 Lines • Show Last 20 Lines | |||||