Skip to content
Snippets Groups Projects
Commit daa97196 authored by Joseph Walton-Rivers's avatar Joseph Walton-Rivers
Browse files

fix issues with assimp loader in release mode

parent c9553fb4
No related branches found
No related tags found
No related merge requests found
Pipeline #3632 failed
......@@ -139,7 +139,7 @@ namespace fggl::data::models {
}
static assets::AssetRefRaw load_assimp_model(assets::Loader* loader, const assets::AssetID& guid, const assets::LoaderContext& data, void* userPtr) {
assets::AssetRefRaw load_assimp_model(assets::Loader* loader, const assets::AssetID& guid, const assets::LoaderContext& data, void* userPtr) {
// auto *filePath = std::get<assets::AssetPath *>(data);
assets::AssetManager* manager = (assets::AssetManager*)userPtr;
auto filePath = data.assetPath;
......@@ -191,7 +191,7 @@ namespace fggl::data::models {
return nullptr;
}
static assets::AssetRefRaw load_assimp_texture(assets::Loader* loader, const assets::AssetID& guid, const assets::LoaderContext& data, void* userPtr) {
assets::AssetRefRaw load_assimp_texture(assets::Loader* loader, const assets::AssetID& guid, const assets::LoaderContext& data, void* userPtr) {
assets::AssetManager* manager = (assets::AssetManager*)userPtr;
if ( manager->has(guid) ) {
......@@ -217,7 +217,7 @@ namespace fggl::data::models {
return nullptr;
}
static bool load_tex_stb(std::filesystem::path filePath, assets::MemoryBlock& block) {
bool load_tex_stb(std::filesystem::path filePath, assets::MemoryBlock& block) {
stbi_set_flip_vertically_on_load(true);
//load the texture data into memory
......@@ -238,7 +238,7 @@ namespace fggl::data::models {
}
}
static assets::AssetTypeID is_tex_stb(std::filesystem::path filePath) {
assets::AssetTypeID is_tex_stb(std::filesystem::path filePath) {
// detect jpgs
if ( filePath.extension() == ".jpg" || filePath.extension() == ".jpeg" ) {
return TEXTURE_RGBA;
......@@ -252,7 +252,7 @@ namespace fggl::data::models {
return assets::INVALID_ASSET_TYPE;
}
static assets::AssetTypeID is_model_assimp(std::filesystem::path filePath) {
assets::AssetTypeID is_model_assimp(std::filesystem::path filePath) {
if ( filePath.extension() == ".obj" ){
return MODEL_MULTI3D;
}
......@@ -260,7 +260,7 @@ namespace fggl::data::models {
return assets::INVALID_ASSET_TYPE;
}
static bool extract_requirements(const std::string& packName, std::filesystem::path packRoot, assets::ResourceRecord& rr) {
bool extract_requirements(const std::string& packName, std::filesystem::path packRoot, assets::ResourceRecord& rr) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile( rr.m_path, aiProcess_Triangulate | aiProcess_FlipUVs);
if ( !scene || scene->mFlags & AI_SCENE_FLAGS_INCOMPLETE || !scene->mRootNode ) {
......@@ -304,6 +304,7 @@ namespace fggl::data::models {
checkin->setLoader( MIME_OBJ, assets::NEEDS_CHECKIN, is_model_assimp );
checkin->setProcessor( MIME_OBJ, extract_requirements);
return false;
}
}
......
......@@ -36,6 +36,18 @@ namespace fggl::data::models {
constexpr auto MODEL_MULTI3D = assets::make_asset_type("model/multi3D");
constexpr auto TEXTURE_RGBA = assets::make_asset_type("texture/rgba");
// old-style loaders
assets::AssetRefRaw load_assimp_model(assets::Loader* loader, const assets::AssetID& guid, const assets::LoaderContext& data, void* userPtr);
assets::AssetRefRaw load_assimp_texture(assets::Loader* loader, const assets::AssetID& guid, const assets::LoaderContext& data, void* userPtr);
// new style loaders (textures)
bool load_tex_stb(std::filesystem::path filePath, assets::MemoryBlock& block);
static assets::AssetTypeID is_tex_stb(std::filesystem::path filePath);
// new style loaders (models)
assets::AssetTypeID is_model_assimp(std::filesystem::path filePath);
bool extract_requirements(const std::string& packName, std::filesystem::path packRoot, assets::ResourceRecord& rr);
struct AssimpModule {
constexpr static const char *name = "fggl::data::Assimp";
constexpr static const std::array<modules::ModuleService, 1> provides = {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment