[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [42206] branches/bmesh/blender/source/ blender/bmesh: minor changes
Campbell Barton
ideasman42 at gmail.com
Mon Nov 28 06:56:12 CET 2011
Revision: 42206
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=42206
Author: campbellbarton
Date: 2011-11-28 05:56:00 +0000 (Mon, 28 Nov 2011)
Log Message:
-----------
minor changes
- comment BM_SetIndex as setting dirty.
- have alloc_flag_layer validate the index data and clear the dirty flag since it loops on the data anyway.
Modified Paths:
--------------
branches/bmesh/blender/source/blender/bmesh/intern/bmesh_operators.c
branches/bmesh/blender/source/blender/bmesh/operators/bevel.c
Modified: branches/bmesh/blender/source/blender/bmesh/intern/bmesh_operators.c
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/intern/bmesh_operators.c 2011-11-28 05:00:34 UTC (rev 42205)
+++ branches/bmesh/blender/source/blender/bmesh/intern/bmesh_operators.c 2011-11-28 05:56:00 UTC (rev 42206)
@@ -1,6 +1,7 @@
#include "MEM_guardedalloc.h"
#include "BLI_utildefines.h"
+#include "BLI_string.h"
#include "BLI_math.h"
#include "BLI_memarena.h"
#include "BLI_mempool.h"
@@ -112,6 +113,10 @@
(void)bm;
#endif
+ if (opcode == -1) {
+ opcode= 0; /* error!, already printed, have a better way to handle this? */
+ }
+
memset(op, 0, sizeof(BMOperator));
op->type = opcode;
op->flag = opdefines[opcode]->flag;
@@ -808,15 +813,17 @@
*/
static void alloc_flag_layer(BMesh *bm)
{
- BMVert *v;
- BMEdge *e;
- BMFace *f;
+ BMHeader *ele;
+ /* set the index values since we are looping over all data anyway,
+ * may save time later on */
+ int i;
- BMIter verts;
- BMIter edges;
- BMIter faces;
+ BMIter iter;
BLI_mempool *oldpool = bm->toolflagpool; /*old flag pool*/
void *oldflags;
+
+ /* store memcpy size for reuse */
+ const size_t old_totflags_size= (bm->totflags * sizeof(BMFlagLayer));
bm->totflags++;
@@ -824,22 +831,27 @@
bm->toolflagpool = BLI_mempool_create(sizeof(BMFlagLayer)*bm->totflags, 512, 512, FALSE, FALSE);
/*now go through and memcpy all the flags. Loops don't get a flag layer at this time...*/
- for(v = BMIter_New(&verts, bm, BM_VERTS_OF_MESH, bm); v; v = BMIter_Step(&verts)){
- oldflags = v->head.flags;
- v->head.flags = BLI_mempool_calloc(bm->toolflagpool);
- memcpy(v->head.flags, oldflags, sizeof(BMFlagLayer)*(bm->totflags-1));
+ for(ele = BMIter_New(&iter, bm, BM_VERTS_OF_MESH, bm), i = 0; ele; ele = BMIter_Step(&iter), i++){
+ oldflags = ele->flags;
+ ele->flags = BLI_mempool_calloc(bm->toolflagpool);
+ memcpy(ele->flags, oldflags, old_totflags_size);
+ BM_SetIndex(ele, i); /* set_inline */
}
- for(e = BMIter_New(&edges, bm, BM_EDGES_OF_MESH, bm); e; e = BMIter_Step(&edges)){
- oldflags = e->head.flags;
- e->head.flags = BLI_mempool_calloc(bm->toolflagpool);
- memcpy(e->head.flags, oldflags, sizeof(BMFlagLayer)*(bm->totflags-1));
+ for(ele = BMIter_New(&iter, bm, BM_EDGES_OF_MESH, bm), i = 0; ele; ele = BMIter_Step(&iter), i++){
+ oldflags = ele->flags;
+ ele->flags = BLI_mempool_calloc(bm->toolflagpool);
+ memcpy(ele->flags, oldflags, old_totflags_size);
+ BM_SetIndex(ele, i); /* set_inline */
}
- for(f = BMIter_New(&faces, bm, BM_FACES_OF_MESH, bm); f; f = BMIter_Step(&faces)){
- oldflags = f->head.flags;
- f->head.flags = BLI_mempool_calloc(bm->toolflagpool);
- memcpy(f->head.flags, oldflags, sizeof(BMFlagLayer)*(bm->totflags-1));
+ for(ele = BMIter_New(&iter, bm, BM_FACES_OF_MESH, bm), i = 0; ele; ele = BMIter_Step(&iter), i++){
+ oldflags = ele->flags;
+ ele->flags = BLI_mempool_calloc(bm->toolflagpool);
+ memcpy(ele->flags, oldflags, old_totflags_size);
+ BM_SetIndex(ele, i); /* set_inline */
}
+ bm->elem_index_dirty &= ~(BM_VERT|BM_EDGE|BM_FACE);
+
BLI_mempool_destroy(oldpool);
}
@@ -1085,7 +1097,7 @@
int i;
for (i=0; def->slottypes[i].type; i++) {
- if (!strcmp(name, def->slottypes[i].name)) return i;
+ if (!strncmp(name, def->slottypes[i].name, MAX_SLOTNAME)) return i;
}
return -1;
@@ -1106,15 +1118,11 @@
int i;
for (i=0; i<bmesh_total_ops; i++) {
- if (!strcmp(opname, opdefines[i]->name)) break;
+ if (!strcmp(opname, opdefines[i]->name)) return i;
}
-
- if (i == bmesh_total_ops) {
- fprintf(stderr, "%s: ! could not find bmesh slot for name %s! (bmesh internal error)\n", __func__, opname);
- return 0;
- }
- return i;
+ fprintf(stderr, "%s: ! could not find bmesh slot for name %s! (bmesh internal error)\n", __func__, opname);
+ return -1;
}
int BMO_VInitOpf(BMesh *bm, BMOperator *op, const char *_fmt, va_list vlist)
@@ -1137,11 +1145,9 @@
fmt += i + (noslot ? 0 : 1);
- for (i=0; i<bmesh_total_ops; i++) {
- if (!strcmp(opname, opdefines[i]->name)) break;
- }
+ i= bmesh_opname_to_opcode(opname);
- if (i == bmesh_total_ops) {
+ if (i == -1) {
MEM_freeN(ofmt);
return 0;
}
@@ -1172,7 +1178,7 @@
if (bmesh_name_to_slotcode_check(def, fmt) < 0) goto error;
- strcpy(slotname, fmt);
+ BLI_strncpy(slotname, fmt, sizeof(slotname));
state = 0;
fmt += i;
Modified: branches/bmesh/blender/source/blender/bmesh/operators/bevel.c
===================================================================
--- branches/bmesh/blender/source/blender/bmesh/operators/bevel.c 2011-11-28 05:00:34 UTC (rev 42205)
+++ branches/bmesh/blender/source/blender/bmesh/operators/bevel.c 2011-11-28 05:56:00 UTC (rev 42206)
@@ -202,7 +202,7 @@
BMLoop *l;
if (!BMO_TestFlag(bm, e, EDGE_OLD)) {
- BM_SetIndex(e, BLI_array_count(etags));
+ BM_SetIndex(e, BLI_array_count(etags)); /* set_dirty! */
BLI_array_growone(etags);
BMO_SetFlag(bm, e, EDGE_OLD);
@@ -216,11 +216,11 @@
continue;
BM_ITER(l2, &liter2, bm, BM_LOOPS_OF_FACE, l->f) {
- BM_SetIndex(l2, BLI_array_count(tags));
+ BM_SetIndex(l2, BLI_array_count(tags)); /* set_dirty! */
BLI_array_growone(tags);
if (!BMO_TestFlag(bm, l2->e, EDGE_OLD)) {
- BM_SetIndex(l2->e, BLI_array_count(etags));
+ BM_SetIndex(l2->e, BLI_array_count(etags)); /* set_dirty! */
BLI_array_growone(etags);
BMO_SetFlag(bm, l2->e, EDGE_OLD);
@@ -231,7 +231,7 @@
BLI_array_append(faces, l->f);
}
} else {
- BM_SetIndex(e, -1);
+ BM_SetIndex(e, -1); /* set_dirty! */
}
}
#endif
@@ -252,7 +252,7 @@
if (!BLI_smallhash_haskey(&hash, (intptr_t)e)) {
BLI_array_growone(etags);
- BM_SetIndex(e, BLI_array_count(etags)-1);
+ BM_SetIndex(e, BLI_array_count(etags)-1); /* set_dirty! */
BLI_smallhash_insert(&hash, (intptr_t)e, NULL);
BMO_SetFlag(bm, e, EDGE_OLD);
}
@@ -270,11 +270,11 @@
/*create tags for all loops in l->f*/
BM_ITER(l2, &liter2, bm, BM_LOOPS_OF_FACE, l->f) {
BLI_array_growone(tags);
- BM_SetIndex(l2, BLI_array_count(tags)-1);
+ BM_SetIndex(l2, BLI_array_count(tags)-1); /* set_ok (loop) */
if (!BLI_smallhash_haskey(&hash, (intptr_t)l2->e)) {
BLI_array_growone(etags);
- BM_SetIndex(l2->e, BLI_array_count(etags)-1);
+ BM_SetIndex(l2->e, BLI_array_count(etags)-1); /* set_dirty! */
BLI_smallhash_insert(&hash, (intptr_t)l2->e, NULL);
BMO_SetFlag(bm, l2->e, EDGE_OLD);
}
@@ -287,6 +287,8 @@
}
}
+ bm->elem_index_dirty |= BM_VERT;
+
BM_ITER(v, &iter, bm, BM_VERTS_OF_MESH, NULL) {
BMIter eiter;
More information about the Bf-blender-cvs
mailing list