[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [29843] branches/nurbs25/source/blender: Shapekeys for curves/surfeces

Sergey Sharybin g.ulairi at gmail.com
Thu Jul 1 13:37:52 CEST 2010


Revision: 29843
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=29843
Author:   nazgul
Date:     2010-07-01 13:37:51 +0200 (Thu, 01 Jul 2010)

Log Message:
-----------
Shapekeys for curves/surfeces

Added full support of shape keys for curves and nurbs surfaces including
topology changing in edit mode, undo stuff, updating relative keys when
working under basis and so on.

This commit also fixes issue #21498: Edit curve Shape key /252_r 27318

Modified Paths:
--------------
    branches/nurbs25/source/blender/blenkernel/BKE_curve.h
    branches/nurbs25/source/blender/blenkernel/intern/anim.c
    branches/nurbs25/source/blender/blenkernel/intern/curve.c
    branches/nurbs25/source/blender/blenkernel/intern/displist.c
    branches/nurbs25/source/blender/blenkernel/intern/key.c
    branches/nurbs25/source/blender/blenkernel/intern/object.c
    branches/nurbs25/source/blender/editors/curve/editcurve.c
    branches/nurbs25/source/blender/editors/include/ED_curve.h
    branches/nurbs25/source/blender/editors/render/render_shading.c
    branches/nurbs25/source/blender/editors/space_info/info_stats.c
    branches/nurbs25/source/blender/editors/space_view3d/drawobject.c
    branches/nurbs25/source/blender/editors/space_view3d/view3d_buttons.c
    branches/nurbs25/source/blender/editors/space_view3d/view3d_snap.c
    branches/nurbs25/source/blender/editors/transform/transform_conversions.c
    branches/nurbs25/source/blender/editors/transform/transform_generics.c
    branches/nurbs25/source/blender/editors/transform/transform_manipulator.c
    branches/nurbs25/source/blender/editors/transform/transform_orientations.c
    branches/nurbs25/source/blender/makesdna/DNA_curve_types.h
    branches/nurbs25/source/blender/makesrna/intern/rna_curve.c
    branches/nurbs25/source/blenderplayer/bad_level_call_stubs/stubs.c

Modified: branches/nurbs25/source/blender/blenkernel/BKE_curve.h
===================================================================
--- branches/nurbs25/source/blender/blenkernel/BKE_curve.h	2010-07-01 11:37:39 UTC (rev 29842)
+++ branches/nurbs25/source/blender/blenkernel/BKE_curve.h	2010-07-01 11:37:51 UTC (rev 29843)
@@ -108,5 +108,7 @@
 int clamp_nurb_order_u( struct Nurb *nu);
 int clamp_nurb_order_v( struct Nurb *nu);
 
+ListBase *BKE_curve_nurbs(struct Curve *cu);
+
 #endif
 

Modified: branches/nurbs25/source/blender/blenkernel/intern/anim.c
===================================================================
--- branches/nurbs25/source/blender/blenkernel/intern/anim.c	2010-07-01 11:37:39 UTC (rev 29842)
+++ branches/nurbs25/source/blender/blenkernel/intern/anim.c	2010-07-01 11:37:51 UTC (rev 29843)
@@ -80,6 +80,8 @@
 #include <config.h>
 #endif
 
+#include "ED_curve.h" /* for ED_curve_nurbs */
+
 // XXX bad level call...
 #include "ED_mesh.h"
 
@@ -391,17 +393,17 @@
 	float *fp, *dist, *maxdist, xyz[3];
 	float fac, d=0, fac1, fac2;
 	int a, tot, cycl=0;
+	ListBase *nurbs;
 	
 	/* in a path vertices are with equal differences: path->len = number of verts */
 	/* NOW WITH BEVELCURVE!!! */
 	
 	if(ob==NULL || ob->type != OB_CURVE) return;
 	cu= ob->data;
-	if(cu->editnurb) 
-		nu= cu->editnurb->first;
-	else 
-		nu= cu->nurb.first;
-	
+
+	nurbs= BKE_curve_nurbs(cu);
+	nu= nurbs->first;
+
 	if(cu->path) free_path(cu->path);
 	cu->path= NULL;
 	

Modified: branches/nurbs25/source/blender/blenkernel/intern/curve.c
===================================================================
--- branches/nurbs25/source/blender/blenkernel/intern/curve.c	2010-07-01 11:37:39 UTC (rev 29842)
+++ branches/nurbs25/source/blender/blenkernel/intern/curve.c	2010-07-01 11:37:51 UTC (rev 29843)
@@ -66,6 +66,8 @@
 #include "BKE_utildefines.h"  // VECCOPY
 
 #include "nurbana.h"
+#include "ED_curve.h"
+
 /* globals */
 
 /* local */
@@ -112,13 +114,8 @@
 	BLI_freelistN(&cu->bev);
 	freedisplist(&cu->disp);
 	BKE_free_editfont(cu);
-	
-	if(cu->editnurb) {
-		freeNurblist(cu->editnurb);
-		MEM_freeN(cu->editnurb);
-		cu->editnurb= NULL;
-	}
 
+	free_curve_editNurb(cu);
 	unlink_curve(cu);
 	BKE_free_animdata((ID *)cu);
 	
@@ -1894,8 +1891,10 @@
 	/* STEP 1: MAKE POLYS  */
 
 	BLI_freelistN(&(cu->bev));
-	if(cu->editnurb && ob->type!=OB_FONT) nu= cu->editnurb->first;
-	else nu= cu->nurb.first;
+	if(cu->editnurb && ob->type!=OB_FONT) {
+		ListBase *nurbs= ED_curve_editnurbs(cu);
+		nu= nurbs->first;
+	} else nu= cu->nurb.first;
 	
 	while(nu) {
 		
@@ -2881,7 +2880,7 @@
 				VECCOPY(co, key); co+=3; key+=3;
 				VECCOPY(co, key); co+=3; key+=3;
 				VECCOPY(co, key); co+=3; key+=3;
-				key++; /* skip tilt */
+				key+=3; /* skip tilt */
 			}
 		}
 		else {
@@ -2981,5 +2980,12 @@
 	return change;
 }
 
+/* Get edit nurbs or normal nurbs list */
+ListBase *BKE_curve_nurbs(Curve *cu)
+{
+	if (cu->editnurb) {
+		return ED_curve_editnurbs(cu);
+	}
 
-
+	return &cu->nurb;
+}

Modified: branches/nurbs25/source/blender/blenkernel/intern/displist.c
===================================================================
--- branches/nurbs25/source/blender/blenkernel/intern/displist.c	2010-07-01 11:37:39 UTC (rev 29842)
+++ branches/nurbs25/source/blender/blenkernel/intern/displist.c	2010-07-01 11:37:51 UTC (rev 29843)
@@ -1,6 +1,6 @@
 /*  displist.c
- * 
- * 
+ *
+ *
  * $Id$
  *
  * ***** BEGIN GPL LICENSE BLOCK *****
@@ -89,6 +89,7 @@
 
 #include "BLO_sys_types.h" // for intptr_t support
 
+#include "ED_curve.h" /* for BKE_curve_nurbs */
 
 static void boundbox_displist(Object *ob);
 
@@ -120,7 +121,7 @@
 DispList *find_displist_create(ListBase *lb, int type)
 {
 	DispList *dl;
-	
+
 	dl= lb->first;
 	while(dl) {
 		if(dl->type==type) return dl;
@@ -137,7 +138,7 @@
 DispList *find_displist(ListBase *lb, int type)
 {
 	DispList *dl;
-	
+
 	dl= lb->first;
 	while(dl) {
 		if(dl->type==type) return dl;
@@ -160,12 +161,12 @@
 void copy_displist(ListBase *lbn, ListBase *lb)
 {
 	DispList *dln, *dl;
-	
+
 	lbn->first= lbn->last= 0;
-	
+
 	dl= lb->first;
 	while(dl) {
-		
+
 		dln= MEM_dupallocN(dl);
 		BLI_addtail(lbn, dln);
 		dln->verts= MEM_dupallocN(dl->verts);
@@ -173,7 +174,7 @@
 		dln->index= MEM_dupallocN(dl->index);
 		dln->col1= MEM_dupallocN(dl->col1);
 		dln->col2= MEM_dupallocN(dl->col2);
-		
+
 		dl= dl->next;
 	}
 }
@@ -193,7 +194,7 @@
 	Nurb* nu = NULL;
 
 	dl= lb->first;
-	
+
 	while(dl) {
 		if(dl->type==DL_INDEX3) {
 			if(dl->nors==NULL) {
@@ -257,10 +258,10 @@
 void count_displist(ListBase *lb, int *totvert, int *totface)
 {
 	DispList *dl;
-	
+
 	dl= lb->first;
 	while(dl) {
-		
+
 		switch(dl->type) {
 			case DL_SURF:
 				*totvert+= dl->nr*dl->parts;
@@ -275,7 +276,7 @@
 			case DL_SEGM:
 				*totvert+= dl->nr*dl->parts;
 		}
-		
+
 		dl= dl->next;
 	}
 }
@@ -285,7 +286,7 @@
 	if((dl->flag & DL_CYCL_V)==0 && a==(dl->parts)-1) {
 		return 0;
 	}
-	
+
 	if(dl->flag & DL_CYCL_U) {
 		(*p1)= dl->nr*a;
 		(*p2)= (*p1)+ dl->nr-1;
@@ -299,12 +300,12 @@
 		(*p3)= (*p1)+ dl->nr;
 		(*b)= 1;
 	}
-	
+
 	if( (dl->flag & DL_CYCL_V) && a==dl->parts-1) {			    \
 		(*p3)-= dl->nr*dl->parts;				    \
 		(*p4)-= dl->nr*dl->parts;				    \
 	}
-	
+
 	return 1;
 }
 
@@ -329,17 +330,17 @@
 #if 0
 	/* XXX ugly global still, but we can't do preview while rendering */
 	if(G.rendering==0) {
-		
+
 		Render *re= RE_GetRender("_Shade View_");
 		if(re==NULL) {
 			re= RE_NewRender("_Shade View_");
-		
+
 			RE_Database_Baking(re, scene, 0, 0);	/* 0= no faces */
 		}
 		return re;
 	}
 #endif
-	
+
 	return NULL;
 }
 
@@ -347,7 +348,7 @@
 void fastshade_free_render(void)
 {
 	Render *re= RE_GetRender("_Shade View_");
-	
+
 	if(re) {
 		RE_Database_Free(re);
 		RE_FreeRender(re);
@@ -355,7 +356,7 @@
 }
 
 static int fastshade_customdata_layer_num(int n, int active)
-{   
+{
 	/* make the active layer the first */
 	if (n == active) return 0;
 	else if (n < active) return n+1;
@@ -374,7 +375,7 @@
 
 	for(index=0; index<fdata->totlayer; index++) {
 		layer= &fdata->layers[index];
-		
+
 		if(needuv && layer->type == CD_MTFACE && shi.totuv < MAX_MTFACE) {
 			n= fastshade_customdata_layer_num(shi.totuv, layer->active_rnd);
 			mtface= &((MTFace*)layer->data)[a];
@@ -410,17 +411,17 @@
 {
 	ShadeResult shr;
 	int a;
-	
+
 	VECCOPY(shi.co, co);
 	shi.vn[0]= -nor[0];
 	shi.vn[1]= -nor[1];
 	shi.vn[2]= -nor[2];
 	VECCOPY(shi.vno, shi.vn);
 	VECCOPY(shi.facenor, shi.vn);
-	
+
 	if(ma->texco) {
 		VECCOPY(shi.lo, orco);
-		
+
 		if(ma->texco & TEXCO_GLOB) {
 			VECCOPY(shi.gl, shi.lo);
 		}
@@ -443,25 +444,25 @@
 			shi.ref[2]= (-1.0+inp*shi.vn[2]);
 		}
 	}
-	
+
 	shi.mat= ma;	/* set each time... node shaders change it */
 	RE_shade_external(NULL, &shi, &shr);
-	
+
 	a= 256.0f*(shr.combined[0]);
 	col1[0]= CLAMPIS(a, 0, 255);
 	a= 256.0f*(shr.combined[1]);
 	col1[1]= CLAMPIS(a, 0, 255);
 	a= 256.0f*(shr.combined[2]);
 	col1[2]= CLAMPIS(a, 0, 255);
-	
+
 	if(col2) {
 		shi.vn[0]= -shi.vn[0];
 		shi.vn[1]= -shi.vn[1];
 		shi.vn[2]= -shi.vn[2];
-		
+
 		shi.mat= ma;	/* set each time... node shaders change it */
 		RE_shade_external(NULL, &shi, &shr);
-		
+
 		a= 256.0f*(shr.combined[0]);
 		col2[0]= CLAMPIS(a, 0, 255);
 		a= 256.0f*(shr.combined[1]);
@@ -476,20 +477,20 @@
 	float tmat[4][4];
 	float amb[3]= {0.0f, 0.0f, 0.0f};
 	int a;
-	
+
 	/* initialize globals in render */
 	RE_shade_external(re, NULL, NULL);
 
 	/* initialize global here */
 	init_fastshade_shadeinput(re);
-	
+
 	RE_DataBase_GetView(re, tmat);
 	mul_m4_m4m4(mat, ob->obmat, tmat);
-	
+
 	invert_m4_m4(tmat, mat);
 	copy_m3_m4(imat, tmat);
 	if(ob->transflag & OB_NEG_SCALE) mul_m3_fl(imat, -1.0);
-	
+
 	if (need_orco_r) *need_orco_r= 0;
 	for(a=0; a<ob->totcol; a++) {
 		Material *ma= give_current_material(ob, a+1);
@@ -506,7 +507,7 @@
 static void end_fastshade_for_ob(Object *ob)
 {
 	int a;
-	
+
 	for(a=0; a<ob->totcol; a++) {
 		Material *ma= give_current_material(ob, a+1);
 		if(ma)
@@ -537,7 +538,7 @@
 		dm = mesh_get_derived_deform(RE_GetScene(re), ob, dataMask);
 	else
 		dm = mesh_get_derived_final(RE_GetScene(re), ob, dataMask);
-	
+
 	mvert = dm->getVertArray(dm);
 	mface = dm->getFaceArray(dm);
 	nors = dm->getFaceDataArray(dm, CD_NORMAL);
@@ -555,7 +556,7 @@
 			col2 = MEM_mallocN(sizeof(*col2)*totface*4, "col2");
 		else
 			col2 = NULL;
-		
+
 		if (col2_r) *col2_r = col2;
 	}
 
@@ -564,16 +565,16 @@
 	for (a=0; a<totvert; a++) {
 		MVert *mv = &mvert[a];
 		float *vn= &vnors[a*3];
-		float xn= mv->no[0]; 
-		float yn= mv->no[1]; 
+		float xn= mv->no[0];
+		float yn= mv->no[1];
 		float zn= mv->no[2];
-		
+
 			/* transpose ! */
 		vn[0]= imat[0][0]*xn+imat[0][1]*yn+imat[0][2]*zn;
 		vn[1]= imat[1][0]*xn+imat[1][1]*yn+imat[1][2]*zn;
 		vn[2]= imat[2][0]*xn+imat[2][1]*yn+imat[2][2]*zn;
 		normalize_v3(vn);
-	}		
+	}
 
 	for (i=0; i<totface; i++) {
 		extern Material defmaterial;	/* material.c */
@@ -583,9 +584,9 @@
 		unsigned char *col1base= (unsigned char*) &col1[i*4];
 		unsigned char *col2base= (unsigned char*) (col2?&col2[i*4]:NULL);
 		float nor[3], n1[3];
-		
+
 		if(ma==NULL) ma= &defmaterial;
-		
+
 		vidx[0]= mf->v1;
 		vidx[1]= mf->v2;
 		vidx[2]= mf->v3;
@@ -610,7 +611,7 @@
 			char *col1= (char*)&col1base[j*4];
 			char *col2= (char*)(col2base?&col2base[j*4]:NULL);
 			float *vn = (mf->flag & ME_SMOOTH)?&vnors[3*vidx[j]]:n1;
-			
+
 			VECCOPY(vec, mv->co);
 			mul_m4_v3(mat, vec);
 			vec[0]+= 0.001*vn[0];
@@ -620,7 +621,7 @@
 			fastshade_customdata(&dm->faceData, i, j, ma);
 			fastshade(vec, vn, orco?&orco[vidx[j]*3]:mv->co, ma, col1, col2);
 		}
-	} 
+	}
 	MEM_freeN(vnors);
 
 	dm->release(dm);
@@ -634,7 +635,7 @@
 	int a;
 	char *cp;
 	unsigned int *mcol= (unsigned int*)me->mcol;
-	
+
 	if(re) {
 		mesh_create_shadedColors(re, ob, 1, &mcol, NULL);
 		me->mcol= (MCol*)mcol;
@@ -660,11 +661,11 @@
 	float *fp, *nor, n1[3];
 	unsigned int *col1;
 	int a, need_orco;
-	
+
 	re= fastshade_get_render(scene);
 	if(re==NULL)
 		return;
-	
+
 	dl = find_displist(&ob->disp, DL_VERTCOL);
 	if (dl) {
 		BLI_remlink(&ob->disp, dl);
@@ -684,33 +685,33 @@
 	else {
 
 		init_fastshade_for_ob(re, ob, &need_orco, mat, imat);
-		
+
 		if (ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT)) {
-		
+
 			/* now we need the normals */
 			cu= ob->data;
 			dl= cu->disp.first;
-			
+
 			while(dl) {
 				extern Material defmaterial;	/* material.c */
-				
+
 				dlob= MEM_callocN(sizeof(DispList), "displistshade");
 				BLI_addtail(&ob->disp, dlob);
 				dlob->type= DL_VERTCOL;
 				dlob->parts= dl->parts;
 				dlob->nr= dl->nr;
-				
+
 				if(dl->type==DL_INDEX3) {
 					col1= dlob->col1= MEM_mallocN(sizeof(int)*dl->nr, "col1");
 				}
 				else {

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list