diff --git a/source/blender/blenlib/BLI_lasso.h b/source/blender/blenlib/BLI_lasso.h new file mode 100644 index 00000000000..2360173c3b8 --- /dev/null +++ b/source/blender/blenlib/BLI_lasso.h @@ -0,0 +1,41 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#ifndef __BLI_LASSO_H__ +#define __BLI_LASSO_H__ + +/** \file BLI_lasso.h + * \ingroup bli + */ + +struct rcti; + +void BLI_lasso_boundbox(struct rcti *rect, int mcords[][2], short moves); +int BLI_lasso_is_point_inside(int mcords[][2], short moves, int sx, int sy, const int error_value); +int BLI_lasso_is_edge_inside(int mcords[][2], short moves, int x0, int y0, int x1, int y1, const int error_value); + +#endif diff --git a/source/blender/blenlib/CMakeLists.txt b/source/blender/blenlib/CMakeLists.txt index c06a1240729..61fe3b560e2 100644 --- a/source/blender/blenlib/CMakeLists.txt +++ b/source/blender/blenlib/CMakeLists.txt @@ -61,6 +61,7 @@ set(SRC intern/graph.c intern/gsqueue.c intern/jitter.c + intern/lasso.c intern/listbase.c intern/math_base.c intern/math_base_inline.c @@ -90,10 +91,9 @@ set(SRC intern/voxel.c intern/winstuff.c + BLI_args.h BLI_array.h BLI_bitmap.h - BLI_smallhash.h - BLI_args.h BLI_blenlib.h BLI_boxpack2d.h BLI_bpath.h @@ -114,6 +114,7 @@ set(SRC BLI_jitter.h BLI_kdopbvh.h BLI_kdtree.h + BLI_lasso.h BLI_linklist.h BLI_listbase.h BLI_math.h @@ -133,6 +134,7 @@ set(SRC BLI_rand.h BLI_rect.h BLI_scanfill.h + BLI_smallhash.h BLI_string.h BLI_string_cursor_utf8.h BLI_string_utf8.h diff --git a/source/blender/blenlib/intern/lasso.c b/source/blender/blenlib/intern/lasso.c new file mode 100644 index 00000000000..29b967fcd37 --- /dev/null +++ b/source/blender/blenlib/intern/lasso.c @@ -0,0 +1,129 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + * + */ + +/** \file blender/blenlib/intern/lasso.c + * \ingroup bli + */ + +#include "DNA_vec_types.h" + +#include "BLI_math.h" +#include "BLI_rect.h" + +#include "BLI_lasso.h" /* own include */ + +void BLI_lasso_boundbox(rcti *rect, int mcords[][2], short moves) +{ + short a; + + rect->xmin = rect->xmax = mcords[0][0]; + rect->ymin = rect->ymax = mcords[0][1]; + + for (a = 1; a < moves; a++) { + if (mcords[a][0] < rect->xmin) rect->xmin = mcords[a][0]; + else if (mcords[a][0] > rect->xmax) rect->xmax = mcords[a][0]; + if (mcords[a][1] < rect->ymin) rect->ymin = mcords[a][1]; + else if (mcords[a][1] > rect->ymax) rect->ymax = mcords[a][1]; + } +} + + +int BLI_lasso_is_point_inside(int mcords[][2], short moves, + const int sx, const int sy, + const int error_value) +{ + /* we do the angle rule, define that all added angles should be about zero or (2 * PI) */ + float angletot = 0.0, dot, ang, cross, fp1[2], fp2[2]; + int a; + int *p1, *p2; + + if (sx == error_value) { + return 0; + } + + p1 = mcords[moves - 1]; + p2 = mcords[0]; + + /* first vector */ + fp1[0] = (float)(p1[0] - sx); + fp1[1] = (float)(p1[1] - sy); + normalize_v2(fp1); + + for (a = 0; a < moves; a++) { + /* second vector */ + fp2[0] = (float)(p2[0] - sx); + fp2[1] = (float)(p2[1] - sy); + normalize_v2(fp2); + + /* dot and angle and cross */ + dot = fp1[0] * fp2[0] + fp1[1] * fp2[1]; + ang = fabs(saacos(dot)); + + cross = (float)((p1[1] - p2[1]) * (p1[0] - sx) + (p2[0] - p1[0]) * (p1[1] - sy)); + + if (cross < 0.0f) angletot -= ang; + else angletot += ang; + + /* circulate */ + fp1[0] = fp2[0]; fp1[1] = fp2[1]; + p1 = p2; + p2 = mcords[a + 1]; + } + + if (fabs(angletot) > 4.0) return 1; + return 0; +} + +/* edge version for lasso select. we assume boundbox check was done */ +int BLI_lasso_is_edge_inside(int mcords[][2], short moves, + int x0, int y0, int x1, int y1, + const int error_value) +{ + int v1[2], v2[2]; + int a; + + if (x0 == error_value || x1 == error_value) { + return 0; + } + + v1[0] = x0, v1[1] = y0; + v2[0] = x1, v2[1] = y1; + + /* check points in lasso */ + if (BLI_lasso_is_point_inside(mcords, moves, v1[0], v1[1], error_value)) return 1; + if (BLI_lasso_is_point_inside(mcords, moves, v2[0], v2[1], error_value)) return 1; + + /* no points in lasso, so we have to intersect with lasso edge */ + + if (isect_line_line_v2_int(mcords[0], mcords[moves - 1], v1, v2) > 0) return 1; + for (a = 0; a < moves - 1; a++) { + if (isect_line_line_v2_int(mcords[a], mcords[a + 1], v1, v2) > 0) return 1; + } + + return 0; +} diff --git a/source/blender/blenlib/intern/listbase.c b/source/blender/blenlib/intern/listbase.c index fecaa507b5c..b2b18286cfb 100644 --- a/source/blender/blenlib/intern/listbase.c +++ b/source/blender/blenlib/intern/listbase.c @@ -1,9 +1,4 @@ -/* util.c - * - * various string, file, list operations. - * - * - * +/* * ***** BEGIN GPL LICENSE BLOCK ***** * * This program is free software; you can redistribute it and/or diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index f886c01039e..4b614085f8e 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -269,8 +269,6 @@ void view3d_get_transformation(const struct ARegion *ar, struct RegionView3D *rv /* XXX should move to BLI_math */ int edge_inside_circle(short centx, short centy, short rad, short x1, short y1, short x2, short y2); -int lasso_inside(int mcords[][2], short moves, int sx, int sy); -int lasso_inside_edge(int mcords[][2], short moves, int x0, int y0, int x1, int y1); /* get 3d region from context, also if mouse is in header or toolbar */ struct RegionView3D *ED_view3d_context_rv3d(struct bContext *C); diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c index 7c02f26dbdc..96fb2afbac4 100644 --- a/source/blender/editors/mesh/meshtools.c +++ b/source/blender/editors/mesh/meshtools.c @@ -1016,7 +1016,7 @@ static float *editmesh_get_mirror_uv(BMEditMesh *em, int axis, float *uv, float BMFace *efa; BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { - poly_uv_center(em, efa, cent); + uv_poly_center(em, efa, cent); if ( (fabs(cent[0] - cent_vec[0]) < 0.001) && (fabs(cent[1] - cent_vec[1]) < 0.001) ) { BMIter liter; diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index 5f22165176b..591015a7479 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -45,7 +45,9 @@ #include "DNA_space_types.h" #include "BLI_math.h" -#include "BLI_blenlib.h" +#include "BLI_lasso.h" +#include "BLI_listbase.h" +#include "BLI_string.h" #include "BLI_dynstr.h" #include "BLI_kdtree.h" #include "BLI_rand.h" @@ -1633,7 +1635,9 @@ int PE_lasso_select(bContext *C, int mcords[][2], short moves, short extend, sho copy_v3_v3(co, key->co); mul_m4_v3(mat, co); project_int(ar, co, vertco); - if ((vertco[0] != IS_CLIPPED) && lasso_inside(mcords,moves,vertco[0],vertco[1]) && key_test_depth(&data, co)) { + if (BLI_lasso_is_point_inside(mcords,moves,vertco[0],vertco[1], IS_CLIPPED) && + key_test_depth(&data, co)) + { if (select && !(key->flag & PEK_SELECT)) { key->flag |= PEK_SELECT; point->flag |= PEP_EDIT_RECALC; @@ -1651,7 +1655,9 @@ int PE_lasso_select(bContext *C, int mcords[][2], short moves, short extend, sho copy_v3_v3(co, key->co); mul_m4_v3(mat, co); project_int(ar, co,vertco); - if ((vertco[0] != IS_CLIPPED) && lasso_inside(mcords,moves,vertco[0],vertco[1]) && key_test_depth(&data, co)) { + if (BLI_lasso_is_point_inside(mcords,moves,vertco[0],vertco[1], IS_CLIPPED) && + key_test_depth(&data, co)) + { if (select && !(key->flag & PEK_SELECT)) { key->flag |= PEK_SELECT; point->flag |= PEP_EDIT_RECALC; diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index ac9c32816dd..09cc6b9c7a5 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -48,9 +48,12 @@ #include "MEM_guardedalloc.h" #include "BLI_math.h" -#include "BLI_blenlib.h" +#include "BLI_lasso.h" +#include "BLI_rect.h" #include "BLI_rand.h" #include "BLI_linklist.h" +#include "BLI_listbase.h" +#include "BLI_string.h" #include "BLI_utildefines.h" /* vertex box select */ @@ -319,79 +322,6 @@ static int edge_inside_rect(rcti *rect, short x1, short y1, short x2, short y2) #define MOVES_GESTURE 50 #define MOVES_LASSO 500 -int lasso_inside(int mcords[][2], short moves, int sx, int sy) -{ - /* we do the angle rule, define that all added angles should be about zero or 2*PI */ - float angletot = 0.0, len, dot, ang, cross, fp1[2], fp2[2]; - int a; - int *p1, *p2; - - if (sx == IS_CLIPPED) - return 0; - - p1 = mcords[moves - 1]; - p2 = mcords[0]; - - /* first vector */ - fp1[0] = (float)(p1[0] - sx); - fp1[1] = (float)(p1[1] - sy); - len = sqrt(fp1[0] * fp1[0] + fp1[1] * fp1[1]); - fp1[0] /= len; - fp1[1] /= len; - - for (a = 0; a < moves; a++) { - /* second vector */ - fp2[0] = (float)(p2[0] - sx); - fp2[1] = (float)(p2[1] - sy); - len = sqrt(fp2[0] * fp2[0] + fp2[1] * fp2[1]); - fp2[0] /= len; - fp2[1] /= len; - - /* dot and angle and cross */ - dot = fp1[0] * fp2[0] + fp1[1] * fp2[1]; - ang = fabs(saacos(dot)); - - cross = (float)((p1[1] - p2[1]) * (p1[0] - sx) + (p2[0] - p1[0]) * (p1[1] - sy)); - - if (cross < 0.0f) angletot -= ang; - else angletot += ang; - - /* circulate */ - fp1[0] = fp2[0]; fp1[1] = fp2[1]; - p1 = p2; - p2 = mcords[a + 1]; - } - - if (fabs(angletot) > 4.0) return 1; - return 0; -} - -/* edge version for lasso select. we assume boundbox check was done */ -int lasso_inside_edge(int mcords[][2], short moves, int x0, int y0, int x1, int y1) -{ - int v1[2], v2[2]; - int a; - - if (x0 == IS_CLIPPED || x1 == IS_CLIPPED) - return 0; - - v1[0] = x0, v1[1] = y0; - v2[0] = x1, v2[1] = y1; - - /* check points in lasso */ - if (lasso_inside(mcords, moves, v1[0], v1[1])) return 1; - if (lasso_inside(mcords, moves, v2[0], v2[1])) return 1; - - /* no points in lasso, so we have to intersect with lasso edge */ - - if (isect_line_line_v2_int(mcords[0], mcords[moves - 1], v1, v2) > 0) return 1; - for (a = 0; a < moves - 1; a++) { - if (isect_line_line_v2_int(mcords[a], mcords[a + 1], v1, v2) > 0) return 1; - } - - return 0; -} - /* warning; lasso select with backbuffer-check draws in backbuf with persp(PERSP_WIN) * and returns with persp(PERSP_VIEW). After lasso select backbuf is not OK @@ -412,7 +342,7 @@ static void do_lasso_select_pose(ViewContext *vc, Object *ob, int mcords[][2], s mul_v3_m4v3(vec, ob->obmat, pchan->pose_tail); project_int(vc->ar, vec, sco2); - if (lasso_inside_edge(mcords, moves, sco1[0], sco1[1], sco2[0], sco2[1])) { + if (BLI_lasso_is_edge_inside(mcords, moves, sco1[0], sco1[1], sco2[0], sco2[1], IS_CLIPPED)) { if (select) pchan->bone->flag |= BONE_SELECTED; else pchan->bone->flag &= ~BONE_SELECTED; } @@ -441,7 +371,7 @@ static void do_lasso_select_objects(ViewContext *vc, int mcords[][2], short move for (base = vc->scene->base.first; base; base = base->next) { if (BASE_SELECTABLE(vc->v3d, base)) { /* use this to avoid un-needed lasso lookups */ project_short(vc->ar, base->object->obmat[3], &base->sx); - if (lasso_inside(mcords, moves, base->sx, base->sy)) { + if (BLI_lasso_is_point_inside(mcords, moves, base->sx, base->sy, IS_CLIPPED)) { if (select) ED_base_object_select(base, BA_SELECT); else ED_base_object_select(base, BA_DESELECT); @@ -454,26 +384,13 @@ static void do_lasso_select_objects(ViewContext *vc, int mcords[][2], short move } } -static void lasso_select_boundbox(rcti *rect, int mcords[][2], short moves) -{ - short a; - - rect->xmin = rect->xmax = mcords[0][0]; - rect->ymin = rect->ymax = mcords[0][1]; - - for (a = 1; a < moves; a++) { - if (mcords[a][0] < rect->xmin) rect->xmin = mcords[a][0]; - else if (mcords[a][0] > rect->xmax) rect->xmax = mcords[a][0]; - if (mcords[a][1] < rect->ymin) rect->ymin = mcords[a][1]; - else if (mcords[a][1] > rect->ymax) rect->ymax = mcords[a][1]; - } -} - static void do_lasso_select_mesh__doSelectVert(void *userData, BMVert *eve, int x, int y, int UNUSED(index)) { LassoSelectUserData *data = userData; - if (BLI_in_rcti(data->rect, x, y) && lasso_inside(data->mcords, data->moves, x, y)) { + if (BLI_in_rcti(data->rect, x, y) && + BLI_lasso_is_point_inside(data->mcords, data->moves, x, y, IS_CLIPPED)) + { BM_vert_select_set(data->vc->em->bm, eve, data->select); } } @@ -484,14 +401,15 @@ static void do_lasso_select_mesh__doSelectEdge(void *userData, BMEdge *eed, int if (EDBM_backbuf_check(bm_solidoffs + index)) { if (data->pass == 0) { if (edge_fully_inside_rect(data->rect, x0, y0, x1, y1) && - lasso_inside(data->mcords, data->moves, x0, y0) && - lasso_inside(data->mcords, data->moves, x1, y1)) { + BLI_lasso_is_point_inside(data->mcords, data->moves, x0, y0, IS_CLIPPED) && + BLI_lasso_is_point_inside(data->mcords, data->moves, x1, y1, IS_CLIPPED)) + { BM_edge_select_set(data->vc->em->bm, eed, data->select); data->done = 1; } } else { - if (lasso_inside_edge(data->mcords, data->moves, x0, y0, x1, y1)) { + if (BLI_lasso_is_edge_inside(data->mcords, data->moves, x0, y0, x1, y1, IS_CLIPPED)) { BM_edge_select_set(data->vc->em->bm, eed, data->select); } } @@ -501,7 +419,9 @@ static void do_lasso_select_mesh__doSelectFace(void *userData, BMFace *efa, int { LassoSelectUserData *data = userData; - if (BLI_in_rcti(data->rect, x, y) && lasso_inside(data->mcords, data->moves, x, y)) { + if (BLI_in_rcti(data->rect, x, y) && + BLI_lasso_is_point_inside(data->mcords, data->moves, x, y, IS_CLIPPED)) + { BM_face_select_set(data->vc->em->bm, efa, data->select); } } @@ -513,7 +433,7 @@ static void do_lasso_select_mesh(ViewContext *vc, int mcords[][2], short moves, rcti rect; int bbsel; - lasso_select_boundbox(&rect, mcords, moves); + BLI_lasso_boundbox(&rect, mcords, moves); /* set editmesh */ vc->em = BMEdit_FromObject(vc->obedit); @@ -577,7 +497,7 @@ static void do_lasso_select_mesh_uv(int mcords[][2], short moves, short select) int screenUV[2], nverts, i, ok = 1; rcti rect; - lasso_select_boundbox(&rect, mcords, moves); + BLI_lasso_boundbox(&rect, mcords, moves); if (draw_uvs_face_check()) { /* Face Center Sel */ float cent[2]; @@ -589,7 +509,7 @@ static void do_lasso_select_mesh_uv(int mcords[][2], short moves, short select) if ((select) != (simaFaceSel_Check(efa, tf))) { uv_center(tf->uv, cent, (void *)efa->v4); uvco_to_areaco_noclip(cent, screenUV); - if (BLI_in_rcti(&rect, screenUV[0], screenUV[1]) && lasso_inside(mcords, moves, screenUV[0], screenUV[1])) { + if (BLI_in_rcti(&rect, screenUV[0], screenUV[1]) && BLI_lasso_is_point_inside(mcords, moves, screenUV[0], screenUV[1])) { efa->tmp.l = ok = 1; } } @@ -607,7 +527,7 @@ static void do_lasso_select_mesh_uv(int mcords[][2], short moves, short select) for (i = 0; i < nverts; i++) { if ((select) != (simaUVSel_Check(efa, tf, i))) { uvco_to_areaco_noclip(tf->uv[i], screenUV); - if (BLI_in_rcti(&rect, screenUV[0], screenUV[1]) && lasso_inside(mcords, moves, screenUV[0], screenUV[1])) { + if (BLI_in_rcti(&rect, screenUV[0], screenUV[1]) && BLI_lasso_is_point_inside(mcords, moves, screenUV[0], screenUV[1])) { if (select) { simaUVSel_Set(efa, tf, i); } @@ -633,7 +553,7 @@ static void do_lasso_select_curve__doSelect(void *userData, Nurb *UNUSED(nu), BP Object *obedit = data->vc->obedit; Curve *cu = (Curve *)obedit->data; - if (lasso_inside(data->mcords, data->moves, x, y)) { + if (BLI_lasso_is_point_inside(data->mcords, data->moves, x, y, IS_CLIPPED)) { if (bp) { bp->f1 = data->select ? (bp->f1 | SELECT) : (bp->f1 & ~SELECT); if (bp == cu->lastsel && !(bp->f1 & 1)) cu->lastsel = NULL; @@ -681,7 +601,7 @@ static void do_lasso_select_lattice__doSelect(void *userData, BPoint *bp, int x, { LassoSelectUserData *data = userData; - if (lasso_inside(data->mcords, data->moves, x, y)) { + if (BLI_lasso_is_point_inside(data->mcords, data->moves, x, y, IS_CLIPPED)) { bp->f1 = data->select ? (bp->f1 | SELECT) : (bp->f1 & ~SELECT); } } @@ -722,20 +642,22 @@ static void do_lasso_select_armature(ViewContext *vc, int mcords[][2], short mov project_short(vc->ar, vec, sco2); didpoint = 0; - if (lasso_inside(mcords, moves, sco1[0], sco1[1])) { + if (BLI_lasso_is_point_inside(mcords, moves, sco1[0], sco1[1], IS_CLIPPED)) { if (select) ebone->flag |= BONE_ROOTSEL; else ebone->flag &= ~BONE_ROOTSEL; didpoint = 1; change = TRUE; } - if (lasso_inside(mcords, moves, sco2[0], sco2[1])) { + if (BLI_lasso_is_point_inside(mcords, moves, sco2[0], sco2[1], IS_CLIPPED)) { if (select) ebone->flag |= BONE_TIPSEL; else ebone->flag &= ~BONE_TIPSEL; didpoint = 1; change = TRUE; } /* if one of points selected, we skip the bone itself */ - if (didpoint == 0 && lasso_inside_edge(mcords, moves, sco1[0], sco1[1], sco2[0], sco2[1])) { + if (didpoint == 0 && + BLI_lasso_is_edge_inside(mcords, moves, sco1[0], sco1[1], sco2[0], sco2[1], IS_CLIPPED)) + { if (select) ebone->flag |= BONE_TIPSEL | BONE_ROOTSEL | BONE_SELECTED; else ebone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL); change = TRUE; @@ -771,7 +693,7 @@ static void do_lasso_select_meta(ViewContext *vc, int mcords[][2], short moves, mul_v3_m4v3(vec, vc->obedit->obmat, &ml->x); project_short(vc->ar, vec, sco); - if (lasso_inside(mcords, moves, sco[0], sco[1])) { + if (BLI_lasso_is_point_inside(mcords, moves, sco[0], sco[1], IS_CLIPPED)) { if (select) ml->flag |= SELECT; else ml->flag &= ~SELECT; } @@ -850,7 +772,7 @@ static void do_lasso_select_paintvert(ViewContext *vc, int mcords[][2], short mo paintvert_deselect_all_visible(ob, SEL_DESELECT, FALSE); /* flush selection at the end */ bm_vertoffs = me->totvert + 1; /* max index array */ - lasso_select_boundbox(&rect, mcords, moves); + BLI_lasso_boundbox(&rect, mcords, moves); EDBM_backbuf_border_mask_init(vc, mcords, moves, rect.xmin, rect.ymin, rect.xmax, rect.ymax); edbm_backbuf_check_and_select_verts_obmode(me, select); @@ -873,7 +795,7 @@ static void do_lasso_select_paintface(ViewContext *vc, int mcords[][2], short mo bm_vertoffs = me->totpoly + 1; /* max index array */ - lasso_select_boundbox(&rect, mcords, moves); + BLI_lasso_boundbox(&rect, mcords, moves); EDBM_backbuf_border_mask_init(vc, mcords, moves, rect.xmin, rect.ymin, rect.xmax, rect.ymax); edbm_backbuf_check_and_select_tfaces(me, select); @@ -893,7 +815,7 @@ static void do_lasso_select_node(int mcords[][2], short moves, short select) short node_cent[2]; float node_centf[2]; - lasso_select_boundbox(&rect, mcords, moves); + BLI_lasso_boundbox(&rect, mcords, moves); /* store selection in temp test flag */ for (node = snode->edittree->nodes.first; node; node = node->next) { @@ -902,7 +824,7 @@ static void do_lasso_select_node(int mcords[][2], short moves, short select) node_centf[1] = (node->totr.ymin + node->totr.ymax) / 2; ipoco_to_areaco_noclip(G.v2d, node_centf, node_cent); - if (BLI_in_rcti(&rect, node_cent[0], node_cent[1]) && lasso_inside(mcords, moves, node_cent[0], node_cent[1])) { + if (BLI_in_rcti(&rect, node_cent[0], node_cent[1]) && BLI_lasso_is_point_inside(mcords, moves, node_cent[0], node_cent[1])) { if (select) { node->flag |= SELECT; } diff --git a/source/blender/editors/uvedit/uvedit_draw.c b/source/blender/editors/uvedit/uvedit_draw.c index e772ff5a87a..987f6b250cb 100644 --- a/source/blender/editors/uvedit/uvedit_draw.c +++ b/source/blender/editors/uvedit/uvedit_draw.c @@ -198,11 +198,11 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, BMEditMesh *em, MTe i++; } - poly_copy_aspect(tf_uvorig, tf_uv, aspx, aspy, efa->len); + uv_poly_copy_aspect(tf_uvorig, tf_uv, aspx, aspy, efa->len); totarea += BM_face_calc_area(efa); //totuvarea += tf_area(tf, efa->v4!=0); - totuvarea += poly_uv_area(tf_uv, efa->len); + totuvarea += uv_poly_area(tf_uv, efa->len); if (uvedit_face_visible_test(scene, ima, efa, tf)) { BM_elem_flag_enable(efa, BM_ELEM_TAG); @@ -248,10 +248,10 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, BMEditMesh *em, MTe i++; } - poly_copy_aspect(tf_uvorig, tf_uv, aspx, aspy, efa->len); + uv_poly_copy_aspect(tf_uvorig, tf_uv, aspx, aspy, efa->len); //uvarea = tf_area(tf, efa->v4!=0) / totuvarea; - uvarea = poly_uv_area(tf_uv, efa->len) / totuvarea; + uvarea = uv_poly_area(tf_uv, efa->len) / totuvarea; if (area < FLT_EPSILON || uvarea < FLT_EPSILON) areadiff = 1.0f; @@ -315,7 +315,7 @@ static void draw_uvs_stretch(SpaceImage *sima, Scene *scene, BMEditMesh *em, MTe copy_v2_v2(tf_uvorig[i], luv->uv); } - poly_copy_aspect(tf_uvorig, tf_uv, aspx, aspy, nverts); + uv_poly_copy_aspect(tf_uvorig, tf_uv, aspx, aspy, nverts); j = nverts - 1; BM_ITER_ELEM_INDEX (l, &liter, efa, BM_LOOPS_OF_FACE, i) { @@ -742,7 +742,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) continue; if (!uvedit_face_select_test(scene, em, efa)) { - poly_uv_center(em, efa, cent); + uv_poly_center(em, efa, cent); bglVertex2fv(cent); } } @@ -757,7 +757,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit) continue; if (uvedit_face_select_test(scene, em, efa)) { - poly_uv_center(em, efa, cent); + uv_poly_center(em, efa, cent); bglVertex2fv(cent); } } diff --git a/source/blender/editors/uvedit/uvedit_intern.h b/source/blender/editors/uvedit/uvedit_intern.h index fdcb5db1911..04d20b3ba09 100644 --- a/source/blender/editors/uvedit/uvedit_intern.h +++ b/source/blender/editors/uvedit/uvedit_intern.h @@ -54,14 +54,9 @@ struct BMVert; int uvedit_face_visible_nolocal(struct Scene *scene, struct BMFace *efa); /* geometric utilities */ - -void uv_center(float uv[][2], float cent[2], int quad); -float uv_area(float uv[][2], int quad); -void uv_copy_aspect(float uv_orig[][2], float uv[][2], float aspx, float aspy); - -float poly_uv_area(float uv[][2], int len); -void poly_copy_aspect(float uv_orig[][2], float uv[][2], float aspx, float aspy, int len); -void poly_uv_center(struct BMEditMesh *em, struct BMFace *f, float cent[2]); +float uv_poly_area(float uv[][2], int len); +void uv_poly_copy_aspect(float uv_orig[][2], float uv[][2], float aspx, float aspy, int len); +void uv_poly_center(struct BMEditMesh *em, struct BMFace *f, float cent[2]); /* find nearest */ diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c index 1c62ce3a684..832bf6f57e9 100644 --- a/source/blender/editors/uvedit/uvedit_ops.c +++ b/source/blender/editors/uvedit/uvedit_ops.c @@ -522,7 +522,7 @@ void uvedit_live_unwrap_update(SpaceImage *sima, Scene *scene, Object *obedit) } /*********************** geometric utilities ***********************/ -void poly_uv_center(BMEditMesh *em, BMFace *f, float cent[2]) +void uv_poly_center(BMEditMesh *em, BMFace *f, float cent[2]) { BMLoop *l; MLoopUV *luv; @@ -538,28 +538,7 @@ void poly_uv_center(BMEditMesh *em, BMFace *f, float cent[2]) mul_v2_fl(cent, 1.0f / (float)f->len); } - -void uv_center(float uv[][2], float cent[2], int quad) -{ - if (quad) { - cent[0] = (uv[0][0] + uv[1][0] + uv[2][0] + uv[3][0]) / 4.0f; - cent[1] = (uv[0][1] + uv[1][1] + uv[2][1] + uv[3][1]) / 4.0f; - } - else { - cent[0] = (uv[0][0] + uv[1][0] + uv[2][0]) / 3.0f; - cent[1] = (uv[0][1] + uv[1][1] + uv[2][1]) / 3.0f; - } -} - -float uv_area(float uv[][2], int quad) -{ - if (quad) - return area_tri_v2(uv[0], uv[1], uv[2]) + area_tri_v2(uv[0], uv[2], uv[3]); - else - return area_tri_v2(uv[0], uv[1], uv[2]); -} - -float poly_uv_area(float uv[][2], int len) +float uv_poly_area(float uv[][2], int len) { //BMESH_TODO: make this not suck //maybe use scanfill? I dunno. @@ -572,7 +551,7 @@ float poly_uv_area(float uv[][2], int len) return 1.0; } -void poly_copy_aspect(float uv_orig[][2], float uv[][2], float aspx, float aspy, int len) +void uv_poly_copy_aspect(float uv_orig[][2], float uv[][2], float aspx, float aspy, int len) { int i; for (i = 0; i < len; i++) { @@ -2469,7 +2448,7 @@ static int border_select_exec(bContext *C, wmOperator *op) tf = CustomData_bmesh_get(&em->bm->pdata, efa->head.data, CD_MTEXPOLY); if (uvedit_face_visible_test(scene, ima, efa, tf)) { - poly_uv_center(em, efa, cent); + uv_poly_center(em, efa, cent); if (BLI_in_rctf(&rectf, cent[0], cent[1])) { BM_elem_flag_enable(efa, BM_ELEM_TAG); change = 1;