Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/intern
diff options
context:
space:
mode:
authorPeter Kim <pk15950@gmail.com>2021-10-03 06:16:07 +0300
committerPeter Kim <pk15950@gmail.com>2021-10-03 06:16:07 +0300
commit85e1f28fcaafd137a546bf192777b00f96851e80 (patch)
treeab0505102bf10d9efa9d1aa849aeef5885798b20 /intern
parentc4f65fa5da4c1f3498316da3eac7c0b43b218fd6 (diff)
Fix controller model loading for no stb image
Diffstat (limited to 'intern')
-rw-r--r--intern/ghost/intern/GHOST_XrControllerModel.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/intern/ghost/intern/GHOST_XrControllerModel.cpp b/intern/ghost/intern/GHOST_XrControllerModel.cpp
index 659bf8555f3..ae15bf11aa0 100644
--- a/intern/ghost/intern/GHOST_XrControllerModel.cpp
+++ b/intern/ghost/intern/GHOST_XrControllerModel.cpp
@@ -484,6 +484,31 @@ void GHOST_XrControllerModel::loadControllerModel(XrSession session)
tinygltf::TinyGLTF gltf_loader;
tinygltf::Model gltf_model;
std::string err_msg;
+ {
+ /* Workaround for TINYGLTF_NO_STB_IMAGE define. Set custom image loader to prevent failure when
+ * parsing image data. */
+ auto load_img_func = [](tinygltf::Image *img,
+ const int p0,
+ std::string *p1,
+ std::string *p2,
+ int p3,
+ int p4,
+ const unsigned char *p5,
+ int p6,
+ void *user_pointer) -> bool {
+ (void)img;
+ (void)p0;
+ (void)p1;
+ (void)p2;
+ (void)p3;
+ (void)p4;
+ (void)p5;
+ (void)p6;
+ (void)user_pointer;
+ return true;
+ };
+ gltf_loader.SetImageLoader(load_img_func, nullptr);
+ }
if (!gltf_loader.LoadBinaryFromMemory(&gltf_model, &err_msg, nullptr, buf.data(), buf_size)) {
throw GHOST_XrException(("Failed to load glTF controller model: " + err_msg).c_str());