mirror of
https://github.com/aseprite/aseprite.git
synced 2024-11-20 14:21:45 +00:00
Fix Ctrl+click to pick tilemaps correctly using the tile pixels
Before this we picked tilemaps only by bounds of the cel.
This commit is contained in:
parent
1c6660e964
commit
15541412a4
@ -614,9 +614,35 @@ void Sprite::pickCels(const double x,
|
||||
if (!celBounds.contains(pos))
|
||||
continue;
|
||||
|
||||
const gfx::Point ipos(
|
||||
int((pos.x-celBounds.x)*image->width()/celBounds.w),
|
||||
int((pos.y-celBounds.y)*image->height()/celBounds.h));
|
||||
gfx::Point ipos;
|
||||
if (image->isTilemap()) {
|
||||
Tileset* tileset = static_cast<LayerTilemap*>(cel->layer())->tileset();
|
||||
if (!tileset)
|
||||
continue;
|
||||
|
||||
const Grid grid = cel->grid();
|
||||
|
||||
tile_t tile = notile;
|
||||
gfx::Point tilePos = grid.canvasToTile(gfx::Point(pos));
|
||||
if (image->bounds().contains(tilePos.x, tilePos.y))
|
||||
tile = image->getPixel(tilePos.x, tilePos.y);
|
||||
if (tile == notile)
|
||||
continue;
|
||||
|
||||
image = tileset->get(tile).get();
|
||||
if (!image)
|
||||
continue;
|
||||
|
||||
gfx::Point tileStart = grid.tileToCanvas(tilePos);
|
||||
ipos = gfx::Point(pos.x - tileStart.x,
|
||||
pos.y - tileStart.y);
|
||||
}
|
||||
else {
|
||||
ipos = gfx::Point(
|
||||
int((pos.x-celBounds.x)*image->width()/celBounds.w),
|
||||
int((pos.y-celBounds.y)*image->height()/celBounds.h));
|
||||
}
|
||||
|
||||
if (!image->bounds().contains(ipos))
|
||||
continue;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user