Blender
V3.3
|
#include <stdarg.h>
#include <stddef.h>
#include <math.h>
#include <stdlib.h>
#include "MEM_guardedalloc.h"
#include "DNA_collection_types.h"
#include "DNA_curve_types.h"
#include "DNA_listBase.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_object_force_types.h"
#include "DNA_object_types.h"
#include "DNA_particle_types.h"
#include "DNA_scene_types.h"
#include "DNA_texture_types.h"
#include "BLI_blenlib.h"
#include "BLI_ghash.h"
#include "BLI_math.h"
#include "BLI_noise.h"
#include "BLI_rand.h"
#include "BLI_utildefines.h"
#include "PIL_time.h"
#include "BKE_anim_path.h"
#include "BKE_bvhutils.h"
#include "BKE_collection.h"
#include "BKE_collision.h"
#include "BKE_curve.h"
#include "BKE_displist.h"
#include "BKE_effect.h"
#include "BKE_fluid.h"
#include "BKE_global.h"
#include "BKE_layer.h"
#include "BKE_mesh.h"
#include "BKE_modifier.h"
#include "BKE_object.h"
#include "BKE_particle.h"
#include "BKE_scene.h"
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_physics.h"
#include "DEG_depsgraph_query.h"
#include "RE_texture.h"
Go to the source code of this file.
Macros | |
#define | rot(x, k) (((x) << (k)) | ((x) >> (32 - (k)))) |
Variables | |
SimDebugData * | _sim_debug_data = NULL |
|
static |
Definition at line 186 of file effect.c.
References BLI_addtail(), EffectorCache::depsgraph, depsgraph, EffectorCache::frame, MEM_callocN, NULL, EffectorCache::ob, EffectorCache::pd, precalculate_effector(), EffectorCache::psys, EffectorCache::scene, and scene.
Referenced by BKE_effectors_create().
|
static |
Definition at line 173 of file effect.c.
References BLI_addtail(), MEM_callocN, EffectorRelation::ob, EffectorRelation::pd, and EffectorRelation::psys.
Referenced by BKE_effector_relations_create().
EffectorWeights* BKE_effector_add_weights | ( | Collection * | collection | ) |
Definition at line 58 of file effect.c.
References EffectorWeights::global_gravity, EffectorWeights::group, MEM_callocN, NUM_PFIELD_TYPES, and EffectorWeights::weight.
Referenced by BKE_fluid_modifier_create_type_data(), BKE_modifier_blend_read_data(), dynamicPaint_createNewSurface(), initData(), object_blend_read_data(), particle_settings_blend_read_data(), particle_settings_blend_read_lib(), particle_settings_init(), sbNew(), and scene_blend_read_data().
ListBase* BKE_effector_relations_create | ( | struct Depsgraph * | depsgraph, |
struct ViewLayer * | view_layer, | ||
struct Collection * | collection | ||
) |
Create list of effector relations in the collection or entire scene. This is used by the depsgraph to build relations, as well as faster lookup of effectors during evaluation.
Definition at line 209 of file effect.c.
References add_effector_relation(), BASE_ENABLED_RENDER, BASE_ENABLED_VIEWPORT, BKE_collection_or_layer_objects(), DAG_EVAL_RENDER, DEG_get_mode(), depsgraph, Base::flag, PartDeflect::forcefield, LISTBASE_FOREACH, MEM_callocN, Base::next, NULL, Base::object, Object::particlesystem, Object::pd, ParticleSettings::pd, ParticleSettings::pd2, and psys_check_enabled().
Referenced by blender::deg::build_effector_relations().
Definition at line 247 of file effect.c.
References BLI_freelistN(), and MEM_freeN.
Referenced by blender::deg::clear_physics_relations().
void BKE_effectors_apply | ( | struct ListBase * | effectors, |
struct ListBase * | colliders, | ||
struct EffectorWeights * | weights, | ||
struct EffectedPoint * | point, | ||
float * | force, | ||
float * | wind_force, | ||
float * | impulse | ||
) |
Generic force/speed system, now used for particles, soft-bodies & dynamic-paint.
Definition at line 1114 of file effect.c.
References add_v3_v3(), add_v3_v3v3(), do_physical_effector(), do_texture_effector(), eff_calc_visibility(), effector_falloff(), PartDeflect::f_wind_factor, EffectorData::falloff, ListBase::first, EffectorCache::flag, PartDeflect::forcefield, get_effector_data(), get_effector_tot(), madd_v3_v3fl(), EffectorCache::next, EffectorCache::pd, PE_VELOCITY_TO_IMPULSE, PE_WIND_AS_SPEED, PFIELD_TEXTURE, point, sub_v3_v3v3(), and EffectorData::vel.
Referenced by _scan_for_ext_spring_forces(), _softbody_calc_forces_slice_in_a_thread(), basic_force_cb(), boid_body(), cloth_calc_force(), do_path_effectors(), and dynamic_paint_prepare_effect_cb().
ListBase* BKE_effectors_create | ( | struct Depsgraph * | depsgraph, |
struct Object * | ob_src, | ||
struct ParticleSystem * | psys_src, | ||
struct EffectorWeights * | weights, | ||
bool | use_rotation | ||
) |
Create effective list of effectors from relations built beforehand.
Definition at line 314 of file effect.c.
References add_effector_evaluation(), BKE_object_get_evaluated_mesh(), BLI_findstring(), DEG_get_effector_relations(), DEG_get_evaluated_id(), DEG_get_evaluated_scene(), depsgraph, ParticleSettings::flag, EffectorWeights::group, if(), is_effector_relevant(), LISTBASE_FOREACH, NULL, ParticleSystem::part, PART_SELF_EFFECT, Object::particlesystem, Object::pd, ParticleSettings::pd, ParticleSettings::pd2, PFIELD_SHAPE_POINTS, scene, and PartDeflect::shape.
Referenced by do_step_cloth(), dynamicPaint_prepareEffectStep(), psys_update_effectors(), sb_sfesf_threads_run(), and softbody_calc_forces().
Definition at line 369 of file effect.c.
References BLI_freelistN(), LISTBASE_FOREACH, and MEM_freeN.
Referenced by do_step_cloth(), dynamicPaint_prepareEffectStep(), psys_free(), psys_update_effectors(), sb_sfesf_threads_run(), and softbody_calc_forces().
PartDeflect* BKE_partdeflect_copy | ( | const struct PartDeflect * | pd_src | ) |
Definition at line 110 of file effect.c.
References BLI_rng_copy(), MEM_dupallocN, NULL, and PartDeflect::rng.
Referenced by particle_settings_copy_data().
void BKE_partdeflect_free | ( | PartDeflect * | pd | ) |
Definition at line 122 of file effect.c.
References BLI_rng_free(), MEM_freeN, and PartDeflect::rng.
Referenced by object_free_data(), and particle_settings_free_data().
PartDeflect* BKE_partdeflect_new | ( | int | type | ) |
Definition at line 71 of file effect.c.
References ceil(), PartDeflect::f_damp, PartDeflect::f_flow, PartDeflect::f_size, PartDeflect::f_strength, PartDeflect::f_wind_factor, PartDeflect::flag, PartDeflect::forcefield, MEM_callocN, PartDeflect::pdef_cfrict, PartDeflect::pdef_sbdamp, PartDeflect::pdef_sbift, PartDeflect::pdef_sboft, PFIELD_CLOTH_USE_CULLING, PFIELD_DO_LOCATION, PFIELD_DO_ROTATION, PFIELD_FLUIDFLOW, PFIELD_SHAPE_PLANE, PFIELD_TEXTURE, PFIELD_VORTEX, PFIELD_WIND, PIL_check_seconds_timer(), PartDeflect::seed, PartDeflect::shape, and type.
Referenced by ED_object_modifier_add(), effector_add_exec(), forcefield_toggle_exec(), and particle_settings_init().
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 | ||
) |
Definition at line 1307 of file effect.c.
References _sim_debug_data, usdtokens::b(), BKE_sim_debug_data_set_enabled(), BLI_ghashutil_strhash_p(), BLI_strncpy(), SimDebugElement::category_hash, SimDebugElement::color, copy_v3_v3(), debug_data_insert(), usdtokens::g(), G, G_DEBUG_SIMDATA, SimDebugElement::hash, hash, MEM_callocN, r, str, SimDebugElement::str, SimDebugElement::type, type, SimDebugElement::v1, v1, SimDebugElement::v2, v2, and zero_v3().
Definition at line 1368 of file effect.c.
References _sim_debug_data, BLI_ghash_clear(), debug_element_free(), SimDebugData::gh, and NULL.
void BKE_sim_debug_data_clear_category | ( | const char * | category | ) |
Definition at line 1378 of file effect.c.
References _sim_debug_data, BLI_ghash_remove(), BLI_ghashIterator_done(), BLI_ghashIterator_getValue(), BLI_ghashIterator_init(), BLI_ghashIterator_step(), BLI_ghashutil_strhash_p(), SimDebugElement::category_hash, debug_element_free(), SimDebugData::gh, and NULL.
Referenced by cloth_continuum_step(), and SIM_cloth_solve().
Definition at line 1285 of file effect.c.
References _sim_debug_data, BLI_ghash_free(), debug_element_free(), SimDebugData::gh, MEM_freeN, and NULL.
Referenced by BKE_sim_debug_data_set_enabled().
Definition at line 1280 of file effect.c.
References _sim_debug_data, and NULL.
uint BKE_sim_debug_data_hash | ( | int | i | ) |
Definition at line 1208 of file effect.c.
References BLI_ghashutil_uinthash().
Definition at line 1213 of file effect.c.
References Freestyle::a, usdtokens::b(), Freestyle::c, and rot.
Definition at line 1358 of file effect.c.
References _sim_debug_data, BLI_ghash_remove(), debug_element_free(), SimDebugData::gh, SimDebugElement::hash, hash, and NULL.
Definition at line 1266 of file effect.c.
References _sim_debug_data, BKE_sim_debug_data_free(), BLI_ghash_new(), debug_element_compare(), debug_element_hash(), SimDebugData::gh, and MEM_callocN.
Referenced by BKE_sim_debug_data_add_element().
bool closest_point_on_surface | ( | SurfaceModifierData * | surmd, |
const float | co[3], | ||
float | surface_co[3], | ||
float | surface_nor[3], | ||
float | surface_vel[3] | ||
) |
Definition at line 640 of file effect.c.
References add_v3_v3(), BLI_bvhtree_find_nearest(), SurfaceModifierData::bvhtree, BVHTreeNearest::co, MVert::co, copy_v3_v3(), BVHTreeNearest::dist_sq, BVHTreeNearest::index, BVHTreeFromMesh::loop, BVHTreeFromMesh::looptri, mul_v3_fl(), BVHTreeFromMesh::nearest_callback, BVHTreeNearest::no, BVHTreeFromMesh::tree, MLoopTri::tri, MLoop::v, and SurfaceModifierData::v.
Referenced by boid_find_ground(), and get_effector_data().
|
static |
Definition at line 1295 of file effect.c.
References BLI_ghash_insert(), BLI_ghash_lookup(), SimDebugData::gh, and MEM_freeN.
Referenced by BKE_sim_debug_data_add_element().
Definition at line 1249 of file effect.c.
References Freestyle::a, usdtokens::b(), and SimDebugElement::hash.
Referenced by BKE_sim_debug_data_set_enabled().
Definition at line 1260 of file effect.c.
References MEM_freeN.
Referenced by BKE_sim_debug_data_clear(), BKE_sim_debug_data_clear_category(), BKE_sim_debug_data_free(), and BKE_sim_debug_data_remove_element().
Definition at line 1243 of file effect.c.
References SimDebugElement::hash.
Referenced by BKE_sim_debug_data_set_enabled().
|
static |
Definition at line 954 of file effect.c.
References add_v3_v3(), add_v3_v3v3(), BKE_fluid_get_velocity_at(), BLI_noise_generic_turbulence(), copy_v3_v3(), cross_v3_v3v3(), usdtokens::density(), EffectorData::distance, ELEM, PartDeflect::f_damp, PartDeflect::f_flow, PartDeflect::f_noise, PartDeflect::f_size, PartDeflect::f_source, PartDeflect::f_strength, fabsf, EffectorData::falloff, PartDeflect::flag, PartDeflect::forcefield, madd_v3_v3fl(), MIN2, mul_qt_v3(), mul_v3_fl(), EffectorData::nor, EffectorData::nor2, normalize_v3(), EffectorCache::pd, PFIELD_BOID, PFIELD_CHARGE, PFIELD_DO_LOCATION, PFIELD_DO_ROTATION, PFIELD_DRAG, PFIELD_FLUIDFLOW, PFIELD_FORCE, PFIELD_GLOBAL_CO, PFIELD_GRAVITATION, PFIELD_HARMONIC, PFIELD_LENNARDJ, PFIELD_MAGNET, PFIELD_SHAPE_LINE, PFIELD_SHAPE_POINT, PFIELD_SMOKE_DENSITY, PFIELD_TURBULENCE, PFIELD_VORTEX, PFIELD_WIND, point, pow(), powf, PartDeflect::rng, PartDeflect::shape, Particle::size, EffectorData::size, sqrtf, EffectorData::vec_to_point, EffectorData::vec_to_point2, wind_func(), and zero_v3().
Referenced by BKE_effectors_apply().
|
static |
Definition at line 855 of file effect.c.
References add_v3_v3(), BKE_scene_check_color_management_enabled(), copy_v3_v3(), dot_v3v3(), PartDeflect::f_strength, EffectorData::falloff, PartDeflect::flag, Object::imat, madd_v3_v3fl(), mul_m4_v3(), multitex_ext(), EffectorData::nor, NULL, EffectorCache::ob, EffectorCache::pd, PFIELD_DO_LOCATION, PFIELD_TEX_2D, PFIELD_TEX_GRAD, PFIELD_TEX_OBJECT, PFIELD_TEX_RGB, point, result, EffectorCache::scene, PartDeflect::tex, PartDeflect::tex_mode, PartDeflect::tex_nabla, TEX_RGB, and zero_v3().
Referenced by BKE_effectors_apply().
|
static |
Get visibility of a wind ray.
Definition at line 468 of file effect.c.
References absorption(), BKE_collider_cache_create(), BKE_collider_cache_free(), BLI_bvhtree_ray_cast_ex(), BVH_RAYCAST_DEFAULT, BVH_RAYCAST_WATERTIGHT, CollisionModifierData::bvhtree, CLAMPIS, col, EffectorCache::depsgraph, BVHTreeRayHit::dist, eff_tri_ray_hit(), ListBase::first, PartDeflect::flag, BVHTreeRayHit::index, len, negate_v3_v3(), norm(), normalize_v3(), NULL, EffectorCache::ob, EffectorCache::pd, PFIELD_VISIBILITY, point, and EffectorData::vec_to_point.
Referenced by BKE_effectors_apply().
|
static |
Definition at line 455 of file effect.c.
References BVHTreeRayHit::dist, and BVHTreeRayHit::index.
Referenced by eff_calc_visibility().
float effector_falloff | ( | EffectorCache * | eff, |
EffectorData * | efd, | ||
EffectedPoint * | UNUSEDpoint, | ||
EffectorWeights * | weights | ||
) |
Definition at line 591 of file effect.c.
References EffectorData::distance, dot_v3v3(), fabsf, PartDeflect::falloff, falloff_func_dist(), falloff_func_rad(), PartDeflect::forcefield, len_v3(), madd_v3_v3v3fl(), EffectorData::nor, EffectorCache::pd, PFIELD_FALL_CONE, PFIELD_FALL_SPHERE, PFIELD_FALL_TUBE, PFIELD_Z_NEG, PFIELD_Z_POS, RAD2DEGF, saacos(), EffectorData::vec_to_point2, EffectorWeights::weight, and PartDeflect::zdir.
Referenced by BKE_effectors_apply().
|
static |
Definition at line 552 of file effect.c.
References pow().
Referenced by falloff_func_dist(), and falloff_func_rad().
|
static |
Definition at line 571 of file effect.c.
References PartDeflect::f_power, falloff_func(), PartDeflect::flag, PartDeflect::maxdist, PartDeflect::mindist, PFIELD_USEMAX, and PFIELD_USEMIN.
Referenced by effector_falloff().
|
static |
Definition at line 581 of file effect.c.
References PartDeflect::f_power_r, falloff_func(), PartDeflect::flag, PartDeflect::maxrad, PartDeflect::minrad, PFIELD_USEMAXR, and PFIELD_USEMINR.
Referenced by effector_falloff().
bool get_effector_data | ( | EffectorCache * | eff, |
EffectorData * | efd, | ||
EffectedPoint * | point, | ||
int | real_velocity | ||
) |
Definition at line 676 of file effect.c.
References add_v3_v3(), add_v3_v3v3(), BKE_mesh_vertex_normals_ensure(), BKE_object_get_evaluated_mesh(), SurfaceModifierData::bvhtree, closest_point_on_surface(), MVert::co, copy_v3_v3(), DEG_get_ctime(), EffectorCache::depsgraph, ParticleSimulationData::depsgraph, EffectorData::distance, ELEM, PartDeflect::f_size, EffectorCache::flag, float(), PartDeflect::forcefield, Particle::index, EffectorData::index, len_v3(), EffectorData::loc, mul_m4_v3(), mul_mat3_m4_v3(), mul_qt_v3(), mul_v3_fl(), Mesh::mvert, EffectorData::nor, EffectorData::nor2, normalize_v3(), normalize_v3_v3(), NULL, EffectorCache::ob, ParticleSimulationData::ob, Object::obmat, ParticleSystem::particles, EffectorCache::pd, PE_USE_NORMAL_DATA, PFIELD_HARMONIC, PFIELD_SHAPE_LINE, PFIELD_SHAPE_PLANE, PFIELD_SHAPE_POINTS, PFIELD_SHAPE_SURFACE, PFIELD_VORTEX, point, project_v3_v3v3(), EffectorCache::psys, ParticleSimulationData::psys, psys_get_particle_state(), ret, EffectorCache::scene, ParticleSimulationData::scene, PartDeflect::shape, EffectorData::size, ParticleData::size, state, sub_v3_v3v3(), EffectorCache::surmd, EffectorData::vec_to_point, EffectorData::vec_to_point2, EffectorData::vel, and zero_v3().
Referenced by BKE_effectors_apply(), and rule_goal_avoid().
|
static |
Definition at line 809 of file effect.c.
References BKE_object_get_evaluated_mesh(), ceil(), EffectorData::charge, ParticleSettings::effector_amount, PartDeflect::f_strength, PartDeflect::flag, PartDeflect::forcefield, Particle::index, EffectorData::index, NULL, EffectorCache::ob, ParticleSystem::part, EffectorCache::pd, PFIELD_CHARGE, PFIELD_HARMONIC, PFIELD_MULTIPLE_SPRINGS, PFIELD_SHAPE_POINTS, point, EffectorCache::psys, PartDeflect::shape, ParticleSystem::totpart, and Mesh::totvert.
Referenced by BKE_effectors_apply().
|
static |
Definition at line 256 of file effect.c.
References PartDeflect::flag, PartDeflect::forcefield, NULL, PFIELD_BOID, PFIELD_DO_LOCATION, PFIELD_DO_ROTATION, PFIELD_GUIDE, PFIELD_TEXTURE, and PartDeflect::tex.
Referenced by is_effector_relevant().
|
static |
Definition at line 277 of file effect.c.
References PartDeflect::f_damp, PartDeflect::f_flow, PartDeflect::f_noise, PartDeflect::f_strength, PartDeflect::forcefield, PFIELD_BOID, PFIELD_DRAG, PFIELD_GUIDE, PFIELD_SHAPE_POINT, PFIELD_TEXTURE, PFIELD_VORTEX, and PartDeflect::shape.
Referenced by is_effector_relevant().
|
static |
Definition at line 308 of file effect.c.
References PartDeflect::forcefield, is_effector_enabled(), is_effector_nonzero_strength(), and EffectorWeights::weight.
Referenced by BKE_effectors_create().
void pd_point_from_loc | ( | Scene * | scene, |
float * | loc, | ||
float * | vel, | ||
int | index, | ||
EffectedPoint * | point | ||
) |
Definition at line 419 of file effect.c.
References float(), RenderData::frs_sec, Particle::index, NULL, point, Scene::r, scene, and Particle::size.
Referenced by cloth_calc_force(), and dynamic_paint_prepare_effect_cb().
void pd_point_from_particle | ( | ParticleSimulationData * | sim, |
ParticleData * | pa, | ||
ParticleKey * | state, | ||
EffectedPoint * | point | ||
) |
Definition at line 383 of file effect.c.
References PartDeflect::f_strength, ParticleSettings::flag, PartDeflect::forcefield, Particle::index, NULL, ParticleSystem::part, PART_ROT_DYN, ParticleSystem::particles, ParticleSettings::pd, ParticleSettings::pd2, PFIELD_CHARGE, point, ParticleSimulationData::psys, psys_get_timestep(), Particle::size, ParticleData::size, and state.
Referenced by basic_force_cb(), boid_body(), do_path_effectors(), precalc_guides(), and rule_goal_avoid().
void pd_point_from_soft | ( | Scene * | scene, |
float * | loc, | ||
float * | vel, | ||
int | index, | ||
EffectedPoint * | point | ||
) |
Definition at line 434 of file effect.c.
References float(), RenderData::frs_sec, Particle::index, NULL, PE_WIND_AS_SPEED, point, Scene::r, scene, and Particle::size.
Referenced by _scan_for_ext_spring_forces(), and _softbody_calc_forces_slice_in_a_thread().
|
static |
Definition at line 135 of file effect.c.
References CurveCache::anim_path_accum_length, BKE_displist_make_curveTypes(), BKE_modifiers_findby_type(), BKE_where_on_path(), BLI_rng_new(), BLI_rng_srandom(), CU_PATH, Object_Runtime::curve_cache, Object::data, DEG_get_ctime(), depsgraph, eModifierType_Surface, EffectorCache::flag, Curve::flag, PartDeflect::forcefield, EffectorCache::guide_dir, EffectorCache::guide_loc, EffectorCache::guide_radius, mul_m4_v3(), mul_mat3_m4_v3(), NULL, EffectorCache::ob, OB_CURVES_LEGACY, Object::obmat, EffectorCache::pd, PE_USE_NORMAL_DATA, PFIELD_GUIDE, PFIELD_SHAPE_SURFACE, EffectorCache::psys, psys_update_particle_tree(), PartDeflect::rng, Object::runtime, EffectorCache::scene, PartDeflect::seed, PartDeflect::shape, EffectorCache::surmd, and Object::type.
Referenced by add_effector_evaluation().
Definition at line 534 of file effect.c.
References BLI_rng_get_float(), BLI_rng_get_int(), float(), random(), ret, and KDL::sign().
Referenced by do_physical_effector().
SimDebugData* _sim_debug_data = NULL |
Definition at line 1206 of file effect.c.
Referenced by BKE_sim_debug_data_add_element(), BKE_sim_debug_data_clear(), BKE_sim_debug_data_clear_category(), BKE_sim_debug_data_free(), BKE_sim_debug_data_get_enabled(), BKE_sim_debug_data_remove_element(), and BKE_sim_debug_data_set_enabled().