mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-27 22:49:25 +02:00
ready draft
This commit is contained in:
@@ -129,26 +129,25 @@ void MapView::onMapSwiped(const Point & viewPosition)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MapView::postSwipe(uint32_t msPassed) {
|
void MapView::postSwipe(uint32_t msPassed) {
|
||||||
if(!actions->dragActive && swipeHistory.size() > 0)
|
if(!actions->dragActive)
|
||||||
{
|
{
|
||||||
Point diff = Point(0, 0);
|
if(swipeHistory.size() > 1)
|
||||||
for (auto & x : swipeHistory)
|
{
|
||||||
diff += x.second;
|
Point diff = Point(0, 0);
|
||||||
|
for (auto & x : swipeHistory)
|
||||||
|
diff += x.second;
|
||||||
|
|
||||||
uint64_t timediff = swipeHistory.rbegin()->first - swipeHistory.begin()->first;
|
uint64_t timediff = swipeHistory.rbegin()->first - swipeHistory.begin()->first;
|
||||||
|
|
||||||
postSwipeAngle = diff.angle();
|
postSwipeAngle = diff.angle();
|
||||||
postSwipeSpeed = static_cast<double>(diff.length()) / static_cast<double>(timediff); // unit: pixel/millisecond
|
postSwipeSpeed = static_cast<double>(diff.length()) / static_cast<double>(timediff); // unit: pixel/millisecond
|
||||||
|
}
|
||||||
std::cout << postSwipeAngle << " " << postSwipeSpeed << " " << diff.x << "x" << diff.y << " " << timediff << "\n";
|
|
||||||
swipeHistory.clear();
|
swipeHistory.clear();
|
||||||
}
|
}
|
||||||
if(postSwipeSpeed > 0.1) {
|
if(postSwipeSpeed > 0.1) {
|
||||||
double len = postSwipeSpeed * static_cast<double>(msPassed);
|
double len = postSwipeSpeed * static_cast<double>(msPassed);
|
||||||
Point delta = Point(len * cos(postSwipeAngle), len * sin(postSwipeAngle));
|
Point delta = Point(len * cos(postSwipeAngle), len * sin(postSwipeAngle));
|
||||||
|
|
||||||
std::cout << len << " " << delta.x << "x" << delta.y << "\n";
|
|
||||||
|
|
||||||
controller->setViewCenter(model->getMapViewCenter() + delta, model->getLevel());
|
controller->setViewCenter(model->getMapViewCenter() + delta, model->getLevel());
|
||||||
|
|
||||||
postSwipeSpeed /= 1.1;
|
postSwipeSpeed /= 1.1;
|
||||||
|
|||||||
Reference in New Issue
Block a user