"Fill deformed" option for 2D curves

Add new option named "Fill deformed". If this option is switched on.
2D curve will be first deformed by modifiers and only then be filled
with faces.
This commit is contained in:
Sergey Sharybin 2010-03-16 21:09:53 +00:00
parent 8ac0359852
commit 14e29a62dc
5 changed files with 21 additions and 2 deletions

@ -124,6 +124,7 @@ class DATA_PT_shape_curve(DataButtonsPanel):
sub.label(text="Caps:") sub.label(text="Caps:")
sub.prop(curve, "front") sub.prop(curve, "front")
sub.prop(curve, "back") sub.prop(curve, "back")
sub.prop(curve, "use_deform_fill")
col.label(text="Textures:") col.label(text="Textures:")
# col.prop(curve, "uv_orco") # col.prop(curve, "uv_orco")

@ -1391,6 +1391,10 @@ static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispba
CDDM_calc_normals(dm); CDDM_calc_normals(dm);
} }
} else { } else {
if (ELEM(ob->type, OB_CURVE, OB_FONT) && (cu->flag & CU_DEFORM_FILL)) {
curve_to_filledpoly(cu, nurb, &cu->disp);
}
dm= CDDM_from_curve_customDB(ob, dispbase); dm= CDDM_from_curve_customDB(ob, dispbase);
if(dmDeformedVerts) { if(dmDeformedVerts) {
@ -1801,7 +1805,9 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba
freedisplist(&dlbev); freedisplist(&dlbev);
} }
curve_to_filledpoly(cu, nubase, dispbase); if (!(cu->flag & CU_DEFORM_FILL)) {
curve_to_filledpoly(cu, nubase, dispbase);
}
if(cu->flag & CU_PATH) calc_curvepath(ob); if(cu->flag & CU_PATH) calc_curvepath(ob);
@ -1810,6 +1816,10 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba
} }
if(!forOrco) curve_calc_modifiers_post(scene, ob, dispbase, derivedFinal, forRender, originalVerts, deformedVerts); if(!forOrco) curve_calc_modifiers_post(scene, ob, dispbase, derivedFinal, forRender, originalVerts, deformedVerts);
if (cu->flag & CU_DEFORM_FILL && !ob->derivedFinal) {
curve_to_filledpoly(cu, nubase, dispbase);
}
} }
} }

@ -503,11 +503,14 @@ static int object_add_curve_exec(bContext *C, wmOperator *op)
ED_object_add_generic_get_opts(op, loc, rot, &enter_editmode, &layer); ED_object_add_generic_get_opts(op, loc, rot, &enter_editmode, &layer);
if(obedit==NULL || obedit->type!=OB_CURVE) { if(obedit==NULL || obedit->type!=OB_CURVE) {
Curve *cu;
obedit= ED_object_add_type(C, OB_CURVE, loc, rot, TRUE, layer); obedit= ED_object_add_type(C, OB_CURVE, loc, rot, TRUE, layer);
newob = 1; newob = 1;
cu= (Curve*)obedit->data;
cu->flag |= CU_DEFORM_FILL;
if(type & CU_PRIM_PATH) if(type & CU_PRIM_PATH)
((Curve*)obedit->data)->flag |= CU_PATH|CU_3D; cu->flag |= CU_PATH|CU_3D;
} }
else DAG_id_flush_update(&obedit->id, OB_RECALC_DATA); else DAG_id_flush_update(&obedit->id, OB_RECALC_DATA);

@ -243,6 +243,7 @@ typedef struct Curve {
#define CU_RETOPO 1024 #define CU_RETOPO 1024
#define CU_DS_EXPAND 2048 #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_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 */
/* twist mode */ /* twist mode */
#define CU_TWIST_Z_UP 0 #define CU_TWIST_Z_UP 0

@ -880,6 +880,10 @@ static void rna_def_curve(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Twist Smooth", "Smoothing iteration for tangents"); RNA_def_property_ui_text(prop, "Twist Smooth", "Smoothing iteration for tangents");
RNA_def_property_update(prop, 0, "rna_Curve_update_data"); RNA_def_property_update(prop, 0, "rna_Curve_update_data");
prop= RNA_def_property(srna, "use_deform_fill", 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 deformation");
RNA_def_property_update(prop, 0, "rna_Curve_update_data");
} }
static void rna_def_curve_nurb(BlenderRNA *brna) static void rna_def_curve_nurb(BlenderRNA *brna)