Graphics: Rename ParticleSystem to ParticleGroup
Preparing for integration into the ECS Former-commit-id: 201e28c9f00ee31f809d9de3d9a37f57a7fe740c [formerly 9b88616308f9801482fc8811a9a19a7231dce2a7] Former-commit-id: 579f4e9597f94620f922fb145931202d8fc9cc96
This commit is contained in:
parent
364cbed673
commit
9fa7267523
|
|
@ -63,10 +63,10 @@
|
||||||
#include <Nazara/Graphics/ParticleDeclaration.hpp>
|
#include <Nazara/Graphics/ParticleDeclaration.hpp>
|
||||||
#include <Nazara/Graphics/ParticleEmitter.hpp>
|
#include <Nazara/Graphics/ParticleEmitter.hpp>
|
||||||
#include <Nazara/Graphics/ParticleGenerator.hpp>
|
#include <Nazara/Graphics/ParticleGenerator.hpp>
|
||||||
|
#include <Nazara/Graphics/ParticleGroup.hpp>
|
||||||
#include <Nazara/Graphics/ParticleMapper.hpp>
|
#include <Nazara/Graphics/ParticleMapper.hpp>
|
||||||
#include <Nazara/Graphics/ParticleRenderer.hpp>
|
#include <Nazara/Graphics/ParticleRenderer.hpp>
|
||||||
#include <Nazara/Graphics/ParticleStruct.hpp>
|
#include <Nazara/Graphics/ParticleStruct.hpp>
|
||||||
#include <Nazara/Graphics/ParticleSystem.hpp>
|
|
||||||
#include <Nazara/Graphics/Renderable.hpp>
|
#include <Nazara/Graphics/Renderable.hpp>
|
||||||
#include <Nazara/Graphics/RenderTechniques.hpp>
|
#include <Nazara/Graphics/RenderTechniques.hpp>
|
||||||
#include <Nazara/Graphics/SceneData.hpp>
|
#include <Nazara/Graphics/SceneData.hpp>
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ namespace Nz
|
||||||
{
|
{
|
||||||
class ParticleController;
|
class ParticleController;
|
||||||
class ParticleMapper;
|
class ParticleMapper;
|
||||||
class ParticleSystem;
|
class ParticleGroup;
|
||||||
|
|
||||||
using ParticleControllerConstRef = ObjectRef<const ParticleController>;
|
using ParticleControllerConstRef = ObjectRef<const ParticleController>;
|
||||||
using ParticleControllerLibrary = ObjectLibrary<ParticleController>;
|
using ParticleControllerLibrary = ObjectLibrary<ParticleController>;
|
||||||
|
|
@ -34,7 +34,7 @@ namespace Nz
|
||||||
ParticleController(const ParticleController& controller);
|
ParticleController(const ParticleController& controller);
|
||||||
virtual ~ParticleController();
|
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:
|
// Signals:
|
||||||
NazaraSignal(OnParticleControllerRelease, const ParticleController* /*particleController*/);
|
NazaraSignal(OnParticleControllerRelease, const ParticleController* /*particleController*/);
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
namespace Nz
|
namespace Nz
|
||||||
{
|
{
|
||||||
class ParticleMapper;
|
class ParticleMapper;
|
||||||
class ParticleSystem;
|
class ParticleGroup;
|
||||||
|
|
||||||
class NAZARA_GRAPHICS_API ParticleEmitter : public Node
|
class NAZARA_GRAPHICS_API ParticleEmitter : public Node
|
||||||
{
|
{
|
||||||
|
|
@ -24,7 +24,7 @@ namespace Nz
|
||||||
ParticleEmitter(ParticleEmitter&& emitter) = default;
|
ParticleEmitter(ParticleEmitter&& emitter) = default;
|
||||||
virtual ~ParticleEmitter();
|
virtual ~ParticleEmitter();
|
||||||
|
|
||||||
virtual void Emit(ParticleSystem& system, float elapsedTime) const;
|
virtual void Emit(ParticleGroup& system, float elapsedTime) const;
|
||||||
|
|
||||||
void EnableLagCompensation(bool enable);
|
void EnableLagCompensation(bool enable);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ namespace Nz
|
||||||
{
|
{
|
||||||
class ParticleGenerator;
|
class ParticleGenerator;
|
||||||
class ParticleMapper;
|
class ParticleMapper;
|
||||||
class ParticleSystem;
|
class ParticleGroup;
|
||||||
|
|
||||||
using ParticleGeneratorConstRef = ObjectRef<const ParticleGenerator>;
|
using ParticleGeneratorConstRef = ObjectRef<const ParticleGenerator>;
|
||||||
using ParticleGeneratorLibrary = ObjectLibrary<ParticleGenerator>;
|
using ParticleGeneratorLibrary = ObjectLibrary<ParticleGenerator>;
|
||||||
|
|
@ -34,7 +34,7 @@ namespace Nz
|
||||||
ParticleGenerator(const ParticleGenerator& generator);
|
ParticleGenerator(const ParticleGenerator& generator);
|
||||||
virtual ~ParticleGenerator();
|
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:
|
// Signals:
|
||||||
NazaraSignal(OnParticleGeneratorRelease, const ParticleGenerator* /*particleGenerator*/);
|
NazaraSignal(OnParticleGeneratorRelease, const ParticleGenerator* /*particleGenerator*/);
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#ifndef NAZARA_PARTICLESYSTEM_HPP
|
#ifndef NAZARA_PARTICLEGROUP_HPP
|
||||||
#define NAZARA_PARTICLESYSTEM_HPP
|
#define NAZARA_PARTICLEGROUP_HPP
|
||||||
|
|
||||||
#include <Nazara/Prerequesites.hpp>
|
#include <Nazara/Prerequesites.hpp>
|
||||||
#include <Nazara/Graphics/ParticleController.hpp>
|
#include <Nazara/Graphics/ParticleController.hpp>
|
||||||
|
|
@ -22,13 +22,13 @@
|
||||||
|
|
||||||
namespace Nz
|
namespace Nz
|
||||||
{
|
{
|
||||||
class NAZARA_GRAPHICS_API ParticleSystem : public Renderable
|
class NAZARA_GRAPHICS_API ParticleGroup : public Renderable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ParticleSystem(unsigned int maxParticleCount, ParticleLayout layout);
|
ParticleGroup(unsigned int maxParticleCount, ParticleLayout layout);
|
||||||
ParticleSystem(unsigned int maxParticleCount, ParticleDeclarationConstRef declaration);
|
ParticleGroup(unsigned int maxParticleCount, ParticleDeclarationConstRef declaration);
|
||||||
ParticleSystem(const ParticleSystem& emitter);
|
ParticleGroup(const ParticleGroup& emitter);
|
||||||
~ParticleSystem();
|
~ParticleGroup();
|
||||||
|
|
||||||
void AddController(ParticleControllerRef controller);
|
void AddController(ParticleControllerRef controller);
|
||||||
void AddEmitter(ParticleEmitter* emitter);
|
void AddEmitter(ParticleEmitter* emitter);
|
||||||
|
|
@ -66,7 +66,7 @@ namespace Nz
|
||||||
void Update(float elapsedTime);
|
void Update(float elapsedTime);
|
||||||
void UpdateBoundingVolume(const Matrix4f& transformMatrix) override;
|
void UpdateBoundingVolume(const Matrix4f& transformMatrix) override;
|
||||||
|
|
||||||
ParticleSystem& operator=(const ParticleSystem& emitter);
|
ParticleGroup& operator=(const ParticleGroup& emitter);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void MakeBoundingVolume() const override;
|
void MakeBoundingVolume() const override;
|
||||||
|
|
@ -89,4 +89,4 @@ namespace Nz
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // NAZARA_PARTICLESYSTEM_HPP
|
#endif // NAZARA_PARTICLEGROUP_HPP
|
||||||
|
|
@ -19,7 +19,7 @@ namespace Nz
|
||||||
class AbstractRenderQueue;
|
class AbstractRenderQueue;
|
||||||
class ParticleMapper;
|
class ParticleMapper;
|
||||||
class ParticleRenderer;
|
class ParticleRenderer;
|
||||||
class ParticleSystem;
|
class ParticleGroup;
|
||||||
|
|
||||||
using ParticleRendererConstRef = ObjectRef<const ParticleRenderer>;
|
using ParticleRendererConstRef = ObjectRef<const ParticleRenderer>;
|
||||||
using ParticleRendererLibrary = ObjectLibrary<ParticleRenderer>;
|
using ParticleRendererLibrary = ObjectLibrary<ParticleRenderer>;
|
||||||
|
|
@ -35,7 +35,7 @@ namespace Nz
|
||||||
ParticleRenderer(const ParticleRenderer& renderer);
|
ParticleRenderer(const ParticleRenderer& renderer);
|
||||||
virtual ~ParticleRenderer();
|
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:
|
// Signals:
|
||||||
NazaraSignal(OnParticleRendererRelease, const ParticleRenderer* /*particleRenderer*/);
|
NazaraSignal(OnParticleRendererRelease, const ParticleRenderer* /*particleRenderer*/);
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
#include <Nazara/Core/ErrorFlags.hpp>
|
#include <Nazara/Core/ErrorFlags.hpp>
|
||||||
#include <Nazara/Core/StringStream.hpp>
|
#include <Nazara/Core/StringStream.hpp>
|
||||||
#include <Nazara/Graphics/ParticleMapper.hpp>
|
#include <Nazara/Graphics/ParticleMapper.hpp>
|
||||||
#include <Nazara/Graphics/ParticleSystem.hpp>
|
#include <Nazara/Graphics/ParticleGroup.hpp>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <Nazara/Graphics/Debug.hpp>
|
#include <Nazara/Graphics/Debug.hpp>
|
||||||
|
|
@ -41,7 +41,7 @@ namespace Nz
|
||||||
* \param elapsedTime Delta time between the previous frame
|
* \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)
|
if (m_emissionRate > 0.f)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
// This file is part of the "Nazara Engine - Graphics module"
|
// This file is part of the "Nazara Engine - Graphics module"
|
||||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||||
|
|
||||||
#include <Nazara/Graphics/ParticleSystem.hpp>
|
#include <Nazara/Graphics/ParticleGroup.hpp>
|
||||||
#include <Nazara/Core/CallOnExit.hpp>
|
#include <Nazara/Core/CallOnExit.hpp>
|
||||||
#include <Nazara/Core/ErrorFlags.hpp>
|
#include <Nazara/Core/ErrorFlags.hpp>
|
||||||
#include <Nazara/Core/StringStream.hpp>
|
#include <Nazara/Core/StringStream.hpp>
|
||||||
|
|
@ -26,8 +26,8 @@ namespace Nz
|
||||||
* \param layout Enumeration for the layout of data information for the particles
|
* \param layout Enumeration for the layout of data information for the particles
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ParticleSystem::ParticleSystem(unsigned int maxParticleCount, ParticleLayout layout) :
|
ParticleGroup::ParticleGroup(unsigned int maxParticleCount, ParticleLayout layout) :
|
||||||
ParticleSystem(maxParticleCount, ParticleDeclaration::Get(layout))
|
ParticleGroup(maxParticleCount, ParticleDeclaration::Get(layout))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -38,7 +38,7 @@ namespace Nz
|
||||||
* \param declaration Data information for the particles
|
* \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_declaration(std::move(declaration)),
|
||||||
m_processing(false),
|
m_processing(false),
|
||||||
m_maxParticleCount(maxParticleCount),
|
m_maxParticleCount(maxParticleCount),
|
||||||
|
|
@ -58,7 +58,7 @@ namespace Nz
|
||||||
* \param system ParticleSystem to copy into this
|
* \param system ParticleSystem to copy into this
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ParticleSystem::ParticleSystem(const ParticleSystem& system) :
|
ParticleGroup::ParticleGroup(const ParticleGroup& system) :
|
||||||
Renderable(system),
|
Renderable(system),
|
||||||
m_controllers(system.m_controllers),
|
m_controllers(system.m_controllers),
|
||||||
m_generators(system.m_generators),
|
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);
|
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
|
* \brief Adds a controller to the particles
|
||||||
|
|
@ -87,7 +87,7 @@ namespace Nz
|
||||||
* \remark Produces a NazaraAssert if controller is invalid
|
* \remark Produces a NazaraAssert if controller is invalid
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void ParticleSystem::AddController(ParticleControllerRef controller)
|
void ParticleGroup::AddController(ParticleControllerRef controller)
|
||||||
{
|
{
|
||||||
NazaraAssert(controller, "Invalid particle controller");
|
NazaraAssert(controller, "Invalid particle controller");
|
||||||
|
|
||||||
|
|
@ -102,7 +102,7 @@ namespace Nz
|
||||||
* \remark Produces a NazaraAssert if emitter is invalid
|
* \remark Produces a NazaraAssert if emitter is invalid
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void ParticleSystem::AddEmitter(ParticleEmitter* emitter)
|
void ParticleGroup::AddEmitter(ParticleEmitter* emitter)
|
||||||
{
|
{
|
||||||
NazaraAssert(emitter, "Invalid particle emitter");
|
NazaraAssert(emitter, "Invalid particle emitter");
|
||||||
|
|
||||||
|
|
@ -117,7 +117,7 @@ namespace Nz
|
||||||
* \remark Produces a NazaraAssert if generator is invalid
|
* \remark Produces a NazaraAssert if generator is invalid
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void ParticleSystem::AddGenerator(ParticleGeneratorRef generator)
|
void ParticleGroup::AddGenerator(ParticleGeneratorRef generator)
|
||||||
{
|
{
|
||||||
NazaraAssert(generator, "Invalid particle generator");
|
NazaraAssert(generator, "Invalid particle generator");
|
||||||
|
|
||||||
|
|
@ -134,7 +134,7 @@ namespace Nz
|
||||||
* \remark Produces a NazaraAssert if renderQueue is invalid
|
* \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(m_renderer, "Invalid particle renderer");
|
||||||
NazaraAssert(renderQueue, "Invalid renderqueue");
|
NazaraAssert(renderQueue, "Invalid renderqueue");
|
||||||
|
|
@ -155,7 +155,7 @@ namespace Nz
|
||||||
* \param elapsedTime Delta time between the previous frame
|
* \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;
|
m_processing = true;
|
||||||
|
|
||||||
|
|
@ -190,7 +190,7 @@ namespace Nz
|
||||||
* \return Pointer to the particle memory buffer
|
* \return Pointer to the particle memory buffer
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void* ParticleSystem::CreateParticle()
|
void* ParticleGroup::CreateParticle()
|
||||||
{
|
{
|
||||||
return CreateParticles(1);
|
return CreateParticles(1);
|
||||||
}
|
}
|
||||||
|
|
@ -200,7 +200,7 @@ namespace Nz
|
||||||
* \return Pointer to the first particle memory buffer
|
* \return Pointer to the first particle memory buffer
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void* ParticleSystem::CreateParticles(unsigned int count)
|
void* ParticleGroup::CreateParticles(unsigned int count)
|
||||||
{
|
{
|
||||||
if (count == 0)
|
if (count == 0)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
@ -219,7 +219,7 @@ namespace Nz
|
||||||
* \return Pointer to the particle memory buffer
|
* \return Pointer to the particle memory buffer
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void* ParticleSystem::GenerateParticle()
|
void* ParticleGroup::GenerateParticle()
|
||||||
{
|
{
|
||||||
return GenerateParticles(1);
|
return GenerateParticles(1);
|
||||||
}
|
}
|
||||||
|
|
@ -229,7 +229,7 @@ namespace Nz
|
||||||
* \return Pointer to the first particle memory buffer
|
* \return Pointer to the first particle memory buffer
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void* ParticleSystem::GenerateParticles(unsigned int count)
|
void* ParticleGroup::GenerateParticles(unsigned int count)
|
||||||
{
|
{
|
||||||
void* ptr = CreateParticles(count);
|
void* ptr = CreateParticles(count);
|
||||||
if (!ptr)
|
if (!ptr)
|
||||||
|
|
@ -247,7 +247,7 @@ namespace Nz
|
||||||
* \return Particle declaration
|
* \return Particle declaration
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const ParticleDeclarationConstRef& ParticleSystem::GetDeclaration() const
|
const ParticleDeclarationConstRef& ParticleGroup::GetDeclaration() const
|
||||||
{
|
{
|
||||||
return m_declaration;
|
return m_declaration;
|
||||||
}
|
}
|
||||||
|
|
@ -257,7 +257,7 @@ namespace Nz
|
||||||
* \return Current fixed step size
|
* \return Current fixed step size
|
||||||
*/
|
*/
|
||||||
|
|
||||||
float ParticleSystem::GetFixedStepSize() const
|
float ParticleGroup::GetFixedStepSize() const
|
||||||
{
|
{
|
||||||
return m_stepSize;
|
return m_stepSize;
|
||||||
}
|
}
|
||||||
|
|
@ -267,7 +267,7 @@ namespace Nz
|
||||||
* \return Current maximum number
|
* \return Current maximum number
|
||||||
*/
|
*/
|
||||||
|
|
||||||
unsigned int ParticleSystem::GetMaxParticleCount() const
|
unsigned int ParticleGroup::GetMaxParticleCount() const
|
||||||
{
|
{
|
||||||
return m_maxParticleCount;
|
return m_maxParticleCount;
|
||||||
}
|
}
|
||||||
|
|
@ -277,7 +277,7 @@ namespace Nz
|
||||||
* \return Current number
|
* \return Current number
|
||||||
*/
|
*/
|
||||||
|
|
||||||
unsigned int ParticleSystem::GetParticleCount() const
|
unsigned int ParticleGroup::GetParticleCount() const
|
||||||
{
|
{
|
||||||
return m_particleCount;
|
return m_particleCount;
|
||||||
}
|
}
|
||||||
|
|
@ -287,7 +287,7 @@ namespace Nz
|
||||||
* \return Current size
|
* \return Current size
|
||||||
*/
|
*/
|
||||||
|
|
||||||
unsigned int ParticleSystem::GetParticleSize() const
|
unsigned int ParticleGroup::GetParticleSize() const
|
||||||
{
|
{
|
||||||
return m_particleSize;
|
return m_particleSize;
|
||||||
}
|
}
|
||||||
|
|
@ -297,7 +297,7 @@ namespace Nz
|
||||||
* \return true If it is the case
|
* \return true If it is the case
|
||||||
*/
|
*/
|
||||||
|
|
||||||
bool ParticleSystem::IsFixedStepEnabled() const
|
bool ParticleGroup::IsFixedStepEnabled() const
|
||||||
{
|
{
|
||||||
return m_fixedStepEnabled;
|
return m_fixedStepEnabled;
|
||||||
}
|
}
|
||||||
|
|
@ -308,7 +308,7 @@ namespace Nz
|
||||||
* \param index Index of the particle
|
* \param index Index of the particle
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void ParticleSystem::KillParticle(unsigned int index)
|
void ParticleGroup::KillParticle(unsigned int index)
|
||||||
{
|
{
|
||||||
///FIXME: Verify the index
|
///FIXME: Verify the index
|
||||||
|
|
||||||
|
|
@ -328,7 +328,7 @@ namespace Nz
|
||||||
* \brief Kills every particles
|
* \brief Kills every particles
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void ParticleSystem::KillParticles()
|
void ParticleGroup::KillParticles()
|
||||||
{
|
{
|
||||||
m_particleCount = 0;
|
m_particleCount = 0;
|
||||||
}
|
}
|
||||||
|
|
@ -339,7 +339,7 @@ namespace Nz
|
||||||
* \param controller Controller for the particles to remove
|
* \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);
|
auto it = std::find(m_controllers.begin(), m_controllers.end(), controller);
|
||||||
if (it != m_controllers.end())
|
if (it != m_controllers.end())
|
||||||
|
|
@ -352,7 +352,7 @@ namespace Nz
|
||||||
* \param emitter Emitter for the particles to remove
|
* \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);
|
auto it = std::find(m_emitters.begin(), m_emitters.end(), emitter);
|
||||||
if (it != m_emitters.end())
|
if (it != m_emitters.end())
|
||||||
|
|
@ -365,7 +365,7 @@ namespace Nz
|
||||||
* \param generator Generator for the particles to remove
|
* \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);
|
auto it = std::find(m_generators.begin(), m_generators.end(), generator);
|
||||||
if (it != m_generators.end())
|
if (it != m_generators.end())
|
||||||
|
|
@ -378,7 +378,7 @@ namespace Nz
|
||||||
* \param stepSize Fixed step size
|
* \param stepSize Fixed step size
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void ParticleSystem::SetFixedStepSize(float stepSize)
|
void ParticleGroup::SetFixedStepSize(float stepSize)
|
||||||
{
|
{
|
||||||
m_stepSize = stepSize;
|
m_stepSize = stepSize;
|
||||||
}
|
}
|
||||||
|
|
@ -389,7 +389,7 @@ namespace Nz
|
||||||
* \param renderer Renderer for the particles
|
* \param renderer Renderer for the particles
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void ParticleSystem::SetRenderer(ParticleRenderer* renderer)
|
void ParticleGroup::SetRenderer(ParticleRenderer* renderer)
|
||||||
{
|
{
|
||||||
m_renderer = renderer;
|
m_renderer = renderer;
|
||||||
}
|
}
|
||||||
|
|
@ -400,7 +400,7 @@ namespace Nz
|
||||||
* \param elapsedTime Delta time between the previous frame
|
* \param elapsedTime Delta time between the previous frame
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void ParticleSystem::Update(float elapsedTime)
|
void ParticleGroup::Update(float elapsedTime)
|
||||||
{
|
{
|
||||||
// Emission
|
// Emission
|
||||||
for (ParticleEmitter* emitter : m_emitters)
|
for (ParticleEmitter* emitter : m_emitters)
|
||||||
|
|
@ -421,7 +421,7 @@ namespace Nz
|
||||||
* \param transformMatrix Matrix transformation for our bounding volume
|
* \param transformMatrix Matrix transformation for our bounding volume
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void ParticleSystem::UpdateBoundingVolume(const Matrix4f& transformMatrix)
|
void ParticleGroup::UpdateBoundingVolume(const Matrix4f& transformMatrix)
|
||||||
{
|
{
|
||||||
NazaraUnused(transformMatrix);
|
NazaraUnused(transformMatrix);
|
||||||
|
|
||||||
|
|
@ -435,7 +435,7 @@ namespace Nz
|
||||||
* \param system The other ParticleSystem
|
* \param system The other ParticleSystem
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ParticleSystem& ParticleSystem::operator=(const ParticleSystem& system)
|
ParticleGroup& ParticleGroup::operator=(const ParticleGroup& system)
|
||||||
{
|
{
|
||||||
ErrorFlags flags(ErrorFlag_ThrowException, true);
|
ErrorFlags flags(ErrorFlag_ThrowException, true);
|
||||||
|
|
||||||
|
|
@ -468,7 +468,7 @@ namespace Nz
|
||||||
* \brief Makes the bounding volume of this text
|
* \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)
|
///TODO: Compute the AABB (taking into account the size of particles)
|
||||||
m_boundingVolume.MakeInfinite();
|
m_boundingVolume.MakeInfinite();
|
||||||
|
|
@ -480,7 +480,7 @@ namespace Nz
|
||||||
* \remark Produces a NazaraError if resize did not work
|
* \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
|
// Just to have a better description of our problem in case of error
|
||||||
try
|
try
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#include <Nazara/Graphics/ParticleSystem.hpp>
|
#include <Nazara/Graphics/ParticleGroup.hpp>
|
||||||
#include <Catch/catch.hpp>
|
#include <Catch/catch.hpp>
|
||||||
|
|
||||||
#include <Nazara/Core/SparsePtr.hpp>
|
#include <Nazara/Core/SparsePtr.hpp>
|
||||||
|
|
@ -8,7 +8,7 @@ class TestParticleController : public Nz::ParticleController
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// Be aware that the interval is [startId, endId] and NOT [startId, endId)
|
// 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<Nz::Vector3f> positionPtr = mapper.GetComponentPtr<Nz::Vector3f>(Nz::ParticleComponent_Position);
|
Nz::SparsePtr<Nz::Vector3f> positionPtr = mapper.GetComponentPtr<Nz::Vector3f>(Nz::ParticleComponent_Position);
|
||||||
Nz::SparsePtr<Nz::Vector3f> velocityPtr = mapper.GetComponentPtr<Nz::Vector3f>(Nz::ParticleComponent_Velocity);
|
Nz::SparsePtr<Nz::Vector3f> velocityPtr = mapper.GetComponentPtr<Nz::Vector3f>(Nz::ParticleComponent_Velocity);
|
||||||
|
|
@ -32,7 +32,7 @@ class TestParticleEmitter : public Nz::ParticleEmitter
|
||||||
public:
|
public:
|
||||||
~TestParticleEmitter() override = default;
|
~TestParticleEmitter() override = default;
|
||||||
|
|
||||||
void Emit(Nz::ParticleSystem& system, float elapsedTime) const override
|
void Emit(Nz::ParticleGroup& system, float elapsedTime) const override
|
||||||
{
|
{
|
||||||
system.GenerateParticles(GetEmissionCount());
|
system.GenerateParticles(GetEmissionCount());
|
||||||
}
|
}
|
||||||
|
|
@ -49,7 +49,7 @@ class TestParticleGenerator : public Nz::ParticleGenerator
|
||||||
~TestParticleGenerator() override = default;
|
~TestParticleGenerator() override = default;
|
||||||
|
|
||||||
// Be aware that the interval is [startId, endId] and NOT [startId, endId)
|
// 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<Nz::Vector3f> positionPtr = mapper.GetComponentPtr<Nz::Vector3f>(Nz::ParticleComponent_Position);
|
Nz::SparsePtr<Nz::Vector3f> positionPtr = mapper.GetComponentPtr<Nz::Vector3f>(Nz::ParticleComponent_Position);
|
||||||
Nz::SparsePtr<Nz::Vector3f> velocityPtr = mapper.GetComponentPtr<Nz::Vector3f>(Nz::ParticleComponent_Velocity);
|
Nz::SparsePtr<Nz::Vector3f> velocityPtr = mapper.GetComponentPtr<Nz::Vector3f>(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")
|
GIVEN("A particle system of maximum 10 billboards with its generators")
|
||||||
{
|
{
|
||||||
// These need to be alive longer than the particle system
|
// These need to be alive longer than the particle system
|
||||||
TestParticleController particleController;
|
TestParticleController particleController;
|
||||||
TestParticleGenerator particleGenerator;
|
TestParticleGenerator particleGenerator;
|
||||||
Nz::ParticleSystem particleSystem(10, Nz::ParticleLayout_Billboard);
|
Nz::ParticleGroup particleGroup(10, Nz::ParticleLayout_Billboard);
|
||||||
|
|
||||||
particleSystem.AddController(&particleController);
|
particleGroup.AddController(&particleController);
|
||||||
TestParticleEmitter particleEmitter;
|
TestParticleEmitter particleEmitter;
|
||||||
particleEmitter.SetEmissionCount(10);
|
particleEmitter.SetEmissionCount(10);
|
||||||
particleSystem.AddEmitter(&particleEmitter);
|
particleGroup.AddEmitter(&particleEmitter);
|
||||||
|
|
||||||
particleSystem.AddGenerator(&particleGenerator);
|
particleGroup.AddGenerator(&particleGenerator);
|
||||||
|
|
||||||
WHEN("We update to generate 10 particles")
|
WHEN("We update to generate 10 particles")
|
||||||
{
|
{
|
||||||
particleSystem.Update(1.f);
|
particleGroup.Update(1.f);
|
||||||
|
|
||||||
THEN("There must be 10 particles")
|
THEN("There must be 10 particles")
|
||||||
{
|
{
|
||||||
REQUIRE(particleSystem.GetParticleCount() == 10);
|
REQUIRE(particleGroup.GetParticleCount() == 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
AND_THEN("We update to make them die")
|
AND_THEN("We update to make them die")
|
||||||
{
|
{
|
||||||
particleSystem.Update(2.f);
|
particleGroup.Update(2.f);
|
||||||
REQUIRE(particleSystem.GetParticleCount() == 0);
|
REQUIRE(particleGroup.GetParticleCount() == 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue