diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index e4bde79c6e..5a0fbd4524 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -5,6 +5,7 @@ A new header is inserted each time a *tag* is created. ## Next release +- Removed `` from math headers. - Fix bad instruction exception with macOS Catalina. - Added support for solid and thin layer cubemap and screen-space refraction. - Improved high roughness material rendering by default when regenerating environments maps. diff --git a/filament/backend/src/android/ExternalStreamManagerAndroid.cpp b/filament/backend/src/android/ExternalStreamManagerAndroid.cpp index da2941f545..5587ce666b 100644 --- a/filament/backend/src/android/ExternalStreamManagerAndroid.cpp +++ b/filament/backend/src/android/ExternalStreamManagerAndroid.cpp @@ -22,6 +22,8 @@ #include +#include + using namespace utils; namespace filament { diff --git a/libs/gltfio/src/MaterialProvider.cpp b/libs/gltfio/src/MaterialProvider.cpp index 3e2c608304..58eea85067 100644 --- a/libs/gltfio/src/MaterialProvider.cpp +++ b/libs/gltfio/src/MaterialProvider.cpp @@ -16,6 +16,8 @@ #include +#include + using namespace gltfio; bool gltfio::operator==(const MaterialKey& k1, const MaterialKey& k2) { diff --git a/libs/ibl/src/CubemapSH.cpp b/libs/ibl/src/CubemapSH.cpp index 0758d83d06..fc8b00c782 100644 --- a/libs/ibl/src/CubemapSH.cpp +++ b/libs/ibl/src/CubemapSH.cpp @@ -28,6 +28,7 @@ #include #include +#include using namespace filament::math; using namespace utils; diff --git a/libs/imageio/src/ImageDecoder.cpp b/libs/imageio/src/ImageDecoder.cpp index f10f469d01..54b01c01dc 100644 --- a/libs/imageio/src/ImageDecoder.cpp +++ b/libs/imageio/src/ImageDecoder.cpp @@ -20,7 +20,7 @@ #include #include // for memcmp -#include +#include // for cerr #include #include #include diff --git a/libs/imageio/src/ImageEncoder.cpp b/libs/imageio/src/ImageEncoder.cpp index 0846244f85..4e7f3b5749 100644 --- a/libs/imageio/src/ImageEncoder.cpp +++ b/libs/imageio/src/ImageEncoder.cpp @@ -22,7 +22,7 @@ #include #include #include -#include +#include // for cerr #if defined(WIN32) #include diff --git a/libs/math/CMakeLists.txt b/libs/math/CMakeLists.txt index 31ed064e0b..906b1dd3f7 100644 --- a/libs/math/CMakeLists.txt +++ b/libs/math/CMakeLists.txt @@ -13,9 +13,25 @@ endif() # ================================================================================================== # Sources and headers # ================================================================================================== -file(GLOB_RECURSE PUBLIC_HDRS ${PUBLIC_HDR_DIR}/${TARGET}/*.h) +set(PUBLIC_HDRS + include/math/TMatHelpers.h + include/math/TQuatHelpers.h + include/math/TVecHelpers.h + include/math/compiler.h + include/math/fast.h + include/math/half.h + include/math/mat2.h + include/math/mat3.h + include/math/mat4.h + include/math/norm.h + include/math/quat.h + include/math/scalar.h + include/math/vec2.h + include/math/vec3.h + include/math/vec4.h +) -set(SRCS dummy.cpp) +set(SRCS src/StreamHelpers.cpp) # ================================================================================================== # Include and target definitions diff --git a/libs/math/dummy.cpp b/libs/math/dummy.cpp deleted file mode 100644 index 3a6c9c21f3..0000000000 --- a/libs/math/dummy.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (C) 2018 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// Empty symbol used to suppress warnings on Darwin -#if __has_attribute(visibility) - __attribute__((visibility("hidden"))) -#endif -void e() { -} diff --git a/libs/math/include/math/TMatHelpers.h b/libs/math/include/math/TMatHelpers.h index a419ff2acc..187744ad35 100644 --- a/libs/math/include/math/TMatHelpers.h +++ b/libs/math/include/math/TMatHelpers.h @@ -23,8 +23,7 @@ #include // for std::swap #include // for std:: namespace -#include // for operator<< -#include // for std::setw +#include // for operator<< #include #include @@ -801,34 +800,14 @@ public: } }; +template +std::ostream& printMatrix(std::ostream& stream, const T* data, size_t rows, size_t cols); template class BASE, typename T> class TMatDebug { private: friend std::ostream& operator<<(std::ostream& stream, const BASE& m) { - for (size_t row = 0; row < BASE::NUM_ROWS; ++row) { - if (row != 0) { - stream << std::endl; - } - if (row == 0) { - stream << "/ "; - } else if (row == BASE::NUM_ROWS - 1) { - stream << "\\ "; - } else { - stream << "| "; - } - for (size_t col = 0; col < BASE::NUM_COLS; ++col) { - stream << std::setw(10) << std::to_string(m[col][row]); - } - if (row == 0) { - stream << " \\"; - } else if (row == BASE::NUM_ROWS - 1) { - stream << " /"; - } else { - stream << " |"; - } - } - return stream; + return printMatrix(stream, &m[0][0], BASE::NUM_ROWS, BASE::NUM_COLS); } }; diff --git a/libs/math/include/math/TQuatHelpers.h b/libs/math/include/math/TQuatHelpers.h index 68549cc049..b7a834079a 100644 --- a/libs/math/include/math/TQuatHelpers.h +++ b/libs/math/include/math/TQuatHelpers.h @@ -22,7 +22,7 @@ #include #include -#include +#include #include #include @@ -286,6 +286,9 @@ public: } }; +template class BASE, typename T> +std::ostream& printQuat(std::ostream& stream, const BASE& m); + /* * TQuatDebug implements functions on a vector of type BASE. * @@ -304,7 +307,7 @@ public: * (the first one, BASE being known). */ friend std::ostream& operator<<(std::ostream& stream, const QUATERNION& q) { - return stream << "< " << q.w << " + " << q.x << "i + " << q.y << "j + " << q.z << "k >"; + return printQuat(stream, q); } }; diff --git a/libs/math/include/math/TVecHelpers.h b/libs/math/include/math/TVecHelpers.h index 044e2dbe21..798b7da69f 100644 --- a/libs/math/include/math/TVecHelpers.h +++ b/libs/math/include/math/TVecHelpers.h @@ -21,7 +21,7 @@ #include // for std:: namespace #include // for appl() and map() -#include // for operator<< +#include // for operator<< #include #include @@ -567,6 +567,9 @@ private: } }; +template +std::ostream& printVector(std::ostream& stream, const T* data, size_t count); + /* * TVecDebug implements functions on a vector of type BASE. * @@ -585,12 +588,7 @@ private: * (the first one, BASE being known). */ friend std::ostream& operator<<(std::ostream& stream, const VECTOR& v) { - stream << "< "; - for (size_t i = 0; i < v.size() - 1; i++) { - stream << T(v[i]) << ", "; - } - stream << T(v[v.size() - 1]) << " >"; - return stream; + return printVector(stream, &v[0], v.size()); } }; diff --git a/libs/math/src/StreamHelpers.cpp b/libs/math/src/StreamHelpers.cpp new file mode 100644 index 0000000000..a10c6fe669 --- /dev/null +++ b/libs/math/src/StreamHelpers.cpp @@ -0,0 +1,89 @@ +/* + * Copyright 2020 The Android Open Source Project +* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +namespace filament { +namespace math { +namespace details { + +template +std::ostream& printVector(std::ostream& stream, const T* data, size_t count) { + stream << "< "; + for (size_t i = 0; i < count - 1; i++) { + stream << data[i] << ", "; + } + stream << data[count - 1] << " >"; + return stream; +} + +template +std::ostream& printMatrix(std::ostream& stream, const T* m, size_t rows, size_t cols) { + for (size_t row = 0; row < rows; ++row) { + if (row != 0) { + stream << std::endl; + } + if (row == 0) { + stream << "/ "; + } else if (row == rows - 1) { + stream << "\\ "; + } else { + stream << "| "; + } + for (size_t col = 0; col < cols; ++col) { + stream << std::setw(10) << std::to_string(m[row + col * rows]); + } + if (row == 0) { + stream << " \\"; + } else if (row == rows - 1) { + stream << " /"; + } else { + stream << " |"; + } + } + return stream; +} + +template class BASE, typename T> +std::ostream& printQuat(std::ostream& stream, const BASE& q) { + return stream << "< " << q.w << " + " << q.x << "i + " << q.y << "j + " << q.z << "k >"; +} + +template std::ostream& printMatrix(std::ostream& stream, const double* data, size_t rows, size_t cols); +template std::ostream& printMatrix(std::ostream& stream, const float* data, size_t rows, size_t cols); + +template std::ostream& printVector(std::ostream& stream, const double* data, size_t count); +template std::ostream& printVector(std::ostream& stream, const float* data, size_t count); +template std::ostream& printVector(std::ostream& stream, const int* data, size_t count); +template std::ostream& printVector(std::ostream& stream, const half* data, size_t count); + +template std::ostream& printQuat(std::ostream& stream, const quath& q); +template std::ostream& printQuat(std::ostream& stream, const quatf& q); +template std::ostream& printQuat(std::ostream& stream, const quat& q); + +} // namespace details +} // namespace math +} // namespace filament diff --git a/libs/utils/include/utils/Path.h b/libs/utils/include/utils/Path.h index 1f498932b5..d5317b129f 100644 --- a/libs/utils/include/utils/Path.h +++ b/libs/utils/include/utils/Path.h @@ -17,7 +17,7 @@ #ifndef UTILS_PATH_H_ #define UTILS_PATH_H_ -#include +#include #include #include diff --git a/samples/app/FilamentApp.cpp b/samples/app/FilamentApp.cpp index e166032551..4ade324608 100644 --- a/samples/app/FilamentApp.cpp +++ b/samples/app/FilamentApp.cpp @@ -25,6 +25,8 @@ # include #endif +#include + #include #include diff --git a/samples/app/IBL.cpp b/samples/app/IBL.cpp index b13236664f..3532a04b76 100644 --- a/samples/app/IBL.cpp +++ b/samples/app/IBL.cpp @@ -17,6 +17,7 @@ #include "IBL.h" #include +#include #include #include diff --git a/samples/app/MeshAssimp.cpp b/samples/app/MeshAssimp.cpp index ad2777b6c0..be3b33eed0 100644 --- a/samples/app/MeshAssimp.cpp +++ b/samples/app/MeshAssimp.cpp @@ -31,6 +31,7 @@ #include #include +#include #include #include diff --git a/samples/frame_generator.cpp b/samples/frame_generator.cpp index 0ad5f8749b..e843dc85c4 100644 --- a/samples/frame_generator.cpp +++ b/samples/frame_generator.cpp @@ -16,6 +16,8 @@ #include #include +#include +#include #include #include #include diff --git a/samples/gltf_baker.cpp b/samples/gltf_baker.cpp index 684c865ab1..608da542c1 100644 --- a/samples/gltf_baker.cpp +++ b/samples/gltf_baker.cpp @@ -47,6 +47,7 @@ #include #include #include +#include #include #include "generated/resources/resources.h" diff --git a/samples/gltf_viewer.cpp b/samples/gltf_viewer.cpp index 1fe665dcc4..e3ec586565 100644 --- a/samples/gltf_viewer.cpp +++ b/samples/gltf_viewer.cpp @@ -34,6 +34,7 @@ #include #include +#include #include #include "generated/resources/gltf_viewer.h" diff --git a/samples/lightbulb.cpp b/samples/lightbulb.cpp index 194538f2c1..3bcdd421bf 100644 --- a/samples/lightbulb.cpp +++ b/samples/lightbulb.cpp @@ -14,6 +14,7 @@ * limitations under the License. */ +#include #include #include #include diff --git a/samples/material_sandbox.cpp b/samples/material_sandbox.cpp index dba3ac2193..3155e52451 100644 --- a/samples/material_sandbox.cpp +++ b/samples/material_sandbox.cpp @@ -14,6 +14,7 @@ * limitations under the License. */ +#include #include #include #include diff --git a/samples/sample_cloth.cpp b/samples/sample_cloth.cpp index cb34955a8a..e915717204 100644 --- a/samples/sample_cloth.cpp +++ b/samples/sample_cloth.cpp @@ -14,6 +14,7 @@ * limitations under the License. */ +#include #include #include #include diff --git a/samples/sample_full_pbr.cpp b/samples/sample_full_pbr.cpp index 21a65ed8c6..0a17bba437 100644 --- a/samples/sample_full_pbr.cpp +++ b/samples/sample_full_pbr.cpp @@ -40,6 +40,7 @@ #include +#include #include #include #include diff --git a/samples/sample_normal_map.cpp b/samples/sample_normal_map.cpp index 39d7e42122..91a665acd9 100644 --- a/samples/sample_normal_map.cpp +++ b/samples/sample_normal_map.cpp @@ -14,6 +14,7 @@ * limitations under the License. */ +#include #include #include #include diff --git a/samples/vk_texturedquad.cpp b/samples/vk_texturedquad.cpp index 175a1dd52e..92e74b3db8 100644 --- a/samples/vk_texturedquad.cpp +++ b/samples/vk_texturedquad.cpp @@ -31,8 +31,7 @@ #include -#include -#include +#include // for cerr #include "generated/resources/resources.h"