diff options
-rw-r--r-- | source/blender/blenkernel/BKE_utildefines.h | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/modifiers_bmesh.c | 42 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/subsurf_ccg.c | 2 | ||||
-rw-r--r-- | source/blender/blenlib/intern/BLI_cellalloc.c | 11 |
4 files changed, 37 insertions, 20 deletions
diff --git a/source/blender/blenkernel/BKE_utildefines.h b/source/blender/blenkernel/BKE_utildefines.h index 530012e7aa9..3d25ef98634 100644 --- a/source/blender/blenkernel/BKE_utildefines.h +++ b/source/blender/blenkernel/BKE_utildefines.h @@ -250,7 +250,7 @@ behaviour, though it may not be the best in practice. #define BM_INLINE static inline __attribute((always_inline)) #endif -#define BMEMSET(mem, val, size) {int _i; char *_c = mem; for (_i=0; _i<size; _i++) *_c++ = val;} +#define BMEMSET(mem, val, size) {unsigned int _i; char *_c = (char*) mem; for (_i=0; _i<size; _i++) *_c++ = val;} #endif diff --git a/source/blender/blenkernel/intern/modifiers_bmesh.c b/source/blender/blenkernel/intern/modifiers_bmesh.c index 3026fc9d628..d1a94ca7e6a 100644 --- a/source/blender/blenkernel/intern/modifiers_bmesh.c +++ b/source/blender/blenkernel/intern/modifiers_bmesh.c @@ -121,12 +121,11 @@ BMEditMesh *CDDM_To_BMesh(DerivedMesh *dm, BMEditMesh *existing) BMVert *v, **vtable, **verts=NULL; BMEdge *e, **etable, **edges=NULL; BMFace *f; - BMIter liter, iter; + BMIter liter; V_DECLARE(verts); V_DECLARE(edges); - void *tmp; int numTex, numCol; - int i, j, k, tot, totvert, totedge, totface; + int i, j, k, totvert, totedge, totface; if (em) bm = em->bm; else bm = BM_Make_Mesh(allocsize); @@ -285,12 +284,10 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, float final_offset[4][4]; float tmp_mat[4][4]; float length = amd->length; - int count = amd->count; - int numVerts, numEdges, numFaces; - int maxVerts, maxEdges, maxFaces; + int count = amd->count, maxVerts; int finalVerts, finalEdges, finalFaces; int *indexMap = NULL; - DerivedMesh *result, *start_cap = NULL, *end_cap = NULL; + DerivedMesh *start_cap = NULL, *end_cap = NULL; MVert *src_mvert; /* need to avoid infinite recursion here */ @@ -411,7 +408,6 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, if (j == 0) { BMOperator findop; BMOIter oiter; - BMIter iter; BMVert *v, *v2; BMHeader *h; @@ -516,14 +512,14 @@ DerivedMesh *doMirrorOnAxis(MirrorModifierData *mmd, DerivedMesh *result, *cddm; BMEditMesh *em; BMesh *bm; - BMOIter siter1, siter2; + BMOIter siter1; BMOperator op; - BMVert *v1, *v2; + BMVert *v1; int vector_size=0, a, b; bDeformGroup *def, *defb; bDeformGroup **vector_def = NULL; float mtx[4][4], imtx[4][4]; - int i, j; + int j; cddm = dm; //copying shouldn't be necassary here, as all modifiers return CDDM's em = CDDM_To_BMesh(dm, NULL); @@ -546,15 +542,27 @@ DerivedMesh *doMirrorOnAxis(MirrorModifierData *mmd, } if (mmd->mirror_ob) { - float obinv[4][4]; + float mtx2[4][4], vec[3]; + + Mat4Invert(mtx2, mmd->mirror_ob->obmat); + Mat4Ortho(mtx2); + Mat4MulMat4(imtx, ob->obmat, mtx2); + Mat4Invert(mtx, imtx); - Mat4Invert(obinv, mmd->mirror_ob->obmat); - Mat4MulMat4(mtx, ob->obmat, obinv); - Mat4Invert(imtx, mtx); + /*this math here is probably stupid beyond all reason*/ + VECCOPY(vec, mtx[3]); + VecMulf(vec, -1.0f); + + Mat4One(imtx); + imtx[axis][axis] = -1.0f; + Mat4MulMat4(mtx2, imtx, mtx); + + Mat4One(imtx); + VECCOPY(imtx[3], vec); + Mat4MulMat4(mtx, imtx, mtx2); } else { Mat4One(mtx); - mtx[axis][axis] = -1; - Mat4Invert(imtx, mtx); + mtx[axis][axis] = -1.0f; } BMO_InitOpf(bm, &op, "mirror geom=%avef mat=%m4 mergedist=%f axis=%d", diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c index 73893760f61..64e892458a5 100644 --- a/source/blender/blenkernel/intern/subsurf_ccg.c +++ b/source/blender/blenkernel/intern/subsurf_ccg.c @@ -565,7 +565,7 @@ static DerivedMesh *ss_to_cdderivedmesh(CSubSurf *ss, int ssFromEditmesh, double curt = PIL_check_seconds_timer(); cgdm = getCCGDerivedMesh(ss, drawInteriorEdges, useSubsurfUv, dm); - result = CDDM_copy(cgdm, 0); + result = CDDM_copy(cgdm, 1); printf("subsurf conversion time: %.6lf\n", PIL_check_seconds_timer() - curt); diff --git a/source/blender/blenlib/intern/BLI_cellalloc.c b/source/blender/blenlib/intern/BLI_cellalloc.c index f45916f1663..efed99011d0 100644 --- a/source/blender/blenlib/intern/BLI_cellalloc.c +++ b/source/blender/blenlib/intern/BLI_cellalloc.c @@ -62,11 +62,16 @@ typedef struct MemHeader { int idcheck; } MemHeader; +//#define USE_GUARDEDALLOC + void *BLI_cellalloc_malloc(long size, char *tag) { MemHeader *memh; int slot = size + sizeof(MemHeader); - + +#ifdef USE_GUARDEDALLOC + return MEM_mallocN(size, tag); +#endif if (!slot) return NULL; @@ -115,6 +120,10 @@ void BLI_cellalloc_free(void *mem) MemHeader *memh = mem; int slot; +#ifdef USE_GUARDEDALLOC + MEM_freeN(mem); + return; +#endif if (!memh) return; |