コード例 #1
0
static int isDisabled(ModifierData *md, int useRenderParams)
{
	SubsurfModifierData *smd = (SubsurfModifierData *) md;
	int levels = (useRenderParams) ? smd->renderLevels : smd->levels;

	return get_render_subsurf_level(&md->scene->r, levels) == 0;
}
コード例 #2
0
ファイル: subsurf_sl.c プロジェクト: Micket/SLSubSurf
/*
 * Entrypoint for modifier. Should return the output DM based on the input DM.
 */
struct DerivedMesh *sl_subsurf_make_derived_from_derived(
	struct DerivedMesh *input,
	struct SubsurfModifierData *smd,
	float (*vertCos)[3],
	SubsurfFlags flags)
{
	SLSubSurf *ss;
	int i,j;
	int numCol, numTex;
	int levels;
	int smoothing = smd->subdivType == ME_SL_SUBSURF;
	int useSubsurfUv = smd->flags & eSubsurfModifierFlag_SubsurfUv;
	// TODO drawInterior
	//int drawInteriorEdges = !(smd->flags & eSubsurfModifierFlag_ControlEdges);
	DerivedMesh *result, *prevResult;
	
	// We don't use caches for this modifier
	if (smd->emCache) {
		smd->cacheFree(smd->emCache);
		smd->emCache = NULL;
	}
	if (smd->mCache) {
		smd->cacheFree(smd->mCache);
		smd->mCache = NULL;
	}

	if (flags & SUBSURF_USE_RENDER_PARAMS) {
		levels = (smd->modifier.scene) ? get_render_subsurf_level(&smd->modifier.scene->r, smd->renderLevels) : smd->renderLevels;
	}
	else /*if (flags & SUBSURF_FOR_EDIT_MODE)*/ {
		levels = (smd->modifier.scene) ? get_render_subsurf_level(&smd->modifier.scene->r, smd->levels) : smd->levels;
	}
	// Not sure if this is acceptable, but it needs to be dealt with:
	if (levels == 0) return input;

	// Now create the structures recursively, freeing all the middle steps (this gets a bit messy...)
	numCol = CustomData_number_of_layers(&input->loopData, CD_MLOOPCOL);
	numTex = CustomData_number_of_layers(&input->loopData, CD_MLOOPUV);
	
	prevResult = input;
	for (i = 0; i < levels; i++) {
		if (i == 0) {
			prevResult = input;
		} else {
			prevResult = result;
		}
		ss = SL_SubSurf_new(smoothing, prevResult, vertCos);
		result = SL_SubSurf_constructOutput(ss);
		SL_syncVertData(ss, result); // Have to before syncing verts themselves.
		SL_syncVerts(ss, result);
		for (j = 0; j < numCol; j++) {
			SL_syncPaint(ss, result, j);
		}
		for (j = 0; j < numTex; j++) {
			SL_syncUV(ss, result, useSubsurfUv, j);
		}
		if (prevResult != input && i < levels - 1) { // We are not allowed to remove the input DM, and not the last DM either (we need to tesselate)
			prevResult->release(prevResult);
		}
	}
	// We know the what the output DM contains, so we can optimize the tess face generation;
	//slDM_constructTessFaces(result);
	// TODO: All poly custom data should be copied over to tess faces as CD_REFERENCE, which would save time and memory.
	//result->recalcTessellation(result);
	slDM_constructTessFaces(result);
	if (prevResult != input) { // We are not allowed to remove the input DM, and not the last DM either (we need to tesselate)
		prevResult->release(prevResult);
	}
	
	// The preview color (for weight painting) needs to be copied over manually;
	
	
	loops_to_customdata_corners(result);
	
	
	return result;
}