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

Ton Roosendaal ton at blender.org
Wed Jan 14 13:26:46 CET 2009


Revision: 18495
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=18495
Author:   ton
Date:     2009-01-14 13:26:45 +0100 (Wed, 14 Jan 2009)

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

Another one back: editcurve.c

- removed global editNurb everywhere
  (cu->editnurb now has listbase with edit data)
- also added 'active bpoint' and 'active nurb' in
  Curve struct
- editmode in/out works, mouse/border select works

Modified Paths:
--------------
    branches/blender2.5/blender/source/Makefile
    branches/blender2.5/blender/source/blender/blenkernel/intern/curve.c
    branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c
    branches/blender2.5/blender/source/blender/editors/include/ED_object.h
    branches/blender2.5/blender/source/blender/editors/object/object_edit.c
    branches/blender2.5/blender/source/blender/editors/object/object_intern.h
    branches/blender2.5/blender/source/blender/editors/space_view3d/drawobject.c
    branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_header.c
    branches/blender2.5/blender/source/blender/editors/space_view3d/view3d_select.c
    branches/blender2.5/blender/source/blender/editors/transform/transform_conversions.c
    branches/blender2.5/blender/source/blender/editors/transform/transform_generics.c
    branches/blender2.5/blender/source/blender/editors/transform/transform_manipulator.c
    branches/blender2.5/blender/source/blender/editors/transform/transform_orientations.c
    branches/blender2.5/blender/source/blender/makesdna/DNA_curve_types.h

Added Paths:
-----------
    branches/blender2.5/blender/source/blender/editors/curve/editcurve.c
    branches/blender2.5/blender/source/blender/editors/include/ED_curve.h

Modified: branches/blender2.5/blender/source/Makefile
===================================================================
--- branches/blender2.5/blender/source/Makefile	2009-01-14 03:02:44 UTC (rev 18494)
+++ branches/blender2.5/blender/source/Makefile	2009-01-14 12:26:45 UTC (rev 18495)
@@ -238,6 +238,7 @@
 PULIB += $(OCGDIR)/blender/ed_view3d/libed_view3d.a
 PULIB += $(OCGDIR)/blender/ed_interface/libed_interface.a
 PULIB += $(OCGDIR)/blender/ed_object/libed_object.a
+PULIB += $(OCGDIR)/blender/ed_curve/libed_curve.a
 PULIB += $(OCGDIR)/blender/ed_armature/libed_armature.a
 PULIB += $(OCGDIR)/blender/ed_mesh/libed_mesh.a
 PULIB += $(OCGDIR)/blender/ed_animation/libed_animation.a

Modified: branches/blender2.5/blender/source/blender/blenkernel/intern/curve.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenkernel/intern/curve.c	2009-01-14 03:02:44 UTC (rev 18494)
+++ branches/blender2.5/blender/source/blender/blenkernel/intern/curve.c	2009-01-14 12:26:45 UTC (rev 18495)
@@ -101,6 +101,12 @@
 	BLI_freelistN(&cu->bev);
 	freedisplist(&cu->disp);
 	
+	if(cu->editnurb) {
+		freeNurblist(cu->editnurb);
+		MEM_freeN(cu->editnurb);
+		cu->editnurb= NULL;
+	}
+
 	unlink_curve(cu);
 	
 	if(cu->mat) MEM_freeN(cu->mat);

Modified: branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c
===================================================================
--- branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c	2009-01-14 03:02:44 UTC (rev 18494)
+++ branches/blender2.5/blender/source/blender/blenloader/intern/readfile.c	2009-01-14 12:26:45 UTC (rev 18495)
@@ -2490,6 +2490,7 @@
 	cu->bev.first=cu->bev.last= NULL;
 	cu->disp.first=cu->disp.last= NULL;
 	cu->editnurb= NULL;
+	cu->lastselbp= NULL;
 	cu->path= NULL;
 	cu->editstr= NULL;
 	

Copied: branches/blender2.5/blender/source/blender/editors/curve/editcurve.c (from rev 18494, trunk/blender/source/blender/src/editcurve.c)
===================================================================
--- branches/blender2.5/blender/source/blender/editors/curve/editcurve.c	                        (rev 0)
+++ branches/blender2.5/blender/source/blender/editors/curve/editcurve.c	2009-01-14 12:26:45 UTC (rev 18495)
@@ -0,0 +1,4712 @@
+/**
+ * $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) 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 *****
+ */
+
+#include <math.h>
+#include <string.h>
+
+#ifndef WIN32
+#include <unistd.h>
+#else
+#include <io.h>
+#endif
+#include <stdlib.h>
+#include "MEM_guardedalloc.h"
+
+#include "BMF_Api.h"
+
+#include "BLI_blenlib.h"
+#include "BLI_arithb.h"
+#include "BLI_dynstr.h"
+#include "BLI_rand.h"
+
+#include "DNA_curve_types.h"
+#include "DNA_ipo_types.h"
+#include "DNA_key_types.h"
+#include "DNA_mesh_types.h"
+#include "DNA_object_types.h"
+#include "DNA_scene_types.h"
+#include "DNA_screen_types.h"
+#include "DNA_space_types.h"
+#include "DNA_view3d_types.h"
+#include "DNA_userdef_types.h"
+
+#include "BKE_context.h"
+#include "BKE_curve.h"
+#include "BKE_depsgraph.h"
+#include "BKE_ipo.h"
+#include "BKE_key.h"
+#include "BKE_library.h"
+#include "BKE_global.h"
+#include "BKE_main.h"
+#include "BKE_object.h"
+#include "BKE_utildefines.h"
+
+#include "ED_anim_api.h"
+#include "ED_keyframes_edit.h"
+#include "ED_object.h"
+#include "ED_types.h"
+#include "ED_util.h"
+#include "ED_view3d.h"
+
+/* still need to eradicate a few :( */
+#define callocstructN(x,y,name) (x*)MEM_callocN((y)* sizeof(x),name)
+
+/* for curve objects in editmode that can have hidden handles - may use for IPO's later */
+#define BEZSELECTED_HIDDENHANDLES(bezt)   ((G.f & G_HIDDENHANDLES) ? (bezt)->f2 & SELECT : BEZSELECTED(bezt))
+
+/* XXX */
+static void BIF_undo_push() {}
+static void waitcursor() {}
+static void error() {}
+static int okee() {return 0;}
+static int pupmenu() {return 0;}
+static int button() {return 0;}
+static float fbutton() {return 0;}
+static void adduplicate() {}
+static void error_libdata() {}
+/* XXX */
+
+float nurbcircle[8][2]= {
+	{0.0, -1.0}, {-1.0, -1.0}, {-1.0, 0.0}, {-1.0,  1.0},
+	{0.0,  1.0}, { 1.0,  1.0}, { 1.0, 0.0}, { 1.0, -1.0}
+};
+
+ListBase *curve_get_editcurve(Object *ob)
+{
+	if(ob && ELEM(ob->type, OB_CURVE, OB_SURF)) {
+		Curve *cu= ob->data;
+		return cu->editnurb;
+	}
+	return NULL;
+}
+
+/* this replaces the active flag used in uv/face mode */
+void set_actNurb(Object *obedit, Nurb *nu)
+{
+	Curve *cu= obedit->data;
+	
+	if (nu==NULL) {
+		cu->actnu = -1;
+	} else {
+		cu->actnu = BLI_findindex(cu->editnurb, nu);
+	}
+}
+
+Nurb *get_actNurb(Object *obedit)
+{
+	Curve *cu= obedit->data;
+	
+	return BLI_findlink(cu->editnurb, cu->actnu);
+}
+
+
+/* ******************* SELECTION FUNCTIONS ********************* */
+
+#define HIDDEN			1
+#define VISIBLE			0
+
+#define FIRST			1
+#define LAST			0
+
+
+/* returns 1 in case (de)selection was successful */
+static short select_beztriple(BezTriple *bezt, short selstatus, short flag, short hidden)
+{	
+	if(bezt) {
+		if((bezt->hide==0) || (hidden==1)) {
+			if(selstatus==1) { /* selects */			
+				bezt->f1 |= flag;
+				bezt->f2 |= flag;
+				bezt->f3 |= flag;
+				return 1;			
+			}
+			else { /* deselects */	
+				bezt->f1 &= ~flag; 
+				bezt->f2 &= ~flag; 
+				bezt->f3 &= ~flag; 
+				return 1;
+			}
+		}
+	}
+	
+	return 0;
+}
+
+/* returns 1 in case (de)selection was successful */
+static short select_bpoint(BPoint *bp, short selstatus, short flag, short hidden) 
+{	
+	if(bp) {
+		if((bp->hide==0) || (hidden==1)) {
+			if(selstatus==1) {
+				bp->f1 |= flag;
+				return 1;
+			}
+			else {
+				bp->f1 &= ~flag;
+				return 1;
+			}
+		}
+	}
+
+	return 0;
+}
+
+static short swap_selection_beztriple(BezTriple *bezt)
+{
+	if(bezt->f2 & SELECT)
+		return select_beztriple(bezt, DESELECT, 1, VISIBLE);
+	else
+		return select_beztriple(bezt, SELECT, 1, VISIBLE);
+}
+
+static short swap_selection_bpoint(BPoint *bp)
+{
+	if(bp->f1 & SELECT)
+		return select_bpoint(bp, DESELECT, 1, VISIBLE);
+	else
+		return select_bpoint(bp, SELECT, 1, VISIBLE);
+}
+
+short isNurbsel(Nurb *nu)
+{
+	BezTriple *bezt;
+	BPoint *bp;
+	int a;
+
+	if((nu->type & 7)==CU_BEZIER) {
+		bezt= nu->bezt;
+		a= nu->pntsu;
+		while(a--) {
+			if( (bezt->f1 & SELECT) || (bezt->f2 & SELECT) || (bezt->f3 & SELECT) ) return 1;
+			bezt++;
+		}
+	}
+	else {
+		bp= nu->bp;
+		a= nu->pntsu*nu->pntsv;
+		while(a--) {
+			if( (bp->f1 & SELECT) ) return 1;
+			bp++;
+		}
+	}
+	return 0;
+}
+
+int isNurbsel_count(Nurb *nu)
+{
+	BezTriple *bezt;
+	BPoint *bp;
+	int a, sel=0;
+
+	if((nu->type & 7)==CU_BEZIER) {
+		bezt= nu->bezt;
+		a= nu->pntsu;
+		while(a--) {
+			if (BEZSELECTED_HIDDENHANDLES(bezt)) sel++;
+			bezt++;
+		}
+	}
+	else {
+		bp= nu->bp;
+		a= nu->pntsu*nu->pntsv;
+		while(a--) {
+			if( (bp->f1 & SELECT) ) sel++;
+			bp++;
+		}
+	}
+	return sel;
+}
+
+/* ******************* PRINTS ********************* */
+
+void printknots(Object *obedit)
+{
+	ListBase *editnurb= curve_get_editcurve(obedit);
+	Nurb *nu;
+	int a, num;
+
+	for(nu= editnurb->first; nu; nu= nu->next) {
+		if(isNurbsel(nu) &&  (nu->type & 7)==CU_NURBS) {
+			if(nu->knotsu) {
+				num= KNOTSU(nu);
+				for(a=0;a<num;a++) printf("knotu %d: %f\n", a, nu->knotsu[a]);
+			}
+			if(nu->knotsv) {
+				num= KNOTSV(nu);
+				for(a=0;a<num;a++) printf("knotv %d: %f\n", a, nu->knotsv[a]);
+			}
+		}
+	}
+}
+
+/* ********************* LOAD and MAKE *************** */
+
+/* load editNurb in object */
+void load_editNurb(Object *obedit)
+{
+	ListBase *editnurb= curve_get_editcurve(obedit);
+
+	if(obedit==NULL) return;
+
+	if (ELEM(obedit->type, OB_CURVE, OB_SURF)) {
+		Curve *cu= obedit->data;
+		Nurb *nu, *newnu;
+		KeyBlock *actkey;
+		int totvert= count_curveverts(editnurb);
+
+		/* are there keys? */
+		actkey = ob_get_keyblock(obedit);
+		if(actkey) {
+			/* active key: the vertices */
+			
+			if(totvert) {
+				if(actkey->data) MEM_freeN(actkey->data);
+			
+				actkey->data= MEM_callocN(cu->key->elemsize*totvert, "actkey->data");
+				actkey->totelem= totvert;
+		
+				curve_to_key(cu, actkey, editnurb);
+			}
+		}
+		
+		if(cu->key && actkey!=cu->key->refkey) {
+			;
+		}
+		else {
+			freeNurblist(&(cu->nurb));
+			
+			for(nu= editnurb->first; nu; nu= nu->next) {
+				newnu= duplicateNurb(nu);
+				BLI_addtail(&(cu->nurb), newnu);
+				
+				if((nu->type & 7)==CU_NURBS) {
+					clamp_nurb_order_u(nu);
+				}
+			}
+		}
+	}
+	
+	set_actNurb(obedit, NULL);
+}
+
+/* make copy in cu->editnurb */
+void make_editNurb(Object *obedit)
+{
+	ListBase *editnurb= curve_get_editcurve(obedit);
+	Nurb *nu, *newnu;
+	KeyBlock *actkey;
+
+	if(obedit==NULL) return;
+
+	if (ELEM(obedit->type, OB_CURVE, OB_SURF)) {
+		Curve *cu= obedit->data;
+		
+		if(editnurb)
+			freeNurblist(editnurb);
+		else
+			editnurb= cu->editnurb= MEM_callocN(sizeof(ListBase), "editnurb");
+		
+		nu= cu->nurb.first;
+		cu->lastselbp= NULL;   /* for select row */
+		
+		while(nu) {
+			newnu= duplicateNurb(nu);
+			test2DNurb(newnu);	// after join, or any other creation of curve
+			BLI_addtail(editnurb, newnu);
+			nu= nu->next;
+		}
+		
+		actkey = ob_get_keyblock(obedit);
+		if(actkey) {
+			strcpy(G.editModeTitleExtra, "(Key) ");
+			key_to_curve(actkey, cu, editnurb);
+		}
+	}
+	
+	set_actNurb(obedit, NULL);
+}
+
+void remake_editNurb(Object *obedit)
+{
+
+	if(okee("Reload original data")==0) return;
+	
+	make_editNurb(obedit);
+}
+
+void free_editNurb(Object *obedit)
+{
+	Curve *cu= obedit->data;
+
+	if(cu->editnurb) {
+		freeNurblist(cu->editnurb);
+		MEM_freeN(cu->editnurb);
+		cu->editnurb= NULL;
+	}
+}
+
+void separate_nurb(Scene *scene)
+{
+	Object *obedit= scene->obedit; // XXX use context
+	ListBase *editnurb= curve_get_editcurve(obedit);

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list