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
18struct Particle_t {
24 pVec velB; // Used to compute binormal, normal, etc.
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
A single-precision floating point three-vector.
Definition: pVec.h:63
PAPIClasses.h.
Definition: pAPIContext.h:16
unsigned int pdata_t
Definition: pDeclarations.h:16
Definition: pParticle.h:18
pVec color
Definition: pParticle.h:27
pVec vel
Definition: pParticle.h:23
float tmp0
Definition: pParticle.h:31
pVec velB
Definition: pParticle.h:24
Particle_t()
Definition: pParticle.h:34
pVec pos
Definition: pParticle.h:19
float age
Definition: pParticle.h:29
pVec upB
Definition: pParticle.h:22
float mass
Definition: pParticle.h:30
Particle_t(const Particle_t &rhs)
Definition: pParticle.h:43
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
float alpha
Definition: pParticle.h:28
pVec posB
Definition: pParticle.h:20
pVec rvel
Definition: pParticle.h:25
pVec up
Definition: pParticle.h:21
pdata_t data
Definition: pParticle.h:32
pVec size
Definition: pParticle.h:26
bool operator<(const Particle_t &P) const
Definition: pParticle.h:50