added further fixes, and upgrades
This commit is contained in:
@@ -25,6 +25,8 @@ void TSE::TileMapChunk::RemoveTile(Vector2 p)
|
||||
void TSE::TileMapChunk::SetOrdering(SortingOrder _order)
|
||||
{
|
||||
order = _order;
|
||||
dirtyPositions = true;
|
||||
dirtySpriteIds = true;
|
||||
}
|
||||
|
||||
const std::vector<TSE::Vector2>* TSE::TileMapChunk::GetOrderedPositions()
|
||||
@@ -43,7 +45,7 @@ const std::vector<TSE::Vector2>* TSE::TileMapChunk::GetOrderedPositions()
|
||||
Vector2 p(x,y);
|
||||
auto v = sprites.find(p);
|
||||
if(v != sprites.end())
|
||||
orderedPositions.push_back(v->first - offset);
|
||||
orderedPositions.push_back(v->first * Vector2(nextLine.x, nextLine.y * 0.5f) + Vector2(-nextLine.x * y, nextLine.y * 0.5f * x));
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -56,7 +58,7 @@ const std::vector<TSE::Vector2>* TSE::TileMapChunk::GetOrderedPositions()
|
||||
Vector2 p(x,y);
|
||||
auto v = sprites.find(p);
|
||||
if(v != sprites.end())
|
||||
orderedPositions.push_back(v->first - offset);
|
||||
orderedPositions.push_back(v->first * Vector2(nextLine.x, nextLine.y * 0.5f) + Vector2(-nextLine.x * y, nextLine.y * 0.5f * x));
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -69,7 +71,7 @@ const std::vector<TSE::Vector2>* TSE::TileMapChunk::GetOrderedPositions()
|
||||
Vector2 p(x,y);
|
||||
auto v = sprites.find(p);
|
||||
if(v != sprites.end())
|
||||
orderedPositions.push_back(v->first - offset);
|
||||
orderedPositions.push_back(v->first * Vector2(nextLine.x, nextLine.y * 0.5f) + Vector2(-nextLine.x * y, nextLine.y * 0.5f * x));
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -82,7 +84,7 @@ const std::vector<TSE::Vector2>* TSE::TileMapChunk::GetOrderedPositions()
|
||||
Vector2 p(x,y);
|
||||
auto v = sprites.find(p);
|
||||
if(v != sprites.end())
|
||||
orderedPositions.push_back(v->first - offset);
|
||||
orderedPositions.push_back(v->first * Vector2(nextLine.x, nextLine.y * 0.5f) + Vector2(-nextLine.x * y, nextLine.y * 0.5f * x));
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -271,6 +273,7 @@ void TSE::TileMap::SetNextLineOffset(const Vector2 &offset)
|
||||
{
|
||||
chunk.nextLine = offset;
|
||||
}
|
||||
DirtyAll();
|
||||
}
|
||||
|
||||
TSE::Vector2 TSE::TileMap::GetNextLineOffset()
|
||||
@@ -278,6 +281,16 @@ TSE::Vector2 TSE::TileMap::GetNextLineOffset()
|
||||
return nextLine;
|
||||
}
|
||||
|
||||
void TSE::TileMap::DirtyAll()
|
||||
{
|
||||
dirty = true;
|
||||
for(auto& chunk : chunks)
|
||||
{
|
||||
chunk.second.dirtyPositions = true;
|
||||
chunk.second.dirtySpriteIds = true;
|
||||
}
|
||||
}
|
||||
|
||||
void TSE::TileMap::CheckBounds(Vector2 pos)
|
||||
{
|
||||
if(pos.x > bounds.p2.x)
|
||||
@@ -305,10 +318,10 @@ TSE::Vector2 TSE::TileMap::ChunkToLocalPos(const Vector2 &v, const TileMapChunk
|
||||
|
||||
TSE::Vector2 TSE::TileMap::RealPosToTileMapPos(const Vector2 &v)
|
||||
{
|
||||
return v + nextLine * v.y;
|
||||
return v * Vector2(nextLine.x, nextLine.y * 0.5f) + Vector2(-nextLine.x * v.y, nextLine.y * 0.5f * v.x);
|
||||
}
|
||||
|
||||
TSE::Vector2 TSE::TileMap::TileMapToRealPos(const Vector2 &v)
|
||||
{
|
||||
return v - nextLine * v.y;
|
||||
return v * Vector2(nextLine.x, nextLine.y * 0.5f) + Vector2(-nextLine.x * v.y, nextLine.y * 0.5f * v.x);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user