Blender  V2.93
BKE_particle.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2007 by Janne Karhu.
17  * All rights reserved.
18  * Adaptive time step
19  * Classical SPH
20  * Copyright 2011-2012 AutoCRC
21  */
22 
23 #pragma once
24 
29 #include "BLI_buffer.h"
30 #include "BLI_utildefines.h"
31 
32 #include "DNA_particle_types.h"
33 
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37 
38 struct ParticleKey;
39 struct ParticleSettings;
40 struct ParticleSystem;
42 
43 struct BVHTreeRay;
44 struct BVHTreeRayHit;
45 struct BlendDataReader;
46 struct BlendLibReader;
47 struct BlendWriter;
49 struct Depsgraph;
50 struct EdgeHash;
51 struct KDTree_3d;
52 struct LatticeDeformData;
53 struct LinkNode;
54 struct MCol;
55 struct MFace;
56 struct MTFace;
57 struct MVert;
58 struct Main;
59 struct ModifierData;
60 struct Object;
61 struct RNG;
62 struct Scene;
63 
64 #define PARTICLE_COLLISION_MAX_COLLISIONS 10
65 
66 #define PARTICLE_P \
67  ParticleData *pa; \
68  int p
69 #define LOOP_PARTICLES for (p = 0, pa = psys->particles; p < psys->totpart; p++, pa++)
70 #define LOOP_EXISTING_PARTICLES \
71  for (p = 0, pa = psys->particles; p < psys->totpart; p++, pa++) \
72  if (!(pa->flag & PARS_UNEXIST))
73 #define LOOP_SHOWN_PARTICLES \
74  for (p = 0, pa = psys->particles; p < psys->totpart; p++, pa++) \
75  if (!(pa->flag & (PARS_UNEXIST | PARS_NO_DISP)))
76 /* OpenMP: Can only advance one variable within loop definition. */
77 #define LOOP_DYNAMIC_PARTICLES \
78  for (p = 0; p < psys->totpart; p++) \
79  if ((pa = psys->particles + p)->state.time > 0.0f)
80 
81 /* fast but sure way to get the modifier*/
82 #define PARTICLE_PSMD \
83  ParticleSystemModifierData *psmd = sim->psmd ? sim->psmd : psys_get_modifier(sim->ob, sim->psys)
84 
85 /* common stuff that many particle functions need */
86 typedef struct ParticleSimulationData {
88  struct Scene *scene;
89  struct Object *ob;
93  /* Courant number. This is used to implement an adaptive time step. Only the
94  * maximum value per time step is important. Only sph_integrate makes use of
95  * this at the moment. Other solvers could, too. */
96  float courant_num;
97  /* Only valid during dynamics_step(). */
98  struct RNG *rng;
100 
101 typedef struct SPHData {
104  float mass;
105  struct EdgeHash *eh;
106  float *gravity;
107  float hfac;
108  /* Average distance to neighbors (other particles in the support domain),
109  * for calculating the Courant number (adaptive time step). */
110  int pass;
112  float flow[3];
113 
114  /* Temporary thread-local buffer for springs created during this step. */
116 
117  /* Integrator callbacks. This allows different SPH implementations. */
118  void (*force_cb)(void *sphdata_v, ParticleKey *state, float *force, float *impulse);
119  void (*density_cb)(void *rangedata_v, int index, const float co[3], float squared_dist);
121 
122 typedef struct ParticleTexture {
123  float ivel; /* used in reset */
124  float time, life, exist, size; /* used in init */
125  float damp, gravity, field; /* used in physics */
126  float length, clump, kink_freq, kink_amp, effector; /* used in path caching */
127  float rough1, rough2, roughe; /* used in path caching */
128  float twist; /* used in path caching */
130 
131 typedef struct ParticleSeam {
132  float v0[3], v1[3];
133  float nor[3], dir[3], tan[3];
134  float length2;
136 
137 typedef struct ParticleCacheKey {
138  float co[3];
139  float vel[3];
140  float rot[4];
141  float col[3];
142  float time;
143  int segments;
145 
146 typedef struct ParticleThreadContext {
147  /* shared */
149  struct Mesh *mesh;
150  struct Material *ma;
151 
152  /* distribution */
153  struct KDTree_3d *tree;
154 
156  int totseam;
157 
158  float *jit, *jitoff, *weight;
159  float maxweight;
161 
162  int cfrom, distr;
163 
165 
166  /* path caching */
170 
171  float cfra;
172 
175  float *vg_effector;
176  float *vg_twist;
177 
182 
183 typedef struct ParticleTask {
185  struct RNG *rng, *rng_path;
186  int begin, end;
188 
189 typedef struct ParticleCollisionElement {
190  /* pointers to original data */
191  float *x[3], *v[3];
192 
193  /* values interpolated from original data*/
194  float x0[3], x1[3], x2[3], p[3];
195 
196  /* results for found intersection point */
197  float nor[3], vel[3], uv[2];
198 
199  /* count of original data (1-4) */
200  int tot;
201 
202  /* index of the collision face */
203  int index;
204 
205  /* flags for inversed normal / particle already inside element at start */
206  short inv_nor, inside;
208 
210 typedef struct ParticleCollision {
211  struct Object *current;
212  struct Object *hit;
214  struct Object *emitter;
215 
218 
220  float f;
221  float fac1, fac2;
222 
223  float cfra, old_cfra;
224 
227 
229 
231 
232  /* total_time is the amount of time in this subframe
233  * inv_total_time is the opposite
234  * inv_timestep is the inverse of the amount of time in this frame */
236 
237  float radius;
238  float co1[3], co2[3];
239  float ve1[3], ve2[3];
240 
241  float acc[3], boid_z;
242 
243  int boid;
245 
246 typedef struct ParticleDrawData {
247  float *vdata, *vd; /* vertice data */
248  float *ndata, *nd; /* normal data */
249  float *cdata, *cd; /* color data */
250  float *vedata, *ved; /* velocity data */
251  float *ma_col;
253  int flag;
256 
257 #define PARTICLE_DRAW_DATA_UPDATED 1
258 
259 #define PSYS_FRAND_COUNT 1024
260 extern unsigned int PSYS_FRAND_SEED_OFFSET[PSYS_FRAND_COUNT];
261 extern unsigned int PSYS_FRAND_SEED_MULTIPLIER[PSYS_FRAND_COUNT];
262 extern float PSYS_FRAND_BASE[PSYS_FRAND_COUNT];
263 
264 void BKE_particle_init_rng(void);
265 
266 BLI_INLINE float psys_frand(ParticleSystem *psys, unsigned int seed)
267 {
268  /* XXX far from ideal, this simply scrambles particle random numbers a bit
269  * to avoid obvious correlations.
270  * Can't use previous psys->frand arrays because these require initialization
271  * inside psys_check_enabled, which wreaks havoc in multi-threaded depsgraph updates.
272  */
273  unsigned int offset = PSYS_FRAND_SEED_OFFSET[psys->seed % PSYS_FRAND_COUNT];
274  unsigned int multiplier = PSYS_FRAND_SEED_MULTIPLIER[psys->seed % PSYS_FRAND_COUNT];
275  return PSYS_FRAND_BASE[(offset + seed * multiplier) % PSYS_FRAND_COUNT];
276 }
277 
278 BLI_INLINE void psys_frand_vec(ParticleSystem *psys, unsigned int seed, float vec[3])
279 {
280  unsigned int offset = PSYS_FRAND_SEED_OFFSET[psys->seed % PSYS_FRAND_COUNT];
281  unsigned int multiplier = PSYS_FRAND_SEED_MULTIPLIER[psys->seed % PSYS_FRAND_COUNT];
282  vec[0] = PSYS_FRAND_BASE[(offset + (seed + 0) * multiplier) % PSYS_FRAND_COUNT];
283  vec[1] = PSYS_FRAND_BASE[(offset + (seed + 1) * multiplier) % PSYS_FRAND_COUNT];
284  vec[2] = PSYS_FRAND_BASE[(offset + (seed + 2) * multiplier) % PSYS_FRAND_COUNT];
285 }
286 
287 /* ----------- functions needed outside particlesystem ---------------- */
288 /* particle.c */
289 int count_particles(struct ParticleSystem *psys);
290 int count_particles_mod(struct ParticleSystem *psys, int totgr, int cur);
291 
292 int psys_get_child_number(struct Scene *scene,
293  struct ParticleSystem *psys,
294  const bool use_render_params);
295 int psys_get_tot_child(struct Scene *scene,
296  struct ParticleSystem *psys,
297  const bool use_render_params);
298 
299 struct ParticleSystem *psys_get_current(struct Object *ob);
300 /* for rna */
301 short psys_get_current_num(struct Object *ob);
302 void psys_set_current_num(struct Object *ob, int index);
303 /* UNUSED */
304 // struct Object *psys_find_object(struct Scene *scene, struct ParticleSystem *psys);
305 
307 
308 /* For a given evaluated particle system get its original.
309  *
310  * If this input is an original particle system already, the return value is the
311  * same as the input. */
312 struct ParticleSystem *psys_orig_get(struct ParticleSystem *psys);
313 
314 /* For a given original object and its particle system, get evaluated particle
315  * system within a given dependency graph. */
317  struct Object *object,
318  struct ParticleSystem *psys);
319 
320 bool psys_in_edit_mode(struct Depsgraph *depsgraph, const struct ParticleSystem *psys);
321 bool psys_check_enabled(struct Object *ob,
322  struct ParticleSystem *psys,
323  const bool use_render_params);
324 bool psys_check_edited(struct ParticleSystem *psys);
325 
330 
331 /* free */
332 void psys_free_path_cache(struct ParticleSystem *psys, struct PTCacheEdit *edit);
333 void psys_free(struct Object *ob, struct ParticleSystem *psys);
334 
335 /* Copy. */
336 void psys_copy_particles(struct ParticleSystem *psys_dst, struct ParticleSystem *psys_src);
337 
339  struct ChildParticle *cpa,
340  float *params);
341 
342 void psys_interpolate_uvs(const struct MTFace *tface, int quad, const float w[4], float uvco[2]);
343 void psys_interpolate_mcol(const struct MCol *mcol, int quad, const float w[4], struct MCol *mc);
344 
345 void copy_particle_key(struct ParticleKey *to, struct ParticleKey *from, int time);
346 
348  struct CustomData_MeshMasks *r_cddata_masks);
350  int from,
351  int index,
352  int index_dmcache,
353  float fuv[4],
354  float foffset,
355  float vec[3],
356  float nor[3],
357  float utan[3],
358  float vtan[3],
359  float orco[3]);
361  struct ParticleSystem *psys);
362 
363 struct ModifierData *object_add_particle_system(struct Main *bmain,
364  struct Scene *scene,
365  struct Object *ob,
366  const char *name);
368  struct Scene *scene,
369  struct Object *ob,
370  const struct ParticleSystem *psys_orig);
371 void object_remove_particle_system(struct Main *bmain, struct Scene *scene, struct Object *ob);
372 struct ParticleSettings *BKE_particlesettings_add(struct Main *bmain, const char *name);
373 void psys_reset(struct ParticleSystem *psys, int mode);
374 
375 void psys_find_parents(struct ParticleSimulationData *sim, const bool use_render_params);
376 
377 void psys_unique_name(struct Object *object, struct ParticleSystem *psys, const char *defname);
378 
380  float cfra,
381  const bool use_render_params);
383  struct Scene *scene,
384  struct Object *ob,
385  struct PTCacheEdit *edit,
386  float cfra,
387  const bool use_render_params);
389  float cfra,
390  const bool editupdate,
391  const bool use_render_params);
392 int do_guides(struct Depsgraph *depsgraph,
393  struct ParticleSettings *part,
394  struct ListBase *effectors,
396  int index,
397  float time);
398 void precalc_guides(struct ParticleSimulationData *sim, struct ListBase *effectors);
399 float psys_get_timestep(struct ParticleSimulationData *sim);
400 float psys_get_child_time(struct ParticleSystem *psys,
401  struct ChildParticle *cpa,
402  float cfra,
403  float *birthtime,
404  float *dietime);
406  struct ChildParticle *cpa,
407  float cfra,
408  float *pa_time);
410  int pa_num,
411  struct ParticleKey *state,
412  const bool vel);
414  int p,
415  struct ParticleKey *state,
416  int always);
417 
418 /* child paths */
423  struct ListBase *modifiers,
424  struct ChildParticle *cpa,
425  struct ParticleTexture *ptex,
426  const float orco[3],
427  float hairmat[4][4],
428  struct ParticleCacheKey *keys,
429  struct ParticleCacheKey *parent_keys,
430  const float parent_orco[3]);
431 
432 void psys_sph_init(struct ParticleSimulationData *sim, struct SPHData *sphdata);
433 void psys_sph_finalize(struct SPHData *sphdata);
434 void psys_sph_density(struct BVHTree *tree, struct SPHData *data, float co[3], float vars[2]);
435 
436 /* for anim.c */
437 void psys_get_dupli_texture(struct ParticleSystem *psys,
438  struct ParticleSettings *part,
439  struct ParticleSystemModifierData *psmd,
440  struct ParticleData *pa,
441  struct ChildParticle *cpa,
442  float uv[2],
443  float orco[3]);
445  struct ParticleData *pa,
446  struct ChildParticle *cpa,
447  struct ParticleCacheKey *cache,
448  float mat[4][4],
449  float *scale);
450 
452  struct ParticleSimulationData *sim);
455  int startpart,
456  int endpart,
457  struct ParticleTask **r_tasks,
458  int *r_numtasks);
459 void psys_tasks_free(struct ParticleTask *tasks, int numtasks);
460 
462  struct Scene *scene,
463  struct Object *ob,
464  struct ParticleSystem *psys);
465 
466 /* particle_system.c */
467 struct ParticleSystem *psys_get_target_system(struct Object *ob, struct ParticleTarget *pt);
469 void psys_update_particle_tree(struct ParticleSystem *psys, float cfra);
470 void psys_changed_type(struct Object *ob, struct ParticleSystem *psys);
471 
472 void psys_make_temp_pointcache(struct Object *ob, struct ParticleSystem *psys);
474  ParticleSystem *psys,
475  int *sfra,
476  int *efra);
477 
478 void psys_check_boid_data(struct ParticleSystem *psys);
479 
481  struct ParticleData *pa,
482  struct ParticleKey *state,
483  float dtime,
484  float cfra);
485 
487  struct Scene *scene,
488  struct Object *ob,
489  struct ParticleSystem *psys,
490  const bool use_render_params);
491 
492 /* Callback format for performing operations on ID-pointers for particle systems */
493 typedef void (*ParticleSystemIDFunc)(struct ParticleSystem *psys,
494  struct ID **idpoin,
495  void *userdata,
496  int cb_flag);
497 
500  void *userdata);
501 
502 /* Reset all particle systems in the given object. */
503 void BKE_particlesystem_reset_all(struct Object *object);
504 
505 /* ----------- functions needed only inside particlesystem ------------ */
506 /* particle.c */
507 void psys_disable_all(struct Object *ob);
508 void psys_enable_all(struct Object *ob);
509 
510 void free_hair(struct Object *ob, struct ParticleSystem *psys, int dynamics);
511 void free_keyed_keys(struct ParticleSystem *psys);
512 void psys_free_particles(struct ParticleSystem *psys);
513 void psys_free_children(struct ParticleSystem *psys);
514 
516  short type, struct ParticleKey keys[4], float dt, struct ParticleKey *result, bool velocity);
517 void psys_vec_rot_to_face(struct Mesh *mesh, struct ParticleData *pa, float vec[3]);
519  struct Mesh *mesh,
520  short from,
521  struct ParticleData *pa,
522  float hairmat[4][4]);
523 void psys_mat_hair_to_global(struct Object *ob,
524  struct Mesh *mesh,
525  short from,
526  struct ParticleData *pa,
527  float hairmat[4][4]);
528 void psys_mat_hair_to_orco(struct Object *ob,
529  struct Mesh *mesh,
530  short from,
531  struct ParticleData *pa,
532  float hairmat[4][4]);
533 
534 float psys_get_dietime_from_cache(struct PointCache *cache, int index);
535 
536 void psys_free_pdd(struct ParticleSystem *psys);
537 
538 float *psys_cache_vgroup(struct Mesh *mesh, struct ParticleSystem *psys, int vgroup);
540  struct ParticleData *pa,
541  struct ParticleTexture *ptex,
542  int event,
543  float cfra);
544 void psys_interpolate_face(struct MVert *mvert,
545  struct MFace *mface,
546  struct MTFace *tface,
547  float (*orcodata)[3],
548  float w[4],
549  float vec[3],
550  float nor[3],
551  float utan[3],
552  float vtan[3],
553  float orco[3]);
555  short from,
556  struct ParticleData *pa,
557  float *values);
558 void psys_get_from_key(
559  struct ParticleKey *key, float loc[3], float vel[3], float rot[4], float *time);
560 
561 /* BLI_bvhtree_ray_cast callback */
562 void BKE_psys_collision_neartest_cb(void *userdata,
563  int index,
564  const struct BVHTreeRay *ray,
565  struct BVHTreeRayHit *hit);
566 void psys_particle_on_dm(struct Mesh *mesh_final,
567  int from,
568  int index,
569  int index_dmcache,
570  const float fw[4],
571  float foffset,
572  float vec[3],
573  float nor[3],
574  float utan[3],
575  float vtan[3],
576  float orco[3]);
577 
578 /* particle_system.c */
579 void distribute_particles(struct ParticleSimulationData *sim, int from);
580 void init_particle(struct ParticleSimulationData *sim, struct ParticleData *pa);
581 void psys_calc_dmcache(struct Object *ob,
582  struct Mesh *mesh_final,
583  struct Mesh *mesh_original,
584  struct ParticleSystem *psys);
585 int psys_particle_dm_face_lookup(struct Mesh *mesh_final,
586  struct Mesh *mesh_original,
587  int findex,
588  const float fw[4],
589  struct LinkNode **poly_nodes);
590 
591 void reset_particle(struct ParticleSimulationData *sim,
592  struct ParticleData *pa,
593  float dtime,
594  float cfra);
595 
597  const bool use_render_params);
598 
599 /* psys_reset */
600 #define PSYS_RESET_ALL 1
601 #define PSYS_RESET_DEPSGRAPH 2
602 /* #define PSYS_RESET_CHILDREN 3 */ /*UNUSED*/
603 #define PSYS_RESET_CACHE_MISS 4
604 
605 /* index_dmcache */
606 #define DMCACHE_NOTFOUND -1
607 #define DMCACHE_ISCHILD -2
608 
609 /* **** Depsgraph evaluation **** */
610 
611 struct Depsgraph;
612 
614  struct ParticleSettings *particle_settings);
615 
616 void BKE_particle_system_eval_init(struct Depsgraph *depsgraph, struct Object *object);
617 
618 /* Draw Cache */
619 enum {
621 };
622 void BKE_particle_batch_cache_dirty_tag(struct ParticleSystem *psys, int mode);
624 
625 extern void (*BKE_particle_batch_cache_dirty_tag_cb)(struct ParticleSystem *psys, int mode);
626 extern void (*BKE_particle_batch_cache_free_cb)(struct ParticleSystem *psys);
627 
628 /* .blend file I/O */
630  struct PartDeflect *pd);
632  struct ID *id,
633  struct PartDeflect *pd);
634 void BKE_particle_system_blend_write(struct BlendWriter *writer, struct ListBase *particles);
636  struct ListBase *particles);
638  struct Object *ob,
639  struct ID *id,
640  struct ListBase *particles);
641 
642 #ifdef __cplusplus
643 }
644 #endif
void BKE_particlesettings_fluid_default_settings(struct ParticleSettings *part)
void distribute_particles(struct ParticleSimulationData *sim, int from)
#define PSYS_FRAND_COUNT
Definition: BKE_particle.h:259
struct ParticleSystem * psys_eval_get(struct Depsgraph *depsgraph, struct Object *object, struct ParticleSystem *psys)
Definition: particle.c:749
void psys_get_dupli_path_transform(struct ParticleSimulationData *sim, struct ParticleData *pa, struct ChildParticle *cpa, struct ParticleCacheKey *cache, float mat[4][4], float *scale)
Definition: particle.c:5107
void psys_get_from_key(struct ParticleKey *key, float loc[3], float vel[3], float rot[4], float *time)
Definition: particle.c:3774
void psys_thread_context_init(struct ParticleThreadContext *ctx, struct ParticleSimulationData *sim)
void psys_calc_dmcache(struct Object *ob, struct Mesh *mesh_final, struct Mesh *mesh_original, struct ParticleSystem *psys)
void psys_vec_rot_to_face(struct Mesh *mesh, struct ParticleData *pa, float vec[3])
Definition: particle.c:3900
void psys_cache_edit_paths(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, struct PTCacheEdit *edit, float cfra, const bool use_render_params)
Definition: particle.c:3686
void psys_get_dupli_texture(struct ParticleSystem *psys, struct ParticleSettings *part, struct ParticleSystemModifierData *psmd, struct ParticleData *pa, struct ChildParticle *cpa, float uv[2], float orco[3])
Definition: particle.c:5019
float * psys_cache_vgroup(struct Mesh *mesh, struct ParticleSystem *psys, int vgroup)
Definition: particle.c:2619
void psys_tasks_free(struct ParticleTask *tasks, int numtasks)
void precalc_guides(struct ParticleSimulationData *sim, struct ListBase *effectors)
Definition: particle.c:2325
int psys_get_tot_child(struct Scene *scene, struct ParticleSystem *psys, const bool use_render_params)
void psys_count_keyed_targets(struct ParticleSimulationData *sim)
void psys_mat_hair_to_orco(struct Object *ob, struct Mesh *mesh, short from, struct ParticleData *pa, float hairmat[4][4])
Definition: particle.c:3884
void psys_sph_finalize(struct SPHData *sphdata)
struct LatticeDeformData * psys_create_lattice_deform_data(struct ParticleSimulationData *sim)
Definition: particle.c:696
struct ParticleSystem * psys_get_target_system(struct Object *ob, struct ParticleTarget *pt)
void BKE_particlesettings_rough_curve_init(struct ParticleSettings *part)
Definition: particle.c:4109
void particle_system_update(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, struct ParticleSystem *psys, const bool use_render_params)
void psys_apply_child_modifiers(struct ParticleThreadContext *ctx, struct ListBase *modifiers, struct ChildParticle *cpa, struct ParticleTexture *ptex, const float orco[3], float hairmat[4][4], struct ParticleCacheKey *keys, struct ParticleCacheKey *parent_keys, const float parent_orco[3])
void psys_get_particle_on_path(struct ParticleSimulationData *sim, int pa_num, struct ParticleKey *state, const bool vel)
Definition: particle.c:4585
void BKE_particle_system_blend_read_lib(struct BlendLibReader *reader, struct Object *ob, struct ID *id, struct ListBase *particles)
Definition: particle.c:5388
void psys_disable_all(struct Object *ob)
Definition: particle.c:724
void psys_mat_hair_to_global(struct Object *ob, struct Mesh *mesh, short from, struct ParticleData *pa, float hairmat[4][4])
Definition: particle.c:3909
float PSYS_FRAND_BASE[PSYS_FRAND_COUNT]
Definition: particle.c:521
void reset_particle(struct ParticleSimulationData *sim, struct ParticleData *pa, float dtime, float cfra)
bool psys_render_simplify_params(struct ParticleSystem *psys, struct ChildParticle *cpa, float *params)
void psys_get_pointcache_start_end(struct Scene *scene, ParticleSystem *psys, int *sfra, int *efra)
void psys_set_current_num(struct Object *ob, int index)
Definition: particle.c:677
void psys_tasks_create(struct ParticleThreadContext *ctx, int startpart, int endpart, struct ParticleTask **r_tasks, int *r_numtasks)
int do_guides(struct Depsgraph *depsgraph, struct ParticleSettings *part, struct ListBase *effectors, ParticleKey *state, int index, float time)
Definition: particle.c:2381
int psys_get_child_number(struct Scene *scene, struct ParticleSystem *psys, const bool use_render_params)
struct ParticleSystem * psys_orig_get(struct ParticleSystem *psys)
Definition: particle.c:741
struct ParticleSettings * BKE_particlesettings_add(struct Main *bmain, const char *name)
Definition: particle.c:4086
struct ParticleDrawData ParticleDrawData
bool psys_check_edited(struct ParticleSystem *psys)
Definition: particle.c:815
void copy_particle_key(struct ParticleKey *to, struct ParticleKey *from, int time)
Definition: particle.c:3763
short psys_get_current_num(struct Object *ob)
Definition: particle.c:660
void BKE_particlesettings_twist_curve_init(struct ParticleSettings *part)
Definition: particle.c:4123
struct ParticleThreadContext ParticleThreadContext
void psys_interpolate_uvs(const struct MTFace *tface, int quad, const float w[4], float uvco[2])
void psys_cache_paths(struct ParticleSimulationData *sim, float cfra, const bool use_render_params)
Definition: particle.c:3278
void psys_check_group_weights(struct ParticleSettings *part)
Definition: particle.c:845
void(* BKE_particle_batch_cache_dirty_tag_cb)(struct ParticleSystem *psys, int mode)
Definition: particle.c:5240
struct ParticleCollisionElement ParticleCollisionElement
void BKE_particle_system_eval_init(struct Depsgraph *depsgraph, struct Object *object)
void psys_interpolate_particle(short type, struct ParticleKey keys[4], float dt, struct ParticleKey *result, bool velocity)
Definition: particle.c:1212
void psys_thread_context_free(struct ParticleThreadContext *ctx)
void psys_reset(struct ParticleSystem *psys, int mode)
void BKE_particlesettings_clump_curve_init(struct ParticleSettings *part)
Definition: particle.c:4095
void psys_mat_hair_to_object(struct Object *ob, struct Mesh *mesh, short from, struct ParticleData *pa, float hairmat[4][4])
bool psys_in_edit_mode(struct Depsgraph *depsgraph, const struct ParticleSystem *psys)
float psys_get_timestep(struct ParticleSimulationData *sim)
Definition: particle.c:4459
void object_remove_particle_system(struct Main *bmain, struct Scene *scene, struct Object *ob)
void BKE_psys_collision_neartest_cb(void *userdata, int index, const struct BVHTreeRay *ray, struct BVHTreeRayHit *hit)
void psys_particle_on_emitter(struct ParticleSystemModifierData *psmd, int from, int index, int index_dmcache, float fuv[4], float foffset, float vec[3], float nor[3], float utan[3], float vtan[3], float orco[3])
Definition: particle.c:2290
void BKE_particle_system_blend_read_data(struct BlendDataReader *reader, struct ListBase *particles)
Definition: particle.c:5300
void BKE_particle_partdeflect_blend_read_lib(struct BlendLibReader *reader, struct ID *id, struct PartDeflect *pd)
Definition: particle.c:372
void psys_particle_on_dm(struct Mesh *mesh_final, int from, int index, int index_dmcache, const float fw[4], float foffset, float vec[3], float nor[3], float utan[3], float vtan[3], float orco[3])
Definition: particle.c:2095
float psys_get_dietime_from_cache(struct PointCache *cache, int index)
Definition: particle.c:1347
void BKE_particlesystem_reset_all(struct Object *object)
void psys_free_particles(struct ParticleSystem *psys)
Definition: particle.c:1011
void psys_unique_name(struct Object *object, struct ParticleSystem *psys, const char *defname)
unsigned int PSYS_FRAND_SEED_MULTIPLIER[PSYS_FRAND_COUNT]
Definition: particle.c:520
float psys_get_child_time(struct ParticleSystem *psys, struct ChildParticle *cpa, float cfra, float *birthtime, float *dietime)
Definition: particle.c:4463
void psys_free_children(struct ParticleSystem *psys)
Definition: particle.c:1001
void free_keyed_keys(struct ParticleSystem *psys)
Definition: particle.c:960
int psys_particle_dm_face_lookup(struct Mesh *mesh_final, struct Mesh *mesh_original, int findex, const float fw[4], struct LinkNode **poly_nodes)
Definition: particle.c:1913
int psys_uses_gravity(struct ParticleSimulationData *sim)
Definition: particle.c:907
void psys_enable_all(struct Object *ob)
Definition: particle.c:732
int psys_get_particle_state(struct ParticleSimulationData *sim, int p, struct ParticleKey *state, int always)
Definition: particle.c:4854
void psys_emitter_customdata_mask(struct ParticleSystem *psys, struct CustomData_MeshMasks *r_cddata_masks)
Definition: particle.c:2251
float psys_particle_value_from_verts(struct Mesh *mesh, short from, struct ParticleData *pa, float *values)
Definition: particle.c:2188
int count_particles_mod(struct ParticleSystem *psys, int totgr, int cur)
Definition: particle.c:573
struct ParticleSeam ParticleSeam
struct ParticleSystem * psys_get_current(struct Object *ob)
Definition: particle.c:645
void psys_sph_density(struct BVHTree *tree, struct SPHData *data, float co[3], float vars[2])
void psys_update_particle_tree(struct ParticleSystem *psys, float cfra)
void psys_check_boid_data(struct ParticleSystem *psys)
void psys_changed_type(struct Object *ob, struct ParticleSystem *psys)
struct ParticleTask ParticleTask
void init_particle(struct ParticleSimulationData *sim, struct ParticleData *pa)
unsigned int PSYS_FRAND_SEED_OFFSET[PSYS_FRAND_COUNT]
Definition: particle.c:519
void psys_make_temp_pointcache(struct Object *ob, struct ParticleSystem *psys)
void psys_sph_init(struct ParticleSimulationData *sim, struct SPHData *sphdata)
void BKE_particle_init_rng(void)
Definition: particle.c:523
float psys_get_current_display_percentage(struct ParticleSystem *psys, const bool use_render_params)
struct ParticleSystemModifierData * psys_get_modifier(struct Object *ob, struct ParticleSystem *psys)
Definition: particle.c:2201
void psys_free_path_cache(struct ParticleSystem *psys, struct PTCacheEdit *edit)
Definition: particle.c:986
void psys_find_parents(struct ParticleSimulationData *sim, const bool use_render_params)
Definition: particle.c:2645
void psys_free_pdd(struct ParticleSystem *psys)
Definition: particle.c:1041
void psys_find_group_weights(struct ParticleSettings *part)
Definition: particle.c:824
#define PARTICLE_COLLISION_MAX_COLLISIONS
Definition: BKE_particle.h:64
int count_particles(struct ParticleSystem *psys)
Definition: particle.c:555
float psys_get_child_size(struct ParticleSystem *psys, struct ChildParticle *cpa, float cfra, float *pa_time)
void psys_get_texture(struct ParticleSimulationData *sim, struct ParticleData *pa, struct ParticleTexture *ptex, int event, float cfra)
Definition: particle.c:4326
struct ModifierData * object_add_particle_system(struct Main *bmain, struct Scene *scene, struct Object *ob, const char *name)
Definition: particle.c:3975
struct SPHData SPHData
void free_hair(struct Object *ob, struct ParticleSystem *psys, int dynamics)
Definition: particle.c:922
void BKE_particle_batch_cache_dirty_tag(struct ParticleSystem *psys, int mode)
Definition: particle.c:5243
struct ParticleSimulationData ParticleSimulationData
void BKE_particle_partdeflect_blend_read_data(struct BlendDataReader *reader, struct PartDeflect *pd)
void BKE_particle_system_blend_write(struct BlendWriter *writer, struct ListBase *particles)
Definition: particle.c:5256
void psys_free(struct Object *ob, struct ParticleSystem *psys)
Definition: particle.c:1070
void BKE_particle_batch_cache_free(struct ParticleSystem *psys)
Definition: particle.c:5249
BLI_INLINE void psys_frand_vec(ParticleSystem *psys, unsigned int seed, float vec[3])
Definition: BKE_particle.h:278
void psys_apply_hair_lattice(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, struct ParticleSystem *psys)
Definition: particle.c:5201
void psys_interpolate_mcol(const struct MCol *mcol, int quad, const float w[4], struct MCol *mc)
struct ParticleCollision ParticleCollision
void BKE_particle_settings_eval_reset(struct Depsgraph *depsgraph, struct ParticleSettings *particle_settings)
void(* ParticleSystemIDFunc)(struct ParticleSystem *psys, struct ID **idpoin, void *userdata, int cb_flag)
Definition: BKE_particle.h:493
struct ParticleTexture ParticleTexture
struct ParticleCacheKey ParticleCacheKey
bool psys_check_enabled(struct Object *ob, struct ParticleSystem *psys, const bool use_render_params)
Definition: particle.c:789
void BKE_particlesystem_id_loop(struct ParticleSystem *psys, ParticleSystemIDFunc func, void *userdata)
void psys_copy_particles(struct ParticleSystem *psys_dst, struct ParticleSystem *psys_src)
Definition: particle.c:1149
void psys_interpolate_face(struct MVert *mvert, struct MFace *mface, struct MTFace *tface, float(*orcodata)[3], float w[4], float vec[3], float nor[3], float utan[3], float vtan[3], float orco[3])
Definition: particle.c:1670
struct ModifierData * object_copy_particle_system(struct Main *bmain, struct Scene *scene, struct Object *ob, const struct ParticleSystem *psys_orig)
void psys_cache_child_paths(struct ParticleSimulationData *sim, float cfra, const bool editupdate, const bool use_render_params)
Definition: particle.c:3165
BLI_INLINE float psys_frand(ParticleSystem *psys, unsigned int seed)
Definition: BKE_particle.h:266
@ BKE_PARTICLE_BATCH_DIRTY_ALL
Definition: BKE_particle.h:620
void psys_get_birth_coords(struct ParticleSimulationData *sim, struct ParticleData *pa, struct ParticleKey *state, float dtime, float cfra)
void(* BKE_particle_batch_cache_free_cb)(struct ParticleSystem *psys)
Definition: particle.c:5241
#define BLI_INLINE
struct Depsgraph Depsgraph
Definition: DEG_depsgraph.h:51
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
Definition: btQuadWord.h:119
static unsigned long seed
Definition: btSoftBody.h:39
StackEntry * from
double time
Scene scene
const Depsgraph * depsgraph
void * tree
#define rot(x, k)
uint nor
GPUBatch * quad
uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]
static ulong state[N]
Definition: DNA_ID.h:273
Definition: BKE_main.h:116
struct Object * current
Definition: BKE_particle.h:211
ParticleCollisionElement pce
Definition: BKE_particle.h:230
struct CollisionModifierData * md
Definition: BKE_particle.h:217
struct Object * skip[PARTICLE_COLLISION_MAX_COLLISIONS+1]
Definition: BKE_particle.h:213
struct Object * emitter
Definition: BKE_particle.h:214
struct Object * hit
Definition: BKE_particle.h:212
float v0[3]
Definition: BKE_particle.h:132
float dir[3]
Definition: BKE_particle.h:133
float v1[3]
Definition: BKE_particle.h:132
float tan[3]
Definition: BKE_particle.h:133
float nor[3]
Definition: BKE_particle.h:133
struct Depsgraph * depsgraph
Definition: BKE_particle.h:87
struct ParticleSystemModifierData * psmd
Definition: BKE_particle.h:91
struct Scene * scene
Definition: BKE_particle.h:88
struct ParticleSystem * psys
Definition: BKE_particle.h:90
struct Object * ob
Definition: BKE_particle.h:89
struct ListBase * colliders
Definition: BKE_particle.h:92
struct ParticleSystem * psys
struct PTCacheEdit * edit
ParticleData * particles
ParticleSettings * part
struct RNG * rng_path
Definition: BKE_particle.h:185
ParticleThreadContext * ctx
Definition: BKE_particle.h:184
struct RNG * rng
Definition: BKE_particle.h:185
struct ParticleData * tpars
Definition: BKE_particle.h:164
struct CurveMapping * roughcurve
Definition: BKE_particle.h:179
struct Mesh * mesh
Definition: BKE_particle.h:149
struct Material * ma
Definition: BKE_particle.h:150
struct CurveMapping * twistcurve
Definition: BKE_particle.h:180
struct CurveMapping * clumpcurve
Definition: BKE_particle.h:178
struct ParticleSeam * seams
Definition: BKE_particle.h:155
struct ParticleSimulationData sim
Definition: BKE_particle.h:148
struct KDTree_3d * tree
Definition: BKE_particle.h:153
Definition: rand.cc:48
BLI_Buffer new_springs
Definition: BKE_particle.h:115
struct EdgeHash * eh
Definition: BKE_particle.h:105
void(* force_cb)(void *sphdata_v, ParticleKey *state, float *force, float *impulse)
Definition: BKE_particle.h:118
ParticleData * pa
Definition: BKE_particle.h:103
ParticleSystem * psys[10]
Definition: BKE_particle.h:102
void(* density_cb)(void *rangedata_v, int index, const float co[3], float squared_dist)
Definition: BKE_particle.h:119
float * gravity
Definition: BKE_particle.h:106
float element_size
Definition: BKE_particle.h:111
float flow[3]
Definition: BKE_particle.h:112
float mass
Definition: BKE_particle.h:104
float hfac
Definition: BKE_particle.h:107