diff options
author | Campbell Barton <ideasman42@gmail.com> | 2007-06-09 14:51:02 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2007-06-09 14:51:02 +0400 |
commit | 10a22bdba75a5c7c74ea95aad59d22bc0cab0fea (patch) | |
tree | c37639cf83e5610d4beb263feb8eb1d07384309d | |
parent | c356f3d68fe94134edfd5def4a9da7494c571e58 (diff) |
subsurfs EDGE_getSharpness function was looping when it didnt need to and also took an unused value.
removed loop and unused var, since this is a sensitive (and not my) area - I did some mesh comparisons and ran a comparison with the old function passing random values, so this should be ok.
-rw-r--r-- | source/blender/blenkernel/intern/CCGSubSurf.c | 35 |
1 files changed, 16 insertions, 19 deletions
diff --git a/source/blender/blenkernel/intern/CCGSubSurf.c b/source/blender/blenkernel/intern/CCGSubSurf.c index bd585d36a68..4e00e29029c 100644 --- a/source/blender/blenkernel/intern/CCGSubSurf.c +++ b/source/blender/blenkernel/intern/CCGSubSurf.c @@ -483,20 +483,17 @@ static void _edge_unlinkMarkAndFree(CCGEdge *e, CCGSubSurf *ss) { _edge_free(e, ss); } -static float EDGE_getSharpness(CCGEdge *e, int lvl, CCGSubSurf *ss) { - float sharpness = e->crease; - while (lvl--) { - if (sharpness>1.0) { - sharpness -= 1.0; - } else { - sharpness = 0.0; - } - } - return sharpness; +static float EDGE_getSharpness(CCGEdge *e, int lvl) { + if (!lvl) + return e->crease; + else if (!e->crease) + return 0.0; + else if (e->crease - lvl < 0.0) + return 0.0; + else + return e->crease - lvl; } -/***/ - static CCGFace *_face_new(CCGFaceHDL fHDL, CCGVert **verts, CCGEdge **edges, int numVerts, int levels, int dataSize, CCGSubSurf *ss) { int maxGridSize = 1 + (1<<(ss->subdivLevels-1)); CCGFace *f = CCGSUBSURF_alloc(ss, sizeof(CCGFace) + sizeof(CCGVert*)*numVerts + sizeof(CCGEdge*)*numVerts + ss->meshIFC.vertDataSize *(1 + numVerts*maxGridSize + numVerts*maxGridSize*maxGridSize) + ss->meshIFC.faceUserSize); @@ -1194,7 +1191,7 @@ static void ccgSubSurf__sync(CCGSubSurf *ss) { for (ptrIdx=0; ptrIdx<numEffectedE; ptrIdx++) { CCGEdge *e = effectedE[ptrIdx]; void *co = EDGE_getCo(e, nextLvl, 1); - float sharpness = EDGE_getSharpness(e, curLvl, ss); + float sharpness = EDGE_getSharpness(e, curLvl); if (_edge_isBoundary(e) || sharpness>=1.0) { VertDataCopy(co, VERT_getCo(e->v0, curLvl)); @@ -1233,7 +1230,7 @@ static void ccgSubSurf__sync(CCGSubSurf *ss) { for (i=0; i<v->numEdges; i++) { CCGEdge *e = v->edges[i]; - float sharpness = EDGE_getSharpness(e, curLvl, ss); + float sharpness = EDGE_getSharpness(e, curLvl); if (seam && _edge_isBoundary(e)) seamEdges++; @@ -1307,7 +1304,7 @@ static void ccgSubSurf__sync(CCGSubSurf *ss) { for (i=0; i<v->numEdges; i++) { CCGEdge *e = v->edges[i]; - float sharpness = EDGE_getSharpness(e, curLvl, ss); + float sharpness = EDGE_getSharpness(e, curLvl); if (seam) { if (_edge_isBoundary(e)) { @@ -1472,7 +1469,7 @@ static void ccgSubSurf__sync(CCGSubSurf *ss) { */ for (ptrIdx=0; ptrIdx<numEffectedE; ptrIdx++) { CCGEdge *e = (CCGEdge*) effectedE[ptrIdx]; - float sharpness = EDGE_getSharpness(e, curLvl, ss); + float sharpness = EDGE_getSharpness(e, curLvl); if (_edge_isBoundary(e) || sharpness>1.0) { for (x=0; x<edgeSize-1; x++) { @@ -1531,7 +1528,7 @@ static void ccgSubSurf__sync(CCGSubSurf *ss) { for (i=0; i<v->numEdges; i++) { CCGEdge *e = v->edges[i]; - float sharpness = EDGE_getSharpness(e, curLvl, ss); + float sharpness = EDGE_getSharpness(e, curLvl); if (seam && _edge_isBoundary(e)) seamEdges++; @@ -1607,7 +1604,7 @@ static void ccgSubSurf__sync(CCGSubSurf *ss) { for (i=0; i<v->numEdges; i++) { CCGEdge *e = v->edges[i]; - float sharpness = EDGE_getSharpness(e, curLvl, ss); + float sharpness = EDGE_getSharpness(e, curLvl); if (seam) { if (_edge_isBoundary(e)) @@ -1647,7 +1644,7 @@ static void ccgSubSurf__sync(CCGSubSurf *ss) { */ for (ptrIdx=0; ptrIdx<numEffectedE; ptrIdx++) { CCGEdge *e = (CCGEdge*) effectedE[ptrIdx]; - float sharpness = EDGE_getSharpness(e, curLvl, ss); + float sharpness = EDGE_getSharpness(e, curLvl); int sharpCount = 0; float avgSharpness = 0.0; |