diff options
-rw-r--r-- | source/blender/bmesh/bmesh_operator_api.h | 8 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_construct.c | 33 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_mesh_conv.c | 2 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_mods.c | 2 | ||||
-rw-r--r-- | source/blender/bmesh/operators/bmo_create.c | 2 | ||||
-rw-r--r-- | source/blender/bmesh/operators/bmo_dupe.c | 7 | ||||
-rw-r--r-- | source/blender/bmesh/operators/bmo_primitive.c | 2 | ||||
-rw-r--r-- | source/blender/bmesh/operators/bmo_subdivide.c | 10 | ||||
-rw-r--r-- | source/blender/editors/mesh/bmesh_select.c | 10 | ||||
-rw-r--r-- | source/blender/editors/mesh/bmesh_tools.c | 32 | ||||
-rw-r--r-- | source/blender/editors/mesh/bmesh_utils.c | 14 | ||||
-rw-r--r-- | source/blender/python/bmesh/bmesh_py_types_customdata.c | 2 |
12 files changed, 73 insertions, 51 deletions
diff --git a/source/blender/bmesh/bmesh_operator_api.h b/source/blender/bmesh/bmesh_operator_api.h index 84de5d57aa3..1b4e119ad92 100644 --- a/source/blender/bmesh/bmesh_operator_api.h +++ b/source/blender/bmesh/bmesh_operator_api.h @@ -43,7 +43,7 @@ extern "C" { * when it's executed. tool flags are allocated in layers, one per operator * execution, and are used for all internal flagging a tool needs to do. * - * each operator has a series of "slots," which can be of the following types: + * each operator has a series of "slots" which can be of the following types: * - simple numerical types * - arrays of elements (e.g. arrays of faces). * - hash mappings. @@ -339,7 +339,7 @@ void BMO_slot_map_to_flag(BMesh *bm, BMOperator *op, const char *slotname, * BMFace *f; * * f = BMO_iter_new(&oiter, bm, some_operator, "slotname", BM_FACE); - * for (; f; f=BMO_iter_step(&oiter)) { + * for (; f; f = BMO_iter_step(&oiter)) { * /do something with the face * } * @@ -349,7 +349,7 @@ void BMO_slot_map_to_flag(BMesh *bm, BMOperator *op, const char *slotname, * void *val; * * key = BMO_iter_new(&oiter, bm, some_operator, "slotname", 0); - * for (; key; key=BMO_iter_step(&oiter)) { + * for (; key; key = BMO_iter_step(&oiter)) { * val = BMO_iter_map_value(&oiter); * //do something with the key/val pair * //note that val is a pointer to the val data, @@ -389,7 +389,7 @@ float BMO_iter_map_value_f(BMOIter *iter); #define BMO_ITER(ele, iter, bm, op, slotname, restrict) \ ele = BMO_iter_new(iter, bm, op, slotname, restrict); \ - for ( ; ele; ele=BMO_iter_step(iter)) + for ( ; ele; ele = BMO_iter_step(iter)) /******************* Inlined Functions********************/ typedef void (*opexec)(BMesh *bm, BMOperator *op); diff --git a/source/blender/bmesh/intern/bmesh_construct.c b/source/blender/bmesh/intern/bmesh_construct.c index a9e6827676c..097f4c7a9d7 100644 --- a/source/blender/bmesh/intern/bmesh_construct.c +++ b/source/blender/bmesh/intern/bmesh_construct.c @@ -76,6 +76,27 @@ BMFace *BM_face_create_quad_tri_v(BMesh *bm, BMVert **verts, int len, const BMFa BMFace *f = NULL; int is_overlap = FALSE; + /* sanity check - debug mode only */ + if (len == 3) { + BLI_assert(verts[0] != verts[1]); + BLI_assert(verts[0] != verts[2]); + BLI_assert(verts[1] != verts[2]); + } + else if (len == 4) { + BLI_assert(verts[0] != verts[1]); + BLI_assert(verts[0] != verts[2]); + BLI_assert(verts[0] != verts[3]); + + BLI_assert(verts[1] != verts[2]); + BLI_assert(verts[1] != verts[3]); + + BLI_assert(verts[2] != verts[3]); + } + else { + BLI_assert(0); + } + + if (nodouble) { /* check if face exists or overlaps */ is_overlap = BM_face_exists(bm, verts, len, &f); @@ -320,14 +341,14 @@ BMFace *BM_face_create_ngon_vcloud(BMesh *bm, BMVert **vert_arr, int totv, int n /* get the center point and collect vector array since we loop over these a lot */ zero_v3(cent); - for (i = 0; i < totv; ++i) { + for (i = 0; i < totv; i++) { madd_v3_v3fl(cent, vert_arr[i]->co, totv_inv); } /* find the far point from cent */ far_best = 0.0f; - for (i = 0; i < totv; ++i) { + for (i = 0; i < totv; i++) { far_dist = len_squared_v3v3(vert_arr[i]->co, cent); if (far_dist > far_best || far == NULL) { far = vert_arr[i]->co; @@ -342,7 +363,7 @@ BMFace *BM_face_create_ngon_vcloud(BMesh *bm, BMVert **vert_arr, int totv, int n /* find a point 90deg about to compare with */ far_cross_best = 0.0f; - for (i = 0; i < totv; ++i) { + for (i = 0; i < totv; i++) { if (far == vert_arr[i]->co) { continue; @@ -379,7 +400,7 @@ BMFace *BM_face_create_ngon_vcloud(BMesh *bm, BMVert **vert_arr, int totv, int n /* now calcualte every points angle around the normal (signed) */ vang = MEM_mallocN(sizeof(AngleIndexPair) * totv, __func__); - for (i = 0; i < totv; ++i) { + for (i = 0; i < totv; i++) { float co[3]; float proj_vec[3]; float angle; @@ -411,13 +432,13 @@ BMFace *BM_face_create_ngon_vcloud(BMesh *bm, BMVert **vert_arr, int totv, int n vert_arr_map = MEM_mallocN(sizeof(BMVert **) * totv, __func__); edge_arr = MEM_mallocN(sizeof(BMEdge **) * totv, __func__); - for (i = 0; i < totv; ++i) { + for (i = 0; i < totv; i++) { vert_arr_map[i] = vert_arr[vang[i].index]; } MEM_freeN(vang); i_prev = totv - 1; - for (i = 0; i < totv; ++i) { + for (i = 0; i < totv; i++) { edge_arr[i] = BM_edge_create(bm, vert_arr_map[i_prev], vert_arr_map[i], NULL, TRUE); /* the edge may exist already and be attached to a face diff --git a/source/blender/bmesh/intern/bmesh_mesh_conv.c b/source/blender/bmesh/intern/bmesh_mesh_conv.c index 476c049c687..16214d5fbb4 100644 --- a/source/blender/bmesh/intern/bmesh_mesh_conv.c +++ b/source/blender/bmesh/intern/bmesh_mesh_conv.c @@ -374,7 +374,7 @@ static BMVert **bm_to_mesh_vertex_map(BMesh *bm, int ototvert) /* caller needs to ensure this */ BLI_assert(ototvert > 0); - vertMap = MEM_callocN(sizeof(*vertMap)*ototvert, "vertMap"); + vertMap = MEM_callocN(sizeof(*vertMap) * ototvert, "vertMap"); if (CustomData_has_layer(&bm->vdata, CD_SHAPE_KEYINDEX)) { int *keyi; BM_ITER(eve, &iter, bm, BM_VERTS_OF_MESH, NULL) { diff --git a/source/blender/bmesh/intern/bmesh_mods.c b/source/blender/bmesh/intern/bmesh_mods.c index 2b9387ed73d..792882751cd 100644 --- a/source/blender/bmesh/intern/bmesh_mods.c +++ b/source/blender/bmesh/intern/bmesh_mods.c @@ -429,7 +429,7 @@ BMFace *BM_face_split_n(BMesh *bm, BMFace *f, BMVert *v1, BMVert *v2, float cos[ /* interpolate the loop data for the loops with v==newv, using orig face */ for (j = 0; j < 2; j++) { - BMEdge *e_iter = (j==0)? e : newe; + BMEdge *e_iter = (j == 0) ? e : newe; BMLoop *l_iter = e_iter->l; do { if (l_iter->v == newv) { diff --git a/source/blender/bmesh/operators/bmo_create.c b/source/blender/bmesh/operators/bmo_create.c index 7db29501ed5..a761520dabb 100644 --- a/source/blender/bmesh/operators/bmo_create.c +++ b/source/blender/bmesh/operators/bmo_create.c @@ -466,7 +466,7 @@ static void init_rotsys(BMesh *bm, EdgeData *edata, VertData *vdata) copy_v3_v3(cent, v->co); for (j = 0; j < 3; j++) { - float fac = (BLI_frand() - 0.5f)*size; + float fac = (BLI_frand() - 0.5f) * size; cent[j] += fac; } diff --git a/source/blender/bmesh/operators/bmo_dupe.c b/source/blender/bmesh/operators/bmo_dupe.c index bb5f090431b..9a87acbb84f 100644 --- a/source/blender/bmesh/operators/bmo_dupe.c +++ b/source/blender/bmesh/operators/bmo_dupe.c @@ -486,11 +486,12 @@ void bmo_spin_exec(BMesh *bm, BMOperator *op) phi = BMO_slot_float_get(op, "ang") * (float)M_PI / (360.0f * steps); do_dupli = BMO_slot_bool_get(op, "do_dupli"); + /* BMESH_TODO - can replace this with BLI_math? */ si = (float)sin(phi); q[0] = (float)cos(phi); - q[1] = axis[0]*si; - q[2] = axis[1]*si; - q[3] = axis[2]*si; + q[1] = axis[0] * si; + q[2] = axis[1] * si; + q[3] = axis[2] * si; quat_to_mat3(rmat, q); BMO_slot_copy(op, op, "geom", "lastout"); diff --git a/source/blender/bmesh/operators/bmo_primitive.c b/source/blender/bmesh/operators/bmo_primitive.c index 5b46b251846..837fe46b65b 100644 --- a/source/blender/bmesh/operators/bmo_primitive.c +++ b/source/blender/bmesh/operators/bmo_primitive.c @@ -445,7 +445,7 @@ void bmo_create_icosphere_exec(BMesh *bm, BMOperator *op) void bmo_create_monkey_exec(BMesh *bm, BMOperator *op) { BMVert *eve; - BMVert **tv = MEM_mallocN(sizeof(*tv)*monkeynv * 2, "tv"); + BMVert **tv = MEM_mallocN(sizeof(*tv) * monkeynv * 2, "tv"); float mat[4][4]; int i; diff --git a/source/blender/bmesh/operators/bmo_subdivide.c b/source/blender/bmesh/operators/bmo_subdivide.c index c19c337192b..f97f5225169 100644 --- a/source/blender/bmesh/operators/bmo_subdivide.c +++ b/source/blender/bmesh/operators/bmo_subdivide.c @@ -75,7 +75,7 @@ static BMEdge *connect_smallest_face(BMesh *bm, BMVert *v1, BMVert *v2, BMFace * /* this isn't the best thing in the world. it doesn't handle cases where there's * multiple faces yet. that might require a convexity test to figure out which - * face is "best," and who knows what for non-manifold conditions. */ + * face is "best" and who knows what for non-manifold conditions. */ for (face = BM_iter_new(&iter, bm, BM_FACES_OF_VERT, v1); face; face = BM_iter_step(&iter)) { for (v = BM_iter_new(&iter2, bm, BM_VERTS_OF_FACE, face); v; v = BM_iter_step(&iter2)) { if (v == v2) { @@ -290,7 +290,7 @@ static void quad_1edge_split(BMesh *bm, BMFace *UNUSED(face), add = 2; for (i = 0; i < numcuts; i++) { connect_smallest_face(bm, verts[i], verts[numcuts + add], &nf); - if (i == numcuts/2) { + if (i == numcuts / 2) { add -= 1; connect_smallest_face(bm, verts[i], verts[numcuts + add], &nf); } @@ -487,8 +487,8 @@ static void quad_4edge_subdivide(BMesh *bm, BMFace *UNUSED(face), BMVert **verts BMO_elem_flag_enable(bm, nf, ELE_INNER); - v1 = lines[(i + 1)*s] = verts[a]; - v2 = lines[(i + 1)*s + s - 1] = verts[b]; + v1 = lines[(i + 1) * s] = verts[a]; + v2 = lines[(i + 1) * s + s - 1] = verts[b]; temp = *e; for (a = 0; a < numcuts; a++) { @@ -949,7 +949,7 @@ void bmo_esubd_exec(BMesh *bmesh, BMOperator *op) a = (a + 1) % vlen; } - //BM_face_legal_splits(bmesh, face, splits, BLI_array_count(splits)/2); + //BM_face_legal_splits(bmesh, face, splits, BLI_array_count(splits) / 2); for (j = 0; j < BLI_array_count(splits) / 2; j++) { if (splits[j * 2]) { diff --git a/source/blender/editors/mesh/bmesh_select.c b/source/blender/editors/mesh/bmesh_select.c index fdf8ba15e59..f1998eabbac 100644 --- a/source/blender/editors/mesh/bmesh_select.c +++ b/source/blender/editors/mesh/bmesh_select.c @@ -189,7 +189,7 @@ int EDBM_init_backbuf_border(ViewContext *vc, short xmin, short ymin, short xmax /* build selection lookup */ selbuf = MEM_callocN(bm_vertoffs + 1, "selbuf"); - a = (xmax - xmin + 1) * (ymax-ymin + 1); + a = (xmax - xmin + 1) * (ymax - ymin + 1); while (a--) { if (*dr > 0 && *dr <= bm_vertoffs) selbuf[*dr] = 1; @@ -499,7 +499,7 @@ BMEdge *EDBM_findnearestedge(ViewContext *vc, int *dist) view3d_validate_backbuf(vc); - index = view3d_sample_backbuf_rect(vc, vc->mval, 50, bm_solidoffs, bm_wireoffs, &distance,0, NULL, NULL); + index = view3d_sample_backbuf_rect(vc, vc->mval, 50, bm_solidoffs, bm_wireoffs, &distance, 0, NULL, NULL); eed = BM_edge_at_index(vc->em->bm, index - 1); if (eed && distance < *dist) { @@ -649,7 +649,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); @@ -933,7 +933,7 @@ static int loop_multiselect(bContext *C, wmOperator *op) } - edarray = MEM_mallocN(sizeof(BMEdge *)*totedgesel,"edge array"); + edarray = MEM_mallocN(sizeof(BMEdge *) * totedgesel, "edge array"); edindex = 0; for (eed = BM_iter_new(&iter, em->bm, BM_EDGES_OF_MESH, NULL); @@ -2398,7 +2398,7 @@ static int mesh_select_random_exec(bContext *C, wmOperator *op) BMEdge *eed; BMFace *efa; BMIter iter; - float randfac = RNA_float_get(op->ptr, "percent")/100.0f; + float randfac = RNA_float_get(op->ptr, "percent") / 100.0f; BLI_srand(BLI_rand()); /* random seed */ diff --git a/source/blender/editors/mesh/bmesh_tools.c b/source/blender/editors/mesh/bmesh_tools.c index 34e3977d72a..79f0288a063 100644 --- a/source/blender/editors/mesh/bmesh_tools.c +++ b/source/blender/editors/mesh/bmesh_tools.c @@ -80,9 +80,9 @@ static int subdivide_exec(bContext *C, wmOperator *op) ToolSettings *ts = CTX_data_tool_settings(C); Object *obedit = CTX_data_edit_object(C); BMEditMesh *em = BMEdit_FromObject(obedit); - int cuts = RNA_int_get(op->ptr,"number_cuts"); + int cuts = RNA_int_get(op->ptr, "number_cuts"); float smooth = 0.292f * RNA_float_get(op->ptr, "smoothness"); - float fractal = RNA_float_get(op->ptr, "fractal")/2.5; + float fractal = RNA_float_get(op->ptr, "fractal") / 2.5f; int flag = 0; if (smooth != 0.0f) @@ -378,9 +378,9 @@ static int extrude_repeat_mesh(bContext *C, wmOperator *op) BMEditMesh *em = BMEdit_FromObject(obedit); RegionView3D *rv3d = CTX_wm_region_view3d(C); - int steps = RNA_int_get(op->ptr,"steps"); + int steps = RNA_int_get(op->ptr, "steps"); - float offs = RNA_float_get(op->ptr,"offset"); + float offs = RNA_float_get(op->ptr, "offset"); float dvec[3], tmat[3][3], bmat[3][3], nor[3] = {0.0, 0.0, 0.0}; short a; @@ -972,14 +972,14 @@ static int delete_mesh(bContext *C, Object *obedit, wmOperator *op, int event, S /* Note, these values must match delete_mesh() event values */ static EnumPropertyItem prop_mesh_delete_types[] = { - {7, "DISSOLVE", 0, "Dissolve", ""}, - {12, "COLLAPSE", 0, "Collapse", ""}, - {10,"VERT", 0, "Vertices", ""}, - {1, "EDGE", 0, "Edges", ""}, - {2, "FACE", 0, "Faces", ""}, + {7, "DISSOLVE", 0, "Dissolve", ""}, + {12, "COLLAPSE", 0, "Collapse", ""}, + {10, "VERT", 0, "Vertices", ""}, + {1, "EDGE", 0, "Edges", ""}, + {2, "FACE", 0, "Faces", ""}, {11, "EDGE_LOOP", 0, "Edge Loop", ""}, - {4, "EDGE_FACE", 0, "Edges & Faces", ""}, - {5, "ONLY_FACE", 0, "Only Faces", ""}, + {4, "EDGE_FACE", 0, "Edges & Faces", ""}, + {5, "ONLY_FACE", 0, "Only Faces", ""}, {0, NULL, 0, NULL, NULL} }; @@ -1227,7 +1227,7 @@ static int editbmesh_edge_split(bContext *C, wmOperator *op) int len = 0; if (!EDBM_InitOpf(em, &bmop, op, "edgesplit edges=%he numcuts=%i", - BM_ELEM_SELECT, RNA_int_get(op->ptr,"number_cuts"))) + BM_ELEM_SELECT, RNA_int_get(op->ptr, "number_cuts"))) { return OPERATOR_CANCELLED; } @@ -1635,7 +1635,7 @@ static int do_smooth_vertex(bContext *C, wmOperator *op) } } - repeat = RNA_int_get(op->ptr,"repeat"); + repeat = RNA_int_get(op->ptr, "repeat"); if (!repeat) repeat = 1; @@ -4061,7 +4061,7 @@ static void xsortvert_flag(bContext *UNUSED(C), int UNUSED(flag)) em = vc.em; amount = em->bm->totvert; - sortblock = MEM_callocN(sizeof(xvertsort) * amount,"xsort"); + sortblock = MEM_callocN(sizeof(xvertsort) * amount, "xsort"); BM_ITER(eve, &iter, em->bm, BM_VERTS_OF_MESH, NULL) { if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) sortblock[i].v1 = eve; @@ -4221,7 +4221,7 @@ static int sort_faces_exec(bContext *C, wmOperator *op) for (i = 0; i < me->totpoly; i++, mp++) { if (event == 3) { - face_sort_floats[i] = ((float)mp->mat_nr)*reverse; + face_sort_floats[i] = ((float)mp->mat_nr) * reverse; } else if (event == 4) { /* selected first */ @@ -4314,7 +4314,7 @@ static void hashvert_flag(EditMesh *em, int flag) if (amount == 0) return; /* allocate memory */ - sb = sortblock = (struct xvertsort *)MEM_mallocN(sizeof(struct xvertsort)*amount,"sortremovedoub"); + sb = sortblock = (struct xvertsort *)MEM_mallocN(sizeof(struct xvertsort) * amount, "sortremovedoub"); eve = em->verts.first; while (eve) { if (eve->f & flag) { diff --git a/source/blender/editors/mesh/bmesh_utils.c b/source/blender/editors/mesh/bmesh_utils.c index 5ac663b573b..085624fe23f 100644 --- a/source/blender/editors/mesh/bmesh_utils.c +++ b/source/blender/editors/mesh/bmesh_utils.c @@ -623,8 +623,8 @@ UvVertMap *EDBM_make_uv_vert_map(BMEditMesh *em, int selected, int do_face_idx_a return NULL; } - vmap->vert = (UvMapVert **)MEM_callocN(sizeof(*vmap->vert)*totverts, "UvMapVert_pt"); - buf = vmap->buf = (UvMapVert *)MEM_callocN(sizeof(*vmap->buf)*totuv, "UvMapVert"); + vmap->vert = (UvMapVert **)MEM_callocN(sizeof(*vmap->vert) * totverts, "UvMapVert_pt"); + buf = vmap->buf = (UvMapVert *)MEM_callocN(sizeof(*vmap->buf) * totuv, "UvMapVert"); if (!vmap->vert || !vmap->buf) { free_uv_vert_map(vmap); @@ -748,7 +748,7 @@ UvElementMap *EDBM_make_uv_element_map(BMEditMesh *em, int selected, int do_isla totverts = em->bm->totvert; totuv = 0; - island_number = MEM_mallocN(sizeof(*stack)*em->bm->totface, "uv_island_number_face"); + island_number = MEM_mallocN(sizeof(*stack) * em->bm->totface, "uv_island_number_face"); if (!island_number) { return NULL; } @@ -848,9 +848,9 @@ UvElementMap *EDBM_make_uv_element_map(BMEditMesh *em, int selected, int do_isla if (do_islands) { /* map holds the map from current vmap->buf to the new, sorted map */ - map = MEM_mallocN(sizeof(*map)*totuv, "uvelement_remap"); - stack = MEM_mallocN(sizeof(*stack)*em->bm->totface, "uv_island_face_stack"); - islandbuf = MEM_callocN(sizeof(*islandbuf)*totuv, "uvelement_island_buffer"); + map = MEM_mallocN(sizeof(*map) * totuv, "uvelement_remap"); + stack = MEM_mallocN(sizeof(*stack) * em->bm->totface, "uv_island_face_stack"); + islandbuf = MEM_callocN(sizeof(*islandbuf) * totuv, "uvelement_island_buffer"); /* at this point, every UvElement in vert points to a UvElement sharing the same vertex. Now we should sort uv's in islands. */ for (i = 0; i < totuv; i++) { @@ -907,7 +907,7 @@ UvElementMap *EDBM_make_uv_element_map(BMEditMesh *em, int selected, int do_isla element_map->vert[i] = &islandbuf[map[element_map->vert[i] - element_map->buf]]; } - element_map->islandIndices = MEM_callocN(sizeof(*element_map->islandIndices)*nislands,"UvElementMap_island_indices"); + element_map->islandIndices = MEM_callocN(sizeof(*element_map->islandIndices) * nislands, "UvElementMap_island_indices"); if (!element_map->islandIndices) { MEM_freeN(islandbuf); MEM_freeN(stack); diff --git a/source/blender/python/bmesh/bmesh_py_types_customdata.c b/source/blender/python/bmesh/bmesh_py_types_customdata.c index 7fb1f93cd2e..1f7f7290030 100644 --- a/source/blender/python/bmesh/bmesh_py_types_customdata.c +++ b/source/blender/python/bmesh/bmesh_py_types_customdata.c @@ -912,7 +912,7 @@ int BPy_BMLayerItem_SetItem(BPy_BMElem *py_ele, BPy_BMLayerItem *py_layer, PyObj ret = -1; } else { - copy_v3_v3((float *)value,tmp_val); + copy_v3_v3((float *)value, tmp_val); } break; } |