Skip to content

Commit ac38e67

Browse files
AssetLoader: expose GLTF texture image index helper
1 parent 38019f8 commit ac38e67

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

AssetLoader/interface/GLTFLoader.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ class Model;
6060
struct Mesh;
6161
struct Material;
6262
struct Image;
63+
struct Texture;
6364

6465
} // namespace tinygltf
6566

@@ -75,6 +76,9 @@ class MeshLoader;
7576
class ModelBuilder;
7677
class MaterialBuilder;
7778

79+
int GetTextureImageIndex(const tinygltf::Model& GltfModel,
80+
const tinygltf::Texture& GltfTexture);
81+
7882
/// Texture attribute description.
7983
struct TextureAttributeDesc
8084
{

AssetLoader/src/GLTFLoader.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -897,6 +897,13 @@ int GetSource(const tinygltf::Texture& gltf_tex,
897897

898898
} // namespace MSFTTextureDDS
899899

900+
int GetTextureImageIndex(const tinygltf::Model& gltf_model,
901+
const tinygltf::Texture& gltf_tex)
902+
{
903+
const int DDSSource = MSFTTextureDDS::GetSource(gltf_tex, gltf_model);
904+
return DDSSource >= 0 ? DDSSource : gltf_tex.source;
905+
}
906+
900907
struct GLTFTextureSource
901908
{
902909
Uint32 TextureIndex = 0;
@@ -912,8 +919,7 @@ static GLTFTextureSource GetGLTFTextureSource(const tinygltf::Model& gltf_mode
912919
const tinygltf::Texture& gltf_tex,
913920
const std::string& BaseDir)
914921
{
915-
const int DDSSource = MSFTTextureDDS::GetSource(gltf_tex, gltf_model);
916-
const int ImageSource = DDSSource >= 0 ? DDSSource : gltf_tex.source;
922+
const int ImageSource = GetTextureImageIndex(gltf_model, gltf_tex);
917923

918924
const tinygltf::Image& gltf_image = gltf_model.images[ImageSource];
919925

0 commit comments

Comments
 (0)