"Fill deformed" option for 2D curves
authorSergey Sharybin <sergey.vfx@gmail.com>
Tue, 16 Mar 2010 21:09:53 +0000 (21:09 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Tue, 16 Mar 2010 21:09:53 +0000 (21:09 +0000)
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.

release/scripts/ui/properties_data_curve.py
source/blender/blenkernel/intern/displist.c
source/blender/editors/object/object_add.c
source/blender/makesdna/DNA_curve_types.h
source/blender/makesrna/intern/rna_curve.c

index 9848e4236652a2290d88b8f9f6d9bce7f4649039..ff78791fa0b3a12d72462bf0e35f47c7035716fd 100644 (file)
@@ -124,6 +124,7 @@ class DATA_PT_shape_curve(DataButtonsPanel):
             sub.label(text="Caps:")
             sub.prop(curve, "front")
             sub.prop(curve, "back")
+            sub.prop(curve, "use_deform_fill")
 
         col.label(text="Textures:")
 #       col.prop(curve, "uv_orco")
index b9588f4520c70aa08e73e183cde4022bbc95787b..56eabc0f5eff13c2a746ab6ed5726bc55c8ecadc 100644 (file)
@@ -1391,6 +1391,10 @@ static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispba
                                        CDDM_calc_normals(dm);
                                }
                        } 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);
 
                                if(dmDeformedVerts) {
@@ -1801,7 +1805,9 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba
                        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);
 
@@ -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 (cu->flag & CU_DEFORM_FILL && !ob->derivedFinal) {
+                       curve_to_filledpoly(cu, nubase, dispbase);
+               }
        }
 }
 
index 2a0d6e6c046a56f2100ed1a654e32e19fb1f1aff..4f6a188304aaacdf64c4155462000e96926325fb 100644 (file)
@@ -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);
        
        if(obedit==NULL || obedit->type!=OB_CURVE) {
+               Curve *cu;
                obedit= ED_object_add_type(C, OB_CURVE, loc, rot, TRUE, layer);
                newob = 1;
 
+               cu= (Curve*)obedit->data;
+               cu->flag |= CU_DEFORM_FILL;
                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);
        
index cd002894c5d7ada141b010769652cb7b0eb701a9..1e2cc2745a4d3324e1b99372857de037faa858f9 100644 (file)
@@ -243,6 +243,7 @@ typedef struct Curve {
 #define CU_RETOPO               1024
 #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 */
 
 /* twist mode */
 #define CU_TWIST_Z_UP                  0
index 499423276ab5b4796b6fd57b76aff67fa0ad588d..24701ed866d2c360bf81e28b319f7a058fc4fafd 100644 (file)
@@ -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_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)