X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=laserbrain_demo;a=blobdiff_plain;f=src%2Fexman.cc;h=21e00749f7e9a405e3d29649be36f9ebc3b23546;hp=6517b65f1b3dafe30a3e7bfc5f6046c6609558ac;hb=b5ed5107e21ff834d5a4510b9047f976abb03dff;hpb=ebbb52cd0de8e27817a0770bd7bdb48a58348a02 diff --git a/src/exman.cc b/src/exman.cc index 6517b65..21e0074 100644 --- a/src/exman.cc +++ b/src/exman.cc @@ -1,3 +1,4 @@ +#include #include #include "exman.h" #include "exhibit.h" @@ -103,13 +104,18 @@ bool ExhibitManager::load(MetaScene *mscn, const char *fname) ExSelection ExhibitManager::select(const Ray &ray) const { - ExSelection sel; - if(!items.empty()) { - sel.ex = items[0]; - sel.selray = ray; - sel.validmask = EXSEL_RAY; + ExSelection nearest; + nearest.dist = FLT_MAX; + + int nitems = items.size(); + for(int i=0; iselect(ray); + if(sel && sel.dist < nearest.dist) { + nearest = sel; + } } - return sel; // TODO + + return nearest; } ExSelection ExhibitManager::select(const Sphere &sph) const