ParticleAPI 3.0.0 Performant particle system API in C++ for interactive graphics

pParticle.h
Go to the documentation of this file.
1/// Particle.h
2///
3/// Copyright 1997-2007, 2022 by David K. McAllister
4///
5/// This file contains the definition of a particle.
6/// It should only be included by API implementation files, not by applications.
7/// The only exception is callback functions.
8
9#ifndef Particle_h
10#define Particle_h
11
12#include "Particle/pDeclarations.h"
13#include "Particle/pVec.h"
14
15namespace PAPI {
16
17// A single particle
18 struct Particle_t {
19 pVec pos;
20 pVec posB;
21 pVec up;
22 pVec upB;
23 pVec vel;
24 pVec velB; // Used to compute binormal, normal, etc.
25 pVec rvel;
26 pVec size;
27 pVec color; // Color must be next to alpha so glColor4fv works.
28 float alpha; // This is both cunning and scary.
29 float age;
30 float mass;
31 float tmp0; // These temporaries are used as padding and for sorting.
32 pdata_t data; // Arbitrary data for user callbacks
33
34 inline Particle_t() {}
35
36 inline Particle_t(const pVec& pos, const pVec& posB, const pVec& up, const pVec& upB, const pVec& vel, const pVec& velB, const pVec& rvel,
37 const pVec& rvelB, const pVec& size, const pVec& color, float alpha, float age, float mass, pdata_t data, float tmp0) :
38 pos(pos),
39 posB(posB), up(up), upB(upB), vel(vel), velB(velB), rvel(rvel), size(size), color(color), alpha(alpha), age(age), mass(mass), data(data), tmp0(0)
40 {
41 }
42
43 inline Particle_t(const Particle_t& rhs) :
44 pos(rhs.pos), posB(rhs.posB), up(rhs.up), upB(rhs.upB), vel(rhs.vel), velB(rhs.velB), rvel(rhs.rvel), size(rhs.size), color(rhs.color),
45 alpha(rhs.alpha), age(rhs.age), mass(rhs.mass), data(rhs.data), tmp0(rhs.tmp0)
46 {
47 }
48
49 // For sorting.
50 bool operator<(const Particle_t& P) const { return tmp0 < P.tmp0; }
51};
52
53static_assert(sizeof(Particle_t) == 32 * 4, "Unexpected change in Particle_t size!");
54}; // namespace PAPI
55
56#endif
PAPI::pVec
A single-precision floating point three-vector.
Definition: pVec.h:63
PAPI
PAPIClasses.h.
Definition: pAPIContext.h:16
PAPI::pdata_t
unsigned int pdata_t
Definition: pDeclarations.h:16
PAPI::Particle_t
Definition: pParticle.h:18
PAPI::Particle_t::color
pVec color
Definition: pParticle.h:27
PAPI::Particle_t::vel
pVec vel
Definition: pParticle.h:23
PAPI::Particle_t::tmp0
float tmp0
Definition: pParticle.h:31
PAPI::Particle_t::velB
pVec velB
Definition: pParticle.h:24
PAPI::Particle_t::Particle_t
Particle_t()
Definition: pParticle.h:34
PAPI::Particle_t::pos
pVec pos
Definition: pParticle.h:19
PAPI::Particle_t::age
float age
Definition: pParticle.h:29
PAPI::Particle_t::upB
pVec upB
Definition: pParticle.h:22
PAPI::Particle_t::mass
float mass
Definition: pParticle.h:30
PAPI::Particle_t::Particle_t
Particle_t(const Particle_t &rhs)
Definition: pParticle.h:43
PAPI::Particle_t::Particle_t
Particle_t(const pVec &pos, const pVec &posB, const pVec &up, const pVec &upB, const pVec &vel, const pVec &velB, const pVec &rvel, const pVec &rvelB, const pVec &size, const pVec &color, float alpha, float age, float mass, pdata_t data, float tmp0)
Definition: pParticle.h:36
PAPI::Particle_t::alpha
float alpha
Definition: pParticle.h:28
PAPI::Particle_t::posB
pVec posB
Definition: pParticle.h:20
PAPI::Particle_t::rvel
pVec rvel
Definition: pParticle.h:25
PAPI::Particle_t::up
pVec up
Definition: pParticle.h:21
PAPI::Particle_t::data
pdata_t data
Definition: pParticle.h:32
PAPI::Particle_t::size
pVec size
Definition: pParticle.h:26
PAPI::Particle_t::operator<
bool operator<(const Particle_t &P) const
Definition: pParticle.h:50