From 5023a658e75bc2e4e81048fa528011762254f354 Mon Sep 17 00:00:00 2001 From: Green Sky Date: Tue, 26 Apr 2022 15:27:15 +0200 Subject: [PATCH] allow changing particle buffer size --- .../src/mm/opengl/render_tasks/lite_particles2d.cpp | 6 ++++++ .../src/mm/opengl/render_tasks/lite_particles2d.hpp | 7 +++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/framework/opengl_renderer/src/mm/opengl/render_tasks/lite_particles2d.cpp b/framework/opengl_renderer/src/mm/opengl/render_tasks/lite_particles2d.cpp index 8c8bd14..305b6a0 100644 --- a/framework/opengl_renderer/src/mm/opengl/render_tasks/lite_particles2d.cpp +++ b/framework/opengl_renderer/src/mm/opengl/render_tasks/lite_particles2d.cpp @@ -304,6 +304,12 @@ void LiteParticles2D::render(Services::OpenGLRenderer& rs, Engine& engine) { renderParticles(rs, scene); } +void LiteParticles2D::setParticleBufferSize(uint32_t new_buffer_size) { + _particle_buffer_size = new_buffer_size; + + resetBuffers(); +} + void LiteParticles2D::resetBuffers(void) { const auto gl_buffer_type = GL_DYNAMIC_COPY; auto reset_buffer_0 = [this](size_t i) { diff --git a/framework/opengl_renderer/src/mm/opengl/render_tasks/lite_particles2d.hpp b/framework/opengl_renderer/src/mm/opengl/render_tasks/lite_particles2d.hpp index 719f7c9..069aca7 100644 --- a/framework/opengl_renderer/src/mm/opengl/render_tasks/lite_particles2d.hpp +++ b/framework/opengl_renderer/src/mm/opengl/render_tasks/lite_particles2d.hpp @@ -47,10 +47,8 @@ namespace MM::OpenGL::RenderTasks { float _time {0}; public: - //glm::vec3 env_vec{0, 1, 0}; - //float env_force{0.3}; - //float noise_force{0.5}; - //float dampening{0.99}; + // TODO: impl some environment controlled force + //glm::vec2 env_vec{0, 1}; LiteParticles2D(Engine& engine); ~LiteParticles2D(void); @@ -62,6 +60,7 @@ namespace MM::OpenGL::RenderTasks { void renderParticles(Services::OpenGLRenderer& rs, Scene& scene); void render(Services::OpenGLRenderer& rs, Engine& engine) override; + void setParticleBufferSize(uint32_t new_buffer_size = 10'000); void resetBuffers(void); void resetTypeBuffers(void);