From 6fcc13bcd198b5c8d2eb5c2eaf858c5da21881b2 Mon Sep 17 00:00:00 2001 From: Yousif Aldolaijan Date: Tue, 11 Feb 2025 11:02:58 +0300 Subject: [PATCH] apply clang-tidy on gltf code --- platform/darwin/src/gltf/Camera.cpp | 22 +- platform/darwin/src/gltf/Camera.hpp | 8 +- platform/darwin/src/gltf/GLTFMTLRenderItem.h | 5 +- platform/darwin/src/gltf/GLTFManager.hpp | 171 +++++++------- .../gltf/GLTFManagerRenderingEnvironment.hpp | 41 ++-- .../GLTFManagerRenderingEnvironmentMetal.hpp | 47 ++-- platform/darwin/src/gltf/GLTFMath.cpp | 147 +++++------- platform/darwin/src/gltf/GLTFMath.hpp | 20 +- platform/darwin/src/gltf/GLTFModel.hpp | 62 ++--- platform/darwin/src/gltf/GLTFModelLayer.h | 16 +- platform/darwin/src/gltf/GLTFModelLoader.h | 7 +- platform/darwin/src/gltf/GLTFRenderer.cpp | 19 +- platform/darwin/src/gltf/GLTFRenderer.hpp | 103 ++++----- .../darwin/src/gltf/gltfkit/GLTFAccessor.h | 6 +- .../darwin/src/gltf/gltfkit/GLTFAnimation.h | 2 +- platform/darwin/src/gltf/gltfkit/GLTFAsset.h | 24 +- .../darwin/src/gltf/gltfkit/GLTFBinaryChunk.h | 10 +- platform/darwin/src/gltf/gltfkit/GLTFBuffer.h | 3 +- .../darwin/src/gltf/gltfkit/GLTFBufferView.h | 2 +- platform/darwin/src/gltf/gltfkit/GLTFCamera.h | 10 +- platform/darwin/src/gltf/gltfkit/GLTFEnums.h | 214 +++++++++--------- platform/darwin/src/gltf/gltfkit/GLTFImage.h | 8 +- .../darwin/src/gltf/gltfkit/GLTFKHRLight.h | 8 +- .../src/gltf/gltfkit/GLTFMTLBufferAllocator.h | 8 +- .../src/gltf/gltfkit/GLTFMTLShaderBuilder.h | 13 +- .../src/gltf/gltfkit/GLTFMTLTextureLoader.h | 9 +- .../src/gltf/gltfkit/GLTFMTLUtilities.h | 7 +- .../darwin/src/gltf/gltfkit/GLTFMaterial.h | 30 +-- platform/darwin/src/gltf/gltfkit/GLTFMesh.h | 2 +- platform/darwin/src/gltf/gltfkit/GLTFNode.h | 20 +- .../darwin/src/gltf/gltfkit/GLTFNodeVisitor.h | 4 +- platform/darwin/src/gltf/gltfkit/GLTFObject.h | 4 +- platform/darwin/src/gltf/gltfkit/GLTFScene.h | 4 +- .../darwin/src/gltf/gltfkit/GLTFTexture.h | 9 +- .../src/gltf/gltfkit/GLTFTextureSampler.h | 2 +- .../darwin/src/gltf/gltfkit/GLTFUtilities.h | 17 +- .../src/gltf/gltfkit/GLTFVertexDescriptor.h | 2 +- 37 files changed, 520 insertions(+), 566 deletions(-) diff --git a/platform/darwin/src/gltf/Camera.cpp b/platform/darwin/src/gltf/Camera.cpp index d716830ac50..6dc63dced2f 100644 --- a/platform/darwin/src/gltf/Camera.cpp +++ b/platform/darwin/src/gltf/Camera.cpp @@ -20,43 +20,35 @@ Camera::Camera() { _rotationVelocity = 0; _velocity = 0; _distance = 4; // 0; // 2; - } simd_double4x4 Camera::projectionMatrix() { - float fov = M_PI / 3; // original + float fov = M_PI / 3; // original fov = 0.6435011087932844; // Constant that i found in ML simd_double4x4 matrix = GLTFPerspectiveProjectionMatrixAspectFovRH(fov, 1.0, 0.01, 250); return matrix; } void Camera::updateWithTimestep(double timestep) { - - _rotationAngles += _rotationVelocity * timestep; static double rot = 0; // rot += 0.03; -// self.rotationAngles = rot; -// _rotationAngles = simd_make_float3(rot, M_PI/4.0, 0); + // self.rotationAngles = rot; + // _rotationAngles = simd_make_float3(rot, M_PI/4.0, 0); _rotationAngles = simd_make_float3(rot, 0, 0); - // Clamp pitch - _rotationAngles = (simd_float3){ _rotationAngles.x, - static_cast(fmax(-M_PI_2, fmin(_rotationAngles.y, M_PI_2))), - 0 }; - + _rotationAngles = (simd_float3){ + _rotationAngles.x, static_cast(fmax(-M_PI_2, fmin(_rotationAngles.y, M_PI_2))), 0}; _rotationVelocity *= GLTFViewerOrbitCameraRotationDrag; // _distance += _velocity * timestep; _velocity *= GLTFViewerOrbitCameraZoomDrag; - + simd_double4x4 pitchRotation = GLTFRotationMatrixFromAxisAngleD(GLTFAxisXD, -_rotationAngles.y); simd_double4x4 yawRotation = GLTFRotationMatrixFromAxisAngleD(GLTFAxisYD, -_rotationAngles.x); - simd_double4x4 translation = GLTFMatrixFromTranslationD((simd_double3){ 0, 0, _distance }); + simd_double4x4 translation = GLTFMatrixFromTranslationD((simd_double3){0, 0, _distance}); _viewMatrix = matrix_invert(matrix_multiply(matrix_multiply(yawRotation, pitchRotation), translation)); - - } diff --git a/platform/darwin/src/gltf/Camera.hpp b/platform/darwin/src/gltf/Camera.hpp index 05ebba2f6e8..89f760c7e03 100644 --- a/platform/darwin/src/gltf/Camera.hpp +++ b/platform/darwin/src/gltf/Camera.hpp @@ -11,7 +11,8 @@ #include #include -namespace maplibre { namespace gltf { +namespace maplibre { +namespace gltf { class Camera { public: @@ -23,10 +24,9 @@ class Camera { simd_double4x4 projectionMatrix(); simd_double4x4 _viewMatrix; void updateWithTimestep(double timestep); - }; -}} - +} // namespace gltf +} // namespace maplibre #endif /* Camera_hpp */ diff --git a/platform/darwin/src/gltf/GLTFMTLRenderItem.h b/platform/darwin/src/gltf/GLTFMTLRenderItem.h index 4b9cc968b0d..68b0753b1a6 100644 --- a/platform/darwin/src/gltf/GLTFMTLRenderItem.h +++ b/platform/darwin/src/gltf/GLTFMTLRenderItem.h @@ -6,13 +6,12 @@ // #import -#import "gltfkit/GLTFNode.h" #import "gltfkit/GLTFMesh.h" +#import "gltfkit/GLTFNode.h" NS_ASSUME_NONNULL_BEGIN - -@interface GLTFMTLRenderItem: NSObject +@interface GLTFMTLRenderItem : NSObject @property (nonatomic) NSString *label; @property (nonatomic) GLTFNode *node; @property (nonatomic, strong) GLTFSubmesh *submesh; diff --git a/platform/darwin/src/gltf/GLTFManager.hpp b/platform/darwin/src/gltf/GLTFManager.hpp index fcd1061e8dd..9fce472cb1e 100644 --- a/platform/darwin/src/gltf/GLTFManager.hpp +++ b/platform/darwin/src/gltf/GLTFManager.hpp @@ -17,91 +17,90 @@ #include "GLTFModel.hpp" #include "GLTFManagerRenderingEnvironment.hpp" -namespace maplibre { namespace gltf { - - // The type of rendering environment we're in - typedef enum { - RenderingEnvironmentUnknown, - RenderingEnvironmentMetal, - RenderingEnvironmentOpenGL, - RenderingEnvironmentVulkan - } RenderingEnvironment; - - struct Coordinate2D { - double _lat; - double _lon; - }; - - struct Cartesian3D { - double _x; - double _y; - double _z; - }; - - - typedef std::function ProjectionCallback; - - // The GLTF Manager class is the top level entry point - // for all things model based - class GLTFManager { - public: - // Set the callback - void setProjectionCallback(ProjectionCallback projectionCallback); - - // Instantiate the manager with the appropriate environment - GLTFManager(RenderingEnvironment renderingEnvironment); - - // Load a model - void addModel(std::shared_ptr model); - - // Remove a model - void removeModel(std::shared_ptr model); - - // Current meter to screen pixel scale - double _metersPerPixel = 1.0; - - // Set the drawable size - void setDrawableSize(int width, int height); - - // Set the tilt deg - void setTiltDeg(double tiltDeg); - - // Set the rotation deg - void setRotationDeg(double rotationDeg); - - // Set the rendering environment variables - void setRenderingEnvironmentVariables(std::shared_ptr environmentVars); - - // Update any animations - void updateScene(float timeSinceLastDraw); - - // Render - void render(); - - private: - RenderingEnvironment _renderingEnvironment = RenderingEnvironmentUnknown; - - // List of models - std::vector> _models; - - // Projection callback - ProjectionCallback _projectionCallback; - - private: - // Rendering environment - void createRenderingEnvironment(); - - // The renderer - std::shared_ptr _renderer = nullptr; - - - int _drawableWidth = 1; - int _drawableHeight = 1; - double _tiltDeg = 0; - double _rotationDeg = 0; - - }; - -}} +namespace maplibre { +namespace gltf { + +// The type of rendering environment we're in +typedef enum { + RenderingEnvironmentUnknown, + RenderingEnvironmentMetal, + RenderingEnvironmentOpenGL, + RenderingEnvironmentVulkan +} RenderingEnvironment; + +struct Coordinate2D { + double _lat; + double _lon; +}; + +struct Cartesian3D { + double _x; + double _y; + double _z; +}; + +typedef std::function ProjectionCallback; + +// The GLTF Manager class is the top level entry point +// for all things model based +class GLTFManager { +public: + // Set the callback + void setProjectionCallback(ProjectionCallback projectionCallback); + + // Instantiate the manager with the appropriate environment + GLTFManager(RenderingEnvironment renderingEnvironment); + + // Load a model + void addModel(std::shared_ptr model); + + // Remove a model + void removeModel(std::shared_ptr model); + + // Current meter to screen pixel scale + double _metersPerPixel = 1.0; + + // Set the drawable size + void setDrawableSize(int width, int height); + + // Set the tilt deg + void setTiltDeg(double tiltDeg); + + // Set the rotation deg + void setRotationDeg(double rotationDeg); + + // Set the rendering environment variables + void setRenderingEnvironmentVariables(std::shared_ptr environmentVars); + + // Update any animations + void updateScene(float timeSinceLastDraw); + + // Render + void render(); + +private: + RenderingEnvironment _renderingEnvironment = RenderingEnvironmentUnknown; + + // List of models + std::vector> _models; + + // Projection callback + ProjectionCallback _projectionCallback; + +private: + // Rendering environment + void createRenderingEnvironment(); + + // The renderer + std::shared_ptr _renderer = nullptr; + + int _drawableWidth = 1; + int _drawableHeight = 1; + double _tiltDeg = 0; + double _rotationDeg = 0; +}; + +} // namespace gltf +} // namespace maplibre #endif /* GLTFManager_hpp */ diff --git a/platform/darwin/src/gltf/GLTFManagerRenderingEnvironment.hpp b/platform/darwin/src/gltf/GLTFManagerRenderingEnvironment.hpp index 0be4b404648..1e37c11260c 100644 --- a/platform/darwin/src/gltf/GLTFManagerRenderingEnvironment.hpp +++ b/platform/darwin/src/gltf/GLTFManagerRenderingEnvironment.hpp @@ -11,31 +11,30 @@ #include #include -namespace maplibre { namespace gltf { +namespace maplibre { +namespace gltf { - // Bsae class does nothing really, just a place holder - class GLTFManagerRenderingEnvironment { - public: - // If the bloom should be used - bool _useBloomPass = false; +// Bsae class does nothing really, just a place holder +class GLTFManagerRenderingEnvironment { +public: + // If the bloom should be used + bool _useBloomPass = false; - // FOV - double _currentFOVDEG = 50; - - // Environment projection matrix - simd_double4x4 _currentProjectionMatrix; - - // Current zoom level - double _currentZoomLevel = 1; + // FOV + double _currentFOVDEG = 50; - // - simd_float3 _lightDirection; + // Environment projection matrix + simd_double4x4 _currentProjectionMatrix; - GLTFManagerRenderingEnvironment() { - _lightDirection = simd_make_float3(0.0, 10000.0, 10000.0); - } + // Current zoom level + double _currentZoomLevel = 1; - }; + // + simd_float3 _lightDirection; -}} + GLTFManagerRenderingEnvironment() { _lightDirection = simd_make_float3(0.0, 10000.0, 10000.0); } +}; + +} // namespace gltf +} // namespace maplibre #endif /* GLTFManagerRenderingEnvironment_hpp */ diff --git a/platform/darwin/src/gltf/GLTFManagerRenderingEnvironmentMetal.hpp b/platform/darwin/src/gltf/GLTFManagerRenderingEnvironmentMetal.hpp index ba73b24973e..b64b422bf6b 100644 --- a/platform/darwin/src/gltf/GLTFManagerRenderingEnvironmentMetal.hpp +++ b/platform/darwin/src/gltf/GLTFManagerRenderingEnvironmentMetal.hpp @@ -13,28 +13,29 @@ #include #include "GLTFManagerRenderingEnvironment.hpp" -namespace maplibre { namespace gltf { - - // Bsae class does nothing really, just a place holder - class GLTFManagerRenderingEnvironmentMetal: public GLTFManagerRenderingEnvironment { - public: - // Allows command buffer and render encoder to be passed in. - // if these are nil, then the renderer will create them - id _currentCommandEncoder = nullptr; - id _currentCommandBuffer = nullptr; - - id _currentDrawable = nullptr; - MTLRenderPassDescriptor *_currentRenderPassDescriptor = nullptr; - id _metalDevice = nullptr; - - // TBD: These are placeholders as we noodle how to integrate with ML - // Depth descriptor: If this is null, then use an internal depth - id _depthStencilTexture = nullptr; - - id _colorTexture = nullptr; - }; - -}} - +namespace maplibre { +namespace gltf { + +// Bsae class does nothing really, just a place holder +class GLTFManagerRenderingEnvironmentMetal : public GLTFManagerRenderingEnvironment { +public: + // Allows command buffer and render encoder to be passed in. + // if these are nil, then the renderer will create them + id _currentCommandEncoder = nullptr; + id _currentCommandBuffer = nullptr; + + id _currentDrawable = nullptr; + MTLRenderPassDescriptor *_currentRenderPassDescriptor = nullptr; + id _metalDevice = nullptr; + + // TBD: These are placeholders as we noodle how to integrate with ML + // Depth descriptor: If this is null, then use an internal depth + id _depthStencilTexture = nullptr; + + id _colorTexture = nullptr; +}; + +} // namespace gltf +} // namespace maplibre #endif /* GLTFManagerRenderingEnvironmentMetal_hpp */ diff --git a/platform/darwin/src/gltf/GLTFMath.cpp b/platform/darwin/src/gltf/GLTFMath.cpp index 97f5821e903..8a067505ef5 100644 --- a/platform/darwin/src/gltf/GLTFMath.cpp +++ b/platform/darwin/src/gltf/GLTFMath.cpp @@ -7,7 +7,6 @@ #include "GLTFMath.hpp" - simd_float4x4 GLTFMatrixFromScale(const simd_float3 s) { simd_float4x4 m = matrix_identity_float4x4; m.columns[0].x = s.x; @@ -24,7 +23,6 @@ simd_double4x4 GLTFMatrixFromScaleD(const simd_double3 s) { return m; } - simd_float4x4 GLTFMatrixFromUniformScale(float s) { simd_float4x4 m = matrix_identity_float4x4; m.columns[0].x = s; @@ -41,17 +39,15 @@ simd_double4x4 GLTFMatrixFromUniformScaleD(double s) { return m; } - simd_double4x4 GLTFMatrixFromTranslationD(simd_double3 t) { simd_double4x4 m = matrix_identity_double4x4; - m.columns[3] = (simd_double4) { t.x, t.y, t.z, 1.0 }; + m.columns[3] = (simd_double4){t.x, t.y, t.z, 1.0}; return m; } - simd_float4x4 GLTFMatrixFromTranslation(simd_float3 t) { simd_float4x4 m = matrix_identity_float4x4; - m.columns[3] = (simd_float4) { t.x, t.y, t.z, 1.0 }; + m.columns[3] = (simd_float4){t.x, t.y, t.z, 1.0}; return m; } @@ -60,10 +56,10 @@ GLTFBoundingSphere GLTFBoundingSphereFromBox(const GLTFBoundingBox b) { double midX = (b.maxPoint.x + b.minPoint.x) * 0.5; double midY = (b.maxPoint.y + b.minPoint.y) * 0.5; double midZ = (b.maxPoint.z + b.minPoint.z) * 0.5; - + double r = sqrt(pow(b.maxPoint.x - midX, 2) + pow(b.maxPoint.y - midY, 2) + pow(b.maxPoint.z - midZ, 2)); - - s.center = (simd_double3){ midX, midY, midZ }; + + s.center = (simd_double3){midX, midY, midZ}; s.radius = r; return s; } @@ -73,13 +69,13 @@ simd_float4x4 GLTFRotationMatrixFromAxisAngle(simd_float3 axis, float angle) { float c = cosf(angle); float s = sinf(angle); float t = 1 - c; - - simd_float4 c0 = { t * x * x + c, t * x * y + z * s, t * x * z - y * s, 0 }; - simd_float4 c1 = { t * x * y - z * s, t * y * y + c, t * y * z + x * s, 0 }; - simd_float4 c2 = { t * x * z + y * s, t * y * z - x * s, t * z * z + c, 0 }; - simd_float4 c3 = { 0, 0, 0, 1 }; - - return (simd_float4x4){ c0, c1, c2, c3 }; + + simd_float4 c0 = {t * x * x + c, t * x * y + z * s, t * x * z - y * s, 0}; + simd_float4 c1 = {t * x * y - z * s, t * y * y + c, t * y * z + x * s, 0}; + simd_float4 c2 = {t * x * z + y * s, t * y * z - x * s, t * z * z + c, 0}; + simd_float4 c3 = {0, 0, 0, 1}; + + return (simd_float4x4){c0, c1, c2, c3}; } simd_double4x4 GLTFRotationMatrixFromAxisAngleD(simd_double3 axis, double angle) { @@ -87,83 +83,68 @@ simd_double4x4 GLTFRotationMatrixFromAxisAngleD(simd_double3 axis, double angle) double c = cos(angle); double s = sin(angle); double t = 1 - c; - - simd_double4 c0 = { t * x * x + c, t * x * y + z * s, t * x * z - y * s, 0 }; - simd_double4 c1 = { t * x * y - z * s, t * y * y + c, t * y * z + x * s, 0 }; - simd_double4 c2 = { t * x * z + y * s, t * y * z - x * s, t * z * z + c, 0 }; - simd_double4 c3 = { 0, 0, 0, 1 }; - - return (simd_double4x4){ c0, c1, c2, c3 }; -} + simd_double4 c0 = {t * x * x + c, t * x * y + z * s, t * x * z - y * s, 0}; + simd_double4 c1 = {t * x * y - z * s, t * y * y + c, t * y * z + x * s, 0}; + simd_double4 c2 = {t * x * z + y * s, t * y * z - x * s, t * z * z + c, 0}; + simd_double4 c3 = {0, 0, 0, 1}; -simd_float3 GLTFAxisX = (simd_float3){ 1, 0, 0 }; -simd_float3 GLTFAxisY = (simd_float3){ 0, 1, 0 }; -simd_float3 GLTFAxisZ = (simd_float3){ 0, 0, 1 }; + return (simd_double4x4){c0, c1, c2, c3}; +} -simd_double3 GLTFAxisXD = (simd_double3){ 1, 0, 0 }; -simd_double3 GLTFAxisYD = (simd_double3){ 0, 1, 0 }; -simd_double3 GLTFAxisZD = (simd_double3){ 0, 0, 1 }; +simd_float3 GLTFAxisX = (simd_float3){1, 0, 0}; +simd_float3 GLTFAxisY = (simd_float3){0, 1, 0}; +simd_float3 GLTFAxisZ = (simd_float3){0, 0, 1}; -simd_double4x4 GLTFPerspectiveProjectionMatrixAspectFovRH(const double fovY, const double aspect, const double nearZ, const double farZ) -{ +simd_double3 GLTFAxisXD = (simd_double3){1, 0, 0}; +simd_double3 GLTFAxisYD = (simd_double3){0, 1, 0}; +simd_double3 GLTFAxisZD = (simd_double3){0, 0, 1}; + +simd_double4x4 GLTFPerspectiveProjectionMatrixAspectFovRH(const double fovY, + const double aspect, + const double nearZ, + const double farZ) { double yscale = 1 / tanf(fovY * 0.5f); // 1 / tan == cot double xscale = yscale / aspect; double q = -farZ / (farZ - nearZ); - - simd_double4x4 m = { - .columns[0] = { xscale, 0, 0, 0 }, - .columns[1] = { 0, yscale, 0, 0 }, - .columns[2] = { 0, 0, q, -1 }, - .columns[3] = { 0, 0, q * nearZ, 0 } - }; - + + simd_double4x4 m = {.columns[0] = {xscale, 0, 0, 0}, + .columns[1] = {0, yscale, 0, 0}, + .columns[2] = {0, 0, q, -1}, + .columns[3] = {0, 0, q * nearZ, 0}}; + return m; } - -simd_float4x4 GLTFOrthoProjectionMatrix(const float left, - const float right, - const float bottom, - const float top, - const float nearZ, - const float farZ) { - +simd_float4x4 GLTFOrthoProjectionMatrix( + const float left, const float right, const float bottom, const float top, const float nearZ, const float farZ) { simd_float4x4 m = { - .columns[0] = { 2 / (right - left), 0, 0, 0 }, - .columns[1] = { 0, 2 / (top - bottom), 0, 0 }, - .columns[2] = { 0, 0, 1 / (farZ - nearZ), 0 }, - .columns[3] = { (left + right) / (left - right), (top + bottom) / (bottom - top), nearZ / (nearZ - farZ), 1 } - }; - + .columns[0] = {2 / (right - left), 0, 0, 0}, + .columns[1] = {0, 2 / (top - bottom), 0, 0}, + .columns[2] = {0, 0, 1 / (farZ - nearZ), 0}, + .columns[3] = {(left + right) / (left - right), (top + bottom) / (bottom - top), nearZ / (nearZ - farZ), 1}}; + return m; - } - simd_float3x3 GLTFMatrixUpperLeft3x3(simd_float4x4 m) { - simd_float3x3 mout = { { - { m.columns[0][0], m.columns[0][1], m.columns[0][2] }, - { m.columns[1][0], m.columns[1][1], m.columns[1][2] }, - { m.columns[2][0], m.columns[2][1], m.columns[2][2] } - } }; + simd_float3x3 mout = {{{m.columns[0][0], m.columns[0][1], m.columns[0][2]}, + {m.columns[1][0], m.columns[1][1], m.columns[1][2]}, + {m.columns[2][0], m.columns[2][1], m.columns[2][2]}}}; return mout; } simd_double3x3 GLTFMatrixUpperLeft3x3D(simd_double4x4 m) { - simd_double3x3 mout = { { - { m.columns[0][0], m.columns[0][1], m.columns[0][2] }, - { m.columns[1][0], m.columns[1][1], m.columns[1][2] }, - { m.columns[2][0], m.columns[2][1], m.columns[2][2] } - } }; + simd_double3x3 mout = {{{m.columns[0][0], m.columns[0][1], m.columns[0][2]}, + {m.columns[1][0], m.columns[1][1], m.columns[1][2]}, + {m.columns[2][0], m.columns[2][1], m.columns[2][2]}}}; return mout; } - GLTFTextureTransform GLTFTextureTransformMakeIdentity(void) { GLTFTextureTransform t = { - .offset = (simd_float2){ 0, 0 }, - .scale = (simd_float2){ 1, 1 }, + .offset = (simd_float2){0, 0}, + .scale = (simd_float2){1, 1}, .rotation = 0, }; return t; @@ -185,31 +166,27 @@ simd_float3x3 GLTFTextureMatrixFromTransform(GLTFTextureTransform transform) { float ty = transform.offset.y; float sx = transform.scale.x; float sy = transform.scale.y; - simd_float3 c0 = (simd_float3){ rc * sx, rs * sy, 0 }; - simd_float3 c1 = (simd_float3){ -rs * sx, rc * sy, 0 }; - simd_float3 c2 = (simd_float3){ tx, ty, 1 }; - simd_float3x3 m = (simd_float3x3){ c0, c1, c2 }; + simd_float3 c0 = (simd_float3){rc * sx, rs * sy, 0}; + simd_float3 c1 = (simd_float3){-rs * sx, rc * sy, 0}; + simd_float3 c2 = (simd_float3){tx, ty, 1}; + simd_float3x3 m = (simd_float3x3){c0, c1, c2}; return m; } simd_float4x4 GLTFNormalMatrixFromModelMatrix(simd_float4x4 m) { simd_float3x3 nm = simd_inverse(simd_transpose(GLTFMatrixUpperLeft3x3(m))); - simd_float4x4 mout = { { - { nm.columns[0][0], nm.columns[0][1], nm.columns[0][2], 0 }, - { nm.columns[1][0], nm.columns[1][1], nm.columns[1][2], 0 }, - { nm.columns[2][0], nm.columns[2][1], nm.columns[2][2], 0 }, - { 0, 0, 0, 1 } - } }; + simd_float4x4 mout = {{{nm.columns[0][0], nm.columns[0][1], nm.columns[0][2], 0}, + {nm.columns[1][0], nm.columns[1][1], nm.columns[1][2], 0}, + {nm.columns[2][0], nm.columns[2][1], nm.columns[2][2], 0}, + {0, 0, 0, 1}}}; return mout; } simd_double4x4 GLTFNormalMatrixFromModelMatrixD(simd_double4x4 m) { simd_double3x3 nm = simd_inverse(simd_transpose(GLTFMatrixUpperLeft3x3D(m))); - simd_double4x4 mout = { { - { nm.columns[0][0], nm.columns[0][1], nm.columns[0][2], 0 }, - { nm.columns[1][0], nm.columns[1][1], nm.columns[1][2], 0 }, - { nm.columns[2][0], nm.columns[2][1], nm.columns[2][2], 0 }, - { 0, 0, 0, 1 } - } }; + simd_double4x4 mout = {{{nm.columns[0][0], nm.columns[0][1], nm.columns[0][2], 0}, + {nm.columns[1][0], nm.columns[1][1], nm.columns[1][2], 0}, + {nm.columns[2][0], nm.columns[2][1], nm.columns[2][2], 0}, + {0, 0, 0, 1}}}; return mout; } diff --git a/platform/darwin/src/gltf/GLTFMath.hpp b/platform/darwin/src/gltf/GLTFMath.hpp index eae5a828c56..6e8ce7a4f39 100644 --- a/platform/darwin/src/gltf/GLTFMath.hpp +++ b/platform/darwin/src/gltf/GLTFMath.hpp @@ -22,8 +22,8 @@ typedef enum { GLTFTextureBindIndexBRDFLookup, } GLTFMTLTextureBindIndex; -#define DEG_RAD (M_PI/180.0) -#define RAD_DEG (180.0/M_PI) +#define DEG_RAD (M_PI / 180.0) +#define RAD_DEG (180.0 / M_PI) // 0.0174533 // 57.2958 @@ -31,7 +31,6 @@ typedef enum { #define GLTFMTLMaximumLightCount 3 #define GLTFMTLMaximumTextureCount (GLTFTextureBindIndexEmissive + 1) - typedef struct { simd_float3 minPoint; simd_float3 maxPoint; @@ -42,7 +41,6 @@ typedef struct { float radius; } GLTFBoundingSphere; - typedef struct { simd_float4x4 modelMatrix; simd_float4x4 modelViewProjectionMatrix; @@ -112,14 +110,13 @@ simd_float4x4 GLTFRotationMatrixFromAxisAngle(simd_float3 axis, float angle); simd_double4x4 GLTFRotationMatrixFromAxisAngleD(simd_double3 axis, double angle); -simd_double4x4 GLTFPerspectiveProjectionMatrixAspectFovRH(const double fovY, const double aspect, const double nearZ, const double farZ); +simd_double4x4 GLTFPerspectiveProjectionMatrixAspectFovRH(const double fovY, + const double aspect, + const double nearZ, + const double farZ); -simd_float4x4 GLTFOrthoProjectionMatrix(const float left, - const float right, - const float bottom, - const float top, - const float nearZ, - const float farZ); +simd_float4x4 GLTFOrthoProjectionMatrix( + const float left, const float right, const float bottom, const float top, const float nearZ, const float farZ); simd_float3x3 GLTFMatrixUpperLeft3x3(simd_float4x4 m); @@ -135,7 +132,6 @@ simd_float4x4 GLTFNormalMatrixFromModelMatrix(simd_float4x4 m); simd_double4x4 GLTFNormalMatrixFromModelMatrixD(simd_double4x4 m); - #ifdef __cplusplus } #endif diff --git a/platform/darwin/src/gltf/GLTFModel.hpp b/platform/darwin/src/gltf/GLTFModel.hpp index a09e05b56e5..174b7dd91ee 100644 --- a/platform/darwin/src/gltf/GLTFModel.hpp +++ b/platform/darwin/src/gltf/GLTFModel.hpp @@ -11,36 +11,36 @@ #include #include -namespace maplibre { namespace gltf { - - // Model - class GLTFModel { - public: - // - double _referenceLat = 0; - double _referenceLon = 0; - - // What it takes to scale this model to meters units - float _scaleFactor = 1; - - // Rotation around the reference point - float _rotationDeg = 0; - - // The URL for the model, used by the loader - std::string _modelURL; - - // The brightness - float _brightness = 1.0; - - // This is a hack to deal with passing in the translation vector. - // NEed to reconcile this with the renderable model's version of it - double _xLateX = 0; - double _xLateY = 0; - double _xLateZ = 0; - - }; - - -}} +namespace maplibre { +namespace gltf { + +// Model +class GLTFModel { +public: + // + double _referenceLat = 0; + double _referenceLon = 0; + + // What it takes to scale this model to meters units + float _scaleFactor = 1; + + // Rotation around the reference point + float _rotationDeg = 0; + + // The URL for the model, used by the loader + std::string _modelURL; + + // The brightness + float _brightness = 1.0; + + // This is a hack to deal with passing in the translation vector. + // NEed to reconcile this with the renderable model's version of it + double _xLateX = 0; + double _xLateY = 0; + double _xLateZ = 0; +}; + +} // namespace gltf +} // namespace maplibre #endif /* GLTFModel_hpp */ diff --git a/platform/darwin/src/gltf/GLTFModelLayer.h b/platform/darwin/src/gltf/GLTFModelLayer.h index d9715474eb8..640f3735565 100644 --- a/platform/darwin/src/gltf/GLTFModelLayer.h +++ b/platform/darwin/src/gltf/GLTFModelLayer.h @@ -13,16 +13,16 @@ NS_ASSUME_NONNULL_BEGIN // This sets the relative light position for all the models being rendered // The light position is in meters from the origin of the model. --(void)setLightPositionX:(float)x y:(float)y z:(float)z; +- (void)setLightPositionX:(float)x y:(float)y z:(float)z; --(void)loadModelFromJSON:(NSString *)modelMetadataFilename; +- (void)loadModelFromJSON:(NSString *)modelMetadataFilename; --(void)loadModel:(NSString *)appResourceFilename - lat:(double)lat - lon:(double)lon - rotationDeg:(double)rotationDeg - scaleFactor:(float)scaleFactor - brightness:(float)brightness; +- (void)loadModel:(NSString *)appResourceFilename + lat:(double)lat + lon:(double)lon + rotationDeg:(double)rotationDeg + scaleFactor:(float)scaleFactor + brightness:(float)brightness; @end diff --git a/platform/darwin/src/gltf/GLTFModelLoader.h b/platform/darwin/src/gltf/GLTFModelLoader.h index 6cf1b928b98..d1e3ab9d787 100644 --- a/platform/darwin/src/gltf/GLTFModelLoader.h +++ b/platform/darwin/src/gltf/GLTFModelLoader.h @@ -14,10 +14,9 @@ typedef void (^GLTFModelLoaderCompletionHandler)(GLTFAsset *asset); @interface GLTFModelLoader : NSObject --(void)loadURL:(NSURL *)assetURL -withCompletionHandler:(GLTFModelLoaderCompletionHandler)completionHandler -bufferAllocator:(id)bufferAllocator; - +- (void)loadURL:(NSURL *)assetURL + withCompletionHandler:(GLTFModelLoaderCompletionHandler)completionHandler + bufferAllocator:(id)bufferAllocator; @end diff --git a/platform/darwin/src/gltf/GLTFRenderer.cpp b/platform/darwin/src/gltf/GLTFRenderer.cpp index 86fc66be865..c308e566f32 100644 --- a/platform/darwin/src/gltf/GLTFRenderer.cpp +++ b/platform/darwin/src/gltf/GLTFRenderer.cpp @@ -18,14 +18,13 @@ GLTFRenderer::~GLTFRenderer() { // Base class does nothing } - // Update any animations void GLTFRenderer::update(float timeSinceLastDraw) { // Base class does nothing } // Render - void GLTFRenderer::render() { +void GLTFRenderer::render() { // Base class does nothing } @@ -35,18 +34,11 @@ void GLTFRenderer::setDrawableSize(int width, int height) { } // Protected items -void GLTFRenderer::loadBloomPipelines() { - -} - -void GLTFRenderer::loadTonemapPipeline() { - -} +void GLTFRenderer::loadBloomPipelines() {} -void GLTFRenderer::updateFramebufferSize() { - -} +void GLTFRenderer::loadTonemapPipeline() {} +void GLTFRenderer::updateFramebufferSize() {} // Load a model void GLTFRenderer::loadGLTFModel(std::shared_ptr model) { @@ -68,14 +60,11 @@ void GLTFRenderer::setRotationDeg(double rotationDeg) { _rotationDeg = rotationDeg; } - - // Use bloom pass void GLTFRenderer::setUseBloomPass(bool useBloomPass) { _useBloomPass = useBloomPass; } - // Set the rendering environemnt variables void GLTFRenderer::setRenderingEnvironemnt(std::shared_ptr renderingEnvironment) { _renderingEnvironment = renderingEnvironment; diff --git a/platform/darwin/src/gltf/GLTFRenderer.hpp b/platform/darwin/src/gltf/GLTFRenderer.hpp index 22d52ad0722..dba305678e6 100644 --- a/platform/darwin/src/gltf/GLTFRenderer.hpp +++ b/platform/darwin/src/gltf/GLTFRenderer.hpp @@ -14,56 +14,57 @@ #include "GLTFManagerRenderingEnvironment.hpp" #include -namespace maplibre { namespace gltf { - - class GLTFRenderer { - public: - // Constructor - GLTFRenderer(); - - // Destructor - virtual ~GLTFRenderer(); - - // Update any animations - virtual void update(float timeSinceLastDraw); - - // Render - virtual void render(); - - // Set the drawable size - virtual void setDrawableSize(int width, int height); - - // Load a model - virtual void loadGLTFModel(std::shared_ptr model); - - // Set the meters per pixel scale - void setMetersPerPixel(double metersPerPixel); - - // Set tilt - void setTiltDeg(double tiltDeg); - - // Set the rotation deg - void setRotationDeg(double rotationDeg); - - // Use bloom pass - void setUseBloomPass(bool useBloomPass); - - // Set the rendering environemnt variables - virtual void setRenderingEnvironemnt(std::shared_ptr renderingEnvironment); - - protected: - std::unique_ptr _camera = nullptr; - double _metersPerPixel = 1; - std::shared_ptr _renderingEnvironment = nullptr; - double _tiltDeg = 0; - double _rotationDeg = 0; - bool _useBloomPass = true; - virtual void loadBloomPipelines(); - virtual void loadTonemapPipeline(); - virtual void updateFramebufferSize(); - - }; - -}} +namespace maplibre { +namespace gltf { + +class GLTFRenderer { +public: + // Constructor + GLTFRenderer(); + + // Destructor + virtual ~GLTFRenderer(); + + // Update any animations + virtual void update(float timeSinceLastDraw); + + // Render + virtual void render(); + + // Set the drawable size + virtual void setDrawableSize(int width, int height); + + // Load a model + virtual void loadGLTFModel(std::shared_ptr model); + + // Set the meters per pixel scale + void setMetersPerPixel(double metersPerPixel); + + // Set tilt + void setTiltDeg(double tiltDeg); + + // Set the rotation deg + void setRotationDeg(double rotationDeg); + + // Use bloom pass + void setUseBloomPass(bool useBloomPass); + + // Set the rendering environemnt variables + virtual void setRenderingEnvironemnt(std::shared_ptr renderingEnvironment); + +protected: + std::unique_ptr _camera = nullptr; + double _metersPerPixel = 1; + std::shared_ptr _renderingEnvironment = nullptr; + double _tiltDeg = 0; + double _rotationDeg = 0; + bool _useBloomPass = true; + virtual void loadBloomPipelines(); + virtual void loadTonemapPipeline(); + virtual void updateFramebufferSize(); +}; + +} // namespace gltf +} // namespace maplibre #endif /* GLTFRenderer_hpp */ diff --git a/platform/darwin/src/gltf/gltfkit/GLTFAccessor.h b/platform/darwin/src/gltf/gltfkit/GLTFAccessor.h index 4414b8ab58f..e5bdf0d2f77 100644 --- a/platform/darwin/src/gltf/gltfkit/GLTFAccessor.h +++ b/platform/darwin/src/gltf/gltfkit/GLTFAccessor.h @@ -14,8 +14,8 @@ // OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. // -#import "GLTFObject.h" #import "GLTFEnums.h" +#import "GLTFObject.h" #import @@ -24,8 +24,8 @@ NS_ASSUME_NONNULL_BEGIN @class GLTFBufferView; typedef struct { - float minValue[16]; - float maxValue[16]; + float minValue[16]; + float maxValue[16]; } GLTFValueRange; @interface GLTFAccessor : GLTFObject diff --git a/platform/darwin/src/gltf/gltfkit/GLTFAnimation.h b/platform/darwin/src/gltf/gltfkit/GLTFAnimation.h index b70ab091a02..e00693e578f 100644 --- a/platform/darwin/src/gltf/gltfkit/GLTFAnimation.h +++ b/platform/darwin/src/gltf/gltfkit/GLTFAnimation.h @@ -14,8 +14,8 @@ // OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. // -#import "GLTFObject.h" #import "GLTFEnums.h" +#import "GLTFObject.h" NS_ASSUME_NONNULL_BEGIN diff --git a/platform/darwin/src/gltf/gltfkit/GLTFAsset.h b/platform/darwin/src/gltf/gltfkit/GLTFAsset.h index 2f883a685bd..bbd795d35a7 100644 --- a/platform/darwin/src/gltf/gltfkit/GLTFAsset.h +++ b/platform/darwin/src/gltf/gltfkit/GLTFAsset.h @@ -16,8 +16,8 @@ #import -#import "GLTFObject.h" #import "GLTFEnums.h" +#import "GLTFObject.h" NS_ASSUME_NONNULL_BEGIN @@ -27,7 +27,9 @@ NS_ASSUME_NONNULL_BEGIN @protocol GLTFBufferAllocator; @protocol GLTFAssetLoadingDelegate -- (void)assetWithURL:(NSURL *)assetURL requiresContentsOfURL:(NSURL *)url completionHandler:(void (^)(NSData *_Nullable, NSError *_Nullable))completionHandler; +- (void)assetWithURL:(NSURL *)assetURL + requiresContentsOfURL:(NSURL *)url + completionHandler:(void (^)(NSData *_Nullable, NSError *_Nullable))completionHandler; - (void)assetWithURL:(NSURL *)assetURL didFinishLoading:(GLTFAsset *)asset; - (void)assetWithURL:(NSURL *)assetURL didFailToLoadWithError:(NSError *)error; @end @@ -35,7 +37,7 @@ NS_ASSUME_NONNULL_BEGIN @interface GLTFAsset : NSObject @property (nonatomic, readonly, strong) NSArray *scenes; -@property (nonatomic, readonly) GLTFScene * _Nullable defaultScene; +@property (nonatomic, readonly) GLTFScene *_Nullable defaultScene; @property (nonatomic, readonly, strong) NSArray *animations; @@ -43,16 +45,18 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic, readonly, strong) NSArray *cameras; -@property (nonatomic, copy) NSString * _Nullable generator; -@property (nonatomic, copy) NSString * _Nullable copyright; -@property (nonatomic, copy) NSString * _Nullable formatVersion; +@property (nonatomic, copy) NSString *_Nullable generator; +@property (nonatomic, copy) NSString *_Nullable copyright; +@property (nonatomic, copy) NSString *_Nullable formatVersion; @property (nonatomic, copy) NSArray *extensionsUsed; -/// Load an asset asynchronously. The asset may either be a local asset or a remote asset; the provided -/// delegate will receive callbacks requesting the contents of remote URLs referenced by the asset. These -/// callbacks will occur on an arbitrary internal queue. -+ (void)loadAssetWithURL:(NSURL *)url bufferAllocator:(id)bufferAllocator delegate:(id)delegate; +/// Load an asset asynchronously. The asset may either be a local asset or a remote asset; the +/// provided delegate will receive callbacks requesting the contents of remote URLs referenced by +/// the asset. These callbacks will occur on an arbitrary internal queue. ++ (void)loadAssetWithURL:(NSURL *)url + bufferAllocator:(id)bufferAllocator + delegate:(id)delegate; /// Load a local asset. The provided URL must be a file URL, or else loading will fail. - (instancetype)initWithURL:(NSURL *)url bufferAllocator:(id)bufferAllocator; diff --git a/platform/darwin/src/gltf/gltfkit/GLTFBinaryChunk.h b/platform/darwin/src/gltf/gltfkit/GLTFBinaryChunk.h index 593b8329f29..cb4fd22591c 100644 --- a/platform/darwin/src/gltf/gltfkit/GLTFBinaryChunk.h +++ b/platform/darwin/src/gltf/gltfkit/GLTFBinaryChunk.h @@ -19,14 +19,14 @@ extern const UInt32 GLTFBinaryMagic; typedef NS_ENUM(NSInteger, GLTFChunkType) { - GLTFChunkTypeJSON = 0x4E4F534A, - GLTFChunkTypeBinary = 0x004E4942 + GLTFChunkTypeJSON = 0x4E4F534A, + GLTFChunkTypeBinary = 0x004E4942 }; typedef struct { - UInt32 magic; - UInt32 version; - UInt32 length; + UInt32 magic; + UInt32 version; + UInt32 length; } GLTFBinaryHeader; @interface GLTFBinaryChunk : NSObject diff --git a/platform/darwin/src/gltf/gltfkit/GLTFBuffer.h b/platform/darwin/src/gltf/gltfkit/GLTFBuffer.h index 0be3d201b02..a91cd8fda24 100644 --- a/platform/darwin/src/gltf/gltfkit/GLTFBuffer.h +++ b/platform/darwin/src/gltf/gltfkit/GLTFBuffer.h @@ -22,7 +22,8 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic, readonly) NSInteger length; -/// The actual data associated with this buffer. If uri is a data URI, this is populated when loading; else it is nil +/// The actual data associated with this buffer. If uri is a data URI, this is populated when +/// loading; else it is nil @property (nonatomic, readonly) void *contents; @end diff --git a/platform/darwin/src/gltf/gltfkit/GLTFBufferView.h b/platform/darwin/src/gltf/gltfkit/GLTFBufferView.h index 2b41ec2f46c..3f83f265f35 100644 --- a/platform/darwin/src/gltf/gltfkit/GLTFBufferView.h +++ b/platform/darwin/src/gltf/gltfkit/GLTFBufferView.h @@ -14,8 +14,8 @@ // OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. // -#import "GLTFObject.h" #import "GLTFEnums.h" +#import "GLTFObject.h" NS_ASSUME_NONNULL_BEGIN diff --git a/platform/darwin/src/gltf/gltfkit/GLTFCamera.h b/platform/darwin/src/gltf/gltfkit/GLTFCamera.h index 2d710a7ffcb..67d729b85c9 100644 --- a/platform/darwin/src/gltf/gltfkit/GLTFCamera.h +++ b/platform/darwin/src/gltf/gltfkit/GLTFCamera.h @@ -14,8 +14,8 @@ // OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. // -#import "GLTFObject.h" #import "GLTFEnums.h" +#import "GLTFObject.h" #import @@ -26,10 +26,10 @@ NS_ASSUME_NONNULL_BEGIN @interface GLTFCamera : GLTFObject @property (nonatomic, assign) GLTFCameraType cameraType; -@property (nonatomic, assign) float aspectRatio; // Only applicable when type is perspective -@property (nonatomic, assign) float yfov; // Only applicable when type is perspective -@property (nonatomic, assign) float xmag; // Only applicable when type is orthographic -@property (nonatomic, assign) float ymag; // Only applicable when type is orthographic +@property (nonatomic, assign) float aspectRatio; // Only applicable when type is perspective +@property (nonatomic, assign) float yfov; // Only applicable when type is perspective +@property (nonatomic, assign) float xmag; // Only applicable when type is orthographic +@property (nonatomic, assign) float ymag; // Only applicable when type is orthographic @property (nonatomic, assign) float znear; @property (nonatomic, assign) float zfar; diff --git a/platform/darwin/src/gltf/gltfkit/GLTFEnums.h b/platform/darwin/src/gltf/gltfkit/GLTFEnums.h index dbf5177be5f..76bffbc8779 100644 --- a/platform/darwin/src/gltf/gltfkit/GLTFEnums.h +++ b/platform/darwin/src/gltf/gltfkit/GLTFEnums.h @@ -17,162 +17,162 @@ #import typedef NS_ENUM(NSInteger, GLTFDataType) { - GLTFBaseTypeUnknown, - GLTFDataTypeChar = 0x1400, - GLTFDataTypeUChar = 0x1401, - GLTFDataTypeShort = 0x1402, - GLTFDataTypeUShort = 0x1403, - GLTFDataTypeInt = 0x1404, - GLTFDataTypeUInt = 0x1405, - GLTFDataTypeFloat = 0x1406, - - GLTFDataTypeFloat2 = 0x8B50, - GLTFDataTypeFloat3 = 0x8B51, - GLTFDataTypeFloat4 = 0x8B52, - GLTFDataTypeInt2 = 0x8B53, - GLTFDataTypeInt3 = 0x8B54, - GLTFDataTypeInt4 = 0x8B55, - GLTFDataTypeBool = 0x8B56, - GLTFDataTypeBool2 = 0x8B57, - GLTFDataTypeBool3 = 0x8B58, - GLTFDataTypeBool4 = 0x8B59, - GLTFDataTypeFloat2x2 = 0x8B5A, - GLTFDataTypeFloat3x3 = 0x8B5B, - GLTFDataTypeFloat4x4 = 0x8B5C, - GLTFDataTypeSampler2D = 0x8B5E, + GLTFBaseTypeUnknown, + GLTFDataTypeChar = 0x1400, + GLTFDataTypeUChar = 0x1401, + GLTFDataTypeShort = 0x1402, + GLTFDataTypeUShort = 0x1403, + GLTFDataTypeInt = 0x1404, + GLTFDataTypeUInt = 0x1405, + GLTFDataTypeFloat = 0x1406, + + GLTFDataTypeFloat2 = 0x8B50, + GLTFDataTypeFloat3 = 0x8B51, + GLTFDataTypeFloat4 = 0x8B52, + GLTFDataTypeInt2 = 0x8B53, + GLTFDataTypeInt3 = 0x8B54, + GLTFDataTypeInt4 = 0x8B55, + GLTFDataTypeBool = 0x8B56, + GLTFDataTypeBool2 = 0x8B57, + GLTFDataTypeBool3 = 0x8B58, + GLTFDataTypeBool4 = 0x8B59, + GLTFDataTypeFloat2x2 = 0x8B5A, + GLTFDataTypeFloat3x3 = 0x8B5B, + GLTFDataTypeFloat4x4 = 0x8B5C, + GLTFDataTypeSampler2D = 0x8B5E, }; typedef NS_ENUM(NSInteger, GLTFDataDimension) { - GLTFDataDimensionUnknown, - GLTFDataDimensionScalar, - GLTFDataDimensionVector2, - GLTFDataDimensionVector3, - GLTFDataDimensionVector4, - GLTFDataDimensionMatrix2x2, - GLTFDataDimensionMatrix3x3, - GLTFDataDimensionMatrix4x4, + GLTFDataDimensionUnknown, + GLTFDataDimensionScalar, + GLTFDataDimensionVector2, + GLTFDataDimensionVector3, + GLTFDataDimensionVector4, + GLTFDataDimensionMatrix2x2, + GLTFDataDimensionMatrix3x3, + GLTFDataDimensionMatrix4x4, }; typedef NS_ENUM(NSInteger, GLTFTarget) { - GLTFTargetUnknown, - GLTFTargetArrayBuffer = 0x8892, - GLTFTargetElementArrayBuffer = 0x8893, + GLTFTargetUnknown, + GLTFTargetArrayBuffer = 0x8892, + GLTFTargetElementArrayBuffer = 0x8893, }; typedef NS_ENUM(NSInteger, GLTFPrimitiveType) { - GLTFPrimitiveTypePoints, - GLTFPrimitiveTypeLines, - GLTFPrimitiveTypeLineLoop, - GLTFPrimitiveTypeLineStrip, - GLTFPrimitiveTypeTriangles, - GLTFPrimitiveTypeTriangleStrip, - GLTFPrimitiveTypeTriangleFan, + GLTFPrimitiveTypePoints, + GLTFPrimitiveTypeLines, + GLTFPrimitiveTypeLineLoop, + GLTFPrimitiveTypeLineStrip, + GLTFPrimitiveTypeTriangles, + GLTFPrimitiveTypeTriangleStrip, + GLTFPrimitiveTypeTriangleFan, }; typedef NS_ENUM(NSInteger, GLTFCameraType) { - GLTFCameraTypePerspective, - GLTFCameraTypeOrthographic, + GLTFCameraTypePerspective, + GLTFCameraTypeOrthographic, }; typedef NS_ENUM(NSInteger, GLTFTextureTarget) { - GLTFTextureTargetTexture2D = 0x0DE1, + GLTFTextureTargetTexture2D = 0x0DE1, }; typedef NS_ENUM(NSInteger, GLTFTextureFormat) { - GLTFTextureFormatUnknown, - GLTFTextureFormatAlpha = 0x1906, - GLTFTextureFormatRGB = 0x1907, - GLTFTextureFormatRGBA = 0x1908, - GLTFTextureFormatLuminance = 0x1909, - GLTFTextureFormatLuminanceAlpha = 0x190A, + GLTFTextureFormatUnknown, + GLTFTextureFormatAlpha = 0x1906, + GLTFTextureFormatRGB = 0x1907, + GLTFTextureFormatRGBA = 0x1908, + GLTFTextureFormatLuminance = 0x1909, + GLTFTextureFormatLuminanceAlpha = 0x190A, }; typedef NS_ENUM(NSInteger, GLTFTextureType) { - GLTFTextureTypeUnknown, - GLTFTextureTypeUChar = 0x1401, - GLTFTextureTypeUShort565 = 0x8363, - GLTFTextureTypeUShort4444 = 0x8033, - GLTFTextureTypeUShort5551 = 0x8034, + GLTFTextureTypeUnknown, + GLTFTextureTypeUChar = 0x1401, + GLTFTextureTypeUShort565 = 0x8363, + GLTFTextureTypeUShort4444 = 0x8033, + GLTFTextureTypeUShort5551 = 0x8034, }; typedef NS_ENUM(NSInteger, GLTFShaderType) { - GLTFShaderTypeVertex = 0x8B31, - GLTFShaderTypeFragment = 0x8B30, + GLTFShaderTypeVertex = 0x8B31, + GLTFShaderTypeFragment = 0x8B30, }; typedef NS_ENUM(NSInteger, GLTFSamplingFilter) { - GLTFSamplingFilterUnknown, - GLTFSamplingFilterNearest = 0x2600, - GLTFSamplingFilterLinear = 0x2601, - GLTFSamplingFilterNearestMipNearest = 0x2700, - GLTFSamplingFilterLinearMipNearest = 0x2701, - GLTFSamplingFilterNearestMipLinear = 0x2702, - GLTFSamplingLinearMipLinear = 0x2703, + GLTFSamplingFilterUnknown, + GLTFSamplingFilterNearest = 0x2600, + GLTFSamplingFilterLinear = 0x2601, + GLTFSamplingFilterNearestMipNearest = 0x2700, + GLTFSamplingFilterLinearMipNearest = 0x2701, + GLTFSamplingFilterNearestMipLinear = 0x2702, + GLTFSamplingLinearMipLinear = 0x2703, }; typedef NS_ENUM(NSInteger, GLTFAddressMode) { - GLTFAddressModeUnknown, - GLTFAddressModeClampToEdge = 0x812F, - GLTFAddressModeMirroredRepeat = 0x8370, - GLTFAddressModeRepeat = 0x2901, + GLTFAddressModeUnknown, + GLTFAddressModeClampToEdge = 0x812F, + GLTFAddressModeMirroredRepeat = 0x8370, + GLTFAddressModeRepeat = 0x2901, }; typedef NS_ENUM(NSInteger, GLTFComparisonFunc) { - GLTFComparisonFuncLess = 0x0201, - GLTFComparisonFuncEqual = 0x0202, - GLTFComparisonFuncLessEqual = 0x0203, - GLTFComparisonFuncGreater = 0x0204, - GLTFComparisonFuncNotEqual = 0x0205, - GLTFComparisonFuncGreaterEqual = 0x0206, - GLTFComparisonFuncAlways = 0x0207, + GLTFComparisonFuncLess = 0x0201, + GLTFComparisonFuncEqual = 0x0202, + GLTFComparisonFuncLessEqual = 0x0203, + GLTFComparisonFuncGreater = 0x0204, + GLTFComparisonFuncNotEqual = 0x0205, + GLTFComparisonFuncGreaterEqual = 0x0206, + GLTFComparisonFuncAlways = 0x0207, }; typedef NS_ENUM(NSInteger, GLTFFace) { - GLTFFaceFront = 0x0404, - GLTFFaceBack = 0x405, - GLTFFaceFrontAndBack = 0x408, + GLTFFaceFront = 0x0404, + GLTFFaceBack = 0x405, + GLTFFaceFrontAndBack = 0x408, }; typedef NS_ENUM(NSInteger, GLTFWinding) { - GLTFWindingClockwise = 0x900, - GLTFWindingCounterclockwise = 0x0901, + GLTFWindingClockwise = 0x900, + GLTFWindingCounterclockwise = 0x0901, }; typedef NS_ENUM(NSInteger, GLTFState) { - GLTFStateBlendingEnabled = 0x0BE2, - GLTFStateCullFaceEnabled = 0x0B44, - GLTFStateDepthTestEnabled = 0x0B71, - GLTFStatePolygonOffsetFillEnabled = 0x8037, - GLTFStateAlphaToCoverageEnabled = 0x809E, - GLTFStateScissorTestEnabled = 0x0C11, + GLTFStateBlendingEnabled = 0x0BE2, + GLTFStateCullFaceEnabled = 0x0B44, + GLTFStateDepthTestEnabled = 0x0B71, + GLTFStatePolygonOffsetFillEnabled = 0x8037, + GLTFStateAlphaToCoverageEnabled = 0x809E, + GLTFStateScissorTestEnabled = 0x0C11, }; typedef NS_ENUM(NSInteger, GLTFBlendFunction) { - GLTFBlendFunctionAdd = 0x8006, - GLTFBlendFunctionSubtract = 0x800A, - GLTFBlendFunctionReverseSubtract = 0x800B, + GLTFBlendFunctionAdd = 0x8006, + GLTFBlendFunctionSubtract = 0x800A, + GLTFBlendFunctionReverseSubtract = 0x800B, }; typedef NS_ENUM(NSInteger, GLTFBlendEquation) { - GLTFBlendEquationZero = 0x0000, - GLTFBlendEquationOne = 0x0001, - GLTFBlendEquationSrcColor = 0x0300, - GLTFBlendEquationOneMinusSrcColor = 0x0301, - GLTFBlendEquationSrcAlpha = 0x0302, - GLTFBlendEquationOneMinusSrcAlpha = 0x0303, - GLTFBlendEquationDestAlpha = 0x0304, - GLTFBlendEquationOneMinusDestAlpha = 0x0305, - GLTFBlendEquationDestColor = 0x0306, - GLTFBlendEquationOneMinusDestColor = 0x0307, - GLTFBlendEquationSrcAlphaSaturate = 0x0308, - GLTFBlendEquationConstantColor = 0x8001, - GLTFBlendEquationOneMinusConstColor = 0x8002, - GLTFBlendEquationConstantAlpha = 0x8003, - GLTFBlendEquationOneMinusConstAlpha = 0x8004, + GLTFBlendEquationZero = 0x0000, + GLTFBlendEquationOne = 0x0001, + GLTFBlendEquationSrcColor = 0x0300, + GLTFBlendEquationOneMinusSrcColor = 0x0301, + GLTFBlendEquationSrcAlpha = 0x0302, + GLTFBlendEquationOneMinusSrcAlpha = 0x0303, + GLTFBlendEquationDestAlpha = 0x0304, + GLTFBlendEquationOneMinusDestAlpha = 0x0305, + GLTFBlendEquationDestColor = 0x0306, + GLTFBlendEquationOneMinusDestColor = 0x0307, + GLTFBlendEquationSrcAlphaSaturate = 0x0308, + GLTFBlendEquationConstantColor = 0x8001, + GLTFBlendEquationOneMinusConstColor = 0x8002, + GLTFBlendEquationConstantAlpha = 0x8003, + GLTFBlendEquationOneMinusConstAlpha = 0x8004, }; typedef NS_ENUM(NSInteger, GLTFInterpolationMode) { - GLTFInterpolationModeStep, - GLTFInterpolationModeLinear, - GLTFInterpolationModeCubic, + GLTFInterpolationModeStep, + GLTFInterpolationModeLinear, + GLTFInterpolationModeCubic, }; diff --git a/platform/darwin/src/gltf/gltfkit/GLTFImage.h b/platform/darwin/src/gltf/gltfkit/GLTFImage.h index ce444daff38..fe621ff196b 100644 --- a/platform/darwin/src/gltf/gltfkit/GLTFImage.h +++ b/platform/darwin/src/gltf/gltfkit/GLTFImage.h @@ -14,8 +14,8 @@ // OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. // -#import "GLTFObject.h" #import "GLTFBufferView.h" +#import "GLTFObject.h" #import @@ -24,13 +24,13 @@ NS_ASSUME_NONNULL_BEGIN @interface GLTFImage : GLTFObject /// A reference to a buffer view containing image data, if url is nil -@property (nonatomic, strong) GLTFBufferView * _Nullable bufferView; +@property (nonatomic, strong) GLTFBufferView *_Nullable bufferView; /// The MIME type of the data contained in this image's buffer view -@property (nonatomic, copy) NSString * _Nullable mimeType; +@property (nonatomic, copy) NSString *_Nullable mimeType; /// A file URL, if the URI was not a decodable data-uri; otherwise nil -@property (nonatomic, copy) NSURL * _Nullable url; +@property (nonatomic, copy) NSURL *_Nullable url; /// A data object containing the data encoded in the image's data-uri, if present; otherwise nil @property (nonatomic, strong) NSData *imageData; diff --git a/platform/darwin/src/gltf/gltfkit/GLTFKHRLight.h b/platform/darwin/src/gltf/gltfkit/GLTFKHRLight.h index 3848b78488b..9139bacf582 100644 --- a/platform/darwin/src/gltf/gltfkit/GLTFKHRLight.h +++ b/platform/darwin/src/gltf/gltfkit/GLTFKHRLight.h @@ -19,10 +19,10 @@ #import typedef NS_ENUM(NSInteger, GLTFKHRLightType) { - GLTFKHRLightTypeAmbient, - GLTFKHRLightTypeDirectional, - GLTFKHRLightTypePoint, - GLTFKHRLightTypeSpot, + GLTFKHRLightTypeAmbient, + GLTFKHRLightTypeDirectional, + GLTFKHRLightTypePoint, + GLTFKHRLightTypeSpot, }; @interface GLTFKHRLight : GLTFObject diff --git a/platform/darwin/src/gltf/gltfkit/GLTFMTLBufferAllocator.h b/platform/darwin/src/gltf/gltfkit/GLTFMTLBufferAllocator.h index fe422fe80ec..07abe678380 100644 --- a/platform/darwin/src/gltf/gltfkit/GLTFMTLBufferAllocator.h +++ b/platform/darwin/src/gltf/gltfkit/GLTFMTLBufferAllocator.h @@ -14,20 +14,20 @@ // OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. // -#import "GLTFBuffer.h" -#import "GLTFBufferAllocator.h" #import #import +#import "GLTFBuffer.h" +#import "GLTFBufferAllocator.h" NS_ASSUME_NONNULL_BEGIN -@interface GLTFMTLBuffer : NSObject +@interface GLTFMTLBuffer : NSObject @property (nonatomic, readonly) id buffer; @end -@interface GLTFMTLBufferAllocator : NSObject +@interface GLTFMTLBufferAllocator : NSObject - (instancetype)initWithDevice:(id)device; diff --git a/platform/darwin/src/gltf/gltfkit/GLTFMTLShaderBuilder.h b/platform/darwin/src/gltf/gltfkit/GLTFMTLShaderBuilder.h index 4e35d6a9f47..4c664894ad7 100644 --- a/platform/darwin/src/gltf/gltfkit/GLTFMTLShaderBuilder.h +++ b/platform/darwin/src/gltf/gltfkit/GLTFMTLShaderBuilder.h @@ -27,12 +27,13 @@ NS_ASSUME_NONNULL_BEGIN @interface GLTFMTLShaderBuilder : NSObject -- (id)renderPipelineStateForSubmesh:(GLTFSubmesh *)submesh - // lightingEnvironment:(GLTFMTLLightingEnvironment * _Nullable)lightingEnvironment - colorPixelFormat:(MTLPixelFormat)colorPixelFormat - depthStencilPixelFormat:(MTLPixelFormat)depthStencilPixelFormat - sampleCount:(int)sampleCount - device:(id)device; +- (id) + renderPipelineStateForSubmesh:(GLTFSubmesh *)submesh + // lightingEnvironment:(GLTFMTLLightingEnvironment * _Nullable)lightingEnvironment + colorPixelFormat:(MTLPixelFormat)colorPixelFormat + depthStencilPixelFormat:(MTLPixelFormat)depthStencilPixelFormat + sampleCount:(int)sampleCount + device:(id)device; @end diff --git a/platform/darwin/src/gltf/gltfkit/GLTFMTLTextureLoader.h b/platform/darwin/src/gltf/gltfkit/GLTFMTLTextureLoader.h index 48682d2f058..286838dda5f 100644 --- a/platform/darwin/src/gltf/gltfkit/GLTFMTLTextureLoader.h +++ b/platform/darwin/src/gltf/gltfkit/GLTFMTLTextureLoader.h @@ -14,7 +14,6 @@ // OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. // - #import NS_ASSUME_NONNULL_BEGIN @@ -25,8 +24,12 @@ extern NSString *const GLTFMTLTextureLoaderOptionSRGB; @interface GLTFMTLTextureLoader : NSObject - (instancetype)initWithDevice:(id)device; -- (id _Nullable)newTextureWithContentsOfURL:(NSURL *)url options:(NSDictionary * _Nullable)options error:(NSError **)error; -- (id _Nullable)newTextureWithData:(NSData *)data options:(NSDictionary * _Nullable)options error:(NSError **)error; +- (id _Nullable)newTextureWithContentsOfURL:(NSURL *)url + options:(NSDictionary *_Nullable)options + error:(NSError **)error; +- (id _Nullable)newTextureWithData:(NSData *)data + options:(NSDictionary *_Nullable)options + error:(NSError **)error; @end NS_ASSUME_NONNULL_END diff --git a/platform/darwin/src/gltf/gltfkit/GLTFMTLUtilities.h b/platform/darwin/src/gltf/gltfkit/GLTFMTLUtilities.h index 9764472aafd..774e113d4c5 100644 --- a/platform/darwin/src/gltf/gltfkit/GLTFMTLUtilities.h +++ b/platform/darwin/src/gltf/gltfkit/GLTFMTLUtilities.h @@ -25,7 +25,6 @@ NS_ASSUME_NONNULL_BEGIN extern "C" { #endif - extern MTLPrimitiveType GLTFMTLPrimitiveTypeForPrimitiveType(GLTFPrimitiveType gltfType); extern MTLBlendOperation GLTFMTLBlendOperationForBlendFunction(GLTFBlendFunction f); @@ -44,9 +43,11 @@ extern MTLSamplerMipFilter GLTFMTLSamplerMipFilterForSamplingFilter(GLTFSampling extern MTLSamplerAddressMode GLTFMTLSamplerAddressModeForSamplerAddressMode(GLTFAddressMode mode); -extern NSString *GLTFMTLTypeNameForType(GLTFDataType baseType, GLTFDataDimension dimension, BOOL packedIfPossible); +extern NSString *GLTFMTLTypeNameForType(GLTFDataType baseType, GLTFDataDimension dimension, + BOOL packedIfPossible); -extern MTLVertexFormat GLTFMTLVertexFormatForComponentTypeAndDimension(GLTFDataType baseType, GLTFDataDimension dimension); +extern MTLVertexFormat GLTFMTLVertexFormatForComponentTypeAndDimension(GLTFDataType baseType, + GLTFDataDimension dimension); #ifdef __cplusplus } diff --git a/platform/darwin/src/gltf/gltfkit/GLTFMaterial.h b/platform/darwin/src/gltf/gltfkit/GLTFMaterial.h index 92f1d29b4ff..cc8a889ab82 100644 --- a/platform/darwin/src/gltf/gltfkit/GLTFMaterial.h +++ b/platform/darwin/src/gltf/gltfkit/GLTFMaterial.h @@ -24,9 +24,9 @@ NS_ASSUME_NONNULL_BEGIN @class GLTFParameter; typedef NS_ENUM(NSInteger, GLTFAlphaMode) { - GLTFAlphaModeOpaque, - GLTFAlphaModeMask, - GLTFAlphaModeBlend, + GLTFAlphaModeOpaque, + GLTFAlphaModeMask, + GLTFAlphaModeBlend, }; @interface GLTFMaterial : GLTFObject @@ -38,23 +38,27 @@ typedef NS_ENUM(NSInteger, GLTFAlphaMode) { @property (nonatomic, assign) float occlusionStrength; @property (nonatomic, assign) simd_float3 emissiveFactor; -@property (nonatomic, assign) float glossinessFactor; // Only used by KHR_materials_pbrSpecularGlossiness extension -@property (nonatomic, assign) simd_float3 specularFactor; // Only used by KHR_materials_pbrSpecularGlossiness extension +@property (nonatomic, assign) + float glossinessFactor; // Only used by KHR_materials_pbrSpecularGlossiness extension +@property (nonatomic, assign) + simd_float3 specularFactor; // Only used by KHR_materials_pbrSpecularGlossiness extension -@property (nonatomic, strong) GLTFTextureInfo * _Nullable baseColorTexture; -@property (nonatomic, strong) GLTFTextureInfo * _Nullable metallicRoughnessTexture; -@property (nonatomic, strong) GLTFTextureInfo * _Nullable normalTexture; -@property (nonatomic, strong) GLTFTextureInfo * _Nullable emissiveTexture; -@property (nonatomic, strong) GLTFTextureInfo * _Nullable occlusionTexture; +@property (nonatomic, strong) GLTFTextureInfo* _Nullable baseColorTexture; +@property (nonatomic, strong) GLTFTextureInfo* _Nullable metallicRoughnessTexture; +@property (nonatomic, strong) GLTFTextureInfo* _Nullable normalTexture; +@property (nonatomic, strong) GLTFTextureInfo* _Nullable emissiveTexture; +@property (nonatomic, strong) GLTFTextureInfo* _Nullable occlusionTexture; -@property (nonatomic, assign) BOOL hasTextureTransforms; // Only used when KHR_texture_transform extension is present +@property (nonatomic, assign) + BOOL hasTextureTransforms; // Only used when KHR_texture_transform extension is present @property (nonatomic, assign, getter=isDoubleSided) BOOL doubleSided; @property (nonatomic, assign) GLTFAlphaMode alphaMode; -@property (nonatomic, assign) float alphaCutoff; // Only used when `alphaMode` == GLTFAlphaModeMask +@property (nonatomic, assign) float alphaCutoff; // Only used when `alphaMode` == GLTFAlphaModeMask -@property (nonatomic, assign, getter=isUnlit) BOOL unlit; // Only used when KHR_materials_unlit extension is present +@property (nonatomic, assign, getter=isUnlit) + BOOL unlit; // Only used when KHR_materials_unlit extension is present @end diff --git a/platform/darwin/src/gltf/gltfkit/GLTFMesh.h b/platform/darwin/src/gltf/gltfkit/GLTFMesh.h index 3bf40f62d25..19d4ea6f9ee 100644 --- a/platform/darwin/src/gltf/gltfkit/GLTFMesh.h +++ b/platform/darwin/src/gltf/gltfkit/GLTFMesh.h @@ -14,8 +14,8 @@ // OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. // -#import "GLTFObject.h" #import "GLTFEnums.h" +#import "GLTFObject.h" NS_ASSUME_NONNULL_BEGIN diff --git a/platform/darwin/src/gltf/gltfkit/GLTFNode.h b/platform/darwin/src/gltf/gltfkit/GLTFNode.h index 3863bb90913..f370d029909 100644 --- a/platform/darwin/src/gltf/gltfkit/GLTFNode.h +++ b/platform/darwin/src/gltf/gltfkit/GLTFNode.h @@ -14,32 +14,32 @@ // OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. // +#import +#import "GLTFNodeVisitor.h" #import "GLTFObject.h" #import "GLTFUtilities.h" -#import "GLTFNodeVisitor.h" -#import NS_ASSUME_NONNULL_BEGIN - @class GLTFCamera, GLTFSkin, GLTFMesh; @class GLTFKHRLight; @interface GLTFNode : GLTFObject -@property (nonatomic, weak) GLTFCamera * _Nullable camera; -@property (nonatomic, weak) GLTFKHRLight * _Nullable light; -@property (nonatomic, weak) GLTFNode * _Nullable parent; +@property (nonatomic, weak) GLTFCamera *_Nullable camera; +@property (nonatomic, weak) GLTFKHRLight *_Nullable light; +@property (nonatomic, weak) GLTFNode *_Nullable parent; @property (nonatomic, copy) NSArray *children; -@property (nonatomic, weak) GLTFSkin * _Nullable skin; -@property (nonatomic, copy) NSString * _Nullable jointName; -@property (nonatomic, weak) GLTFMesh * _Nullable mesh; +@property (nonatomic, weak) GLTFSkin *_Nullable skin; +@property (nonatomic, copy) NSString *_Nullable jointName; +@property (nonatomic, weak) GLTFMesh *_Nullable mesh; @property (nonatomic, copy) NSArray *morphTargetWeights; @property (nonatomic, assign) GLTFQuaternion rotationQuaternion; @property (nonatomic, assign) simd_float3 scale; @property (nonatomic, assign) simd_float3 translation; @property (nonatomic, assign) simd_float4x4 localTransform; @property (nonatomic, readonly, assign) simd_float4x4 globalTransform; -@property (nonatomic, readonly, assign) GLTFBoundingBox approximateBounds; // axis-aligned; in local coordinates +@property (nonatomic, readonly, assign) + GLTFBoundingBox approximateBounds; // axis-aligned; in local coordinates - (void)addChildNode:(GLTFNode *)node; - (void)removeFromParent; diff --git a/platform/darwin/src/gltf/gltfkit/GLTFNodeVisitor.h b/platform/darwin/src/gltf/gltfkit/GLTFNodeVisitor.h index a3bceddb5e3..ee3ce2b5de4 100644 --- a/platform/darwin/src/gltf/gltfkit/GLTFNodeVisitor.h +++ b/platform/darwin/src/gltf/gltfkit/GLTFNodeVisitor.h @@ -20,9 +20,7 @@ NS_ASSUME_NONNULL_BEGIN @class GLTFNode; -typedef NS_ENUM(NSInteger, GLTFVisitationStrategy) { - GLTFVisitationStrategyDepthFirst -}; +typedef NS_ENUM(NSInteger, GLTFVisitationStrategy) { GLTFVisitationStrategyDepthFirst }; typedef void (^GLTFNodeVisitor)(GLTFNode *node, int depth, BOOL *stop); diff --git a/platform/darwin/src/gltf/gltfkit/GLTFObject.h b/platform/darwin/src/gltf/gltfkit/GLTFObject.h index c745d543c20..146d6c82a30 100644 --- a/platform/darwin/src/gltf/gltfkit/GLTFObject.h +++ b/platform/darwin/src/gltf/gltfkit/GLTFObject.h @@ -21,7 +21,7 @@ NS_ASSUME_NONNULL_BEGIN @protocol GLTFObject /// The user-defined name of this object. Need not be unique. -@property (nonatomic, copy) NSString * _Nullable name; +@property (nonatomic, copy) NSString *_Nullable name; /// Data specific to any extensions used in this document @property (nonatomic, copy) NSDictionary *extensions; /// Contains application-specific information that is passed through but not parsed @@ -34,7 +34,7 @@ NS_ASSUME_NONNULL_BEGIN /// A unique identifier for this object @property (nonatomic, readonly) NSUUID *identifier; /// The user-defined name of this object. Need not be unique. -@property (nonatomic, copy) NSString * _Nullable name; +@property (nonatomic, copy) NSString *_Nullable name; /// Data specific to any extensions used in this document @property (nonatomic, copy) NSDictionary *extensions; /// Contains application-specific information that is passed through but not parsed diff --git a/platform/darwin/src/gltf/gltfkit/GLTFScene.h b/platform/darwin/src/gltf/gltfkit/GLTFScene.h index cf5ae848079..6abf39c6c92 100644 --- a/platform/darwin/src/gltf/gltfkit/GLTFScene.h +++ b/platform/darwin/src/gltf/gltfkit/GLTFScene.h @@ -14,9 +14,9 @@ // OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. // +#import "GLTFNodeVisitor.h" #import "GLTFObject.h" #import "GLTFUtilities.h" -#import "GLTFNodeVisitor.h" NS_ASSUME_NONNULL_BEGIN @@ -25,7 +25,7 @@ NS_ASSUME_NONNULL_BEGIN @interface GLTFScene : GLTFObject @property (nonatomic, copy) NSArray *nodes; -@property (nonatomic, weak) GLTFKHRLight * _Nullable ambientLight; +@property (nonatomic, weak) GLTFKHRLight *_Nullable ambientLight; @property (nonatomic, readonly, assign) GLTFBoundingBox approximateBounds; - (void)addNode:(GLTFNode *)node; diff --git a/platform/darwin/src/gltf/gltfkit/GLTFTexture.h b/platform/darwin/src/gltf/gltfkit/GLTFTexture.h index 556ab715cd4..7b7a9f97bb0 100644 --- a/platform/darwin/src/gltf/gltfkit/GLTFTexture.h +++ b/platform/darwin/src/gltf/gltfkit/GLTFTexture.h @@ -14,11 +14,10 @@ // OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. // -#import "GLTFObject.h" -#import "GLTFEnums.h" -#import "../GLTFMath.hpp" #import - +#import "../GLTFMath.hpp" +#import "GLTFEnums.h" +#import "GLTFObject.h" NS_ASSUME_NONNULL_BEGIN @@ -61,6 +60,4 @@ NS_ASSUME_NONNULL_BEGIN @end - NS_ASSUME_NONNULL_END - diff --git a/platform/darwin/src/gltf/gltfkit/GLTFTextureSampler.h b/platform/darwin/src/gltf/gltfkit/GLTFTextureSampler.h index a3b37249455..fbe3b026f52 100644 --- a/platform/darwin/src/gltf/gltfkit/GLTFTextureSampler.h +++ b/platform/darwin/src/gltf/gltfkit/GLTFTextureSampler.h @@ -14,8 +14,8 @@ // OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. // -#import "GLTFObject.h" #import "GLTFEnums.h" +#import "GLTFObject.h" NS_ASSUME_NONNULL_BEGIN diff --git a/platform/darwin/src/gltf/gltfkit/GLTFUtilities.h b/platform/darwin/src/gltf/gltfkit/GLTFUtilities.h index b23bc221102..db7a39064ce 100644 --- a/platform/darwin/src/gltf/gltfkit/GLTFUtilities.h +++ b/platform/darwin/src/gltf/gltfkit/GLTFUtilities.h @@ -23,44 +23,37 @@ NS_ASSUME_NONNULL_BEGIN typedef struct __attribute__((packed)) { - float x, y, z; + float x, y, z; } GLTFVector3; typedef struct __attribute__((packed)) { - float x, y, z, w; + float x, y, z, w; } GLTFVector4; typedef struct __attribute__((packed)) { - GLTFVector4 columns[4]; + GLTFVector4 columns[4]; } GLTFMatrix4; typedef simd_quatf GLTFQuaternion; - extern bool GLTFBoundingBoxIsEmpty(GLTFBoundingBox b); extern GLTFBoundingBox *GLTFBoundingBoxUnion(GLTFBoundingBox *a, GLTFBoundingBox b); extern void GLTFBoundingBoxTransform(GLTFBoundingBox *b, simd_float4x4 transform); - extern GLTFQuaternion GLTFQuaternionFromEulerAngles(float pitch, float yaw, float roll); - - - - extern simd_float3x3 GLTFMatrixUpperLeft3x3(simd_float4x4); extern simd_float4x4 GLTFNormalMatrixFromModelMatrix(simd_float4x4); - - extern GLTFDataDimension GLTFDataDimensionForName(NSString *name); extern size_t GLTFSizeOfDataType(GLTFDataType type); -extern size_t GLTFSizeOfComponentTypeWithDimension(GLTFDataType baseType, GLTFDataDimension dimension); +extern size_t GLTFSizeOfComponentTypeWithDimension(GLTFDataType baseType, + GLTFDataDimension dimension); extern NSInteger GLTFComponentCountForDimension(GLTFDataDimension dimension); diff --git a/platform/darwin/src/gltf/gltfkit/GLTFVertexDescriptor.h b/platform/darwin/src/gltf/gltfkit/GLTFVertexDescriptor.h index 4a73f93ef05..beaf2bf9d09 100644 --- a/platform/darwin/src/gltf/gltfkit/GLTFVertexDescriptor.h +++ b/platform/darwin/src/gltf/gltfkit/GLTFVertexDescriptor.h @@ -46,7 +46,7 @@ extern NSString *const GLTFAttributeSemanticMetallic; @property (nonatomic, assign) NSInteger stride; @end -@interface GLTFVertexDescriptor: NSObject +@interface GLTFVertexDescriptor : NSObject @property (nonatomic, copy) NSArray *attributes; @property (nonatomic, copy) NSArray *bufferLayouts; @end