2016-05-17 03:04:11 +12:00
|
|
|
#pragma once
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
#ifndef PARTICLES_CONTAINER
|
|
|
|
#define PARTICLES_CONTAINER
|
|
|
|
|
|
|
|
#include "tsmartpointer.h"
|
|
|
|
#include "trenderresourcemanager.h"
|
|
|
|
#include "trandom.h"
|
|
|
|
#include "particles.h"
|
|
|
|
|
|
|
|
#include <QThreadStorage>
|
|
|
|
#include <QMutex>
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------
|
|
|
|
|
|
|
|
// Forward declarations
|
|
|
|
class Particle;
|
|
|
|
class TRandom;
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------
|
|
|
|
|
2016-06-29 18:17:12 +12:00
|
|
|
class ParticlesManager final : public TRenderResourceManager {
|
2016-06-15 18:43:10 +12:00
|
|
|
T_RENDER_RESOURCE_MANAGER
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
public:
|
2016-06-15 18:43:10 +12:00
|
|
|
struct FxData;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
struct FrameData {
|
|
|
|
FxData *m_fxData;
|
|
|
|
double m_frame;
|
|
|
|
TRandom m_random;
|
|
|
|
std::list<Particle> m_particles;
|
|
|
|
bool m_calculated;
|
|
|
|
int m_maxTrail;
|
|
|
|
int m_totalParticles;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
FrameData(FxData *fxData);
|
|
|
|
~FrameData();
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void buildMaxTrail();
|
|
|
|
void clear();
|
|
|
|
};
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-29 18:17:12 +12:00
|
|
|
struct FxData final : public TSmartObject {
|
2016-06-15 18:43:10 +12:00
|
|
|
DECLARE_CLASS_CODE
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
QThreadStorage<FrameData *> m_frames;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
FxData();
|
|
|
|
};
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
public:
|
2016-06-15 18:43:10 +12:00
|
|
|
ParticlesManager();
|
|
|
|
~ParticlesManager();
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
static ParticlesManager *instance();
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
FrameData *data(unsigned long fxId);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
private:
|
2016-06-15 18:43:10 +12:00
|
|
|
std::map<unsigned long, FxData *> m_fxs;
|
|
|
|
QMutex m_mutex;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
int m_renderStatus;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-19 20:06:29 +12:00
|
|
|
void onRenderStatusStart(int renderStatus) override;
|
2016-03-19 06:57:51 +13:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|