Update fastgltf to 0.9.0
This commit is contained in:
+2
-2
@@ -220,8 +220,8 @@ FetchContent_Declare(boost EXCLUDE_FROM_ALL SYSTEM URL https://github.co
|
|||||||
# Client dependencies
|
# Client dependencies
|
||||||
FetchContent_Declare(simdjson EXCLUDE_FROM_ALL SYSTEM URL https://github.com/simdjson/simdjson/archive/refs/tags/v3.10.1.tar.gz
|
FetchContent_Declare(simdjson EXCLUDE_FROM_ALL SYSTEM URL https://github.com/simdjson/simdjson/archive/refs/tags/v3.10.1.tar.gz
|
||||||
URL_HASH SHA256=1e8f881cb2c0f626c56cd3665832f1e97b9d4ffc648ad9e1067c134862bba060)
|
URL_HASH SHA256=1e8f881cb2c0f626c56cd3665832f1e97b9d4ffc648ad9e1067c134862bba060)
|
||||||
FetchContent_Declare(fastgltf EXCLUDE_FROM_ALL SYSTEM URL https://github.com/spnda/fastgltf/archive/refs/tags/v0.7.1.tar.gz
|
FetchContent_Declare(fastgltf EXCLUDE_FROM_ALL SYSTEM URL https://github.com/spnda/fastgltf/archive/refs/tags/v0.9.0.tar.gz
|
||||||
URL_HASH SHA256=44bcb025dd5cd480236a3bc7a3f8c9a708a801ed773b7859677440d22e0e1e7c)
|
URL_HASH SHA256=0bb564e127b14c22f062db50f89381dd2e0a20dbaf4987ca138a4ae8728712f9)
|
||||||
FetchContent_Declare(glm EXCLUDE_FROM_ALL SYSTEM URL https://github.com/g-truc/glm/archive/refs/tags/1.0.1.tar.gz
|
FetchContent_Declare(glm EXCLUDE_FROM_ALL SYSTEM URL https://github.com/g-truc/glm/archive/refs/tags/1.0.1.tar.gz
|
||||||
URL_HASH SHA256=9f3174561fd26904b23f0db5e560971cbf9b3cbda0b280f04d5c379d03bf234c)
|
URL_HASH SHA256=9f3174561fd26904b23f0db5e560971cbf9b3cbda0b280f04d5c379d03bf234c)
|
||||||
FetchContent_Declare(openxr_loader EXCLUDE_FROM_ALL SYSTEM URL https://github.com/KhronosGroup/OpenXR-SDK/archive/refs/tags/release-1.1.48.tar.gz
|
FetchContent_Declare(openxr_loader EXCLUDE_FROM_ALL SYSTEM URL https://github.com/KhronosGroup/OpenXR-SDK/archive/refs/tags/release-1.1.48.tar.gz
|
||||||
|
|||||||
@@ -165,12 +165,12 @@ vk::PrimitiveTopology convert(fastgltf::PrimitiveType type)
|
|||||||
throw std::invalid_argument("type");
|
throw std::invalid_argument("type");
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::vec4 convert(const std::array<float, 4> & v)
|
glm::vec4 convert(const fastgltf::math::nvec4 & v)
|
||||||
{
|
{
|
||||||
return {v[0], v[1], v[2], v[3]};
|
return {v[0], v[1], v[2], v[3]};
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::vec3 convert(const std::array<float, 3> & v)
|
glm::vec3 convert(const fastgltf::math::nvec3 & v)
|
||||||
{
|
{
|
||||||
return {v[0], v[1], v[2]};
|
return {v[0], v[1], v[2]};
|
||||||
}
|
}
|
||||||
@@ -196,7 +196,7 @@ void copy_vertex_attributes(
|
|||||||
if (it == primitive.attributes.end())
|
if (it == primitive.attributes.end())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const fastgltf::Accessor & accessor = asset.accessors.at(it->second);
|
const fastgltf::Accessor & accessor = asset.accessors.at(it->accessorIndex);
|
||||||
|
|
||||||
if (vertices.size() < accessor.count)
|
if (vertices.size() < accessor.count)
|
||||||
vertices.resize(accessor.count, {});
|
vertices.resize(accessor.count, {});
|
||||||
@@ -221,7 +221,7 @@ void copy_vertex_attributes(
|
|||||||
if (it == primitive.attributes.end())
|
if (it == primitive.attributes.end())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const fastgltf::Accessor & accessor = asset.accessors.at(it->second);
|
const fastgltf::Accessor & accessor = asset.accessors.at(it->accessorIndex);
|
||||||
|
|
||||||
if (vertices.size() < accessor.count)
|
if (vertices.size() < accessor.count)
|
||||||
vertices.resize(accessor.count, {});
|
vertices.resize(accessor.count, {});
|
||||||
@@ -285,6 +285,21 @@ loaded_image do_load_image(
|
|||||||
}
|
}
|
||||||
// END
|
// END
|
||||||
|
|
||||||
|
// BEGIN Error category
|
||||||
|
struct : std::error_category
|
||||||
|
{
|
||||||
|
const char * name() const noexcept override
|
||||||
|
{
|
||||||
|
return "fastgltf";
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string message(int condition) const override
|
||||||
|
{
|
||||||
|
return (std::string)fastgltf::getErrorMessage(static_cast<fastgltf::Error>(condition));
|
||||||
|
}
|
||||||
|
} fastgltf_error_category;
|
||||||
|
// END
|
||||||
|
|
||||||
fastgltf::Asset load_gltf_asset(fastgltf::GltfDataBuffer & buffer, const std::filesystem::path & directory)
|
fastgltf::Asset load_gltf_asset(fastgltf::GltfDataBuffer & buffer, const std::filesystem::path & directory)
|
||||||
{
|
{
|
||||||
fastgltf::Parser parser(fastgltf::Extensions::KHR_texture_basisu);
|
fastgltf::Parser parser(fastgltf::Extensions::KHR_texture_basisu);
|
||||||
@@ -292,13 +307,12 @@ fastgltf::Asset load_gltf_asset(fastgltf::GltfDataBuffer & buffer, const std::fi
|
|||||||
auto gltf_options =
|
auto gltf_options =
|
||||||
fastgltf::Options::DontRequireValidAssetMember |
|
fastgltf::Options::DontRequireValidAssetMember |
|
||||||
fastgltf::Options::AllowDouble |
|
fastgltf::Options::AllowDouble |
|
||||||
fastgltf::Options::LoadGLBBuffers |
|
|
||||||
fastgltf::Options::DecomposeNodeMatrices;
|
fastgltf::Options::DecomposeNodeMatrices;
|
||||||
|
|
||||||
auto expected_asset = parser.loadGltf(&buffer, directory, gltf_options);
|
auto expected_asset = parser.loadGltf(buffer, directory, gltf_options);
|
||||||
|
|
||||||
if (auto error = expected_asset.error(); error != fastgltf::Error::None)
|
if (auto error = expected_asset.error(); error != fastgltf::Error::None)
|
||||||
throw std::runtime_error(std::string(fastgltf::getErrorMessage(error)));
|
throw std::system_error((int)error, fastgltf_error_category);
|
||||||
|
|
||||||
return std::move(expected_asset.get());
|
return std::move(expected_asset.get());
|
||||||
}
|
}
|
||||||
@@ -776,15 +790,17 @@ entt::registry scene_loader::operator()(const std::filesystem::path & gltf_path)
|
|||||||
spdlog::debug("Loading {}", gltf_path.native());
|
spdlog::debug("Loading {}", gltf_path.native());
|
||||||
|
|
||||||
asset asset_file(gltf_path);
|
asset asset_file(gltf_path);
|
||||||
fastgltf::GltfDataBuffer data_buffer;
|
|
||||||
data_buffer.copyBytes(reinterpret_cast<const uint8_t *>(asset_file.data()), asset_file.size());
|
|
||||||
|
|
||||||
fastgltf::Asset asset = load_gltf_asset(data_buffer, gltf_path.parent_path());
|
auto data_buffer = fastgltf::GltfDataBuffer::FromBytes(asset_file.data(), asset_file.size());
|
||||||
|
if (auto error = data_buffer.error(); error != fastgltf::Error::None)
|
||||||
|
throw std::system_error((int)error, fastgltf_error_category);
|
||||||
|
|
||||||
|
fastgltf::Asset asset = load_gltf_asset(data_buffer.get(), gltf_path.parent_path());
|
||||||
loader_context ctx(gltf_path.parent_path(), gltf_path, asset, physical_device, device, queue, cb_pool);
|
loader_context ctx(gltf_path.parent_path(), gltf_path, asset, physical_device, device, queue, cb_pool);
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
if (auto error = fastgltf::validate(asset); error != fastgltf::Error::None)
|
if (auto error = fastgltf::validate(asset); error != fastgltf::Error::None)
|
||||||
throw std::runtime_error(std::string(fastgltf::getErrorMessage(error)));
|
throw std::system_error((int)error, fastgltf_error_category);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Load all buffers from URIs
|
// Load all buffers from URIs
|
||||||
|
|||||||
Reference in New Issue
Block a user