aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--voronoisplat.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/voronoisplat.cpp b/voronoisplat.cpp
index f1ed821..da81817 100644
--- a/voronoisplat.cpp
+++ b/voronoisplat.cpp
@@ -524,7 +524,13 @@ void VoronoiSplatRenderer::computeDT()
const std::vector<float> &sites = *m_sites;
std::vector<float> buf(w*h);
for (unsigned i = 0; i < sites.size(); i += 2) {
- buf[int(m_sy(sites[i + 1]))*h + int(m_sx(sites[i]))] = i/2.0f + 1.0f;
+ unsigned bufIndex = unsigned(m_sy(sites[i + 1]))*h + unsigned(m_sx(sites[i]));
+ if (bufIndex > buf.size()) {
+ // points outside our scale
+ continue;
+ }
+
+ buf[bufIndex] = i/2.0f + 1.0f;
}
skelft2DFT(0, buf.data(), 0, 0, w, h, w);