summaryrefslogtreecommitdiff
path: root/indra/newview/gltf/llgltfloader.h
diff options
context:
space:
mode:
authorAndrey Lihatskiy <alihatskiy@productengine.com>2025-07-15 19:06:28 +0300
committerAndrey Lihatskiy <118752495+marchcat@users.noreply.github.com>2025-07-15 18:43:51 +0000
commitb046a8b72ab7959c789b1b5dfb7da42e97044ba4 (patch)
tree6c37de4dc8e74a498b410dd75256e20ca701b4aa /indra/newview/gltf/llgltfloader.h
parent5a50be4e1554c6f96ff52fdbda5ba1c890d18a6d (diff)
#4204 Cache material names, centralize texture index validation
Diffstat (limited to 'indra/newview/gltf/llgltfloader.h')
-rw-r--r--indra/newview/gltf/llgltfloader.h16
1 files changed, 13 insertions, 3 deletions
diff --git a/indra/newview/gltf/llgltfloader.h b/indra/newview/gltf/llgltfloader.h
index 46506cdf50..e8b91996c7 100644
--- a/indra/newview/gltf/llgltfloader.h
+++ b/indra/newview/gltf/llgltfloader.h
@@ -71,6 +71,14 @@ class LLGLTFLoader : public LLModelLoader
typedef std::map <S32, JointNodeData> joints_data_map_t;
typedef std::map <std::string, S32> joints_name_to_node_map_t;
+ class LLGLTFImportMaterial : public LLImportMaterial
+ {
+ public:
+ std::string name;
+ LLGLTFImportMaterial() = default;
+ LLGLTFImportMaterial(const LLImportMaterial& mat, const std::string& n) : LLImportMaterial(mat), name(n) {}
+ };
+
LLGLTFLoader(std::string filename,
S32 lod,
LLModelLoader::load_callback_t load_cb,
@@ -131,16 +139,18 @@ protected:
// per skin joint count, needs to be tracked for the sake of limits check.
std::vector<S32> mValidJointsCount;
- // Material cache to avoid duplicate processing
- std::map<S32, LLImportMaterial> mMaterialCache;
+ // Cached material information
+ typedef std::map<S32, LLGLTFImportMaterial> MaterialCache;
+ MaterialCache mMaterialCache;
private:
bool parseMeshes();
void computeCombinedNodeTransform(const LL::GLTF::Asset& asset, S32 node_index, glm::mat4& combined_transform) const;
void processNodeHierarchy(S32 node_idx, std::map<std::string, S32>& mesh_name_counts, U32 submodel_limit, const LLVolumeParams& volume_params);
bool addJointToModelSkin(LLMeshSkinInfo& skin_info, S32 gltf_skin_idx, size_t gltf_joint_idx);
- LLImportMaterial processMaterial(S32 material_index);
+ LLGLTFImportMaterial processMaterial(S32 material_index, S32 fallback_index);
std::string processTexture(S32 texture_index, const std::string& texture_type, const std::string& material_name);
+ bool validateTextureIndex(S32 texture_index, S32& source_index);
std::string generateMaterialName(S32 material_index, S32 fallback_index = -1);
bool populateModelFromMesh(LLModel* pModel, const std::string& base_name, const LL::GLTF::Mesh &mesh, const LL::GLTF::Node &node, material_map& mats);
void populateJointsFromSkin(S32 skin_idx);