[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [13928] trunk/blender/source/blender/src: Bugfix:

Ton Roosendaal ton at blender.org
Sat Mar 1 15:54:18 CET 2008


Revision: 13928
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=13928
Author:   ton
Date:     2008-03-01 15:54:18 +0100 (Sat, 01 Mar 2008)

Log Message:
-----------
Bugfix:
New option "move texture channel up/down" lacked redraw calls.

Featurette:
There's still no manipulator handles for lamps to set cone size, dist, 
clipping. To save our poor Peach artists hours of work I've added a
quick method to at least be able to do it interactive.
Option is hidden behind Wkey, and uses a similar function like Scaling.
(Put mouse cursor close to start value, move mouse to center of lamp)

Ultimately this should move to custom manipulator handles...

Modified Paths:
--------------
    trunk/blender/source/blender/src/buttons_shading.c
    trunk/blender/source/blender/src/editobject.c

Modified: trunk/blender/source/blender/src/buttons_shading.c
===================================================================
--- trunk/blender/source/blender/src/buttons_shading.c	2008-03-01 12:31:00 UTC (rev 13927)
+++ trunk/blender/source/blender/src/buttons_shading.c	2008-03-01 14:54:18 UTC (rev 13928)
@@ -1947,6 +1947,7 @@
 			wrld->mtex[(int)wrld->texact] = wrld->mtex[((int)wrld->texact)-1];
 			wrld->mtex[((int)wrld->texact)-1] = mtexswap;
 			wrld->texact--;
+			allqueue(REDRAWBUTSSHADING, 0);
 		}
 		break;
 	case B_WMTEXMOVEDOWN:
@@ -1956,6 +1957,7 @@
 			wrld->mtex[(int)wrld->texact] = wrld->mtex[((int)wrld->texact)+1];
 			wrld->mtex[((int)wrld->texact)+1] = mtexswap;
 			wrld->texact++;
+			allqueue(REDRAWBUTSSHADING, 0);
 		}
 		break;
 	case B_AO_FALLOFF:
@@ -2424,6 +2426,7 @@
 			la->mtex[(int)la->texact] = la->mtex[((int)la->texact)-1];
 			la->mtex[((int)la->texact)-1] = mtexswap;
 			la->texact--;
+			allqueue(REDRAWBUTSSHADING, 0);
 		}
 		break;
 	case B_LMTEXMOVEDOWN:
@@ -2433,6 +2436,7 @@
 			la->mtex[(int)la->texact] = la->mtex[((int)la->texact)+1];
 			la->mtex[((int)la->texact)+1] = mtexswap;
 			la->texact++;
+			allqueue(REDRAWBUTSSHADING, 0);
 		}
 		break;
 	case B_LFALLOFFCHANGED:
@@ -3077,6 +3081,7 @@
 			ma->mtex[(int)ma->texact] = ma->mtex[((int)ma->texact)-1];
 			ma->mtex[((int)ma->texact)-1] = mtexswap;
 			ma->texact--;
+			allqueue(REDRAWBUTSSHADING, 0);
 		}
 		break;
 	case B_MTEXMOVEDOWN:
@@ -3085,6 +3090,7 @@
 			ma->mtex[(int)ma->texact] = ma->mtex[((int)ma->texact)+1];
 			ma->mtex[((int)ma->texact)+1] = mtexswap;
 			ma->texact++;
+			allqueue(REDRAWBUTSSHADING, 0);
 		}
 		break;
 	case B_MATZTRANSP:

Modified: trunk/blender/source/blender/src/editobject.c
===================================================================
--- trunk/blender/source/blender/src/editobject.c	2008-03-01 12:31:00 UTC (rev 13927)
+++ trunk/blender/source/blender/src/editobject.c	2008-03-01 14:54:18 UTC (rev 13928)
@@ -2216,6 +2216,149 @@
 	}
 }
 
+static void helpline(short *mval, int *center2d)
+{
+	
+	/* helpline, copied from transform.c actually */
+	persp(PERSP_WIN);
+	glDrawBuffer(GL_FRONT);
+	
+	BIF_ThemeColor(TH_WIRE);
+	
+	setlinestyle(3);
+	glBegin(GL_LINE_STRIP); 
+	glVertex2sv(mval); 
+	glVertex2iv((GLint *)center2d); 
+	glEnd();
+	setlinestyle(0);
+	
+	persp(PERSP_VIEW);
+	bglFlush(); // flush display for frontbuffer
+	glDrawBuffer(GL_BACK);
+	
+	
+}
+
+/* context: ob = lamp */
+/* code should be replaced with proper (custom) transform handles for lamp properties */
+static void spot_interactive(Object *ob, int mode)
+{
+	Lamp *la= ob->data;
+	float transfac, dx, dy, ratio, origval;
+	int keep_running= 1, center2d[2];
+	short mval[2], mvalo[2];
+	
+	getmouseco_areawin(mval);
+	getmouseco_areawin(mvalo);
+	
+	project_int(ob->obmat[3], center2d);
+	if( center2d[0] > 100000 ) {		/* behind camera */
+		center2d[0]= curarea->winx/2;
+		center2d[1]= curarea->winy/2;
+	}
+
+	helpline(mval, center2d);
+	
+	/* ratio is like scaling */
+	dx = (float)(center2d[0] - mval[0]);
+	dy = (float)(center2d[1] - mval[1]);
+	transfac = (float)sqrt( dx*dx + dy*dy);
+	if(transfac==0.0f) transfac= 1.0f;
+	
+	if(mode==1)	
+		origval= la->spotsize;
+	else if(mode==2)	
+		origval= la->dist;
+	else if(mode==3)	
+		origval= la->clipsta;
+	else	
+		origval= la->clipend;
+	
+	while (keep_running>0) {
+		
+		getmouseco_areawin(mval);
+		
+		/* essential for idling subloop */
+		if(mval[0]==mvalo[0] && mval[1]==mvalo[1]) {
+			PIL_sleep_ms(2);
+		}
+		else {
+			char str[32];
+			
+			dx = (float)(center2d[0] - mval[0]);
+			dy = (float)(center2d[1] - mval[1]);
+			ratio = (float)(sqrt( dx*dx + dy*dy))/transfac;
+			
+			/* do the trick */
+			
+			if(mode==1) {	/* spot */
+				la->spotsize = ratio*origval;
+				CLAMP(la->spotsize, 1.0f, 180.0f);
+				sprintf(str, "Spot size %.2f\n", la->spotsize);
+			}
+			else if(mode==2) {	/* dist */
+				la->dist = ratio*origval;
+				CLAMP(la->dist, 0.01f, 5000.0f);
+				sprintf(str, "Distance %.2f\n", la->dist);
+			}
+			else if(mode==3) {	/* sta */
+				la->clipsta = ratio*origval;
+				CLAMP(la->clipsta, 0.001f, 5000.0f);
+				sprintf(str, "Distance %.2f\n", la->clipsta);
+			}
+			else if(mode==4) {	/* end */
+				la->clipend = ratio*origval;
+				CLAMP(la->clipend, 0.1f, 5000.0f);
+				sprintf(str, "Clip End %.2f\n", la->clipend);
+			}
+
+			/* cleanup */
+			mvalo[0]= mval[0];
+			mvalo[1]= mval[1];
+			
+			/* DRAW */	
+			headerprint(str);
+			force_draw_plus(SPACE_BUTS, 0);
+
+			helpline(mval, center2d);
+		}
+		
+		while( qtest() ) {
+			short val;
+			unsigned short event= extern_qread(&val);
+			
+			switch (event){
+				case ESCKEY:
+				case RIGHTMOUSE:
+					keep_running= 0;
+					break;
+				case LEFTMOUSE:
+				case SPACEKEY:
+				case PADENTER:
+				case RETKEY:
+					if(val)
+						keep_running= -1;
+					break;
+			}
+		}
+	}
+
+	if(keep_running==0) {
+		if(mode==1)	
+			la->spotsize= origval;
+		else if(mode==2)	
+			la->dist= origval;
+		else if(mode==3)	
+			la->clipsta= origval;
+		else	
+			la->clipend= origval;
+	}
+
+	allqueue(REDRAWVIEW3D, 0);
+	allqueue(REDRAWBUTSSHADING, 0);
+}
+
+
 void special_editmenu(void)
 {
 	static short numcuts= 2;
@@ -2403,6 +2546,14 @@
 
 				allqueue(REDRAWVIEW3D, 0);
 			}
+			else if (ob->type == OB_LAMP) {
+				Lamp *la= ob->data;
+				if(la->type==LA_SPOT) {
+					short nr= pupmenu("Lamp Tools%t|Spot Size%x1|Distance%x2|Clip Start%x3|Clip End%x4");
+					if(nr>0)
+						spot_interactive(ob, nr);
+				}
+			}
 			else if (ob->type == OB_FONT) {
 				/* removed until this gets a decent implementation (ton) */
 /*				nr= pupmenu("Split %t|Characters%x1");





More information about the Bf-blender-cvs mailing list