From 2279f3969bf1ea15f78fd6a344d6ca39af9da20a Mon Sep 17 00:00:00 2001 From: Armin <armin.co@hs-bochum.de> Date: Sun, 31 Jan 2021 19:07:22 +0100 Subject: [PATCH] constexpr fix --- App/GameLayer.cpp | 2 +- QPong/Particle.cpp | 2 +- QPong/Utils.cpp | 10 +--------- QPong/Utils.hpp | 3 +-- assets/shaders/particle.vert.glsl | 6 +++--- 5 files changed, 7 insertions(+), 16 deletions(-) diff --git a/App/GameLayer.cpp b/App/GameLayer.cpp index e651207..bf95ba2 100644 --- a/App/GameLayer.cpp +++ b/App/GameLayer.cpp @@ -21,7 +21,7 @@ const std::string vertexShaderPath = "assets/shaders/particle.vert.glsl"; const std::string fragmentShaderPath = "assets/shaders/particle.frag.glsl"; -constexpr QPong::Particle::Properties initialParticleSettings = { +const QPong::Particle::Properties initialParticleSettings = { .size = 512, .position = {0.0, 0.0, 0.0}, .momentum = {0.0, 0.0, 0.0}, diff --git a/QPong/Particle.cpp b/QPong/Particle.cpp index 3673b87..22cb841 100644 --- a/QPong/Particle.cpp +++ b/QPong/Particle.cpp @@ -77,7 +77,7 @@ Particle::Particle(Properties properties, GameOptions &options, Player &playerOn if (options.game == true) { - calculateBorderPotential(m_staticBorders, m_yAt, m_properties.elements()); + calculateBorderPotential(m_staticBorders, m_xAt, m_yAt, m_properties.elements()); m_leftBat.moveToStartingPosition(); m_rightBat.moveToStartingPosition(); } diff --git a/QPong/Utils.cpp b/QPong/Utils.cpp index 7fa3285..87244ee 100644 --- a/QPong/Utils.cpp +++ b/QPong/Utils.cpp @@ -74,7 +74,7 @@ void calculateTriangleIndices(uint32_t *indices, int arraySize) } } -void calculateBorderPotential(float *potential, double *yAt, int arrayElements) +void calculateBorderPotential(float *potential, [[maybe_unused]] double *xAt, double *yAt, int arrayElements) { double y {0.0}; for (int i {0}; i < arrayElements; ++i) @@ -85,14 +85,6 @@ void calculateBorderPotential(float *potential, double *yAt, int arrayElements) } } -void calculateSchroedingerPotential(float *potential, double *xAt, double *yAt, int arrayElements) -{ - for (int i {0}; i < arrayElements; ++i) - { - potential[i] = ( pow2(pow2(xAt[i]) + pow2(yAt[i])) ) / 200.0; - } -} - void calculateGaussBox(float *potential, double *xAt, double *yAt, int arrayElements) { constexpr double grow = 0.1; diff --git a/QPong/Utils.hpp b/QPong/Utils.hpp index 54ecfcb..c8ce49e 100644 --- a/QPong/Utils.hpp +++ b/QPong/Utils.hpp @@ -16,7 +16,6 @@ const T pow2(const T v) void calculatePointPositions(float *points, int arraySize); void calculateMomentumViewPositions(float *points, int arraySize); void calculateTriangleIndices(uint32_t *indices, int arraySize); -void calculateBorderPotential(float *potential, double *yAt, int arrayElements); -void calculateSchroedingerPotential(float *potential, double *xAt, double *yAt, int arrayElements); +void calculateBorderPotential(float *potential, double *xAt, double *yAt, int arrayElements); void calculateGaussBox(float *potential, double *xAt, double *yAt, int arrayElemnts); #endif \ No newline at end of file diff --git a/assets/shaders/particle.vert.glsl b/assets/shaders/particle.vert.glsl index a4b3781..9cd55d6 100644 --- a/assets/shaders/particle.vert.glsl +++ b/assets/shaders/particle.vert.glsl @@ -25,7 +25,7 @@ void main() gl_Position = u_viewProjection * vec4(pos, 1.0f); // Calculate "color" value of the momentum - float pot = potential * 120.0 * u_showPotential; + float pot = potential * 100.0 * u_showPotential; // Generate color from data float real = v_particle_complex[0]; @@ -35,6 +35,6 @@ void main() fragmentColor = vec3( sqrt(real2) * 5.0 + pot, // red - sqrt(real2) * 5.0 + sqrt(imag2) * 5.0 + pot, // green + (sqrt(real2) + sqrt(imag2)) * 5.0 + pot, // green sqrt(imag2) * 5.0 + pot); // blue -} \ No newline at end of file +} -- GitLab