TilemapVX: Fix map viewport not updating on scene geometry change

This commit is contained in:
Jonas Kulla 2014-08-15 23:19:21 +02:00
parent 9003f9a435
commit 062c7267d7
1 changed files with 18 additions and 16 deletions

View File

@ -189,28 +189,21 @@ struct TilemapVXPrivate : public ViewportElement, TileAtlasVX::Reader
dispPos.y = -(offset.y - viewpPos.y * 32) + sceneOffset.y; 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() void updateMapViewport()
{ {
int tileOX, tileOY; int tileOX, tileOY;
if (offset.x >= 0) Vec2i offs(offset.x-sceneOffset.x, offset.y-sceneOffset.y);
tileOX = offset.x / 32;
else
tileOX = -(-(offset.x-31) / 32);
if (offset.y >= 0) if (offs.x >= 0)
tileOY = offset.y / 32; tileOX = offs.x / 32;
else 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; bool dirty = false;
@ -340,6 +333,15 @@ struct TilemapVXPrivate : public ViewportElement, TileAtlasVX::Reader
GLMeta::vaoUnbind(vao); 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 */ /* TileAtlasVX::Reader */
void onQuads1(const FloatRect &t1, const FloatRect &p1, void onQuads1(const FloatRect &t1, const FloatRect &p1,
bool overPlayer) bool overPlayer)