diff options
Diffstat (limited to 'source/blender/editors/transform')
7 files changed, 35 insertions, 43 deletions
diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h index b198918b698..fe05207e645 100644 --- a/source/blender/editors/transform/transform.h +++ b/source/blender/editors/transform/transform.h @@ -655,7 +655,7 @@ void restoreBones(TransInfo *t); #define MANIPULATOR_AXIS_LINE_WIDTH 2.0f /* return 0 when no gimbal for selection */ -bool gimbal_axis(struct Object *ob, float gmat[3][3], const eObjectMode object_mode); +bool gimbal_axis(struct Object *ob, float gmat[3][3]); /*********************** TransData Creation and General Handling *********** */ void createTransData(struct bContext *C, TransInfo *t); diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 3ccf65a8a69..2d7ff1eb523 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -998,7 +998,7 @@ static short pose_grab_with_ik(Object *ob) Bone *bonec; short tot_ik = 0; - if ((ob == NULL) || (ob->pose == NULL)) + if ((ob == NULL) || (ob->pose == NULL) || (ob->mode & OB_MODE_POSE) == 0) return 0; arm = ob->data; @@ -2559,7 +2559,7 @@ static void createTransEditVerts(TransInfo *t) /* detect CrazySpace [tm] */ if (modifiers_getCageIndex(t->scene, t->obedit, NULL, 1) != -1) { int totleft = -1; - if (modifiers_isCorrectableDeformed(&t->eval_ctx, t->scene, t->obedit)) { + if (modifiers_isCorrectableDeformed(t->scene, t->obedit)) { /* check if we can use deform matrices for modifier from the * start up to stack, they are more accurate than quats */ totleft = BKE_crazyspace_get_first_deform_matrices_editbmesh(&t->eval_ctx, t->scene, t->obedit, em, &defmats, &defcos); @@ -6549,7 +6549,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t) } else if ((t->view_layer->basact) && (ob = t->view_layer->basact->object) && - (t->eval_ctx.object_mode & OB_MODE_PARTICLE_EDIT) && + (ob->mode & OB_MODE_PARTICLE_EDIT) && PE_get_current(t->scene, ob)) { /* do nothing */ @@ -8287,28 +8287,26 @@ void createTransData(bContext *C, TransInfo *t) t->poseobj = ob; /* <- tsk tsk, this is going to give issues one day */ } } - else if (ob && (t->eval_ctx.object_mode & OB_MODE_POSE)) { + else if (ob && (ob->mode & OB_MODE_POSE)) { // XXX this is currently limited to active armature only... // XXX active-layer checking isn't done as that should probably be checked through context instead createTransPose(t, ob); } - else if (ob && (t->eval_ctx.object_mode & OB_MODE_WEIGHT_PAINT) && !(t->options & CTX_PAINT_CURVE)) { + else if (ob && (ob->mode & OB_MODE_WEIGHT_PAINT) && !(t->options & CTX_PAINT_CURVE)) { /* important that ob_armature can be set even when its not selected [#23412] * lines below just check is also visible */ Object *ob_armature = modifiers_isDeformedByArmature(ob); - if (ob_armature) { -// const bArmature *arm = ob_armature->data; + if (ob_armature && ob_armature->mode & OB_MODE_POSE) { Base *base_arm = BKE_view_layer_base_find(t->view_layer, ob_armature); if (base_arm) { if (BASE_VISIBLE(base_arm)) { createTransPose(t, ob_armature); } } + } } - else if (ob && (t->eval_ctx.object_mode & OB_MODE_PARTICLE_EDIT) && - PE_start_edit(PE_get_current(scene, ob))) - { + else if (ob && (ob->mode & OB_MODE_PARTICLE_EDIT) && PE_start_edit(PE_get_current(scene, ob))) { createTransParticleVerts(C, t); t->flag |= T_POINTS; @@ -8318,7 +8316,7 @@ void createTransData(bContext *C, TransInfo *t) sort_trans_data_dist(t); } } - else if (ob && (t->eval_ctx.object_mode & OB_MODE_ALL_PAINT)) { + else if (ob && (ob->mode & OB_MODE_ALL_PAINT)) { if ((t->options & CTX_PAINT_CURVE) && !ELEM(t->mode, TFM_SHEAR, TFM_SHRINKFATTEN)) { t->flag |= T_POINTS | T_2D_EDIT; createTransPaintCurveVerts(C, t); diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index e051b401f87..b42e00a2bb4 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -901,7 +901,7 @@ static void recalcData_objects(TransInfo *t) else BKE_pose_where_is(&t->eval_ctx, t->scene, ob); } - else if (base && (t->eval_ctx.object_mode & OB_MODE_PARTICLE_EDIT) && + else if (base && (base->object->mode & OB_MODE_PARTICLE_EDIT) && PE_get_current(t->scene, base->object)) { if (t->state != TRANS_CANCEL) { @@ -1266,7 +1266,7 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve } } - if (ob && t->eval_ctx.object_mode & OB_MODE_ALL_PAINT) { + if (ob && ob->mode & OB_MODE_ALL_PAINT) { Paint *p = BKE_paint_get_active_from_context(C); if (p && p->brush && (p->brush->flag & BRUSH_CURVE)) { t->options |= CTX_PAINT_CURVE; @@ -1815,7 +1815,7 @@ bool calculateCenterActive(TransInfo *t, bool select_only, float r_center[3]) } } else if (t->options & CTX_PAINT_CURVE) { - Paint *p = BKE_paint_get_active(t->scene, t->view_layer, t->eval_ctx.object_mode); + Paint *p = BKE_paint_get_active(t->scene, t->view_layer); Brush *br = p->brush; PaintCurve *pc = br->paint_curve; copy_v3_v3(r_center, pc->points[pc->add_index - 1].bez.vec[1]); diff --git a/source/blender/editors/transform/transform_manipulator.c b/source/blender/editors/transform/transform_manipulator.c index cb5b17b415e..8944817baca 100644 --- a/source/blender/editors/transform/transform_manipulator.c +++ b/source/blender/editors/transform/transform_manipulator.c @@ -520,9 +520,9 @@ static bool test_rotmode_euler(short rotmode) return (ELEM(rotmode, ROT_MODE_AXISANGLE, ROT_MODE_QUAT)) ? 0 : 1; } -bool gimbal_axis(Object *ob, float gmat[3][3], const eObjectMode object_mode) +bool gimbal_axis(Object *ob, float gmat[3][3]) { - if (object_mode & OB_MODE_POSE) { + if (ob->mode & OB_MODE_POSE) { bPoseChannel *pchan = BKE_pose_channel_active(ob); if (pchan) { @@ -591,7 +591,6 @@ static int calc_manipulator_stats( const bContext *C, bool use_only_center, struct TransformBounds *tbounds) { - const WorkSpace *workspace = CTX_wm_workspace(C); ScrArea *sa = CTX_wm_area(C); ARegion *ar = CTX_wm_region(C); Scene *scene = CTX_data_scene(C); @@ -629,7 +628,7 @@ static int calc_manipulator_stats( case V3D_MANIP_GIMBAL: { float mat[3][3]; - if (gimbal_axis(ob, mat, workspace->object_mode)) { + if (gimbal_axis(ob, mat)) { copy_m4_m3(rv3d->twmat, mat); break; } @@ -638,7 +637,7 @@ static int calc_manipulator_stats( } case V3D_MANIP_NORMAL: { - if (obedit || workspace->object_mode & OB_MODE_POSE) { + if (obedit || ob->mode & OB_MODE_POSE) { float mat[3][3]; ED_getTransformOrientationMatrix(C, mat, v3d->around); copy_m4_m3(rv3d->twmat, mat); @@ -649,7 +648,7 @@ static int calc_manipulator_stats( } case V3D_MANIP_LOCAL: { - if (workspace->object_mode & OB_MODE_POSE) { + if (ob->mode & OB_MODE_POSE) { /* each bone moves on its own local axis, but to avoid confusion, * use the active pones axis for display [#33575], this works as expected on a single bone * and users who select many bones will understand whats going on and what local means @@ -691,7 +690,7 @@ static int calc_manipulator_stats( #ifdef USE_AXIS_BOUNDS copy_m3_m4(tbounds->axis, rv3d->twmat); - if (ob && workspace->object_mode & OB_MODE_EDIT) { + if (ob && ob->mode & OB_MODE_EDIT) { float diff_mat[3][3]; copy_m3_m4(diff_mat, ob->obmat); normalize_m3(diff_mat); @@ -934,7 +933,7 @@ static int calc_manipulator_stats( mul_m4_v3(obedit->obmat, tbounds->max); } } - else if (ob && (workspace->object_mode & OB_MODE_POSE)) { + else if (ob && (ob->mode & OB_MODE_POSE)) { bPoseChannel *pchan; int mode = TFM_ROTATION; // mislead counting bones... bah. We don't know the manipulator mode, could be mixed bool ok = false; @@ -972,10 +971,10 @@ static int calc_manipulator_stats( mul_m4_v3(ob->obmat, tbounds->max); } } - else if (ob && (workspace->object_mode & OB_MODE_ALL_PAINT)) { + else if (ob && (ob->mode & OB_MODE_ALL_PAINT)) { /* pass */ } - else if (ob && workspace->object_mode & OB_MODE_PARTICLE_EDIT) { + else if (ob && ob->mode & OB_MODE_PARTICLE_EDIT) { PTCacheEdit *edit = PE_get_current(scene, ob); PTCacheEditPoint *point; PTCacheEditKey *ek; @@ -1065,13 +1064,12 @@ static void manipulator_prepare_mat( case V3D_AROUND_CENTER_BOUNDS: case V3D_AROUND_ACTIVE: { - const WorkSpace *workspace = CTX_wm_workspace(C); bGPdata *gpd = CTX_data_gpencil_data(C); Object *ob = OBACT(view_layer); - if (((v3d->around == V3D_AROUND_ACTIVE) && ((workspace->object_mode & OB_MODE_EDIT) == 0)) && + if (((v3d->around == V3D_AROUND_ACTIVE) && (OBEDIT_FROM_OBACT(ob) == NULL)) && ((gpd == NULL) || !(gpd->flag & GP_DATA_STROKE_EDITMODE)) && - (!(workspace->object_mode & OB_MODE_POSE))) + (!(ob->mode & OB_MODE_POSE))) { copy_v3_v3(rv3d->twmat[3], ob->obmat[3]); } @@ -1660,10 +1658,10 @@ static void WIDGETGROUP_xform_cage_draw_prepare(const bContext *C, wmManipulator { struct XFormCageWidgetGroup *xmgroup = mgroup->customdata; wmManipulator *mpr = xmgroup->manipulator; - const WorkSpace *workspace = CTX_wm_workspace(C); + ViewLayer *view_layer = CTX_data_view_layer(C); Object *ob = OBACT(view_layer); - if (ob && workspace->object_mode & OB_MODE_EDIT) { + if (ob && ob->mode & OB_MODE_EDIT) { copy_m4_m4(mpr->matrix_space, ob->obmat); } else { diff --git a/source/blender/editors/transform/transform_orientations.c b/source/blender/editors/transform/transform_orientations.c index b39e5f286c0..7b3f91b81da 100644 --- a/source/blender/editors/transform/transform_orientations.c +++ b/source/blender/editors/transform/transform_orientations.c @@ -55,8 +55,6 @@ #include "BKE_screen.h" #include "BKE_workspace.h" -#include "DEG_depsgraph.h" - #include "BLT_translation.h" #include "ED_armature.h" @@ -298,7 +296,6 @@ void BIF_createTransformOrientation(bContext *C, ReportList *reports, ts = createViewSpace(C, reports, name, overwrite); } else { - const WorkSpace *workspace = CTX_wm_workspace(C); Object *obedit = CTX_data_edit_object(C); Object *ob = CTX_data_active_object(C); if (obedit) { @@ -309,7 +306,7 @@ void BIF_createTransformOrientation(bContext *C, ReportList *reports, else if (obedit->type == OB_CURVE) ts = createCurveSpace(C, reports, name, overwrite); } - else if (ob && (workspace->object_mode & OB_MODE_POSE)) { + else if (ob && (ob->mode & OB_MODE_POSE)) { ts = createBoneSpace(C, reports, name, overwrite); } else { @@ -444,13 +441,13 @@ void initTransformOrientation(bContext *C, TransInfo *t) case V3D_MANIP_GIMBAL: unit_m3(t->spacemtx); - if (ob && gimbal_axis(ob, t->spacemtx, t->eval_ctx.object_mode)) { + if (ob && gimbal_axis(ob, t->spacemtx)) { BLI_strncpy(t->spacename, IFACE_("gimbal"), sizeof(t->spacename)); break; } ATTR_FALLTHROUGH; /* no gimbal fallthrough to normal */ case V3D_MANIP_NORMAL: - if (obedit || (ob && t->eval_ctx.object_mode & OB_MODE_POSE)) { + if (obedit || (ob && ob->mode & OB_MODE_POSE)) { BLI_strncpy(t->spacename, IFACE_("normal"), sizeof(t->spacename)); ED_getTransformOrientationMatrix(C, t->spacemtx, t->around); break; @@ -581,7 +578,6 @@ static unsigned int bm_mesh_faces_select_get_n(BMesh *bm, BMVert **elems, const int getTransformOrientation_ex(const bContext *C, float normal[3], float plane[3], const short around) { - const WorkSpace *workspace = CTX_wm_workspace(C); ViewLayer *view_layer = CTX_data_view_layer(C); Object *obedit = CTX_data_edit_object(C); Base *base; @@ -1012,7 +1008,7 @@ int getTransformOrientation_ex(const bContext *C, float normal[3], float plane[3 mul_m3_v3(mat, plane); } } - else if (ob && (workspace->object_mode & OB_MODE_POSE)) { + else if (ob && (ob->mode & OB_MODE_POSE)) { bArmature *arm = ob->data; bPoseChannel *pchan; float imat[3][3], mat[3][3]; @@ -1052,7 +1048,7 @@ int getTransformOrientation_ex(const bContext *C, float normal[3], float plane[3 result = ORIENTATION_EDGE; } } - else if (ob && (workspace->object_mode & (OB_MODE_ALL_PAINT | OB_MODE_PARTICLE_EDIT))) { + else if (ob && (ob->mode & (OB_MODE_ALL_PAINT | OB_MODE_PARTICLE_EDIT))) { /* pass */ } else { diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c index 9946f1ad546..ad913cd2336 100644 --- a/source/blender/editors/transform/transform_snap.c +++ b/source/blender/editors/transform/transform_snap.c @@ -544,7 +544,7 @@ static void initSnappingMode(TransInfo *t) } /* Particles edit mode*/ else if (t->tsnap.applySnap != NULL && // A snapping function actually exist - (obedit == NULL && base_act && base_act->object && t->eval_ctx.object_mode & OB_MODE_PARTICLE_EDIT)) + (obedit == NULL && base_act && base_act->object && base_act->object->mode & OB_MODE_PARTICLE_EDIT)) { t->tsnap.modeSelect = SNAP_ALL; } diff --git a/source/blender/editors/transform/transform_snap_object.c b/source/blender/editors/transform/transform_snap_object.c index 0020b0924bb..c336cd1d31e 100644 --- a/source/blender/editors/transform/transform_snap_object.c +++ b/source/blender/editors/transform/transform_snap_object.c @@ -821,7 +821,7 @@ static bool raycastObjects( Object **r_ob, float r_obmat[4][4], ListBase *r_hit_list) { - Object *obedit = use_object_edit_cage ? OBEDIT_FROM_EVAL_CTX(&sctx->eval_ctx) : NULL; + Object *obedit = use_object_edit_cage ? OBEDIT_FROM_VIEW_LAYER(sctx->eval_ctx.view_layer) : NULL; struct RaycastObjUserData data = { .ray_start = ray_start, @@ -2054,7 +2054,7 @@ static bool snapObjectsRay( float r_loc[3], float r_no[3], Object **r_ob, float r_obmat[4][4]) { - Object *obedit = use_object_edit_cage ? OBEDIT_FROM_EVAL_CTX(&sctx->eval_ctx) : NULL; + Object *obedit = use_object_edit_cage ? OBEDIT_FROM_VIEW_LAYER(sctx->eval_ctx.view_layer) : NULL; struct SnapObjUserData data = { .snapdata = snapdata, @@ -2089,7 +2089,7 @@ SnapObjectContext *ED_transform_snap_object_context_create( sctx->scene = scene; DEG_evaluation_context_init_from_scene( - &sctx->eval_ctx, scene, view_layer, engine_type, OB_MODE_OBJECT, DAG_EVAL_VIEWPORT); + &sctx->eval_ctx, scene, view_layer, engine_type, DAG_EVAL_VIEWPORT); sctx->cache.object_map = BLI_ghash_ptr_new(__func__); sctx->cache.mem_arena = BLI_memarena_new(BLI_MEMARENA_STD_BUFSIZE, __func__); |