Blender V2.61 - r43446
Classes | Typedefs | Functions | Variables

boids.c File Reference

#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.

Classes

struct  BoidValues

Typedefs

typedef struct BoidValues BoidValues
typedef int(* boid_rule_cb )(BoidRule *rule, BoidBrainData *data, BoidValues *val, ParticleData *pa)

Functions

static int apply_boid_rule (BoidBrainData *bbd, BoidRule *rule, BoidValues *val, ParticleData *pa, float fuzziness)
static int rule_none (BoidRule *UNUSED(rule), BoidBrainData *UNUSED(data), BoidValues *UNUSED(val), ParticleData *UNUSED(pa))
static int rule_goal_avoid (BoidRule *rule, BoidBrainData *bbd, BoidValues *val, ParticleData *pa)
static int rule_avoid_collision (BoidRule *rule, BoidBrainData *bbd, BoidValues *val, ParticleData *pa)
static int rule_separate (BoidRule *UNUSED(rule), BoidBrainData *bbd, BoidValues *val, ParticleData *pa)
static int rule_flock (BoidRule *UNUSED(rule), BoidBrainData *bbd, BoidValues *UNUSED(val), ParticleData *pa)
static int rule_follow_leader (BoidRule *rule, BoidBrainData *bbd, BoidValues *val, ParticleData *pa)
static int rule_average_speed (BoidRule *rule, BoidBrainData *bbd, BoidValues *val, ParticleData *pa)
static int rule_fight (BoidRule *rule, BoidBrainData *bbd, BoidValues *val, ParticleData *pa)
static void set_boid_values (BoidValues *val, BoidSettings *boids, ParticleData *pa)
static Objectboid_find_ground (BoidBrainData *bbd, ParticleData *pa, float ground_co[3], float ground_nor[3])
static int boid_rule_applies (ParticleData *pa, BoidSettings *UNUSED(boids), BoidRule *rule)
void boids_precalc_rules (ParticleSettings *part, float cfra)
static void boid_climb (BoidSettings *boids, ParticleData *pa, float *surface_co, float *surface_nor)
static float boid_goal_signed_dist (float *boid_co, float *goal_co, float *goal_nor)
static BoidStateget_boid_state (BoidSettings *boids, ParticleData *pa)
void boid_brain (BoidBrainData *bbd, int p, ParticleData *pa)
void boid_body (BoidBrainData *bbd, ParticleData *pa)
BoidRuleboid_new_rule (int type)
void boid_default_settings (BoidSettings *boids)
BoidStateboid_new_state (BoidSettings *boids)
BoidStateboid_duplicate_state (BoidSettings *boids, BoidState *state)
void boid_free_settings (BoidSettings *boids)
BoidSettingsboid_copy_settings (BoidSettings *boids)
BoidStateboid_get_current_state (BoidSettings *boids)

Variables

static boid_rule_cb boid_rules []

Detailed Description

Definition in file boids.c.


Typedef Documentation

typedef int(* boid_rule_cb)(BoidRule *rule, BoidBrainData *data, BoidValues *val, ParticleData *pa)

Definition at line 703 of file boids.c.

typedef struct BoidValues BoidValues

Function Documentation

static int apply_boid_rule ( BoidBrainData bbd,
BoidRule rule,
BoidValues val,
ParticleData pa,
float  fuzziness 
) [static]
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 
)
static void boid_climb ( BoidSettings boids,
ParticleData pa,
float *  surface_co,
float *  surface_nor 
) [static]
BoidSettings* boid_copy_settings ( BoidSettings boids)
void boid_default_settings ( BoidSettings boids)
BoidState* boid_duplicate_state ( BoidSettings boids,
BoidState state 
)
static Object* boid_find_ground ( BoidBrainData bbd,
ParticleData pa,
float  ground_co[3],
float  ground_nor[3] 
) [static]
void boid_free_settings ( BoidSettings boids)
BoidState* boid_get_current_state ( BoidSettings boids)
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)
BoidState* boid_new_state ( BoidSettings boids)
static int boid_rule_applies ( ParticleData pa,
BoidSettings UNUSEDboids,
BoidRule rule 
) [static]
void boids_precalc_rules ( ParticleSettings part,
float  cfra 
)
static BoidState* get_boid_state ( BoidSettings boids,
ParticleData pa 
) [static]
static int rule_average_speed ( BoidRule rule,
BoidBrainData bbd,
BoidValues val,
ParticleData pa 
) [static]
static int rule_avoid_collision ( BoidRule rule,
BoidBrainData bbd,
BoidValues val,
ParticleData pa 
) [static]
static int rule_fight ( BoidRule rule,
BoidBrainData bbd,
BoidValues val,
ParticleData pa 
) [static]
static int rule_flock ( BoidRule UNUSEDrule,
BoidBrainData bbd,
BoidValues UNUSEDval,
ParticleData pa 
) [static]
static int rule_follow_leader ( BoidRule rule,
BoidBrainData bbd,
BoidValues val,
ParticleData pa 
) [static]
static int rule_goal_avoid ( BoidRule rule,
BoidBrainData bbd,
BoidValues val,
ParticleData pa 
) [static]
static int rule_none ( BoidRule UNUSEDrule,
BoidBrainData UNUSEDdata,
BoidValues UNUSEDval,
ParticleData UNUSEDpa 
) [static]

Definition at line 64 of file boids.c.

static int rule_separate ( BoidRule UNUSEDrule,
BoidBrainData bbd,
BoidValues val,
ParticleData pa 
) [static]
static void set_boid_values ( BoidValues val,
BoidSettings boids,
ParticleData pa 
) [static]

Variable Documentation