diff options
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_subsurf.h | 11 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/multires.c | 5 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/shrinkwrap.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/subsurf_ccg.c | 17 |
4 files changed, 22 insertions, 13 deletions
diff --git a/source/blender/blenkernel/BKE_subsurf.h b/source/blender/blenkernel/BKE_subsurf.h index 8179c688580..400056c527c 100644 --- a/source/blender/blenkernel/BKE_subsurf.h +++ b/source/blender/blenkernel/BKE_subsurf.h @@ -56,11 +56,18 @@ struct DMGridAdjacency; /**************************** External *****************************/ +typedef enum { + SUBSURF_USE_RENDER_PARAMS = 1, + SUBSURF_IS_FINAL_CALC = 2, + SUBSURF_FOR_EDIT_MODE = 4, + SUBSURF_IN_EDIT_MODE = 8 +} SubsurfFlags; + struct DerivedMesh *subsurf_make_derived_from_derived( struct DerivedMesh *dm, struct SubsurfModifierData *smd, - int useRenderParams, float (*vertCos)[3], - int isFinalCalc, int forEditMode, int inEditMode); + float (*vertCos)[3], + SubsurfFlags flags); void subsurf_calculate_limit_positions(struct Mesh *me, float (*positions_r)[3]); diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index 026134609b7..886278eb809 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -684,6 +684,7 @@ static DerivedMesh *multires_dm_create_local(Object *ob, DerivedMesh *dm, int lv static DerivedMesh *subsurf_dm_create_local(Object *ob, DerivedMesh *dm, int lvl, int simple, int optimal, int plain_uv) { SubsurfModifierData smd = {{NULL}}; + SubsurfFlags flags = 0; smd.levels = smd.renderLevels = lvl; if (!plain_uv) @@ -693,7 +694,9 @@ static DerivedMesh *subsurf_dm_create_local(Object *ob, DerivedMesh *dm, int lvl if (optimal) smd.flags |= eSubsurfModifierFlag_ControlEdges; - return subsurf_make_derived_from_derived(dm, &smd, 0, NULL, 0, 0, (ob->mode & OB_MODE_EDIT)); + if (ob->mode & OB_MODE_EDIT) + flags |= SUBSURF_IN_EDIT_MODE; + return subsurf_make_derived_from_derived(dm, &smd, NULL, flags); } diff --git a/source/blender/blenkernel/intern/shrinkwrap.c b/source/blender/blenkernel/intern/shrinkwrap.c index fdda1c6ec0a..67c60d61b66 100644 --- a/source/blender/blenkernel/intern/shrinkwrap.c +++ b/source/blender/blenkernel/intern/shrinkwrap.c @@ -523,7 +523,7 @@ void shrinkwrapModifier_deform(ShrinkwrapModifierData *smd, Object *ob, DerivedM ssmd.subdivType = ME_CC_SUBSURF; //catmull clark ssmd.levels = smd->subsurfLevels; //levels - ss_mesh = subsurf_make_derived_from_derived(dm, &ssmd, FALSE, NULL, 0, 0, (ob->mode & OB_MODE_EDIT)); + ss_mesh = subsurf_make_derived_from_derived(dm, &ssmd, NULL, (ob->mode & OB_MODE_EDIT) ? SUBSURF_IN_EDIT_MODE : 0); if (ss_mesh) { calc.vert = ss_mesh->getVertDataArray(ss_mesh, CD_MVERT); diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index e81cab6b912..becdf585259 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -3367,8 +3367,8 @@ static CCGDerivedMesh *getCCGDerivedMesh(CCGSubSurf *ss, struct DerivedMesh *subsurf_make_derived_from_derived( struct DerivedMesh *dm, struct SubsurfModifierData *smd, - int useRenderParams, float (*vertCos)[3], - int isFinalCalc, int forEditMode, int inEditMode) + float (*vertCos)[3], + SubsurfFlags flags) { int useSimple = smd->subdivType == ME_SIMPLE_SUBSURF; CCGFlags useAging = smd->flags & eSubsurfModifierFlag_DebugIncr ? CCG_USE_AGING : 0; @@ -3376,7 +3376,7 @@ struct DerivedMesh *subsurf_make_derived_from_derived( int drawInteriorEdges = !(smd->flags & eSubsurfModifierFlag_ControlEdges); CCGDerivedMesh *result; - if (forEditMode) { + if (flags & SUBSURF_FOR_EDIT_MODE) { int levels = (smd->modifier.scene) ? get_render_subsurf_level(&smd->modifier.scene->r, smd->levels) : smd->levels; smd->emCache = _getSubSurf(smd->emCache, levels, useAging | CCG_CALC_NORMALS); @@ -3386,7 +3386,7 @@ struct DerivedMesh *subsurf_make_derived_from_derived( drawInteriorEdges, useSubsurfUv, dm); } - else if (useRenderParams) { + else if (flags & SUBSURF_USE_RENDER_PARAMS) { /* Do not use cache in render mode. */ CCGSubSurf *ss; int levels = (smd->modifier.scene) ? get_render_subsurf_level(&smd->modifier.scene->r, smd->renderLevels) : smd->renderLevels; @@ -3419,14 +3419,13 @@ struct DerivedMesh *subsurf_make_derived_from_derived( * Addendum: we can't really ensure that this is never called in edit * mode, so now we have a parameter to verify it. - brecht */ - if (!inEditMode && smd->emCache) { + if (!(flags & SUBSURF_IN_EDIT_MODE) && smd->emCache) { ccgSubSurf_free(smd->emCache); smd->emCache = NULL; } - if (useIncremental && isFinalCalc) { + if (useIncremental && (flags & SUBSURF_IS_FINAL_CALC)) { smd->mCache = ss = _getSubSurf(smd->mCache, levels, useAging | CCG_CALC_NORMALS); - ss_sync_from_derivedmesh(ss, dm, vertCos, useSimple); result = getCCGDerivedMesh(smd->mCache, @@ -3434,7 +3433,7 @@ struct DerivedMesh *subsurf_make_derived_from_derived( useSubsurfUv, dm); } else { - if (smd->mCache && isFinalCalc) { + if (smd->mCache && (flags & SUBSURF_IS_FINAL_CALC)) { ccgSubSurf_free(smd->mCache); smd->mCache = NULL; } @@ -3444,7 +3443,7 @@ struct DerivedMesh *subsurf_make_derived_from_derived( result = getCCGDerivedMesh(ss, drawInteriorEdges, useSubsurfUv, dm); - if (isFinalCalc) + if (flags & SUBSURF_IS_FINAL_CALC) smd->mCache = ss; else result->freeSS = 1; |