72 weights->
group = collection;
80 pd = MEM_new<PartDeflect>(
"PartDeflect");
119 if (pd_src ==
nullptr) {
139 uint cfra =
uint(ctime >= 0 ? ctime : -ctime);
167 else if (eff->
psys) {
179 relation->
psys = psys;
186 Depsgraph *depsgraph,
192 if (*effectors ==
nullptr) {
219 "effector relations");
221 for (; base; base = base->
next) {
222 if (!(base->
flag & base_flag)) {
252 lb->free_no_destruct();
302 return pd->
f_damp != 0.0f;
324 ListBaseT<EffectorCache> *effectors =
nullptr;
344 PartDeflect *pd = (relation.pd == relation.psys->part->pd) ? part->
pd : part->
pd2;
378 if (eff.guide_data) {
379 MEM_delete(eff.guide_data);
383 lb->free_no_destruct();
418 point->
ave = point->
rot =
nullptr;
436 point->
ave = point->
rot =
nullptr;
437 point->
psys =
nullptr;
451 point->
ave = point->
rot =
nullptr;
453 point->
psys =
nullptr;
479 ListBaseT<ColliderCache> *colls = colliders;
500 if (col.ob == eff->
ob) {
522 visibility *= std::clamp(1.0f -
absorption, 0.0f, 1.0f);
524 if (visibility <= 0.0f) {
558 float fac,
int usemin,
float mindist,
int usemax,
float maxdist,
float power)
561 if (usemax && fac > maxdist) {
565 if (usemin && fac < mindist) {
573 return pow(
double(1.0f + fac - mindist),
double(-
power));
621 if (falloff == 0.0f) {
631 if (falloff == 0.0f) {
648 float surface_nor[3],
649 float surface_vel[3])
654 const std::optional<bke::bvh::ClosestPointResult> nearest =
666 if (
mesh.faces_num > 0) {
667 const int3 &tri =
mesh.corner_tris()[nearest->index];
669 const int verts[3] = {corner_verts[tri[0]], corner_verts[tri[1]], corner_verts[tri[2]]};
672 normal_tri_v3(surface_nor, positions[verts[0]], positions[verts[1]], positions[verts[2]]);
675 copy_v3_v3(surface_vel, velocities[verts[0]]);
676 add_v3_v3(surface_vel, velocities[verts[1]]);
677 add_v3_v3(surface_vel, velocities[verts[2]]);
683 const int2 edge =
mesh.edges()[nearest->index];
686 sub_v3_v3v3(surface_nor, positions[edge[0]], positions[edge[1]]);
691 add_v3_v3(surface_vel, velocities[edge[1]]);
719 eff->
surmd, vec, efd->
loc, efd->
nor, real_velocity ? efd->
vel :
nullptr);
726 if (mesh_eval !=
nullptr) {
727 const Span<float3> positions = mesh_eval->vert_positions();
728 const Span<float3> vert_normals = mesh_eval->vert_normals();
742 else if (eff->
psys) {
758 state.time = cfra - 1.0f;
771 efd->
nor[1] = efd->
nor[2] = 0.0f;
842 *tot = mesh_eval !=
nullptr ? mesh_eval->
verts_num : 1;
845 *p = point->
index % *tot;
849 else if (eff->
psys) {
873 *
step = (totpart > amount) ?
int(
ceil(
float(totpart) /
float(amount))) : 1;
886 float tex_co[3], strength, force[3];
900 mul_m4_v3(eff->
ob->world_to_object().ptr(), tex_co);
914 force[0] = (0.5f -
result->trgba[0]) * strength;
915 force[1] = (0.5f -
result->trgba[1]) * strength;
916 force[2] = (0.5f -
result->trgba[2]) * strength;
918 else if (nabla != 0) {
935 for (
int i = 0; i < 4; i++) {
936 result[i].tin = (1.0f / 3.0f) *
945 float dbdy, dgdz, drdz, dbdx, dgdx, drdy;
954 force[0] = (dbdy - dgdz) * strength;
955 force[1] = (drdz - dbdx) * strength;
956 force[2] = (dgdx - drdy) * strength;
979 float force[3] = {0, 0, 0};
984 float noise_factor = pd->
f_noise;
985 float flow_falloff = efd->
falloff;
987 if (noise_factor > 0.0f) {
988 strength +=
wind_func(rng, noise_factor);
1059 fac = -fac * (1.0f - fac) / efd->
distance;
1062 fac = ((fac > 2.0f) ? 2.0f : fac);
1077 pd->
f_size, temp[0], temp[1], temp[2], 2,
false, 2);
1079 pd->
f_size, temp[1], temp[2], temp[0], 2,
false, 2);
1081 pd->
f_size, temp[2], temp[0], temp[1], 2,
false, 2);
1088 strength = std::min(strength, 2.0f);
1089 damp = std::min(damp, 2.0f);
1099 if (density >= 0.0f) {
1100 float influence = strength * efd->
falloff;
1102 influence *= density;
1105 flow_falloff = influence;
1123 float xvec[3] = {1.0f, 0.0f, 0.0f};
1127 if (pd->
f_flow != 0.0f) {
1135 ListBaseT<ColliderCache> *colliders,
1172 int p = 0, tot = 1,
step = 1;
1183 for (; p < tot; p +=
step) {
1191 float out_force[3] = {0, 0, 0};
1206 madd_v3_v3fl(force, out_force, 1.0f - eff.pd->f_wind_factor);
1207 madd_v3_v3fl(wind_force, out_force, eff.pd->f_wind_factor);
1234#define rot(x, k) (((x) << (k)) | ((x) >> (32 - (k))))
1238 a =
b = c = 0xdeadbeef + (2 << 2) + 13;
1334 const char *category,
1372 elem->
str[0] =
'\0';
display list (or rather multi purpose list) stuff.
#define PE_VELOCITY_TO_IMPULSE
#define PE_USE_NORMAL_DATA
General operations, lookup, etc. for blender objects.
#define BVH_RAYCAST_DEFAULT
Platform independent time functions.
These structs are the foundation for all linked lists in the library system.
Object is a sort of wrapper for general info.
Read Blender memory allocation and freeing.
SIMD_FORCE_INLINE btScalar norm() const
Return the norm (length) of the vector.
std::optional< ClosestPointResult > closest_point(const float3 &point, float radius=std::numeric_limits< float >::max()) const
VecBase< float, D > step(VecOp< float, D >, VecOp< float, D >) RET
float4x4 translate(float4x4 mat, float3 translation)
ccl_device_inline dual1 len(const ccl_private dual< T > &a)
ccl_device_inline float2 power(const float2 v, const float e)
MINLINE void madd_v3_v3v3fl(float r[3], const float a[3], const float b[3], float f)
MINLINE void negate_v3_v3(float r[3], const float a[3])
struct PartDeflect * BKE_partdeflect_new(ePFieldType type)
unsigned int BLI_ghashutil_uinthash(unsigned int key)
float BLI_noise_generic_turbulence(float noisesize, float x, float y, float z, int oct, bool hard, int noisebasis)
char * STRNCPY(char(&dst)[N], const char *src)
MINLINE void copy_v3_v3(float r[3], const float a[3])
void BKE_collider_cache_free(ListBaseT< ColliderCache > **colliders)
void BKE_sim_debug_data_set_enabled(bool enable)
MINLINE void add_v3_v3v3(float r[3], const float a[3], const float b[3])
int multitex_ext(Tex *tex, const float texvec[3], TexResult *texres, const short thread, ImagePool *pool, bool scene_color_manage, const bool skip_load_image)
@ PFIELD_CLOTH_USE_CULLING
@ PFIELD_MULTIPLE_SPRINGS
void * BLI_ghash_lookup(const GHash *gh, const void *key) ATTR_WARN_UNUSED_RESULT
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)
static void precalculate_effector(Depsgraph *depsgraph, EffectorCache *eff)
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)
MINLINE float safe_acosf(float a)
void pd_point_from_particle(struct ParticleSimulationData *sim, struct ParticleData *pa, struct ParticleKey *state, struct EffectedPoint *point)
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, unsigned int hash)
struct PartDeflect * BKE_partdeflect_copy(const struct PartDeflect *pd_src)
void * BLI_findstring(const ListBase *listbase, const char *id, int offset) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void BKE_effectors_apply(ListBaseT< EffectorCache > *effectors, ListBaseT< ColliderCache > *colliders, struct EffectorWeights *weights, struct EffectedPoint *point, float *force, float *wind_force, float *impulse)
static uint debug_element_hash(const void *key)
unsigned int BKE_sim_debug_data_hash_combine(unsigned int kx, unsigned int ky)
static void eff_tri_ray_hit(void *, int, const BVHTreeRay *, BVHTreeRayHit *hit)
float normal_tri_v3(float n[3], const float v1[3], const float v2[3], const float v3[3])
float psys_get_timestep(struct ParticleSimulationData *sim)
struct RNG * BLI_rng_new(unsigned int seed)
MINLINE void mul_v3_fl(float r[3], float f)
void BLI_ghash_insert(GHash *gh, void *key, void *val)
float effector_falloff(struct EffectorCache *eff, struct EffectorData *efd, struct EffectedPoint *point, struct EffectorWeights *weights)
void project_v3_v3v3(float out[3], const float p[3], const float v_proj[3])
BLI_INLINE void * BLI_ghashIterator_getValue(GHashIterator *ghi) ATTR_WARN_UNUSED_RESULT
void mul_qt_v3(const float q[4], float r[3])
float BKE_fluid_get_velocity_at(struct Object *ob, float position[3], float velocity[3])
void mul_m4_v3(const float M[4][4], float r[3])
MINLINE void madd_v3_v3fl(float r[3], const float a[3], float f)
static bool is_effector_enabled(PartDeflect *pd, bool use_rotation)
void BLI_ghashIterator_step(GHashIterator *ghi)
VecBase< int32_t, 2 > int2
void BKE_sim_debug_data_clear()
bool psys_get_particle_state(struct ParticleSimulationData *sim, int p, struct ParticleKey *state, bool always)
VecBase< int32_t, 3 > int3
void * MEM_new_zeroed(size_t len, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2)
MINLINE void cross_v3_v3v3(float r[3], const float a[3], const float b[3])
void BLI_ghash_free(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp)
ListBaseT< ColliderCache > * BKE_collider_cache_create(struct Depsgraph *depsgraph, struct Object *self, struct Collection *collection)
Main * DEG_get_bmain(const Depsgraph *graph)
void BKE_sim_debug_data_remove_element(unsigned int hash)
T * DEG_get_evaluated(const Depsgraph *depsgraph, T *id)
static void add_effector_relation(ListBaseT< EffectorRelation > *relations, Object *ob, ParticleSystem *psys, PartDeflect *pd)
void BLI_ghash_clear(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp)
ListBaseT< EffectorRelation > * DEG_get_effector_relations(const Depsgraph *depsgraph, Collection *collection)
bool get_effector_data(struct EffectorCache *eff, struct EffectorData *efd, struct EffectedPoint *point, int real_velocity)
SimDebugData * _sim_debug_data
Base * BKE_collection_or_layer_objects(const Main &bmain, const Scene *scene, ViewLayer *view_layer, Collection *collection)
static float falloff_func_dist(PartDeflect *pd, float fac)
void BLI_rng_free(struct RNG *rng) ATTR_NONNULL(1)
MINLINE float len_v3(const float a[3]) ATTR_WARN_UNUSED_RESULT
static void get_effector_tot(EffectorCache *eff, EffectorData *efd, EffectedPoint *point, int *tot, int *p, int *step)
void BLI_ghashIterator_init(GHashIterator *ghi, GHash *gh)
MINLINE void zero_v3(float r[3])
eEvaluationMode DEG_get_mode(const Depsgraph *graph)
bool psys_check_enabled(struct Object *ob, struct ParticleSystem *psys, bool use_render_params)
float BLI_rng_get_float(struct RNG *rng) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void mul_mat3_m4_v3(const float mat[4][4], float r[3])
void BKE_partdeflect_free(struct PartDeflect *pd)
MINLINE float normalize_v3_v3(float r[3], const float a[3])
void int BLI_rng_get_int(struct RNG *rng) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
static bool debug_element_compare(const void *a, const void *b)
MINLINE float normalize_v3(float n[3])
unsigned int BKE_sim_debug_data_hash(int i)
ModifierData * BKE_modifiers_findby_type(const Object *ob, ModifierType type)
MINLINE void add_v3_v3(float r[3], const float a[3])
MINLINE void sub_v3_v3v3(float r[3], const float a[3], const float b[3])
void pd_point_from_loc(struct Scene *scene, float *loc, float *vel, int index, struct EffectedPoint *point)
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
ATTR_WARN_UNUSED_RESULT const BMVert * v2
static float wind_func(RNG *rng, float strength)
void psys_update_particle_tree(struct ParticleSystem *psys, float cfra)
static float falloff_func_rad(PartDeflect *pd, float fac)
void BKE_effector_relations_free(ListBaseT< EffectorRelation > *lb)
static void do_texture_effector(EffectorCache *eff, EffectorData *efd, EffectedPoint *point, float *total_force)
static void do_physical_effector(EffectorCache *eff, EffectorData *efd, EffectedPoint *point, float *total_force)
bool BLI_ghash_remove(GHash *gh, const void *key, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp)
ListBaseT< EffectorCache > * BKE_effectors_create(struct Depsgraph *depsgraph, struct Object *ob_src, struct ParticleSystem *psys_src, struct EffectorWeights *weights, bool use_rotation)
ListBaseT< EffectorRelation > * BKE_effector_relations_create(struct Depsgraph *depsgraph, const struct Scene *scene, struct ViewLayer *view_layer, struct Collection *collection)
bool BKE_sim_debug_data_get_enabled()
void pd_point_from_soft(struct Scene *scene, float *loc, float *vel, int index, struct EffectedPoint *point)
unsigned int BLI_ghashutil_strhash_p(const void *ptr)
double BLI_time_now_seconds()
static void debug_data_insert(SimDebugData *debug_data, SimDebugElement *elem)
static bool is_effector_nonzero_strength(PartDeflect *pd)
bool closest_point_on_surface(struct SurfaceModifierData *surmd, const float co[3], float surface_co[3], float surface_nor[3], float surface_vel[3])
static void add_effector_evaluation(ListBaseT< EffectorCache > **effectors, Depsgraph *depsgraph, Scene *scene, Object *ob, ParticleSystem *psys, PartDeflect *pd)
GHash * BLI_ghash_new(GHashHashFP hashfp, GHashCmpFP cmpfp, const char *info) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
void BKE_displist_make_curveTypes(struct Depsgraph *depsgraph, const struct Scene *scene, struct Object *ob, bool for_render)
VecBase< float, 3 > float3
void BKE_sim_debug_data_clear_category(const char *category)
static float eff_calc_visibility(ListBaseT< ColliderCache > *colliders, EffectorCache *eff, EffectorData *efd, EffectedPoint *point)
Scene * DEG_get_evaluated_scene(const Depsgraph *graph)
struct EffectorWeights * BKE_effector_add_weights(struct Collection *collection)
MINLINE float dot_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
float DEG_get_ctime(const Depsgraph *graph)
BLI_INLINE bool BLI_ghashIterator_done(const GHashIterator *ghi) ATTR_WARN_UNUSED_RESULT
static bool is_effector_relevant(PartDeflect *pd, EffectorWeights *weights, bool use_rotation)
void BKE_effectors_free(ListBaseT< EffectorCache > *lb)
static void debug_element_free(void *val)
static float falloff_func(float fac, int usemin, float mindist, int usemax, float maxdist, float power)
void BKE_sim_debug_data_free()
Mesh * BKE_object_get_evaluated_mesh(const Object *object_eval)
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
closure color absorption() BUILTIN
const float * anim_path_accum_length
struct ParticleSystem * psys
struct SurfaceModifierData * surmd
struct Depsgraph * depsgraph
struct ParticleSystem * psys
struct ParticleSystem * psys
struct Collection * group
bke::ObjectRuntime * runtime
ListBaseT< struct ParticleSystem > particlesystem
struct Depsgraph * depsgraph
struct ParticleSystem * psys
unsigned int category_hash
float(* vert_velocities)[3]
const bke::bvh::Tree * bvhtree
SurfaceModifierData_Runtime runtime