[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [17975] branches/blender2.5/blender/source /blender/editors/space_view3d: 2.5

Ton Roosendaal ton at blender.org
Sat Dec 20 19:43:21 CET 2008


Revision: 17975
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=17975
Author:   ton
Date:     2008-12-20 19:43:21 +0100 (Sat, 20 Dec 2008)

Log Message:
-----------
2.5

View3D: ported selection code, another 2000 lines :)
Border select (BKEY) in 3d window now works. For lasso
and circle I have to add WM support still.

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/editors/space_view3d/drawobject.c
    branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_edit.c
    branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_header.c
    branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_intern.h
    branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_ops.c
    branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_view.c

Added Paths:
-----------
    branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_select.c

Modified: branches/blender2.5/blender/source/blender/editors/space_view3d/drawobject.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_view3d/drawobject.c	2008-12-20 17:09:45 UTC (rev 17974)
+++ branches/blender2.5/blender/source/blender/editors/space_view3d/drawobject.c	2008-12-20 18:43:21 UTC (rev 17975)
@@ -133,10 +133,9 @@
 void EM_free_index_arrays(void) {}		// XXX
 #define EM_FGON	0
 EditFace *EM_get_actFace(int x) {return NULL;} // XXX
-int em_solidoffs;	// XXX
-int em_wireoffs;
-int em_vertoffs;
 
+extern unsigned int em_vertoffs, em_solidoffs, em_wireoffs;
+
 /* check for glsl drawing */
 
 int draw_glsl_material(Scene *scene, Object *ob, View3D *v3d, int dt)
@@ -1260,6 +1259,7 @@
 		data->func(data->userData, eed, s[0][0], s[0][1], s[1][0], s[1][1], index);
 	}
 }
+
 void mesh_foreachScreenEdge(ARegion *ar, View3D *v3d, void (*func)(void *userData, EditEdge *eed, int x0, int y0, int x1, int y1, int index), void *userData, int clipVerts)
 {
 	struct { void (*func)(void *userData, EditEdge *eed, int x0, int y0, int x1, int y1, int index); void *userData; ARegion *ar; View3D *v3d; int clipVerts; float pmat[4][4], vmat[4][4]; } data;
@@ -1292,6 +1292,7 @@
 		data->func(data->userData, efa, s[0], s[1], index);
 	}
 }
+
 void mesh_foreachScreenFace(ARegion *ar, View3D *v3d, void (*func)(void *userData, EditFace *efa, int x, int y, int index), void *userData)
 {
 	struct { void (*func)(void *userData, EditFace *efa, int x, int y, int index); void *userData; ARegion *ar; View3D *v3d; float pmat[4][4], vmat[4][4]; } data;

Modified: branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_edit.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_edit.c	2008-12-20 17:09:45 UTC (rev 17974)
+++ branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_edit.c	2008-12-20 18:43:21 UTC (rev 17975)
@@ -824,7 +824,7 @@
 	else {
 		Base *base= FIRSTBASE;
 		while(base) {
-			if TESTBASE(v3d, base)  {
+			if(TESTBASE(v3d, base))  {
 				minmax_object(base->object, min, max);
 				/* account for duplis */
 				minmax_object_duplis(base->object, min, max);
@@ -894,436 +894,7 @@
 	ot->poll= ED_operator_areaactive;
 }
 
-/* ************************** mouse select ************************* */
 
-
-#define MAXPICKBUF      10000
-/* The max number of menu items in an object select menu */
-#define SEL_MENU_SIZE	22
-
-void set_active_base(Scene *scene, Base *base)
-{
-	Base *tbase;
-	
-	/* activating a non-mesh, should end a couple of modes... */
-//	if(base && base->object->type!=OB_MESH)
-// XXX		exit_paint_modes();
-	
-	/* sets scene->basact */
-	BASACT= base;
-	
-	if(base) {
-		
-		/* signals to buttons */
-//		redraw_test_buttons(base->object);
-		
-		/* signal to ipo */
-//		allqueue(REDRAWIPO, base->object->ipowin);
-		
-//		allqueue(REDRAWACTION, 0);
-//		allqueue(REDRAWNLA, 0);
-//		allqueue(REDRAWNODE, 0);
-		
-		/* signal to action */
-//		select_actionchannel_by_name(base->object->action, "Object", 1);
-		
-		/* disable temporal locks */
-		for(tbase=FIRSTBASE; tbase; tbase= tbase->next) {
-			if(base!=tbase && (tbase->object->shapeflag & OB_SHAPE_TEMPLOCK)) {
-				tbase->object->shapeflag &= ~OB_SHAPE_TEMPLOCK;
-				DAG_object_flush_update(G.scene, tbase->object, OB_RECALC_DATA);
-			}
-		}
-	}
-}
-
-
-/* simple API for object selection, rather than just using the flag
-  * this takes into account the 'restrict selection in 3d view' flag.
-  * deselect works always, the restriction just prevents selection */
-void select_base_v3d(Base *base, short mode)
-{
-	if (base) {
-		if (mode==BA_SELECT) {
-			if (!(base->object->restrictflag & OB_RESTRICT_SELECT))
-				if (mode==BA_SELECT) base->flag |= SELECT;
-		}
-		else if (mode==BA_DESELECT) {
-			base->flag &= ~SELECT;
-		}
-	}
-}
-
-static void deselectall_except(Scene *scene, Base *b)   /* deselect all except b */
-{
-	Base *base;
-	
-	for(base= FIRSTBASE; base; base= base->next) {
-		if (base->flag & SELECT) {
-			if(b!=base) {
-				select_base_v3d(base, BA_DESELECT);
-				base->object->flag= base->flag;
-			}
-		}
-	}
-}
-
-static Base *mouse_select_menu(Scene *scene, ARegion *ar, View3D *v3d, unsigned int *buffer, int hits, short *mval)
-{
-	Base *baseList[SEL_MENU_SIZE]={NULL}; /*baseList is used to store all possible bases to bring up a menu */
-	Base *base;
-	short baseCount = 0;
-	char menuText[20 + SEL_MENU_SIZE*32] = "Select Object%t";	/* max ob name = 22 */
-	char str[32];
-	
-	for(base=FIRSTBASE; base; base= base->next) {
-		if (BASE_SELECTABLE(v3d, base)) {
-			baseList[baseCount] = NULL;
-			
-			/* two selection methods, the CTRL select uses max dist of 15 */
-			if(buffer) {
-				int a;
-				for(a=0; a<hits; a++) {
-					/* index was converted */
-					if(base->selcol==buffer[ (4 * a) + 3 ]) baseList[baseCount] = base;
-				}
-			}
-			else {
-				int temp, dist=15;
-				
-				project_short(ar, v3d, base->object->obmat[3], &base->sx);
-				
-				temp= abs(base->sx -mval[0]) + abs(base->sy -mval[1]);
-				if(temp<dist ) baseList[baseCount] = base;
-			}
-			
-			if(baseList[baseCount]) {
-				if (baseCount < SEL_MENU_SIZE) {
-					baseList[baseCount] = base;
-					sprintf(str, "|%s %%x%d", base->object->id.name+2, baseCount+1);	/* max ob name == 22 */
-							strcat(menuText, str);
-							baseCount++;
-				}
-			}
-		}
-	}
-
-	if(baseCount<=1) return baseList[0];
-	else {
-		baseCount = -1; // XXX = pupmenu(menuText);
-		
-		if (baseCount != -1) { /* If nothing is selected then dont do anything */
-			return baseList[baseCount-1];
-		}
-		else return NULL;
-	}
-}
-
-/* we want a select buffer with bones, if there are... */
-/* so check three selection levels and compare */
-static short mixed_bones_object_selectbuffer(Scene *scene, ARegion *ar, View3D *v3d, unsigned int *buffer, short *mval)
-{
-	rcti rect;
-	int offs;
-	short a, hits15, hits9=0, hits5=0;
-	short has_bones15=0, has_bones9=0, has_bones5=0;
-	
-	BLI_init_rcti(&rect, mval[0]-14, mval[0]+14, mval[1]-14, mval[1]+14);
-	hits15= view3d_opengl_select(scene, ar, v3d, buffer, MAXPICKBUF, &rect);
-	if(hits15>0) {
-		for(a=0; a<hits15; a++) if(buffer[4*a+3] & 0xFFFF0000) has_bones15= 1;
-		
-		offs= 4*hits15;
-		BLI_init_rcti(&rect, mval[0]-9, mval[0]+9, mval[1]-9, mval[1]+9);
-		hits9= view3d_opengl_select(scene, ar, v3d, buffer+offs, MAXPICKBUF-offs, &rect);
-		if(hits9>0) {
-			for(a=0; a<hits9; a++) if(buffer[offs+4*a+3] & 0xFFFF0000) has_bones9= 1;
-			
-			offs+= 4*hits9;
-			BLI_init_rcti(&rect, mval[0]-5, mval[0]+5, mval[1]-5, mval[1]+5);
-			hits5= view3d_opengl_select(scene, ar, v3d, buffer+offs, MAXPICKBUF-offs, &rect);
-			if(hits5>0) {
-				for(a=0; a<hits5; a++) if(buffer[offs+4*a+3] & 0xFFFF0000) has_bones5= 1;
-			}
-		}
-		
-		if(has_bones5) {
-			offs= 4*hits15 + 4*hits9;
-			memcpy(buffer, buffer+offs, 4*offs);
-			return hits5;
-		}
-		if(has_bones9) {
-			offs= 4*hits15;
-			memcpy(buffer, buffer+offs, 4*offs);
-			return hits9;
-		}
-		if(has_bones15) {
-			return hits15;
-		}
-		
-		if(hits5>0) {
-			offs= 4*hits15 + 4*hits9;
-			memcpy(buffer, buffer+offs, 4*offs);
-			return hits5;
-		}
-		if(hits9>0) {
-			offs= 4*hits15;
-			memcpy(buffer, buffer+offs, 4*offs);
-			return hits9;
-		}
-		return hits15;
-	}
-	
-	return 0;
-}
-
-/* mval is region coords */
-static void mouse_select(Scene *scene, ARegion *ar, View3D *v3d, short *mval)
-{
-	Base *base, *startbase=NULL, *basact=NULL, *oldbasact=NULL;
-	unsigned int buffer[4*MAXPICKBUF];
-	int temp, a, dist=100;
-	short hits;
-	short ctrl=0, shift=0, alt=0;
-	
-	/* always start list from basact in wire mode */
-	startbase=  FIRSTBASE;
-	if(BASACT && BASACT->next) startbase= BASACT->next;
-	
-	/* This block uses the control key to make the object selected by its center point rather then its contents */
-	if(G.obedit==0 && ctrl) {
-		
-		/* note; shift+alt goes to group-flush-selecting */
-		if(alt && ctrl) 
-			basact= mouse_select_menu(scene, ar, v3d, NULL, 0, mval);
-		else {
-			base= startbase;
-			while(base) {
-				if (BASE_SELECTABLE(v3d, base)) {
-					project_short(ar, v3d, base->object->obmat[3], &base->sx);
-					
-					temp= abs(base->sx -mval[0]) + abs(base->sy -mval[1]);
-					if(base==BASACT) temp+=10;
-					if(temp<dist ) {
-						
-						dist= temp;
-						basact= base;
-					}
-				}
-				base= base->next;
-				
-				if(base==0) base= FIRSTBASE;
-				if(base==startbase) break;
-			}
-		}
-	}
-	else {
-		/* if objects have posemode set, the bones are in the same selection buffer */
-		
-		hits= mixed_bones_object_selectbuffer(scene, ar, v3d, buffer, mval);
-		
-		if(hits>0) {
-			int has_bones= 0;
-			
-			for(a=0; a<hits; a++) if(buffer[4*a+3] & 0xFFFF0000) has_bones= 1;
-
-			/* note; shift+alt goes to group-flush-selecting */
-			if(has_bones==0 && (alt)) 
-				basact= mouse_select_menu(scene, ar, v3d, buffer, hits, mval);
-			else {
-				static short lastmval[2]={-100, -100};
-				int donearest= 0;
-				
-				/* define if we use solid nearest select or not */
-				if(v3d->drawtype>OB_WIRE) {
-					donearest= 1;
-					if( ABS(mval[0]-lastmval[0])<3 && ABS(mval[1]-lastmval[1])<3) {
-						if(!has_bones)	/* hrms, if theres bones we always do nearest */
-							donearest= 0;
-					}
-				}
-				lastmval[0]= mval[0]; lastmval[1]= mval[1];
-				
-				if(donearest) {
-					unsigned int min= 0xFFFFFFFF;
-					int selcol= 0, notcol=0;
-					
-
-					if(has_bones) {
-						/* we skip non-bone hits */
-						for(a=0; a<hits; a++) {
-							if( min > buffer[4*a+1] && (buffer[4*a+3] & 0xFFFF0000) ) {
-								min= buffer[4*a+1];
-								selcol= buffer[4*a+3] & 0xFFFF;
-							}
-						}
-					}
-					else {
-						/* only exclude active object when it is selected... */
-						if(BASACT && (BASACT->flag & SELECT) && hits>1) notcol= BASACT->selcol;	
-					
-						for(a=0; a<hits; a++) {
-							if( min > buffer[4*a+1] && notcol!=(buffer[4*a+3] & 0xFFFF)) {
-								min= buffer[4*a+1];
-								selcol= buffer[4*a+3] & 0xFFFF;
-							}
-						}
-					}
-
-					base= FIRSTBASE;
-					while(base) {
-						if(base->lay & v3d->lay) {
-							if(base->selcol==selcol) break;
-						}
-						base= base->next;
-					}
-					if(base) basact= base;
-				}
-				else {
-					
-					base= startbase;
-					while(base) {
-						/* skip objects with select restriction, to prevent prematurely ending this loop
-						 * with an un-selectable choice */
-						if (base->object->restrictflag & OB_RESTRICT_SELECT) {

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list