diff options
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/BKE_multires.h | 11 | ||||
-rw-r--r-- | source/blender/blenkernel/BKE_object.h | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/multires.c | 47 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/object.c | 4 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/subsurf_ccg.c | 2 | ||||
-rw-r--r-- | source/blender/editors/object/object_bake.c | 4 | ||||
-rw-r--r-- | source/blender/editors/object/object_modifier.c | 9 | ||||
-rw-r--r-- | source/blender/editors/object/object_relations.c | 3 | ||||
-rw-r--r-- | source/blender/modifiers/intern/MOD_multires.c | 5 |
9 files changed, 49 insertions, 38 deletions
diff --git a/source/blender/blenkernel/BKE_multires.h b/source/blender/blenkernel/BKE_multires.h index cecea927e8a..3a70e145744 100644 --- a/source/blender/blenkernel/BKE_multires.h +++ b/source/blender/blenkernel/BKE_multires.h @@ -61,7 +61,7 @@ void multires_force_render_update(struct Object *ob); void multires_force_external_reload(struct Object *ob); /* internal, only called in subsurf_ccg.c */ -void multires_modifier_update_mdisps(struct DerivedMesh *dm); +void multires_modifier_update_mdisps(struct DerivedMesh *dm, struct Scene *scene); void multires_modifier_update_hidden(struct DerivedMesh *dm); void multiresModifier_set_levels_from_disps(struct MultiresModifierData *mmd, struct Object *ob); @@ -75,6 +75,7 @@ typedef enum { struct DerivedMesh *multires_make_derived_from_derived(struct DerivedMesh *dm, struct MultiresModifierData *mmd, + struct Scene *scene, struct Object *ob, MultiresFlags flags); @@ -83,11 +84,11 @@ struct MultiresModifierData *find_multires_modifier_before(struct Scene *scene, struct MultiresModifierData *get_multires_modifier(struct Scene *scene, struct Object *ob, bool use_first); struct DerivedMesh *get_multires_dm(struct Depsgraph *depsgraph, struct Scene *scene, struct MultiresModifierData *mmd, struct Object *ob); -void multiresModifier_del_levels(struct MultiresModifierData *, struct Object *, int direction); -void multiresModifier_base_apply(struct MultiresModifierData *mmd, struct Object *ob); -void multiresModifier_subdivide(struct MultiresModifierData *mmd, struct Object *ob, int updateblock, int simple); +void multiresModifier_del_levels(struct MultiresModifierData *mmd, struct Scene *scene, struct Object *object, int direction); +void multiresModifier_base_apply(struct MultiresModifierData *mmd, struct Scene *scene, struct Object *ob); +void multiresModifier_subdivide(struct MultiresModifierData *mmd, struct Scene *scene, struct Object *ob, int updateblock, int simple); void multiresModifier_sync_levels_ex( - struct Object *ob_dst, struct MultiresModifierData *mmd_src, struct MultiresModifierData *mmd_dst); + struct Scene *scene, struct Object *ob_dst, struct MultiresModifierData *mmd_src, struct MultiresModifierData *mmd_dst); int multiresModifier_reshape(struct Depsgraph *depsgraph, struct Scene *scene, struct MultiresModifierData *mmd, struct Object *dst, struct Object *src); int multiresModifier_reshapeFromDM(struct Depsgraph *depsgraph, struct Scene *scene, struct MultiresModifierData *mmd, diff --git a/source/blender/blenkernel/BKE_object.h b/source/blender/blenkernel/BKE_object.h index 9562e0e8f15..a54b244f5fd 100644 --- a/source/blender/blenkernel/BKE_object.h +++ b/source/blender/blenkernel/BKE_object.h @@ -73,7 +73,7 @@ void BKE_object_modifier_hook_reset(struct Object *ob, struct HookModifierData * bool BKE_object_support_modifier_type_check(const struct Object *ob, int modifier_type); -void BKE_object_link_modifiers(struct Object *ob_dst, const struct Object *ob_src); +void BKE_object_link_modifiers(struct Scene *scene, struct Object *ob_dst, const struct Object *ob_src); void BKE_object_free_modifiers(struct Object *ob, const int flag); void BKE_object_make_proxy(struct Object *ob, struct Object *target, struct Object *gob); diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index 5bd4a1a0475..22309be2a1b 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -337,17 +337,17 @@ MultiresModifierData *get_multires_modifier(Scene *scene, Object *ob, bool use_f return mmd; } -static int multires_get_level(Object *ob, MultiresModifierData *mmd, +static int multires_get_level(Scene *scene, Object *ob, MultiresModifierData *mmd, bool render, bool ignore_simplify) { if (render) - return (mmd->modifier.scene) ? get_render_subsurf_level(&mmd->modifier.scene->r, mmd->renderlvl, true) : mmd->renderlvl; + return (scene != NULL) ? get_render_subsurf_level(&scene->r, mmd->renderlvl, true) : mmd->renderlvl; else if (ob->mode == OB_MODE_SCULPT) return mmd->sculptlvl; else if (ignore_simplify) return mmd->lvl; else - return (mmd->modifier.scene) ? get_render_subsurf_level(&mmd->modifier.scene->r, mmd->lvl, false) : mmd->lvl; + return (scene != NULL) ? get_render_subsurf_level(&scene->r, mmd->lvl, false) : mmd->lvl; } void multires_set_tot_level(Object *ob, MultiresModifierData *mmd, int lvl) @@ -435,7 +435,7 @@ int multiresModifier_reshapeFromDeformMod(struct Depsgraph *depsgraph, Scene *sc float (*deformedVerts)[3]; const ModifierEvalContext mectx = {depsgraph, ob, 0}; - if (multires_get_level(ob, mmd, false, true) == 0) + if (multires_get_level(scene, ob, mmd, false, true) == 0) return 0; /* Create DerivedMesh for deformation modifier */ @@ -681,10 +681,10 @@ static void multires_del_higher(MultiresModifierData *mmd, Object *ob, int lvl) } /* (direction = 1) for delete higher, (direction = 0) for lower (not implemented yet) */ -void multiresModifier_del_levels(MultiresModifierData *mmd, Object *ob, int direction) +void multiresModifier_del_levels(MultiresModifierData *mmd, Scene *scene, Object *ob, int direction) { Mesh *me = BKE_mesh_from_object(ob); - int lvl = multires_get_level(ob, mmd, false, true); + int lvl = multires_get_level(scene, ob, mmd, false, true); int levels = mmd->totlvl - lvl; MDisps *mdisps; @@ -701,7 +701,7 @@ void multiresModifier_del_levels(MultiresModifierData *mmd, Object *ob, int dire multires_set_tot_level(ob, mmd, lvl); } -static DerivedMesh *multires_dm_create_local(Object *ob, DerivedMesh *dm, int lvl, int totlvl, int simple, bool alloc_paint_mask) +static DerivedMesh *multires_dm_create_local(Scene *scene, Object *ob, DerivedMesh *dm, int lvl, int totlvl, int simple, bool alloc_paint_mask) { MultiresModifierData mmd = {{NULL}}; MultiresFlags flags = MULTIRES_USE_LOCAL_MMD; @@ -715,7 +715,7 @@ static DerivedMesh *multires_dm_create_local(Object *ob, DerivedMesh *dm, int lv if (alloc_paint_mask) flags |= MULTIRES_ALLOC_PAINT_MASK; - return multires_make_derived_from_derived(dm, &mmd, ob, flags); + return multires_make_derived_from_derived(dm, &mmd, scene, ob, flags); } static DerivedMesh *subsurf_dm_create_local(Object *ob, DerivedMesh *dm, int lvl, int simple, int optimal, int plain_uv, int alloc_paint_mask) @@ -751,7 +751,7 @@ static float v3_dist_from_plane(float v[3], float center[3], float no[3]) return dot_v3v3(s, no); } -void multiresModifier_base_apply(MultiresModifierData *mmd, Object *ob) +void multiresModifier_base_apply(MultiresModifierData *mmd, Scene *scene, Object *ob) { DerivedMesh *cddm, *dispdm, *origdm; Mesh *me; @@ -773,7 +773,7 @@ void multiresModifier_base_apply(MultiresModifierData *mmd, Object *ob) /* generate highest level with displacements */ cddm = CDDM_from_mesh(me); DM_set_only_copy(cddm, CD_MASK_BAREMESH); - dispdm = multires_dm_create_local(ob, cddm, totlvl, totlvl, 0, 0); + dispdm = multires_dm_create_local(scene, ob, cddm, totlvl, totlvl, 0, 0); cddm->release(cddm); /* copy the new locations of the base verts into the mesh */ @@ -879,7 +879,9 @@ void multiresModifier_base_apply(MultiresModifierData *mmd, Object *ob) dispdm->release(dispdm); } -static void multires_subdivide(MultiresModifierData *mmd, Object *ob, int totlvl, int updateblock, int simple) +static void multires_subdivide( + MultiresModifierData *mmd, Scene *scene, Object *ob, + int totlvl, int updateblock, int simple) { Mesh *me = ob->data; MDisps *mdisps; @@ -912,7 +914,7 @@ static void multires_subdivide(MultiresModifierData *mmd, Object *ob, int totlvl ss = ((CCGDerivedMesh *)highdm)->ss; /* create multires DM from original mesh at low level */ - lowdm = multires_dm_create_local(ob, cddm, lvl, lvl, simple, has_mask); + lowdm = multires_dm_create_local(scene, ob, cddm, lvl, lvl, simple, has_mask); BLI_assert(lowdm != cddm); cddm->release(cddm); @@ -962,9 +964,9 @@ static void multires_subdivide(MultiresModifierData *mmd, Object *ob, int totlvl multires_set_tot_level(ob, mmd, totlvl); } -void multiresModifier_subdivide(MultiresModifierData *mmd, Object *ob, int updateblock, int simple) +void multiresModifier_subdivide(MultiresModifierData *mmd, Scene *scene, Object *ob, int updateblock, int simple) { - multires_subdivide(mmd, ob, mmd->totlvl + 1, updateblock, simple); + multires_subdivide(mmd, scene, ob, mmd->totlvl + 1, updateblock, simple); } static void grid_tangent(const CCGKey *key, int x, int y, int axis, CCGElem *grid, float t[3]) @@ -1197,7 +1199,7 @@ static void multiresModifier_disp_run(DerivedMesh *dm, Mesh *me, DerivedMesh *dm } } -void multires_modifier_update_mdisps(struct DerivedMesh *dm) +void multires_modifier_update_mdisps(struct DerivedMesh *dm, Scene *scene) { CCGDerivedMesh *ccgdm = (CCGDerivedMesh *)dm; Object *ob; @@ -1233,7 +1235,7 @@ void multires_modifier_update_mdisps(struct DerivedMesh *dm) ss = ((CCGDerivedMesh *)highdm)->ss; /* create multires DM from original mesh and displacements */ - lowdm = multires_dm_create_local(ob, cddm, lvl, totlvl, mmd->simple, has_mask); + lowdm = multires_dm_create_local(scene, ob, cddm, lvl, totlvl, mmd->simple, has_mask); cddm->release(cddm); /* gather grid data */ @@ -1354,6 +1356,7 @@ void multires_stitch_grids(Object *ob) DerivedMesh *multires_make_derived_from_derived(DerivedMesh *dm, MultiresModifierData *mmd, + Scene *scene, Object *ob, MultiresFlags flags) { @@ -1364,7 +1367,7 @@ DerivedMesh *multires_make_derived_from_derived(DerivedMesh *dm, CCGKey key; const bool render = (flags & MULTIRES_USE_RENDER_PARAMS) != 0; const bool ignore_simplify = (flags & MULTIRES_IGNORE_SIMPLIFY) != 0; - int lvl = multires_get_level(ob, mmd, render, ignore_simplify); + int lvl = multires_get_level(scene, ob, mmd, render, ignore_simplify); int i, gridSize, numGrids; if (lvl == 0) @@ -2049,7 +2052,7 @@ void multires_load_old(Object *ob, Mesh *me) BLI_insertlinkbefore(&ob->modifiers, md, mmd); for (i = 0; i < me->mr->level_count - 1; ++i) - multiresModifier_subdivide(mmd, ob, 1, 0); + multiresModifier_subdivide(mmd, NULL, ob, 1, 0); mmd->lvl = mmd->totlvl; orig = CDDM_from_mesh(me); @@ -2058,7 +2061,7 @@ void multires_load_old(Object *ob, Mesh *me) * reference subsurfed dm with this option, before calling multiresModifier_disp_run(), * which implicitly expects both subsurfs from its first dm and oldGridData parameters to * be of the same "format"! */ - dm = multires_make_derived_from_derived(orig, mmd, ob, 0); + dm = multires_make_derived_from_derived(orig, mmd, NULL, ob, 0); multires_load_old_dm(dm, me, mmd->totlvl + 1); @@ -2073,14 +2076,14 @@ void multires_load_old(Object *ob, Mesh *me) /* If 'ob_src' and 'ob_dst' both have multires modifiers, synchronize them * such that 'ob_dst' has the same total number of levels as 'ob_src'. */ -void multiresModifier_sync_levels_ex(Object *ob_dst, MultiresModifierData *mmd_src, MultiresModifierData *mmd_dst) +void multiresModifier_sync_levels_ex(Scene *scene, Object *ob_dst, MultiresModifierData *mmd_src, MultiresModifierData *mmd_dst) { if (mmd_src->totlvl == mmd_dst->totlvl) { return; } if (mmd_src->totlvl > mmd_dst->totlvl) { - multires_subdivide(mmd_dst, ob_dst, mmd_src->totlvl, false, mmd_dst->simple); + multires_subdivide(mmd_dst, scene, ob_dst, mmd_src->totlvl, false, mmd_dst->simple); } else { multires_del_higher(mmd_dst, ob_dst, mmd_src->totlvl); @@ -2102,7 +2105,7 @@ static void multires_sync_levels(Scene *scene, Object *ob_src, Object *ob_dst) } if (mmd_src && mmd_dst) { - multiresModifier_sync_levels_ex(ob_dst, mmd_src, mmd_dst); + multiresModifier_sync_levels_ex(scene, ob_dst, mmd_src, mmd_dst); } } diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index b3b7139a78c..af963d784ec 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -249,7 +249,7 @@ bool BKE_object_support_modifier_type_check(const Object *ob, int modifier_type) return true; } -void BKE_object_link_modifiers(struct Object *ob_dst, const struct Object *ob_src) +void BKE_object_link_modifiers(Scene *scene, struct Object *ob_dst, const struct Object *ob_src) { ModifierData *md; BKE_object_free_modifiers(ob_dst, 0); @@ -288,7 +288,7 @@ void BKE_object_link_modifiers(struct Object *ob_dst, const struct Object *ob_sr if (md->type == eModifierType_Multires) { /* Has to be done after mod creation, but *before* we actually copy its settings! */ - multiresModifier_sync_levels_ex(ob_dst, (MultiresModifierData *)md, (MultiresModifierData *)nmd); + multiresModifier_sync_levels_ex(scene, ob_dst, (MultiresModifierData *)md, (MultiresModifierData *)nmd); } modifier_copyData(md, nmd); diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index e4f08703dfc..694f1d8bd5a 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -1827,7 +1827,7 @@ static void ccgDM_release(DerivedMesh *dm) if (ccgdm->multires.mmd) { if (ccgdm->multires.modified_flags & MULTIRES_COORDS_MODIFIED) - multires_modifier_update_mdisps(dm); + multires_modifier_update_mdisps(dm, NULL); if (ccgdm->multires.modified_flags & MULTIRES_HIDDEN_MODIFIED) multires_modifier_update_hidden(dm); } diff --git a/source/blender/editors/object/object_bake.c b/source/blender/editors/object/object_bake.c index a8da5c038b4..954de8e58af 100644 --- a/source/blender/editors/object/object_bake.c +++ b/source/blender/editors/object/object_bake.c @@ -241,7 +241,7 @@ static DerivedMesh *multiresbake_create_loresdm(Scene *scene, Object *ob, int *l tmp_mmd.lvl = *lvl; tmp_mmd.sculptlvl = *lvl; - dm = multires_make_derived_from_derived(cddm, &tmp_mmd, ob, 0); + dm = multires_make_derived_from_derived(cddm, &tmp_mmd, scene, ob, 0); cddm->release(cddm); return dm; @@ -268,7 +268,7 @@ static DerivedMesh *multiresbake_create_hiresdm(Scene *scene, Object *ob, int *l tmp_mmd.lvl = mmd->totlvl; tmp_mmd.sculptlvl = mmd->totlvl; - dm = multires_make_derived_from_derived(cddm, &tmp_mmd, ob, 0); + dm = multires_make_derived_from_derived(cddm, &tmp_mmd, scene, ob, 0); cddm->release(cddm); return dm; diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index 29ccd985029..f66a69253e8 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -1154,13 +1154,14 @@ static int multires_poll(bContext *C) static int multires_higher_levels_delete_exec(bContext *C, wmOperator *op) { + Scene *scene = CTX_data_scene(C); Object *ob = ED_object_active_context(C); MultiresModifierData *mmd = (MultiresModifierData *)edit_modifier_property_get(op, ob, eModifierType_Multires); if (!mmd) return OPERATOR_CANCELLED; - multiresModifier_del_levels(mmd, ob, 1); + multiresModifier_del_levels(mmd, scene, ob, 1); ED_object_iter_other(CTX_data_main(C), ob, true, ED_object_multires_update_totlevels_cb, @@ -1198,13 +1199,14 @@ void OBJECT_OT_multires_higher_levels_delete(wmOperatorType *ot) static int multires_subdivide_exec(bContext *C, wmOperator *op) { + Scene *scene = CTX_data_scene(C); Object *ob = ED_object_active_context(C); MultiresModifierData *mmd = (MultiresModifierData *)edit_modifier_property_get(op, ob, eModifierType_Multires); if (!mmd) return OPERATOR_CANCELLED; - multiresModifier_subdivide(mmd, ob, 0, mmd->simple); + multiresModifier_subdivide(mmd, scene, ob, 0, mmd->simple); ED_object_iter_other(CTX_data_main(C), ob, true, ED_object_multires_update_totlevels_cb, @@ -1421,13 +1423,14 @@ void OBJECT_OT_multires_external_pack(wmOperatorType *ot) /********************* multires apply base ***********************/ static int multires_base_apply_exec(bContext *C, wmOperator *op) { + Scene *scene = CTX_data_scene(C); Object *ob = ED_object_active_context(C); MultiresModifierData *mmd = (MultiresModifierData *)edit_modifier_property_get(op, ob, eModifierType_Multires); if (!mmd) return OPERATOR_CANCELLED; - multiresModifier_base_apply(mmd, ob); + multiresModifier_base_apply(mmd, scene, ob); DEG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index a114b2cc6d5..f2e996237cf 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -1419,6 +1419,7 @@ static bool allow_make_links_data(const int type, Object *ob_src, Object *ob_dst static int make_links_data_exec(bContext *C, wmOperator *op) { + Scene *scene = CTX_data_scene(C); Main *bmain = CTX_data_main(C); const int type = RNA_enum_get(op->ptr, "type"); Object *ob_src; @@ -1503,7 +1504,7 @@ static int make_links_data_exec(bContext *C, wmOperator *op) } break; case MAKE_LINKS_MODIFIERS: - BKE_object_link_modifiers(ob_dst, ob_src); + BKE_object_link_modifiers(scene, ob_dst, ob_src); DEG_id_tag_update(&ob_dst->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); break; case MAKE_LINKS_FONTS: diff --git a/source/blender/modifiers/intern/MOD_multires.c b/source/blender/modifiers/intern/MOD_multires.c index a23511ff87a..aa9bc0dbc20 100644 --- a/source/blender/modifiers/intern/MOD_multires.c +++ b/source/blender/modifiers/intern/MOD_multires.c @@ -46,6 +46,8 @@ #include "BKE_modifier.h" #include "BKE_subsurf.h" +#include "DEG_depsgraph_query.h" + #include "MOD_modifiertypes.h" static void initData(ModifierData *md) @@ -63,6 +65,7 @@ static DerivedMesh *applyModifier( DerivedMesh *dm) { MultiresModifierData *mmd = (MultiresModifierData *)md; + struct Scene *scene = DEG_get_evaluated_scene(ctx->depsgraph); DerivedMesh *result; Mesh *me = (Mesh *)ctx->object->data; const bool useRenderParams = (ctx->flag & MOD_APPLY_RENDER) != 0; @@ -86,7 +89,7 @@ static DerivedMesh *applyModifier( if (ignore_simplify) flags |= MULTIRES_IGNORE_SIMPLIFY; - result = multires_make_derived_from_derived(dm, mmd, ctx->object, flags); + result = multires_make_derived_from_derived(dm, mmd, scene, ctx->object, flags); if (result == dm) return dm; |