Merge pull request #109630 from aaronfranke/openxr-gltf-doc-ext

OpenXR: Use GLTFDocument function to get supported extension names
This commit is contained in:
Thaddeus Crews 2025-08-21 06:24:28 -05:00
commit d5ad0556a2
No known key found for this signature in database
GPG key ID: 8C6E5FEB5FC03CCC

View file

@ -345,29 +345,20 @@ RID OpenXRRenderModelExtension::render_model_create(XrRenderModelIdEXT p_render_
RenderModel render_model; RenderModel render_model;
render_model.xr_render_model_id = p_render_model_id; render_model.xr_render_model_id = p_render_model_id;
// Start with the extensions that are supported in our base (see GLTFDocument::_parse_gltf_extensions). // Get a list of supported glTF extensions.
Vector<const char *> supported_gltf_extensions = { const HashSet<String> supported_gltf_extensions_hash_set = GLTFDocument::get_supported_gltf_extensions_hashset();
"KHR_lights_punctual", Vector<CharString> supported_gltf_extensions_char_string; // Just for temp storage of our c-strings.
"KHR_materials_pbrSpecularGlossiness", supported_gltf_extensions_char_string.resize(supported_gltf_extensions_hash_set.size());
"KHR_texture_transform", int64_t supported_gltf_extension_index = 0;
"KHR_materials_unlit", for (const String &ext : supported_gltf_extensions_hash_set) {
"KHR_materials_emissive_strength", supported_gltf_extensions_char_string.set(supported_gltf_extension_index, ext.utf8());
}; supported_gltf_extension_index++;
// Now find anything we support through plugins, which is a bit of a pain as they are converted to Strings
// and we need to convert them back.
Vector<CharString> char_extensions; // Just for temp storage of our c-strings.
Vector<Ref<GLTFDocumentExtension>> gltf_document_extensions = GLTFDocument::get_all_gltf_document_extensions();
for (Ref<GLTFDocumentExtension> &gltf_document_extension : gltf_document_extensions) {
Vector<String> supported_extensions = gltf_document_extension->get_supported_extensions();
for (const String &extension : supported_extensions) {
char_extensions.push_back(extension.utf8());
}
} }
// Now we can convert them to the `const char *` format.
// Now we can add them to our supported extensions list. Vector<const char *> supported_gltf_extensions;
for (const CharString &cs : char_extensions) { supported_gltf_extensions.resize(supported_gltf_extensions_char_string.size());
supported_gltf_extensions.push_back(cs.get_data()); for (int64_t i = 0; i < supported_gltf_extensions_char_string.size(); i++) {
supported_gltf_extensions.write[i] = supported_gltf_extensions_char_string[i].get_data();
} }
XrRenderModelCreateInfoEXT create_info = { XrRenderModelCreateInfoEXT create_info = {