[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [28520] trunk/blender: Highlight last selected point in curve/surface edit mode.

Sergey Sharybin g.ulairi at gmail.com
Fri Apr 30 06:48:41 CEST 2010


Revision: 28520
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=28520
Author:   nazgul
Date:     2010-04-30 06:48:40 +0200 (Fri, 30 Apr 2010)

Log Message:
-----------
Highlight last selected point in curve/surface edit mode.

Curve->lastselbp field was renamed to Curve->lastsel and now not last
either BPoint or BezTriple is storing here. It's not easy to determine
type of selected point, but operator which depends on such point reviews
the full nurbs, so this shouldn't be a problem.

Made changes to curve undo stuff to restore last selected point on undo/redo.

Added new theme color for curve last selected point.

Modified Paths:
--------------
    trunk/blender/release/scripts/ui/space_userpref.py
    trunk/blender/source/blender/blenloader/intern/readfile.c
    trunk/blender/source/blender/editors/curve/editcurve.c
    trunk/blender/source/blender/editors/include/UI_resources.h
    trunk/blender/source/blender/editors/interface/resources.c
    trunk/blender/source/blender/editors/space_view3d/drawobject.c
    trunk/blender/source/blender/editors/space_view3d/view3d_select.c
    trunk/blender/source/blender/makesdna/DNA_curve_types.h
    trunk/blender/source/blender/makesdna/DNA_userdef_types.h
    trunk/blender/source/blender/makesrna/intern/rna_userdef.c

Modified: trunk/blender/release/scripts/ui/space_userpref.py
===================================================================
--- trunk/blender/release/scripts/ui/space_userpref.py	2010-04-30 01:22:21 UTC (rev 28519)
+++ trunk/blender/release/scripts/ui/space_userpref.py	2010-04-30 04:48:40 UTC (rev 28520)
@@ -612,6 +612,7 @@
             col.prop(v3d, "handle_sel_vect")
             col.prop(v3d, "handle_sel_align")
             col.prop(v3d, "act_spline")
+            col.prop(v3d, "lastsel_point")
 
             col = split.column()
             col.prop(v3d, "vertex")

Modified: trunk/blender/source/blender/blenloader/intern/readfile.c
===================================================================
--- trunk/blender/source/blender/blenloader/intern/readfile.c	2010-04-30 01:22:21 UTC (rev 28519)
+++ trunk/blender/source/blender/blenloader/intern/readfile.c	2010-04-30 04:48:40 UTC (rev 28520)
@@ -2754,7 +2754,7 @@
 	cu->bev.first=cu->bev.last= NULL;
 	cu->disp.first=cu->disp.last= NULL;
 	cu->editnurb= NULL;
-	cu->lastselbp= NULL;
+	cu->lastsel= NULL;
 	cu->path= NULL;
 	cu->editfont= NULL;
 	

Modified: trunk/blender/source/blender/editors/curve/editcurve.c
===================================================================
--- trunk/blender/source/blender/editors/curve/editcurve.c	2010-04-30 01:22:21 UTC (rev 28519)
+++ trunk/blender/source/blender/editors/curve/editcurve.c	2010-04-30 04:48:40 UTC (rev 28520)
@@ -75,6 +75,12 @@
 #include "RNA_access.h"
 #include "RNA_define.h"
 
+/* Undo stuff */
+typedef struct {
+	ListBase nubase;
+	void *lastsel;
+} UndoCurve;
+
 void selectend_nurb(Object *obedit, short selfirst, short doswap, short selstatus);
 static void select_adjacent_cp(ListBase *editnurb, short next, short cont, short selstatus);
 
@@ -324,7 +330,7 @@
 			editnurb= cu->editnurb= MEM_callocN(sizeof(ListBase), "editnurb");
 		
 		nu= cu->nurb.first;
-		cu->lastselbp= NULL;   /* for select row */
+		cu->lastsel= NULL;   /* for select row */
 		
 		while(nu) {
 			newnu= duplicateNurb(nu);
@@ -389,6 +395,8 @@
 		BezTriple *bezt;
 		int a;
 
+		cu->lastsel= NULL;
+
 		for(nu= editnurb->first; nu; nu= nu->next) {
 			if(nu->type == CU_BEZIER) {
 				bezt= nu->bezt;
@@ -654,7 +662,7 @@
 	if(obedit && obedit->type==OB_SURF);
 	else return OPERATOR_CANCELLED;
 
-	cu->lastselbp= NULL;
+	cu->lastsel= NULL;
 
 	nu= editnurb->first;
 	while(nu) {
@@ -887,9 +895,12 @@
 	Nurb *nu, *newnu;
 	BezTriple *bezt, *bezt1;
 	BPoint *bp, *bp1;
+	Curve *cu= (Curve*)obedit->data;
 	int a, b, starta, enda, newu, newv;
 	char *usel;
 
+	cu->lastsel= NULL;
+
 	nu= editnurb->last;
 	while(nu) {
 		if(nu->type == CU_BEZIER) {
@@ -1499,11 +1510,15 @@
 	Nurb *nu;
 	BPoint *bp;
 	BezTriple *bezt;
+	Curve *cu;
 	int a;
 	short sel;
-	
+
 	if(obedit==0) return;
-	
+
+	cu= (Curve*)obedit->data;
+	cu->lastsel= NULL;
+
 	for(nu= editnurb->first; nu; nu= nu->next) {
 		sel= 0;
 		if(nu->type == CU_BEZIER) {
@@ -1819,6 +1834,8 @@
 	BezTriple *bezt;
 	int a;
 
+	cu->lastsel= NULL;
+
 	for(nu= editnurb->first; nu; nu= nu->next) {
 		if(nu->type == CU_BEZIER) {
 			bezt= nu->bezt;
@@ -3183,12 +3200,18 @@
 
 			if(bezt) {
 
-				if(hand==1) select_beztriple(bezt, SELECT, 1, HIDDEN);
-				else if(hand==0) bezt->f1|= SELECT;
-				else bezt->f3|= SELECT;
+				if(hand==1) {
+					select_beztriple(bezt, SELECT, 1, HIDDEN);
+					cu->lastsel= bezt;
+				} else {
+					if(hand==0) bezt->f1|= SELECT;
+					else bezt->f3|= SELECT;
+
+					cu->lastsel= NULL;
+				}
 			}
 			else {
-				cu->lastselbp= bp;
+				cu->lastsel= bp;
 				select_bpoint(bp, SELECT, 1, HIDDEN);
 			}
 
@@ -3196,8 +3219,13 @@
 		else {
 			if(bezt) {
 				if(hand==1) {
-					if(bezt->f2 & SELECT) select_beztriple(bezt, DESELECT, 1, HIDDEN);
-					else select_beztriple(bezt, SELECT, 1, HIDDEN);
+					if(bezt->f2 & SELECT) {
+						select_beztriple(bezt, DESELECT, 1, HIDDEN);
+						if (bezt == cu->lastsel) cu->lastsel = NULL;
+					} else {
+						select_beztriple(bezt, SELECT, 1, HIDDEN);
+						cu->lastsel= bezt;
+					}
 				} else if(hand==0) {
 					bezt->f1 ^= SELECT;
 				} else {
@@ -3205,10 +3233,12 @@
 				}
 			}
 			else {
-				if(bp->f1 & SELECT) select_bpoint(bp, DESELECT, 1, HIDDEN);
-				else {
+				if(bp->f1 & SELECT) {
+					select_bpoint(bp, DESELECT, 1, HIDDEN);
+					if (cu->lastsel == bp) cu->lastsel = NULL;
+				} else {
 					select_bpoint(bp, SELECT, 1, HIDDEN);
-					cu->lastselbp= bp;
+					cu->lastsel= bp;
 				}
 			}
 
@@ -3813,7 +3843,7 @@
 
 	if(editnurb->first==0)
 		return OPERATOR_CANCELLED;
-	if(cu->lastselbp==NULL)
+	if(cu->lastsel==NULL)
 		return OPERATOR_CANCELLED;
 
 	/* find the correct nurb and toggle with u of v */
@@ -3821,7 +3851,7 @@
 		bp= nu->bp;
 		for(v=0; v<nu->pntsv; v++) {
 			for(u=0; u<nu->pntsu; u++, bp++) {
-				if(bp==cu->lastselbp) {
+				if(bp==cu->lastsel) {
 					if(bp->f1 & SELECT) {
 						ok= 1;
 						break;
@@ -3832,11 +3862,11 @@
 		}
 
 		if(ok) {
-			if(last==cu->lastselbp) {
+			if(last==cu->lastsel) {
 				direction= 1-direction;
 				setflagsNurb(editnurb, 0);
 			}
-			last= cu->lastselbp;
+			last= cu->lastsel;
 
 			bp= nu->bp;
 			for(a=0; a<nu->pntsv; a++) {
@@ -5190,49 +5220,87 @@
 
 /****************** undo for curves ****************/
 
-static void undoCurve_to_editCurve(void *lbu, void *lbe)
+static void *undo_check_lastsel(void *lastsel, Nurb *nu, Nurb *newnu)
 {
-	ListBase *lb= lbu;
-	ListBase *editnurb= lbe;
+	if (nu->bezt) {
+		BezTriple *lastbezt= (BezTriple*)lastsel;
+		if (lastbezt >= nu->bezt && lastbezt < nu->bezt + nu->pntsu) {
+			return newnu->bezt + (lastbezt - nu->bezt);
+		}
+	} else {
+		BPoint *lastbp= (BPoint*)lastsel;
+		if (lastbp >= nu->bp && lastbp < nu->bp + nu->pntsu*nu->pntsv) {
+			return newnu->bp + (lastbp - nu->bp);
+		}
+	}
+
+	return NULL;
+}
+
+static void undoCurve_to_editCurve(void *ucu, void *cue)
+{
+	Curve *cu= cue;
+	UndoCurve *undoCurve= ucu;
+	ListBase *undobase= &undoCurve->nubase;
+	ListBase *editbase= cu->editnurb;
 	Nurb *nu, *newnu;
-	
-	freeNurblist(editnurb);
+	void *lastsel= NULL;
 
+	freeNurblist(editbase);
+
 	/* copy  */
-	for(nu= lb->first; nu; nu= nu->next) {
+	for(nu= undobase->first; nu; nu= nu->next) {
 		newnu= duplicateNurb(nu);
-		BLI_addtail(editnurb, newnu);
+
+		if (lastsel == NULL) {
+			lastsel= undo_check_lastsel(undoCurve->lastsel, nu, newnu);
+		}
+
+		BLI_addtail(editbase, newnu);
 	}
+
+	cu->lastsel= lastsel;
 }
 
-static void *editCurve_to_undoCurve(void *lbe)
+static void *editCurve_to_undoCurve(void *cue)
 {
-	ListBase *editnurb= lbe;
-	ListBase *lb;
+	Curve *cu= cue;
+	ListBase *nubase= cu->editnurb;
+	UndoCurve *undoCurve;
 	Nurb *nu, *newnu;
+	void *lastsel= NULL;
 
-	lb= MEM_callocN(sizeof(ListBase), "listbase undo");
-	
+	undoCurve= MEM_callocN(sizeof(UndoCurve), "undoCurve");
+
 	/* copy  */
-	for(nu= editnurb->first; nu; nu= nu->next) {
+	for(nu= nubase->first; nu; nu= nu->next) {
 		newnu= duplicateNurb(nu);
-		BLI_addtail(lb, newnu);
+
+		if (lastsel == NULL) {
+			lastsel= undo_check_lastsel(cu->lastsel, nu, newnu);
+		}
+
+		BLI_addtail(&undoCurve->nubase, newnu);
 	}
-	return lb;
+
+	undoCurve->lastsel= lastsel;
+
+	return undoCurve;
 }
 
-static void free_undoCurve(void *lbv)
+static void free_undoCurve(void *ucv)
 {
-	ListBase *lb= lbv;
-	
-	freeNurblist(lb);
-	MEM_freeN(lb);
+	UndoCurve *undoCurve= ucv;
+
+	freeNurblist(&undoCurve->nubase);
+
+	MEM_freeN(undoCurve);
 }
 
 static void *get_data(bContext *C)
 {
 	Object *obedit= CTX_data_edit_object(C);
-	return curve_get_editcurve(obedit);
+	return obedit->data;
 }
 
 /* and this is all the undo system needs to know */

Modified: trunk/blender/source/blender/editors/include/UI_resources.h
===================================================================
--- trunk/blender/source/blender/editors/include/UI_resources.h	2010-04-30 01:22:21 UTC (rev 28519)
+++ trunk/blender/source/blender/editors/include/UI_resources.h	2010-04-30 04:48:40 UTC (rev 28520)
@@ -180,6 +180,7 @@
 	TH_HANDLE_SEL_ALIGN,
 
 	TH_ACTIVE_SPLINE,
+	TH_LASTSEL_POINT,
 
 	TH_SYNTAX_B,
 	TH_SYNTAX_V,

Modified: trunk/blender/source/blender/editors/interface/resources.c
===================================================================
--- trunk/blender/source/blender/editors/interface/resources.c	2010-04-30 01:22:21 UTC (rev 28519)
+++ trunk/blender/source/blender/editors/interface/resources.c	2010-04-30 04:48:40 UTC (rev 28520)
@@ -309,6 +309,8 @@
 				cp= ts->nurb_sel_vline; break;
 			case TH_ACTIVE_SPLINE:
 				cp= ts->act_spline; break;
+			case TH_LASTSEL_POINT:
+				cp= ts->lastsel_point; break;
 			case TH_HANDLE_FREE:
 				cp= ts->handle_free; break;
 			case TH_HANDLE_AUTO:
@@ -530,6 +532,7 @@
 	SETCOL(btheme->tv3d.handle_sel_align, 0xf0, 0x90, 0xa0, 255);
 
 	SETCOL(btheme->tv3d.act_spline, 0xdb, 0x25, 0x12, 255);
+	SETCOL(btheme->tv3d.lastsel_point,  0xff, 0xff, 0xff, 255);
 
 	SETCOL(btheme->tv3d.bone_solid, 200, 200, 200, 255);
 	SETCOL(btheme->tv3d.bone_pose, 80, 200, 255, 80);               // alpha 80 is not meant editable, used for wire+action draw
@@ -1451,7 +1454,15 @@
 			SETCOLF(btheme->tv3d.edge_crease, 0.8, 0, 0.6, 1.0);
 		}
 	}
+	if (G.main->versionfile <= 252) {
+		bTheme *btheme;
 
+		/* init new curve colors */
+		for(btheme= U.themes.first; btheme; btheme= btheme->next) {
+			if (btheme->tv3d.lastsel_point[3] == 0)
+				SETCOL(btheme->tv3d.lastsel_point, 0xff, 0xff, 0xff, 255);
+		}
+	}
 	
 	/* GL Texture Garbage Collection (variable abused above!) */
 	if (U.textimeout == 0) {

Modified: trunk/blender/source/blender/editors/space_view3d/drawobject.c
===================================================================
--- trunk/blender/source/blender/editors/space_view3d/drawobject.c	2010-04-30 01:22:21 UTC (rev 28519)
+++ trunk/blender/source/blender/editors/space_view3d/drawobject.c	2010-04-30 04:48:40 UTC (rev 28520)
@@ -4405,18 +4405,20 @@
 	glLineWidth(1);
 }
 
-static void tekenvertsN(Nurb *nu, short sel, short hide_handles)
+static void tekenvertsN(Nurb *nu, short sel, short hide_handles, void *lastsel)
 {
 	BezTriple *bezt;
 	BPoint *bp;
 	float size;
-	int a;
+	int a, color;
 
 	if(nu->hide) return;
 
-	if(sel) UI_ThemeColor(TH_VERTEX_SELECT);
-	else UI_ThemeColor(TH_VERTEX);
+	if(sel) color= TH_VERTEX_SELECT;
+	else color= TH_VERTEX;
 
+	UI_ThemeColor(color);
+
 	size= UI_GetThemeValuef(TH_VERTEX_SIZE);
 	glPointSize(size);
 	
@@ -4428,7 +4430,17 @@
 		a= nu->pntsu;
 		while(a--) {
 			if(bezt->hide==0) {
-				if (hide_handles) {
+				if (bezt == lastsel) {
+					UI_ThemeColor(TH_LASTSEL_POINT);
+					bglVertex3fv(bezt->vec[1]);
+
+					if (!hide_handles) {

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list