Voxellancer  0.3
A game about voxels in space
 All Classes Functions Pages
voxelparticleengine.h
1 #pragma once
2 
3 #include <memory>
4 #include <vector>
5 #include <stack>
6 
7 #include "etc/contextdependant.h"
8 
9 #include "property/property.h"
10 
11 class Player;
12 class Camera;
13 struct VoxelParticleData;
14 class VoxelParticleSetup;
17 class VoxelCluster;
18 
19 /*
20  Main class for managing and displaying the VoxelParticles of
21  a World.
22 */
24 public:
27 
28  float time() const;
29 
30  int particleCount() const;
31  int particleDataCount() const;
32  VoxelParticleData* particleData(int index);
33  std::vector<VoxelParticleData>& particleDataVector();
34 
35  void addParticle(const VoxelParticleSetup& particleSetup, const VoxelCluster* creator);
36  void removeParticle(int index);
37 
38  void update(float deltaSec);
39  void draw(const Camera& camera);
40 
41 protected:
42  float m_time;
43  bool m_initialized;
44 
45  std::unique_ptr<VoxelParticleRenderer> m_renderer;
46  std::unique_ptr<VoxelParticleRemover> m_remover;
47 
48  std::vector<VoxelParticleData> m_cpuParticleBuffer;
49  std::stack<int> m_freeParticleBufferIndices;
50 
51  bool m_gpuParticleBufferInvalid;
52  int m_gpuParticleBufferInvalidBegin;
53  int m_gpuParticleBufferInvalidEnd;
54 
55  void setBufferSize(int bufferSize);
56  void particleChanged(int bufferIndex);
57  void updateGPUBuffers(int begin, int end);
58 
59  virtual void beforeContextDestroy();
60  virtual void afterContextRebuild();
61 
62 };
63 
Definition: voxelparticledata.h:7
Definition: contextdependant.h:7
Definition: voxelparticleengine.h:23
Definition: voxelcluster.h:21
Definition: voxelparticlerenderer.h:27
Definition: camera.h:10
Definition: voxelparticleremover.h:22
Definition: player.h:22
Definition: voxelparticlesetup.h:17