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:
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
15
src/ObjLoading/Image/ImageLoaderCommon.cpp
Normal file
15
src/ObjLoading/Image/ImageLoaderCommon.cpp
Normal 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
|
||||
23
src/ObjLoading/Image/ImageLoaderCommon.h
Normal file
23
src/ObjLoading/Image/ImageLoaderCommon.h
Normal 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
|
||||
Reference in New Issue
Block a user