mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-06 03:21:49 +00:00
feat: update atlas texture extrusion on its reload
This commit is contained in:
parent
b89888969f
commit
28dd2f38d2
5 changed files with 26 additions and 6 deletions
|
|
@ -6,6 +6,7 @@
|
|||
#include <random>
|
||||
|
||||
#include "lua_commons.hpp"
|
||||
#include "constants.hpp"
|
||||
#include "maths/UVRegion.hpp"
|
||||
|
||||
struct fnl_state;
|
||||
|
|
@ -108,7 +109,7 @@ namespace lua {
|
|||
return texture;
|
||||
}
|
||||
|
||||
void update();
|
||||
void update(int extrusion = ATLAS_EXTRUSION);
|
||||
|
||||
void createTexture();
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ LuaCanvas::LuaCanvas(
|
|||
region(std::move(region)) {
|
||||
}
|
||||
|
||||
void LuaCanvas::update() {
|
||||
void LuaCanvas::update(int extrusion) {
|
||||
if (!hasTexture()) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -39,7 +39,24 @@ void LuaCanvas::update() {
|
|||
w = std::min<uint>(w, imgWidth);
|
||||
h = std::min<uint>(h, imgHeight);
|
||||
|
||||
texture->reloadPartial(*data, x, y, w, h);
|
||||
if (extrusion > 0) {
|
||||
auto extruded = std::make_unique<ImageData>(
|
||||
data->getFormat(),
|
||||
w + extrusion * 2,
|
||||
h + extrusion * 2
|
||||
);
|
||||
extruded->blit(*data, extrusion, extrusion);
|
||||
extruded->extrude(0, 0, w + extrusion * 2, h + extrusion * 2);
|
||||
texture->reloadPartial(
|
||||
*extruded,
|
||||
x - extrusion,
|
||||
y - extrusion,
|
||||
w + extrusion * 2,
|
||||
h + extrusion * 2
|
||||
);
|
||||
} else {
|
||||
texture->reloadPartial(*data, x, y, w, h);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue