Example #1
0
void Contact::calcSpeed(CursorEventPtr pEvent, CursorEventPtr pOldEvent)
{
    if (pEvent->getSpeed() == glm::vec2(0,0)) {
        glm::vec2 posDiff = pEvent->getPos() - pOldEvent->getPos();
        long long timeDiff = pEvent->getWhen() - pOldEvent->getWhen();
        if (timeDiff != 0) {
            pEvent->setSpeed(posDiff/float(timeDiff));
        }
    }
}
Example #2
0
void Contact::updateDistanceTravelled(CursorEventPtr pEvent1, CursorEventPtr pEvent2)
{
    float dist = glm::length(pEvent2->getPos() - pEvent1->getPos());
    m_DistanceTravelled += dist;
}