LCOV - code coverage report
Current view: top level - source/graphics - ParticleManager.h (source / functions) Hit Total Coverage
Test: 0 A.D. test coverage report Lines: 0 2 0.0 %
Date: 2026-12-03 01:19:39 Functions: 0 0 -

          Line data    Source code
       1             : /* Copyright (C) 2026 Wildfire Games.
       2             :  * This file is part of 0 A.D.
       3             :  *
       4             :  * 0 A.D. is free software: you can redistribute it and/or modify
       5             :  * it under the terms of the GNU General Public License as published by
       6             :  * the Free Software Foundation, either version 2 of the License, or
       7             :  * (at your option) any later version.
       8             :  *
       9             :  * 0 A.D. is distributed in the hope that it will be useful,
      10             :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      11             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      12             :  * GNU General Public License for more details.
      13             :  *
      14             :  * You should have received a copy of the GNU General Public License
      15             :  * along with 0 A.D.  If not, see <http://www.gnu.org/licenses/>.
      16             :  */
      17             : 
      18             : #ifndef INCLUDED_PARTICLEMANAGER
      19             : #define INCLUDED_PARTICLEMANAGER
      20             : 
      21             : #include "graphics/ParticleEmitter.h"
      22             : #include "graphics/ParticleEmitterType.h"
      23             : #include "lib/file/vfs/vfs_path.h"
      24             : #include "lib/path.h"
      25             : #include "lib/status.h"
      26             : 
      27             : #include <random>
      28             : #include <unordered_map>
      29             : #include <vector>
      30             : 
      31             : class CFrustum;
      32             : class SceneCollector;
      33             : 
      34             : namespace Renderer::Backend { class IDevice; }
      35             : 
      36             : class CParticleManager
      37             : {
      38             : public:
      39             :     CParticleManager(Renderer::Backend::IDevice& device);
      40             :     ~CParticleManager();
      41             : 
      42             :     CParticleEmitterType* LoadEmitterType(const VfsPath& path);
      43             : 
      44             :     /**
      45             :      * Tell the manager to handle rendering of an emitter that is no longer
      46             :      * attached to a unit. After the call the emitter becomes inactive.
      47             :      *
      48             :      * This should be called before dropping the emitter so that the manager
      49             :      * will carry on rendering (until all particles have dissipated)
      50             :      * even when it's no longer attached to a model.
      51             :      */
      52             :     void AddUnattachedEmitter(std::unique_ptr<CParticleEmitter> emitter);
      53             : 
      54             :     /**
      55             :      * Delete unattached emitters if we don't wish to see them anymore (like in actor viewer)
      56             :      */
      57             :     void ClearUnattachedEmitters();
      58             : 
      59             :     void RenderSubmit(SceneCollector& collector, const CFrustum& frustum);
      60             : 
      61             :     void Interpolate(const float simFrameLength);
      62             : 
      63           0 :     float GetCurrentTime() const { return m_CurrentTime; }
      64             : 
      65             :     Status ReloadChangedFile(const VfsPath& path);
      66             : 
      67           0 :     bool ShouldUseInstancing() const { return m_UseInstancing; }
      68             : 
      69             :     /// Random number generator shared between all particle emitters.
      70             :     std::mt19937 m_RNG;
      71             : 
      72             : private:
      73             :     float m_CurrentTime{0.0f};
      74             : 
      75             :     std::vector<std::unique_ptr<CParticleEmitter>> m_UnattachedEmitters;
      76             : 
      77             :     std::unordered_map<VfsPath, std::unique_ptr<CParticleEmitterType>> m_EmitterTypes;
      78             : 
      79             :     bool m_UseInstancing{false};
      80             : };
      81             : 
      82             : #endif // INCLUDED_PARTICLEMANAGER

Generated by: LCOV version 1.16