Blender V2.61 - r43446
|
#include <stddef.h>
#include <math.h>
#include <stdlib.h>
#include "MEM_guardedalloc.h"
#include "DNA_curve_types.h"
#include "DNA_effect_types.h"
#include "DNA_group_types.h"
#include "DNA_ipo_types.h"
#include "DNA_key_types.h"
#include "DNA_lattice_types.h"
#include "DNA_listBase.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_material_types.h"
#include "DNA_object_types.h"
#include "DNA_object_force.h"
#include "DNA_particle_types.h"
#include "DNA_texture_types.h"
#include "DNA_scene_types.h"
#include "BLI_math.h"
#include "BLI_blenlib.h"
#include "BLI_jitter.h"
#include "BLI_rand.h"
#include "BLI_utildefines.h"
#include "PIL_time.h"
#include "BKE_action.h"
#include "BKE_anim.h"
#include "BKE_armature.h"
#include "BKE_blender.h"
#include "BKE_collision.h"
#include "BKE_constraint.h"
#include "BKE_deform.h"
#include "BKE_depsgraph.h"
#include "BKE_displist.h"
#include "BKE_DerivedMesh.h"
#include "BKE_cdderivedmesh.h"
#include "BKE_effect.h"
#include "BKE_global.h"
#include "BKE_group.h"
#include "BKE_ipo.h"
#include "BKE_key.h"
#include "BKE_lattice.h"
#include "BKE_mesh.h"
#include "BKE_material.h"
#include "BKE_main.h"
#include "BKE_modifier.h"
#include "BKE_object.h"
#include "BKE_particle.h"
#include "BKE_scene.h"
#include "RE_render_ext.h"
#include "RE_shader_ext.h"
Go to the source code of this file.
Classes | |
struct | VeNoCo |
Typedefs | |
typedef struct VeNoCo | VeNoCo |
Functions | |
EffectorWeights * | BKE_add_effector_weights (Group *group) |
PartDeflect * | object_add_collision_fields (int type) |
void | free_partdeflect (PartDeflect *pd) |
static void | precalculate_effector (EffectorCache *eff) |
static EffectorCache * | new_effector_cache (Scene *scene, Object *ob, ParticleSystem *psys, PartDeflect *pd) |
static void | add_object_to_effectors (ListBase **effectors, Scene *scene, EffectorWeights *weights, Object *ob, Object *ob_src) |
static void | add_particles_to_effectors (ListBase **effectors, Scene *scene, EffectorWeights *weights, Object *ob, ParticleSystem *psys, ParticleSystem *psys_src) |
ListBase * | pdInitEffectors (Scene *scene, Object *ob_src, ParticleSystem *psys_src, EffectorWeights *weights) |
void | pdEndEffectors (ListBase **effectors) |
void | pd_point_from_particle (ParticleSimulationData *sim, ParticleData *pa, ParticleKey *state, EffectedPoint *point) |
void | pd_point_from_loc (Scene *scene, float *loc, float *vel, int index, EffectedPoint *point) |
void | pd_point_from_soft (Scene *scene, float *loc, float *vel, int index, EffectedPoint *point) |
static void | eff_tri_ray_hit (void *UNUSED(userData), int UNUSED(index), const BVHTreeRay *UNUSED(ray), BVHTreeRayHit *hit) |
static float | eff_calc_visibility (ListBase *colliders, EffectorCache *eff, EffectorData *efd, EffectedPoint *point) |
static float | wind_func (struct RNG *rng, float strength) |
static float | falloff_func (float fac, int usemin, float mindist, int usemax, float maxdist, float power) |
static float | falloff_func_dist (PartDeflect *pd, float fac) |
static float | falloff_func_rad (PartDeflect *pd, float fac) |
float | effector_falloff (EffectorCache *eff, EffectorData *efd, EffectedPoint *UNUSED(point), EffectorWeights *weights) |
int | closest_point_on_surface (SurfaceModifierData *surmd, const float co[3], float surface_co[3], float surface_nor[3], float surface_vel[3]) |
int | get_effector_data (EffectorCache *eff, EffectorData *efd, EffectedPoint *point, int real_velocity) |
static void | get_effector_tot (EffectorCache *eff, EffectorData *efd, EffectedPoint *point, int *tot, int *p, int *step) |
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) |
void | pdDoEffectors (ListBase *effectors, ListBase *colliders, EffectorWeights *weights, EffectedPoint *point, float *force, float *impulse) |
Definition in file effect.c.
static void add_object_to_effectors | ( | ListBase ** | effectors, |
Scene * | scene, | ||
EffectorWeights * | weights, | ||
Object * | ob, | ||
Object * | ob_src | ||
) | [static] |
Definition at line 224 of file effect.c.
References BLI_addtail(), Object::derivedFinal, PartDeflect::forcefield, Object::imat, invert_m4_m4(), MEM_callocN(), new_effector_cache(), NULL, Object::obmat, Object::pd, PFIELD_SHAPE_POINTS, PartDeflect::shape, and EffectorWeights::weight.
Referenced by pdInitEffectors().
static void add_particles_to_effectors | ( | ListBase ** | effectors, |
Scene * | scene, | ||
EffectorWeights * | weights, | ||
Object * | ob, | ||
ParticleSystem * | psys, | ||
ParticleSystem * | psys_src | ||
) | [static] |
Definition at line 244 of file effect.c.
References BLI_addtail(), ParticleSettings::flag, PartDeflect::forcefield, MEM_callocN(), new_effector_cache(), NULL, ParticleSystem::part, PART_SELF_EFFECT, ParticleSettings::pd, ParticleSettings::pd2, psys_check_enabled(), and EffectorWeights::weight.
Referenced by pdInitEffectors().
EffectorWeights* BKE_add_effector_weights | ( | Group * | group | ) | [read] |
Definition at line 103 of file effect.c.
References EffectorWeights::global_gravity, EffectorWeights::group, i, MEM_callocN(), NUM_PFIELD_TYPES, and EffectorWeights::weight.
Referenced by cloth_init(), default_particle_settings(), direct_link_modifiers(), direct_link_object(), direct_link_particlesettings(), dynamicPaint_createNewSurface(), sbNew(), and smokeModifier_createType().
int 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 539 of file effect.c.
References add_v3_v3(), BLI_bvhtree_find_nearest(), SurfaceModifierData::bvhtree, CDDM_get_face(), MVert::co, BVHTreeNearest::co, copy_v3_v3(), BVHTreeNearest::dist, SurfaceModifierData::dm, FLT_MAX, BVHTreeNearest::index, mul_v3_fl(), BVHTreeFromMesh::nearest_callback, BVHTreeNearest::no, BVHTreeFromMesh::tree, SurfaceModifierData::v, MFace::v1, MFace::v2, MFace::v3, and MFace::v4.
Referenced by boid_find_ground(), and get_effector_data().
static void do_physical_effector | ( | EffectorCache * | eff, |
EffectorData * | efd, | ||
EffectedPoint * | point, | ||
float * | total_force | ||
) | [static] |
Definition at line 819 of file effect.c.
References add_v3_v3(), add_v3_v3v3(), EffectedPoint::ave, BLI_gTurbulence(), EffectedPoint::charge, copy_v3_v3(), cross_v3_v3v3(), EffectorData::distance, ELEM, PartDeflect::f_damp, PartDeflect::f_flow, PartDeflect::f_noise, PartDeflect::f_size, PartDeflect::f_strength, fabs(), EffectorData::falloff, PartDeflect::flag, PartDeflect::forcefield, EffectedPoint::loc, 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_FORCE, PFIELD_GLOBAL_CO, PFIELD_HARMONIC, PFIELD_LENNARDJ, PFIELD_MAGNET, PFIELD_SHAPE_POINT, PFIELD_TURBULENCE, PFIELD_VORTEX, PFIELD_WIND, pow(), PartDeflect::rng, EffectedPoint::rot, PartDeflect::shape, EffectorData::size, EffectedPoint::size, sqrt(), EffectorData::vec_to_point, EffectorData::vec_to_point2, EffectedPoint::vel, EffectedPoint::vel_to_sec, and wind_func().
Referenced by pdDoEffectors().
static void do_texture_effector | ( | EffectorCache * | eff, |
EffectorData * | efd, | ||
EffectedPoint * | point, | ||
float * | total_force | ||
) | [static] |
Definition at line 744 of file effect.c.
References add_v3_v3(), copy_v3_v3(), dot_v3v3(), PartDeflect::f_strength, EffectorData::falloff, PartDeflect::flag, Object::imat, EffectedPoint::loc, madd_v3_v3fl(), mul_m4_v3(), multitex_ext(), EffectorData::nor, TexResult::nor, NULL, EffectorCache::ob, EffectorCache::pd, PFIELD_TEX_2D, PFIELD_TEX_GRAD, PFIELD_TEX_OBJECT, PFIELD_TEX_RGB, TexResult::tb, PartDeflect::tex, PartDeflect::tex_mode, PartDeflect::tex_nabla, TexResult::tg, TexResult::tin, and TexResult::tr.
Referenced by pdDoEffectors().
static float eff_calc_visibility | ( | ListBase * | colliders, |
EffectorCache * | eff, | ||
EffectorData * | efd, | ||
EffectedPoint * | point | ||
) | [static] |
Definition at line 402 of file effect.c.
References PartDeflect::absorption, BLI_bvhtree_ray_cast(), CollisionModifierData::bvhtree, CLAMPIS, ColliderCache::collmd, BVHTreeRayHit::dist, eff_tri_ray_hit(), ListBase::first, PartDeflect::flag, free_collider_cache(), get_collider_cache(), BVHTreeRayHit::index, len(), EffectedPoint::loc, negate_v3_v3(), ColliderCache::next, norm(), normalize_v3(), NULL, EffectorCache::ob, ColliderCache::ob, EffectorCache::pd, Object::pd, PFIELD_VISIBILITY, EffectorCache::scene, and EffectorData::vec_to_point.
Referenced by pdDoEffectors().
static void eff_tri_ray_hit | ( | void * | UNUSEDuserData, |
int | UNUSEDindex, | ||
const BVHTreeRay * | UNUSEDray, | ||
BVHTreeRayHit * | hit | ||
) | [static] |
Definition at line 394 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 499 of file effect.c.
References ABS, EffectorData::distance, dot_v3v3(), 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_point, EffectorData::vec_to_point2, EffectorWeights::weight, and PartDeflect::zdir.
static float falloff_func | ( | float | fac, |
int | usemin, | ||
float | mindist, | ||
int | usemax, | ||
float | maxdist, | ||
float | power | ||
) | [static] |
Definition at line 474 of file effect.c.
References pow().
Referenced by falloff_func_dist(), and falloff_func_rad().
static float falloff_func_dist | ( | PartDeflect * | pd, |
float | fac | ||
) | [static] |
Definition at line 489 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 float falloff_func_rad | ( | PartDeflect * | pd, |
float | fac | ||
) | [static] |
Definition at line 494 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().
void free_partdeflect | ( | PartDeflect * | pd | ) |
Definition at line 158 of file effect.c.
References Tex::id, MEM_freeN(), PartDeflect::rng, rng_free(), PartDeflect::tex, and ID::us.
Referenced by free_object(), and psys_free_settings().
int get_effector_data | ( | EffectorCache * | eff, |
EffectorData * | efd, | ||
EffectedPoint * | point, | ||
int | real_velocity | ||
) |
Definition at line 571 of file effect.c.
References add_v3_v3(), add_v3_v3v3(), RenderData::cfra, closest_point_on_surface(), ParticleKey::co, copy_v3_v3(), Object::derivedFinal, EffectorData::distance, PartDeflect::f_size, EffectorCache::flag, PartDeflect::forcefield, DerivedMesh::getVertCo, DerivedMesh::getVertNo, EffectedPoint::index, EffectorData::index, len_v3(), EffectorData::loc, EffectedPoint::loc, mul_m4_v3(), mul_mat3_m4_v3(), mul_qt_v3(), mul_v3_fl(), 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_PLANE, PFIELD_SHAPE_POINTS, PFIELD_SHAPE_SURFACE, PFIELD_VORTEX, project_v3_v3v3(), ParticleSimulationData::psys, EffectedPoint::psys, EffectorCache::psys, psys_get_particle_state(), Scene::r, ParticleKey::rot, EffectorCache::scene, ParticleSimulationData::scene, PartDeflect::shape, EffectorData::size, ParticleData::size, state, sub_v3_v3v3(), EffectorCache::surmd, ParticleKey::time, EffectorData::vec_to_point, EffectorData::vec_to_point2, EffectorData::vel, ParticleKey::vel, EffectedPoint::vel, EffectedPoint::vel_to_frame, and EffectorCache::velocity.
Referenced by pdDoEffectors(), and rule_goal_avoid().
static void get_effector_tot | ( | EffectorCache * | eff, |
EffectorData * | efd, | ||
EffectedPoint * | point, | ||
int * | tot, | ||
int * | p, | ||
int * | step | ||
) | [static] |
Definition at line 698 of file effect.c.
References EffectorData::charge, Object::derivedFinal, ParticleSettings::effector_amount, PartDeflect::f_strength, PartDeflect::flag, PartDeflect::forcefield, EffectedPoint::index, EffectorData::index, DerivedMesh::numVertData, EffectorCache::ob, p, ParticleSystem::part, EffectorCache::pd, PFIELD_CHARGE, PFIELD_HARMONIC, PFIELD_MULTIPLE_SPRINGS, PFIELD_SHAPE_POINTS, EffectorCache::psys, PartDeflect::shape, and ParticleSystem::totpart.
Referenced by pdDoEffectors().
static EffectorCache* new_effector_cache | ( | Scene * | scene, |
Object * | ob, | ||
ParticleSystem * | psys, | ||
PartDeflect * | pd | ||
) | [static] |
Definition at line 211 of file effect.c.
References EffectorCache::frame, MEM_callocN(), EffectorCache::ob, EffectorCache::pd, precalculate_effector(), EffectorCache::psys, and EffectorCache::scene.
Referenced by add_object_to_effectors(), and add_particles_to_effectors().
PartDeflect* object_add_collision_fields | ( | int | type | ) | [read] |
Definition at line 117 of file effect.c.
References PartDeflect::f_damp, PartDeflect::f_flow, PartDeflect::f_size, PartDeflect::f_strength, PartDeflect::flag, PartDeflect::forcefield, MEM_callocN(), PartDeflect::pdef_sbdamp, PartDeflect::pdef_sbift, PartDeflect::pdef_sboft, PFIELD_DO_LOCATION, PFIELD_DO_ROTATION, PFIELD_SHAPE_PLANE, PFIELD_TEXTURE, PFIELD_VORTEX, PFIELD_WIND, PIL_check_seconds_timer(), PartDeflect::seed, PartDeflect::shape, and UndoElem::type.
Referenced by ED_object_modifier_add(), effector_add_type(), and forcefield_toggle_exec().
void pd_point_from_loc | ( | Scene * | scene, |
float * | loc, | ||
float * | vel, | ||
int | index, | ||
EffectedPoint * | point | ||
) |
Definition at line 358 of file effect.c.
References EffectedPoint::ave, EffectedPoint::flag, RenderData::frs_sec, EffectedPoint::index, EffectedPoint::loc, NULL, EffectedPoint::psys, Scene::r, EffectedPoint::rot, EffectedPoint::size, EffectedPoint::vel, EffectedPoint::vel_to_frame, and EffectedPoint::vel_to_sec.
Referenced by cloth_calc_force(), and dynamicPaint_prepareEffectStep().
void pd_point_from_particle | ( | ParticleSimulationData * | sim, |
ParticleData * | pa, | ||
ParticleKey * | state, | ||
EffectedPoint * | point | ||
) |
Definition at line 328 of file effect.c.
References ParticleKey::ave, EffectedPoint::ave, EffectedPoint::charge, ParticleKey::co, PartDeflect::f_strength, ParticleSettings::flag, EffectedPoint::flag, PartDeflect::forcefield, EffectedPoint::index, EffectedPoint::loc, NULL, ParticleSystem::part, PART_ROT_DYN, ParticleSystem::particles, ParticleSettings::pd, ParticleSettings::pd2, PFIELD_CHARGE, EffectedPoint::psys, ParticleSimulationData::psys, psys_get_timestep(), ParticleKey::rot, EffectedPoint::rot, ParticleData::size, EffectedPoint::size, ParticleKey::vel, EffectedPoint::vel, EffectedPoint::vel_to_frame, and EffectedPoint::vel_to_sec.
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 373 of file effect.c.
References EffectedPoint::ave, EffectedPoint::flag, RenderData::frs_sec, EffectedPoint::index, EffectedPoint::loc, NULL, PE_WIND_AS_SPEED, EffectedPoint::psys, Scene::r, EffectedPoint::rot, EffectedPoint::size, EffectedPoint::vel, EffectedPoint::vel_to_frame, and EffectedPoint::vel_to_sec.
Referenced by _scan_for_ext_spring_forces(), _softbody_calc_forces_slice_in_a_thread(), and softbody_calc_forces().
void pdDoEffectors | ( | ListBase * | effectors, |
ListBase * | colliders, | ||
EffectorWeights * | weights, | ||
EffectedPoint * | point, | ||
float * | force, | ||
float * | impulse | ||
) |
Definition at line 958 of file effect.c.
References add_v3_v3v3(), copy_v3_v3(), do_physical_effector(), do_texture_effector(), eff_calc_visibility(), effector_falloff(), EffectorData::falloff, ListBase::first, EffectorCache::flag, EffectedPoint::flag, PartDeflect::forcefield, get_effector_data(), get_effector_tot(), EffectorCache::next, p, EffectorCache::pd, PE_VELOCITY_TO_IMPULSE, PE_WIND_AS_SPEED, PFIELD_TEXTURE, step(), 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(), dynamicPaint_prepareEffectStep(), and softbody_calc_forces().
void pdEndEffectors | ( | ListBase ** | effectors | ) |
Definition at line 311 of file effect.c.
References BLI_freelistN(), EffectorCache::guide_data, MEM_freeN(), EffectorCache::next, and NULL.
Referenced by build_dag_object(), do_step_cloth(), dynamicPaint_prepareEffectStep(), psys_free(), psys_update_effectors(), sb_sfesf_threads_run(), scan_for_ext_spring_forces(), softbody_calc_forces(), and softbody_calc_forcesEx().
ListBase* pdInitEffectors | ( | Scene * | scene, |
Object * | ob_src, | ||
ParticleSystem * | psys_src, | ||
EffectorWeights * | weights | ||
) | [read] |
Definition at line 270 of file effect.c.
References add_object_to_effectors(), add_particles_to_effectors(), Scene::base, ListBase::first, PartDeflect::forcefield, Group::gobject, EffectorWeights::group, Base::lay, Object::lay, Base::next, ParticleSystem::next, GroupObject::next, NULL, GroupObject::ob, Base::object, Object::particlesystem, and Object::pd.
Referenced by build_dag_object(), do_step_cloth(), dynamicPaint_prepareEffectStep(), psys_update_effectors(), sb_sfesf_threads_run(), scan_for_ext_spring_forces(), softbody_calc_forces(), and softbody_calc_forcesEx().
static void precalculate_effector | ( | EffectorCache * | eff | ) | [static] |
Definition at line 172 of file effect.c.
References RenderData::cfra, copy_v3_v3(), CU_PATH, Object::data, Path::data, eModifierType_Surface, Curve::flag, EffectorCache::flag, PartDeflect::forcefield, EffectorCache::guide_dir, EffectorCache::guide_loc, EffectorCache::guide_radius, makeDispListCurveTypes(), modifiers_findByType(), mul_m4_v3(), mul_mat3_m4_v3(), NULL, EffectorCache::ob, OB_CURVE, Object::obmat, Curve::path, EffectorCache::pd, PE_USE_NORMAL_DATA, PFIELD_GUIDE, PFIELD_SHAPE_SURFACE, EffectorCache::psys, psys_update_particle_tree(), Scene::r, PartDeflect::rng, rng_new(), rng_srandom(), EffectorCache::scene, PartDeflect::seed, PartDeflect::shape, sub_v3_v3v3(), EffectorCache::surmd, Object::type, EffectorCache::velocity, where_is_object_time(), and where_on_path().
Referenced by new_effector_cache().
static float wind_func | ( | struct RNG * | rng, |
float | strength | ||
) | [static] |
Definition at line 457 of file effect.c.
References random(), rng_getFloat(), rng_getInt(), and TNT::sign().
Referenced by do_physical_effector().