[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [23073] branches/bmesh/blender/source/ blender: finished removedoubles, and inlined a bunch of functions.

Joseph Eagar joeedh at gmail.com
Wed Sep 9 08:29:00 CEST 2009


Revision: 23073
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=23073
Author:   joeedh
Date:     2009-09-09 08:28:58 +0200 (Wed, 09 Sep 2009)

Log Message:
-----------
finished removedoubles, and inlined a bunch of functions.

Modified Paths:
--------------
    branches/bmesh/blender/source/blender/blenkernel/BKE_tessmesh.h
    branches/bmesh/blender/source/blender/blenkernel/BKE_utildefines.h
    branches/bmesh/blender/source/blender/blenkernel/intern/modifier.c
    branches/bmesh/blender/source/blender/blenkernel/intern/modifiers_bmesh.c
    branches/bmesh/blender/source/blender/blenlib/BLI_ghash.h
    branches/bmesh/blender/source/blender/blenlib/intern/BLI_ghash.c
    branches/bmesh/blender/source/blender/bmesh/bmesh_operator_api.h
    branches/bmesh/blender/source/blender/bmesh/intern/bmesh_operators.c
    branches/bmesh/blender/source/blender/bmesh/operators/mesh_conv.c
    branches/bmesh/blender/source/blender/bmesh/operators/removedoubles.c
    branches/bmesh/blender/source/blender/editors/mesh/bmesh_tools.c
    branches/bmesh/blender/source/blender/editors/mesh/bmeshutils.c
    branches/bmesh/blender/source/blender/editors/mesh/editmesh_tools.c

Modified: branches/bmesh/blender/source/blender/blenkernel/BKE_tessmesh.h
===================================================================
--- branches/bmesh/blender/source/blender/blenkernel/BKE_tessmesh.h	2009-09-09 02:44:08 UTC (rev 23072)
+++ branches/bmesh/blender/source/blender/blenkernel/BKE_tessmesh.h	2009-09-09 06:28:58 UTC (rev 23073)
@@ -24,6 +24,7 @@
 
 	/*this is for undoing failed operations*/
 	struct BMEditMesh *emcopy;
+	int emcopyusers;
 	
 	/*we store tesselations as triplets of three loops,
 	  which each define a triangle.*/

Modified: branches/bmesh/blender/source/blender/blenkernel/BKE_utildefines.h
===================================================================
--- branches/bmesh/blender/source/blender/blenkernel/BKE_utildefines.h	2009-09-09 02:44:08 UTC (rev 23072)
+++ branches/bmesh/blender/source/blender/blenkernel/BKE_utildefines.h	2009-09-09 06:28:58 UTC (rev 23073)
@@ -241,7 +241,7 @@
 
 /*little macro so inline keyword works*/
 #if defined(_MSC_VER)
-#define BM_INLINE //__forceinline
+#define BM_INLINE __forceinline
 #else
 #define BM_INLINE inline
 #endif

Modified: branches/bmesh/blender/source/blender/blenkernel/intern/modifier.c
===================================================================
--- branches/bmesh/blender/source/blender/blenkernel/intern/modifier.c	2009-09-09 02:44:08 UTC (rev 23072)
+++ branches/bmesh/blender/source/blender/blenkernel/intern/modifier.c	2009-09-09 06:28:58 UTC (rev 23073)
@@ -2171,7 +2171,44 @@
 /* EdgeSplit modifier: Splits edges in the mesh according to sharpness flag
  * or edge angle (can be used to achieve autosmoothing)
 */
+
+/*new cddm-based edge split code*/
 #if 0
+typedef struct VertUser {
+	int ov, v, done;
+	ListBase users;
+} VertUser;
+
+typedef struct EdgeNode {
+	struct EdgeNode *next, *prev;
+	struct EdgeData *edge;
+} EdgeNode;
+
+typedef struct EdgeData {
+	EdgeNode v1list, v2list;
+	VertUser *v1user, *v2user;
+	int tag;
+	int v1, v2;
+} EdgeData;
+
+DerivedMesh *doEdgeSplit(DerivedMesh *dm, EdgeSplitModifierData *emd)
+{
+	DerivedMesh *cddm = CDDM_copy(dm);
+	EdgeData *etags;
+	VertUser *vusers;
+
+	if (!cddm->numVertData || !cddm->numEdgeData)
+		return cddm;
+
+	etags = MEM_callocN(sizeof(EdgeData)*cddm->numEdgeData, "edgedata tag thingies");
+
+	MEM_freeN(etags);
+	return cddm;
+}
+
+#endif
+
+#if 0
 #define EDGESPLIT_DEBUG_3
 #define EDGESPLIT_DEBUG_2
 #define EDGESPLIT_DEBUG_1

Modified: branches/bmesh/blender/source/blender/blenkernel/intern/modifiers_bmesh.c
===================================================================
--- branches/bmesh/blender/source/blender/blenkernel/intern/modifiers_bmesh.c	2009-09-09 02:44:08 UTC (rev 23072)
+++ branches/bmesh/blender/source/blender/blenkernel/intern/modifiers_bmesh.c	2009-09-09 06:28:58 UTC (rev 23073)
@@ -275,7 +275,7 @@
 					  Scene *scene, Object *ob, DerivedMesh *dm,
                                           int initFlags)
 {
-	DerivedMesh *cddm = dm; //CDDM_copy(dm); copying shouldn't be necassary here, as all modifiers return CDDM's
+	DerivedMesh *cddm = dm; //copying shouldn't be necassary here, as all modifiers return CDDM's
 	BMEditMesh *em = CDDM_To_BMesh(cddm, NULL);
 	BMOperator op, oldop, weldop;
 	int i, j, indexLen;
@@ -388,9 +388,6 @@
 		MTC_Mat4CpyMat4(final_offset, tmp_mat);
 	}
 
-	//cddm->needsFree = 1;
-	//cddm->release(cddm);
-	
 	BMO_Init_Op(&weldop, "weldverts");
 	BMO_InitOpf(em->bm, &op, "dupe geom=%avef");
 	oldop = op;
@@ -535,12 +532,9 @@
 	float mtx[4][4], imtx[4][4];
 	int i, j;
 
-	cddm = dm; //CDDM_copy(dm); copying shouldn't be necassary here, as all modifiers return CDDM's
+	cddm = dm; //copying shouldn't be necassary here, as all modifiers return CDDM's
 	em = CDDM_To_BMesh(dm, NULL);
 
-	//cddm->needsFree = 1;
-	//cddm->release(cddm);
-	
 	/*convienence variable*/
 	bm = em->bm;
 

Modified: branches/bmesh/blender/source/blender/blenlib/BLI_ghash.h
===================================================================
--- branches/bmesh/blender/source/blender/blenlib/BLI_ghash.h	2009-09-09 02:44:08 UTC (rev 23072)
+++ branches/bmesh/blender/source/blender/blenlib/BLI_ghash.h	2009-09-09 06:28:58 UTC (rev 23073)
@@ -32,8 +32,15 @@
 #ifndef BLI_GHASH_H
 #define BLI_GHASH_H
 
+#include "stdio.h"
+#include "stdlib.h"
+#include "string.h"
+
 #include "BKE_utildefines.h"
 
+#include "BLI_mempool.h"
+#include "BLI_blenlib.h"
+
 typedef unsigned int	(*GHashHashFP)		(void *key);
 typedef int				(*GHashCmpFP)		(void *a, void *b);
 typedef	void			(*GHashKeyFreeFP)	(void *key);
@@ -63,10 +70,10 @@
 GHash*	BLI_ghash_new		(GHashHashFP hashfp, GHashCmpFP cmpfp);
 void	BLI_ghash_free		(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp);
 
-BM_INLINE void	BLI_ghash_insert	(GHash *gh, void *key, void *val);
-BM_INLINE int		BLI_ghash_remove	(GHash *gh, void *key, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp);
-BM_INLINE void*	BLI_ghash_lookup	(GHash *gh, void *key);
-BM_INLINE int		BLI_ghash_haskey	(GHash *gh, void *key);
+//BM_INLINE void	BLI_ghash_insert	(GHash *gh, void *key, void *val);
+//BM_INLINE int		BLI_ghash_remove	(GHash *gh, void *key, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp);
+//BM_INLINE void*	BLI_ghash_lookup	(GHash *gh, void *key);
+//BM_INLINE int		BLI_ghash_haskey	(GHash *gh, void *key);
 
 int		BLI_ghash_size		(GHash *gh);
 
@@ -139,11 +146,10 @@
 unsigned int	BLI_ghashutil_inthash	(void *ptr);
 int				BLI_ghashutil_intcmp(void *a, void *b);
 
-#endif
-
 /*begin of macro-inlined functions*/
 extern unsigned int hashsizes[];
 
+#if 0
 #define BLI_ghash_insert(gh, _k, _v){\
 	unsigned int _hash= (gh)->hashfp(_k)%gh->nbuckets;\
 	Entry *_e= BLI_mempool_alloc((gh)->entrypool);\
@@ -167,3 +173,94 @@
 			}\
 		}\
 		free(_old); } }
+#endif
+
+/*---------inlined functions---------*/
+BM_INLINE void BLI_ghash_insert(GHash *gh, void *key, void *val) {
+	unsigned int hash= gh->hashfp(key)%gh->nbuckets;
+	Entry *e= BLI_mempool_alloc(gh->entrypool);
+
+	e->key= key;
+	e->val= val;
+	e->next= gh->buckets[hash];
+	gh->buckets[hash]= e;
+	
+	if (++gh->nentries>gh->nbuckets*3) {
+		Entry *e, **old= gh->buckets;
+		int i, nold= gh->nbuckets;
+		
+		gh->nbuckets= hashsizes[++gh->cursize];
+		gh->buckets= malloc(gh->nbuckets*sizeof(*gh->buckets));
+		memset(gh->buckets, 0, gh->nbuckets*sizeof(*gh->buckets));
+		
+		for (i=0; i<nold; i++) {
+			for (e= old[i]; e;) {
+				Entry *n= e->next;
+				
+				hash= gh->hashfp(e->key)%gh->nbuckets;
+				e->next= gh->buckets[hash];
+				gh->buckets[hash]= e;
+				
+				e= n;
+			}
+		}
+		
+		free(old);
+	}
+}
+
+BM_INLINE void* BLI_ghash_lookup(GHash *gh, void *key) 
+{
+	if(gh) {
+		unsigned int hash= gh->hashfp(key)%gh->nbuckets;
+		Entry *e;
+		
+		for (e= gh->buckets[hash]; e; e= e->next)
+			if (gh->cmpfp(key, e->key)==0)
+				return e->val;
+	}	
+	return NULL;
+}
+
+BM_INLINE int BLI_ghash_remove (GHash *gh, void *key, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp)
+{
+	unsigned int hash= gh->hashfp(key)%gh->nbuckets;
+	Entry *e;
+	Entry *p = 0;
+
+	for (e= gh->buckets[hash]; e; e= e->next) {
+		if (gh->cmpfp(key, e->key)==0) {
+			Entry *n= e->next;
+
+			if (keyfreefp) keyfreefp(e->key);
+			if (valfreefp) valfreefp(e->val);
+			BLI_mempool_free(gh->entrypool, e);
+
+
+			e= n;
+			if (p)
+				p->next = n;
+			else
+				gh->buckets[hash] = n;
+
+			--gh->nentries;
+			return 1;
+		}
+		p = e;
+	}
+ 
+	return 0;
+}
+
+BM_INLINE int BLI_ghash_haskey(GHash *gh, void *key) {
+	unsigned int hash= gh->hashfp(key)%gh->nbuckets;
+	Entry *e;
+	
+	for (e= gh->buckets[hash]; e; e= e->next)
+		if (gh->cmpfp(key, e->key)==0)
+			return 1;
+	
+	return 0;
+}
+
+#endif

Modified: branches/bmesh/blender/source/blender/blenlib/intern/BLI_ghash.c
===================================================================
--- branches/bmesh/blender/source/blender/blenlib/intern/BLI_ghash.c	2009-09-09 02:44:08 UTC (rev 23072)
+++ branches/bmesh/blender/source/blender/blenlib/intern/BLI_ghash.c	2009-09-09 06:28:58 UTC (rev 23073)
@@ -76,93 +76,6 @@
 #undef BLI_ghash_insert
 #endif
 
-BM_INLINE void BLI_ghash_insert(GHash *gh, void *key, void *val) {
-	unsigned int hash= gh->hashfp(key)%gh->nbuckets;
-	Entry *e= BLI_mempool_alloc(gh->entrypool);
-
-	e->key= key;
-	e->val= val;
-	e->next= gh->buckets[hash];
-	gh->buckets[hash]= e;
-	
-	if (++gh->nentries>gh->nbuckets*3) {
-		Entry *e, **old= gh->buckets;
-		int i, nold= gh->nbuckets;
-		
-		gh->nbuckets= hashsizes[++gh->cursize];
-		gh->buckets= malloc(gh->nbuckets*sizeof(*gh->buckets));
-		memset(gh->buckets, 0, gh->nbuckets*sizeof(*gh->buckets));
-		
-		for (i=0; i<nold; i++) {
-			for (e= old[i]; e;) {
-				Entry *n= e->next;
-				
-				hash= gh->hashfp(e->key)%gh->nbuckets;
-				e->next= gh->buckets[hash];
-				gh->buckets[hash]= e;
-				
-				e= n;
-			}
-		}
-		
-		free(old);
-	}
-}
-
-BM_INLINE void* BLI_ghash_lookup(GHash *gh, void *key) 
-{
-	if(gh) {
-		unsigned int hash= gh->hashfp(key)%gh->nbuckets;
-		Entry *e;
-		
-		for (e= gh->buckets[hash]; e; e= e->next)
-			if (gh->cmpfp(key, e->key)==0)
-				return e->val;
-	}	
-	return NULL;
-}
-
-BM_INLINE int BLI_ghash_remove (GHash *gh, void *key, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp)
-{
-	unsigned int hash= gh->hashfp(key)%gh->nbuckets;
-	Entry *e;
-	Entry *p = 0;
-
-	for (e= gh->buckets[hash]; e; e= e->next) {
-		if (gh->cmpfp(key, e->key)==0) {
-			Entry *n= e->next;
-
-			if (keyfreefp) keyfreefp(e->key);
-			if (valfreefp) valfreefp(e->val);
-			BLI_mempool_free(gh->entrypool, e);
-
-
-			e= n;
-			if (p)
-				p->next = n;
-			else
-				gh->buckets[hash] = n;
-
-			--gh->nentries;
-			return 1;
-		}
-		p = e;
-	}
- 
-	return 0;
-}
-
-BM_INLINE int BLI_ghash_haskey(GHash *gh, void *key) {
-	unsigned int hash= gh->hashfp(key)%gh->nbuckets;
-	Entry *e;
-	
-	for (e= gh->buckets[hash]; e; e= e->next)
-		if (gh->cmpfp(key, e->key)==0)
-			return 1;
-	
-	return 0;
-}
-
 int BLI_ghash_size(GHash *gh) {
 	return gh->nentries;
 }

Modified: branches/bmesh/blender/source/blender/bmesh/bmesh_operator_api.h
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/bmesh_operator_api.h	2009-09-09 02:44:08 UTC (rev 23072)
+++ branches/bmesh/blender/source/blender/bmesh/bmesh_operator_api.h	2009-09-09 06:28:58 UTC (rev 23073)
@@ -253,25 +253,25 @@
 
 /*counts number of elements inside a slot array.*/
 int BMO_CountSlotBuf(struct BMesh *bm, struct BMOperator *op, char *slotname);
+int BMO_CountSlotMap(struct BMesh *bm, struct BMOperator *op, char *slotname);
 
-

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list