2
0
mirror of https://github.com/Laupetin/OpenAssetTools.git synced 2026-01-12 11:41:50 +00:00

chore: update image namespacing

This commit is contained in:
Jan Laupetin
2026-01-03 13:58:46 +01:00
parent 793d7ad5dc
commit da2a76f6da
47 changed files with 1940 additions and 1832 deletions

View File

@@ -12,6 +12,7 @@
#include <iostream>
using namespace IW3;
using namespace image;
namespace
{
@@ -38,7 +39,7 @@ namespace
if (!file.IsOpen())
return AssetCreationResult::NoAction();
const auto texture = dds::LoadDds(*file.m_stream);
const auto texture = image::LoadDds(*file.m_stream);
if (!texture)
{
con::error("Failed to load dds file for image asset \"{}\"", assetName);
@@ -91,11 +92,11 @@ namespace
loadDef->levelCount = static_cast<char>(mipCount);
loadDef->flags = 0;
if (!texture->HasMipMaps())
loadDef->flags |= iwi6::IMG_FLAG_NOMIPMAPS;
loadDef->flags |= image::iwi6::IMG_FLAG_NOMIPMAPS;
if (texture->GetTextureType() == TextureType::T_CUBE)
loadDef->flags |= iwi6::IMG_FLAG_CUBEMAP;
loadDef->flags |= image::iwi6::IMG_FLAG_CUBEMAP;
if (texture->GetTextureType() == TextureType::T_3D)
loadDef->flags |= iwi6::IMG_FLAG_VOLMAP;
loadDef->flags |= image::iwi6::IMG_FLAG_VOLMAP;
loadDef->dimensions[0] = image->width;
loadDef->dimensions[1] = image->height;
loadDef->dimensions[2] = image->depth;

View File

@@ -37,7 +37,7 @@ namespace
file.m_stream->read(fileData.get(), fileSize);
std::istringstream ss(std::string(fileData.get(), fileSize));
const auto texture = iwi::LoadIwi(ss);
const auto texture = image::LoadIwi(ss);
if (!texture)
{
con::error("Failed to load texture from: {}", fileName);

View File

@@ -38,7 +38,7 @@ namespace
const auto dataHash = static_cast<unsigned>(crc32(0u, reinterpret_cast<const Bytef*>(fileData.get()), static_cast<unsigned>(fileSize)));
std::istringstream ss(std::string(fileData.get(), fileSize));
const auto texture = iwi::LoadIwi(ss);
const auto texture = image::LoadIwi(ss);
if (!texture)
{
con::error("Failed to load texture from: {}", fileName);

View File

@@ -0,0 +1,15 @@
#include "ImageLoaderCommon.h"
namespace image
{
std::optional<AssetCreationResult> CommonImageLoaderResult::GetResultIfCancelled() const
{
if (m_failure)
return AssetCreationResult::Failure();
if (!m_texture)
return AssetCreationResult::NoAction();
return std::nullopt;
}
} // namespace image

View File

@@ -0,0 +1,23 @@
#pragma once
#include "Asset/AssetCreationResult.h"
#include "Image/IwiTypes.h"
#include "Image/Texture.h"
#include <memory>
#include <optional>
#include <string>
namespace image
{
struct CommonImageLoaderResult
{
std::optional<AssetCreationResult> GetResultIfCancelled() const;
bool m_failure;
std::string m_iwi_path;
std::unique_ptr<Texture> m_texture;
};
CommonImageLoaderResult LoadImageCommon();
} // namespace image