Revision: 23697 http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=23697 Author: joeedh Date: 2009-10-07 23:19:58 +0200 (Wed, 07 Oct 2009)
Log Message: ----------- part 1 of vkey rip tool. still needs more work. ugh, doing this tool correctly is a nightmare. Modified Paths: -------------- branches/bmesh/blender/source/blender/blenkernel/intern/editderivedbmesh.c branches/bmesh/blender/source/blender/blenlib/BLI_array.h branches/bmesh/blender/source/blender/bmesh/bmesh_queries.h branches/bmesh/blender/source/blender/bmesh/intern/bmesh_opdefines.c branches/bmesh/blender/source/blender/bmesh/intern/bmesh_operators_private.h branches/bmesh/blender/source/blender/bmesh/intern/bmesh_queries.c branches/bmesh/blender/source/blender/bmesh/operators/subdivideop.c branches/bmesh/blender/source/blender/editors/mesh/bmesh_select.c branches/bmesh/blender/source/blender/editors/mesh/bmesh_tools.c branches/bmesh/blender/source/blender/editors/mesh/editmesh_tools.c branches/bmesh/blender/source/blender/editors/mesh/mesh_ops.c branches/bmesh/blender/source/blender/editors/space_view3d/view3d_view.c Added Paths: ----------- branches/bmesh/blender/source/blender/bmesh/operators/edgesplitop.c branches/bmesh/blender/source/blender/editors/mesh/editbmesh_bvh.c branches/bmesh/blender/source/blender/editors/mesh/editbmesh_bvh.h Modified: branches/bmesh/blender/source/blender/blenkernel/intern/editderivedbmesh.c =================================================================== --- branches/bmesh/blender/source/blender/blenkernel/intern/editderivedbmesh.c 2009-10-07 21:19:35 UTC (rev 23696) +++ branches/bmesh/blender/source/blender/blenkernel/intern/editderivedbmesh.c 2009-10-07 21:19:58 UTC (rev 23697) @@ -882,32 +882,50 @@ bmdm_get_tri_tex(bm, ls, luv, lcol, has_uv, has_vcol); - glTexCoord2fv(luv[0]->uv); - glColor3ub(lcol[0]->r, lcol[0]->g, lcol[0]->b); + if (luv[0]) + glTexCoord2fv(luv[0]->uv); + if (lcol[0]) + glColor3ub(lcol[0]->r, lcol[0]->g, lcol[0]->b); + else glColor3ub(0, 0, 0); glVertex3fv(ls[0]->v->co); - glTexCoord2fv(luv[1]->uv); - glColor3ub(lcol[1]->r, lcol[1]->g, lcol[1]->b); + if (luv[1]) + glTexCoord2fv(luv[1]->uv); + if (lcol[1]) + glColor3ub(lcol[1]->r, lcol[1]->g, lcol[1]->b); + else glColor3ub(0, 0, 0); glVertex3fv(ls[1]->v->co); - glTexCoord2fv(luv[2]->uv); - glColor3ub(lcol[2]->r, lcol[2]->g, lcol[2]->b); + if (luv[2]) + glTexCoord2fv(luv[2]->uv); + if (lcol[2]) + glColor3ub(lcol[2]->r, lcol[2]->g, lcol[2]->b); + else glColor3ub(0, 0, 0); glVertex3fv(ls[2]->v->co); } else { bmdm_get_tri_tex(bm, ls, luv, lcol, has_uv, has_vcol); - glTexCoord2fv(luv[0]->uv); - glColor3ub(lcol[0]->r, lcol[0]->g, lcol[0]->b); + if (luv[0]) + glTexCoord2fv(luv[0]->uv); + if (lcol[0]) + glColor3ub(lcol[0]->r, lcol[0]->g, lcol[0]->b); + else glColor3ub(0, 0, 0); glNormal3fv(ls[0]->v->no); glVertex3fv(ls[0]->v->co); - glTexCoord2fv(luv[1]->uv); - glColor3ub(lcol[1]->r, lcol[1]->g, lcol[1]->b); + if (luv[1]) + glTexCoord2fv(luv[1]->uv); + if (lcol[1]) + glColor3ub(lcol[1]->r, lcol[1]->g, lcol[1]->b); + else glColor3ub(0, 0, 0); glNormal3fv(ls[1]->v->no); glVertex3fv(ls[1]->v->co); - glTexCoord2fv(luv[2]->uv); - glColor3ub(lcol[2]->r, lcol[2]->g, lcol[2]->b); + if (luv[2]) + glTexCoord2fv(luv[2]->uv); + if (lcol[2]) + glColor3ub(lcol[2]->r, lcol[2]->g, lcol[2]->b); + else glColor3ub(0, 0, 0); glNormal3fv(ls[2]->v->no); glVertex3fv(ls[2]->v->co); } Modified: branches/bmesh/blender/source/blender/blenlib/BLI_array.h =================================================================== --- branches/bmesh/blender/source/blender/blenlib/BLI_array.h 2009-10-07 21:19:35 UTC (rev 23696) +++ branches/bmesh/blender/source/blender/blenlib/BLI_array.h 2009-10-07 21:19:58 UTC (rev 23697) @@ -30,9 +30,15 @@ /* this library needs to be changed to not use macros quite so heavily, -and to be more of a complete vector array API. The way arrays are +and to be more of a complete array API. The way arrays are exposed to client code as normal C arrays is very useful though, imho. -it does require some use of macros, however. +it does require some use of macros, however. + +anyway, it's used a bit too heavily to simply rewrite as a +more "correct" solution without macros entirely. I originally wrote this +to be very easy to use, without the normal pain of most array libraries. +This was especially helpful when it came to the massive refactors necessary for +bmesh, and really helped to speed the process up. - joeedh little array macro library. example of usage: @@ -51,28 +57,35 @@ behaviour, though it may not be the best in practice. */ -#define BLI_array_declare(vec) int _##vec##_count=0; void *_##vec##_tmp +#define BLI_array_declare(arr) int _##arr##_count=0; void *_##arr##_tmp /*this returns the entire size of the array, including any buffering.*/ -#define BLI_array_totalsize(vec) ((signed int)((vec)==NULL ? 0 : MEM_allocN_len(vec) / sizeof(*vec))) +#define BLI_array_totalsize(arr) ((signed int)((arr)==NULL ? 0 : MEM_allocN_len(arr) / sizeof(*arr))) /*this returns the logical size of the array, not including buffering.*/ -#define BLI_array_count(vec) _##vec##_count +#define BLI_array_count(arr) _##arr##_count /*grow the array by one. zeroes the new elements.*/ -#define BLI_array_growone(vec) \ - BLI_array_totalsize(vec) > _##vec##_count ? _##vec##_count++ : \ - ((_##vec##_tmp = MEM_callocN(sizeof(*vec)*(_##vec##_count*2+2), #vec " " __FILE__ " ")),\ - (vec && memcpy(_##vec##_tmp, vec, sizeof(*vec) * _##vec##_count)),\ - (vec && (MEM_freeN(vec),1)),\ - (vec = _##vec##_tmp),\ - _##vec##_count++) +#define BLI_array_growone(arr) \ + BLI_array_totalsize(arr) > _##arr##_count ? _##arr##_count++ : \ + ((_##arr##_tmp = MEM_callocN(sizeof(*arr)*(_##arr##_count*2+2), #arr " " __FILE__ " ")),\ + (arr && memcpy(_##arr##_tmp, arr, sizeof(*arr) * _##arr##_count)),\ + (arr && (MEM_freeN(arr),1)),\ + (arr = _##arr##_tmp),\ + _##arr##_count++) -#define BLI_array_free(vec) if (vec) MEM_freeN(vec); +/*appends an item to the array and returns a pointer to the item in the array. + item is not a pointer, but actual data value.*/ +#define BLI_array_append(arr, item) (BLI_array_growone(arr), arr[_##arr##_count] = item, (arr+_##arr##_count)) +/*grow an array by a specified number of items.*/ +#define BLI_array_growitems(arr, num) {int _i; for (_i=0; _i<(num); _i++) {BLI_array_growone(arr);}} +#define BLI_array_free(arr) if (arr) MEM_freeN(arr) + /*resets the logical size of an array to zero, but doesn't free the memory.*/ -#define BLI_array_empty(vec) _##vec##_count=0 +#define BLI_array_empty(arr) _##arr##_count=0 -/*set the count of the array*/ -#define BLI_array_set_length(vec, count) _##vec##_count = (count) +/*set the count of the array, doesn't actually increase the allocated array + size. don't use this unless you know what your doing.*/ +#define BLI_array_set_length(arr, count) _##arr##_count = (count) Modified: branches/bmesh/blender/source/blender/bmesh/bmesh_queries.h =================================================================== --- branches/bmesh/blender/source/blender/bmesh/bmesh_queries.h 2009-10-07 21:19:35 UTC (rev 23696) +++ branches/bmesh/blender/source/blender/bmesh/bmesh_queries.h 2009-10-07 21:19:58 UTC (rev 23697) @@ -13,7 +13,7 @@ /*returns true if v is in f*/ int BM_Vert_In_Face(struct BMFace *f, struct BMVert *v); -// int BM_VERTS_OF_MESH_In_Face(struct BMFace *f, struct BMVert **varr, int len); +// int BM_Verts_In_Face(struct BMFace *f, struct BMVert **varr, int len); int BM_Verts_In_Face(struct BMesh *bm, struct BMFace *f, struct BMVert **varr, int len); int BM_Edge_In_Face(struct BMFace *f, struct BMEdge *e); Modified: branches/bmesh/blender/source/blender/bmesh/intern/bmesh_opdefines.c =================================================================== --- branches/bmesh/blender/source/blender/bmesh/intern/bmesh_opdefines.c 2009-10-07 21:19:35 UTC (rev 23696) +++ branches/bmesh/blender/source/blender/bmesh/intern/bmesh_opdefines.c 2009-10-07 21:19:58 UTC (rev 23697) @@ -154,12 +154,13 @@ }; /* - Edge Split + Edge Bisect Splits input edges (but doesn't do anything else). + This creates a 2-valence vert. */ -BMOpDefine def_edgesplit = { - "edgesplit", +BMOpDefine def_edgebisect = { + "edgebisect", {{BMOP_OPSLOT_ELEMENT_BUF, "edges"}, //input edges {BMOP_OPSLOT_INT, "numcuts"}, //number of cuts {BMOP_OPSLOT_ELEMENT_BUF, "outsplit"}, //newly created vertices and edges @@ -802,6 +803,21 @@ 0 }; +/* + Edge Split + + Disconnects faces along input edges. + */ +BMOpDefine def_edgesplit = { + "edgesplit", + {{BMOP_OPSLOT_ELEMENT_BUF, "edges"}, /* input edges */ + {BMOP_OPSLOT_ELEMENT_BUF, "edgeout1"}, /* old output disconnected edges */ + {BMOP_OPSLOT_ELEMENT_BUF, "edgeout2"}, /* new output disconnected edges */ + {0} /*null-terminating sentinel*/}, + bmesh_edgesplitop_exec, + 0 +}; + BMOpDefine *opdefines[] = { &def_splitop, &def_dupeop, @@ -831,7 +847,7 @@ &def_removedoubles, &def_finddoubles, &def_mirror, - &def_edgesplit, + &def_edgebisect, &def_reversefaces, &def_edgerotate, &def_regionextend, @@ -855,6 +871,7 @@ &def_meshreversecolors, &def_vertexshortestpath, &def_scale, + &def_edgesplit, }; int bmesh_total_ops = (sizeof(opdefines) / sizeof(void*)); Modified: branches/bmesh/blender/source/blender/bmesh/intern/bmesh_operators_private.h =================================================================== --- branches/bmesh/blender/source/blender/bmesh/intern/bmesh_operators_private.h 2009-10-07 21:19:35 UTC (rev 23696) +++ branches/bmesh/blender/source/blender/bmesh/intern/bmesh_operators_private.h 2009-10-07 21:19:58 UTC (rev 23697) @@ -59,4 +59,5 @@ void bmesh_reversecolors_exec(BMesh *bm, BMOperator *op); void bmesh_vertexshortestpath_exec(BMesh *bm, BMOperator *op); void bmesh_scale_exec(BMesh *bm, BMOperator *op); +void bmesh_edgesplitop_exec(BMesh *bm, BMOperator *op); #endif Modified: branches/bmesh/blender/source/blender/bmesh/intern/bmesh_queries.c =================================================================== --- branches/bmesh/blender/source/blender/bmesh/intern/bmesh_queries.c 2009-10-07 21:19:35 UTC (rev 23696) +++ branches/bmesh/blender/source/blender/bmesh/intern/bmesh_queries.c 2009-10-07 21:19:58 UTC (rev 23697) @@ -184,6 +184,9 @@ BMEdge *curedge; int i, len=0; + if (!v1 || !v2 || v1 == v2) + return NULL; + if(v1->edge){ diskbase = bmesh_disk_getpointer(v1->edge,v1); len = bmesh_cycle_length(diskbase); Added: branches/bmesh/blender/source/blender/bmesh/operators/edgesplitop.c =================================================================== --- branches/bmesh/blender/source/blender/bmesh/operators/edgesplitop.c (rev 0) +++ branches/bmesh/blender/source/blender/bmesh/operators/edgesplitop.c 2009-10-07 21:19:58 UTC (rev 23697) @@ -0,0 +1,357 @@ +/** + * $Id: + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. The Blender + * Foundation also sells licenses for use in proprietary software under + * the Blender License. See http://www.blender.org/BL/ for information + * about this. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ Diff output truncated at 10240 characters. @@ _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org http://lists.blender.org/mailman/listinfo/bf-blender-cvs