Shinya Kitaoka 810553
#pragma once
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifndef PARTICLES_CONTAINER
Toshihiro Shimizu 890ddd
#define PARTICLES_CONTAINER
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "tsmartpointer.h"
Toshihiro Shimizu 890ddd
#include "trenderresourcemanager.h"
Toshihiro Shimizu 890ddd
#include "trandom.h"
Toshihiro Shimizu 890ddd
#include "particles.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include <qthreadstorage></qthreadstorage>
Toshihiro Shimizu 890ddd
#include <qmutex></qmutex>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//  Forward declarations
Toshihiro Shimizu 890ddd
class Particle;
Toshihiro Shimizu 890ddd
class TRandom;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
class ParticlesManager : public TRenderResourceManager
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	T_RENDER_RESOURCE_MANAGER
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
	struct FxData;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	struct FrameData {
Toshihiro Shimizu 890ddd
		FxData *m_fxData;
Toshihiro Shimizu 890ddd
		double m_frame;
Toshihiro Shimizu 890ddd
		TRandom m_random;
Toshihiro Shimizu 890ddd
		std::list<particle> m_particles;</particle>
Toshihiro Shimizu 890ddd
		bool m_calculated;
Toshihiro Shimizu 890ddd
		int m_maxTrail;
Toshihiro Shimizu 890ddd
		int m_totalParticles;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		FrameData(FxData *fxData);
Toshihiro Shimizu 890ddd
		~FrameData();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		void buildMaxTrail();
Toshihiro Shimizu 890ddd
		void clear();
Toshihiro Shimizu 890ddd
	};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	struct FxData : public TSmartObject {
Toshihiro Shimizu 890ddd
		DECLARE_CLASS_CODE
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		QThreadStorage<framedata *=""> m_frames;</framedata>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
		FxData();
Toshihiro Shimizu 890ddd
	};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
	ParticlesManager();
Toshihiro Shimizu 890ddd
	~ParticlesManager();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	static ParticlesManager *instance();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	FrameData *data(unsigned long fxId);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
private:
Toshihiro Shimizu 890ddd
	std::map<unsigned *="" fxdata="" long,=""> m_fxs;</unsigned>
Toshihiro Shimizu 890ddd
	QMutex m_mutex;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	int m_renderStatus;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void onRenderStatusStart(int renderStatus);
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#endif