[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [46002] trunk/blender/source/blender: add files missing from previous commit
Campbell Barton
ideasman42 at gmail.com
Fri Apr 27 11:01:59 CEST 2012
Revision: 46002
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=46002
Author: campbellbarton
Date: 2012-04-27 09:01:58 +0000 (Fri, 27 Apr 2012)
Log Message:
-----------
add files missing from previous commit
Modified Paths:
--------------
trunk/blender/source/blender/editors/physics/particle_edit.c
Added Paths:
-----------
trunk/blender/source/blender/blenlib/BLI_lasso.h
trunk/blender/source/blender/blenlib/intern/lasso.c
Added: trunk/blender/source/blender/blenlib/BLI_lasso.h
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_lasso.h (rev 0)
+++ trunk/blender/source/blender/blenlib/BLI_lasso.h 2012-04-27 09:01:58 UTC (rev 46002)
@@ -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
Property changes on: trunk/blender/source/blender/blenlib/BLI_lasso.h
___________________________________________________________________
Added: svn:eol-style
+ native
Added: trunk/blender/source/blender/blenlib/intern/lasso.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/lasso.c (rev 0)
+++ trunk/blender/source/blender/blenlib/intern/lasso.c 2012-04-27 09:01:58 UTC (rev 46002)
@@ -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;
+}
Property changes on: trunk/blender/source/blender/blenlib/intern/lasso.c
___________________________________________________________________
Added: svn:eol-style
+ native
Modified: trunk/blender/source/blender/editors/physics/particle_edit.c
===================================================================
--- trunk/blender/source/blender/editors/physics/particle_edit.c 2012-04-27 07:26:28 UTC (rev 46001)
+++ trunk/blender/source/blender/editors/physics/particle_edit.c 2012-04-27 09:01:58 UTC (rev 46002)
@@ -1635,8 +1635,8 @@
copy_v3_v3(co, key->co);
mul_m4_v3(mat, co);
project_int(ar, co, vertco);
- if ((vertco[0] != IS_CLIPPED) &&
- BLI_lasso_is_point_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;
@@ -1655,8 +1655,8 @@
copy_v3_v3(co, key->co);
mul_m4_v3(mat, co);
project_int(ar, co,vertco);
- if ((vertco[0] != IS_CLIPPED) &&
- BLI_lasso_is_point_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;
More information about the Bf-blender-cvs
mailing list