Blender  V2.93
DNA_boid_types.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2009 by Janne Karhu.
17  * All rights reserved.
18  */
19 
24 #pragma once
25 
26 #include "DNA_listBase.h"
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
32 typedef enum eBoidRuleType {
50 #if 0
52  eBoidRuleType_Protect = 9,
54  eBoidRuleType_Hide = 10,
56  eBoidRuleType_FollowPath = 11,
58  eBoidRuleType_FollowWall = 12,
59 #endif
61 
62 /* boidrule->flag */
63 #define BOIDRULE_CURRENT (1 << 0)
64 #define BOIDRULE_IN_AIR (1 << 2)
65 #define BOIDRULE_ON_LAND (1 << 3)
66 typedef struct BoidRule {
67  struct BoidRule *next, *prev;
68  int type, flag;
69  char name[32];
71 #define BRULE_GOAL_AVOID_PREDICT (1 << 0)
72 #define BRULE_GOAL_AVOID_ARRIVE (1 << 1)
73 #define BRULE_GOAL_AVOID_SIGNAL (1 << 2)
74 typedef struct BoidRuleGoalAvoid {
76  struct Object *ob;
77  int options;
78  float fear_factor;
79 
80  /* signals */
83 #define BRULE_ACOLL_WITH_BOIDS (1 << 0)
84 #define BRULE_ACOLL_WITH_DEFLECTORS (1 << 1)
85 typedef struct BoidRuleAvoidCollision {
87  int options;
88  float look_ahead;
90 #define BRULE_LEADER_IN_LINE (1 << 0)
91 typedef struct BoidRuleFollowLeader {
93  struct Object *ob;
94  float loc[3], oloc[3];
95  float cfra, distance;
98 typedef struct BoidRuleAverageSpeed {
100  float wander, level, speed, rt;
102 typedef struct BoidRuleFight {
106 
107 typedef enum eBoidMode {
114 
115 typedef struct BoidData {
116  float health, acc[3];
117  short state_id, mode;
119 
120 // planned for near future
121 // typedef enum BoidConditionMode {
122 // eBoidConditionType_Then = 0,
123 // eBoidConditionType_And = 1,
124 // eBoidConditionType_Or = 2,
125 // NUM_BOID_CONDITION_MODES
126 //} BoidConditionMode;
127 // typedef enum BoidConditionType {
128 // eBoidConditionType_None = 0,
129 // eBoidConditionType_Signal = 1,
130 // eBoidConditionType_NoSignal = 2,
131 // eBoidConditionType_HealthBelow = 3,
132 // eBoidConditionType_HealthAbove = 4,
133 // eBoidConditionType_See = 5,
134 // eBoidConditionType_NotSee = 6,
135 // eBoidConditionType_StateTime = 7,
136 // eBoidConditionType_Touching = 8,
137 // NUM_BOID_CONDITION_TYPES
138 //} BoidConditionType;
139 // typedef struct BoidCondition {
140 // struct BoidCondition *next, *prev;
141 // int state_id;
142 // short type, mode;
143 // float threshold, probability;
144 //
145 // /* signals */
146 // int signal_id, channels;
147 //} BoidCondition;
148 
149 typedef enum eBoidRulesetType {
154 #define BOIDSTATE_CURRENT 1
155 typedef struct BoidState {
156  struct BoidState *next, *prev;
160  char name[32];
161  int id, flag;
162 
163  /* rules */
166 
167  /* signal */
169  float volume, falloff;
171 
172 // planned for near future
173 // typedef struct BoidSignal {
174 // struct BoidSignal *next, *prev;
175 // float loc[3];
176 // float volume, falloff;
177 // int id;
178 //} BoidSignal;
179 // typedef struct BoidSignalDefine {
180 // struct BoidSignalDefine *next, *prev;
181 // int id, rt;
182 // char name[32];
183 //} BoidSignalDefine;
184 
185 // typedef struct BoidSimulationData {
186 // ListBase signal_defines;/* list of defined signals */
187 // ListBase signals[20]; /* gathers signals from all channels */
188 // struct KDTree_3d *signaltrees[20];
189 // char channel_names[20][32];
190 // int last_signal_id; /* used for incrementing signal ids */
191 // int flag; /* switches for drawing stuff */
192 //} BoidSimulationData;
193 
194 typedef struct BoidSettings {
196 
198  float banking, pitch;
199 
202 
203  /* flying related */
207 
208  /* walk/run related */
213 
214  struct ListBase states;
216 
217 /* boidsettings->options */
218 #define BOID_ALLOW_FLIGHT (1 << 0)
219 #define BOID_ALLOW_LAND (1 << 1)
220 #define BOID_ALLOW_CLIMB (1 << 2)
221 
222 /* boidrule->options */
223 //#define BOID_RULE_FOLLOW_LINE (1 << 0) /* follow leader */
224 //#define BOID_RULE_PREDICT (1 << 1) /* goal/avoid */
225 //#define BOID_RULE_ARRIVAL (1 << 2) /* goal */
226 //#define BOID_RULE_LAND (1 << 3) /* goal */
227 //#define BOID_RULE_WITH_BOIDS (1 << 4) /* avoid collision */
228 //#define BOID_RULE_WITH_DEFLECTORS (1 << 5) /* avoid collision */
229 
230 #ifdef __cplusplus
231 }
232 #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