Blender V5.3
BKE_particle.h File Reference
#include <optional>
#include "BLI_compiler_attrs.hh"
#include "BLI_map.hh"
#include "BLI_ordered_edge.hh"
#include "BLI_vector.hh"
#include "BKE_lib_query.hh"
#include "DNA_particle_types.h"

Go to the source code of this file.

Classes

struct  blender::ParticleSimulationData
struct  blender::SPHData
struct  blender::ParticleTexture
struct  blender::ParticleSeam
struct  blender::ParticleCacheKey
struct  blender::ParticleThreadContext
struct  blender::ParticleTask
struct  blender::ParticleCollisionElement
struct  blender::ParticleCollision
struct  blender::ParticleDrawData

Namespaces

namespace  blender
 BMesh Iterators.

Macros

#define PARTICLE_COLLISION_MAX_COLLISIONS   10
#define PARTICLE_P
#define LOOP_PARTICLES   for (p = 0, pa = psys->particles; p < psys->totpart; p++, pa++)
#define LOOP_EXISTING_PARTICLES
#define LOOP_SHOWN_PARTICLES
#define LOOP_DYNAMIC_PARTICLES
#define PARTICLE_PSMD   ParticleSystemModifierData *psmd = sim->psmd ? sim->psmd : psys_get_modifier(sim->ob, sim->psys)
#define PARTICLE_DRAW_DATA_UPDATED   1
#define PSYS_FRAND_COUNT   1024
#define PSYS_RESET_ALL   1
#define PSYS_RESET_DEPSGRAPH   2
#define PSYS_RESET_CACHE_MISS   4
#define DMCACHE_NOTFOUND   -1
#define DMCACHE_ISCHILD   -2

Typedefs

typedef void(*) blender::ParticleSystemIDFunc(struct ParticleSystem *psys, struct ID **idpoin, void *userdata, LibraryForeachIDCallbackFlag cb_flag)

Enumerations

enum  { blender::BKE_PARTICLE_BATCH_DIRTY_ALL = 0 }

Functions

void blender::BKE_particle_init_rng ()
BLI_INLINE float blender::psys_frand (ParticleSystem *psys, unsigned int seed)
BLI_INLINE void blender::psys_frand_vec (ParticleSystem *psys, unsigned int seed, float vec[3])
int blender::count_particles (struct ParticleSystem *psys)
int blender::count_particles_mod (struct ParticleSystem *psys, int totgr, int cur)
bool blender::psys_in_edit_mode (struct Depsgraph *depsgraph, const struct ParticleSystem *psys)
bool blender::psys_render_simplify_params (struct ParticleSystem *psys, struct ChildParticle *cpa, float *params)
void blender::psys_interpolate_uvs (const struct MTFace *tface, int quad, const float w[4], float r_uv[2])
void blender::psys_interpolate_mcol (const struct MCol *mcol, int quad, const float w[4], struct MCol *mc)
struct ModifierData * blender::object_add_particle_system (struct Main *bmain, const struct Scene *scene, struct Object *ob, const char *name)
struct ModifierData * blender::object_copy_particle_system (struct Main *bmain, const struct Scene *scene, struct Object *ob, const struct ParticleSystem *psys_orig)
void blender::psys_apply_child_modifiers (struct ParticleThreadContext *ctx, ListBaseT< ModifierData > *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 blender::psys_interpolate_face (struct Mesh *mesh, const float(*vert_positions)[3], const float(*vert_normals)[3], const struct MFace *mface, struct MTFace *tface, const float(*orcodata)[3], float w[4], float vec[3], float nor[3], float utan[3], float vtan[3], float orco[3])
void blender::BKE_psys_collision_neartest_cb (void *userdata, int index, const struct BVHTreeRay *ray, struct BVHTreeRayHit *hit)
void blender::distribute_particles (struct ParticleSimulationData *sim, int from)
void blender::BKE_particle_partdeflect_blend_read_data (struct BlendDataReader *reader, struct PartDeflect *pd)
Reacting to System Events
int blender::psys_get_child_number (struct Scene *scene, struct ParticleSystem *psys, bool use_render_params)
int blender::psys_get_tot_child (struct Scene *scene, struct ParticleSystem *psys, bool use_render_params)
void blender::psys_reset (struct ParticleSystem *psys, int mode)
void blender::psys_unique_name (struct Object *object, struct ParticleSystem *psys, const char *defname) ATTR_NONNULL(1
float blender::psys_get_current_display_percentage (struct ParticleSystem *psys, bool use_render_params)
Getting Stuff
struct ParticleSystem * blender::psys_get_current (struct Object *ob)
short blender::psys_get_current_num (struct Object *ob)
void blender::psys_set_current_num (struct Object *ob, int index)
void blender::psys_sim_data_init (struct ParticleSimulationData *sim)
void blender::psys_sim_data_free (struct ParticleSimulationData *sim)
struct ParticleSystem * blender::psys_orig_get (struct ParticleSystem *psys)
struct ParticleSystem * blender::psys_eval_get (struct Depsgraph *depsgraph, struct Object *object, struct ParticleSystem *psys)
bool blender::psys_check_enabled (struct Object *ob, struct ParticleSystem *psys, bool use_render_params)
bool blender::psys_check_edited (struct ParticleSystem *psys)
void blender::psys_find_group_weights (struct ParticleSettings *part)
void blender::psys_check_group_weights (struct ParticleSettings *part)
int blender::psys_uses_gravity (struct ParticleSimulationData *sim)
void blender::psys_disable_all (struct Object *ob)
void blender::psys_enable_all (struct Object *ob)
System Core
void blender::BKE_particlesettings_fluid_default_settings (struct ParticleSettings *part)
void blender::psys_changed_type (struct Object *ob, struct ParticleSystem *psys)
void blender::psys_check_boid_data (struct ParticleSystem *psys)
void blender::particle_system_update (struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, struct ParticleSystem *psys, bool use_render_params)
void blender::BKE_particlesystem_id_loop (struct ParticleSystem *psys, ParticleSystemIDFunc func, void *userdata)
void blender::BKE_particlesystem_reset_all (struct Object *object)
Freeing Stuff
void blender::psys_free_path_cache (struct ParticleSystem *psys, struct PTCacheEdit *edit)
void blender::psys_free (struct Object *ob, struct ParticleSystem *psys)
void blender::psys_copy_particles (struct ParticleSystem *psys_dst, struct ParticleSystem *psys_src)
void blender::free_hair (struct Object *ob, struct ParticleSystem *psys, int dynamics)
void blender::free_keyed_keys (struct ParticleSystem *psys)
void blender::psys_free_particles (struct ParticleSystem *psys)
void blender::psys_free_children (struct ParticleSystem *psys)
void blender::psys_free_pdd (struct ParticleSystem *psys)
Particle Key Handling
void blender::copy_particle_key (struct ParticleKey *to, struct ParticleKey *from, int time)
void blender::psys_vec_rot_to_face (struct Mesh *mesh, struct ParticleData *pa, float vec[3])
void blender::psys_mat_hair_to_object (struct Object *ob, struct Mesh *mesh, short from, struct ParticleData *pa, float hairmat[4][4])
void blender::psys_mat_hair_to_global (struct Object *ob, struct Mesh *mesh, short from, struct ParticleData *pa, float hairmat[4][4])
void blender::psys_mat_hair_to_orco (struct Object *ob, struct Mesh *mesh, short from, struct ParticleData *pa, float hairmat[4][4])
void blender::psys_get_from_key (struct ParticleKey *key, float loc[3], float vel[3], float rot[4], float *time)
Particles on Emitter
void blender::psys_emitter_customdata_mask (struct ParticleSystem *psys, struct CustomData_MeshMasks *r_cddata_masks)
void blender::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])
Particles on a DM
struct ParticleSystemModifierData * blender::psys_get_modifier (struct Object *ob, struct ParticleSystem *psys)
float blender::psys_particle_value_from_verts (struct Mesh *mesh, short from, struct ParticleData *pa, float *values)
void blender::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])
int blender::psys_particle_dm_face_lookup (struct Mesh *mesh_final, struct Mesh *mesh_original, int findex_orig, const float fw[4], struct LinkNode **poly_nodes)
ParticleSettings Handling
void blender::object_remove_particle_system (struct Main *bmain, struct Scene *scene, struct Object *ob, struct ParticleSystem *psys)
struct ParticleSettings * blender::BKE_particlesettings_add (struct Main *bmain, const char *name)
void blender::BKE_particlesettings_clump_curve_init (struct ParticleSettings *part)
void blender::BKE_particlesettings_rough_curve_init (struct ParticleSettings *part)
void blender::BKE_particlesettings_twist_curve_init (struct ParticleSettings *part)
Path Cache
void blender::psys_find_parents (struct ParticleSimulationData *sim, bool use_render_params)
void void blender::psys_cache_paths (struct ParticleSimulationData *sim, float cfra, bool use_render_params)
void blender::psys_cache_edit_paths (struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, struct PTCacheEdit *edit, float cfra, bool use_render_params)
void blender::psys_cache_child_paths (struct ParticleSimulationData *sim, float cfra, bool editupdate, bool use_render_params)
bool blender::do_guides (struct Depsgraph *depsgraph, struct ParticleSettings *part, ListBaseT< EffectorCache > *effectors, ParticleKey *state, int index, float time)
void blender::precalc_guides (struct ParticleSimulationData *sim, ListBaseT< EffectorCache > *effectors)
float * blender::psys_cache_vgroup (struct Mesh *mesh, struct ParticleSystem *psys, int vgroup)
SPH Fluid Physics

In theory, there could be unlimited implementation of SPH simulators

This code uses in some parts adapted algorithms from the pseudo code as outlined in the Research paper:

Titled: Particle-based Viscoelastic Fluid Simulation. Authors: Simon Clavet, Philippe Beaudoin and Pierre Poulin Website: http://www.iro.umontreal.ca/labs/infographie/papers/Clavet-2005-PVFS/

Presented at SIGGRAPH, (2005)

void blender::psys_sph_finalize (struct SPHData *sphdata)
void blender::psys_sph_density (struct BVHTree *tree, struct SPHData *data, float co[3], float vars[2])
Distribution
void blender::psys_thread_context_init (struct ParticleThreadContext *ctx, struct ParticleSimulationData *sim)
void blender::psys_thread_context_free (struct ParticleThreadContext *ctx)
Vector< ParticleTask > blender::psys_tasks_create (struct ParticleThreadContext *ctx, int startpart, int endpart)
void blender::psys_tasks_free (Vector< ParticleTask > &tasks)
void blender::psys_get_birth_coords (struct ParticleSimulationData *sim, struct ParticleData *pa, struct ParticleKey *state, float dtime, float cfra)
void blender::init_particle (struct ParticleSimulationData *sim, struct ParticleData *pa)
void blender::psys_calc_dmcache (struct Object *ob, struct Mesh *mesh_final, struct Mesh *mesh_original, struct ParticleSystem *psys)
void blender::reset_particle (struct ParticleSimulationData *sim, struct ParticleData *pa, float dtime, float cfra)
Particle Targets
struct ParticleSystem * blender::psys_get_target_system (struct Object *ob, struct ParticleTarget *pt)
Keyed Particles
void blender::psys_count_keyed_targets (struct ParticleSimulationData *sim)
Effectors
void blender::psys_update_particle_tree (struct ParticleSystem *psys, float cfra)
Point Cache
void blender::psys_make_temp_pointcache (struct Object *ob, struct ParticleSystem *psys)
void blender::psys_get_pointcache_start_end (struct Scene *scene, ParticleSystem *psys, int *sfra, int *efra)
Interpolation
void blender::psys_interpolate_particle (short type, struct ParticleKey keys[4], float dt, struct ParticleKey *result, bool velocity)
float blender::psys_get_dietime_from_cache (struct PointCache *cache, int index)
Textures
void blender::psys_get_texture (struct ParticleSimulationData *sim, struct ParticleData *pa, struct ParticleTexture *ptex, int event, float cfra)
Depsgraph evaluation
void blender::BKE_particle_settings_eval_reset (struct Depsgraph *depsgraph, struct ParticleSettings *particle_settings)
void blender::BKE_particle_system_eval_init (struct Depsgraph *depsgraph, struct Object *object)

Variables

unsigned int blender::PSYS_FRAND_SEED_OFFSET [PSYS_FRAND_COUNT]
unsigned int blender::PSYS_FRAND_SEED_MULTIPLIER [PSYS_FRAND_COUNT]
float blender::PSYS_FRAND_BASE [PSYS_FRAND_COUNT]

Particle State

void(*) blender::BKE_particle_batch_cache_dirty_tag_cb (struct ParticleSystem *psys, int mode) = nullptr
void(*) blender::BKE_particle_batch_cache_free_cb (struct ParticleSystem *psys) = nullptr
float blender::psys_get_timestep (struct ParticleSimulationData *sim)
float blender::psys_get_child_time (struct ParticleSystem *psys, struct ChildParticle *cpa, float cfra, float *birthtime, float *dietime)
float blender::psys_get_child_size (struct ParticleSystem *psys, struct ChildParticle *cpa, float cfra, float *pa_time)
void blender::psys_get_particle_on_path (struct ParticleSimulationData *sim, int pa_num, struct ParticleKey *state, bool vel)
bool blender::psys_get_particle_state (struct ParticleSimulationData *sim, int p, struct ParticleKey *state, bool always)
void blender::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])
void blender::psys_get_dupli_path_transform (struct ParticleSimulationData *sim, struct ParticleData *pa, struct ChildParticle *cpa, struct ParticleCacheKey *cache, float mat[4][4], float *scale)
void blender::psys_apply_hair_lattice (struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, struct ParticleSystem *psys)
void blender::BKE_particle_co_hair (const ParticleSystem *particlesystem, const Object *object, int particle_no, int step, float n_co[3])
void blender::BKE_particle_uv_on_emitter (ParticleSystem *particlesystem, ReportList *reports, ParticleSystemModifierData *modifier, ParticleData *particle, int particle_no, int uv_no, float r_uv[2])
void blender::BKE_particle_mcol_on_emitter (ParticleSystem *particlesystem, ReportList *reports, ParticleSystemModifierData *modifier, ParticleData *particle, int particle_no, int vcol_no, float r_mcol[3])
void blender::BKE_particle_batch_cache_dirty_tag (struct ParticleSystem *psys, int mode)
void blender::BKE_particle_batch_cache_free (struct ParticleSystem *psys)
void blender::BKE_particle_system_blend_write (struct BlendWriter *writer, ListBaseT< ParticleSystem > *particles)
void blender::BKE_particle_system_blend_read_data (struct BlendDataReader *reader, ListBaseT< ParticleSystem > *particles)
void blender::BKE_particle_system_blend_read_after_liblink (struct BlendLibReader *reader, struct Object *ob, struct ID *id, ListBaseT< ParticleSystem > *particles)

Macro Definition Documentation

◆ DMCACHE_ISCHILD

◆ DMCACHE_NOTFOUND

◆ LOOP_DYNAMIC_PARTICLES

#define LOOP_DYNAMIC_PARTICLES
Value:
for (p = 0; p < psys->totpart; p++) \
if ((pa = psys->particles + p)->state.time > 0.0f)

Definition at line 62 of file BKE_particle.h.

Referenced by blender::dynamics_step().

◆ LOOP_EXISTING_PARTICLES

#define LOOP_EXISTING_PARTICLES
Value:
for (p = 0, pa = psys->particles; p < psys->totpart; p++, pa++) \
if (!(pa->flag & PARS_UNEXIST))

Definition at line 56 of file BKE_particle.h.

Referenced by blender::dynamics_step(), and blender::particle_system_update().

◆ LOOP_PARTICLES

◆ LOOP_SHOWN_PARTICLES

#define LOOP_SHOWN_PARTICLES
Value:
for (p = 0, pa = psys->particles; p < psys->totpart; p++, pa++) \
if (!(pa->flag & (PARS_UNEXIST | PARS_NO_DISP)))

Definition at line 59 of file BKE_particle.h.

Referenced by blender::count_particles(), blender::count_particles_mod(), blender::dynamics_step(), blender::psys_update_particle_bvhtree(), and blender::psys_update_particle_tree().

◆ PARTICLE_COLLISION_MAX_COLLISIONS

#define PARTICLE_COLLISION_MAX_COLLISIONS   10

Definition at line 50 of file BKE_particle.h.

Referenced by blender::collision_check().

◆ PARTICLE_DRAW_DATA_UPDATED

#define PARTICLE_DRAW_DATA_UPDATED   1

Definition at line 247 of file BKE_particle.h.

Referenced by blender::particle_system_update().

◆ PARTICLE_P

◆ PARTICLE_PSMD

#define PARTICLE_PSMD   ParticleSystemModifierData *psmd = sim->psmd ? sim->psmd : psys_get_modifier(sim->ob, sim->psys)

◆ PSYS_FRAND_COUNT

#define PSYS_FRAND_COUNT   1024

◆ PSYS_RESET_ALL

◆ PSYS_RESET_CACHE_MISS

#define PSYS_RESET_CACHE_MISS   4

Definition at line 697 of file BKE_particle.h.

Referenced by blender::psys_reset(), and blender::system_step().

◆ PSYS_RESET_DEPSGRAPH

#define PSYS_RESET_DEPSGRAPH   2