Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2012-02-02 19:15:52 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2012-02-02 19:15:52 +0400
commitaef11b52d06766aa09342051bee3bb2a14c049cc (patch)
tree4ac9a49e9991c65bb5f1b0ac5fcc76c83aa8fe82 /source
parent4aaf59324e0ea5fecf28c1e9d54b1aed9b135dc5 (diff)
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.
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/intern/displist.c95
-rw-r--r--source/blender/makesdna/DNA_curve_types.h1
-rw-r--r--source/blender/makesrna/intern/rna_curve.c9
3 files changed, 78 insertions, 27 deletions
diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c
index e0f76917368..71dcc1a69a6 100644
--- a/source/blender/blenkernel/intern/displist.c
+++ b/source/blender/blenkernel/intern/displist.c
@@ -1179,6 +1179,63 @@ void makeDispListSurf(Scene *scene, Object *ob, ListBase *dispbase,
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 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba
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 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba
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 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba
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;
-
- 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];
- }
+ /* rotate bevel piece and write in data */
+ rotateBevelPiece(cu, bevp, dlb, widfac, fac, &data);
+
+ 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);
}
}
}
diff --git a/source/blender/makesdna/DNA_curve_types.h b/source/blender/makesdna/DNA_curve_types.h
index ffcc516f393..455738c840b 100644
--- a/source/blender/makesdna/DNA_curve_types.h
+++ b/source/blender/makesdna/DNA_curve_types.h
@@ -260,6 +260,7 @@ typedef struct Curve {
#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
diff --git a/source/blender/makesrna/intern/rna_curve.c b/source/blender/makesrna/intern/rna_curve.c
index 5fd67efba1d..088f2dba0bb 100644
--- a/source/blender/makesrna/intern/rna_curve.c
+++ b/source/blender/makesrna/intern/rna_curve.c
@@ -1386,9 +1386,14 @@ static void rna_def_curve(BlenderRNA *brna)
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);