[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [13264] branches/blender2.5/blender/source /blender: * Start ActionZone support for areas.

Nathan Letwory jesterking at letwory.net
Thu Jan 17 06:33:54 CET 2008


Revision: 13264
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=13264
Author:   jesterking
Date:     2008-01-17 06:33:54 +0100 (Thu, 17 Jan 2008)

Log Message:
-----------
* Start ActionZone support for areas. This is bScreen level stuff to be able to do funky stuff.

Right now 2 AZones are defined for each new ScrArea, and mouse over is now detected. Enter ugly triangle.

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/blenkernel/intern/screen.c
    branches/blender2.5/blender/source/blender/blenlib/BLI_arithb.h
    branches/blender2.5/blender/source/blender/blenlib/intern/arithb.c
    branches/blender2.5/blender/source/blender/editors/screen/area.c
    branches/blender2.5/blender/source/blender/editors/screen/screen_edit.c
    branches/blender2.5/blender/source/blender/editors/screen/screen_ops.c
    branches/blender2.5/blender/source/blender/makesdna/DNA_screen_types.h
    branches/blender2.5/blender/source/blender/windowmanager/WM_types.h

Added Paths:
-----------
    branches/blender2.5/blender/source/blender/editors/include/ED_screen_types.h

Modified: branches/blender2.5/blender/source/blender/blenkernel/intern/screen.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/intern/screen.c	2008-01-17 00:28:14 UTC (rev 13263)
+++ branches/blender2.5/blender/source/blender/blenkernel/intern/screen.c	2008-01-17 05:33:54 UTC (rev 13264)
@@ -93,6 +93,7 @@
 	BKE_spacedata_freelist(&sa->spacedata);
 	
 	BLI_freelistN(&sa->regionbase);
+	BLI_freelistN(&sa->actionzones);
 	
 	BLI_freelistN(&sa->panels);
 	//	uiFreeBlocks(&sa->uiblocks);

Modified: branches/blender2.5/blender/source/blender/blenlib/BLI_arithb.h
===================================================================
--- branches/blender2.5/blender/source/blender/blenlib/BLI_arithb.h	2008-01-17 00:28:14 UTC (rev 13263)
+++ branches/blender2.5/blender/source/blender/blenlib/BLI_arithb.h	2008-01-17 05:33:54 UTC (rev 13264)
@@ -374,6 +374,8 @@
 void VecfCubicInterpol(float *x1, float *v1, float *x2, float *v2, float t, float *x, float *v);
 void PointInQuad2DUV(float v0[2], float v1[2], float v2[2], float v3[2], float pt[2], float *uv);
 void PointInFace2DUV(int isquad, float v0[2], float v1[2], float v2[2], float v3[2], float pt[2], float *uv);
+int IsPointInTri2D(float v0[2], float v1[2], float v2[2], float pt[2]);
+int IsPointInTri2DInts(int x1, int y1, int x2, int y2, int a, int b);
 int point_in_tri_prism(float p[3], float v1[3], float v2[3], float v3[3]);
 
 float lambda_cp_line_ex(float p[3], float l1[3], float l2[3], float cp[3]);

Modified: branches/blender2.5/blender/source/blender/blenlib/intern/arithb.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenlib/intern/arithb.c	2008-01-17 00:28:14 UTC (rev 13263)
+++ branches/blender2.5/blender/source/blender/blenlib/intern/arithb.c	2008-01-17 05:33:54 UTC (rev 13264)
@@ -4084,6 +4084,63 @@
 	}
 }
 
+int IsPointInTri2D(float v0[2], float v1[2], float v2[2], float pt[2])
+{
+		/* not for quads, use for our abuse of LineIntersectsTriangleUV */
+		float p1_3d[3], p2_3d[3], v0_3d[3], v1_3d[3], v2_3d[3];
+		/* not used */
+		float lambda, uv[3];
+			
+		p1_3d[0] = p2_3d[0] = uv[0]= pt[0];
+		p1_3d[1] = p2_3d[1] = uv[1]= uv[2]= pt[1];
+		p1_3d[2] = 1.0f;
+		p2_3d[2] = -1.0f;
+		v0_3d[2] = v1_3d[2] = v2_3d[2] = 0.0;
+		
+		/* generate a new fuv, (this is possibly a non optimal solution,
+		 * since we only need 2d calculation but use 3d func's)
+		 * 
+		 * this method makes an imaginary triangle in 2d space using the UV's from the derived mesh face
+		 * Then find new uv coords using the fuv and this face with LineIntersectsTriangleUV.
+		 * This means the new values will be correct in relation to the derived meshes face. 
+		 */
+		Vec2Copyf(v0_3d, v0);
+		Vec2Copyf(v1_3d, v1);
+		Vec2Copyf(v2_3d, v2);
+		
+		/* Doing this in 3D is not nice */
+		return LineIntersectsTriangle(p1_3d, p2_3d, v0_3d, v1_3d, v2_3d, &lambda, &uv);
+}
+
+/*
+
+	x1,y2
+	|  \
+	|   \     .(a,b)
+	|    \
+	x1,y1-- x2,y1
+
+*/
+int IsPointInTri2DInts(int x1, int y1, int x2, int y2, int a, int b)
+{
+	float v1[2], v2[2], v3[2], p[2];
+	
+	v1[0]= (float)x1;
+	v1[1]= (float)y1;
+	
+	v2[0]= (float)x1;
+	v2[1]= (float)y2;
+	
+	v3[0]= (float)x2;
+	v3[1]= (float)y1;
+	
+	p[0]= (float)a;
+	p[1]= (float)b;
+	
+	return IsPointInTri2D(v1, v2, v3, p);
+	
+}
+
 /* (x1,v1)(t1=0)------(x2,v2)(t2=1), 0<t<1 --> (x,v)(t) */
 void VecfCubicInterpol(float *x1, float *v1, float *x2, float *v2, float t, float *x, float *v)
 {

Added: branches/blender2.5/blender/source/blender/editors/include/ED_screen_types.h
===================================================================
--- branches/blender2.5/blender/source/blender/editors/include/ED_screen_types.h	                        (rev 0)
+++ branches/blender2.5/blender/source/blender/editors/include/ED_screen_types.h	2008-01-17 05:33:54 UTC (rev 13264)
@@ -0,0 +1,63 @@
+/**
+ * $Id:
+ *
+ * ***** 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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2008 Blender Foundation.
+ * All rights reserved.
+ *
+ * 
+ * Contributor(s): Blender Foundation
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifndef ED_SCREEN_TYPES_H__
+#define ED_SCREEN_TYPES_H__
+
+typedef struct AZone {
+	struct AZone *next, *prev;
+	int type;
+	int flag;
+	int action;
+	int pos;
+	short x1, y1, x2, y2;
+} AZone;
+
+#define MAX_AZONES			8
+
+
+/* actionzone type */
+#define	AZONE_TRI			1
+#define AZONE_QUAD			2
+
+/* actionzone action */
+#define AZONE_SPLIT			1
+#define AZONE_JOIN			2
+#define AZONE_DRAG			3
+
+/* actionzone pos */
+#define AZONE_S				1
+#define AZONE_SW			2
+#define AZONE_W				3
+#define AZONE_NW			4
+#define AZONE_N				5
+#define AZONE_NE			6
+#define AZONE_E				7
+#define AZONE_SE			8
+
+#endif /* ED_SCREEN_TYPES_H__ */

Modified: branches/blender2.5/blender/source/blender/editors/screen/area.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/screen/area.c	2008-01-17 00:28:14 UTC (rev 13263)
+++ branches/blender2.5/blender/source/blender/editors/screen/area.c	2008-01-17 05:33:54 UTC (rev 13264)
@@ -40,7 +40,8 @@
 #include "BKE_utildefines.h"
 
 #include "ED_area.h"
-#include "ED_screen.h"
+#include "ED_screen.h"
+#include "ED_screen_types.h"
 
 #include "WM_api.h"
 #include "WM_types.h"
@@ -257,6 +258,95 @@
 	/* for speedup */
 	sa->winx= sa->totrct.xmax-sa->totrct.xmin+1;
 	sa->winy= sa->totrct.ymax-sa->totrct.ymin+1;
+}
+
+void area_azone_initialize(ScrArea *sa) {
+	AZone *az;
+	if(sa->actionzones.first==NULL) {
+		printf("area_azone_initialize\n");
+		/* set action zones - should these actually be ARegions? With these we can easier check area hotzones */
+		az= (AZone *)MEM_callocN(sizeof(AZone), "actionzone");
+		BLI_addtail(&(sa->actionzones), az);
+		az->type= AZONE_TRI;
+		az->x1= sa->v1->vec.x+1;
+		az->y1= sa->v1->vec.y+1;
+		az->x2= sa->v1->vec.x+HEADERY;
+		az->y2= sa->v1->vec.y+HEADERY;
+		az->pos= AZONE_SW;
+		az->action= AZONE_SPLIT;
+		
+		az= (AZone *)MEM_callocN(sizeof(AZone), "actionzone");
+		BLI_addtail(&(sa->actionzones), az);
+		az->type= AZONE_TRI;
+		az->x1= sa->v3->vec.x-1;
+		az->y1= sa->v3->vec.y-1;
+		az->x2= sa->v3->vec.x-HEADERY;
+		az->y2= sa->v3->vec.y-HEADERY;
+		az->pos= AZONE_NE;
+		az->action= AZONE_DRAG;
+		
+		/*az= (AZone *)MEM_callocN(sizeof(AZone), "actionzone");
+		BLI_addtail(&sa->azones, az);
+		az->type= AZONE_TRI;
+		az->x1= as->v1->vec.x;
+		az->y1= as->v1->vec.y;
+		az->x2= as->v1->vec.x+HEADERY;
+		az->y2= as->v1->vec.y+HEADERY;
+		
+		az= (AZone *)MEM_callocN(sizeof(AZone), "actionzone");
+		BLI_addtail(&sa->azones, az);
+		az->type= AZONE_TRI;
+		az->x1= as->v1->vec.x;
+		az->y1= as->v1->vec.y;
+		az->x2= as->v1->vec.x+HEADERY;
+		az->y2= as->v1->vec.y+HEADERY;
+		
+		az= (AZone *)MEM_callocN(sizeof(AZone), "actionzone");
+		BLI_addtail(&sa->azones, az);
+		az->type= AZONE_QUAD;
+		az->x1= as->v1->vec.x;
+		az->y1= as->v1->vec.y;
+		az->x2= as->v1->vec.x+HEADERY;
+		az->y2= as->v1->vec.y+HEADERY;
+		
+		az= (AZone *)MEM_callocN(sizeof(AZone), "actionzone");
+		BLI_addtail(&sa->azones, az);
+		az->type= AZONE_QUAD;
+		az->x1= as->v1->vec.x;
+		az->y1= as->v1->vec.y;
+		az->x2= as->v1->vec.x+HEADERY;
+		az->y2= as->v1->vec.y+HEADERY;
+		
+		az= (AZone *)MEM_callocN(sizeof(AZone), "actionzone");
+		BLI_addtail(&sa->azones, az);
+		az->type= AZONE_QUAD;
+		az->x1= as->v1->vec.x;
+		az->y1= as->v1->vec.y;
+		az->x2= as->v1->vec.x+HEADERY;
+		az->y2= as->v1->vec.y+HEADERY;
+		
+		az= (AZone *)MEM_callocN(sizeof(AZone), "actionzone");
+		BLI_addtail(&sa->azones, az);
+		az->type= AZONE_QUAD;
+		az->x1= as->v1->vec.x;
+		az->y1= as->v1->vec.y;
+		az->x2= as->v1->vec.x+HEADERY;
+		az->y2= as->v1->vec.y+HEADERY;*/
+	}
+	
+	for(az= sa->actionzones.first; az; az= az->next) {
+		if(az->pos==AZONE_SW) {
+			az->x1= sa->v1->vec.x+1;
+			az->y1= sa->v1->vec.y+1;
+			az->x2= sa->v1->vec.x+HEADERY;
+			az->y2= sa->v1->vec.y+HEADERY;
+		} else if (az->pos==AZONE_NE) {
+			az->x1= sa->v3->vec.x-1;
+			az->y1= sa->v3->vec.y-1;
+			az->x2= sa->v3->vec.x-HEADERY;
+			az->y2= sa->v3->vec.y-HEADERY;
+		}
+	}
 }
 
 /* called in screen_refresh, or screens_init */
@@ -293,7 +383,9 @@
 			ar->swinid= wm_subwindow_open(win, &ar->winrct);
 		else 
 			wm_subwindow_position(win, ar->swinid, &ar->winrct);
-	}
+	}
+	
+	area_azone_initialize(sa);
 }
 
 /* sa2 to sa1, we swap spaces for fullscreen to keep all allocated data */
@@ -302,7 +394,8 @@
 void area_copy_data(ScrArea *sa1, ScrArea *sa2, int swap_space)
 {
 	Panel *pa1, *pa2, *patab;
-	ARegion *ar;
+	ARegion *ar;
+	AZone *az;
 	
 	sa1->headertype= sa2->headertype;
 	sa1->spacetype= sa2->spacetype;
@@ -340,7 +433,13 @@
 	BLI_freelistN(&sa1->regionbase);
 	BLI_duplicatelist(&sa1->regionbase, &sa2->regionbase);
 	for(ar= sa1->regionbase.first; ar; ar= ar->next)
-		ar->swinid= 0;
+		ar->swinid= 0;
+	
+	/* azones */
+	BLI_freelistN(&sa1->actionzones);
+	BLI_duplicatelist(&sa1->actionzones, &sa2->actionzones);
+	for(az= sa1->actionzones.first; az; az= az->next)
+		az->flag= 0;
 	
 	/* scripts */
 	BPY_free_scriptlink(&sa1->scriptlink);

Modified: branches/blender2.5/blender/source/blender/editors/screen/screen_edit.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/screen/screen_edit.c	2008-01-17 00:28:14 UTC (rev 13263)
+++ branches/blender2.5/blender/source/blender/editors/screen/screen_edit.c	2008-01-17 05:33:54 UTC (rev 13264)
@@ -26,7 +26,8 @@
 
 #include "MEM_guardedalloc.h"
 
-#include "BLI_blenlib.h"
+#include "BLI_blenlib.h"
+#include "BLI_arithb.h"
 
 #include "BKE_global.h"
 #include "BKE_library.h"
@@ -43,8 +44,8 @@
 
 #include "ED_area.h"
 #include "ED_screen.h"
+#include "ED_screen_types.h"
 
-

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list