This used to result in 0 pixel movement in first frame
Change-Id: Ia12ba1660a6ae8c17c8596437dfbb3be5e506fb4
Signed-off-by: Julien Heanley <j.heanley@partner.samsung.com>
mWritePosition %= PAN_GESTURE_HISTORY;
}
mWritePosition %= PAN_GESTURE_HISTORY;
}
-void PanGesture::RemoveOldHistory(PanInfoHistory& panHistory, uint currentTime, uint maxAge, uint minEvents)
+void PanGesture::RemoveOldHistory(PanInfoHistory& panHistory, unsigned int currentTime, unsigned int maxAge, unsigned int minEvents)
{
PanInfoHistoryConstIter endIter = panHistory.end();
PanInfoHistoryIter iter = panHistory.begin();
{
PanInfoHistoryConstIter endIter = panHistory.end();
PanInfoHistoryIter iter = panHistory.begin();
PanInfoHistoryIter iter = panHistory.begin();
Vector2 screenVelocity = gestureOut.screen.velocity;
Vector2 localVelocity = gestureOut.local.velocity;
PanInfoHistoryIter iter = panHistory.begin();
Vector2 screenVelocity = gestureOut.screen.velocity;
Vector2 localVelocity = gestureOut.local.velocity;
+ Vector2 screenDisplacement = gestureOut.screen.displacement;
+ Vector2 localDisplacement = gestureOut.local.displacement;
bool havePreviousAcceleration = false;
bool previousVelocity = false;
float previousAccel = 0.0f;
unsigned int lastTime(0);
bool havePreviousAcceleration = false;
bool previousVelocity = false;
float previousAccel = 0.0f;
unsigned int lastTime(0);
+ unsigned int interpolationTime = (lastVSyncTime + mPredictionAmount) - gestureOut.time;
while( iter != endIter )
{
PanInfo currentGesture = *iter;
while( iter != endIter )
{
PanInfo currentGesture = *iter;
{
acceleration = velDiff / time;
}
{
acceleration = velDiff / time;
}
- float interpolationTime = (float)((int)lastVSyncTime - (int)currentGesture.time);
+ int currentInterpolation = (lastVSyncTime + mPredictionAmount) - currentGesture.time;
if( !havePreviousAcceleration )
{
if( !havePreviousAcceleration )
{
- newVelMag = velMag + (acceleration * interpolationTime);
+ newVelMag = velMag + (acceleration * currentInterpolation);
havePreviousAcceleration = true;
}
else
havePreviousAcceleration = true;
}
else
}
gestureOut.screen.velocity = currentGesture.screen.velocity * velMod;
gestureOut.local.velocity = currentGesture.local.velocity * velMod;
}
gestureOut.screen.velocity = currentGesture.screen.velocity * velMod;
gestureOut.local.velocity = currentGesture.local.velocity * velMod;
+ screenDisplacement = gestureOut.screen.displacement + (gestureOut.screen.velocity * interpolationTime);
+ localDisplacement = gestureOut.local.displacement + (gestureOut.local.velocity * interpolationTime);
screenVelocity = currentGesture.screen.velocity;
localVelocity = currentGesture.local.velocity;
previousAccel = acceleration;
screenVelocity = currentGesture.screen.velocity;
localVelocity = currentGesture.local.velocity;
previousAccel = acceleration;
}
// gestureOut's position is currently equal to the last event's position and its displacement is equal to last frame's total displacement
// add interpolated distance and position to current
}
// gestureOut's position is currently equal to the last event's position and its displacement is equal to last frame's total displacement
// add interpolated distance and position to current
- unsigned int interpolationTime = (lastVSyncTime + mPredictionAmount) - gestureOut.time;
// work out interpolated velocity
// work out interpolated velocity
- gestureOut.screen.displacement = (gestureOut.screen.velocity * interpolationTime);
- gestureOut.local.displacement = (gestureOut.local.velocity * interpolationTime);
- gestureOut.screen.position += gestureOut.screen.displacement;
- gestureOut.local.position += gestureOut.local.displacement;
+ gestureOut.screen.displacement = screenDisplacement;
+ gestureOut.local.displacement = localDisplacement;
+ gestureOut.screen.position = (gestureOut.screen.position - gestureOut.screen.displacement) + screenDisplacement;
+ gestureOut.local.position = (gestureOut.local.position - gestureOut.local.displacement) + localDisplacement;
gestureOut.time += interpolationTime;
}
gestureOut.time += interpolationTime;
}
* @param[in] maxAge Maximum age of an event before removing (in millis)
* @param[in] minEvents The minimum number of events to leave in history, oldest events are removed before newest
*/
* @param[in] maxAge Maximum age of an event before removing (in millis)
* @param[in] minEvents The minimum number of events to leave in history, oldest events are removed before newest
*/
- void RemoveOldHistory(PanInfoHistory& panHistory, uint currentTime, uint maxAge, uint minEvents);
+ void RemoveOldHistory(PanInfoHistory& panHistory, unsigned int currentTime, unsigned int maxAge, unsigned int minEvents);
/**
* USes last two gestures
/**
* USes last two gestures