From b3280495170f4d2303c451ac4c9fedf624f0e392 Mon Sep 17 00:00:00 2001 From: Bart van Strien Date: Sat, 11 Jun 2016 19:51:51 +0200 Subject: [PATCH 1/2] Fix print coloring bug with empty strings (fixes #1171) --- changes.txt | 1 + src/modules/graphics/opengl/Font.cpp | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/changes.txt b/changes.txt index c092f5efc..0e60579b7 100644 --- a/changes.txt +++ b/changes.txt @@ -17,6 +17,7 @@ Released: N/A * Fixed love.window.setMode crashing when called with a Canvas active. * Fixed gamma correction of ImageFonts and BMFonts with colored images. * Fixed the default shader improperly applying gamma correction to per-vertex colors when gamma correction is requested but not supported on OpenGL ES. + * Fixed text coloring breaking because of an empty string. * Improved performance of Channel methods by roughly 2x in many cases. diff --git a/src/modules/graphics/opengl/Font.cpp b/src/modules/graphics/opengl/Font.cpp index 9831fff39..867b70e30 100644 --- a/src/modules/graphics/opengl/Font.cpp +++ b/src/modules/graphics/opengl/Font.cpp @@ -387,6 +387,11 @@ void Font::getCodepointsFromString(const std::vector &strs, Color for (const ColoredString &cstr : strs) { + // No need to add the color if the string is empty anyway, and the code + // further on assumes no two colors share the same starting position. + if (cstr.str.size() == 0) + continue; + IndexedColor c = {cstr.color, (int) codepoints.cps.size()}; codepoints.colors.push_back(c); From debea1192bc5cf77ccee85638cc76d52eb14e9d2 Mon Sep 17 00:00:00 2001 From: Bart van Strien Date: Tue, 21 Jun 2016 15:48:49 +0200 Subject: [PATCH 2/2] Fixed large burst of particles when dramatically increasing the emission rate of a ParticleSystem. (fixes #1169) --- changes.txt | 1 + src/modules/graphics/ParticleSystem.cpp | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/changes.txt b/changes.txt index 0e60579b7..c2191a4d9 100644 --- a/changes.txt +++ b/changes.txt @@ -18,6 +18,7 @@ Released: N/A * Fixed gamma correction of ImageFonts and BMFonts with colored images. * Fixed the default shader improperly applying gamma correction to per-vertex colors when gamma correction is requested but not supported on OpenGL ES. * Fixed text coloring breaking because of an empty string. + * Fixed large burst of particles when dramatically increasing the emission rate of a ParticleSystem. * Improved performance of Channel methods by roughly 2x in many cases. diff --git a/src/modules/graphics/ParticleSystem.cpp b/src/modules/graphics/ParticleSystem.cpp index 377d5e14d..2a4f2accf 100644 --- a/src/modules/graphics/ParticleSystem.cpp +++ b/src/modules/graphics/ParticleSystem.cpp @@ -437,6 +437,9 @@ void ParticleSystem::setEmissionRate(float rate) if (rate < 0.0f) throw love::Exception("Invalid emission rate"); emissionRate = rate; + + // Prevent an explosion when dramatically increasing the rate + emitCounter = std::min(emitCounter, 1.0f/rate); } float ParticleSystem::getEmissionRate() const @@ -932,9 +935,6 @@ void ParticleSystem::update(float dt) addParticle(1.0f - (emitCounter - rate) / total); emitCounter -= rate; } - /*int particles = (int)(emissionRate * dt); - for (int i = 0; i != particles; i++) - add();*/ life -= dt; if (lifetime != -1 && life < 0)