From a1aace74e58460d0d5c6462cea81682b5647e4b7 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Tue, 28 Feb 2023 21:53:18 +0100 Subject: [PATCH 01/16] Fix: Use C++17 compliant utf8 encoding. --- samples/SharedCode/UTFConverter.cpp | 2 +- samples/SharedCode/UTFConverter.h | 43 ++++++++++++++++++----------- 2 files changed, 28 insertions(+), 17 deletions(-) diff --git a/samples/SharedCode/UTFConverter.cpp b/samples/SharedCode/UTFConverter.cpp index a1bff7e4b..e6c07e946 100644 --- a/samples/SharedCode/UTFConverter.cpp +++ b/samples/SharedCode/UTFConverter.cpp @@ -46,7 +46,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. namespace AssimpSamples { namespace SharedCode { -typename UTFConverter::UTFConverterImpl UTFConverter::impl_; +//typename UTFConverter::UTFConverterImpl UTFConverter::impl_; } } diff --git a/samples/SharedCode/UTFConverter.h b/samples/SharedCode/UTFConverter.h index 17e89ee4d..34b2293de 100644 --- a/samples/SharedCode/UTFConverter.h +++ b/samples/SharedCode/UTFConverter.h @@ -45,43 +45,54 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define ASSIMP_SAMPLES_SHARED_CODE_UTFCONVERTER_H #include -#include -#include +#include + +#ifdef ASSIMP_USE_HUNTER +#include +#else +#include "../contrib/utf8cpp/source/utf8.h" +#endif namespace AssimpSamples { namespace SharedCode { // Used to convert between multibyte and unicode strings. class UTFConverter { - using UTFConverterImpl = std::wstring_convert, wchar_t>; public: - UTFConverter(const char* s) : - s_(s), - ws_(impl_.from_bytes(s)) { + //utf8::utf16to8(start, end, back_inserter(str)); + + UTFConverter(const char* s) : s_(s), ws_() { + std::vector str; + utf8::utf8to16(s, s + std::strlen(s) + 1, back_inserter(str)); } - UTFConverter(const wchar_t* s) : - s_(impl_.to_bytes(s)), - ws_(s) { + + UTFConverter(const wchar_t* s) : s_(),ws_(s) { + std::vector str; + utf8::utf16to8(s, s + ws_.size() + 1, back_inserter(str)); } - UTFConverter(const std::string& s) : - s_(s), - ws_(impl_.from_bytes(s)) { + + UTFConverter(const std::string& s) : s_(s), ws_() { + std::vector str; + utf8::utf8to16(s.c_str(), s.c_str() + s.size() + 1, back_inserter(str)); } - UTFConverter(const std::wstring& s) : - s_(impl_.to_bytes(s)), - ws_(s) { + + UTFConverter(const std::wstring& s) : s_(), ws_(s) { + std::vector str; + utf8::utf16to8(s.c_str(), s.c_str() + ws_.size() + 1, back_inserter(str)); } + inline const char* c_str() const { return s_.c_str(); } + inline const std::string& str() const { return s_; } + inline const wchar_t* c_wstr() const { return ws_.c_str(); } private: - static UTFConverterImpl impl_; std::string s_; std::wstring ws_; }; From 60da5e7e963d5753a5a532cea1ff78600cf8185f Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Tue, 28 Feb 2023 23:27:46 +0100 Subject: [PATCH 02/16] Update UTFConverter.cpp --- samples/SharedCode/UTFConverter.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/samples/SharedCode/UTFConverter.cpp b/samples/SharedCode/UTFConverter.cpp index e6c07e946..383ae43f1 100644 --- a/samples/SharedCode/UTFConverter.cpp +++ b/samples/SharedCode/UTFConverter.cpp @@ -5,8 +5,6 @@ Open Asset Import Library (assimp) Copyright (c) 2006-2020, assimp team - - All rights reserved. Redistribution and use of this software in source and binary forms, @@ -46,7 +44,5 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. namespace AssimpSamples { namespace SharedCode { -//typename UTFConverter::UTFConverterImpl UTFConverter::impl_; - } } From 534ee288c5d5864f871a924a44ef5462c2acf435 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Tue, 28 Feb 2023 23:28:24 +0100 Subject: [PATCH 03/16] Update UTFConverter.h --- samples/SharedCode/UTFConverter.h | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/samples/SharedCode/UTFConverter.h b/samples/SharedCode/UTFConverter.h index 34b2293de..8173d474c 100644 --- a/samples/SharedCode/UTFConverter.h +++ b/samples/SharedCode/UTFConverter.h @@ -3,9 +3,7 @@ Open Asset Import Library (assimp) --------------------------------------------------------------------------- -Copyright (c) 2006-2020, assimp team - - +Copyright (c) 2006-2023, assimp team All rights reserved. @@ -56,11 +54,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. namespace AssimpSamples { namespace SharedCode { -// Used to convert between multibyte and unicode strings. +/// @brief Used to convert between multibyte and unicode strings. class UTFConverter { public: - //utf8::utf16to8(start, end, back_inserter(str)); - UTFConverter(const char* s) : s_(s), ws_() { std::vector str; utf8::utf8to16(s, s + std::strlen(s) + 1, back_inserter(str)); From 1092f0d94e4cf60a28ce96a51334c9f243b997e0 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Wed, 1 Mar 2023 21:40:45 +0100 Subject: [PATCH 04/16] Fix:Use correct encoding --- include/assimp/Base64.hpp | 14 ++- samples/SharedCode/UTFConverter.cpp | 52 --------- samples/SharedCode/UTFConverter.h | 103 ------------------ .../SimpleTexturedDirectx11/CMakeLists.txt | 2 - .../SimpleTexturedDirectx11/main.cpp | 19 +++- samples/SimpleTexturedOpenGL/CMakeLists.txt | 2 - tools/assimp_view/AnimEvaluator.cpp | 6 - tools/assimp_view/AnimEvaluator.h | 2 +- tools/assimp_view/AssetHelper.h | 17 ++- tools/assimp_view/Material.cpp | 22 ++-- tools/assimp_view/assimp_view.cpp | 9 +- tools/assimp_view/assimp_view.h | 6 + 12 files changed, 49 insertions(+), 205 deletions(-) delete mode 100644 samples/SharedCode/UTFConverter.cpp delete mode 100644 samples/SharedCode/UTFConverter.h diff --git a/include/assimp/Base64.hpp b/include/assimp/Base64.hpp index 403723857..10288713c 100644 --- a/include/assimp/Base64.hpp +++ b/include/assimp/Base64.hpp @@ -43,6 +43,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef AI_BASE64_HPP_INC #define AI_BASE64_HPP_INC +#include + #include #include #include @@ -54,35 +56,35 @@ namespace Base64 { /// @param in The UTF-64 buffer. /// @param inLength The size of the buffer /// @param out The encoded ASCII string. -void Encode(const uint8_t *in, size_t inLength, std::string &out); +ASSIMP_API void Encode(const uint8_t *in, size_t inLength, std::string &out); /// @brief Will encode the given character buffer from UTF64 to ASCII. /// @param in A vector, which contains the buffer for encoding. /// @param out The encoded ASCII string. -void Encode(const std::vector& in, std::string &out); +ASSIMP_API void Encode(const std::vector &in, std::string &out); /// @brief Will encode the given character buffer from UTF64 to ASCII. /// @param in A vector, which contains the buffer for encoding. /// @return The encoded ASCII string. -std::string Encode(const std::vector& in); +ASSIMP_API std::string Encode(const std::vector &in); /// @brief Will decode the given character buffer from ASCII to UTF64. /// @param in The ASCII buffer to decode. /// @param inLength The size of the buffer. /// @param out The decoded buffer. /// @return The new buffer size. -size_t Decode(const char *in, size_t inLength, uint8_t *&out); +ASSIMP_API size_t Decode(const char *in, size_t inLength, uint8_t *&out); /// @brief Will decode the given character buffer from ASCII to UTF64. /// @param in The ASCII buffer to decode as a std::string. /// @param out The decoded buffer. /// @return The new buffer size. -size_t Decode(const std::string& in, std::vector& out); +ASSIMP_API size_t Decode(const std::string &in, std::vector &out); /// @brief Will decode the given character buffer from ASCII to UTF64. /// @param in The ASCII string. /// @return The decoded buffer in a vector. -std::vector Decode(const std::string& in); +ASSIMP_API std::vector Decode(const std::string &in); } // namespace Base64 } // namespace Assimp diff --git a/samples/SharedCode/UTFConverter.cpp b/samples/SharedCode/UTFConverter.cpp deleted file mode 100644 index e6c07e946..000000000 --- a/samples/SharedCode/UTFConverter.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/* ---------------------------------------------------------------------------- -Open Asset Import Library (assimp) ---------------------------------------------------------------------------- - -Copyright (c) 2006-2020, assimp team - - - -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the following -conditions are met: - -* Redistributions of source code must retain the above - copyright notice, this list of conditions and the - following disclaimer. - -* Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the - following disclaimer in the documentation and/or other - materials provided with the distribution. - -* Neither the name of the assimp team, nor the names of its - contributors may be used to endorse or promote products - derived from this software without specific prior - written permission of the assimp team. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---------------------------------------------------------------------------- -*/ - -#include "UTFConverter.h" - -namespace AssimpSamples { -namespace SharedCode { - -//typename UTFConverter::UTFConverterImpl UTFConverter::impl_; - -} -} diff --git a/samples/SharedCode/UTFConverter.h b/samples/SharedCode/UTFConverter.h deleted file mode 100644 index 34b2293de..000000000 --- a/samples/SharedCode/UTFConverter.h +++ /dev/null @@ -1,103 +0,0 @@ -/* ---------------------------------------------------------------------------- -Open Asset Import Library (assimp) ---------------------------------------------------------------------------- - -Copyright (c) 2006-2020, assimp team - - - -All rights reserved. - -Redistribution and use of this software in source and binary forms, -with or without modification, are permitted provided that the following -conditions are met: - -* Redistributions of source code must retain the above - copyright notice, this list of conditions and the - following disclaimer. - -* Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the - following disclaimer in the documentation and/or other - materials provided with the distribution. - -* Neither the name of the assimp team, nor the names of its - contributors may be used to endorse or promote products - derived from this software without specific prior - written permission of the assimp team. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ---------------------------------------------------------------------------- -*/ - -#ifndef ASSIMP_SAMPLES_SHARED_CODE_UTFCONVERTER_H -#define ASSIMP_SAMPLES_SHARED_CODE_UTFCONVERTER_H - -#include -#include - -#ifdef ASSIMP_USE_HUNTER -#include -#else -#include "../contrib/utf8cpp/source/utf8.h" -#endif - -namespace AssimpSamples { -namespace SharedCode { - -// Used to convert between multibyte and unicode strings. -class UTFConverter { -public: - //utf8::utf16to8(start, end, back_inserter(str)); - - UTFConverter(const char* s) : s_(s), ws_() { - std::vector str; - utf8::utf8to16(s, s + std::strlen(s) + 1, back_inserter(str)); - } - - UTFConverter(const wchar_t* s) : s_(),ws_(s) { - std::vector str; - utf8::utf16to8(s, s + ws_.size() + 1, back_inserter(str)); - } - - UTFConverter(const std::string& s) : s_(s), ws_() { - std::vector str; - utf8::utf8to16(s.c_str(), s.c_str() + s.size() + 1, back_inserter(str)); - } - - UTFConverter(const std::wstring& s) : s_(), ws_(s) { - std::vector str; - utf8::utf16to8(s.c_str(), s.c_str() + ws_.size() + 1, back_inserter(str)); - } - - inline const char* c_str() const { - return s_.c_str(); - } - - inline const std::string& str() const { - return s_; - } - - inline const wchar_t* c_wstr() const { - return ws_.c_str(); - } -private: - std::string s_; - std::wstring ws_; -}; - -} -} - -#endif // ASSIMP_SAMPLES_SHARED_CODE_UTFCONVERTER_H diff --git a/samples/SimpleTexturedDirectx11/CMakeLists.txt b/samples/SimpleTexturedDirectx11/CMakeLists.txt index 007ada3af..f1e03888c 100644 --- a/samples/SimpleTexturedDirectx11/CMakeLists.txt +++ b/samples/SimpleTexturedDirectx11/CMakeLists.txt @@ -33,8 +33,6 @@ ADD_EXECUTABLE( assimp_simpletextureddirectx11 WIN32 #SimpleTexturedDirectx11/VertexShader.hlsl SimpleTexturedDirectx11/main.cpp SimpleTexturedDirectx11/SafeRelease.hpp - ${SAMPLES_SHARED_CODE_DIR}/UTFConverter.cpp - ${SAMPLES_SHARED_CODE_DIR}/UTFConverter.h ) TARGET_USE_COMMON_OUTPUT_DIRECTORY(assimp_simpletextureddirectx11) diff --git a/samples/SimpleTexturedDirectx11/SimpleTexturedDirectx11/main.cpp b/samples/SimpleTexturedDirectx11/SimpleTexturedDirectx11/main.cpp index f7b35024b..7f0d0c84e 100644 --- a/samples/SimpleTexturedDirectx11/SimpleTexturedDirectx11/main.cpp +++ b/samples/SimpleTexturedDirectx11/SimpleTexturedDirectx11/main.cpp @@ -21,8 +21,12 @@ #include #include #include +#ifdef ASSIMP_USE_HUNTER +#include +#else +#include "../contrib/utf8cpp/source/utf8.h" +#endif #include "ModelLoader.h" -#include "UTFConverter.h" #include "SafeRelease.hpp" #ifdef _MSC_VER @@ -33,7 +37,6 @@ #endif // _MSC_VER using namespace DirectX; -using namespace AssimpSamples::SharedCode; #define VERTEX_SHADER_FILE L"VertexShader.hlsl" #define PIXEL_SHADER_FILE L"PixelShader.hlsl" @@ -154,8 +157,14 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, } // Retrieve the model file path. - g_ModelPath = UTFConverter(argv[1]).str(); + std::wstring filename(argv[1]); + + char *targetStart = new char[filename.size()+1]; + memset(targetStart, '\0', filename.size() + 1); + utf8::utf16to8(filename.c_str(), filename.c_str() + filename.size(), targetStart); + g_ModelPath = targetStart; + delete[] targetStart; free_command_line_allocated_memory(); WNDCLASSEX wc; @@ -511,9 +520,9 @@ void InitPipeline() { ID3DBlob *VS, *PS; if(FAILED(CompileShaderFromFile(SHADER_PATH VERTEX_SHADER_FILE, 0, "main", "vs_4_0", &VS))) - Throwanerror(UTFConverter(L"Failed to compile shader from file " VERTEX_SHADER_FILE).c_str()); + Throwanerror("Failed to compile shader from file"); if(FAILED(CompileShaderFromFile(SHADER_PATH PIXEL_SHADER_FILE, 0, "main", "ps_4_0", &PS))) - Throwanerror(UTFConverter(L"Failed to compile shader from file " PIXEL_SHADER_FILE).c_str()); + Throwanerror("Failed to compile shader from file "); dev->CreateVertexShader(VS->GetBufferPointer(), VS->GetBufferSize(), nullptr, &pVS); dev->CreatePixelShader(PS->GetBufferPointer(), PS->GetBufferSize(), nullptr, &pPS); diff --git a/samples/SimpleTexturedOpenGL/CMakeLists.txt b/samples/SimpleTexturedOpenGL/CMakeLists.txt index 1837af033..70837e87c 100644 --- a/samples/SimpleTexturedOpenGL/CMakeLists.txt +++ b/samples/SimpleTexturedOpenGL/CMakeLists.txt @@ -30,8 +30,6 @@ LINK_DIRECTORIES( ADD_EXECUTABLE( assimp_simpletexturedogl WIN32 SimpleTexturedOpenGL/src/model_loading.cpp - ${SAMPLES_SHARED_CODE_DIR}/UTFConverter.cpp - ${SAMPLES_SHARED_CODE_DIR}/UTFConverter.h ) TARGET_USE_COMMON_OUTPUT_DIRECTORY(assimp_simpletexturedogl) diff --git a/tools/assimp_view/AnimEvaluator.cpp b/tools/assimp_view/AnimEvaluator.cpp index ad8e7f5b2..4f8d1bda8 100644 --- a/tools/assimp_view/AnimEvaluator.cpp +++ b/tools/assimp_view/AnimEvaluator.cpp @@ -55,12 +55,6 @@ AnimEvaluator::AnimEvaluator(const aiAnimation *pAnim) : mLastPositions.resize(pAnim->mNumChannels, std::make_tuple(0, 0, 0)); } -// ------------------------------------------------------------------------------------------------ -// Destructor. -AnimEvaluator::~AnimEvaluator() { - // empty -} - // ------------------------------------------------------------------------------------------------ // Evaluates the animation tracks for a given time stamp. void AnimEvaluator::Evaluate(double pTime) { diff --git a/tools/assimp_view/AnimEvaluator.h b/tools/assimp_view/AnimEvaluator.h index 76b22ea8a..aa44ab211 100644 --- a/tools/assimp_view/AnimEvaluator.h +++ b/tools/assimp_view/AnimEvaluator.h @@ -66,7 +66,7 @@ public: AnimEvaluator(const aiAnimation *pAnim); /// @brief The class destructor. - ~AnimEvaluator(); + ~AnimEvaluator() = default; /// @brief Evaluates the animation tracks for a given time stamp. /// The calculated pose can be retrieved as an array of transformation diff --git a/tools/assimp_view/AssetHelper.h b/tools/assimp_view/AssetHelper.h index 1ae469f85..8661d875f 100644 --- a/tools/assimp_view/AssetHelper.h +++ b/tools/assimp_view/AssetHelper.h @@ -77,6 +77,13 @@ public: pcScene = NULL; } + // set the normal set to be used + void SetNormalSet(unsigned int iSet); + + // flip all normal vectors + void FlipNormals(); + void FlipNormalsInt(); + //--------------------------------------------------------------- // default vertex data structure // (even if tangents, bitangents or normals aren't @@ -221,16 +228,8 @@ public: // Specifies the normal set to be used unsigned int iNormalSet; - - // ------------------------------------------------------------------ - // set the normal set to be used - void SetNormalSet(unsigned int iSet); - - // ------------------------------------------------------------------ - // flip all normal vectors - void FlipNormals(); - void FlipNormalsInt(); }; + } // namespace AssimpView #endif // !! IG diff --git a/tools/assimp_view/Material.cpp b/tools/assimp_view/Material.cpp index e3c023bd9..c28231332 100644 --- a/tools/assimp_view/Material.cpp +++ b/tools/assimp_view/Material.cpp @@ -175,33 +175,29 @@ VOID WINAPI FillFunc(D3DXVECTOR4* pOut, pOut->x = pOut->y = 1.0f; pOut->z = 0.0f; } - return; } //------------------------------------------------------------------------------- -int CMaterialManager::UpdateSpecularMaterials() - { - if (g_pcAsset && g_pcAsset->pcScene) - { - for (unsigned int i = 0; i < g_pcAsset->pcScene->mNumMeshes;++i) - { - if (aiShadingMode_Phong == g_pcAsset->apcMeshes[i]->eShadingMode) - { +int CMaterialManager::UpdateSpecularMaterials() { + if (g_pcAsset && g_pcAsset->pcScene) { + for (unsigned int i = 0; i < g_pcAsset->pcScene->mNumMeshes;++i) { + if (aiShadingMode_Phong == g_pcAsset->apcMeshes[i]->eShadingMode) { this->DeleteMaterial(g_pcAsset->apcMeshes[i]); this->CreateMaterial(g_pcAsset->apcMeshes[i],g_pcAsset->pcScene->mMeshes[i]); - } } } - return 1; } + return 1; +} + //------------------------------------------------------------------------------- -int CMaterialManager::SetDefaultTexture(IDirect3DTexture9** p_ppiOut) -{ +int CMaterialManager::SetDefaultTexture(IDirect3DTexture9** p_ppiOut) { if (sDefaultTexture) { sDefaultTexture->AddRef(); *p_ppiOut = sDefaultTexture; return 1; } + if(FAILED(g_piDevice->CreateTexture( 256, 256, diff --git a/tools/assimp_view/assimp_view.cpp b/tools/assimp_view/assimp_view.cpp index c5c48fd93..e00c6e39d 100644 --- a/tools/assimp_view/assimp_view.cpp +++ b/tools/assimp_view/assimp_view.cpp @@ -145,9 +145,7 @@ float g_fLoadTime = 0.0f; // The loader thread loads the asset while the progress dialog displays the // smart progress bar //------------------------------------------------------------------------------- -DWORD WINAPI LoadThreadProc(LPVOID lpParameter) { - UNREFERENCED_PARAMETER(lpParameter); - +DWORD WINAPI LoadThreadProc(LPVOID) { // get current time double fCur = (double)timeGetTime(); @@ -367,7 +365,7 @@ int CalculateBounds(aiNode *piNode, aiVector3D *p_avOut, const aiMatrix4x4 &piMa // The function calculates the boundaries of the mesh and modifies the // global world transformation matrix according to the aset AABB //------------------------------------------------------------------------------- -int ScaleAsset(void) { +int ScaleAsset() { aiVector3D aiVecs[2] = { aiVector3D(1e10f, 1e10f, 1e10f), aiVector3D(-1e10f, -1e10f, -1e10f) }; @@ -521,8 +519,7 @@ int CreateAssetData() { } } else { // create 16 bit index buffer - if (FAILED(g_piDevice->CreateIndexBuffer(2 * -numIndices, + if (FAILED(g_piDevice->CreateIndexBuffer(2 * numIndices, D3DUSAGE_WRITEONLY | dwUsage, D3DFMT_INDEX16, D3DPOOL_DEFAULT, diff --git a/tools/assimp_view/assimp_view.h b/tools/assimp_view/assimp_view.h index cbcee3cac..e67cc9fd0 100644 --- a/tools/assimp_view/assimp_view.h +++ b/tools/assimp_view/assimp_view.h @@ -98,6 +98,12 @@ namespace AssimpView { //------------------------------------------------------------------------------- // Function prototypes //------------------------------------------------------------------------------- +class AssimpVew { +public: + AssimpVew(); + ~AssimpVew(); +}; + int InitD3D(void); int ShutdownD3D(void); int CreateDevice(bool p_bMultiSample, bool p_bSuperSample, bool bHW = true); From 011382424b9bea9984f294a2cf7ec43f378c4e6c Mon Sep 17 00:00:00 2001 From: Urs Hanselmann Date: Fri, 3 Mar 2023 19:31:50 +0100 Subject: [PATCH 05/16] remove debug message from MemoryIOStream (used by public Importer::ReadFileFromMemory method) --- include/assimp/MemoryIOWrapper.h | 1 - 1 file changed, 1 deletion(-) diff --git a/include/assimp/MemoryIOWrapper.h b/include/assimp/MemoryIOWrapper.h index 77071e96f..1b986ff1b 100644 --- a/include/assimp/MemoryIOWrapper.h +++ b/include/assimp/MemoryIOWrapper.h @@ -150,7 +150,6 @@ public: // ------------------------------------------------------------------- /// @brief Tests for the existence of a file at the given path. bool Exists(const char* pFile) const override { - printf("Exists\n"); if (0 == strncmp( pFile, AI_MEMORYIO_MAGIC_FILENAME, AI_MEMORYIO_MAGIC_FILENAME_LENGTH ) ) { return true; } From 74c406dd262e3c92229760683ce814d12116ada5 Mon Sep 17 00:00:00 2001 From: Urs Hanselmann Date: Sat, 4 Mar 2023 14:27:58 +0100 Subject: [PATCH 06/16] add ci script to scan for unexpected printf statements --- .github/workflows/sanitizer.yml | 10 ++++++++++ scripts/scan_printf.sh | 20 ++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100755 scripts/scan_printf.sh diff --git a/.github/workflows/sanitizer.yml b/.github/workflows/sanitizer.yml index 57d6e78f1..b23f4520f 100644 --- a/.github/workflows/sanitizer.yml +++ b/.github/workflows/sanitizer.yml @@ -57,3 +57,13 @@ jobs: - name: test run: cd build/bin && ./unit shell: bash + + job3: + name: printf-sanitizer + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: run scan_printf script + run: ./scripts/scan_printf.sh + shell: bash diff --git a/scripts/scan_printf.sh b/scripts/scan_printf.sh new file mode 100755 index 000000000..b507e6438 --- /dev/null +++ b/scripts/scan_printf.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +PATHS="include code" +FILTER_INCLUDE='\*.{c,cpp,h}' +FILTER_EXCLUDE="{include/assimp/Compiler/pstdint.h,code/AssetLib/M3D/m3d.h}" + +PATTERN='^\s*printf' + +grep \ + --include=\*.{c,cpp,h} \ + --exclude={include/assimp/Compiler/pstdint.h,code/AssetLib/M3D/m3d.h} \ + -rnw include code \ + -e '^\s*printf' + +if [ $? ] +then + echo "Debug statement(s) detected. Please remove, or manually add to exclude filter, if appropriate" + exit 1 +fi + From 1520aff68027047d3c86d64c26f6ee3148af3423 Mon Sep 17 00:00:00 2001 From: Urs Hanselmann Date: Sat, 4 Mar 2023 14:41:10 +0100 Subject: [PATCH 07/16] fix scan_printf script in linux bash --- scripts/scan_printf.sh | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/scripts/scan_printf.sh b/scripts/scan_printf.sh index b507e6438..90ab7c870 100755 --- a/scripts/scan_printf.sh +++ b/scripts/scan_printf.sh @@ -1,14 +1,8 @@ -#!/bin/sh - -PATHS="include code" -FILTER_INCLUDE='\*.{c,cpp,h}' -FILTER_EXCLUDE="{include/assimp/Compiler/pstdint.h,code/AssetLib/M3D/m3d.h}" - -PATTERN='^\s*printf' +#!/bin/bash grep \ --include=\*.{c,cpp,h} \ - --exclude={include/assimp/Compiler/pstdint.h,code/AssetLib/M3D/m3d.h} \ + --exclude={pstdint,m3d}.h \ -rnw include code \ -e '^\s*printf' From 4fa433c8ff9839ac466c4c4bb333d7113db33d78 Mon Sep 17 00:00:00 2001 From: Urs Hanselmann Date: Sat, 4 Mar 2023 14:52:49 +0100 Subject: [PATCH 08/16] improve scan_printf ci script error message --- scripts/scan_printf.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/scan_printf.sh b/scripts/scan_printf.sh index 90ab7c870..a71fab756 100755 --- a/scripts/scan_printf.sh +++ b/scripts/scan_printf.sh @@ -8,7 +8,7 @@ grep \ if [ $? ] then - echo "Debug statement(s) detected. Please remove, or manually add to exclude filter, if appropriate" + echo "Debug statement(s) detected. Please uncomment (using single-line comment), remove, or manually add to exclude filter, if appropriate" exit 1 fi From 2efd48dee2208a255ca4bfa3a821bfd3615e6924 Mon Sep 17 00:00:00 2001 From: Urs Hanselmann Date: Sat, 4 Mar 2023 14:53:48 +0100 Subject: [PATCH 09/16] disable another debug print message --- code/AssetLib/Ogre/OgreXmlSerializer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/AssetLib/Ogre/OgreXmlSerializer.cpp b/code/AssetLib/Ogre/OgreXmlSerializer.cpp index cd9d6dcc2..623f2961e 100644 --- a/code/AssetLib/Ogre/OgreXmlSerializer.cpp +++ b/code/AssetLib/Ogre/OgreXmlSerializer.cpp @@ -490,7 +490,7 @@ bool OgreXmlSerializer::ImportSkeleton(Assimp::IOSystem *pIOHandler, MeshXml *me OgreXmlSerializer serializer(xmlParser.get()); XmlNode root = xmlParser->getRootNode(); if (std::string(root.name()) != nnSkeleton) { - printf("\nSkeleton is not a valid root: %s\n", root.name()); + // printf("\nSkeleton is not a valid root: %s\n", root.name()); for (auto &a : root.children()) { if (std::string(a.name()) == nnSkeleton) { root = a; From dcb89cf1070ed8cc7676f8f00cf8951906d5b2b6 Mon Sep 17 00:00:00 2001 From: Urs Hanselmann Date: Sat, 4 Mar 2023 15:00:43 +0100 Subject: [PATCH 10/16] fix scan_printf script error code handling --- scripts/scan_printf.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/scan_printf.sh b/scripts/scan_printf.sh index a71fab756..f8c902941 100755 --- a/scripts/scan_printf.sh +++ b/scripts/scan_printf.sh @@ -6,8 +6,7 @@ grep \ -rnw include code \ -e '^\s*printf' -if [ $? ] -then +if [ $? -eq 0 ]; then echo "Debug statement(s) detected. Please uncomment (using single-line comment), remove, or manually add to exclude filter, if appropriate" exit 1 fi From c089f117680c4f99f02b4a1e6771fe348acda2dd Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Mon, 6 Mar 2023 19:56:11 +0100 Subject: [PATCH 11/16] Update utf82utf16. --- include/assimp/types.h | 6 + .../SimpleTexturedDirectx11/main.cpp | 14 +- .../src/model_loading.cpp | 155 ++++++------------ 3 files changed, 64 insertions(+), 111 deletions(-) diff --git a/include/assimp/types.h b/include/assimp/types.h index a41363b8a..be2aad18b 100644 --- a/include/assimp/types.h +++ b/include/assimp/types.h @@ -57,6 +57,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include +#ifdef ASSIMP_USE_HUNTER +#include +#else +#include "../contrib/utf8cpp/source/utf8.h" +#endif + // Our compile configuration #include diff --git a/samples/SimpleTexturedDirectx11/SimpleTexturedDirectx11/main.cpp b/samples/SimpleTexturedDirectx11/SimpleTexturedDirectx11/main.cpp index 7f0d0c84e..4da5820a1 100644 --- a/samples/SimpleTexturedDirectx11/SimpleTexturedDirectx11/main.cpp +++ b/samples/SimpleTexturedDirectx11/SimpleTexturedDirectx11/main.cpp @@ -13,6 +13,8 @@ // Written by IAS. :) // --------------------------------------------------------------------------- +#include + #include #include #include @@ -21,11 +23,7 @@ #include #include #include -#ifdef ASSIMP_USE_HUNTER -#include -#else -#include "../contrib/utf8cpp/source/utf8.h" -#endif + #include "ModelLoader.h" #include "SafeRelease.hpp" @@ -53,10 +51,10 @@ struct ConstantBuffer { // ------------------------------------------------------------ // Window Variables // ------------------------------------------------------------ -#define SCREEN_WIDTH 800 -#define SCREEN_HEIGHT 600 +static constexpr uint32_t SCREEN_WIDTH = 800; +static constexpr uint32_t SCREEN_HEIGHT = 600; -const char g_szClassName[] = "directxWindowClass"; +constexpr char g_szClassName[] = "directxWindowClass"; static std::string g_ModelPath; diff --git a/samples/SimpleTexturedOpenGL/SimpleTexturedOpenGL/src/model_loading.cpp b/samples/SimpleTexturedOpenGL/SimpleTexturedOpenGL/src/model_loading.cpp index 48066f189..2eb73b403 100644 --- a/samples/SimpleTexturedOpenGL/SimpleTexturedOpenGL/src/model_loading.cpp +++ b/samples/SimpleTexturedOpenGL/SimpleTexturedOpenGL/src/model_loading.cpp @@ -41,15 +41,14 @@ #include #include #include -#include "UTFConverter.h" // The default hard-coded path. Can be overridden by supplying a path through the command line. static std::string modelpath = "../../test/models/OBJ/spider.obj"; -HGLRC hRC=nullptr; // Permanent Rendering Context -HDC hDC=nullptr; // Private GDI Device Context -HWND g_hWnd=nullptr; // Holds Window Handle -HINSTANCE g_hInstance=nullptr; // Holds The Instance Of The Application +HGLRC hRC = nullptr; // Permanent Rendering Context +HDC hDC = nullptr; // Private GDI Device Context +HWND g_hWnd = nullptr; // Holds Window Handle +HINSTANCE g_hInstance = nullptr; // Holds The Instance Of The Application bool keys[256]; // Array used for Keyboard Routine; bool active=TRUE; // Window Active Flag Set To TRUE by Default @@ -69,8 +68,6 @@ GLfloat LightAmbient[]= { 0.5f, 0.5f, 0.5f, 1.0f }; GLfloat LightDiffuse[]= { 1.0f, 1.0f, 1.0f, 1.0f }; GLfloat LightPosition[]= { 0.0f, 0.0f, 15.0f, 1.0f }; - - // the global Assimp scene object const aiScene* g_scene = nullptr; GLuint scene_list = 0; @@ -83,12 +80,8 @@ GLuint* textureIds; // pointer to texture Array // Create an instance of the Importer class Assimp::Importer importer; -using namespace AssimpSamples::SharedCode; - -void createAILogger() -{ - // Change this line to normal if you not want to analyse the import process - //Assimp::Logger::LogSeverity severity = Assimp::Logger::NORMAL; +void createAILogger() { + // Change this line to normal if you not want to analyze the import process Assimp::Logger::LogSeverity severity = Assimp::Logger::VERBOSE; // Create a logger instance for Console Output @@ -101,62 +94,52 @@ void createAILogger() Assimp::DefaultLogger::get()->info("this is my info-call"); } -void destroyAILogger() -{ - // Kill it after the work is done +void destroyAILogger() { Assimp::DefaultLogger::kill(); } -void logInfo(std::string logString) -{ - // Will add message to File with "info" Tag +void logInfo(const std::string &logString) { Assimp::DefaultLogger::get()->info(logString.c_str()); } -void logDebug(const char* logString) -{ - // Will add message to File with "debug" Tag +void logDebug(const char* logString) { Assimp::DefaultLogger::get()->debug(logString); } -bool Import3DFromFile( const std::string& pFile) -{ +bool Import3DFromFile( const std::string &filename) { // Check if file exists - std::ifstream fin(pFile.c_str()); - if(!fin.fail()) - { - fin.close(); + std::ifstream fin(filename.c_str()); + if(fin.fail()) { + std::string message = "Couldn't open file: " + filename; + std::wstring targetMessage; + //utf8::utf8to16(message.c_str(), message.c_str() + message.size(), targetMessage); + ::MessageBox(nullptr, targetMessage.c_str(), L"Error", MB_OK | MB_ICONEXCLAMATION); + logInfo(importer.GetErrorString()); + return false; } - else - { - MessageBox(nullptr, UTFConverter("Couldn't open file: " + pFile).c_wstr() , TEXT("ERROR"), MB_OK | MB_ICONEXCLAMATION); - logInfo( importer.GetErrorString()); - return false; - } - - g_scene = importer.ReadFile(pFile, aiProcessPreset_TargetRealtime_Quality); + + fin.close(); + + g_scene = importer.ReadFile(filename, aiProcessPreset_TargetRealtime_Quality); // If the import failed, report it - if(!g_scene) - { + if (g_scene == nullptr) { logInfo( importer.GetErrorString()); return false; } // Now we can access the file's contents. - logInfo("Import of scene " + pFile + " succeeded."); + logInfo("Import of scene " + filename + " succeeded."); // We're done. Everything will be cleaned up by the importer destructor return true; } // Resize And Initialize The GL Window -void ReSizeGLScene(GLsizei width, GLsizei height) -{ +void ReSizeGLScene(GLsizei width, GLsizei height) { // Prevent A Divide By Zero By - if (height==0) - { + if (height == 0) { // Making Height Equal One height=1; } @@ -174,43 +157,26 @@ void ReSizeGLScene(GLsizei width, GLsizei height) } -std::string getBasePath(const std::string& path) -{ +std::string getBasePath(const std::string& path) { size_t pos = path.find_last_of("\\/"); return (std::string::npos == pos) ? "" : path.substr(0, pos + 1); } -void freeTextureIds() -{ - textureIdMap.clear(); //no need to delete pointers in it manually here. (Pointers point to textureIds deleted in next step) +void freeTextureIds() { + // no need to delete pointers in it manually here. (Pointers point to textureIds deleted in next step) + textureIdMap.clear(); - if (textureIds) - { + if (textureIds) { delete[] textureIds; textureIds = nullptr; } } -int LoadGLTextures(const aiScene* scene) -{ +int LoadGLTextures(const aiScene* scene) { freeTextureIds(); - //ILboolean success; - - /* Before calling ilInit() version should be checked. */ - /*if (ilGetInteger(IL_VERSION_NUM) < IL_VERSION) - { - /// wrong DevIL version /// - std::string err_msg = "Wrong DevIL version. Old devil.dll in system32/SysWow64?"; - char* cErr_msg = (char *) err_msg.c_str(); - abortGLInit(cErr_msg); - return -1; - }*/ - - //ilInit(); /* Initialization of DevIL */ - - if (scene->HasTextures()) return 1; - //abortGLInit("Support for meshes with embedded textures is not implemented"); + if (scene->HasTextures()) + return 1; /* getTexture Filenames and Numb of Textures */ for (unsigned int m=0; mmNumMaterials; m++) @@ -230,14 +196,6 @@ int LoadGLTextures(const aiScene* scene) const size_t numTextures = textureIdMap.size(); - - /* array with DevIL image IDs */ - //ILuint* imageIds = NULL; -// imageIds = new ILuint[numTextures]; - - /* generate DevIL Image IDs */ -// ilGenImages(numTextures, imageIds); /* Generation of numTextures image names */ - /* create and fill array with GL texture ids */ textureIds = new GLuint[numTextures]; glGenTextures(static_cast(numTextures), textureIds); /* Texture name generation */ @@ -248,29 +206,17 @@ int LoadGLTextures(const aiScene* scene) std::string basepath = getBasePath(modelpath); for (size_t i=0; i 1) { std::wstring modelpathW(argv[1]); - modelpath = UTFConverter(modelpathW).str(); + utf8::utf16to8(modelpathW.c_str(), modelpathW.c_str() + modelpathW.size(), back_inserter(modelpath)); } if (!Import3DFromFile(modelpath)) From 8171e041fafea7432b397ef30f7576e0b6156178 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Mon, 6 Mar 2023 20:56:09 +0100 Subject: [PATCH 12/16] Update utf82utf16. --- .../src/model_loading.cpp | 32 +++++++++++++------ 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/samples/SimpleTexturedOpenGL/SimpleTexturedOpenGL/src/model_loading.cpp b/samples/SimpleTexturedOpenGL/SimpleTexturedOpenGL/src/model_loading.cpp index 2eb73b403..89731bd9b 100644 --- a/samples/SimpleTexturedOpenGL/SimpleTexturedOpenGL/src/model_loading.cpp +++ b/samples/SimpleTexturedOpenGL/SimpleTexturedOpenGL/src/model_loading.cpp @@ -233,13 +233,15 @@ int LoadGLTextures(const aiScene* scene) { glPixelStorei( GL_UNPACK_SKIP_PIXELS, 0 ); glPixelStorei( GL_UNPACK_SKIP_ROWS, 0 ); stbi_image_free(data); - } - else - { - /* Error occurred */ + } else { + /* Error occurred */ const std::string message = "Couldn't load Image: " + fileloc; std::wstring targetMessage; - utf8::utf8to16(message.c_str(), message.c_str() + message.size(), back_inserter(targetMessage)); + wchar_t *tmp = new wchar_t[message.size() + 1]; + memset(tmp, L'\0', sizeof(wchar_t) *(message.size() + 1)); + utf8::utf8to16(message.c_str(), message.c_str() + message.size(), tmp); + targetMessage = tmp; + delete [] tmp; MessageBox(nullptr, targetMessage.c_str(), TEXT("ERROR"), MB_OK | MB_ICONEXCLAMATION); } } @@ -535,7 +537,12 @@ GLboolean abortGLInit(const char* abortMessage) KillGLWindow(); const std::string message = abortMessage; std::wstring targetMessage; - utf8::utf8to16(message.c_str(), message.c_str() + message.size(), back_inserter(targetMessage)); + const size_t len = std::strlen(abortMessage) + 1; + wchar_t *tmp = new wchar_t[len]; + memset(tmp, L'\0', len); + utf8::utf8to16(message.c_str(), message.c_str() + message.size(), tmp); + targetMessage = tmp; + delete [] tmp; MessageBox(nullptr, targetMessage.c_str(), TEXT("ERROR"), MB_OK|MB_ICONEXCLAMATION); return FALSE; // quit and return False @@ -587,7 +594,8 @@ BOOL CreateGLWindow(const char* title, int width, int height, int bits, bool ful if (ChangeDisplaySettings(&dmScreenSettings, CDS_FULLSCREEN)!=DISP_CHANGE_SUCCESSFUL) { // If The Mode Fails, Offer Two Options. Quit Or Run In A Window. - if (MessageBox(nullptr,TEXT("The Requested Fullscreen Mode Is Not Supported By\nYour Video Card. Use Windowed Mode Instead?"),TEXT("NeHe GL"),MB_YESNO|MB_ICONEXCLAMATION)==IDYES) + if (MessageBox(nullptr,TEXT("The Requested Fullscreen Mode Is Not Supported By\nYour Video Card. Use Windowed Mode Instead?"), + TEXT("NeHe GL"),MB_YESNO|MB_ICONEXCLAMATION)==IDYES) { fullscreen = FALSE; // Select Windowed Mode (Fullscreen = FALSE) } @@ -618,7 +626,7 @@ BOOL CreateGLWindow(const char* title, int width, int height, int bits, bool ful std::wstring targetMessage; utf8::utf8to16(message.c_str(), message.c_str() + message.size(), back_inserter(targetMessage)); - if (nullptr == (g_hWnd=CreateWindowEx(dwExStyle, // Extended Style For The Window + if (nullptr == (g_hWnd = CreateWindowEx(dwExStyle, // Extended Style For The Window TEXT("OpenGL"), // Class Name targetMessage.c_str(), // Window Title WS_CLIPSIBLINGS | // Required Window Style @@ -792,7 +800,11 @@ int WINAPI WinMain( HINSTANCE /*hInstance*/, // The instance if (argv != nullptr && argc > 1) { std::wstring modelpathW(argv[1]); - utf8::utf16to8(modelpathW.c_str(), modelpathW.c_str() + modelpathW.size(), back_inserter(modelpath)); + char *tmp = new char[modelpathW.size() + 1]; + memset(tmp, '\0', modelpathW.size() + 1); + utf8::utf16to8(modelpathW.c_str(), modelpathW.c_str() + modelpathW.size(), tmp); + modelpath = tmp; + delete[]tmp; } if (!Import3DFromFile(modelpath)) @@ -820,7 +832,7 @@ int WINAPI WinMain( HINSTANCE /*hInstance*/, // The instance { if (msg.message==WM_QUIT) { - done=TRUE; + done = TRUE; } else { From 5082c940d0d76871288024ba406864f36bcc8eb8 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Mon, 6 Mar 2023 21:13:40 +0100 Subject: [PATCH 13/16] Fix: Replace back_inserter usage. --- .../SimpleTexturedOpenGL/src/model_loading.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/samples/SimpleTexturedOpenGL/SimpleTexturedOpenGL/src/model_loading.cpp b/samples/SimpleTexturedOpenGL/SimpleTexturedOpenGL/src/model_loading.cpp index 89731bd9b..7d730a630 100644 --- a/samples/SimpleTexturedOpenGL/SimpleTexturedOpenGL/src/model_loading.cpp +++ b/samples/SimpleTexturedOpenGL/SimpleTexturedOpenGL/src/model_loading.cpp @@ -622,9 +622,12 @@ BOOL CreateGLWindow(const char* title, int width, int height, int bits, bool ful AdjustWindowRectEx(&WindowRect, dwStyle, FALSE, dwExStyle); // Adjust Window To True Requested Size - const std::string message = title; - std::wstring targetMessage; - utf8::utf8to16(message.c_str(), message.c_str() + message.size(), back_inserter(targetMessage)); + const size_t len = std::strlen(title) + 1; + wchar_t *tmp = new wchar_t[len]; + memset(tmp, L'\0', sizeof(wchar_t) * len); + utf8::utf8to16(title, title+len, tmp); + std::wstring targetMessage = tmp; + delete[] tmp; if (nullptr == (g_hWnd = CreateWindowEx(dwExStyle, // Extended Style For The Window TEXT("OpenGL"), // Class Name From 44c2785663d38f79614138bfa87d91d0b0ad69c7 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Tue, 7 Mar 2023 17:01:08 +0100 Subject: [PATCH 14/16] Make debug message more professional. --- code/AssetLib/Ogre/OgreXmlSerializer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/AssetLib/Ogre/OgreXmlSerializer.cpp b/code/AssetLib/Ogre/OgreXmlSerializer.cpp index 623f2961e..a8faaec34 100644 --- a/code/AssetLib/Ogre/OgreXmlSerializer.cpp +++ b/code/AssetLib/Ogre/OgreXmlSerializer.cpp @@ -490,7 +490,7 @@ bool OgreXmlSerializer::ImportSkeleton(Assimp::IOSystem *pIOHandler, MeshXml *me OgreXmlSerializer serializer(xmlParser.get()); XmlNode root = xmlParser->getRootNode(); if (std::string(root.name()) != nnSkeleton) { - // printf("\nSkeleton is not a valid root: %s\n", root.name()); + ASSIMP_LOG_VERBOSE_DEBUG("nSkeleton is not a valid root: ", root.name(), "."); for (auto &a : root.children()) { if (std::string(a.name()) == nnSkeleton) { root = a; From 069b3ecdf814784f8f80f3858863222184f15172 Mon Sep 17 00:00:00 2001 From: Florian Born Date: Tue, 7 Mar 2023 17:44:48 +0100 Subject: [PATCH 15/16] After Kim's addition to meta data types, use it in the FBX converter --- code/AssetLib/FBX/FBXConverter.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/code/AssetLib/FBX/FBXConverter.cpp b/code/AssetLib/FBX/FBXConverter.cpp index d45919e10..37654746e 100644 --- a/code/AssetLib/FBX/FBXConverter.cpp +++ b/code/AssetLib/FBX/FBXConverter.cpp @@ -873,8 +873,12 @@ void FBXConverter::SetupNodeMetadata(const Model &model, aiNode &nd) { data->Set(index++, prop.first, interpretedBool->Value()); } else if (const TypedProperty *interpretedInt = prop.second->As>()) { data->Set(index++, prop.first, interpretedInt->Value()); + } else if (const TypedProperty *interpretedUInt = prop.second->As>()) { + data->Set(index++, prop.first, interpretedUInt->Value()); } else if (const TypedProperty *interpretedUint64 = prop.second->As>()) { data->Set(index++, prop.first, interpretedUint64->Value()); + } else if (const TypedProperty *interpretedint64 = prop.second->As>()) { + data->Set(index++, prop.first, interpretedint64->Value()); } else if (const TypedProperty *interpretedFloat = prop.second->As>()) { data->Set(index++, prop.first, interpretedFloat->Value()); } else if (const TypedProperty *interpretedString = prop.second->As>()) { From 4f48348af8f2d0b046788edab8f952af9bf2d52b Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Tue, 7 Mar 2023 18:55:18 +0100 Subject: [PATCH 16/16] Fix: Move c++ include to c++ section --- include/assimp/types.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/include/assimp/types.h b/include/assimp/types.h index be2aad18b..605dc590f 100644 --- a/include/assimp/types.h +++ b/include/assimp/types.h @@ -57,12 +57,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include -#ifdef ASSIMP_USE_HUNTER -#include -#else -#include "../contrib/utf8cpp/source/utf8.h" -#endif - // Our compile configuration #include @@ -79,6 +73,12 @@ typedef uint32_t ai_uint32; #ifdef __cplusplus +#ifdef ASSIMP_USE_HUNTER +# include +#else +# include "../contrib/utf8cpp/source/utf8.h" +#endif + #include #include // for std::nothrow_t #include // for aiString::Set(const std::string&)