Skip to content

Commit

Permalink
fixed asset browser when using out of tree data
Browse files Browse the repository at this point in the history
  • Loading branch information
nem0 committed Jun 15, 2024
1 parent 4517e66 commit 2c44ad7
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/renderer/editor/render_plugins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ static void flipX(Vec4* data, int texture_size)
}
}

static bool saveAsLBC(const char* path, const u8* data, int w, int h, bool generate_mipmaps, bool is_origin_bottom_left, IAllocator& allocator) {
static bool saveAsLBC(FileSystem& fs, const char* path, const u8* data, int w, int h, bool generate_mipmaps, bool is_origin_bottom_left, IAllocator& allocator) {
ASSERT(data);

OutputMemoryStream blob(allocator);
Expand All @@ -638,7 +638,7 @@ static bool saveAsLBC(const char* path, const u8* data, int w, int h, bool gener
return false;
}
os::OutputFile file;
if (!file.open(path)) return false;
if (!fs.open(path, file)) return false;
(void)file.write("lbc", 3);
(void)file.write(u32(0));
(void)file.write(blob.data(), blob.size());
Expand Down Expand Up @@ -1459,7 +1459,7 @@ struct TexturePlugin final : AssetBrowser::IPlugin, AssetCompiler::IPlugin {

applyTint();

if (!saveAsLBC(m_out_path.c_str(), resized_data.data(), AssetBrowser::TILE_SIZE, AssetBrowser::TILE_SIZE, false, true, m_allocator)) {
if (!saveAsLBC(fs, m_out_path.c_str(), resized_data.data(), AssetBrowser::TILE_SIZE, AssetBrowser::TILE_SIZE, false, true, m_allocator)) {
logError("Failed to save ", m_out_path);
}
}
Expand All @@ -1485,7 +1485,7 @@ struct TexturePlugin final : AssetBrowser::IPlugin, AssetCompiler::IPlugin {

applyTint();

if (!saveAsLBC(m_out_path.c_str(), resized_data.data(), AssetBrowser::TILE_SIZE, AssetBrowser::TILE_SIZE, false, true, m_allocator)) {
if (!saveAsLBC(fs, m_out_path.c_str(), resized_data.data(), AssetBrowser::TILE_SIZE, AssetBrowser::TILE_SIZE, false, true, m_allocator)) {
logError("Failed to save ", m_out_path);
}
}
Expand Down Expand Up @@ -2853,7 +2853,7 @@ struct ModelPlugin final : AssetBrowser::IPlugin, AssetCompiler::IPlugin {
destroyEntityRecursive(*m_tile.world, (EntityRef)m_tile.entity);
Engine& engine = m_app.getEngine();
FileSystem& fs = engine.getFileSystem();
const Path path(fs.getBasePath(), ".lumix/asset_tiles/", m_tile.out_path_hash, ".lbc");
const Path path(".lumix/asset_tiles/", m_tile.out_path_hash, ".lbc");

if (!gpu::isOriginBottomLeft()) {
u32* p = (u32*)m_tile.data.getMutableData();
Expand All @@ -2864,7 +2864,7 @@ struct ModelPlugin final : AssetBrowser::IPlugin, AssetCompiler::IPlugin {
}
}

saveAsLBC(path.c_str(), m_tile.data.data(), AssetBrowser::TILE_SIZE, AssetBrowser::TILE_SIZE, false, gpu::isOriginBottomLeft(), m_app.getAllocator());
saveAsLBC(fs, path.c_str(), m_tile.data.data(), AssetBrowser::TILE_SIZE, AssetBrowser::TILE_SIZE, false, gpu::isOriginBottomLeft(), m_app.getAllocator());
memset(m_tile.data.getMutableData(), 0, m_tile.data.size());
m_renderer->getEndFrameDrawStream().destroy(m_tile.texture);
m_tile.entity = INVALID_ENTITY;
Expand Down

0 comments on commit 2c44ad7

Please sign in to comment.