Copying scripts from 2.4x without 2.5x changes
[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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, 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 typedef struct BoidData {
108         float health, acc[3];
109         short state_id, mode;
110 } BoidData;
111
112 // planned for near future
113 //typedef enum BoidConditionMode {
114 //      eBoidConditionType_Then = 0,
115 //      eBoidConditionType_And,
116 //      eBoidConditionType_Or,
117 //      NUM_BOID_CONDITION_MODES
118 //} BoidConditionMode;
119 //typedef enum BoidConditionType {
120 //      eBoidConditionType_None = 0,
121 //      eBoidConditionType_Signal,
122 //      eBoidConditionType_NoSignal,
123 //      eBoidConditionType_HealthBelow,
124 //      eBoidConditionType_HealthAbove,
125 //      eBoidConditionType_See,
126 //      eBoidConditionType_NotSee,
127 //      eBoidConditionType_StateTime,
128 //      eBoidConditionType_Touching,
129 //      NUM_BOID_CONDITION_TYPES
130 //} BoidConditionType;
131 //typedef struct BoidCondition {
132 //      struct BoidCondition *next, *prev;
133 //      int state_id;
134 //      short type, mode;
135 //      float threshold, probability;
136 //
137 //      /* signals */
138 //      int signal_id, channels;
139 //} BoidCondition;
140
141 typedef enum BoidRulesetType {
142         eBoidRulesetType_Fuzzy = 0,
143         eBoidRulesetType_Random,
144         eBoidRulesetType_Average,
145         NUM_BOID_RULESET_TYPES
146 } BoidRulesetType;
147 #define BOIDSTATE_CURRENT       1
148 typedef struct BoidState {
149         struct BoidState *next, *prev;
150         ListBase rules;
151         ListBase conditions;
152         ListBase actions;
153         char name[32];
154         int id, flag;
155         
156         /* rules */
157         int ruleset_type;
158         float rule_fuzziness;
159
160         /* signal */
161         int signal_id, channels;
162         float volume, falloff;
163 } BoidState;
164
165 // planned for near future
166 //typedef struct BoidSignal {
167 //      struct BoidSignal *next, *prev;
168 //      float loc[3];
169 //      float volume, falloff;
170 //      int id;
171 //} BoidSignal;
172 //typedef struct BoidSignalDefine {
173 //      struct BoidSignalDefine *next, *prev;
174 //      int id, rt;
175 //      char name[32];
176 //} BoidSignalDefine;
177
178 //typedef struct BoidSimulationData {
179 //      ListBase signal_defines;/* list of defined signals */
180 //      ListBase signals[20];   /* gathers signals from all channels */
181 //      struct KDTree *signaltrees[20];
182 //      char channel_names[20][32];
183 //      int last_signal_id;             /* used for incrementing signal ids */
184 //      int flag;                               /* switches for drawing stuff */
185 //} BoidSimulationData;
186
187 typedef struct BoidSettings {
188         int options, last_state_id;
189
190         float landing_smoothness, rt;
191         float banking, height;
192
193         float health, aggression;
194         float strength, accuracy, range;
195
196         /* flying related */
197         float air_min_speed, air_max_speed;
198         float air_max_acc, air_max_ave;
199         float air_personal_space;
200
201         /* walk/run related */
202         float land_jump_speed, land_max_speed;
203         float land_max_acc, land_max_ave;
204         float land_personal_space;
205         float land_stick_force;
206
207         struct ListBase states;
208 } BoidSettings;
209
210 /* boidsettings->options */
211 #define BOID_ALLOW_FLIGHT       1
212 #define BOID_ALLOW_LAND         2
213 #define BOID_ALLOW_CLIMB        4
214
215 /* boidrule->options */
216 //#define BOID_RULE_FOLLOW_LINE 1               /* follow leader */
217 //#define BOID_RULE_PREDICT             2               /* goal/avoid */
218 //#define BOID_RULE_ARRIVAL             4               /* goal */
219 //#define BOID_RULE_LAND                        8               /* goal */
220 //#define BOID_RULE_WITH_BOIDS  16              /* avoid collision */
221 //#define BOID_RULE_WITH_DEFLECTORS     32      /* avoid collision */
222
223 #endif