Blender V2.61 - r43446

DNA_particle_types.h

Go to the documentation of this file.
00001 /*
00002  * ***** BEGIN GPL LICENSE BLOCK *****
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License
00006  * as published by the Free Software Foundation; either version 2
00007  * of the License, or (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software Foundation,
00016  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017  *
00018  * The Original Code is Copyright (C) 2007 by Janne Karhu.
00019  * All rights reserved.
00020  *
00021  * The Original Code is: all of this file.
00022  *
00023  * Contributor(s): none yet.
00024  *
00025  * ***** END GPL LICENSE BLOCK *****
00026  */
00027 
00032 #ifndef DNA_PARTICLE_TYPES_H
00033 #define DNA_PARTICLE_TYPES_H
00034 
00035 #include "DNA_defs.h"
00036 #include "DNA_ID.h"
00037 #include "DNA_boid_types.h"
00038 
00039 struct AnimData;
00040 
00041 typedef struct HairKey {
00042     float co[3];    /* location of hair vertex */
00043     float time;     /* time along hair, default 0-100 */
00044     float weight;   /* softbody weight */
00045     short editflag; /* saved particled edit mode flags */
00046     short pad;
00047 } HairKey;
00048 
00049 typedef struct ParticleKey {    /* when changed update size of struct to copy_particleKey()!! */
00050     float co[3];    /* location */
00051     float vel[3];   /* velocity */
00052     float rot[4];   /* rotation quaternion */
00053     float ave[3];   /* angular velocity */
00054     float time;     /* when this key happens */
00055 } ParticleKey;
00056 
00057 typedef struct BoidParticle {
00058     struct Object *ground;
00059     struct BoidData data;
00060     float gravity[3];
00061     float wander[3];
00062     float rt;
00063 } BoidParticle;
00064 
00065 typedef struct ParticleSpring {
00066     float rest_length;
00067     unsigned int particle_index[2], delete_flag;
00068 } ParticleSpring;
00069 
00070 /* Child particles are created around or between parent particles */
00071 typedef struct ChildParticle {
00072     int num, parent;    /* num is face index on the final derived mesh */
00073     int pa[4];          /* nearest particles to the child, used for the interpolation */
00074     float w[4];         /* interpolation weights for the above particles */
00075     float fuv[4], foffset; /* face vertex weights and offset */
00076     float rt;
00077 } ChildParticle;
00078 
00079 typedef struct ParticleTarget {
00080     struct ParticleTarget *next, *prev;
00081     struct Object *ob;
00082     int psys;
00083     short flag, mode;
00084     float time, duration;
00085 } ParticleTarget;
00086 
00087 typedef struct ParticleDupliWeight {
00088     struct ParticleDupliWeight *next, *prev;
00089     struct Object *ob;
00090     short count;
00091     short flag;
00092     short index, rt; /* only updated on file save and used on file load */
00093 } ParticleDupliWeight;
00094 
00095 typedef struct ParticleData {
00096     ParticleKey state;      /* current global coordinates */
00097 
00098     ParticleKey prev_state; /* previous state */
00099     
00100     HairKey *hair;          /* hair vertices */
00101 
00102     ParticleKey *keys;      /* keyed keys */
00103 
00104     BoidParticle *boid;     /* boids data */
00105 
00106     int totkey;             /* amount of hair or keyed keys*/
00107 
00108     float time, lifetime;   /* dietime is not nescessarily time+lifetime as */
00109     float dietime;          /* particles can die unnaturally (collision)    */
00110 
00111     int num;                /* index to vert/edge/face */
00112     int num_dmcache;        /* index to derived mesh data (face) to avoid slow lookups */
00113 
00114     float fuv[4], foffset;  /* coordinates on face/edge number "num" and depth along*/
00115                             /* face normal for volume emission                      */
00116 
00117     float size;             /* size and multiplier so that we can update size when ever */
00118 
00119     int hair_index;
00120     short flag;
00121     short alive;            /* the life state of a particle */
00122 } ParticleData;
00123 
00124 typedef struct SPHFluidSettings {
00125     /*Particle Fluid*/
00126     float radius, spring_k, rest_length;
00127     float plasticity_constant, yield_ratio;
00128     float plasticity_balance, yield_balance;
00129     float viscosity_omega, viscosity_beta;
00130     float stiffness_k, stiffness_knear, rest_density;
00131     float buoyancy;
00132     int flag, spring_frames;
00133 } SPHFluidSettings;
00134 
00135 /* fluid->flag */
00136 #define SPH_VISCOELASTIC_SPRINGS    1
00137 #define SPH_CURRENT_REST_LENGTH     2
00138 #define SPH_FAC_REPULSION           4
00139 #define SPH_FAC_DENSITY             8
00140 #define SPH_FAC_RADIUS              16
00141 #define SPH_FAC_VISCOSITY           32
00142 #define SPH_FAC_REST_LENGTH         64
00143 
00144 typedef struct ParticleSettings {
00145     ID id;
00146     struct AnimData *adt;
00147 
00148     struct BoidSettings *boids;
00149     struct SPHFluidSettings *fluid;
00150 
00151     struct EffectorWeights *effector_weights;
00152 
00153     int flag, rt;
00154     short type, from, distr, texact;
00155     /* physics modes */
00156     short phystype, rotmode, avemode, reactevent;
00157     short draw, draw_as, draw_size, childtype;
00158     short ren_as, subframes, draw_col;
00159     /* number of path segments, power of 2 except */
00160     short draw_step, ren_step;
00161     short hair_step, keys_step;
00162 
00163     /* adaptive path rendering */
00164     short adapt_angle, adapt_pix;
00165 
00166     short disp, omat, interpolation, rotfrom, integrator;
00167     short kink, kink_axis;
00168 
00169     /* billboards */
00170     short bb_align, bb_uv_split, bb_anim, bb_split_offset;
00171     float bb_tilt, bb_rand_tilt, bb_offset[2], bb_size[2], bb_vel_head, bb_vel_tail;
00172 
00173     /* draw color */
00174     float color_vec_max;
00175 
00176     /* simplification */
00177     short simplify_flag, simplify_refsize;
00178     float simplify_rate, simplify_transition;
00179     float simplify_viewport;
00180 
00181     /* time and emission */
00182     float sta, end, lifetime, randlife;
00183     float timetweak, courant_target;
00184     float jitfac, eff_hair, grid_rand, ps_offset[1];
00185     int totpart, userjit, grid_res, effector_amount;
00186     short time_flag, time_pad[3];
00187 
00188     /* initial velocity factors */
00189     float normfac, obfac, randfac, partfac, tanfac, tanphase, reactfac;
00190     float ob_vel[3];
00191     float avefac, phasefac, randrotfac, randphasefac;
00192     /* physical properties */
00193     float mass, size, randsize;
00194     /* global physical properties */
00195     float acc[3], dragfac, brownfac, dampfac;
00196     /* length */
00197     float randlength;
00198     /* children */
00199     int child_nbr, ren_child_nbr;
00200     float parents, childsize, childrandsize;
00201     float childrad, childflat;
00202     /* clumping */
00203     float clumpfac, clumppow;
00204     /* kink */
00205     float kink_amp, kink_freq, kink_shape, kink_flat;
00206     float kink_amp_clump;
00207     /* rough */
00208     float rough1, rough1_size;
00209     float rough2, rough2_size, rough2_thres;
00210     float rough_end, rough_end_shape;
00211     /* length */
00212     float clength, clength_thres;
00213     /* parting */
00214     float parting_fac;
00215     float parting_min, parting_max;
00216     /* branching */
00217     float branch_thres;
00218     /* drawing stuff */
00219     float draw_line[2];
00220     float path_start, path_end;
00221     int trail_count;
00222     /* keyed particles */
00223     int keyed_loops;
00224 
00225     struct MTex *mtex[18];      /* MAX_MTEX */
00226 
00227     struct Group *dup_group;
00228     struct ListBase dupliweights;
00229     struct Group *eff_group  DNA_DEPRECATED;        // deprecated
00230     struct Object *dup_ob;
00231     struct Object *bb_ob;
00232     struct Ipo *ipo  DNA_DEPRECATED;  /* old animation system, deprecated for 2.5 */
00233     struct PartDeflect *pd;
00234     struct PartDeflect *pd2;
00235 } ParticleSettings;
00236 
00237 typedef struct ParticleSystem
00238 {   /* note1: make sure all (runtime) are NULL's in 'copy_particlesystem' XXX, this function is no more! - need to invstigate */
00239     /* note2: make sure any uses of this struct in DNA are accounted for in 'copy_object_particlesystems' */
00240 
00241     struct ParticleSystem *next, *prev;
00242 
00243     ParticleSettings *part;                 /* particle settings */
00244 
00245     ParticleData *particles;                /* (parent) particles */
00246     ChildParticle *child;                   /* child particles */
00247 
00248     struct PTCacheEdit *edit;                       /* particle editmode (runtime) */
00249     void (*free_edit)(struct PTCacheEdit *edit);    /* free callback */
00250 
00251     struct ParticleCacheKey **pathcache;    /* path cache (runtime) */
00252     struct ParticleCacheKey **childcache;   /* child cache (runtime) */
00253     ListBase pathcachebufs, childcachebufs; /* buffers for the above */
00254 
00255     struct ClothModifierData *clmd;                 /* cloth simulation for hair */
00256     struct DerivedMesh *hair_in_dm, *hair_out_dm;   /* input/output for cloth simulation */
00257 
00258     struct Object *target_ob;
00259     struct Object *lattice;
00260     struct Object *parent;                  /* particles from global space -> parent space */
00261 
00262     struct ListBase targets;                /* used for keyed and boid physics */
00263 
00264     char name[64];                          /* particle system name, MAX_NAME */
00265     
00266     float imat[4][4];   /* used for duplicators */
00267     float cfra, tree_frame, bvhtree_frame;
00268     int seed, child_seed;
00269     int flag, totpart, totunexist, totchild, totcached, totchildcache;
00270     short recalc, target_psys, totkeyed, bakespace;
00271 
00272     char bb_uvname[3][64];                  /* billboard uv name, MAX_CUSTOMDATA_LAYER_NAME */
00273 
00274     /* if you change these remember to update array lengths to PSYS_TOT_VG! */
00275     short vgroup[12], vg_neg, rt3;          /* vertex groups, 0==disable, 1==starting index */
00276 
00277     /* temporary storage during render */
00278     void *renderdata;
00279 
00280     /* point cache */
00281     struct PointCache *pointcache;
00282     struct ListBase ptcaches;
00283 
00284     struct ListBase *effectors;
00285 
00286     ParticleSpring *fluid_springs;
00287     int tot_fluidsprings, alloc_fluidsprings;
00288 
00289     struct KDTree *tree;                                /* used for interactions with self and other systems */
00290     struct BVHTree *bvhtree;                                /* used for interactions with self and other systems */
00291 
00292     struct ParticleDrawData *pdd;
00293 
00294     float *frand;                           /* array of 1024 random floats for fast lookups */
00295 
00296     float dt_frac;                          /* current time step, as a fraction of a frame */
00297     float _pad;                             /* spare capacity */
00298 } ParticleSystem;
00299 
00300 /* part->type */
00301 /* hair is allways baked static in object/geometry space */
00302 /* other types (normal particles) are in global space and not static baked */
00303 #define PART_EMITTER        0
00304 //#define PART_REACTOR      1
00305 #define PART_HAIR           2
00306 #define PART_FLUID          3
00307 
00308 /* part->flag */
00309 #define PART_REACT_STA_END  1
00310 #define PART_REACT_MULTIPLE 2
00311 
00312 //#define PART_LOOP         4   /* not used anymore */
00313         /* for dopesheet */
00314 #define PART_DS_EXPAND      8
00315 
00316 #define PART_HAIR_REGROW    16  /* regrow hair for each frame */
00317 
00318 #define PART_UNBORN         32  /*show unborn particles*/
00319 #define PART_DIED           64  /*show died particles*/
00320 
00321 #define PART_TRAND          128 
00322 #define PART_EDISTR         256 /* particle/face from face areas */
00323 
00324 //#define PART_STICKY           512 /*collided particles can stick to collider*/
00325 #define PART_DIE_ON_COL     (1<<12)
00326 #define PART_SIZE_DEFL      (1<<13) /* swept sphere deflections */
00327 #define PART_ROT_DYN        (1<<14) /* dynamic rotation */
00328 #define PART_SIZEMASS       (1<<16)
00329 
00330 #define PART_HIDE_ADVANCED_HAIR (1<<15)
00331 
00332 //#define PART_ABS_TIME     (1<<17)
00333 //#define PART_GLOB_TIME        (1<<18)
00334 
00335 #define PART_BOIDS_2D       (1<<19)
00336 
00337 //#define PART_BRANCHING        (1<<20)
00338 //#define PART_ANIM_BRANCHING   (1<<21)
00339 
00340 #define PART_HAIR_BSPLINE   1024
00341 
00342 #define PART_GRID_HEXAGONAL (1<<24)
00343 #define PART_GRID_INVERT    (1<<26)
00344 
00345 #define PART_CHILD_EFFECT       (1<<27)
00346 #define PART_CHILD_LONG_HAIR    (1<<28)
00347 /* #define PART_CHILD_RENDER        (1<<29) */ /*UNUSED*/
00348 #define PART_CHILD_GUIDE        (1<<30)
00349 
00350 #define PART_SELF_EFFECT    (1<<22)
00351 
00352 /* part->rotfrom */
00353 #define PART_ROT_KEYS       0   /* interpolate directly from keys */
00354 #define PART_ROT_ZINCR      1   /* same as zdir but done incrementally from previous position */
00355 #define PART_ROT_IINCR      2   /* same as idir but done incrementally from previous position */
00356 
00357 /* part->from */
00358 #define PART_FROM_VERT      0
00359 #define PART_FROM_FACE      1
00360 #define PART_FROM_VOLUME    2
00361 /* #define PART_FROM_PARTICLE   3  deprecated! */ 
00362 #define PART_FROM_CHILD     4
00363 
00364 /* part->distr */
00365 #define PART_DISTR_JIT      0
00366 #define PART_DISTR_RAND     1
00367 #define PART_DISTR_GRID     2
00368 
00369 /* part->phystype */
00370 #define PART_PHYS_NO        0
00371 #define PART_PHYS_NEWTON    1
00372 #define PART_PHYS_KEYED     2
00373 #define PART_PHYS_BOIDS     3
00374 #define PART_PHYS_FLUID     4
00375 
00376 /* part->kink */
00377 #define PART_KINK_NO        0
00378 #define PART_KINK_CURL      1
00379 #define PART_KINK_RADIAL    2
00380 #define PART_KINK_WAVE      3
00381 #define PART_KINK_BRAID     4
00382 
00383 /* part->draw */
00384 #define PART_DRAW_VEL       1
00385 #define PART_DRAW_GLOBAL_OB 2
00386 #define PART_DRAW_SIZE      4
00387 #define PART_DRAW_EMITTER   8   /* render emitter also */
00388 #define PART_DRAW_HEALTH    16
00389 #define PART_ABS_PATH_TIME  32
00390 #define PART_DRAW_COUNT_GR  64
00391 #define PART_DRAW_BB_LOCK   128 /* used with billboards */
00392 #define PART_DRAW_ROTATE_OB 128 /* used with dupliobjects/groups */
00393 #define PART_DRAW_PARENT    256
00394 #define PART_DRAW_NUM       512
00395 #define PART_DRAW_RAND_GR   1024
00396 #define PART_DRAW_REN_ADAPT 2048
00397 #define PART_DRAW_VEL_LENGTH    (1<<12)
00398 #define PART_DRAW_MAT_COL       (1<<13) /* deprecated, but used in do_versions */
00399 #define PART_DRAW_WHOLE_GR      (1<<14)
00400 #define PART_DRAW_REN_STRAND    (1<<15)
00401 
00402 /* part->draw_col */
00403 #define PART_DRAW_COL_NONE      0
00404 #define PART_DRAW_COL_MAT       1
00405 #define PART_DRAW_COL_VEL       2
00406 #define PART_DRAW_COL_ACC       3
00407 
00408 
00409 /* part->simplify_flag */
00410 #define PART_SIMPLIFY_ENABLE    1
00411 #define PART_SIMPLIFY_VIEWPORT  2
00412 
00413 /* part->time_flag */
00414 #define PART_TIME_AUTOSF    1 /* Automatic subframes */
00415 
00416 /* part->bb_align */
00417 #define PART_BB_X       0
00418 #define PART_BB_Y       1
00419 #define PART_BB_Z       2
00420 #define PART_BB_VIEW    3
00421 #define PART_BB_VEL     4
00422 
00423 /* part->bb_anim */
00424 #define PART_BB_ANIM_NONE   0
00425 #define PART_BB_ANIM_AGE    1
00426 #define PART_BB_ANIM_ANGLE  2
00427 #define PART_BB_ANIM_FRAME  3
00428 
00429 /* part->bb_split_offset */
00430 #define PART_BB_OFF_NONE    0
00431 #define PART_BB_OFF_LINEAR  1
00432 #define PART_BB_OFF_RANDOM  2
00433 
00434 /* part->draw_as */
00435 /* part->ren_as*/
00436 #define PART_DRAW_NOT       0
00437 #define PART_DRAW_DOT       1
00438 #define PART_DRAW_HALO      1
00439 #define PART_DRAW_CIRC      2
00440 #define PART_DRAW_CROSS     3
00441 #define PART_DRAW_AXIS      4
00442 #define PART_DRAW_LINE      5
00443 #define PART_DRAW_PATH      6
00444 #define PART_DRAW_OB        7
00445 #define PART_DRAW_GR        8
00446 #define PART_DRAW_BB        9
00447 #define PART_DRAW_REND      10
00448 
00449 /* part->integrator */
00450 #define PART_INT_EULER      0
00451 #define PART_INT_MIDPOINT   1
00452 #define PART_INT_RK4        2
00453 #define PART_INT_VERLET     3
00454 
00455 /* part->rotmode */
00456 #define PART_ROT_NOR        1
00457 #define PART_ROT_VEL        2
00458 #define PART_ROT_GLOB_X     3
00459 #define PART_ROT_GLOB_Y     4
00460 #define PART_ROT_GLOB_Z     5
00461 #define PART_ROT_OB_X       6
00462 #define PART_ROT_OB_Y       7
00463 #define PART_ROT_OB_Z       8
00464 
00465 /* part->avemode */
00466 #define PART_AVE_SPIN       1
00467 #define PART_AVE_RAND       2
00468 
00469 /* part->reactevent */
00470 #define PART_EVENT_DEATH    0
00471 #define PART_EVENT_COLLIDE  1
00472 #define PART_EVENT_NEAR     2
00473 
00474 /* part->childtype */
00475 #define PART_CHILD_PARTICLES    1
00476 #define PART_CHILD_FACES        2
00477 
00478 /* psys->recalc */
00479 /* starts from 8 so that the first bits can be ob->recalc */
00480 #define PSYS_RECALC_REDO    8   /* only do pathcache etc */
00481 #define PSYS_RECALC_RESET   16  /* reset everything including pointcache */
00482 #define PSYS_RECALC_TYPE    32  /* handle system type change */
00483 #define PSYS_RECALC_CHILD   64  /* only child settings changed */
00484 #define PSYS_RECALC_PHYS    128 /* physics type changed */
00485 #define PSYS_RECALC         248
00486 
00487 /* psys->flag */
00488 #define PSYS_CURRENT        1
00489 #define PSYS_GLOBAL_HAIR    2
00490 #define PSYS_HAIR_DYNAMICS  4
00491 #define PSYS_KEYED_TIMING   8
00492 #define PSYS_ENABLED        16  /* deprecated */
00493 #define PSYS_HAIR_UPDATED   32  /* signal for updating hair particle mode */
00494 #define PSYS_DRAWING        64
00495 #define PSYS_USE_IMAT       128
00496 #define PSYS_DELETE         256 /* remove particlesystem as soon as possible */
00497 #define PSYS_HAIR_DONE      512
00498 #define PSYS_KEYED          1024
00499 #define PSYS_EDITED         2048
00500 //#define PSYS_PROTECT_CACHE    4096 /* deprecated */
00501 #define PSYS_DISABLED       8192
00502 
00503 /* pars->flag */
00504 #define PARS_UNEXIST        1
00505 #define PARS_NO_DISP        2
00506 //#define PARS_STICKY           4 /* deprecated */
00507 #define PARS_REKEY          8
00508 
00509 /* pars->alive */
00510 //#define PARS_KILLED           0 /* deprecated */
00511 #define PARS_DEAD           1
00512 #define PARS_UNBORN         2
00513 #define PARS_ALIVE          3
00514 #define PARS_DYING          4
00515 
00516 /* ParticleDupliWeight->flag */
00517 #define PART_DUPLIW_CURRENT 1
00518 
00519 /* psys->vg */
00520 #define PSYS_TOT_VG         12
00521 
00522 #define PSYS_VG_DENSITY     0
00523 #define PSYS_VG_VEL         1
00524 #define PSYS_VG_LENGTH      2
00525 #define PSYS_VG_CLUMP       3
00526 #define PSYS_VG_KINK        4
00527 #define PSYS_VG_ROUGH1      5
00528 #define PSYS_VG_ROUGH2      6
00529 #define PSYS_VG_ROUGHE      7
00530 #define PSYS_VG_SIZE        8
00531 #define PSYS_VG_TAN         9
00532 #define PSYS_VG_ROT         10
00533 #define PSYS_VG_EFFECTOR    11
00534 
00535 /* ParticleTarget->flag */
00536 #define PTARGET_CURRENT     1
00537 #define PTARGET_VALID       2
00538 
00539 /* ParticleTarget->mode */
00540 #define PTARGET_MODE_NEUTRAL    0
00541 #define PTARGET_MODE_FRIEND     1
00542 #define PTARGET_MODE_ENEMY      2
00543 
00544 /* mapto */
00545 /* init */
00546 #define PAMAP_INIT      15
00547 #define PAMAP_TIME      (1<<0)  /* emission time */
00548 #define PAMAP_LIFE      (1<<1)  /* life time */
00549 #define PAMAP_DENS      (1<<2)  /* density */
00550 #define PAMAP_SIZE      (1<<3)  /* physical size */
00551 /* reset */
00552 #define PAMAP_IVEL      (1<<5)  /* initial velocity */
00553 /* physics */
00554 #define PAMAP_PHYSICS   3136
00555 #define PAMAP_FIELD     (1<<6)  /* force fields */
00556 #define PAMAP_GRAVITY   (1<<10)
00557 #define PAMAP_DAMP      (1<<11)
00558 /* children */
00559 #define PAMAP_CHILD     912
00560 #define PAMAP_CLUMP     (1<<7)
00561 #define PAMAP_KINK      (1<<8)
00562 #define PAMAP_ROUGH     (1<<9)
00563 #define PAMAP_LENGTH    (1<<4)
00564 
00565 #endif