diff options
Diffstat (limited to 'source/blender/editors/transform')
5 files changed, 78 insertions, 51 deletions
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index f6f4566f836..d79babde707 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -66,6 +66,8 @@ #include "BKE_report.h" #include "BKE_workspace.h" +#include "DEG_depsgraph.h" + #include "BIF_glutil.h" #include "GPU_immediate.h" @@ -2623,6 +2625,9 @@ static void constraintTransLim(TransInfo *t, TransData *td) if (td->con) { const bConstraintTypeInfo *ctiLoc = BKE_constraint_typeinfo_from_type(CONSTRAINT_TYPE_LOCLIMIT); const bConstraintTypeInfo *ctiDist = BKE_constraint_typeinfo_from_type(CONSTRAINT_TYPE_DISTLIMIT); + EvaluationContext eval_ctx; + + CTX_data_eval_ctx(t->context, &eval_ctx); bConstraintOb cob = {NULL}; bConstraint *con; @@ -2672,7 +2677,7 @@ static void constraintTransLim(TransInfo *t, TransData *td) } /* get constraint targets if needed */ - BKE_constraint_targets_for_solving_get(con, &cob, &targets, ctime); + BKE_constraint_targets_for_solving_get(&eval_ctx, con, &cob, &targets, ctime); /* do constraint */ cti->evaluate_constraint(con, &cob, &targets); diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 6f17a15c334..094c1d48366 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -2046,7 +2046,7 @@ void flushTransParticles(TransInfo *t) point->flag |= PEP_EDIT_RECALC; } - PE_update_object(scene, sl, OBACT_NEW, 1); + PE_update_object(t->context, scene, sl, OBACT_NEW, 1); } /* ********************* mesh ****************** */ @@ -2458,6 +2458,7 @@ static void createTransEditVerts(TransInfo *t) { TransData *tob = NULL; TransDataExtension *tx = NULL; + EvaluationContext eval_ctx; BMEditMesh *em = BKE_editmesh_from_object(t->obedit); Mesh *me = t->obedit->data; BMesh *bm = em->bm; @@ -2476,6 +2477,8 @@ static void createTransEditVerts(TransInfo *t) int island_info_tot; int *island_vert_map = NULL; + CTX_data_eval_ctx(t->context, &eval_ctx); + /* Even for translation this is needed because of island-orientation, see: T51651. */ const bool is_island_center = (t->around == V3D_AROUND_LOCAL_ORIGINS); /* Original index of our connected vertex when connected distances are calculated. @@ -2559,7 +2562,7 @@ static void createTransEditVerts(TransInfo *t) 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->scene, t->obedit, em, &defmats, &defcos); + totleft = BKE_crazyspace_get_first_deform_matrices_editbmesh(&eval_ctx, t->scene, t->obedit, em, &defmats, &defcos); } /* if we still have more modifiers, also do crazyspace @@ -2572,7 +2575,7 @@ static void createTransEditVerts(TransInfo *t) if (totleft > 0) #endif { - mappedcos = BKE_crazyspace_get_mapped_editverts(t->scene, t->obedit); + mappedcos = BKE_crazyspace_get_mapped_editverts(&eval_ctx, t->scene, t->obedit); quats = MEM_mallocN(em->bm->totvert * sizeof(*quats), "crazy quats"); BKE_crazyspace_set_quats_editmesh(em, defcos, mappedcos, quats, !prop_mode); if (mappedcos) @@ -5398,6 +5401,9 @@ static void ObjectToTransData(TransInfo *t, TransData *td, Object *ob) Scene *scene = t->scene; bool constinv; bool skip_invert = false; + EvaluationContext eval_ctx; + + CTX_data_eval_ctx(t->context, &eval_ctx); if (t->mode != TFM_DUMMY && ob->rigidbody_object) { float rot[3][3], scale[3]; @@ -5445,11 +5451,11 @@ static void ObjectToTransData(TransInfo *t, TransData *td, Object *ob) if (skip_invert == false && constinv == false) { ob->transflag |= OB_NO_CONSTRAINTS; /* BKE_object_where_is_calc_time checks this */ - BKE_object_where_is_calc(t->scene, ob); + BKE_object_where_is_calc(&eval_ctx, t->scene, ob); ob->transflag &= ~OB_NO_CONSTRAINTS; } else - BKE_object_where_is_calc(t->scene, ob); + BKE_object_where_is_calc(&eval_ctx, t->scene, ob); td->ob = ob; @@ -5930,7 +5936,7 @@ void autokeyframe_pose_cb_func(bContext *C, Scene *scene, View3D *v3d, Object *o */ if (C && (ob->pose->avs.path_bakeflag & MOTIONPATH_BAKE_HAS_PATHS)) { //ED_pose_clear_paths(C, ob); // XXX for now, don't need to clear - ED_pose_recalculate_paths(scene, ob); + ED_pose_recalculate_paths(C, scene, ob); } } else { @@ -6090,10 +6096,13 @@ static void special_aftertrans_update__mesh(bContext *UNUSED(C), TransInfo *t) * */ void special_aftertrans_update(bContext *C, TransInfo *t) { + EvaluationContext eval_ctx; Object *ob; // short redrawipo=0, resetslowpar=1; const bool canceled = (t->state == TRANS_CANCEL); const bool duplicate = (t->mode == TFM_TIME_DUPLICATE); + + CTX_data_eval_ctx(C, &eval_ctx); /* early out when nothing happened */ if (t->total == 0 || t->mode == TFM_DUMMY) @@ -6433,7 +6442,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t) * we need to update the pose otherwise no updates get called during * transform and the auto-ik is not applied. see [#26164] */ struct Object *pose_ob = t->poseobj; - BKE_pose_where_is(t->scene, pose_ob); + BKE_pose_where_is(&eval_ctx, t->scene, pose_ob); } /* set BONE_TRANSFORM flags for autokey, manipulator draw might have changed them */ diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index ca9e15f5de4..6d3b2408542 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -714,6 +714,9 @@ static void recalcData_spaceclip(TransInfo *t) static void recalcData_objects(TransInfo *t) { Base *base = t->scene_layer->basact; + EvaluationContext eval_ctx; + + CTX_data_eval_ctx(t->context, &eval_ctx); if (t->obedit) { if (ELEM(t->obedit->type, OB_CURVE, OB_SURF)) { @@ -898,7 +901,7 @@ static void recalcData_objects(TransInfo *t) BIK_clear_data(ob->pose); } else - BKE_pose_where_is(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)) { if (t->state != TRANS_CANCEL) { diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c index 1181f584313..906a6ce20ef 100644 --- a/source/blender/editors/transform/transform_snap.c +++ b/source/blender/editors/transform/transform_snap.c @@ -1197,7 +1197,7 @@ bool snapObjectsTransform( float r_loc[3], float r_no[3]) { return ED_transform_snap_object_project_view3d_ex( - t->tsnap.object_context, + t->context, t->tsnap.object_context, t->scene->toolsettings->snap_mode, &(const struct SnapObjectParams){ .snap_select = t->tsnap.modeSelect, @@ -1211,7 +1211,7 @@ bool snapObjectsTransform( /******************** PEELING *********************************/ bool peelObjectsSnapContext( - SnapObjectContext *sctx, + const bContext *C, SnapObjectContext *sctx, const float mval[2], const struct SnapObjectParams *params, const bool use_peel_object, @@ -1220,7 +1220,7 @@ bool peelObjectsSnapContext( { ListBase depths_peel = {0}; ED_transform_snap_object_project_all_view3d_ex( - sctx, + C, sctx, params, mval, -1.0f, false, &depths_peel); @@ -1287,7 +1287,7 @@ bool peelObjectsTransform( float r_loc[3], float r_no[3], float *r_thickness) { return peelObjectsSnapContext( - t->tsnap.object_context, + t->context, t->tsnap.object_context, mval, &(const struct SnapObjectParams){ .snap_select = t->tsnap.modeSelect, diff --git a/source/blender/editors/transform/transform_snap_object.c b/source/blender/editors/transform/transform_snap_object.c index 96f51b99158..b750dbb0893 100644 --- a/source/blender/editors/transform/transform_snap_object.c +++ b/source/blender/editors/transform/transform_snap_object.c @@ -51,6 +51,9 @@ #include "BKE_editmesh.h" #include "BKE_main.h" #include "BKE_tracking.h" +#include "BKE_context.h" + +#include "DEG_depsgraph.h" #include "ED_transform.h" #include "ED_transform_snap_object_context.h" @@ -140,7 +143,7 @@ struct SnapObjectContext { * \{ */ -typedef void(*IterSnapObjsCallback)(SnapObjectContext *sctx, bool is_obedit, Object *ob, float obmat[4][4], void *data); +typedef void(*IterSnapObjsCallback)(const bContext *C, SnapObjectContext *sctx, bool is_obedit, Object *ob, float obmat[4][4], void *data); /** * Walks through all objects in the scene to create the list of objets to snap. @@ -150,6 +153,7 @@ typedef void(*IterSnapObjsCallback)(SnapObjectContext *sctx, bool is_obedit, Obj * \param obedit : Object Edited to use its coordinates of BMesh(if any) to do the snapping. */ static void iter_snap_objects( + const bContext *C, SnapObjectContext *sctx, const SnapSelect snap_select, Object *obedit, @@ -163,7 +167,7 @@ static void iter_snap_objects( * To solve that problem, we do it first as an exception. * */ if (base_act && base_act->object && base_act->object->mode & OB_MODE_PARTICLE_EDIT) { - sob_callback(sctx, false, base_act->object, base_act->object->obmat, data); + sob_callback(C, sctx, false, base_act->object, base_act->object->obmat, data); } for (Base *base = sctx->scene_layer->object_bases.first; base != NULL; base = base->next) { @@ -178,13 +182,13 @@ static void iter_snap_objects( ListBase *lb = object_duplilist(sctx->bmain->eval_ctx, sctx->scene, obj); for (dupli_ob = lb->first; dupli_ob; dupli_ob = dupli_ob->next) { use_obedit = obedit && dupli_ob->ob->data == obedit->data; - sob_callback(sctx, use_obedit, use_obedit ? obedit : dupli_ob->ob, dupli_ob->mat, data); + sob_callback(C, sctx, use_obedit, use_obedit ? obedit : dupli_ob->ob, dupli_ob->mat, data); } free_object_duplilist(lb); } use_obedit = obedit && obj->data == obedit->data; - sob_callback(sctx, use_obedit, use_obedit ? obedit : obj, obj->obmat, data); + sob_callback(C, sctx, use_obedit, use_obedit ? obedit : obj, obj->obmat, data); } } } @@ -723,7 +727,7 @@ static bool raycastEditMesh( * \note Duplicate args here are documented at #snapObjectsRay */ static bool raycastObj( - SnapObjectContext *sctx, + const bContext *C, SnapObjectContext *sctx, const float ray_orig[3], const float ray_start[3], const float ray_dir[3], const float depth_range[2], Object *ob, float obmat[4][4], const unsigned int ob_index, bool use_obedit, @@ -734,8 +738,11 @@ static bool raycastObj( Object **r_ob, float r_obmat[4][4], ListBase *r_hit_list) { + EvaluationContext eval_ctx; bool retval = false; + CTX_data_eval_ctx(C, &eval_ctx); + if (ob->type == OB_MESH) { BMEditMesh *em; @@ -753,10 +760,10 @@ static bool raycastObj( DerivedMesh *dm; em = BKE_editmesh_from_object(ob); if (em) { - editbmesh_get_derived_cage_and_final(sctx->scene, ob, em, CD_MASK_BAREMESH, &dm); + editbmesh_get_derived_cage_and_final(&eval_ctx, sctx->scene, ob, em, CD_MASK_BAREMESH, &dm); } else { - dm = mesh_get_derived_final(sctx->scene, ob, CD_MASK_BAREMESH); + dm = mesh_get_derived_final(&eval_ctx, sctx->scene, ob, CD_MASK_BAREMESH); } retval = raycastDerivedMesh( sctx, @@ -797,11 +804,11 @@ struct RaycastObjUserData { bool ret; }; -static void raycast_obj_cb(SnapObjectContext *sctx, bool is_obedit, Object *ob, float obmat[4][4], void *data) +static void raycast_obj_cb(const bContext *C, SnapObjectContext *sctx, bool is_obedit, Object *ob, float obmat[4][4], void *data) { struct RaycastObjUserData *dt = data; dt->ret |= raycastObj( - sctx, + C, sctx, dt->ray_orig, dt->ray_start, dt->ray_dir, dt->depth_range, ob, obmat, dt->ob_index++, is_obedit, dt->ray_depth, @@ -840,7 +847,7 @@ static void raycast_obj_cb(SnapObjectContext *sctx, bool is_obedit, Object *ob, * */ static bool raycastObjects( - SnapObjectContext *sctx, + const bContext *C, SnapObjectContext *sctx, const float ray_orig[3], const float ray_start[3], const float ray_dir[3], const float depth_range[2], const SnapSelect snap_select, const bool use_object_edit_cage, /* read/write args */ @@ -868,7 +875,7 @@ static bool raycastObjects( .ret = false, }; - iter_snap_objects(sctx, snap_select, obedit, raycast_obj_cb, &data); + iter_snap_objects(C, sctx, snap_select, obedit, raycast_obj_cb, &data); return data.ret; } @@ -1961,7 +1968,7 @@ static bool snapEditMesh( * \note Duplicate args here are documented at #snapObjectsRay */ static bool snapObject( - SnapObjectContext *sctx, SnapData *snapdata, + const bContext *C, SnapObjectContext *sctx, SnapData *snapdata, Object *ob, float obmat[4][4], bool use_obedit, /* read/write args */ @@ -1970,8 +1977,11 @@ static bool snapObject( float r_loc[3], float r_no[3], Object **r_ob, float r_obmat[4][4]) { + EvaluationContext eval_ctx; bool retval = false; + CTX_data_eval_ctx(C, &eval_ctx); + if (ob->type == OB_MESH) { BMEditMesh *em; @@ -1988,10 +1998,10 @@ static bool snapObject( DerivedMesh *dm; em = BKE_editmesh_from_object(ob); if (em) { - editbmesh_get_derived_cage_and_final(sctx->scene, ob, em, CD_MASK_BAREMESH, &dm); + editbmesh_get_derived_cage_and_final(&eval_ctx, sctx->scene, ob, em, CD_MASK_BAREMESH, &dm); } else { - dm = mesh_get_derived_final(sctx->scene, ob, CD_MASK_BAREMESH); + dm = mesh_get_derived_final(&eval_ctx, sctx->scene, ob, CD_MASK_BAREMESH); } retval = snapDerivedMesh( sctx, snapdata, ob, dm, obmat, @@ -2055,11 +2065,11 @@ struct SnapObjUserData { bool ret; }; -static void sanp_obj_cb(SnapObjectContext *sctx, bool is_obedit, Object *ob, float obmat[4][4], void *data) +static void sanp_obj_cb(const bContext *C, SnapObjectContext *sctx, bool is_obedit, Object *ob, float obmat[4][4], void *data) { struct SnapObjUserData *dt = data; dt->ret |= snapObject( - sctx, dt->snapdata, + C, sctx, dt->snapdata, ob, obmat, is_obedit, /* read/write args */ dt->ray_depth, dt->dist_px, @@ -2098,7 +2108,7 @@ static void sanp_obj_cb(SnapObjectContext *sctx, bool is_obedit, Object *ob, flo * */ static bool snapObjectsRay( - SnapObjectContext *sctx, SnapData *snapdata, + const bContext *C, SnapObjectContext *sctx, SnapData *snapdata, const SnapSelect snap_select, const bool use_object_edit_cage, /* read/write args */ float *ray_depth, float *dist_px, @@ -2119,7 +2129,7 @@ static bool snapObjectsRay( .ret = false, }; - iter_snap_objects(sctx, snap_select, obedit, sanp_obj_cb, &data); + iter_snap_objects(C, sctx, snap_select, obedit, sanp_obj_cb, &data); return data.ret; } @@ -2215,7 +2225,7 @@ void ED_transform_snap_object_context_set_editmesh_callbacks( } bool ED_transform_snap_object_project_ray_ex( - SnapObjectContext *sctx, + const bContext *C, SnapObjectContext *sctx, const struct SnapObjectParams *params, const float ray_start[3], const float ray_normal[3], float *ray_depth, @@ -2225,7 +2235,7 @@ bool ED_transform_snap_object_project_ray_ex( const float depth_range[2] = {0.0f, FLT_MAX}; return raycastObjects( - sctx, + C, sctx, ray_start, ray_start, ray_normal, depth_range, params->snap_select, params->use_object_edit_cage, ray_depth, r_loc, r_no, r_index, r_ob, r_obmat, NULL); @@ -2239,7 +2249,7 @@ bool ED_transform_snap_object_project_ray_ex( * \param r_hit_list: List of #SnapObjectHitDepth (caller must free). */ bool ED_transform_snap_object_project_ray_all( - SnapObjectContext *sctx, + const bContext *C, SnapObjectContext *sctx, const struct SnapObjectParams *params, const float ray_start[3], const float ray_normal[3], float ray_depth, bool sort, @@ -2255,7 +2265,7 @@ bool ED_transform_snap_object_project_ray_all( #endif bool retval = raycastObjects( - sctx, + C, sctx, ray_start, ray_start, ray_normal, depth_range, params->snap_select, params->use_object_edit_cage, &ray_depth, NULL, NULL, NULL, NULL, NULL, @@ -2281,7 +2291,7 @@ bool ED_transform_snap_object_project_ray_all( * \return Snap success */ static bool transform_snap_context_project_ray_impl( - SnapObjectContext *sctx, + const bContext *C, SnapObjectContext *sctx, const struct SnapObjectParams *params, const float ray_start[3], const float ray_normal[3], float *ray_depth, float r_co[3], float r_no[3]) @@ -2290,7 +2300,7 @@ static bool transform_snap_context_project_ray_impl( /* try snap edge, then face if it fails */ ret = ED_transform_snap_object_project_ray_ex( - sctx, + C, sctx, params, ray_start, ray_normal, ray_depth, r_co, r_no, NULL, @@ -2300,7 +2310,7 @@ static bool transform_snap_context_project_ray_impl( } bool ED_transform_snap_object_project_ray( - SnapObjectContext *sctx, + const bContext *C, SnapObjectContext *sctx, const struct SnapObjectParams *params, const float ray_origin[3], const float ray_direction[3], float *ray_depth, float r_co[3], float r_no[3]) @@ -2312,14 +2322,14 @@ bool ED_transform_snap_object_project_ray( } return transform_snap_context_project_ray_impl( - sctx, + C, sctx, params, ray_origin, ray_direction, ray_depth, r_co, r_no); } static bool transform_snap_context_project_view3d_mixed_impl( - SnapObjectContext *sctx, + const bContext *C, SnapObjectContext *sctx, const unsigned short snap_to_flag, const struct SnapObjectParams *params, const float mval[2], float *dist_px, @@ -2343,7 +2353,7 @@ static bool transform_snap_context_project_view3d_mixed_impl( *dist_px = dist_px_orig; } if (ED_transform_snap_object_project_view3d( - sctx, + C, sctx, elem_type[i], params, mval, dist_px, &ray_depth, r_co, r_no)) @@ -2360,7 +2370,7 @@ static bool transform_snap_context_project_view3d_mixed_impl( for (int i = 0; i < 3; i++) { if (snap_to_flag & (1 << i)) { if (ED_transform_snap_object_project_view3d( - sctx, + C, sctx, elem_type[i], params, mval, dist_px, &ray_depth, r_co, r_no)) @@ -2389,7 +2399,7 @@ static bool transform_snap_context_project_view3d_mixed_impl( * \return Snap success */ bool ED_transform_snap_object_project_view3d_mixed( - SnapObjectContext *sctx, + const bContext *C, SnapObjectContext *sctx, const unsigned short snap_to_flag, const struct SnapObjectParams *params, const float mval_fl[2], float *dist_px, @@ -2397,14 +2407,14 @@ bool ED_transform_snap_object_project_view3d_mixed( float r_co[3], float r_no[3]) { return transform_snap_context_project_view3d_mixed_impl( - sctx, + C, sctx, snap_to_flag, params, mval_fl, dist_px, use_depth, r_co, r_no); } bool ED_transform_snap_object_project_view3d_ex( - SnapObjectContext *sctx, + const bContext *C, SnapObjectContext *sctx, const unsigned short snap_to, const struct SnapObjectParams *params, const float mval[2], float *dist_px, @@ -2438,7 +2448,7 @@ bool ED_transform_snap_object_project_view3d_ex( if (snap_to == SCE_SNAP_MODE_FACE) { return raycastObjects( - sctx, + C, sctx, ray_origin, ray_start, ray_normal, depth_range, params->snap_select, params->use_object_edit_cage, ray_depth, r_loc, r_no, r_index, NULL, NULL, NULL); @@ -2450,14 +2460,14 @@ bool ED_transform_snap_object_project_view3d_ex( ray_origin, ray_start, ray_normal, depth_range); return snapObjectsRay( - sctx, &snapdata, + C, sctx, &snapdata, params->snap_select, params->use_object_edit_cage, ray_depth, dist_px, r_loc, r_no, NULL, NULL); } } bool ED_transform_snap_object_project_view3d( - SnapObjectContext *sctx, + const bContext *C, SnapObjectContext *sctx, const unsigned short snap_to, const struct SnapObjectParams *params, const float mval[2], float *dist_px, @@ -2465,7 +2475,7 @@ bool ED_transform_snap_object_project_view3d( float r_loc[3], float r_no[3]) { return ED_transform_snap_object_project_view3d_ex( - sctx, + C, sctx, snap_to, params, mval, dist_px, @@ -2477,7 +2487,7 @@ bool ED_transform_snap_object_project_view3d( * see: #ED_transform_snap_object_project_ray_all */ bool ED_transform_snap_object_project_all_view3d_ex( - SnapObjectContext *sctx, + const bContext *C, SnapObjectContext *sctx, const struct SnapObjectParams *params, const float mval[2], float ray_depth, bool sort, @@ -2493,7 +2503,7 @@ bool ED_transform_snap_object_project_all_view3d_ex( } return ED_transform_snap_object_project_ray_all( - sctx, + C, sctx, params, ray_start, ray_normal, ray_depth, sort, r_hit_list); |