Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Eagar <joeedh@gmail.com>2009-09-06 06:43:36 +0400
committerJoseph Eagar <joeedh@gmail.com>2009-09-06 06:43:36 +0400
commit67c64cf82b8b8f8def26a3412437f8d63e13adf6 (patch)
tree1f268fc9526e31ac087e45cee444bfe62f489ff4 /source/blender
parent971155b3733f56ebf3aedddc65a6110a5b1229ae (diff)
more optimization stuff. transformed a few functions into macro that profiling showed were taking a bunch of time. also have some work-in-progress (if disabled) stuff related to inlining, which I'm trying to get working but may be too much trouble.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenkernel/BKE_utildefines.h9
-rw-r--r--source/blender/blenlib/BLI_ghash.h62
-rw-r--r--source/blender/blenlib/intern/BLI_ghash.c34
-rw-r--r--source/blender/blenlib/intern/BLI_mempool.c9
-rw-r--r--source/blender/blenlib/intern/scanfill.c39
-rw-r--r--source/blender/bmesh/bmesh_iterators.h9
-rw-r--r--source/blender/bmesh/bmesh_operator_api.h16
-rw-r--r--source/blender/bmesh/intern/bmesh_mesh.c6
-rw-r--r--source/blender/bmesh/intern/bmesh_operators.c16
-rw-r--r--source/blender/bmesh/operators/mesh_conv.c20
-rw-r--r--source/blender/bmesh/operators/removedoubles.c27
-rw-r--r--source/blender/editors/transform/transform_conversions.c27
-rw-r--r--source/blender/editors/uvedit/uvedit_unwrap_ops.c3
13 files changed, 188 insertions, 89 deletions
diff --git a/source/blender/blenkernel/BKE_utildefines.h b/source/blender/blenkernel/BKE_utildefines.h
index 9a076ee16da..950c89aaa89 100644
--- a/source/blender/blenkernel/BKE_utildefines.h
+++ b/source/blender/blenkernel/BKE_utildefines.h
@@ -239,5 +239,14 @@ behaviour, though it may not be the best in practice.
free the memory.*/
#define V_RESET(vec) _##vec##_count=0
+/*little macro so inline keyword works*/
+#if defined(_MSC_VER)
+#define BM_INLINE //__forceinline
+#else
+#define BM_INLINE inline
+#endif
+
+#define BMEMSET(mem, val, size) {int _i; char *_c = mem; for (_i=0; _i<size; _i++) *_c++ = val;}
+
#endif
diff --git a/source/blender/blenlib/BLI_ghash.h b/source/blender/blenlib/BLI_ghash.h
index c77e82f0a2b..a19b6ccbe4c 100644
--- a/source/blender/blenlib/BLI_ghash.h
+++ b/source/blender/blenlib/BLI_ghash.h
@@ -32,8 +32,27 @@
#ifndef BLI_GHASH_H
#define BLI_GHASH_H
-struct GHash;
-typedef struct GHash GHash;
+#include "BKE_utildefines.h"
+
+typedef unsigned int (*GHashHashFP) (void *key);
+typedef int (*GHashCmpFP) (void *a, void *b);
+typedef void (*GHashKeyFreeFP) (void *key);
+typedef void (*GHashValFreeFP) (void *val);
+
+typedef struct Entry {
+ struct Entry *next;
+
+ void *key, *val;
+} Entry;
+
+typedef struct GHash {
+ GHashHashFP hashfp;
+ GHashCmpFP cmpfp;
+
+ Entry **buckets;
+ struct BLI_mempool *entrypool;
+ int nbuckets, nentries, cursize;
+} GHash;
typedef struct GHashIterator {
GHash *gh;
@@ -41,18 +60,13 @@ typedef struct GHashIterator {
struct Entry *curEntry;
} GHashIterator;
-typedef unsigned int (*GHashHashFP) (void *key);
-typedef int (*GHashCmpFP) (void *a, void *b);
-typedef void (*GHashKeyFreeFP) (void *key);
-typedef void (*GHashValFreeFP) (void *val);
-
GHash* BLI_ghash_new (GHashHashFP hashfp, GHashCmpFP cmpfp);
void BLI_ghash_free (GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp);
-void BLI_ghash_insert (GHash *gh, void *key, void *val);
-int BLI_ghash_remove (GHash *gh, void *key, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp);
-void* BLI_ghash_lookup (GHash *gh, void *key);
-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);
@@ -127,3 +141,29 @@ int BLI_ghashutil_intcmp(void *a, void *b);
#endif
+/*begin of macro-inlined functions*/
+extern unsigned int hashsizes[];
+
+#define BLI_ghash_insert(gh, _k, _v){\
+ unsigned int _hash= (gh)->hashfp(_k)%gh->nbuckets;\
+ Entry *_e= BLI_mempool_alloc((gh)->entrypool);\
+ _e->key= _k;\
+ _e->val= _v;\
+ _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); } }
diff --git a/source/blender/blenlib/intern/BLI_ghash.c b/source/blender/blenlib/intern/BLI_ghash.c
index d835ed18476..414beb3d19a 100644
--- a/source/blender/blenlib/intern/BLI_ghash.c
+++ b/source/blender/blenlib/intern/BLI_ghash.c
@@ -37,13 +37,15 @@
#include "BLO_sys_types.h" // for intptr_t support
+#include "BKE_utildefines.h"
+
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
/***/
-static unsigned int hashsizes[]= {
+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,
@@ -52,29 +54,13 @@ static unsigned int hashsizes[]= {
/***/
-typedef struct Entry Entry;
-struct Entry {
- Entry *next;
-
- void *key, *val;
-};
-
-struct GHash {
- GHashHashFP hashfp;
- GHashCmpFP cmpfp;
-
- Entry **buckets;
- struct BLI_mempool *entrypool;
- int nbuckets, nentries, cursize;
-};
-
/***/
GHash *BLI_ghash_new(GHashHashFP hashfp, GHashCmpFP cmpfp) {
GHash *gh= MEM_mallocN(sizeof(*gh), "GHash");
gh->hashfp= hashfp;
gh->cmpfp= cmpfp;
- gh->entrypool = BLI_mempool_create(sizeof(Entry), 1, 32);
+ gh->entrypool = BLI_mempool_create(sizeof(Entry), 1024, 1024);
gh->cursize= 0;
gh->nentries= 0;
@@ -86,7 +72,11 @@ GHash *BLI_ghash_new(GHashHashFP hashfp, GHashCmpFP cmpfp) {
return gh;
}
-void BLI_ghash_insert(GHash *gh, void *key, void *val) {
+#ifdef BLI_ghash_insert
+#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);
@@ -119,7 +109,7 @@ void BLI_ghash_insert(GHash *gh, void *key, void *val) {
}
}
-void* BLI_ghash_lookup(GHash *gh, void *key)
+BM_INLINE void* BLI_ghash_lookup(GHash *gh, void *key)
{
if(gh) {
unsigned int hash= gh->hashfp(key)%gh->nbuckets;
@@ -132,7 +122,7 @@ void* BLI_ghash_lookup(GHash *gh, void *key)
return NULL;
}
-int BLI_ghash_remove (GHash *gh, void *key, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp)
+BM_INLINE int BLI_ghash_remove (GHash *gh, void *key, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp)
{
unsigned int hash= gh->hashfp(key)%gh->nbuckets;
Entry *e;
@@ -162,7 +152,7 @@ int BLI_ghash_remove (GHash *gh, void *key, GHashKeyFreeFP keyfreefp, GHashValFr
return 0;
}
-int BLI_ghash_haskey(GHash *gh, void *key) {
+BM_INLINE int BLI_ghash_haskey(GHash *gh, void *key) {
unsigned int hash= gh->hashfp(key)%gh->nbuckets;
Entry *e;
diff --git a/source/blender/blenlib/intern/BLI_mempool.c b/source/blender/blenlib/intern/BLI_mempool.c
index 493bbba3567..b0c916db357 100644
--- a/source/blender/blenlib/intern/BLI_mempool.c
+++ b/source/blender/blenlib/intern/BLI_mempool.c
@@ -31,9 +31,14 @@
*/
#include "MEM_guardedalloc.h"
+
+#include "BKE_utildefines.h"
+
#include "BLI_blenlib.h"
-#include "DNA_listBase.h"
#include "BLI_linklist.h"
+
+#include "DNA_listBase.h"
+
#include <string.h>
typedef struct BLI_freenode{
@@ -122,7 +127,7 @@ void *BLI_mempool_alloc(BLI_mempool *pool){
void *BLI_mempool_calloc(BLI_mempool *pool){
void *retval=NULL;
retval = BLI_mempool_alloc(pool);
- memset(retval, 0, pool->esize);
+ BMEMSET(retval, 0, pool->esize);
return retval;
}
diff --git a/source/blender/blenlib/intern/scanfill.c b/source/blender/blenlib/intern/scanfill.c
index d0a225b5ea2..df7d608027b 100644
--- a/source/blender/blenlib/intern/scanfill.c
+++ b/source/blender/blenlib/intern/scanfill.c
@@ -31,6 +31,7 @@
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
+#include <string.h>
#include "MEM_guardedalloc.h"
@@ -154,7 +155,7 @@ static void *new_mem_element(int size)
{
int blocksize= 16384;
static int offs= 0; /* the current free adress */
- static struct mem_elements *cur= 0;
+ static struct mem_elements *cur= 0, *first;
static ListBase lb= {0, 0};
void *adr;
@@ -162,6 +163,10 @@ static void *new_mem_element(int size)
printf("incorrect use of new_mem_element\n");
}
else if(size== -1) {
+ /*keep the first block*/
+ first = lb.first;
+ BLI_remlink(&lb, first);
+
cur= lb.first;
while(cur) {
MEM_freeN(cur->data);
@@ -169,6 +174,12 @@ static void *new_mem_element(int size)
}
BLI_freelistN(&lb);
+ /*reset the block we're keeping*/
+ BLI_addtail(&lb, first);
+ memset(first->data, 0, blocksize);
+ cur = first;
+ offs = 0;
+
return NULL;
}
@@ -770,6 +781,7 @@ int BLI_edgefill(int mode, int mat_nr)
- struct elements xs en ys are not used here: don't hide stuff in it
- edge flag ->f becomes 2 when it's a new edge
- mode: & 1 is check for crossings, then create edges (TO DO )
+ - mode: & 2 is enable shortest diagonal test for quads
*/
ListBase tempve, temped;
EditVert *eve;
@@ -798,17 +810,22 @@ int BLI_edgefill(int mode, int mat_nr)
float vec1[3], vec2[3];
eve = fillvertbase.first;
-
- /*use shortest diagonal for quad*/
- VecSubf(vec1, eve->co, eve->next->next->co);
- VecSubf(vec2, eve->next->co, eve->next->next->next->co);
-
- if (INPR(vec1, vec1) < INPR(vec2, vec2)) {
- addfillface(eve, eve->next, eve->next->next, 0);
- addfillface(eve->next->next, eve->next->next->next, eve, 0);
+
+ if (mode & 2) {
+ /*use shortest diagonal for quad*/
+ VecSubf(vec1, eve->co, eve->next->next->co);
+ VecSubf(vec2, eve->next->co, eve->next->next->next->co);
+
+ if (INPR(vec1, vec1) < INPR(vec2, vec2)) {
+ addfillface(eve, eve->next, eve->next->next, 0);
+ addfillface(eve->next->next, eve->next->next->next, eve, 0);
+ } else{
+ addfillface(eve->next, eve->next->next, eve->next->next->next, 0);
+ addfillface(eve->next->next->next, eve, eve->next, 0);
+ }
} else {
- addfillface(eve->next, eve->next->next, eve->next->next->next, 0);
- addfillface(eve->next->next->next, eve, eve->next, 0);
+ addfillface(eve, eve->next, eve->next->next, 0);
+ addfillface(eve->next->next, eve->next->next->next, eve, 0);
}
return 1;
}
diff --git a/source/blender/bmesh/bmesh_iterators.h b/source/blender/bmesh/bmesh_iterators.h
index 316ef56a101..cae022d66bd 100644
--- a/source/blender/bmesh/bmesh_iterators.h
+++ b/source/blender/bmesh/bmesh_iterators.h
@@ -16,7 +16,7 @@
/*Defines for passing to BMIter_New.
"OF" can be substituted for "around"
- so BM_VERTS_OF_MESH_OF_FACE means "vertices
+ so BM_VERTS_OF_FACE means "vertices
around a face."
*/
@@ -32,14 +32,13 @@
#define BM_LOOPS_OF_VERT 6
#define BM_FACES_OF_EDGE 7
#define BM_VERTS_OF_FACE 8
-#define BM_FACEVERTS_OF_FACE 9
-#define BM_EDGES_OF_FACE 10
-#define BM_LOOPS_OF_FACE 11
+#define BM_EDGES_OF_FACE 9
+#define BM_LOOPS_OF_FACE 10
/*iterate through loops around this loop, which are fetched
from the other faces in the radial cycle surrounding the
input loop's edge.*/
-#define BM_LOOPS_OF_LOOP 12
+#define BM_LOOPS_OF_LOOP 11
#define BM_ITER(ele, iter, bm, type, data) \
ele = BMIter_New(iter, bm, type, data); \
diff --git a/source/blender/bmesh/bmesh_operator_api.h b/source/blender/bmesh/bmesh_operator_api.h
index fd8889f5c71..1c8ae67081b 100644
--- a/source/blender/bmesh/bmesh_operator_api.h
+++ b/source/blender/bmesh/bmesh_operator_api.h
@@ -4,6 +4,8 @@
#include "BLI_memarena.h"
#include "BLI_ghash.h"
+#include "BKE_utildefines.h"
+
#include <stdarg.h>
/*
@@ -255,21 +257,21 @@ int BMO_CountSlotBuf(struct BMesh *bm, struct BMOperator *op, char *slotname);
/*inserts a key/value mapping into a mapping slot. note that it copies the
value, it doesn't store a reference to it.*/
-void BMO_Insert_Mapping(BMesh *bm, BMOperator *op, char *slotname,
+BM_INLINE void BMO_Insert_Mapping(BMesh *bm, BMOperator *op, char *slotname,
void *element, void *data, int len);
/*inserts a key/float mapping pair into a mapping slot.*/
-void BMO_Insert_MapFloat(BMesh *bm, BMOperator *op, char *slotname,
+BM_INLINE void BMO_Insert_MapFloat(BMesh *bm, BMOperator *op, char *slotname,
void *element, float val);
//returns 1 if the specified pointer is in the map.
-int BMO_InMap(BMesh *bm, BMOperator *op, char *slotname, void *element);
+BM_INLINE int BMO_InMap(BMesh *bm, BMOperator *op, char *slotname, void *element);
/*returns a point to the value of a specific key.*/
-void *BMO_Get_MapData(BMesh *bm, BMOperator *op, char *slotname, void *element);
+BM_INLINE void *BMO_Get_MapData(BMesh *bm, BMOperator *op, char *slotname, void *element);
/*returns the float part of a key/float pair.*/
-float BMO_Get_MapFloat(BMesh *bm, BMOperator *op, char *slotname, void *element);
+BM_INLINE float BMO_Get_MapFloat(BMesh *bm, BMOperator *op, char *slotname, void *element);
/*flags all elements in a mapping. note that the mapping must only have
bmesh elements in it.*/
@@ -280,9 +282,9 @@ void BMO_Mapping_To_Flag(struct BMesh *bm, struct BMOperator *op,
do NOT use these for non-operator-api-allocated memory! instead
use BMO_Get_MapData and BMO_Insert_Mapping, which copies the data.*/
-void BMO_Insert_MapPointer(BMesh *bm, BMOperator *op, char *slotname,
+BM_INLINE void BMO_Insert_MapPointer(BMesh *bm, BMOperator *op, char *slotname,
void *key, void *val);
-void *BMO_Get_MapPointer(BMesh *bm, BMOperator *op, char *slotname,
+BM_INLINE void *BMO_Get_MapPointer(BMesh *bm, BMOperator *op, char *slotname,
void *key);
/*this part of the API is used to iterate over element buffer or
diff --git a/source/blender/bmesh/intern/bmesh_mesh.c b/source/blender/bmesh/intern/bmesh_mesh.c
index 53617af9686..c4e92c64492 100644
--- a/source/blender/bmesh/intern/bmesh_mesh.c
+++ b/source/blender/bmesh/intern/bmesh_mesh.c
@@ -247,7 +247,11 @@ void BM_Compute_Normals(BMesh *bm)
*/
void bmesh_begin_edit(BMesh *bm){
-
+ if(bm->vtar) MEM_freeN(bm->vtar);
+ if(bm->edar) MEM_freeN(bm->edar);
+ if(bm->lpar) MEM_freeN(bm->lpar);
+ if(bm->plar) MEM_freeN(bm->plar);
+
/*Initialize some scratch pointer arrays used by eulers*/
bm->vtar = MEM_callocN(sizeof(BMVert *) * 1024, "BM scratch vert array");
bm->edar = MEM_callocN(sizeof(BMEdge *) * 1024, "BM scratch edge array");
diff --git a/source/blender/bmesh/intern/bmesh_operators.c b/source/blender/bmesh/intern/bmesh_operators.c
index 041f0320488..9c5f31cd2d4 100644
--- a/source/blender/bmesh/intern/bmesh_operators.c
+++ b/source/blender/bmesh/intern/bmesh_operators.c
@@ -225,7 +225,7 @@ void BMO_CopySlot(BMOperator *source_op, BMOperator *dest_op, char *src, char *d
dstmap->len = srcmap->len;
memcpy(dstmap+1, srcmap+1, srcmap->len);
- BLI_ghash_insert(dest_slot->data.ghash,
+ BLI_ghash_insert(dest_slot->data.ghash,
dstmap->element, dstmap);
}
}
@@ -455,7 +455,7 @@ void *BMO_Grow_Array(BMesh *bm, BMOperator *op, int slotcode, int totadd) {
}
#endif
-void BMO_Insert_Mapping(BMesh *bm, BMOperator *op, char *slotname,
+BM_INLINE void BMO_Insert_Mapping(BMesh *bm, BMOperator *op, char *slotname,
void *element, void *data, int len) {
element_mapping *mapping;
BMOpSlot *slot = BMO_GetSlot(op, slotname);
@@ -494,19 +494,19 @@ void BMO_Mapping_To_Flag(struct BMesh *bm, struct BMOperator *op,
}
}
-void BMO_Insert_MapFloat(BMesh *bm, BMOperator *op, char *slotname,
+BM_INLINE void BMO_Insert_MapFloat(BMesh *bm, BMOperator *op, char *slotname,
void *element, float val)
{
BMO_Insert_Mapping(bm, op, slotname, element, &val, sizeof(float));
}
-void BMO_Insert_MapPointer(BMesh *bm, BMOperator *op, char *slotname,
+BM_INLINE void BMO_Insert_MapPointer(BMesh *bm, BMOperator *op, char *slotname,
void *element, void *val)
{
BMO_Insert_Mapping(bm, op, slotname, element, &val, sizeof(void*));
}
-int BMO_InMap(BMesh *bm, BMOperator *op, char *slotname, void *element)
+BM_INLINE int BMO_InMap(BMesh *bm, BMOperator *op, char *slotname, void *element)
{
BMOpSlot *slot = BMO_GetSlot(op, slotname);
@@ -517,7 +517,7 @@ int BMO_InMap(BMesh *bm, BMOperator *op, char *slotname, void *element)
return BLI_ghash_haskey(slot->data.ghash, element);
}
-void *BMO_Get_MapData(BMesh *bm, BMOperator *op, char *slotname,
+BM_INLINE void *BMO_Get_MapData(BMesh *bm, BMOperator *op, char *slotname,
void *element)
{
element_mapping *mapping;
@@ -534,7 +534,7 @@ void *BMO_Get_MapData(BMesh *bm, BMOperator *op, char *slotname,
return mapping + 1;
}
-float BMO_Get_MapFloat(BMesh *bm, BMOperator *op, char *slotname,
+BM_INLINE float BMO_Get_MapFloat(BMesh *bm, BMOperator *op, char *slotname,
void *element)
{
float *val = BMO_Get_MapData(bm, op, slotname, element);
@@ -543,7 +543,7 @@ float BMO_Get_MapFloat(BMesh *bm, BMOperator *op, char *slotname,
return 0.0f;
}
-void *BMO_Get_MapPointer(BMesh *bm, BMOperator *op, char *slotname,
+BM_INLINE void *BMO_Get_MapPointer(BMesh *bm, BMOperator *op, char *slotname,
void *element)
{
void **val = BMO_Get_MapData(bm, op, slotname, element);
diff --git a/source/blender/bmesh/operators/mesh_conv.c b/source/blender/bmesh/operators/mesh_conv.c
index 31eb2914427..ac92beb1327 100644
--- a/source/blender/bmesh/operators/mesh_conv.c
+++ b/source/blender/bmesh/operators/mesh_conv.c
@@ -74,14 +74,15 @@ void mesh_to_bmesh_exec(BMesh *bm, BMOperator *op) {
BMINDEX_SET(v, i);
/*transfer flags*/
- v->head.flag = (mvert->flag & ME_HIDE) ? BM_HIDDEN : 0;
- if(mvert->flag & SELECT) BM_Select_Vert(bm, v, 1);
+ v->head.flag = MEFlags_To_BMFlags(mvert->flag, BM_VERT);
+
+ /*this is necassary for selection counts to work properly*/
+ if(v->head.flag & BM_SELECT) BM_Select_Vert(bm, v, 1);
+
v->bweight = (float)mvert->bweight / 255.0f;
/*Copy Custom Data*/
CustomData_to_bmesh_block(&me->vdata, &bm->vdata, i, &v->head.data);
-
- v->head.flag = MEFlags_To_BMFlags(mvert->flag, BM_VERT);
}
if (!me->totedge) return;
@@ -99,7 +100,11 @@ void mesh_to_bmesh_exec(BMesh *bm, BMOperator *op) {
e->crease = (float)medge->crease / 255.0f;
e->bweight = (float)medge->bweight / 255.0f;
+ /*transfer flags*/
e->head.flag = MEFlags_To_BMFlags(medge->flag, BM_EDGE);
+
+ /*this is necassary for selection counts to work properly*/
+ if (e->head.flag & BM_SELECT) BM_Select(bm, e, 1);
}
if (!me->totpoly) return;
@@ -132,8 +137,13 @@ void mesh_to_bmesh_exec(BMesh *bm, BMOperator *op) {
}
f = BM_Make_Ngon(bm, v1, v2, fedges, mpoly->totloop, 0);
-
+
+ /*transfer flags*/
f->head.flag = MEFlags_To_BMFlags(mpoly->flag, BM_FACE);
+
+ /*this is necassary for selection counts to work properly*/
+ if (f->head.flag & BM_SELECT) BM_Select(bm, f, 1);
+
f->mat_nr = mpoly->mat_nr;
if (i == me->act_face) bm->act_face = f;
diff --git a/source/blender/bmesh/operators/removedoubles.c b/source/blender/bmesh/operators/removedoubles.c
index 24d57b6b1fd..b19b409b93d 100644
--- a/source/blender/bmesh/operators/removedoubles.c
+++ b/source/blender/bmesh/operators/removedoubles.c
@@ -501,7 +501,7 @@ void bmesh_finddoubles_exec(BMesh *bm, BMOperator *op)
BMVert **verts=NULL;
V_DECLARE(verts);
float dist, distsqr;
- int i, j, len;
+ int i, j, len, keepvert;
dist = BMO_Get_Float(op, "dist");
distsqr = dist*dist;
@@ -512,8 +512,10 @@ void bmesh_finddoubles_exec(BMesh *bm, BMOperator *op)
verts[i++] = v;
}
+ keepvert = BMO_IterNew(&oiter, bm, op, "keepverts", BM_VERT) != NULL;
+
/*sort by vertex coordinates added together*/
- //qsort(verts, V_COUNT(verts), sizeof(void*), vergaverco);
+ qsort(verts, V_COUNT(verts), sizeof(void*), vergaverco);
BMO_Flag_Buffer(bm, op, "keepverts", VERT_KEEP, BM_VERT);
@@ -522,21 +524,16 @@ void bmesh_finddoubles_exec(BMesh *bm, BMOperator *op)
v = verts[i];
if (BMO_TestFlag(bm, v, VERT_DOUBLE)) continue;
- //BMO_SetFlag(bm, v, VERT_TESTED);
- for (j=0; j<len; j++) {
- if (j == i) continue;
-
- //float vec[3];
- if (BMO_TestFlag(bm, v, VERT_KEEP)) continue;
-
+ for (j=i+1; j<len; j++) {
v2 = verts[j];
- //if ((v2->co[0]+v2->co[1]+v2->co[2]) - (v->co[0]+v->co[1]+v->co[2])
- // > distsqr) break;
-
- //vec[0] = v->co[0] - v2->co[0];
- //vec[1] = v->co[1] - v2->co[1];
- //vec[2] = v->co[2] - v2->co[2];
+ if ((v2->co[0]+v2->co[1]+v2->co[2]) - (v->co[0]+v->co[1]+v->co[2])
+ > distsqr) break;
+ if (keepvert) {
+ if (BMO_TestFlag(bm, v2, VERT_KEEP) == BMO_TestFlag(bm, v, VERT_KEEP))
+ continue;
+ }
+
if (VecLenCompare(v->co, v2->co, dist)) {
BMO_SetFlag(bm, v2, VERT_DOUBLE);
BMO_SetFlag(bm, v, VERT_TARGET);
diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c
index 34b36c9b7c1..f7acab46c4b 100644
--- a/source/blender/editors/transform/transform_conversions.c
+++ b/source/blender/editors/transform/transform_conversions.c
@@ -1907,9 +1907,33 @@ static void editmesh_set_connectivity_distance(EditMesh *em, int total, float *v
VECCOPY(centout, cent);
}
+#define VertsToTransData(t, td, em, eve) \
+ td->flag = 0;\
+ td->loc = eve->co;\
+ VECCOPY(td->center, td->loc);\
+ if(t->around==V3D_LOCAL && (em->selectmode & SCE_SELECT_FACE))\
+ get_face_center(td->center, em, eve);\
+ VECCOPY(td->iloc, td->loc);\
+ VECCOPY(td->axismtx[2], eve->no);\
+ td->axismtx[0][0] =\
+ td->axismtx[0][1] =\
+ td->axismtx[0][2] =\
+ td->axismtx[1][0] =\
+ td->axismtx[1][1] =\
+ td->axismtx[1][2] = 0.0f;\
+ td->ext = NULL;\
+ td->tdi = NULL;\
+ td->val = NULL;\
+ td->extra = NULL;\
+ if (t->mode == TFM_BWEIGHT) {\
+ td->val = &(eve->bweight);\
+ td->ival = eve->bweight;\
+ }
+
+#if 0
//way to overwrite what data is edited with transform
//static void VertsToTransData(TransData *td, EditVert *eve, BakeKey *key)
-static void VertsToTransData(TransInfo *t, TransData *td, BMesh *em, BMVert *eve)
+inline void VertsToTransData(TransInfo *t, TransData *td, BMesh *em, BMVert *eve)
{
td->flag = 0;
//if(key)
@@ -1940,6 +1964,7 @@ static void VertsToTransData(TransInfo *t, TransData *td, BMesh *em, BMVert *eve
td->ival = eve->bweight;
}
}
+#endif
/* *********************** CrazySpace correction. Now without doing subsurf optimal ****************** */
diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c
index 53eceb4d342..e24b34f0b8f 100644
--- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c
+++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c
@@ -188,7 +188,8 @@ ParamHandle *construct_param_handle(Scene *scene, BMEditMesh *em,
BLI_addfilledge(firstv, v);
- BLI_edgefill(0, 0);
+ /*mode 2 enables shortest-diagonal for quads*/
+ BLI_edgefill(2, 0);
for (sefa = fillfacebase.first; sefa; sefa=sefa->next) {
ls[0] = sefa->v1->tmp.p;
ls[1] = sefa->v2->tmp.p;