projects
/
laserbrain_demo
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
select and move exhibits
[laserbrain_demo]
/
src
/
exman.cc
diff --git
a/src/exman.cc
b/src/exman.cc
index
6517b65
..
21e0074
100644
(file)
--- a/
src/exman.cc
+++ b/
src/exman.cc
@@
-1,3
+1,4
@@
+#include <float.h>
#include <algorithm>
#include "exman.h"
#include "exhibit.h"
#include <algorithm>
#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 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; i<nitems; i++) {
+ ExSelection sel = items[i]->select(ray);
+ if(sel && sel.dist < nearest.dist) {
+ nearest = sel;
+ }
}
}
- return sel; // TODO
+
+ return nearest;
}
ExSelection ExhibitManager::select(const Sphere &sph) const
}
ExSelection ExhibitManager::select(const Sphere &sph) const