From ce0cb4de8d9174f94e1c48952050080576b76141 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 6 Feb 2018 19:34:36 +1100 Subject: Object Mode: use eval_ctx for modifiers_isCorrectableDeformed Some other minor changes from D3037 as well --- source/blender/blenkernel/BKE_cloth.h | 4 +++- source/blender/blenkernel/BKE_modifier.h | 3 ++- source/blender/blenkernel/intern/cloth.c | 6 ++++-- source/blender/blenkernel/intern/modifier.c | 8 +++++--- source/blender/editors/object/object_edit.c | 6 +++++- source/blender/editors/sculpt_paint/sculpt_undo.c | 3 --- source/blender/editors/transform/transform_conversions.c | 2 +- 7 files changed, 20 insertions(+), 12 deletions(-) diff --git a/source/blender/blenkernel/BKE_cloth.h b/source/blender/blenkernel/BKE_cloth.h index 7f7cbd678e2..27b928c1671 100644 --- a/source/blender/blenkernel/BKE_cloth.h +++ b/source/blender/blenkernel/BKE_cloth.h @@ -236,7 +236,9 @@ void bvhtree_update_from_cloth(struct ClothModifierData *clmd, bool moving); void bvhselftree_update_from_cloth(struct ClothModifierData *clmd, bool moving); // needed for button_object.c -void cloth_clear_cache (struct Object *ob, struct ClothModifierData *clmd, float framenr ); +void cloth_clear_cache( + const struct EvaluationContext *eval_ctx, + struct Object *ob, struct ClothModifierData *clmd, float framenr ); void cloth_parallel_transport_hair_frame(float mat[3][3], const float dir_old[3], const float dir_new[3]); diff --git a/source/blender/blenkernel/BKE_modifier.h b/source/blender/blenkernel/BKE_modifier.h index 451823aedf5..8ee67850e5f 100644 --- a/source/blender/blenkernel/BKE_modifier.h +++ b/source/blender/blenkernel/BKE_modifier.h @@ -374,7 +374,8 @@ struct Object *modifiers_isDeformedByArmature(struct Object *ob); struct Object *modifiers_isDeformedByLattice(struct Object *ob); struct Object *modifiers_isDeformedByCurve(struct Object *ob); bool modifiers_usesArmature(struct Object *ob, struct bArmature *arm); -bool modifiers_isCorrectableDeformed(struct Scene *scene, struct Object *ob); +bool modifiers_isCorrectableDeformed( + const struct EvaluationContext *eval_ctx, struct Scene *scene, struct Object *ob); void modifier_freeTemporaryData(struct ModifierData *md); bool modifiers_isPreview(struct Object *ob); diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c index 09b793629f7..22fd0bbfa9c 100644 --- a/source/blender/blenkernel/intern/cloth.c +++ b/source/blender/blenkernel/intern/cloth.c @@ -40,6 +40,8 @@ #include "BLI_edgehash.h" #include "BLI_linklist.h" +#include "DEG_depsgraph.h" + #include "BKE_cdderivedmesh.h" #include "BKE_cloth.h" #include "BKE_effect.h" @@ -304,14 +306,14 @@ void bvhselftree_update_from_cloth(ClothModifierData *clmd, bool moving) } } -void cloth_clear_cache(Object *ob, ClothModifierData *clmd, float framenr) +void cloth_clear_cache(const EvaluationContext *eval_ctx, Object *ob, ClothModifierData *clmd, float framenr) { PTCacheID pid; BKE_ptcache_id_from_cloth(&pid, ob, clmd); // don't do anything as long as we're in editmode! - if (pid.cache->edit && ob->mode & OB_MODE_PARTICLE_EDIT) + if (pid.cache->edit && eval_ctx->object_mode & OB_MODE_PARTICLE_EDIT) return; BKE_ptcache_id_clear(&pid, PTCACHE_CLEAR_AFTER, framenr); diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index 8bfeacd256c..1604a017054 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -69,6 +69,8 @@ #include "BKE_main.h" /* end */ +#include "DEG_depsgraph.h" + #include "MOD_modifiertypes.h" static ModifierTypeInfo *modifier_types[NUM_MODIFIER_TYPES] = {NULL}; @@ -660,15 +662,15 @@ bool modifier_isCorrectableDeformed(ModifierData *md) return (mti->deformMatricesEM != NULL); } -bool modifiers_isCorrectableDeformed(struct Scene *scene, Object *ob) +bool modifiers_isCorrectableDeformed(const EvaluationContext *eval_ctx, struct Scene *scene, Object *ob) { VirtualModifierData virtualModifierData; ModifierData *md = modifiers_getVirtualModifierList(ob, &virtualModifierData); int required_mode = eModifierMode_Realtime; - if (ob->mode == OB_MODE_EDIT) + if (eval_ctx->object_mode == OB_MODE_EDIT) { required_mode |= eModifierMode_Editmode; - + } for (; md; md = md->next) { if (!modifier_isEnabled(scene, md, required_mode)) { /* pass */ diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 4b00852557f..c9dc9e6952c 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -472,9 +472,13 @@ static int editmode_toggle_poll(bContext *C) if (ELEM(NULL, ob, ob->data) || ID_IS_LINKED(ob->data)) return 0; + EvaluationContext eval_ctx; + CTX_data_eval_ctx(C, &eval_ctx); + /* if hidden but in edit mode, we still display */ - if ((ob->restrictflag & OB_RESTRICT_VIEW) && !(ob->mode & OB_MODE_EDIT)) + if ((ob->restrictflag & OB_RESTRICT_VIEW) && !(eval_ctx.object_mode & OB_MODE_EDIT)) { return 0; + } return OB_TYPE_SUPPORT_EDITMODE(ob->type); } diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c index 19dcf7b4a44..3d9021480d9 100644 --- a/source/blender/editors/sculpt_paint/sculpt_undo.c +++ b/source/blender/editors/sculpt_paint/sculpt_undo.c @@ -334,9 +334,6 @@ static void sculpt_undo_bmesh_restore_generic(bContext *C, Object *ob, SculptSession *ss) { - EvaluationContext eval_ctx; - CTX_data_eval_ctx(C, &eval_ctx); - if (unode->applied) { BM_log_undo(ss->bm, ss->bm_log); unode->applied = false; diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index ecc02ef7abc..9720cc1e613 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -2562,7 +2562,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->scene, t->obedit)) { + if (modifiers_isCorrectableDeformed(&t->eval_ctx, 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); -- cgit v1.2.3