diff --git a/projects/fire_works/src/main.cpp b/projects/fire_works/src/main.cpp index aa23f74a75f4c4deab44632bdf7f7c53f543098e..ef1a66bfcd501948d0ed3004ba793071ce1dc7a0 100644 --- a/projects/fire_works/src/main.cpp +++ b/projects/fire_works/src/main.cpp @@ -85,18 +85,16 @@ struct draw_smoke_t { #define POINT_COUNT (2048 * 256) void InitializeParticles(std::vector<particle_t> &particles) { - for (size_t i = 0; i < particles.size(); i++) { - particle_t particle; - particle.position = glm::vec3(2.0f * (std::rand() % RAND_MAX) / RAND_MAX - 1.0f, - 2.0f * (std::rand() % RAND_MAX) / RAND_MAX - 1.0f, - 2.0f * (std::rand() % RAND_MAX) / RAND_MAX - 1.0f); + const auto rand_max = static_cast<float>(RAND_MAX); + for (auto& particle : particles) { + particle.position = glm::vec3(2.0f * (std::rand() % RAND_MAX) / rand_max - 1.0f, + 2.0f * (std::rand() % RAND_MAX) / rand_max - 1.0f, + 2.0f * (std::rand() % RAND_MAX) / rand_max - 1.0f); particle.lifetime = 0.0f; particle.velocity = glm::vec3(0.0f); particle.size = 0.01f; particle.color = glm::vec3(1.0f, 0.0f, 0.0f); - - particles [i] = particle; } } diff --git a/projects/particle_simulation/src/Particle.cpp b/projects/particle_simulation/src/Particle.cpp index b80d063d382c9ae1cb63887388cce065b8289b63..5e726cee99fa05b6ad27b00ceecdd09f6352ab80 100644 --- a/projects/particle_simulation/src/Particle.cpp +++ b/projects/particle_simulation/src/Particle.cpp @@ -9,34 +9,34 @@ Particle::Particle(glm::vec3 position, glm::vec3 velocity, float lifeTime) m_reset_velocity(velocity) {} -const glm::vec3& Particle::getPosition()const{ +const glm::vec3& Particle::getPosition() const { return m_position; } -bool Particle::isAlive()const{ +bool Particle::isAlive() const { return m_lifeTime > 0.f; } -void Particle::setPosition( const glm::vec3 pos ){ +void Particle::setPosition(const glm::vec3& pos) { m_position = pos; } -const glm::vec3& Particle::getVelocity()const{ +const glm::vec3& Particle::getVelocity() const { return m_velocity; } -void Particle::setVelocity( const glm::vec3 vel ){ +void Particle::setVelocity(const glm::vec3& vel) { m_velocity = vel; } -void Particle::update( const float delta ){ +void Particle::update(float delta) { m_position += m_velocity * delta; } -void Particle::setLifeTime( const float lifeTime ){ +void Particle::setLifeTime(float lifeTime) { m_lifeTime = lifeTime; } -const float& Particle::getLifeTime()const{ +float Particle::getLifeTime() const { return m_lifeTime; } \ No newline at end of file diff --git a/projects/particle_simulation/src/Particle.hpp b/projects/particle_simulation/src/Particle.hpp index 73e7cbf517709ee03274cfd199081ade3f756545..35d39dac9519a2ea7168f78f4613a8cdb2143bfc 100644 --- a/projects/particle_simulation/src/Particle.hpp +++ b/projects/particle_simulation/src/Particle.hpp @@ -6,29 +6,33 @@ class Particle { public: Particle(glm::vec3 position, glm::vec3 velocity, float lifeTime = 1.f); + + [[nodiscard]] + const glm::vec3& getPosition() const; - const glm::vec3& getPosition()const; + void setPosition(const glm::vec3& pos); + + [[nodiscard]] + const glm::vec3& getVelocity() const; - void setPosition( const glm::vec3 pos ); + void setVelocity(const glm::vec3& vel); - const glm::vec3& getVelocity()const; + void update(float delta); - void setVelocity( const glm::vec3 vel ); + [[nodiscard]] + bool isAlive() const; - void update( const float delta ); - - bool isAlive()const; - - void setLifeTime( const float lifeTime ); - - const float& getLifeTime()const; + void setLifeTime(float lifeTime); + + [[nodiscard]] + float getLifeTime() const; private: // all properties of the Particle glm::vec3 m_position; float m_lifeTime; glm::vec3 m_velocity; - float m_mass; - glm::vec3 m_reset_velocity; - float padding_3; + [[maybe_unused]] float m_mass; + [[maybe_unused]] glm::vec3 m_reset_velocity; + [[maybe_unused]] float m_padding; }; diff --git a/projects/sph/src/Particle.hpp b/projects/sph/src/Particle.hpp index 6c4ab50b74cc4544976318c23e36f4b91989ee66..c94f484be0775768338ec78bca358bf324d63f9e 100644 --- a/projects/sph/src/Particle.hpp +++ b/projects/sph/src/Particle.hpp @@ -26,7 +26,7 @@ public: private: // all properties of the Particle glm::vec3 m_position; - float m_padding1; + [[maybe_unused]] [[maybe_unused]] float m_padding; glm::vec3 m_velocity; float m_density; glm::vec3 m_force; diff --git a/projects/sph/src/main.cpp b/projects/sph/src/main.cpp index dff31b8a41c5504b2e7ce1e64f398b57ebdbe730..3d8cf07842e542036125c26a2f95f298ec043343 100644 --- a/projects/sph/src/main.cpp +++ b/projects/sph/src/main.cpp @@ -136,25 +136,28 @@ int main(int argc, const char **argv) { vkcv::BufferType::UNIFORM, 1 ); + + const float rand_max = static_cast<float>(RAND_MAX); // generating particles int numberParticles = 20000; std::vector<Particle> particles; + particles.reserve(numberParticles); + for (int i = 0; i < numberParticles; i++) { const float lo = 0.6; const float hi = 0.9; const float vlo = 0; const float vhi = 70; - float x = lo + static_cast <float> (rand()) /( static_cast <float> (RAND_MAX/(hi-lo))); - float y = lo + static_cast <float> (rand()) /( static_cast <float> (RAND_MAX/(hi-lo))); - float z = lo + static_cast <float> (rand()) /( static_cast <float> (RAND_MAX/(hi-lo))); - float vx = vlo + static_cast <float> (rand()) /( static_cast <float> (RAND_MAX/(vhi-vlo))); - float vy = vlo + static_cast <float> (rand()) /( static_cast <float> (RAND_MAX/(vhi-vlo))); - float vz = vlo + static_cast <float> (rand()) /( static_cast <float> (RAND_MAX/(vhi-vlo))); + float x = lo + static_cast <float> (rand()) /( static_cast <float> (rand_max/(hi-lo))); + float y = lo + static_cast <float> (rand()) /( static_cast <float> (rand_max/(hi-lo))); + float z = lo + static_cast <float> (rand()) /( static_cast <float> (rand_max/(hi-lo))); + float vx = vlo + static_cast <float> (rand()) /( static_cast <float> (rand_max/(vhi-vlo))); + float vy = vlo + static_cast <float> (rand()) /( static_cast <float> (rand_max/(vhi-vlo))); + float vz = vlo + static_cast <float> (rand()) /( static_cast <float> (rand_max/(vhi-vlo))); glm::vec3 pos = glm::vec3(x,y,z); glm::vec3 vel = glm::vec3(vx,vy,vz); - //glm::vec3 vel = glm::vec3(0.0,0.0,0.0); - particles.push_back(Particle(pos, vel)); + particles.emplace_back(pos, vel); } // creating and filling particle buffer diff --git a/src/vkcv/AccelerationStructureManager.hpp b/src/vkcv/AccelerationStructureManager.hpp index 2a8a6901288f942fb015fc8f76fd89c2586e73e3..062a1bcfead0910ed1084d8c3917abb9e904dfe1 100644 --- a/src/vkcv/AccelerationStructureManager.hpp +++ b/src/vkcv/AccelerationStructureManager.hpp @@ -37,6 +37,7 @@ namespace vkcv { private: BufferManager* m_bufferManager; + using HandleManager<AccelerationStructureEntry, AccelerationStructureHandle>::init; bool init(Core &core, BufferManager &bufferManager); [[nodiscard]] uint64_t getIdFrom(const AccelerationStructureHandle &handle) const override; diff --git a/src/vkcv/DescriptorSetManager.hpp b/src/vkcv/DescriptorSetManager.hpp index 5dbdc954fcdfa7c927b50618f7c8bfcd64b02c9c..4b0d307bb4e96292d7c23ad4d2b3bf942727762e 100644 --- a/src/vkcv/DescriptorSetManager.hpp +++ b/src/vkcv/DescriptorSetManager.hpp @@ -38,7 +38,8 @@ namespace vkcv { Vector<vk::DescriptorPool> m_Pools; Vector<vk::DescriptorPoolSize> m_PoolSizes; vk::DescriptorPoolCreateInfo m_PoolInfo; - + + using HandleManager<DescriptorSetEntry, DescriptorSetHandle>::init; bool init(Core &core, DescriptorSetLayoutManager &descriptorSetLayoutManager); [[nodiscard]] uint64_t getIdFrom(const DescriptorSetHandle &handle) const override; diff --git a/src/vkcv/ImageManager.hpp b/src/vkcv/ImageManager.hpp index d334c59b2344771c72bf44f7eb7cda72c9f3c43c..123c972a9be1f11ed50b68277a0c47d44c4c471e 100644 --- a/src/vkcv/ImageManager.hpp +++ b/src/vkcv/ImageManager.hpp @@ -54,6 +54,7 @@ namespace vkcv { Vector<ImageEntry> m_swapchainImages; int m_currentSwapchainInputImage; + using HandleManager<ImageEntry, ImageHandle>::init; bool init(Core &core, BufferManager &bufferManager); [[nodiscard]] uint64_t getIdFrom(const ImageHandle &handle) const override;