diff --git a/include/Nazara/Graphics.hpp b/include/Nazara/Graphics.hpp index 17b10e9a1..4809d9481 100644 --- a/include/Nazara/Graphics.hpp +++ b/include/Nazara/Graphics.hpp @@ -63,10 +63,10 @@ #include #include #include +#include #include #include #include -#include #include #include #include diff --git a/include/Nazara/Graphics/ParticleController.hpp b/include/Nazara/Graphics/ParticleController.hpp index 17e4ac9e1..05537ba55 100644 --- a/include/Nazara/Graphics/ParticleController.hpp +++ b/include/Nazara/Graphics/ParticleController.hpp @@ -18,7 +18,7 @@ namespace Nz { class ParticleController; class ParticleMapper; - class ParticleSystem; + class ParticleGroup; using ParticleControllerConstRef = ObjectRef; using ParticleControllerLibrary = ObjectLibrary; @@ -34,7 +34,7 @@ namespace Nz ParticleController(const ParticleController& controller); virtual ~ParticleController(); - virtual void Apply(ParticleSystem& system, ParticleMapper& mapper, unsigned int startId, unsigned int endId, float elapsedTime) = 0; + virtual void Apply(ParticleGroup& system, ParticleMapper& mapper, unsigned int startId, unsigned int endId, float elapsedTime) = 0; // Signals: NazaraSignal(OnParticleControllerRelease, const ParticleController* /*particleController*/); diff --git a/include/Nazara/Graphics/ParticleEmitter.hpp b/include/Nazara/Graphics/ParticleEmitter.hpp index d5e3c8ea8..b6acee156 100644 --- a/include/Nazara/Graphics/ParticleEmitter.hpp +++ b/include/Nazara/Graphics/ParticleEmitter.hpp @@ -14,7 +14,7 @@ namespace Nz { class ParticleMapper; - class ParticleSystem; + class ParticleGroup; class NAZARA_GRAPHICS_API ParticleEmitter : public Node { @@ -24,7 +24,7 @@ namespace Nz ParticleEmitter(ParticleEmitter&& emitter) = default; virtual ~ParticleEmitter(); - virtual void Emit(ParticleSystem& system, float elapsedTime) const; + virtual void Emit(ParticleGroup& system, float elapsedTime) const; void EnableLagCompensation(bool enable); diff --git a/include/Nazara/Graphics/ParticleGenerator.hpp b/include/Nazara/Graphics/ParticleGenerator.hpp index d9d2a789a..d072ae346 100644 --- a/include/Nazara/Graphics/ParticleGenerator.hpp +++ b/include/Nazara/Graphics/ParticleGenerator.hpp @@ -18,7 +18,7 @@ namespace Nz { class ParticleGenerator; class ParticleMapper; - class ParticleSystem; + class ParticleGroup; using ParticleGeneratorConstRef = ObjectRef; using ParticleGeneratorLibrary = ObjectLibrary; @@ -34,7 +34,7 @@ namespace Nz ParticleGenerator(const ParticleGenerator& generator); virtual ~ParticleGenerator(); - virtual void Generate(ParticleSystem& system, ParticleMapper& mapper, unsigned int startId, unsigned int endId) = 0; + virtual void Generate(ParticleGroup& system, ParticleMapper& mapper, unsigned int startId, unsigned int endId) = 0; // Signals: NazaraSignal(OnParticleGeneratorRelease, const ParticleGenerator* /*particleGenerator*/); diff --git a/include/Nazara/Graphics/ParticleSystem.hpp b/include/Nazara/Graphics/ParticleGroup.hpp similarity index 84% rename from include/Nazara/Graphics/ParticleSystem.hpp rename to include/Nazara/Graphics/ParticleGroup.hpp index 76b834f6e..aaa65bb7f 100644 --- a/include/Nazara/Graphics/ParticleSystem.hpp +++ b/include/Nazara/Graphics/ParticleGroup.hpp @@ -4,8 +4,8 @@ #pragma once -#ifndef NAZARA_PARTICLESYSTEM_HPP -#define NAZARA_PARTICLESYSTEM_HPP +#ifndef NAZARA_PARTICLEGROUP_HPP +#define NAZARA_PARTICLEGROUP_HPP #include #include @@ -22,13 +22,13 @@ namespace Nz { - class NAZARA_GRAPHICS_API ParticleSystem : public Renderable + class NAZARA_GRAPHICS_API ParticleGroup : public Renderable { public: - ParticleSystem(unsigned int maxParticleCount, ParticleLayout layout); - ParticleSystem(unsigned int maxParticleCount, ParticleDeclarationConstRef declaration); - ParticleSystem(const ParticleSystem& emitter); - ~ParticleSystem(); + ParticleGroup(unsigned int maxParticleCount, ParticleLayout layout); + ParticleGroup(unsigned int maxParticleCount, ParticleDeclarationConstRef declaration); + ParticleGroup(const ParticleGroup& emitter); + ~ParticleGroup(); void AddController(ParticleControllerRef controller); void AddEmitter(ParticleEmitter* emitter); @@ -66,7 +66,7 @@ namespace Nz void Update(float elapsedTime); void UpdateBoundingVolume(const Matrix4f& transformMatrix) override; - ParticleSystem& operator=(const ParticleSystem& emitter); + ParticleGroup& operator=(const ParticleGroup& emitter); private: void MakeBoundingVolume() const override; @@ -89,4 +89,4 @@ namespace Nz }; } -#endif // NAZARA_PARTICLESYSTEM_HPP +#endif // NAZARA_PARTICLEGROUP_HPP diff --git a/include/Nazara/Graphics/ParticleRenderer.hpp b/include/Nazara/Graphics/ParticleRenderer.hpp index d79d448f2..2ddca18b3 100644 --- a/include/Nazara/Graphics/ParticleRenderer.hpp +++ b/include/Nazara/Graphics/ParticleRenderer.hpp @@ -19,7 +19,7 @@ namespace Nz class AbstractRenderQueue; class ParticleMapper; class ParticleRenderer; - class ParticleSystem; + class ParticleGroup; using ParticleRendererConstRef = ObjectRef; using ParticleRendererLibrary = ObjectLibrary; @@ -35,7 +35,7 @@ namespace Nz ParticleRenderer(const ParticleRenderer& renderer); virtual ~ParticleRenderer(); - virtual void Render(const ParticleSystem& system, const ParticleMapper& mapper, unsigned int startId, unsigned int endId, AbstractRenderQueue* renderQueue) = 0; + virtual void Render(const ParticleGroup& system, const ParticleMapper& mapper, unsigned int startId, unsigned int endId, AbstractRenderQueue* renderQueue) = 0; // Signals: NazaraSignal(OnParticleRendererRelease, const ParticleRenderer* /*particleRenderer*/); diff --git a/src/Nazara/Graphics/ParticleEmitter.cpp b/src/Nazara/Graphics/ParticleEmitter.cpp index ded77d80e..b11cfdfe9 100644 --- a/src/Nazara/Graphics/ParticleEmitter.cpp +++ b/src/Nazara/Graphics/ParticleEmitter.cpp @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include #include #include @@ -41,7 +41,7 @@ namespace Nz * \param elapsedTime Delta time between the previous frame */ - void ParticleEmitter::Emit(ParticleSystem& system, float elapsedTime) const + void ParticleEmitter::Emit(ParticleGroup& system, float elapsedTime) const { if (m_emissionRate > 0.f) { diff --git a/src/Nazara/Graphics/ParticleSystem.cpp b/src/Nazara/Graphics/ParticleGroup.cpp similarity index 83% rename from src/Nazara/Graphics/ParticleSystem.cpp rename to src/Nazara/Graphics/ParticleGroup.cpp index 0783dd7fd..08fb03f39 100644 --- a/src/Nazara/Graphics/ParticleSystem.cpp +++ b/src/Nazara/Graphics/ParticleGroup.cpp @@ -2,7 +2,7 @@ // This file is part of the "Nazara Engine - Graphics module" // For conditions of distribution and use, see copyright notice in Config.hpp -#include +#include #include #include #include @@ -26,8 +26,8 @@ namespace Nz * \param layout Enumeration for the layout of data information for the particles */ - ParticleSystem::ParticleSystem(unsigned int maxParticleCount, ParticleLayout layout) : - ParticleSystem(maxParticleCount, ParticleDeclaration::Get(layout)) + ParticleGroup::ParticleGroup(unsigned int maxParticleCount, ParticleLayout layout) : + ParticleGroup(maxParticleCount, ParticleDeclaration::Get(layout)) { } @@ -38,7 +38,7 @@ namespace Nz * \param declaration Data information for the particles */ - ParticleSystem::ParticleSystem(unsigned int maxParticleCount, ParticleDeclarationConstRef declaration) : + ParticleGroup::ParticleGroup(unsigned int maxParticleCount, ParticleDeclarationConstRef declaration) : m_declaration(std::move(declaration)), m_processing(false), m_maxParticleCount(maxParticleCount), @@ -58,7 +58,7 @@ namespace Nz * \param system ParticleSystem to copy into this */ - ParticleSystem::ParticleSystem(const ParticleSystem& system) : + ParticleGroup::ParticleGroup(const ParticleGroup& system) : Renderable(system), m_controllers(system.m_controllers), m_generators(system.m_generators), @@ -77,7 +77,7 @@ namespace Nz std::memcpy(m_buffer.data(), system.m_buffer.data(), system.m_particleCount*m_particleSize); } - ParticleSystem::~ParticleSystem() = default; + ParticleGroup::~ParticleGroup() = default; /*! * \brief Adds a controller to the particles @@ -87,7 +87,7 @@ namespace Nz * \remark Produces a NazaraAssert if controller is invalid */ - void ParticleSystem::AddController(ParticleControllerRef controller) + void ParticleGroup::AddController(ParticleControllerRef controller) { NazaraAssert(controller, "Invalid particle controller"); @@ -102,7 +102,7 @@ namespace Nz * \remark Produces a NazaraAssert if emitter is invalid */ - void ParticleSystem::AddEmitter(ParticleEmitter* emitter) + void ParticleGroup::AddEmitter(ParticleEmitter* emitter) { NazaraAssert(emitter, "Invalid particle emitter"); @@ -117,7 +117,7 @@ namespace Nz * \remark Produces a NazaraAssert if generator is invalid */ - void ParticleSystem::AddGenerator(ParticleGeneratorRef generator) + void ParticleGroup::AddGenerator(ParticleGeneratorRef generator) { NazaraAssert(generator, "Invalid particle generator"); @@ -134,7 +134,7 @@ namespace Nz * \remark Produces a NazaraAssert if renderQueue is invalid */ - void ParticleSystem::AddToRenderQueue(AbstractRenderQueue* renderQueue, const Matrix4f& transformMatrix) const + void ParticleGroup::AddToRenderQueue(AbstractRenderQueue* renderQueue, const Matrix4f& transformMatrix) const { NazaraAssert(m_renderer, "Invalid particle renderer"); NazaraAssert(renderQueue, "Invalid renderqueue"); @@ -155,7 +155,7 @@ namespace Nz * \param elapsedTime Delta time between the previous frame */ - void ParticleSystem::ApplyControllers(ParticleMapper& mapper, unsigned int particleCount, float elapsedTime) + void ParticleGroup::ApplyControllers(ParticleMapper& mapper, unsigned int particleCount, float elapsedTime) { m_processing = true; @@ -190,7 +190,7 @@ namespace Nz * \return Pointer to the particle memory buffer */ - void* ParticleSystem::CreateParticle() + void* ParticleGroup::CreateParticle() { return CreateParticles(1); } @@ -200,7 +200,7 @@ namespace Nz * \return Pointer to the first particle memory buffer */ - void* ParticleSystem::CreateParticles(unsigned int count) + void* ParticleGroup::CreateParticles(unsigned int count) { if (count == 0) return nullptr; @@ -219,7 +219,7 @@ namespace Nz * \return Pointer to the particle memory buffer */ - void* ParticleSystem::GenerateParticle() + void* ParticleGroup::GenerateParticle() { return GenerateParticles(1); } @@ -229,7 +229,7 @@ namespace Nz * \return Pointer to the first particle memory buffer */ - void* ParticleSystem::GenerateParticles(unsigned int count) + void* ParticleGroup::GenerateParticles(unsigned int count) { void* ptr = CreateParticles(count); if (!ptr) @@ -247,7 +247,7 @@ namespace Nz * \return Particle declaration */ - const ParticleDeclarationConstRef& ParticleSystem::GetDeclaration() const + const ParticleDeclarationConstRef& ParticleGroup::GetDeclaration() const { return m_declaration; } @@ -257,7 +257,7 @@ namespace Nz * \return Current fixed step size */ - float ParticleSystem::GetFixedStepSize() const + float ParticleGroup::GetFixedStepSize() const { return m_stepSize; } @@ -267,7 +267,7 @@ namespace Nz * \return Current maximum number */ - unsigned int ParticleSystem::GetMaxParticleCount() const + unsigned int ParticleGroup::GetMaxParticleCount() const { return m_maxParticleCount; } @@ -277,7 +277,7 @@ namespace Nz * \return Current number */ - unsigned int ParticleSystem::GetParticleCount() const + unsigned int ParticleGroup::GetParticleCount() const { return m_particleCount; } @@ -287,7 +287,7 @@ namespace Nz * \return Current size */ - unsigned int ParticleSystem::GetParticleSize() const + unsigned int ParticleGroup::GetParticleSize() const { return m_particleSize; } @@ -297,7 +297,7 @@ namespace Nz * \return true If it is the case */ - bool ParticleSystem::IsFixedStepEnabled() const + bool ParticleGroup::IsFixedStepEnabled() const { return m_fixedStepEnabled; } @@ -308,7 +308,7 @@ namespace Nz * \param index Index of the particle */ - void ParticleSystem::KillParticle(unsigned int index) + void ParticleGroup::KillParticle(unsigned int index) { ///FIXME: Verify the index @@ -328,7 +328,7 @@ namespace Nz * \brief Kills every particles */ - void ParticleSystem::KillParticles() + void ParticleGroup::KillParticles() { m_particleCount = 0; } @@ -339,7 +339,7 @@ namespace Nz * \param controller Controller for the particles to remove */ - void ParticleSystem::RemoveController(ParticleController* controller) + void ParticleGroup::RemoveController(ParticleController* controller) { auto it = std::find(m_controllers.begin(), m_controllers.end(), controller); if (it != m_controllers.end()) @@ -352,7 +352,7 @@ namespace Nz * \param emitter Emitter for the particles to remove */ - void ParticleSystem::RemoveEmitter(ParticleEmitter* emitter) + void ParticleGroup::RemoveEmitter(ParticleEmitter* emitter) { auto it = std::find(m_emitters.begin(), m_emitters.end(), emitter); if (it != m_emitters.end()) @@ -365,7 +365,7 @@ namespace Nz * \param generator Generator for the particles to remove */ - void ParticleSystem::RemoveGenerator(ParticleGenerator* generator) + void ParticleGroup::RemoveGenerator(ParticleGenerator* generator) { auto it = std::find(m_generators.begin(), m_generators.end(), generator); if (it != m_generators.end()) @@ -378,7 +378,7 @@ namespace Nz * \param stepSize Fixed step size */ - void ParticleSystem::SetFixedStepSize(float stepSize) + void ParticleGroup::SetFixedStepSize(float stepSize) { m_stepSize = stepSize; } @@ -389,7 +389,7 @@ namespace Nz * \param renderer Renderer for the particles */ - void ParticleSystem::SetRenderer(ParticleRenderer* renderer) + void ParticleGroup::SetRenderer(ParticleRenderer* renderer) { m_renderer = renderer; } @@ -400,7 +400,7 @@ namespace Nz * \param elapsedTime Delta time between the previous frame */ - void ParticleSystem::Update(float elapsedTime) + void ParticleGroup::Update(float elapsedTime) { // Emission for (ParticleEmitter* emitter : m_emitters) @@ -421,7 +421,7 @@ namespace Nz * \param transformMatrix Matrix transformation for our bounding volume */ - void ParticleSystem::UpdateBoundingVolume(const Matrix4f& transformMatrix) + void ParticleGroup::UpdateBoundingVolume(const Matrix4f& transformMatrix) { NazaraUnused(transformMatrix); @@ -435,7 +435,7 @@ namespace Nz * \param system The other ParticleSystem */ - ParticleSystem& ParticleSystem::operator=(const ParticleSystem& system) + ParticleGroup& ParticleGroup::operator=(const ParticleGroup& system) { ErrorFlags flags(ErrorFlag_ThrowException, true); @@ -468,7 +468,7 @@ namespace Nz * \brief Makes the bounding volume of this text */ - void ParticleSystem::MakeBoundingVolume() const + void ParticleGroup::MakeBoundingVolume() const { ///TODO: Compute the AABB (taking into account the size of particles) m_boundingVolume.MakeInfinite(); @@ -480,7 +480,7 @@ namespace Nz * \remark Produces a NazaraError if resize did not work */ - void ParticleSystem::ResizeBuffer() + void ParticleGroup::ResizeBuffer() { // Just to have a better description of our problem in case of error try diff --git a/tests/Engine/Graphics/ParticleSystem.cpp b/tests/Engine/Graphics/ParticleGroup.cpp similarity index 75% rename from tests/Engine/Graphics/ParticleSystem.cpp rename to tests/Engine/Graphics/ParticleGroup.cpp index 32f5f01f9..36ad2cb0b 100644 --- a/tests/Engine/Graphics/ParticleSystem.cpp +++ b/tests/Engine/Graphics/ParticleGroup.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include @@ -8,7 +8,7 @@ class TestParticleController : public Nz::ParticleController { public: // Be aware that the interval is [startId, endId] and NOT [startId, endId) - void Apply(Nz::ParticleSystem& system, Nz::ParticleMapper& mapper, unsigned int startId, unsigned int endId, float elapsedTime) override + void Apply(Nz::ParticleGroup& system, Nz::ParticleMapper& mapper, unsigned int startId, unsigned int endId, float elapsedTime) override { Nz::SparsePtr positionPtr = mapper.GetComponentPtr(Nz::ParticleComponent_Position); Nz::SparsePtr velocityPtr = mapper.GetComponentPtr(Nz::ParticleComponent_Velocity); @@ -32,7 +32,7 @@ class TestParticleEmitter : public Nz::ParticleEmitter public: ~TestParticleEmitter() override = default; - void Emit(Nz::ParticleSystem& system, float elapsedTime) const override + void Emit(Nz::ParticleGroup& system, float elapsedTime) const override { system.GenerateParticles(GetEmissionCount()); } @@ -49,7 +49,7 @@ class TestParticleGenerator : public Nz::ParticleGenerator ~TestParticleGenerator() override = default; // Be aware that the interval is [startId, endId] and NOT [startId, endId) - void Generate(Nz::ParticleSystem& system, Nz::ParticleMapper& mapper, unsigned int startId, unsigned int endId) override + void Generate(Nz::ParticleGroup& system, Nz::ParticleMapper& mapper, unsigned int startId, unsigned int endId) override { Nz::SparsePtr positionPtr = mapper.GetComponentPtr(Nz::ParticleComponent_Position); Nz::SparsePtr velocityPtr = mapper.GetComponentPtr(Nz::ParticleComponent_Velocity); @@ -68,35 +68,35 @@ class TestParticleGenerator : public Nz::ParticleGenerator } }; -SCENARIO("ParticleSystem", "[GRAPHICS][PARTICLESYSTEM]") +SCENARIO("ParticleGroup", "[GRAPHICS][PARTICLEGROUP]") { GIVEN("A particle system of maximum 10 billboards with its generators") { // These need to be alive longer than the particle system TestParticleController particleController; TestParticleGenerator particleGenerator; - Nz::ParticleSystem particleSystem(10, Nz::ParticleLayout_Billboard); + Nz::ParticleGroup particleGroup(10, Nz::ParticleLayout_Billboard); - particleSystem.AddController(&particleController); + particleGroup.AddController(&particleController); TestParticleEmitter particleEmitter; particleEmitter.SetEmissionCount(10); - particleSystem.AddEmitter(&particleEmitter); + particleGroup.AddEmitter(&particleEmitter); - particleSystem.AddGenerator(&particleGenerator); + particleGroup.AddGenerator(&particleGenerator); WHEN("We update to generate 10 particles") { - particleSystem.Update(1.f); + particleGroup.Update(1.f); THEN("There must be 10 particles") { - REQUIRE(particleSystem.GetParticleCount() == 10); + REQUIRE(particleGroup.GetParticleCount() == 10); } AND_THEN("We update to make them die") { - particleSystem.Update(2.f); - REQUIRE(particleSystem.GetParticleCount() == 0); + particleGroup.Update(2.f); + REQUIRE(particleGroup.GetParticleCount() == 0); } } }