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_object_types.h
30 * \brief Object is a sort of wrapper for general info.
33 #ifndef __DNA_OBJECT_TYPES_H__
34 #define __DNA_OBJECT_TYPES_H__
37 #include "DNA_listBase.h"
39 #include "DNA_action_types.h" /* bAnimVizSettings */
51 struct bConstraintChannel;
54 struct FluidsimSettings;
55 struct ParticleSystem;
61 /* Vertex Groups - Name Info */
62 typedef struct bDeformGroup {
63 struct bDeformGroup *next, *prev;
64 char name[64]; /* MAX_VGROUP_NAME */
65 /* need this flag for locking weights */
68 #define MAX_VGROUP_NAME 64
70 /* bDeformGroup->flag */
71 #define DG_LOCK_WEIGHT 1
74 * The following illustrates the orientation of the
75 * bounding box in local space
94 typedef struct BoundBox {
100 #define OB_BB_DISABLED 1
102 typedef struct Object {
104 struct AnimData *adt; /* animation data (must be immediately after id for utilities to use it) */
106 struct SculptSession *sculpt;
109 int par1, par2, par3; /* can be vertexnrs */
110 char parsubstr[64]; /* String describing subobject info, MAX_ID_NAME-2 */
111 struct Object *parent, *track;
112 /* if ob->proxy (or proxy_group), this object is proxy for object ob->proxy */
113 /* proxy_from is set in target back to the proxy. */
114 struct Object *proxy, *proxy_group, *proxy_from;
115 struct Ipo *ipo DNA_DEPRECATED; /* old animation system, deprecated for 2.5 */
116 /* struct Path *path; */
118 struct bAction *action DNA_DEPRECATED; // XXX depreceated... old animation system
119 struct bAction *poselib;
120 struct bPose *pose; /* pose data, armature objects only */
121 void *data; /* pointer to objects data - an 'ID' or NULL */
123 struct bGPdata *gpd; /* Grease Pencil data */
125 bAnimVizSettings avs; /* settings for visualization of object-transform animation */
126 bMotionPath *mpath; /* motion path cache for this object */
128 ListBase constraintChannels DNA_DEPRECATED; // XXX depreceated... old animation system
129 ListBase effect DNA_DEPRECATED; // XXX depreceated... keep for readfile
130 ListBase disp; /* list of DispList, used by lattice, metaballs curve & surfaces */
131 ListBase defbase; /* list of bDeformGroup (vertex groups) names and flag only */
132 ListBase modifiers; /* list of ModifierData structures */
134 int mode; /* Local object mode */
135 int restore_mode; /* Keep track of what mode to return to after toggling a mode */
138 struct Material **mat; /* material slots */
139 char *matbits; /* a boolean field, with each byte 1 if corresponding material is linked to object */
140 int totcol; /* copy of mesh or curve or meta */
141 int actcol; /* currently selected material in the UI */
143 /* rot en drot have to be together! (transform('r' en 's')) */
144 float loc[3], dloc[3], orig[3];
145 float size[3]; /* scale in fact */
146 float dsize[3] DNA_DEPRECATED ; /* DEPRECATED, 2.60 and older only */
147 float dscale[3]; /* ack!, changing */
148 float rot[3], drot[3]; /* euler rotation */
149 float quat[4], dquat[4]; /* quaternion rotation */
150 float rotAxis[3], drotAxis[3]; /* axis angle rotation - axis part */
151 float rotAngle, drotAngle; /* axis angle rotation - angle part */
152 float obmat[4][4]; /* final worldspace matrix with constraints & animsys applied */
153 float parentinv[4][4]; /* inverse result of parent, so that object doesn't 'stick' to parent */
154 float constinv[4][4]; /* inverse result of constraints. doesn't include effect of parent or object local transform */
155 float imat[4][4]; /* inverse matrix of 'obmat' for any other use than rendering! */
156 /* note: this isn't assured to be valid as with 'obmat',
157 * before using this value you should do...
158 * invert_m4_m4(ob->imat, ob->obmat); */
160 /* Previously 'imat' was used at render time, but as other places use it too
161 * the interactive ui of 2.5 creates problems. So now only 'imat_ren' should
162 * be used when ever the inverse of ob->obmat * re->viewmat is needed! - jahka
164 float imat_ren[4][4];
166 unsigned int lay; /* copy of Base's layer in the scene */
168 float sf; /* sf is time-offset */
170 short flag; /* copy of Base */
171 short colbits DNA_DEPRECATED; /* deprecated */
173 short transflag, protectflag; /* transformation settings and transform locks */
174 short trackflag, upflag;
175 short nlaflag; /* used for DopeSheet filtering settings (expanded/collapsed) */
176 short ipoflag; // xxx depreceated... old animation system
177 short scaflag; /* ui state for game logic */
178 char scavisflag; /* more display settings for game logic */
181 int dupon, dupoff, dupsta, dupend;
183 /* during realtime */
185 /* note that inertia is only called inertia for historical reasons
186 * and is not changed to avoid DNA surgery. It actually reflects the
187 * Size value in the GameButtons (= radius) */
189 float mass, damping, inertia;
190 /* The form factor k is introduced to give the user more control
191 * and to fix incompatibility problems.
192 * For rotational symmetric objects, the inertia value can be
193 * expressed as: Theta = k * m * r^2
194 * where m = Mass, r = Radius
195 * For a Sphere, the form factor is by default = 0.4
199 float rdamping, sizefac;
201 float max_vel; /* clamp the maximum velocity 0.0 is disabled */
202 float min_vel; /* clamp the minimum velocity 0.0 is disabled */
203 float m_contactProcessingThreshold;
206 /* "Character" physics properties */
212 short rotmode; /* rotation mode - uses defines set out in DNA_action_types.h for PoseChannel rotations... */
214 char boundtype; /* bounding box use for drawing */
215 char collision_boundtype; /* bounding box type used for collision */
217 char restrictflag; /* for restricting view, select, render etc. accessible in outliner */
219 char dt; /* viewport draw type */
220 char dtx; /* viewport draw extra settings */
222 float empty_drawsize;
223 float dupfacesca; /* dupliface scale */
225 ListBase prop; /* game logic property list (not to be confused with IDProperties) */
226 ListBase sensors; /* game logic sensors */
227 ListBase controllers; /* game logic controllers */
228 ListBase actuators; /* game logic actuators */
230 float bbsize[3] DNA_DEPRECATED;
231 short index; /* custom index, for renderpasses */
232 unsigned short actdef; /* current deformation group, note: index starts at 1 */
233 float col[4]; /* object color */
238 struct BulletSoftBody *bsoft; /* settings for game engine bullet soft body */
240 short softflag; /* softbody settings */
241 short recalc; /* dependency flag */
242 float anisotropicFriction[3];
244 ListBase constraints; /* object constraints */
245 ListBase nlastrips DNA_DEPRECATED; // XXX depreceated... old animation system
246 ListBase hooks DNA_DEPRECATED; // XXX depreceated... old animation system
247 ListBase particlesystem; /* particle systems */
249 struct PartDeflect *pd; /* particle deflector/attractor/collision data */
250 struct SoftBody *soft; /* if exists, saved in file */
251 struct Group *dup_group; /* object duplicator for group */
253 char body_type; /* for now used to temporarily holds the type of collision object */
254 char shapeflag; /* flag for pinning */
255 short shapenr; /* current shape key for menu or pinned */
256 float smoothresh; /* smoothresh is phong interpolation ray_shadow correction in render */
258 struct FluidsimSettings *fluidsimSettings; /* if fluidsim enabled, store additional settings */
260 struct DerivedMesh *derivedDeform, *derivedFinal;
262 uint64_t lastDataMask; /* the custom data layer mask that was last used to calculate derivedDeform and derivedFinal */
263 uint64_t customdata_mask; /* (extra) custom data layer mask to use for creating derivedmesh, set by depsgraph */
264 unsigned int state; /* bit masks of game controllers that are active */
265 unsigned int init_state; /* bit masks of initial state as recorded by the users */
267 ListBase gpulamp; /* runtime, for glsl lamp display only */
269 ListBase *duplilist; /* for temporary dupli list storage, only for use by RNA API */
271 float ima_ofs[2]; /* offset for image empties */
274 /* Warning, this is not used anymore because hooks are now modifiers */
275 typedef struct ObHook {
276 struct ObHook *next, *prev;
278 struct Object *parent;
279 float parentinv[4][4]; /* matrix making current transform unmodified */
280 float mat[4][4]; /* temp matrix while hooking */
281 float cent[3]; /* visualization of hook */
282 float falloff; /* if not zero, falloff is distance where influence zero */
284 char name[64]; /* MAX_NAME */
287 int totindex, curindex; /* curindex is cache for fast lookup */
288 short type, active; /* active is only first hook, for button menu */
292 /* runtime only, but include here for rna access */
293 typedef struct DupliObject {
294 struct DupliObject *next, *prev;
296 unsigned int origlay;
298 float mat[4][4], omat[4][4];
299 float orco[3], uv[2];
301 short type; /* from Object.transflag */
302 char no_draw, animated;
304 /* Lowest-level particle index.
305 * Note: This is needed for particle info in shaders.
306 * Otherwise dupli groups in particle systems would override the
307 * index value from higher dupli levels. Would be nice to have full generic access
308 * to all dupli levels somehow, but for now this should cover most use-cases.
314 /* **************** OBJECT ********************* */
316 /* used many places... should be specialized */
330 #define OB_SPEAKER 12
332 // #define OB_WAVE 21
333 #define OB_LATTICE 22
335 /* 23 and 24 are for life and sector (old file compat.) */
336 #define OB_ARMATURE 25
338 /* check if the object type supports materials */
339 #define OB_TYPE_SUPPORT_MATERIAL(_type) \
340 ((_type) >= OB_MESH && (_type) <= OB_MBALL)
341 #define OB_TYPE_SUPPORT_VGROUP(_type) \
342 (ELEM(_type, OB_MESH, OB_LATTICE))
343 #define OB_TYPE_SUPPORT_EDITMODE(_type) \
344 (ELEM7(_type, OB_MESH, OB_FONT, OB_CURVE, OB_SURF, OB_MBALL, OB_LATTICE, OB_ARMATURE))
346 /* is this ID type used as object data */
347 #define OB_DATA_SUPPORT_ID(_id_type) \
348 (ELEM8(_id_type, ID_ME, ID_CU, ID_MB, ID_LA, ID_SPK, ID_CA, ID_LT, ID_AR))
350 /* partype: first 4 bits: type */
361 /* slow parenting - is not threadsafe and/or may give errors after jumping */
364 /* (short) transflag */
365 /* flags 1 and 2 were unused or relics from past features */
366 #define OB_NEG_SCALE 4
367 #define OB_DUPLI (8+16+256+512+2048)
368 #define OB_DUPLIFRAMES 8
369 #define OB_DUPLIVERTS 16
370 #define OB_DUPLIROT 32
371 #define OB_DUPLINOSPEED 64
372 /*#define OB_POWERTRACK 128*/ /*UNUSED*/
373 #define OB_DUPLIGROUP 256
374 #define OB_DUPLIFACES 512
375 #define OB_DUPLIFACES_SCALE 1024
376 #define OB_DUPLIPARTS 2048
377 #define OB_RENDER_DUPLI 4096
378 #define OB_NO_CONSTRAINTS 8192 /* runtime constraints disable */
380 /* (short) ipoflag */
381 /* XXX: many old flags for features removed due to incompatibility
382 * with new system and/or other design issues were here
384 /* for stride/path editing (XXX: NEEDS REVIEW) */
385 #define OB_DISABLE_PATH 1024
387 /* (short) trackflag / upflag */
395 /* gameflag in game.h */
398 #define OB_BOUNDBOX 1
401 #define OB_MATERIAL 4
405 #define OB_PAINT 100 /* temporary used in draw code */
407 /* dtx: flags, char! */
409 #define OB_TEXSPACE 4
410 #define OB_DRAWNAME 8
411 #define OB_DRAWIMAGE 16
412 /* for solid+wire display */
413 #define OB_DRAWWIRE 32
415 #define OB_DRAWXRAY 64
416 /* enable transparent draw */
417 #define OB_DRAWTRANSP 128
419 /* empty_drawtype: no flags */
421 #define OB_PLAINAXES 2
423 #define OB_SINGLE_ARROW 4
425 #define OB_EMPTY_SPHERE 6
426 #define OB_EMPTY_CONE 7
427 #define OB_EMPTY_IMAGE 8
430 #define OB_BOUND_BOX 0
431 #define OB_BOUND_SPHERE 1
432 #define OB_BOUND_CYLINDER 2
433 #define OB_BOUND_CONE 3
434 #define OB_BOUND_TRIANGLE_MESH 4
435 #define OB_BOUND_CONVEX_HULL 5
436 /* #define OB_BOUND_DYN_MESH 6 */ /*UNUSED*/
437 #define OB_BOUND_CAPSULE 7
440 /* **************** BASE ********************* */
442 /* also needed for base!!!!! or rather, thy interfere....*/
443 /* base->flag and ob->flag */
445 #define BA_HAS_RECALC_OB 4
446 #define BA_HAS_RECALC_DATA 8
448 /* NOTE: this was used as a proper setting in past, so nullify before using */
449 #define BA_TEMP_TAG 32
451 /* #define BA_FROMSET 128 */ /*UNUSED*/
453 #define BA_TRANSFORM_CHILD 256 /* child of a transformed object */
454 #define BA_TRANSFORM_PARENT 8192 /* parent of a transformed object */
457 /* an initial attempt as making selection more specific! */
458 #define BA_DESELECT 0
462 #define OB_FROMDUPLI 512
464 // #define OB_RADIO 2048 /* deprecated */
465 #define OB_FROMGROUP 4096
467 /* WARNING - when adding flags check on PSYS_RECALC */
468 /* ob->recalc (flag bits!) */
469 #define OB_RECALC_OB (1 << 0)
470 #define OB_RECALC_DATA (1 << 1)
471 /* time flag is set when time changes need recalc, so baked systems can ignore it */
472 #define OB_RECALC_TIME (1 << 2)
473 /* only use for matching any flag, NOT as an argument since more flags may be added. */
474 #define OB_RECALC_ALL (OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME)
476 /* controller state */
477 #define OB_MAX_STATES 30
483 #define OB_INERTIA_LOCK_X 8
484 #define OB_INERTIA_LOCK_Y 16
485 #define OB_INERTIA_LOCK_Z 32
487 #define OB_ROT_FH 128
488 #define OB_ANISOTROPIC_FRICTION 256
490 #define OB_RIGID_BODY 1024
491 #define OB_BOUNDS 2048
493 #define OB_COLLISION_RESPONSE 4096
494 #define OB_SECTOR 8192
495 #define OB_PROP 16384
496 #define OB_MAINACTOR 32768
498 #define OB_COLLISION 65536
499 #define OB_SOFT_BODY 0x20000
500 #define OB_OCCLUDER 0x40000
501 #define OB_SENSOR 0x80000
502 #define OB_NAVMESH 0x100000
503 #define OB_HASOBSTACLE 0x200000
504 #define OB_CHARACTER 0x400000
507 #define OB_NEVER_DO_ACTIVITY_CULLING 1
508 #define OB_LOCK_RIGID_BODY_X_AXIS 4
509 #define OB_LOCK_RIGID_BODY_Y_AXIS 8
510 #define OB_LOCK_RIGID_BODY_Z_AXIS 16
511 #define OB_LOCK_RIGID_BODY_X_ROT_AXIS 32
512 #define OB_LOCK_RIGID_BODY_Y_ROT_AXIS 64
513 #define OB_LOCK_RIGID_BODY_Z_ROT_AXIS 128
515 /* #define OB_LIFE (OB_PROP|OB_DYNAMIC|OB_ACTOR|OB_MAINACTOR|OB_CHILD) */
518 #define OB_BODY_TYPE_NO_COLLISION 0
519 #define OB_BODY_TYPE_STATIC 1
520 #define OB_BODY_TYPE_DYNAMIC 2
521 #define OB_BODY_TYPE_RIGID 3
522 #define OB_BODY_TYPE_SOFT 4
523 #define OB_BODY_TYPE_OCCLUDER 5
524 #define OB_BODY_TYPE_SENSOR 6
525 #define OB_BODY_TYPE_NAVMESH 7
526 #define OB_BODY_TYPE_CHARACTER 8
529 #define OB_VIS_SENS 1
530 #define OB_VIS_CONT 2
534 #define OB_SHOWSENS 64
535 #define OB_SHOWACT 128
536 #define OB_ADDSENS 256
537 #define OB_ADDCONT 512
538 #define OB_ADDACT 1024
539 #define OB_SHOWCONT 2048
540 #define OB_ALLSTATE 4096
541 #define OB_INITSTBIT 8192
542 #define OB_DEBUGSTATE 16384
543 #define OB_SHOWSTATE 32768
545 /* ob->restrictflag */
546 #define OB_RESTRICT_VIEW 1
547 #define OB_RESTRICT_SELECT 2
548 #define OB_RESTRICT_RENDER 4
551 #define OB_SHAPE_LOCK 1
552 #define OB_SHAPE_TEMPLOCK 2 // deprecated
553 #define OB_SHAPE_EDIT_MODE 4
556 /* WARNING: flags (1<<0) and (1<<1) were from old animsys */
557 /* object-channel expanded status */
558 #define OB_ADS_COLLAPSED (1<<10)
559 /* object's ipo-block */
560 #define OB_ADS_SHOWIPO (1<<11)
561 /* object's constraint channels */
562 #define OB_ADS_SHOWCONS (1<<12)
563 /* object's material channels */
564 #define OB_ADS_SHOWMATS (1<<13)
565 /* object's marticle channels */
566 #define OB_ADS_SHOWPARTS (1<<14)
568 /* ob->protectflag */
569 #define OB_LOCK_LOCX 1
570 #define OB_LOCK_LOCY 2
571 #define OB_LOCK_LOCZ 4
572 #define OB_LOCK_LOC 7
573 #define OB_LOCK_ROTX 8
574 #define OB_LOCK_ROTY 16
575 #define OB_LOCK_ROTZ 32
576 #define OB_LOCK_ROT 56
577 #define OB_LOCK_SCALEX 64
578 #define OB_LOCK_SCALEY 128
579 #define OB_LOCK_SCALEZ 256
580 #define OB_LOCK_SCALE 448
581 #define OB_LOCK_ROTW 512
582 #define OB_LOCK_ROT4D 1024
585 typedef enum ObjectMode {
589 OB_MODE_VERTEX_PAINT = 4,
590 OB_MODE_WEIGHT_PAINT = 8,
591 OB_MODE_TEXTURE_PAINT = 16,
592 OB_MODE_PARTICLE_EDIT = 32,
596 /* any mode where the brush system is used */
597 #define OB_MODE_ALL_PAINT (OB_MODE_SCULPT|OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT|OB_MODE_TEXTURE_PAINT)
599 #define MAX_DUPLI_RECUR 8