diff options
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r-- | source/blender/blenkernel/intern/CCGSubSurf.c | 36 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/CCGSubSurf.h | 24 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/anim.c | 18 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/subsurf_ccg.c | 19 |
4 files changed, 43 insertions, 54 deletions
diff --git a/source/blender/blenkernel/intern/CCGSubSurf.c b/source/blender/blenkernel/intern/CCGSubSurf.c index 140f596f78c..3ab52a7c17b 100644 --- a/source/blender/blenkernel/intern/CCGSubSurf.c +++ b/source/blender/blenkernel/intern/CCGSubSurf.c @@ -218,7 +218,7 @@ static CCGAllocatorIFC *_getStandardAllocatorIFC(void) { /***/ -static int VertDataEqual(float *a, float *b) { +static int VertDataEqual(const float *a, const float *b) { return a[0]==b[0] && a[1]==b[1] && a[2]==b[2]; } #define VertDataZero(av) { float *_a = (float*) av; _a[0] = _a[1] = _a[2] = 0.0f; } @@ -238,7 +238,7 @@ static int VertDataEqual(float *a, float *b) { #define NormAdd(av, bv) { float *_a = (float*) av, *_b = (float*) bv; _a[0]+=_b[0]; _a[1]+=_b[1]; _a[2]+=_b[2]; } -static int _edge_isBoundary(CCGEdge *e); +static int _edge_isBoundary(const CCGEdge *e); /***/ @@ -392,7 +392,7 @@ static void _vert_addFace(CCGVert *v, CCGFace *f, CCGSubSurf *ss) { v->faces = CCGSUBSURF_realloc(ss, v->faces, (v->numFaces+1)*sizeof(*v->faces), v->numFaces*sizeof(*v->faces)); v->faces[v->numFaces++] = f; } -static CCGEdge *_vert_findEdgeTo(CCGVert *v, CCGVert *vQ) { +static CCGEdge *_vert_findEdgeTo(const CCGVert *v, const CCGVert *vQ) { int i; for (i=0; i<v->numEdges; i++) { CCGEdge *e = v->edges[v->numEdges-1-i]; // XXX, note reverse @@ -402,7 +402,7 @@ static CCGEdge *_vert_findEdgeTo(CCGVert *v, CCGVert *vQ) { } return NULL; } -static int _vert_isBoundary(CCGVert *v) { +static int _vert_isBoundary(const CCGVert *v) { int i; for (i=0; i<v->numEdges; i++) if (_edge_isBoundary(v->edges[i])) @@ -423,7 +423,7 @@ static void _vert_free(CCGVert *v, CCGSubSurf *ss) { CCGSUBSURF_free(ss, v); } -static int VERT_seam(CCGVert *v) { +static int VERT_seam(const CCGVert *v) { return ((v->flags & Vert_eSeam) != 0); } @@ -462,7 +462,7 @@ static void _edge_addFace(CCGEdge *e, CCGFace *f, CCGSubSurf *ss) { e->faces = CCGSUBSURF_realloc(ss, e->faces, (e->numFaces+1)*sizeof(*e->faces), e->numFaces*sizeof(*e->faces)); e->faces[e->numFaces++] = f; } -static int _edge_isBoundary(CCGEdge *e) { +static int _edge_isBoundary(const CCGEdge *e) { return e->numFaces<2; } @@ -900,7 +900,7 @@ CCGError ccgSubSurf_syncFaceDel(CCGSubSurf *ss, CCGFaceHDL fHDL) { return eCCGError_None; } -CCGError ccgSubSurf_syncVert(CCGSubSurf *ss, CCGVertHDL vHDL, void *vertData, int seam, CCGVert **v_r) { +CCGError ccgSubSurf_syncVert(CCGSubSurf *ss, CCGVertHDL vHDL, const void *vertData, int seam, CCGVert **v_r) { void **prevp; CCGVert *v = NULL; short seamflag = (seam)? Vert_eSeam: 0; @@ -2484,13 +2484,13 @@ CCGError ccgSubSurf_updateLevels(CCGSubSurf *ss, int lvl, CCGFace **effectedF, i /*** External API accessor functions ***/ -int ccgSubSurf_getNumVerts(CCGSubSurf *ss) { +int ccgSubSurf_getNumVerts(const CCGSubSurf *ss) { return ss->vMap->numEntries; } -int ccgSubSurf_getNumEdges(CCGSubSurf *ss) { +int ccgSubSurf_getNumEdges(const CCGSubSurf *ss) { return ss->eMap->numEntries; } -int ccgSubSurf_getNumFaces(CCGSubSurf *ss) { +int ccgSubSurf_getNumFaces(const CCGSubSurf *ss) { return ss->fMap->numEntries; } @@ -2504,23 +2504,23 @@ CCGFace *ccgSubSurf_getFace(CCGSubSurf *ss, CCGFaceHDL f) { return (CCGFace*) _ehash_lookup(ss->fMap, f); } -int ccgSubSurf_getSubdivisionLevels(CCGSubSurf *ss) { +int ccgSubSurf_getSubdivisionLevels(const CCGSubSurf *ss) { return ss->subdivLevels; } -int ccgSubSurf_getEdgeSize(CCGSubSurf *ss) { +int ccgSubSurf_getEdgeSize(const CCGSubSurf *ss) { return ccgSubSurf_getEdgeLevelSize(ss, ss->subdivLevels); } -int ccgSubSurf_getEdgeLevelSize(CCGSubSurf *ss, int level) { +int ccgSubSurf_getEdgeLevelSize(const CCGSubSurf *ss, int level) { if (level<1 || level>ss->subdivLevels) { return -1; } else { return 1 + (1<<level); } } -int ccgSubSurf_getGridSize(CCGSubSurf *ss) { +int ccgSubSurf_getGridSize(const CCGSubSurf *ss) { return ccgSubSurf_getGridLevelSize(ss, ss->subdivLevels); } -int ccgSubSurf_getGridLevelSize(CCGSubSurf *ss, int level) { +int ccgSubSurf_getGridLevelSize(const CCGSubSurf *ss, int level) { if (level<1 || level>ss->subdivLevels) { return -1; } else { @@ -2736,19 +2736,19 @@ void ccgFaceIterator_free(CCGFaceIterator *vi) { /*** Extern API final vert/edge/face interface ***/ -int ccgSubSurf_getNumFinalVerts(CCGSubSurf *ss) { +int ccgSubSurf_getNumFinalVerts(const CCGSubSurf *ss) { int edgeSize = 1 + (1<<ss->subdivLevels); int gridSize = 1 + (1<<(ss->subdivLevels-1)); int numFinalVerts = ss->vMap->numEntries + ss->eMap->numEntries*(edgeSize-2) + ss->fMap->numEntries + ss->numGrids*((gridSize-2) + ((gridSize-2)*(gridSize-2))); return numFinalVerts; } -int ccgSubSurf_getNumFinalEdges(CCGSubSurf *ss) { +int ccgSubSurf_getNumFinalEdges(const CCGSubSurf *ss) { int edgeSize = 1 + (1<<ss->subdivLevels); int gridSize = 1 + (1<<(ss->subdivLevels-1)); int numFinalEdges = ss->eMap->numEntries*(edgeSize-1) + ss->numGrids*((gridSize-1) + 2*((gridSize-2)*(gridSize-1))); return numFinalEdges; } -int ccgSubSurf_getNumFinalFaces(CCGSubSurf *ss) { +int ccgSubSurf_getNumFinalFaces(const CCGSubSurf *ss) { int gridSize = 1 + (1<<(ss->subdivLevels-1)); int numFinalFaces = ss->numGrids*((gridSize-1)*(gridSize-1)); return numFinalFaces; diff --git a/source/blender/blenkernel/intern/CCGSubSurf.h b/source/blender/blenkernel/intern/CCGSubSurf.h index 457ad2af353..543411f26f4 100644 --- a/source/blender/blenkernel/intern/CCGSubSurf.h +++ b/source/blender/blenkernel/intern/CCGSubSurf.h @@ -56,7 +56,7 @@ CCGError ccgSubSurf_sync (CCGSubSurf *ss); CCGError ccgSubSurf_initFullSync (CCGSubSurf *ss); CCGError ccgSubSurf_initPartialSync (CCGSubSurf *ss); -CCGError ccgSubSurf_syncVert (CCGSubSurf *ss, CCGVertHDL vHDL, void *vertData, int seam, CCGVert **v_r); +CCGError ccgSubSurf_syncVert (CCGSubSurf *ss, CCGVertHDL vHDL, const void *vertData, int seam, CCGVert **v_r); CCGError ccgSubSurf_syncEdge (CCGSubSurf *ss, CCGEdgeHDL eHDL, CCGVertHDL e_vHDL0, CCGVertHDL e_vHDL1, float crease, CCGEdge **e_r); CCGError ccgSubSurf_syncFace (CCGSubSurf *ss, CCGFaceHDL fHDL, int numVerts, CCGVertHDL *vHDLs, CCGFace **f_r); @@ -84,15 +84,15 @@ CCGError ccgSubSurf_setCalcVertexNormals (CCGSubSurf *ss, int useVertNormals, i /***/ -int ccgSubSurf_getNumVerts (CCGSubSurf *ss); -int ccgSubSurf_getNumEdges (CCGSubSurf *ss); -int ccgSubSurf_getNumFaces (CCGSubSurf *ss); +int ccgSubSurf_getNumVerts (const CCGSubSurf *ss); +int ccgSubSurf_getNumEdges (const CCGSubSurf *ss); +int ccgSubSurf_getNumFaces (const CCGSubSurf *ss); -int ccgSubSurf_getSubdivisionLevels (CCGSubSurf *ss); -int ccgSubSurf_getEdgeSize (CCGSubSurf *ss); -int ccgSubSurf_getEdgeLevelSize (CCGSubSurf *ss, int level); -int ccgSubSurf_getGridSize (CCGSubSurf *ss); -int ccgSubSurf_getGridLevelSize (CCGSubSurf *ss, int level); +int ccgSubSurf_getSubdivisionLevels (const CCGSubSurf *ss); +int ccgSubSurf_getEdgeSize (const CCGSubSurf *ss); +int ccgSubSurf_getEdgeLevelSize (const CCGSubSurf *ss, int level); +int ccgSubSurf_getGridSize (const CCGSubSurf *ss); +int ccgSubSurf_getGridLevelSize (const CCGSubSurf *ss, int level); CCGVert* ccgSubSurf_getVert (CCGSubSurf *ss, CCGVertHDL v); CCGVertHDL ccgSubSurf_getVertVertHandle (CCGVert *v); @@ -135,9 +135,9 @@ void* ccgSubSurf_getFaceGridEdgeData (CCGSubSurf *ss, CCGFace *f, int gridInde void* ccgSubSurf_getFaceGridDataArray (CCGSubSurf *ss, CCGFace *f, int gridIndex); void* ccgSubSurf_getFaceGridData (CCGSubSurf *ss, CCGFace *f, int gridIndex, int x, int y); -int ccgSubSurf_getNumFinalVerts (CCGSubSurf *ss); -int ccgSubSurf_getNumFinalEdges (CCGSubSurf *ss); -int ccgSubSurf_getNumFinalFaces (CCGSubSurf *ss); +int ccgSubSurf_getNumFinalVerts (const CCGSubSurf *ss); +int ccgSubSurf_getNumFinalEdges (const CCGSubSurf *ss); +int ccgSubSurf_getNumFinalFaces (const CCGSubSurf *ss); /***/ diff --git a/source/blender/blenkernel/intern/anim.c b/source/blender/blenkernel/intern/anim.c index bb8022c59fe..89bad72044e 100644 --- a/source/blender/blenkernel/intern/anim.c +++ b/source/blender/blenkernel/intern/anim.c @@ -1143,21 +1143,17 @@ static void face_duplilist(ListBase *lb, ID *id, Scene *scene, Object *par, floa madd_v3_v3v3fl(dob->orco, dob->orco, orco[mv1], w); madd_v3_v3v3fl(dob->orco, dob->orco, orco[mv2], w); madd_v3_v3v3fl(dob->orco, dob->orco, orco[mv3], w); - if(mv4) + if (mv4) { madd_v3_v3v3fl(dob->orco, dob->orco, orco[mv4], w); + } } if(mtface) { - dob->uv[0] += w*mtface[a].uv[0][0]; - dob->uv[1] += w*mtface[a].uv[0][1]; - dob->uv[0] += w*mtface[a].uv[1][0]; - dob->uv[1] += w*mtface[a].uv[1][1]; - dob->uv[0] += w*mtface[a].uv[2][0]; - dob->uv[1] += w*mtface[a].uv[2][1]; - - if(mv4) { - dob->uv[0] += w*mtface[a].uv[3][0]; - dob->uv[1] += w*mtface[a].uv[3][1]; + madd_v2_v2v2fl(dob->uv, dob->uv, mtface[a].uv[0], w); + madd_v2_v2v2fl(dob->uv, dob->uv, mtface[a].uv[1], w); + madd_v2_v2v2fl(dob->uv, dob->uv, mtface[a].uv[2], w); + if (mv4) { + madd_v2_v2v2fl(dob->uv, dob->uv, mtface[a].uv[3], w); } } } diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index f7cf0122269..374ef3512e8 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -225,6 +225,7 @@ static int ss_sync_from_uv(CCGSubSurf *ss, CCGSubSurf *origss, DerivedMesh *dm, CCGVertHDL fverts[4]; EdgeHash *ehash; float creaseFactor = (float)ccgSubSurf_getSubdivisionLevels(ss); + float uv[3]= {0.0f, 0.0f, 0.0f}; /* only first 2 values are written into */ limit[0]= limit[1]= STD_UV_CONNECT_LIMIT; vmap= make_uv_vert_map(mface, tface, totface, totvert, 0, limit); @@ -248,11 +249,8 @@ static int ss_sync_from_uv(CCGSubSurf *ss, CCGSubSurf *origss, DerivedMesh *dm, if (v->separate) { CCGVert *ssv; CCGVertHDL vhdl = SET_INT_IN_POINTER(v->f*4 + v->tfindex); - float uv[3]; - uv[0]= (tface+v->f)->uv[v->tfindex][0]; - uv[1]= (tface+v->f)->uv[v->tfindex][1]; - uv[2]= 0.0f; + copy_v2_v2(uv, (tface+v->f)->uv[v->tfindex]); ccgSubSurf_syncVert(ss, vhdl, uv, seam, &ssv); } @@ -359,15 +357,10 @@ static void set_subsurf_uv(CCGSubSurf *ss, DerivedMesh *dm, DerivedMesh *result, for(y = 0; y < gridFaces; y++) { for(x = 0; x < gridFaces; x++) { - float *a = faceGridData[(y + 0)*gridSize + x + 0].co; - float *b = faceGridData[(y + 0)*gridSize + x + 1].co; - float *c = faceGridData[(y + 1)*gridSize + x + 1].co; - float *d = faceGridData[(y + 1)*gridSize + x + 0].co; - - tf->uv[0][0] = a[0]; tf->uv[0][1] = a[1]; - tf->uv[1][0] = d[0]; tf->uv[1][1] = d[1]; - tf->uv[2][0] = c[0]; tf->uv[2][1] = c[1]; - tf->uv[3][0] = b[0]; tf->uv[3][1] = b[1]; + copy_v2_v2(tf->uv[0], faceGridData[(y + 0)*gridSize + x + 0].co); + copy_v2_v2(tf->uv[1], faceGridData[(y + 1)*gridSize + x + 0].co); + copy_v2_v2(tf->uv[2], faceGridData[(y + 1)*gridSize + x + 1].co); + copy_v2_v2(tf->uv[3], faceGridData[(y + 0)*gridSize + x + 1].co); tf++; } |