From 062c7267d7b3d3f0ce0f6d99ec8813e24a26f68d Mon Sep 17 00:00:00 2001 From: Jonas Kulla Date: Fri, 15 Aug 2014 23:19:21 +0200 Subject: [PATCH] TilemapVX: Fix map viewport not updating on scene geometry change --- src/tilemapvx.cpp | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/src/tilemapvx.cpp b/src/tilemapvx.cpp index 633a551..d183877 100644 --- a/src/tilemapvx.cpp +++ b/src/tilemapvx.cpp @@ -189,28 +189,21 @@ struct TilemapVXPrivate : public ViewportElement, TileAtlasVX::Reader dispPos.y = -(offset.y - viewpPos.y * 32) + sceneOffset.y; } - void onGeometryChange(const Scene::Geometry &geo) - { - sceneOffset.x = geo.rect.x - geo.xOrigin; - sceneOffset.y = geo.rect.y - geo.yOrigin; - sceneGeo = geo; - - updatePosition(); - } - void updateMapViewport() { int tileOX, tileOY; - if (offset.x >= 0) - tileOX = offset.x / 32; - else - tileOX = -(-(offset.x-31) / 32); + Vec2i offs(offset.x-sceneOffset.x, offset.y-sceneOffset.y); - if (offset.y >= 0) - tileOY = offset.y / 32; + if (offs.x >= 0) + tileOX = offs.x / 32; else - tileOY = -(-(offset.y-31) / 32); + tileOX = -(-(offs.x-31) / 32); + + if (offs.y >= 0) + tileOY = offs.y / 32; + else + tileOY = -(-(offs.y-31) / 32); bool dirty = false; @@ -340,6 +333,15 @@ struct TilemapVXPrivate : public ViewportElement, TileAtlasVX::Reader GLMeta::vaoUnbind(vao); } + void onGeometryChange(const Scene::Geometry &geo) + { + sceneOffset.x = geo.rect.x - geo.xOrigin; + sceneOffset.y = geo.rect.y - geo.yOrigin; + sceneGeo = geo; + + mapViewportDirty = true; + } + /* TileAtlasVX::Reader */ void onQuads1(const FloatRect &t1, const FloatRect &p1, bool overPlayer)