From c66fbe9ea0c1988c51d030709267af377ae864f4 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Fri, 20 Mar 2020 19:50:15 +0100 Subject: [PATCH] flocking:: prevent crash in follow=2 when no boids found --- rogueviz/flocking.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/rogueviz/flocking.cpp b/rogueviz/flocking.cpp index 39bc71bf..b7402f72 100644 --- a/rogueviz/flocking.cpp +++ b/rogueviz/flocking.cpp @@ -283,12 +283,16 @@ namespace flocking { // are taken), and normalize the result to project it back to the hyperboloid // (the same method is commonly used on the sphere AFAIK) hyperpoint h = Hypc; + bool ok = false; for(int i=0; ibase)) { + ok = true; vdata[i].m->pat = gmatrix[vdata[i].m->base] * vdata[i].m->at; h += tC0(vdata[i].m->pat); } - h = normalize(h); - View = gpushxto0(h) * View; + if(ok) { + h = normalize(h); + View = inverse(actual_view_transform) * gpushxto0(h) * actual_view_transform * View; + } } optimizeview();