diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-02-26 00:58:03 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-02-26 00:58:03 +0400 |
commit | 98aececc8e61e7d6d9225e59ab10d27da9498953 (patch) | |
tree | cee5dfeb04d4c0016dadaeabcfad5428ac7e692c /source | |
parent | 4f4bba39fb0da31bb4adad7e5110f98f85e59ebe (diff) |
bmesh code cleanup
* change BMO_elem_flag_* defines to inline functions.
* BMO_slot_map_insert() is too big for an inline function - un-inline it.
* remove redundant casts.
Diffstat (limited to 'source')
18 files changed, 141 insertions, 90 deletions
diff --git a/source/blender/bmesh/bmesh_operator_api.h b/source/blender/bmesh/bmesh_operator_api.h index 80f2856b066..f7ff7ea71a6 100644 --- a/source/blender/bmesh/bmesh_operator_api.h +++ b/source/blender/bmesh/bmesh_operator_api.h @@ -170,23 +170,6 @@ void BMO_op_exec(struct BMesh *bm, struct BMOperator *op); * after it finishes executing in BMO_op_exec).*/ void BMO_op_finish(struct BMesh *bm, struct BMOperator *op); - -/* tool flag API. never, ever ever should tool code put junk in - * header flags (element->head.flag), nor should they use - * element->head.eflag1/eflag2. instead, use this api to set - * flags. - * - * if you need to store a value per element, use a - * ghash or a mapping slot to do it. */ - -/* flags 15 and 16 (1<<14 and 1<<15) are reserved for bmesh api use */ -#define BMO_elem_flag_test(bm, element, oflag) ((element)->oflags[bm->stackdepth-1].f & (oflag)) -#define BMO_elem_flag_enable(bm, element, oflag) ((element)->oflags[bm->stackdepth-1].f |= (oflag)) -#define BMO_elem_flag_disable(bm, element, oflag) ((element)->oflags[bm->stackdepth-1].f &= ~(oflag)) -#define BMO_elem_flag_set(bm, element, oflag, val)((val) ? BMO_elem_flag_enable(bm, element, oflag) : \ - BMO_elem_flag_disable(bm, element, oflag)) -#define BMO_elem_flag_toggle(bm, element, oflag) ((element)->oflags[bm->stackdepth-1].f ^= (oflag)) - /* count the number of elements with a specific flag. * type can be a bitmask of BM_FACE, BM_EDGE, or BM_FACE. */ int BMO_mesh_flag_count(struct BMesh *bm, const short oflag, const char htype); @@ -331,6 +314,9 @@ void BMO_slot_from_hflag(struct BMesh *bm, struct BMOperator *op, const char *sl int BMO_slot_buf_count(struct BMesh *bm, struct BMOperator *op, const char *slotname); int BMO_slot_map_count(struct BMesh *bm, struct BMOperator *op, const char *slotname); +void BMO_slot_map_insert(BMesh *UNUSED(bm), BMOperator *op, const char *slotname, + void *element, void *data, int len); + /* Counts the number of edges with tool flag toolflag around */ int BMO_vert_edge_flags_count(BMesh *bm, BMVert *v, const short oflag); diff --git a/source/blender/bmesh/intern/bmesh_construct.c b/source/blender/bmesh/intern/bmesh_construct.c index ac37041b073..202d43c67c0 100644 --- a/source/blender/bmesh/intern/bmesh_construct.c +++ b/source/blender/bmesh/intern/bmesh_construct.c @@ -559,25 +559,37 @@ void BM_elem_attrs_copy(BMesh *source_mesh, BMesh *target_mesh, const void *sour { const BMHeader *sheader = source; BMHeader *theader = target; - + + BLI_assert(sheader->htype == theader->htype); + if (sheader->htype != theader->htype) return; /* First we copy select */ - if (BM_elem_flag_test(source, BM_ELEM_SELECT)) BM_elem_select_set(target_mesh, target, TRUE); + if (BM_elem_flag_test(source, BM_ELEM_SELECT)) { + BM_elem_select_set(target_mesh, target, TRUE); + } /* Now we copy flags */ theader->hflag = sheader->hflag; /* Copy specific attributes */ - if (theader->htype == BM_VERT) - bm_vert_attrs_copy(source_mesh, target_mesh, (const BMVert *)source, (BMVert *)target); - else if (theader->htype == BM_EDGE) - bm_edge_attrs_copy(source_mesh, target_mesh, (const BMEdge *)source, (BMEdge *)target); - else if (theader->htype == BM_LOOP) - bm_loop_attrs_copy(source_mesh, target_mesh, (const BMLoop *)source, (BMLoop *)target); - else if (theader->htype == BM_FACE) - bm_face_attrs_copy(source_mesh, target_mesh, (const BMFace *)source, (BMFace *)target); + switch (theader->htype) { + case BM_VERT: + bm_vert_attrs_copy(source_mesh, target_mesh, (const BMVert *)source, (BMVert *)target); + break; + case BM_EDGE: + bm_edge_attrs_copy(source_mesh, target_mesh, (const BMEdge *)source, (BMEdge *)target); + break; + case BM_LOOP: + bm_loop_attrs_copy(source_mesh, target_mesh, (const BMLoop *)source, (BMLoop *)target); + break; + case BM_FACE: + bm_face_attrs_copy(source_mesh, target_mesh, (const BMFace *)source, (BMFace *)target); + break; + default: + BLI_assert(0); + } } BMesh *BM_mesh_copy(BMesh *bmold) diff --git a/source/blender/bmesh/intern/bmesh_interp.c b/source/blender/bmesh/intern/bmesh_interp.c index 060ec8753c9..7d94fac2414 100644 --- a/source/blender/bmesh/intern/bmesh_interp.c +++ b/source/blender/bmesh/intern/bmesh_interp.c @@ -422,7 +422,7 @@ static float bmesh_loop_flip_equotion(float mat[2][2], float b[2], float target_ b[0] = coord[i]; b[1] = coord[j]; - return mat[0][0]*mat[1][1] - mat[0][1]*mat[1][0]; + return mat[0][0] * mat[1][1] - mat[0][1] * mat[1][0]; } static void bmesh_loop_flip_disp(float source_axis_x[3], float source_axis_y[3], @@ -449,8 +449,8 @@ static void bmesh_loop_flip_disp(float source_axis_x[3], float source_axis_y[3], d = bmesh_loop_flip_equotion(mat, b, target_axis_x, target_axis_y, coord, 1, 2); } - disp[0] = (b[0]*mat[1][1] - mat[0][1]*b[1]) / d; - disp[1] = (mat[0][0]*b[1] - b[0]*mat[1][0]) / d; + disp[0] = (b[0] * mat[1][1] - mat[0][1] * b[1]) / d; + disp[1] = (mat[0][0] * b[1] - b[0] * mat[1][0]) / d; } static void bmesh_loop_interp_mdisps(BMesh *bm, BMLoop *target, BMFace *source) diff --git a/source/blender/bmesh/intern/bmesh_marking.c b/source/blender/bmesh/intern/bmesh_marking.c index 21ecc245707..be542dfef0f 100644 --- a/source/blender/bmesh/intern/bmesh_marking.c +++ b/source/blender/bmesh/intern/bmesh_marking.c @@ -479,9 +479,20 @@ void BM_elem_select_set(struct BMesh *bm, void *element, int select) { BMHeader *head = element; - if (head->htype == BM_VERT) BM_vert_select_set(bm, (BMVert *)element, select); - else if (head->htype == BM_EDGE) BM_edge_select_set(bm, (BMEdge *)element, select); - else if (head->htype == BM_FACE) BM_face_select_set(bm, (BMFace *)element, select); + switch (head->htype) { + case BM_VERT: + BM_vert_select_set(bm, (BMVert *)element, select); + break; + case BM_EDGE: + BM_edge_select_set(bm, (BMEdge *)element, select); + break; + case BM_FACE: + BM_face_select_set(bm, (BMFace *)element, select); + break; + default: + BLI_assert(0); + break; + } } /* this replaces the active flag used in uv/face mode */ diff --git a/source/blender/bmesh/intern/bmesh_newcore.c b/source/blender/bmesh/intern/bmesh_newcore.c index 2bace65056d..31e141a77e0 100644 --- a/source/blender/bmesh/intern/bmesh_newcore.c +++ b/source/blender/bmesh/intern/bmesh_newcore.c @@ -67,20 +67,22 @@ BMVert *BM_vert_create(BMesh *bm, const float co[3], const struct BMVert *exampl v->head.htype = BM_VERT; /* 'v->no' is handled by BM_elem_attrs_copy */ - if (co) copy_v3_v3(v->co, co); - + if (co) { + copy_v3_v3(v->co, co); + } + /* allocate flag */ v->oflags = BLI_mempool_calloc(bm->toolflagpool); CustomData_bmesh_set_default(&bm->vdata, &v->head.data); if (example) { - BM_elem_attrs_copy(bm, bm, (BMVert *)example, v); + BM_elem_attrs_copy(bm, bm, example, v); } BM_CHECK_ELEMENT(bm, v); - return (BMVert *) v; + return v; } /** @@ -112,7 +114,7 @@ BMEdge *BM_edge_create(BMesh *bm, BMVert *v1, BMVert *v2, const BMEdge *example, BMEdge *e; if (nodouble && (e = BM_edge_exists(v1, v2))) - return (BMEdge *)e; + return e; e = BLI_mempool_calloc(bm->epool); @@ -131,8 +133,8 @@ BMEdge *BM_edge_create(BMesh *bm, BMVert *v1, BMVert *v2, const BMEdge *example, /* allocate flag */ e->oflags = BLI_mempool_calloc(bm->toolflagpool); - e->v1 = (BMVert *) v1; - e->v2 = (BMVert *) v2; + e->v1 = v1; + e->v2 = v2; BM_elem_flag_enable(e, BM_ELEM_SMOOTH); @@ -142,11 +144,11 @@ BMEdge *BM_edge_create(BMesh *bm, BMVert *v1, BMVert *v2, const BMEdge *example, bmesh_disk_append_edge(e, e->v2); if (example) - BM_elem_attrs_copy(bm, bm, (BMEdge *)example, (BMEdge *)e); + BM_elem_attrs_copy(bm, bm, example, e); BM_CHECK_ELEMENT(bm, e); - return (BMEdge *) e; + return e; } static BMLoop *bmesh_create_loop(BMesh *bm, BMVert *v, BMEdge *e, BMFace *f, const BMLoop *example) @@ -292,14 +294,14 @@ BMFace *BM_face_create(BMesh *bm, BMVert **verts, BMEdge **edges, const int len, f->head.htype = BM_FACE; - startl = lastl = bm_face_boundary_add(bm, (BMFace *)f, verts[0], edges[0]); + startl = lastl = bm_face_boundary_add(bm, f, verts[0], edges[0]); - startl->v = (BMVert *)verts[0]; - startl->e = (BMEdge *)edges[0]; + startl->v = verts[0]; + startl->e = edges[0]; for (i = 1; i < len; i++) { - l = bmesh_create_loop(bm, verts[i], edges[i], (BMFace *)f, edges[i]->l); + l = bmesh_create_loop(bm, verts[i], edges[i], f, edges[i]->l); - l->f = (BMFace *) f; + l->f = f; bmesh_radial_append(edges[i], l); l->prev = lastl; @@ -323,7 +325,7 @@ BMFace *BM_face_create(BMesh *bm, BMVert **verts, BMEdge **edges, const int len, BM_CHECK_ELEMENT(bm, f); - return (BMFace *) f; + return f; } int bmesh_check_element(BMesh *UNUSED(bm), void *element, const char htype) @@ -1083,7 +1085,7 @@ static BMFace *bmesh_addpolylist(BMesh *bm, BMFace *UNUSED(example)) f->totbounds = 1; #endif - return (BMFace *) f; + return f; } /** diff --git a/source/blender/bmesh/intern/bmesh_operator_api_inline.c b/source/blender/bmesh/intern/bmesh_operator_api_inline.c index 8e32f2710e2..7e5d6c3376f 100644 --- a/source/blender/bmesh/intern/bmesh_operator_api_inline.c +++ b/source/blender/bmesh/intern/bmesh_operator_api_inline.c @@ -31,34 +31,48 @@ #include "bmesh.h" -/* inserts a key/value mapping into a mapping slot. note that it copies the - * value, it doesn't store a reference to it. */ -BM_INLINE void BMO_slot_map_insert(BMesh *UNUSED(bm), BMOperator *op, const char *slotname, - void *element, void *data, int len) -{ - BMOElemMapping *mapping; - BMOpSlot *slot = BMO_slot_get(op, slotname); +/* tool flag API. never, ever ever should tool code put junk in + * header flags (element->head.flag), nor should they use + * element->head.eflag1/eflag2. instead, use this api to set + * flags. + * + * if you need to store a value per element, use a + * ghash or a mapping slot to do it. */ - /*sanity check*/ - if (slot->slottype != BMO_OP_SLOT_MAPPING) { - return; - } +/* flags 15 and 16 (1<<14 and 1<<15) are reserved for bmesh api use */ +BM_INLINE int _bmo_elem_flag_test(BMesh *bm, BMFlagLayer *oflags, const short oflag) +{ + return oflags[bm->stackdepth-1].f & oflag; +} - mapping = (BMOElemMapping *) BLI_memarena_alloc(op->arena, sizeof(*mapping) + len); +BM_INLINE void _bmo_elem_flag_enable(BMesh *bm, BMFlagLayer *oflags, const short oflag) +{ + oflags[bm->stackdepth-1].f |= oflag; +} - mapping->element = (BMHeader*) element; - mapping->len = len; - memcpy(mapping + 1, data, len); +BM_INLINE void _bmo_elem_flag_disable(BMesh *bm, BMFlagLayer *oflags, const short oflag) +{ + oflags[bm->stackdepth-1].f &= ~oflag; +} - if (!slot->data.ghash) { - slot->data.ghash = BLI_ghash_new(BLI_ghashutil_ptrhash, - BLI_ghashutil_ptrcmp, "bmesh op"); - } +BM_INLINE void _bmo_elem_flag_set(BMesh *bm, BMFlagLayer *oflags, const short oflag, int val) +{ + if (val) oflags[bm->stackdepth-1].f |= oflag; + else oflags[bm->stackdepth-1].f &= ~oflag; +} - BLI_ghash_insert(slot->data.ghash, element, mapping); +BM_INLINE void _bmo_elem_flag_toggle(BMesh *bm, BMFlagLayer *oflags, const short oflag) +{ + oflags[bm->stackdepth-1].f ^= oflag; } +#define BMO_elem_flag_test( bm, ele, oflag) _bmo_elem_flag_test (bm, (ele)->oflags, oflag) +#define BMO_elem_flag_enable( bm, ele, oflag) _bmo_elem_flag_enable (bm, (ele)->oflags, oflag) +#define BMO_elem_flag_disable(bm, ele, oflag) _bmo_elem_flag_disable (bm, (ele)->oflags, oflag) +#define BMO_elem_flag_set( bm, ele, oflag, val) _bmo_elem_flag_set (bm, (ele)->oflags, oflag, val) +#define BMO_elem_flag_toggle( bm, ele, oflag) _bmo_elem_flag_toggle (bm, (ele)->oflags, oflag) + BM_INLINE void BMO_slot_map_int_insert(BMesh *bm, BMOperator *op, const char *slotname, void *element, int val) { diff --git a/source/blender/bmesh/intern/bmesh_operators.c b/source/blender/bmesh/intern/bmesh_operators.c index f26dd7bbe6f..f0898734d4c 100644 --- a/source/blender/bmesh/intern/bmesh_operators.c +++ b/source/blender/bmesh/intern/bmesh_operators.c @@ -534,6 +534,34 @@ int BMO_slot_map_count(BMesh *UNUSED(bm), BMOperator *op, const char *slotname) return slot->data.ghash ? BLI_ghash_size(slot->data.ghash) : 0; } +/* inserts a key/value mapping into a mapping slot. note that it copies the + * value, it doesn't store a reference to it. */ + +void BMO_slot_map_insert(BMesh *UNUSED(bm), BMOperator *op, const char *slotname, + void *element, void *data, int len) +{ + BMOElemMapping *mapping; + BMOpSlot *slot = BMO_slot_get(op, slotname); + + /*sanity check*/ + if (slot->slottype != BMO_OP_SLOT_MAPPING) { + return; + } + + mapping = (BMOElemMapping *) BLI_memarena_alloc(op->arena, sizeof(*mapping) + len); + + mapping->element = (BMHeader *) element; + mapping->len = len; + memcpy(mapping + 1, data, len); + + if (!slot->data.ghash) { + slot->data.ghash = BLI_ghash_new(BLI_ghashutil_ptrhash, + BLI_ghashutil_ptrcmp, "bmesh op"); + } + + BLI_ghash_insert(slot->data.ghash, element, mapping); +} + #if 0 void *BMO_Grow_Array(BMesh *bm, BMOperator *op, int slotcode, int totadd) { diff --git a/source/blender/bmesh/intern/bmesh_polygon.c b/source/blender/bmesh/intern/bmesh_polygon.c index 19b13a00f6d..c511193209e 100644 --- a/source/blender/bmesh/intern/bmesh_polygon.c +++ b/source/blender/bmesh/intern/bmesh_polygon.c @@ -135,12 +135,12 @@ static void compute_poly_normal(float normal[3], float (*verts)[3], int nverts) so thats?: (a[1] - b[1]) * (a[2] + b[2]); - a[1]*b[2] - b[1]*a[2] - b[1]*b[2] + a[1]*a[2] + a[1] * b[2] - b[1] * a[2] - b[1] * b[2] + a[1] * a[2] odd. half of that is the cross product. . .what's the other half? - also could be like a[1]*(b[2] + a[2]) - b[1]*(a[2] - b[2]) + also could be like a[1] * (b[2] + a[2]) - b[1] * (a[2] - b[2]) */ n[0] += (u[1] - v[1]) * (u[2] + v[2]); diff --git a/source/blender/bmesh/intern/bmesh_private.h b/source/blender/bmesh/intern/bmesh_private.h index 694d68549cd..c6237743541 100644 --- a/source/blender/bmesh/intern/bmesh_private.h +++ b/source/blender/bmesh/intern/bmesh_private.h @@ -43,15 +43,15 @@ struct BMLoop; int bmesh_check_element(BMesh *bm, void *element, const char htype); #define BM_CHECK_ELEMENT(bm, el) \ - if (bmesh_check_element(bm, el, ((BMHeader*)el)->htype)) { \ + if (bmesh_check_element(bm, el, ((BMHeader *)el)->htype)) { \ printf("check_element failure, with code %i on line %i in file\n" \ " \"%s\"\n\n", \ - bmesh_check_element(bm, el, ((BMHeader*)el)->htype), \ + bmesh_check_element(bm, el, ((BMHeader *)el)->htype), \ __LINE__, __FILE__); \ } #define BM_EDGE_DISK_LINK_GET(e, v) ( \ - ((v) == ((BMEdge*)(e))->v1) ? \ + ((v) == ((BMEdge *)(e))->v1) ? \ &((e)->v1_disk_link) : \ &((e)->v2_disk_link) \ ) diff --git a/source/blender/bmesh/intern/bmesh_structure.c b/source/blender/bmesh/intern/bmesh_structure.c index 35c3146fcb9..8b16c641c3a 100644 --- a/source/blender/bmesh/intern/bmesh_structure.c +++ b/source/blender/bmesh/intern/bmesh_structure.c @@ -191,7 +191,7 @@ void bmesh_disk_remove_edge(struct BMEdge *e, struct BMVert *v) } if (v->e == e) - v->e = (e != (BMEdge *)dl1->next) ? (BMEdge *)dl1->next : NULL; + v->e = (e != dl1->next) ? dl1->next : NULL; dl1->next = dl1->prev = NULL; } diff --git a/source/blender/bmesh/intern/bmesh_walkers_impl.c b/source/blender/bmesh/intern/bmesh_walkers_impl.c index e6bcbf405fe..e34bf5d88a7 100644 --- a/source/blender/bmesh/intern/bmesh_walkers_impl.c +++ b/source/blender/bmesh/intern/bmesh_walkers_impl.c @@ -67,8 +67,7 @@ static void shellWalker_begin(BMWalker *walker, void *data) BMEdge *e; BMVert *v; - if (h == NULL) - { + if (UNLIKELY(h == NULL)) { return; } diff --git a/source/blender/bmesh/operators/bmo_create.c b/source/blender/bmesh/operators/bmo_create.c index 610790393f1..b93e12fbfc4 100644 --- a/source/blender/bmesh/operators/bmo_create.c +++ b/source/blender/bmesh/operators/bmo_create.c @@ -134,7 +134,7 @@ static void UNUSED_FUNCTION(rotsys_remove_edge)(struct BMEdge *e, struct BMVert } if (vd->e == e) - vd->e = (e != (BMEdge *)e1->next) ? (BMEdge *)e1->next : NULL; + vd->e = (e != e1->next) ? e1->next : NULL; e1->next = e1->prev = NULL; } diff --git a/source/blender/bmesh/operators/bmo_removedoubles.c b/source/blender/bmesh/operators/bmo_removedoubles.c index bd528faa43e..35fc6a1eadf 100644 --- a/source/blender/bmesh/operators/bmo_removedoubles.c +++ b/source/blender/bmesh/operators/bmo_removedoubles.c @@ -518,7 +518,7 @@ void bmesh_finddoubles_common(BMesh *bm, BMOperator *op, BMOperator *optarget, c /* Compare sort values of the verts using 3x tolerance (allowing for the tolerance * on each of the three axes). This avoids the more expensive length comparison * for most vertex pairs. */ - if ((v2->co[0]+v2->co[1]+v2->co[2])-(v->co[0]+v->co[1]+v->co[2]) > dist3) + if ((v2->co[0] + v2->co[1] + v2->co[2]) - (v->co[0] + v->co[1] + v->co[2]) > dist3) break; if (keepvert) { diff --git a/source/blender/bmesh/operators/bmo_subdivide.c b/source/blender/bmesh/operators/bmo_subdivide.c index 50b66abd703..f35d05f69df 100644 --- a/source/blender/bmesh/operators/bmo_subdivide.c +++ b/source/blender/bmesh/operators/bmo_subdivide.c @@ -459,7 +459,7 @@ static void quad_4edge_subdivide(BMesh *bm, BMFace *UNUSED(face), BMVert **verts int numcuts = params->numcuts; int i, j, a, b, s = numcuts + 2 /* , totv = numcuts * 4 + 4 */; - lines = MEM_callocN(sizeof(BMVert *)*(numcuts + 2)*(numcuts + 2), "q_4edge_split"); + lines = MEM_callocN(sizeof(BMVert *) * (numcuts + 2) * (numcuts + 2), "q_4edge_split"); /* build a 2-dimensional array of verts, * containing every vert (and all new ones) * in the face */ @@ -564,7 +564,7 @@ static void tri_3edge_subdivide(BMesh *bm, BMFace *UNUSED(face), BMVert **verts, int i, j, a, b, numcuts = params->numcuts; /* number of verts in each lin */ - lines = MEM_callocN(sizeof(void *)*(numcuts + 2), "triangle vert table"); + lines = MEM_callocN(sizeof(void *) * (numcuts + 2), "triangle vert table"); lines[0] = (BMVert **) stackarr; lines[0][0] = verts[numcuts * 2 + 1]; @@ -577,7 +577,7 @@ static void tri_3edge_subdivide(BMesh *bm, BMFace *UNUSED(face), BMVert **verts, lines[numcuts + 1][numcuts + 1] = verts[numcuts]; for (i = 0; i < numcuts; i++) { - lines[i + 1] = MEM_callocN(sizeof(void *)*(2 + i), "triangle vert table row"); + lines[i + 1] = MEM_callocN(sizeof(void *) * (2 + i), "triangle vert table row"); a = numcuts * 2 + 2 + i; b = numcuts + numcuts - i; e = connect_smallest_face(bm, verts[a], verts[b], &nf); diff --git a/source/blender/bmesh/operators/bmo_utils.c b/source/blender/bmesh/operators/bmo_utils.c index 1acdf05ef35..b3102d7fafc 100644 --- a/source/blender/bmesh/operators/bmo_utils.c +++ b/source/blender/bmesh/operators/bmo_utils.c @@ -271,7 +271,7 @@ void bmesh_righthandfaces_exec(BMesh *bm, BMOperator *op) BMFace *f, *startf, **fstack = NULL; BLI_array_declare(fstack); BMLoop *l, *l2; - float maxx, cent[3]; + float maxx, maxx_test, cent[3]; int i, maxi, flagflip = BMO_slot_bool_get(op, "do_flip"); startf = NULL; @@ -292,9 +292,8 @@ void bmesh_righthandfaces_exec(BMesh *bm, BMOperator *op) BM_face_center_bounds_calc(bm, f, cent); - cent[0] = cent[0]*cent[0] + cent[1]*cent[1] + cent[2]*cent[2]; - if (cent[0] > maxx) { - maxx = cent[0]; + if ((maxx_test = dot_v3v3(cent, cent)) > maxx) { + maxx = maxx_test; startf = f; } } diff --git a/source/blender/editors/mesh/knifetool.c b/source/blender/editors/mesh/knifetool.c index e08db8b6e46..924be605281 100755 --- a/source/blender/editors/mesh/knifetool.c +++ b/source/blender/editors/mesh/knifetool.c @@ -1045,7 +1045,7 @@ static BMEdgeHit *knife_edge_tri_isect(knifetool_opdata *kcd, BMBVHTree *bmtree, for (i = 0; i < tot; i++, result++) { float p[3]; - ls = (BMLoop**)kcd->em->looptris[result->indexA]; + ls = (BMLoop **)kcd->em->looptris[result->indexA]; for (j = 0; j < 3; j++) { BMLoop *l1 = ls[j]; diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c index ad70ae78f51..a61bc823e47 100644 --- a/source/blender/editors/space_view3d/view3d_buttons.c +++ b/source/blender/editors/space_view3d/view3d_buttons.c @@ -622,10 +622,10 @@ static void act_vert_def(Object *ob, BMVert **eve, MDeformVert **dvert) if (ob && ob->mode & OB_MODE_EDIT && ob->type==OB_MESH && ob->defbase.first) { Mesh *me= ob->data; BMEditMesh *em = me->edit_btmesh; - BMEditSelection *ese= (BMEditSelection*)em->bm->selected.last; + BMEditSelection *ese = (BMEditSelection *)em->bm->selected.last; if (ese && ese->htype == BM_VERT) { - *eve= (BMVert*)ese->data; + *eve= (BMVert *)ese->data; *dvert= CustomData_bmesh_get(&em->bm->vdata, (*eve)->head.data, CD_MDEFORMVERT); return; } diff --git a/source/blender/modifiers/intern/MOD_array.c b/source/blender/modifiers/intern/MOD_array.c index dd40dc6f59b..4366ea7ee08 100644 --- a/source/blender/modifiers/intern/MOD_array.c +++ b/source/blender/modifiers/intern/MOD_array.c @@ -306,7 +306,7 @@ static DerivedMesh *arrayModifier_doArray(ArrayModifierData *amd, BMO_op_callf(em->bm, "transform mat=%m4 verts=%s", offset, &op, "newout"); - #define _E(s, i) ((BMVert**)(s)->data.buf)[i] + #define _E(s, i) ((BMVert **)(s)->data.buf)[i] /*calculate merge mapping*/ if (j == 0) { |