diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2012-05-09 19:00:26 +0400 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2012-05-09 19:00:26 +0400 |
commit | 318b44fe5d142ca1ac29a6933da8cd9e2c439e9a (patch) | |
tree | 5dd43e6332ba8005a5ae29126a8ad37c6147fd48 /source/blender/blenkernel/intern | |
parent | 895e426e2661b4969a9aaa6d1c526253e2e9e1d4 (diff) |
Refactor of modifiers' apply function: now use a single bit-flag parameter to pass options, instead of having one parameter per boolean flag (i.e. replaces current useRenderParams and isFinalCalc by a single ModifierApplyFlag flag. ModifierApplyFlag is an enum defined in BKE_modifier.h). This way we won't anymore have to edit all modifier files when e.g. adding a new control flag!
Should have no effect over modifier behavior.
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r-- | source/blender/blenkernel/intern/DerivedMesh.c | 28 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/displist.c | 30 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/lattice.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/multires.c | 4 |
4 files changed, 43 insertions, 21 deletions
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index e74a412420c..50c10ea3c3d 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -814,7 +814,7 @@ DerivedMesh *mesh_create_derived_for_modifier(Scene *scene, Object *ob, int numVerts; float (*deformedVerts)[3] = mesh_getVertexCos(me, &numVerts); - mti->deformVerts(md, ob, NULL, deformedVerts, numVerts, 0, 0); + mti->deformVerts(md, ob, NULL, deformedVerts, numVerts, 0); dm = mesh_create_derived(me, ob, deformedVerts); if (build_shapekey_layers) @@ -828,7 +828,7 @@ DerivedMesh *mesh_create_derived_for_modifier(Scene *scene, Object *ob, if (build_shapekey_layers) add_shapekey_layers(tdm, me, ob); - dm = mti->applyModifier(md, ob, tdm, 0, 0); + dm = mti->applyModifier(md, ob, tdm, 0); if (tdm != dm) tdm->release(tdm); } @@ -1383,6 +1383,13 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos /* XXX Same as above... For now, only weights preview in WPaint mode. */ const int do_mod_wmcol = do_init_wmcol; + ModifierApplyFlag app_flags = useRenderParams ? MOD_APPLY_RENDER : 0; + ModifierApplyFlag deform_app_flags = app_flags; + if (useCache) + app_flags |= MOD_APPLY_USECACHE; + if (useDeform) + deform_app_flags |= MOD_APPLY_USECACHE; + if (mmd && !mmd->sculptlvl) has_multires = 0; @@ -1434,7 +1441,7 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos if (!deformedVerts) deformedVerts = mesh_getVertexCos(me, &numVerts); - mti->deformVerts(md, ob, NULL, deformedVerts, numVerts, useRenderParams, useDeform); + mti->deformVerts(md, ob, NULL, deformedVerts, numVerts, deform_app_flags); } else { break; @@ -1547,7 +1554,7 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos } } - mti->deformVerts(md, ob, dm, deformedVerts, numVerts, useRenderParams, useDeform); + mti->deformVerts(md, ob, dm, deformedVerts, numVerts, deform_app_flags); } else { DerivedMesh *ndm; @@ -1622,7 +1629,7 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos } } - ndm = mti->applyModifier(md, ob, dm, useRenderParams, useCache); + ndm = mti->applyModifier(md, ob, dm, app_flags); if (ndm) { /* if the modifier returned a new dm, release the old one */ @@ -1645,7 +1652,7 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos nextmask &= ~CD_MASK_ORCO; DM_set_only_copy(orcodm, nextmask | CD_MASK_ORIGINDEX); - ndm = mti->applyModifier(md, ob, orcodm, useRenderParams, 0); + ndm = mti->applyModifier(md, ob, orcodm, app_flags & ~MOD_APPLY_USECACHE); if (ndm) { /* if the modifier returned a new dm, release the old one */ @@ -1661,7 +1668,7 @@ static void mesh_calc_modifiers(Scene *scene, Object *ob, float (*inputVertexCos nextmask &= ~CD_MASK_CLOTH_ORCO; DM_set_only_copy(clothorcodm, nextmask | CD_MASK_ORIGINDEX); - ndm = mti->applyModifier(md, ob, clothorcodm, useRenderParams, 0); + ndm = mti->applyModifier(md, ob, clothorcodm, app_flags & ~MOD_APPLY_USECACHE); if (ndm) { /* if the modifier returned a new dm, release the old one */ @@ -1928,7 +1935,8 @@ static void editbmesh_calc_modifiers(Scene *scene, Object *ob, BMEditMesh *em, D if (mti->deformVertsEM) mti->deformVertsEM(md, ob, em, dm, deformedVerts, numVerts); - else mti->deformVerts(md, ob, dm, deformedVerts, numVerts, 0, 0); + else + mti->deformVerts(md, ob, dm, deformedVerts, numVerts, 0); } else { DerivedMesh *ndm; @@ -1971,7 +1979,7 @@ static void editbmesh_calc_modifiers(Scene *scene, Object *ob, BMEditMesh *em, D if (mti->applyModifierEM) ndm = mti->applyModifierEM(md, ob, em, orcodm); else - ndm = mti->applyModifier(md, ob, orcodm, 0, 0); + ndm = mti->applyModifier(md, ob, orcodm, 0); if (ndm) { /* if the modifier returned a new dm, release the old one */ @@ -1995,7 +2003,7 @@ static void editbmesh_calc_modifiers(Scene *scene, Object *ob, BMEditMesh *em, D if (mti->applyModifierEM) ndm = mti->applyModifierEM(md, ob, em, dm); else - ndm = mti->applyModifier(md, ob, dm, 0, 0); + ndm = mti->applyModifier(md, ob, dm, 0); if (ndm) { if (dm && dm != ndm) diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index a3f5c5c23c6..29aab8b3eb6 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -752,14 +752,19 @@ static void curve_calc_modifiers_pre(Scene *scene, Object *ob, int forRender, fl Curve *cu = ob->data; ListBase *nurb = BKE_curve_nurbs_get(cu); int numVerts = 0; - int editmode = (!forRender && cu->editnurb); + const int editmode = (!forRender && cu->editnurb); + ModifierApplyFlag app_flag = 0; float (*originalVerts)[3] = NULL; float (*deformedVerts)[3] = NULL; float *keyVerts = NULL; int required_mode; - if (forRender) + if (editmode) + app_flag |= MOD_APPLY_USECACHE; + if (forRender) { + app_flag |= MOD_APPLY_RENDER; required_mode = eModifierMode_Render; + } else required_mode = eModifierMode_Realtime; @@ -800,7 +805,7 @@ static void curve_calc_modifiers_pre(Scene *scene, Object *ob, int forRender, fl originalVerts = MEM_dupallocN(deformedVerts); } - mti->deformVerts(md, ob, NULL, deformedVerts, numVerts, forRender, editmode); + mti->deformVerts(md, ob, NULL, deformedVerts, numVerts, app_flag); if (md == pretessellatePoint) break; @@ -866,9 +871,12 @@ static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispba DerivedMesh *dm = NULL, *ndm; float (*vertCos)[3] = NULL; int useCache = !forRender; + ModifierApplyFlag app_flag = 0; - if (forRender) + if (forRender) { + app_flag |= MOD_APPLY_RENDER; required_mode = eModifierMode_Render; + } else required_mode = eModifierMode_Realtime; @@ -887,6 +895,7 @@ static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispba for (; md; md = md->next) { ModifierTypeInfo *mti = modifierType_getInfo(md->type); + ModifierApplyFlag appf = app_flag; md->scene = scene; @@ -897,6 +906,8 @@ static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispba if (mti->type == eModifierTypeType_OnlyDeform || (mti->type == eModifierTypeType_DeformOrConstruct && !dm)) { + if (editmode) + appf |= MOD_APPLY_USECACHE; if (dm) { if (!vertCos) { totvert = dm->getNumVerts(dm); @@ -904,14 +915,14 @@ static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispba dm->getVertCos(dm, vertCos); } - mti->deformVerts(md, ob, dm, vertCos, totvert, forRender, editmode); + mti->deformVerts(md, ob, dm, vertCos, totvert, appf); } else { if (!vertCos) { vertCos = displist_get_allverts(dispbase, &totvert); } - mti->deformVerts(md, ob, NULL, vertCos, totvert, forRender, editmode); + mti->deformVerts(md, ob, NULL, vertCos, totvert, appf); } } else { @@ -953,7 +964,9 @@ static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispba vertCos = NULL; } - ndm = mti->applyModifier(md, ob, dm, forRender, useCache); + if (useCache) + appf |= MOD_APPLY_USECACHE; + ndm = mti->applyModifier(md, ob, dm, appf); if (ndm) { /* Modifier returned a new derived mesh */ @@ -1084,6 +1097,7 @@ static void curve_calc_orcodm(Scene *scene, Object *ob, DerivedMesh *derivedFina int required_mode; int editmode = (!forRender && cu->editnurb); DerivedMesh *ndm, *orcodm = NULL; + const ModifierApplyFlag app_flag = forRender ? MOD_APPLY_RENDER : 0; if (forRender) required_mode = eModifierMode_Render; @@ -1114,7 +1128,7 @@ static void curve_calc_orcodm(Scene *scene, Object *ob, DerivedMesh *derivedFina if (!orcodm) orcodm = create_orco_dm(scene, ob); - ndm = mti->applyModifier(md, ob, orcodm, forRender, 0); + ndm = mti->applyModifier(md, ob, orcodm, app_flag); if (ndm) { /* if the modifier returned a new dm, release the old one */ diff --git a/source/blender/blenkernel/intern/lattice.c b/source/blender/blenkernel/intern/lattice.c index 8ac8acf6edf..c6f2bb75858 100644 --- a/source/blender/blenkernel/intern/lattice.c +++ b/source/blender/blenkernel/intern/lattice.c @@ -976,7 +976,7 @@ void BKE_lattice_modifiers_calc(Scene *scene, Object *ob) if (mti->type != eModifierTypeType_OnlyDeform) continue; if (!vertexCos) vertexCos = BKE_lattice_vertexcos_get(ob, &numVerts); - mti->deformVerts(md, ob, NULL, vertexCos, numVerts, 0, 0); + mti->deformVerts(md, ob, NULL, vertexCos, numVerts, 0); } /* always displist to make this work like derivedmesh */ diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index bee1f534d05..026134609b7 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -279,7 +279,7 @@ DerivedMesh *get_multires_dm(Scene *scene, MultiresModifierData *mmd, Object *ob DerivedMesh *tdm = mesh_get_derived_deform(scene, ob, CD_MASK_BAREMESH); DerivedMesh *dm; - dm = mti->applyModifier(md, ob, tdm, 0, 1); + dm = mti->applyModifier(md, ob, tdm, MOD_APPLY_USECACHE); if (dm == tdm) { dm = CDDM_copy(tdm); } @@ -438,7 +438,7 @@ int multiresModifier_reshapeFromDeformMod(Scene *scene, MultiresModifierData *mm deformedVerts = MEM_callocN(sizeof(float) * numVerts * 3, "multiresReshape_deformVerts"); dm->getVertCos(dm, deformedVerts); - mti->deformVerts(md, ob, dm, deformedVerts, numVerts, 0, 0); + mti->deformVerts(md, ob, dm, deformedVerts, numVerts, 0); ndm = CDDM_copy(dm); CDDM_apply_vert_coords(ndm, deformedVerts); |