diff options
Diffstat (limited to 'source/blender/makesrna/intern/rna_curve.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_curve.c | 456 |
1 files changed, 394 insertions, 62 deletions
diff --git a/source/blender/makesrna/intern/rna_curve.c b/source/blender/makesrna/intern/rna_curve.c index 499423276ab..d8bc683ae12 100644 --- a/source/blender/makesrna/intern/rna_curve.c +++ b/source/blender/makesrna/intern/rna_curve.c @@ -25,7 +25,6 @@ #include <stdlib.h> #include "RNA_define.h" -#include "RNA_types.h" #include "rna_internal.h" @@ -50,8 +49,18 @@ EnumPropertyItem beztriple_interpolation_mode_items[] = { {BEZT_IPO_BEZ, "BEZIER", 0, "Bezier", ""}, {0, NULL, 0, NULL, NULL}}; +EnumPropertyItem curve_type_items[] = { + {CU_POLY, "POLY", 0, "Poly", ""}, + {CU_BEZIER, "BEZIER", 0, "Bezier", ""}, + {CU_BSPLINE, "BSPLINE", 0, "BSpline", ""}, + {CU_CARDINAL, "CARDINAL", 0, "Cardinal", ""}, + {CU_NURBS, "NURBS", 0, "Ease", ""}, + {0, NULL, 0, NULL, NULL}}; + #ifdef RNA_RUNTIME +#include "BLI_math.h" + #include "DNA_object_types.h" #include "BKE_curve.h" @@ -72,22 +81,6 @@ static StructRNA *rna_Curve_refine(PointerRNA *ptr) else return &RNA_Curve; } - -static PointerRNA rna_Curve_active_nurb_get(PointerRNA *ptr) -{ - Curve *cu= (Curve*)ptr->data; - Nurb *nu= NULL; - - if(cu->editnurb) - nu = BLI_findlink(cu->editnurb, cu->actnu); - - if(nu) - return rna_pointer_inherit_refine(ptr, &RNA_Spline, nu); - - return rna_pointer_inherit_refine(ptr, NULL, NULL); -} - - static void rna_BezTriple_handle1_get(PointerRNA *ptr, float *values) { BezTriple *bt= (BezTriple*)ptr->data; @@ -148,6 +141,40 @@ static int rna_Curve_texspace_editable(PointerRNA *ptr) return (cu->texflag & CU_AUTOSPACE)? 0: PROP_EDITABLE; } +static void rna_Curve_texspace_loc_get(PointerRNA *ptr, float *values) +{ + Curve *cu= (Curve *)ptr->data; + + if (!cu->bb) + tex_space_curve(cu); + + copy_v3_v3(values, cu->loc); +} + +static void rna_Curve_texspace_loc_set(PointerRNA *ptr, const float *values) +{ + Curve *cu= (Curve *)ptr->data; + + copy_v3_v3(cu->loc, values); +} + +static void rna_Curve_texspace_size_get(PointerRNA *ptr, float *values) +{ + Curve *cu= (Curve *)ptr->data; + + if (!cu->bb) + tex_space_curve(cu); + + copy_v3_v3(values, cu->size); +} + +static void rna_Curve_texspace_size_set(PointerRNA *ptr, const float *values) +{ + Curve *cu= (Curve *)ptr->data; + + copy_v3_v3(cu->size, values); +} + static void rna_Curve_material_index_range(PointerRNA *ptr, int *min, int *max) { Curve *cu= (Curve*)ptr->id.data; @@ -188,10 +215,10 @@ static void rna_Curve_dimension_set(PointerRNA *ptr, int value) } - static int rna_Nurb_length(PointerRNA *ptr) { Nurb *nu= (Nurb*)ptr->data; + if(nu->type == CU_BEZIER) return 0; return nu->pntsv>0 ? nu->pntsu*nu->pntsv : nu->pntsu; } @@ -208,20 +235,77 @@ static void rna_BPoint_array_begin(CollectionPropertyIterator *iter, PointerRNA rna_iterator_array_begin(iter, (void*)nu->bp, sizeof(BPoint), nu->pntsv>0 ? nu->pntsu*nu->pntsv : nu->pntsu, 0, NULL); } -static void rna_Curve_update_data(Main *bmain, Scene *scene, PointerRNA *ptr) +static void rna_Curve_update_data_id(Main *bmain, Scene *scene, ID *id) { - ID *id= ptr->id.data; - DAG_id_flush_update(id, OB_RECALC_DATA); WM_main_add_notifier(NC_GEOM|ND_DATA, id); } +static void rna_Curve_update_data(Main *bmain, Scene *scene, PointerRNA *ptr) +{ + rna_Curve_update_data_id(bmain, scene, ptr->id.data); +} + static void rna_Curve_update_deps(Main *bmain, Scene *scene, PointerRNA *ptr) { DAG_scene_sort(scene); rna_Curve_update_data(bmain, scene, ptr); } +static PointerRNA rna_Curve_bevelObject_get(PointerRNA *ptr) +{ + Curve *cu= (Curve*)ptr->id.data; + Object *ob= cu->bevobj; + + if(ob) + return rna_pointer_inherit_refine(ptr, &RNA_Object, ob); + + return rna_pointer_inherit_refine(ptr, NULL, NULL); +} + +static void rna_Curve_bevelObject_set(PointerRNA *ptr, PointerRNA value) +{ + Curve *cu= (Curve*)ptr->id.data; + Object *ob= (Object*)value.data; + + if (ob) { + /* if bevel object has got the save curve, as object, for which it's */ + /* set as bevobj, there could be infinity loop in displist calculation */ + if (ob->type == OB_CURVE && ob->data != cu) { + cu->bevobj = ob; + } + } else { + cu->bevobj = NULL; + } +} + +static PointerRNA rna_Curve_taperObject_get(PointerRNA *ptr) +{ + Curve *cu= (Curve*)ptr->id.data; + Object *ob= cu->taperobj; + + if(ob) + return rna_pointer_inherit_refine(ptr, &RNA_Object, ob); + + return rna_pointer_inherit_refine(ptr, NULL, NULL); +} + +static void rna_Curve_taperObject_set(PointerRNA *ptr, PointerRNA value) +{ + Curve *cu= (Curve*)ptr->id.data; + Object *ob= (Object*)value.data; + + if (ob) { + /* if taper object has got the save curve, as object, for which it's */ + /* set as bevobj, there could be infinity loop in displist calculation */ + if (ob->type == OB_CURVE && ob->data != cu) { + cu->taperobj = ob; + } + } else { + cu->taperobj = NULL; + } +} + static void rna_Curve_resolution_u_update_data(Main *bmain, Scene *scene, PointerRNA *ptr) { Curve *cu= (Curve*)ptr->id.data; @@ -316,6 +400,119 @@ static void rna_Nurb_update_knot_v(Main *bmain, Scene *scene, PointerRNA *ptr) rna_Curve_update_data(bmain, scene, ptr); } +static void rna_Curve_spline_points_add(ID *id, Nurb *nu, ReportList *reports, int number) +{ + if(nu->type == CU_BEZIER) { + BKE_report(reports, RPT_ERROR, "Bezier spline can't have points added"); + } + else if(number==0) { + // do nothing + } else { + + addNurbPoints(nu, number); + + /* update */ + makeknots(nu, 1); + + rna_Curve_update_data_id(NULL, NULL, id); + } +} + +static void rna_Curve_spline_bezpoints_add(ID *id, Nurb *nu, ReportList *reports, int number) +{ + if(nu->type != CU_BEZIER) { + BKE_report(reports, RPT_ERROR, "Only bezier splines can be added"); + } + else if(number==0) { + // do nothing + } else { + addNurbPointsBezier(nu, number); + + /* update */ + makeknots(nu, 1); + + rna_Curve_update_data_id(NULL, NULL, id); + } +} + +static Nurb *rna_Curve_spline_new(Curve *cu, int type) +{ + Nurb *nu= ( Nurb * ) MEM_callocN( sizeof( Nurb ), "spline.new" ); + + if(type==CU_BEZIER) { + BezTriple *bezt= (BezTriple *)MEM_callocN(sizeof(BezTriple), "spline.new.bezt"); + bezt->radius= 1.0; + nu->bezt= bezt; + } + else { + BPoint *bp= (BPoint *)MEM_callocN(sizeof(BPoint), "spline.new.bp"); + bp->radius= 1.0f; + nu->bp= bp; + } + + nu->type= type; + nu->pntsu= 1; + nu->pntsv= 1; + + nu->orderu= nu->orderv= 4; + nu->resolu= nu->resolv= 12; + nu->flag= CU_SMOOTH; + + BLI_addtail(&cu->nurb, nu); + + return nu; +} + +static void rna_Curve_spline_remove(Curve *cu, ReportList *reports, Nurb *nu) +{ + /* todo, check we're in the list */ + int found= 0; + if(cu->editnurb) { + found= BLI_remlink_safe(cu->editnurb, nu); + } + else { + found= BLI_remlink_safe(&cu->nurb, nu); + } + + if(!found) { + BKE_reportf(reports, RPT_ERROR, "Curve \"%s\" does not contain spline given", cu->id.name+2); + return; + } + + freeNurb(nu); + /* invalidate pointer!, no can do */ +} + +static PointerRNA rna_Curve_active_spline_get(PointerRNA *ptr) +{ + Curve *cu= (Curve*)ptr->data; + Nurb *nu; + + if(cu->editnurb) + nu= BLI_findlink(cu->editnurb, cu->actnu); + else + nu= BLI_findlink(&cu->nurb, cu->actnu); // currently set to -1, should be changed to be allowed outside of editmode. + + if(nu) + return rna_pointer_inherit_refine(ptr, &RNA_Spline, nu); + + return rna_pointer_inherit_refine(ptr, NULL, NULL); +} + +static void rna_Curve_active_spline_set(PointerRNA *ptr, PointerRNA value) +{ + Curve *cu= (Curve*)ptr->data; + Nurb *nu= value.data; + + /* -1 is ok for an unset index */ + if(nu==NULL) + cu->actnu= -1; + else if(cu->editnurb) + cu->actnu= BLI_findindex(cu->editnurb, nu); + else + cu->actnu= BLI_findindex(&cu->nurb, nu); +} + #else static void rna_def_bpoint(BlenderRNA *brna) @@ -496,9 +693,9 @@ static void rna_def_nurbs(BlenderRNA *brna, StructRNA *srna) PropertyRNA *prop; /* flags */ - prop= RNA_def_property(srna, "uv_orco", PROP_BOOLEAN, PROP_NONE); + prop= RNA_def_property(srna, "map_along_length", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_UV_ORCO); - RNA_def_property_ui_text(prop, "UV Orco", "Forces to use UV coordinates for texture mapping 'orco'"); + RNA_def_property_ui_text(prop, "Map Along Length", "Generate texture mapping coordinates following the curve direction, rather than the local bounding box"); RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "vertex_normal_flip", PROP_BOOLEAN, PROP_NONE); @@ -533,6 +730,12 @@ static void rna_def_font(BlenderRNA *brna, StructRNA *srna) RNA_def_property_ui_text(prop, "Font size", ""); RNA_def_property_update(prop, 0, "rna_Curve_update_data"); + prop= RNA_def_property(srna, "small_caps_scale", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "smallcaps_scale"); + RNA_def_property_ui_range(prop, 0, 1.0, 0.1, 0); + RNA_def_property_ui_text(prop, "Small Caps", "Scale of small capitals"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); + prop= RNA_def_property(srna, "line_dist", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "linedist"); RNA_def_property_range(prop, 0.0f, 10.0f); @@ -599,7 +802,7 @@ static void rna_def_font(BlenderRNA *brna, StructRNA *srna) prop= RNA_def_property(srna, "body", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "str"); - RNA_def_property_ui_text(prop, "Body Text", "contence of this text object"); + RNA_def_property_ui_text(prop, "Body Text", "contents of this text object"); RNA_def_property_string_funcs(prop, "rna_Curve_body_get", "rna_Curve_body_length", "rna_Curve_body_set"); RNA_def_property_string_maxlength(prop, 8192); /* note that originally str did not have a limit! */ RNA_def_struct_name_property(srna, prop); @@ -637,6 +840,7 @@ static void rna_def_textbox(BlenderRNA *brna) srna= RNA_def_struct(brna, "TextBox", NULL); RNA_def_struct_ui_text(srna, "Text Box", "Text bounding box for layout"); + // XXX: still needs path function /* number values */ prop= RNA_def_property(srna, "x", PROP_FLOAT, PROP_NONE); @@ -674,29 +878,30 @@ static void rna_def_charinfo(BlenderRNA *brna) RNA_def_struct_ui_text(srna, "Text Character Format", "Text character formatting settings"); /* flags */ - prop= RNA_def_property(srna, "style", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_STYLE); - RNA_def_property_ui_text(prop, "Style", ""); - RNA_def_property_update(prop, 0, "rna_Curve_update_data"); - prop= RNA_def_property(srna, "bold", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_BOLD); + RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_CHINFO_BOLD); RNA_def_property_ui_text(prop, "Bold", ""); RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "italic", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_ITALIC); + RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_CHINFO_ITALIC); RNA_def_property_ui_text(prop, "Italic", ""); RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "underline", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_UNDERLINE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_CHINFO_UNDERLINE); RNA_def_property_ui_text(prop, "Underline", ""); RNA_def_property_update(prop, 0, "rna_Curve_update_data"); - prop= RNA_def_property(srna, "wrap", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_WRAP); + /* probably there is no reason to expose this */ + /* prop= RNA_def_property(srna, "wrap", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_CHINFO_WRAP); RNA_def_property_ui_text(prop, "Wrap", ""); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); */ + + prop= RNA_def_property(srna, "use_small_caps", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_CHINFO_SMALLCAPS); + RNA_def_property_ui_text(prop, "Small Caps", ""); RNA_def_property_update(prop, 0, "rna_Curve_update_data"); } @@ -725,6 +930,100 @@ static void rna_def_text(BlenderRNA *brna) rna_def_nurbs(brna, srna); } + +/* curve.splines[0].points */ +static void rna_def_curve_spline_points(BlenderRNA *brna, PropertyRNA *cprop) +{ + StructRNA *srna; + //PropertyRNA *prop; + + FunctionRNA *func; + PropertyRNA *parm; + + RNA_def_property_srna(cprop, "SplinePoints"); + srna= RNA_def_struct(brna, "SplinePoints", NULL); + RNA_def_struct_sdna(srna, "Nurb"); + RNA_def_struct_ui_text(srna, "Spline Points", "Collection of spline points"); + + func= RNA_def_function(srna, "add", "rna_Curve_spline_points_add"); + RNA_def_function_ui_description(func, "Add a number of points to this spline."); + RNA_def_function_flag(func, FUNC_USE_SELF_ID|FUNC_USE_REPORTS); + parm= RNA_def_int(func, "number", 1, INT_MIN, INT_MAX, "Number", "Number of points to add to the spline", 0, INT_MAX); + + /* + func= RNA_def_function(srna, "remove", "rna_Curve_spline_remove"); + RNA_def_function_ui_description(func, "Remove a spline from a curve."); + RNA_def_function_flag(func, FUNC_USE_REPORTS); + parm= RNA_def_pointer(func, "spline", "Spline", "", "The spline to remove."); + RNA_def_property_flag(parm, PROP_REQUIRED); + */ +} + +static void rna_def_curve_spline_bezpoints(BlenderRNA *brna, PropertyRNA *cprop) +{ + StructRNA *srna; + //PropertyRNA *prop; + + FunctionRNA *func; + PropertyRNA *parm; + + RNA_def_property_srna(cprop, "SplineBezierPoints"); + srna= RNA_def_struct(brna, "SplineBezierPoints", NULL); + RNA_def_struct_sdna(srna, "Nurb"); + RNA_def_struct_ui_text(srna, "Spline Bezier Points", "Collection of spline bezirt points"); + + func= RNA_def_function(srna, "add", "rna_Curve_spline_bezpoints_add"); + RNA_def_function_ui_description(func, "Add a number of points to this spline."); + RNA_def_function_flag(func, FUNC_USE_SELF_ID|FUNC_USE_REPORTS); + parm= RNA_def_int(func, "number", 1, INT_MIN, INT_MAX, "Number", "Number of points to add to the spline", 0, INT_MAX); + + /* + func= RNA_def_function(srna, "remove", "rna_Curve_spline_remove"); + RNA_def_function_ui_description(func, "Remove a spline from a curve."); + RNA_def_function_flag(func, FUNC_USE_REPORTS); + parm= RNA_def_pointer(func, "spline", "Spline", "", "The spline to remove."); + RNA_def_property_flag(parm, PROP_REQUIRED); + */ +} + +/* curve.splines */ +static void rna_def_curve_splines(BlenderRNA *brna, PropertyRNA *cprop) +{ + StructRNA *srna; + PropertyRNA *prop; + + FunctionRNA *func; + PropertyRNA *parm; + + RNA_def_property_srna(cprop, "CurveSplines"); + srna= RNA_def_struct(brna, "CurveSplines", NULL); + RNA_def_struct_sdna(srna, "Curve"); + RNA_def_struct_ui_text(srna, "Curve Splines", "Collection of curve splines"); + + func= RNA_def_function(srna, "new", "rna_Curve_spline_new"); + RNA_def_function_ui_description(func, "Add a new spline to the curve."); + parm= RNA_def_enum(func, "type", curve_type_items, CU_POLY, "", "type for the new spline."); + RNA_def_property_flag(parm, PROP_REQUIRED); + parm= RNA_def_pointer(func, "spline", "Spline", "", "The newly created spline."); + RNA_def_function_return(func, parm); + + func= RNA_def_function(srna, "remove", "rna_Curve_spline_remove"); + RNA_def_function_ui_description(func, "Remove a spline from a curve."); + RNA_def_function_flag(func, FUNC_USE_REPORTS); + parm= RNA_def_pointer(func, "spline", "Spline", "", "The spline to remove."); + RNA_def_property_flag(parm, PROP_REQUIRED); + + prop= RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE); + RNA_def_property_struct_type(prop, "Object"); + RNA_def_property_pointer_funcs(prop, "rna_Curve_active_spline_get", "rna_Curve_active_spline_set", NULL); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Active Spline", "Active curve spline"); + /* Could call: ED_base_object_activate(C, scene->basact); + * but would be a bad level call and it seems the notifier is enough */ + RNA_def_property_update(prop, NC_SCENE|ND_OB_ACTIVE, NULL); +} + + static void rna_def_curve(BlenderRNA *brna) { StructRNA *srna; @@ -747,7 +1046,6 @@ static void rna_def_curve(BlenderRNA *brna) RNA_def_struct_refine_func(srna, "rna_Curve_refine"); rna_def_animdata_common(srna); - rna_def_texmat_common(srna, "rna_Curve_texspace_editable"); prop= RNA_def_property(srna, "shape_keys", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "key"); @@ -757,12 +1055,7 @@ static void rna_def_curve(BlenderRNA *brna) RNA_def_property_collection_sdna(prop, NULL, "nurb", NULL); RNA_def_property_struct_type(prop, "Spline"); RNA_def_property_ui_text(prop, "Splines", "Collection of splines in this curve data object"); - - prop= RNA_def_property(srna, "active_spline", PROP_POINTER, PROP_NONE); - RNA_def_property_struct_type(prop, "Spline"); - RNA_def_property_pointer_funcs(prop, "rna_Curve_active_nurb_get", NULL, NULL); - RNA_def_property_ui_text(prop, "Active Spline", "The active editmode spline"); - + rna_def_curve_splines(brna, prop); prop= RNA_def_property(srna, "draw_handles", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "drawflag", CU_HIDE_HANDLES); @@ -820,12 +1113,12 @@ static void rna_def_curve(BlenderRNA *brna) prop= RNA_def_property(srna, "render_resolution_u", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "resolu_ren"); RNA_def_property_range(prop, 0, INT_MAX); - RNA_def_property_ui_range(prop, 1, 64, 1, 0); + RNA_def_property_ui_range(prop, 0, 64, 1, 0); RNA_def_property_ui_text(prop, "Render Resolution U", "Surface resolution in U direction used while rendering. Zero skips this property"); prop= RNA_def_property(srna, "render_resolution_v", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "resolv_ren"); - RNA_def_property_ui_range(prop, 1, 64, 1, 0); + RNA_def_property_ui_range(prop, 0, 64, 1, 0); RNA_def_property_range(prop, 0, INT_MAX); RNA_def_property_ui_text(prop, "Render Resolution V", "Surface resolution in V direction used while rendering. Zero skips this property"); @@ -837,17 +1130,21 @@ static void rna_def_curve(BlenderRNA *brna) /* pointers */ prop= RNA_def_property(srna, "bevel_object", PROP_POINTER, PROP_NONE); + RNA_def_property_struct_type(prop, "Object"); RNA_def_property_pointer_sdna(prop, NULL, "bevobj"); RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Bevel Object", "Curve object name that defines the bevel shape"); RNA_def_property_update(prop, 0, "rna_Curve_update_deps"); - + RNA_def_property_pointer_funcs(prop, "rna_Curve_bevelObject_get", "rna_Curve_bevelObject_set", NULL); + prop= RNA_def_property(srna, "taper_object", PROP_POINTER, PROP_NONE); + RNA_def_property_struct_type(prop, "Object"); RNA_def_property_pointer_sdna(prop, NULL, "taperobj"); RNA_def_property_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Taper Object", "Curve object name that defines the taper (width)"); RNA_def_property_update(prop, 0, "rna_Curve_update_deps"); - + RNA_def_property_pointer_funcs(prop, "rna_Curve_taperObject_get", "rna_Curve_taperObject_set", NULL); + /* Flags */ prop= RNA_def_property(srna, "dimensions", PROP_ENUM, PROP_NONE); /* as an enum */ @@ -880,18 +1177,51 @@ 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"); + + /* texture space */ + prop= RNA_def_property(srna, "auto_texspace", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "texflag", CU_AUTOSPACE); + RNA_def_property_ui_text(prop, "Auto Texture Space", "Adjusts active object's texture space automatically when transforming object"); + + prop= RNA_def_property(srna, "texspace_loc", PROP_FLOAT, PROP_TRANSLATION); + RNA_def_property_array(prop, 3); + RNA_def_property_ui_text(prop, "Texture Space Location", "Texture space location"); + RNA_def_property_editable_func(prop, "rna_Curve_texspace_editable"); + RNA_def_property_float_funcs(prop, "rna_Curve_texspace_loc_get", "rna_Curve_texspace_loc_set", NULL); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); + + prop= RNA_def_property(srna, "texspace_size", PROP_FLOAT, PROP_XYZ); + RNA_def_property_array(prop, 3); + RNA_def_property_ui_text(prop, "Texture Space Size", "Texture space size"); + RNA_def_property_editable_func(prop, "rna_Curve_texspace_editable"); + RNA_def_property_float_funcs(prop, "rna_Curve_texspace_size_get", "rna_Curve_texspace_size_set", NULL); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); + + /* not supported yet + prop= RNA_def_property(srna, "texspace_rot", PROP_FLOAT, PROP_EULER); + RNA_def_property_float(prop, NULL, "rot"); + RNA_def_property_ui_text(prop, "Texture Space Rotation", "Texture space rotation"); + RNA_def_property_editable_func(prop, texspace_editable); + RNA_def_property_update(prop, 0, "rna_Curve_update_data");*/ + + prop= RNA_def_property(srna, "map_along_length", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_UV_ORCO); + RNA_def_property_ui_text(prop, "Map Along Length", "Generate texture mapping coordinates following the curve direction, rather than the local bounding box"); + RNA_def_property_update(prop, 0, "rna_Curve_update_data"); + + /* materials */ + prop= RNA_def_property(srna, "materials", PROP_COLLECTION, PROP_NONE); + RNA_def_property_collection_sdna(prop, NULL, "mat", "totcol"); + RNA_def_property_struct_type(prop, "Material"); + RNA_def_property_ui_text(prop, "Materials", ""); } static void rna_def_curve_nurb(BlenderRNA *brna) { - static EnumPropertyItem curve_type_items[] = { - {CU_POLY, "POLY", 0, "Poly", ""}, - {CU_BEZIER, "BEZIER", 0, "Bezier", ""}, - {CU_BSPLINE, "BSPLINE", 0, "BSpline", ""}, - {CU_CARDINAL, "CARDINAL", 0, "Cardinal", ""}, - {CU_NURBS, "NURBS", 0, "Ease", ""}, - {0, NULL, 0, NULL, NULL}}; - static EnumPropertyItem spline_interpolation_items[] = { {BEZT_IPO_CONST, "LINEAR", 0, "Linear", ""}, {BEZT_IPO_LIN, "CARDINAL", 0, "Cardinal", ""}, @@ -903,7 +1233,7 @@ static void rna_def_curve_nurb(BlenderRNA *brna) PropertyRNA *prop; srna= RNA_def_struct(brna, "Spline", NULL); - RNA_def_struct_sdna(srna, "Nurb"); + RNA_def_struct_sdna(srna, "Nurb"); RNA_def_struct_ui_text(srna, "Spline", "Element of a curve, either Nurbs, Bezier or Polyline or a character with text objects"); prop= RNA_def_property(srna, "points", PROP_COLLECTION, PROP_NONE); @@ -911,11 +1241,13 @@ static void rna_def_curve_nurb(BlenderRNA *brna) RNA_def_property_struct_type(prop, "SplinePoint"); RNA_def_property_collection_funcs(prop, "rna_BPoint_array_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", "rna_Nurb_length", 0, 0); RNA_def_property_ui_text(prop, "Points", "Collection of points that make up this poly or nurbs spline"); + rna_def_curve_spline_points(brna, prop); prop= RNA_def_property(srna, "bezier_points", PROP_COLLECTION, PROP_NONE); RNA_def_property_struct_type(prop, "BezierSplinePoint"); RNA_def_property_collection_sdna(prop, NULL, "bezt", "pntsu"); RNA_def_property_ui_text(prop, "Bezier Points", "Collection of points for bezier curves only"); + rna_def_curve_spline_bezpoints(brna, prop); prop= RNA_def_property(srna, "tilt_interpolation", PROP_ENUM, PROP_NONE); @@ -937,13 +1269,13 @@ static void rna_def_curve_nurb(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Type", "The interpolation type for this curve element"); RNA_def_property_update(prop, 0, "rna_Curve_update_data"); - prop= RNA_def_property(srna, "point_count_u", PROP_INT, PROP_NONE); + prop= RNA_def_property(srna, "point_count_u", PROP_INT, PROP_UNSIGNED); RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* editing this needs knot recalc*/ RNA_def_property_int_sdna(prop, NULL, "pntsu"); RNA_def_property_ui_text(prop, "Points U", "Total number points for the curve or surface in the U direction"); RNA_def_property_update(prop, 0, "rna_Curve_update_data"); - prop= RNA_def_property(srna, "point_count_v", PROP_INT, PROP_NONE); + prop= RNA_def_property(srna, "point_count_v", PROP_INT, PROP_UNSIGNED); RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* editing this needs knot recalc*/ RNA_def_property_int_sdna(prop, NULL, "pntsv"); RNA_def_property_ui_text(prop, "Points V", "Total number points for the surface on the V direction"); @@ -978,34 +1310,34 @@ static void rna_def_curve_nurb(BlenderRNA *brna) RNA_def_property_update(prop, 0, "rna_Curve_update_data"); prop= RNA_def_property(srna, "cyclic_u", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flagu", CU_CYCLIC); + RNA_def_property_boolean_sdna(prop, NULL, "flagu", CU_NURB_CYCLIC); RNA_def_property_ui_text(prop, "Cyclic U", "Make this curve or surface a closed loop in the U direction"); RNA_def_property_update(prop, 0, "rna_Nurb_update_handle_data"); /* only needed for cyclic_u because cyclic_v cant do bezier */ prop= RNA_def_property(srna, "cyclic_v", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flagv", CU_CYCLIC); + RNA_def_property_boolean_sdna(prop, NULL, "flagv", CU_NURB_CYCLIC); RNA_def_property_ui_text(prop, "Cyclic V", "Make this surface a closed loop in the V direction"); RNA_def_property_update(prop, 0, "rna_Curve_update_data"); /* Note, endpoint and bezier flags should never be on at the same time! */ prop= RNA_def_property(srna, "endpoint_u", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flagu", 2); + RNA_def_property_boolean_sdna(prop, NULL, "flagu", CU_NURB_ENDPOINT); RNA_def_property_ui_text(prop, "Endpoint U", "Make this nurbs curve or surface meet the endpoints in the U direction (Cyclic U must be disabled)"); RNA_def_property_update(prop, 0, "rna_Nurb_update_knot_u"); prop= RNA_def_property(srna, "endpoint_v", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flagv", 2); + RNA_def_property_boolean_sdna(prop, NULL, "flagv", CU_NURB_ENDPOINT); RNA_def_property_ui_text(prop, "Endpoint V", "Make this nurbs surface meet the endpoints in the V direction (Cyclic V must be disabled)"); RNA_def_property_update(prop, 0, "rna_Nurb_update_knot_v"); prop= RNA_def_property(srna, "bezier_u", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flagu", 4); + RNA_def_property_boolean_sdna(prop, NULL, "flagu", CU_NURB_BEZIER); RNA_def_property_ui_text(prop, "Bezier U", "Make this nurbs curve or surface act like a bezier spline in the U direction (Order U must be 3 or 4, Cyclic U must be disabled)"); RNA_def_property_update(prop, 0, "rna_Nurb_update_knot_u"); prop= RNA_def_property(srna, "bezier_v", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flagv", 4); + RNA_def_property_boolean_sdna(prop, NULL, "flagv", CU_NURB_BEZIER); RNA_def_property_ui_text(prop, "Bezier V", "Make this nurbs surface act like a bezier spline in the V direction (Order V must be 3 or 4, Cyclic V must be disabled)"); RNA_def_property_update(prop, 0, "rna_Nurb_update_knot_v"); |