4 * ***** BEGIN GPL LICENSE BLOCK *****
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 * Contributor(s): Blender Foundation (2008), Juho Veps�l�inen
22 * ***** END GPL LICENSE BLOCK *****
27 #include "RNA_define.h"
29 #include "rna_internal.h"
31 #include "DNA_curve_types.h"
32 #include "DNA_key_types.h"
33 #include "DNA_material_types.h"
34 #include "DNA_scene_types.h"
40 #include "BKE_curve.h"
43 EnumPropertyItem beztriple_handle_type_items[] = {
44 {HD_FREE, "FREE", 0, "Free", ""},
45 {HD_AUTO, "AUTO", 0, "Auto", ""},
46 {HD_VECT, "VECTOR", 0, "Vector", ""},
47 {HD_ALIGN, "ALIGNED", 0, "Aligned", ""},
48 {0, NULL, 0, NULL, NULL}};
50 EnumPropertyItem beztriple_interpolation_mode_items[] = {
51 {BEZT_IPO_CONST, "CONSTANT", 0, "Constant", ""},
52 {BEZT_IPO_LIN, "LINEAR", 0, "Linear", ""},
53 {BEZT_IPO_BEZ, "BEZIER", 0, "Bezier", ""},
54 {0, NULL, 0, NULL, NULL}};
56 EnumPropertyItem curve_type_items[] = {
57 {CU_POLY, "POLY", 0, "Poly", ""},
58 {CU_BEZIER, "BEZIER", 0, "Bezier", ""},
59 {CU_BSPLINE, "BSPLINE", 0, "BSpline", ""},
60 {CU_CARDINAL, "CARDINAL", 0, "Cardinal", ""},
61 {CU_NURBS, "NURBS", 0, "Ease", ""},
62 {0, NULL, 0, NULL, NULL}};
68 #include "DNA_object_types.h"
70 #include "BKE_curve.h"
71 #include "BKE_depsgraph.h"
76 #include "MEM_guardedalloc.h"
78 #include "ED_curve.h" /* for BKE_curve_nurbs */
80 /* highly irritating but from RNA we cant know this */
81 static Nurb *curve_nurb_from_point(Curve *cu, const void *point, int *nu_index, int *pt_index)
83 ListBase *nurbs= BKE_curve_nurbs(cu);
87 for(nu= nurbs->first; nu; nu= nu->next, i++) {
88 if(nu->type == CU_BEZIER) {
89 if(point >= (void *)nu->bezt && point < (void *)(nu->bezt + nu->pntsu)) {
94 if(point >= (void *)nu->bp && point < (void *)(nu->bp + (nu->pntsu * nu->pntsv))) {
106 if(nu->type == CU_BEZIER) *pt_index= (int)((BezTriple *)point - nu->bezt);
107 else *pt_index= (int)((BPoint *)point - nu->bp);
114 static StructRNA *rna_Curve_refine(PointerRNA *ptr)
116 Curve *cu= (Curve*)ptr->data;
117 short obtype= curve_type(cu);
119 if(obtype == OB_FONT) return &RNA_TextCurve;
120 else if(obtype == OB_SURF) return &RNA_SurfaceCurve;
121 else return &RNA_Curve;
124 static void rna_BezTriple_handle1_get(PointerRNA *ptr, float *values)
126 BezTriple *bt= (BezTriple*)ptr->data;
128 values[0]= bt->vec[0][0];
129 values[1]= bt->vec[0][1];
130 values[2]= bt->vec[0][2];
133 static void rna_BezTriple_handle1_set(PointerRNA *ptr, const float *values)
135 BezTriple *bt= (BezTriple*)ptr->data;
137 bt->vec[0][0]= values[0];
138 bt->vec[0][1]= values[1];
139 bt->vec[0][2]= values[2];
142 static void rna_BezTriple_handle2_get(PointerRNA *ptr, float *values)
144 BezTriple *bt= (BezTriple*)ptr->data;
146 values[0]= bt->vec[2][0];
147 values[1]= bt->vec[2][1];
148 values[2]= bt->vec[2][2];
151 static void rna_BezTriple_handle2_set(PointerRNA *ptr, const float *values)
153 BezTriple *bt= (BezTriple*)ptr->data;
155 bt->vec[2][0]= values[0];
156 bt->vec[2][1]= values[1];
157 bt->vec[2][2]= values[2];
160 static void rna_BezTriple_ctrlpoint_get(PointerRNA *ptr, float *values)
162 BezTriple *bt= (BezTriple*)ptr->data;
164 values[0]= bt->vec[1][0];
165 values[1]= bt->vec[1][1];
166 values[2]= bt->vec[1][2];
169 static void rna_BezTriple_ctrlpoint_set(PointerRNA *ptr, const float *values)
171 BezTriple *bt= (BezTriple*)ptr->data;
173 bt->vec[1][0]= values[0];
174 bt->vec[1][1]= values[1];
175 bt->vec[1][2]= values[2];
178 static int rna_Curve_texspace_editable(PointerRNA *ptr)
180 Curve *cu= (Curve*)ptr->data;
181 return (cu->texflag & CU_AUTOSPACE)? 0: PROP_EDITABLE;
184 static void rna_Curve_texspace_loc_get(PointerRNA *ptr, float *values)
186 Curve *cu= (Curve *)ptr->data;
191 copy_v3_v3(values, cu->loc);
194 static void rna_Curve_texspace_loc_set(PointerRNA *ptr, const float *values)
196 Curve *cu= (Curve *)ptr->data;
198 copy_v3_v3(cu->loc, values);
201 static void rna_Curve_texspace_size_get(PointerRNA *ptr, float *values)
203 Curve *cu= (Curve *)ptr->data;
208 copy_v3_v3(values, cu->size);
211 static void rna_Curve_texspace_size_set(PointerRNA *ptr, const float *values)
213 Curve *cu= (Curve *)ptr->data;
215 copy_v3_v3(cu->size, values);
218 static void rna_Curve_material_index_range(PointerRNA *ptr, int *min, int *max)
220 Curve *cu= (Curve*)ptr->id.data;
225 static void rna_Curve_active_textbox_index_range(PointerRNA *ptr, int *min, int *max)
227 Curve *cu= (Curve*)ptr->id.data;
233 static void rna_Curve_dimension_set(PointerRNA *ptr, int value)
235 Curve *cu= (Curve*)ptr->id.data;
236 ListBase *nurbs= BKE_curve_nurbs(cu);
237 Nurb *nu= nurbs->first;
241 for( ; nu; nu= nu->next) {
247 for( ; nu; nu= nu->next) {
251 /* since the handles are moved they need to be auto-located again */
252 if(nu->type == CU_BEZIER)
259 static int rna_Nurb_length(PointerRNA *ptr)
261 Nurb *nu= (Nurb*)ptr->data;
262 if(nu->type == CU_BEZIER) return 0;
263 return nu->pntsv>0 ? nu->pntsu*nu->pntsv : nu->pntsu;
266 static void rna_Nurb_type_set(PointerRNA *ptr, int value)
268 Nurb *nu= (Nurb*)ptr->data;
270 // XXX - TODO change datatypes
273 static void rna_BPoint_array_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
275 Nurb *nu= (Nurb*)ptr->data;
276 rna_iterator_array_begin(iter, (void*)nu->bp, sizeof(BPoint), nu->pntsv>0 ? nu->pntsu*nu->pntsv : nu->pntsu, 0, NULL);
279 static void rna_Curve_update_data_id(Main *bmain, Scene *scene, ID *id)
281 DAG_id_flush_update(id, OB_RECALC_DATA);
282 WM_main_add_notifier(NC_GEOM|ND_DATA, id);
285 static void rna_Curve_update_data(Main *bmain, Scene *scene, PointerRNA *ptr)
287 rna_Curve_update_data_id(bmain, scene, ptr->id.data);
290 static void rna_Curve_update_deps(Main *bmain, Scene *scene, PointerRNA *ptr)
292 DAG_scene_sort(bmain, scene);
293 rna_Curve_update_data(bmain, scene, ptr);
296 static void rna_Curve_update_points(Main *bmain, Scene *scene, PointerRNA *ptr)
298 Curve *cu= (Curve*)ptr->id.data;
299 Nurb *nu= curve_nurb_from_point(cu, ptr->data, NULL, NULL);
304 rna_Curve_update_data(bmain, scene, ptr);
307 static PointerRNA rna_Curve_bevelObject_get(PointerRNA *ptr)
309 Curve *cu= (Curve*)ptr->id.data;
310 Object *ob= cu->bevobj;
313 return rna_pointer_inherit_refine(ptr, &RNA_Object, ob);
315 return rna_pointer_inherit_refine(ptr, NULL, NULL);
318 static void rna_Curve_bevelObject_set(PointerRNA *ptr, PointerRNA value)
320 Curve *cu= (Curve*)ptr->id.data;
321 Object *ob= (Object*)value.data;
324 /* if bevel object has got the save curve, as object, for which it's */
325 /* set as bevobj, there could be infinity loop in displist calculation */
326 if (ob->type == OB_CURVE && ob->data != cu) {
334 static int rna_Curve_otherObject_poll(PointerRNA *ptr, PointerRNA value)
336 Curve *cu= (Curve*)ptr->id.data;
337 Object *ob= (Object*)value.data;
340 if (ob->type == OB_CURVE && ob->data != cu) {
348 static PointerRNA rna_Curve_taperObject_get(PointerRNA *ptr)
350 Curve *cu= (Curve*)ptr->id.data;
351 Object *ob= cu->taperobj;
354 return rna_pointer_inherit_refine(ptr, &RNA_Object, ob);
356 return rna_pointer_inherit_refine(ptr, NULL, NULL);
359 static void rna_Curve_taperObject_set(PointerRNA *ptr, PointerRNA value)
361 Curve *cu= (Curve*)ptr->id.data;
362 Object *ob= (Object*)value.data;
365 /* if taper object has got the save curve, as object, for which it's */
366 /* set as bevobj, there could be infinity loop in displist calculation */
367 if (ob->type == OB_CURVE && ob->data != cu) {
375 static void rna_Curve_resolution_u_update_data(Main *bmain, Scene *scene, PointerRNA *ptr)
377 Curve *cu= (Curve*)ptr->id.data;
378 ListBase *nurbs= BKE_curve_nurbs(cu);
379 Nurb *nu= nurbs->first;
382 nu->resolu= cu->resolu;
386 rna_Curve_update_data(bmain, scene, ptr);
389 static void rna_Curve_resolution_v_update_data(Main *bmain, Scene *scene, PointerRNA *ptr)
391 Curve *cu= (Curve*)ptr->id.data;
392 ListBase *nurbs= BKE_curve_nurbs(cu);
393 Nurb *nu=nurbs->first;
397 nu->resolv= cu->resolv;
401 rna_Curve_update_data(bmain, scene, ptr);
404 static float rna_Curve_offset_get(PointerRNA *ptr)
406 Curve *cu= (Curve*)ptr->id.data;
407 return cu->width - 1.0f;
410 static void rna_Curve_offset_set(PointerRNA *ptr, float value)
412 Curve *cu= (Curve*)ptr->id.data;
413 cu->width= 1.0f + value;
416 /* name functions that ignore the first two ID characters */
417 void rna_Curve_body_get(PointerRNA *ptr, char *value)
419 Curve *cu= (Curve*)ptr->id.data;
420 BLI_strncpy(value, cu->str, cu->len+1);
423 int rna_Curve_body_length(PointerRNA *ptr)
425 Curve *cu= (Curve*)ptr->id.data;
429 /* TODO - check UTF & python play nice */
430 void rna_Curve_body_set(PointerRNA *ptr, const char *value)
432 int len= strlen(value);
433 Curve *cu= (Curve*)ptr->id.data;
435 cu->len= cu->pos = len;
437 if(cu->str) MEM_freeN(cu->str);
438 if(cu->strinfo) MEM_freeN(cu->strinfo);
440 cu->str = MEM_callocN(len + sizeof(wchar_t), "str");
441 cu->strinfo = MEM_callocN( (len+4) *sizeof(CharInfo), "strinfo"); /* don't know why this is +4, just duplicating load_editText() */
443 //wcs2utf8s(cu->str, value); // value is not wchar_t
444 BLI_strncpy(cu->str, value, len+1);
447 static void rna_Nurb_update_cyclic_u(Main *bmain, Scene *scene, PointerRNA *ptr)
449 Nurb *nu= (Nurb*)ptr->data;
451 if(nu->type == CU_BEZIER) {
454 nurbs_knot_calc_u(nu);
457 rna_Curve_update_data(bmain, scene, ptr);
460 static void rna_Nurb_update_cyclic_v(Main *bmain, Scene *scene, PointerRNA *ptr)
462 Nurb *nu= (Nurb*)ptr->data;
464 nurbs_knot_calc_v(nu);
466 rna_Curve_update_data(bmain, scene, ptr);
469 static void rna_Nurb_update_knot_u(Main *bmain, Scene *scene, PointerRNA *ptr)
471 Nurb *nu= (Nurb*)ptr->data;
473 clamp_nurb_order_u(nu);
474 nurbs_knot_calc_u(nu);
476 rna_Curve_update_data(bmain, scene, ptr);
479 static void rna_Nurb_update_knot_v(Main *bmain, Scene *scene, PointerRNA *ptr)
481 Nurb *nu= (Nurb*)ptr->data;
483 clamp_nurb_order_v(nu);
484 nurbs_knot_calc_v(nu);
486 rna_Curve_update_data(bmain, scene, ptr);
489 static void rna_Curve_spline_points_add(ID *id, Nurb *nu, ReportList *reports, int number)
491 if(nu->type == CU_BEZIER) {
492 BKE_report(reports, RPT_ERROR, "Bezier spline can't have points added");
498 addNurbPoints(nu, number);
501 nurbs_knot_calc_u(nu);
503 rna_Curve_update_data_id(NULL, NULL, id);
507 static void rna_Curve_spline_bezpoints_add(ID *id, Nurb *nu, ReportList *reports, int number)
509 if(nu->type != CU_BEZIER) {
510 BKE_report(reports, RPT_ERROR, "Only bezier splines can be added");
515 addNurbPointsBezier(nu, number);
518 nurbs_knot_calc_u(nu);
520 rna_Curve_update_data_id(NULL, NULL, id);
524 static Nurb *rna_Curve_spline_new(Curve *cu, int type)
526 Nurb *nu= ( Nurb * ) MEM_callocN( sizeof( Nurb ), "spline.new" );
528 if(type==CU_BEZIER) {
529 BezTriple *bezt= (BezTriple *)MEM_callocN(sizeof(BezTriple), "spline.new.bezt");
534 BPoint *bp= (BPoint *)MEM_callocN(sizeof(BPoint), "spline.new.bp");
543 nu->orderu= nu->orderv= 4;
544 nu->resolu= nu->resolv= 12;
547 BLI_addtail(BKE_curve_nurbs(cu), nu);
552 static void rna_Curve_spline_remove(Curve *cu, ReportList *reports, Nurb *nu)
555 ListBase *nurbs= BKE_curve_nurbs(cu);
557 found= BLI_remlink_safe(nurbs, nu);
560 BKE_reportf(reports, RPT_ERROR, "Curve \"%s\" does not contain spline given", cu->id.name+2);
565 /* invalidate pointer!, no can do */
568 static PointerRNA rna_Curve_active_spline_get(PointerRNA *ptr)
570 Curve *cu= (Curve*)ptr->data;
572 ListBase *nurbs= BKE_curve_nurbs(cu);
574 // for curve outside editmode will set to -1, should be changed to be allowed outside of editmode.
575 nu= BLI_findlink(nurbs, cu->actnu);
578 return rna_pointer_inherit_refine(ptr, &RNA_Spline, nu);
580 return rna_pointer_inherit_refine(ptr, NULL, NULL);
583 static void rna_Curve_active_spline_set(PointerRNA *ptr, PointerRNA value)
585 Curve *cu= (Curve*)ptr->data;
586 Nurb *nu= value.data;
587 ListBase *nubase= BKE_curve_nurbs(cu);
589 /* -1 is ok for an unset index */
593 cu->actnu= BLI_findindex(nubase, nu);
596 static char *rna_Curve_spline_path(PointerRNA *ptr)
598 Curve *cu= (Curve*)ptr->id.data;
599 ListBase *nubase= BKE_curve_nurbs(cu);
601 int index= BLI_findindex(nubase, nu);
604 return BLI_sprintfN("splines[%d]", index);
606 return BLI_strdup("");
609 /* use for both bezier and nurbs */
610 static char *rna_Curve_spline_point_path(PointerRNA *ptr)
612 Curve *cu= (Curve*)ptr->id.data;
614 void *point= ptr->data;
615 int nu_index, pt_index;
617 nu= curve_nurb_from_point(cu, point, &nu_index, &pt_index);
620 if(nu->type == CU_BEZIER) {
621 return BLI_sprintfN("splines[%d].bezier_points[%d]", nu_index, pt_index);
624 return BLI_sprintfN("splines[%d].points[%d]", nu_index, pt_index);
628 return BLI_strdup("");
633 static char *rna_TextBox_path(PointerRNA *ptr)
635 Curve *cu= (Curve*)ptr->id.data;
636 TextBox *tb= ptr->data;
637 int index= (int)(tb - cu->tb);
639 if (index >= 0 && index < cu->totbox)
640 return BLI_sprintfN("textboxes[%d]", index);
642 return BLI_strdup("");
645 static void rna_Curve_splines_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
647 Curve *cu= (Curve*)ptr->id.data;
648 rna_iterator_listbase_begin(iter, BKE_curve_nurbs(cu), NULL);
653 static void rna_def_bpoint(BlenderRNA *brna)
658 srna= RNA_def_struct(brna, "SplinePoint", NULL);
659 RNA_def_struct_sdna(srna, "BPoint");
660 RNA_def_struct_ui_text(srna, "SplinePoint", "Spline point without handles");
663 prop= RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
664 RNA_def_property_boolean_sdna(prop, NULL, "f1", 0);
665 RNA_def_property_ui_text(prop, "Select", "Selection status");
666 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
668 prop= RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE);
669 RNA_def_property_boolean_sdna(prop, NULL, "hide", 0);
670 RNA_def_property_ui_text(prop, "Hide", "Visibility status");
671 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
674 prop= RNA_def_property(srna, "co", PROP_FLOAT, PROP_TRANSLATION);
675 RNA_def_property_array(prop, 3);
676 RNA_def_property_float_sdna(prop, NULL, "vec");
677 RNA_def_property_ui_text(prop, "Point", "Point coordinates");
678 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
680 prop= RNA_def_property(srna, "weight", PROP_FLOAT, PROP_NONE);
681 RNA_def_property_float_sdna(prop, NULL, "vec[3]");
682 RNA_def_property_ui_text(prop, "Weight", "Nurbs weight");
683 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
686 prop= RNA_def_property(srna, "tilt", PROP_FLOAT, PROP_NONE);
687 RNA_def_property_float_sdna(prop, NULL, "alfa");
688 /*RNA_def_property_range(prop, -FLT_MAX, FLT_MAX);*/
689 RNA_def_property_ui_text(prop, "Tilt", "Tilt in 3D View");
690 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
692 prop= RNA_def_property(srna, "weight_softbody", PROP_FLOAT, PROP_NONE);
693 RNA_def_property_float_sdna(prop, NULL, "weight");
694 RNA_def_property_range(prop, 0.01f, 100.0f);
695 RNA_def_property_ui_text(prop, "Weight", "Softbody goal weight");
696 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
698 prop= RNA_def_property(srna, "radius", PROP_FLOAT, PROP_NONE);
699 RNA_def_property_float_sdna(prop, NULL, "radius");
700 RNA_def_property_range(prop, 0.0f, FLT_MAX);
701 RNA_def_property_ui_text(prop, "Bevel Radius", "Radius for bevelling");
702 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
704 RNA_def_struct_path_func(srna, "rna_Curve_spline_point_path");
707 static void rna_def_beztriple(BlenderRNA *brna)
712 srna= RNA_def_struct(brna, "BezierSplinePoint", NULL);
713 RNA_def_struct_sdna(srna, "BezTriple");
714 RNA_def_struct_ui_text(srna, "Bezier Curve Point", "Bezier curve point with two handles");
717 prop= RNA_def_property(srna, "select_left_handle", PROP_BOOLEAN, PROP_NONE);
718 RNA_def_property_boolean_sdna(prop, NULL, "f1", 0);
719 RNA_def_property_ui_text(prop, "Handle 1 selected", "Handle 1 selection status");
720 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
722 prop= RNA_def_property(srna, "select_right_handle", PROP_BOOLEAN, PROP_NONE);
723 RNA_def_property_boolean_sdna(prop, NULL, "f3", 0);
724 RNA_def_property_ui_text(prop, "Handle 2 selected", "Handle 2 selection status");
725 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
727 prop= RNA_def_property(srna, "select_control_point", PROP_BOOLEAN, PROP_NONE);
728 RNA_def_property_boolean_sdna(prop, NULL, "f2", 0);
729 RNA_def_property_ui_text(prop, "Control Point selected", "Control point selection status");
730 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
732 prop= RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE);
733 RNA_def_property_boolean_sdna(prop, NULL, "hide", 0);
734 RNA_def_property_ui_text(prop, "Hide", "Visibility status");
735 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
738 prop= RNA_def_property(srna, "handle_left_type", PROP_ENUM, PROP_NONE);
739 RNA_def_property_enum_sdna(prop, NULL, "h1");
740 RNA_def_property_enum_items(prop, beztriple_handle_type_items);
741 RNA_def_property_ui_text(prop, "Handle 1 Type", "Handle types");
742 RNA_def_property_update(prop, 0, "rna_Curve_update_points");
744 prop= RNA_def_property(srna, "handle_right_type", PROP_ENUM, PROP_NONE);
745 RNA_def_property_enum_sdna(prop, NULL, "h2");
746 RNA_def_property_enum_items(prop, beztriple_handle_type_items);
747 RNA_def_property_ui_text(prop, "Handle 2 Type", "Handle types");
748 RNA_def_property_update(prop, 0, "rna_Curve_update_points");
751 prop= RNA_def_property(srna, "handle_left", PROP_FLOAT, PROP_TRANSLATION);
752 RNA_def_property_array(prop, 3);
753 RNA_def_property_float_funcs(prop, "rna_BezTriple_handle1_get", "rna_BezTriple_handle1_set", NULL);
754 RNA_def_property_ui_text(prop, "Handle 1", "Coordinates of the first handle");
755 RNA_def_property_update(prop, 0, "rna_Curve_update_points");
757 prop= RNA_def_property(srna, "co", PROP_FLOAT, PROP_TRANSLATION);
758 RNA_def_property_array(prop, 3);
759 RNA_def_property_float_funcs(prop, "rna_BezTriple_ctrlpoint_get", "rna_BezTriple_ctrlpoint_set", NULL);
760 RNA_def_property_ui_text(prop, "Control Point", "Coordinates of the control point");
761 RNA_def_property_update(prop, 0, "rna_Curve_update_points");
763 prop= RNA_def_property(srna, "handle_right", PROP_FLOAT, PROP_TRANSLATION);
764 RNA_def_property_array(prop, 3);
765 RNA_def_property_float_funcs(prop, "rna_BezTriple_handle2_get", "rna_BezTriple_handle2_set", NULL);
766 RNA_def_property_ui_text(prop, "Handle 2", "Coordinates of the second handle");
767 RNA_def_property_update(prop, 0, "rna_Curve_update_points");
770 prop= RNA_def_property(srna, "tilt", PROP_FLOAT, PROP_NONE);
771 RNA_def_property_float_sdna(prop, NULL, "alfa");
772 /*RNA_def_property_range(prop, -FLT_MAX, FLT_MAX);*/
773 RNA_def_property_ui_text(prop, "Tilt", "Tilt in 3D View");
774 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
776 prop= RNA_def_property(srna, "weight", PROP_FLOAT, PROP_NONE);
777 RNA_def_property_range(prop, 0.01f, 100.0f);
778 RNA_def_property_ui_text(prop, "Weight", "Softbody goal weight");
779 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
781 prop= RNA_def_property(srna, "radius", PROP_FLOAT, PROP_NONE);
782 RNA_def_property_float_sdna(prop, NULL, "radius");
783 RNA_def_property_range(prop, 0.0f, FLT_MAX);
784 RNA_def_property_ui_text(prop, "Bevel Radius", "Radius for bevelling");
785 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
787 RNA_def_struct_path_func(srna, "rna_Curve_spline_point_path");
790 static void rna_def_path(BlenderRNA *brna, StructRNA *srna)
795 prop= RNA_def_property(srna, "path_duration", PROP_INT, PROP_NONE);
796 RNA_def_property_int_sdna(prop, NULL, "pathlen");
797 RNA_def_property_range(prop, 1, MAXFRAME);
798 RNA_def_property_ui_text(prop, "Path Length", "The number of frames that are needed to traverse the path, defining the maximum value for the 'Evaluation Time' setting");
799 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
802 prop= RNA_def_property(srna, "use_path", PROP_BOOLEAN, PROP_NONE);
803 RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_PATH);
804 RNA_def_property_ui_text(prop, "Path", "Enable the curve to become a translation path");
805 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
807 prop= RNA_def_property(srna, "use_path_follow", PROP_BOOLEAN, PROP_NONE);
808 RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_FOLLOW);
809 RNA_def_property_ui_text(prop, "Follow", "Make curve path children to rotate along the path");
810 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
812 prop= RNA_def_property(srna, "use_stretch", PROP_BOOLEAN, PROP_NONE);
813 RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_STRETCH);
814 RNA_def_property_ui_text(prop, "Stretch", "Option for curve-deform: makes deformed child to stretch along entire path");
815 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
817 prop= RNA_def_property(srna, "use_deform_bounds", PROP_BOOLEAN, PROP_NONE);
818 RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", CU_DEFORM_BOUNDS_OFF);
819 RNA_def_property_ui_text(prop, "Bounds Clamp", "Use the mesh bounds to clamp the deformation");
820 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
822 prop= RNA_def_property(srna, "use_time_offset", PROP_BOOLEAN, PROP_NONE);
823 RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_OFFS_PATHDIST);
824 RNA_def_property_ui_text(prop, "Offset Path Distance", "Children will use TimeOffs value as path distance offset");
825 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
827 prop= RNA_def_property(srna, "use_radius", PROP_BOOLEAN, PROP_NONE);
828 RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_PATH_RADIUS);
829 RNA_def_property_ui_text(prop, "Radius", "Option for paths: apply the curve radius with path following it and deforming");
830 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
833 static void rna_def_nurbs(BlenderRNA *brna, StructRNA *srna)
838 prop= RNA_def_property(srna, "use_uv_as_generated", PROP_BOOLEAN, PROP_NONE);
839 RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_UV_ORCO);
840 RNA_def_property_ui_text(prop, "Use UV for Mapping", "Uses the UV values as Generated textured coordinates");
841 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
844 static void rna_def_font(BlenderRNA *brna, StructRNA *srna)
848 static EnumPropertyItem prop_align_items[] = {
849 {CU_LEFT, "LEFT", 0, "Left", "Align text to the left"},
850 {CU_MIDDLE, "CENTRAL", 0, "Center", "Center text"},
851 {CU_RIGHT, "RIGHT", 0, "Right", "Align text to the right"},
852 {CU_JUSTIFY, "JUSTIFY", 0, "Justify", "Align to the left and the right"},
853 {CU_FLUSH, "FLUSH", 0, "Flush", "Align to the left and the right, with equal character spacing"},
854 {0, NULL, 0, NULL, NULL}};
857 prop= RNA_def_property(srna, "align", PROP_ENUM, PROP_NONE);
858 RNA_def_property_enum_sdna(prop, NULL, "spacemode");
859 RNA_def_property_enum_items(prop, prop_align_items);
860 RNA_def_property_ui_text(prop, "Text Align", "Text align from the object center");
861 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
864 prop= RNA_def_property(srna, "size", PROP_FLOAT, PROP_NONE);
865 RNA_def_property_float_sdna(prop, NULL, "fsize");
866 RNA_def_property_range(prop, 0.0001f, 10000.0f);
867 RNA_def_property_ui_range(prop, 0.01, 10, 1, 3);
868 RNA_def_property_ui_text(prop, "Font size", "");
869 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
871 prop= RNA_def_property(srna, "small_caps_scale", PROP_FLOAT, PROP_NONE);
872 RNA_def_property_float_sdna(prop, NULL, "smallcaps_scale");
873 RNA_def_property_ui_range(prop, 0, 1.0, 1, 2);
874 RNA_def_property_ui_text(prop, "Small Caps", "Scale of small capitals");
875 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
877 prop= RNA_def_property(srna, "space_line", PROP_FLOAT, PROP_NONE);
878 RNA_def_property_float_sdna(prop, NULL, "linedist");
879 RNA_def_property_range(prop, 0.0f, 10.0f);
880 RNA_def_property_ui_text(prop, "Distance between lines of text", "");
881 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
883 prop= RNA_def_property(srna, "space_word", PROP_FLOAT, PROP_NONE);
884 RNA_def_property_float_sdna(prop, NULL, "wordspace");
885 RNA_def_property_range(prop, 0.0f, 10.0f);
886 RNA_def_property_ui_text(prop, "Spacing between words", "");
887 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
889 prop= RNA_def_property(srna, "space_character", PROP_FLOAT, PROP_NONE);
890 RNA_def_property_float_sdna(prop, NULL, "spacing");
891 RNA_def_property_range(prop, 0.0f, 10.0f);
892 RNA_def_property_ui_text(prop, "Global spacing between characters", "");
893 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
895 prop= RNA_def_property(srna, "shear", PROP_FLOAT, PROP_NONE);
896 RNA_def_property_float_sdna(prop, NULL, "shear");
897 RNA_def_property_range(prop, -1.0f, 1.0f);
898 RNA_def_property_ui_text(prop, "Shear", "Italic angle of the characters");
899 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
901 prop= RNA_def_property(srna, "offset_x", PROP_FLOAT, PROP_NONE);
902 RNA_def_property_float_sdna(prop, NULL, "xof");
903 RNA_def_property_range(prop, -50.0f, 50.0f);
904 RNA_def_property_ui_text(prop, "X Offset", "Horizontal offset from the object origin");
905 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
907 prop= RNA_def_property(srna, "offset_y", PROP_FLOAT, PROP_NONE);
908 RNA_def_property_float_sdna(prop, NULL, "yof");
909 RNA_def_property_range(prop, -50.0f, 50.0f);
910 RNA_def_property_ui_text(prop, "Y Offset", "Vertical offset from the object origin");
911 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
913 prop= RNA_def_property(srna, "underline_position", PROP_FLOAT, PROP_NONE);
914 RNA_def_property_float_sdna(prop, NULL, "ulpos");
915 RNA_def_property_range(prop, -0.2f, 0.8f);
916 RNA_def_property_ui_text(prop, "Underline Position", "Vertical position of underline");
917 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
919 prop= RNA_def_property(srna, "underline_height", PROP_FLOAT, PROP_NONE);
920 RNA_def_property_float_sdna(prop, NULL, "ulheight");
921 RNA_def_property_range(prop, -0.2f, 0.8f);
922 RNA_def_property_ui_text(prop, "Underline Thickness", "");
923 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
925 prop= RNA_def_property(srna, "text_boxes", PROP_COLLECTION, PROP_NONE);
926 RNA_def_property_collection_sdna(prop, NULL, "tb", "totbox");
927 RNA_def_property_struct_type(prop, "TextBox");
928 RNA_def_property_ui_text(prop, "Textboxes", "");
930 prop= RNA_def_property(srna, "active_textbox", PROP_INT, PROP_NONE);
931 RNA_def_property_int_sdna(prop, NULL, "actbox");
932 RNA_def_property_ui_text(prop, "The active text box", "");
933 RNA_def_property_int_funcs(prop, NULL, NULL, "rna_Curve_active_textbox_index_range");
936 prop= RNA_def_property(srna, "family", PROP_STRING, PROP_NONE);
937 RNA_def_property_string_maxlength(prop, (sizeof((ID *)NULL)->name)-2);
938 RNA_def_property_ui_text(prop, "Object Font", "Use Blender Objects as font characters. Give font objects a common name followed by the character it represents, eg. familya, familyb etc, and turn on Verts Duplication");
939 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
941 prop= RNA_def_property(srna, "body", PROP_STRING, PROP_NONE);
942 RNA_def_property_string_sdna(prop, NULL, "str");
943 RNA_def_property_ui_text(prop, "Body Text", "contents of this text object");
944 RNA_def_property_string_funcs(prop, "rna_Curve_body_get", "rna_Curve_body_length", "rna_Curve_body_set");
945 RNA_def_property_string_maxlength(prop, 8192); /* note that originally str did not have a limit! */
946 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
948 prop= RNA_def_property(srna, "body_format", PROP_COLLECTION, PROP_NONE);
949 RNA_def_property_collection_sdna(prop, NULL, "strinfo", "len");
950 RNA_def_property_struct_type(prop, "TextCharacterFormat");
951 RNA_def_property_ui_text(prop, "Character Info", "Stores the style of each character");
954 prop= RNA_def_property(srna, "follow_curve", PROP_POINTER, PROP_NONE);
955 RNA_def_property_pointer_sdna(prop, NULL, "textoncurve");
956 RNA_def_property_pointer_funcs(prop, NULL, NULL, NULL, "rna_Curve_otherObject_poll");
957 RNA_def_property_flag(prop, PROP_EDITABLE);
958 RNA_def_property_ui_text(prop, "Text on Curve", "Curve deforming text object");
959 RNA_def_property_update(prop, 0, "rna_Curve_update_deps");
961 prop= RNA_def_property(srna, "font", PROP_POINTER, PROP_NONE);
962 RNA_def_property_pointer_sdna(prop, NULL, "vfont");
963 RNA_def_property_ui_text(prop, "Font", "");
964 RNA_def_property_flag(prop, PROP_EDITABLE);
965 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
967 prop= RNA_def_property(srna, "edit_format", PROP_POINTER, PROP_NONE);
968 RNA_def_property_pointer_sdna(prop, NULL, "curinfo");
969 RNA_def_property_ui_text(prop, "Edit Format", "Editing settings character formatting");
970 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
973 prop= RNA_def_property(srna, "use_fast_edit", PROP_BOOLEAN, PROP_NONE);
974 RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_FAST);
975 RNA_def_property_ui_text(prop, "Fast", "Don't fill polygons while editing");
976 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
979 static void rna_def_textbox(BlenderRNA *brna)
984 srna= RNA_def_struct(brna, "TextBox", NULL);
985 RNA_def_struct_ui_text(srna, "Text Box", "Text bounding box for layout");
988 prop= RNA_def_property(srna, "x", PROP_FLOAT, PROP_NONE);
989 RNA_def_property_float_sdna(prop, NULL, "x");
990 RNA_def_property_range(prop, -50.0f, 50.0f);
991 RNA_def_property_ui_text(prop, "Textbox X Offset", "");
992 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
994 prop= RNA_def_property(srna, "y", PROP_FLOAT, PROP_NONE);
995 RNA_def_property_float_sdna(prop, NULL, "y");
996 RNA_def_property_range(prop, -50.0f, 50.0f);
997 RNA_def_property_ui_text(prop, "Textbox Y Offset", "");
998 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
1000 prop= RNA_def_property(srna, "width", PROP_FLOAT, PROP_NONE);
1001 RNA_def_property_float_sdna(prop, NULL, "w");
1002 RNA_def_property_range(prop, 0.0f, 50.0f);
1003 RNA_def_property_ui_text(prop, "Textbox Width", "");
1004 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
1006 prop= RNA_def_property(srna, "height", PROP_FLOAT, PROP_NONE);
1007 RNA_def_property_float_sdna(prop, NULL, "h");
1008 RNA_def_property_range(prop, 0.0f, 50.0f);
1009 RNA_def_property_ui_text(prop, "Textbox Height", "");
1010 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
1012 RNA_def_struct_path_func(srna, "rna_TextBox_path");
1015 static void rna_def_charinfo(BlenderRNA *brna)
1020 srna= RNA_def_struct(brna, "TextCharacterFormat", NULL);
1021 RNA_def_struct_sdna(srna, "CharInfo");
1022 RNA_def_struct_ui_text(srna, "Text Character Format", "Text character formatting settings");
1025 prop= RNA_def_property(srna, "use_bold", PROP_BOOLEAN, PROP_NONE);
1026 RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_CHINFO_BOLD);
1027 RNA_def_property_ui_text(prop, "Bold", "");
1028 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
1030 prop= RNA_def_property(srna, "use_italic", PROP_BOOLEAN, PROP_NONE);
1031 RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_CHINFO_ITALIC);
1032 RNA_def_property_ui_text(prop, "Italic", "");
1033 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
1035 prop= RNA_def_property(srna, "use_underline", PROP_BOOLEAN, PROP_NONE);
1036 RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_CHINFO_UNDERLINE);
1037 RNA_def_property_ui_text(prop, "Underline", "");
1038 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
1040 /* probably there is no reason to expose this */
1041 /* prop= RNA_def_property(srna, "wrap", PROP_BOOLEAN, PROP_NONE);
1042 RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_CHINFO_WRAP);
1043 RNA_def_property_ui_text(prop, "Wrap", "");
1044 RNA_def_property_update(prop, 0, "rna_Curve_update_data"); */
1046 prop= RNA_def_property(srna, "use_small_caps", PROP_BOOLEAN, PROP_NONE);
1047 RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_CHINFO_SMALLCAPS);
1048 RNA_def_property_ui_text(prop, "Small Caps", "");
1049 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
1052 static void rna_def_surface(BlenderRNA *brna)
1056 srna= RNA_def_struct(brna, "SurfaceCurve", "Curve");
1057 RNA_def_struct_sdna(srna, "Curve");
1058 RNA_def_struct_ui_text(srna, "Surface Curve", "Curve datablock used for storing surfaces");
1059 RNA_def_struct_ui_icon(srna, ICON_SURFACE_DATA);
1061 rna_def_nurbs(brna, srna);
1064 static void rna_def_text(BlenderRNA *brna)
1068 srna= RNA_def_struct(brna, "TextCurve", "Curve");
1069 RNA_def_struct_sdna(srna, "Curve");
1070 RNA_def_struct_ui_text(srna, "Text Curve", "Curve datablock used for storing text");
1071 RNA_def_struct_ui_icon(srna, ICON_FONT_DATA);
1073 rna_def_font(brna, srna);
1074 rna_def_nurbs(brna, srna);
1078 /* curve.splines[0].points */
1079 static void rna_def_curve_spline_points(BlenderRNA *brna, PropertyRNA *cprop)
1082 //PropertyRNA *prop;
1087 RNA_def_property_srna(cprop, "SplinePoints");
1088 srna= RNA_def_struct(brna, "SplinePoints", NULL);
1089 RNA_def_struct_sdna(srna, "Nurb");
1090 RNA_def_struct_ui_text(srna, "Spline Points", "Collection of spline points");
1092 func= RNA_def_function(srna, "add", "rna_Curve_spline_points_add");
1093 RNA_def_function_ui_description(func, "Add a number of points to this spline.");
1094 RNA_def_function_flag(func, FUNC_USE_SELF_ID|FUNC_USE_REPORTS);
1095 parm= RNA_def_int(func, "number", 1, INT_MIN, INT_MAX, "Number", "Number of points to add to the spline", 0, INT_MAX);
1098 func= RNA_def_function(srna, "remove", "rna_Curve_spline_remove");
1099 RNA_def_function_ui_description(func, "Remove a spline from a curve.");
1100 RNA_def_function_flag(func, FUNC_USE_REPORTS);
1101 parm= RNA_def_pointer(func, "spline", "Spline", "", "The spline to remove.");
1102 RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL);
1106 static void rna_def_curve_spline_bezpoints(BlenderRNA *brna, PropertyRNA *cprop)
1109 //PropertyRNA *prop;
1114 RNA_def_property_srna(cprop, "SplineBezierPoints");
1115 srna= RNA_def_struct(brna, "SplineBezierPoints", NULL);
1116 RNA_def_struct_sdna(srna, "Nurb");
1117 RNA_def_struct_ui_text(srna, "Spline Bezier Points", "Collection of spline bezirt points");
1119 func= RNA_def_function(srna, "add", "rna_Curve_spline_bezpoints_add");
1120 RNA_def_function_ui_description(func, "Add a number of points to this spline.");
1121 RNA_def_function_flag(func, FUNC_USE_SELF_ID|FUNC_USE_REPORTS);
1122 parm= RNA_def_int(func, "number", 1, INT_MIN, INT_MAX, "Number", "Number of points to add to the spline", 0, INT_MAX);
1125 func= RNA_def_function(srna, "remove", "rna_Curve_spline_remove");
1126 RNA_def_function_ui_description(func, "Remove a spline from a curve.");
1127 RNA_def_function_flag(func, FUNC_USE_REPORTS);
1128 parm= RNA_def_pointer(func, "spline", "Spline", "", "The spline to remove.");
1129 RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL);
1134 static void rna_def_curve_splines(BlenderRNA *brna, PropertyRNA *cprop)
1142 RNA_def_property_srna(cprop, "CurveSplines");
1143 srna= RNA_def_struct(brna, "CurveSplines", NULL);
1144 RNA_def_struct_sdna(srna, "Curve");
1145 RNA_def_struct_ui_text(srna, "Curve Splines", "Collection of curve splines");
1147 func= RNA_def_function(srna, "new", "rna_Curve_spline_new");
1148 RNA_def_function_ui_description(func, "Add a new spline to the curve.");
1149 parm= RNA_def_enum(func, "type", curve_type_items, CU_POLY, "", "type for the new spline.");
1150 RNA_def_property_flag(parm, PROP_REQUIRED);
1151 parm= RNA_def_pointer(func, "spline", "Spline", "", "The newly created spline.");
1152 RNA_def_function_return(func, parm);
1154 func= RNA_def_function(srna, "remove", "rna_Curve_spline_remove");
1155 RNA_def_function_ui_description(func, "Remove a spline from a curve.");
1156 RNA_def_function_flag(func, FUNC_USE_REPORTS);
1157 parm= RNA_def_pointer(func, "spline", "Spline", "", "The spline to remove.");
1158 RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL);
1160 prop= RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
1161 RNA_def_property_struct_type(prop, "Object");
1162 RNA_def_property_pointer_funcs(prop, "rna_Curve_active_spline_get", "rna_Curve_active_spline_set", NULL, NULL);
1163 RNA_def_property_flag(prop, PROP_EDITABLE);
1164 RNA_def_property_ui_text(prop, "Active Spline", "Active curve spline");
1165 /* Could call: ED_base_object_activate(C, scene->basact);
1166 * but would be a bad level call and it seems the notifier is enough */
1167 RNA_def_property_update(prop, NC_SCENE|ND_OB_ACTIVE, NULL);
1171 static void rna_def_curve(BlenderRNA *brna)
1176 static EnumPropertyItem curve_twist_mode_items[] = {
1177 {CU_TWIST_Z_UP, "Z_UP", 0, "Z-Up", "Use Z-Up axis to calculate the curve twist at each point"},
1178 {CU_TWIST_MINIMUM, "MINIMUM", 0, "Minimum", "Use the least twist over the entire curve"},
1179 {CU_TWIST_TANGENT, "TANGENT", 0, "Tangent", "Use the tangent to calculate twist"},
1180 {0, NULL, 0, NULL, NULL}};
1182 static const EnumPropertyItem curve_axis_items[]= {
1183 {0, "2D", 0, "2D", "Clamp the Z axis of of the curve"},
1184 {CU_3D, "3D", 0, "3D", "Allow editing on the Z axis of this curve, also alows tilt and curve radius to be used"},
1185 {0, NULL, 0, NULL, NULL}};
1187 srna= RNA_def_struct(brna, "Curve", "ID");
1188 RNA_def_struct_ui_text(srna, "Curve", "Curve datablock storing curves, splines and NURBS");
1189 RNA_def_struct_ui_icon(srna, ICON_CURVE_DATA);
1190 RNA_def_struct_refine_func(srna, "rna_Curve_refine");
1192 rna_def_animdata_common(srna);
1194 prop= RNA_def_property(srna, "shape_keys", PROP_POINTER, PROP_NONE);
1195 RNA_def_property_pointer_sdna(prop, NULL, "key");
1196 RNA_def_property_ui_text(prop, "Shape Keys", "");
1199 prop= RNA_def_property(srna, "splines", PROP_COLLECTION, PROP_NONE);
1201 RNA_def_property_collection_sdna(prop, NULL, "nurb", NULL);
1203 /* this way we get editmode nurbs too, keyframe in editmode */
1204 RNA_def_property_collection_funcs(prop, "rna_Curve_splines_begin", "rna_iterator_listbase_next", "rna_iterator_listbase_end", "rna_iterator_listbase_get", 0, 0, 0);
1206 RNA_def_property_struct_type(prop, "Spline");
1207 RNA_def_property_ui_text(prop, "Splines", "Collection of splines in this curve data object");
1208 rna_def_curve_splines(brna, prop);
1210 prop= RNA_def_property(srna, "show_handles", PROP_BOOLEAN, PROP_NONE);
1211 RNA_def_property_boolean_negative_sdna(prop, NULL, "drawflag", CU_HIDE_HANDLES);
1212 RNA_def_property_ui_text(prop, "Draw Handles", "Display bezier handles in editmode");
1213 RNA_def_property_update(prop, NC_GEOM|ND_DATA, NULL);
1215 prop= RNA_def_property(srna, "show_normal_face", PROP_BOOLEAN, PROP_NONE);
1216 RNA_def_property_boolean_negative_sdna(prop, NULL, "drawflag", CU_HIDE_NORMALS);
1217 RNA_def_property_ui_text(prop, "Draw Normals", "Display 3D curve normals in editmode");
1218 RNA_def_property_update(prop, NC_GEOM|ND_DATA, NULL);
1220 rna_def_path(brna, srna);
1223 prop= RNA_def_property(srna, "bevel_resolution", PROP_INT, PROP_NONE);
1224 RNA_def_property_int_sdna(prop, NULL, "bevresol");
1225 RNA_def_property_range(prop, 0, 32);
1226 RNA_def_property_ui_range(prop, 0, 32, 1.0, 0);
1227 RNA_def_property_ui_text(prop, "Bevel Resolution", "Bevel resolution when depth is non-zero and no specific bevel object has been defined");
1228 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
1230 prop= RNA_def_property(srna, "offset", PROP_FLOAT, PROP_NONE);
1231 RNA_def_property_float_sdna(prop, NULL, "width");
1232 RNA_def_property_ui_range(prop, -1.0, 1.0, 0.1, 3);
1233 RNA_def_property_float_funcs(prop, "rna_Curve_offset_get", "rna_Curve_offset_set", NULL);
1234 RNA_def_property_ui_text(prop, "Offset", "Offset the curve to adjust the width of a text");
1235 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
1237 prop= RNA_def_property(srna, "extrude", PROP_FLOAT, PROP_NONE);
1238 RNA_def_property_float_sdna(prop, NULL, "ext1");
1239 RNA_def_property_ui_range(prop, 0, 100.0, 0.1, 3);
1240 RNA_def_property_range(prop, 0.0, FLT_MAX);
1241 RNA_def_property_ui_text(prop, "Extrude", "Amount of curve extrusion when not using a bevel object");
1242 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
1244 prop= RNA_def_property(srna, "bevel_depth", PROP_FLOAT, PROP_NONE);
1245 RNA_def_property_float_sdna(prop, NULL, "ext2");
1246 RNA_def_property_ui_range(prop, 0, 100.0, 0.1, 3);
1247 RNA_def_property_ui_text(prop, "Bevel Depth", "Bevel depth when not using a bevel object");
1248 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
1250 prop= RNA_def_property(srna, "resolution_u", PROP_INT, PROP_NONE);
1251 RNA_def_property_int_sdna(prop, NULL, "resolu");
1252 RNA_def_property_range(prop, 1, INT_MAX);
1253 RNA_def_property_ui_range(prop, 1, 64, 1, 0);
1254 RNA_def_property_ui_text(prop, "Resolution U", "Surface resolution in U direction");
1255 RNA_def_property_update(prop, 0, "rna_Curve_resolution_u_update_data");
1257 prop= RNA_def_property(srna, "resolution_v", PROP_INT, PROP_NONE);
1258 RNA_def_property_int_sdna(prop, NULL, "resolv");
1259 RNA_def_property_ui_range(prop, 1, 64, 1, 0);
1260 RNA_def_property_range(prop, 1, INT_MAX);
1261 RNA_def_property_ui_text(prop, "Resolution V", "Surface resolution in V direction");
1262 RNA_def_property_update(prop, 0, "rna_Curve_resolution_v_update_data");
1264 prop= RNA_def_property(srna, "render_resolution_u", PROP_INT, PROP_NONE);
1265 RNA_def_property_int_sdna(prop, NULL, "resolu_ren");
1266 RNA_def_property_range(prop, 0, INT_MAX);
1267 RNA_def_property_ui_range(prop, 0, 64, 1, 0);
1268 RNA_def_property_ui_text(prop, "Render Resolution U", "Surface resolution in U direction used while rendering. Zero skips this property");
1270 prop= RNA_def_property(srna, "render_resolution_v", PROP_INT, PROP_NONE);
1271 RNA_def_property_int_sdna(prop, NULL, "resolv_ren");
1272 RNA_def_property_ui_range(prop, 0, 64, 1, 0);
1273 RNA_def_property_range(prop, 0, INT_MAX);
1274 RNA_def_property_ui_text(prop, "Render Resolution V", "Surface resolution in V direction used while rendering. Zero skips this property");
1277 prop= RNA_def_property(srna, "eval_time", PROP_FLOAT, PROP_NONE);
1278 RNA_def_property_float_sdna(prop, NULL, "ctime");
1279 RNA_def_property_ui_text(prop, "Evaluation Time", "Parametric position along the length of the curve that Objects 'following' it should be at. Position is evaluated by dividing by the 'Path Length' value");
1280 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
1283 prop= RNA_def_property(srna, "bevel_object", PROP_POINTER, PROP_NONE);
1284 RNA_def_property_struct_type(prop, "Object");
1285 RNA_def_property_pointer_sdna(prop, NULL, "bevobj");
1286 RNA_def_property_flag(prop, PROP_EDITABLE);
1287 RNA_def_property_ui_text(prop, "Bevel Object", "Curve object name that defines the bevel shape");
1288 RNA_def_property_update(prop, 0, "rna_Curve_update_deps");
1289 RNA_def_property_pointer_funcs(prop, "rna_Curve_bevelObject_get", "rna_Curve_bevelObject_set", NULL, "rna_Curve_otherObject_poll");
1291 prop= RNA_def_property(srna, "taper_object", PROP_POINTER, PROP_NONE);
1292 RNA_def_property_struct_type(prop, "Object");
1293 RNA_def_property_pointer_sdna(prop, NULL, "taperobj");
1294 RNA_def_property_flag(prop, PROP_EDITABLE);
1295 RNA_def_property_ui_text(prop, "Taper Object", "Curve object name that defines the taper (width)");
1296 RNA_def_property_update(prop, 0, "rna_Curve_update_deps");
1297 RNA_def_property_pointer_funcs(prop, "rna_Curve_taperObject_get", "rna_Curve_taperObject_set", NULL, "rna_Curve_otherObject_poll");
1301 prop= RNA_def_property(srna, "dimensions", PROP_ENUM, PROP_NONE); /* as an enum */
1302 RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag");
1303 RNA_def_property_enum_items(prop, curve_axis_items);
1304 RNA_def_property_enum_funcs(prop, NULL, "rna_Curve_dimension_set", NULL);
1305 RNA_def_property_ui_text(prop, "Dimensions", "Select 2D or 3D curve type");
1306 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
1308 prop= RNA_def_property(srna, "use_fill_front", PROP_BOOLEAN, PROP_NONE);
1309 RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_FRONT);
1310 RNA_def_property_ui_text(prop, "Front", "Draw filled front for extruded/beveled curves");
1311 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
1313 prop= RNA_def_property(srna, "use_fill_back", PROP_BOOLEAN, PROP_NONE);
1314 RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_BACK);
1315 RNA_def_property_ui_text(prop, "Back", "Draw filled back for extruded/beveled curves");
1316 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
1318 prop= RNA_def_property(srna, "twist_mode", PROP_ENUM, PROP_NONE);
1319 RNA_def_property_enum_sdna(prop, NULL, "twist_mode");
1320 RNA_def_property_enum_items(prop, curve_twist_mode_items);
1321 RNA_def_property_ui_text(prop, "Twist Method", "The type of tilt calculation for 3D Curves");
1322 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
1324 // XXX - would be nice to have a better way to do this, only add for testing.
1325 prop= RNA_def_property(srna, "twist_smooth", PROP_FLOAT, PROP_NONE);
1326 RNA_def_property_float_sdna(prop, NULL, "twist_smooth");
1327 RNA_def_property_ui_range(prop, 0, 100.0, 0.1, 0);
1328 RNA_def_property_ui_text(prop, "Twist Smooth", "Smoothing iteration for tangents");
1329 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
1331 prop= RNA_def_property(srna, "use_fill_deform", PROP_BOOLEAN, PROP_NONE);
1332 RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_DEFORM_FILL);
1333 RNA_def_property_ui_text(prop, "Fill deformed", "Fill curve after applying shape keys and all modifiers");
1334 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
1337 prop= RNA_def_property(srna, "use_auto_texspace", PROP_BOOLEAN, PROP_NONE);
1338 RNA_def_property_boolean_sdna(prop, NULL, "texflag", CU_AUTOSPACE);
1339 RNA_def_property_ui_text(prop, "Auto Texture Space", "Adjusts active object's texture space automatically when transforming object");
1341 prop= RNA_def_property(srna, "texspace_location", PROP_FLOAT, PROP_TRANSLATION);
1342 RNA_def_property_array(prop, 3);
1343 RNA_def_property_ui_text(prop, "Texture Space Location", "Texture space location");
1344 RNA_def_property_editable_func(prop, "rna_Curve_texspace_editable");
1345 RNA_def_property_float_funcs(prop, "rna_Curve_texspace_loc_get", "rna_Curve_texspace_loc_set", NULL);
1346 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
1348 prop= RNA_def_property(srna, "texspace_size", PROP_FLOAT, PROP_XYZ);
1349 RNA_def_property_array(prop, 3);
1350 RNA_def_property_ui_text(prop, "Texture Space Size", "Texture space size");
1351 RNA_def_property_editable_func(prop, "rna_Curve_texspace_editable");
1352 RNA_def_property_float_funcs(prop, "rna_Curve_texspace_size_get", "rna_Curve_texspace_size_set", NULL);
1353 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
1355 /* not supported yet
1356 prop= RNA_def_property(srna, "texspace_rot", PROP_FLOAT, PROP_EULER);
1357 RNA_def_property_float(prop, NULL, "rot");
1358 RNA_def_property_ui_text(prop, "Texture Space Rotation", "Texture space rotation");
1359 RNA_def_property_editable_func(prop, texspace_editable);
1360 RNA_def_property_update(prop, 0, "rna_Curve_update_data");*/
1362 prop= RNA_def_property(srna, "use_uv_as_generated", PROP_BOOLEAN, PROP_NONE);
1363 RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_UV_ORCO);
1364 RNA_def_property_ui_text(prop, "Use UV for mapping", "Uses the UV values as Generated textured coordinates");
1365 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
1368 prop= RNA_def_property(srna, "materials", PROP_COLLECTION, PROP_NONE);
1369 RNA_def_property_collection_sdna(prop, NULL, "mat", "totcol");
1370 RNA_def_property_struct_type(prop, "Material");
1371 RNA_def_property_ui_text(prop, "Materials", "");
1372 RNA_def_property_srna(prop, "IDMaterials"); /* see rna_ID.c */
1375 static void rna_def_curve_nurb(BlenderRNA *brna)
1377 static EnumPropertyItem spline_interpolation_items[] = {
1378 {KEY_LINEAR, "LINEAR", 0, "Linear", ""},
1379 {KEY_CARDINAL, "CARDINAL", 0, "Cardinal", ""},
1380 {KEY_BSPLINE, "BSPLINE", 0, "BSpline", ""},
1381 {KEY_CU_EASE, "EASE", 0, "Ease", ""}, /* todo, define somewhere, not one of BEZT_IPO_* */
1382 {0, NULL, 0, NULL, NULL}};
1387 srna= RNA_def_struct(brna, "Spline", NULL);
1388 RNA_def_struct_sdna(srna, "Nurb");
1389 RNA_def_struct_ui_text(srna, "Spline", "Element of a curve, either Nurbs, Bezier or Polyline or a character with text objects");
1391 prop= RNA_def_property(srna, "points", PROP_COLLECTION, PROP_NONE);
1392 RNA_def_property_collection_sdna(prop, NULL, "bp", NULL);
1393 RNA_def_property_struct_type(prop, "SplinePoint");
1394 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);
1395 RNA_def_property_ui_text(prop, "Points", "Collection of points that make up this poly or nurbs spline");
1396 rna_def_curve_spline_points(brna, prop);
1398 prop= RNA_def_property(srna, "bezier_points", PROP_COLLECTION, PROP_NONE);
1399 RNA_def_property_struct_type(prop, "BezierSplinePoint");
1400 RNA_def_property_collection_sdna(prop, NULL, "bezt", "pntsu");
1401 RNA_def_property_ui_text(prop, "Bezier Points", "Collection of points for bezier curves only");
1402 rna_def_curve_spline_bezpoints(brna, prop);
1405 prop= RNA_def_property(srna, "tilt_interpolation", PROP_ENUM, PROP_NONE);
1406 RNA_def_property_enum_sdna(prop, NULL, "tilt_interp");
1407 RNA_def_property_enum_items(prop, spline_interpolation_items);
1408 RNA_def_property_ui_text(prop, "Tilt Interpolation", "The type of tilt interpolation for 3D, Bezier curves");
1409 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
1411 prop= RNA_def_property(srna, "radius_interpolation", PROP_ENUM, PROP_NONE);
1412 RNA_def_property_enum_sdna(prop, NULL, "radius_interp");
1413 RNA_def_property_enum_items(prop, spline_interpolation_items);
1414 RNA_def_property_ui_text(prop, "Radius Interpolation", "The type of radius interpolation for Bezier curves");
1415 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
1417 // XXX - switching type probably needs comprehensive recalc of data like in 2.4x
1418 prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
1419 RNA_def_property_enum_items(prop, curve_type_items);
1420 RNA_def_property_enum_funcs(prop, NULL, "rna_Nurb_type_set", NULL);
1421 RNA_def_property_ui_text(prop, "Type", "The interpolation type for this curve element");
1422 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
1424 prop= RNA_def_property(srna, "point_count_u", PROP_INT, PROP_UNSIGNED);
1425 RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* editing this needs knot recalc*/
1426 RNA_def_property_int_sdna(prop, NULL, "pntsu");
1427 RNA_def_property_ui_text(prop, "Points U", "Total number points for the curve or surface in the U direction");
1428 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
1430 prop= RNA_def_property(srna, "point_count_v", PROP_INT, PROP_UNSIGNED);
1431 RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* editing this needs knot recalc*/
1432 RNA_def_property_int_sdna(prop, NULL, "pntsv");
1433 RNA_def_property_ui_text(prop, "Points V", "Total number points for the surface on the V direction");
1434 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
1437 prop= RNA_def_property(srna, "order_u", PROP_INT, PROP_NONE);
1438 RNA_def_property_int_sdna(prop, NULL, "orderu");
1439 RNA_def_property_range(prop, 2, 6);
1440 RNA_def_property_ui_text(prop, "Order U", "Nurbs order in the U direction (For splines and surfaces), Higher values let points influence a greater area");
1441 RNA_def_property_update(prop, 0, "rna_Nurb_update_knot_u");
1443 prop= RNA_def_property(srna, "order_v", PROP_INT, PROP_NONE);
1444 RNA_def_property_int_sdna(prop, NULL, "orderv");
1445 RNA_def_property_range(prop, 2, 6);
1446 RNA_def_property_ui_text(prop, "Order V", "Nurbs order in the V direction (For surfaces only), Higher values let points influence a greater area");
1447 RNA_def_property_update(prop, 0, "rna_Nurb_update_knot_v");
1450 prop= RNA_def_property(srna, "resolution_u", PROP_INT, PROP_NONE);
1451 RNA_def_property_int_sdna(prop, NULL, "resolu");
1452 RNA_def_property_range(prop, 1, INT_MAX);
1453 RNA_def_property_ui_range(prop, 1, 64, 1, 0);
1454 RNA_def_property_ui_text(prop, "Resolution U", "Curve or Surface subdivisions per segment");
1455 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
1457 prop= RNA_def_property(srna, "resolution_v", PROP_INT, PROP_NONE);
1458 RNA_def_property_int_sdna(prop, NULL, "resolv");
1459 RNA_def_property_range(prop, 1, INT_MAX);
1460 RNA_def_property_ui_range(prop, 1, 64, 1, 0);
1461 RNA_def_property_ui_text(prop, "Resolution V", "Surface subdivisions per segment");
1462 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
1464 prop= RNA_def_property(srna, "use_cyclic_u", PROP_BOOLEAN, PROP_NONE);
1465 RNA_def_property_boolean_sdna(prop, NULL, "flagu", CU_NURB_CYCLIC);
1466 RNA_def_property_ui_text(prop, "Cyclic U", "Make this curve or surface a closed loop in the U direction");
1467 RNA_def_property_update(prop, 0, "rna_Nurb_update_cyclic_u");
1469 prop= RNA_def_property(srna, "use_cyclic_v", PROP_BOOLEAN, PROP_NONE);
1470 RNA_def_property_boolean_sdna(prop, NULL, "flagv", CU_NURB_CYCLIC);
1471 RNA_def_property_ui_text(prop, "Cyclic V", "Make this surface a closed loop in the V direction");
1472 RNA_def_property_update(prop, 0, "rna_Nurb_update_cyclic_v");
1475 /* Note, endpoint and bezier flags should never be on at the same time! */
1476 prop= RNA_def_property(srna, "use_endpoint_u", PROP_BOOLEAN, PROP_NONE);
1477 RNA_def_property_boolean_sdna(prop, NULL, "flagu", CU_NURB_ENDPOINT);
1478 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)");
1479 RNA_def_property_update(prop, 0, "rna_Nurb_update_knot_u");
1481 prop= RNA_def_property(srna, "use_endpoint_v", PROP_BOOLEAN, PROP_NONE);
1482 RNA_def_property_boolean_sdna(prop, NULL, "flagv", CU_NURB_ENDPOINT);
1483 RNA_def_property_ui_text(prop, "Endpoint V", "Make this nurbs surface meet the endpoints in the V direction (Cyclic V must be disabled)");
1484 RNA_def_property_update(prop, 0, "rna_Nurb_update_knot_v");
1486 prop= RNA_def_property(srna, "use_bezier_u", PROP_BOOLEAN, PROP_NONE);
1487 RNA_def_property_boolean_sdna(prop, NULL, "flagu", CU_NURB_BEZIER);
1488 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)");
1489 RNA_def_property_update(prop, 0, "rna_Nurb_update_knot_u");
1491 prop= RNA_def_property(srna, "use_bezier_v", PROP_BOOLEAN, PROP_NONE);
1492 RNA_def_property_boolean_sdna(prop, NULL, "flagv", CU_NURB_BEZIER);
1493 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)");
1494 RNA_def_property_update(prop, 0, "rna_Nurb_update_knot_v");
1497 prop= RNA_def_property(srna, "use_smooth", PROP_BOOLEAN, PROP_NONE);
1498 RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_SMOOTH);
1499 RNA_def_property_ui_text(prop, "Smooth", "Smooth the normals of the surface or beveled curve");
1500 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
1502 prop= RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE);
1503 RNA_def_property_boolean_sdna(prop, NULL, "hide", 1);
1504 RNA_def_property_ui_text(prop, "Hide", "Hide this curve in editmode");
1505 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
1507 prop= RNA_def_property(srna, "material_index", PROP_INT, PROP_UNSIGNED);
1508 RNA_def_property_int_sdna(prop, NULL, "mat_nr");
1509 RNA_def_property_ui_text(prop, "Material Index", "");
1510 RNA_def_property_int_funcs(prop, NULL, NULL, "rna_Curve_material_index_range");
1511 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
1513 prop= RNA_def_property(srna, "character_index", PROP_INT, PROP_UNSIGNED);
1514 RNA_def_property_int_sdna(prop, NULL, "charidx");
1515 RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* editing this needs knot recalc*/
1516 RNA_def_property_ui_text(prop, "Character Index", "Location of this character in the text data (only for text curves)");
1517 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
1519 RNA_def_struct_path_func(srna, "rna_Curve_spline_path");
1522 void RNA_def_curve(BlenderRNA *brna)
1524 rna_def_curve(brna);
1525 rna_def_surface(brna);
1527 rna_def_textbox(brna);
1528 rna_def_charinfo(brna);
1529 rna_def_bpoint(brna);
1530 rna_def_beztriple(brna);
1531 rna_def_curve_nurb(brna);