- work-in-progress: subsurf level 0 now just acts like a regular mesh,
before it would follow subsurf code path by creating fake displistmesh, etc... kinda fun for testing but just annoying now. - change to creasing behavior, to make sure that with full creasing effect is just simple subdivision.
This commit is contained in:
		@@ -39,9 +39,6 @@ struct EditMesh;
 | 
			
		||||
struct DerivedMesh *subsurf_make_derived_from_editmesh(struct EditMesh *em, int subdivLevels, short type, struct DerivedMesh *oldDerived);
 | 
			
		||||
struct DerivedMesh *subsurf_make_derived_from_mesh(struct Mesh *me, int subdivLevels);
 | 
			
		||||
 | 
			
		||||
struct DerivedMesh *subsurf_ccg_make_derived_from_editmesh(struct EditMesh *em, int useFlatSubdiv, int subdivLevels, struct DerivedMesh *oldDerived);
 | 
			
		||||
struct DerivedMesh *subsurf_ccg_make_derived_from_mesh(struct Mesh *me, int useFlatSubdiv, int subdivLevels);
 | 
			
		||||
 | 
			
		||||
void subsurf_calculate_limit_positions(Mesh *me, float (*positions_r)[3]);
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 
 | 
			
		||||
@@ -1131,7 +1131,7 @@ static void ccgSubSurf__sync(CCGSubSurf *ss) {
 | 
			
		||||
		CCGVert *v = effectedV[ptrIdx];
 | 
			
		||||
		void *co = VERT_getCo(v, curLvl);
 | 
			
		||||
		void *nCo = VERT_getCo(v, nextLvl);
 | 
			
		||||
		int sharpCount = 0;
 | 
			
		||||
		int sharpCount = 0, allSharp = 1;
 | 
			
		||||
		float avgSharpness = 0.0;
 | 
			
		||||
 | 
			
		||||
		for (i=0; i<v->numEdges; i++) {
 | 
			
		||||
@@ -1141,6 +1141,8 @@ static void ccgSubSurf__sync(CCGSubSurf *ss) {
 | 
			
		||||
			if (sharpness!=0.0f) {
 | 
			
		||||
				sharpCount++;
 | 
			
		||||
				avgSharpness += sharpness;
 | 
			
		||||
			} else {
 | 
			
		||||
				allSharp = 0;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
@@ -1206,7 +1208,7 @@ static void ccgSubSurf__sync(CCGSubSurf *ss) {
 | 
			
		||||
 | 
			
		||||
			ss->meshIFC.vertDataMulN(ss->meshData, q, (float) 1/sharpCount);
 | 
			
		||||
 | 
			
		||||
			if (sharpCount!=2) {
 | 
			
		||||
			if (sharpCount!=2 || allSharp) {
 | 
			
		||||
					// q = q + (co-q)*avgSharpness
 | 
			
		||||
				ss->meshIFC.vertDataCopy(ss->meshData, r, co);
 | 
			
		||||
				ss->meshIFC.vertDataSub(ss->meshData, r, q);
 | 
			
		||||
@@ -1409,7 +1411,7 @@ static void ccgSubSurf__sync(CCGSubSurf *ss) {
 | 
			
		||||
			CCGVert *v = (CCGVert*) effectedV[ptrIdx];
 | 
			
		||||
			void *co = VERT_getCo(v, curLvl);
 | 
			
		||||
			void *nCo = VERT_getCo(v, nextLvl);
 | 
			
		||||
			int sharpCount = 0;
 | 
			
		||||
			int sharpCount = 0, allSharp = 1;
 | 
			
		||||
			float avgSharpness = 0.0;
 | 
			
		||||
 | 
			
		||||
			for (i=0; i<v->numEdges; i++) {
 | 
			
		||||
@@ -1419,6 +1421,8 @@ static void ccgSubSurf__sync(CCGSubSurf *ss) {
 | 
			
		||||
				if (sharpness!=0.0f) {
 | 
			
		||||
					sharpCount++;
 | 
			
		||||
					avgSharpness += sharpness;
 | 
			
		||||
				} else {
 | 
			
		||||
					allSharp = 0;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
@@ -1485,7 +1489,7 @@ static void ccgSubSurf__sync(CCGSubSurf *ss) {
 | 
			
		||||
 | 
			
		||||
				ss->meshIFC.vertDataMulN(ss->meshData, q, (float) 1/sharpCount);
 | 
			
		||||
 | 
			
		||||
				if (sharpCount!=2) {
 | 
			
		||||
				if (sharpCount!=2 || allSharp) {
 | 
			
		||||
						// q = q + (co-q)*avgSharpness
 | 
			
		||||
					ss->meshIFC.vertDataCopy(ss->meshData, r, co);
 | 
			
		||||
					ss->meshIFC.vertDataSub(ss->meshData, r, q);
 | 
			
		||||
 
 | 
			
		||||
@@ -969,7 +969,7 @@ static void build_mesh_data(Object *ob, int inEditMode)
 | 
			
		||||
			if(eff->type==EFF_WAVE) makeDispList(ob);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	if(mesh_uses_displist(me)) {
 | 
			
		||||
	if(me->flag&ME_SUBSURF) {
 | 
			
		||||
		if(inEditMode && !G.editMesh->derived) {
 | 
			
		||||
			makeDispList(ob);
 | 
			
		||||
		} else if (!inEditMode && !me->derived) {
 | 
			
		||||
@@ -986,8 +986,7 @@ DerivedMesh *mesh_get_derived(Object *ob)
 | 
			
		||||
{
 | 
			
		||||
	Mesh *me= ob->data;
 | 
			
		||||
 | 
			
		||||
	if (mesh_uses_displist(me)) {
 | 
			
		||||
 | 
			
		||||
	if ((me->flag&ME_SUBSURF) && me->subdiv) {
 | 
			
		||||
		if(G.obedit && me==G.obedit->data) {
 | 
			
		||||
			build_mesh_data(ob, 1);
 | 
			
		||||
			return G.editMesh->derived;
 | 
			
		||||
@@ -1004,8 +1003,7 @@ DerivedMesh *mesh_get_derived_render(Object *ob, int *needsFree)
 | 
			
		||||
{
 | 
			
		||||
	Mesh *me= ob->data;
 | 
			
		||||
 | 
			
		||||
	if (mesh_uses_displist(me)) {
 | 
			
		||||
			// XXX, assumes was created earlier... is this for sure?
 | 
			
		||||
	if ((me->flag&ME_SUBSURF) && me->subdivr) {
 | 
			
		||||
		if (me->subdiv==me->subdivr) {
 | 
			
		||||
			*needsFree = 0;
 | 
			
		||||
			if(G.obedit && me==G.obedit->data) {
 | 
			
		||||
@@ -1013,7 +1011,8 @@ DerivedMesh *mesh_get_derived_render(Object *ob, int *needsFree)
 | 
			
		||||
			} else {
 | 
			
		||||
				return me->derived;
 | 
			
		||||
			}
 | 
			
		||||
		} else {
 | 
			
		||||
		} 
 | 
			
		||||
 | 
			
		||||
		*needsFree = 1;
 | 
			
		||||
		if(G.obedit && me==G.obedit->data) {
 | 
			
		||||
			return subsurf_make_derived_from_editmesh(G.editMesh, me->subdivr, me->subsurftype, NULL);
 | 
			
		||||
@@ -1021,7 +1020,6 @@ DerivedMesh *mesh_get_derived_render(Object *ob, int *needsFree)
 | 
			
		||||
			return subsurf_make_derived_from_mesh(me, me->subdivr);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return NULL;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1203,7 +1203,7 @@ void mcol_to_tface(Mesh *me, int freedata)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int mesh_uses_displist(Mesh *me) {
 | 
			
		||||
	return (me->flag&ME_SUBSURF);
 | 
			
		||||
	return (me->flag&ME_SUBSURF) && me->subdiv;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void mesh_calculate_vertex_normals(Mesh *me)
 | 
			
		||||
 
 | 
			
		||||
@@ -1082,37 +1082,6 @@ static DispListMesh *subsurf_subdivide_to_displistmesh(HyperMesh *hme, short sub
 | 
			
		||||
	return dlm;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
DerivedMesh *subsurf_make_derived_from_editmesh(EditMesh *em, int subdivLevels, short type, DerivedMesh *oldDerived) {
 | 
			
		||||
	if (subdivLevels<1) {
 | 
			
		||||
		if (oldDerived) {
 | 
			
		||||
			oldDerived->release(oldDerived);
 | 
			
		||||
		}
 | 
			
		||||
		return derivedmesh_from_displistmesh(em, displistmesh_from_editmesh(em));
 | 
			
		||||
	} else if (type==ME_CCG_SUBSURF || type==ME_SIMPLE_SUBSURF) {
 | 
			
		||||
		return subsurf_ccg_make_derived_from_editmesh(em, type==ME_SIMPLE_SUBSURF, subdivLevels, oldDerived);
 | 
			
		||||
	} else {
 | 
			
		||||
		HyperMesh *hme= hypermesh_from_editmesh(em, subdivLevels);
 | 
			
		||||
	
 | 
			
		||||
		if (oldDerived) {
 | 
			
		||||
			oldDerived->release(oldDerived);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		return derivedmesh_from_displistmesh(em, subsurf_subdivide_to_displistmesh(hme, subdivLevels, type));
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
DerivedMesh *subsurf_make_derived_from_mesh(Mesh *me, int subdivLevels) {
 | 
			
		||||
	if (subdivLevels<1) {
 | 
			
		||||
		return derivedmesh_from_displistmesh(NULL, displistmesh_from_mesh(me, NULL));
 | 
			
		||||
	} else if (me->subsurftype==ME_CCG_SUBSURF || me->subsurftype==ME_SIMPLE_SUBSURF) {
 | 
			
		||||
		return subsurf_ccg_make_derived_from_mesh(me, me->subsurftype==ME_SIMPLE_SUBSURF, subdivLevels);
 | 
			
		||||
	} else {
 | 
			
		||||
		HyperMesh *hme= hypermesh_from_mesh(me, subdivLevels);
 | 
			
		||||
 | 
			
		||||
		return derivedmesh_from_displistmesh(NULL, subsurf_subdivide_to_displistmesh(hme, subdivLevels, me->subsurftype));
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
	// editarmature.c
 | 
			
		||||
void subsurf_calculate_limit_positions(Mesh *me, float (*positions_r)[3]) 
 | 
			
		||||
{
 | 
			
		||||
 
 | 
			
		||||
@@ -988,7 +988,7 @@ static CCGDerivedMesh *getCCGDerivedMesh(SubSurf *ss) {
 | 
			
		||||
 | 
			
		||||
/***/
 | 
			
		||||
 | 
			
		||||
DerivedMesh *subsurf_ccg_make_derived_from_editmesh(EditMesh *em, int useFlatSubdiv, int subdivLevels, DerivedMesh *oldDerived) {
 | 
			
		||||
DerivedMesh *subsurf_make_derived_from_editmesh(EditMesh *em, int subdivLevels, short type, DerivedMesh *oldDerived) {
 | 
			
		||||
	CCGDerivedMesh *ccgdm;
 | 
			
		||||
 | 
			
		||||
	if (oldDerived) {
 | 
			
		||||
@@ -998,12 +998,13 @@ DerivedMesh *subsurf_ccg_make_derived_from_editmesh(EditMesh *em, int useFlatSub
 | 
			
		||||
		ccgdm = getCCGDerivedMesh(ss);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	subSurf_sync(ccgdm->ss, useFlatSubdiv);
 | 
			
		||||
	subSurf_sync(ccgdm->ss, type==ME_SIMPLE_SUBSURF);
 | 
			
		||||
 | 
			
		||||
	return (DerivedMesh*) ccgdm;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
DerivedMesh *subsurf_ccg_make_derived_from_mesh(Mesh *me, int useFlatSubdiv, int subdivLevels) {
 | 
			
		||||
DerivedMesh *subsurf_make_derived_from_mesh(Mesh *me, int subdivLevels) {
 | 
			
		||||
	int useFlatSubdiv = me->subsurftype==ME_SIMPLE_SUBSURF;
 | 
			
		||||
	SubSurf *ss = subSurf_fromMesh(me, useFlatSubdiv, subdivLevels);
 | 
			
		||||
	DispListMesh *dlm;
 | 
			
		||||
 | 
			
		||||
@@ -1015,3 +1016,4 @@ DerivedMesh *subsurf_ccg_make_derived_from_mesh(Mesh *me, int useFlatSubdiv, int
 | 
			
		||||
	
 | 
			
		||||
	return derivedmesh_from_displistmesh(NULL, dlm);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1344,7 +1344,7 @@ static void init_render_mesh(Object *ob)
 | 
			
		||||
	
 | 
			
		||||
	/* we do this before deform */
 | 
			
		||||
	if(need_orco) {
 | 
			
		||||
		if (mesh_uses_displist(me)) 
 | 
			
		||||
		if ((me->flag&ME_SUBSURF) && me->subdivr) 
 | 
			
		||||
			make_orco_displist_mesh(ob, me->subdivr);
 | 
			
		||||
		else
 | 
			
		||||
			make_orco_mesh(me);
 | 
			
		||||
@@ -1353,7 +1353,7 @@ static void init_render_mesh(Object *ob)
 | 
			
		||||
	/* after orco, because this changes mesh vertices (too) */
 | 
			
		||||
	do_puno= mesh_modifier(ob, 's');
 | 
			
		||||
	
 | 
			
		||||
	if (mesh_uses_displist(me)) {
 | 
			
		||||
	if ((me->flag&ME_SUBSURF) && me->subdivr) {
 | 
			
		||||
		int needsFree;
 | 
			
		||||
		DerivedMesh *dm = mesh_get_derived_render(ob, &needsFree);
 | 
			
		||||
		dlm = dm->convertToDispListMesh(dm);
 | 
			
		||||
@@ -2734,7 +2734,7 @@ void RE_freeRotateBlenderScene(void)
 | 
			
		||||
				MEM_freeN(me->orco);
 | 
			
		||||
				me->orco= 0;
 | 
			
		||||
			}
 | 
			
		||||
			if (mesh_uses_displist(me) && ((me->subdiv!=me->subdivr) || (ob->effect.first != NULL) || ob==G.obedit) ) { 
 | 
			
		||||
			if ((me->flag&ME_SUBSURF) && ((me->subdiv!=me->subdivr) || (ob->effect.first != NULL) || ob==G.obedit) ) { 
 | 
			
		||||
			    /* Need to recalc for effects since they are time dependant */
 | 
			
		||||
				makeDispList(ob);  /* XXX this should be replaced with proper caching */
 | 
			
		||||
			}
 | 
			
		||||
@@ -2956,7 +2956,7 @@ void RE_rotateBlenderScene(void)
 | 
			
		||||
				else if(ob->parent && ob->parent->type==OB_LATTICE) makeDispList(ob);
 | 
			
		||||
				else if(ob->hooks.first) makeDispList(ob);
 | 
			
		||||
				else if(ob->softflag & 0x01) makeDispList(ob);
 | 
			
		||||
				else if(me->disp.first==NULL && mesh_uses_displist(me)) makeDispList(ob);
 | 
			
		||||
				else if(me->disp.first==NULL && (me->flag&ME_SUBSURF)) makeDispList(ob);
 | 
			
		||||
				else if(ob->effect.first) {	// as last check
 | 
			
		||||
					Effect *eff= ob->effect.first;
 | 
			
		||||
					if(eff->type==EFF_WAVE) makeDispList(ob);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user