copy BLI_edgehash changes from bmesh branch, main change is use of mempool.
authorCampbell Barton <ideasman42@gmail.com>
Wed, 28 Dec 2011 10:20:37 +0000 (10:20 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Wed, 28 Dec 2011 10:20:37 +0000 (10:20 +0000)
source/blender/blenkernel/intern/cdderivedmesh.c
source/blender/blenkernel/intern/customdata.c
source/blender/blenkernel/intern/mesh_validate.c
source/blender/blenlib/BLI_edgehash.h
source/blender/blenlib/intern/edgehash.c
source/blender/editors/mesh/editmesh_lib.c
source/blender/modifiers/intern/MOD_explode.c
source/blender/modifiers/intern/MOD_solidify.c

index 6f088b8abf75aaa93f3c5df08e85043792640319..5af3dc15704b0b1f5e129721ff8ac246ea82b5c3 100644 (file)
@@ -1950,7 +1950,7 @@ void CDDM_calc_edges(DerivedMesh *dm)
        index = CustomData_get_layer(&edgeData, CD_ORIGINDEX);
        for(i = 0; !BLI_edgehashIterator_isDone(ehi);
                BLI_edgehashIterator_step(ehi), ++i, ++med, ++index) {
-               BLI_edgehashIterator_getKey(ehi, (int*)&med->v1, (int*)&med->v2);
+               BLI_edgehashIterator_getKey(ehi, &med->v1, &med->v2);
 
                med->flag = ME_EDGEDRAW|ME_EDGERENDER;
                *index = ORIGINDEX_NONE;
index 0363ba459a701a2a8455c82d696c4664bb94d202..166f9735dc4a1521789c3d521a7fac6fd2cbc88d 100644 (file)
@@ -829,8 +829,8 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = {
        /* 8: CD_NORMAL */
        /* 3 floats per normal vector */
        {sizeof(float)*3, "", 0, NULL, NULL, NULL, NULL, NULL, NULL},
-       /* 9: CD_FLAGS */
-       {sizeof(int), "", 0, NULL, NULL, NULL, NULL, NULL, NULL},
+       /* 9: CD_POLYINDEX */
+       {sizeof(int), "MIntProperty", 1, NULL, NULL, NULL, NULL, NULL, NULL},
        /* 10: CD_PROP_FLT */
        {sizeof(MFloatProperty), "MFloatProperty",1,"Float",NULL,NULL,NULL,NULL},
        /* 11: CD_PROP_INT */
@@ -896,7 +896,6 @@ const CustomDataMask CD_MASK_FACECORNERS =
        CD_MASK_MTFACE | CD_MASK_MCOL | CD_MASK_MTEXPOLY | CD_MASK_MLOOPUV |
        CD_MASK_MLOOPCOL;
 
-
 static const LayerTypeInfo *layerType_getInfo(int type)
 {
        if(type < 0 || type >= CD_NUMTYPES) return NULL;
index a1bf9cb9481da46439f8eae8e476f3e9d96aef55..ed9b63fe98ddae393526e2c14fc6e04799f04306 100644 (file)
@@ -509,7 +509,7 @@ void BKE_mesh_calc_edges(Mesh *mesh, int update)
                if(update && (med_orig=BLI_edgehashIterator_getValue(ehi))) {
                        *med= *med_orig; /* copy from the original */
                } else {
-                       BLI_edgehashIterator_getKey(ehi, (int*)&med->v1, (int*)&med->v2);
+                       BLI_edgehashIterator_getKey(ehi, &med->v1, &med->v2);
                        med->flag = ME_EDGEDRAW|ME_EDGERENDER|SELECT; /* select for newly created meshes which are selected [#25595] */
                }
        }
index 283b52e06b928fa9c9964d76916d2862f14e162e..9153155e359aeed78089900a9835a84d6847b8cc 100644 (file)
@@ -47,22 +47,22 @@ void                        BLI_edgehash_free               (EdgeHash *eh, EdgeHashFreeFP valfreefp);
        /* Insert edge (v0,v1) into hash with given value, does
         * not check for duplicates.
         */
-void                   BLI_edgehash_insert             (EdgeHash *eh, int v0, int v1, void *val);
+void                   BLI_edgehash_insert             (EdgeHash *eh, unsigned int v0, unsigned int v1, void *val);
 
        /* Return value for given edge (v0,v1), or NULL if
         * if key does not exist in hash. (If need exists 
         * to differentiate between key-value being NULL and 
         * lack of key then see BLI_edgehash_lookup_p().
         */
-void*                  BLI_edgehash_lookup             (EdgeHash *eh, int v0, int v1);
+void*                  BLI_edgehash_lookup             (EdgeHash *eh, unsigned int v0, unsigned int v1);
 
        /* Return pointer to value for given edge (v0,v1),
         * or NULL if key does not exist in hash.
         */
-void**                 BLI_edgehash_lookup_p   (EdgeHash *eh, int v0, int v1);
+void**                 BLI_edgehash_lookup_p   (EdgeHash *eh, unsigned int v0, unsigned int v1);
 
        /* Return boolean true/false if edge (v0,v1) in hash. */
-int                            BLI_edgehash_haskey             (EdgeHash *eh, int v0, int v1);
+int                            BLI_edgehash_haskey             (EdgeHash *eh, unsigned int v0, unsigned int v1);
 
        /* Return number of keys in hash. */
 int                            BLI_edgehash_size               (EdgeHash *eh);
@@ -83,7 +83,7 @@ EdgeHashIterator*     BLI_edgehashIterator_new                (EdgeHash *eh);
 void                           BLI_edgehashIterator_free               (EdgeHashIterator *ehi);
 
        /* Retrieve the key from an iterator. */
-void                           BLI_edgehashIterator_getKey             (EdgeHashIterator *ehi, int *v0_r, int *v1_r);
+void                           BLI_edgehashIterator_getKey             (EdgeHashIterator *ehi, unsigned int *v0_r, unsigned int *v1_r);
        
        /* Retrieve the value from an iterator. */
 void*                          BLI_edgehashIterator_getValue   (EdgeHashIterator *ehi);
@@ -98,4 +98,3 @@ void                          BLI_edgehashIterator_step               (EdgeHashIterator *ehi);
 int                                    BLI_edgehashIterator_isDone             (EdgeHashIterator *ehi);
 
 #endif
-
index 7ae68101154650dec362a08e2c8766a15fd0fb76..b710e5d496de78989730229252b796a26a30745a 100644 (file)
@@ -20,7 +20,7 @@
  *
  * The Original Code is: none of this file.
  *
- * Contributor(s): Daniel Dunbar
+ * Contributor(s): Daniel Dunbar, Joseph Eagar
  *
  * ***** END GPL LICENSE BLOCK *****
  * A general (pointer -> pointer) hash table ADT
 #include <string.h>
 
 #include "MEM_guardedalloc.h"
-#include "BLI_edgehash.h"
 
-/***/
+#include "BLI_utildefines.h"
+#include "BLI_edgehash.h"
+#include "BLI_mempool.h"
 
-static unsigned int hashsizes[]= {
-       1, 3, 5, 11, 17, 37, 67, 131, 257, 521, 1031, 2053, 4099, 8209, 
-       16411, 32771, 65537, 131101, 262147, 524309, 1048583, 2097169, 
-       4194319, 8388617, 16777259, 33554467, 67108879, 134217757, 
+/**************inlined code************/
+static unsigned int _ehash_hashsizes[]= {
+       1, 3, 5, 11, 17, 37, 67, 131, 257, 521, 1031, 2053, 4099, 8209,
+       16411, 32771, 65537, 131101, 262147, 524309, 1048583, 2097169,
+       4194319, 8388617, 16777259, 33554467, 67108879, 134217757,
        268435459
 };
 
-#define EDGEHASH(v0,v1)                ((v0*39)^(v1*31))
+#define EDGE_HASH(v0, v1)  ((v0 * 39)^(v1 * 31))
+
+/* ensure v0 is smaller */
+#define EDGE_ORD(v0, v1) \
+       if (v0 < v1) {       \
+               v0 ^= v1;        \
+               v1 ^= v0;        \
+               v0 ^= v1;        \
+       }
 
 /***/
 
-typedef struct Entry Entry;
-struct Entry {
-       Entry *next;
-       int v0, v1;
+typedef struct EdgeEntry EdgeEntry;
+struct EdgeEntry {
+       EdgeEntry *next;
+       unsigned int v0, v1;
        void *val;
 };
 
 struct EdgeHash {
-       Entry **buckets;
+       EdgeEntry **buckets;
+       BLI_mempool *epool;
        int nbuckets, nentries, cursize;
 };
 
@@ -66,87 +77,82 @@ struct EdgeHash {
 
 EdgeHash *BLI_edgehash_new(void)
 {
-       EdgeHash *eh= MEM_mallocN(sizeof(*eh), "EdgeHash");
-       eh->cursize= 0;
-       eh->nentries= 0;
-       eh->nbuckets= hashsizes[eh->cursize];
-       
-       eh->buckets= malloc(eh->nbuckets*sizeof(*eh->buckets));
-       memset(eh->buckets, 0, eh->nbuckets*sizeof(*eh->buckets));
+       EdgeHash *eh = MEM_callocN(sizeof(*eh), "EdgeHash");
+       eh->cursize = 0;
+       eh->nentries = 0;
+       eh->nbuckets = _ehash_hashsizes[eh->cursize];
        
+       eh->buckets = MEM_callocN(eh->nbuckets * sizeof(*eh->buckets), "eh buckets 2");
+       eh->epool = BLI_mempool_create(sizeof(EdgeEntry), 512, 512, TRUE, FALSE);
+
        return eh;
 }
 
-void BLI_edgehash_insert(EdgeHash *eh, int v0, int v1, void *val)
+
+void BLI_edgehash_insert(EdgeHash *eh, unsigned int v0, unsigned int v1, void *val)
 {
        unsigned int hash;
-       Entry *e= malloc(sizeof(*e));
+       EdgeEntry *e = BLI_mempool_alloc(eh->epool);
 
-       if (v1<v0) {
-               v0 ^= v1;
-               v1 ^= v0;
-               v0 ^= v1;
-       }
-       hash = EDGEHASH(v0,v1)%eh->nbuckets;
+       EDGE_ORD(v0, v1); /* ensure v0 is smaller */
+
+       hash = EDGE_HASH(v0, v1) % eh->nbuckets;
 
        e->v0 = v0;
        e->v1 = v1;
        e->val = val;
-       e->next= eh->buckets[hash];
+       e->next = eh->buckets[hash];
        eh->buckets[hash]= e;
-       
-       if (++eh->nentries>eh->nbuckets*3) {
-               Entry **old= eh->buckets;
-               int i, nold= eh->nbuckets;
-               
-               eh->nbucketshashsizes[++eh->cursize];
-               eh->buckets= malloc(eh->nbuckets*sizeof(*eh->buckets));
-               memset(eh->buckets, 0, eh->nbuckets*sizeof(*eh->buckets));
-               
-               for (i=0; i<nold; i++) {
-                       for (e= old[i]; e;) {
-                               Entry *n= e->next;
-                               
-                               hash= EDGEHASH(e->v0,e->v1)%eh->nbuckets;
-                               e->next= eh->buckets[hash];
+
+       if (++eh->nentries>eh->nbuckets * 3) {
+               EdgeEntry *e, **old = eh->buckets;
+               int i, nold = eh->nbuckets;
+
+               eh->nbuckets = _ehash_hashsizes[++eh->cursize];
+               eh->buckets = MEM_mallocN(eh->nbuckets * sizeof(*eh->buckets), "eh buckets");
+               memset(eh->buckets, 0, eh->nbuckets * sizeof(*eh->buckets));
+
+               for (i = 0; i < nold; i++) {
+                       for (e = old[i]; e;) {
+                               EdgeEntry *n = e->next;
+
+                               hash = EDGE_HASH(e->v0, e->v1) % eh->nbuckets;
+                               e->next = eh->buckets[hash];
                                eh->buckets[hash]= e;
-                               
-                               e= n;
+
+                               e = n;
                        }
                }
-               
-               free(old);
+
+               MEM_freeN(old);
        }
 }
 
-void** BLI_edgehash_lookup_p(EdgeHash *eh, int v0, int v1)
+void **BLI_edgehash_lookup_p(EdgeHash *eh, unsigned int v0, unsigned int v1)
 {
        unsigned int hash;
-       Entry *e;
+       EdgeEntry *e;
 
-       if (v1<v0) {
-               v0 ^= v1;
-               v1 ^= v0;
-               v0 ^= v1;
-       }
-       hash = EDGEHASH(v0,v1)%eh->nbuckets;
-       for (e= eh->buckets[hash]; e; e= e->next)
-               if (v0==e->v0 && v1==e->v1)
+       EDGE_ORD(v0, v1); /* ensure v0 is smaller */
+
+       hash = EDGE_HASH(v0, v1) % eh->nbuckets;
+       for (e = eh->buckets[hash]; e; e = e->next)
+               if (v0 == e->v0 && v1 == e->v1)
                        return &e->val;
-       
+
        return NULL;
 }
 
-void* BLI_edgehash_lookup(EdgeHash *eh, int v0, int v1)
+void *BLI_edgehash_lookup(EdgeHash *eh, unsigned int v0, unsigned int v1)
 {
-       void **value_p = BLI_edgehash_lookup_p(eh,v0,v1);
+       void **value_p = BLI_edgehash_lookup_p(eh, v0, v1);
 
        return value_p?*value_p:NULL;
 }
 
-int BLI_edgehash_haskey(EdgeHash *eh, int v0, int v1)
+int BLI_edgehash_haskey(EdgeHash *eh, unsigned int v0, unsigned int v1)
 {
-       return BLI_edgehash_lookup_p(eh, v0, v1)!=NULL;
+       return BLI_edgehash_lookup_p(eh, v0, v1) != NULL;
 }
 
 int BLI_edgehash_size(EdgeHash *eh)
@@ -158,28 +164,30 @@ void BLI_edgehash_clear(EdgeHash *eh, EdgeHashFreeFP valfreefp)
 {
        int i;
        
-       for (i=0; i<eh->nbuckets; i++) {
-               Entry *e;
+       for (i = 0; i<eh->nbuckets; i++) {
+               EdgeEntry *e;
                
-               for (e= eh->buckets[i]; e; ) {
-                       Entry *n= e->next;
+               for (e = eh->buckets[i]; e; ) {
+                       EdgeEntry *n = e->next;
                        
                        if (valfreefp) valfreefp(e->val);
-                       free(e);
+                       BLI_mempool_free(eh->epool, e);
                        
-                       e= n;
+                       e = n;
                }
-               eh->buckets[i]= NULL;
+               eh->buckets[i] = NULL;
        }
 
-       eh->nentries= 0;
+       eh->nentries = 0;
 }
 
 void BLI_edgehash_free(EdgeHash *eh, EdgeHashFreeFP valfreefp)
 {
        BLI_edgehash_clear(eh, valfreefp);
-       
-       free(eh->buckets);
+
+       BLI_mempool_destroy(eh->epool);
+
+       MEM_freeN(eh->buckets);
        MEM_freeN(eh);
 }
 
@@ -189,29 +197,29 @@ void BLI_edgehash_free(EdgeHash *eh, EdgeHashFreeFP valfreefp)
 struct EdgeHashIterator {
        EdgeHash *eh;
        int curBucket;
-       Entry *curEntry;
+       EdgeEntry *curEntry;
 };
 
 EdgeHashIterator *BLI_edgehashIterator_new(EdgeHash *eh)
 {
-       EdgeHashIterator *ehi= malloc(sizeof(*ehi));
-       ehi->eh= eh;
-       ehi->curEntry= NULL;
-       ehi->curBucket= -1;
+       EdgeHashIterator *ehi = MEM_mallocN(sizeof(*ehi), "eh iter");
+       ehi->eh = eh;
+       ehi->curEntry = NULL;
+       ehi->curBucket = -1;
        while (!ehi->curEntry) {
                ehi->curBucket++;
-               if (ehi->curBucket==ehi->eh->nbuckets)
+               if (ehi->curBucket == ehi->eh->nbuckets)
                        break;
-               ehi->curEntry= ehi->eh->buckets[ehi->curBucket];
+               ehi->curEntry = ehi->eh->buckets[ehi->curBucket];
        }
        return ehi;
 }
 void BLI_edgehashIterator_free(EdgeHashIterator *ehi)
 {
-       free(ehi);
+       MEM_freeN(ehi);
 }
 
-void BLI_edgehashIterator_getKey(EdgeHashIterator *ehi, int *v0_r, int *v1_r)
+void BLI_edgehashIterator_getKey(EdgeHashIterator *ehi, unsigned int *v0_r, unsigned int *v1_r)
 {
        if (ehi->curEntry) {
                *v0_r = ehi->curEntry->v0;
@@ -225,19 +233,22 @@ void *BLI_edgehashIterator_getValue(EdgeHashIterator *ehi)
 
 void BLI_edgehashIterator_setValue(EdgeHashIterator *ehi, void *val)
 {
-       if(ehi->curEntry)
-               ehi->curEntry->val= val;
+       if (ehi->curEntry) {
+               ehi->curEntry->val = val;
+       }
 }
 
 void BLI_edgehashIterator_step(EdgeHashIterator *ehi)
 {
        if (ehi->curEntry) {
-               ehi->curEntry= ehi->curEntry->next;
+               ehi->curEntry = ehi->curEntry->next;
                while (!ehi->curEntry) {
                        ehi->curBucket++;
-                       if (ehi->curBucket==ehi->eh->nbuckets)
+                       if (ehi->curBucket == ehi->eh->nbuckets) {
                                break;
-                       ehi->curEntry= ehi->eh->buckets[ehi->curBucket];
+                       }
+
+                       ehi->curEntry = ehi->eh->buckets[ehi->curBucket];
                }
        }
 }
index 5e8105d507a05f3f4f1fb7c6325cc567c9a4a1a1..8dea636f0b6b3c8544170894201f35a2ec8514ba 100644 (file)
@@ -2412,7 +2412,7 @@ void EM_make_hq_normals(EditMesh *em)
        EdgeHash *edge_hash = BLI_edgehash_new();
        EdgeHashIterator *edge_iter;
        int edge_ref_count = 0;
-       int ed_v1, ed_v2; /* use when getting the key */
+       unsigned int ed_v1, ed_v2; /* use when getting the key */
        EdgeFaceRef *edge_ref_array = MEM_callocN(em->totedge * sizeof(EdgeFaceRef), "Edge Connectivity");
        EdgeFaceRef *edge_ref;
        float edge_normal[3];
@@ -2426,15 +2426,20 @@ void EM_make_hq_normals(EditMesh *em)
 
        /* This function adds an edge hash if its not there, and adds the face index */
 #define NOCALC_EDGEWEIGHT_ADD_EDGEREF_FACE(EDV1, EDV2); \
-                       edge_ref = (EdgeFaceRef *)BLI_edgehash_lookup(edge_hash, EDV1, EDV2); \
+               { \
+                       const unsigned int mf_v1 = EDV1; \
+                       const unsigned int mf_v2 = EDV2; \
+                       edge_ref = (EdgeFaceRef *)BLI_edgehash_lookup(edge_hash, mf_v1, mf_v2); \
                        if (!edge_ref) { \
                                edge_ref = &edge_ref_array[edge_ref_count]; edge_ref_count++; \
-                               edge_ref->f1=i; \
-                               edge_ref->f2=-1; \
-                               BLI_edgehash_insert(edge_hash, EDV1, EDV2, edge_ref); \
-                       } else { \
-                               edge_ref->f2=i; \
-                       }
+                               edge_ref->f1 = i; \
+                               edge_ref->f2 = -1; \
+                               BLI_edgehash_insert(edge_hash, mf_v1, mf_v2, edge_ref); \
+                       } \
+                       else { \
+                               edge_ref->f2 = i; \
+                       } \
+               }
 
 
        efa= em->faces.first;
@@ -2456,7 +2461,7 @@ void EM_make_hq_normals(EditMesh *em)
 
        for(edge_iter = BLI_edgehashIterator_new(edge_hash); !BLI_edgehashIterator_isDone(edge_iter); BLI_edgehashIterator_step(edge_iter)) {
                /* Get the edge vert indices, and edge value (the face indices that use it)*/
-               BLI_edgehashIterator_getKey(edge_iter, (int*)&ed_v1, (int*)&ed_v2);
+               BLI_edgehashIterator_getKey(edge_iter, &ed_v1, &ed_v2);
                edge_ref = BLI_edgehashIterator_getValue(edge_iter);
 
                if (edge_ref->f2 != -1) {
index 9821c0b3836d4eb7bb78ab291232d7d5cc41baee..5bd38579b67daf2c7d3e90e608ffb5e6a563a2e7 100644 (file)
@@ -556,10 +556,11 @@ static DerivedMesh * cutEdges(ExplodeModifierData *emd, DerivedMesh *dm)
        int *vertpa = MEM_callocN(sizeof(int)*totvert,"explode_vertpa2");
        int *facepa = emd->facepa;
        int *fs, totesplit=0,totfsplit=0,curdupface=0;
-       int i,j,v1,v2,v3,v4,esplit,
+       int i, v1, v2, v3, v4, esplit,
            v[4]  = {0, 0, 0, 0}, /* To quite gcc barking... */
            uv[4] = {0, 0, 0, 0}; /* To quite gcc barking... */
        int numlayer;
+       unsigned int ed_v1, ed_v2;
 
        edgehash= BLI_edgehash_new();
 
@@ -650,16 +651,16 @@ static DerivedMesh * cutEdges(ExplodeModifierData *emd, DerivedMesh *dm)
        /* create new verts */
        ehi= BLI_edgehashIterator_new(edgehash);
        for(; !BLI_edgehashIterator_isDone(ehi); BLI_edgehashIterator_step(ehi)) {
-               BLI_edgehashIterator_getKey(ehi, &i, &j);
+               BLI_edgehashIterator_getKey(ehi, &ed_v1, &ed_v2);
                esplit= GET_INT_FROM_POINTER(BLI_edgehashIterator_getValue(ehi));
-               mv=CDDM_get_vert(splitdm,j);
+               mv=CDDM_get_vert(splitdm, ed_v2);
                dupve=CDDM_get_vert(splitdm,esplit);
 
-               DM_copy_vert_data(splitdm,splitdm,j,esplit,1);
+               DM_copy_vert_data(splitdm,splitdm, ed_v2, esplit,1);
 
                *dupve=*mv;
 
-               mv=CDDM_get_vert(splitdm,i);
+               mv=CDDM_get_vert(splitdm, ed_v1);
 
                add_v3_v3(dupve->co, mv->co);
                mul_v3_fl(dupve->co, 0.5f);
@@ -789,7 +790,8 @@ static DerivedMesh * explodeMesh(ExplodeModifierData *emd,
        /* float timestep; */
        int *facepa=emd->facepa;
        int totdup=0,totvert=0,totface=0,totpart=0;
-       int i, j, v, mindex=0;
+       int i, v, mindex=0;
+       unsigned int ed_v1, ed_v2;
        MTFace *mtface = NULL, *mtf;
 
        totface= dm->getNumFaces(dm);
@@ -852,24 +854,24 @@ static DerivedMesh * explodeMesh(ExplodeModifierData *emd,
                MVert *dest;
 
                /* get particle + vertex from hash */
-               BLI_edgehashIterator_getKey(ehi, &j, &i);
-               i -= totvert;
+               BLI_edgehashIterator_getKey(ehi, &ed_v1, &ed_v2);
+               ed_v2 -= totvert;
                v= GET_INT_FROM_POINTER(BLI_edgehashIterator_getValue(ehi));
 
-               dm->getVert(dm, j, &source);
+               dm->getVert(dm, ed_v1, &source);
                dest = CDDM_get_vert(explode,v);
 
-               DM_copy_vert_data(dm,explode,j,v,1);
+               DM_copy_vert_data(dm, explode, ed_v1, v, 1);
                *dest = source;
 
-               if(i!=totpart) {
+               if(ed_v2 != totpart) {
                        /* get particle */
-                       pa= pars+i;
+                       pa= pars + ed_v2;
 
                        psys_get_birth_coordinates(&sim, pa, &birth, 0, 0);
 
                        state.time=cfra;
-                       psys_get_particle_state(&sim, i, &state, 1);
+                       psys_get_particle_state(&sim, ed_v2, &state, 1);
 
                        vertco=CDDM_get_vert(explode,v)->co;
                        mul_m4_v3(ob->obmat,vertco);
index 0391f33184f641b027a5154f6cf56645c6632a56..ad47e3fe569f8bf6ab9a7748fb48849200cc92f4 100644 (file)
@@ -93,7 +93,7 @@ static void dm_calc_normal(DerivedMesh *dm, float (*temp_nors)[3])
                EdgeHash *edge_hash = BLI_edgehash_new();
                EdgeHashIterator *edge_iter;
                int edge_ref_count = 0;
-               int ed_v1, ed_v2; /* use when getting the key */
+               unsigned int ed_v1, ed_v2; /* use when getting the key */
                EdgeFaceRef *edge_ref_array = MEM_callocN(numEdges * sizeof(EdgeFaceRef), "Edge Connectivity");
                EdgeFaceRef *edge_ref;
                float edge_normal[3];
@@ -101,17 +101,17 @@ static void dm_calc_normal(DerivedMesh *dm, float (*temp_nors)[3])
                /* This function adds an edge hash if its not there, and adds the face index */
 #define NOCALC_EDGEWEIGHT_ADD_EDGEREF_FACE(EDV1, EDV2); \
                        { \
-                               const unsigned int ed_v1 = EDV1; \
-                               const unsigned int ed_v2 = EDV2; \
-                               edge_ref = (EdgeFaceRef *)BLI_edgehash_lookup(edge_hash, ed_v1, ed_v2); \
+                               const unsigned int ml_v1 = EDV1; \
+                               const unsigned int ml_v2 = EDV2; \
+                               edge_ref = (EdgeFaceRef *)BLI_edgehash_lookup(edge_hash, ml_v1, ml_v2); \
                                if (!edge_ref) { \
                                        edge_ref = &edge_ref_array[edge_ref_count]; edge_ref_count++; \
                                        edge_ref->f1 = i; \
                                        edge_ref->f2 =- 1; \
-                                       BLI_edgehash_insert(edge_hash, ed_v1, ed_v2, edge_ref); \
+                                       BLI_edgehash_insert(edge_hash, ml_v1, ml_v2, edge_ref); \
                                } \
                                else { \
-                                       edge_ref->f2=i; \
+                                       edge_ref->f2 = i; \
                                } \
                        }
                /* --- end define --- */
@@ -139,7 +139,7 @@ static void dm_calc_normal(DerivedMesh *dm, float (*temp_nors)[3])
 
                for(edge_iter = BLI_edgehashIterator_new(edge_hash); !BLI_edgehashIterator_isDone(edge_iter); BLI_edgehashIterator_step(edge_iter)) {
                        /* Get the edge vert indices, and edge value (the face indices that use it)*/
-                       BLI_edgehashIterator_getKey(edge_iter, (int*)&ed_v1, (int*)&ed_v2);
+                       BLI_edgehashIterator_getKey(edge_iter, &ed_v1, &ed_v2);
                        edge_ref = BLI_edgehashIterator_getValue(edge_iter);
 
                        if (edge_ref->f2 != -1) {
@@ -256,7 +256,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
        if(smd->flag & MOD_SOLIDIFY_RIM) {
                EdgeHash *edgehash = BLI_edgehash_new();
                EdgeHashIterator *ehi;
-               int v1, v2;
+               unsigned int v1, v2;
                int eidx;
 
                for(i=0, mv=orig_mvert; i<numVerts; i++, mv++) {