Code cleanup for parameters of subsurf_make_derived_from_derived.
This is the first commit of the sculpt masking merge. Documentation: http://wiki.blender.org/index.php/User:Nicholasbishop/PaintMasks Thanks to Brecht for reviewing! Replaced four boolean parameters with a single flag and a new enum, SubsurfFlags.
This commit is contained in:
@@ -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]);
|
||||
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -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);
|
||||
|
@@ -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;
|
||||
|
@@ -619,7 +619,7 @@ static void *init_heights_data(MultiresBakeRender *bkr, Image *ima)
|
||||
if (bkr->simple)
|
||||
smd.subdivType = ME_SIMPLE_SUBSURF;
|
||||
|
||||
height_data->ssdm = subsurf_make_derived_from_derived(bkr->lores_dm, &smd, 0, NULL, 0, 0, 0);
|
||||
height_data->ssdm = subsurf_make_derived_from_derived(bkr->lores_dm, &smd, NULL, 0);
|
||||
}
|
||||
|
||||
height_data->origindex = lodm->getTessFaceDataArray(lodm, CD_ORIGINDEX);
|
||||
|
@@ -402,7 +402,7 @@ static ParamHandle *construct_param_handle_subsurfed(Scene *scene, BMEditMesh *e
|
||||
|
||||
initialDerived = CDDM_from_BMEditMesh(em, NULL, 0, 0);
|
||||
derivedMesh = subsurf_make_derived_from_derived(initialDerived, &smd,
|
||||
0, NULL, 0, 0, 1);
|
||||
NULL, SUBSURF_IN_EDIT_MODE);
|
||||
|
||||
initialDerived->release(initialDerived);
|
||||
|
||||
|
@@ -94,12 +94,19 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
|
||||
ModifierApplyFlag flag)
|
||||
{
|
||||
SubsurfModifierData *smd = (SubsurfModifierData *) md;
|
||||
SubsurfFlags subsurf_flags = 0;
|
||||
DerivedMesh *result;
|
||||
const int useRenderParams = flag & MOD_APPLY_RENDER;
|
||||
const int isFinalCalc = flag & MOD_APPLY_USECACHE;
|
||||
|
||||
result = subsurf_make_derived_from_derived(derivedData, smd, useRenderParams, NULL,
|
||||
isFinalCalc, 0, (ob->flag & OB_MODE_EDIT));
|
||||
if(useRenderParams)
|
||||
subsurf_flags |= SUBSURF_USE_RENDER_PARAMS;
|
||||
if(isFinalCalc)
|
||||
subsurf_flags |= SUBSURF_IS_FINAL_CALC;
|
||||
if(ob->flag & OB_MODE_EDIT)
|
||||
subsurf_flags |= SUBSURF_IN_EDIT_MODE;
|
||||
|
||||
result = subsurf_make_derived_from_derived(derivedData, smd, NULL, subsurf_flags);
|
||||
|
||||
if (useRenderParams || !isFinalCalc) {
|
||||
DerivedMesh *cddm = CDDM_copy(result);
|
||||
@@ -117,8 +124,9 @@ static DerivedMesh *applyModifierEM(ModifierData *md, Object *UNUSED(ob),
|
||||
SubsurfModifierData *smd = (SubsurfModifierData *) md;
|
||||
DerivedMesh *result;
|
||||
|
||||
result = subsurf_make_derived_from_derived(derivedData, smd, 0,
|
||||
NULL, 0, 1, 1);
|
||||
result = subsurf_make_derived_from_derived(derivedData, smd,
|
||||
NULL, (SUBSURF_FOR_EDIT_MODE |
|
||||
SUBSURF_IN_EDIT_MODE));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
Reference in New Issue
Block a user