Blender V5.3
particle.cc File Reference
#include "BKE_report.hh"
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <optional>
#include "MEM_guardedalloc.h"
#include "DNA_cloth_types.h"
#include "DNA_collection_types.h"
#include "DNA_curve_types.h"
#include "DNA_dynamicpaint_types.h"
#include "DNA_fluid_types.h"
#include "DNA_key_types.h"
#include "DNA_material_types.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_object_force_types.h"
#include "DNA_particle_types.h"
#include "DNA_scene_types.h"
#include "DNA_texture_types.h"
#include "BLI_kdopbvh.hh"
#include "BLI_kdtree.hh"
#include "BLI_linklist.hh"
#include "BLI_listbase.hh"
#include "BLI_math_base_safe.hh"
#include "BLI_math_geom_c.hh"
#include "BLI_math_matrix_c.hh"
#include "BLI_math_rotation_c.hh"
#include "BLI_math_vector_c.hh"
#include "BLI_rand_c.hh"
#include "BLI_string_utf8.hh"
#include "BLI_task_c.hh"
#include "BLI_threads.hh"
#include "BLI_utildefines.hh"
#include "BLT_translation.hh"
#include "BKE_anim_path.h"
#include "BKE_boids.h"
#include "BKE_cloth.hh"
#include "BKE_collection.hh"
#include "BKE_colortools.hh"
#include "BKE_customdata.hh"
#include "BKE_deform.hh"
#include "BKE_displist.h"
#include "BKE_effect.h"
#include "BKE_idtype.hh"
#include "BKE_key.hh"
#include "BKE_lattice.hh"
#include "BKE_layer.hh"
#include "BKE_lib_id.hh"
#include "BKE_lib_query.hh"
#include "BKE_material.hh"
#include "BKE_mesh.hh"
#include "BKE_mesh_legacy_convert.hh"
#include "BKE_modifier.hh"
#include "BKE_object.hh"
#include "BKE_particle.h"
#include "BKE_pointcache.h"
#include "BKE_scene.hh"
#include "BKE_texture.h"
#include "DEG_depsgraph.hh"
#include "DEG_depsgraph_build.hh"
#include "DEG_depsgraph_query.hh"
#include "RE_texture.h"
#include "BLO_read_write.hh"
#include "particle_private.h"

Go to the source code of this file.

Classes

struct  blender::ParticleInterpolationData
struct  blender::CacheEditrPathsIterData

Namespaces

namespace  blender
 BMesh Iterators.

Macros

#define DNA_DEPRECATED_ALLOW
#define PATH_CACHE_BUF_SIZE   1024

Functions

static void blender::particle_settings_init (ID *id)
static void blender::particle_settings_copy_data (Main *, std::optional< Library * >, ID *id_dst, const ID *id_src, const int)
static void blender::particle_settings_free_data (ID *id)
static void blender::particle_settings_foreach_id (ID *id, LibraryForeachIDData *data)
static void blender::write_boid_state (BlendWriter *writer, BoidState *state)
static void blender::particle_settings_blend_write (BlendWriter *writer, ID *id, const void *id_address)
void blender::BKE_particle_partdeflect_blend_read_data (struct BlendDataReader *reader, struct PartDeflect *pd)
static size_t blender::boid_rule_struct_size (const eBoidRuleType type)
static void blender::particle_settings_blend_read_data (BlendDataReader *reader, ID *id)
static void blender::particle_settings_blend_read_after_liblink (BlendLibReader *, ID *id)
void blender::BKE_particle_init_rng ()
int blender::count_particles (struct ParticleSystem *psys)
int blender::count_particles_mod (struct ParticleSystem *psys, int totgr, int cur)
static ParticleCacheKey * blender::pcache_key_segment_endpoint_safe (ParticleCacheKey *key)
static ParticleCacheKey ** blender::psys_alloc_path_cache_buffers (ListBaseT< LinkData > *bufs, int tot, int totkeys)
static void blender::psys_free_path_cache_buffers (ParticleCacheKey **cache, ListBaseT< LinkData > *bufs)
Freeing Stuff
static void blender::fluid_free_settings (SPHFluidSettings *fluid)
void blender::free_hair (struct Object *ob, struct ParticleSystem *psys, int dynamics)
void blender::free_keyed_keys (struct ParticleSystem *psys)
static void blender::free_child_path_cache (ParticleSystem *psys)
void blender::psys_free_path_cache (struct ParticleSystem *psys, struct PTCacheEdit *edit)
void blender::psys_free_children (struct ParticleSystem *psys)
void blender::psys_free_particles (struct ParticleSystem *psys)
void blender::psys_free_pdd (struct ParticleSystem *psys)
void blender::psys_free (struct Object *ob, struct ParticleSystem *psys)
void blender::psys_copy_particles (struct ParticleSystem *psys_dst, struct ParticleSystem *psys_src)
Particle State
static void blender::get_child_modifier_parameters (ParticleSettings *part, ParticleThreadContext *ctx, ChildParticle *cpa, short cpa_from, int cpa_num, float *cpa_fuv, float *orco, ParticleTexture *ptex)
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])
static int blender::tessfaceidx_on_emitter (ParticleSystem *particlesystem, ParticleSystemModifierData *modifier, ParticleData *particle, int particle_no, float(**r_fuv)[4])
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)
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)
void blender::psys_disable_all (struct Object *ob)
void blender::psys_enable_all (struct Object *ob)
struct ParticleSystem * blender::psys_orig_get (struct ParticleSystem *psys)
struct ParticleSystem * blender::psys_eval_get (struct Depsgraph *depsgraph, struct Object *object, struct ParticleSystem *psys)
static PTCacheEdit * blender::psys_orig_edit_get (ParticleSystem *psys)
bool blender::psys_in_edit_mode (Depsgraph *depsgraph, const 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)
Interpolation
static float blender::interpolate_particle_value (float v1, float v2, float v3, float v4, const float w[4], int four)
void blender::psys_interpolate_particle (short type, struct ParticleKey keys[4], float dt, struct ParticleKey *result, bool velocity)
static void blender::get_pointcache_keys_for_time (Object *, PointCache *cache, PTCacheMem **cur, int index, float t, ParticleKey *key1, ParticleKey *key2)
static int blender::get_pointcache_times_for_particle (PointCache *cache, int index, float *r_start, float *r_dietime)
float blender::psys_get_dietime_from_cache (struct PointCache *cache, int index)
static void blender::init_particle_interpolation (Object *ob, ParticleSystem *psys, ParticleData *pa, ParticleInterpolationData *pind)
static void blender::edit_to_particle (ParticleKey *key, PTCacheEditKey *ekey)
static void blender::hair_to_particle (ParticleKey *key, HairKey *hkey)
static void blender::mvert_to_particle (ParticleKey *key, float3 *position, HairKey *hkey)
static void blender::do_particle_interpolation (ParticleSystem *psys, int p, ParticleData *pa, float t, ParticleInterpolationData *pind, ParticleKey *result)
static void blender::interpolate_pathcache (ParticleCacheKey *first, float t, ParticleCacheKey *result)
Particles on a DM
void blender::psys_interpolate_face (Mesh *mesh, const float(*vert_positions)[3], const float(*vert_normals)[3], const MFace *mface, 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::psys_interpolate_uvs (const MTFace *tface, int quad, const float w[4], float r_uv[2])
void blender::psys_interpolate_mcol (const MCol *mcol, int quad, const float w[4], MCol *mc)
static float blender::psys_interpolate_value_from_verts (Mesh *mesh, short from, int index, const float fw[4], const float *values)
static void blender::psys_w_to_origspace (const float w[4], float uv[2])
static void blender::psys_origspace_to_w (OrigSpaceFace *osface, int quad, const float w[4], float neww[4])
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)
static int blender::psys_map_index_on_dm (Mesh *mesh, int from, int index, int index_dmcache, const float fw[4], float, int *mapindex, float mapfw[4])
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])
float blender::psys_particle_value_from_verts (struct Mesh *mesh, short from, struct ParticleData *pa, float *values)
struct ParticleSystemModifierData * blender::psys_get_modifier (struct Object *ob, struct ParticleSystem *psys)
Particles on a Shape
static void blender::psys_particle_on_shape (int, int, float *, float vec[3], float nor[3], float utan[3], float vtan[3], float orco[3])
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])
Path Cache
void blender::precalc_guides (struct ParticleSimulationData *sim, ListBaseT< EffectorCache > *effectors)
bool blender::do_guides (struct Depsgraph *depsgraph, struct ParticleSettings *part, ListBaseT< EffectorCache > *effectors, ParticleKey *state, int index, float time)
static void blender::do_path_effectors (ParticleSimulationData *sim, int i, ParticleCacheKey *ca, int k, int steps, float *, float effector, float, float, float *length, float *vec)
static void blender::offset_child (ChildParticle *cpa, ParticleKey *par, float *par_rot, ParticleKey *child, float flat, float radius)
float * blender::psys_cache_vgroup (struct Mesh *mesh, struct ParticleSystem *psys, int vgroup)
void blender::psys_find_parents (struct ParticleSimulationData *sim, bool use_render_params)
static bool blender::psys_thread_context_init_path (ParticleThreadContext *ctx, ParticleSimulationData *sim, Scene *scene, float cfra, const bool editupdate, const bool use_render_params)
static void blender::psys_task_init_path (ParticleTask *task, ParticleSimulationData *sim)
static void blender::psys_thread_create_path (ParticleTask *task, ChildParticle *cpa, ParticleCacheKey *child_keys, int i)
static void blender::exec_child_path_cache (TaskPool *__restrict, void *taskdata)
void blender::psys_cache_child_paths (struct ParticleSimulationData *sim, float cfra, bool editupdate, bool use_render_params)
static void blender::cache_key_incremental_rotation (ParticleCacheKey *key0, ParticleCacheKey *key1, ParticleCacheKey *key2, float *prev_tangent, int i)
void void blender::psys_cache_paths (struct ParticleSimulationData *sim, float cfra, bool use_render_params)
static void blender::psys_cache_edit_paths_iter (void *__restrict iter_data_v, const int iter, const TaskParallelTLS *__restrict)
void blender::psys_cache_edit_paths (struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, struct PTCacheEdit *edit, float cfra, bool use_render_params)
Particle Key Handling
void blender::copy_particle_key (struct ParticleKey *to, struct ParticleKey *from, int time)
void blender::psys_get_from_key (struct ParticleKey *key, float loc[3], float vel[3], float rot[4], float *time)
static void blender::triatomat (float *v1, float *v2, float *v3, const float(*uv)[2], float mat[4][4])
static void blender::psys_face_mat (Object *ob, Mesh *mesh, ParticleData *pa, float mat[4][4], int orco)
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_orco (struct Object *ob, struct Mesh *mesh, short from, struct ParticleData *pa, float hairmat[4][4])
void blender::psys_vec_rot_to_face (struct Mesh *mesh, struct ParticleData *pa, float vec[3])
void blender::psys_mat_hair_to_global (struct Object *ob, struct Mesh *mesh, short from, struct ParticleData *pa, float hairmat[4][4])
ParticleSettings Handling
static ModifierData * blender::object_add_or_copy_particle_system (Main *bmain, const Scene *scene, Object *ob, const char *name, const ParticleSystem *psys_orig)
ModifierData * blender::object_add_particle_system (Main *bmain, const Scene *scene, Object *ob, const char *name)
ModifierData * blender::object_copy_particle_system (Main *bmain, const Scene *scene, Object *ob, const ParticleSystem *psys_orig)
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)

Textures

#define SET_PARTICLE_TEXTURE(type, pvalue, texfac)
#define CLAMP_PARTICLE_TEXTURE_POS(type, pvalue)
#define CLAMP_WARP_PARTICLE_TEXTURE_POS(type, pvalue)
#define CLAMP_PARTICLE_TEXTURE_POSNEG(type, pvalue)
static void blender::get_cpa_texture (Mesh *mesh, ParticleSystem *psys, ParticleSettings *part, ParticleData *par, int child_index, int face_index, const float fw[4], float *orco, ParticleTexture *ptex, int event, float cfra)
static int blender::get_particle_uv (Mesh *mesh, ParticleData *pa, int index, const float fuv[4], const char *name, float *texco, bool from_vert)
void blender::psys_get_texture (struct ParticleSimulationData *sim, struct ParticleData *pa, struct ParticleTexture *ptex, int event, float cfra)

Macro Definition Documentation

◆ CLAMP_PARTICLE_TEXTURE_POS

#define CLAMP_PARTICLE_TEXTURE_POS ( type,
pvalue )
Value:
if (event & type) { \
CLAMP(pvalue, 0.0f, 1.0f); \
} \
(void)0

Definition at line 4264 of file particle.cc.

Referenced by blender::get_cpa_texture(), and blender::psys_get_texture().

◆ CLAMP_PARTICLE_TEXTURE_POSNEG

#define CLAMP_PARTICLE_TEXTURE_POSNEG ( type,
pvalue )
Value:
if (event & type) { \
CLAMP(pvalue, -1.0f, 1.0f); \
} \
(void)0

Definition at line 4279 of file particle.cc.

Referenced by blender::psys_get_texture().

◆ CLAMP_WARP_PARTICLE_TEXTURE_POS

#define CLAMP_WARP_PARTICLE_TEXTURE_POS ( type,
pvalue )
Value:
if (event & type) { \
if (pvalue < 0.0f) { \
pvalue = 1.0f + pvalue; \
} \
CLAMP(pvalue, 0.0f, 1.0f); \
} \
(void)0

Definition at line 4270 of file particle.cc.

Referenced by blender::get_cpa_texture(), and blender::psys_get_texture().

◆ DNA_DEPRECATED_ALLOW

#define DNA_DEPRECATED_ALLOW

Definition at line 11 of file particle.cc.

◆ PATH_CACHE_BUF_SIZE

#define PATH_CACHE_BUF_SIZE   1024

Definition at line 519 of file particle.cc.

Referenced by blender::psys_alloc_path_cache_buffers().

◆ SET_PARTICLE_TEXTURE

#define SET_PARTICLE_TEXTURE ( type,
pvalue,
texfac )
Value:
if ((event & mtex->mapto) & type) { \
pvalue = texture_value_blend(def, pvalue, value, texfac, blend); \
} \
(void)0

Definition at line 4258 of file particle.cc.

Referenced by blender::get_cpa_texture(), and blender::psys_get_texture().