2 * ***** BEGIN GPL LICENSE BLOCK *****
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * Contributor(s): Blender Foundation (2008), Juho Veps�l�inen
20 * ***** END GPL LICENSE BLOCK *****
23 /** \file blender/makesrna/intern/rna_curve.c
29 #include "DNA_curve_types.h"
30 #include "DNA_key_types.h"
31 #include "DNA_material_types.h"
32 #include "DNA_scene_types.h"
34 #include "BLI_utildefines.h"
37 #include "BLF_translation.h"
41 #include "RNA_access.h"
42 #include "RNA_define.h"
43 #include "RNA_enum_types.h"
45 #include "rna_internal.h"
49 #include "BKE_curve.h"
53 static EnumPropertyItem beztriple_handle_type_items[] = {
54 {HD_FREE, "FREE", 0, "Free", ""},
55 {HD_VECT, "VECTOR", 0, "Vector", ""},
56 {HD_ALIGN, "ALIGNED", 0, "Aligned", ""},
57 {HD_AUTO, "AUTO", 0, "Auto", ""},
58 {0, NULL, 0, NULL, NULL}
62 EnumPropertyItem keyframe_handle_type_items[] = {
63 {HD_FREE, "FREE", 0, "Free", ""},
64 {HD_VECT, "VECTOR", 0, "Vector", ""},
65 {HD_ALIGN, "ALIGNED", 0, "Aligned", ""},
66 {HD_AUTO, "AUTO", 0, "Automatic", ""},
67 {HD_AUTO_ANIM, "AUTO_CLAMPED", 0, "Auto Clamped", "Auto handles clamped to not overshoot"},
68 {0, NULL, 0, NULL, NULL}
71 EnumPropertyItem beztriple_interpolation_mode_items[] = {
73 {0, "", 0, N_("Interpolation"), "Standard transitions between keyframes"},
74 {BEZT_IPO_CONST, "CONSTANT", 0, "Constant", "No interpolation, value of A gets held until B is encountered"},
75 {BEZT_IPO_LIN, "LINEAR", 0, "Linear", "Straight-line interpolation between A and B (i.e. no ease in/out)"},
76 {BEZT_IPO_BEZ, "BEZIER", 0, "Bezier", "Smooth interpolation between A and B, with some control over curve shape"},
79 {0, "", 0, N_("Easing (by strength)"), "Predefined inertial transitions, useful for motion graphics (from least to most ''dramatic'')"},
80 {BEZT_IPO_QUAD, "QUAD", 0, "Quadratic", "Quadratic easing (weakest)"},
81 {BEZT_IPO_CUBIC, "CUBIC", 0, "Cubic", "Cubic easing"},
82 {BEZT_IPO_QUART, "QUART", 0, "Quartic", "Quartic easing"},
83 {BEZT_IPO_QUINT, "QUINT", 0, "Quintic", "Quintic easing"},
84 {BEZT_IPO_EXPO, "EXPO", 0, "Exponential", "Exponential easing (strongest)"},
86 {0, "", 0, N_("Dynamic Effects"), "Simple physics-inspired easing effects"},
87 {BEZT_IPO_BACK, "BACK", 0, "Back", "Cubic easing with overshoot and settle"},
88 {BEZT_IPO_BOUNCE, "BOUNCE", 0, "Bounce", "Exponentially decaying parabolic bounce, like when objects collide"},
89 {BEZT_IPO_ELASTIC, "ELASTIC", 0, "Elastic", "Exponentially decaying sine wave, like an elastic band"},
91 {0, "", 0, N_("Other"), "Other easing equations"},
92 {BEZT_IPO_SINE, "SINE", 0, "Sinusoidal", "Sinusoidal easing"},
93 {BEZT_IPO_CIRC, "CIRC", 0, "Circular", "Circular easing"},
95 {0, NULL, 0, NULL, NULL}
99 static EnumPropertyItem curve_type_items[] = {
100 {CU_POLY, "POLY", 0, "Poly", ""},
101 {CU_BEZIER, "BEZIER", 0, "Bezier", ""},
102 {CU_BSPLINE, "BSPLINE", 0, "BSpline", ""},
103 {CU_CARDINAL, "CARDINAL", 0, "Cardinal", ""},
104 {CU_NURBS, "NURBS", 0, "Ease", ""},
105 {0, NULL, 0, NULL, NULL}
109 static const EnumPropertyItem curve3d_fill_mode_items[] = {
110 {0, "FULL", 0, "Full", ""},
111 {CU_BACK, "BACK", 0, "Back", ""},
112 {CU_FRONT, "FRONT", 0, "Front", ""},
113 {CU_FRONT | CU_BACK, "HALF", 0, "Half", ""},
114 {0, NULL, 0, NULL, NULL}
118 static const EnumPropertyItem curve2d_fill_mode_items[] = {
119 {0, "NONE", 0, "None", ""},
120 {CU_BACK, "BACK", 0, "Back", ""},
121 {CU_FRONT, "FRONT", 0, "Front", ""},
122 {CU_FRONT | CU_BACK, "BOTH", 0, "Both", ""},
123 {0, NULL, 0, NULL, NULL}
129 #include "BLI_math.h"
131 #include "DNA_object_types.h"
133 #include "BKE_curve.h"
134 #include "BKE_depsgraph.h"
135 #include "BKE_main.h"
139 #include "MEM_guardedalloc.h"
141 #include "ED_curve.h" /* for BKE_curve_nurbs_get */
143 /* highly irritating but from RNA we cant know this */
144 static Nurb *curve_nurb_from_point(Curve *cu, const void *point, int *nu_index, int *pt_index)
146 ListBase *nurbs = BKE_curve_nurbs_get(cu);
150 for (nu = nurbs->first; nu; nu = nu->next, i++) {
151 if (nu->type == CU_BEZIER) {
152 if (point >= (void *)nu->bezt && point < (void *)(nu->bezt + nu->pntsu)) {
157 if (point >= (void *)nu->bp && point < (void *)(nu->bp + (nu->pntsu * nu->pntsv))) {
169 if (nu->type == CU_BEZIER) *pt_index = (int)((BezTriple *)point - nu->bezt);
170 else *pt_index = (int)((BPoint *)point - nu->bp);
177 static StructRNA *rna_Curve_refine(PointerRNA *ptr)
179 Curve *cu = (Curve *)ptr->data;
180 short obtype = BKE_curve_type_get(cu);
182 if (obtype == OB_FONT) return &RNA_TextCurve;
183 else if (obtype == OB_SURF) return &RNA_SurfaceCurve;
184 else return &RNA_Curve;
187 static void rna_BezTriple_handle1_get(PointerRNA *ptr, float *values)
189 BezTriple *bezt = (BezTriple *)ptr->data;
190 copy_v3_v3(values, bezt->vec[0]);
193 static void rna_BezTriple_handle1_set(PointerRNA *ptr, const float *values)
195 BezTriple *bezt = (BezTriple *)ptr->data;
196 copy_v3_v3(bezt->vec[0], values);
199 static void rna_BezTriple_handle2_get(PointerRNA *ptr, float *values)
201 BezTriple *bezt = (BezTriple *)ptr->data;
202 copy_v3_v3(values, bezt->vec[2]);
205 static void rna_BezTriple_handle2_set(PointerRNA *ptr, const float *values)
207 BezTriple *bezt = (BezTriple *)ptr->data;
208 copy_v3_v3(bezt->vec[2], values);
211 static void rna_BezTriple_ctrlpoint_get(PointerRNA *ptr, float *values)
213 BezTriple *bezt = (BezTriple *)ptr->data;
214 copy_v3_v3(values, bezt->vec[1]);
217 static void rna_BezTriple_ctrlpoint_set(PointerRNA *ptr, const float *values)
219 BezTriple *bezt = (BezTriple *)ptr->data;
220 copy_v3_v3(bezt->vec[1], values);
223 static void rna_Curve_texspace_set(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
225 Curve *cu = (Curve *)ptr->data;
227 if (cu->texflag & CU_AUTOSPACE)
228 BKE_curve_texspace_calc(cu);
231 static int rna_Curve_texspace_editable(PointerRNA *ptr)
233 Curve *cu = (Curve *)ptr->data;
234 return (cu->texflag & CU_AUTOSPACE) ? 0 : PROP_EDITABLE;
237 static void rna_Curve_texspace_loc_get(PointerRNA *ptr, float *values)
239 Curve *cu = (Curve *)ptr->data;
242 BKE_curve_texspace_calc(cu);
244 copy_v3_v3(values, cu->loc);
247 static void rna_Curve_texspace_loc_set(PointerRNA *ptr, const float *values)
249 Curve *cu = (Curve *)ptr->data;
251 copy_v3_v3(cu->loc, values);
254 static void rna_Curve_texspace_size_get(PointerRNA *ptr, float *values)
256 Curve *cu = (Curve *)ptr->data;
259 BKE_curve_texspace_calc(cu);
261 copy_v3_v3(values, cu->size);
264 static void rna_Curve_texspace_size_set(PointerRNA *ptr, const float *values)
266 Curve *cu = (Curve *)ptr->data;
268 copy_v3_v3(cu->size, values);
271 static void rna_Curve_material_index_range(PointerRNA *ptr, int *min, int *max,
272 int *UNUSED(softmin), int *UNUSED(softmax))
274 Curve *cu = (Curve *)ptr->id.data;
276 *max = max_ii(0, cu->totcol - 1);
279 /* simply offset by don't expose -1 */
280 static int rna_ChariInfo_material_index_get(PointerRNA *ptr)
282 CharInfo *info = ptr->data;
283 return info->mat_nr ? info->mat_nr - 1 : 0;
286 static void rna_ChariInfo_material_index_set(PointerRNA *ptr, int value)
288 CharInfo *info = ptr->data;
289 info->mat_nr = value + 1;
292 static void rna_Curve_active_textbox_index_range(PointerRNA *ptr, int *min, int *max,
293 int *UNUSED(softmin), int *UNUSED(softmax))
295 Curve *cu = (Curve *)ptr->id.data;
297 *max = max_ii(0, cu->totbox - 1);
301 static void rna_Curve_dimension_set(PointerRNA *ptr, int value)
303 Curve *cu = (Curve *)ptr->id.data;
304 if (value == CU_3D) cu->flag |= CU_3D;
305 else cu->flag &= ~CU_3D;
307 BKE_curve_curve_dimension_update(cu);
310 static EnumPropertyItem *rna_Curve_fill_mode_itemf(bContext *UNUSED(C), PointerRNA *ptr,
311 PropertyRNA *UNUSED(prop), bool *UNUSED(r_free))
313 Curve *cu = (Curve *)ptr->id.data;
315 /* cast to quiet warning it IS a const still */
316 return (EnumPropertyItem *)((cu->flag & CU_3D) ? curve3d_fill_mode_items : curve2d_fill_mode_items);
319 static int rna_Nurb_length(PointerRNA *ptr)
321 Nurb *nu = (Nurb *)ptr->data;
322 if (nu->type == CU_BEZIER) return 0;
323 return nu->pntsv > 0 ? nu->pntsu * nu->pntsv : nu->pntsu;
326 static void rna_Nurb_type_set(PointerRNA *ptr, int value)
328 Nurb *nu = (Nurb *)ptr->data;
329 BKE_nurb_type_convert(nu, value, true);
332 static void rna_BPoint_array_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
334 Nurb *nu = (Nurb *)ptr->data;
335 rna_iterator_array_begin(iter, (void *)nu->bp, sizeof(BPoint),
336 nu->pntsv > 0 ? nu->pntsu * nu->pntsv : nu->pntsu, 0, NULL);
339 static void rna_Curve_update_data_id(Main *UNUSED(bmain), Scene *UNUSED(scene), ID *id)
341 DAG_id_tag_update(id, 0);
342 WM_main_add_notifier(NC_GEOM | ND_DATA, id);
345 static void rna_Curve_update_data(Main *bmain, Scene *scene, PointerRNA *ptr)
347 rna_Curve_update_data_id(bmain, scene, ptr->id.data);
350 static void rna_Curve_update_deps(Main *bmain, Scene *scene, PointerRNA *ptr)
352 DAG_relations_tag_update(bmain);
353 rna_Curve_update_data(bmain, scene, ptr);
356 static void rna_Curve_update_points(Main *bmain, Scene *scene, PointerRNA *ptr)
358 Curve *cu = (Curve *)ptr->id.data;
359 Nurb *nu = curve_nurb_from_point(cu, ptr->data, NULL, NULL);
362 BKE_nurb_handles_calc(nu);
364 rna_Curve_update_data(bmain, scene, ptr);
367 static PointerRNA rna_Curve_bevelObject_get(PointerRNA *ptr)
369 Curve *cu = (Curve *)ptr->id.data;
370 Object *ob = cu->bevobj;
373 return rna_pointer_inherit_refine(ptr, &RNA_Object, ob);
375 return rna_pointer_inherit_refine(ptr, NULL, NULL);
378 static void rna_Curve_bevelObject_set(PointerRNA *ptr, PointerRNA value)
380 Curve *cu = (Curve *)ptr->id.data;
381 Object *ob = (Object *)value.data;
384 /* if bevel object has got the save curve, as object, for which it's */
385 /* set as bevobj, there could be infinity loop in displist calculation */
386 if (ob->type == OB_CURVE && ob->data != cu) {
395 static int rna_Curve_otherObject_poll(PointerRNA *ptr, PointerRNA value)
397 Curve *cu = (Curve *)ptr->id.data;
398 Object *ob = (Object *)value.data;
401 if (ob->type == OB_CURVE && ob->data != cu) {
409 static PointerRNA rna_Curve_taperObject_get(PointerRNA *ptr)
411 Curve *cu = (Curve *)ptr->id.data;
412 Object *ob = cu->taperobj;
415 return rna_pointer_inherit_refine(ptr, &RNA_Object, ob);
417 return rna_pointer_inherit_refine(ptr, NULL, NULL);
420 static void rna_Curve_taperObject_set(PointerRNA *ptr, PointerRNA value)
422 Curve *cu = (Curve *)ptr->id.data;
423 Object *ob = (Object *)value.data;
426 /* if taper object has got the save curve, as object, for which it's */
427 /* set as bevobj, there could be infinity loop in displist calculation */
428 if (ob->type == OB_CURVE && ob->data != cu) {
437 static void rna_Curve_resolution_u_update_data(Main *bmain, Scene *scene, PointerRNA *ptr)
439 Curve *cu = (Curve *)ptr->id.data;
440 ListBase *nurbs = BKE_curve_nurbs_get(cu);
441 Nurb *nu = nurbs->first;
444 nu->resolu = cu->resolu;
448 rna_Curve_update_data(bmain, scene, ptr);
451 static void rna_Curve_resolution_v_update_data(Main *bmain, Scene *scene, PointerRNA *ptr)
453 Curve *cu = (Curve *)ptr->id.data;
454 ListBase *nurbs = BKE_curve_nurbs_get(cu);
455 Nurb *nu = nurbs->first;
459 nu->resolv = cu->resolv;
463 rna_Curve_update_data(bmain, scene, ptr);
466 static float rna_Curve_offset_get(PointerRNA *ptr)
468 Curve *cu = (Curve *)ptr->id.data;
469 return cu->width - 1.0f;
472 static void rna_Curve_offset_set(PointerRNA *ptr, float value)
474 Curve *cu = (Curve *)ptr->id.data;
475 cu->width = 1.0f + value;
478 static int rna_Curve_body_length(PointerRNA *ptr);
479 static void rna_Curve_body_get(PointerRNA *ptr, char *value)
481 Curve *cu = (Curve *)ptr->id.data;
482 BLI_strncpy(value, cu->str, rna_Curve_body_length(ptr) + 1);
485 static int rna_Curve_body_length(PointerRNA *ptr)
487 Curve *cu = (Curve *)ptr->id.data;
491 /* TODO, how to handle editmode? */
492 static void rna_Curve_body_set(PointerRNA *ptr, const char *value)
495 size_t len_chars = BLI_strlen_utf8_ex(value, &len_bytes);
497 Curve *cu = (Curve *)ptr->id.data;
499 cu->len_wchar = len_chars;
506 MEM_freeN(cu->strinfo);
508 cu->str = MEM_mallocN(len_bytes + sizeof(wchar_t), "str");
509 cu->strinfo = MEM_callocN((len_chars + 4) * sizeof(CharInfo), "strinfo");
511 BLI_strncpy(cu->str, value, len_bytes + 1);
514 static void rna_Nurb_update_cyclic_u(Main *bmain, Scene *scene, PointerRNA *ptr)
516 Nurb *nu = (Nurb *)ptr->data;
518 if (nu->type == CU_BEZIER) {
519 BKE_nurb_handles_calc(nu);
522 BKE_nurb_knot_calc_u(nu);
525 rna_Curve_update_data(bmain, scene, ptr);
528 static void rna_Nurb_update_cyclic_v(Main *bmain, Scene *scene, PointerRNA *ptr)
530 Nurb *nu = (Nurb *)ptr->data;
532 BKE_nurb_knot_calc_v(nu);
534 rna_Curve_update_data(bmain, scene, ptr);
537 static void rna_Nurb_update_knot_u(Main *bmain, Scene *scene, PointerRNA *ptr)
539 Nurb *nu = (Nurb *)ptr->data;
541 BKE_nurb_order_clamp_u(nu);
542 BKE_nurb_knot_calc_u(nu);
544 rna_Curve_update_data(bmain, scene, ptr);
547 static void rna_Nurb_update_knot_v(Main *bmain, Scene *scene, PointerRNA *ptr)
549 Nurb *nu = (Nurb *)ptr->data;
551 BKE_nurb_order_clamp_v(nu);
552 BKE_nurb_knot_calc_v(nu);
554 rna_Curve_update_data(bmain, scene, ptr);
557 static void rna_Curve_spline_points_add(ID *id, Nurb *nu, ReportList *reports, int number)
559 if (nu->type == CU_BEZIER) {
560 BKE_report(reports, RPT_ERROR, "Bezier spline cannot have points added");
562 else if (number == 0) {
567 BKE_nurb_points_add(nu, number);
570 BKE_nurb_knot_calc_u(nu);
572 rna_Curve_update_data_id(NULL, NULL, id);
576 static void rna_Curve_spline_bezpoints_add(ID *id, Nurb *nu, ReportList *reports, int number)
578 if (nu->type != CU_BEZIER) {
579 BKE_report(reports, RPT_ERROR, "Only Bezier splines can be added");
581 else if (number == 0) {
585 BKE_nurb_bezierPoints_add(nu, number);
588 BKE_nurb_knot_calc_u(nu);
590 rna_Curve_update_data_id(NULL, NULL, id);
594 static Nurb *rna_Curve_spline_new(Curve *cu, int type)
596 Nurb *nu = (Nurb *) MEM_callocN(sizeof(Nurb), "spline.new");
598 if (type == CU_BEZIER) {
599 BezTriple *bezt = (BezTriple *)MEM_callocN(sizeof(BezTriple), "spline.new.bezt");
604 BPoint *bp = (BPoint *)MEM_callocN(sizeof(BPoint), "spline.new.bp");
613 nu->orderu = nu->orderv = 4;
614 nu->resolu = nu->resolv = 12;
615 nu->flag = CU_SMOOTH;
617 if ((cu->flag & CU_3D) == 0) {
621 BLI_addtail(BKE_curve_nurbs_get(cu), nu);
626 static void rna_Curve_spline_remove(Curve *cu, ReportList *reports, PointerRNA *nu_ptr)
628 Nurb *nu = nu_ptr->data;
629 ListBase *nurbs = BKE_curve_nurbs_get(cu);
631 if (BLI_remlink_safe(nurbs, nu) == FALSE) {
632 BKE_reportf(reports, RPT_ERROR, "Curve '%s' does not contain spline given", cu->id.name + 2);
637 RNA_POINTER_INVALIDATE(nu_ptr);
639 DAG_id_tag_update(&cu->id, OB_RECALC_DATA);
640 WM_main_add_notifier(NC_GEOM | ND_DATA, NULL);
643 static void rna_Curve_spline_clear(Curve *cu)
645 ListBase *nurbs = BKE_curve_nurbs_get(cu);
647 BKE_nurbList_free(nurbs);
649 DAG_id_tag_update(&cu->id, OB_RECALC_DATA);
650 WM_main_add_notifier(NC_GEOM | ND_DATA, NULL);
653 static PointerRNA rna_Curve_active_spline_get(PointerRNA *ptr)
655 Curve *cu = (Curve *)ptr->data;
657 ListBase *nurbs = BKE_curve_nurbs_get(cu);
659 /* for curve outside editmode will set to -1, should be changed to be allowed outside of editmode. */
660 nu = BLI_findlink(nurbs, cu->actnu);
663 return rna_pointer_inherit_refine(ptr, &RNA_Spline, nu);
665 return rna_pointer_inherit_refine(ptr, NULL, NULL);
668 static void rna_Curve_active_spline_set(PointerRNA *ptr, PointerRNA value)
670 Curve *cu = (Curve *)ptr->data;
671 Nurb *nu = value.data;
672 ListBase *nubase = BKE_curve_nurbs_get(cu);
674 /* -1 is ok for an unset index */
678 cu->actnu = BLI_findindex(nubase, nu);
681 static char *rna_Curve_spline_path(PointerRNA *ptr)
683 Curve *cu = (Curve *)ptr->id.data;
684 ListBase *nubase = BKE_curve_nurbs_get(cu);
685 Nurb *nu = ptr->data;
686 int index = BLI_findindex(nubase, nu);
689 return BLI_sprintfN("splines[%d]", index);
691 return BLI_strdup("");
694 /* use for both bezier and nurbs */
695 static char *rna_Curve_spline_point_path(PointerRNA *ptr)
697 Curve *cu = (Curve *)ptr->id.data;
699 void *point = ptr->data;
700 int nu_index, pt_index;
702 nu = curve_nurb_from_point(cu, point, &nu_index, &pt_index);
705 if (nu->type == CU_BEZIER) {
706 return BLI_sprintfN("splines[%d].bezier_points[%d]", nu_index, pt_index);
709 return BLI_sprintfN("splines[%d].points[%d]", nu_index, pt_index);
713 return BLI_strdup("");
718 static char *rna_TextBox_path(PointerRNA *ptr)
720 Curve *cu = (Curve *)ptr->id.data;
721 TextBox *tb = ptr->data;
722 int index = (int)(tb - cu->tb);
724 if (index >= 0 && index < cu->totbox)
725 return BLI_sprintfN("text_boxes[%d]", index);
727 return BLI_strdup("");
730 static void rna_Curve_splines_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
732 Curve *cu = (Curve *)ptr->id.data;
733 rna_iterator_listbase_begin(iter, BKE_curve_nurbs_get(cu), NULL);
736 static int rna_Curve_is_editmode_get(PointerRNA *ptr)
738 Curve *cu = (Curve *)ptr->id.data;
739 const short type = BKE_curve_type_get(cu);
740 if (type == OB_FONT) {
741 return (cu->editfont != NULL);
744 return (cu->editnurb != NULL);
750 static void rna_def_bpoint(BlenderRNA *brna)
754 const float tilt_limit = DEG2RADF(21600.0f);
756 srna = RNA_def_struct(brna, "SplinePoint", NULL);
757 RNA_def_struct_sdna(srna, "BPoint");
758 RNA_def_struct_ui_text(srna, "SplinePoint", "Spline point without handles");
761 prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
762 RNA_def_property_boolean_sdna(prop, NULL, "f1", 0);
763 RNA_def_property_ui_text(prop, "Select", "Selection status");
764 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
766 prop = RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE);
767 RNA_def_property_boolean_sdna(prop, NULL, "hide", 0);
768 RNA_def_property_ui_text(prop, "Hide", "Visibility status");
769 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
772 prop = RNA_def_property(srna, "co", PROP_FLOAT, PROP_TRANSLATION);
773 RNA_def_property_array(prop, 3);
774 RNA_def_property_float_sdna(prop, NULL, "vec");
775 RNA_def_property_ui_text(prop, "Point", "Point coordinates");
776 RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT);
777 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
779 prop = RNA_def_property(srna, "weight", PROP_FLOAT, PROP_NONE);
780 RNA_def_property_float_sdna(prop, NULL, "vec[3]");
781 RNA_def_property_ui_text(prop, "Weight", "NURBS weight");
782 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
785 prop = RNA_def_property(srna, "tilt", PROP_FLOAT, PROP_ANGLE);
786 RNA_def_property_float_sdna(prop, NULL, "alfa");
787 RNA_def_property_range(prop, -tilt_limit, tilt_limit);
788 RNA_def_property_ui_range(prop, -tilt_limit, tilt_limit, 0.1, 3);
789 RNA_def_property_ui_text(prop, "Tilt", "Tilt in 3D View");
790 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
792 prop = RNA_def_property(srna, "weight_softbody", PROP_FLOAT, PROP_NONE);
793 RNA_def_property_float_sdna(prop, NULL, "weight");
794 RNA_def_property_range(prop, 0.01f, 100.0f);
795 RNA_def_property_ui_text(prop, "Weight", "Softbody goal weight");
796 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
798 prop = RNA_def_property(srna, "radius", PROP_FLOAT, PROP_NONE);
799 RNA_def_property_float_sdna(prop, NULL, "radius");
800 RNA_def_property_range(prop, 0.0f, FLT_MAX);
801 RNA_def_property_ui_text(prop, "Bevel Radius", "Radius for beveling");
802 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
804 RNA_def_struct_path_func(srna, "rna_Curve_spline_point_path");
807 static void rna_def_beztriple(BlenderRNA *brna)
812 srna = RNA_def_struct(brna, "BezierSplinePoint", NULL);
813 RNA_def_struct_sdna(srna, "BezTriple");
814 RNA_def_struct_ui_text(srna, "Bezier Curve Point", "Bezier curve point with two handles");
817 prop = RNA_def_property(srna, "select_left_handle", PROP_BOOLEAN, PROP_NONE);
818 RNA_def_property_boolean_sdna(prop, NULL, "f1", 0);
819 RNA_def_property_ui_text(prop, "Handle 1 selected", "Handle 1 selection status");
820 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
822 prop = RNA_def_property(srna, "select_right_handle", PROP_BOOLEAN, PROP_NONE);
823 RNA_def_property_boolean_sdna(prop, NULL, "f3", 0);
824 RNA_def_property_ui_text(prop, "Handle 2 selected", "Handle 2 selection status");
825 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
827 prop = RNA_def_property(srna, "select_control_point", PROP_BOOLEAN, PROP_NONE);
828 RNA_def_property_boolean_sdna(prop, NULL, "f2", 0);
829 RNA_def_property_ui_text(prop, "Control Point selected", "Control point selection status");
830 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
832 prop = RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE);
833 RNA_def_property_boolean_sdna(prop, NULL, "hide", 0);
834 RNA_def_property_ui_text(prop, "Hide", "Visibility status");
835 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
838 prop = RNA_def_property(srna, "handle_left_type", PROP_ENUM, PROP_NONE);
839 RNA_def_property_enum_sdna(prop, NULL, "h1");
840 RNA_def_property_enum_items(prop, beztriple_handle_type_items);
841 RNA_def_property_ui_text(prop, "Handle 1 Type", "Handle types");
842 RNA_def_property_update(prop, 0, "rna_Curve_update_points");
844 prop = RNA_def_property(srna, "handle_right_type", PROP_ENUM, PROP_NONE);
845 RNA_def_property_enum_sdna(prop, NULL, "h2");
846 RNA_def_property_enum_items(prop, beztriple_handle_type_items);
847 RNA_def_property_ui_text(prop, "Handle 2 Type", "Handle types");
848 RNA_def_property_update(prop, 0, "rna_Curve_update_points");
851 prop = RNA_def_property(srna, "handle_left", PROP_FLOAT, PROP_TRANSLATION);
852 RNA_def_property_array(prop, 3);
853 RNA_def_property_float_funcs(prop, "rna_BezTriple_handle1_get", "rna_BezTriple_handle1_set", NULL);
854 RNA_def_property_ui_text(prop, "Handle 1", "Coordinates of the first handle");
855 RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT);
856 RNA_def_property_update(prop, 0, "rna_Curve_update_points");
858 prop = RNA_def_property(srna, "co", PROP_FLOAT, PROP_TRANSLATION);
859 RNA_def_property_array(prop, 3);
860 RNA_def_property_float_funcs(prop, "rna_BezTriple_ctrlpoint_get", "rna_BezTriple_ctrlpoint_set", NULL);
861 RNA_def_property_ui_text(prop, "Control Point", "Coordinates of the control point");
862 RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT);
863 RNA_def_property_update(prop, 0, "rna_Curve_update_points");
865 prop = RNA_def_property(srna, "handle_right", PROP_FLOAT, PROP_TRANSLATION);
866 RNA_def_property_array(prop, 3);
867 RNA_def_property_float_funcs(prop, "rna_BezTriple_handle2_get", "rna_BezTriple_handle2_set", NULL);
868 RNA_def_property_ui_text(prop, "Handle 2", "Coordinates of the second handle");
869 RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT);
870 RNA_def_property_update(prop, 0, "rna_Curve_update_points");
873 prop = RNA_def_property(srna, "tilt", PROP_FLOAT, PROP_ANGLE);
874 RNA_def_property_float_sdna(prop, NULL, "alfa");
875 /*RNA_def_property_range(prop, -FLT_MAX, FLT_MAX);*/
876 RNA_def_property_ui_text(prop, "Tilt", "Tilt in 3D View");
877 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
879 prop = RNA_def_property(srna, "weight_softbody", PROP_FLOAT, PROP_NONE);
880 RNA_def_property_float_sdna(prop, NULL, "weight");
881 RNA_def_property_range(prop, 0.01f, 100.0f);
882 RNA_def_property_ui_text(prop, "Weight", "Softbody goal weight");
883 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
885 prop = RNA_def_property(srna, "radius", PROP_FLOAT, PROP_NONE);
886 RNA_def_property_float_sdna(prop, NULL, "radius");
887 RNA_def_property_range(prop, 0.0f, FLT_MAX);
888 RNA_def_property_ui_text(prop, "Bevel Radius", "Radius for beveling");
889 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
891 RNA_def_struct_path_func(srna, "rna_Curve_spline_point_path");
894 static void rna_def_path(BlenderRNA *UNUSED(brna), StructRNA *srna)
899 prop = RNA_def_property(srna, "path_duration", PROP_INT, PROP_NONE);
900 RNA_def_property_int_sdna(prop, NULL, "pathlen");
901 RNA_def_property_range(prop, 1, MAXFRAME);
902 RNA_def_property_ui_text(prop, "Path Length",
903 "The number of frames that are needed to traverse the path, "
904 "defining the maximum value for the 'Evaluation Time' setting");
905 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
908 prop = RNA_def_property(srna, "use_path", PROP_BOOLEAN, PROP_NONE);
909 RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_PATH);
910 RNA_def_property_ui_text(prop, "Path", "Enable the curve to become a translation path");
911 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
913 prop = RNA_def_property(srna, "use_path_follow", PROP_BOOLEAN, PROP_NONE);
914 RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_FOLLOW);
915 RNA_def_property_ui_text(prop, "Follow", "Make curve path children to rotate along the path");
916 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
918 prop = RNA_def_property(srna, "use_stretch", PROP_BOOLEAN, PROP_NONE);
919 RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_STRETCH);
920 RNA_def_property_ui_text(prop, "Stretch", "Option for curve-deform: "
921 "make deformed child to stretch along entire path");
922 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
924 prop = RNA_def_property(srna, "use_deform_bounds", PROP_BOOLEAN, PROP_NONE);
925 RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", CU_DEFORM_BOUNDS_OFF);
926 RNA_def_property_ui_text(prop, "Bounds Clamp", "Option for curve-deform: "
927 "Use the mesh bounds to clamp the deformation");
928 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
930 prop = RNA_def_property(srna, "use_radius", PROP_BOOLEAN, PROP_NONE);
931 RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_PATH_RADIUS);
932 RNA_def_property_ui_text(prop, "Radius", "Option for paths and curve-deform: "
933 "apply the curve radius with path following it and deforming");
934 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
937 static void rna_def_nurbs(BlenderRNA *UNUSED(brna), StructRNA *srna)
942 prop = RNA_def_property(srna, "use_uv_as_generated", PROP_BOOLEAN, PROP_NONE);
943 RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_UV_ORCO);
944 RNA_def_property_ui_text(prop, "Use UV for Mapping", "Uses the UV values as Generated textured coordinates");
945 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
948 static void rna_def_font(BlenderRNA *UNUSED(brna), StructRNA *srna)
952 static EnumPropertyItem prop_align_items[] = {
953 {CU_LEFT, "LEFT", 0, "Left", "Align text to the left"},
954 {CU_MIDDLE, "CENTER", 0, "Center", "Center text"},
955 {CU_RIGHT, "RIGHT", 0, "Right", "Align text to the right"},
956 {CU_JUSTIFY, "JUSTIFY", 0, "Justify", "Align to the left and the right"},
957 {CU_FLUSH, "FLUSH", 0, "Flush", "Align to the left and the right, with equal character spacing"},
958 {0, NULL, 0, NULL, NULL}
962 prop = RNA_def_property(srna, "align", PROP_ENUM, PROP_NONE);
963 RNA_def_property_enum_sdna(prop, NULL, "spacemode");
964 RNA_def_property_enum_items(prop, prop_align_items);
965 RNA_def_property_ui_text(prop, "Text Align", "Text align from the object center");
966 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
969 prop = RNA_def_property(srna, "size", PROP_FLOAT, PROP_NONE);
970 RNA_def_property_float_sdna(prop, NULL, "fsize");
971 RNA_def_property_range(prop, 0.0001f, 10000.0f);
972 RNA_def_property_ui_range(prop, 0.01, 10, 1, 3);
973 RNA_def_property_ui_text(prop, "Font size", "");
974 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
976 prop = RNA_def_property(srna, "small_caps_scale", PROP_FLOAT, PROP_NONE);
977 RNA_def_property_float_sdna(prop, NULL, "smallcaps_scale");
978 RNA_def_property_ui_range(prop, 0, 1.0, 1, 2);
979 RNA_def_property_ui_text(prop, "Small Caps", "Scale of small capitals");
980 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
982 prop = RNA_def_property(srna, "space_line", PROP_FLOAT, PROP_NONE);
983 RNA_def_property_float_sdna(prop, NULL, "linedist");
984 RNA_def_property_range(prop, 0.0f, 10.0f);
985 RNA_def_property_ui_text(prop, "Distance between lines of text", "");
986 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
988 prop = RNA_def_property(srna, "space_word", PROP_FLOAT, PROP_NONE);
989 RNA_def_property_float_sdna(prop, NULL, "wordspace");
990 RNA_def_property_range(prop, 0.0f, 10.0f);
991 RNA_def_property_ui_text(prop, "Spacing between words", "");
992 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
994 prop = RNA_def_property(srna, "space_character", PROP_FLOAT, PROP_NONE);
995 RNA_def_property_float_sdna(prop, NULL, "spacing");
996 RNA_def_property_range(prop, 0.0f, 10.0f);
997 RNA_def_property_ui_text(prop, "Global spacing between characters", "");
998 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
1000 prop = RNA_def_property(srna, "shear", PROP_FLOAT, PROP_NONE);
1001 RNA_def_property_float_sdna(prop, NULL, "shear");
1002 RNA_def_property_range(prop, -1.0f, 1.0f);
1003 RNA_def_property_ui_text(prop, "Shear", "Italic angle of the characters");
1004 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
1006 prop = RNA_def_property(srna, "offset_x", PROP_FLOAT, PROP_NONE);
1007 RNA_def_property_float_sdna(prop, NULL, "xof");
1008 RNA_def_property_range(prop, -50.0f, 50.0f);
1009 RNA_def_property_ui_text(prop, "X Offset", "Horizontal offset from the object origin");
1010 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
1012 prop = RNA_def_property(srna, "offset_y", PROP_FLOAT, PROP_NONE);
1013 RNA_def_property_float_sdna(prop, NULL, "yof");
1014 RNA_def_property_range(prop, -50.0f, 50.0f);
1015 RNA_def_property_ui_text(prop, "Y Offset", "Vertical offset from the object origin");
1016 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
1018 prop = RNA_def_property(srna, "underline_position", PROP_FLOAT, PROP_NONE);
1019 RNA_def_property_float_sdna(prop, NULL, "ulpos");
1020 RNA_def_property_range(prop, -0.2f, 0.8f);
1021 RNA_def_property_ui_text(prop, "Underline Position", "Vertical position of underline");
1022 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
1024 prop = RNA_def_property(srna, "underline_height", PROP_FLOAT, PROP_NONE);
1025 RNA_def_property_float_sdna(prop, NULL, "ulheight");
1026 RNA_def_property_range(prop, -0.2f, 0.8f);
1027 RNA_def_property_ui_text(prop, "Underline Thickness", "");
1028 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
1030 prop = RNA_def_property(srna, "text_boxes", PROP_COLLECTION, PROP_NONE);
1031 RNA_def_property_collection_sdna(prop, NULL, "tb", "totbox");
1032 RNA_def_property_struct_type(prop, "TextBox");
1033 RNA_def_property_ui_text(prop, "Textboxes", "");
1035 prop = RNA_def_property(srna, "active_textbox", PROP_INT, PROP_NONE);
1036 RNA_def_property_int_sdna(prop, NULL, "actbox");
1037 RNA_def_property_ui_text(prop, "The active text box", "");
1038 RNA_def_property_int_funcs(prop, NULL, NULL, "rna_Curve_active_textbox_index_range");
1041 prop = RNA_def_property(srna, "family", PROP_STRING, PROP_NONE);
1042 RNA_def_property_string_maxlength(prop, MAX_ID_NAME - 2);
1043 RNA_def_property_ui_text(prop, "Object Font",
1044 "Use Objects as font characters (give font objects a common name "
1045 "followed by the character they represent, eg. 'family_a', 'family_b', etc, "
1046 "set this setting to 'family_', and turn on Vertex Duplication)");
1047 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
1049 prop = RNA_def_property(srna, "body", PROP_STRING, PROP_NONE);
1050 RNA_def_property_string_sdna(prop, NULL, "str");
1051 RNA_def_property_ui_text(prop, "Body Text", "Content of this text object");
1052 RNA_def_property_string_funcs(prop, "rna_Curve_body_get", "rna_Curve_body_length", "rna_Curve_body_set");
1053 RNA_def_property_string_maxlength(prop, 8192); /* note that originally str did not have a limit! */
1054 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
1056 prop = RNA_def_property(srna, "body_format", PROP_COLLECTION, PROP_NONE);
1057 RNA_def_property_collection_sdna(prop, NULL, "strinfo", "len_wchar");
1058 RNA_def_property_struct_type(prop, "TextCharacterFormat");
1059 RNA_def_property_ui_text(prop, "Character Info", "Stores the style of each character");
1062 prop = RNA_def_property(srna, "follow_curve", PROP_POINTER, PROP_NONE);
1063 RNA_def_property_pointer_sdna(prop, NULL, "textoncurve");
1064 RNA_def_property_pointer_funcs(prop, NULL, NULL, NULL, "rna_Curve_otherObject_poll");
1065 RNA_def_property_flag(prop, PROP_EDITABLE);
1066 RNA_def_property_ui_text(prop, "Text on Curve", "Curve deforming text object");
1067 RNA_def_property_update(prop, 0, "rna_Curve_update_deps");
1069 prop = RNA_def_property(srna, "font", PROP_POINTER, PROP_NONE);
1070 RNA_def_property_pointer_sdna(prop, NULL, "vfont");
1071 RNA_def_property_ui_text(prop, "Font", "");
1072 RNA_def_property_flag(prop, PROP_EDITABLE);
1073 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
1075 prop = RNA_def_property(srna, "font_bold", PROP_POINTER, PROP_NONE);
1076 RNA_def_property_pointer_sdna(prop, NULL, "vfontb");
1077 RNA_def_property_ui_text(prop, "Font Bold", "");
1078 RNA_def_property_flag(prop, PROP_EDITABLE);
1079 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
1081 prop = RNA_def_property(srna, "font_italic", PROP_POINTER, PROP_NONE);
1082 RNA_def_property_pointer_sdna(prop, NULL, "vfonti");
1083 RNA_def_property_ui_text(prop, "Font Italic", "");
1084 RNA_def_property_flag(prop, PROP_EDITABLE);
1085 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
1087 prop = RNA_def_property(srna, "font_bold_italic", PROP_POINTER, PROP_NONE);
1088 RNA_def_property_pointer_sdna(prop, NULL, "vfontbi");
1089 RNA_def_property_ui_text(prop, "Font Bold Italic", "");
1090 RNA_def_property_flag(prop, PROP_EDITABLE);
1091 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
1093 prop = RNA_def_property(srna, "edit_format", PROP_POINTER, PROP_NONE);
1094 RNA_def_property_pointer_sdna(prop, NULL, "curinfo");
1095 RNA_def_property_ui_text(prop, "Edit Format", "Editing settings character formatting");
1096 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
1099 prop = RNA_def_property(srna, "use_fast_edit", PROP_BOOLEAN, PROP_NONE);
1100 RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_FAST);
1101 RNA_def_property_ui_text(prop, "Fast Editing", "Don't fill polygons while editing");
1102 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
1105 static void rna_def_textbox(BlenderRNA *brna)
1110 srna = RNA_def_struct(brna, "TextBox", NULL);
1111 RNA_def_struct_ui_text(srna, "Text Box", "Text bounding box for layout");
1114 prop = RNA_def_property(srna, "x", PROP_FLOAT, PROP_NONE);
1115 RNA_def_property_float_sdna(prop, NULL, "x");
1116 RNA_def_property_range(prop, -50.0f, 50.0f);
1117 RNA_def_property_ui_text(prop, "Textbox X Offset", "");
1118 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
1120 prop = RNA_def_property(srna, "y", PROP_FLOAT, PROP_NONE);
1121 RNA_def_property_float_sdna(prop, NULL, "y");
1122 RNA_def_property_range(prop, -50.0f, 50.0f);
1123 RNA_def_property_ui_text(prop, "Textbox Y Offset", "");
1124 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
1126 prop = RNA_def_property(srna, "width", PROP_FLOAT, PROP_NONE);
1127 RNA_def_property_float_sdna(prop, NULL, "w");
1128 RNA_def_property_range(prop, 0.0f, 50.0f);
1129 RNA_def_property_ui_text(prop, "Textbox Width", "");
1130 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
1132 prop = RNA_def_property(srna, "height", PROP_FLOAT, PROP_NONE);
1133 RNA_def_property_float_sdna(prop, NULL, "h");
1134 RNA_def_property_range(prop, 0.0f, 50.0f);
1135 RNA_def_property_ui_text(prop, "Textbox Height", "");
1136 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
1138 RNA_def_struct_path_func(srna, "rna_TextBox_path");
1141 static void rna_def_charinfo(BlenderRNA *brna)
1146 srna = RNA_def_struct(brna, "TextCharacterFormat", NULL);
1147 RNA_def_struct_sdna(srna, "CharInfo");
1148 RNA_def_struct_ui_text(srna, "Text Character Format", "Text character formatting settings");
1151 prop = RNA_def_property(srna, "use_bold", PROP_BOOLEAN, PROP_NONE);
1152 RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_CHINFO_BOLD);
1153 RNA_def_property_ui_text(prop, "Bold", "");
1154 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
1156 prop = RNA_def_property(srna, "use_italic", PROP_BOOLEAN, PROP_NONE);
1157 RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_CHINFO_ITALIC);
1158 RNA_def_property_ui_text(prop, "Italic", "");
1159 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
1161 prop = RNA_def_property(srna, "use_underline", PROP_BOOLEAN, PROP_NONE);
1162 RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_CHINFO_UNDERLINE);
1163 RNA_def_property_ui_text(prop, "Underline", "");
1164 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
1166 /* probably there is no reason to expose this */
1168 prop = RNA_def_property(srna, "wrap", PROP_BOOLEAN, PROP_NONE);
1169 RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_CHINFO_WRAP);
1170 RNA_def_property_ui_text(prop, "Wrap", "");
1171 RNA_def_property_update(prop, 0, "rna_Curve_update_data"); */
1174 prop = RNA_def_property(srna, "use_small_caps", PROP_BOOLEAN, PROP_NONE);
1175 RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_CHINFO_SMALLCAPS);
1176 RNA_def_property_ui_text(prop, "Small Caps", "");
1177 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
1179 prop = RNA_def_property(srna, "material_index", PROP_INT, PROP_UNSIGNED);
1180 // RNA_def_property_int_sdna(prop, NULL, "mat_nr");
1181 RNA_def_property_ui_text(prop, "Material Index", "");
1182 RNA_def_property_int_funcs(prop, "rna_ChariInfo_material_index_get", "rna_ChariInfo_material_index_set", "rna_Curve_material_index_range");
1183 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
1186 static void rna_def_surface(BlenderRNA *brna)
1190 srna = RNA_def_struct(brna, "SurfaceCurve", "Curve");
1191 RNA_def_struct_sdna(srna, "Curve");
1192 RNA_def_struct_ui_text(srna, "Surface Curve", "Curve datablock used for storing surfaces");
1193 RNA_def_struct_ui_icon(srna, ICON_SURFACE_DATA);
1195 rna_def_nurbs(brna, srna);
1198 static void rna_def_text(BlenderRNA *brna)
1202 srna = RNA_def_struct(brna, "TextCurve", "Curve");
1203 RNA_def_struct_sdna(srna, "Curve");
1204 RNA_def_struct_ui_text(srna, "Text Curve", "Curve datablock used for storing text");
1205 RNA_def_struct_ui_icon(srna, ICON_FONT_DATA);
1207 rna_def_font(brna, srna);
1208 rna_def_nurbs(brna, srna);
1212 /* curve.splines[0].points */
1213 static void rna_def_curve_spline_points(BlenderRNA *brna, PropertyRNA *cprop)
1216 /*PropertyRNA *prop; */
1219 /*PropertyRNA *parm; */
1221 RNA_def_property_srna(cprop, "SplinePoints");
1222 srna = RNA_def_struct(brna, "SplinePoints", NULL);
1223 RNA_def_struct_sdna(srna, "Nurb");
1224 RNA_def_struct_ui_text(srna, "Spline Points", "Collection of spline points");
1226 func = RNA_def_function(srna, "add", "rna_Curve_spline_points_add");
1227 RNA_def_function_ui_description(func, "Add a number of points to this spline");
1228 RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_REPORTS);
1229 RNA_def_int(func, "count", 1, 0, INT_MAX, "Number", "Number of points to add to the spline", 0, INT_MAX);
1232 func = RNA_def_function(srna, "remove", "rna_Curve_spline_remove");
1233 RNA_def_function_ui_description(func, "Remove a spline from a curve");
1234 RNA_def_function_flag(func, FUNC_USE_REPORTS);
1235 parm = RNA_def_pointer(func, "spline", "Spline", "", "The spline to remove");
1236 RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR);
1237 RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
1241 static void rna_def_curve_spline_bezpoints(BlenderRNA *brna, PropertyRNA *cprop)
1244 /*PropertyRNA *prop; */
1247 /*PropertyRNA *parm; */
1249 RNA_def_property_srna(cprop, "SplineBezierPoints");
1250 srna = RNA_def_struct(brna, "SplineBezierPoints", NULL);
1251 RNA_def_struct_sdna(srna, "Nurb");
1252 RNA_def_struct_ui_text(srna, "Spline Bezier Points", "Collection of spline bezirt points");
1254 func = RNA_def_function(srna, "add", "rna_Curve_spline_bezpoints_add");
1255 RNA_def_function_ui_description(func, "Add a number of points to this spline");
1256 RNA_def_function_flag(func, FUNC_USE_SELF_ID | FUNC_USE_REPORTS);
1257 RNA_def_int(func, "count", 1, 0, INT_MAX, "Number", "Number of points to add to the spline", 0, INT_MAX);
1260 func = RNA_def_function(srna, "remove", "rna_Curve_spline_remove");
1261 RNA_def_function_ui_description(func, "Remove a spline from a curve");
1262 RNA_def_function_flag(func, FUNC_USE_REPORTS);
1263 parm = RNA_def_pointer(func, "spline", "Spline", "", "The spline to remove");
1264 RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR);
1265 RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
1270 static void rna_def_curve_splines(BlenderRNA *brna, PropertyRNA *cprop)
1278 RNA_def_property_srna(cprop, "CurveSplines");
1279 srna = RNA_def_struct(brna, "CurveSplines", NULL);
1280 RNA_def_struct_sdna(srna, "Curve");
1281 RNA_def_struct_ui_text(srna, "Curve Splines", "Collection of curve splines");
1283 func = RNA_def_function(srna, "new", "rna_Curve_spline_new");
1284 RNA_def_function_ui_description(func, "Add a new spline to the curve");
1285 parm = RNA_def_enum(func, "type", curve_type_items, CU_POLY, "", "type for the new spline");
1286 RNA_def_property_flag(parm, PROP_REQUIRED);
1287 parm = RNA_def_pointer(func, "spline", "Spline", "", "The newly created spline");
1288 RNA_def_function_return(func, parm);
1290 func = RNA_def_function(srna, "remove", "rna_Curve_spline_remove");
1291 RNA_def_function_ui_description(func, "Remove a spline from a curve");
1292 RNA_def_function_flag(func, FUNC_USE_REPORTS);
1293 parm = RNA_def_pointer(func, "spline", "Spline", "", "The spline to remove");
1294 RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR);
1295 RNA_def_property_clear_flag(parm, PROP_THICK_WRAP);
1297 func = RNA_def_function(srna, "clear", "rna_Curve_spline_clear");
1298 RNA_def_function_ui_description(func, "Remove all spline from a curve");
1300 prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
1301 RNA_def_property_struct_type(prop, "Object");
1302 RNA_def_property_pointer_funcs(prop, "rna_Curve_active_spline_get", "rna_Curve_active_spline_set", NULL, NULL);
1303 RNA_def_property_flag(prop, PROP_EDITABLE);
1304 RNA_def_property_ui_text(prop, "Active Spline", "Active curve spline");
1305 /* Could call: ED_base_object_activate(C, scene->basact);
1306 * but would be a bad level call and it seems the notifier is enough */
1307 RNA_def_property_update(prop, NC_SCENE | ND_OB_ACTIVE, NULL);
1311 static void rna_def_curve(BlenderRNA *brna)
1316 static EnumPropertyItem curve_twist_mode_items[] = {
1317 {CU_TWIST_Z_UP, "Z_UP", 0, "Z-Up", "Use Z-Up axis to calculate the curve twist at each point"},
1318 {CU_TWIST_MINIMUM, "MINIMUM", 0, "Minimum", "Use the least twist over the entire curve"},
1319 {CU_TWIST_TANGENT, "TANGENT", 0, "Tangent", "Use the tangent to calculate twist"},
1320 {0, NULL, 0, NULL, NULL}
1323 static const EnumPropertyItem curve_axis_items[] = {
1324 {0, "2D", 0, "2D", "Clamp the Z axis of the curve"},
1325 {CU_3D, "3D", 0, "3D",
1326 "Allow editing on the Z axis of this curve, also allows tilt and curve radius to be used"},
1327 {0, NULL, 0, NULL, NULL}
1330 static EnumPropertyItem bevfac_mapping_items[] = {
1331 {CU_BEVFAC_MAP_RESOLU, "RESOLUTION", 0, "Resolution", "Map the bevel factor to the number of subdivisions of a spline (U resolution)"},
1332 {CU_BEVFAC_MAP_SEGMENT, "SEGMENTS", 0, "Segments", "Map the bevel factor to the length of a segment and to the number of subdivisions of a segment"},
1333 {CU_BEVFAC_MAP_SPLINE, "SPLINE", 0, "Spline", "Map the bevel factor to the length of a spline"},
1334 {0, NULL, 0, NULL, NULL}
1337 srna = RNA_def_struct(brna, "Curve", "ID");
1338 RNA_def_struct_ui_text(srna, "Curve", "Curve datablock storing curves, splines and NURBS");
1339 RNA_def_struct_ui_icon(srna, ICON_CURVE_DATA);
1340 RNA_def_struct_refine_func(srna, "rna_Curve_refine");
1343 prop = RNA_def_property(srna, "shape_keys", PROP_POINTER, PROP_NONE);
1344 RNA_def_property_pointer_sdna(prop, NULL, "key");
1345 RNA_def_property_ui_text(prop, "Shape Keys", "");
1348 prop = RNA_def_property(srna, "splines", PROP_COLLECTION, PROP_NONE);
1350 RNA_def_property_collection_sdna(prop, NULL, "nurb", NULL);
1352 /* this way we get editmode nurbs too, keyframe in editmode */
1353 RNA_def_property_collection_funcs(prop, "rna_Curve_splines_begin", "rna_iterator_listbase_next",
1354 "rna_iterator_listbase_end", "rna_iterator_listbase_get",
1355 NULL, NULL, NULL, NULL);
1357 RNA_def_property_struct_type(prop, "Spline");
1358 RNA_def_property_ui_text(prop, "Splines", "Collection of splines in this curve data object");
1359 rna_def_curve_splines(brna, prop);
1361 prop = RNA_def_property(srna, "show_handles", PROP_BOOLEAN, PROP_NONE);
1362 RNA_def_property_boolean_negative_sdna(prop, NULL, "drawflag", CU_HIDE_HANDLES);
1363 RNA_def_property_ui_text(prop, "Draw Handles", "Display Bezier handles in editmode");
1364 RNA_def_property_update(prop, NC_GEOM | ND_DATA, NULL);
1366 prop = RNA_def_property(srna, "show_normal_face", PROP_BOOLEAN, PROP_NONE);
1367 RNA_def_property_boolean_negative_sdna(prop, NULL, "drawflag", CU_HIDE_NORMALS);
1368 RNA_def_property_ui_text(prop, "Draw Normals", "Display 3D curve normals in editmode");
1369 RNA_def_property_update(prop, NC_GEOM | ND_DATA, NULL);
1371 rna_def_path(brna, srna);
1374 prop = RNA_def_property(srna, "bevel_resolution", PROP_INT, PROP_NONE);
1375 RNA_def_property_int_sdna(prop, NULL, "bevresol");
1376 RNA_def_property_range(prop, 0, 32);
1377 RNA_def_property_ui_range(prop, 0, 32, 1.0, -1);
1378 RNA_def_property_ui_text(prop, "Bevel Resolution",
1379 "Bevel resolution when depth is non-zero and no specific bevel object has been defined");
1380 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
1382 prop = RNA_def_property(srna, "offset", PROP_FLOAT, PROP_NONE | PROP_UNIT_LENGTH);
1383 RNA_def_property_float_sdna(prop, NULL, "width");
1384 RNA_def_property_ui_range(prop, -1.0, 1.0, 0.1, 3);
1385 RNA_def_property_float_funcs(prop, "rna_Curve_offset_get", "rna_Curve_offset_set", NULL);
1386 RNA_def_property_ui_text(prop, "Offset", "Offset the curve to adjust the width of a text");
1387 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
1389 prop = RNA_def_property(srna, "extrude", PROP_FLOAT, PROP_NONE | PROP_UNIT_LENGTH);
1390 RNA_def_property_float_sdna(prop, NULL, "ext1");
1391 RNA_def_property_ui_range(prop, 0, 100.0, 0.1, 3);
1392 RNA_def_property_range(prop, 0.0, FLT_MAX);
1393 RNA_def_property_ui_text(prop, "Extrude", "Amount of curve extrusion when not using a bevel object");
1394 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
1396 prop = RNA_def_property(srna, "bevel_depth", PROP_FLOAT, PROP_NONE | PROP_UNIT_LENGTH);
1397 RNA_def_property_float_sdna(prop, NULL, "ext2");
1398 RNA_def_property_ui_range(prop, 0, 100.0, 0.1, 3);
1399 RNA_def_property_ui_text(prop, "Bevel Depth", "Bevel depth when not using a bevel object");
1400 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
1402 prop = RNA_def_property(srna, "resolution_u", PROP_INT, PROP_NONE);
1403 RNA_def_property_int_sdna(prop, NULL, "resolu");
1404 RNA_def_property_range(prop, 1, 1024);
1405 RNA_def_property_ui_range(prop, 1, 64, 1, -1);
1406 RNA_def_property_ui_text(prop, "Resolution U", "Surface resolution in U direction");
1407 RNA_def_property_update(prop, 0, "rna_Curve_resolution_u_update_data");
1409 prop = RNA_def_property(srna, "resolution_v", PROP_INT, PROP_NONE);
1410 RNA_def_property_int_sdna(prop, NULL, "resolv");
1411 RNA_def_property_ui_range(prop, 1, 64, 1, -1);
1412 RNA_def_property_range(prop, 1, 1024);
1413 RNA_def_property_ui_text(prop, "Resolution V", "Surface resolution in V direction");
1414 RNA_def_property_update(prop, 0, "rna_Curve_resolution_v_update_data");
1416 prop = RNA_def_property(srna, "render_resolution_u", PROP_INT, PROP_NONE);
1417 RNA_def_property_int_sdna(prop, NULL, "resolu_ren");
1418 RNA_def_property_range(prop, 0, 1024);
1419 RNA_def_property_ui_range(prop, 0, 64, 1, -1);
1420 RNA_def_property_ui_text(prop, "Render Resolution U",
1421 "Surface resolution in U direction used while rendering (zero skips this property)");
1423 prop = RNA_def_property(srna, "render_resolution_v", PROP_INT, PROP_NONE);
1424 RNA_def_property_int_sdna(prop, NULL, "resolv_ren");
1425 RNA_def_property_ui_range(prop, 0, 64, 1, -1);
1426 RNA_def_property_range(prop, 0, 1024);
1427 RNA_def_property_ui_text(prop, "Render Resolution V",
1428 "Surface resolution in V direction used while rendering (zero skips this property)");
1431 prop = RNA_def_property(srna, "eval_time", PROP_FLOAT, PROP_NONE);
1432 RNA_def_property_float_sdna(prop, NULL, "ctime");
1433 RNA_def_property_ui_text(prop, "Evaluation Time",
1434 "Parametric position along the length of the curve that Objects 'following' it should be "
1435 "at (position is evaluated by dividing by the 'Path Length' value)");
1436 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
1439 prop = RNA_def_property(srna, "bevel_object", PROP_POINTER, PROP_NONE);
1440 RNA_def_property_struct_type(prop, "Object");
1441 RNA_def_property_pointer_sdna(prop, NULL, "bevobj");
1442 RNA_def_property_flag(prop, PROP_EDITABLE);
1443 RNA_def_property_ui_text(prop, "Bevel Object", "Curve object name that defines the bevel shape");
1444 RNA_def_property_update(prop, 0, "rna_Curve_update_deps");
1445 RNA_def_property_pointer_funcs(prop, "rna_Curve_bevelObject_get", "rna_Curve_bevelObject_set", NULL,
1446 "rna_Curve_otherObject_poll");
1448 prop = RNA_def_property(srna, "taper_object", PROP_POINTER, PROP_NONE);
1449 RNA_def_property_struct_type(prop, "Object");
1450 RNA_def_property_pointer_sdna(prop, NULL, "taperobj");
1451 RNA_def_property_flag(prop, PROP_EDITABLE);
1452 RNA_def_property_ui_text(prop, "Taper Object", "Curve object name that defines the taper (width)");
1453 RNA_def_property_update(prop, 0, "rna_Curve_update_deps");
1454 RNA_def_property_pointer_funcs(prop, "rna_Curve_taperObject_get", "rna_Curve_taperObject_set", NULL,
1455 "rna_Curve_otherObject_poll");
1459 prop = RNA_def_property(srna, "dimensions", PROP_ENUM, PROP_NONE); /* as an enum */
1460 RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag");
1461 RNA_def_property_enum_items(prop, curve_axis_items);
1462 RNA_def_property_enum_funcs(prop, NULL, "rna_Curve_dimension_set", NULL);
1463 RNA_def_property_ui_text(prop, "Dimensions", "Select 2D or 3D curve type");
1464 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
1466 prop = RNA_def_property(srna, "fill_mode", PROP_ENUM, PROP_NONE);
1467 RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag");
1468 RNA_def_property_enum_items(prop, curve3d_fill_mode_items);
1469 RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Curve_fill_mode_itemf");
1470 RNA_def_property_ui_text(prop, "Fill Mode", "Mode of filling curve");
1471 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
1473 prop = RNA_def_property(srna, "twist_mode", PROP_ENUM, PROP_NONE);
1474 RNA_def_property_enum_sdna(prop, NULL, "twist_mode");
1475 RNA_def_property_enum_items(prop, curve_twist_mode_items);
1476 RNA_def_property_ui_text(prop, "Twist Method", "The type of tilt calculation for 3D Curves");
1477 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
1479 prop = RNA_def_property(srna, "bevel_factor_mapping_start", PROP_ENUM, PROP_NONE);
1480 RNA_def_property_enum_sdna(prop, NULL, "bevfac1_mapping");
1481 RNA_def_property_enum_items(prop, bevfac_mapping_items);
1482 RNA_def_property_ui_text(prop, "Start Mapping Type", "Determines how the start bevel factor is mappend to a spline");
1483 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
1485 prop = RNA_def_property(srna, "bevel_factor_mapping_end", PROP_ENUM, PROP_NONE);
1486 RNA_def_property_enum_sdna(prop, NULL, "bevfac2_mapping");
1487 RNA_def_property_enum_items(prop, bevfac_mapping_items);
1488 RNA_def_property_ui_text(prop, "End Mapping Type", "Determines how the end bevel factor is mappend to a spline");
1489 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
1491 /* XXX - would be nice to have a better way to do this, only add for testing. */
1492 prop = RNA_def_property(srna, "twist_smooth", PROP_FLOAT, PROP_NONE);
1493 RNA_def_property_float_sdna(prop, NULL, "twist_smooth");
1494 RNA_def_property_ui_range(prop, 0, 100.0, 1, 2);
1495 RNA_def_property_ui_text(prop, "Twist Smooth", "Smoothing iteration for tangents");
1496 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
1498 prop = RNA_def_property(srna, "use_fill_deform", PROP_BOOLEAN, PROP_NONE);
1499 RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_DEFORM_FILL);
1500 RNA_def_property_ui_text(prop, "Fill Deformed", "Fill curve after applying shape keys and all modifiers");
1501 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
1503 prop = RNA_def_property(srna, "use_fill_caps", PROP_BOOLEAN, PROP_NONE);
1504 RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_FILL_CAPS);
1505 RNA_def_property_ui_text(prop, "Fill Caps", "Fill caps for beveled curves");
1506 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
1508 prop = RNA_def_property(srna, "use_map_taper", PROP_BOOLEAN, PROP_NONE);
1509 RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_MAP_TAPER);
1510 RNA_def_property_ui_text(prop, "Map Taper", "Map effect of taper object on actually beveled curve");
1511 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
1514 prop = RNA_def_property(srna, "use_auto_texspace", PROP_BOOLEAN, PROP_NONE);
1515 RNA_def_property_boolean_sdna(prop, NULL, "texflag", CU_AUTOSPACE);
1516 RNA_def_property_ui_text(prop, "Auto Texture Space",
1517 "Adjust active object's texture space automatically when transforming object");
1518 RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Curve_texspace_set");
1520 prop = RNA_def_property(srna, "texspace_location", PROP_FLOAT, PROP_TRANSLATION);
1521 RNA_def_property_array(prop, 3);
1522 RNA_def_property_ui_text(prop, "Texture Space Location", "Texture space location");
1523 RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, RNA_TRANSLATION_PREC_DEFAULT);
1524 RNA_def_property_editable_func(prop, "rna_Curve_texspace_editable");
1525 RNA_def_property_float_funcs(prop, "rna_Curve_texspace_loc_get", "rna_Curve_texspace_loc_set", NULL);
1526 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
1528 prop = RNA_def_property(srna, "texspace_size", PROP_FLOAT, PROP_XYZ);
1529 RNA_def_property_array(prop, 3);
1530 RNA_def_property_flag(prop, PROP_PROPORTIONAL);
1531 RNA_def_property_ui_text(prop, "Texture Space Size", "Texture space size");
1532 RNA_def_property_editable_func(prop, "rna_Curve_texspace_editable");
1533 RNA_def_property_float_funcs(prop, "rna_Curve_texspace_size_get", "rna_Curve_texspace_size_set", NULL);
1534 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
1536 /* not supported yet */
1538 prop = RNA_def_property(srna, "texspace_rot", PROP_FLOAT, PROP_EULER);
1539 RNA_def_property_float(prop, NULL, "rot");
1540 RNA_def_property_ui_text(prop, "Texture Space Rotation", "Texture space rotation");
1541 RNA_def_property_editable_func(prop, texspace_editable);
1542 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
1545 prop = RNA_def_property(srna, "use_uv_as_generated", PROP_BOOLEAN, PROP_NONE);
1546 RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_UV_ORCO);
1547 RNA_def_property_ui_text(prop, "Use UV for mapping", "Uses the UV values as Generated textured coordinates");
1548 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
1551 prop = RNA_def_property(srna, "materials", PROP_COLLECTION, PROP_NONE);
1552 RNA_def_property_collection_sdna(prop, NULL, "mat", "totcol");
1553 RNA_def_property_struct_type(prop, "Material");
1554 RNA_def_property_ui_text(prop, "Materials", "");
1555 RNA_def_property_srna(prop, "IDMaterials"); /* see rna_ID.c */
1556 RNA_def_property_collection_funcs(prop, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "rna_IDMaterials_assign_int");
1558 prop = RNA_def_property(srna, "bevel_factor_start", PROP_FLOAT, PROP_FACTOR);
1559 RNA_def_property_float_sdna(prop, NULL, "bevfac1");
1560 RNA_def_property_range(prop, 0, 1.0);
1561 RNA_def_property_ui_text(prop, "Start Bevel Factor", "Factor that defines from where beveling of spline happens (0=from the very beginning, 1=from the very end)");
1562 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
1564 prop = RNA_def_property(srna, "bevel_factor_end", PROP_FLOAT, PROP_FACTOR);
1565 RNA_def_property_float_sdna(prop, NULL, "bevfac2");
1566 RNA_def_property_range(prop, 0, 1.0);
1567 RNA_def_property_ui_text(prop, "End Bevel Factor", "Factor that defines to where beveling of spline happens (0=to the very beginning, 1=to the very end)");
1568 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
1570 prop = RNA_def_property(srna, "is_editmode", PROP_BOOLEAN, PROP_NONE);
1571 RNA_def_property_boolean_funcs(prop, "rna_Curve_is_editmode_get", NULL);
1572 RNA_def_property_clear_flag(prop, PROP_EDITABLE);
1573 RNA_def_property_ui_text(prop, "Is Editmode", "True when used in editmode");
1575 rna_def_animdata_common(srna);
1577 RNA_api_curve(srna);
1580 static void rna_def_curve_nurb(BlenderRNA *brna)
1582 static EnumPropertyItem spline_interpolation_items[] = {
1583 {KEY_LINEAR, "LINEAR", 0, "Linear", ""},
1584 {KEY_CARDINAL, "CARDINAL", 0, "Cardinal", ""},
1585 {KEY_BSPLINE, "BSPLINE", 0, "BSpline", ""},
1586 {KEY_CU_EASE, "EASE", 0, "Ease", ""}, /* todo, define somewhere, not one of BEZT_IPO_* */
1587 {0, NULL, 0, NULL, NULL}
1593 srna = RNA_def_struct(brna, "Spline", NULL);
1594 RNA_def_struct_sdna(srna, "Nurb");
1595 RNA_def_struct_ui_text(srna, "Spline",
1596 "Element of a curve, either NURBS, Bezier or Polyline or a character with text objects");
1598 prop = RNA_def_property(srna, "points", PROP_COLLECTION, PROP_NONE);
1599 RNA_def_property_collection_sdna(prop, NULL, "bp", NULL);
1600 RNA_def_property_struct_type(prop, "SplinePoint");
1601 RNA_def_property_collection_funcs(prop, "rna_BPoint_array_begin", "rna_iterator_array_next",
1602 "rna_iterator_array_end", "rna_iterator_array_get", "rna_Nurb_length",
1604 RNA_def_property_ui_text(prop, "Points", "Collection of points that make up this poly or nurbs spline");
1605 rna_def_curve_spline_points(brna, prop);
1607 prop = RNA_def_property(srna, "bezier_points", PROP_COLLECTION, PROP_NONE);
1608 RNA_def_property_struct_type(prop, "BezierSplinePoint");
1609 RNA_def_property_collection_sdna(prop, NULL, "bezt", "pntsu");
1610 RNA_def_property_ui_text(prop, "Bezier Points", "Collection of points for Bezier curves only");
1611 rna_def_curve_spline_bezpoints(brna, prop);
1614 prop = RNA_def_property(srna, "tilt_interpolation", PROP_ENUM, PROP_NONE);
1615 RNA_def_property_enum_sdna(prop, NULL, "tilt_interp");
1616 RNA_def_property_enum_items(prop, spline_interpolation_items);
1617 RNA_def_property_ui_text(prop, "Tilt Interpolation", "The type of tilt interpolation for 3D, Bezier curves");
1618 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
1620 prop = RNA_def_property(srna, "radius_interpolation", PROP_ENUM, PROP_NONE);
1621 RNA_def_property_enum_sdna(prop, NULL, "radius_interp");
1622 RNA_def_property_enum_items(prop, spline_interpolation_items);
1623 RNA_def_property_ui_text(prop, "Radius Interpolation", "The type of radius interpolation for Bezier curves");
1624 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
1626 prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
1627 RNA_def_property_enum_items(prop, curve_type_items);
1628 RNA_def_property_enum_funcs(prop, NULL, "rna_Nurb_type_set", NULL);
1629 RNA_def_property_ui_text(prop, "Type", "The interpolation type for this curve element");
1630 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
1632 prop = RNA_def_property(srna, "point_count_u", PROP_INT, PROP_UNSIGNED);
1633 RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* editing this needs knot recalc*/
1634 RNA_def_property_int_sdna(prop, NULL, "pntsu");
1635 RNA_def_property_ui_text(prop, "Points U", "Total number points for the curve or surface in the U direction");
1636 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
1638 prop = RNA_def_property(srna, "point_count_v", PROP_INT, PROP_UNSIGNED);
1639 RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* editing this needs knot recalc*/
1640 RNA_def_property_int_sdna(prop, NULL, "pntsv");
1641 RNA_def_property_ui_text(prop, "Points V", "Total number points for the surface on the V direction");
1642 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
1645 prop = RNA_def_property(srna, "order_u", PROP_INT, PROP_NONE);
1646 RNA_def_property_int_sdna(prop, NULL, "orderu");
1647 RNA_def_property_range(prop, 2, 6);
1648 RNA_def_property_ui_text(prop, "Order U",
1649 "NURBS order in the U direction (for splines and surfaces, higher values "
1650 "let points influence a greater area)");
1651 RNA_def_property_update(prop, 0, "rna_Nurb_update_knot_u");
1653 prop = RNA_def_property(srna, "order_v", PROP_INT, PROP_NONE);
1654 RNA_def_property_int_sdna(prop, NULL, "orderv");
1655 RNA_def_property_range(prop, 2, 6);
1656 RNA_def_property_ui_text(prop, "Order V",
1657 "NURBS order in the V direction (for surfaces only, higher values "
1658 "let points influence a greater area)");
1659 RNA_def_property_update(prop, 0, "rna_Nurb_update_knot_v");
1662 prop = RNA_def_property(srna, "resolution_u", PROP_INT, PROP_NONE);
1663 RNA_def_property_int_sdna(prop, NULL, "resolu");
1664 RNA_def_property_range(prop, 1, 1024);
1665 RNA_def_property_ui_range(prop, 1, 64, 1, -1);
1666 RNA_def_property_ui_text(prop, "Resolution U", "Curve or Surface subdivisions per segment");
1667 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
1669 prop = RNA_def_property(srna, "resolution_v", PROP_INT, PROP_NONE);
1670 RNA_def_property_int_sdna(prop, NULL, "resolv");
1671 RNA_def_property_range(prop, 1, 1024);
1672 RNA_def_property_ui_range(prop, 1, 64, 1, -1);
1673 RNA_def_property_ui_text(prop, "Resolution V", "Surface subdivisions per segment");
1674 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
1676 prop = RNA_def_property(srna, "use_cyclic_u", PROP_BOOLEAN, PROP_NONE);
1677 RNA_def_property_boolean_sdna(prop, NULL, "flagu", CU_NURB_CYCLIC);
1678 RNA_def_property_ui_text(prop, "Cyclic U", "Make this curve or surface a closed loop in the U direction");
1679 RNA_def_property_update(prop, 0, "rna_Nurb_update_cyclic_u");
1681 prop = RNA_def_property(srna, "use_cyclic_v", PROP_BOOLEAN, PROP_NONE);
1682 RNA_def_property_boolean_sdna(prop, NULL, "flagv", CU_NURB_CYCLIC);
1683 RNA_def_property_ui_text(prop, "Cyclic V", "Make this surface a closed loop in the V direction");
1684 RNA_def_property_update(prop, 0, "rna_Nurb_update_cyclic_v");
1687 /* Note, endpoint and bezier flags should never be on at the same time! */
1688 prop = RNA_def_property(srna, "use_endpoint_u", PROP_BOOLEAN, PROP_NONE);
1689 RNA_def_property_boolean_sdna(prop, NULL, "flagu", CU_NURB_ENDPOINT);
1690 RNA_def_property_ui_text(prop, "Endpoint U",
1691 "Make this nurbs curve or surface meet the endpoints in the U direction "
1692 "(Cyclic U must be disabled)");
1693 RNA_def_property_update(prop, 0, "rna_Nurb_update_knot_u");
1695 prop = RNA_def_property(srna, "use_endpoint_v", PROP_BOOLEAN, PROP_NONE);
1696 RNA_def_property_boolean_sdna(prop, NULL, "flagv", CU_NURB_ENDPOINT);
1697 RNA_def_property_ui_text(prop, "Endpoint V",
1698 "Make this nurbs surface meet the endpoints in the V direction "
1699 "(Cyclic V must be disabled)");
1700 RNA_def_property_update(prop, 0, "rna_Nurb_update_knot_v");
1702 prop = RNA_def_property(srna, "use_bezier_u", PROP_BOOLEAN, PROP_NONE);
1703 RNA_def_property_boolean_sdna(prop, NULL, "flagu", CU_NURB_BEZIER);
1704 RNA_def_property_ui_text(prop, "Bezier U",
1705 "Make this nurbs curve or surface act like a Bezier spline in the U direction "
1706 "(Order U must be 3 or 4, Cyclic U must be disabled)");
1707 RNA_def_property_update(prop, 0, "rna_Nurb_update_knot_u");
1709 prop = RNA_def_property(srna, "use_bezier_v", PROP_BOOLEAN, PROP_NONE);
1710 RNA_def_property_boolean_sdna(prop, NULL, "flagv", CU_NURB_BEZIER);
1711 RNA_def_property_ui_text(prop, "Bezier V",
1712 "Make this nurbs surface act like a Bezier spline in the V direction "
1713 "(Order V must be 3 or 4, Cyclic V must be disabled)");
1714 RNA_def_property_update(prop, 0, "rna_Nurb_update_knot_v");
1717 prop = RNA_def_property(srna, "use_smooth", PROP_BOOLEAN, PROP_NONE);
1718 RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_SMOOTH);
1719 RNA_def_property_ui_text(prop, "Smooth", "Smooth the normals of the surface or beveled curve");
1720 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
1722 prop = RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE);
1723 RNA_def_property_boolean_sdna(prop, NULL, "hide", 1);
1724 RNA_def_property_ui_text(prop, "Hide", "Hide this curve in Edit mode");
1725 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
1727 prop = RNA_def_property(srna, "material_index", PROP_INT, PROP_UNSIGNED);
1728 RNA_def_property_int_sdna(prop, NULL, "mat_nr");
1729 RNA_def_property_ui_text(prop, "Material Index", "");
1730 RNA_def_property_int_funcs(prop, NULL, NULL, "rna_Curve_material_index_range");
1731 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
1733 prop = RNA_def_property(srna, "character_index", PROP_INT, PROP_UNSIGNED);
1734 RNA_def_property_int_sdna(prop, NULL, "charidx");
1735 RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* editing this needs knot recalc*/
1736 RNA_def_property_ui_text(prop, "Character Index",
1737 "Location of this character in the text data (only for text curves)");
1738 RNA_def_property_update(prop, 0, "rna_Curve_update_data");
1740 RNA_def_struct_path_func(srna, "rna_Curve_spline_path");
1743 void RNA_def_curve(BlenderRNA *brna)
1745 rna_def_curve(brna);
1746 rna_def_surface(brna);
1748 rna_def_textbox(brna);
1749 rna_def_charinfo(brna);
1750 rna_def_bpoint(brna);
1751 rna_def_beztriple(brna);
1752 rna_def_curve_nurb(brna);