small fix on processedList to lastList, TuioTime still not a good way to compare different timestamped inputs

This commit is contained in:
Jonathan Bosson
2017-02-22 18:52:11 -07:00
parent 49ca8eb2aa
commit a2ff460d78
4 changed files with 22 additions and 18 deletions

View File

@@ -60,7 +60,6 @@ class TuioEar : public TuioListener {
void refresh(TuioTime frameTime);
TuioTime getLastProcessedTime(int id);
std::vector<TuioCursor> getInput();
void clearInput();
@@ -70,7 +69,6 @@ class TuioEar : public TuioListener {
std::vector<TuioCursor> _list;
std::vector<int> _removeList;
std::vector<std::pair<int, TuioTime>> _processedPath;
std::mutex _mx;
};

View File

@@ -58,7 +58,7 @@ void TuioEar::addTuioCursor(TuioCursor *tcur) {
// find same id in _list if it exists in _removeList (new input with same ID as a previously stored)
int i = tcur->getSessionID();
auto foundID = std::find_if(
std::vector<int>::iterator foundID = std::find_if(
_removeList.begin(),
_removeList.end(),
[&i](int id) { return id == i; });
@@ -116,19 +116,8 @@ void TuioEar::refresh(TuioTime frameTime) {
//LINFO("refresh " << frameTime.getTotalMilliseconds() << "\n"); // about every 15ms on TuioPad app
}
TuioTime TuioEar::getLastProcessedTime(int id) {
return std::find_if(
_processedPath.begin(),
_processedPath.end(),
[&id](std::pair<int, TuioTime> t) { return id = t.first; }
)->second;
}
std::vector<TuioCursor> TuioEar::getInput() {
std::lock_guard<std::mutex> lock(_mx);
_processedPath.clear();
for (const TuioCursor& c : _list)
_processedPath.push_back(std::make_pair(c.getSessionID(), c.getTuioTime()));
return _list;
}

View File

@@ -74,7 +74,7 @@ TouchModule::TouchModule()
OpenSpaceEngine::CallbackOption::PreSync,
[&]() {
//std::this_thread::sleep_for(std::chrono::seconds(1));
std::vector<TuioCursor> list = ear->getInput();
list = ear->getInput();
ear->clearInput();
glm::vec2 centroid;
@@ -83,11 +83,23 @@ TouchModule::TouchModule()
std::string s = "";
std::ostringstream os;
for (const TuioCursor &j : list) {
os << j.getCursorID() << ", path size: " << j.getPath().size() << ", (" << j.getX() << "," << j.getY() << ") ";
int count = 0;
std::list<TuioPoint> path = j.getPath();
if (lastList.size() > 0 && list.size() > 0) { // sanity check
std::vector<TuioCursor>::iterator last = find_if(
lastList.begin(),
lastList.end(),
[&j](const TuioCursor& c) { return c.getSessionID() == j.getSessionID(); }
);
if (last != lastList.end())
(path.size() < 128) ? count = path.size() - last->getPath().size() : count = 1; // guess how many? all?
}
os << ", Id: " << j.getCursorID() << ", path size: " << j.getPath().size() << ", (" << j.getX() << "," << j.getY() << "), To Process: " << count;
}
if (list.size() > 0)
LINFO("List size: " << list.size() << ", Id: " << os.str() << "\n");
LINFO("List size: " << list.size() << os.str() << "\n");
os.clear();
/*
// calculate centroid if multipleID
@@ -105,7 +117,10 @@ TouchModule::TouchModule()
*/
glm::mat4 t;
//OsEng.interactionHandler().camera()->rotate();
lastList = list;
}
);

View File

@@ -35,6 +35,8 @@ public:
TouchModule();
TuioEar *ear;
std::vector<TuioCursor> list;
std::vector<TuioCursor> lastList;
};
} // namespace openspace