67 weights->
group = collection;
112 if (pd_src ==
nullptr) {
132 uint cfra =
uint(ctime >= 0 ? ctime : -ctime);
139 if (eff->
ob->
runtime->curve_cache ==
nullptr ||
140 eff->
ob->
runtime->curve_cache->anim_path_accum_length ==
nullptr)
145 if (eff->
ob->
runtime->curve_cache->anim_path_accum_length) {
159 else if (eff->
psys) {
172 relation->
psys = psys;
185 if (*effectors ==
nullptr) {
214 for (; base; base = base->
next) {
215 if (!(base->
flag & base_flag)) {
229 if (part->pd && part->pd->forcefield) {
232 if (part->pd2 && part->pd2->forcefield) {
295 return pd->
f_damp != 0.0f;
327 if (relation->psys) {
337 PartDeflect *pd = (relation->pd == relation->psys->part->pd) ? part->pd : part->pd2;
371 if (eff->guide_data) {
387 point->loc =
state->co;
388 point->vel =
state->vel;
391 point->charge = 0.0f;
394 point->charge += part->pd->f_strength;
398 point->charge += part->pd2->f_strength;
401 point->vel_to_sec = 1.0f;
407 point->ave =
state->ave;
408 point->rot =
state->rot;
411 point->ave = point->rot =
nullptr;
414 point->psys = sim->
psys;
421 point->index = index;
424 point->vel_to_sec =
float(scene->r.frs_sec);
425 point->vel_to_frame = 1.0f;
429 point->ave = point->rot =
nullptr;
430 point->psys =
nullptr;
436 point->index = index;
439 point->vel_to_sec =
float(scene->r.frs_sec);
440 point->vel_to_frame = 1.0f;
444 point->ave = point->rot =
nullptr;
446 point->psys =
nullptr;
493 if (
col->ob == eff->
ob) {
500 hit.dist =
len + FLT_EPSILON;
515 visibility *= std::clamp(1.0f -
absorption, 0.0f, 1.0f);
517 if (visibility <= 0.0f) {
540 sign = (
float(random) > 64.0f) ? 1.0f : -1.0f;
542 ret = sign * (
float(random) / force) * strength / 128.0f;
551 float fac,
int usemin,
float mindist,
int usemax,
float maxdist,
float power)
554 if (usemax && fac > maxdist) {
558 if (usemin && fac < mindist) {
566 return pow(
double(1.0f + fac - mindist),
double(-
power));
614 if (falloff == 0.0f) {
624 if (falloff == 0.0f) {
641 float surface_nor[3],
642 float surface_vel[3])
652 if (nearest.index != -1) {
696 eff->
surmd, vec, efd->
loc, efd->
nor, real_velocity ? efd->
vel :
nullptr);
703 if (mesh_eval !=
nullptr) {
719 else if (eff->
psys) {
724 if (eff->
psys == point->psys && *efd->
index == point->index) {
735 state.time = cfra - 1.0f;
748 efd->
nor[1] = efd->
nor[2] = 0.0f;
765 float temp[3], translate[3];
766 sub_v3_v3v3(temp, point->loc, ob->object_to_world().location());
771 add_v3_v3v3(efd->
loc, ob->object_to_world().location(), translate);
819 *tot = mesh_eval !=
nullptr ? mesh_eval->
verts_num : 1;
822 *p = point->index % *tot;
826 else if (eff->
psys) {
850 *step = (totpart > amount) ?
int(
ceil(
float(totpart) /
float(amount))) : 1;
863 float tex_co[3], strength, force[3];
877 mul_m4_v3(eff->
ob->world_to_object().ptr(), tex_co);
889 eff->
pd->
tex, tex_co,
nullptr,
nullptr, 0, result, 0,
nullptr,
true,
false);
892 force[0] = (0.5f - result->trgba[0]) * strength;
893 force[1] = (0.5f - result->trgba[1]) * strength;
894 force[2] = (0.5f - result->trgba[2]) * strength;
896 else if (nabla != 0) {
900 multitex_ext(eff->
pd->
tex, tex_co,
nullptr,
nullptr, 0, result + 1, 0,
nullptr,
true,
false);
904 multitex_ext(eff->
pd->
tex, tex_co,
nullptr,
nullptr, 0, result + 2, 0,
nullptr,
true,
false);
908 multitex_ext(eff->
pd->
tex, tex_co,
nullptr,
nullptr, 0, result + 3, 0,
nullptr,
true,
false);
913 for (
int i = 0; i < 4; i++) {
914 result[i].tin = (1.0f / 3.0f) *
915 (result[i].trgba[0] + result[i].trgba[1] + result[i].trgba[2]);
918 force[0] = (result[0].tin - result[1].tin) * strength;
919 force[1] = (result[0].tin - result[2].tin) * strength;
920 force[2] = (result[0].tin - result[3].tin) * strength;
923 float dbdy, dgdz, drdz, dbdx, dgdx, drdy;
925 dbdy = result[2].trgba[2] - result[0].trgba[2];
926 dgdz = result[3].trgba[1] - result[0].trgba[1];
927 drdz = result[3].trgba[0] - result[0].trgba[0];
928 dbdx = result[1].trgba[2] - result[0].trgba[2];
929 dgdx = result[1].trgba[1] - result[0].trgba[1];
930 drdy = result[2].trgba[0] - result[0].trgba[0];
932 force[0] = (dbdy - dgdz) * strength;
933 force[1] = (drdz - dbdx) * strength;
934 force[2] = (dgdx - drdy) * strength;
957 float force[3] = {0, 0, 0};
962 float noise_factor = pd->
f_noise;
963 float flow_falloff = efd->
falloff;
965 if (noise_factor > 0.0f) {
966 strength +=
wind_func(rng, noise_factor);
1037 fac = -fac * (1.0f - fac) / efd->
distance;
1040 fac = ((fac > 2.0f) ? 2.0f : fac);
1055 pd->
f_size, temp[0], temp[1], temp[2], 2,
false, 2);
1057 pd->
f_size, temp[1], temp[2], temp[0], 2,
false, 2);
1059 pd->
f_size, temp[2], temp[0], temp[1], 2,
false, 2);
1066 strength = std::min(strength, 2.0f);
1067 damp = std::min(damp, 2.0f);
1078 float influence = strength * efd->
falloff;
1080 influence *= density;
1083 flow_falloff = influence;
1091 madd_v3_v3fl(total_force, force, 1.0f / point->vel_to_sec);
1099 float xvec[3] = {1.0f, 0.0f, 0.0f};
1103 if (pd->
f_flow != 0.0f) {
1148 int p = 0, tot = 1, step = 1;
1159 for (; p < tot; p += step) {
1167 float out_force[3] = {0, 0, 0};
1182 madd_v3_v3fl(force, out_force, 1.0f - eff->pd->f_wind_factor);
1183 madd_v3_v3fl(wind_force, out_force, eff->pd->f_wind_factor);
1210#define rot(x, k) (((x) << (k)) | ((x) >> (32 - (k))))
1214 a =
b = c = 0xdeadbeef + (2 << 2) + 13;
1311 const char *category,
1350 elem->
str[0] =
'\0';
bool BKE_where_on_path(const struct Object *ob, float ctime, float r_vec[4], float r_dir[3], float r_quat[4], float *r_radius, float *r_weight)
Base * BKE_collection_or_layer_objects(const Scene *scene, ViewLayer *view_layer, Collection *collection)
void BKE_collider_cache_free(struct ListBase **colliders)
struct ListBase * BKE_collider_cache_create(struct Depsgraph *depsgraph, struct Object *self, struct Collection *collection)
display list (or rather multi purpose list) stuff.
void BKE_displist_make_curveTypes(struct Depsgraph *depsgraph, const struct Scene *scene, struct Object *ob, bool for_render)
#define PE_VELOCITY_TO_IMPULSE
#define PE_USE_NORMAL_DATA
float BKE_fluid_get_velocity_at(struct Object *ob, float position[3], float velocity[3])
ModifierData * BKE_modifiers_findby_type(const Object *ob, ModifierType type)
General operations, lookup, etc. for blender objects.
Mesh * BKE_object_get_evaluated_mesh(const Object *object_eval)
bool psys_check_enabled(struct Object *ob, struct ParticleSystem *psys, bool use_render_params)
float psys_get_timestep(struct ParticleSimulationData *sim)
void psys_update_particle_tree(struct ParticleSystem *psys, float cfra)
bool psys_get_particle_state(struct ParticleSimulationData *sim, int p, struct ParticleKey *state, bool always)
unsigned int BLI_ghashutil_uinthash(unsigned int key)
void BLI_ghashIterator_step(GHashIterator *ghi)
void BLI_ghash_clear(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp)
BLI_INLINE void * BLI_ghashIterator_getValue(GHashIterator *ghi) ATTR_WARN_UNUSED_RESULT
unsigned int BLI_ghashutil_strhash_p(const void *ptr)
GHash * BLI_ghash_new(GHashHashFP hashfp, GHashCmpFP cmpfp, const char *info) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
bool BLI_ghash_remove(GHash *gh, const void *key, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp)
void * BLI_ghash_lookup(const GHash *gh, const void *key) ATTR_WARN_UNUSED_RESULT
void BLI_ghash_insert(GHash *gh, void *key, void *val)
void BLI_ghash_free(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp)
void BLI_ghashIterator_init(GHashIterator *ghi, GHash *gh)
BLI_INLINE bool BLI_ghashIterator_done(const GHashIterator *ghi) ATTR_WARN_UNUSED_RESULT
#define BVH_RAYCAST_DEFAULT
int BLI_bvhtree_ray_cast_ex(const BVHTree *tree, const float co[3], const float dir[3], float radius, BVHTreeRayHit *hit, BVHTree_RayCastCallback callback, void *userdata, int flag)
int BLI_bvhtree_find_nearest(const BVHTree *tree, const float co[3], BVHTreeNearest *nearest, BVHTree_NearestPointCallback callback, void *userdata)
void * BLI_findstring(const struct ListBase *listbase, const char *id, int offset) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
#define LISTBASE_FOREACH(type, var, list)
void void BLI_freelistN(struct ListBase *listbase) ATTR_NONNULL(1)
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
MINLINE float safe_acosf(float a)
void mul_m4_v3(const float M[4][4], float r[3])
void mul_mat3_m4_v3(const float mat[4][4], float r[3])
void mul_qt_v3(const float q[4], float r[3])
MINLINE void madd_v3_v3fl(float r[3], const float a[3], float f)
MINLINE void sub_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE void mul_v3_fl(float r[3], float f)
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE void negate_v3_v3(float r[3], const float a[3])
void project_v3_v3v3(float out[3], const float p[3], const float v_proj[3])
MINLINE float dot_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
MINLINE void add_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE void cross_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE float normalize_v3_v3(float r[3], const float a[3])
MINLINE void madd_v3_v3v3fl(float r[3], const float a[3], const float b[3], float f)
MINLINE void zero_v3(float r[3])
MINLINE void add_v3_v3(float r[3], const float a[3])
MINLINE float normalize_v3(float n[3])
MINLINE float len_v3(const float a[3]) ATTR_WARN_UNUSED_RESULT
float BLI_noise_generic_turbulence(float noisesize, float x, float y, float z, int oct, bool hard, int noisebasis)
void int BLI_rng_get_int(struct RNG *rng) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
struct RNG * BLI_rng_new(unsigned int seed)
void BLI_rng_free(struct RNG *rng) ATTR_NONNULL(1)
float BLI_rng_get_float(struct RNG *rng) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
#define STRNCPY(dst, src)
Platform independent time functions.
double BLI_time_now_seconds(void)
ListBase * DEG_get_effector_relations(const Depsgraph *depsgraph, Collection *collection)
float DEG_get_ctime(const Depsgraph *graph)
Scene * DEG_get_evaluated_scene(const Depsgraph *graph)
eEvaluationMode DEG_get_mode(const Depsgraph *graph)
ID * DEG_get_evaluated_id(const Depsgraph *depsgraph, ID *id)
These structs are the foundation for all linked lists in the library system.
@ PFIELD_MULTIPLE_SPRINGS
@ PFIELD_CLOTH_USE_CULLING
Object is a sort of wrapper for general info.
Read Guarded memory(de)allocation.
ATTR_WARN_UNUSED_RESULT const BMVert * v2
SIMD_FORCE_INLINE btScalar norm() const
Return the norm (length) of the vector.
constexpr const T * data() const
local_group_size(16, 16) .push_constant(Type b
pow(value.r - subtrahend, 2.0)") .do_static_compilation(true)
const Depsgraph * depsgraph
draw_view in_light_buf[] float
draw_view push_constant(Type::INT, "radiance_src") .push_constant(Type capture_info_buf storage_buf(1, Qualifier::READ, "ObjectBounds", "bounds_buf[]") .push_constant(Type draw_view int
bool closest_point_on_surface(SurfaceModifierData *surmd, const float co[3], float surface_co[3], float surface_nor[3], float surface_vel[3])
ListBase * BKE_effector_relations_create(Depsgraph *depsgraph, const Scene *scene, ViewLayer *view_layer, Collection *collection)
void BKE_sim_debug_data_add_element(int type, const float v1[3], const float v2[3], const char *str, float r, float g, float b, const char *category, uint hash)
EffectorWeights * BKE_effector_add_weights(Collection *collection)
static bool is_effector_relevant(PartDeflect *pd, EffectorWeights *weights, bool use_rotation)
void BKE_sim_debug_data_clear_category(const char *category)
static void do_texture_effector(EffectorCache *eff, EffectorData *efd, EffectedPoint *point, float *total_force)
static void debug_data_insert(SimDebugData *debug_data, SimDebugElement *elem)
SimDebugData * _sim_debug_data
bool BKE_sim_debug_data_get_enabled()
void BKE_effectors_free(ListBase *lb)
static bool is_effector_enabled(PartDeflect *pd, bool use_rotation)
uint BKE_sim_debug_data_hash(int i)
static uint debug_element_hash(const void *key)
static bool debug_element_compare(const void *a, const void *b)
void pd_point_from_loc(Scene *scene, float *loc, float *vel, int index, EffectedPoint *point)
void pd_point_from_particle(ParticleSimulationData *sim, ParticleData *pa, ParticleKey *state, EffectedPoint *point)
static float falloff_func_dist(PartDeflect *pd, float fac)
static void do_physical_effector(EffectorCache *eff, EffectorData *efd, EffectedPoint *point, float *total_force)
static void add_effector_evaluation(ListBase **effectors, Depsgraph *depsgraph, Scene *scene, Object *ob, ParticleSystem *psys, PartDeflect *pd)
PartDeflect * BKE_partdeflect_new(int type)
void BKE_effector_relations_free(ListBase *lb)
void BKE_sim_debug_data_set_enabled(bool enable)
void BKE_partdeflect_free(PartDeflect *pd)
void BKE_sim_debug_data_remove_element(uint hash)
static float wind_func(RNG *rng, float strength)
void BKE_effectors_apply(ListBase *effectors, ListBase *colliders, EffectorWeights *weights, EffectedPoint *point, float *force, float *wind_force, float *impulse)
static void eff_tri_ray_hit(void *, int, const BVHTreeRay *, BVHTreeRayHit *hit)
static void add_effector_relation(ListBase *relations, Object *ob, ParticleSystem *psys, PartDeflect *pd)
void BKE_sim_debug_data_clear()
static void debug_element_free(void *val)
static void get_effector_tot(EffectorCache *eff, EffectorData *efd, EffectedPoint *point, int *tot, int *p, int *step)
static bool is_effector_nonzero_strength(PartDeflect *pd)
void pd_point_from_soft(Scene *scene, float *loc, float *vel, int index, EffectedPoint *point)
PartDeflect * BKE_partdeflect_copy(const PartDeflect *pd_src)
bool get_effector_data(EffectorCache *eff, EffectorData *efd, EffectedPoint *point, int real_velocity)
float effector_falloff(EffectorCache *eff, EffectorData *efd, EffectedPoint *, EffectorWeights *weights)
ListBase * BKE_effectors_create(Depsgraph *depsgraph, Object *ob_src, ParticleSystem *psys_src, EffectorWeights *weights, bool use_rotation)
uint BKE_sim_debug_data_hash_combine(uint kx, uint ky)
static void precalculate_effector(Depsgraph *depsgraph, EffectorCache *eff)
static float eff_calc_visibility(ListBase *colliders, EffectorCache *eff, EffectorData *efd, EffectedPoint *point)
static float falloff_func(float fac, int usemin, float mindist, int usemax, float maxdist, float power)
static float falloff_func_rad(PartDeflect *pd, float fac)
void BKE_sim_debug_data_free()
void MEM_freeN(void *vmemh)
void *(* MEM_callocN)(size_t len, const char *str)
void *(* MEM_dupallocN)(const void *vmemh)
ccl_device_inline float2 power(float2 v, float e)
ccl_device_inline float3 ceil(const float3 a)
closure color absorption() BUILTIN
blender::Span< blender::int3 > corner_tris
blender::Span< int > corner_verts
BVHTree_NearestPointCallback nearest_callback
struct ParticleSystem * psys
struct SurfaceModifierData * surmd
struct Depsgraph * depsgraph
struct ParticleSystem * psys
struct Collection * group
ObjectRuntimeHandle * runtime
struct Depsgraph * depsgraph
struct ParticleSystem * psys
unsigned int category_hash
float(* vert_velocities)[3]
struct BVHTreeFromMesh * bvhtree
SurfaceModifierData_Runtime runtime
int multitex_ext(Tex *tex, const float texvec[3], float dxt[3], float dyt[3], int osatex, TexResult *texres, const short thread, ImagePool *pool, bool scene_color_manage, const bool skip_load_image)