00001
00002
00003
00004
00005
00006
00007 #ifndef PARTICLEACTIONS_H
00008 #define PARTICLEACTIONS_H
00009
00010
00011 #include "pDomain.h"
00012 #include "ParticleGroup.h"
00013
00014
00015
00016 #define PWorkingSetSize (0x1c0000 / sizeof(Particle))
00017
00018
00019 #define EXEC_METHOD void Execute(ParticleGroup &pg, ParticleList::iterator ibegin, ParticleList::iterator iend)
00020
00021 struct PActionBase
00022 {
00023 static float dt;
00024
00025 bool GetKillsParticles() { return bKillsParticles; }
00026 bool GetDoNotSegment() { return bDoNotSegment; }
00027
00028 void SetKillsParticles(const bool v) { bKillsParticles = v; }
00029 void SetDoNotSegment(const bool v) { bDoNotSegment = v; }
00030
00031 virtual EXEC_METHOD = 0;
00032
00033 virtual ~PActionBase(){}
00034 private:
00035
00036
00037
00038 bool bKillsParticles;
00039 bool bDoNotSegment;
00040 };
00041
00043
00044
00045 struct PAAvoid : public PActionBase
00046 {
00047 pDomain *position;
00048 float look_ahead;
00049 float magnitude;
00050 float epsilon;
00051
00052 EXEC_METHOD;
00053
00054 ~PAAvoid() {delete position;}
00055
00056 void Exec(const PDTriangle &dom, ParticleGroup &group, ParticleList::iterator ibegin, ParticleList::iterator iend);
00057 void Exec(const PDRectangle &dom, ParticleGroup &group, ParticleList::iterator ibegin, ParticleList::iterator iend);
00058 void Exec(const PDPlane &dom, ParticleGroup &group, ParticleList::iterator ibegin, ParticleList::iterator iend);
00059 void Exec(const PDSphere &dom, ParticleGroup &group, ParticleList::iterator ibegin, ParticleList::iterator iend);
00060 void Exec(const PDDisc &dom, ParticleGroup &group, ParticleList::iterator ibegin, ParticleList::iterator iend);
00061 };
00062
00063 struct PABounce : public PActionBase
00064 {
00065 pDomain *position;
00066 float oneMinusFriction;
00067 float resilience;
00068 float cutoffSqr;
00069
00070 EXEC_METHOD;
00071
00072 ~PABounce() {delete position;}
00073
00074 void Exec(const PDTriangle &dom, ParticleGroup &group, ParticleList::iterator ibegin, ParticleList::iterator iend);
00075 void Exec(const PDRectangle &dom, ParticleGroup &group, ParticleList::iterator ibegin, ParticleList::iterator iend);
00076 void Exec(const PDPlane &dom, ParticleGroup &group, ParticleList::iterator ibegin, ParticleList::iterator iend);
00077 void Exec(const PDSphere &dom, ParticleGroup &group, ParticleList::iterator ibegin, ParticleList::iterator iend);
00078 void Exec(const PDDisc &dom, ParticleGroup &group, ParticleList::iterator ibegin, ParticleList::iterator iend);
00079 };
00080
00081 struct PACallActionList : public PActionBase
00082 {
00083 int action_list_num;
00084
00085 EXEC_METHOD;
00086 };
00087
00088 struct PACopyVertexB : public PActionBase
00089 {
00090 bool copy_pos;
00091 bool copy_vel;
00092
00093 EXEC_METHOD;
00094 };
00095
00096 struct PADamping : public PActionBase
00097 {
00098 pVec damping;
00099 float vlowSqr;
00100 float vhighSqr;
00101
00102 EXEC_METHOD;
00103 };
00104
00105 struct PARotDamping : public PActionBase
00106 {
00107 pVec damping;
00108 float vlowSqr;
00109 float vhighSqr;
00110
00111 EXEC_METHOD;
00112 };
00113
00114 struct PAExplosion : public PActionBase
00115 {
00116 pVec center;
00117 float velocity;
00118 float magnitude;
00119 float stdev;
00120 float age;
00121 float epsilon;
00122
00123 EXEC_METHOD;
00124 };
00125
00126 struct PAFollow : public PActionBase
00127 {
00128 float magnitude;
00129 float epsilon;
00130 float max_radius;
00131
00132 EXEC_METHOD;
00133 };
00134
00135 struct PAFountain : public PActionBase
00136 {
00137 PActionBase *AL;
00138
00139 EXEC_METHOD;
00140 };
00141
00142 struct PAGravitate : public PActionBase
00143 {
00144 float magnitude;
00145 float epsilon;
00146 float max_radius;
00147
00148 EXEC_METHOD;
00149 };
00150
00151 struct PAGravity : public PActionBase
00152 {
00153 pVec direction;
00154
00155 EXEC_METHOD;
00156 };
00157
00158 struct PAJet : public PActionBase
00159 {
00160 pDomain *dom;
00161 pDomain *acc;
00162
00163 EXEC_METHOD;
00164
00165 ~PAJet() {delete dom; delete acc;}
00166 };
00167
00168 struct PAKillOld : public PActionBase
00169 {
00170 float age_limit;
00171 bool kill_less_than;
00172
00173 EXEC_METHOD;
00174 };
00175
00176 struct PAMatchVelocity : public PActionBase
00177 {
00178 float magnitude;
00179 float epsilon;
00180 float max_radius;
00181
00182 EXEC_METHOD;
00183 };
00184
00185 struct PAMatchRotVelocity : public PActionBase
00186 {
00187 float magnitude;
00188 float epsilon;
00189 float max_radius;
00190
00191 EXEC_METHOD;
00192 };
00193
00194 struct PAMove : public PActionBase
00195 {
00196
00197 EXEC_METHOD;
00198 };
00199
00200 struct PAOrbitLine : public PActionBase
00201 {
00202 pVec p, axis;
00203 float magnitude;
00204 float epsilon;
00205 float max_radius;
00206
00207 EXEC_METHOD;
00208 };
00209
00210 struct PAOrbitPoint : public PActionBase
00211 {
00212 pVec center;
00213 float magnitude;
00214 float epsilon;
00215 float max_radius;
00216
00217 EXEC_METHOD;
00218 };
00219
00220 struct PARandomAccel : public PActionBase
00221 {
00222 pDomain *gen_acc;
00223
00224 EXEC_METHOD;
00225
00226 ~PARandomAccel() {delete gen_acc;}
00227 };
00228
00229 struct PARandomDisplace : public PActionBase
00230 {
00231 pDomain *gen_disp;
00232
00233 EXEC_METHOD;
00234
00235 ~PARandomDisplace() {delete gen_disp;}
00236 };
00237
00238 struct PARandomVelocity : public PActionBase
00239 {
00240 pDomain *gen_vel;
00241
00242 EXEC_METHOD;
00243
00244 ~PARandomVelocity() {delete gen_vel;}
00245 };
00246
00247 struct PARandomRotVelocity : public PActionBase
00248 {
00249 pDomain *gen_vel;
00250
00251 EXEC_METHOD;
00252
00253 ~PARandomRotVelocity() {delete gen_vel;}
00254 };
00255
00256 struct PARestore : public PActionBase
00257 {
00258 float time_left;
00259 bool restore_velocity;
00260 bool restore_rvelocity;
00261
00262 EXEC_METHOD;
00263 };
00264
00265 struct PASink : public PActionBase
00266 {
00267 bool kill_inside;
00268 pDomain *position;
00269
00270 EXEC_METHOD;
00271
00272 ~PASink() {delete position;}
00273 };
00274
00275 struct PASinkVelocity : public PActionBase
00276 {
00277 bool kill_inside;
00278 pDomain *velocity;
00279
00280 EXEC_METHOD;
00281
00282 ~PASinkVelocity() {delete velocity;}
00283 };
00284
00285 struct PASort : public PActionBase
00286 {
00287 pVec Eye;
00288 pVec Look;
00289
00290 EXEC_METHOD;
00291 };
00292
00293 struct PASource : public PActionBase
00294 {
00295 pDomain *position;
00296 pDomain *positionB;
00297 pDomain *upVec;
00298 pDomain *velocity;
00299 pDomain *rvelocity;
00300 pDomain *size;
00301 pDomain *color;
00302 pDomain *alpha;
00303 float particle_rate;
00304 float age;
00305 float age_sigma;
00306 bool vertexB_tracks;
00307
00308 EXEC_METHOD;
00309
00310 ~PASource()
00311 {
00312 delete position;
00313 delete positionB;
00314 delete upVec;
00315 delete velocity;
00316 delete rvelocity;
00317 delete size;
00318 delete color;
00319 delete alpha;
00320 }
00321 };
00322
00323 struct PASpeedLimit : public PActionBase
00324 {
00325 float min_speed;
00326 float max_speed;
00327
00328 EXEC_METHOD;
00329 };
00330
00331 struct PATargetColor : public PActionBase
00332 {
00333 pVec color;
00334 float alpha;
00335 float scale;
00336
00337 EXEC_METHOD;
00338 };
00339
00340 struct PATargetSize : public PActionBase
00341 {
00342 pVec size;
00343 pVec scale;
00344
00345 EXEC_METHOD;
00346 };
00347
00348 struct PATargetVelocity : public PActionBase
00349 {
00350 pVec velocity;
00351 float scale;
00352
00353 EXEC_METHOD;
00354 };
00355
00356 struct PATargetRotVelocity : public PActionBase
00357 {
00358 pVec velocity;
00359 float scale;
00360
00361 EXEC_METHOD;
00362 };
00363
00364 struct PAVortex : public PActionBase
00365 {
00366 pVec tip;
00367 pVec axis;
00368 float magnitude;
00369 float tightnessExponent;
00370 float rotSpeed;
00371 float epsilon;
00372 float max_radius;
00373
00374 EXEC_METHOD;
00375 };
00376
00377 #endif // PARTICLEACTIONS_H