patern_preview/world: Place selection into the world
This commit is contained in:
@@ -143,7 +143,6 @@ void World::resize(int width, int height) {
|
||||
}
|
||||
|
||||
std::vector<uint32_t> World::getSelection(Vector2i &origin, Vector2i &size) {
|
||||
// We assume the selection is in the grid for now
|
||||
std::vector<uint32_t> data = {static_cast<uint32_t>(size.x),
|
||||
static_cast<uint32_t>(size.y)};
|
||||
for (int y = origin.y; y < origin.y + size.y; y++) {
|
||||
@@ -153,3 +152,12 @@ std::vector<uint32_t> World::getSelection(Vector2i &origin, Vector2i &size) {
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
void World::setSelection(Vector2i &origin, Vector2i &size, std::vector<uint32_t> &data) {
|
||||
|
||||
for (int y = 0; y < size.y; y++) {
|
||||
for (int x = 0; x < size.x; x++) {
|
||||
(*_data)[(x + origin.x) + (y + origin.y) * _width] = data[x + y * size.x];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user