- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
struct Vector2f{float x, y;};
struct Vector3f{float x, y, z;};
struct Tensor3f{float xx, xy, xz, yy, yz, zz;};
struct Matrix3x3f{float data[9];};
struct Space2
{
typedef Vector2f Vector;
};
struct Space3
{
typedef Vector3f Vector;
};
template<typename Space>
struct ParticleSystem
{
template<typename T>
struct ParticleData{};
template<>
struct ParticleData<Space2>
{
float orientation;
float invInertia;
};
template<>
struct ParticleData<Space3>
{
typename Matrix3x3f orientation;
typename Tensor3f inertiaTensor;
};
struct Particle : public ParticleData<Space>
{
typename Space::Vector pos, velocity;
};
template<typename T>
void DumpParticle(){}
template<>
void DumpParticle<Space2>()
{
printf("%f %f", particles[0].orientation, particles[0].invInertia);
}
template<>
void DumpParticle<Space3>()
{
printf("%f %f", particles[0].orientation.data[0], particles[0].inertia.xx);
}
void DumpParticles()
{
DumpParticle<Space>();
}
std::vector<Particle> particles;
};