Blender V2.61 - r43446
|
#include <string.h>
#include <math.h>
#include "MEM_guardedalloc.h"
#include "DNA_object_force.h"
#include "DNA_scene_types.h"
#include "BLI_rand.h"
#include "BLI_math.h"
#include "BLI_blenlib.h"
#include "BLI_kdtree.h"
#include "BLI_utildefines.h"
#include "BKE_collision.h"
#include "BKE_effect.h"
#include "BKE_boids.h"
#include "BKE_particle.h"
#include "BKE_modifier.h"
#include "RNA_enum_types.h"
Go to the source code of this file.
Definition in file boids.c.
typedef int(* boid_rule_cb)(BoidRule *rule, BoidBrainData *data, BoidValues *val, ParticleData *pa) |
typedef struct BoidValues BoidValues |
static int apply_boid_rule | ( | BoidBrainData * | bbd, |
BoidRule * | rule, | ||
BoidValues * | val, | ||
ParticleData * | pa, | ||
float | fuzziness | ||
) | [static] |
Definition at line 891 of file boids.c.
References boid_rule_applies(), ParticleSettings::boids, compare_len_v3v3(), len_v3(), NULL, BoidBrainData::part, ParticleData::prev_state, BoidRule::type, ParticleKey::vel, and BoidBrainData::wanted_co.
Referenced by boid_brain().
void boid_body | ( | BoidBrainData * | bbd, |
ParticleData * | pa | ||
) |
* gather apparent gravity to r_ve */
* raise boid it's size from surface */
* remove normal component from velocity */
Definition at line 1081 of file boids.c.
References BoidData::acc, add_v3_v3(), angle(), ParticleKey::ave, axis_angle_to_quat(), BoidSettings::banking, BLI_frand(), ParticleData::boid, BOID_ALLOW_FLIGHT, BOID_ALLOW_LAND, boid_climb(), boid_find_ground(), boid_goal_signed_dist(), ParticleSettings::boids, ParticleKey::co, ParticleSimulationData::colliders, copy_particle_key(), copy_qt_qt(), copy_v2_v2(), copy_v3_v3(), cross_v3_v3v3(), ParticleSettings::dampfac, BoidParticle::data, BoidBrainData::dfra, dot_v2v2(), dot_v3v3(), eBoidMode_Climbing, eBoidMode_Falling, eBoidMode_InAir, eBoidMode_Liftoff, eBoidMode_OnLand, ParticleSettings::effector_weights, ParticleSystem::effectors, ELEM, ParticleSettings::flag, BoidBrainData::goal_co, BoidBrainData::goal_nor, BoidBrainData::goal_ob, PhysicsSettings::gravity, BoidParticle::gravity, BoidParticle::ground, BoidSettings::height, BoidSettings::land_stick_force, BoidSettings::landing_smoothness, len_v3(), length(), madd_v3_v3fl(), madd_v3_v3v3fl(), ParticleSettings::mass, mat3_to_quat_is_ok(), MAX2, BoidValues::max_acc, BoidValues::max_ave, BoidValues::max_speed, MIN2, BoidValues::min_speed, BoidData::mode, mul_qt_v3(), mul_v2_fl(), mul_v3_fl(), negate_v3(), negate_v3_v3(), normalize_v2(), normalize_v3(), normalize_v3_v3(), NULL, BoidSettings::options, BoidBrainData::part, PART_SIZEMASS, pd_point_from_particle(), pdDoEffectors(), Scene::physics_settings, BoidSettings::pitch, ParticleData::prev_state, project_v3_v3v3(), ParticleSimulationData::psys, psys_uses_gravity(), MakeCursor::root, ParticleKey::rot, saacos(), sasqrt(), ParticleSimulationData::scene, set_boid_values(), BoidBrainData::sim, ParticleData::size, ParticleData::state, sub_v3_v3v3(), BoidBrainData::timestep, simple_enum_gen::val, ParticleKey::vel, BoidBrainData::wanted_co, and BoidBrainData::wanted_speed.
Referenced by dynamics_step().
void boid_brain | ( | BoidBrainData * | bbd, |
int | p, | ||
ParticleData * | pa | ||
) |
Definition at line 930 of file boids.c.
References add_v2_v2v2(), add_v3_v3(), ParticleData::alive, apply_boid_rule(), ParticleKey::ave, BLI_countlist(), BLI_findlink(), ParticleData::boid, BOID_ALLOW_FLIGHT, ParticleSettings::boids, BoidBrainData::cfra, copy_v3_v3(), BoidParticle::data, ParticleData::dietime, dot_v2v2(), eBoidMode_Falling, eBoidMode_Liftoff, eBoidMode_OnLand, eBoidRulesetType_Average, eBoidRulesetType_Fuzzy, eBoidRulesetType_Random, ListBase::first, get_boid_state(), PhysicsSettings::gravity, BoidData::health, BoidValues::jump_speed, len(), len_v2(), BoidValues::max_speed, MIN2, BoidData::mode, mul(), mul_v3_fl(), BoidRule::next, normalize_v2(), normalize_v3(), BoidSettings::options, PARS_DYING, BoidBrainData::part, Scene::physics_settings, ParticleData::prev_state, ParticleSimulationData::psys, PSYS_FRAND, BoidState::rule_fuzziness, BoidState::rules, BoidState::ruleset_type, sasqrt(), ParticleSimulationData::scene, ParticleSystem::seed, set_boid_values(), BoidBrainData::sim, state, simple_enum_gen::val, ParticleKey::vel, BoidBrainData::wanted_co, and BoidBrainData::wanted_speed.
Referenced by dynamics_step().
static void boid_climb | ( | BoidSettings * | boids, |
ParticleData * | pa, | ||
float * | surface_co, | ||
float * | surface_nor | ||
) | [static] |
Definition at line 864 of file boids.c.
References add_v3_v3v3(), ParticleData::boid, ParticleKey::co, copy_v3_v3(), BoidParticle::gravity, BoidSettings::height, madd_v3_v3fl(), mul_v3_fl(), normalize_v3(), project_v3_v3v3(), ParticleData::size, ParticleData::state, sub_v3_v3v3(), and ParticleKey::vel.
Referenced by boid_body().
BoidSettings* boid_copy_settings | ( | BoidSettings * | boids | ) |
Definition at line 1545 of file boids.c.
References BoidState::actions, BLI_duplicatelist(), BoidState::conditions, ListBase::first, MEM_dupallocN(), BoidState::next, NULL, BoidState::rules, state, and BoidSettings::states.
Referenced by psys_copy_settings().
void boid_default_settings | ( | BoidSettings * | boids | ) |
Definition at line 1474 of file boids.c.
References BoidSettings::accuracy, BoidSettings::aggression, BoidSettings::air_max_acc, BoidSettings::air_max_ave, BoidSettings::air_max_speed, BoidSettings::air_personal_space, BoidSettings::banking, BOID_ALLOW_FLIGHT, BoidSettings::health, BoidSettings::height, BoidSettings::land_max_acc, BoidSettings::land_max_ave, BoidSettings::land_max_speed, BoidSettings::land_personal_space, BoidSettings::landing_smoothness, BoidSettings::options, BoidSettings::pitch, BoidSettings::range, and BoidSettings::strength.
Referenced by psys_prepare_physics().
BoidState* boid_duplicate_state | ( | BoidSettings * | boids, |
BoidState * | state | ||
) |
Definition at line 1517 of file boids.c.
References BoidState::actions, BLI_duplicatelist(), BoidState::conditions, BoidState::id, BoidSettings::last_state_id, MEM_dupallocN(), and BoidState::rules.
static Object* boid_find_ground | ( | BoidBrainData * | bbd, |
ParticleData * | pa, | ||
float | ground_co[3], | ||
float | ground_nor[3] | ||
) | [static] |
Definition at line 744 of file boids.c.
References add_v3_v3(), add_v3_v3v3(), BKE_psys_collision_neartest_cb(), BLI_bvhtree_ray_cast(), ParticleData::boid, CollisionModifierData::bvhtree, closest_point_on_surface(), ParticleKey::co, ParticleCollision::co1, ParticleCollision::co2, ParticleSimulationData::colliders, ColliderCache::collmd, copy_v3_v3(), ParticleCollision::current, BoidParticle::data, BVHTreeRayHit::dist, eBoidMode_Climbing, eModifierType_Surface, ParticleCollision::f, ParticleCollision::fac1, ParticleCollision::fac2, ListBase::first, BoidParticle::ground, ParticleCollision::hit, BVHTreeRayHit::index, ParticleCollisionElement::inside, interp_v3_v3v3(), len_v3(), ParticleCollision::md, BoidData::mode, modifiers_findByType(), ColliderCache::next, ParticleCollisionElement::nor, normalize_v3_v3(), NULL, ColliderCache::ob, ParticleCollision::original_ray_length, ParticleCollision::pce, BoidBrainData::sim, ParticleData::state, sub_v3_v3(), and sub_v3_v3v3().
Referenced by boid_body().
void boid_free_settings | ( | BoidSettings * | boids | ) |
Definition at line 1529 of file boids.c.
References BoidState::actions, BLI_freelistN(), BoidState::conditions, ListBase::first, MEM_freeN(), BoidState::next, BoidState::rules, state, and BoidSettings::states.
Referenced by psys_free_settings().
BoidState* boid_get_current_state | ( | BoidSettings * | boids | ) |
Definition at line 1568 of file boids.c.
References BOIDSTATE_CURRENT, ListBase::first, BoidState::flag, BoidState::next, state, and BoidSettings::states.
Referenced by rule_add_exec(), rule_del_exec(), rule_move_down_exec(), and rule_move_up_exec().
static float boid_goal_signed_dist | ( | float * | boid_co, |
float * | goal_co, | ||
float * | goal_nor | ||
) | [static] |
Definition at line 882 of file boids.c.
References dot_v3v3(), and sub_v3_v3v3().
Referenced by boid_body().
BoidRule* boid_new_rule | ( | int | type | ) |
Definition at line 1435 of file boids.c.
References BLI_strncpy(), BOIDRULE_IN_AIR, BOIDRULE_ON_LAND, boidrule_type_items, eBoidRuleType_AverageSpeed, eBoidRuleType_Avoid, eBoidRuleType_AvoidCollision, eBoidRuleType_Fight, eBoidRuleType_FollowLeader, eBoidRuleType_Goal, BoidRule::flag, MEM_callocN(), BoidRule::name, EnumPropertyItem::name, NULL, and BoidRule::type.
Referenced by psys_prepare_physics(), and rule_add_exec().
BoidState* boid_new_state | ( | BoidSettings * | boids | ) |
Definition at line 1500 of file boids.c.
References BLI_snprintf(), BoidState::channels, BoidState::id, BoidSettings::last_state_id, MEM_callocN(), BoidState::name, BoidState::rule_fuzziness, state, and BoidState::volume.
Referenced by psys_prepare_physics(), state_add_exec(), and state_del_exec().
static int boid_rule_applies | ( | ParticleData * | pa, |
BoidSettings * | UNUSEDboids, | ||
BoidRule * | rule | ||
) | [static] |
Definition at line 830 of file boids.c.
References ParticleData::boid, BOIDRULE_IN_AIR, BOIDRULE_ON_LAND, BoidParticle::data, eBoidMode_Climbing, eBoidMode_InAir, eBoidMode_OnLand, ELEM, BoidRule::flag, BoidData::mode, and NULL.
Referenced by apply_boid_rule().
void boids_precalc_rules | ( | ParticleSettings * | part, |
float | cfra | ||
) |
Definition at line 845 of file boids.c.
References ParticleSettings::boids, BoidRuleFollowLeader::cfra, copy_v3_v3(), eBoidRuleType_FollowLeader, ListBase::first, BoidRuleFollowLeader::loc, BoidState::next, BoidRule::next, BoidRuleFollowLeader::ob, Object::obmat, BoidRuleFollowLeader::oloc, BoidState::rules, state, BoidSettings::states, and BoidRule::type.
Referenced by dynamics_step().
static BoidState* get_boid_state | ( | BoidSettings * | boids, |
ParticleData * | pa | ||
) | [static] |
Definition at line 907 of file boids.c.
References ParticleData::boid, BoidParticle::data, ListBase::first, BoidState::id, BoidState::next, state, BoidData::state_id, and BoidSettings::states.
Referenced by boid_brain().
static int rule_average_speed | ( | BoidRule * | rule, |
BoidBrainData * | bbd, | ||
BoidValues * | val, | ||
ParticleData * | pa | ||
) | [static] |
Definition at line 552 of file boids.c.
References add_v3_v3(), ParticleKey::ave, BLI_frand(), ParticleData::boid, copy_v3_v3(), dot_v2v2(), PhysicsSettings::gravity, BoidRuleAverageSpeed::level, BoidValues::max_speed, mul_qt_v3(), mul_v3_fl(), normalize_v3(), Scene::physics_settings, ParticleData::prev_state, project_v3_v3v3(), psys_uses_gravity(), ParticleKey::rot, ParticleSimulationData::scene, BoidBrainData::sim, BoidRuleAverageSpeed::speed, sub_v3_v3(), BoidParticle::wander, BoidRuleAverageSpeed::wander, BoidBrainData::wanted_co, and BoidBrainData::wanted_speed.
static int rule_avoid_collision | ( | BoidRule * | rule, |
BoidBrainData * | bbd, | ||
BoidValues * | val, | ||
ParticleData * | pa | ||
) | [static] |
Definition at line 188 of file boids.c.
References add_v3_v3v3(), ParticleKey::ave, BKE_psys_collision_neartest_cb(), BLI_bvhtree_ray_cast(), BLI_frand(), BLI_kdtree_range_search(), ParticleData::boid, BRULE_ACOLL_WITH_BOIDS, BRULE_ACOLL_WITH_DEFLECTORS, CollisionModifierData::bvhtree, ParticleKey::co, ParticleCollision::co1, ParticleCollision::co2, ParticleSimulationData::colliders, ColliderCache::collmd, copy_v3_v3(), ParticleCollision::current, BVHTreeRayHit::dist, dot_v3v3(), ParticleCollision::f, ListBase::first, BoidParticle::ground, KDTreeNearest::index, BVHTreeRayHit::index, len(), len_v3(), BoidRuleAvoidCollision::look_ahead, madd_v3_v3fl(), MAX2, ParticleCollision::md, MEM_freeN(), BoidValues::min_speed, mul_v3_fl(), ParticleTarget::next, ColliderCache::next, ParticleCollisionElement::nor, normalize_v3(), NULL, ParticleSimulationData::ob, ColliderCache::ob, BoidRuleAvoidCollision::options, ParticleCollision::original_ray_length, ParticleSystem::particles, ParticleCollision::pce, BoidValues::personal_space, ParticleData::prev_state, ParticleSimulationData::psys, psys_get_target_system(), BoidBrainData::sim, ParticleData::size, sqrtf, sub_v3_v3v3(), ParticleSystem::targets, ParticleSystem::tree, ParticleKey::vel, BoidBrainData::wanted_co, and BoidBrainData::wanted_speed.
static int rule_fight | ( | BoidRule * | rule, |
BoidBrainData * | bbd, | ||
BoidValues * | val, | ||
ParticleData * | pa | ||
) | [static] |
Definition at line 605 of file boids.c.
References BoidSettings::accuracy, BoidSettings::aggression, ParticleKey::ave, BLI_frand(), BLI_kdtree_range_search(), ParticleData::boid, ParticleSettings::boids, ParticleKey::co, co, copy_v3_v3(), BoidParticle::data, KDTreeNearest::dist, BoidRuleFight::distance, dot_v3v3(), ListBase::first, BoidSettings::health, BoidData::health, KDTreeNearest::index, BoidValues::max_speed, MEM_freeN(), ParticleTarget::mode, negate_v3(), ParticleTarget::next, normalize_v3_v3(), NULL, ParticleSimulationData::ob, ParticleSystem::part, BoidBrainData::part, ParticleSystem::particles, ParticleData::prev_state, ParticleSimulationData::psys, psys_get_target_system(), PTARGET_MODE_ENEMY, PTARGET_MODE_FRIEND, BoidBrainData::sim, ParticleData::size, BoidSettings::strength, sub_v3_v3v3(), ParticleSystem::targets, BoidBrainData::timestep, ParticleSystem::tree, BoidBrainData::wanted_co, and BoidBrainData::wanted_speed.
static int rule_flock | ( | BoidRule * | UNUSEDrule, |
BoidBrainData * | bbd, | ||
BoidValues * | UNUSEDval, | ||
ParticleData * | pa | ||
) | [static] |
Definition at line 390 of file boids.c.
References add_v3_v3(), ParticleKey::ave, BLI_kdtree_find_n_nearest(), ParticleKey::co, KDTreeNearest::index, len_v3(), mul_v3_fl(), ParticleSystem::particles, ParticleData::prev_state, ParticleSimulationData::psys, BoidBrainData::sim, ParticleData::state, sub_v3_v3(), ParticleSystem::tree, ParticleKey::vel, BoidBrainData::wanted_co, and BoidBrainData::wanted_speed.
static int rule_follow_leader | ( | BoidRule * | rule, |
BoidBrainData * | bbd, | ||
BoidValues * | val, | ||
ParticleData * | pa | ||
) | [static] |
Definition at line 418 of file boids.c.
References BRULE_LEADER_IN_LINE, ParticleKey::co, copy_v3_v3(), BoidRuleFollowLeader::distance, dot_v3v3(), i, len(), len_v3(), BoidRuleFollowLeader::loc, madd_v3_v3fl(), BoidValues::max_speed, mul(), mul_v3_fl(), BoidRuleFollowLeader::ob, BoidRuleFollowLeader::oloc, BoidRuleFollowLeader::options, p, ParticleSystem::particles, ParticleData::prev_state, ParticleSimulationData::psys, BoidRuleFollowLeader::queue_size, BoidBrainData::sim, ParticleData::size, sub_v3_v3v3(), BoidBrainData::timestep, ParticleSystem::totpart, ParticleKey::vel, BoidBrainData::wanted_co, and BoidBrainData::wanted_speed.
static int rule_goal_avoid | ( | BoidRule * | rule, |
BoidBrainData * | bbd, | ||
BoidValues * | val, | ||
ParticleData * | pa | ||
) | [static] |
Definition at line 69 of file boids.c.
References add_v3_v3(), ParticleData::boid, BOID_ALLOW_CLIMB, ParticleSettings::boids, BRULE_GOAL_AVOID_PREDICT, ParticleKey::co, copy_v3_v3(), BoidParticle::data, EffectorData::distance, eBoidMode_Climbing, eBoidRuleType_Avoid, eBoidRuleType_Goal, effector_falloff(), ParticleSettings::effector_weights, ParticleSystem::effectors, PartDeflect::f_strength, BoidRuleGoalAvoid::fear_factor, ListBase::first, PartDeflect::forcefield, get_effector_data(), BoidBrainData::goal_co, BoidBrainData::goal_nor, BoidBrainData::goal_ob, BoidBrainData::goal_priority, BoidParticle::gravity, BoidParticle::ground, BoidSettings::height, BoidSettings::landing_smoothness, len(), len_v3(), EffectorData::loc, BoidValues::max_speed, BoidData::mode, mul(), mul_v3_fl(), negate_v3_v3(), EffectorCache::next, EffectorData::nor, NULL, EffectorCache::ob, BoidRuleGoalAvoid::ob, BoidSettings::options, BoidRuleGoalAvoid::options, BoidBrainData::part, EffectorCache::pd, pd_point_from_particle(), PFIELD_BOID, PFIELD_SHAPE_SURFACE, powf, ParticleData::prev_state, ParticleSimulationData::psys, EffectorCache::scene, ParticleSimulationData::scene, PartDeflect::shape, BoidBrainData::sim, ParticleData::size, ParticleData::state, sub_v3_v3v3(), BoidBrainData::timestep, BoidRule::type, EffectorData::vec_to_point, EffectorData::vel, ParticleKey::vel, BoidBrainData::wanted_co, and BoidBrainData::wanted_speed.
static int rule_none | ( | BoidRule * | UNUSEDrule, |
BoidBrainData * | UNUSEDdata, | ||
BoidValues * | UNUSEDval, | ||
ParticleData * | UNUSEDpa | ||
) | [static] |
static int rule_separate | ( | BoidRule * | UNUSEDrule, |
BoidBrainData * | bbd, | ||
BoidValues * | val, | ||
ParticleData * | pa | ||
) | [static] |
Definition at line 350 of file boids.c.
References add_v3_v3(), BLI_kdtree_range_search(), ParticleKey::co, KDTreeNearest::co, KDTreeNearest::dist, ListBase::first, KDTreeNearest::index, len(), BoidValues::max_speed, MEM_freeN(), mul_v3_fl(), ParticleTarget::next, NULL, ParticleSimulationData::ob, ParticleSystem::particles, BoidValues::personal_space, ParticleData::prev_state, ParticleSimulationData::psys, psys_get_target_system(), BoidBrainData::sim, ParticleData::size, ParticleData::state, sub_v3_v3v3(), ParticleSystem::targets, ParticleSystem::tree, BoidBrainData::wanted_co, and BoidBrainData::wanted_speed.
static void set_boid_values | ( | BoidValues * | val, |
BoidSettings * | boids, | ||
ParticleData * | pa | ||
) | [static] |
Definition at line 722 of file boids.c.
References BoidSettings::air_max_acc, BoidSettings::air_max_ave, BoidSettings::air_max_speed, BoidSettings::air_min_speed, BoidSettings::air_personal_space, ParticleData::boid, BoidParticle::data, eBoidMode_Climbing, eBoidMode_OnLand, ELEM, BoidSettings::health, BoidData::health, BoidValues::jump_speed, BoidSettings::land_jump_speed, BoidSettings::land_max_acc, BoidSettings::land_max_ave, BoidSettings::land_max_speed, BoidSettings::land_personal_space, M_PI, BoidValues::max_acc, BoidValues::max_ave, BoidValues::max_speed, BoidValues::min_speed, BoidData::mode, and BoidValues::personal_space.
Referenced by boid_body(), and boid_brain().
boid_rule_cb boid_rules[] [static] |