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.
This commit is contained in:
Sergey Sharybin 2012-02-02 15:15:52 +00:00
parent 4aaf59324e
commit aef11b52d0
4 changed files with 79 additions and 27 deletions

@ -111,7 +111,8 @@ class DATA_PT_shape_curve(CurveButtonsPanel, Panel):
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):

@ -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;
/* 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);
}
}
}

@ -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

@ -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);