[Bf-blender-cvs] [6daab062b46] xr-controller-support: Fix build errors/warnings on some platforms

Peter Kim noreply at git.blender.org
Thu Jul 22 10:37:20 CEST 2021


Commit: 6daab062b467c4ed8d9a23d024d7f348e11bcd6b
Author: Peter Kim
Date:   Thu Jul 22 17:35:14 2021 +0900
Branches: xr-controller-support
https://developer.blender.org/rB6daab062b467c4ed8d9a23d024d7f348e11bcd6b

Fix build errors/warnings on some platforms

===================================================================

M	extern/tinygltf/stb_image.h
M	extern/tinygltf/stb_image_write.h
M	intern/ghost/intern/GHOST_XrContext.cpp
M	intern/ghost/intern/GHOST_XrControllerModel.cpp

===================================================================

diff --git a/extern/tinygltf/stb_image.h b/extern/tinygltf/stb_image.h
index 8b710609e3b..8d9c7a54c17 100644
--- a/extern/tinygltf/stb_image.h
+++ b/extern/tinygltf/stb_image.h
@@ -5392,10 +5392,10 @@ static int stbi__tga_get_comp(int bits_per_pixel, int is_grey, int* is_rgb16)
    switch(bits_per_pixel) {
       case 8:  return STBI_grey;
       case 16: if(is_grey) return STBI_grey_alpha;
-               // fallthrough
+               [[fallthrough]]; // fallthrough
       case 15: if(is_rgb16) *is_rgb16 = 1;
                return STBI_rgb;
-      case 24: // fallthrough
+      case 24: [[fallthrough]]; // fallthrough
       case 32: return bits_per_pixel/8;
       default: return 0;
    }
@@ -6723,10 +6723,10 @@ static void stbi__hdr_convert(float *output, stbi_uc *input, int req_comp)
       if (req_comp == 4) output[3] = 1;
    } else {
       switch (req_comp) {
-         case 4: output[3] = 1; /* fallthrough */
+         case 4: output[3] = 1; [[fallthrough]]; /* fallthrough */
          case 3: output[0] = output[1] = output[2] = 0;
                  break;
-         case 2: output[1] = 1; /* fallthrough */
+         case 2: output[1] = 1; [[fallthrough]]; /* fallthrough */
          case 1: output[0] = 0;
                  break;
       }
diff --git a/extern/tinygltf/stb_image_write.h b/extern/tinygltf/stb_image_write.h
index ebaa0c55419..25bed9fa702 100644
--- a/extern/tinygltf/stb_image_write.h
+++ b/extern/tinygltf/stb_image_write.h
@@ -421,6 +421,7 @@ static void stbiw__write_pixel(stbi__write_context *s, int rgb_dir, int comp, in
             stbiw__write3(s, px[1 - rgb_dir], px[1], px[1 + rgb_dir]);
             break;
          }
+         [[fallthrough]];
          /* FALLTHROUGH */
       case 3:
          stbiw__write3(s, d[1 - rgb_dir], d[1], d[1 + rgb_dir]);
@@ -649,7 +650,7 @@ static void stbiw__write_hdr_scanline(stbi__write_context *s, int width, int nco
    if (width < 8 || width >= 32768) {
       for (x=0; x < width; x++) {
          switch (ncomp) {
-            case 4: /* fallthrough */
+            case 4: [[fallthrough]]; /* fallthrough */
             case 3: linear[2] = scanline[x*ncomp + 2];
                     linear[1] = scanline[x*ncomp + 1];
                     linear[0] = scanline[x*ncomp + 0];
@@ -666,7 +667,7 @@ static void stbiw__write_hdr_scanline(stbi__write_context *s, int width, int nco
       /* encode into scratch buffer */
       for (x=0; x < width; x++) {
          switch(ncomp) {
-            case 4: /* fallthrough */
+            case 4: [[fallthrough]]; /* fallthrough */
             case 3: linear[2] = scanline[x*ncomp + 2];
                     linear[1] = scanline[x*ncomp + 1];
                     linear[0] = scanline[x*ncomp + 0];
diff --git a/intern/ghost/intern/GHOST_XrContext.cpp b/intern/ghost/intern/GHOST_XrContext.cpp
index 355168b0fba..069dc789eea 100644
--- a/intern/ghost/intern/GHOST_XrContext.cpp
+++ b/intern/ghost/intern/GHOST_XrContext.cpp
@@ -628,7 +628,7 @@ bool GHOST_XrContext::isControllerModelExtensionEnabled() const
 {
 #ifdef XR_MSFT_controller_model
   for (const char *ext_name : m_enabled_extensions) {
-    if (std::strcmp(ext_name, XR_MSFT_CONTROLLER_MODEL_EXTENSION_NAME) == 0) {
+    if (strcmp(ext_name, XR_MSFT_CONTROLLER_MODEL_EXTENSION_NAME) == 0) {
       return true;
     }
   }
diff --git a/intern/ghost/intern/GHOST_XrControllerModel.cpp b/intern/ghost/intern/GHOST_XrControllerModel.cpp
index 52f6d69d929..bbf82622370 100644
--- a/intern/ghost/intern/GHOST_XrControllerModel.cpp
+++ b/intern/ghost/intern/GHOST_XrControllerModel.cpp
@@ -20,17 +20,18 @@
 
 #include <cassert>
 
+#include <Eigen/Core>
+
 #include "GHOST_Types.h"
 #include "GHOST_XrException.h"
 #include "GHOST_Xr_intern.h"
 
 #include "GHOST_XrControllerModel.h"
 
-#include <Eigen/Core>
-
 #define TINYGLTF_IMPLEMENTATION
 #define STB_IMAGE_IMPLEMENTATION
 #define STB_IMAGE_WRITE_IMPLEMENTATION
+#define STBIWDEF static inline
 #include "tiny_gltf.h"
 
 using Eigen::Matrix4f; /* For matrix multiplication. */
@@ -49,11 +50,11 @@ struct GHOST_XrPrimitive {
 
 /* Validate that an accessor does not go out of bounds of the buffer view that it references and
    that the buffer view does not exceed the bounds of the buffer that it references. */
-void validate_accessor(const tinygltf::Accessor &accessor,
-                       const tinygltf::BufferView &buffer_view,
-                       const tinygltf::Buffer &buffer,
-                       size_t byte_stride,
-                       size_t element_size)
+static void validate_accessor(const tinygltf::Accessor &accessor,
+                              const tinygltf::BufferView &buffer_view,
+                              const tinygltf::Buffer &buffer,
+                              size_t byte_stride,
+                              size_t element_size)
 {
   /* Make sure the accessor does not go out of range of the buffer view. */
   if (accessor.byteOffset + (accessor.count - 1) * byte_stride + element_size >
@@ -133,10 +134,10 @@ static void load_attribute_accessor(const tinygltf::Model &gltf_model,
    16bit or 32bit integers. This will coalesce indices from the source type(s) into a 32bit
    integer. */
 template<typename TSrcIndex>
-void read_indices(const tinygltf::Accessor &accessor,
-                  const tinygltf::BufferView &buffer_view,
-                  const tinygltf::Buffer &buffer,
-                  GHOST_XrPrimitive &primitive)
+static void read_indices(const tinygltf::Accessor &accessor,
+                         const tinygltf::BufferView &buffer_view,
+                         const tinygltf::Buffer &buffer,
+                         GHOST_XrPrimitive &primitive)
 {
   if (buffer_view.target != TINYGLTF_TARGET_ELEMENT_ARRAY_BUFFER &&
       buffer_view.target != 0) { /* Allow 0 (not specified) even though spec doesn't seem to allow
@@ -264,7 +265,7 @@ static void load_node(tinygltf::Model gltf_model,
     const tinygltf::Mesh &gltf_mesh = gltf_model.meshes.at(gltf_node.mesh);
 
     GHOST_XrControllerModelComponent &component = components.emplace_back();
-    std::memcpy(component.transform, transform, sizeof(component.transform));
+    memcpy(component.transform, transform, sizeof(component.transform));
     component.vertex_offset = vertices.size();
     component.index_offset = indices.size();



More information about the Bf-blender-cvs mailing list