Blender  V3.3
DNA_boid_types.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2009 by Janne Karhu. All rights reserved. */
3 
8 #pragma once
9 
10 #include "DNA_listBase.h"
11 
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15 
16 typedef enum eBoidRuleType {
34 #if 0
36  eBoidRuleType_Protect = 9,
38  eBoidRuleType_Hide = 10,
40  eBoidRuleType_FollowPath = 11,
42  eBoidRuleType_FollowWall = 12,
43 #endif
45 
46 /* boidrule->flag */
47 #define BOIDRULE_CURRENT (1 << 0)
48 #define BOIDRULE_IN_AIR (1 << 2)
49 #define BOIDRULE_ON_LAND (1 << 3)
50 typedef struct BoidRule {
51  struct BoidRule *next, *prev;
52  int type, flag;
53  char name[32];
55 #define BRULE_GOAL_AVOID_PREDICT (1 << 0)
56 #define BRULE_GOAL_AVOID_ARRIVE (1 << 1)
57 #define BRULE_GOAL_AVOID_SIGNAL (1 << 2)
58 typedef struct BoidRuleGoalAvoid {
60  struct Object *ob;
61  int options;
62  float fear_factor;
63 
64  /* signals */
67 #define BRULE_ACOLL_WITH_BOIDS (1 << 0)
68 #define BRULE_ACOLL_WITH_DEFLECTORS (1 << 1)
69 typedef struct BoidRuleAvoidCollision {
71  int options;
72  float look_ahead;
74 #define BRULE_LEADER_IN_LINE (1 << 0)
75 typedef struct BoidRuleFollowLeader {
77  struct Object *ob;
78  float loc[3], oloc[3];
79  float cfra, distance;
82 typedef struct BoidRuleAverageSpeed {
84  float wander, level, speed;
85  char _pad0[4];
87 typedef struct BoidRuleFight {
91 
92 typedef enum eBoidMode {
99 
100 typedef struct BoidData {
101  float health, acc[3];
102  short state_id, mode;
104 
105 // planned for near future
106 // typedef enum BoidConditionMode {
107 // eBoidConditionType_Then = 0,
108 // eBoidConditionType_And = 1,
109 // eBoidConditionType_Or = 2,
110 // NUM_BOID_CONDITION_MODES
111 //} BoidConditionMode;
112 // typedef enum BoidConditionType {
113 // eBoidConditionType_None = 0,
114 // eBoidConditionType_Signal = 1,
115 // eBoidConditionType_NoSignal = 2,
116 // eBoidConditionType_HealthBelow = 3,
117 // eBoidConditionType_HealthAbove = 4,
118 // eBoidConditionType_See = 5,
119 // eBoidConditionType_NotSee = 6,
120 // eBoidConditionType_StateTime = 7,
121 // eBoidConditionType_Touching = 8,
122 // NUM_BOID_CONDITION_TYPES
123 //} BoidConditionType;
124 // typedef struct BoidCondition {
125 // struct BoidCondition *next, *prev;
126 // int state_id;
127 // short type, mode;
128 // float threshold, probability;
129 //
130 // /* signals */
131 // int signal_id, channels;
132 //} BoidCondition;
133 
134 typedef enum eBoidRulesetType {
139 #define BOIDSTATE_CURRENT 1
140 typedef struct BoidState {
141  struct BoidState *next, *prev;
145  char name[32];
146  int id, flag;
147 
148  /* rules */
151 
152  /* signal */
154  float volume, falloff;
156 
157 // planned for near future
158 // typedef struct BoidSignal {
159 // struct BoidSignal *next, *prev;
160 // float loc[3];
161 // float volume, falloff;
162 // int id;
163 //} BoidSignal;
164 // typedef struct BoidSignalDefine {
165 // struct BoidSignalDefine *next, *prev;
166 // int id, _pad[4];
167 // char name[32];
168 //} BoidSignalDefine;
169 
170 // typedef struct BoidSimulationData {
171 // ListBase signal_defines;/* list of defined signals */
172 // ListBase signals[20]; /* gathers signals from all channels */
173 // struct KDTree_3d *signaltrees[20];
174 // char channel_names[20][32];
175 // int last_signal_id; /* used for incrementing signal ids */
176 // int flag; /* switches for drawing stuff */
177 //} BoidSimulationData;
178 
179 typedef struct BoidSettings {
181 
183  float banking, pitch;
184 
187 
188  /* flying related */
192 
193  /* walk/run related */
198 
199  struct ListBase states;
201 
202 /* boidsettings->options */
203 #define BOID_ALLOW_FLIGHT (1 << 0)
204 #define BOID_ALLOW_LAND (1 << 1)
205 #define BOID_ALLOW_CLIMB (1 << 2)
206 
207 /* boidrule->options */
208 //#define BOID_RULE_FOLLOW_LINE (1 << 0) /* follow leader */
209 //#define BOID_RULE_PREDICT (1 << 1) /* goal/avoid */
210 //#define BOID_RULE_ARRIVAL (1 << 2) /* goal */
211 //#define BOID_RULE_LAND (1 << 3) /* goal */
212 //#define BOID_RULE_WITH_BOIDS (1 << 4) /* avoid collision */
213 //#define BOID_RULE_WITH_DEFLECTORS (1 << 5) /* avoid collision */
214 
215 #ifdef __cplusplus
216 }
217 #endif
struct BoidRuleGoalAvoid BoidRuleGoalAvoid
eBoidMode
@ eBoidMode_OnLand
@ eBoidMode_Liftoff
@ eBoidMode_Climbing
@ eBoidMode_Falling
@ eBoidMode_InAir
struct BoidRuleFight BoidRuleFight
struct BoidRuleAvoidCollision BoidRuleAvoidCollision
struct BoidRuleAverageSpeed BoidRuleAverageSpeed
eBoidRulesetType
@ eBoidRulesetType_Average
@ eBoidRulesetType_Fuzzy
@ eBoidRulesetType_Random
struct BoidData BoidData
struct BoidRule BoidRule
struct BoidSettings BoidSettings
struct BoidRuleFollowLeader BoidRuleFollowLeader
struct BoidState BoidState
eBoidRuleType
@ eBoidRuleType_Flock
@ eBoidRuleType_Separate
@ eBoidRuleType_Goal
@ eBoidRuleType_None
@ eBoidRuleType_Fight
@ eBoidRuleType_Avoid
@ eBoidRuleType_FollowLeader
@ eBoidRuleType_AvoidCollision
@ eBoidRuleType_AverageSpeed
These structs are the foundation for all linked lists in the library system.
short state_id
float health
float acc[3]
struct Object * ob
struct Object * ob
struct BoidRule * next
struct BoidRule * prev
char name[32]
float land_max_speed
struct ListBase states
float landing_smoothness
float land_jump_speed
float land_stick_force
float air_personal_space
float land_personal_space
ListBase conditions
char name[32]
struct BoidState * prev
ListBase actions
float rule_fuzziness
ListBase rules
struct BoidState * next