Bugfix #24890
[blender.git] / source / blender / makesdna / DNA_boid_types.h
1 /* DNA_particle_types.h
2  *
3  *
4  * $Id$
5  *
6  * ***** BEGIN GPL LICENSE BLOCK *****
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software Foundation,
20  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21  *
22  * The Original Code is Copyright (C) 2009 by Janne Karhu.
23  * All rights reserved.
24  *
25  * The Original Code is: all of this file.
26  *
27  * Contributor(s): none yet.
28  *
29  * ***** END GPL LICENSE BLOCK *****
30  */
31
32 #ifndef DNA_BOID_TYPES_H
33 #define DNA_BOID_TYPES_H
34
35 #include "DNA_listBase.h"
36
37 typedef enum BoidRuleType {
38         eBoidRuleType_None = 0,
39         eBoidRuleType_Goal,                             /* go to goal assigned object or loudest assigned signal source */
40         eBoidRuleType_Avoid,                    /* get away from assigned object or loudest assigned signal source */
41         eBoidRuleType_AvoidCollision,   /* manoeuver to avoid collisions with other boids and deflector object in near future */
42         eBoidRuleType_Separate,                 /* keep from going through other boids */
43         eBoidRuleType_Flock,                    /* move to center of neighbors and match their velocity */
44         eBoidRuleType_FollowLeader,             /* follow a boid or assigned object */
45         eBoidRuleType_AverageSpeed,             /* maintain speed, flight level or wander*/
46         eBoidRuleType_Fight,                    /* go to closest enemy and attack when in range */
47         //eBoidRuleType_Protect,                /* go to enemy closest to target and attack when in range */
48         //eBoidRuleType_Hide,                   /* find a deflector move to it's other side from closest enemy */
49         //eBoidRuleType_FollowPath,             /* move along a assigned curve or closest curve in a group */
50         //eBoidRuleType_FollowWall,             /* move next to a deflector object's in direction of it's tangent */
51         NUM_BOID_RULE_TYPES
52 } BoidRuleType;
53
54 /* boidrule->flag */
55 #define BOIDRULE_CURRENT                1
56 #define BOIDRULE_IN_AIR                 4
57 #define BOIDRULE_ON_LAND                8
58 typedef struct BoidRule {
59         struct BoidRule *next, *prev;
60         int type, flag;
61         char name[32];
62 } BoidRule;
63 #define BRULE_GOAL_AVOID_PREDICT        1
64 #define BRULE_GOAL_AVOID_ARRIVE         2
65 #define BRULE_GOAL_AVOID_SIGNAL         4
66 typedef struct BoidRuleGoalAvoid {
67         BoidRule rule;
68         struct Object *ob;
69         int options;
70         float fear_factor;      
71
72         /* signals */
73         int signal_id, channels;
74 } BoidRuleGoalAvoid;
75 #define BRULE_ACOLL_WITH_BOIDS          1
76 #define BRULE_ACOLL_WITH_DEFLECTORS     2
77 typedef struct BoidRuleAvoidCollision {
78         BoidRule rule;
79         int options;
80         float look_ahead;
81 } BoidRuleAvoidCollision;
82 #define BRULE_LEADER_IN_LINE            1
83 typedef struct BoidRuleFollowLeader {
84         BoidRule rule;
85         struct Object *ob;
86         float loc[3], oloc[3];
87         float cfra, distance;
88         int options, queue_size;
89 } BoidRuleFollowLeader;
90 typedef struct BoidRuleAverageSpeed {
91         BoidRule rule;
92         float wander, level, speed, rt;
93 } BoidRuleAverageSpeed;
94 typedef struct BoidRuleFight {
95         BoidRule rule;
96         float distance, flee_distance;
97 } BoidRuleFight;
98
99 typedef enum BoidMode {
100         eBoidMode_InAir = 0,
101         eBoidMode_OnLand,
102         eBoidMode_Climbing,
103         eBoidMode_Falling,
104         eBoidMode_Liftoff,
105         NUM_BOID_MODES
106 } BoidMode;
107
108
109 /* XXX WARNING!!! */
110 /* BoidData is NOT in DNA, it gets saved via write_data. Do not change struct */
111 typedef struct BoidData {
112         float health, acc[3];
113         short state_id, mode;
114 } BoidData;
115
116 // planned for near future
117 //typedef enum BoidConditionMode {
118 //      eBoidConditionType_Then = 0,
119 //      eBoidConditionType_And,
120 //      eBoidConditionType_Or,
121 //      NUM_BOID_CONDITION_MODES
122 //} BoidConditionMode;
123 //typedef enum BoidConditionType {
124 //      eBoidConditionType_None = 0,
125 //      eBoidConditionType_Signal,
126 //      eBoidConditionType_NoSignal,
127 //      eBoidConditionType_HealthBelow,
128 //      eBoidConditionType_HealthAbove,
129 //      eBoidConditionType_See,
130 //      eBoidConditionType_NotSee,
131 //      eBoidConditionType_StateTime,
132 //      eBoidConditionType_Touching,
133 //      NUM_BOID_CONDITION_TYPES
134 //} BoidConditionType;
135 //typedef struct BoidCondition {
136 //      struct BoidCondition *next, *prev;
137 //      int state_id;
138 //      short type, mode;
139 //      float threshold, probability;
140 //
141 //      /* signals */
142 //      int signal_id, channels;
143 //} BoidCondition;
144
145 typedef enum BoidRulesetType {
146         eBoidRulesetType_Fuzzy = 0,
147         eBoidRulesetType_Random,
148         eBoidRulesetType_Average,
149         NUM_BOID_RULESET_TYPES
150 } BoidRulesetType;
151 #define BOIDSTATE_CURRENT       1
152 typedef struct BoidState {
153         struct BoidState *next, *prev;
154         ListBase rules;
155         ListBase conditions;
156         ListBase actions;
157         char name[32];
158         int id, flag;
159         
160         /* rules */
161         int ruleset_type;
162         float rule_fuzziness;
163
164         /* signal */
165         int signal_id, channels;
166         float volume, falloff;
167 } BoidState;
168
169 // planned for near future
170 //typedef struct BoidSignal {
171 //      struct BoidSignal *next, *prev;
172 //      float loc[3];
173 //      float volume, falloff;
174 //      int id;
175 //} BoidSignal;
176 //typedef struct BoidSignalDefine {
177 //      struct BoidSignalDefine *next, *prev;
178 //      int id, rt;
179 //      char name[32];
180 //} BoidSignalDefine;
181
182 //typedef struct BoidSimulationData {
183 //      ListBase signal_defines;/* list of defined signals */
184 //      ListBase signals[20];   /* gathers signals from all channels */
185 //      struct KDTree *signaltrees[20];
186 //      char channel_names[20][32];
187 //      int last_signal_id;             /* used for incrementing signal ids */
188 //      int flag;                               /* switches for drawing stuff */
189 //} BoidSimulationData;
190
191 typedef struct BoidSettings {
192         int options, last_state_id;
193
194         float landing_smoothness, height;
195         float banking, pitch;
196
197         float health, aggression;
198         float strength, accuracy, range;
199
200         /* flying related */
201         float air_min_speed, air_max_speed;
202         float air_max_acc, air_max_ave;
203         float air_personal_space;
204
205         /* walk/run related */
206         float land_jump_speed, land_max_speed;
207         float land_max_acc, land_max_ave;
208         float land_personal_space;
209         float land_stick_force;
210
211         struct ListBase states;
212 } BoidSettings;
213
214 /* boidsettings->options */
215 #define BOID_ALLOW_FLIGHT       1
216 #define BOID_ALLOW_LAND         2
217 #define BOID_ALLOW_CLIMB        4
218
219 /* boidrule->options */
220 //#define BOID_RULE_FOLLOW_LINE 1               /* follow leader */
221 //#define BOID_RULE_PREDICT             2               /* goal/avoid */
222 //#define BOID_RULE_ARRIVAL             4               /* goal */
223 //#define BOID_RULE_LAND                        8               /* goal */
224 //#define BOID_RULE_WITH_BOIDS  16              /* avoid collision */
225 //#define BOID_RULE_WITH_DEFLECTORS     32      /* avoid collision */
226
227 #endif