1 /* DNA_particle_types.h
6 * ***** BEGIN GPL LICENSE BLOCK *****
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software Foundation,
20 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 * The Original Code is Copyright (C) 2007 by Janne Karhu.
23 * All rights reserved.
25 * The Original Code is: all of this file.
27 * Contributor(s): none yet.
29 * ***** END GPL LICENSE BLOCK *****
32 #ifndef DNA_PARTICLE_TYPES_H
33 #define DNA_PARTICLE_TYPES_H
37 typedef struct HairKey {
38 float co[3]; /* location of hair vertex */
39 float time; /* time along hair, default 0-100 */
40 float weight; /* softbody weight */
41 short editflag; /* saved particled edit mode flags */
45 typedef struct ParticleKey { /* when changed update size of struct to copy_particleKey()!! */
46 float co[3]; /* location */
47 float vel[3]; /* velocity */
48 float rot[4]; /* rotation quaternion */
49 float ave[3]; /* angular velocity */
50 float time; /* when this key happens */
53 /* Child particles are created around or between parent particles */
54 typedef struct ChildParticle {
55 int num, parent; /* num is face index on the final derived mesh */
56 int pa[4]; /* nearest particles to the child, used for the interpolation */
57 float w[4]; /* interpolation weights for the above particles */
58 float fuv[4], foffset; /* face vertex weights and offset */
62 /* Everything that's non dynamic for a particle: */
63 typedef struct ParticleData {
64 struct Object *stick_ob;/* object that particle sticks to when dead */
66 ParticleKey state; /* normally current global coordinates or */
67 /* in sticky object space if dead & sticky */
69 ParticleKey prev_state; /* previous state */
71 HairKey *hair; /* hair vertices */
73 ParticleKey *keys; /* keyed states */
75 float i_rot[4],r_rot[4];/* initial & random values (i_rot should be removed as it's not used anymore)*/
76 float r_ave[3],r_ve[3];
78 float fuv[4], foffset; /* coordinates on face/edge number "num" and depth along*/
79 /* face normal for volume emission */
81 float time, lifetime; /* dietime is not nescessarily time+lifetime as */
82 float dietime; /* particles can die unnaturally (collision) */
84 float bank; /* banking angle for boids */
86 float size, sizemul; /* size and multiplier so that we can update size when ever */
88 int num; /* index to vert/edge/face */
89 int num_dmcache; /* index to derived mesh data (face) to avoid slow lookups */
93 int bpi; /* softbody body point start index */
96 short alive; /* the life state of a particle */
97 short loop; /* how many times particle life has looped */
101 typedef struct ParticleSettings {
105 short type, from, distr;
107 short phystype, rotmode, avemode, reactevent;
108 short draw, draw_as, draw_size, childtype;
109 short ren_as, rt2[3];
110 /* number of path segments, power of 2 except */
111 short draw_step, ren_step;
112 short hair_step, keys_step;
114 /* adaptive path rendering */
115 short adapt_angle, adapt_pix;
117 short disp, omat, interpolation, rotfrom, integrator;
118 short kink, kink_axis, nbetween, boidneighbours;
121 short bb_align, bb_uv_split, bb_anim, bb_split_offset;
122 float bb_tilt, bb_rand_tilt, bb_offset[2];
125 short simplify_flag, simplify_refsize;
126 float simplify_rate, simplify_transition;
127 float simplify_viewport;
130 float sta, end, lifetime, randlife;
131 float timetweak, jitfac, keyed_time, eff_hair, rt;
132 int totpart, userjit, grid_res;
134 /* initial velocity factors */
135 float normfac, obfac, randfac, partfac, tanfac, tanphase, reactfac;
136 float avefac, phasefac, randrotfac, randphasefac;
137 /* physical properties */
138 float mass, size, randsize, reactshape;
139 /* global physical properties */
140 float acc[3], dragfac, brownfac, dampfac;
142 float length, abslength, randlength;
144 int child_nbr, ren_child_nbr;
145 float parents, childsize, childrandsize;
146 float childrad, childflat, childspread;
148 float clumpfac, clumppow;
150 float kink_amp, kink_freq, kink_shape;
152 float rough1, rough1_size;
153 float rough2, rough2_size, rough2_thres;
154 float rough_end, rough_end_shape;
161 float max_vel, max_lat_acc, max_tan_acc;
162 float average_vel, banking, max_bank, groundz;
166 struct Group *dup_group;
167 struct Group *eff_group;
168 struct Object *dup_ob;
169 struct Object *bb_ob;
171 struct PartDeflect *pd;
172 struct PartDeflect *pd2;
175 typedef struct ParticleSystem{ /* note, make sure all (runtime) are NULL's in copy_particlesystem */
176 struct ParticleSystem *next, *prev;
178 ParticleSettings *part; /* particle settings */
180 ParticleData *particles; /* (parent) particles */
181 ChildParticle *child; /* child particles */
183 struct ParticleEdit *edit; /* particle editmode (runtime) */
184 void (*free_edit)(struct ParticleSystem *sys); /* free callback */
186 struct ParticleCacheKey **pathcache; /* path cache (runtime) */
187 struct ParticleCacheKey **childcache; /* child cache (runtime) */
188 ListBase pathcachebufs, childcachebufs; /* buffers for the above */
190 struct SoftBody *soft; /* hair softbody */
192 struct Object *target_ob;
193 struct Object *keyed_ob;
194 struct Object *lattice;
196 struct ListBase effectors, reactevents; /* runtime */
198 float imat[4][4]; /* used for duplicators */
201 int flag, totpart, totchild, totcached, totchildcache, rt;
202 short recalc, target_psys, keyed_psys, totkeyed, softflag, bakespace;
204 char bb_uvname[3][32]; /* billboard uv name */
206 /* if you change these remember to update array lengths to PSYS_TOT_VG! */
207 short vgroup[12], vg_neg, rt3; /* vertex groups */
209 /* temporary storage during render */
213 struct PointCache *pointcache;
216 /* general particle maximums */
217 /* no special why's, just seem reasonable */
218 /* changing these (atleast upwards) should not cause any major problems */
219 #define MAX_PARTS 100000 /* real particles/system */
220 #define MAX_PART_CHILDREN 10000 /* child particles/real particles */
221 #define MAX_BOIDNEIGHBOURS 10 /* neigbours considered/boid */
224 /* hair is allways baked static in object/geometry space */
225 /* other types (normal particles) are in global space and not static baked */
226 #define PART_EMITTER 0
227 #define PART_REACTOR 1
232 #define PART_REACT_STA_END 1
233 #define PART_REACT_MULTIPLE 2
236 //#define PART_LOOP_INSTANT 8
238 #define PART_HAIR_GEOMETRY 16
240 #define PART_UNBORN 32 /*show unborn particles*/
241 #define PART_DIED 64 /*show died particles*/
243 #define PART_TRAND 128
244 #define PART_EDISTR 256 /* particle/face from face areas */
246 #define PART_STICKY 512 /*collided particles can stick to collider*/
247 #define PART_DIE_ON_COL (1<<12)
248 #define PART_SIZE_DEFL (1<<13) /* swept sphere deflections */
249 #define PART_ROT_DYN (1<<14) /* dynamic rotation */
250 #define PART_SIZEMASS (1<<16)
252 #define PART_ABS_LENGTH (1<<15)
254 #define PART_ABS_TIME (1<<17)
255 #define PART_GLOB_TIME (1<<18)
257 #define PART_BOIDS_2D (1<<19)
259 #define PART_BRANCHING (1<<20)
260 #define PART_ANIM_BRANCHING (1<<21)
261 #define PART_SYMM_BRANCHING (1<<24)
263 #define PART_HAIR_BSPLINE 1024
265 #define PART_GRID_INVERT (1<<26)
267 #define PART_CHILD_EFFECT (1<<27)
268 #define PART_CHILD_SEAMS (1<<28)
269 #define PART_CHILD_RENDER (1<<29)
270 #define PART_CHILD_GUIDE (1<<30)
272 #define PART_SELF_EFFECT (1<<22)
275 #define PART_ROT_KEYS 0 /* interpolate directly from keys */
276 #define PART_ROT_ZINCR 1 /* same as zdir but done incrementally from previous position */
277 #define PART_ROT_IINCR 2 /* same as idir but done incrementally from previous position */
280 #define PART_FROM_VERT 0
281 #define PART_FROM_FACE 1
282 #define PART_FROM_VOLUME 2
283 #define PART_FROM_PARTICLE 3
284 #define PART_FROM_CHILD 4
287 #define PART_DISTR_JIT 0
288 #define PART_DISTR_RAND 1
289 #define PART_DISTR_GRID 2
292 #define PART_PHYS_NO 0
293 #define PART_PHYS_NEWTON 1
294 #define PART_PHYS_KEYED 2
295 #define PART_PHYS_BOIDS 3
298 #define PART_KINK_NO 0
299 #define PART_KINK_CURL 1
300 #define PART_KINK_RADIAL 2
301 #define PART_KINK_WAVE 3
302 #define PART_KINK_BRAID 4
305 #define PART_DRAW_VEL 1
306 //#define PART_DRAW_PATH_LEN 2
307 #define PART_DRAW_SIZE 4
308 #define PART_DRAW_EMITTER 8 /* render emitter also */
309 //#define PART_DRAW_HEALTH 16
310 //#define PART_DRAW_TIMED_PATH 32
311 //#define PART_DRAW_CACHED_PATH 64
312 #define PART_DRAW_BB_LOCK 128
313 #define PART_DRAW_PARENT 256
314 #define PART_DRAW_NUM 512
315 #define PART_DRAW_RAND_GR 1024
316 #define PART_DRAW_REN_ADAPT 2048
317 #define PART_DRAW_VEL_LENGTH (1<<12)
318 #define PART_DRAW_MAT_COL (1<<13)
319 #define PART_DRAW_WHOLE_GR (1<<14)
320 #define PART_DRAW_REN_STRAND (1<<15)
322 /* part->simplify_flag */
323 #define PART_SIMPLIFY_ENABLE 1
324 #define PART_SIMPLIFY_VIEWPORT 2
330 #define PART_BB_VIEW 3
331 #define PART_BB_VEL 4
334 #define PART_BB_ANIM_NONE 0
335 #define PART_BB_ANIM_TIME 1
336 #define PART_BB_ANIM_ANGLE 2
337 #define PART_BB_ANIM_OFF_TIME 3
338 #define PART_BB_ANIM_OFF_ANGLE 4
340 /* part->bb_split_offset */
341 #define PART_BB_OFF_NONE 0
342 #define PART_BB_OFF_LINEAR 1
343 #define PART_BB_OFF_RANDOM 2
347 #define PART_DRAW_NOT 0
348 #define PART_DRAW_DOT 1
349 #define PART_DRAW_HALO 1
350 #define PART_DRAW_CIRC 2
351 #define PART_DRAW_CROSS 3
352 #define PART_DRAW_AXIS 4
353 #define PART_DRAW_LINE 5
354 #define PART_DRAW_PATH 6
355 #define PART_DRAW_OB 7
356 #define PART_DRAW_GR 8
357 #define PART_DRAW_BB 9
358 #define PART_DRAW_REND 10
360 /* part->integrator */
361 #define PART_INT_EULER 0
362 #define PART_INT_MIDPOINT 1
363 #define PART_INT_RK4 2
366 #define PART_ROT_NOR 1
367 #define PART_ROT_VEL 2
368 #define PART_ROT_GLOB_X 3
369 #define PART_ROT_GLOB_Y 4
370 #define PART_ROT_GLOB_Z 5
371 #define PART_ROT_OB_X 6
372 #define PART_ROT_OB_Y 7
373 #define PART_ROT_OB_Z 8
376 #define PART_AVE_SPIN 1
377 #define PART_AVE_RAND 2
379 /* part->reactevent */
380 #define PART_EVENT_DEATH 0
381 #define PART_EVENT_COLLIDE 1
382 #define PART_EVENT_NEAR 2
384 /* part->childtype */
385 #define PART_CHILD_PARTICLES 1
386 #define PART_CHILD_FACES 2
389 #define PSYS_RECALC_REDO 1 /* only do pathcache etc */
390 #define PSYS_RECALC_RESET 2 /* reset everything including pointcache */
391 #define PSYS_RECALC_TYPE 4 /* handle system type change */
392 #define PSYS_RECALC_CHILD 16 /* only child settings changed */
395 #define PSYS_CURRENT 1
396 //#define PSYS_BAKING 2
397 //#define PSYS_BAKE_UI 4
398 #define PSYS_KEYED_TIME 8
399 #define PSYS_ENABLED 16 /* deprecated */
400 #define PSYS_FIRST_KEYED 32
401 #define PSYS_DRAWING 64
402 //#define PSYS_SOFT_BAKE 128
403 #define PSYS_DELETE 256 /* remove particlesystem as soon as possible */
404 #define PSYS_HAIR_DONE 512
405 #define PSYS_KEYED 1024
406 #define PSYS_EDITED 2048
407 //#define PSYS_PROTECT_CACHE 4096
408 #define PSYS_DISABLED 8192
411 #define PARS_UNEXIST 1
412 #define PARS_NO_DISP 2
413 #define PARS_STICKY 4
414 #define PARS_TRANSFORM 8
417 #define PARS_REKEY 64
418 #define PARS_EDIT_RECALC 128
421 #define PARS_KILLED 0
423 #define PARS_UNBORN 2
428 #define PSYS_TOT_VG 12
430 #define PSYS_VG_DENSITY 0
431 #define PSYS_VG_VEL 1
432 #define PSYS_VG_LENGTH 2
433 #define PSYS_VG_CLUMP 3
434 #define PSYS_VG_KINK 4
435 #define PSYS_VG_ROUGH1 5
436 #define PSYS_VG_ROUGH2 6
437 #define PSYS_VG_ROUGHE 7
438 #define PSYS_VG_SIZE 8
439 #define PSYS_VG_TAN 9
440 #define PSYS_VG_ROT 10
441 #define PSYS_VG_EFFECTOR 11
443 /* part->boidrules */
444 #define BOID_TOT_RULES 8
446 #define BOID_COLLIDE 0
449 #define BOID_CENTER 3
450 #define BOID_AV_VEL 4
451 #define BOID_VEL_MATCH 5
456 //#define PSYS_INTER_CUBIC 0
457 //#define PSYS_INTER_LINEAR 1
458 //#define PSYS_INTER_CARDINAL 2
459 //#define PSYS_INTER_BSPLINE 3