diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/bmesh/bmesh.h | 6 | ||||
-rw-r--r-- | source/blender/bmesh/bmesh_marking.h | 6 | ||||
-rw-r--r-- | source/blender/bmesh/bmesh_operator_api.h | 4 | ||||
-rw-r--r-- | source/blender/bmesh/bmesh_queries.h | 3 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_eulers.c | 2 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_marking.c | 67 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_operators.c | 6 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_polygon.c | 24 | ||||
-rw-r--r-- | source/blender/bmesh/operators/bevel.c | 2 | ||||
-rw-r--r-- | source/blender/bmesh/operators/utils.c | 23 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/drawobject.c | 2 | ||||
-rw-r--r-- | source/blender/editors/uvedit/uvedit_draw.c | 4 |
12 files changed, 65 insertions, 84 deletions
diff --git a/source/blender/bmesh/bmesh.h b/source/blender/bmesh/bmesh.h index dcc9c3c9b3b..b6344fea992 100644 --- a/source/blender/bmesh/bmesh.h +++ b/source/blender/bmesh/bmesh.h @@ -287,9 +287,11 @@ void BM_free_data_layer_n(BMesh *bm, CustomData *data, int type, int n); float BM_GetCDf(struct CustomData *cd, void *element, int type); void BM_SetCDf(struct CustomData *cd, void *element, int type, float val); -/*computes the centroid of a face, using the center of the bounding box*/ +/* get the area of the face */ +float BM_Compute_Face_Area(BMesh *bm, BMFace *f); +/* computes the centroid of a face, using the center of the bounding box */ void BM_Compute_Face_CenterBounds(BMesh *bm, BMFace *f, float center[3]); -/*computes the centroid of a face, using the mean average*/ +/* computes the centroid of a face, using the mean average */ void BM_Compute_Face_CenterMean(BMesh *bm, BMFace *f, float center[3]); void BM_SelectMode_Flush ( BMesh *bm ); diff --git a/source/blender/bmesh/bmesh_marking.h b/source/blender/bmesh/bmesh_marking.h index 22c1887d794..ad2ef79cbd9 100644 --- a/source/blender/bmesh/bmesh_marking.h +++ b/source/blender/bmesh/bmesh_marking.h @@ -43,9 +43,9 @@ int BM_CountFlag(struct BMesh *bm, const char htype, const char hflag, int respe /*edit selection stuff*/ void BM_set_actFace(BMesh *em, BMFace *f); BMFace *BM_get_actFace(BMesh *bm, int sloppy); -void BM_editselection_center(BMesh *bm, float *center, BMEditSelection *ese); -void BM_editselection_normal(float *normal, BMEditSelection *ese); -void BM_editselection_plane(BMesh *bm, float *plane, BMEditSelection *ese); +void BM_editselection_center(BMesh *bm, float r_center[3], BMEditSelection *ese); +void BM_editselection_normal(float r_normal[3], BMEditSelection *ese); +void BM_editselection_plane(BMesh *bm, float r_plane[3], BMEditSelection *ese); void BM_remove_selection(BMesh *bm, void *data); void BM_store_selection(BMesh *bm, void *data); void BM_validate_selections(BMesh *bm); diff --git a/source/blender/bmesh/bmesh_operator_api.h b/source/blender/bmesh/bmesh_operator_api.h index 5122391d9d5..24a0173ebb2 100644 --- a/source/blender/bmesh/bmesh_operator_api.h +++ b/source/blender/bmesh/bmesh_operator_api.h @@ -249,8 +249,8 @@ int BMO_Get_Int(BMOperator *op, const char *slotname); though.*/ void BMO_Set_Pnt(struct BMOperator *op, const char *slotname, void *p); void *BMO_Get_Pnt(BMOperator *op, const char *slotname); -void BMO_Set_Vec(struct BMOperator *op, const char *slotname, float *vec); -void BMO_Get_Vec(BMOperator *op, const char *slotname, float *vec_out); +void BMO_Set_Vec(struct BMOperator *op, const char *slotname, const float vec[3]); +void BMO_Get_Vec(BMOperator *op, const char *slotname, float r_vec[3]); /*only supports square mats*/ /*size must be 3 or 4; this api is meant only for transformation matrices. diff --git a/source/blender/bmesh/bmesh_queries.h b/source/blender/bmesh/bmesh_queries.h index 6edd4f6b59e..5647e98c688 100644 --- a/source/blender/bmesh/bmesh_queries.h +++ b/source/blender/bmesh/bmesh_queries.h @@ -4,9 +4,6 @@ /*Queries*/ -/*get the area of face f*/ -float BM_face_area(BMFace *f); - /*counts number of elements of type type are in the mesh.*/ int BM_Count_Element(struct BMesh *bm, const char htype); diff --git a/source/blender/bmesh/intern/bmesh_eulers.c b/source/blender/bmesh/intern/bmesh_eulers.c index ca456f9fff8..85f9afd9c00 100644 --- a/source/blender/bmesh/intern/bmesh_eulers.c +++ b/source/blender/bmesh/intern/bmesh_eulers.c @@ -110,7 +110,7 @@ * A BMVert pointer. */ -BMVert *bmesh_mv(BMesh *bm, float *vec) +BMVert *bmesh_mv(BMesh *bm, const float vec[3]) { BMVert *v = bmesh_addvertlist(bm, NULL); copy_v3_v3(v->co,vec); diff --git a/source/blender/bmesh/intern/bmesh_marking.c b/source/blender/bmesh/intern/bmesh_marking.c index 58fb322d0c8..0c3e0c9ff48 100644 --- a/source/blender/bmesh/intern/bmesh_marking.c +++ b/source/blender/bmesh/intern/bmesh_marking.c @@ -430,56 +430,57 @@ BMFace *BM_get_actFace(BMesh *bm, int sloppy) return NULL; } -/* generic way to get data from an EditSelection type -These functions were written to be used by the Modifier widget when in Rotate about active mode, -but can be used anywhere. -EM_editselection_center -EM_editselection_normal -EM_editselection_plane +/* Generic way to get data from an EditSelection type + * These functions were written to be used by the Modifier widget + * when in Rotate about active mode, but can be used anywhere. + * + * - EM_editselection_center + * - EM_editselection_normal + * - EM_editselection_plane */ -void BM_editselection_center(BMesh *bm, float *center, BMEditSelection *ese) +void BM_editselection_center(BMesh *bm, float r_center[3], BMEditSelection *ese) { if (ese->htype == BM_VERT) { BMVert *eve= ese->data; - copy_v3_v3(center, eve->co); + copy_v3_v3(r_center, eve->co); } else if (ese->htype == BM_EDGE) { BMEdge *eed= ese->data; - add_v3_v3v3(center, eed->v1->co, eed->v2->co); - mul_v3_fl(center, 0.5); + add_v3_v3v3(r_center, eed->v1->co, eed->v2->co); + mul_v3_fl(r_center, 0.5); } else if (ese->htype == BM_FACE) { BMFace *efa= ese->data; - BM_Compute_Face_CenterBounds(bm, efa, center); + BM_Compute_Face_CenterBounds(bm, efa, r_center); } } -void BM_editselection_normal(float *normal, BMEditSelection *ese) +void BM_editselection_normal(float r_normal[3], BMEditSelection *ese) { if (ese->htype == BM_VERT) { BMVert *eve= ese->data; - copy_v3_v3(normal, eve->no); + copy_v3_v3(r_normal, eve->no); } else if (ese->htype == BM_EDGE) { BMEdge *eed= ese->data; float plane[3]; /* need a plane to correct the normal */ float vec[3]; /* temp vec storage */ - add_v3_v3v3(normal, eed->v1->no, eed->v2->no); + add_v3_v3v3(r_normal, eed->v1->no, eed->v2->no); sub_v3_v3v3(plane, eed->v2->co, eed->v1->co); /* the 2 vertex normals will be close but not at rightangles to the edge for rotate about edge we want them to be at right angles, so we need to do some extra colculation to correct the vert normals, we need the plane for this */ - cross_v3_v3v3(vec, normal, plane); - cross_v3_v3v3(normal, plane, vec); - normalize_v3(normal); + cross_v3_v3v3(vec, r_normal, plane); + cross_v3_v3v3(r_normal, plane, vec); + normalize_v3(r_normal); } else if (ese->htype == BM_FACE) { BMFace *efa= ese->data; - copy_v3_v3(normal, efa->no); + copy_v3_v3(r_normal, efa->no); } } @@ -488,7 +489,7 @@ void BM_editselection_normal(float *normal, BMEditSelection *ese) /* Calculate a plane that is rightangles to the edge/vert/faces normal also make the plane run along an axis that is related to the geometry, because this is used for the manipulators Y axis.*/ -void BM_editselection_plane(BMesh *bm, float *plane, BMEditSelection *ese) +void BM_editselection_plane(BMesh *bm, float r_plane[3], BMEditSelection *ese) { if (ese->htype == BM_VERT) { BMVert *eve= ese->data; @@ -496,7 +497,7 @@ void BM_editselection_plane(BMesh *bm, float *plane, BMEditSelection *ese) if (ese->prev) { /*use previously selected data to make a useful vertex plane */ BM_editselection_center(bm, vec, ese->prev); - sub_v3_v3v3(plane, vec, eve->co); + sub_v3_v3v3(r_plane, vec, eve->co); } else { /* make a fake plane thats at rightangles to the normal we cant make a crossvec from a vec thats the same as the vec @@ -505,7 +506,7 @@ void BM_editselection_plane(BMesh *bm, float *plane, BMEditSelection *ese) if (eve->no[0] < 0.5f) vec[0]= 1.0f; else if (eve->no[1] < 0.5f) vec[1]= 1.0f; else vec[2]= 1.0f; - cross_v3_v3v3(plane, eve->no, vec); + cross_v3_v3v3(r_plane, eve->no, vec); } } else if (ese->htype == BM_EDGE) { @@ -517,9 +518,9 @@ void BM_editselection_plane(BMesh *bm, float *plane, BMEditSelection *ese) (running along the edge).. to flip less often. at least its more pradictable */ if (eed->v2->co[1] > eed->v1->co[1]) /*check which to do first */ - sub_v3_v3v3(plane, eed->v2->co, eed->v1->co); + sub_v3_v3v3(r_plane, eed->v2->co, eed->v1->co); else - sub_v3_v3v3(plane, eed->v1->co, eed->v2->co); + sub_v3_v3v3(r_plane, eed->v1->co, eed->v2->co); } else if (ese->htype == BM_FACE) { @@ -537,7 +538,7 @@ void BM_editselection_plane(BMesh *bm, float *plane, BMEditSelection *ese) if (efa->no[0] < 0.5f) vec[0]= 1.0f; else if (efa->no[1] < 0.5f) vec[1]= 1.0f; else vec[2]= 1.0f; - cross_v3_v3v3(plane, efa->no, vec); + cross_v3_v3v3(r_plane, efa->no, vec); } else { BMVert *verts[4]= {NULL}; @@ -548,37 +549,37 @@ void BM_editselection_plane(BMesh *bm, float *plane, BMEditSelection *ese) float vecA[3], vecB[3]; sub_v3_v3v3(vecA, verts[3]->co, verts[2]->co); sub_v3_v3v3(vecB, verts[0]->co, verts[1]->co); - add_v3_v3v3(plane, vecA, vecB); + add_v3_v3v3(r_plane, vecA, vecB); sub_v3_v3v3(vecA, verts[0]->co, verts[3]->co); sub_v3_v3v3(vecB, verts[1]->co, verts[2]->co); add_v3_v3v3(vec, vecA, vecB); /*use the biggest edge length*/ - if (dot_v3v3(plane, plane) < dot_v3v3(vec, vec)) { - copy_v3_v3(plane, vec); + if (dot_v3v3(r_plane, r_plane) < dot_v3v3(vec, vec)) { + copy_v3_v3(r_plane, vec); } } else { /* BMESH_TODO (not urgent, use longest ngon edge for alignment) */ /*start with v1-2 */ - sub_v3_v3v3(plane, verts[0]->co, verts[1]->co); + sub_v3_v3v3(r_plane, verts[0]->co, verts[1]->co); /*test the edge between v2-3, use if longer */ sub_v3_v3v3(vec, verts[1]->co, verts[2]->co); - if (dot_v3v3(plane, plane) < dot_v3v3(vec, vec)) - copy_v3_v3(plane, vec); + if (dot_v3v3(r_plane, r_plane) < dot_v3v3(vec, vec)) + copy_v3_v3(r_plane, vec); /*test the edge between v1-3, use if longer */ sub_v3_v3v3(vec, verts[2]->co, verts[0]->co); - if (dot_v3v3(plane, plane) < dot_v3v3(vec, vec)) { - copy_v3_v3(plane, vec); + if (dot_v3v3(r_plane, r_plane) < dot_v3v3(vec, vec)) { + copy_v3_v3(r_plane, vec); } } } } - normalize_v3(plane); + normalize_v3(r_plane); } static int BM_check_selection(BMesh *bm, void *data) diff --git a/source/blender/bmesh/intern/bmesh_operators.c b/source/blender/bmesh/intern/bmesh_operators.c index 7c4e3213c8e..c41ea4af66d 100644 --- a/source/blender/bmesh/intern/bmesh_operators.c +++ b/source/blender/bmesh/intern/bmesh_operators.c @@ -377,7 +377,7 @@ void BMO_Set_Pnt(BMOperator *op, const char *slotname, void *p) slot->data.p = p; } -void BMO_Set_Vec(BMOperator *op, const char *slotname, float *vec) +void BMO_Set_Vec(BMOperator *op, const char *slotname, const float vec[3]) { BMOpSlot *slot = BMO_GetSlot(op, slotname); if( !(slot->slottype == BMOP_OPSLOT_VEC) ) @@ -415,13 +415,13 @@ void *BMO_Get_Pnt(BMOperator *op, const char *slotname) return slot->data.p; } -void BMO_Get_Vec(BMOperator *op, const char *slotname, float *vec_out) +void BMO_Get_Vec(BMOperator *op, const char *slotname, float r_vec[3]) { BMOpSlot *slot = BMO_GetSlot(op, slotname); if( !(slot->slottype == BMOP_OPSLOT_VEC) ) return; - copy_v3_v3(vec_out, slot->data.vec); + copy_v3_v3(r_vec, slot->data.vec); } /* diff --git a/source/blender/bmesh/intern/bmesh_polygon.c b/source/blender/bmesh/intern/bmesh_polygon.c index 12222349cb7..8990567b8db 100644 --- a/source/blender/bmesh/intern/bmesh_polygon.c +++ b/source/blender/bmesh/intern/bmesh_polygon.c @@ -58,7 +58,7 @@ * */ -static short testedgeside(double *v1, double *v2, double *v3) +static short testedgeside(const double v1[2], const double v2[2], const double v3[2]) /* is v3 to the right of v1-v2 ? With exception: v3==v1 || v3==v2 */ { double inp; @@ -74,7 +74,7 @@ static short testedgeside(double *v1, double *v2, double *v3) return 1; } -static short testedgesidef(float *v1, float *v2, float *v3) +static short testedgesidef(const float v1[2], const float v2[2], const float v3[2]) /* is v3 to the right of v1-v2 ? With exception: v3==v1 || v3==v2 */ { double inp; @@ -90,7 +90,7 @@ static short testedgesidef(float *v1, float *v2, float *v3) return 1; } -static int point_in_triangle(double *v1, double *v2, double *v3, double *pt) +static int point_in_triangle(const double v1[2], const double v2[2], const double v3[2], const double pt[2]) { if(testedgeside(v1,v2,pt) && testedgeside(v2,v3,pt) && testedgeside(v3,v1,pt)) return 1; @@ -187,7 +187,7 @@ static void compute_poly_normal(float normal[3], float (*verts)[3], int nverts) * */ -static int compute_poly_center(float center[3], float *area, float (*verts)[3], int nverts) +static int compute_poly_center(float center[3], float *r_area, float (*verts)[3], int nverts) { int i, j; float atmp = 0.0, xtmp = 0.0, ytmp = 0.0, ai; @@ -209,8 +209,8 @@ static int compute_poly_center(float center[3], float *area, float (*verts)[3], j += 1; } - if(area) - *area = atmp / 2.0f; + if(r_area) + *r_area = atmp / 2.0f; if (atmp != 0){ center[0] = xtmp / (3.0f * atmp); @@ -220,7 +220,7 @@ static int compute_poly_center(float center[3], float *area, float (*verts)[3], return 0; } -float BM_face_area(BMFace *f) +float BM_Compute_Face_Area(BMesh *bm, BMFace *f) { BMLoop *l; BMIter iter; @@ -231,7 +231,7 @@ float BM_face_area(BMFace *f) BLI_array_fixedstack_declare(verts, BM_NGON_STACK_SIZE, f->len, __func__); i = 0; - BM_ITER(l, &iter, NULL, BM_LOOPS_OF_FACE, f) { + BM_ITER(l, &iter, bm, BM_LOOPS_OF_FACE, f) { copy_v3_v3(verts[i], l->v->co); i++; } @@ -275,7 +275,7 @@ void BM_Compute_Face_CenterMean(BMesh *bm, BMFace *f, float r_cent[3]) add_v3_v3(r_cent, l->v->co); } - mul_v3_fl(r_cent, 1.0f / (float)f->len); + if (f->len) mul_v3_fl(r_cent, 1.0f / (float)f->len); } /* @@ -355,7 +355,7 @@ static void shrink_edged(double *v1, double *v2, double fac) } #endif -static void shrink_edgef(float *v1, float *v2, float fac) +static void shrink_edgef(float v1[3], float v2[3], const float fac) { float mid[3]; @@ -537,7 +537,7 @@ void BM_flip_normal(BMesh *bm, BMFace *f) /* detects if two line segments cross each other (intersects). note, there could be more winding cases then there needs to be. */ -static int UNUSED_FUNCTION(linecrosses)(double *v1, double *v2, double *v3, double *v4) +static int UNUSED_FUNCTION(linecrosses)(const double v1[2], const double v2[2], const double v3[2], const double v4[2]) { int w1, w2, w3, w4, w5; @@ -558,7 +558,7 @@ static int UNUSED_FUNCTION(linecrosses)(double *v1, double *v2, double *v3, doub /* detects if two line segments cross each other (intersects). note, there could be more winding cases then there needs to be. */ -static int linecrossesf(float *v1, float *v2, float *v3, float *v4) +static int linecrossesf(const float v1[2], const float v2[2], const float v3[2], const float v4[2]) { int w1, w2, w3, w4, w5 /*, ret*/; float mv1[2], mv2[2], mv3[2], mv4[2]; diff --git a/source/blender/bmesh/operators/bevel.c b/source/blender/bmesh/operators/bevel.c index b37ce139249..e9f6677a6c8 100644 --- a/source/blender/bmesh/operators/bevel.c +++ b/source/blender/bmesh/operators/bevel.c @@ -79,7 +79,7 @@ static void calc_corner_co(BMesh *bm, BMLoop *l, const float fac, float r_co[3]) /* not strictly necessary, balance vectors * so the longer edge doesn't skew the result, - * gives nicer, move event output */ + * gives nicer, move even output */ float medium= (normalize_v3(l_vec_prev) + normalize_v3(l_vec_next)) / 2.0f; mul_v3_fl(l_vec_prev, medium); mul_v3_fl(l_vec_next, medium); diff --git a/source/blender/bmesh/operators/utils.c b/source/blender/bmesh/operators/utils.c index 778359354f7..b4de92a3088 100644 --- a/source/blender/bmesh/operators/utils.c +++ b/source/blender/bmesh/operators/utils.c @@ -416,25 +416,6 @@ void bmesh_vertexsmooth_exec(BMesh *bm, BMOperator *op) } /* -** compute the centroid of an ngon -** -** NOTE: This should probably go to bmesh_polygon.c and replace the function that compute its center -** basing on bounding box -*/ -static void ngon_center(float *v, BMesh *bm, BMFace *f) -{ - BMIter liter; - BMLoop *l; - v[0] = v[1] = v[2] = 0; - - BM_ITER(l, &liter, bm, BM_LOOPS_OF_FACE, f) { - add_v3_v3v3(v, v, l->v->co); - } - - if( f->len ) mul_v3_fl(v, 1.0f / (float)f->len); -} - -/* ** compute the perimeter of an ngon ** ** NOTE: This should probably go to bmesh_polygon.c @@ -478,7 +459,7 @@ static float ngon_fake_area(BMesh *bm, BMFace *f) float v[3], sv[3], c[3]; float area = 0.0f; - ngon_center(c, bm, f); + BM_Compute_Face_CenterMean(bm, f, c); BM_ITER(l, &liter, bm, BM_LOOPS_OF_FACE, f) { if( num_verts == 0 ) { @@ -572,7 +553,7 @@ void bmesh_similarfaces_exec(BMesh *bm, BMOperator *op) case SIMFACE_COPLANAR: /* compute the center of the polygon */ - ngon_center(f_ext[i].c, bm, f_ext[i].f); + BM_Compute_Face_CenterMean(bm, f_ext[i].f, f_ext[i].c); /* normalize the polygon normal */ copy_v3_v3(t_no, f_ext[i].f->no); diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index edcfc42a798..9805191b490 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -2700,7 +2700,7 @@ static void draw_em_measure_stats(View3D *v3d, RegionView3D *rv3d, } if(me->drawflag & ME_DRAWEXTRA_FACEAREA) { - /* would be nice to use BM_face_area, but that is for 2d faces + /* would be nice to use BM_Compute_Face_Area, but that is for 2d faces so instead add up tessalation triangle areas */ BMFace *f; int n; diff --git a/source/blender/editors/uvedit/uvedit_draw.c b/source/blender/editors/uvedit/uvedit_draw.c index 539c7cada7a..8f4a8ef540f 100644 --- a/source/blender/editors/uvedit/uvedit_draw.c +++ b/source/blender/editors/uvedit/uvedit_draw.c @@ -202,7 +202,7 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, BMEditMesh *em, MTe poly_copy_aspect(tf_uvorig, tf_uv, aspx, aspy, efa->len); - totarea += BM_face_area(efa); + totarea += BM_Compute_Face_Area(em->bm, efa); //totuvarea += tf_area(tf, efa->v4!=0); totuvarea += poly_uv_area(tf_uv, efa->len); @@ -234,7 +234,7 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, BMEditMesh *em, MTe else { BM_ITER(efa, &iter, em->bm, BM_FACES_OF_MESH, NULL) { if(BM_TestHFlag(efa, BM_TMP_TAG)) { - area = BM_face_area(efa) / totarea; + area = BM_Compute_Face_Area(em->bm, efa) / totarea; BLI_array_empty(tf_uv); BLI_array_empty(tf_uvorig); |