[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [43852] trunk/blender: Added option to fill caps of bevelled curves.

Sergey Sharybin sergey.vfx at gmail.com
Thu Feb 2 16:15:58 CET 2012


Revision: 43852
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=43852
Author:   nazgul
Date:     2012-02-02 15:15:52 +0000 (Thu, 02 Feb 2012)
Log Message:
-----------
Added option to fill caps of bevelled curves.

It can be found in Shape panel below Fill label. If this option is enabled,
caps of curve will be filled.

Modified Paths:
--------------
    trunk/blender/release/scripts/startup/bl_ui/properties_data_curve.py
    trunk/blender/source/blender/blenkernel/intern/displist.c
    trunk/blender/source/blender/makesdna/DNA_curve_types.h
    trunk/blender/source/blender/makesrna/intern/rna_curve.c

Modified: trunk/blender/release/scripts/startup/bl_ui/properties_data_curve.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_ui/properties_data_curve.py	2012-02-02 14:07:24 UTC (rev 43851)
+++ trunk/blender/release/scripts/startup/bl_ui/properties_data_curve.py	2012-02-02 15:15:52 UTC (rev 43852)
@@ -111,7 +111,8 @@
             sub = col.column()
             sub.active = (curve.dimensions == '2D' or (curve.bevel_object is None and curve.dimensions == '3D'))
             sub.prop(curve, "fill_mode", text="")
-            col.prop(curve, "use_fill_deform", text="Fill Deformed")
+            col.prop(curve, "use_fill_deform")
+            col.prop(curve, "use_fill_caps")
 
 
 class DATA_PT_curve_texture_space(CurveButtonsPanel, Panel):

Modified: trunk/blender/source/blender/blenkernel/intern/displist.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/displist.c	2012-02-02 14:07:24 UTC (rev 43851)
+++ trunk/blender/source/blender/blenkernel/intern/displist.c	2012-02-02 15:15:52 UTC (rev 43852)
@@ -1179,6 +1179,63 @@
 			forRender, originalVerts, deformedVerts);
 }
 
+static void rotateBevelPiece(Curve *cu, BevPoint *bevp, DispList *dlb, float widfac, float fac, float **data_r)
+{
+	float *fp, *data = *data_r;
+	int b;
+
+	fp = dlb->verts;
+	for (b = 0; b<dlb->nr; b++,fp += 3,data += 3) {
+		if(cu->flag & CU_3D) {
+			float vec[3];
+
+			vec[0] = fp[1]+widfac;
+			vec[1] = fp[2];
+			vec[2 ]= 0.0;
+
+			mul_qt_v3(bevp->quat, vec);
+
+			data[0] = bevp->vec[0] + fac*vec[0];
+			data[1] = bevp->vec[1] + fac*vec[1];
+			data[2] = bevp->vec[2] + fac*vec[2];
+		}
+		else {
+			data[0] = bevp->vec[0] + fac*(widfac+fp[1])*bevp->sina;
+			data[1] = bevp->vec[1] + fac*(widfac+fp[1])*bevp->cosa;
+			data[2] = bevp->vec[2] + fac*fp[2];
+		}
+	}
+
+	*data_r = data;
+}
+
+static void fillBevelCap(Curve *cu, Nurb *nu, BevPoint *bevp, DispList *dlb, float fac, float widfac, int flipnormal, ListBase *dispbase)
+{
+	ListBase tmpdisp = {NULL, NULL};
+	DispList *dl;
+	float *data;
+
+	dl= MEM_callocN(sizeof(DispList), "makeDispListbev2");
+	dl->verts= data= MEM_callocN(3*sizeof(float)*dlb->nr, "dlverts");
+
+	dl->type= DL_POLY;
+
+	dl->parts= 1;
+	dl->nr= dlb->nr;
+	dl->col= nu->mat_nr;
+	dl->charidx= nu->charidx;
+
+	/* dl->rt will be used as flag for render face and */
+	/* CU_2D conflicts with R_NOPUNOFLIP */
+	dl->rt= nu->flag & ~CU_2D;
+
+	rotateBevelPiece(cu, bevp, dlb, widfac, fac, &data);
+
+	BLI_addtail(&tmpdisp, dl);
+	filldisplist(&tmpdisp, dispbase, flipnormal);
+	freedisplist(&tmpdisp);
+}
+
 static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispbase,
 	DerivedMesh **derivedFinal, int forRender, int forOrco)
 {
@@ -1223,9 +1280,9 @@
 
 			for (; bl && nu; bl=bl->next,nu=nu->next) {
 				DispList *dl;
-				float *fp1, *data;
+				float *data;
 				BevPoint *bevp;
-				int a,b;
+				int a;
 
 				if (bl->nr) { /* blank bevel lists can happen */
 
@@ -1264,7 +1321,8 @@
 						DispList *dlb;
 
 						for (dlb=dlbev.first; dlb; dlb=dlb->next) {
-	
+							ListBase capbase = {NULL, NULL};
+
 							/* for each part of the bevel use a separate displblock */
 							dl= MEM_callocN(sizeof(DispList), "makeDispListbev1");
 							dl->verts= data= MEM_callocN(3*sizeof(float)*dlb->nr*bl->nr, "dlverts");
@@ -1302,32 +1360,19 @@
 									dl->bevelSplitFlag[a>>5] |= 1<<(a&0x1F);
 								}
 	
-									/* rotate bevel piece and write in data */
-								fp1= dlb->verts;
-								for (b=0; b<dlb->nr; b++,fp1+=3,data+=3) {
-									if(cu->flag & CU_3D) {
-										float vec[3];
-	
-										vec[0]= fp1[1]+widfac;
-										vec[1]= fp1[2];
-										vec[2]= 0.0;
+								/* rotate bevel piece and write in data */
+								rotateBevelPiece(cu, bevp, dlb, widfac, fac, &data);
 
-										mul_qt_v3(bevp->quat, vec);
-
-										data[0]= bevp->vec[0] + fac*vec[0];
-										data[1]= bevp->vec[1] + fac*vec[1];
-										data[2]= bevp->vec[2] + fac*vec[2];
-									}
-									else {
-										data[0]= bevp->vec[0] + fac*(widfac+fp1[1])*bevp->sina;
-										data[1]= bevp->vec[1] + fac*(widfac+fp1[1])*bevp->cosa;
-										data[2]= bevp->vec[2] + fac*fp1[2];
-									}
+								if (cu->flag & CU_FILL_CAPS) {
+									if (a == 0 || a == bl->nr - 1)
+										fillBevelCap(cu, nu, bevp, dlb, fac, widfac, a == 0, &capbase);
 								}
 							}
-							
+
 							/* gl array drawing: using indices */
 							displist_surf_indices(dl);
+
+							BLI_movelisttolist(dispbase, &capbase);
 						}
 					}
 				}

Modified: trunk/blender/source/blender/makesdna/DNA_curve_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_curve_types.h	2012-02-02 14:07:24 UTC (rev 43851)
+++ trunk/blender/source/blender/makesdna/DNA_curve_types.h	2012-02-02 15:15:52 UTC (rev 43852)
@@ -260,6 +260,7 @@
 #define CU_DS_EXPAND	2048
 #define CU_PATH_RADIUS	4096 /* make use of the path radius if this is enabled (default for new curves) */
 #define CU_DEFORM_FILL	8192 /* fill 2d curve after deformation */
+#define CU_FILL_CAPS	16384 /* fill bevel caps */
 
 /* twist mode */
 #define CU_TWIST_Z_UP			0

Modified: trunk/blender/source/blender/makesrna/intern/rna_curve.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_curve.c	2012-02-02 14:07:24 UTC (rev 43851)
+++ trunk/blender/source/blender/makesrna/intern/rna_curve.c	2012-02-02 15:15:52 UTC (rev 43852)
@@ -1386,9 +1386,14 @@
 
 	prop= RNA_def_property(srna, "use_fill_deform", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_DEFORM_FILL);
-	RNA_def_property_ui_text(prop, "Fill deformed", "Fill curve after applying shape keys and all modifiers");
+	RNA_def_property_ui_text(prop, "Fill Deformed", "Fill curve after applying shape keys and all modifiers");
 	RNA_def_property_update(prop, 0, "rna_Curve_update_data");
-	
+
+	prop= RNA_def_property(srna, "use_fill_caps", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_FILL_CAPS);
+	RNA_def_property_ui_text(prop, "Fill Caps", "Fill caps for bevelled curves");
+	RNA_def_property_update(prop, 0, "rna_Curve_update_data");
+
 	/* texture space */
 	prop= RNA_def_property(srna, "use_auto_texspace", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "texflag", CU_AUTOSPACE);




More information about the Bf-blender-cvs mailing list