1
2
3
4
5
6
7#ifndef particle_api_classes_h
8#define particle_api_classes_h
9
10#include "Particle/pDeclarations.h"
11#include "Particle/pError.h"
12#include "Particle/pInternalsIface.h"
13#include "Particle/pParticle.h"
14#include "Particle/pSourceState.h"
15
17
18class PInternalState_t;
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
41public:
42
43
44
45
46
47
48
49 void Seed(
const unsigned int seed);
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
82
83
85
86
87
88
89
90
91
92
93
94
95
96
98
99
100
101
102
104 const int action_list_count = 1
105 );
106
107
108
109
111
112
113
114
115
117 );
118
119
120
121
122
123
124
126
127protected:
128 std::shared_ptr<PInternalState_t>
PS;
130};
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
147public:
148
149
150
151
152
153
155 const size_t index,
156 const size_t copy_count
157 );
158
159
160
161
163
164
165
166
167
168
169
170
172 const int p_group_count = 1
173 );
174
175
176
177
178
179
181 const size_t max_particles = 0
182 );
183
184
185
186
188
189
190
191
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
214 const size_t count,
215 float* position,
216 const bool getAlpha,
217 float* color = NULL,
218 float* vel = NULL,
219 float* size = NULL,
220 float* age = NULL
221 );
222
223
224
225
226
227
228
229
230
232 size_t& stride,
233 size_t& pos3Ofs,
234 size_t& posB3Ofs,
235 size_t& size3Ofs,
236 size_t& vel3Ofs,
237 size_t& velB3Ofs,
238 size_t& color3Ofs,
239 size_t& alpha1Ofs,
240 size_t& age1Ofs,
241 size_t& up3Ofs,
242 size_t& rvel3Ofs,
243 size_t& upB3Ofs,
244 size_t& mass1Ofs,
245 size_t& data1Ofs
246 );
247
248
249
250
251
252
254
255
256
257
258
259
260
261
264 );
265
266
267
268
269
270
271
272
275 );
276
277
278
279
280
281
282
283
285
286protected:
287 std::shared_ptr<PInternalState_t>
PS;
289};
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
333public:
334
335
336
337
338
339
340
342 const float epsilon,
343 const float look_ahead,
345 );
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
368 const float resilience,
369 const float fric_min_vel,
371 );
372
373
375
376 const bool copy_vel = false
377
378 );
379
380
381
382
383
384
385
387 const float min_vel = 0.0f,
389 );
390
391
392
393
394
395
396
398 const float min_vel = 0.0f,
400 );
401
402
403
404
405
406
407
408
409
410
411
412
414 const float radius,
415 const float magnitude,
416 const float sigma,
417 const float epsilon =
P_EPS
418 );
419
420
421
422
423
425 );
426
427
428
429
430
433 );
434
435
436
437
438
439
440
441
442
444 const bool move_rotational_velocity = true
445 );
446
447
448
449
452 const float magnitude = 1.0f,
453 const float epsilon =
P_EPS,
455 );
456
457
458
459
461 const float magnitude = 1.0f,
462 const float epsilon =
P_EPS,
464 );
465
466
467
468
469
470
472 );
473
474
475
476
477
478
479
480
481
482
484 );
485
486
487
488
489
491 );
492
493
494
495
496
498 );
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
518 const bool vel = true,
519 const bool rvel = true
520 );
521
522
523
524
525
526
527
529 const float max_speed
530 );
531
532
533
534
535
536
537
538
540 const float alpha,
541 const float scale
542 );
543
544
545
546
547
548
549
550
551
552
553
556 );
557
558
559
560
561
562
563
564
565
567 const float scale
568 );
569
570
571
572
573
574
575
576
577
579 const float scale
580 );
581
582
583
584
587 const float tightnessExponent,
588 const float max_radius,
589 const float inSpeed,
590 const float upSpeed,
591 const float aroundSpeed
592 );
593
594
595
596
597
598
599
600
601
602
604 const float epsilon =
P_EPS,
606 );
607
608
609
610
611
613 const float epsilon =
P_EPS,
615 );
616
617
618
619
620
621
623 const float epsilon =
P_EPS,
625 );
626
627
628
629
630
631
633 const float epsilon =
P_EPS,
635 );
636
637
638
639
640
641
642
645 );
646
647
648
649
650
651
652
653
654
655
657 const bool kill_less_than = false
658 );
659
660
661
662
665 );
666
667
668
669
670
671
672
675 );
676
677
678
679
680
681
682
683
685 const float epsilon,
686 const float look_ahead,
688 );
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
711 const float resilience,
712 const float fric_min_vel,
714 );
715
716
718
719 const bool copy_vel = false
720
721 );
722
723
724
725
726
727
728
730 const float min_vel = 0.0f,
732 );
733
734
735
736
737
738
739
741 const float min_vel = 0.0f,
743 );
744
745
746
747
748
749
750
751
752
753
754
755
757 const float radius,
758 const float magnitude,
759 const float sigma,
760 const float epsilon =
P_EPS
761 );
762
763
764
765
766
768 );
769
770
771
772
773
776 );
777
778
779
780
781
782
783
784
785
786 void Move(
const bool move_velocity =
true,
787 const bool move_rotational_velocity = true
788 );
789
790
791
792
795 const float magnitude = 1.0f,
796 const float epsilon =
P_EPS,
798 );
799
800
801
802
804 const float magnitude = 1.0f,
805 const float epsilon =
P_EPS,
807 );
808
809
810
811
812
813
815 );
816
817
818
819
820
821
822
823
824
825
827 );
828
829
830
831
832
834 );
835
836
837
838
839
841 );
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
861 const bool vel = true,
862 const bool rvel = true
863 );
864
865
866
867
868
869
870
872 const float max_speed
873 );
874
875
876
877
878
879
880
881
883 const float alpha,
884 const float scale
885 );
886
887
888
889
890
891
892
893
894
895
896
899 );
900
901
902
903
904
905
906
907
908
910 const float scale
911 );
912
913
914
915
916
917
918
919
920
922 const float scale
923 );
924
925
926
927
930 const float tightnessExponent,
931 const float max_radius,
932 const float inSpeed,
933 const float upSpeed,
934 const float aroundSpeed
935 );
936
937
938
939
940
941
942
943
944
945
946 void Follow(
const float magnitude = 1.0f,
947 const float epsilon =
P_EPS,
949 );
950
951
952
953
954
956 const float epsilon =
P_EPS,
958 );
959
960
961
962
963
964
966 const float epsilon =
P_EPS,
968 );
969
970
971
972
973
974
976 const float epsilon =
P_EPS,
978 );
979
980
981
982
983
984
985
988 );
989
990
991
992
993
994
995
996
997
998
1000 const bool kill_less_than = false
1001 );
1002
1003
1004
1005
1008 );
1009
1010
1011
1012
1013
1014
1015
1018 );
1019
1020
1022
1023
1024
1025
1026
1027
1028
1030 const pVec& look_dir,
1031 const bool front_to_back = false,
1032 const bool clamp_negative = false
1033 );
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1052 );
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1069 );
1070
1071
1072
1073
1074
1075
1077 {
1081 }
1082
1083
1084
1085
1086
1087
1088
1089 template <
class ExPol,
class UnaryFunction>
void ParticleLoop(ExPol&& policy, UnaryFunction f)
1090 {
1094 }
1095
1096protected:
1098 std::shared_ptr<PInternalState_t>
PS;
1100};
1101
1102
1103
1104
1105
1106
1108public:
1110};
1111};
1112
1113#endif
Action List Calls.
Definition: pAPIContext.h:40
void TimeStep(const float new_dt)
Specify the time step length.
void CallActionList(const int action_list_num)
Execute the specified action list on the current particle group.
float GetTimeStep() const
Return the current time step, as set with TimeStep()
void Seed(const unsigned int seed)
Set the random number seed.
int GenActionLists(const int action_list_count=1)
Generate a block of empty action lists.
std::shared_ptr< PInternalState_t > PS
Definition: pAPIContext.h:128
void DeleteActionLists(const int action_list_num, const int action_list_count=1)
Delete one or more consecutive action lists.
void NewActionList(const int action_list_num)
Begin the creation of the specified action list.
void EndActionList()
End the creation of a new action list.
void InternalSetup(std::shared_ptr< PInternalState_t > Sr)
This class contains the Action API.
Definition: pAPIContext.h:332
void RandomDisplace(const pDomain &dom)
Immediately displace position by a random amount.
void RandomDisplace(Particle_t &m, const pDomain &dom)
Immediately displace position by a random amount.
Definition: pInlineActionsAPI.h:118
void KillOld(const float age_limit, const bool kill_less_than=false)
Get rid of older particles.
void Bounce(const float friction, const float resilience, const float fric_min_vel, const pDomain &dom)
Bounce particles off an object defined by a domain.
void TargetRotVelocity(Particle_t &m, const pVec &rvel, const float scale)
Change rotational velocity of all particles toward the specified rotational velocity.
Definition: pInlineActionsAPI.h:166
void RandomAccel(Particle_t &m, const pDomain &dom)
Accelerate particles in random directions.
Definition: pInlineActionsAPI.h:112
void CommitKills()
Delete particles tagged to be killed by inline P.I.KillOld(), P.I.Sink(), and P.I....
void SinkVelocity(Particle_t &m, const bool kill_inside, const pDomain &kill_vel_dom)
Kill particles that have velocities on wrong side of the specified domain.
Definition: pInlineActionsAPI.h:227
void RandomAccel(const pDomain &dom)
Accelerate particles in random directions.
void CopyVertexB(const bool copy_pos=true, const bool copy_vel=false)
Set the secondary position and velocity from current.
void Source(const float particle_rate, const pDomain &dom, const pSourceState &SrcSt)
Add particles with positions in the specified domain.
void TargetColor(const pVec &color, const float alpha, const float scale)
Change color of all particles toward the specified color.
void MatchVelocity(Particle_t &m, const float magnitude=1.0f, const float epsilon=P_EPS, const float max_radius=P_MAXFLOAT)
Modify each particle's velocity to be similar to that of its neighbors.
Definition: pInlineActionsAPI.h:194
void Restore(Particle_t &m, const float time, const bool vel=true, const bool rvel=true)
Over time, restore particles to their target positionB and upB.
Definition: pInlineActionsAPI.h:136
void Callback(Particle_t &m, P_PARTICLE_CALLBACK_ACTION callbackFunc, const pdata_t call_data=0)
Call an arbitrary user-provided function on each particle in the group.
Definition: pInlineActionsAPI.h:209
void Vertex(const pVec &v, const pSourceState &SrcSt, const pdata_t data=0)
Add a single particle at the specified location.
void Move(Particle_t &m, const bool move_velocity=true, const bool move_rotational_velocity=true)
Apply the particles' velocities to their positions, and age the particles.
Definition: pInlineActionsAPI.h:94
void Restore(const float time, const bool vel=true, const bool rvel=true)
Over time, restore particles to their target positionB and upB.
void Jet(Particle_t &m, const pDomain &dom, const pDomain &acc)
For particles in the domain of influence, accelerate them with a domain.
Definition: pInlineActionsAPI.h:88
void RandomRotVelocity(const pDomain &dom)
Immediately assign a random rotational velocity.
void Avoid(const float magnitude, const float epsilon, const float look_ahead, const pDomain &dom)
Steer particles away from a domain of space.
void Follow(const float magnitude=1.0f, const float epsilon=P_EPS, const float max_radius=P_MAXFLOAT)
Accelerate toward the next particle in the list.
void OrbitLine(Particle_t &m, const pVec &p, const pVec &axis, const float magnitude=1.0f, const float epsilon=P_EPS, const float max_radius=P_MAXFLOAT)
Accelerate particles toward the closest point on the given line.
Definition: pInlineActionsAPI.h:100
void SpeedClamp(const float min_speed, const float max_speed)
Clamp particle velocities to the given range.
void KillOld(Particle_t &m, const float age_limit, const bool kill_less_than=false)
Get rid of older particles.
Definition: pInlineActionsAPI.h:215
void ParticleLoop(ExPol &&policy, UnaryFunction f)
Loop over particles executing all actions expressed in function f using the given execution policy fo...
Definition: pAPIContext.h:1089
void Bounce(Particle_t &m, const float friction, const float resilience, const float fric_min_vel, const pDomain &dom)
Bounce particles off an object defined by a domain.
Definition: pInlineActionsAPI.h:44
void Sort(const pVec &eye, const pVec &look_dir, const bool front_to_back=false, const bool clamp_negative=false)
Sort the particles by their projection onto the look vector.
void ParticleLoop(UnaryFunction f)
Loop over particles executing all actions expressed in function f
Definition: pAPIContext.h:1076
void OrbitPoint(const pVec ¢er, const float magnitude=1.0f, const float epsilon=P_EPS, const float max_radius=P_MAXFLOAT)
Accelerate particles toward the given center point.
void Vortex(const pVec &tip, const pVec &axis, const float tightnessExponent, const float max_radius, const float inSpeed, const float upSpeed, const float aroundSpeed)
Accelerate particles in a vortex-like way.
void Damping(Particle_t &m, const pVec &damping, const float min_vel=0.0f, const float max_vel=P_MAXFLOAT)
Simulate air by dampening particle velocities.
Definition: pInlineActionsAPI.h:64
void OrbitLine(const pVec &p, const pVec &axis, const float magnitude=1.0f, const float epsilon=P_EPS, const float max_radius=P_MAXFLOAT)
Accelerate particles toward the closest point on the given line.
void TargetVelocity(Particle_t &m, const pVec &vel, const float scale)
Change velocity of all particles toward the specified velocity.
Definition: pInlineActionsAPI.h:160
void Move(const bool move_velocity=true, const bool move_rotational_velocity=true)
Apply the particles' velocities to their positions, and age the particles.
void Explosion(Particle_t &m, const pVec ¢er, const float radius, const float magnitude, const float sigma, const float epsilon=P_EPS)
Exert force on each particle away from explosion center.
Definition: pInlineActionsAPI.h:76
void Gravity(Particle_t &m, const pVec &dir)
Accelerate particles in the given direction.
Definition: pInlineActionsAPI.h:82
void Gravitate(Particle_t &m, const float magnitude=1.0f, const float epsilon=P_EPS, const float max_radius=P_MAXFLOAT)
Accelerate each particle toward each other particle.
Definition: pInlineActionsAPI.h:188
PInternalShadow_t PSh
Definition: pAPIContext.h:1097
void TargetVelocity(const pVec &vel, const float scale)
Change velocity of all particles toward the specified velocity.
void Follow(Particle_t &m, const float magnitude=1.0f, const float epsilon=P_EPS, const float max_radius=P_MAXFLOAT)
Accelerate toward the next particle in the list.
Definition: pInlineActionsAPI.h:182
void Avoid(Particle_t &m, const float magnitude, const float epsilon, const float look_ahead, const pDomain &dom)
Steer particles away from a domain of space.
Definition: pInlineActionsAPI.h:31
void Vortex(Particle_t &m, const pVec &tip, const pVec &axis, const float tightnessExponent, const float max_radius, const float inSpeed, const float upSpeed, const float aroundSpeed)
Accelerate particles in a vortex-like way.
Definition: pInlineActionsAPI.h:172
void OrbitPoint(Particle_t &m, const pVec ¢er, const float magnitude=1.0f, const float epsilon=P_EPS, const float max_radius=P_MAXFLOAT)
Accelerate particles toward the given center point.
Definition: pInlineActionsAPI.h:106
void Explosion(const pVec ¢er, const float radius, const float magnitude, const float sigma, const float epsilon=P_EPS)
Exert force on each particle away from explosion center.
void Sink(Particle_t &m, const bool kill_inside, const pDomain &kill_pos_dom)
Kill particles that have positions on wrong side of the specified domain.
Definition: pInlineActionsAPI.h:221
void SpeedClamp(Particle_t &m, const float min_speed, const float max_speed)
Clamp particle velocities to the given range.
Definition: pInlineActionsAPI.h:142
void Callback(P_PARTICLE_CALLBACK_ACTION callbackFunc, const pdata_t call_data=0)
Call an arbitrary user-provided function on each particle in the group.
std::shared_ptr< PInternalState_t > PS
Definition: pAPIContext.h:1098
void RandomVelocity(const pDomain &dom)
Replace particle velocity with a random velocity.
void Jet(const pDomain &dom, const pDomain &acc)
For particles in the domain of influence, accelerate them with a domain.
void Sink(const bool kill_inside, const pDomain &kill_pos_dom)
Kill particles that have positions on wrong side of the specified domain.
void RotDamping(const pVec &damping, const float min_vel=0.0f, const float max_vel=P_MAXFLOAT)
Simulate air by dampening rotational velocities.
void MatchRotVelocity(const float magnitude=1.0f, const float epsilon=P_EPS, const float max_radius=P_MAXFLOAT)
Modify each particle's rotational velocity to be similar to that of its neighbors.
void MatchRotVelocity(Particle_t &m, const float magnitude=1.0f, const float epsilon=P_EPS, const float max_radius=P_MAXFLOAT)
Modify each particle's rotational velocity to be similar to that of its neighbors.
Definition: pInlineActionsAPI.h:200
void CopyVertexB(Particle_t &m, const bool copy_pos=true, const bool copy_vel=false)
Set the secondary position and velocity from current.
Definition: pInlineActionsAPI.h:58
void TargetSize(Particle_t &m, const pVec &size, const pVec &scale)
Change sizes of all particles toward the specified size.
Definition: pInlineActionsAPI.h:154
void SinkVelocity(const bool kill_inside, const pDomain &kill_vel_dom)
Kill particles that have velocities on wrong side of the specified domain.
void Gravitate(const float magnitude=1.0f, const float epsilon=P_EPS, const float max_radius=P_MAXFLOAT)
Accelerate each particle toward each other particle.
void Damping(const pVec &damping, const float min_vel=0.0f, const float max_vel=P_MAXFLOAT)
Simulate air by dampening particle velocities.
void MatchVelocity(const float magnitude=1.0f, const float epsilon=P_EPS, const float max_radius=P_MAXFLOAT)
Modify each particle's velocity to be similar to that of its neighbors.
void RotDamping(Particle_t &m, const pVec &damping, const float min_vel=0.0f, const float max_vel=P_MAXFLOAT)
Simulate air by dampening rotational velocities.
Definition: pInlineActionsAPI.h:70
void RandomRotVelocity(Particle_t &m, const pDomain &dom)
Immediately assign a random rotational velocity.
Definition: pInlineActionsAPI.h:130
void TargetRotVelocity(const pVec &rvel, const float scale)
Change rotational velocity of all particles toward the specified rotational velocity.
void RandomVelocity(Particle_t &m, const pDomain &dom)
Replace particle velocity with a random velocity.
Definition: pInlineActionsAPI.h:124
void TargetSize(const pVec &size, const pVec &scale)
Change sizes of all particles toward the specified size.
void TargetColor(Particle_t &m, const pVec &color, const float alpha, const float scale)
Change color of all particles toward the specified color.
Definition: pInlineActionsAPI.h:148
void Gravity(const pVec &dir)
Accelerate particles in the given direction.
void InternalSetup(std::shared_ptr< PInternalState_t > Sr)
This class contains the API calls that operate on particle groups.
Definition: pAPIContext.h:146
void DeathCallback(P_PARTICLE_CALLBACK callback, pdata_t group_data=0)
Specify a particle death callback.
void SetWorkingSetSize(const int set_size_bytes)
Set the number of particles that fit in the CPU's cache.
void BirthCallback(P_PARTICLE_CALLBACK callback, pdata_t group_data=0)
Specify a particle creation callback.
void DeleteParticleGroups(const int p_group_num, const int p_group_count=1)
Delete one or more consecutive particle groups.
size_t GetParticlePointer(const float *&ptr, size_t &stride, size_t &pos3Ofs, size_t &posB3Ofs, size_t &size3Ofs, size_t &vel3Ofs, size_t &velB3Ofs, size_t &color3Ofs, size_t &alpha1Ofs, size_t &age1Ofs, size_t &up3Ofs, size_t &rvel3Ofs, size_t &upB3Ofs, size_t &mass1Ofs, size_t &data1Ofs)
Return a pointer to particle data stored in API memory.
void CopyGroup(const int p_src_group_num, const size_t index, const size_t copy_count)
Copy particles from the specified group into the current group.
std::shared_ptr< PInternalState_t > PS
Definition: pAPIContext.h:287
size_t GetMaxParticles()
Return the maximum number of particles allowed in the current group.
size_t GetGroupCount()
Returns the number of particles existing in the current group.
void SetMaxParticles(const size_t max_count)
Change the maximum number of particles in the current group.
int GenParticleGroups(const int p_group_count=1, const size_t max_particles=0)
Create particle groups, each with a maximum of max_particles.
void CurrentGroup(const int p_group_num)
Change which group is current.
size_t GetParticles(const size_t index, const size_t count, float *position, const bool getAlpha, float *color=NULL, float *vel=NULL, float *size=NULL, float *age=NULL)
Copy particles from the current group to application memory.
void InternalSetup(std::shared_ptr< PInternalState_t > Sr)
The Particle System API Context - Your app should have one of these per host thread that will do part...
Definition: pAPIContext.h:1107
A representation of a region of space.
Definition: pDomain.h:55
These functions set the current state needed by Source() and Vertex() actions.
Definition: pSourceState.h:21
A single-precision floating point three-vector.
Definition: pVec.h:63
PAPIClasses.h.
Definition: pAPIContext.h:16
const float P_MAXFLOAT
A very large float value used as a default arg passed into functions.
Definition: pDeclarations.h:19
void(* P_PARTICLE_CALLBACK_ACTION)(struct Particle_t &particle, const pdata_t data, const float dt)
This is the type of the callback functions that you can register for the Callback() action.
Definition: pDeclarations.h:28
unsigned int pdata_t
Definition: pDeclarations.h:16
const float P_EPS
A very small float value added to some physical calculations to dampen them and improve stability.
Definition: pDeclarations.h:22
Definition: pParticle.h:18