style cleanup: editors/mesh - mostly whitespace around operators

This commit is contained in:
Campbell Barton
2012-03-26 02:56:48 +00:00
parent 44010fb659
commit 48f0444760
12 changed files with 1088 additions and 1079 deletions

View File

@@ -27,8 +27,6 @@
* \ingroup edmesh
*/
#include <math.h>
#include <string.h>
@@ -77,7 +75,7 @@ void paintface_flush_flags(Object *ob)
int totface, totpoly;
int i;
if (me==NULL || dm==NULL)
if (me == NULL || dm == NULL)
return;
/*
@@ -92,7 +90,7 @@ void paintface_flush_flags(Object *ob)
totface = me->totface;
/* loop over tessfaces */
for (i= 0; i<totface; i++) {
for (i = 0; i < totface; i++) {
/* Copy flags onto the original tessface from its original poly */
mp_orig = me->mpoly + index_array[i];
faces[i].flag = mp_orig->flag;
@@ -104,7 +102,7 @@ void paintface_flush_flags(Object *ob)
totpoly = dm->getNumPolys(dm);
/* loop over final derived polys */
for (i= 0; i<totpoly; i++) {
for (i = 0; i < totpoly; i++) {
/* Copy flags onto the final derived poly from the original mesh poly */
mp_orig = me->mpoly + index_array[i];
polys[i].flag = mp_orig->flag;
@@ -117,7 +115,7 @@ void paintface_flush_flags(Object *ob)
totface = dm->getNumTessFaces(dm);
/* loop over tessfaces */
for (i= 0; i<totface; i++) {
for (i = 0; i < totface; i++) {
/* Copy flags onto the final tessface from its final poly */
mp_orig = polys + index_array[i];
faces[i].flag = mp_orig->flag;
@@ -132,29 +130,29 @@ static int facesel_face_pick(struct bContext *C, Mesh *me, Object *ob, const int
ViewContext vc;
view3d_set_viewcontext(C, &vc);
if (!me || me->totpoly==0)
if (!me || me->totpoly == 0)
return 0;
makeDerivedMesh(scene, ob, NULL, CD_MASK_BAREMESH, 0);
// XXX if (v3d->flag & V3D_INVALID_BACKBUF) {
// XXX if (v3d->flag & V3D_INVALID_BACKBUF) {
// XXX drawview.c! check_backbuf();
// XXX persp(PERSP_VIEW);
// XXX }
// XXX }
if (rect) {
/* sample rect to increase changes of selecting, so that when clicking
* on an edge in the backbuf, we can still select a face */
int dist;
*index = view3d_sample_backbuf_rect(&vc, mval, 3, 1, me->totpoly+1, &dist,0,NULL, NULL);
*index = view3d_sample_backbuf_rect(&vc, mval, 3, 1, me->totpoly + 1, &dist, 0, NULL, NULL);
}
else {
/* sample only on the exact position */
*index = view3d_sample_backbuf(&vc, mval[0], mval[1]);
}
if ((*index)<=0 || (*index)>(unsigned int)me->totpoly)
if ((*index) <= 0 || (*index) > (unsigned int)me->totpoly)
return 0;
(*index)--;
@@ -168,15 +166,15 @@ void paintface_hide(Object *ob, const int unselected)
MPoly *mface;
int a;
me= get_mesh(ob);
if (me==NULL || me->totpoly==0) return;
me = get_mesh(ob);
if (me == NULL || me->totpoly == 0) return;
mface= me->mpoly;
a= me->totpoly;
mface = me->mpoly;
a = me->totpoly;
while (a--) {
if ((mface->flag & ME_HIDE) == 0) {
if (unselected) {
if ( (mface->flag & ME_FACE_SEL)==0) mface->flag |= ME_HIDE;
if ( (mface->flag & ME_FACE_SEL) == 0) mface->flag |= ME_HIDE;
}
else {
if ( (mface->flag & ME_FACE_SEL)) mface->flag |= ME_HIDE;
@@ -197,11 +195,11 @@ void paintface_reveal(Object *ob)
MPoly *mface;
int a;
me= get_mesh(ob);
if (me==NULL || me->totpoly==0) return;
me = get_mesh(ob);
if (me == NULL || me->totpoly == 0) return;
mface= me->mpoly;
a= me->totpoly;
mface = me->mpoly;
a = me->totpoly;
while (a--) {
if (mface->flag & ME_HIDE) {
mface->flag |= ME_FACE_SEL;
@@ -220,7 +218,7 @@ static void hash_add_face(EdgeHash *ehash, MPoly *mp, MLoop *mloop)
MLoop *ml;
int i;
for (i=0, ml=mloop; i<mp->totloop; i++, ml++) {
for (i = 0, ml = mloop; i < mp->totloop; i++, ml++) {
BLI_edgehash_insert(ehash, ml->v, ME_POLY_LOOP_NEXT(mloop, mp, i)->v, NULL);
}
}
@@ -233,59 +231,59 @@ static void select_linked_tfaces_with_seams(int mode, Mesh *me, unsigned int ind
MLoop *ml;
MEdge *med;
char *linkflag;
int a, b, doit=1, mark=0;
int a, b, doit = 1, mark = 0;
ehash= BLI_edgehash_new();
ehash = BLI_edgehash_new();
seamhash = BLI_edgehash_new();
linkflag= MEM_callocN(sizeof(char)*me->totpoly, "linkflaguv");
linkflag = MEM_callocN(sizeof(char) * me->totpoly, "linkflaguv");
for (med=me->medge, a=0; a < me->totedge; a++, med++)
for (med = me->medge, a = 0; a < me->totedge; a++, med++)
if (med->flag & ME_SEAM)
BLI_edgehash_insert(seamhash, med->v1, med->v2, NULL);
if (mode==0 || mode==1) {
if (mode == 0 || mode == 1) {
/* only put face under cursor in array */
mf= ((MPoly*)me->mpoly) + index;
mf = ((MPoly *)me->mpoly) + index;
hash_add_face(ehash, mf, me->mloop + mf->loopstart);
linkflag[index]= 1;
linkflag[index] = 1;
}
else {
/* fill array by selection */
mf= me->mpoly;
for (a=0; a<me->totpoly; a++, mf++) {
if (mf->flag & ME_HIDE);
mf = me->mpoly;
for (a = 0; a < me->totpoly; a++, mf++) {
if (mf->flag & ME_HIDE) ;
else if (mf->flag & ME_FACE_SEL) {
hash_add_face(ehash, mf, me->mloop + mf->loopstart);
linkflag[a]= 1;
linkflag[a] = 1;
}
}
}
while (doit) {
doit= 0;
doit = 0;
/* expand selection */
mf= me->mpoly;
for (a=0; a<me->totpoly; a++, mf++) {
mf = me->mpoly;
for (a = 0; a < me->totpoly; a++, mf++) {
if (mf->flag & ME_HIDE)
continue;
if (!linkflag[a]) {
MLoop *mnextl;
mark= 0;
mark = 0;
ml = me->mloop + mf->loopstart;
for (b=0; b<mf->totloop; b++, ml++) {
mnextl = b < mf->totloop-1 ? ml - 1 : me->mloop + mf->loopstart;
for (b = 0; b < mf->totloop; b++, ml++) {
mnextl = b < mf->totloop - 1 ? ml - 1 : me->mloop + mf->loopstart;
if (!BLI_edgehash_haskey(seamhash, ml->v, mnextl->v))
if (!BLI_edgehash_haskey(ehash, ml->v, mnextl->v))
mark = 1;
}
if (mark) {
linkflag[a]= 1;
linkflag[a] = 1;
hash_add_face(ehash, mf, me->mloop + mf->loopstart);
doit= 1;
doit = 1;
}
}
}
@@ -295,25 +293,25 @@ static void select_linked_tfaces_with_seams(int mode, Mesh *me, unsigned int ind
BLI_edgehash_free(ehash, NULL);
BLI_edgehash_free(seamhash, NULL);
if (mode==0 || mode==2) {
for (a=0, mf=me->mpoly; a<me->totpoly; a++, mf++)
if (mode == 0 || mode == 2) {
for (a = 0, mf = me->mpoly; a < me->totpoly; a++, mf++)
if (linkflag[a])
mf->flag |= ME_FACE_SEL;
else
mf->flag &= ~ME_FACE_SEL;
}
else if (mode==1) {
for (a=0, mf=me->mpoly; a<me->totpoly; a++, mf++)
else if (mode == 1) {
for (a = 0, mf = me->mpoly; a < me->totpoly; a++, mf++)
if (linkflag[a] && (mf->flag & ME_FACE_SEL))
break;
if (a<me->totpoly) {
for (a=0, mf=me->mpoly; a<me->totpoly; a++, mf++)
if (a < me->totpoly) {
for (a = 0, mf = me->mpoly; a < me->totpoly; a++, mf++)
if (linkflag[a])
mf->flag &= ~ME_FACE_SEL;
}
else {
for (a=0, mf=me->mpoly; a<me->totpoly; a++, mf++)
for (a = 0, mf = me->mpoly; a < me->totpoly; a++, mf++)
if (linkflag[a])
mf->flag |= ME_FACE_SEL;
}
@@ -325,12 +323,12 @@ static void select_linked_tfaces_with_seams(int mode, Mesh *me, unsigned int ind
void paintface_select_linked(bContext *UNUSED(C), Object *ob, int UNUSED(mval[2]), int mode)
{
Mesh *me;
unsigned int index=0;
unsigned int index = 0;
me = get_mesh(ob);
if (me==NULL || me->totpoly==0) return;
if (me == NULL || me->totpoly == 0) return;
if (mode==0 || mode==1) {
if (mode == 0 || mode == 1) {
// XXX - Causes glitches, not sure why
#if 0
if (!facesel_face_pick(C, me, mval, &index, 1))
@@ -349,12 +347,12 @@ void paintface_deselect_all_visible(Object *ob, int action, short flush_flags)
MPoly *mface;
int a;
me= get_mesh(ob);
if (me==NULL) return;
me = get_mesh(ob);
if (me == NULL) return;
if (action == SEL_INVERT) {
mface= me->mpoly;
a= me->totpoly;
mface = me->mpoly;
a = me->totpoly;
while (a--) {
if ((mface->flag & ME_HIDE) == 0) {
mface->flag ^= ME_FACE_SEL;
@@ -366,8 +364,8 @@ void paintface_deselect_all_visible(Object *ob, int action, short flush_flags)
if (action == SEL_TOGGLE) {
action = SEL_SELECT;
mface= me->mpoly;
a= me->totpoly;
mface = me->mpoly;
a = me->totpoly;
while (a--) {
if ((mface->flag & ME_HIDE) == 0 && mface->flag & ME_FACE_SEL) {
action = SEL_DESELECT;
@@ -377,20 +375,20 @@ void paintface_deselect_all_visible(Object *ob, int action, short flush_flags)
}
}
mface= me->mpoly;
a= me->totpoly;
mface = me->mpoly;
a = me->totpoly;
while (a--) {
if ((mface->flag & ME_HIDE) == 0) {
switch (action) {
case SEL_SELECT:
mface->flag |= ME_FACE_SEL;
break;
case SEL_DESELECT:
mface->flag &= ~ME_FACE_SEL;
break;
case SEL_INVERT:
mface->flag ^= ME_FACE_SEL;
break;
case SEL_SELECT:
mface->flag |= ME_FACE_SEL;
break;
case SEL_DESELECT:
mface->flag &= ~ME_FACE_SEL;
break;
case SEL_INVERT:
mface->flag ^= ME_FACE_SEL;
break;
}
}
mface++;
@@ -409,30 +407,30 @@ int paintface_minmax(Object *ob, float *min, float *max)
MTexPoly *tf;
MLoop *ml;
MVert *mvert;
int a, b, ok=0;
int a, b, ok = 0;
float vec[3], bmat[3][3];
me= get_mesh(ob);
me = get_mesh(ob);
if (!me || !me->mtpoly) return ok;
copy_m3_m4(bmat, ob->obmat);
mvert= me->mvert;
mf= me->mpoly;
tf= me->mtpoly;
for (a=me->totpoly; a>0; a--, mf++, tf++) {
mvert = me->mvert;
mf = me->mpoly;
tf = me->mtpoly;
for (a = me->totpoly; a > 0; a--, mf++, tf++) {
if (mf->flag & ME_HIDE || !(mf->flag & ME_FACE_SEL))
continue;
ml = me->mloop + mf->totloop;
for (b=0; b<mf->totloop; b++, ml++) {
for (b = 0; b < mf->totloop; b++, ml++) {
copy_v3_v3(vec, (mvert[ml->v].co));
mul_m3_v3(bmat, vec);
add_v3_v3v3(vec, vec, ob->obmat[3]);
DO_MINMAX(vec, min, max);
}
ok= 1;
ok = 1;
}
return ok;
@@ -445,9 +443,9 @@ static void seam_edgehash_insert_face(EdgeHash *ehash, MPoly *mf, MLoop *loopsta
MLoop *ml1, *ml2;
int a;
for (a=0; a<mf->totloop; a++) {
for (a = 0; a < mf->totloop; a++) {
ml1 = loopstart + a;
ml2 = loopstart + (a+1) % mf->totloop;
ml2 = loopstart + (a + 1) % mf->totloop;
BLI_edgehash_insert(ehash, ml1->v, ml2->v, NULL);
}
@@ -461,8 +459,8 @@ void seam_mark_clear_tface(Scene *scene, short mode)
MEdge *med;
int a, b;
me= get_mesh(OBACT);
if (me==0 || me->totpoly==0) return;
me = get_mesh(OBACT);
if (me == 0 || me->totpoly == 0) return;
if (mode == 0)
mode = pupmenu("Seams%t|Mark Border Seam %x1|Clear Seam %x2");
@@ -473,11 +471,11 @@ void seam_mark_clear_tface(Scene *scene, short mode)
if (mode == 2) {
EdgeHash *ehash = BLI_edgehash_new();
for (a=0, mf=me->mpoly; a<me->totpoly; a++, mf++)
for (a = 0, mf = me->mpoly; a < me->totpoly; a++, mf++)
if (!(mf->flag & ME_HIDE) && (mf->flag & ME_FACE_SEL))
seam_edgehash_insert_face(ehash, mf, me->mloop + mf->loopstart);
for (a=0, med=me->medge; a<me->totedge; a++, med++)
for (a = 0, med = me->medge; a < me->totedge; a++, med++)
if (BLI_edgehash_haskey(ehash, med->v1, med->v2))
med->flag &= ~ME_SEAM;
@@ -488,16 +486,16 @@ void seam_mark_clear_tface(Scene *scene, short mode)
EdgeHash *ehash1 = BLI_edgehash_new();
EdgeHash *ehash2 = BLI_edgehash_new();
for (a=0, mf=me->mpoly; a<me->totpoly; a++, mf++) {
for (a = 0, mf = me->mpoly; a < me->totpoly; a++, mf++) {
if ((mf->flag & ME_HIDE) || !(mf->flag & ME_FACE_SEL))
seam_edgehash_insert_face(ehash1, mf, me->mloop + mf->loopstart);
else
seam_edgehash_insert_face(ehash2, mf, me->mloop + mf->loopstart);
}
for (a=0, med=me->medge; a<me->totedge; a++, med++)
for (a = 0, med = me->medge; a < me->totedge; a++, med++)
if (BLI_edgehash_haskey(ehash1, med->v1, med->v2) &&
BLI_edgehash_haskey(ehash2, med->v1, med->v2))
BLI_edgehash_haskey(ehash2, med->v1, med->v2))
med->flag |= ME_SEAM;
BLI_edgehash_free(ehash1, NULL);
@@ -526,7 +524,7 @@ int paintface_mouse_select(struct bContext *C, Object *ob, const int mval[2], in
if (index >= me->totpoly || index < 0)
return 0;
msel= me->mpoly + index;
msel = me->mpoly + index;
if (msel->flag & ME_HIDE) return 0;
/* clear flags */
@@ -552,7 +550,7 @@ int paintface_mouse_select(struct bContext *C, Object *ob, const int mval[2], in
/* image window redraw */
paintface_flush_flags(ob);
WM_event_add_notifier(C, NC_GEOM|ND_SELECT, ob->data);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, ob->data);
ED_region_tag_redraw(CTX_wm_region(C)); // XXX - should redraw all 3D views
return 1;
}
@@ -566,21 +564,21 @@ int do_paintface_box_select(ViewContext *vc, rcti *rect, int select, int extend)
unsigned int *rt;
char *selar;
int a, index;
int sx= rect->xmax-rect->xmin+1;
int sy= rect->ymax-rect->ymin+1;
int sx = rect->xmax - rect->xmin + 1;
int sy = rect->ymax - rect->ymin + 1;
me= get_mesh(ob);
me = get_mesh(ob);
if (me==NULL || me->totpoly==0 || sx*sy <= 0)
if (me == NULL || me->totpoly == 0 || sx * sy <= 0)
return OPERATOR_CANCELLED;
selar= MEM_callocN(me->totpoly+1, "selar");
selar = MEM_callocN(me->totpoly + 1, "selar");
if (extend == 0 && select) {
paintface_deselect_all_visible(vc->obact, SEL_DESELECT, FALSE);
mface= me->mpoly;
for (a=1; a<=me->totpoly; a++, mface++) {
mface = me->mpoly;
for (a = 1; a <= me->totpoly; a++, mface++) {
if ((mface->flag & ME_HIDE) == 0)
mface->flag &= ~ME_FACE_SEL;
}
@@ -588,24 +586,24 @@ int do_paintface_box_select(ViewContext *vc, rcti *rect, int select, int extend)
view3d_validate_backbuf(vc);
ibuf = IMB_allocImBuf(sx,sy,32,IB_rect);
ibuf = IMB_allocImBuf(sx, sy, 32, IB_rect);
rt = ibuf->rect;
glReadPixels(rect->xmin+vc->ar->winrct.xmin, rect->ymin+vc->ar->winrct.ymin, sx, sy, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect);
if (ENDIAN_ORDER==B_ENDIAN) IMB_convert_rgba_to_abgr(ibuf);
glReadPixels(rect->xmin + vc->ar->winrct.xmin, rect->ymin + vc->ar->winrct.ymin, sx, sy, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect);
if (ENDIAN_ORDER == B_ENDIAN) IMB_convert_rgba_to_abgr(ibuf);
a= sx*sy;
a = sx * sy;
while (a--) {
if (*rt) {
index= WM_framebuffer_to_index(*rt);
if (index<=me->totpoly) selar[index]= 1;
index = WM_framebuffer_to_index(*rt);
if (index <= me->totpoly) selar[index] = 1;
}
rt++;
}
mface= me->mpoly;
for (a=1; a<=me->totpoly; a++, mface++) {
mface = me->mpoly;
for (a = 1; a <= me->totpoly; a++, mface++) {
if (selar[a]) {
if (mface->flag & ME_HIDE);
if (mface->flag & ME_HIDE) ;
else {
if (select) mface->flag |= ME_FACE_SEL;
else mface->flag &= ~ME_FACE_SEL;
@@ -631,14 +629,14 @@ int do_paintface_box_select(ViewContext *vc, rcti *rect, int select, int extend)
* use in object mode when selecting vertices (while painting) */
void paintvert_flush_flags(Object *ob)
{
Mesh *me= get_mesh(ob);
DerivedMesh *dm= ob->derivedFinal;
Mesh *me = get_mesh(ob);
DerivedMesh *dm = ob->derivedFinal;
MVert *dm_mvert, *dm_mv;
int *index_array = NULL;
int totvert;
int i;
if (me==NULL || dm==NULL)
if (me == NULL || dm == NULL)
return;
index_array = dm->getVertDataArray(dm, CD_ORIGINDEX);
@@ -646,20 +644,20 @@ void paintvert_flush_flags(Object *ob)
dm_mvert = dm->getVertArray(dm);
totvert = dm->getNumVerts(dm);
dm_mv= dm_mvert;
dm_mv = dm_mvert;
if (index_array) {
int orig_index;
for (i= 0; i<totvert; i++, dm_mv++) {
orig_index= index_array[i];
for (i = 0; i < totvert; i++, dm_mv++) {
orig_index = index_array[i];
if (orig_index != ORIGINDEX_NONE) {
dm_mv->flag= me->mvert[index_array[i]].flag;
dm_mv->flag = me->mvert[index_array[i]].flag;
}
}
}
else {
for (i= 0; i<totvert; i++, dm_mv++) {
dm_mv->flag= me->mvert[i].flag;
for (i = 0; i < totvert; i++, dm_mv++) {
dm_mv->flag = me->mvert[i].flag;
}
}
}
@@ -670,12 +668,12 @@ void paintvert_deselect_all_visible(Object *ob, int action, short flush_flags)
MVert *mvert;
int a;
me= get_mesh(ob);
if (me==NULL) return;
me = get_mesh(ob);
if (me == NULL) return;
if (action == SEL_INVERT) {
mvert= me->mvert;
a= me->totvert;
mvert = me->mvert;
a = me->totvert;
while (a--) {
if ((mvert->flag & ME_HIDE) == 0) {
mvert->flag ^= SELECT;
@@ -687,8 +685,8 @@ void paintvert_deselect_all_visible(Object *ob, int action, short flush_flags)
if (action == SEL_TOGGLE) {
action = SEL_SELECT;
mvert= me->mvert;
a= me->totvert;
mvert = me->mvert;
a = me->totvert;
while (a--) {
if ((mvert->flag & ME_HIDE) == 0 && mvert->flag & SELECT) {
action = SEL_DESELECT;
@@ -698,20 +696,20 @@ void paintvert_deselect_all_visible(Object *ob, int action, short flush_flags)
}
}
mvert= me->mvert;
a= me->totvert;
mvert = me->mvert;
a = me->totvert;
while (a--) {
if ((mvert->flag & ME_HIDE) == 0) {
switch (action) {
case SEL_SELECT:
mvert->flag |= SELECT;
break;
case SEL_DESELECT:
mvert->flag &= ~SELECT;
break;
case SEL_INVERT:
mvert->flag ^= SELECT;
break;
case SEL_SELECT:
mvert->flag |= SELECT;
break;
case SEL_DESELECT:
mvert->flag &= ~SELECT;
break;
case SEL_INVERT:
mvert->flag ^= SELECT;
break;
}
}
mvert++;
@@ -731,21 +729,21 @@ void paintvert_deselect_all_visible(Object *ob, int action, short flush_flags)
typedef int MirrTopoHash_t;
typedef struct MirrTopoVert_t {
MirrTopoHash_t hash;
int v_index;
MirrTopoHash_t hash;
int v_index;
} MirrTopoVert_t;
static int mirrtopo_hash_sort(const void *l1, const void *l2)
{
if ((MirrTopoHash_t)(intptr_t)l1 > (MirrTopoHash_t)(intptr_t)l2 ) return 1;
else if ((MirrTopoHash_t)(intptr_t)l1 < (MirrTopoHash_t)(intptr_t)l2 ) return -1;
if ((MirrTopoHash_t)(intptr_t)l1 > (MirrTopoHash_t)(intptr_t)l2) return 1;
else if ((MirrTopoHash_t)(intptr_t)l1 < (MirrTopoHash_t)(intptr_t)l2) return -1;
return 0;
}
static int mirrtopo_vert_sort(const void *v1, const void *v2)
{
if (((MirrTopoVert_t *)v1)->hash > ((MirrTopoVert_t *)v2)->hash ) return 1;
else if (((MirrTopoVert_t *)v1)->hash < ((MirrTopoVert_t *)v2)->hash ) return -1;
if (((MirrTopoVert_t *)v1)->hash > ((MirrTopoVert_t *)v2)->hash) return 1;
else if (((MirrTopoVert_t *)v1)->hash < ((MirrTopoVert_t *)v2)->hash) return -1;
return 0;
}
@@ -763,10 +761,10 @@ int ED_mesh_mirrtopo_recalc_check(Mesh *me, const int ob_mode, MirrTopoStore_t *
totedge = me->totedge;
}
if ( (mesh_topo_store->index_lookup==NULL) ||
(mesh_topo_store->prev_ob_mode != ob_mode) ||
(totvert != mesh_topo_store->prev_vert_tot) ||
(totedge != mesh_topo_store->prev_edge_tot))
if ((mesh_topo_store->index_lookup == NULL) ||
(mesh_topo_store->prev_ob_mode != ob_mode) ||
(totvert != mesh_topo_store->prev_vert_tot) ||
(totedge != mesh_topo_store->prev_edge_tot))
{
return TRUE;
}
@@ -824,7 +822,7 @@ void ED_mesh_mirrtopo_init(Mesh *me, const int ob_mode, MirrTopoStore_t *mesh_to
else {
totedge = me->totedge;
for (a=0, medge=me->medge; a < me->totedge; a++, medge++) {
for (a = 0, medge = me->medge; a < me->totedge; a++, medge++) {
topo_hash[medge->v1]++;
topo_hash[medge->v2]++;
}
@@ -843,7 +841,7 @@ void ED_mesh_mirrtopo_init(Mesh *me, const int ob_mode, MirrTopoStore_t *mesh_to
}
}
else {
for (a=0, medge=me->medge; a<me->totedge; a++, medge++) {
for (a = 0, medge = me->medge; a < me->totedge; a++, medge++) {
/* This can make really big numbers, wrapping around here is fine */
topo_hash[medge->v1] += topo_hash_prev[medge->v2];
topo_hash[medge->v2] += topo_hash_prev[medge->v1];
@@ -855,8 +853,8 @@ void ED_mesh_mirrtopo_init(Mesh *me, const int ob_mode, MirrTopoStore_t *mesh_to
qsort(topo_hash_prev, totvert, sizeof(MirrTopoHash_t), mirrtopo_hash_sort);
tot_unique = 1; /* account for skiping the first value */
for (a=1; a<totvert; a++) {
if (topo_hash_prev[a-1] != topo_hash_prev[a]) {
for (a = 1; a < totvert; a++) {
if (topo_hash_prev[a - 1] != topo_hash_prev[a]) {
tot_unique++;
}
}
@@ -874,19 +872,19 @@ void ED_mesh_mirrtopo_init(Mesh *me, const int ob_mode, MirrTopoStore_t *mesh_to
}
/* Hash/Index pairs are needed for sorting to find index pairs */
topo_pairs = MEM_callocN( sizeof(MirrTopoVert_t) * totvert, "MirrTopoPairs");
topo_pairs = MEM_callocN(sizeof(MirrTopoVert_t) * totvert, "MirrTopoPairs");
/* since we are looping through verts, initialize these values here too */
index_lookup = MEM_mallocN(totvert * sizeof(*index_lookup), "mesh_topo_lookup");
if (em) {
if (skip_em_vert_array_init == FALSE) {
EDBM_init_index_arrays(em,1, 0, 0);
EDBM_init_index_arrays(em, 1, 0, 0);
}
}
for (a=0; a<totvert; a++) {
for (a = 0; a < totvert; a++) {
topo_pairs[a].hash = topo_hash[a];
topo_pairs[a].v_index = a;
@@ -901,17 +899,17 @@ void ED_mesh_mirrtopo_init(Mesh *me, const int ob_mode, MirrTopoStore_t *mesh_to
/* Get the pairs out of the sorted hashes, note, totvert+1 means we can use the previous 2,
* but you cant ever access the last 'a' index of MirrTopoPairs */
for (a=2; a <= totvert; a++) {
for (a = 2; a <= totvert; a++) {
/* printf("I %d %ld %d\n", (a-last), MirrTopoPairs[a ].hash, MirrTopoPairs[a ].v_index ); */
if ((a==totvert) || (topo_pairs[a-1].hash != topo_pairs[a].hash)) {
if (a-last==2) {
if ((a == totvert) || (topo_pairs[a - 1].hash != topo_pairs[a].hash)) {
if (a - last == 2) {
if (em) {
index_lookup[topo_pairs[a-1].v_index] = (intptr_t)EDBM_get_vert_for_index(em, topo_pairs[a-2].v_index);
index_lookup[topo_pairs[a-2].v_index] = (intptr_t)EDBM_get_vert_for_index(em, topo_pairs[a-1].v_index);
index_lookup[topo_pairs[a - 1].v_index] = (intptr_t)EDBM_get_vert_for_index(em, topo_pairs[a - 2].v_index);
index_lookup[topo_pairs[a - 2].v_index] = (intptr_t)EDBM_get_vert_for_index(em, topo_pairs[a - 1].v_index);
}
else {
index_lookup[topo_pairs[a-1].v_index] = topo_pairs[a-2].v_index;
index_lookup[topo_pairs[a-2].v_index] = topo_pairs[a-1].v_index;
index_lookup[topo_pairs[a - 1].v_index] = topo_pairs[a - 2].v_index;
index_lookup[topo_pairs[a - 2].v_index] = topo_pairs[a - 1].v_index;
}
}
last = a;

View File

@@ -95,7 +95,7 @@ static void make_prim_init(bContext *C, const char *idname,
rename_id((ID *)obedit->data, idname);
/* create editmode */
ED_object_enter_editmode(C, EM_DO_UNDO|EM_IGNORE_LAYER); /* rare cases the active layer is messed up */
ED_object_enter_editmode(C, EM_DO_UNDO | EM_IGNORE_LAYER); /* rare cases the active layer is messed up */
*state = 1;
}
else {
@@ -120,13 +120,13 @@ static void make_prim_finish(bContext *C, int *state, int enter_editmode)
EDBM_selectmode_flush_ex(em, SCE_SELECT_VERTEX);
DAG_id_tag_update(obedit->data, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
/* userdef */
if (*state && !enter_editmode) {
ED_object_exit_editmode(C, EM_FREEDATA); /* adding EM_DO_UNDO messes up operator redo */
}
WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, obedit);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, obedit);
}
static int add_primitive_plane_exec(bContext *C, wmOperator *op)
@@ -170,7 +170,7 @@ void MESH_OT_primitive_plane_add(wmOperatorType *ot)
ot->poll = ED_operator_scene_editable;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
ED_object_add_generic_props(ot, TRUE);
}
@@ -215,12 +215,12 @@ void MESH_OT_primitive_cube_add(wmOperatorType *ot)
ot->poll = ED_operator_scene_editable;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
ED_object_add_generic_props(ot, TRUE);
}
static const EnumPropertyItem fill_type_items[]= {
static const EnumPropertyItem fill_type_items[] = {
{0, "NOTHING", 0, "Nothing", "Don't fill at all"},
{1, "NGON", 0, "Ngon", "Use ngons"},
{2, "TRIFAN", 0, "Triangle Fan", "Use triangle fans"},
@@ -274,7 +274,7 @@ void MESH_OT_primitive_circle_add(wmOperatorType *ot)
ot->poll = ED_operator_scene_editable;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* props */
RNA_def_int(ot->srna, "vertices", 32, 3, INT_MAX, "Vertices", "", 3, 500);
@@ -337,7 +337,7 @@ void MESH_OT_primitive_cylinder_add(wmOperatorType *ot)
ot->poll = ED_operator_scene_editable;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* props */
RNA_def_int(ot->srna, "vertices", 32, 2, INT_MAX, "Vertices", "", 2, 500);
@@ -399,7 +399,7 @@ void MESH_OT_primitive_cone_add(wmOperatorType *ot)
ot->poll = ED_operator_scene_editable;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* props */
RNA_def_int(ot->srna, "vertices", 32, 2, INT_MAX, "Vertices", "", 2, 500);
@@ -459,7 +459,7 @@ void MESH_OT_primitive_grid_add(wmOperatorType *ot)
ot->poll = ED_operator_scene_editable;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* props */
RNA_def_int(ot->srna, "x_subdivisions", 10, 3, INT_MAX, "X Subdivisions", "", 3, 1000);
@@ -511,7 +511,7 @@ void MESH_OT_primitive_monkey_add(wmOperatorType *ot)
ot->poll = ED_operator_scene_editable;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
ED_object_add_generic_props(ot, TRUE);
}
@@ -561,7 +561,7 @@ void MESH_OT_primitive_uv_sphere_add(wmOperatorType *ot)
ot->poll = ED_operator_scene_editable;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* props */
RNA_def_int(ot->srna, "segments", 32, 3, INT_MAX, "Segments", "", 3, 500);
@@ -618,7 +618,7 @@ void MESH_OT_primitive_ico_sphere_add(wmOperatorType *ot)
ot->poll = ED_operator_scene_editable;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* props */
RNA_def_int(ot->srna, "subdivisions", 2, 1, INT_MAX, "Subdivisions", "", 1, 8);

View File

@@ -70,7 +70,7 @@ typedef struct BMBVHTree {
} BMBVHTree;
static void cage_mapped_verts_callback(void *userData, int index, float *co,
float *UNUSED(no_f), short *UNUSED(no_s))
float *UNUSED(no_f), short *UNUSED(no_s))
{
void **data = userData;
BMEditMesh *em = data[0];
@@ -166,7 +166,7 @@ void BMBVH_FreeBVH(BMBVHTree *tree)
/* taken from bvhutils.c */
static float ray_tri_intersection(const BVHTreeRay *ray, const float UNUSED(m_dist), float *v0,
float *v1, float *v2, float *uv, float UNUSED(e))
float *v1, float *v2, float *uv, float UNUSED(e))
{
float dist;

View File

@@ -65,7 +65,7 @@
/* this code here is kindof messy. . .I might need to eventually rework it - joeedh */
#define KMAXDIST 10 /* max mouse distance from edge before not detecting it */
#define KMAXDIST 10 /* max mouse distance from edge before not detecting it */
/* knifetool operator */
typedef struct KnifeVert {
@@ -118,8 +118,8 @@ typedef struct KnifePosData {
/* struct for properties used while drawing */
typedef struct knifetool_opdata {
ARegion *ar; /* region that knifetool was activated in */
void *draw_handle; /* for drawing preview loop */
ARegion *ar; /* region that knifetool was activated in */
void *draw_handle; /* for drawing preview loop */
ViewContext vc;
bContext *C;
@@ -1013,7 +1013,7 @@ static BMEdgeHit *knife_edge_tri_isect(knifetool_opdata *kcd, BMBVHTree *bmtree,
/* for comparing distances, error of intersection depends on triangle scale.
* need to scale down before squaring for accurate comparison */
const float depsilon = 50 * FLT_EPSILON * len_v3_tri_side_max(v1, v2, v3);
const float depsilon = 50 * FLT_EPSILON *len_v3_tri_side_max(v1, v2, v3);
const float depsilon_squared = depsilon * depsilon;
copy_v3_v3(cos + 0, v1);
@@ -1435,7 +1435,7 @@ static KnifeEdge *knife_find_closest_edge(knifetool_opdata *kcd, float p[3], flo
/* find a vertex near the mouse cursor, if it exists */
static KnifeVert *knife_find_closest_vert(knifetool_opdata *kcd, float p[3], float cagep[3], BMFace **fptr,
int *is_space)
int *is_space)
{
BMFace *f;
float co[3], cageco[3], sco[3], maxdist = knife_snap_size(kcd, kcd->vthresh);
@@ -1580,13 +1580,13 @@ static int knife_update_active(knifetool_opdata *kcd)
return 1;
}
#define MARK 4
#define DEL 8
#define VERT_ON_EDGE 16
#define VERT_ORIG 32
#define FACE_FLIP 64
#define BOUNDARY 128
#define FACE_NEW 256
#define MARK 4
#define DEL 8
#define VERT_ON_EDGE 16
#define VERT_ORIG 32
#define FACE_FLIP 64
#define BOUNDARY 128
#define FACE_NEW 256
#define SCANFILL_CUTS 0
#if SCANFILL_CUTS
@@ -1849,7 +1849,7 @@ static void knifenet_fill_faces(knifetool_opdata *kcd)
ScanFillEdge *eed;
eed = BLI_addfilledge(lasteve, eve);
if (entry->kfe->oe)
eed->f = FILLBOUNDARY; /* mark as original boundary edge */
eed->f = FILLBOUNDARY; /* mark as original boundary edge */
BMO_elem_flag_disable(bm, entry->kfe->e->v1, DEL);
BMO_elem_flag_disable(bm, entry->kfe->e->v2, DEL);
@@ -2023,7 +2023,7 @@ static int find_chain_search(knifetool_opdata *kcd, KnifeVert *kfv, ListBase *fe
return FALSE;
}
static ListBase * find_chain_from_vertex(knifetool_opdata *kcd, KnifeEdge *kfe, BMVert *v, ListBase *fedges)
static ListBase *find_chain_from_vertex(knifetool_opdata *kcd, KnifeEdge *kfe, BMVert *v, ListBase *fedges)
{
SmallHash visited_, *visited = &visited_;
ListBase *ans;
@@ -2053,7 +2053,7 @@ static ListBase * find_chain_from_vertex(knifetool_opdata *kcd, KnifeEdge *kfe,
/* Find a chain in fedges from one instantiated vertex to another.
* Remove the edges in the chain from fedges and return a separate list of the chain. */
static ListBase * find_chain(knifetool_opdata *kcd, ListBase *fedges)
static ListBase *find_chain(knifetool_opdata *kcd, ListBase *fedges)
{
Ref *r, *ref;
KnifeEdge *kfe;
@@ -2549,7 +2549,7 @@ static void knife_make_cuts(knifetool_opdata *kcd)
BLI_mempool_iternew(kcd->kverts, &iter);
for (kfv = BLI_mempool_iterstep(&iter); kfv; kfv = BLI_mempool_iterstep(&iter)) {
if (kfv->v)
continue; /* already have a BMVert */
continue; /* already have a BMVert */
for (ref = kfv->edges.first; ref; ref = ref->next) {
kfe = ref->ref;
e = kfe->e;
@@ -2568,7 +2568,8 @@ static void knife_make_cuts(knifetool_opdata *kcd)
/* split bmesh edges where needed */
for (lst = BLI_smallhash_iternew(ehash, &hiter, (uintptr_t *)&e); lst;
lst = BLI_smallhash_iternext(&hiter, (uintptr_t *)&e)) {
lst = BLI_smallhash_iternext(&hiter, (uintptr_t *)&e))
{
sort_by_frac_along(lst, e);
for (ref = lst->first; ref; ref = ref->next) {
kfv = ref->ref;
@@ -2579,7 +2580,8 @@ static void knife_make_cuts(knifetool_opdata *kcd)
/* do cuts for each face */
for (lst = BLI_smallhash_iternew(fhash, &hiter, (uintptr_t *)&f); lst;
lst = BLI_smallhash_iternext(&hiter, (uintptr_t *)&f)) {
lst = BLI_smallhash_iternext(&hiter, (uintptr_t *)&f))
{
knife_make_face_cuts(kcd, f, lst);
}

View File

@@ -87,8 +87,8 @@
/* struct for properties used while drawing */
typedef struct tringselOpData {
ARegion *ar; /* region that ringsel was activated in */
void *draw_handle; /* for drawing preview loop */
ARegion *ar; /* region that ringsel was activated in */
void *draw_handle; /* for drawing preview loop */
float (*edges)[2][3];
int totedge;
@@ -322,24 +322,24 @@ static void ringsel_finish(bContext *C, wmOperator *op)
CTX_data_tool_settings(C)->selectmode = em->selectmode;
EDBM_selectmode_set(em);
WM_event_add_notifier(C, NC_SCENE|ND_TOOLSETTINGS, CTX_data_scene(C));
WM_event_add_notifier(C, NC_SCENE | ND_TOOLSETTINGS, CTX_data_scene(C));
WM_event_add_notifier(C, NC_SCENE|ND_TOOLSETTINGS, CTX_data_scene(C));
WM_event_add_notifier(C, NC_SCENE | ND_TOOLSETTINGS, CTX_data_scene(C));
}
WM_event_add_notifier(C, NC_GEOM|ND_SELECT|ND_DATA, lcd->ob->data);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT | ND_DATA, lcd->ob->data);
DAG_id_tag_update(lcd->ob->data, 0);
}
else {
/* sets as active, useful for other tools */
if (em->selectmode & SCE_SELECT_VERTEX)
EDBM_store_selection(em, lcd->eed->v1); /* low priority TODO, get vertrex close to mouse */
EDBM_store_selection(em, lcd->eed->v1); /* low priority TODO, get vertrex close to mouse */
if (em->selectmode & SCE_SELECT_EDGE)
EDBM_store_selection(em, lcd->eed);
EDBM_selectmode_flush(lcd->em);
WM_event_add_notifier(C, NC_GEOM|ND_SELECT, lcd->ob->data);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, lcd->ob->data);
}
}
}
@@ -363,7 +363,7 @@ static void ringsel_exit(bContext *UNUSED(C), wmOperator *op)
}
/* called when modal loop selection gets set up... */
static int ringsel_init (bContext *C, wmOperator *op, int do_cut)
static int ringsel_init(bContext *C, wmOperator *op, int do_cut)
{
tringselOpData *lcd;
@@ -389,14 +389,14 @@ static int ringsel_init (bContext *C, wmOperator *op, int do_cut)
return 1;
}
static int ringcut_cancel (bContext *C, wmOperator *op)
static int ringcut_cancel(bContext *C, wmOperator *op)
{
/* this is just a wrapper around exit() */
ringsel_exit(C, op);
return OPERATOR_CANCELLED;
}
static int ringcut_invoke (bContext *C, wmOperator *op, wmEvent *evt)
static int ringcut_invoke(bContext *C, wmOperator *op, wmEvent *evt)
{
Object *obedit = CTX_data_edit_object(C);
tringselOpData *lcd;
@@ -428,7 +428,7 @@ static int ringcut_invoke (bContext *C, wmOperator *op, wmEvent *evt)
return OPERATOR_RUNNING_MODAL;
}
static int loopcut_modal (bContext *C, wmOperator *op, wmEvent *event)
static int loopcut_modal(bContext *C, wmOperator *op, wmEvent *event)
{
int cuts = RNA_int_get(op->ptr, "number_cuts");
tringselOpData *lcd = op->customdata;
@@ -544,7 +544,7 @@ static int loopcut_modal (bContext *C, wmOperator *op, wmEvent *event)
/* for bmesh this tool is in bmesh_select.c */
#if 0
void MESH_OT_edgering_select (wmOperatorType *ot)
void MESH_OT_edgering_select(wmOperatorType *ot)
{
/* description */
ot->name = "Edge Ring Select";
@@ -556,14 +556,14 @@ void MESH_OT_edgering_select (wmOperatorType *ot)
ot->poll = ED_operator_editmesh_region_view3d;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
RNA_def_boolean(ot->srna, "extend", 0, "Extend", "Extend the selection");
}
#endif
void MESH_OT_loopcut (wmOperatorType *ot)
void MESH_OT_loopcut(wmOperatorType *ot)
{
PropertyRNA *prop;
@@ -579,7 +579,7 @@ void MESH_OT_loopcut (wmOperatorType *ot)
ot->poll = ED_operator_editmesh_region_view3d;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
/* properties */
prop = RNA_def_int(ot->srna, "number_cuts", 1, 1, INT_MAX, "Number of Cuts", "", 1, 10);

View File

@@ -121,7 +121,7 @@ void EDBM_automerge(Scene *scene, Object *obedit, int update)
/* ****************************** SELECTION ROUTINES **************** */
unsigned int bm_solidoffs = 0, bm_wireoffs = 0, bm_vertoffs = 0; /* set in drawobject.c ... for colorindices */
unsigned int bm_solidoffs = 0, bm_wireoffs = 0, bm_vertoffs = 0; /* set in drawobject.c ... for colorindices */
/* facilities for border select and circle select */
static char *selbuf = NULL;
@@ -260,7 +260,7 @@ int EDBM_mask_init_backbuf_border(ViewContext *vc, int mcords[][2], short tot, s
}
glEnd();
glFinish(); /* to be sure readpixels sees mask */
glFinish(); /* to be sure readpixels sees mask */
/* grab mask */
bufmask = view3d_read_backbuf(vc, xmin, ymin, xmax, ymax);
@@ -371,8 +371,8 @@ static unsigned int findnearestvert__backbufIndextest(void *handle, unsigned int
*
* dist (in/out): minimal distance to the nearest and at the end, actual distance
* sel: selection bias
* if SELECT, selected vertice are given a 5 pixel bias to make them further than unselect verts
* if 0, unselected vertice are given the bias
* if SELECT, selected vertice are given a 5 pixel bias to make them further than unselect verts
* if 0, unselected vertice are given the bias
* strict: if 1, the vertice corresponding to the sel parameter are ignored and not just biased
*/
BMVert *EDBM_findnearestvert(ViewContext *vc, int *dist, short sel, short strict)
@@ -583,12 +583,12 @@ BMFace *EDBM_findnearestface(ViewContext *vc, int *dist)
data.mval[0] = vc->mval[0];
data.mval[1] = vc->mval[1];
data.dist = 0x7FFF; /* largest short */
data.dist = 0x7FFF; /* largest short */
data.toFace = efa;
mesh_foreachScreenFace(vc, findnearestface__getDistance, &data);
if (vc->em->selectmode == SCE_SELECT_FACE || data.dist < *dist) { /* only faces, no dist check */
if (vc->em->selectmode == SCE_SELECT_FACE || data.dist < *dist) { /* only faces, no dist check */
*dist = data.dist;
return efa;
}
@@ -653,7 +653,7 @@ static int unified_findnearest(ViewContext *vc, BMVert **r_eve, BMEdge **r_eed,
if (em->selectmode & SCE_SELECT_FACE)
*r_efa = EDBM_findnearestface(vc, &dist);
dist -= 20; /* since edges select lines, we give dots advantage of 20 pix */
dist -= 20; /* since edges select lines, we give dots advantage of 20 pix */
if (em->selectmode & SCE_SELECT_EDGE)
*r_eed = EDBM_findnearestedge(vc, &dist);
@@ -724,7 +724,7 @@ static int similar_face_select_exec(bContext *C, wmOperator *op)
/* dependencies graph and notification stuff */
DAG_id_tag_update(ob->data, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_GEOM|ND_SELECT, ob->data);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, ob->data);
/* we succeeded */
return OPERATOR_FINISHED;
@@ -765,7 +765,7 @@ static int similar_edge_select_exec(bContext *C, wmOperator *op)
/* dependencies graph and notification stuff */
DAG_id_tag_update(ob->data, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_GEOM|ND_SELECT, ob->data);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, ob->data);
/* we succeeded */
return OPERATOR_FINISHED;
@@ -809,7 +809,7 @@ static int similar_vert_select_exec(bContext *C, wmOperator *op)
/* dependencies graph and notification stuff */
DAG_id_tag_update(ob->data, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_GEOM|ND_SELECT, ob->data);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, ob->data);
/* we succeeded */
return OPERATOR_FINISHED;
@@ -831,7 +831,7 @@ static int edbm_select_similar_exec(bContext *C, wmOperator *op)
if (type < 100) return similar_vert_select_exec(C, op);
else if (type < 200) return similar_edge_select_exec(C, op);
else return similar_face_select_exec(C, op);
else return similar_face_select_exec(C, op);
}
static EnumPropertyItem *select_similar_type_itemf(bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop),
@@ -884,7 +884,7 @@ void MESH_OT_select_similar(wmOperatorType *ot)
ot->description = "Select similar vertices, edges or faces by property types";
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */
prop = ot->prop = RNA_def_enum(ot->srna, "type", prop_similar_types, SIMVERT_NORMAL, "Type", "");
@@ -907,7 +907,7 @@ static void walker_select(BMEditMesh *em, int walkercode, void *start, int selec
BMW_MASK_NOP, BMW_MASK_NOP, BMW_MASK_NOP, BMW_MASK_NOP,
BMW_NIL_LAY);
ele = BMW_begin(&walker, start);
for ( ; ele; ele = BMW_step(&walker)) {
for (; ele; ele = BMW_step(&walker)) {
if (!select) {
BM_select_history_remove(bm, ele);
}
@@ -929,7 +929,7 @@ static int edbm_loop_multiselect_exec(bContext *C, wmOperator *op)
int totedgesel = 0;
for (eed = BM_iter_new(&iter, em->bm, BM_EDGES_OF_MESH, NULL);
eed; eed = BM_iter_step(&iter)) {
eed; eed = BM_iter_step(&iter)) {
if (BM_elem_flag_test(eed, BM_ELEM_SELECT)) {
totedgesel++;
@@ -968,7 +968,7 @@ static int edbm_loop_multiselect_exec(bContext *C, wmOperator *op)
MEM_freeN(edarray);
// if (EM_texFaceCheck())
WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit);
return OPERATOR_FINISHED;
}
@@ -985,7 +985,7 @@ void MESH_OT_loop_multi_select(wmOperatorType *ot)
ot->description = "Select a loop of connected edges by connection type";
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */
RNA_def_boolean(ot->srna, "ring", 0, "Ring", "");
@@ -1062,7 +1062,7 @@ static void mouse_mesh_loop(bContext *C, int mval[2], short extend, short ring)
* active here in face select mode */
}
WM_event_add_notifier(C, NC_GEOM|ND_SELECT, vc.obedit);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, vc.obedit);
}
}
@@ -1072,7 +1072,7 @@ static int edbm_select_loop_invoke(bContext *C, wmOperator *op, wmEvent *event)
view3d_operator_needs_opengl(C);
mouse_mesh_loop(C, event->mval, RNA_boolean_get(op->ptr, "extend"),
RNA_boolean_get(op->ptr, "ring"));
RNA_boolean_get(op->ptr, "ring"));
/* cannot do tweaks for as long this keymap is after transform map */
return OPERATOR_FINISHED;
@@ -1139,7 +1139,7 @@ static float edgetag_cut_cost(BMEditMesh *UNUSED(em), BMEdge *e1, BMEdge *e2, BM
}
static void edgetag_add_adjacent(BMEditMesh *em, SmallHash *visithash, Heap *heap, int mednum, int vertnum,
int *nedges, int *edges, int *prevedge, float *cost)
int *nedges, int *edges, int *prevedge, float *cost)
{
BMEdge *e1 = EDBM_get_edge_for_index(em, mednum);
BMVert *v = EDBM_get_vert_for_index(em, vertnum);
@@ -1169,43 +1169,43 @@ static void edgetag_context_set(BMEditMesh *em, Scene *scene, BMEdge *e, int val
{
switch (scene->toolsettings->edge_mode) {
case EDGE_MODE_SELECT:
BM_elem_select_set(em->bm, e, val);
break;
case EDGE_MODE_TAG_SEAM:
BM_elem_flag_set(e, BM_ELEM_SEAM, val);
break;
case EDGE_MODE_TAG_SHARP:
BM_elem_flag_set(e, BM_ELEM_SMOOTH, !val);
break;
case EDGE_MODE_TAG_CREASE:
{
float *crease = CustomData_bmesh_get(&em->bm->edata, e->head.data, CD_CREASE);
*crease = (val) ? 1.0f : 0.0f;
break;
}
case EDGE_MODE_TAG_BEVEL:
{
float *bweight = CustomData_bmesh_get(&em->bm->edata, e->head.data, CD_BWEIGHT);
*bweight = (val) ? 1.0f : 0.0f;
break;
}
case EDGE_MODE_SELECT:
BM_elem_select_set(em->bm, e, val);
break;
case EDGE_MODE_TAG_SEAM:
BM_elem_flag_set(e, BM_ELEM_SEAM, val);
break;
case EDGE_MODE_TAG_SHARP:
BM_elem_flag_set(e, BM_ELEM_SMOOTH, !val);
break;
case EDGE_MODE_TAG_CREASE:
{
float *crease = CustomData_bmesh_get(&em->bm->edata, e->head.data, CD_CREASE);
*crease = (val) ? 1.0f : 0.0f;
break;
}
case EDGE_MODE_TAG_BEVEL:
{
float *bweight = CustomData_bmesh_get(&em->bm->edata, e->head.data, CD_BWEIGHT);
*bweight = (val) ? 1.0f : 0.0f;
break;
}
}
}
static int edgetag_context_check(Scene *scene, BMEditMesh *em, BMEdge *e)
{
switch (scene->toolsettings->edge_mode) {
case EDGE_MODE_SELECT:
return BM_elem_flag_test(e, BM_ELEM_SELECT) ? 1 : 0;
case EDGE_MODE_TAG_SEAM:
return BM_elem_flag_test(e, BM_ELEM_SEAM);
case EDGE_MODE_TAG_SHARP:
return !BM_elem_flag_test(e, BM_ELEM_SMOOTH);
case EDGE_MODE_TAG_CREASE:
return BM_elem_float_data_get(&em->bm->edata, e, CD_CREASE) ? 1 : 0;
case EDGE_MODE_TAG_BEVEL:
return BM_elem_float_data_get(&em->bm->edata, e, CD_BWEIGHT) ? 1 : 0;
case EDGE_MODE_SELECT:
return BM_elem_flag_test(e, BM_ELEM_SELECT) ? 1 : 0;
case EDGE_MODE_TAG_SEAM:
return BM_elem_flag_test(e, BM_ELEM_SEAM);
case EDGE_MODE_TAG_SHARP:
return !BM_elem_flag_test(e, BM_ELEM_SMOOTH);
case EDGE_MODE_TAG_CREASE:
return BM_elem_float_data_get(&em->bm->edata, e, CD_CREASE) ? 1 : 0;
case EDGE_MODE_TAG_BEVEL:
return BM_elem_float_data_get(&em->bm->edata, e, CD_BWEIGHT) ? 1 : 0;
}
return 0;
}
@@ -1225,7 +1225,8 @@ static int edgetag_shortest_path(Scene *scene, BMEditMesh *em, BMEdge *source, B
/* note, would pass BM_EDGE except we are looping over all edges anyway */
BM_mesh_elem_index_ensure(em->bm, BM_VERT /* | BM_EDGE */);
BM_ITER(e, &iter, em->bm, BM_EDGES_OF_MESH, NULL) {
BM_ITER(e, &iter, em->bm, BM_EDGES_OF_MESH, NULL)
{
e->oflags[0].f = 0; /* XXX, whats this for, BMESH_TODO, double check if this is needed */
if (BM_elem_flag_test(e, BM_ELEM_HIDDEN)) {
BLI_smallhash_insert(&visithash, (uintptr_t)e, NULL);
@@ -1416,7 +1417,7 @@ static void mouse_mesh_shortest_path(bContext *C, int mval[2])
}
DAG_id_tag_update(ob->data, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_GEOM|ND_SELECT, ob->data);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, ob->data);
}
}
@@ -1443,7 +1444,7 @@ void MESH_OT_select_shortest_path(wmOperatorType *ot)
ot->description = "Select shortest path between two selections";
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */
RNA_def_boolean(ot->srna, "extend", 0, "Extend Select", "");
@@ -1512,7 +1513,7 @@ int mouse_mesh(bContext *C, const int mval[2], short extend)
// BIF_preview_changed(ID_MA);
}
WM_event_add_notifier(C, NC_GEOM|ND_SELECT, vc.obedit);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, vc.obedit);
return 1;
}
@@ -1568,10 +1569,10 @@ void EDBM_selectmode_set(BMEditMesh *em)
else if (em->selectmode & SCE_SELECT_EDGE) {
/* deselect vertices, and select again based on edge select */
eve = BM_iter_new(&iter, em->bm, BM_VERTS_OF_MESH, NULL);
for ( ; eve; eve = BM_iter_step(&iter)) BM_elem_select_set(em->bm, eve, FALSE);
for (; eve; eve = BM_iter_step(&iter)) BM_elem_select_set(em->bm, eve, FALSE);
eed = BM_iter_new(&iter, em->bm, BM_EDGES_OF_MESH, NULL);
for ( ; eed; eed = BM_iter_step(&iter)) {
for (; eed; eed = BM_iter_step(&iter)) {
if (BM_elem_flag_test(eed, BM_ELEM_SELECT)) {
BM_elem_select_set(em->bm, eed, TRUE);
}
@@ -1583,10 +1584,10 @@ void EDBM_selectmode_set(BMEditMesh *em)
else if (em->selectmode & SCE_SELECT_FACE) {
/* deselect eges, and select again based on face select */
eed = BM_iter_new(&iter, em->bm, BM_EDGES_OF_MESH, NULL);
for ( ; eed; eed = BM_iter_step(&iter)) BM_elem_select_set(em->bm, eed, FALSE);
for (; eed; eed = BM_iter_step(&iter)) BM_elem_select_set(em->bm, eed, FALSE);
efa = BM_iter_new(&iter, em->bm, BM_FACES_OF_MESH, NULL);
for ( ; efa; efa = BM_iter_step(&iter)) {
for (; efa; efa = BM_iter_step(&iter)) {
if (BM_elem_flag_test(efa, BM_ELEM_SELECT)) {
BM_elem_select_set(em->bm, efa, TRUE);
}
@@ -1605,7 +1606,7 @@ void EDBM_convertsel(BMEditMesh *em, short oldmode, short selectmode)
if (selectmode == SCE_SELECT_EDGE) {
/* select all edges associated with every selected vertex */
eed = BM_iter_new(&iter, em->bm, BM_EDGES_OF_MESH, NULL);
for ( ; eed; eed = BM_iter_step(&iter)) {
for (; eed; eed = BM_iter_step(&iter)) {
if ((BM_elem_flag_test(eed->v1, BM_ELEM_SELECT) ||
BM_elem_flag_test(eed->v2, BM_ELEM_SELECT)))
{
@@ -1619,7 +1620,7 @@ void EDBM_convertsel(BMEditMesh *em, short oldmode, short selectmode)
/* select all faces associated with every selected vertex */
efa = BM_iter_new(&iter, em->bm, BM_FACES_OF_MESH, NULL);
for ( ; efa; efa = BM_iter_step(&iter)) {
for (; efa; efa = BM_iter_step(&iter)) {
l = BM_iter_new(&liter, em->bm, BM_LOOPS_OF_FACE, efa);
for (; l; l = BM_iter_step(&liter)) {
if (BM_elem_flag_test(l->v, BM_ELEM_SELECT)) {
@@ -1638,7 +1639,7 @@ void EDBM_convertsel(BMEditMesh *em, short oldmode, short selectmode)
/* select all faces associated with every selected vertex */
efa = BM_iter_new(&iter, em->bm, BM_FACES_OF_MESH, NULL);
for ( ; efa; efa = BM_iter_step(&iter)) {
for (; efa; efa = BM_iter_step(&iter)) {
l = BM_iter_new(&liter, em->bm, BM_LOOPS_OF_FACE, efa);
for (; l; l = BM_iter_step(&liter)) {
if (BM_elem_flag_test(l->v, BM_ELEM_SELECT)) {
@@ -1786,7 +1787,7 @@ static int edbm_select_linked_pick_invoke(bContext *C, wmOperator *op, wmEvent *
/* return warning! */
if (unified_findnearest(&vc, &eve, &eed, &efa) == 0) {
WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit);
return OPERATOR_CANCELLED;
}
@@ -1832,13 +1833,13 @@ static int edbm_select_linked_pick_invoke(bContext *C, wmOperator *op, wmEvent *
BMW_NIL_LAY);
e = BMW_begin(&walker, eed->v1);
for ( ; e; e = BMW_step(&walker)) {
for (; e; e = BMW_step(&walker)) {
BM_elem_select_set(bm, e, sel);
}
BMW_end(&walker);
}
WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit);
return OPERATOR_FINISHED;
}
@@ -1854,7 +1855,7 @@ void MESH_OT_select_linked_pick(wmOperatorType *ot)
ot->description = "(De)select all vertices linked to the edge under the mouse cursor";
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
RNA_def_boolean(ot->srna, "deselect", 0, "Deselect", "");
RNA_def_boolean(ot->srna, "limit", 0, "Limit by Seams", "");
@@ -1932,7 +1933,7 @@ static int edbm_select_linked_exec(bContext *C, wmOperator *op)
}
EDBM_selectmode_flush_ex(em, SCE_SELECT_VERTEX);
WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit);
return OPERATOR_FINISHED;
}
@@ -1949,7 +1950,7 @@ void MESH_OT_select_linked(wmOperatorType *ot)
ot->description = "Select all vertices linked to the active mesh";
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
RNA_def_boolean(ot->srna, "limit", 0, "Limit by Seams", "");
}
@@ -1963,7 +1964,7 @@ static int edbm_select_more_exec(bContext *C, wmOperator *UNUSED(op))
EDBM_select_more(em);
WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit);
return OPERATOR_FINISHED;
}
@@ -1979,7 +1980,7 @@ void MESH_OT_select_more(wmOperatorType *ot)
ot->poll = ED_operator_editmesh;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
static int edbm_select_less_exec(bContext *C, wmOperator *UNUSED(op))
@@ -1989,7 +1990,7 @@ static int edbm_select_less_exec(bContext *C, wmOperator *UNUSED(op))
EDBM_select_less(em);
WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit);
return OPERATOR_FINISHED;
}
@@ -2005,7 +2006,7 @@ void MESH_OT_select_less(wmOperatorType *ot)
ot->poll = ED_operator_editmesh;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
/* Walk all reachable elements of the same type as h_act in breadth-first
@@ -2028,30 +2029,31 @@ static void walker_deselect_nth(BMEditMesh *em, int nth, int offset, BMHeader *h
/* Determine which type of iter, walker, and select flush to use
* based on type of the elements being deselected */
switch (h_act->htype) {
case BM_VERT:
itertype = BM_VERTS_OF_MESH;
walktype = BMW_CONNECTED_VERTEX;
flushtype = SCE_SELECT_VERTEX;
mask_vert = BM_ELEM_SELECT;
break;
case BM_EDGE:
itertype = BM_EDGES_OF_MESH;
walktype = BMW_SHELL;
flushtype = SCE_SELECT_EDGE;
mask_edge = BM_ELEM_SELECT;
break;
case BM_FACE:
itertype = BM_FACES_OF_MESH;
walktype = BMW_ISLAND;
flushtype = SCE_SELECT_FACE;
mask_face = BM_ELEM_SELECT;
break;
case BM_VERT:
itertype = BM_VERTS_OF_MESH;
walktype = BMW_CONNECTED_VERTEX;
flushtype = SCE_SELECT_VERTEX;
mask_vert = BM_ELEM_SELECT;
break;
case BM_EDGE:
itertype = BM_EDGES_OF_MESH;
walktype = BMW_SHELL;
flushtype = SCE_SELECT_EDGE;
mask_edge = BM_ELEM_SELECT;
break;
case BM_FACE:
itertype = BM_FACES_OF_MESH;
walktype = BMW_ISLAND;
flushtype = SCE_SELECT_FACE;
mask_face = BM_ELEM_SELECT;
break;
}
/* Walker restrictions uses BMO flags, not header flags,
* so transfer BM_ELEM_SELECT from HFlags onto a BMO flag layer. */
BMO_push(bm, NULL);
BM_ITER(ele, &iter, bm, itertype, NULL) {
BM_ITER(ele, &iter, bm, itertype, NULL)
{
if (BM_elem_flag_test(ele, BM_ELEM_SELECT)) {
/* BMESH_TODO, don't use 'BM_ELEM_SELECT' here, its a HFLAG only! */
BMO_elem_flag_enable(bm, (BMElemF *)ele, BM_ELEM_SELECT);
@@ -2095,15 +2097,15 @@ static void deselect_nth_active(BMEditMesh *em, BMVert **r_eve, BMEdge **r_eed,
if (ese) {
switch (ese->htype) {
case BM_VERT:
*r_eve = (BMVert *)ese->ele;
return;
case BM_EDGE:
*r_eed = (BMEdge *)ese->ele;
return;
case BM_FACE:
*r_efa = (BMFace *)ese->ele;
return;
case BM_VERT:
*r_eve = (BMVert *)ese->ele;
return;
case BM_EDGE:
*r_eed = (BMEdge *)ese->ele;
return;
case BM_FACE:
*r_efa = (BMFace *)ese->ele;
return;
}
}
@@ -2171,7 +2173,7 @@ static int edbm_select_nth_exec(bContext *C, wmOperator *op)
}
DAG_id_tag_update(obedit->data, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
return OPERATOR_FINISHED;
}
@@ -2189,7 +2191,7 @@ void MESH_OT_select_nth(wmOperatorType *ot)
ot->poll = ED_operator_editmesh;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
RNA_def_int(ot->srna, "nth", 2, 2, 100, "Nth Selection", "", 1, INT_MAX);
RNA_def_int(ot->srna, "offset", 0, 0, 100, "Offset", "", 0, INT_MAX);
@@ -2249,7 +2251,7 @@ static int edbm_select_sharp_edges_exec(bContext *C, wmOperator *op)
}
WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
return OPERATOR_FINISHED;
}
@@ -2266,7 +2268,7 @@ void MESH_OT_edges_select_sharp(wmOperatorType *ot)
ot->poll = ED_operator_editmesh;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* props */
RNA_def_float(ot->srna, "sharpness", 1.0f, 0.01f, FLT_MAX, "sharpness", "", 1.0f, 180.0f);
@@ -2330,7 +2332,7 @@ static int edbm_select_linked_flat_faces_exec(bContext *C, wmOperator *op)
BLI_array_free(stack);
WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
return OPERATOR_FINISHED;
}
@@ -2347,7 +2349,7 @@ void MESH_OT_faces_select_linked_flat(wmOperatorType *ot)
ot->poll = ED_operator_editmesh;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* props */
RNA_def_float(ot->srna, "sharpness", 1.0f, 0.01f, FLT_MAX, "sharpness", "", 1.0f, 180.0f);
@@ -2382,7 +2384,7 @@ static int edbm_select_non_manifold_exec(bContext *C, wmOperator *op)
}
}
WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
return OPERATOR_FINISHED;
}
@@ -2399,7 +2401,7 @@ void MESH_OT_select_non_manifold(wmOperatorType *ot)
ot->poll = ED_operator_editmesh;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
static int edbm_select_random_exec(bContext *C, wmOperator *op)
@@ -2442,7 +2444,7 @@ static int edbm_select_random_exec(bContext *C, wmOperator *op)
EDBM_selectmode_flush(em);
}
WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
return OPERATOR_FINISHED;
}
@@ -2459,7 +2461,7 @@ void MESH_OT_select_random(wmOperatorType *ot)
ot->poll = ED_operator_editmesh;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* props */
RNA_def_float_percentage(ot->srna, "percent", 50.f, 0.0f, 100.0f,
@@ -2498,7 +2500,7 @@ static int edbm_select_next_loop_exec(bContext *C, wmOperator *UNUSED(op))
}
}
WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit);
return OPERATOR_FINISHED;
}
@@ -2514,7 +2516,7 @@ void MESH_OT_select_next_loop(wmOperatorType *ot)
ot->poll = ED_operator_editmesh;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -2565,7 +2567,7 @@ static int edbm_region_to_loop_exec(bContext *C, wmOperator *UNUSED(op))
EDBM_selectmode_to_scene(C);
}
WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
return OPERATOR_FINISHED;
}
@@ -2581,7 +2583,7 @@ void MESH_OT_region_to_loop(wmOperatorType *ot)
ot->poll = ED_operator_editmesh;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
static int loop_find_region(BMEditMesh *em, BMLoop *l, int flag,
@@ -2747,7 +2749,7 @@ static int edbm_loop_to_region_exec(bContext *C, wmOperator *op)
}
}
WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
return OPERATOR_FINISHED;
}
@@ -2762,7 +2764,7 @@ void MESH_OT_loop_to_region(wmOperatorType *ot)
ot->poll = ED_operator_editmesh;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
RNA_def_boolean(ot->srna, "select_bigger", 0, "Select Bigger", "Select bigger regions instead of smaller ones");
}

View File

@@ -102,13 +102,13 @@ static int edbm_subdivide_exec(bContext *C, wmOperator *op)
BM_mesh_esubdivideflag(obedit, em->bm, BM_ELEM_SELECT,
smooth, fractal,
ts->editbutflag|flag,
ts->editbutflag | flag,
cuts, 0, RNA_enum_get(op->ptr, "quadcorner"),
RNA_boolean_get(op->ptr, "quadtri"),
TRUE, RNA_int_get(op->ptr, "seed"));
DAG_id_tag_update(obedit->data, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
return OPERATOR_FINISHED;
}
@@ -136,7 +136,7 @@ void MESH_OT_subdivide(wmOperatorType *ot)
ot->poll = ED_operator_editmesh;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */
prop = RNA_def_int(ot->srna, "number_cuts", 1, 1, INT_MAX, "Number of Cuts", "", 1, 10);
@@ -160,7 +160,7 @@ void EMBM_project_snap_verts(bContext *C, ARegion *ar, Object *obedit, BMEditMes
BMIter iter;
BMVert *eve;
BM_ITER(eve, &iter, em->bm, BM_VERTS_OF_MESH, NULL) {
BM_ITER(eve, &iter, em->bm, BM_VERTS_OF_MESH, NULL) {
if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) {
float mval[2], vec[3], no_dummy[3];
int dist_dummy;
@@ -218,7 +218,7 @@ static short edbm_extrude_edges_indiv(BMEditMesh *em, wmOperator *op, const char
EDBM_flag_disable_all(em, BM_ELEM_SELECT);
BMO_op_exec(em->bm, &bmop);
BMO_slot_buffer_hflag_enable(em->bm, &bmop, "geomout", BM_VERT|BM_EDGE, BM_ELEM_SELECT, TRUE);
BMO_slot_buffer_hflag_enable(em->bm, &bmop, "geomout", BM_VERT | BM_EDGE, BM_ELEM_SELECT, TRUE);
if (!EDBM_FinishOp(em, &bmop, op, TRUE)) {
return 0;
@@ -259,7 +259,7 @@ static short edbm_extrude_edge(Object *obedit, BMEditMesh *em, const char hflag,
BMElem *ele;
BMO_op_init(bm, &extop, "extrude_face_region");
BMO_slot_buffer_from_hflag(bm, &extop, "edgefacein", BM_VERT|BM_EDGE|BM_FACE, hflag);
BMO_slot_buffer_from_hflag(bm, &extop, "edgefacein", BM_VERT | BM_EDGE | BM_FACE, hflag);
/* If a mirror modifier with clipping is on, we need to adjust some
* of the cases above to handle edges on the line of symmetry.
@@ -297,21 +297,21 @@ static short edbm_extrude_edge(Object *obedit, BMEditMesh *em, const char hflag,
if (mmd->flag & MOD_MIR_AXIS_X) {
if ((fabsf(co1[0]) < mmd->tolerance) &&
(fabsf(co2[0]) < mmd->tolerance))
(fabsf(co2[0]) < mmd->tolerance))
{
BMO_slot_map_ptr_insert(bm, &extop, "exclude", edge, NULL);
}
}
if (mmd->flag & MOD_MIR_AXIS_Y) {
if ((fabsf(co1[1]) < mmd->tolerance) &&
(fabsf(co2[1]) < mmd->tolerance))
(fabsf(co2[1]) < mmd->tolerance))
{
BMO_slot_map_ptr_insert(bm, &extop, "exclude", edge, NULL);
}
}
if (mmd->flag & MOD_MIR_AXIS_Z) {
if ((fabsf(co1[2]) < mmd->tolerance) &&
(fabsf(co2[2]) < mmd->tolerance))
(fabsf(co2[2]) < mmd->tolerance))
{
BMO_slot_map_ptr_insert(bm, &extop, "exclude", edge, NULL);
}
@@ -408,7 +408,7 @@ static int edbm_extrude_repeat_exec(bContext *C, wmOperator *op)
EDBM_RecalcNormals(em);
DAG_id_tag_update(obedit->data, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
return OPERATOR_FINISHED;
}
@@ -425,7 +425,7 @@ void MESH_OT_extrude_repeat(wmOperatorType *ot)
ot->poll = ED_operator_editmesh_view3d;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* props */
RNA_def_float(ot->srna, "offset", 2.0f, 0.0f, 100.0f, "Offset", "", 0.0f, FLT_MAX);
@@ -446,11 +446,11 @@ static int edbm_extrude_mesh(Scene *scene, Object *obedit, BMEditMesh *em, wmOpe
else if (em->bm->totvertsel == 1) nr = 4;
else if (em->bm->totedgesel == 0) nr = 4;
else if (em->bm->totfacesel == 0)
nr = 3; // pupmenu("Extrude %t|Only Edges%x3|Only Vertices%x4");
nr = 3; // pupmenu("Extrude %t|Only Edges%x3|Only Vertices%x4");
else if (em->bm->totfacesel == 1)
nr = 1; // pupmenu("Extrude %t|Region %x1|Only Edges%x3|Only Vertices%x4");
nr = 1; // pupmenu("Extrude %t|Region %x1|Only Edges%x3|Only Vertices%x4");
else
nr = 1; // pupmenu("Extrude %t|Region %x1||Individual Faces %x2|Only Edges%x3|Only Vertices%x4");
nr = 1; // pupmenu("Extrude %t|Region %x1||Individual Faces %x2|Only Edges%x3|Only Vertices%x4");
}
else if (em->selectmode & SCE_SELECT_EDGE) {
if (em->bm->totedgesel == 0) nr = 0;
@@ -460,16 +460,16 @@ static int edbm_extrude_mesh(Scene *scene, Object *obedit, BMEditMesh *em, wmOpe
else if (em->totedgesel == 1) nr = 3;
else if (em->totfacesel == 0) nr = 3;
else if (em->totfacesel == 1)
nr = 1; // pupmenu("Extrude %t|Region %x1|Only Edges%x3");
nr = 1; // pupmenu("Extrude %t|Region %x1|Only Edges%x3");
else
nr = 1; // pupmenu("Extrude %t|Region %x1||Individual Faces %x2|Only Edges%x3");
nr = 1; // pupmenu("Extrude %t|Region %x1||Individual Faces %x2|Only Edges%x3");
#endif
}
else {
if (em->bm->totfacesel == 0) nr = 0;
else if (em->bm->totfacesel == 1) nr = 1;
else
nr = 1; // pupmenu("Extrude %t|Region %x1||Individual Faces %x2");
nr = 1; // pupmenu("Extrude %t|Region %x1||Individual Faces %x2");
}
if (nr < 1) return 'g';
@@ -530,7 +530,7 @@ static int edbm_extrude_region_exec(bContext *C, wmOperator *op)
EDBM_RecalcNormals(em);
BMEdit_RecalcTessellation(em);
WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit);
return OPERATOR_FINISHED;
}
@@ -547,7 +547,7 @@ void MESH_OT_extrude_region(wmOperatorType *ot)
ot->poll = ED_operator_editmesh;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
RNA_def_boolean(ot->srna, "mirror", 0, "Mirror Editing", "");
}
@@ -560,7 +560,7 @@ static int edbm_extrude_verts_exec(bContext *C, wmOperator *op)
edbm_extrude_verts_indiv(em, op, BM_ELEM_SELECT, nor);
WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit);
return OPERATOR_FINISHED;
}
@@ -576,7 +576,7 @@ void MESH_OT_extrude_verts_indiv(wmOperatorType *ot)
ot->poll = ED_operator_editmesh;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* to give to transform */
RNA_def_boolean(ot->srna, "mirror", 0, "Mirror Editing", "");
@@ -590,7 +590,7 @@ static int edbm_extrude_edges_exec(bContext *C, wmOperator *op)
edbm_extrude_edges_indiv(em, op, BM_ELEM_SELECT, nor);
WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit);
return OPERATOR_FINISHED;
}
@@ -606,7 +606,7 @@ void MESH_OT_extrude_edges_indiv(wmOperatorType *ot)
ot->poll = ED_operator_editmesh;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* to give to transform */
RNA_def_boolean(ot->srna, "mirror", 0, "Mirror Editing", "");
@@ -620,7 +620,7 @@ static int edbm_extrude_faces_exec(bContext *C, wmOperator *op)
edbm_extrude_face_indiv(em, op, BM_ELEM_SELECT, nor);
WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit);
return OPERATOR_FINISHED;
}
@@ -636,7 +636,7 @@ void MESH_OT_extrude_faces_indiv(wmOperatorType *ot)
ot->poll = ED_operator_editmesh;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
RNA_def_boolean(ot->srna, "mirror", 0, "Mirror Editing", "");
}
@@ -650,21 +650,21 @@ static int edbm_select_all_exec(bContext *C, wmOperator *op)
int action = RNA_enum_get(op->ptr, "action");
switch (action) {
case SEL_TOGGLE:
EDBM_select_toggle_all(em);
break;
case SEL_SELECT:
EDBM_flag_enable_all(em, BM_ELEM_SELECT);
break;
case SEL_DESELECT:
EDBM_flag_disable_all(em, BM_ELEM_SELECT);
break;
case SEL_INVERT:
EDBM_select_swap(em);
break;
case SEL_TOGGLE:
EDBM_select_toggle_all(em);
break;
case SEL_SELECT:
EDBM_flag_enable_all(em, BM_ELEM_SELECT);
break;
case SEL_DESELECT:
EDBM_flag_disable_all(em, BM_ELEM_SELECT);
break;
case SEL_INVERT:
EDBM_select_swap(em);
break;
}
WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit);
return OPERATOR_FINISHED;
}
@@ -681,7 +681,7 @@ void MESH_OT_select_all(wmOperatorType *ot)
ot->poll = ED_operator_editmesh;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
WM_operator_properties_select_all(ot);
}
@@ -692,7 +692,7 @@ static int edbm_faces_select_interior_exec(bContext *C, wmOperator *UNUSED(op))
BMEditMesh *em = BMEdit_FromObject(obedit);
if (EDBM_select_interior_faces(em)) {
WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit);
return OPERATOR_FINISHED;
}
@@ -714,7 +714,7 @@ void MESH_OT_select_interior_faces(wmOperatorType *ot)
ot->poll = ED_operator_editmesh;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
/* *************** add-click-mesh (extrude) operator ************** */
@@ -729,7 +729,7 @@ static int edbm_dupli_extrude_cursor_invoke(bContext *C, wmOperator *op, wmEvent
em_setup_viewcontext(C, &vc);
use_proj = (vc.scene->toolsettings->snap_flag & SCE_SNAP) && (vc.scene->toolsettings->snap_mode == SCE_SNAP_MODE_FACE);
use_proj = (vc.scene->toolsettings->snap_flag & SCE_SNAP) && (vc.scene->toolsettings->snap_mode == SCE_SNAP_MODE_FACE);
INIT_MINMAX(min, max);
@@ -799,7 +799,7 @@ static int edbm_dupli_extrude_cursor_invoke(bContext *C, wmOperator *op, wmEvent
mid_v3_v3v3(cent, min, max);
copy_v3_v3(min, cent);
mul_m4_v3(vc.obedit->obmat, min); // view space
mul_m4_v3(vc.obedit->obmat, min); /* view space */
view3d_get_view_aligned_coordinate(&vc, min, event->mval, TRUE);
mul_m4_v3(vc.obedit->imat, min); // back in object space
@@ -836,7 +836,7 @@ static int edbm_dupli_extrude_cursor_invoke(bContext *C, wmOperator *op, wmEvent
if (rot_src) {
EDBM_CallOpf(vc.em, op, "rotate verts=%hv cent=%v mat=%m3",
BM_ELEM_SELECT, cent, mat);
BM_ELEM_SELECT, cent, mat);
/* also project the source, for retopo workflow */
if (use_proj)
@@ -845,9 +845,9 @@ static int edbm_dupli_extrude_cursor_invoke(bContext *C, wmOperator *op, wmEvent
edbm_extrude_edge(vc.obedit, vc.em, BM_ELEM_SELECT, nor);
EDBM_CallOpf(vc.em, op, "rotate verts=%hv cent=%v mat=%m3",
BM_ELEM_SELECT, cent, mat);
BM_ELEM_SELECT, cent, mat);
EDBM_CallOpf(vc.em, op, "translate verts=%hv vec=%v",
BM_ELEM_SELECT, min);
BM_ELEM_SELECT, min);
}
else {
float *curs = give_cursor(vc.scene, vc.v3d);
@@ -881,7 +881,7 @@ static int edbm_dupli_extrude_cursor_invoke(bContext *C, wmOperator *op, wmEvent
EDBM_RecalcNormals(vc.em);
BMEdit_RecalcTessellation(vc.em);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, vc.obedit->data);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, vc.obedit->data);
DAG_id_tag_update(vc.obedit->data, OB_RECALC_DATA);
return OPERATOR_FINISHED;
@@ -899,7 +899,7 @@ void MESH_OT_dupli_extrude_cursor(wmOperatorType *ot)
ot->poll = ED_operator_editmesh;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
RNA_def_boolean(ot->srna, "rotate_source", 1, "Rotate Source", "Rotate initial selection giving better shape");
}
@@ -949,7 +949,7 @@ static int edbm_delete_exec(bContext *C, wmOperator *op)
DAG_id_tag_update(obedit->data, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_GEOM|ND_DATA|ND_SELECT, obedit);
WM_event_add_notifier(C, NC_GEOM | ND_DATA | ND_SELECT, obedit);
return OPERATOR_FINISHED;
}
@@ -968,7 +968,7 @@ void MESH_OT_delete(wmOperatorType *ot)
ot->poll = ED_operator_editmesh;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* props */
ot->prop = RNA_def_enum(ot->srna, "type", prop_mesh_delete_types, 0, "Type", "Method used for deleting mesh data");
@@ -983,7 +983,7 @@ static int edbm_collapse_edge_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
DAG_id_tag_update(obedit->data, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_GEOM|ND_DATA|ND_SELECT, obedit);
WM_event_add_notifier(C, NC_GEOM | ND_DATA | ND_SELECT, obedit);
return OPERATOR_FINISHED;
}
@@ -1000,7 +1000,7 @@ void MESH_OT_edge_collapse(wmOperatorType *ot)
ot->poll = ED_operator_editmesh;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
static int edbm_collapse_edge_loop_exec(bContext *C, wmOperator *op)
@@ -1012,7 +1012,7 @@ static int edbm_collapse_edge_loop_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
DAG_id_tag_update(obedit->data, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_GEOM|ND_DATA|ND_SELECT, obedit);
WM_event_add_notifier(C, NC_GEOM | ND_DATA | ND_SELECT, obedit);
return OPERATOR_FINISHED;
}
@@ -1029,7 +1029,7 @@ void MESH_OT_edge_collapse_loop(wmOperatorType *ot)
ot->poll = ED_operator_editmesh;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
static int edbm_add_edge_face_exec(bContext *C, wmOperator *op)
@@ -1048,7 +1048,7 @@ static int edbm_add_edge_face_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
}
WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit);
DAG_id_tag_update(obedit->data, OB_RECALC_DATA);
return OPERATOR_FINISHED;
@@ -1066,7 +1066,7 @@ void MESH_OT_edge_face_add(wmOperatorType *ot)
ot->poll = ED_operator_editmesh;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
/* ************************* SEAMS AND EDGES **************** */
@@ -1103,7 +1103,7 @@ static int edbm_mark_seam(bContext *C, wmOperator *op)
}
DAG_id_tag_update(obedit->data, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
return OPERATOR_FINISHED;
}
@@ -1120,7 +1120,7 @@ void MESH_OT_mark_seam(wmOperatorType *ot)
ot->poll = ED_operator_editmesh;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
RNA_def_boolean(ot->srna, "clear", 0, "Clear", "");
}
@@ -1159,7 +1159,7 @@ static int edbm_mark_sharp(bContext *C, wmOperator *op)
DAG_id_tag_update(obedit->data, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
return OPERATOR_FINISHED;
}
@@ -1176,7 +1176,7 @@ void MESH_OT_mark_sharp(wmOperatorType *ot)
ot->poll = ED_operator_editmesh;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
RNA_def_boolean(ot->srna, "clear", 0, "Clear", "");
}
@@ -1200,7 +1200,7 @@ static int edbm_vert_connect(bContext *C, wmOperator *op)
}
DAG_id_tag_update(obedit->data, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
return len ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
}
@@ -1216,7 +1216,7 @@ void MESH_OT_vert_connect(wmOperatorType *ot)
ot->poll = ED_operator_editmesh;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
static int edbm_edge_split_exec(bContext *C, wmOperator *op)
@@ -1239,7 +1239,7 @@ static int edbm_edge_split_exec(bContext *C, wmOperator *op)
}
DAG_id_tag_update(obedit->data, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
return len ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
}
@@ -1255,7 +1255,7 @@ void MESH_OT_edge_split(wmOperatorType *ot)
ot->poll = ED_operator_editmesh;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
/****************** add duplicate operator ***************/
@@ -1278,7 +1278,7 @@ static int edbm_duplicate_exec(bContext *C, wmOperator *op)
}
DAG_id_tag_update(ob->data, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, ob->data);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data);
return OPERATOR_FINISHED;
}
@@ -1318,7 +1318,7 @@ static int edbm_flip_normals_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
DAG_id_tag_update(obedit->data, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
return OPERATOR_FINISHED;
}
@@ -1335,7 +1335,7 @@ void MESH_OT_flip_normals(wmOperatorType *ot)
ot->poll = ED_operator_editmesh;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
static const EnumPropertyItem direction_items[] = {
@@ -1399,7 +1399,7 @@ static int edbm_edge_rotate_selected_exec(bContext *C, wmOperator *op)
}
DAG_id_tag_update(obedit->data, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
return OPERATOR_FINISHED;
}
@@ -1416,7 +1416,7 @@ void MESH_OT_edge_rotate(wmOperatorType *ot)
ot->poll = ED_operator_editmesh;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* props */
RNA_def_enum(ot->srna, "direction", direction_items, DIRECTION_CW, "Direction", "Direction to rotate edge around");
@@ -1431,7 +1431,7 @@ static int edbm_hide_exec(bContext *C, wmOperator *op)
EDBM_hide_mesh(em, RNA_boolean_get(op->ptr, "unselected"));
DAG_id_tag_update(obedit->data, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
return OPERATOR_FINISHED;
}
@@ -1445,10 +1445,10 @@ void MESH_OT_hide(wmOperatorType *ot)
/* api callbacks */
ot->exec = edbm_hide_exec;
ot->poll = ED_operator_editmesh;
ot->description = "Hide (un)selected vertices, edges or faces";
ot->description = "Hide (un)selected vertices, edges or faces";
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* props */
RNA_def_boolean(ot->srna, "unselected", 0, "Unselected", "Hide unselected rather than selected");
@@ -1462,7 +1462,7 @@ static int edbm_reveal_exec(bContext *C, wmOperator *UNUSED(op))
EDBM_reveal_mesh(em);
DAG_id_tag_update(obedit->data, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
return OPERATOR_FINISHED;
}
@@ -1479,7 +1479,7 @@ void MESH_OT_reveal(wmOperatorType *ot)
ot->poll = ED_operator_editmesh;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
static int edbm_normals_make_consistent_exec(bContext *C, wmOperator *op)
@@ -1496,7 +1496,7 @@ static int edbm_normals_make_consistent_exec(bContext *C, wmOperator *op)
EDBM_CallOpf(em, op, "reversefaces faces=%hf", BM_ELEM_SELECT);
DAG_id_tag_update(obedit->data, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
return OPERATOR_FINISHED;
}
@@ -1513,7 +1513,7 @@ void MESH_OT_normals_make_consistent(wmOperatorType *ot)
ot->poll = ED_operator_editmesh;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
RNA_def_boolean(ot->srna, "inside", 0, "Inside", "");
}
@@ -1574,7 +1574,7 @@ static int edbm_do_smooth_vertex_exec(bContext *C, wmOperator *op)
}
DAG_id_tag_update(obedit->data, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
return OPERATOR_FINISHED;
}
@@ -1591,7 +1591,7 @@ void MESH_OT_vertices_smooth(wmOperatorType *ot)
ot->poll = ED_operator_editmesh;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
RNA_def_int(ot->srna, "repeat", 1, 1, 100, "Number of times to smooth the mesh", "", 1, INT_MAX);
}
@@ -1620,7 +1620,7 @@ static int edbm_faces_shade_smooth_exec(bContext *C, wmOperator *UNUSED(op))
mesh_set_smooth_faces(em, 1);
DAG_id_tag_update(obedit->data, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
return OPERATOR_FINISHED;
}
@@ -1629,7 +1629,7 @@ void MESH_OT_faces_shade_smooth(wmOperatorType *ot)
{
/* identifiers */
ot->name = "Shade Smooth";
ot->description = "Display faces smooth (using vertex normals)";
ot->description = "Display faces smooth (using vertex normals)";
ot->idname = "MESH_OT_faces_shade_smooth";
/* api callbacks */
@@ -1637,7 +1637,7 @@ void MESH_OT_faces_shade_smooth(wmOperatorType *ot)
ot->poll = ED_operator_editmesh;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
static int edbm_faces_shade_flat_exec(bContext *C, wmOperator *UNUSED(op))
@@ -1648,7 +1648,7 @@ static int edbm_faces_shade_flat_exec(bContext *C, wmOperator *UNUSED(op))
mesh_set_smooth_faces(em, 0);
DAG_id_tag_update(obedit->data, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
return OPERATOR_FINISHED;
}
@@ -1665,7 +1665,7 @@ void MESH_OT_faces_shade_flat(wmOperatorType *ot)
ot->poll = ED_operator_editmesh;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -1693,7 +1693,7 @@ static int edbm_rotate_uvs_exec(bContext *C, wmOperator *op)
/* dependencies graph and notification stuff */
DAG_id_tag_update(ob->data, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, ob->data);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data);
/* we succeeded */
return OPERATOR_FINISHED;
@@ -1718,7 +1718,7 @@ static int edbm_reverse_uvs_exec(bContext *C, wmOperator *op)
/* dependencies graph and notification stuff */
DAG_id_tag_update(ob->data, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, ob->data);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data);
/* we succeeded */
return OPERATOR_FINISHED;
@@ -1746,7 +1746,7 @@ static int edbm_rotate_colors_exec(bContext *C, wmOperator *op)
/* dependencies graph and notification stuff */
DAG_id_tag_update(ob->data, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, ob->data);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data);
/* DAG_object_flush_update(scene, ob, OB_RECALC_DATA);
* WM_event_add_notifier(C, NC_OBJECT | ND_GEOM_SELECT, ob);
*/
@@ -1773,7 +1773,7 @@ static int edbm_reverse_colors_exec(bContext *C, wmOperator *op)
}
DAG_id_tag_update(ob->data, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, ob->data);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data);
/* we succeeded */
return OPERATOR_FINISHED;
@@ -1790,7 +1790,7 @@ void MESH_OT_uvs_rotate(wmOperatorType *ot)
ot->poll = ED_operator_editmesh;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* props */
RNA_def_enum(ot->srna, "direction", direction_items, DIRECTION_CW, "Direction", "Direction to rotate UVs around");
@@ -1808,7 +1808,7 @@ void MESH_OT_uvs_reverse(wmOperatorType *ot)
ot->poll = ED_operator_editmesh;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* props */
//RNA_def_enum(ot->srna, "axis", axis_items, DIRECTION_CW, "Axis", "Axis to mirror UVs around");
@@ -1825,7 +1825,7 @@ void MESH_OT_colors_rotate(wmOperatorType *ot)
ot->poll = ED_operator_editmesh;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* props */
RNA_def_enum(ot->srna, "direction", direction_items, DIRECTION_CCW, "Direction", "Direction to rotate edge around");
@@ -1842,7 +1842,7 @@ void MESH_OT_colors_reverse(wmOperatorType *ot)
ot->poll = ED_operator_editmesh;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* props */
//RNA_def_enum(ot->srna, "axis", axis_items, DIRECTION_CW, "Axis", "Axis to mirror colors around");
@@ -1955,7 +1955,7 @@ static int edbm_merge_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
DAG_id_tag_update(obedit->data, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
return OPERATOR_FINISHED;
}
@@ -2022,7 +2022,7 @@ void MESH_OT_merge(wmOperatorType *ot)
ot->poll = ED_operator_editmesh;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */
ot->prop = RNA_def_enum(ot->srna, "type", merge_type_items, 3, "Type", "Merge method to use");
@@ -2056,7 +2056,7 @@ static int edbm_remove_doubles_exec(bContext *C, wmOperator *op)
DAG_id_tag_update(obedit->data, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
return OPERATOR_FINISHED;
}
@@ -2072,11 +2072,11 @@ void MESH_OT_remove_doubles(wmOperatorType *ot)
ot->poll = ED_operator_editmesh;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
RNA_def_float(ot->srna, "mergedist", 0.0001f, 0.000001f, 50.0f,
"Merge Distance",
"Minimum distance between elements to merge", 0.00001, 10.0);
"Merge Distance",
"Minimum distance between elements to merge", 0.00001, 10.0);
}
/************************ Vertex Path Operator *************************/
@@ -2139,7 +2139,7 @@ static int edbm_select_vertex_path_exec(bContext *C, wmOperator *op)
* WM_event_add_notifier(C, NC_OBJECT | ND_GEOM_SELECT, ob);
*/
DAG_id_tag_update(ob->data, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, ob->data);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data);
/* we succeeded */
@@ -2151,7 +2151,8 @@ void MESH_OT_select_vertex_path(wmOperatorType *ot)
static const EnumPropertyItem type_items[] = {
{VPATH_SELECT_EDGE_LENGTH, "EDGE_LENGTH", 0, "Edge Length", NULL},
{VPATH_SELECT_TOPOLOGICAL, "TOPOLOGICAL", 0, "Topological", NULL},
{0, NULL, 0, NULL, NULL}};
{0, NULL, 0, NULL, NULL}
};
/* identifiers */
ot->name = "Select Vertex Path";
@@ -2162,7 +2163,7 @@ void MESH_OT_select_vertex_path(wmOperatorType *ot)
ot->poll = ED_operator_editmesh;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */
RNA_def_enum(ot->srna, "type", type_items, VPATH_SELECT_EDGE_LENGTH, "Type", "Method to compute distance");
@@ -2411,7 +2412,7 @@ static int edbm_rip_invoke(bContext *C, wmOperator *op, wmEvent *event)
}
DAG_id_tag_update(obedit->data, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
return OPERATOR_FINISHED;
}
@@ -2427,7 +2428,7 @@ void MESH_OT_rip(wmOperatorType *ot)
ot->poll = EM_view3d_poll;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* to give to transform */
Transform_Properties(ot, P_PROPORTIONAL);
@@ -2481,7 +2482,7 @@ static int edbm_shape_propagate_to_all_exec(bContext *C, wmOperator *op)
shape_propagate(obedit, em, op);
DAG_id_tag_update(&me->id, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, me);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, me);
return OPERATOR_FINISHED;
}
@@ -2499,7 +2500,7 @@ void MESH_OT_shape_propagate_to_all(wmOperatorType *ot)
ot->poll = ED_operator_editmesh;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
/* BMESH_TODO this should be properly encapsulated in a bmop. but later.*/
@@ -2541,7 +2542,7 @@ static int edbm_blend_from_shape_exec(bContext *C, wmOperator *op)
}
DAG_id_tag_update(&me->id, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, me);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, me);
return OPERATOR_FINISHED;
}
@@ -2595,7 +2596,7 @@ void MESH_OT_blend_from_shape(wmOperatorType *ot)
ot->poll = ED_operator_editmesh;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */
prop = RNA_def_enum(ot->srna, "shape", shape_items, 0, "Shape", "Shape key to use for blending");
@@ -2631,25 +2632,25 @@ static int edbm_select_axis_exec(bContext *C, wmOperator *op)
BM_ITER(ev, &iter, em->bm, BM_VERTS_OF_MESH, NULL) {
if (!BM_elem_flag_test(ev, BM_ELEM_HIDDEN)) {
switch (mode) {
case -1: /* aligned */
if (fabs(ev->co[axis] - value) < limit)
BM_elem_select_set(em->bm, ev, TRUE);
break;
case 0: /* neg */
if (ev->co[axis] > value)
BM_elem_select_set(em->bm, ev, TRUE);
break;
case 1: /* pos */
if (ev->co[axis] < value)
BM_elem_select_set(em->bm, ev, TRUE);
break;
case -1: /* aligned */
if (fabs(ev->co[axis] - value) < limit)
BM_elem_select_set(em->bm, ev, TRUE);
break;
case 0: /* neg */
if (ev->co[axis] > value)
BM_elem_select_set(em->bm, ev, TRUE);
break;
case 1: /* pos */
if (ev->co[axis] < value)
BM_elem_select_set(em->bm, ev, TRUE);
break;
}
}
}
}
EDBM_selectmode_flush(em);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
return OPERATOR_FINISHED;
}
@@ -2678,7 +2679,7 @@ void MESH_OT_select_axis(wmOperatorType *ot)
ot->poll = ED_operator_editmesh;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */
RNA_def_enum(ot->srna, "mode", axis_mode_items, 0, "Axis Mode", "Axis side to use when selecting");
@@ -2715,7 +2716,7 @@ static int edbm_solidify_exec(bContext *C, wmOperator *op)
}
DAG_id_tag_update(obedit->data, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
return OPERATOR_FINISHED;
}
@@ -2734,7 +2735,7 @@ void MESH_OT_solidify(wmOperatorType *ot)
ot->poll = ED_operator_editmesh;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
prop = RNA_def_float(ot->srna, "thickness", 0.01f, -FLT_MAX, FLT_MAX, "thickness", "", -10.0f, 10.0f);
RNA_def_property_ui_range(prop, -10, 10, 0.1, 4);
@@ -2744,11 +2745,11 @@ void MESH_OT_solidify(wmOperatorType *ot)
#define TRAIL_FREEHAND 2
#define TRAIL_MIXED 3 /* (1|2) */
#define TRAIL_AUTO 4
#define TRAIL_MIDPOINTS 8
#define TRAIL_MIDPOINTS 8
typedef struct CutCurve {
float x;
float y;
float x;
float y;
} CutCurve;
/* ******************************************************************** */
@@ -2771,9 +2772,9 @@ typedef struct CutCurve {
* bmesh port version
*/
#define KNIFE_EXACT 1
#define KNIFE_MIDPOINT 2
#define KNIFE_MULTICUT 3
#define KNIFE_EXACT 1
#define KNIFE_MIDPOINT 2
#define KNIFE_MULTICUT 3
static EnumPropertyItem knife_items[] = {
{KNIFE_EXACT, "EXACT", 0, "Exact", ""},
@@ -2788,13 +2789,13 @@ static float bm_edge_seg_isect(BMEdge *e, CutCurve *c, int len, char mode,
struct GHash *gh, int *isected)
{
#define MAXSLOPE 100000
float x11, y11, x12 = 0, y12 = 0, x2max, x2min, y2max;
float y2min, dist, lastdist = 0, xdiff2, xdiff1;
float m1, b1, m2, b2, x21, x22, y21, y22, xi;
float yi, x1min, x1max, y1max, y1min, perc = 0;
float x11, y11, x12 = 0, y12 = 0, x2max, x2min, y2max;
float y2min, dist, lastdist = 0, xdiff2, xdiff1;
float m1, b1, m2, b2, x21, x22, y21, y22, xi;
float yi, x1min, x1max, y1max, y1min, perc = 0;
float *scr;
float threshold = 0.0;
int i;
float threshold = 0.0;
int i;
//threshold = 0.000001; /* tolerance for vertex intersection */
// XXX threshold = scene->toolsettings->select_thresh / 100;
@@ -2863,8 +2864,8 @@ static float bm_edge_seg_isect(BMEdge *e, CutCurve *c, int len, char mode,
y12 = c[i].y;
/* Perp. Distance from point to line */
if (m2 != MAXSLOPE) dist = (y12 - m2 * x12 - b2);/* /sqrt(m2 * m2 + 1); Only looking for */
/* change in sign. Skip extra math */
if (m2 != MAXSLOPE) dist = (y12 - m2 * x12 - b2); /* /sqrt(m2 * m2 + 1); Only looking for */
/* change in sign. Skip extra math */
else dist = x22 - x12;
if (i == 0) lastdist = dist;
@@ -2929,7 +2930,7 @@ static float bm_edge_seg_isect(BMEdge *e, CutCurve *c, int len, char mode,
}
}
if ((m2 <= 1.0f) && (m2 >= -1.0f)) perc = (xi - x21) / (x22 - x21);
else perc = (yi - y21) / (y22 - y21); /* lower slope more accurate */
else perc = (yi - y21) / (y22 - y21); /* lower slope more accurate */
//isect = 32768.0 * (perc + 0.0000153); /* Percentage in 1 / 32768ths */
break;
@@ -3005,8 +3006,8 @@ static int edbm_knife_cut_exec(bContext *C, wmOperator *op)
if (isect != 0.0f) {
if (mode != KNIFE_MULTICUT && mode != KNIFE_MIDPOINT) {
BMO_slot_map_float_insert(bm, &bmop,
"edgepercents",
be, isect);
"edgepercents",
be, isect);
}
BMO_elem_flag_enable(bm, be, 1);
@@ -3040,7 +3041,7 @@ static int edbm_knife_cut_exec(bContext *C, wmOperator *op)
BLI_ghash_free(gh, NULL, (GHashValFreeFP)MEM_freeN);
DAG_id_tag_update(obedit->data, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
return OPERATOR_FINISHED;
}
@@ -3060,7 +3061,7 @@ void MESH_OT_knife_cut(wmOperatorType *ot)
ot->poll = EM_view3d_poll;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
RNA_def_enum(ot->srna, "type", knife_items, KNIFE_EXACT, "Type", "");
prop = RNA_def_property(ot->srna, "path", PROP_COLLECTION, PROP_NONE);
@@ -3095,7 +3096,7 @@ static int mesh_separate_selected(Main *bmain, Scene *scene, Base *editbase, wmO
CustomData_bmesh_init_pool(&bm_new->ldata, bm_mesh_allocsize_default.totloop, BM_LOOP);
CustomData_bmesh_init_pool(&bm_new->pdata, bm_mesh_allocsize_default.totface, BM_FACE);
basenew = ED_object_add_duplicate(bmain, scene, editbase, USER_DUP_MESH); /* 0 = fully linked */
basenew = ED_object_add_duplicate(bmain, scene, editbase, USER_DUP_MESH); /* 0 = fully linked */
assign_matarar(basenew->object, give_matarar(obedit), *give_totcolp(obedit)); /* new in 2.5 */
ED_base_object_select(basenew, BA_DESELECT);
@@ -3232,7 +3233,7 @@ static int edbm_separate_exec(bContext *C, wmOperator *op)
if (retval) {
DAG_id_tag_update(base->object->data, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, base->object->data);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, base->object->data);
return OPERATOR_FINISHED;
}
@@ -3280,14 +3281,14 @@ static int edbm_fill_exec(bContext *C, wmOperator *op)
BMO_op_exec(em->bm, &bmop);
/* select new geometry */
BMO_slot_buffer_hflag_enable(em->bm, &bmop, "geomout", BM_FACE|BM_EDGE, BM_ELEM_SELECT, TRUE);
BMO_slot_buffer_hflag_enable(em->bm, &bmop, "geomout", BM_FACE | BM_EDGE, BM_ELEM_SELECT, TRUE);
if (!EDBM_FinishOp(em, &bmop, op, TRUE)) {
return OPERATOR_CANCELLED;
}
DAG_id_tag_update(obedit->data, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
return OPERATOR_FINISHED;
@@ -3304,7 +3305,7 @@ void MESH_OT_fill(wmOperatorType *ot)
ot->poll = ED_operator_editmesh;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
static int edbm_beautify_fill_exec(bContext *C, wmOperator *op)
@@ -3316,7 +3317,7 @@ static int edbm_beautify_fill_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
DAG_id_tag_update(obedit->data, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
return OPERATOR_FINISHED;
}
@@ -3332,7 +3333,7 @@ void MESH_OT_beautify_fill(wmOperatorType *ot)
ot->poll = ED_operator_editmesh;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
/********************** Quad/Tri Operators *************************/
@@ -3347,7 +3348,7 @@ static int edbm_quads_convert_to_tris_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
DAG_id_tag_update(obedit->data, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
return OPERATOR_FINISHED;
}
@@ -3363,7 +3364,7 @@ void MESH_OT_quads_convert_to_tris(wmOperatorType *ot)
ot->poll = ED_operator_editmesh;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
RNA_def_boolean(ot->srna, "use_beauty", 1, "Beauty", "Use best triangulation division (currently quads only)");
}
@@ -3388,7 +3389,7 @@ static int edbm_tris_convert_to_quads_exec(bContext *C, wmOperator *op)
}
DAG_id_tag_update(obedit->data, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
return OPERATOR_FINISHED;
}
@@ -3406,7 +3407,7 @@ void MESH_OT_tris_convert_to_quads(wmOperatorType *ot)
ot->poll = ED_operator_editmesh;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
prop = RNA_def_float_rotation(ot->srna, "limit", 0, NULL, 0.0f, DEG2RADF(180.0f),
"Max Angle", "Angle Limit", 0.0f, DEG2RADF(180.0f));
@@ -3440,7 +3441,7 @@ static int edbm_dissolve_exec(bContext *C, wmOperator *op)
DAG_id_tag_update(obedit->data, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_GEOM|ND_DATA|ND_SELECT, obedit);
WM_event_add_notifier(C, NC_GEOM | ND_DATA | ND_SELECT, obedit);
return OPERATOR_FINISHED;
}
@@ -3457,7 +3458,7 @@ void MESH_OT_dissolve(wmOperatorType *ot)
ot->poll = ED_operator_editmesh;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* TODO, move dissolve into its own operator so this doesnt confuse non-dissolve options */
RNA_def_boolean(ot->srna, "use_verts", 0, "Dissolve Verts",
@@ -3478,7 +3479,7 @@ static int edbm_dissolve_limited_exec(bContext *C, wmOperator *op)
}
DAG_id_tag_update(obedit->data, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
return OPERATOR_FINISHED;
}
@@ -3497,7 +3498,7 @@ void MESH_OT_dissolve_limited(wmOperatorType *ot)
ot->poll = ED_operator_editmesh;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
prop = RNA_def_float_rotation(ot->srna, "angle_limit", 0, NULL, 0.0f, DEG2RADF(180.0f),
"Max Angle", "Angle Limit in Degrees", 0.0f, DEG2RADF(180.0f));
@@ -3523,7 +3524,7 @@ static int edbm_split_exec(bContext *C, wmOperator *op)
EDBM_RecalcNormals(em);
DAG_id_tag_update(ob->data, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, ob->data);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, ob->data);
return OPERATOR_FINISHED;
}
@@ -3539,7 +3540,7 @@ void MESH_OT_split(wmOperatorType *ot)
ot->poll = ED_operator_editmesh;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
@@ -3582,7 +3583,7 @@ static int edbm_spin_exec(bContext *C, wmOperator *op)
}
DAG_id_tag_update(obedit->data, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
return OPERATOR_FINISHED;
}
@@ -3612,7 +3613,7 @@ void MESH_OT_spin(wmOperatorType *ot)
ot->poll = EM_view3d_poll;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* props */
RNA_def_int(ot->srna, "steps", 9, 0, INT_MAX, "Steps", "Steps", 0, INT_MAX);
@@ -3654,13 +3655,11 @@ static int edbm_screw_exec(bContext *C, wmOperator *op)
/* find two vertices with valence count == 1, more or less is wrong */
v1 = NULL;
v2 = NULL;
for (eve = BM_iter_new(&iter, em->bm, BM_VERTS_OF_MESH, NULL);
eve; eve = BM_iter_step(&iter)) {
for (eve = BM_iter_new(&iter, em->bm, BM_VERTS_OF_MESH, NULL); eve; eve = BM_iter_step(&iter)) {
valence = 0;
for (eed = BM_iter_new(&eiter, em->bm, BM_EDGES_OF_VERT, eve);
eed; eed = BM_iter_step(&eiter)) {
for (eed = BM_iter_new(&eiter, em->bm, BM_EDGES_OF_VERT, eve); eed; eed = BM_iter_step(&eiter)) {
if (BM_elem_flag_test(eed, BM_ELEM_SELECT)) {
valence++;
@@ -3708,7 +3707,7 @@ static int edbm_screw_exec(bContext *C, wmOperator *op)
}
DAG_id_tag_update(obedit->data, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
return OPERATOR_FINISHED;
}
@@ -3738,7 +3737,7 @@ void MESH_OT_screw(wmOperatorType *ot)
ot->poll = EM_view3d_poll;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* props */
RNA_def_int(ot->srna, "steps", 9, 0, INT_MAX, "Steps", "Steps", 0, 256);
@@ -3760,7 +3759,7 @@ static int edbm_select_by_number_vertices_exec(bContext *C, wmOperator *op)
int type = RNA_enum_get(op->ptr, "type");
for (efa = BM_iter_new(&iter, em->bm, BM_FACES_OF_MESH, NULL);
efa; efa = BM_iter_step(&iter)) {
efa; efa = BM_iter_step(&iter)) {
int select = 0;
@@ -3784,19 +3783,18 @@ static int edbm_select_by_number_vertices_exec(bContext *C, wmOperator *op)
EDBM_selectmode_flush(em);
WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
return OPERATOR_FINISHED;
}
void MESH_OT_select_by_number_vertices(wmOperatorType *ot)
{
static const EnumPropertyItem type_items[] = {
{0, "LESS", 0, "Less Than", ""},
{1, "EQUAL", 0, "Equal To", ""},
{2, "GREATER", 0, "Greater Than", ""},
{3, "NOTEQUAL", 0, "Not Equal To", ""},
{0, NULL, 0, NULL, NULL}
};
{0, "LESS", 0, "Less Than", ""},
{1, "EQUAL", 0, "Equal To", ""},
{2, "GREATER", 0, "Greater Than", ""},
{3, "NOTEQUAL", 0, "Not Equal To", ""},
{0, NULL, 0, NULL, NULL}};
/* identifiers */
ot->name = "Select by Number of Vertices";
@@ -3808,7 +3806,7 @@ void MESH_OT_select_by_number_vertices(wmOperatorType *ot)
ot->poll = ED_operator_editmesh;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */
RNA_def_int(ot->srna, "number", 4, 3, INT_MAX, "Number of Vertices", "", 3, INT_MAX);
@@ -3824,7 +3822,7 @@ static int edbm_select_loose_verts_exec(bContext *C, wmOperator *UNUSED(op))
BMIter iter;
for (eve = BM_iter_new(&iter, em->bm, BM_VERTS_OF_MESH, NULL);
eve; eve = BM_iter_step(&iter)) {
eve; eve = BM_iter_step(&iter)) {
if (!eve->e) {
BM_elem_select_set(em->bm, eve, TRUE);
@@ -3832,7 +3830,7 @@ static int edbm_select_loose_verts_exec(bContext *C, wmOperator *UNUSED(op))
}
for (eed = BM_iter_new(&iter, em->bm, BM_EDGES_OF_MESH, NULL);
eed; eed = BM_iter_step(&iter)) {
eed; eed = BM_iter_step(&iter)) {
if (!eed->l) {
BM_elem_select_set(em->bm, eed, TRUE);
@@ -3841,7 +3839,7 @@ static int edbm_select_loose_verts_exec(bContext *C, wmOperator *UNUSED(op))
EDBM_selectmode_flush(em);
WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
return OPERATOR_FINISHED;
}
@@ -3857,7 +3855,7 @@ void MESH_OT_select_loose_verts(wmOperatorType *ot)
ot->poll = ED_operator_editmesh;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
static int edbm_select_mirror_exec(bContext *C, wmOperator *op)
@@ -3868,7 +3866,7 @@ static int edbm_select_mirror_exec(bContext *C, wmOperator *op)
EDBM_select_mirrored(obedit, em, extend);
EDBM_selectmode_flush(em);
WM_event_add_notifier(C, NC_GEOM|ND_SELECT, obedit->data);
WM_event_add_notifier(C, NC_GEOM | ND_SELECT, obedit->data);
return OPERATOR_FINISHED;
}
@@ -3885,7 +3883,7 @@ void MESH_OT_select_mirror(wmOperatorType *ot)
ot->poll = ED_operator_editmesh;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* props */
RNA_def_boolean(ot->srna, "extend", 0, "Extend", "Extend the existing selection");
@@ -3907,8 +3905,8 @@ static int vergxco(const void *v1, const void *v2)
{
const xvertsort *x1 = v1, *x2 = v2;
if (x1->x > x2->x) return 1;
else if (x1->x < x2->x) return -1;
if (x1->x > x2->x) return 1;
else if (x1->x < x2->x) return -1;
return 0;
}
@@ -3921,8 +3919,8 @@ static int vergface(const void *v1, const void *v2)
{
const struct facesort *x1 = v1, *x2 = v2;
if (x1->x > x2->x) return 1;
else if (x1->x < x2->x) return -1;
if (x1->x > x2->x) return 1;
else if (x1->x < x2->x) return -1;
return 0;
}
#endif
@@ -3956,7 +3954,8 @@ static void xsortvert_flag(bContext *UNUSED(C), int UNUSED(flag))
amount = em->bm->totvert;
sortblock = MEM_callocN(sizeof(xvertsort) * amount, "xsort");
BM_ITER(eve, &iter, em->bm, BM_VERTS_OF_MESH, NULL) {
BM_ITER(eve, &iter, em->bm, BM_VERTS_OF_MESH, NULL)
{
if (BM_elem_flag_test(eve, BM_ELEM_SELECT))
sortblock[i].v1 = eve;
}
@@ -3966,7 +3965,7 @@ static void xsortvert_flag(bContext *UNUSED(C), int UNUSED(flag))
qsort(sortblock, amount, sizeof(xvertsort), vergxco);
/* make temporal listbase */
/* make temporal listbase */
tbase.first = tbase.last = 0;
for (i = 0; i < amount; i++) {
eve = sortblock[i].v1;
@@ -4003,7 +4002,7 @@ void MESH_OT_vertices_sort(wmOperatorType *ot)
ot->poll = EM_view3d_poll; /* uses view relative X axis to sort verts */
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
/* ********************** SORT FACES ******************* */
@@ -4099,7 +4098,7 @@ static int edbm_sort_faces_exec(bContext *C, wmOperator *op)
float cur[3];
if (event == 1)
mult_m4_m4m4(mat, rv3d->viewmat, OBACT->obmat); /* apply the view matrix to the object matrix */
mult_m4_m4m4(mat, rv3d->viewmat, OBACT->obmat); /* apply the view matrix to the object matrix */
else if (event == 2) { /* sort from cursor */
if (v3d && v3d->localvd) {
copy_v3_v3(cur, v3d->cursor);
@@ -4182,7 +4181,7 @@ void MESH_OT_sort_faces(wmOperatorType *ot)
ot->poll = ED_operator_editmesh;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */
ot->prop = RNA_def_enum(ot->srna, "type", type_items, 0, "Type", "");
@@ -4273,7 +4272,7 @@ void MESH_OT_vertices_randomize(wmOperatorType *ot)
ot->poll = ED_operator_editmesh;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
/******end of qsort stuff ****/
@@ -4328,7 +4327,7 @@ static int edbm_noise_exec(bContext *C, wmOperator *op)
EDBM_RecalcNormals(em);
DAG_id_tag_update(obedit->data, 0);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
return OPERATOR_FINISHED;
}
@@ -4345,7 +4344,7 @@ void MESH_OT_noise(wmOperatorType *ot)
ot->poll = ED_operator_editmesh;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
RNA_def_float(ot->srna, "factor", 0.1f, -FLT_MAX, FLT_MAX, "Factor", "", 0.0f, 1.0f);
}
@@ -4417,7 +4416,7 @@ static int edbm_bevel_exec(bContext *C, wmOperator *op)
EDBM_RecalcNormals(em);
DAG_id_tag_update(obedit->data, 0);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
return OPERATOR_FINISHED;
}
@@ -4434,7 +4433,7 @@ void MESH_OT_bevel(wmOperatorType *ot)
ot->poll = ED_operator_editmesh;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
RNA_def_float(ot->srna, "percent", 0.5f, -FLT_MAX, FLT_MAX, "Percentage", "", 0.0f, 1.0f);
RNA_def_int(ot->srna, "recursion", 1, 1, 50, "Recursion Level", "Recursion Level", 1, 8);
@@ -4453,7 +4452,7 @@ static int edbm_bridge_edge_loops_exec(bContext *C, wmOperator *op)
return OPERATOR_CANCELLED;
DAG_id_tag_update(obedit->data, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
return OPERATOR_FINISHED;
}
@@ -4470,7 +4469,7 @@ void MESH_OT_bridge_edge_loops(wmOperatorType *ot)
ot->poll = ED_operator_editmesh;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
RNA_def_boolean(ot->srna, "inside", 0, "Inside", "");
}
@@ -4504,7 +4503,7 @@ static int edbm_inset_exec(bContext *C, wmOperator *op)
}
else {
DAG_id_tag_update(obedit->data, 0);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
return OPERATOR_FINISHED;
}
@@ -4524,7 +4523,7 @@ void MESH_OT_inset(wmOperatorType *ot)
ot->description = "";
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
/* properties */
// RNA_def_boolean(ot->srna, "use_boundary", TRUE, "Boundary", "Inset face boundries");

View File

@@ -214,7 +214,7 @@ int EDBM_CallAndSelectOpf(BMEditMesh *em, wmOperator *op, const char *selectslot
BMO_op_exec(bm, &bmop);
BM_mesh_elem_flag_disable_all(em->bm, BM_VERT|BM_EDGE|BM_FACE, BM_ELEM_SELECT);
BM_mesh_elem_flag_disable_all(em->bm, BM_VERT | BM_EDGE | BM_FACE, BM_ELEM_SELECT);
BMO_slot_buffer_hflag_enable(em->bm, &bmop, selectslot, BM_ALL, BM_ELEM_SELECT, TRUE);
@@ -257,7 +257,7 @@ void EDBM_selectmode_to_scene(bContext *C)
scene->toolsettings->selectmode = em->selectmode;
/* Request redraw of header buttons (to show new select mode) */
WM_event_add_notifier(C, NC_SCENE|ND_TOOLSETTINGS, scene);
WM_event_add_notifier(C, NC_SCENE | ND_TOOLSETTINGS, scene);
}
void EDBM_MakeEditBMesh(ToolSettings *ts, Scene *UNUSED(scene), Object *ob)
@@ -376,12 +376,12 @@ void EDBM_free_index_arrays(BMEditMesh *tm)
BMVert *EDBM_get_vert_for_index(BMEditMesh *tm, int index)
{
return tm->vert_index && index < tm->bm->totvert ?tm->vert_index[index]:NULL;
return tm->vert_index && index < tm->bm->totvert ? tm->vert_index[index] : NULL;
}
BMEdge *EDBM_get_edge_for_index(BMEditMesh *tm, int index)
{
return tm->edge_index && index < tm->bm->totedge ?tm->edge_index[index]:NULL;
return tm->edge_index && index < tm->bm->totedge ? tm->edge_index[index] : NULL;
}
BMFace *EDBM_get_face_for_index(BMEditMesh *tm, int index)
@@ -483,12 +483,12 @@ int EDBM_get_actSelection(BMEditMesh *em, BMEditSelection *ese)
void EDBM_flag_disable_all(BMEditMesh *em, const char hflag)
{
BM_mesh_elem_flag_disable_all(em->bm, BM_VERT|BM_EDGE|BM_FACE, hflag);
BM_mesh_elem_flag_disable_all(em->bm, BM_VERT | BM_EDGE | BM_FACE, hflag);
}
void EDBM_flag_enable_all(BMEditMesh *em, const char hflag)
{
BM_mesh_elem_flag_enable_all(em->bm, BM_VERT|BM_EDGE|BM_FACE, hflag);
BM_mesh_elem_flag_enable_all(em->bm, BM_VERT | BM_EDGE | BM_FACE, hflag);
}
/**************-------------- Undo ------------*****************/
@@ -998,7 +998,7 @@ int EDBM_texFaceCheck(BMEditMesh *em)
{
/* some of these checks could be a touch overkill */
return em && em->bm->totface && CustomData_has_layer(&em->bm->pdata, CD_MTEXPOLY) &&
CustomData_has_layer(&em->bm->ldata, CD_MLOOPUV);
CustomData_has_layer(&em->bm->ldata, CD_MLOOPUV);
}
int EDBM_vertColorCheck(BMEditMesh *em)
@@ -1052,7 +1052,7 @@ void EDBM_CacheMirrorVerts(BMEditMesh *em, const short use_select)
ED_mesh_mirrtopo_init(me, -1, &mesh_topo_store, TRUE);
}
else {
tree = BMBVH_NewBVH(em, 0, NULL, NULL);
tree = BMBVH_NewBVH(em, 0, NULL, NULL);
}
BM_ITER(v, &iter, bm, BM_VERTS_OF_MESH, NULL) {
@@ -1198,8 +1198,7 @@ void EDBM_reveal_mesh(BMEditMesh *em)
int sels[3] = {(em->selectmode & SCE_SELECT_VERTEX),
(em->selectmode & SCE_SELECT_EDGE),
(em->selectmode & SCE_SELECT_FACE),
};
(em->selectmode & SCE_SELECT_FACE), };
BMIter iter;
BMElem *ele;

View File

@@ -79,8 +79,8 @@ static void delete_customdata_layer(bContext *C, Object *ob, CustomDataLayer *la
{
Mesh *me = ob->data;
CustomData *data;
void *actlayerdata, *rndlayerdata, *clonelayerdata, *stencillayerdata, *layerdata=layer->data;
int type= layer->type;
void *actlayerdata, *rndlayerdata, *clonelayerdata, *stencillayerdata, *layerdata = layer->data;
int type = layer->type;
int index;
int i, actindex, rndindex, cloneindex, stencilindex, tot;
@@ -135,7 +135,7 @@ static void delete_customdata_layer(bContext *C, Object *ob, CustomDataLayer *la
if (actlayerdata != layerdata) {
/* find index */
actindex = CustomData_get_layer_index(data, type);
for (i=actindex; i<data->totlayer; i++) {
for (i = actindex; i < data->totlayer; i++) {
if (data->layers[i].data == actlayerdata) {
actindex = i - actindex;
break;
@@ -149,7 +149,7 @@ static void delete_customdata_layer(bContext *C, Object *ob, CustomDataLayer *la
if (rndlayerdata != layerdata) {
/* find index */
rndindex = CustomData_get_layer_index(data, type);
for (i=rndindex; i<data->totlayer; i++) {
for (i = rndindex; i < data->totlayer; i++) {
if (data->layers[i].data == rndlayerdata) {
rndindex = i - rndindex;
break;
@@ -163,7 +163,7 @@ static void delete_customdata_layer(bContext *C, Object *ob, CustomDataLayer *la
if (clonelayerdata != layerdata) {
/* find index */
cloneindex = CustomData_get_layer_index(data, type);
for (i=cloneindex; i<data->totlayer; i++) {
for (i = cloneindex; i < data->totlayer; i++) {
if (data->layers[i].data == clonelayerdata) {
cloneindex = i - cloneindex;
break;
@@ -177,7 +177,7 @@ static void delete_customdata_layer(bContext *C, Object *ob, CustomDataLayer *la
if (stencillayerdata != layerdata) {
/* find index */
stencilindex = CustomData_get_layer_index(data, type);
for (i=stencilindex; i<data->totlayer; i++) {
for (i = stencilindex; i < data->totlayer; i++) {
if (data->layers[i].data == stencillayerdata) {
stencilindex = i - stencilindex;
break;
@@ -197,10 +197,10 @@ static void copy_editface_active_customdata(BMEditMesh *em, int type, int index)
(void)index;
#else
EditFace *efa;
int n= CustomData_get_active_layer(&em->fdata, type);
int n = CustomData_get_active_layer(&em->fdata, type);
for (efa= em->faces.first; efa; efa= efa->next) {
void *data= CustomData_em_get_n(&em->fdata, efa->data, type, n);
for (efa = em->faces.first; efa; efa = efa->next) {
void *data = CustomData_em_get_n(&em->fdata, efa->data, type, n);
CustomData_em_set_n(&em->fdata, efa->data, type, index, data);
}
#endif
@@ -208,7 +208,7 @@ static void copy_editface_active_customdata(BMEditMesh *em, int type, int index)
int ED_mesh_uv_loop_reset_ex(struct bContext *C, struct Mesh *me, const int layernum)
{
BMEditMesh *em= me->edit_btmesh;
BMEditMesh *em = me->edit_btmesh;
MLoopUV *luv;
BLI_array_declare(polylengths);
int *polylengths = NULL;
@@ -287,12 +287,12 @@ int ED_mesh_uv_loop_reset_ex(struct bContext *C, struct Mesh *me, const int laye
fuvs[3][0] = 0.0;
fuvs[3][1] = 1.0;
/*make sure we ignore 2-sided faces*/
/*make sure we ignore 2-sided faces*/
}
else if (len > 2) {
float fac = 0.0f, dfac = 1.0f / (float)len;
dfac *= M_PI*2;
dfac *= M_PI * 2;
for (i = 0; i < len; i++) {
fuvs[i][0] = 0.5f * sin(fac) + 0.5f;
@@ -309,7 +309,7 @@ int ED_mesh_uv_loop_reset_ex(struct bContext *C, struct Mesh *me, const int laye
BLI_array_free(polylengths);
DAG_id_tag_update(&me->id, 0);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, me);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, me);
return 1;
}
@@ -328,7 +328,7 @@ int ED_mesh_uv_texture_add(bContext *C, Mesh *me, const char *name, int active_s
int layernum;
if (me->edit_btmesh) {
em= me->edit_btmesh;
em = me->edit_btmesh;
layernum = CustomData_number_of_layers(&em->bm->pdata, CD_MTEXPOLY);
if (layernum >= MAX_MTFACE)
@@ -383,7 +383,7 @@ int ED_mesh_uv_texture_add(bContext *C, Mesh *me, const char *name, int active_s
ED_mesh_uv_loop_reset_ex(C, me, layernum);
DAG_id_tag_update(&me->id, 0);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, me);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, me);
return layernum;
}
@@ -394,11 +394,11 @@ int ED_mesh_uv_texture_remove(bContext *C, Object *ob, Mesh *me)
CustomDataLayer *cdlp, *cdlu;
int index;
index= CustomData_get_active_layer_index(pdata, CD_MTEXPOLY);
cdlp= (index == -1)? NULL: &pdata->layers[index];
index = CustomData_get_active_layer_index(pdata, CD_MTEXPOLY);
cdlp = (index == -1) ? NULL : &pdata->layers[index];
index= CustomData_get_active_layer_index(ldata, CD_MLOOPUV);
cdlu= (index == -1)? NULL: &ldata->layers[index];
index = CustomData_get_active_layer_index(ldata, CD_MLOOPUV);
cdlu = (index == -1) ? NULL : &ldata->layers[index];
if (!cdlp || !cdlu)
return 0;
@@ -407,7 +407,7 @@ int ED_mesh_uv_texture_remove(bContext *C, Object *ob, Mesh *me)
delete_customdata_layer(C, ob, cdlu);
DAG_id_tag_update(&me->id, 0);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, me);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, me);
return 1;
}
@@ -418,9 +418,9 @@ int ED_mesh_color_add(bContext *C, Scene *UNUSED(scene), Object *UNUSED(ob), Mes
int layernum;
if (me->edit_btmesh) {
em= me->edit_btmesh;
em = me->edit_btmesh;
layernum= CustomData_number_of_layers(&em->bm->ldata, CD_MLOOPCOL);
layernum = CustomData_number_of_layers(&em->bm->ldata, CD_MLOOPCOL);
if (layernum >= MAX_MCOL) {
return -1;
}
@@ -438,7 +438,7 @@ int ED_mesh_color_add(bContext *C, Scene *UNUSED(scene), Object *UNUSED(ob), Mes
}
}
else {
layernum= CustomData_number_of_layers(&me->ldata, CD_MLOOPCOL);
layernum = CustomData_number_of_layers(&me->ldata, CD_MLOOPCOL);
if (layernum >= CD_MLOOPCOL) {
return -1;
}
@@ -452,7 +452,7 @@ int ED_mesh_color_add(bContext *C, Scene *UNUSED(scene), Object *UNUSED(ob), Mes
CustomData_add_layer_named(&me->fdata, CD_MCOL, CD_DEFAULT, NULL, me->totface, name);
}
if (active_set || layernum==0) {
if (active_set || layernum == 0) {
CustomData_set_layer_active(&me->ldata, CD_MLOOPCOL, layernum);
CustomData_set_layer_active(&me->fdata, CD_MCOL, layernum);
}
@@ -461,7 +461,7 @@ int ED_mesh_color_add(bContext *C, Scene *UNUSED(scene), Object *UNUSED(ob), Mes
}
DAG_id_tag_update(&me->id, 0);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, me);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, me);
return layernum;
}
@@ -472,15 +472,15 @@ int ED_mesh_color_remove(bContext *C, Object *ob, Mesh *me)
CustomDataLayer *cdl;
int index;
index= CustomData_get_active_layer_index(ldata, CD_MLOOPCOL);
cdl= (index == -1)? NULL: &ldata->layers[index];
index = CustomData_get_active_layer_index(ldata, CD_MLOOPCOL);
cdl = (index == -1) ? NULL : &ldata->layers[index];
if (!cdl)
return 0;
delete_customdata_layer(C, ob, cdl);
DAG_id_tag_update(&me->id, 0);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, me);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, me);
return 1;
}
@@ -491,7 +491,7 @@ int ED_mesh_color_remove_named(bContext *C, Object *ob, Mesh *me, const char *na
CustomDataLayer *cdl;
int index;
index= CustomData_get_named_layer_index(ldata, CD_MLOOPCOL, name);
index = CustomData_get_named_layer_index(ldata, CD_MLOOPCOL, name);
cdl = (index == -1) ? NULL : &ldata->layers[index];
if (!cdl)
@@ -499,7 +499,7 @@ int ED_mesh_color_remove_named(bContext *C, Object *ob, Mesh *me, const char *na
delete_customdata_layer(C, ob, cdl);
DAG_id_tag_update(&me->id, 0);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, me);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, me);
return 1;
}
@@ -508,15 +508,15 @@ int ED_mesh_color_remove_named(bContext *C, Object *ob, Mesh *me, const char *na
static int layers_poll(bContext *C)
{
Object *ob= ED_object_context(C);
ID *data= (ob)? ob->data: NULL;
return (ob && !ob->id.lib && ob->type==OB_MESH && data && !data->lib);
Object *ob = ED_object_context(C);
ID *data = (ob) ? ob->data : NULL;
return (ob && !ob->id.lib && ob->type == OB_MESH && data && !data->lib);
}
static int mesh_uv_texture_add_exec(bContext *C, wmOperator *UNUSED(op))
{
Object *ob= ED_object_context(C);
Mesh *me= ob->data;
Object *ob = ED_object_context(C);
Mesh *me = ob->data;
if (ED_mesh_uv_texture_add(C, me, NULL, TRUE) == -1)
return OPERATOR_CANCELLED;
@@ -536,23 +536,23 @@ void MESH_OT_uv_texture_add(wmOperatorType *ot)
ot->exec = mesh_uv_texture_add_exec;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
static int drop_named_image_invoke(bContext *C, wmOperator *op, wmEvent *event)
{
Main *bmain= CTX_data_main(C);
Scene *scene= CTX_data_scene(C);
View3D *v3d= CTX_wm_view3d(C);
Base *base= ED_view3d_give_base_under_cursor(C, event->mval);
Image *ima= NULL;
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
View3D *v3d = CTX_wm_view3d(C);
Base *base = ED_view3d_give_base_under_cursor(C, event->mval);
Image *ima = NULL;
Mesh *me;
Object *obedit;
int exitmode= 0;
char name[MAX_ID_NAME-2];
int exitmode = 0;
char name[MAX_ID_NAME - 2];
/* Check context */
if (base==NULL || base->object->type!=OB_MESH) {
if (base == NULL || base->object->type != OB_MESH) {
BKE_report(op->reports, RPT_ERROR, "Not an Object or Mesh");
return OPERATOR_CANCELLED;
}
@@ -562,11 +562,11 @@ static int drop_named_image_invoke(bContext *C, wmOperator *op, wmEvent *event)
char path[FILE_MAX];
RNA_string_get(op->ptr, "filepath", path);
ima= BKE_add_image_file(path);
ima = BKE_add_image_file(path);
}
else {
RNA_string_get(op->ptr, "name", name);
ima= (Image *)find_id("IM", name);
ima = (Image *)find_id("IM", name);
}
if (!ima) {
@@ -576,13 +576,13 @@ static int drop_named_image_invoke(bContext *C, wmOperator *op, wmEvent *event)
/* put mesh in editmode */
obedit= base->object;
me= obedit->data;
if (me->edit_btmesh==NULL) {
obedit = base->object;
me = obedit->data;
if (me->edit_btmesh == NULL) {
EDBM_MakeEditBMesh(scene->toolsettings, scene, obedit);
exitmode= 1;
exitmode = 1;
}
if (me->edit_btmesh==NULL)
if (me->edit_btmesh == NULL)
return OPERATOR_CANCELLED;
ED_uvedit_assign_image(bmain, scene, obedit, ima, NULL);
@@ -591,7 +591,7 @@ static int drop_named_image_invoke(bContext *C, wmOperator *op, wmEvent *event)
EDBM_LoadEditBMesh(scene, obedit);
EDBM_FreeEditBMesh(me->edit_btmesh);
MEM_freeN(me->edit_btmesh);
me->edit_btmesh= NULL;
me->edit_btmesh = NULL;
/* load_editMesh free's pointers used by CustomData layers which might be used by DerivedMesh too,
* so signal to re-create DerivedMesh here (sergey) */
@@ -602,7 +602,7 @@ static int drop_named_image_invoke(bContext *C, wmOperator *op, wmEvent *event)
if (v3d)
v3d->flag2 |= V3D_SOLID_TEX;
WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
return OPERATOR_FINISHED;
}
@@ -622,14 +622,14 @@ void MESH_OT_drop_named_image(wmOperatorType *ot)
ot->flag = OPTYPE_UNDO;
/* properties */
RNA_def_string(ot->srna, "name", "Image", MAX_ID_NAME-2, "Name", "Image name to assign");
RNA_def_string(ot->srna, "name", "Image", MAX_ID_NAME - 2, "Name", "Image name to assign");
RNA_def_string(ot->srna, "filepath", "Path", FILE_MAX, "Filepath", "Path to image file");
}
static int mesh_uv_texture_remove_exec(bContext *C, wmOperator *UNUSED(op))
{
Object *ob= ED_object_context(C);
Mesh *me= ob->data;
Object *ob = ED_object_context(C);
Mesh *me = ob->data;
if (!ED_mesh_uv_texture_remove(C, ob, me))
return OPERATOR_CANCELLED;
@@ -649,16 +649,16 @@ void MESH_OT_uv_texture_remove(wmOperatorType *ot)
ot->exec = mesh_uv_texture_remove_exec;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
/*********************** vertex color operators ************************/
static int mesh_vertex_color_add_exec(bContext *C, wmOperator *UNUSED(op))
{
Scene *scene= CTX_data_scene(C);
Object *ob= ED_object_context(C);
Mesh *me= ob->data;
Scene *scene = CTX_data_scene(C);
Object *ob = ED_object_context(C);
Mesh *me = ob->data;
if (ED_mesh_color_add(C, scene, ob, me, NULL, TRUE) == -1)
return OPERATOR_CANCELLED;
@@ -678,13 +678,13 @@ void MESH_OT_vertex_color_add(wmOperatorType *ot)
ot->exec = mesh_vertex_color_add_exec;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
static int mesh_vertex_color_remove_exec(bContext *C, wmOperator *UNUSED(op))
{
Object *ob= ED_object_context(C);
Mesh *me= ob->data;
Object *ob = ED_object_context(C);
Mesh *me = ob->data;
if (!ED_mesh_color_remove(C, ob, me))
return OPERATOR_CANCELLED;
@@ -704,17 +704,17 @@ void MESH_OT_vertex_color_remove(wmOperatorType *ot)
ot->poll = layers_poll;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
/*********************** sticky operators ************************/
static int mesh_sticky_add_exec(bContext *C, wmOperator *UNUSED(op))
{
Scene *scene= CTX_data_scene(C);
View3D *v3d= CTX_wm_view3d(C);
Object *ob= ED_object_context(C);
Mesh *me= ob->data;
Scene *scene = CTX_data_scene(C);
View3D *v3d = CTX_wm_view3d(C);
Object *ob = ED_object_context(C);
Mesh *me = ob->data;
/* why is this commented out? */
#if 0
@@ -725,7 +725,7 @@ static int mesh_sticky_add_exec(bContext *C, wmOperator *UNUSED(op))
RE_make_sticky(scene, v3d);
DAG_id_tag_update(&me->id, 0);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, me);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, me);
return OPERATOR_FINISHED;
}
@@ -742,22 +742,22 @@ void MESH_OT_sticky_add(wmOperatorType *ot)
ot->exec = mesh_sticky_add_exec;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
static int mesh_sticky_remove_exec(bContext *C, wmOperator *UNUSED(op))
{
Object *ob= ED_object_context(C);
Mesh *me= ob->data;
Object *ob = ED_object_context(C);
Mesh *me = ob->data;
if (!me->msticky)
return OPERATOR_CANCELLED;
CustomData_free_layer_active(&me->vdata, CD_MSTICKY, me->totvert);
me->msticky= NULL;
me->msticky = NULL;
DAG_id_tag_update(&me->id, 0);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, me);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, me);
return OPERATOR_FINISHED;
}
@@ -774,7 +774,7 @@ void MESH_OT_sticky_remove(wmOperatorType *ot)
ot->exec = mesh_sticky_remove_exec;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
/************************** Add Geometry Layers *************************/
@@ -832,7 +832,7 @@ void ED_mesh_update(Mesh *mesh, bContext *C, int calc_edges, int calc_tessface)
#endif
DAG_id_tag_update(&mesh->id, 0);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, mesh);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, mesh);
}
static void mesh_add_verts(Mesh *mesh, int len)
@@ -844,7 +844,7 @@ static void mesh_add_verts(Mesh *mesh, int len)
if (len == 0)
return;
totvert= mesh->totvert + len;
totvert = mesh->totvert + len;
CustomData_copy(&mesh->vdata, &vdata, CD_MASK_MESH, CD_DEFAULT, totvert);
CustomData_copy_data(&mesh->vdata, &vdata, 0, 0, mesh->totvert);
@@ -852,25 +852,25 @@ static void mesh_add_verts(Mesh *mesh, int len)
CustomData_add_layer(&vdata, CD_MVERT, CD_CALLOC, NULL, totvert);
CustomData_free(&mesh->vdata, mesh->totvert);
mesh->vdata= vdata;
mesh->vdata = vdata;
mesh_update_customdata_pointers(mesh, FALSE);
/* scan the input list and insert the new vertices */
mvert= &mesh->mvert[mesh->totvert];
for (i=0; i<len; i++, mvert++)
mvert = &mesh->mvert[mesh->totvert];
for (i = 0; i < len; i++, mvert++)
mvert->flag |= SELECT;
/* set final vertex list size */
mesh->totvert= totvert;
mesh->totvert = totvert;
}
void ED_mesh_transform(Mesh *me, float *mat)
{
int i;
MVert *mvert= me->mvert;
MVert *mvert = me->mvert;
for (i= 0; i < me->totvert; i++, mvert++)
for (i = 0; i < me->totvert; i++, mvert++)
mul_m4_v3((float (*)[4])mat, mvert->co);
mesh_calc_normals_mapping(me->mvert, me->totvert, me->mloop, me->mpoly, me->totloop, me->totpoly, NULL, NULL, 0, NULL, NULL);
@@ -885,7 +885,7 @@ static void mesh_add_edges(Mesh *mesh, int len)
if (len == 0)
return;
totedge= mesh->totedge+len;
totedge = mesh->totedge + len;
/* update customdata */
CustomData_copy(&mesh->edata, &edata, CD_MASK_MESH, CD_DEFAULT, totedge);
@@ -895,15 +895,15 @@ static void mesh_add_edges(Mesh *mesh, int len)
CustomData_add_layer(&edata, CD_MEDGE, CD_CALLOC, NULL, totedge);
CustomData_free(&mesh->edata, mesh->totedge);
mesh->edata= edata;
mesh->edata = edata;
mesh_update_customdata_pointers(mesh, FALSE); /* new edges don't change tessellation */
/* set default flags */
medge= &mesh->medge[mesh->totedge];
for (i=0; i<len; i++, medge++)
medge->flag= ME_EDGEDRAW|ME_EDGERENDER|SELECT;
medge = &mesh->medge[mesh->totedge];
for (i = 0; i < len; i++, medge++)
medge->flag = ME_EDGEDRAW | ME_EDGERENDER | SELECT;
mesh->totedge= totedge;
mesh->totedge = totedge;
}
static void mesh_add_faces(Mesh *mesh, int len)
@@ -915,7 +915,7 @@ static void mesh_add_faces(Mesh *mesh, int len)
if (len == 0)
return;
totface= mesh->totface + len; /* new face count */
totface = mesh->totface + len; /* new face count */
/* update customdata */
CustomData_copy(&mesh->fdata, &fdata, CD_MASK_MESH, CD_DEFAULT, totface);
@@ -925,15 +925,15 @@ static void mesh_add_faces(Mesh *mesh, int len)
CustomData_add_layer(&fdata, CD_MFACE, CD_CALLOC, NULL, totface);
CustomData_free(&mesh->fdata, mesh->totface);
mesh->fdata= fdata;
mesh->fdata = fdata;
mesh_update_customdata_pointers(mesh, TRUE);
/* set default flags */
mface= &mesh->mface[mesh->totface];
for (i=0; i<len; i++, mface++)
mface->flag= ME_FACE_SEL;
mface = &mesh->mface[mesh->totface];
for (i = 0; i < len; i++, mface++)
mface->flag = ME_FACE_SEL;
mesh->totface= totface;
mesh->totface = totface;
}
static void mesh_add_loops(Mesh *mesh, int len)
@@ -944,7 +944,7 @@ static void mesh_add_loops(Mesh *mesh, int len)
if (len == 0)
return;
totloop= mesh->totloop + len; /* new face count */
totloop = mesh->totloop + len; /* new face count */
/* update customdata */
CustomData_copy(&mesh->ldata, &ldata, CD_MASK_MESH, CD_DEFAULT, totloop);
@@ -954,10 +954,10 @@ static void mesh_add_loops(Mesh *mesh, int len)
CustomData_add_layer(&ldata, CD_MLOOP, CD_CALLOC, NULL, totloop);
CustomData_free(&mesh->ldata, mesh->totloop);
mesh->ldata= ldata;
mesh->ldata = ldata;
mesh_update_customdata_pointers(mesh, TRUE);
mesh->totloop= totloop;
mesh->totloop = totloop;
}
static void mesh_add_polys(Mesh *mesh, int len)
@@ -969,7 +969,7 @@ static void mesh_add_polys(Mesh *mesh, int len)
if (len == 0)
return;
totpoly= mesh->totpoly + len; /* new face count */
totpoly = mesh->totpoly + len; /* new face count */
/* update customdata */
CustomData_copy(&mesh->pdata, &pdata, CD_MASK_MESH, CD_DEFAULT, totpoly);
@@ -979,15 +979,15 @@ static void mesh_add_polys(Mesh *mesh, int len)
CustomData_add_layer(&pdata, CD_MPOLY, CD_CALLOC, NULL, totpoly);
CustomData_free(&mesh->pdata, mesh->totpoly);
mesh->pdata= pdata;
mesh->pdata = pdata;
mesh_update_customdata_pointers(mesh, TRUE);
/* set default flags */
mpoly= &mesh->mpoly[mesh->totpoly];
for (i=0; i<len; i++, mpoly++)
mpoly->flag= ME_FACE_SEL;
mpoly = &mesh->mpoly[mesh->totpoly];
for (i = 0; i < len; i++, mpoly++)
mpoly->flag = ME_FACE_SEL;
mesh->totpoly= totpoly;
mesh->totpoly = totpoly;
}
static void mesh_remove_verts(Mesh *mesh, int len)
@@ -997,11 +997,11 @@ static void mesh_remove_verts(Mesh *mesh, int len)
if (len == 0)
return;
totvert= mesh->totvert - len;
totvert = mesh->totvert - len;
CustomData_free_elem(&mesh->vdata, totvert, len);
/* set final vertex list size */
mesh->totvert= totvert;
mesh->totvert = totvert;
}
static void mesh_remove_edges(Mesh *mesh, int len)
@@ -1011,10 +1011,10 @@ static void mesh_remove_edges(Mesh *mesh, int len)
if (len == 0)
return;
totedge= mesh->totedge - len;
totedge = mesh->totedge - len;
CustomData_free_elem(&mesh->edata, totedge, len);
mesh->totedge= totedge;
mesh->totedge = totedge;
}
static void mesh_remove_faces(Mesh *mesh, int len)
@@ -1024,10 +1024,10 @@ static void mesh_remove_faces(Mesh *mesh, int len)
if (len == 0)
return;
totface= mesh->totface - len; /* new face count */
totface = mesh->totface - len; /* new face count */
CustomData_free_elem(&mesh->fdata, totface, len);
mesh->totface= totface;
mesh->totface = totface;
}
#if 0
@@ -1061,7 +1061,7 @@ void ED_mesh_edges_add(Mesh *mesh, ReportList *reports, int count)
{
if (mesh->edit_btmesh) {
BKE_report(reports, RPT_ERROR, "Can't add edges in edit mode");
return;
return;
}
mesh_add_edges(mesh, count);
@@ -1123,7 +1123,7 @@ void ED_mesh_loops_add(Mesh *mesh, ReportList *reports, int count)
{
if (mesh->edit_btmesh) {
BKE_report(reports, RPT_ERROR, "Can't add loops in edit mode.");
return;
return;
}
mesh_add_loops(mesh, count);

View File

@@ -85,89 +85,90 @@ static void createVertsTrisData(bContext *C, LinkNode *obs, int *nverts_r, float
ntris = 0;
/* calculate number of verts and tris */
for (oblink = obs; oblink; oblink= oblink->next) {
ob= (Object*) oblink->link;
dm= mesh_create_derived_no_virtual(scene, ob, NULL, CD_MASK_MESH);
BLI_linklist_append(&dms, (void*)dm);
for (oblink = obs; oblink; oblink = oblink->next) {
ob = (Object *) oblink->link;
dm = mesh_create_derived_no_virtual(scene, ob, NULL, CD_MASK_MESH);
BLI_linklist_append(&dms, (void *)dm);
nverts+= dm->getNumVerts(dm);
nfaces= dm->getNumTessFaces(dm);
ntris+= nfaces;
nverts += dm->getNumVerts(dm);
nfaces = dm->getNumTessFaces(dm);
ntris += nfaces;
/* resolve quad faces */
mface= dm->getTessFaceArray(dm);
for (i= 0; i<nfaces; i++) {
MFace *mf= &mface[i];
mface = dm->getTessFaceArray(dm);
for (i = 0; i < nfaces; i++) {
MFace *mf = &mface[i];
if (mf->v4)
ntris+=1;
ntris += 1;
}
}
/* create data */
verts= MEM_mallocN(sizeof(float)*3*nverts, "createVertsTrisData verts");
tris= MEM_mallocN(sizeof(int)*3*ntris, "createVertsTrisData faces");
verts = MEM_mallocN(sizeof(float) * 3 * nverts, "createVertsTrisData verts");
tris = MEM_mallocN(sizeof(int) * 3 * ntris, "createVertsTrisData faces");
basenverts= 0;
tri= tris;
for (oblink= obs, dmlink= dms; oblink && dmlink;
oblink= oblink->next, dmlink= dmlink->next) {
ob= (Object*) oblink->link;
dm= (DerivedMesh*) dmlink->link;
basenverts = 0;
tri = tris;
for (oblink = obs, dmlink = dms; oblink && dmlink;
oblink = oblink->next, dmlink = dmlink->next)
{
ob = (Object *) oblink->link;
dm = (DerivedMesh *) dmlink->link;
curnverts= dm->getNumVerts(dm);
mvert= dm->getVertArray(dm);
curnverts = dm->getNumVerts(dm);
mvert = dm->getVertArray(dm);
/* copy verts */
for (i= 0; i<curnverts; i++) {
MVert *v= &mvert[i];
for (i = 0; i < curnverts; i++) {
MVert *v = &mvert[i];
copy_v3_v3(co, v->co);
mul_v3_m4v3(wco, ob->obmat, co);
verts[3*(basenverts+i)+0]= wco[0];
verts[3*(basenverts+i)+1]= wco[2];
verts[3*(basenverts+i)+2]= wco[1];
verts[3 * (basenverts + i) + 0] = wco[0];
verts[3 * (basenverts + i) + 1] = wco[2];
verts[3 * (basenverts + i) + 2] = wco[1];
}
/* create tris */
curnfaces= dm->getNumTessFaces(dm);
mface= dm->getTessFaceArray(dm);
curnfaces = dm->getNumTessFaces(dm);
mface = dm->getTessFaceArray(dm);
for (i= 0; i<curnfaces; i++) {
MFace *mf= &mface[i];
for (i = 0; i < curnfaces; i++) {
MFace *mf = &mface[i];
tri[0]= basenverts + mf->v1;
tri[1]= basenverts + mf->v3;
tri[2]= basenverts + mf->v2;
tri[0] = basenverts + mf->v1;
tri[1] = basenverts + mf->v3;
tri[2] = basenverts + mf->v2;
tri += 3;
if (mf->v4) {
tri[0]= basenverts + mf->v1;
tri[1]= basenverts + mf->v4;
tri[2]= basenverts + mf->v3;
tri[0] = basenverts + mf->v1;
tri[1] = basenverts + mf->v4;
tri[2] = basenverts + mf->v3;
tri += 3;
}
}
basenverts+= curnverts;
basenverts += curnverts;
}
/* release derived mesh */
for (dmlink= dms; dmlink; dmlink= dmlink->next) {
dm= (DerivedMesh*) dmlink->link;
for (dmlink = dms; dmlink; dmlink = dmlink->next) {
dm = (DerivedMesh *) dmlink->link;
dm->release(dm);
}
BLI_linklist_free(dms, NULL);
*nverts_r= nverts;
*verts_r= verts;
*ntris_r= ntris;
*tris_r= tris;
*nverts_r = nverts;
*verts_r = verts;
*ntris_r = ntris;
*tris_r = tris;
}
static int buildNavMesh(const RecastData *recastParams, int nverts, float *verts, int ntris, int *tris,
struct recast_polyMesh **pmesh, struct recast_polyMeshDetail **dmesh)
struct recast_polyMesh **pmesh, struct recast_polyMeshDetail **dmesh)
{
float bmin[3], bmax[3];
struct recast_heightfield *solid;
@@ -181,22 +182,22 @@ static int buildNavMesh(const RecastData *recastParams, int nverts, float *verts
recast_calcBounds(verts, nverts, bmin, bmax);
/* ** Step 1. Initialize build config ** */
walkableHeight= (int)ceilf(recastParams->agentheight/ recastParams->cellheight);
walkableClimb= (int)floorf(recastParams->agentmaxclimb / recastParams->cellheight);
walkableRadius= (int)ceilf(recastParams->agentradius / recastParams->cellsize);
minRegionArea= (int)(recastParams->regionminsize * recastParams->regionminsize);
mergeRegionArea= (int)(recastParams->regionmergesize * recastParams->regionmergesize);
maxEdgeLen= (int)(recastParams->edgemaxlen/recastParams->cellsize);
detailSampleDist= recastParams->detailsampledist< 0.9f ? 0 :
recastParams->cellsize * recastParams->detailsampledist;
detailSampleMaxError= recastParams->cellheight * recastParams->detailsamplemaxerror;
walkableHeight = (int)ceilf(recastParams->agentheight / recastParams->cellheight);
walkableClimb = (int)floorf(recastParams->agentmaxclimb / recastParams->cellheight);
walkableRadius = (int)ceilf(recastParams->agentradius / recastParams->cellsize);
minRegionArea = (int)(recastParams->regionminsize * recastParams->regionminsize);
mergeRegionArea = (int)(recastParams->regionmergesize * recastParams->regionmergesize);
maxEdgeLen = (int)(recastParams->edgemaxlen / recastParams->cellsize);
detailSampleDist = recastParams->detailsampledist < 0.9f ? 0 :
recastParams->cellsize * recastParams->detailsampledist;
detailSampleMaxError = recastParams->cellheight * recastParams->detailsamplemaxerror;
/* Set the area where the navigation will be build. */
recast_calcGridSize(bmin, bmax, recastParams->cellsize, &width, &height);
/* ** Step 2: Rasterize input polygon soup ** */
/* Allocate voxel heightfield where we rasterize our input data to */
solid= recast_newHeightfield();
solid = recast_newHeightfield();
if (!recast_createHeightfield(solid, width, height, bmin, bmax, recastParams->cellsize, recastParams->cellheight)) {
recast_destroyHeightfield(solid);
@@ -205,7 +206,7 @@ static int buildNavMesh(const RecastData *recastParams, int nverts, float *verts
}
/* Allocate array that can hold triangle flags */
triflags= MEM_callocN(sizeof(unsigned char)*ntris, "buildNavMesh triflags");
triflags = MEM_callocN(sizeof(unsigned char) * ntris, "buildNavMesh triflags");
/* Find triangles which are walkable based on their slope and rasterize them */
recast_markWalkableTriangles(RAD2DEG(recastParams->agentmaxslope), verts, nverts, tris, ntris, triflags);
@@ -219,7 +220,7 @@ static int buildNavMesh(const RecastData *recastParams, int nverts, float *verts
/* ** Step 4: Partition walkable surface to simple regions ** */
chf= recast_newCompactHeightfield();
chf = recast_newCompactHeightfield();
if (!recast_buildCompactHeightfield(walkableHeight, walkableClimb, solid, chf)) {
recast_destroyHeightfield(solid);
recast_destroyCompactHeightfield(chf);
@@ -252,7 +253,7 @@ static int buildNavMesh(const RecastData *recastParams, int nverts, float *verts
/* ** Step 5: Trace and simplify region contours ** */
/* Create contours */
cset= recast_newContourSet();
cset = recast_newContourSet();
if (!recast_buildContours(chf, recastParams->edgemaxerror, maxEdgeLen, cset)) {
recast_destroyCompactHeightfield(chf);
@@ -262,7 +263,7 @@ static int buildNavMesh(const RecastData *recastParams, int nverts, float *verts
}
/* ** Step 6: Build polygons mesh from contours ** */
*pmesh= recast_newPolyMesh();
*pmesh = recast_newPolyMesh();
if (!recast_buildPolyMesh(cset, recastParams->vertsperpoly, *pmesh)) {
recast_destroyCompactHeightfield(chf);
recast_destroyContourSet(cset);
@@ -274,7 +275,7 @@ static int buildNavMesh(const RecastData *recastParams, int nverts, float *verts
/* ** Step 7: Create detail mesh which allows to access approximate height on each polygon ** */
*dmesh= recast_newPolyMeshDetail();
*dmesh = recast_newPolyMeshDetail();
if (!recast_buildPolyMeshDetail(*pmesh, chf, detailSampleDist, detailSampleMaxError, *dmesh)) {
recast_destroyCompactHeightfield(chf);
recast_destroyContourSet(cset);
@@ -294,12 +295,12 @@ static Object *createRepresentation(bContext *C, struct recast_polyMesh *pmesh,
{
float co[3], rot[3];
BMEditMesh *em;
int i,j, k;
int i, j, k;
unsigned short *v;
int face[3];
Scene *scene= CTX_data_scene(C);
Scene *scene = CTX_data_scene(C);
Object *obedit;
int createob= base==NULL;
int createob = base == NULL;
int nverts, nmeshes, nvp;
unsigned short *verts, *polys;
unsigned int *meshes;
@@ -311,16 +312,16 @@ static Object *createRepresentation(bContext *C, struct recast_polyMesh *pmesh,
if (createob) {
/* create new object */
obedit= ED_object_add_type(C, OB_MESH, co, rot, FALSE, 1);
obedit = ED_object_add_type(C, OB_MESH, co, rot, FALSE, 1);
}
else {
obedit= base->object;
obedit = base->object;
scene_select_base(scene, base);
copy_v3_v3(obedit->loc, co);
copy_v3_v3(obedit->rot, rot);
}
ED_object_enter_editmode(C, EM_DO_UNDO|EM_IGNORE_LAYER);
ED_object_enter_editmode(C, EM_DO_UNDO | EM_IGNORE_LAYER);
em = BMEdit_FromObject(obedit);
if (!createob) {
@@ -329,15 +330,15 @@ static Object *createRepresentation(bContext *C, struct recast_polyMesh *pmesh,
}
/* create verts for polygon mesh */
verts= recast_polyMeshGetVerts(pmesh, &nverts);
verts = recast_polyMeshGetVerts(pmesh, &nverts);
recast_polyMeshGetBoundbox(pmesh, bmin, NULL);
recast_polyMeshGetCell(pmesh, &cs, &ch);
for (i= 0; i<nverts; i++) {
v= &verts[3*i];
co[0]= bmin[0] + v[0]*cs;
co[1]= bmin[1] + v[1]*ch;
co[2]= bmin[2] + v[2]*cs;
for (i = 0; i < nverts; i++) {
v = &verts[3 * i];
co[0] = bmin[0] + v[0] * cs;
co[1] = bmin[1] + v[1] * ch;
co[2] = bmin[2] + v[2] * cs;
SWAP(float, co[1], co[2]);
BM_vert_create(em->bm, co, NULL);
}
@@ -346,28 +347,28 @@ static Object *createRepresentation(bContext *C, struct recast_polyMesh *pmesh,
CustomData_add_layer_named(&em->bm->pdata, CD_RECAST, CD_CALLOC, NULL, 0, "createRepresentation recastData");
/* create verts and faces for detailed mesh */
meshes= recast_polyMeshDetailGetMeshes(dmesh, &nmeshes);
polys= recast_polyMeshGetPolys(pmesh, NULL, &nvp);
dverts= recast_polyMeshDetailGetVerts(dmesh, NULL);
tris= recast_polyMeshDetailGetTris(dmesh, NULL);
meshes = recast_polyMeshDetailGetMeshes(dmesh, &nmeshes);
polys = recast_polyMeshGetPolys(pmesh, NULL, &nvp);
dverts = recast_polyMeshDetailGetVerts(dmesh, NULL);
tris = recast_polyMeshDetailGetTris(dmesh, NULL);
for (i= 0; i<nmeshes; i++) {
int uniquevbase= em->bm->totvert;
unsigned int vbase= meshes[4*i+0];
unsigned short ndv= meshes[4*i+1];
unsigned short tribase= meshes[4*i+2];
unsigned short trinum= meshes[4*i+3];
const unsigned short *p= &polys[i*nvp*2];
int nv= 0;
for (i = 0; i < nmeshes; i++) {
int uniquevbase = em->bm->totvert;
unsigned int vbase = meshes[4 * i + 0];
unsigned short ndv = meshes[4 * i + 1];
unsigned short tribase = meshes[4 * i + 2];
unsigned short trinum = meshes[4 * i + 3];
const unsigned short *p = &polys[i * nvp * 2];
int nv = 0;
for (j= 0; j < nvp; ++j) {
if (p[j]==0xffff) break;
for (j = 0; j < nvp; ++j) {
if (p[j] == 0xffff) break;
nv++;
}
/* create unique verts */
for (j= nv; j<ndv; j++) {
copy_v3_v3(co, &dverts[3*(vbase + j)]);
for (j = nv; j < ndv; j++) {
copy_v3_v3(co, &dverts[3 * (vbase + j)]);
SWAP(float, co[1], co[2]);
BM_vert_create(em->bm, co, NULL);
}
@@ -375,26 +376,26 @@ static Object *createRepresentation(bContext *C, struct recast_polyMesh *pmesh,
EDBM_init_index_arrays(em, 1, 0, 0);
/* create faces */
for (j= 0; j<trinum; j++) {
unsigned char *tri= &tris[4*(tribase+j)];
for (j = 0; j < trinum; j++) {
unsigned char *tri = &tris[4 * (tribase + j)];
BMFace *newFace;
int *polygonIdx;
for (k= 0; k<3; k++) {
if (tri[k]<nv)
face[k] = p[tri[k]]; /* shared vertex */
for (k = 0; k < 3; k++) {
if (tri[k] < nv)
face[k] = p[tri[k]]; /* shared vertex */
else
face[k] = uniquevbase+tri[k]-nv; /* unique vertex */
face[k] = uniquevbase + tri[k] - nv; /* unique vertex */
}
newFace= BM_face_create_quad_tri(em->bm,
EDBM_get_vert_for_index(em, face[0]),
EDBM_get_vert_for_index(em, face[2]),
EDBM_get_vert_for_index(em, face[1]), NULL,
NULL, FALSE);
newFace = BM_face_create_quad_tri(em->bm,
EDBM_get_vert_for_index(em, face[0]),
EDBM_get_vert_for_index(em, face[2]),
EDBM_get_vert_for_index(em, face[1]), NULL,
NULL, FALSE);
/* set navigation polygon idx to the custom layer */
polygonIdx= (int*)CustomData_bmesh_get(&em->bm->pdata, newFace->head.data, CD_RECAST);
*polygonIdx= i+1; /* add 1 to avoid zero idx */
polygonIdx = (int *)CustomData_bmesh_get(&em->bm->pdata, newFace->head.data, CD_RECAST);
*polygonIdx = i + 1; /* add 1 to avoid zero idx */
}
EDBM_free_index_arrays(em);
@@ -403,17 +404,17 @@ static Object *createRepresentation(bContext *C, struct recast_polyMesh *pmesh,
recast_destroyPolyMesh(pmesh);
recast_destroyPolyMeshDetail(dmesh);
DAG_id_tag_update((ID*)obedit->data, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
DAG_id_tag_update((ID *)obedit->data, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
ED_object_exit_editmode(C, EM_FREEDATA);
WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, obedit);
WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, obedit);
if (createob) {
obedit->gameflag&= ~OB_COLLISION;
obedit->gameflag|= OB_NAVMESH;
obedit->body_type= OB_BODY_TYPE_NAVMESH;
obedit->gameflag &= ~OB_COLLISION;
obedit->gameflag |= OB_NAVMESH;
obedit->body_type = OB_BODY_TYPE_NAVMESH;
rename_id((ID *)obedit, "Navmesh");
}
@@ -424,31 +425,31 @@ static Object *createRepresentation(bContext *C, struct recast_polyMesh *pmesh,
static int navmesh_create_exec(bContext *C, wmOperator *op)
{
Scene *scene= CTX_data_scene(C);
LinkNode *obs= NULL;
Base *navmeshBase= NULL;
Scene *scene = CTX_data_scene(C);
LinkNode *obs = NULL;
Base *navmeshBase = NULL;
CTX_DATA_BEGIN(C, Base*, base, selected_editable_bases) {
if (base->object->type == OB_MESH) {
if (base->object->body_type==OB_BODY_TYPE_NAVMESH) {
if (base->object->body_type == OB_BODY_TYPE_NAVMESH) {
if (!navmeshBase || base == scene->basact) {
navmeshBase= base;
navmeshBase = base;
}
}
else {
BLI_linklist_append(&obs, (void*)base->object);
BLI_linklist_append(&obs, (void *)base->object);
}
}
}
CTX_DATA_END;
if (obs) {
struct recast_polyMesh *pmesh= NULL;
struct recast_polyMeshDetail *dmesh= NULL;
struct recast_polyMesh *pmesh = NULL;
struct recast_polyMeshDetail *dmesh = NULL;
int nverts= 0, ntris= 0;
int *tris= 0;
float *verts= NULL;
int nverts = 0, ntris = 0;
int *tris = 0;
float *verts = NULL;
createVertsTrisData(C, obs, &nverts, &verts, &ntris, &tris);
BLI_linklist_free(obs, NULL);
@@ -478,7 +479,7 @@ void MESH_OT_navmesh_make(wmOperatorType *ot)
ot->exec = navmesh_create_exec;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
static int navmesh_face_copy_exec(bContext *C, wmOperator *op)
@@ -487,20 +488,20 @@ static int navmesh_face_copy_exec(bContext *C, wmOperator *op)
BMEditMesh *em = BMEdit_FromObject(obedit);
/* do work here */
BMFace *efa_act= BM_active_face_get(em->bm, FALSE);
BMFace *efa_act = BM_active_face_get(em->bm, FALSE);
if (efa_act) {
if (CustomData_has_layer(&em->bm->pdata, CD_RECAST)) {
BMFace *efa;
BMIter iter;
int targetPolyIdx= *(int*)CustomData_bmesh_get(&em->bm->pdata, efa_act->head.data, CD_RECAST);
targetPolyIdx= targetPolyIdx>=0? targetPolyIdx : -targetPolyIdx;
int targetPolyIdx = *(int *)CustomData_bmesh_get(&em->bm->pdata, efa_act->head.data, CD_RECAST);
targetPolyIdx = targetPolyIdx >= 0 ? targetPolyIdx : -targetPolyIdx;
if (targetPolyIdx > 0) {
/* set target poly idx to other selected faces */
BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
if (BM_elem_flag_test(efa, BM_ELEM_SELECT) && efa != efa_act) {
int *recastDataBlock = (int*)CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_RECAST);
int *recastDataBlock = (int *)CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_RECAST);
*recastDataBlock = targetPolyIdx;
}
}
@@ -511,8 +512,8 @@ static int navmesh_face_copy_exec(bContext *C, wmOperator *op)
}
}
DAG_id_tag_update((ID*)obedit->data, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
DAG_id_tag_update((ID *)obedit->data, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
return OPERATOR_FINISHED;
}
@@ -529,27 +530,27 @@ void MESH_OT_navmesh_face_copy(struct wmOperatorType *ot)
ot->exec = navmesh_face_copy_exec;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
static int compare(const void * a, const void * b)
static int compare(const void *a, const void *b)
{
return ( *(int*)a - *(int*)b );
return (*(int *)a - *(int *)b);
}
static int findFreeNavPolyIndex(BMEditMesh *em)
{
/* construct vector of indices */
int numfaces = em->bm->totface;
int *indices = MEM_callocN(sizeof(int)*numfaces, "findFreeNavPolyIndex(indices)");
int *indices = MEM_callocN(sizeof(int) * numfaces, "findFreeNavPolyIndex(indices)");
BMFace *ef;
BMIter iter;
int i, idx = em->bm->totface-1, freeIdx = 1;
int i, idx = em->bm->totface - 1, freeIdx = 1;
/*XXX this originally went last to first, but that isn't possible anymore*/
BM_ITER(ef, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
int polyIdx = *(int*)CustomData_bmesh_get(&em->bm->pdata, ef->head.data, CD_RECAST);
indices[idx]= polyIdx;
int polyIdx = *(int *)CustomData_bmesh_get(&em->bm->pdata, ef->head.data, CD_RECAST);
indices[idx] = polyIdx;
idx--;
}
@@ -557,10 +558,10 @@ static int findFreeNavPolyIndex(BMEditMesh *em)
/* search first free index */
freeIdx = 1;
for (i = 0; i<numfaces; i++) {
if (indices[i]==freeIdx)
for (i = 0; i < numfaces; i++) {
if (indices[i] == freeIdx)
freeIdx++;
else if (indices[i]>freeIdx)
else if (indices[i] > freeIdx)
break;
}
@@ -579,21 +580,21 @@ static int navmesh_face_add_exec(bContext *C, wmOperator *UNUSED(op))
if (CustomData_has_layer(&em->bm->pdata, CD_RECAST)) {
int targetPolyIdx = findFreeNavPolyIndex(em);
if (targetPolyIdx>0) {
if (targetPolyIdx > 0) {
/* set target poly idx to selected faces */
/*XXX this originally went last to first, but that isn't possible anymore*/
BM_ITER(ef, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
if (BM_elem_flag_test(ef, BM_ELEM_SELECT)) {
int *recastDataBlock = (int*)CustomData_bmesh_get(&em->bm->pdata, ef->head.data, CD_RECAST);
int *recastDataBlock = (int *)CustomData_bmesh_get(&em->bm->pdata, ef->head.data, CD_RECAST);
*recastDataBlock = targetPolyIdx;
}
}
}
}
DAG_id_tag_update((ID*)obedit->data, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, obedit->data);
DAG_id_tag_update((ID *)obedit->data, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, obedit->data);
return OPERATOR_FINISHED;
}
@@ -610,7 +611,7 @@ void MESH_OT_navmesh_face_add(struct wmOperatorType *ot)
ot->exec = navmesh_face_add_exec;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
static int navmesh_obmode_data_poll(bContext *C)
@@ -642,7 +643,7 @@ static int navmesh_reset_exec(bContext *C, wmOperator *UNUSED(op))
BKE_mesh_ensure_navmesh(me);
DAG_id_tag_update(&me->id, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, &me->id);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, &me->id);
return OPERATOR_FINISHED;
}
@@ -659,7 +660,7 @@ void MESH_OT_navmesh_reset(struct wmOperatorType *ot)
ot->exec = navmesh_reset_exec;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
static int navmesh_clear_exec(bContext *C, wmOperator *UNUSED(op))
@@ -670,7 +671,7 @@ static int navmesh_clear_exec(bContext *C, wmOperator *UNUSED(op))
CustomData_free_layers(&me->pdata, CD_RECAST, me->totpoly);
DAG_id_tag_update(&me->id, OB_RECALC_DATA);
WM_event_add_notifier(C, NC_GEOM|ND_DATA, &me->id);
WM_event_add_notifier(C, NC_GEOM | ND_DATA, &me->id);
return OPERATOR_FINISHED;
}
@@ -687,5 +688,5 @@ void MESH_OT_navmesh_clear(struct wmOperatorType *ot)
ot->exec = navmesh_clear_exec;
/* flags */
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}

View File

@@ -177,8 +177,8 @@ void ED_operatortypes_mesh(void)
#if 0 /* UNUSED, remove? */
static int ED_operator_editmesh_face_select(bContext *C)
{
Object *obedit= CTX_data_edit_object(C);
if (obedit && obedit->type==OB_MESH) {
Object *obedit = CTX_data_edit_object(C);
if (obedit && obedit->type == OB_MESH) {
BMEditMesh *em = BMEdit_FromObject(obedit);
if (em && em->selectmode & SCE_SELECT_FACE) {
return 1;
@@ -193,48 +193,48 @@ void ED_operatormacros_mesh(void)
wmOperatorType *ot;
wmOperatorTypeMacro *otmacro;
ot = WM_operatortype_append_macro("MESH_OT_loopcut_slide", "Loop Cut and Slide", OPTYPE_UNDO|OPTYPE_REGISTER);
ot = WM_operatortype_append_macro("MESH_OT_loopcut_slide", "Loop Cut and Slide", OPTYPE_UNDO | OPTYPE_REGISTER);
ot->description = "Cut mesh loop and slide it";
WM_operatortype_macro_define(ot, "MESH_OT_loopcut");
otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_edge_slide");
RNA_struct_idprops_unset(otmacro->ptr, "release_confirm");
ot = WM_operatortype_append_macro("MESH_OT_duplicate_move", "Add Duplicate", OPTYPE_UNDO|OPTYPE_REGISTER);
ot = WM_operatortype_append_macro("MESH_OT_duplicate_move", "Add Duplicate", OPTYPE_UNDO | OPTYPE_REGISTER);
ot->description = "Duplicate mesh and move";
WM_operatortype_macro_define(ot, "MESH_OT_duplicate");
otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
RNA_enum_set(otmacro->ptr, "proportional", 0);
RNA_boolean_set(otmacro->ptr, "mirror", FALSE);
ot = WM_operatortype_append_macro("MESH_OT_rip_move", "Rip", OPTYPE_UNDO|OPTYPE_REGISTER);
ot = WM_operatortype_append_macro("MESH_OT_rip_move", "Rip", OPTYPE_UNDO | OPTYPE_REGISTER);
ot->description = "Rip polygons and move the result";
WM_operatortype_macro_define(ot, "MESH_OT_rip");
otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
RNA_enum_set(otmacro->ptr, "proportional", 0);
RNA_boolean_set(otmacro->ptr, "mirror", FALSE);
ot = WM_operatortype_append_macro("MESH_OT_extrude_region_move", "Extrude Region and Move", OPTYPE_UNDO|OPTYPE_REGISTER);
ot = WM_operatortype_append_macro("MESH_OT_extrude_region_move", "Extrude Region and Move", OPTYPE_UNDO | OPTYPE_REGISTER);
ot->description = "Extrude region and move result";
otmacro = WM_operatortype_macro_define(ot, "MESH_OT_extrude_region");
otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
RNA_enum_set(otmacro->ptr, "proportional", 0);
RNA_boolean_set(otmacro->ptr, "mirror", FALSE);
ot = WM_operatortype_append_macro("MESH_OT_extrude_faces_move", "Extrude Individual Faces and Move", OPTYPE_UNDO|OPTYPE_REGISTER);
ot = WM_operatortype_append_macro("MESH_OT_extrude_faces_move", "Extrude Individual Faces and Move", OPTYPE_UNDO | OPTYPE_REGISTER);
ot->description = "Extrude faces and move result";
otmacro = WM_operatortype_macro_define(ot, "MESH_OT_extrude_faces_indiv");
otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_shrink_fatten");
RNA_enum_set(otmacro->ptr, "proportional", 0);
RNA_boolean_set(otmacro->ptr, "mirror", FALSE);
ot = WM_operatortype_append_macro("MESH_OT_extrude_edges_move", "Extrude Only Edges and Move", OPTYPE_UNDO|OPTYPE_REGISTER);
ot = WM_operatortype_append_macro("MESH_OT_extrude_edges_move", "Extrude Only Edges and Move", OPTYPE_UNDO | OPTYPE_REGISTER);
ot->description = "Extrude edges and move result";
otmacro = WM_operatortype_macro_define(ot, "MESH_OT_extrude_edges_indiv");
otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
RNA_enum_set(otmacro->ptr, "proportional", 0);
RNA_boolean_set(otmacro->ptr, "mirror", FALSE);
ot = WM_operatortype_append_macro("MESH_OT_extrude_vertices_move", "Extrude Only Vertices and Move", OPTYPE_UNDO|OPTYPE_REGISTER);
ot = WM_operatortype_append_macro("MESH_OT_extrude_vertices_move", "Extrude Only Vertices and Move", OPTYPE_UNDO | OPTYPE_REGISTER);
ot->description = "Extrude vertices and move result";
otmacro = WM_operatortype_macro_define(ot, "MESH_OT_extrude_verts_indiv");
otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
@@ -258,12 +258,12 @@ void ED_keymap_mesh(wmKeyConfig *keyconf)
/* standard mouse selection goes via space_view3d */
kmi = WM_keymap_add_item(keymap, "MESH_OT_loop_select", SELECTMOUSE, KM_PRESS, KM_ALT, 0);
RNA_boolean_set(kmi->ptr, "extend", FALSE);
kmi = WM_keymap_add_item(keymap, "MESH_OT_loop_select", SELECTMOUSE, KM_PRESS, KM_SHIFT|KM_ALT, 0);
kmi = WM_keymap_add_item(keymap, "MESH_OT_loop_select", SELECTMOUSE, KM_PRESS, KM_SHIFT | KM_ALT, 0);
RNA_boolean_set(kmi->ptr, "extend", TRUE);
kmi = WM_keymap_add_item(keymap, "MESH_OT_edgering_select", SELECTMOUSE, KM_PRESS, KM_ALT|KM_CTRL, 0);
kmi = WM_keymap_add_item(keymap, "MESH_OT_edgering_select", SELECTMOUSE, KM_PRESS, KM_ALT | KM_CTRL, 0);
RNA_boolean_set(kmi->ptr, "extend", FALSE);
kmi = WM_keymap_add_item(keymap, "MESH_OT_edgering_select", SELECTMOUSE, KM_PRESS, KM_SHIFT|KM_ALT|KM_CTRL, 0);
kmi = WM_keymap_add_item(keymap, "MESH_OT_edgering_select", SELECTMOUSE, KM_PRESS, KM_SHIFT | KM_ALT | KM_CTRL, 0);
RNA_boolean_set(kmi->ptr, "extend", TRUE);
WM_keymap_add_item(keymap, "MESH_OT_select_shortest_path", SELECTMOUSE, KM_PRESS, KM_CTRL, 0);
@@ -275,7 +275,7 @@ void ED_keymap_mesh(wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "MESH_OT_select_more", PADPLUSKEY, KM_PRESS, KM_CTRL, 0);
WM_keymap_add_item(keymap, "MESH_OT_select_less", PADMINUS, KM_PRESS, KM_CTRL, 0);
WM_keymap_add_item(keymap, "MESH_OT_select_non_manifold", MKEY, KM_PRESS, (KM_CTRL|KM_SHIFT|KM_ALT), 0);
WM_keymap_add_item(keymap, "MESH_OT_select_non_manifold", MKEY, KM_PRESS, (KM_CTRL | KM_SHIFT | KM_ALT), 0);
WM_keymap_add_item(keymap, "MESH_OT_select_linked", LKEY, KM_PRESS, KM_CTRL, 0);
kmi = WM_keymap_add_item(keymap, "MESH_OT_select_linked_pick", LKEY, KM_PRESS, 0, 0);
@@ -283,7 +283,7 @@ void ED_keymap_mesh(wmKeyConfig *keyconf)
kmi = WM_keymap_add_item(keymap, "MESH_OT_select_linked_pick", LKEY, KM_PRESS, KM_SHIFT, 0);
RNA_boolean_set(kmi->ptr, "deselect", TRUE);
WM_keymap_add_item(keymap, "MESH_OT_faces_select_linked_flat", FKEY, KM_PRESS, (KM_CTRL|KM_SHIFT|KM_ALT), 0);
WM_keymap_add_item(keymap, "MESH_OT_faces_select_linked_flat", FKEY, KM_PRESS, (KM_CTRL | KM_SHIFT | KM_ALT), 0);
WM_keymap_add_item(keymap, "MESH_OT_select_similar", GKEY, KM_PRESS, KM_SHIFT, 0);
@@ -300,7 +300,7 @@ void ED_keymap_mesh(wmKeyConfig *keyconf)
/* tools */
kmi = WM_keymap_add_item(keymap, "MESH_OT_normals_make_consistent", NKEY, KM_PRESS, KM_CTRL, 0);
RNA_boolean_set(kmi->ptr, "inside", FALSE);
kmi = WM_keymap_add_item(keymap, "MESH_OT_normals_make_consistent", NKEY, KM_PRESS, KM_SHIFT|KM_CTRL, 0);
kmi = WM_keymap_add_item(keymap, "MESH_OT_normals_make_consistent", NKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0);
RNA_boolean_set(kmi->ptr, "inside", TRUE);
WM_keymap_add_item(keymap, "VIEW3D_OT_edit_mesh_extrude_move_normal", EKEY, KM_PRESS, 0, 0); /* python operator */
@@ -311,7 +311,7 @@ void ED_keymap_mesh(wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "MESH_OT_spin", RKEY, KM_PRESS, KM_ALT, 0);
WM_keymap_add_item(keymap, "MESH_OT_fill", FKEY, KM_PRESS, KM_ALT, 0);
WM_keymap_add_item(keymap, "MESH_OT_beautify_fill", FKEY, KM_PRESS, KM_SHIFT|KM_ALT, 0);
WM_keymap_add_item(keymap, "MESH_OT_beautify_fill", FKEY, KM_PRESS, KM_SHIFT | KM_ALT, 0);
WM_keymap_add_item(keymap, "MESH_OT_quads_convert_to_tris", TKEY, KM_PRESS, KM_CTRL, 0);
kmi = WM_keymap_add_item(keymap, "MESH_OT_quads_convert_to_tris", TKEY, KM_PRESS, KM_CTRL | KM_SHIFT, 0);
@@ -319,7 +319,7 @@ void ED_keymap_mesh(wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "MESH_OT_tris_convert_to_quads", JKEY, KM_PRESS, KM_ALT, 0);
WM_keymap_add_item(keymap, "MESH_OT_rip_move",VKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "MESH_OT_rip_move", VKEY, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "MESH_OT_merge", MKEY, KM_PRESS, KM_ALT, 0);
WM_keymap_add_item(keymap, "TRANSFORM_OT_shrink_fatten", SKEY, KM_PRESS, KM_ALT, 0);
@@ -338,7 +338,7 @@ void ED_keymap_mesh(wmKeyConfig *keyconf)
/* use KM_CLICK because same key is used for tweaks */
kmi = WM_keymap_add_item(keymap, "MESH_OT_dupli_extrude_cursor", ACTIONMOUSE, KM_CLICK, KM_CTRL, 0);
RNA_boolean_set(kmi->ptr, "rotate_source", TRUE);
kmi = WM_keymap_add_item(keymap, "MESH_OT_dupli_extrude_cursor", ACTIONMOUSE, KM_CLICK, KM_SHIFT|KM_CTRL, 0);
kmi = WM_keymap_add_item(keymap, "MESH_OT_dupli_extrude_cursor", ACTIONMOUSE, KM_CLICK, KM_SHIFT | KM_CTRL, 0);
RNA_boolean_set(kmi->ptr, "rotate_source", FALSE);
WM_keymap_add_menu(keymap, "VIEW3D_MT_edit_mesh_dissolve", DKEY, KM_PRESS, 0, 0);
@@ -361,8 +361,8 @@ void ED_keymap_mesh(wmKeyConfig *keyconf)
WM_keymap_add_menu(keymap, "VIEW3D_MT_vertex_group", GKEY, KM_PRESS, KM_CTRL, 0);
/* useful stuff from object-mode */
for (i=0; i<=5; i++) {
kmi = WM_keymap_add_item(keymap, "OBJECT_OT_subdivision_set", ZEROKEY+i, KM_PRESS, KM_CTRL, 0);
for (i = 0; i <= 5; i++) {
kmi = WM_keymap_add_item(keymap, "OBJECT_OT_subdivision_set", ZEROKEY + i, KM_PRESS, KM_CTRL, 0);
RNA_int_set(kmi->ptr, "level", i);
}

View File

@@ -91,21 +91,21 @@
int join_mesh_exec(bContext *C, wmOperator *op)
{
Main *bmain= CTX_data_main(C);
Scene *scene= CTX_data_scene(C);
Object *ob= CTX_data_active_object(C);
Main *bmain = CTX_data_main(C);
Scene *scene = CTX_data_scene(C);
Object *ob = CTX_data_active_object(C);
Material **matar, *ma;
Mesh *me;
MVert *mvert, *mv;
MEdge *medge = NULL;
MPoly *mpoly = NULL;
MLoop *mloop = NULL;
Key *key, *nkey=NULL;
Key *key, *nkey = NULL;
KeyBlock *kb, *okb, *kbn;
float imat[4][4], cmat[4][4], *fp1, *fp2, curpos;
int a, b, totcol, totmat=0, totedge=0, totvert=0, ok=0;
int totloop=0, totpoly=0, vertofs, *matmap=NULL;
int i, j, index, haskey=0, edgeofs, loopofs, polyofs;
int a, b, totcol, totmat = 0, totedge = 0, totvert = 0, ok = 0;
int totloop = 0, totpoly = 0, vertofs, *matmap = NULL;
int i, j, index, haskey = 0, edgeofs, loopofs, polyofs;
bDeformGroup *dg, *odg;
MDeformVert *dvert;
CustomData vdata, edata, fdata, ldata, pdata;
@@ -116,24 +116,24 @@ int join_mesh_exec(bContext *C, wmOperator *op)
}
/* ob is the object we are adding geometry to */
if (!ob || ob->type!=OB_MESH) {
if (!ob || ob->type != OB_MESH) {
BKE_report(op->reports, RPT_WARNING, "Active object is not a mesh");
return OPERATOR_CANCELLED;
}
/* count & check */
CTX_DATA_BEGIN(C, Base*, base, selected_editable_bases) {
if (base->object->type==OB_MESH) {
me= base->object->data;
totvert+= me->totvert;
totedge+= me->totedge;
totloop+= me->totloop;
totpoly+= me->totpoly;
totmat+= base->object->totcol;
CTX_DATA_BEGIN(C, Base *, base, selected_editable_bases) {
if (base->object->type == OB_MESH) {
me = base->object->data;
totvert += me->totvert;
totedge += me->totedge;
totloop += me->totloop;
totpoly += me->totpoly;
totmat += base->object->totcol;
if (base->object == ob)
ok= 1;
ok = 1;
/* check for shapekeys */
if (me->key)
@@ -143,16 +143,16 @@ int join_mesh_exec(bContext *C, wmOperator *op)
CTX_DATA_END;
/* that way the active object is always selected */
if (ok==0) {
if (ok == 0) {
BKE_report(op->reports, RPT_WARNING, "Active object is not a selected mesh");
return OPERATOR_CANCELLED;
}
/* only join meshes if there are verts to join, there aren't too many, and we only had one mesh selected */
me= (Mesh *)ob->data;
key= me->key;
me = (Mesh *)ob->data;
key = me->key;
if (totvert==0 || totvert==me->totvert) {
if (totvert == 0 || totvert == me->totvert) {
BKE_report(op->reports, RPT_WARNING, "No mesh data to join");
return OPERATOR_CANCELLED;
}
@@ -163,48 +163,49 @@ int join_mesh_exec(bContext *C, wmOperator *op)
}
/* new material indices and material array */
matar= MEM_callocN(sizeof(void*)*totmat, "join_mesh matar");
if (totmat) matmap= MEM_callocN(sizeof(int)*totmat, "join_mesh matmap");
totcol= ob->totcol;
matar = MEM_callocN(sizeof(void *) * totmat, "join_mesh matar");
if (totmat) matmap = MEM_callocN(sizeof(int) * totmat, "join_mesh matmap");
totcol = ob->totcol;
/* obact materials in new main array, is nicer start! */
for (a=0; a<ob->totcol; a++) {
matar[a]= give_current_material(ob, a+1);
for (a = 0; a < ob->totcol; a++) {
matar[a] = give_current_material(ob, a + 1);
id_us_plus((ID *)matar[a]);
/* increase id->us : will be lowered later */
}
/* - if destination mesh had shapekeys, move them somewhere safe, and set up placeholders
* with arrays that are large enough to hold shapekey data for all meshes
* with arrays that are large enough to hold shapekey data for all meshes
* - if destination mesh didn't have shapekeys, but we encountered some in the meshes we're
* joining, set up a new keyblock and assign to the mesh
*/
if (key) {
/* make a duplicate copy that will only be used here... (must remember to free it!) */
nkey= copy_key(key);
nkey = copy_key(key);
/* for all keys in old block, clear data-arrays */
for (kb= key->block.first; kb; kb= kb->next) {
for (kb = key->block.first; kb; kb = kb->next) {
if (kb->data) MEM_freeN(kb->data);
kb->data= MEM_callocN(sizeof(float)*3*totvert, "join_shapekey");
kb->totelem= totvert;
kb->weights= NULL;
kb->data = MEM_callocN(sizeof(float) * 3 * totvert, "join_shapekey");
kb->totelem = totvert;
kb->weights = NULL;
}
}
else if (haskey) {
/* add a new key-block and add to the mesh */
key= me->key= add_key((ID *)me);
key = me->key = add_key((ID *)me);
key->type = KEY_RELATIVE;
}
/* first pass over objects - copying materials and vertexgroups across */
CTX_DATA_BEGIN(C, Base*, base, selected_editable_bases) {
CTX_DATA_BEGIN(C, Base *, base, selected_editable_bases)
{
/* only act if a mesh, and not the one we're joining to */
if ((ob!=base->object) && (base->object->type==OB_MESH)) {
me= base->object->data;
if ((ob != base->object) && (base->object->type == OB_MESH)) {
me = base->object->data;
/* Join this object's vertex groups to the base one's */
for (dg=base->object->defbase.first; dg; dg=dg->next) {
for (dg = base->object->defbase.first; dg; dg = dg->next) {
/* See if this group exists in the object (if it doesn't, add it to the end) */
if (!defgroup_find_name(ob, dg->name)) {
odg = MEM_callocN(sizeof(bDeformGroup), "join deformGroup");
@@ -212,21 +213,21 @@ int join_mesh_exec(bContext *C, wmOperator *op)
BLI_addtail(&ob->defbase, odg);
}
}
if (ob->defbase.first && ob->actdef==0)
ob->actdef=1;
if (ob->defbase.first && ob->actdef == 0)
ob->actdef = 1;
if (me->totvert) {
/* Add this object's materials to the base one's if they don't exist already (but only if limits not exceeded yet) */
if (totcol < MAXMAT) {
for (a=1; a<=base->object->totcol; a++) {
ma= give_current_material(base->object, a);
for (a = 1; a <= base->object->totcol; a++) {
ma = give_current_material(base->object, a);
for (b=0; b<totcol; b++) {
for (b = 0; b < totcol; b++) {
if (ma == matar[b]) break;
}
if (b==totcol) {
matar[b]= ma;
if (b == totcol) {
matar[b] = ma;
if (ma) {
id_us_plus(&ma->id);
}
@@ -239,29 +240,29 @@ int join_mesh_exec(bContext *C, wmOperator *op)
/* if this mesh has shapekeys, check if destination mesh already has matching entries too */
if (me->key && key) {
for (kb= me->key->block.first; kb; kb= kb->next) {
for (kb = me->key->block.first; kb; kb = kb->next) {
/* if key doesn't exist in destination mesh, add it */
if (key_get_named_keyblock(key, kb->name) == NULL) {
/* copy this existing one over to the new shapekey block */
kbn= MEM_dupallocN(kb);
kbn->prev= kbn->next= NULL;
kbn = MEM_dupallocN(kb);
kbn->prev = kbn->next = NULL;
/* adjust adrcode and other settings to fit (allocate a new data-array) */
kbn->data= MEM_callocN(sizeof(float)*3*totvert, "joined_shapekey");
kbn->totelem= totvert;
kbn->weights= NULL;
kbn->data = MEM_callocN(sizeof(float) * 3 * totvert, "joined_shapekey");
kbn->totelem = totvert;
kbn->weights = NULL;
okb= key->block.last;
curpos= (okb) ? okb->pos : -0.1f;
okb = key->block.last;
curpos = (okb) ? okb->pos : -0.1f;
if (key->type == KEY_RELATIVE)
kbn->pos= curpos + 0.1f;
kbn->pos = curpos + 0.1f;
else
kbn->pos= curpos;
kbn->pos = curpos;
BLI_addtail(&key->block, kbn);
kbn->adrcode= key->totkey;
kbn->adrcode = key->totkey;
key->totkey++;
if (key->totkey==1) key->refkey= kbn;
if (key->totkey == 1) key->refkey = kbn;
// XXX 2.5 Animato
#if 0
@@ -286,23 +287,24 @@ int join_mesh_exec(bContext *C, wmOperator *op)
memset(&ldata, 0, sizeof(ldata));
memset(&pdata, 0, sizeof(pdata));
mvert= CustomData_add_layer(&vdata, CD_MVERT, CD_CALLOC, NULL, totvert);
medge= CustomData_add_layer(&edata, CD_MEDGE, CD_CALLOC, NULL, totedge);
mloop= CustomData_add_layer(&ldata, CD_MLOOP, CD_CALLOC, NULL, totloop);
mpoly= CustomData_add_layer(&pdata, CD_MPOLY, CD_CALLOC, NULL, totpoly);
mvert = CustomData_add_layer(&vdata, CD_MVERT, CD_CALLOC, NULL, totvert);
medge = CustomData_add_layer(&edata, CD_MEDGE, CD_CALLOC, NULL, totedge);
mloop = CustomData_add_layer(&ldata, CD_MLOOP, CD_CALLOC, NULL, totloop);
mpoly = CustomData_add_layer(&pdata, CD_MPOLY, CD_CALLOC, NULL, totpoly);
vertofs= 0;
edgeofs= 0;
loopofs= 0;
polyofs= 0;
vertofs = 0;
edgeofs = 0;
loopofs = 0;
polyofs = 0;
/* inverse transform for all selected meshes in this object */
invert_m4_m4(imat, ob->obmat);
CTX_DATA_BEGIN(C, Base*, base, selected_editable_bases) {
CTX_DATA_BEGIN(C, Base *, base, selected_editable_bases)
{
/* only join if this is a mesh */
if (base->object->type==OB_MESH) {
me= base->object->data;
if (base->object->type == OB_MESH) {
me = base->object->data;
if (me->totvert) {
/* standard data */
@@ -310,17 +312,17 @@ int join_mesh_exec(bContext *C, wmOperator *op)
CustomData_copy_data(&me->vdata, &vdata, 0, vertofs, me->totvert);
/* vertex groups */
dvert= CustomData_get(&vdata, vertofs, CD_MDEFORMVERT);
dvert = CustomData_get(&vdata, vertofs, CD_MDEFORMVERT);
/* NB: vertex groups here are new version */
if (dvert) {
for (i=0; i<me->totvert; i++) {
for (j=0; j<dvert[i].totweight; j++) {
for (i = 0; i < me->totvert; i++) {
for (j = 0; j < dvert[i].totweight; j++) {
/* Find the old vertex group */
odg = BLI_findlink(&base->object->defbase, dvert[i].dw[j].def_nr);
if (odg) {
/* Search for a match in the new object, and set new index */
for (dg=ob->defbase.first, index=0; dg; dg=dg->next, index++) {
for (dg = ob->defbase.first, index = 0; dg; dg = dg->next, index++) {
if (!strcmp(dg->name, odg->name)) {
dvert[i].dw[j].def_nr = index;
break;
@@ -337,7 +339,7 @@ int join_mesh_exec(bContext *C, wmOperator *op)
mult_m4_m4m4(cmat, imat, base->object->obmat);
/* transform vertex coordinates into new space */
for (a=0, mv=mvert; a < me->totvert; a++, mv++) {
for (a = 0, mv = mvert; a < me->totvert; a++, mv++) {
mul_m4_v3(cmat, mv->co);
}
@@ -347,24 +349,24 @@ int join_mesh_exec(bContext *C, wmOperator *op)
*/
if (key) {
/* if this mesh has any shapekeys, check first, otherwise just copy coordinates */
for (kb= key->block.first; kb; kb= kb->next) {
for (kb = key->block.first; kb; kb = kb->next) {
/* get pointer to where to write data for this mesh in shapekey's data array */
fp1= ((float *)kb->data) + (vertofs*3);
fp1 = ((float *)kb->data) + (vertofs * 3);
/* check if this mesh has such a shapekey */
okb= key_get_named_keyblock(me->key, kb->name);
okb = key_get_named_keyblock(me->key, kb->name);
if (okb) {
/* copy this mesh's shapekey to the destination shapekey (need to transform first) */
fp2= ((float *)(okb->data));
for (a=0; a < me->totvert; a++, fp1+=3, fp2+=3) {
fp2 = ((float *)(okb->data));
for (a = 0; a < me->totvert; a++, fp1 += 3, fp2 += 3) {
copy_v3_v3(fp1, fp2);
mul_m4_v3(cmat, fp1);
}
}
else {
/* copy this mesh's vertex coordinates to the destination shapekey */
mv= mvert;
for (a=0; a < me->totvert; a++, fp1+=3, mv++) {
mv = mvert;
for (a = 0; a < me->totvert; a++, fp1 += 3, mv++) {
copy_v3_v3(fp1, mv->co);
}
}
@@ -377,23 +379,23 @@ int join_mesh_exec(bContext *C, wmOperator *op)
* - otherwise, copy across plain coordinates (no need to transform coordinates)
*/
if (key) {
for (kb= key->block.first; kb; kb= kb->next) {
for (kb = key->block.first; kb; kb = kb->next) {
/* get pointer to where to write data for this mesh in shapekey's data array */
fp1= ((float *)kb->data) + (vertofs*3);
fp1 = ((float *)kb->data) + (vertofs * 3);
/* check if this was one of the original shapekeys */
okb= key_get_named_keyblock(nkey, kb->name);
okb = key_get_named_keyblock(nkey, kb->name);
if (okb) {
/* copy this mesh's shapekey to the destination shapekey */
fp2= ((float *)(okb->data));
for (a=0; a < me->totvert; a++, fp1+=3, fp2+=3) {
fp2 = ((float *)(okb->data));
for (a = 0; a < me->totvert; a++, fp1 += 3, fp2 += 3) {
copy_v3_v3(fp1, fp2);
}
}
else {
/* copy base-coordinates to the destination shapekey */
mv= mvert;
for (a=0; a < me->totvert; a++, fp1+=3, mv++) {
mv = mvert;
for (a = 0; a < me->totvert; a++, fp1 += 3, mv++) {
copy_v3_v3(fp1, mv->co);
}
}
@@ -402,27 +404,27 @@ int join_mesh_exec(bContext *C, wmOperator *op)
}
/* advance mvert pointer to end of base mesh's data */
mvert+= me->totvert;
mvert += me->totvert;
}
if (me->totedge) {
CustomData_merge(&me->edata, &edata, CD_MASK_MESH, CD_DEFAULT, totedge);
CustomData_copy_data(&me->edata, &edata, 0, edgeofs, me->totedge);
for (a=0; a<me->totedge; a++, medge++) {
medge->v1+= vertofs;
medge->v2+= vertofs;
for (a = 0; a < me->totedge; a++, medge++) {
medge->v1 += vertofs;
medge->v2 += vertofs;
}
}
if (me->totloop) {
if (base->object!=ob)
if (base->object != ob)
multiresModifier_prepare_join(scene, base->object, ob);
CustomData_merge(&me->ldata, &ldata, CD_MASK_MESH, CD_DEFAULT, totloop);
CustomData_copy_data(&me->ldata, &ldata, 0, loopofs, me->totloop);
for (a=0; a<me->totloop; a++, mloop++) {
for (a = 0; a < me->totloop; a++, mloop++) {
mloop->v += vertofs;
mloop->e += edgeofs;
}
@@ -430,12 +432,12 @@ int join_mesh_exec(bContext *C, wmOperator *op)
if (me->totpoly) {
/* make mapping for materials */
for (a=1; a<=base->object->totcol; a++) {
ma= give_current_material(base->object, a);
for (a = 1; a <= base->object->totcol; a++) {
ma = give_current_material(base->object, a);
for (b=0; b<totcol; b++) {
for (b = 0; b < totcol; b++) {
if (ma == matar[b]) {
matmap[a-1]= b;
matmap[a - 1] = b;
break;
}
}
@@ -444,9 +446,9 @@ int join_mesh_exec(bContext *C, wmOperator *op)
CustomData_merge(&me->pdata, &pdata, CD_MASK_MESH, CD_DEFAULT, totpoly);
CustomData_copy_data(&me->pdata, &pdata, 0, polyofs, me->totpoly);
for (a=0; a<me->totpoly; a++, mpoly++) {
for (a = 0; a < me->totpoly; a++, mpoly++) {
mpoly->loopstart += loopofs;
mpoly->mat_nr= matmap ? matmap[(int)mpoly->mat_nr] : 0;
mpoly->mat_nr = matmap ? matmap[(int)mpoly->mat_nr] : 0;
}
polyofs += me->totpoly;
@@ -467,49 +469,49 @@ int join_mesh_exec(bContext *C, wmOperator *op)
CTX_DATA_END;
/* return to mesh we're merging to */
me= ob->data;
me = ob->data;
CustomData_free(&me->vdata, me->totvert);
CustomData_free(&me->edata, me->totedge);
CustomData_free(&me->ldata, me->totloop);
CustomData_free(&me->pdata, me->totpoly);
me->totvert= totvert;
me->totedge= totedge;
me->totloop= totloop;
me->totpoly= totpoly;
me->vdata= vdata;
me->edata= edata;
me->ldata= ldata;
me->pdata= pdata;
me->totvert = totvert;
me->totedge = totedge;
me->totloop = totloop;
me->totpoly = totpoly;
me->vdata = vdata;
me->edata = edata;
me->ldata = ldata;
me->pdata = pdata;
mesh_update_customdata_pointers(me, TRUE); /* BMESH_TODO, check if this arg can be failse, non urgent - campbell */
/* old material array */
for (a=1; a<=ob->totcol; a++) {
ma= ob->mat[a-1];
for (a = 1; a <= ob->totcol; a++) {
ma = ob->mat[a - 1];
if (ma) ma->id.us--;
}
for (a=1; a<=me->totcol; a++) {
ma= me->mat[a-1];
for (a = 1; a <= me->totcol; a++) {
ma = me->mat[a - 1];
if (ma) ma->id.us--;
}
if (ob->mat) MEM_freeN(ob->mat);
if (ob->matbits) MEM_freeN(ob->matbits);
if (me->mat) MEM_freeN(me->mat);
ob->mat= me->mat= NULL;
ob->matbits= NULL;
ob->mat = me->mat = NULL;
ob->matbits = NULL;
if (totcol) {
me->mat= matar;
ob->mat= MEM_callocN(sizeof(void *)*totcol, "join obmatar");
ob->matbits= MEM_callocN(sizeof(char)*totcol, "join obmatbits");
me->mat = matar;
ob->mat = MEM_callocN(sizeof(void *) * totcol, "join obmatar");
ob->matbits = MEM_callocN(sizeof(char) * totcol, "join obmatbits");
}
else
MEM_freeN(matar);
ob->totcol= me->totcol= totcol;
ob->totcol = me->totcol = totcol;
if (matmap) MEM_freeN(matmap);
@@ -533,21 +535,21 @@ int join_mesh_exec(bContext *C, wmOperator *op)
MEM_freeN(nkey);
}
DAG_scene_sort(bmain, scene); // removed objects, need to rebuild dag before editmode call
DAG_scene_sort(bmain, scene); // removed objects, need to rebuild dag before editmode call
#if 0
ED_object_enter_editmode(C, EM_WAITCURSOR);
ED_object_exit_editmode(C, EM_FREEDATA|EM_WAITCURSOR|EM_DO_UNDO);
ED_object_exit_editmode(C, EM_FREEDATA | EM_WAITCURSOR | EM_DO_UNDO);
#else
/* toggle editmode using lower level functions so this can be called from python */
EDBM_MakeEditBMesh(scene->toolsettings, scene, ob);
EDBM_LoadEditBMesh(scene, ob);
EDBM_FreeEditBMesh(me->edit_btmesh);
MEM_freeN(me->edit_btmesh);
me->edit_btmesh= NULL;
DAG_id_tag_update(&ob->id, OB_RECALC_OB|OB_RECALC_DATA);
me->edit_btmesh = NULL;
DAG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA);
#endif
WM_event_add_notifier(C, NC_SCENE|ND_OB_ACTIVE, scene);
WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, scene);
return OPERATOR_FINISHED;
}
@@ -559,25 +561,25 @@ int join_mesh_exec(bContext *C, wmOperator *op)
int join_mesh_shapes_exec(bContext *C, wmOperator *op)
{
Scene *scene= CTX_data_scene(C);
Object *ob= CTX_data_active_object(C);
Mesh *me= (Mesh *)ob->data;
Mesh *selme=NULL;
DerivedMesh *dm=NULL;
Key *key=me->key;
Scene *scene = CTX_data_scene(C);
Object *ob = CTX_data_active_object(C);
Mesh *me = (Mesh *)ob->data;
Mesh *selme = NULL;
DerivedMesh *dm = NULL;
Key *key = me->key;
KeyBlock *kb;
int ok=0, nonequal_verts=0;
int ok = 0, nonequal_verts = 0;
CTX_DATA_BEGIN(C, Base*, base, selected_editable_bases) {
CTX_DATA_BEGIN(C, Base *, base, selected_editable_bases) {
if (base->object == ob) continue;
if (base->object->type==OB_MESH) {
if (base->object->type == OB_MESH) {
selme = (Mesh *)base->object->data;
if (selme->totvert==me->totvert)
if (selme->totvert == me->totvert)
ok++;
else
nonequal_verts=1;
nonequal_verts = 1;
}
}
CTX_DATA_END;
@@ -591,27 +593,28 @@ int join_mesh_shapes_exec(bContext *C, wmOperator *op)
}
if (key == NULL) {
key= me->key= add_key((ID *)me);
key->type= KEY_RELATIVE;
key = me->key = add_key((ID *)me);
key->type = KEY_RELATIVE;
/* first key added, so it was the basis. initialize it with the existing mesh */
kb= add_keyblock(key, NULL);
kb = add_keyblock(key, NULL);
mesh_to_key(me, kb);
}
/* now ready to add new keys from selected meshes */
CTX_DATA_BEGIN(C, Base*, base, selected_editable_bases) {
CTX_DATA_BEGIN(C, Base *, base, selected_editable_bases)
{
if (base->object == ob) continue;
if (base->object->type==OB_MESH) {
if (base->object->type == OB_MESH) {
selme = (Mesh *)base->object->data;
if (selme->totvert==me->totvert) {
if (selme->totvert == me->totvert) {
dm = mesh_get_derived_deform(scene, base->object, CD_MASK_BAREMESH);
if (!dm) continue;
kb= add_keyblock(key, base->object->id.name+2);
kb = add_keyblock(key, base->object->id.name + 2);
DM_to_meshkey(dm, me, kb);
@@ -621,7 +624,7 @@ int join_mesh_shapes_exec(bContext *C, wmOperator *op)
}
CTX_DATA_END;
WM_event_add_notifier(C, NC_SCENE|ND_OB_ACTIVE, scene);
WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, scene);
return OPERATOR_FINISHED;
}
@@ -630,9 +633,9 @@ int join_mesh_shapes_exec(bContext *C, wmOperator *op)
/* important note; this is unfinished, needs better API for editmode, and custom threshold */
#define MOC_RES 8
#define MOC_NODE_RES 8
#define MOC_THRESH 0.00002f
#define MOC_RES 8
#define MOC_NODE_RES 8
#define MOC_THRESH 0.00002f
typedef struct MocNode {
struct MocNode *next;
@@ -643,30 +646,30 @@ static int mesh_octree_get_base_offs(float *co, float *offs, float *div)
{
int vx, vy, vz;
vx= floor( (co[0]-offs[0])/div[0] );
vy= floor( (co[1]-offs[1])/div[1] );
vz= floor( (co[2]-offs[2])/div[2] );
CLAMP(vx, 0, MOC_RES-1);
CLAMP(vy, 0, MOC_RES-1);
CLAMP(vz, 0, MOC_RES-1);
vx = floor( (co[0] - offs[0]) / div[0]);
vy = floor( (co[1] - offs[1]) / div[1]);
vz = floor( (co[2] - offs[2]) / div[2]);
return (vx*MOC_RES*MOC_RES) + vy*MOC_RES + vz;
CLAMP(vx, 0, MOC_RES - 1);
CLAMP(vy, 0, MOC_RES - 1);
CLAMP(vz, 0, MOC_RES - 1);
return (vx * MOC_RES * MOC_RES) + vy * MOC_RES + vz;
}
static void mesh_octree_add_node(MocNode **bt, intptr_t index)
{
if (*bt==NULL) {
*bt= MEM_callocN(sizeof(MocNode), "MocNode");
(*bt)->index[0]= index;
if (*bt == NULL) {
*bt = MEM_callocN(sizeof(MocNode), "MocNode");
(*bt)->index[0] = index;
}
else {
int a;
for (a=0; a<MOC_NODE_RES; a++) {
if ((*bt)->index[a]==index)
for (a = 0; a < MOC_NODE_RES; a++) {
if ((*bt)->index[a] == index)
return;
else if ((*bt)->index[a]==0) {
(*bt)->index[a]= index;
else if ((*bt)->index[a] == 0) {
(*bt)->index[a] = index;
return;
}
}
@@ -676,7 +679,7 @@ static void mesh_octree_add_node(MocNode **bt, intptr_t index)
static void mesh_octree_free_node(MocNode **bt)
{
if ( (*bt)->next ) {
if ( (*bt)->next) {
mesh_octree_free_node(&(*bt)->next);
}
MEM_freeN(*bt);
@@ -684,52 +687,52 @@ static void mesh_octree_free_node(MocNode **bt)
/* temporal define, just to make nicer code below */
#define MOC_INDEX(vx, vy, vz) (((vx)*MOC_RES*MOC_RES) + (vy)*MOC_RES + (vz))
#define MOC_INDEX(vx, vy, vz) (((vx) * MOC_RES * MOC_RES) + (vy) * MOC_RES + (vz))
static void mesh_octree_add_nodes(MocNode **basetable, float *co, float *offs, float *div, intptr_t index)
{
float fx, fy, fz;
int vx, vy, vz;
if ( !finite(co[0]) ||
!finite(co[1]) ||
!finite(co[2]))
if (!finite(co[0]) ||
!finite(co[1]) ||
!finite(co[2]))
{
return;
}
fx= (co[0]-offs[0])/div[0];
fy= (co[1]-offs[1])/div[1];
fz= (co[2]-offs[2])/div[2];
CLAMP(fx, 0.0f, MOC_RES-MOC_THRESH);
CLAMP(fy, 0.0f, MOC_RES-MOC_THRESH);
CLAMP(fz, 0.0f, MOC_RES-MOC_THRESH);
vx= (int)floorf(fx);
vy= (int)floorf(fy);
vz= (int)floorf(fz);
fx = (co[0] - offs[0]) / div[0];
fy = (co[1] - offs[1]) / div[1];
fz = (co[2] - offs[2]) / div[2];
CLAMP(fx, 0.0f, MOC_RES - MOC_THRESH);
CLAMP(fy, 0.0f, MOC_RES - MOC_THRESH);
CLAMP(fz, 0.0f, MOC_RES - MOC_THRESH);
vx = (int)floorf(fx);
vy = (int)floorf(fy);
vz = (int)floorf(fz);
mesh_octree_add_node(basetable + MOC_INDEX(vx, vy, vz), index);
if (vx > 0)
if (fx-((float)vx)-MOC_THRESH < 0.0f)
if (fx - ((float)vx) - MOC_THRESH < 0.0f)
mesh_octree_add_node(basetable + MOC_INDEX(vx - 1, vy, vz), index);
if (vx < MOC_RES - 2)
if (fx-((float)vx)+MOC_THRESH > 1.0f)
if (fx - ((float)vx) + MOC_THRESH > 1.0f)
mesh_octree_add_node(basetable + MOC_INDEX(vx + 1, vy, vz), index);
if (vy > 0)
if (fy-((float)vy)-MOC_THRESH < 0.0f)
if (fy - ((float)vy) - MOC_THRESH < 0.0f)
mesh_octree_add_node(basetable + MOC_INDEX(vx, vy - 1, vz), index);
if (vy < MOC_RES - 2)
if (fy-((float)vy)+MOC_THRESH > 1.0f)
if (fy - ((float)vy) + MOC_THRESH > 1.0f)
mesh_octree_add_node(basetable + MOC_INDEX(vx, vy + 1, vz), index);
if (vz > 0)
if (fz-((float)vz)-MOC_THRESH < 0.0f)
if (fz - ((float)vz) - MOC_THRESH < 0.0f)
mesh_octree_add_node(basetable + MOC_INDEX(vx, vy, vz - 1), index);
if (vz <MOC_RES - 2)
if (fz-((float)vz)+MOC_THRESH > 1.0f)
if (vz < MOC_RES - 2)
if (fz - ((float)vz) + MOC_THRESH > 1.0f)
mesh_octree_add_node(basetable + MOC_INDEX(vx, vy, vz + 1), index);
}
@@ -739,19 +742,19 @@ static intptr_t mesh_octree_find_index(MocNode **bt, MVert *mvert, float *co)
float *vec;
int a;
if (*bt==NULL)
if (*bt == NULL)
return -1;
for (a=0; a<MOC_NODE_RES; a++) {
for (a = 0; a < MOC_NODE_RES; a++) {
if ((*bt)->index[a]) {
/* does mesh verts and editmode, code looks potential dangerous, octree should really be filled OK! */
if (mvert) {
vec= (mvert+(*bt)->index[a]-1)->co;
vec = (mvert + (*bt)->index[a] - 1)->co;
if (compare_v3v3(vec, co, MOC_THRESH))
return (*bt)->index[a]-1;
return (*bt)->index[a] - 1;
}
else {
BMVert *eve= (BMVert *)((*bt)->index[a]);
BMVert *eve = (BMVert *)((*bt)->index[a]);
if (compare_v3v3(eve->co, co, MOC_THRESH))
return (*bt)->index[a];
}
@@ -775,13 +778,13 @@ intptr_t mesh_octree_table(Object *ob, BMEditMesh *em, float *co, char mode)
{
MocNode **bt;
if (mode=='u') { /* use table */
if (MeshOctree.table==NULL)
if (mode == 'u') { /* use table */
if (MeshOctree.table == NULL)
mesh_octree_table(ob, em, NULL, 's');
if (MeshOctree.table) {
Mesh *me= ob->data;
bt= MeshOctree.table + mesh_octree_get_base_offs(co, MeshOctree.offs, MeshOctree.div);
Mesh *me = ob->data;
bt = MeshOctree.table + mesh_octree_get_base_offs(co, MeshOctree.offs, MeshOctree.div);
if (em)
return mesh_octree_find_index(bt, NULL, co);
else
@@ -789,19 +792,20 @@ intptr_t mesh_octree_table(Object *ob, BMEditMesh *em, float *co, char mode)
}
return -1;
}
else if (mode=='s') { /* start table */
Mesh *me= ob->data;
else if (mode == 's') { /* start table */
Mesh *me = ob->data;
float min[3], max[3];
/* we compute own bounding box and don't reuse ob->bb because
* we are using the undeformed coordinates*/
INIT_MINMAX(min, max);
if (em && me->edit_btmesh==em) {
if (em && me->edit_btmesh == em) {
BMIter iter;
BMVert *eve;
BM_ITER(eve, &iter, em->bm, BM_VERTS_OF_MESH, NULL) {
BM_ITER(eve, &iter, em->bm, BM_VERTS_OF_MESH, NULL)
{
DO_MINMAX(eve->co, min, max);
}
}
@@ -809,36 +813,37 @@ intptr_t mesh_octree_table(Object *ob, BMEditMesh *em, float *co, char mode)
MVert *mvert;
int a;
for (a=0, mvert= me->mvert; a<me->totvert; a++, mvert++)
for (a = 0, mvert = me->mvert; a < me->totvert; a++, mvert++)
DO_MINMAX(mvert->co, min, max);
}
/* for quick unit coordinate calculus */
copy_v3_v3(MeshOctree.offs, min);
MeshOctree.offs[0]-= MOC_THRESH; /* we offset it 1 threshold unit extra */
MeshOctree.offs[1]-= MOC_THRESH;
MeshOctree.offs[2]-= MOC_THRESH;
MeshOctree.offs[0] -= MOC_THRESH; /* we offset it 1 threshold unit extra */
MeshOctree.offs[1] -= MOC_THRESH;
MeshOctree.offs[2] -= MOC_THRESH;
sub_v3_v3v3(MeshOctree.div, max, min);
MeshOctree.div[0]+= 2*MOC_THRESH; /* and divide with 2 threshold unit more extra (try 8x8 unit grid on paint) */
MeshOctree.div[1]+= 2*MOC_THRESH;
MeshOctree.div[2]+= 2*MOC_THRESH;
mul_v3_fl(MeshOctree.div, 1.0f/MOC_RES);
if (MeshOctree.div[0]==0.0f) MeshOctree.div[0]= 1.0f;
if (MeshOctree.div[1]==0.0f) MeshOctree.div[1]= 1.0f;
if (MeshOctree.div[2]==0.0f) MeshOctree.div[2]= 1.0f;
MeshOctree.div[0] += 2 * MOC_THRESH; /* and divide with 2 threshold unit more extra (try 8x8 unit grid on paint) */
MeshOctree.div[1] += 2 * MOC_THRESH;
MeshOctree.div[2] += 2 * MOC_THRESH;
mul_v3_fl(MeshOctree.div, 1.0f / MOC_RES);
if (MeshOctree.div[0] == 0.0f) MeshOctree.div[0] = 1.0f;
if (MeshOctree.div[1] == 0.0f) MeshOctree.div[1] = 1.0f;
if (MeshOctree.div[2] == 0.0f) MeshOctree.div[2] = 1.0f;
if (MeshOctree.table) /* happens when entering this call without ending it */
mesh_octree_table(ob, em, co, 'e');
MeshOctree.table= MEM_callocN(MOC_RES*MOC_RES*MOC_RES*sizeof(void *), "sym table");
MeshOctree.table = MEM_callocN(MOC_RES * MOC_RES * MOC_RES * sizeof(void *), "sym table");
if (em && me->edit_btmesh==em) {
if (em && me->edit_btmesh == em) {
BMVert *eve;
BMIter iter;
BM_ITER(eve, &iter, em->bm, BM_VERTS_OF_MESH, NULL) {
BM_ITER(eve, &iter, em->bm, BM_VERTS_OF_MESH, NULL)
{
mesh_octree_add_nodes(MeshOctree.table, eve->co, MeshOctree.offs, MeshOctree.div, (intptr_t)(eve));
}
}
@@ -846,40 +851,40 @@ intptr_t mesh_octree_table(Object *ob, BMEditMesh *em, float *co, char mode)
MVert *mvert;
int a;
for (a=0, mvert= me->mvert; a<me->totvert; a++, mvert++)
mesh_octree_add_nodes(MeshOctree.table, mvert->co, MeshOctree.offs, MeshOctree.div, a+1);
for (a = 0, mvert = me->mvert; a < me->totvert; a++, mvert++)
mesh_octree_add_nodes(MeshOctree.table, mvert->co, MeshOctree.offs, MeshOctree.div, a + 1);
}
}
else if (mode=='e') { /* end table */
else if (mode == 'e') { /* end table */
if (MeshOctree.table) {
int a;
for (a=0, bt=MeshOctree.table; a<MOC_RES*MOC_RES*MOC_RES; a++, bt++) {
for (a = 0, bt = MeshOctree.table; a < MOC_RES * MOC_RES * MOC_RES; a++, bt++) {
if (*bt) mesh_octree_free_node(bt);
}
MEM_freeN(MeshOctree.table);
MeshOctree.table= NULL;
MeshOctree.table = NULL;
}
}
return 0;
}
MirrTopoStore_t mesh_topo_store= {NULL, -1. -1, -1};
MirrTopoStore_t mesh_topo_store = {NULL, -1. - 1, -1};
/* mode is 's' start, or 'e' end, or 'u' use */
/* if end, ob can be NULL */
/* note, is supposed return -1 on error, which callers are currently checking for, but is not used so far */
int mesh_mirrtopo_table(Object *ob, char mode)
{
if (mode=='u') { /* use table */
if (mode == 'u') { /* use table */
if (ED_mesh_mirrtopo_recalc_check(ob->data, ob->mode, &mesh_topo_store)) {
mesh_mirrtopo_table(ob, 's');
}
}
else if (mode=='s') { /* start table */
else if (mode == 's') { /* start table */
ED_mesh_mirrtopo_init(ob->data, ob->mode, &mesh_topo_store, FALSE);
}
else if (mode=='e') { /* end table */
else if (mode == 'e') { /* end table */
ED_mesh_mirrtopo_free(&mesh_topo_store);
}
return 0;
@@ -887,21 +892,21 @@ int mesh_mirrtopo_table(Object *ob, char mode)
static int mesh_get_x_mirror_vert_spacial(Object *ob, int index)
{
Mesh *me= ob->data;
Mesh *me = ob->data;
MVert *mvert;
float vec[3];
mvert= me->mvert+index;
vec[0]= -mvert->co[0];
vec[1]= mvert->co[1];
vec[2]= mvert->co[2];
mvert = me->mvert + index;
vec[0] = -mvert->co[0];
vec[1] = mvert->co[1];
vec[2] = mvert->co[2];
return mesh_octree_table(ob, NULL, vec, 'u');
}
static int mesh_get_x_mirror_vert_topo(Object *ob, int index)
{
if (mesh_mirrtopo_table(ob, 'u')==-1)
if (mesh_mirrtopo_table(ob, 'u') == -1)
return -1;
return mesh_topo_store.index_lookup[index];
@@ -925,16 +930,16 @@ static BMVert *editbmesh_get_x_mirror_vert_spacial(Object *ob, BMEditMesh *em, f
/* ignore nan verts */
if (!finite(co[0]) ||
!finite(co[1]) ||
!finite(co[2])
)
!finite(co[1]) ||
!finite(co[2])
)
return NULL;
vec[0]= -co[0];
vec[1]= co[1];
vec[2]= co[2];
vec[0] = -co[0];
vec[1] = co[1];
vec[2] = co[2];
poinval= mesh_octree_table(ob, em, vec, 'u');
poinval = mesh_octree_table(ob, em, vec, 'u');
if (poinval != -1)
return (BMVert *)(poinval);
return NULL;
@@ -943,7 +948,7 @@ static BMVert *editbmesh_get_x_mirror_vert_spacial(Object *ob, BMEditMesh *em, f
static BMVert *editbmesh_get_x_mirror_vert_topo(Object *ob, struct BMEditMesh *em, BMVert *eve, int index)
{
intptr_t poinval;
if (mesh_mirrtopo_table(ob, 'u')==-1)
if (mesh_mirrtopo_table(ob, 'u') == -1)
return NULL;
if (index == -1) {
@@ -951,7 +956,8 @@ static BMVert *editbmesh_get_x_mirror_vert_topo(Object *ob, struct BMEditMesh *e
BMVert *v;
index = 0;
BM_ITER(v, &iter, em->bm, BM_VERTS_OF_MESH, NULL) {
BM_ITER(v, &iter, em->bm, BM_VERTS_OF_MESH, NULL)
{
if (v == eve)
break;
index++;
@@ -962,7 +968,7 @@ static BMVert *editbmesh_get_x_mirror_vert_topo(Object *ob, struct BMEditMesh *e
}
}
poinval= mesh_topo_store.index_lookup[index];
poinval = mesh_topo_store.index_lookup[index];
if (poinval != -1)
return (BMVert *)(poinval);
@@ -989,22 +995,22 @@ static float *editmesh_get_mirror_uv(BMEditMesh *em, int axis, float *uv, float
/* ignore nan verts */
if (isnan(uv[0]) || !finite(uv[0]) ||
isnan(uv[1]) || !finite(uv[1])
)
isnan(uv[1]) || !finite(uv[1])
)
return NULL;
if (axis) {
vec[0]= uv[0];
vec[1]= -((uv[1])-mirrCent[1]) + mirrCent[1];
vec[0] = uv[0];
vec[1] = -((uv[1]) - mirrCent[1]) + mirrCent[1];
cent_vec[0] = face_cent[0];
cent_vec[1]= -((face_cent[1])-mirrCent[1]) + mirrCent[1];
cent_vec[1] = -((face_cent[1]) - mirrCent[1]) + mirrCent[1];
}
else {
vec[0]= -((uv[0])-mirrCent[0]) + mirrCent[0];
vec[1]= uv[1];
vec[0] = -((uv[0]) - mirrCent[0]) + mirrCent[0];
vec[1] = uv[1];
cent_vec[0]= -((face_cent[0])-mirrCent[0]) + mirrCent[0];
cent_vec[0] = -((face_cent[0]) - mirrCent[0]) + mirrCent[0];
cent_vec[1] = face_cent[1];
}
@@ -1013,23 +1019,25 @@ static float *editmesh_get_mirror_uv(BMEditMesh *em, int axis, float *uv, float
BMIter iter;
BMFace *efa;
BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) {
BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL)
{
poly_uv_center(em, efa, cent);
if ( (fabs(cent[0] - cent_vec[0]) < 0.001) && (fabs(cent[1] - cent_vec[1]) < 0.001) ) {
BMIter liter;
BMLoop *l;
BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) {
BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa)
{
MLoopUV *luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV);
if ( (fabs(luv->uv[0] - vec[0]) < 0.001) && (fabs(luv->uv[1] - vec[1]) < 0.001) ) {
return luv->uv;
}
}
}
}
}
}
return NULL;
}
@@ -1038,39 +1046,39 @@ static float *editmesh_get_mirror_uv(BMEditMesh *em, int axis, float *uv, float
static unsigned int mirror_facehash(const void *ptr)
{
const MFace *mf= ptr;
const MFace *mf = ptr;
int v0, v1;
if (mf->v4) {
v0= MIN4(mf->v1, mf->v2, mf->v3, mf->v4);
v1= MAX4(mf->v1, mf->v2, mf->v3, mf->v4);
v0 = MIN4(mf->v1, mf->v2, mf->v3, mf->v4);
v1 = MAX4(mf->v1, mf->v2, mf->v3, mf->v4);
}
else {
v0= MIN3(mf->v1, mf->v2, mf->v3);
v1= MAX3(mf->v1, mf->v2, mf->v3);
v0 = MIN3(mf->v1, mf->v2, mf->v3);
v1 = MAX3(mf->v1, mf->v2, mf->v3);
}
return ((v0*39)^(v1*31));
return ((v0 * 39) ^ (v1 * 31));
}
static int mirror_facerotation(MFace *a, MFace *b)
{
if (b->v4) {
if (a->v1==b->v1 && a->v2==b->v2 && a->v3==b->v3 && a->v4==b->v4)
if (a->v1 == b->v1 && a->v2 == b->v2 && a->v3 == b->v3 && a->v4 == b->v4)
return 0;
else if (a->v4==b->v1 && a->v1==b->v2 && a->v2==b->v3 && a->v3==b->v4)
else if (a->v4 == b->v1 && a->v1 == b->v2 && a->v2 == b->v3 && a->v3 == b->v4)
return 1;
else if (a->v3==b->v1 && a->v4==b->v2 && a->v1==b->v3 && a->v2==b->v4)
else if (a->v3 == b->v1 && a->v4 == b->v2 && a->v1 == b->v3 && a->v2 == b->v4)
return 2;
else if (a->v2==b->v1 && a->v3==b->v2 && a->v4==b->v3 && a->v1==b->v4)
else if (a->v2 == b->v1 && a->v3 == b->v2 && a->v4 == b->v3 && a->v1 == b->v4)
return 3;
}
else {
if (a->v1==b->v1 && a->v2==b->v2 && a->v3==b->v3)
if (a->v1 == b->v1 && a->v2 == b->v2 && a->v3 == b->v3)
return 0;
else if (a->v3==b->v1 && a->v1==b->v2 && a->v2==b->v3)
else if (a->v3 == b->v1 && a->v1 == b->v2 && a->v2 == b->v3)
return 1;
else if (a->v2==b->v1 && a->v3==b->v2 && a->v1==b->v3)
else if (a->v2 == b->v1 && a->v3 == b->v2 && a->v1 == b->v3)
return 2;
}
@@ -1079,52 +1087,52 @@ static int mirror_facerotation(MFace *a, MFace *b)
static int mirror_facecmp(const void *a, const void *b)
{
return (mirror_facerotation((MFace*)a, (MFace*)b) == -1);
return (mirror_facerotation((MFace *)a, (MFace *)b) == -1);
}
/* BMESH_TODO, convert to MPoly (functions above also) */
int *mesh_get_x_mirror_faces(Object *ob, BMEditMesh *em)
{
Mesh *me= ob->data;
MVert *mv, *mvert= me->mvert;
MFace mirrormf, *mf, *hashmf, *mface= me->mface;
Mesh *me = ob->data;
MVert *mv, *mvert = me->mvert;
MFace mirrormf, *mf, *hashmf, *mface = me->mface;
GHash *fhash;
int *mirrorverts, *mirrorfaces;
int a;
mirrorverts= MEM_callocN(sizeof(int)*me->totvert, "MirrorVerts");
mirrorfaces= MEM_callocN(sizeof(int)*2*me->totface, "MirrorFaces");
mirrorverts = MEM_callocN(sizeof(int) * me->totvert, "MirrorVerts");
mirrorfaces = MEM_callocN(sizeof(int) * 2 * me->totface, "MirrorFaces");
mesh_octree_table(ob, em, NULL, 's');
for (a=0, mv=mvert; a<me->totvert; a++, mv++)
mirrorverts[a]= mesh_get_x_mirror_vert(ob, a);
for (a = 0, mv = mvert; a < me->totvert; a++, mv++)
mirrorverts[a] = mesh_get_x_mirror_vert(ob, a);
mesh_octree_table(ob, em, NULL, 'e');
fhash= BLI_ghash_new(mirror_facehash, mirror_facecmp, "mirror_facehash gh");
for (a=0, mf=mface; a<me->totface; a++, mf++)
fhash = BLI_ghash_new(mirror_facehash, mirror_facecmp, "mirror_facehash gh");
for (a = 0, mf = mface; a < me->totface; a++, mf++)
BLI_ghash_insert(fhash, mf, mf);
for (a=0, mf=mface; a<me->totface; a++, mf++) {
mirrormf.v1= mirrorverts[mf->v3];
mirrormf.v2= mirrorverts[mf->v2];
mirrormf.v3= mirrorverts[mf->v1];
mirrormf.v4= (mf->v4)? mirrorverts[mf->v4]: 0;
for (a = 0, mf = mface; a < me->totface; a++, mf++) {
mirrormf.v1 = mirrorverts[mf->v3];
mirrormf.v2 = mirrorverts[mf->v2];
mirrormf.v3 = mirrorverts[mf->v1];
mirrormf.v4 = (mf->v4) ? mirrorverts[mf->v4] : 0;
/* make sure v4 is not 0 if a quad */
if (mf->v4 && mirrormf.v4==0) {
if (mf->v4 && mirrormf.v4 == 0) {
SWAP(unsigned int, mirrormf.v1, mirrormf.v3);
SWAP(unsigned int, mirrormf.v2, mirrormf.v4);
}
hashmf= BLI_ghash_lookup(fhash, &mirrormf);
hashmf = BLI_ghash_lookup(fhash, &mirrormf);
if (hashmf) {
mirrorfaces[a*2]= hashmf - mface;
mirrorfaces[a*2+1]= mirror_facerotation(&mirrormf, hashmf);
mirrorfaces[a * 2] = hashmf - mface;
mirrorfaces[a * 2 + 1] = mirror_facerotation(&mirrormf, hashmf);
}
else
mirrorfaces[a*2]= -1;
mirrorfaces[a * 2] = -1;
}
BLI_ghash_free(fhash, NULL, NULL);