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 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
19 * All rights reserved.
21 * The Original Code is: all of this file.
23 * Contributor(s): none yet.
25 * ***** END GPL LICENSE BLOCK *****
28 /** \file DNA_curve_types.h
32 #ifndef __DNA_CURVE_TYPES_H__
33 #define __DNA_CURVE_TYPES_H__
36 #include "DNA_listBase.h"
37 #include "DNA_vec_types.h"
40 #define MAXTEXTBOX 256 /* used in readfile.c and editfont.c */
52 /* These two Lines with # tell makesdna this struct can be excluded. */
55 typedef struct PathPoint {
56 /** Grr, cant get rid of tilt yet. */
62 /* These two Lines with # tell makesdna this struct can be excluded. */
66 struct PathPoint *data;
71 /* These two Lines with # tell makesdna this struct can be excluded. */
74 typedef struct BevPoint {
75 float vec[3], alfa, radius, weight, offset;
79 float dir[3], tan[3], quat[4];
80 short split_tag, dupe_tag;
83 /* These two Lines with # tell makesdna this struct can be excluded. */
86 typedef struct BevList {
87 struct BevList *next, *prev;
97 * Keyframes on F-Curves (allows code reuse of Bezier eval code) and
98 * Points on Bezier Curves/Paths are generally BezTriples
100 * \note alfa location in struct is abused by Key system
102 * \note vec in BezTriple looks like this:
103 * - vec[0][0] = x location of handle 1
104 * - vec[0][1] = y location of handle 1
105 * - vec[0][2] = z location of handle 1 (not used for FCurve Points(2d))
106 * - vec[1][0] = x location of control point
107 * - vec[1][1] = y location of control point
108 * - vec[1][2] = z location of control point
109 * - vec[2][0] = x location of handle 2
110 * - vec[2][1] = y location of handle 2
111 * - vec[2][2] = z location of handle 2 (not used for FCurve Points(2d))
113 typedef struct BezTriple {
115 /** Alfa: tilt in 3D View, weight: used for softbody goal weight, radius: for bevel tapering. */
116 float alfa, weight, radius;
118 /** Ipo: interpolation mode for segment from this BezTriple to the next. */
121 /** H1, h2: the handle type of the two handles. */
123 /** F1, f2, f3: used for selection status. */
126 /** Hide: used to indicate whether BezTriple is hidden (3D), type of keyframe (eBezTriple_KeyframeType). */
129 /** Easing: easing type for interpolation mode (eBezTriple_Easing). */
131 /** BEZT_IPO_BACK. */
133 /** BEZT_IPO_ELASTIC. */
134 float amplitude, period;
136 /** F5: used for auto handle to distinguish between normal handle and exception (extrema). */
141 /* note; alfa location in struct is abused by Key system */
142 typedef struct BPoint {
144 /** Alfa: tilt in 3D View, weight: used for softbody goal weight. */
146 /** F1: selection status, hide: is point hidden or not. */
148 /** User-set radius per point for beveling etc. */
153 * \note Nurb name is misleading, since it can be used for polygons too,
154 * also, it should be NURBS (Nurb isn't the singular of Nurbs).
156 typedef struct Nurb {
157 /** Multiple nurbs per curve object are allowed. */
158 struct Nurb *next, *prev;
160 /** Index into material list. */
163 /** Number of points in the U or V directions. */
166 /** Tessellation resolution in the U or V directions. */
167 short resolu, resolv;
168 short orderu, orderv;
171 float *knotsu, *knotsv;
175 /** KEY_LINEAR, KEY_CARDINAL, KEY_BSPLINE. */
179 /* only used for dynamically generated Nurbs created from OB_FONT's */
183 typedef struct CharInfo {
185 /** Index start at 1, unlike mesh & nurbs. */
192 typedef struct TextBox {
196 typedef struct EditNurb {
197 /* base of nurbs' list (old Curve->editnurb) */
200 /* index data for shape keys */
201 struct GHash *keyindex;
203 /* shape key being edited */
209 typedef struct Curve {
211 /** Animation data (must be immediately after id for utilities to use it). */
212 struct AnimData *adt;
216 /** Actual data, called splines in rna. */
219 /** Edited data, not in file, use pointer so we can check for it. */
222 struct Object *bevobj, *taperobj, *textoncurve;
223 /** Old animation system, deprecated for 2.5. */
224 struct Ipo *ipo DNA_DEPRECATED;
226 struct Material **mat;
228 /* texture space, copied as one block in editobject.c */
233 /** Creation-time type of curve datablock. */
236 /** Keep a short because of BKE_object_obdata_texspace_get(). */
238 short drawflag, twist_mode;
239 float twist_smooth, smallcaps_scale;
242 short bevresol, totcol;
244 float width, ext1, ext2;
247 short resolu, resolv;
248 short resolu_ren, resolv_ren;
250 /* edit, index in nurb list */
252 /* edit, index in active nurb (BPoint or BezTriple) */
256 char spacemode, align_y;
261 float spacing, linedist, shear, fsize, wordspace, ulpos, ulheight;
265 /* copy of EditFont vars (wchar_t aligned),
266 * warning! don't use in editmode (storage only) */
268 int selstart, selend;
271 /** Number of characters (strinfo). */
273 /** Number of bytes (str - utf8). */
276 struct EditFont *editfont;
280 struct VFont *vfontb;
281 struct VFont *vfonti;
282 struct VFont *vfontbi;
287 struct CharInfo *strinfo;
288 struct CharInfo curinfo;
292 /** Current evaltime - for use by Objects parented to curves. */
294 float bevfac1, bevfac2;
295 char bevfac1_mapping, bevfac2_mapping;
298 float fsize_realtime;
304 #define CURVE_VFONT_ANY(cu) \
305 ((cu)->vfont), ((cu)->vfontb), ((cu)->vfonti), ((cu)->vfontbi)
307 /* **************** CURVE ********************* */
314 #if 0 /* Moved to overlay options in 2.8 */
317 CU_HIDE_HANDLES = 1 << 0,
318 CU_HIDE_NORMALS = 1 << 1,
330 CU_DEFORM_BOUNDS_OFF = 1 << 6,
332 /* CU_OFFS_PATHDIST = 1 << 8, */ /* DEPRECATED */
333 CU_FAST = 1 << 9, /* Font: no filling inside editmode */
334 /* CU_RETOPO = 1 << 10, */ /* DEPRECATED */
335 CU_DS_EXPAND = 1 << 11,
336 CU_PATH_RADIUS = 1 << 12, /* make use of the path radius if this is enabled (default for new curves) */
337 CU_DEFORM_FILL = 1 << 13, /* fill 2d curve after deformation */
338 CU_FILL_CAPS = 1 << 14, /* fill bevel caps */
339 CU_MAP_TAPER = 1 << 15, /* map taper object to beveled area */
342 /* Curve.twist_mode */
345 /* CU_TWIST_Y_UP = 1, */ /* not used yet */
346 /* CU_TWIST_X_UP = 2, */
347 CU_TWIST_MINIMUM = 3,
348 CU_TWIST_TANGENT = 4,
351 /* Curve.bevfac1_mapping, Curve.bevfac2_mapping, bevel factor mapping */
353 CU_BEVFAC_MAP_RESOLU = 0,
354 CU_BEVFAC_MAP_SEGMENT = 1,
355 CU_BEVFAC_MAP_SPLINE = 2,
358 /* Curve.spacemode */
361 CU_ALIGN_X_MIDDLE = 1,
362 CU_ALIGN_X_RIGHT = 2,
363 CU_ALIGN_X_JUSTIFY = 3,
364 CU_ALIGN_X_FLUSH = 4,
369 CU_ALIGN_Y_TOP_BASELINE = 0,
371 CU_ALIGN_Y_CENTER = 2,
372 CU_ALIGN_Y_BOTTOM_BASELINE = 3,
373 CU_ALIGN_Y_BOTTOM = 4,
376 /* Curve.overflow. */
378 CU_OVERFLOW_NONE = 0,
379 CU_OVERFLOW_SCALE = 1,
380 CU_OVERFLOW_TRUNCATE = 2,
386 CU_2D = 1 << 3, /* moved from type since 2.4x */
396 CU_TYPE = (CU_POLY | CU_BEZIER | CU_BSPLINE | CU_CARDINAL | CU_NURBS),
398 /* only for adding */
399 CU_PRIMITIVE = 0xF00,
402 CU_PRIM_CURVE = 0x100,
403 /* 8 points circle */
404 CU_PRIM_CIRCLE = 0x200,
406 CU_PRIM_PATCH = 0x300,
407 CU_PRIM_TUBE = 0x400,
408 CU_PRIM_SPHERE = 0x500,
409 CU_PRIM_DONUT = 0x600,
410 /* 5 points, 5th order straight line (for anim path) */
411 CU_PRIM_PATH = 0x700,
414 /* Nurb.flagu, Nurb.flagv */
416 CU_NURB_CYCLIC = 1 << 0,
417 CU_NURB_ENDPOINT = 1 << 1,
418 CU_NURB_BEZIER = 1 << 2,
421 #define CU_ACT_NONE -1
423 /* *************** BEZTRIPLE **************** */
425 /* BezTriple.f1,2,3 */
426 typedef enum eBezTriple_Flag {
428 BEZT_FLAG_TEMP_TAG = (1 << 1), /* always clear. */
431 /* h1 h2 (beztriple) */
432 typedef enum eBezTriple_Handle {
437 HD_AUTO_ANIM = 4, /* auto-clamped handles for animation */
438 HD_ALIGN_DOUBLESIDE = 5, /* align handles, displayed both of them. used for masks */
442 typedef enum eBezTriple_Auto_Type {
443 HD_AUTOTYPE_NORMAL = 0,
444 HD_AUTOTYPE_SPECIAL = 1
445 } eBezTriple_Auto_Type;
447 /* interpolation modes (used only for BezTriple->ipo) */
448 typedef enum eBezTriple_Interpolation {
449 /* traditional interpolation */
450 BEZT_IPO_CONST = 0, /* constant interpolation */
451 BEZT_IPO_LIN = 1, /* linear interpolation */
452 BEZT_IPO_BEZ = 2, /* bezier interpolation */
454 /* easing equations */
459 BEZT_IPO_ELASTIC = 7,
465 } eBezTriple_Interpolation;
467 /* easing modes (used only for Keyframes - BezTriple->easing) */
468 typedef enum eBezTriple_Easing {
469 BEZT_IPO_EASE_AUTO = 0,
471 BEZT_IPO_EASE_IN = 1,
472 BEZT_IPO_EASE_OUT = 2,
473 BEZT_IPO_EASE_IN_OUT = 3,
476 /* types of keyframe (used only for BezTriple->hide when BezTriple is used in F-Curves) */
477 typedef enum eBezTriple_KeyframeType {
478 BEZT_KEYTYPE_KEYFRAME = 0, /* default - 'proper' Keyframe */
479 BEZT_KEYTYPE_EXTREME = 1, /* 'extreme' keyframe */
480 BEZT_KEYTYPE_BREAKDOWN = 2, /* 'breakdown' keyframe */
481 BEZT_KEYTYPE_JITTER = 3, /* 'jitter' keyframe (for adding 'filler' secondary motion) */
482 BEZT_KEYTYPE_MOVEHOLD = 4, /* one end of a 'moving hold' */
483 } eBezTriple_KeyframeType;
485 /* checks if the given BezTriple is selected */
486 #define BEZT_ISSEL_ANY(bezt) \
487 (((bezt)->f2 & SELECT) || ((bezt)->f1 & SELECT) || ((bezt)->f3 & SELECT))
488 #define BEZT_ISSEL_ANY_HIDDENHANDLES(v3d, bezt) \
489 ((((v3d) != NULL) && ((v3d)->overlay.edit_flag & V3D_OVERLAY_EDIT_CU_HANDLES) == 0) ? (bezt)->f2 & SELECT : BEZT_ISSEL_ANY(bezt))
491 #define BEZT_SEL_ALL(bezt) { (bezt)->f1 |= SELECT; (bezt)->f2 |= SELECT; (bezt)->f3 |= SELECT; } ((void)0)
492 #define BEZT_DESEL_ALL(bezt) { (bezt)->f1 &= ~SELECT; (bezt)->f2 &= ~SELECT; (bezt)->f3 &= ~SELECT; } ((void)0)
494 #define BEZT_IS_AUTOH(bezt) (ELEM((bezt)->h1, HD_AUTO, HD_AUTO_ANIM) && ELEM((bezt)->h2, HD_AUTO, HD_AUTO_ANIM))
496 /* *************** CHARINFO **************** */
500 /* note: CU_CHINFO_WRAP, CU_CHINFO_SMALLCAPS_TEST and CU_CHINFO_TRUNCATE are set dynamically */
501 CU_CHINFO_BOLD = 1 << 0,
502 CU_CHINFO_ITALIC = 1 << 1,
503 CU_CHINFO_UNDERLINE = 1 << 2,
504 CU_CHINFO_WRAP = 1 << 3, /* wordwrap occurred here */
505 CU_CHINFO_SMALLCAPS = 1 << 4,
506 CU_CHINFO_SMALLCAPS_CHECK = 1 << 5, /* set at runtime, checks if case switching is needed */
507 CU_CHINFO_OVERFLOW = 1 << 6, /* Set at runtime, indicates char that doesn't fit in text boxes. */
510 /* mixed with KEY_LINEAR but define here since only curve supports */
511 #define KEY_CU_EASE 3
513 /* indicates point has been seen during surface duplication */