use BM_Make_Vert example argument rather then calling inline, was also copying vertex normals twice in quite a few places.
This commit is contained in:
@@ -497,10 +497,9 @@ BMesh *BM_Copy_Mesh(BMesh *bmold)
|
||||
|
||||
v = BMIter_New(&iter, bmold, BM_VERTS_OF_MESH, NULL);
|
||||
for (i=0; v; v=BMIter_Step(&iter), i++) {
|
||||
v2 = BM_Make_Vert(bm, v->co, NULL);
|
||||
v2 = BM_Make_Vert(bm, v->co, NULL); /* copy between meshes so cant use 'example' argument */
|
||||
BM_Copy_Attributes(bmold, bm, v, v2);
|
||||
BLI_array_growone(vtable);
|
||||
copy_v3_v3(v2->no, v->no);
|
||||
|
||||
vtable[BLI_array_count(vtable)-1] = v2;
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ BMVert *BM_Make_Vert(BMesh *bm, float co[3], const struct BMVert *example) {
|
||||
|
||||
v->head.type = BM_VERT;
|
||||
|
||||
/* 'v->no' is handled by BM_Copy_Attributes */
|
||||
if (co) copy_v3_v3(v->co, co);
|
||||
|
||||
/*allocate flags*/
|
||||
|
||||
@@ -207,8 +207,8 @@ void bmesh_edgesplitop_exec(BMesh *bm, BMOperator *op)
|
||||
|
||||
BMO_Flag_Buffer(bm, op, "edges", EDGE_SEAM, BM_EDGE);
|
||||
|
||||
/*single marked edges unconnected to any other marked edges
|
||||
are illegal, go through and unmark them*/
|
||||
/* single marked edges unconnected to any other marked edges
|
||||
* are illegal, go through and unmark them */
|
||||
BMO_ITER(e, &siter, bm, op, "edges", BM_EDGE) {
|
||||
for (i=0; i<2; i++) {
|
||||
BM_ITER(e2, &iter, bm, BM_EDGES_OF_VERT, i ? e->v2 : e->v1) {
|
||||
@@ -231,10 +231,10 @@ void bmesh_edgesplitop_exec(BMesh *bm, BMOperator *op)
|
||||
}
|
||||
|
||||
#ifdef ETV
|
||||
#undef ETV
|
||||
# undef ETV
|
||||
#endif
|
||||
#ifdef SETETV
|
||||
#undef SETETV
|
||||
# undef SETETV
|
||||
#endif
|
||||
|
||||
#define ETV(et, v, l) (l->e->v1 == v ? et->newv1 : et->newv2)
|
||||
@@ -271,9 +271,7 @@ void bmesh_edgesplitop_exec(BMesh *bm, BMOperator *op)
|
||||
if (BMO_TestFlag(bm, l2->e, EDGE_SEAM)) {
|
||||
if (!verts[j ? (i+1) % f->len : i]) {
|
||||
/*make unique vert here for this face only*/
|
||||
v2 = BM_Make_Vert(bm, v->co, NULL);
|
||||
copy_v3_v3(v2->no, v->no);
|
||||
BM_Copy_Attributes(bm, bm, v, v2);
|
||||
v2 = BM_Make_Vert(bm, v->co, v);
|
||||
|
||||
verts[j ? (i+1) % f->len : i] = v2;
|
||||
} else v2 = verts[j ? (i+1) % f->len : i];
|
||||
@@ -301,9 +299,7 @@ void bmesh_edgesplitop_exec(BMesh *bm, BMOperator *op)
|
||||
if (l3 == NULL || (BMO_TestFlag(bm, l3->e, EDGE_SEAM) && l3->e != l->e)) {
|
||||
et = etags + BM_GetIndex(l2->e);
|
||||
if (ETV(et, v, l2) == NULL) {
|
||||
v2 = BM_Make_Vert(bm, v->co, NULL);
|
||||
copy_v3_v3(v2->no, v->no);
|
||||
BM_Copy_Attributes(bm, bm, v, v2);
|
||||
v2 = BM_Make_Vert(bm, v->co, v);
|
||||
|
||||
l3 = l2;
|
||||
do {
|
||||
|
||||
@@ -39,8 +39,7 @@ void bmesh_extrude_face_indiv_exec(BMesh *bm, BMOperator *op)
|
||||
BM_ITER(l, &liter, bm, BM_LOOPS_OF_FACE, f) {
|
||||
BLI_array_growone(edges);
|
||||
|
||||
v = BM_Make_Vert(bm, l->v->co, NULL);
|
||||
BM_Copy_Attributes(bm, bm, l->v, v);
|
||||
v = BM_Make_Vert(bm, l->v->co, l->v);
|
||||
|
||||
if (lastv) {
|
||||
e = BM_Make_Edge(bm, lastv, v, l->e, 0);
|
||||
@@ -151,9 +150,7 @@ void extrude_vert_indiv_exec(BMesh *bm, BMOperator *op)
|
||||
|
||||
v = BMO_IterNew(&siter, bm, op, "verts", BM_VERT);
|
||||
for (; v; v=BMO_IterStep(&siter)) {
|
||||
dupev = BM_Make_Vert(bm, v->co, NULL);
|
||||
copy_v3_v3(dupev->no, v->no);
|
||||
BM_Copy_Attributes(bm, bm, v, dupev);
|
||||
dupev = BM_Make_Vert(bm, v->co, v);
|
||||
|
||||
e = BM_Make_Edge(bm, v, dupev, NULL, 0);
|
||||
|
||||
|
||||
@@ -2709,7 +2709,7 @@ static int mesh_rip_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
||||
BMEdge *e, *e2, *closest = NULL;
|
||||
BMVert *v;
|
||||
int side = 0, i, singlesel = 0;
|
||||
float projectMat[4][4], fmval[3] = {event->mval[0], event->mval[1], 0.0f};
|
||||
float projectMat[4][4], fmval[3] = {event->mval[0], event->mval[1]};
|
||||
float dist = FLT_MAX, d;
|
||||
|
||||
ED_view3d_ob_project_mat_get(rv3d, obedit, projectMat);
|
||||
@@ -2803,34 +2803,31 @@ static int mesh_rip_invoke(bContext *C, wmOperator *op, wmEvent *event)
|
||||
|
||||
for (i=0; i<2; i++) {
|
||||
BMO_ITER(e, &siter, em->bm, &bmop, i ? "edgeout2":"edgeout1", BM_EDGE) {
|
||||
float cent[3] = {0, 0, 0}, mid[4], vec[3];
|
||||
float cent[3] = {0, 0, 0}, mid[3], vec[3];
|
||||
|
||||
if (!BMBVH_EdgeVisible(bvhtree, e, ar, v3d, obedit) || !e->l)
|
||||
continue;
|
||||
|
||||
/*method for calculating distance:
|
||||
|
||||
for each edge: calculate face center, then made a vector
|
||||
from edge midpoint to face center. offset edge midpoint
|
||||
by a small amount along this vector.*/
|
||||
/* method for calculating distance:
|
||||
*
|
||||
* for each edge: calculate face center, then made a vector
|
||||
* from edge midpoint to face center. offset edge midpoint
|
||||
* by a small amount along this vector. */
|
||||
BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, e->l->f) {
|
||||
add_v3_v3v3(cent, cent, l->v->co);
|
||||
add_v3_v3(cent, l->v->co);
|
||||
}
|
||||
mul_v3_fl(cent, 1.0f/(float)e->l->f->len);
|
||||
|
||||
add_v3_v3v3(mid, e->v1->co, e->v2->co);
|
||||
mul_v3_fl(mid, 0.5f);
|
||||
mid_v3_v3v3(mid, e->v1->co, e->v2->co);
|
||||
sub_v3_v3v3(vec, cent, mid);
|
||||
normalize_v3(vec);
|
||||
mul_v3_fl(vec, 0.01f);
|
||||
add_v3_v3v3(mid, mid, vec);
|
||||
|
||||
/*yay we have our comparison point, now project it*/
|
||||
/* yay we have our comparison point, now project it */
|
||||
ED_view3d_project_float(ar, mid, mid, projectMat);
|
||||
|
||||
vec[0] = fmval[0] - mid[0];
|
||||
vec[1] = fmval[1] - mid[1];
|
||||
d = vec[0]*vec[0] + vec[1]*vec[1];
|
||||
d = len_squared_v2v2(fmval, mid);
|
||||
|
||||
if (d < dist) {
|
||||
side = i;
|
||||
|
||||
@@ -1373,6 +1373,7 @@ static void knifenet_fill_faces(knifetool_opdata *kcd)
|
||||
BLI_mempool_iternew(kcd->kverts, &iter);
|
||||
for (kfv=BLI_mempool_iterstep(&iter); kfv; kfv=BLI_mempool_iterstep(&iter)) {
|
||||
if (!kfv->v) {
|
||||
/* shouldn't we be at least copying the normal? - if not some comment here should explain why - campbell */
|
||||
kfv->v = BM_Make_Vert(bm, kfv->co, NULL);
|
||||
kfv->flag = 1;
|
||||
BMO_SetFlag(bm, kfv->v, DEL);
|
||||
|
||||
Reference in New Issue
Block a user