From 0f32f59dc3d1fa11f6b3afb53c2900d9150c474e Mon Sep 17 00:00:00 2001 From: jess Date: Wed, 15 Apr 2020 13:24:22 -0700 Subject: [PATCH 01/33] Add Open Collective MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Hi, I'm making updates for Open Collective. Either you or another core contributor signed this repository up for Open Collective. This pull request adds financial contributors from your Open Collective https://opencollective.com/assimp ❤️ What it does: - adds a badge to show the latest number of financial contributors - adds a banner displaying contributors to the project on GitHub - adds a banner displaying all individuals contributing financially on Open Collective - adds a section displaying all organizations contributing financially on Open Collective, with their logo and a link to their website P.S: As with any pull request, feel free to comment or suggest changes. Thank you for your great contribution to the Open Source community. You are awesome! 🙌 And welcome to the Open Collective community! 😊 Come chat with us in the #opensource channel on https://slack.opencollective.com - great place to ask questions and share best practices with other Open Source sustainers! --- Readme.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/Readme.md b/Readme.md index 61fff538f..15e76b9d2 100644 --- a/Readme.md +++ b/Readme.md @@ -2,6 +2,7 @@ Open Asset Import Library (assimp) ================================== A library to import and export various 3d-model-formats including scene-post-processing to generate missing render data. ### Current project status ### +[![Financial Contributors on Open Collective](https://opencollective.com/assimp/all/badge.svg?label=financial+contributors)](https://opencollective.com/assimp) ![C/C++ CI](https://github.com/assimp/assimp/workflows/C/C++%20CI/badge.svg) [![Linux Build Status](https://travis-ci.org/assimp/assimp.svg)](https://travis-ci.org/assimp/assimp) [![Windows Build Status](https://ci.appveyor.com/api/projects/status/tmo433wax6u6cjp4?svg=true)](https://ci.appveyor.com/project/kimkulling/assimp) @@ -179,6 +180,28 @@ And we also have a Gitter-channel:Gitter [![Join the chat at https://gitter.im/a Contributions to assimp are highly appreciated. The easiest way to get involved is to submit a pull request with your changes against the main repository's `master` branch. +## Contributors + +### Code Contributors + +This project exists thanks to all the people who contribute. [[Contribute](CONTRIBUTING.md)]. + + + +### Financial Contributors + +Become a financial contributor and help us sustain our community. [[Contribute](https://opencollective.com/assimp/contribute)] + +#### Individuals + + + +#### Organizations + +Support this project with your organization. Your logo will show up here with a link to your website. [[Contribute](https://opencollective.com/assimp/contribute)] + + + ### License ### Our license is based on the modified, __3-clause BSD__-License. From bafb8e3189ec472fc9552bbf128047adb4247464 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Sun, 26 Apr 2020 08:59:52 +0200 Subject: [PATCH 02/33] closes https://github.com/assimp/assimp/issues/3165: remove deprecated code whch causes compiler warning. --- code/Common/SpatialSort.cpp | 238 ++++++++++++++--------------- include/assimp/SpatialSort.h | 52 +++---- test/CMakeLists.txt | 1 + test/unit/Common/utSpatialSort.cpp | 84 ++++++++++ test/unit/utStringUtils.cpp | 2 - 5 files changed, 220 insertions(+), 157 deletions(-) create mode 100644 test/unit/Common/utSpatialSort.cpp diff --git a/code/Common/SpatialSort.cpp b/code/Common/SpatialSort.cpp index a32ff5f90..352a36fba 100644 --- a/code/Common/SpatialSort.cpp +++ b/code/Common/SpatialSort.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, @@ -50,71 +48,64 @@ using namespace Assimp; // CHAR_BIT seems to be defined under MVSC, but not under GCC. Pray that the correct value is 8. #ifndef CHAR_BIT -# define CHAR_BIT 8 +#define CHAR_BIT 8 #endif #ifdef _WIN32 -# pragma warning(disable : 4127) +//# pragma warning(disable : 4127) #endif // _WIN32 -// ------------------------------------------------------------------------------------------------ -// Constructs a spatially sorted representation from the given position array. -SpatialSort::SpatialSort( const aiVector3D* pPositions, unsigned int pNumPositions, - unsigned int pElementOffset) +const aiVector3D PlaneInit( 0.8523f, 0.34321f, 0.5736f ); - // define the reference plane. We choose some arbitrary vector away from all basic axises - // in the hope that no model spreads all its vertices along this plane. - : mPlaneNormal(0.8523f, 0.34321f, 0.5736f) -{ + // ------------------------------------------------------------------------------------------------ +// Constructs a spatially sorted representation from the given position array. +// define the reference plane. We choose some arbitrary vector away from all basic axises +// in the hope that no model spreads all its vertices along this plane. +SpatialSort::SpatialSort(const aiVector3D *pPositions, unsigned int pNumPositions, unsigned int pElementOffset) : + mPlaneNormal(PlaneInit) { mPlaneNormal.Normalize(); - Fill(pPositions,pNumPositions,pElementOffset); + Fill(pPositions, pNumPositions, pElementOffset); } // ------------------------------------------------------------------------------------------------ -SpatialSort :: SpatialSort() -: mPlaneNormal(0.8523f, 0.34321f, 0.5736f) -{ +SpatialSort::SpatialSort() : + mPlaneNormal(PlaneInit) { mPlaneNormal.Normalize(); } // ------------------------------------------------------------------------------------------------ // Destructor -SpatialSort::~SpatialSort() -{ - // nothing to do here, everything destructs automatically +SpatialSort::~SpatialSort() { + // empty } // ------------------------------------------------------------------------------------------------ -void SpatialSort::Fill( const aiVector3D* pPositions, unsigned int pNumPositions, - unsigned int pElementOffset, - bool pFinalize /*= true */) -{ +void SpatialSort::Fill(const aiVector3D *pPositions, unsigned int pNumPositions, + unsigned int pElementOffset, + bool pFinalize /*= true */) { mPositions.clear(); - Append(pPositions,pNumPositions,pElementOffset,pFinalize); + Append(pPositions, pNumPositions, pElementOffset, pFinalize); } // ------------------------------------------------------------------------------------------------ -void SpatialSort :: Finalize() -{ - std::sort( mPositions.begin(), mPositions.end()); +void SpatialSort::Finalize() { + std::sort(mPositions.begin(), mPositions.end()); } // ------------------------------------------------------------------------------------------------ -void SpatialSort::Append( const aiVector3D* pPositions, unsigned int pNumPositions, - unsigned int pElementOffset, - bool pFinalize /*= true */) -{ +void SpatialSort::Append(const aiVector3D *pPositions, unsigned int pNumPositions, + unsigned int pElementOffset, + bool pFinalize /*= true */) { // store references to all given positions along with their distance to the reference plane const size_t initial = mPositions.size(); - mPositions.reserve(initial + (pFinalize?pNumPositions:pNumPositions*2)); - for( unsigned int a = 0; a < pNumPositions; a++) - { - const char* tempPointer = reinterpret_cast (pPositions); - const aiVector3D* vec = reinterpret_cast (tempPointer + a * pElementOffset); + mPositions.reserve(initial + (pFinalize ? pNumPositions : pNumPositions * 2)); + for (unsigned int a = 0; a < pNumPositions; a++) { + const char *tempPointer = reinterpret_cast(pPositions); + const aiVector3D *vec = reinterpret_cast(tempPointer + a * pElementOffset); // store position by index and distance ai_real distance = *vec * mPlaneNormal; - mPositions.push_back( Entry( static_cast(a+initial), *vec, distance)); + mPositions.push_back(Entry(static_cast(a + initial), *vec, distance)); } if (pFinalize) { @@ -125,9 +116,8 @@ void SpatialSort::Append( const aiVector3D* pPositions, unsigned int pNumPositio // ------------------------------------------------------------------------------------------------ // Returns an iterator for all positions close to the given position. -void SpatialSort::FindPositions( const aiVector3D& pPosition, - ai_real pRadius, std::vector& poResults) const -{ +void SpatialSort::FindPositions(const aiVector3D &pPosition, + ai_real pRadius, std::vector &poResults) const { const ai_real dist = pPosition * mPlaneNormal; const ai_real minDist = dist - pRadius, maxDist = dist + pRadius; @@ -135,19 +125,18 @@ void SpatialSort::FindPositions( const aiVector3D& pPosition, poResults.clear(); // quick check for positions outside the range - if( mPositions.size() == 0) + if (mPositions.size() == 0) return; - if( maxDist < mPositions.front().mDistance) + if (maxDist < mPositions.front().mDistance) return; - if( minDist > mPositions.back().mDistance) + if (minDist > mPositions.back().mDistance) return; // do a binary search for the minimal distance to start the iteration there unsigned int index = (unsigned int)mPositions.size() / 2; unsigned int binaryStepSize = (unsigned int)mPositions.size() / 4; - while( binaryStepSize > 1) - { - if( mPositions[index].mDistance < minDist) + while (binaryStepSize > 1) { + if (mPositions[index].mDistance < minDist) index += binaryStepSize; else index -= binaryStepSize; @@ -157,21 +146,20 @@ void SpatialSort::FindPositions( const aiVector3D& pPosition, // depending on the direction of the last step we need to single step a bit back or forth // to find the actual beginning element of the range - while( index > 0 && mPositions[index].mDistance > minDist) + while (index > 0 && mPositions[index].mDistance > minDist) index--; - while( index < (mPositions.size() - 1) && mPositions[index].mDistance < minDist) + while (index < (mPositions.size() - 1) && mPositions[index].mDistance < minDist) index++; // Mow start iterating from there until the first position lays outside of the distance range. // Add all positions inside the distance range within the given radius to the result aray std::vector::const_iterator it = mPositions.begin() + index; - const ai_real pSquared = pRadius*pRadius; - while( it->mDistance < maxDist) - { - if( (it->mPosition - pPosition).SquareLength() < pSquared) - poResults.push_back( it->mIndex); + const ai_real pSquared = pRadius * pRadius; + while (it->mDistance < maxDist) { + if ((it->mPosition - pPosition).SquareLength() < pSquared) + poResults.push_back(it->mIndex); ++it; - if( it == mPositions.end()) + if (it == mPositions.end()) break; } @@ -180,70 +168,71 @@ void SpatialSort::FindPositions( const aiVector3D& pPosition, namespace { - // Binary, signed-integer representation of a single-precision floating-point value. - // IEEE 754 says: "If two floating-point numbers in the same format are ordered then they are - // ordered the same way when their bits are reinterpreted as sign-magnitude integers." - // This allows us to convert all floating-point numbers to signed integers of arbitrary size - // and then use them to work with ULPs (Units in the Last Place, for high-precision - // computations) or to compare them (integer comparisons are faster than floating-point - // comparisons on many platforms). - typedef ai_int BinFloat; +// Binary, signed-integer representation of a single-precision floating-point value. +// IEEE 754 says: "If two floating-point numbers in the same format are ordered then they are +// ordered the same way when their bits are reinterpreted as sign-magnitude integers." +// This allows us to convert all floating-point numbers to signed integers of arbitrary size +// and then use them to work with ULPs (Units in the Last Place, for high-precision +// computations) or to compare them (integer comparisons are faster than floating-point +// comparisons on many platforms). +typedef ai_int BinFloat; - // -------------------------------------------------------------------------------------------- - // Converts the bit pattern of a floating-point number to its signed integer representation. - BinFloat ToBinary( const ai_real & pValue) { +// -------------------------------------------------------------------------------------------- +// Converts the bit pattern of a floating-point number to its signed integer representation. +BinFloat ToBinary(const ai_real &pValue) { - // If this assertion fails, signed int is not big enough to store a float on your platform. - // Please correct the declaration of BinFloat a few lines above - but do it in a portable, - // #ifdef'd manner! - static_assert( sizeof(BinFloat) >= sizeof(ai_real), "sizeof(BinFloat) >= sizeof(ai_real)"); + // If this assertion fails, signed int is not big enough to store a float on your platform. + // Please correct the declaration of BinFloat a few lines above - but do it in a portable, + // #ifdef'd manner! + static_assert(sizeof(BinFloat) >= sizeof(ai_real), "sizeof(BinFloat) >= sizeof(ai_real)"); - #if defined( _MSC_VER) - // If this assertion fails, Visual C++ has finally moved to ILP64. This means that this - // code has just become legacy code! Find out the current value of _MSC_VER and modify - // the #if above so it evaluates false on the current and all upcoming VC versions (or - // on the current platform, if LP64 or LLP64 are still used on other platforms). - static_assert( sizeof(BinFloat) == sizeof(ai_real), "sizeof(BinFloat) == sizeof(ai_real)"); +#if defined(_MSC_VER) + // If this assertion fails, Visual C++ has finally moved to ILP64. This means that this + // code has just become legacy code! Find out the current value of _MSC_VER and modify + // the #if above so it evaluates false on the current and all upcoming VC versions (or + // on the current platform, if LP64 or LLP64 are still used on other platforms). + static_assert(sizeof(BinFloat) == sizeof(ai_real), "sizeof(BinFloat) == sizeof(ai_real)"); - // This works best on Visual C++, but other compilers have their problems with it. - const BinFloat binValue = reinterpret_cast(pValue); - #else - // On many compilers, reinterpreting a float address as an integer causes aliasing - // problems. This is an ugly but more or less safe way of doing it. - union { - ai_real asFloat; - BinFloat asBin; - } conversion; - conversion.asBin = 0; // zero empty space in case sizeof(BinFloat) > sizeof(float) - conversion.asFloat = pValue; - const BinFloat binValue = conversion.asBin; - #endif + // This works best on Visual C++, but other compilers have their problems with it. + const BinFloat binValue = reinterpret_cast(pValue); + //::memcpy(&binValue, &pValue, sizeof(pValue)); + //return binValue; +#else + // On many compilers, reinterpreting a float address as an integer causes aliasing + // problems. This is an ugly but more or less safe way of doing it. + union { + ai_real asFloat; + BinFloat asBin; + } conversion; + conversion.asBin = 0; // zero empty space in case sizeof(BinFloat) > sizeof(float) + conversion.asFloat = pValue; + const BinFloat binValue = conversion.asBin; +#endif - // floating-point numbers are of sign-magnitude format, so find out what signed number - // representation we must convert negative values to. - // See http://en.wikipedia.org/wiki/Signed_number_representations. + // floating-point numbers are of sign-magnitude format, so find out what signed number + // representation we must convert negative values to. + // See http://en.wikipedia.org/wiki/Signed_number_representations. - // Two's complement? - if( (-42 == (~42 + 1)) && (binValue & 0x80000000)) - return BinFloat(1 << (CHAR_BIT * sizeof(BinFloat) - 1)) - binValue; - // One's complement? - else if ( (-42 == ~42) && (binValue & 0x80000000)) - return BinFloat(-0) - binValue; - // Sign-magnitude? - else if( (-42 == (42 | (-0))) && (binValue & 0x80000000)) // -0 = 1000... binary - return binValue; - else - return binValue; - } + // Two's complement? + /*if ((-42 == (~42 + 1)) && (binValue & 0x80000000)) + return BinFloat(1 << (CHAR_BIT * sizeof(BinFloat) - 1)) - binValue; + // One's complement? + else if ((-42 == ~42) && (binValue & 0x80000000)) + return BinFloat(-0) - binValue; + // Sign-magnitude? + else if ((-42 == (42 | (-0))) && (binValue & 0x80000000)) // -0 = 1000... binary + return binValue; + else*/ + + return binValue; +} } // namespace // ------------------------------------------------------------------------------------------------ // Fills an array with indices of all positions identical to the given position. In opposite to // FindPositions(), not an epsilon is used but a (very low) tolerance of four floating-point units. -void SpatialSort::FindIdenticalPositions( const aiVector3D& pPosition, - std::vector& poResults) const -{ +void SpatialSort::FindIdenticalPositions(const aiVector3D &pPosition, std::vector &poResults) const { // Epsilons have a huge disadvantage: they are of constant precision, while floating-point // values are of log2 precision. If you apply e=0.01 to 100, the epsilon is rather small, but // if you apply it to 0.001, it is enormous. @@ -269,20 +258,19 @@ void SpatialSort::FindIdenticalPositions( const aiVector3D& pPosition, // Convert the plane distance to its signed integer representation so the ULPs tolerance can be // applied. For some reason, VC won't optimize two calls of the bit pattern conversion. - const BinFloat minDistBinary = ToBinary( pPosition * mPlaneNormal) - distanceToleranceInULPs; + const BinFloat minDistBinary = ToBinary(pPosition * mPlaneNormal) - distanceToleranceInULPs; const BinFloat maxDistBinary = minDistBinary + 2 * distanceToleranceInULPs; // clear the array in this strange fashion because a simple clear() would also deallocate // the array which we want to avoid - poResults.resize( 0 ); + poResults.resize(0); // do a binary search for the minimal distance to start the iteration there unsigned int index = (unsigned int)mPositions.size() / 2; unsigned int binaryStepSize = (unsigned int)mPositions.size() / 4; - while( binaryStepSize > 1) - { + while (binaryStepSize > 1) { // Ugly, but conditional jumps are faster with integers than with floats - if( minDistBinary > ToBinary(mPositions[index].mDistance)) + if (minDistBinary > ToBinary(mPositions[index].mDistance)) index += binaryStepSize; else index -= binaryStepSize; @@ -292,20 +280,19 @@ void SpatialSort::FindIdenticalPositions( const aiVector3D& pPosition, // depending on the direction of the last step we need to single step a bit back or forth // to find the actual beginning element of the range - while( index > 0 && minDistBinary < ToBinary(mPositions[index].mDistance) ) + while (index > 0 && minDistBinary < ToBinary(mPositions[index].mDistance)) index--; - while( index < (mPositions.size() - 1) && minDistBinary > ToBinary(mPositions[index].mDistance)) + while (index < (mPositions.size() - 1) && minDistBinary > ToBinary(mPositions[index].mDistance)) index++; // Now start iterating from there until the first position lays outside of the distance range. // Add all positions inside the distance range within the tolerance to the result array std::vector::const_iterator it = mPositions.begin() + index; - while( ToBinary(it->mDistance) < maxDistBinary) - { - if( distance3DToleranceInULPs >= ToBinary((it->mPosition - pPosition).SquareLength())) + while (ToBinary(it->mDistance) < maxDistBinary) { + if (distance3DToleranceInULPs >= ToBinary((it->mPosition - pPosition).SquareLength())) poResults.push_back(it->mIndex); ++it; - if( it == mPositions.end()) + if (it == mPositions.end()) break; } @@ -313,22 +300,19 @@ void SpatialSort::FindIdenticalPositions( const aiVector3D& pPosition, } // ------------------------------------------------------------------------------------------------ -unsigned int SpatialSort::GenerateMappingTable(std::vector& fill, ai_real pRadius) const -{ - fill.resize(mPositions.size(),UINT_MAX); +unsigned int SpatialSort::GenerateMappingTable(std::vector &fill, ai_real pRadius) const { + fill.resize(mPositions.size(), UINT_MAX); ai_real dist, maxDist; - unsigned int t=0; - const ai_real pSquared = pRadius*pRadius; + unsigned int t = 0; + const ai_real pSquared = pRadius * pRadius; for (size_t i = 0; i < mPositions.size();) { dist = mPositions[i].mPosition * mPlaneNormal; maxDist = dist + pRadius; fill[mPositions[i].mIndex] = t; - const aiVector3D& oldpos = mPositions[i].mPosition; - for (++i; i < fill.size() && mPositions[i].mDistance < maxDist - && (mPositions[i].mPosition - oldpos).SquareLength() < pSquared; ++i) - { + const aiVector3D &oldpos = mPositions[i].mPosition; + for (++i; i < fill.size() && mPositions[i].mDistance < maxDist && (mPositions[i].mPosition - oldpos).SquareLength() < pSquared; ++i) { fill[mPositions[i].mIndex] = t; } ++t; @@ -338,7 +322,7 @@ unsigned int SpatialSort::GenerateMappingTable(std::vector& fill, // debug invariant: mPositions[i].mIndex values must range from 0 to mPositions.size()-1 for (size_t i = 0; i < fill.size(); ++i) { - ai_assert(fill[i] #include +#include namespace Assimp { @@ -62,10 +62,8 @@ namespace Assimp { * time, with O(n) worst case complexity when all vertices lay on the plane. The plane is chosen * so that it avoids common planes in usual data sets. */ // ------------------------------------------------------------------------------------------------ -class ASSIMP_API SpatialSort -{ +class ASSIMP_API SpatialSort { public: - SpatialSort(); // ------------------------------------------------------------------------------------ @@ -76,14 +74,12 @@ public: * @param pNumPositions Number of vectors to expect in that array. * @param pElementOffset Offset in bytes from the beginning of one vector in memory * to the beginning of the next vector. */ - SpatialSort( const aiVector3D* pPositions, unsigned int pNumPositions, - unsigned int pElementOffset); + SpatialSort(const aiVector3D *pPositions, unsigned int pNumPositions, + unsigned int pElementOffset); /** Destructor */ ~SpatialSort(); -public: - // ------------------------------------------------------------------------------------ /** Sets the input data for the SpatialSort. This replaces existing data, if any. * The new data receives new indices in ascending order. @@ -97,17 +93,15 @@ public: * required in order to use #FindPosition() or #GenerateMappingTable(). * If you don't finalize yet, you can use #Append() to add data from * other sources.*/ - void Fill( const aiVector3D* pPositions, unsigned int pNumPositions, - unsigned int pElementOffset, - bool pFinalize = true); - + void Fill(const aiVector3D *pPositions, unsigned int pNumPositions, + unsigned int pElementOffset, + bool pFinalize = true); // ------------------------------------------------------------------------------------ /** Same as #Fill(), except the method appends to existing data in the #SpatialSort. */ - void Append( const aiVector3D* pPositions, unsigned int pNumPositions, - unsigned int pElementOffset, - bool pFinalize = true); - + void Append(const aiVector3D *pPositions, unsigned int pNumPositions, + unsigned int pElementOffset, + bool pFinalize = true); // ------------------------------------------------------------------------------------ /** Finalize the spatial hash data structure. This can be useful after @@ -123,8 +117,8 @@ public: * @param poResults The container to store the indices of the found positions. * Will be emptied by the call so it may contain anything. * @return An iterator to iterate over all vertices in the given area.*/ - void FindPositions( const aiVector3D& pPosition, ai_real pRadius, - std::vector& poResults) const; + void FindPositions(const aiVector3D &pPosition, ai_real pRadius, + std::vector &poResults) const; // ------------------------------------------------------------------------------------ /** Fills an array with indices of all positions identical to the given position. In @@ -133,8 +127,8 @@ public: * @param pPosition The position to look for vertices. * @param poResults The container to store the indices of the found positions. * Will be emptied by the call so it may contain anything.*/ - void FindIdenticalPositions( const aiVector3D& pPosition, - std::vector& poResults) const; + void FindIdenticalPositions(const aiVector3D &pPosition, + std::vector &poResults) const; // ------------------------------------------------------------------------------------ /** Compute a table that maps each vertex ID referring to a spatially close @@ -144,8 +138,8 @@ public: * @param pRadius Maximal distance from the position a vertex may have to * be counted in. * @return Number of unique vertices (n). */ - unsigned int GenerateMappingTable(std::vector& fill, - ai_real pRadius) const; + unsigned int GenerateMappingTable(std::vector &fill, + ai_real pRadius) const; protected: /** Normal of the sorting plane, normalized. The center is always at (0, 0, 0) */ @@ -159,15 +153,17 @@ protected: ai_real mDistance; ///< Distance of this vertex to the sorting plane Entry() AI_NO_EXCEPT - : mIndex( 999999999 ), mPosition(), mDistance( 99999. ) { - // empty + : mIndex(999999999), + mPosition(), + mDistance(99999.) { + // empty } - Entry( unsigned int pIndex, const aiVector3D& pPosition, ai_real pDistance) - : mIndex( pIndex), mPosition( pPosition), mDistance( pDistance) { + Entry(unsigned int pIndex, const aiVector3D &pPosition, ai_real pDistance) : + mIndex(pIndex), mPosition(pPosition), mDistance(pDistance) { // empty } - bool operator < (const Entry& e) const { return mDistance < e.mDistance; } + bool operator<(const Entry &e) const { return mDistance < e.mDistance; } }; // all positions, sorted by distance to the sorting plane diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index fac246d68..bf6694845 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -86,6 +86,7 @@ SET( COMMON unit/utStringUtils.cpp unit/Common/uiScene.cpp unit/Common/utLineSplitter.cpp + unit/Common/utSpatialSort.cpp ) SET( IMPORTERS diff --git a/test/unit/Common/utSpatialSort.cpp b/test/unit/Common/utSpatialSort.cpp new file mode 100644 index 000000000..0783cf5e2 --- /dev/null +++ b/test/unit/Common/utSpatialSort.cpp @@ -0,0 +1,84 @@ +/* +--------------------------------------------------------------------------- +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 "UnitTestPCH.h" + +#include + +using namespace Assimp; + +class utSpatialSort : public ::testing::Test { +public + : + aiVector3D *vecs; + +protected: + void SetUp() override { + ::srand(static_cast(time(0))); + vecs = new aiVector3D[100]; + for (size_t i = 0; i < 100; ++i) { + vecs[i].x = static_cast(rand()) / (static_cast(RAND_MAX / 100)); + vecs[i].y = static_cast(rand()) / (static_cast(RAND_MAX / 100)); + vecs[i].z = static_cast(rand()) / (static_cast(RAND_MAX / 100)); + } + } + + void TearDown() override { + delete[] vecs; + } +}; + +TEST_F( utSpatialSort, findIdenticalsTest ) { + SpatialSort sSort; + sSort.Fill(vecs, 100, sizeof(aiVector3D)); + + std::vector indices; + sSort.FindIdenticalPositions(vecs[0], indices); + EXPECT_EQ(1u, indices.size()); +} + +TEST_F(utSpatialSort, findPositionsTest) { + SpatialSort sSort; + sSort.Fill(vecs, 100, sizeof(aiVector3D)); + + std::vector indices; + sSort.FindPositions(vecs[0], 0.01f, indices); + EXPECT_EQ(1u, indices.size()); +} diff --git a/test/unit/utStringUtils.cpp b/test/unit/utStringUtils.cpp index c5493c502..cb91897e3 100644 --- a/test/unit/utStringUtils.cpp +++ b/test/unit/utStringUtils.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, From 6c1e21d7548b4e36c5213aa0d40718161d89448b Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Sun, 26 Apr 2020 19:14:30 +0200 Subject: [PATCH 03/33] fix formatting. --- code/Common/SceneCombiner.cpp | 3 +- code/Common/SpatialSort.cpp | 23 +- test/unit/utImporter.cpp | 1381 ++------------------------------- 3 files changed, 77 insertions(+), 1330 deletions(-) diff --git a/code/Common/SceneCombiner.cpp b/code/Common/SceneCombiner.cpp index 29b6082a8..b7511ff4e 100644 --- a/code/Common/SceneCombiner.cpp +++ b/code/Common/SceneCombiner.cpp @@ -994,8 +994,7 @@ void SceneCombiner::CopySceneFlat(aiScene** _dest,const aiScene* src) { } else { *_dest = new aiScene(); } - - ::memcpy(*_dest,src,sizeof(aiScene)); + CopyScene(_dest, src, false); } // ------------------------------------------------------------------------------------------------ diff --git a/code/Common/SpatialSort.cpp b/code/Common/SpatialSort.cpp index 352a36fba..2bf6ce2e2 100644 --- a/code/Common/SpatialSort.cpp +++ b/code/Common/SpatialSort.cpp @@ -51,13 +51,9 @@ using namespace Assimp; #define CHAR_BIT 8 #endif -#ifdef _WIN32 -//# pragma warning(disable : 4127) -#endif // _WIN32 +const aiVector3D PlaneInit(0.8523f, 0.34321f, 0.5736f); -const aiVector3D PlaneInit( 0.8523f, 0.34321f, 0.5736f ); - - // ------------------------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------------------------ // Constructs a spatially sorted representation from the given position array. // define the reference plane. We choose some arbitrary vector away from all basic axises // in the hope that no model spreads all its vertices along this plane. @@ -214,17 +210,20 @@ BinFloat ToBinary(const ai_real &pValue) { // See http://en.wikipedia.org/wiki/Signed_number_representations. // Two's complement? - /*if ((-42 == (~42 + 1)) && (binValue & 0x80000000)) + bool DefaultValue = ((-42 == (~42 + 1)) && (binValue & 0x80000000)); + bool OneComplement = ((-42 == ~42) && (binValue & 0x80000000)); + bool SignedMagnitude = ((-42 == (42 | (-0))) && (binValue & 0x80000000)); + + if (DefaultValue) return BinFloat(1 << (CHAR_BIT * sizeof(BinFloat) - 1)) - binValue; // One's complement? - else if ((-42 == ~42) && (binValue & 0x80000000)) + else if (OneComplement) return BinFloat(-0) - binValue; // Sign-magnitude? - else if ((-42 == (42 | (-0))) && (binValue & 0x80000000)) // -0 = 1000... binary + else if (SignedMagnitude) // -0 = 1000... binary + return binValue; + else return binValue; - else*/ - - return binValue; } } // namespace diff --git a/test/unit/utImporter.cpp b/test/unit/utImporter.cpp index c559819a2..0be0037df 100644 --- a/test/unit/utImporter.cpp +++ b/test/unit/utImporter.cpp @@ -51,1335 +51,84 @@ using namespace ::std; using namespace ::Assimp; class ImporterTest : public ::testing::Test { -public: - virtual void SetUp() { +protected: + void SetUp() override { pImp = new Importer(); } - virtual void TearDown() { + void TearDown() override { delete pImp; } -protected: Importer *pImp; }; #define InputData_BLOCK_SIZE 1310 +// clang-format off // test data for Importer::ReadFileFromMemory() - ./test/3DS/CameraRollAnim.3ds static unsigned char InputData_abRawBlock[1310] = { - 77, - 77, - 30, - 5, - 0, - 0, - 2, - 0, - 10, - 0, - 0, - 0, - 3, - 0, - 0, - 0, - 61, - 61, - 91, - 3, - 0, - 0, - 62, - 61, - 10, - 0, - 0, - 0, - 3, - 0, - 0, - 0, - 0, - 1, - 10, - 0, - 0, - 0, - 0, - 0, - 128, - 63, - 0, - 64, - 254, - 2, - 0, - 0, - 66, - 111, - 120, - 48, - 49, - 0, - 0, - 65, - 242, - 2, - 0, - 0, - 16, - 65, - 64, - 1, - 0, - 0, - 26, - 0, - 102, - 74, - 198, - 193, - 102, - 74, - 198, - 193, - 0, - 0, - 0, - 0, - 205, - 121, - 55, - 66, - 102, - 74, - 198, - 193, - 0, - 0, - 0, - 0, - 102, - 74, - 198, - 193, - 138, - 157, - 184, - 65, - 0, - 0, - 0, - 0, - 205, - 121, - 55, - 66, - 138, - 157, - 184, - 65, - 0, - 0, - 0, - 0, - 102, - 74, - 198, - 193, - 102, - 74, - 198, - 193, - 90, - 252, - 26, - 66, - 205, - 121, - 55, - 66, - 102, - 74, - 198, - 193, - 90, - 252, - 26, - 66, - 102, - 74, - 198, - 193, - 138, - 157, - 184, - 65, - 90, - 252, - 26, - 66, - 205, - 121, - 55, - 66, - 138, - 157, - 184, - 65, - 90, - 252, - 26, - 66, - 102, - 74, - 198, - 193, - 102, - 74, - 198, - 193, - 0, - 0, - 0, - 0, - 205, - 121, - 55, - 66, - 102, - 74, - 198, - 193, - 0, - 0, - 0, - 0, - 205, - 121, - 55, - 66, - 102, - 74, - 198, - 193, - 90, - 252, - 26, - 66, - 205, - 121, - 55, - 66, - 102, - 74, - 198, - 193, - 90, - 252, - 26, - 66, - 102, - 74, - 198, - 193, - 102, - 74, - 198, - 193, - 90, - 252, - 26, - 66, - 102, - 74, - 198, - 193, - 102, - 74, - 198, - 193, - 0, - 0, - 0, - 0, - 205, - 121, - 55, - 66, - 138, - 157, - 184, - 65, - 0, - 0, - 0, - 0, - 205, - 121, - 55, - 66, - 102, - 74, - 198, - 193, - 90, - 252, - 26, - 66, - 205, - 121, - 55, - 66, - 138, - 157, - 184, - 65, - 0, - 0, - 0, - 0, - 102, - 74, - 198, - 193, - 138, - 157, - 184, - 65, - 0, - 0, - 0, - 0, - 102, - 74, - 198, - 193, - 138, - 157, - 184, - 65, - 90, - 252, - 26, - 66, - 102, - 74, - 198, - 193, - 138, - 157, - 184, - 65, - 90, - 252, - 26, - 66, - 205, - 121, - 55, - 66, - 138, - 157, - 184, - 65, - 90, - 252, - 26, - 66, - 205, - 121, - 55, - 66, - 138, - 157, - 184, - 65, - 0, - 0, - 0, - 0, - 102, - 74, - 198, - 193, - 138, - 157, - 184, - 65, - 0, - 0, - 0, - 0, - 102, - 74, - 198, - 193, - 102, - 74, - 198, - 193, - 90, - 252, - 26, - 66, - 102, - 74, - 198, - 193, - 102, - 74, - 198, - 193, - 90, - 252, - 26, - 66, - 102, - 74, - 198, - 193, - 138, - 157, - 184, - 65, - 0, - 0, - 0, - 0, - 64, - 65, - 216, - 0, - 0, - 0, - 26, - 0, - 0, - 0, - 128, - 63, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 128, - 63, - 0, - 0, - 128, - 63, - 0, - 0, - 0, - 0, - 0, - 0, - 128, - 63, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 128, - 63, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 128, - 63, - 0, - 0, - 128, - 63, - 0, - 0, - 128, - 63, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 128, - 63, - 0, - 0, - 0, - 0, - 0, - 0, - 128, - 63, - 0, - 0, - 128, - 63, - 0, - 0, - 128, - 63, - 0, - 0, - 128, - 63, - 0, - 0, - 0, - 0, - 0, - 0, - 128, - 63, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 128, - 63, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 128, - 63, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 128, - 63, - 0, - 0, - 0, - 0, - 0, - 0, - 128, - 63, - 0, - 0, - 128, - 63, - 0, - 0, - 128, - 63, - 0, - 0, - 128, - 63, - 0, - 0, - 0, - 0, - 0, - 0, - 128, - 63, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 128, - 63, - 0, - 0, - 128, - 63, - 0, - 0, - 128, - 63, - 0, - 0, - 128, - 63, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 96, - 65, - 54, - 0, - 0, - 0, - 0, - 0, - 128, - 63, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 128, - 63, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 128, - 63, - 53, - 169, - 40, - 65, - 176, - 205, - 90, - 191, - 0, - 0, - 0, - 0, - 32, - 65, - 158, - 0, - 0, - 0, - 12, - 0, - 0, - 0, - 2, - 0, - 3, - 0, - 6, - 0, - 3, - 0, - 1, - 0, - 0, - 0, - 6, - 0, - 4, - 0, - 5, - 0, - 7, - 0, - 6, - 0, - 7, - 0, - 6, - 0, - 4, - 0, - 6, - 0, - 8, - 0, - 9, - 0, - 10, - 0, - 6, - 0, - 11, - 0, - 12, - 0, - 13, - 0, - 6, - 0, - 1, - 0, - 14, - 0, - 7, - 0, - 6, - 0, - 7, - 0, - 15, - 0, - 1, - 0, - 6, - 0, - 16, - 0, - 17, - 0, - 18, - 0, - 6, - 0, - 19, - 0, - 20, - 0, - 21, - 0, - 6, - 0, - 22, - 0, - 0, - 0, - 23, - 0, - 6, - 0, - 24, - 0, - 6, - 0, - 25, - 0, - 6, - 0, - 80, - 65, - 54, - 0, - 0, - 0, - 2, - 0, - 0, - 0, - 2, - 0, - 0, - 0, - 4, - 0, - 0, - 0, - 4, - 0, - 0, - 0, - 8, - 0, - 0, - 0, - 8, - 0, - 0, - 0, - 16, - 0, - 0, - 0, - 16, - 0, - 0, - 0, - 32, - 0, - 0, - 0, - 32, - 0, - 0, - 0, - 64, - 0, - 0, - 0, - 64, - 0, - 0, - 0, - 0, - 64, - 67, - 0, - 0, - 0, - 67, - 97, - 109, - 101, - 114, - 97, - 48, - 49, - 0, - 0, - 71, - 52, - 0, - 0, - 0, - 189, - 19, - 25, - 195, - 136, - 104, - 81, - 64, - 147, - 56, - 182, - 65, - 96, - 233, - 20, - 194, - 67, - 196, - 97, - 190, - 147, - 56, - 182, - 65, - 0, - 0, - 0, - 0, - 85, - 85, - 85, - 66, - 32, - 71, - 14, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 122, - 68, - 0, - 176, - 179, - 1, - 0, - 0, - 10, - 176, - 21, - 0, - 0, - 0, - 5, - 0, - 77, - 65, - 88, - 83, - 67, - 69, - 78, - 69, - 0, - 44, - 1, - 0, - 0, - 8, - 176, - 14, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 44, - 1, - 0, - 0, - 9, - 176, - 10, - 0, - 0, - 0, - 128, - 2, - 0, - 0, - 2, - 176, - 168, - 0, - 0, - 0, - 48, - 176, - 8, - 0, - 0, - 0, - 0, - 0, - 16, - 176, - 18, - 0, - 0, - 0, - 66, - 111, - 120, - 48, - 49, - 0, - 0, - 64, - 0, - 0, - 255, - 255, - 19, - 176, - 18, - 0, - 0, - 0, - 0, - 0, - 0, - 128, - 0, - 0, - 0, - 128, - 0, - 0, - 0, - 128, - 32, - 176, - 38, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 1, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 53, - 169, - 40, - 65, - 176, - 205, - 90, - 191, - 0, - 0, - 0, - 0, - 33, - 176, - 42, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 1, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 34, - 176, - 38, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 1, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 128, - 63, - 0, - 0, - 128, - 63, - 0, - 0, - 128, - 63, - 3, - 176, - 143, - 0, - 0, - 0, - 48, - 176, - 8, - 0, - 0, - 0, - 1, - 0, - 16, - 176, - 21, - 0, - 0, - 0, - 67, - 97, - 109, - 101, - 114, - 97, - 48, - 49, - 0, - 0, - 64, - 0, - 0, - 255, - 255, - 32, - 176, - 38, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 1, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 189, - 19, - 25, - 195, - 136, - 104, - 81, - 64, - 147, - 56, - 182, - 65, - 35, - 176, - 30, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 1, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 52, - 66, - 36, - 176, - 40, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 120, - 0, - 0, - 0, - 2, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 120, - 13, - 90, - 189, - 120, - 0, - 0, - 0, - 0, - 0, - 99, - 156, - 154, - 194, - 4, - 176, - 73, - 0, - 0, - 0, - 48, - 176, - 8, - 0, - 0, - 0, - 2, - 0, - 16, - 176, - 21, - 0, - 0, - 0, - 67, - 97, - 109, - 101, - 114, - 97, - 48, - 49, - 0, - 0, - 64, - 0, - 0, - 255, - 255, - 32, - 176, - 38, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 1, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - 96, - 233, - 20, - 194, - 67, - 196, - 97, - 190, - 147, - 56, - 182, - 65, -}; - + 77, 77, 30, 5, 0, 0, 2, 0, 10, 0, 0, 0, 3, 0, 0, 0, 61, 61, 91, 3, 0, 0, + 62, 61, 10, 0, 0, 0, 3, 0, 0, 0, 0, 1, 10, 0, 0, 0, 0, 0,128, 63, 0, 64, + 254, 2, 0, 0, 66,111,120, 48, 49, 0, 0, 65,242, 2, 0, 0, 16, 65, 64, 1, 0, 0, + 26, 0,102, 74,198,193,102, 74,198,193, 0, 0, 0, 0,205,121, 55, 66,102, 74,198,193, + 0, 0, 0, 0,102, 74,198,193,138,157,184, 65, 0, 0, 0, 0,205,121, 55, 66,138,157, + 184, 65, 0, 0, 0, 0,102, 74,198,193,102, 74,198,193, 90,252, 26, 66,205,121, 55, 66, + 102, 74,198,193, 90,252, 26, 66,102, 74,198,193,138,157,184, 65, 90,252, 26, 66,205,121, + 55, 66,138,157,184, 65, 90,252, 26, 66,102, 74,198,193,102, 74,198,193, 0, 0, 0, 0, + 205,121, 55, 66,102, 74,198,193, 0, 0, 0, 0,205,121, 55, 66,102, 74,198,193, 90,252, + 26, 66,205,121, 55, 66,102, 74,198,193, 90,252, 26, 66,102, 74,198,193,102, 74,198,193, + 90, 252, 26, 66,102, 74,198,193,102, 74,198,193, 0, 0, 0, 0,205,121, 55, 66,138,157, + 184, 65, 0, 0, 0, 0,205,121, 55, 66,102, 74,198,193, 90,252, 26, 66,205,121, 55, 66, + 138,157,184, 65, 0, 0, 0, 0,102, 74,198,193,138,157,184, 65, 0, 0, 0, 0,102, 74, + 198,193,138,157,184, 65, 90,252, 26, 66,102, 74,198,193,138,157,184, 65, 90,252, 26, 66, + 205,121, 55, 66,138,157,184, 65, 90,252, 26, 66,205,121, 55, 66,138,157,184, 65, 0, 0, + 0, 0,102, 74,198,193,138,157,184, 65, 0, 0, 0, 0,102, 74,198,193,102, 74,198,193, + 90,252, 26, 66,102, 74,198,193,102, 74,198,193, 90,252, 26, 66,102, 74,198,193,138,157, + 184, 65, 0, 0, 0, 0, 64, 65,216, 0, 0, 0, 26, 0, 0, 0,128, 63, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,128, 63, 0, 0,128, 63, 0, 0, 0, 0, 0, 0, + 128, 63, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,128, 63, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0,128, 63, 0, 0,128, 63, 0, 0,128, 63, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 128, 63, 0, 0, 0, 0, 0, 0,128, 63, 0, 0,128, 63, 0, 0,128, 63, 0, 0,128, 63, + 0, 0, 0, 0, 0, 0,128, 63, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,128, 63, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0,128, 63, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,128, 63, + 0, 0, 0, 0, 0, 0,128, 63, 0, 0,128, 63, 0, 0,128, 63, 0, 0,128, 63, 0, 0, + 0, 0, 0, 0,128, 63, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0,128, 63, 0, 0,128, 63, 0, 0,128, 63, 0, 0,128, 63, 0, 0, 0, 0, 0, 0, + 0, 0, 96, 65, 54, 0, 0, 0, 0, 0,128, 63, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0,128, 63, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,128, 63, + 53,169, 40, 65,176,205, 90,191, 0, 0, 0, 0, 32, 65,158, 0, 0, 0, 12, 0, 0, 0, + 2, 0, 3, 0, 6, 0, 3, 0, 1, 0, 0, 0, 6, 0, 4, 0, 5, 0, 7, 0, 6, 0, + 7, 0, 6, 0, 4, 0, 6, 0, 8, 0, 9, 0, 10, 0, 6, 0, 11, 0, 12, 0, 13, 0, + 6, 0, 1, 0, 14, 0, 7, 0, 6, 0, 7, 0, 15, 0, 1, 0, 6, 0, 16, 0, 17, 0, + 18, 0, 6, 0, 19, 0, 20, 0, 21, 0, 6, 0, 22, 0, 0, 0, 23, 0, 6, 0, 24, 0, + 6, 0, 25, 0, 6, 0, 80, 65, 54, 0, 0, 0, 2, 0, 0, 0, 2, 0, 0, 0, 4, 0, + 0, 0, 4, 0, 0, 0, 8, 0, 0, 0, 8, 0, 0, 0, 16, 0, 0, 0, 16, 0, 0, 0, + 32, 0, 0, 0, 32, 0, 0, 0, 64, 0, 0, 0, 64, 0, 0, 0, 0, 64, 67, 0, 0, 0, + 67, 97,109,101,114, 97, 48, 49, 0, 0, 71, 52, 0, 0, 0,189, 19, 25,195,136,104, 81, + 64,147, 56,182, 65, 96,233, 20,194, 67,196, 97,190,147, 56,182, 65, 0, 0, 0, 0, 85, + 85, 85, 66, 32, 71, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0,122, 68, 0,176,179, 1, 0, + 0, 10,176, 21, 0, 0, 0, 5, 0, 77, 65, 88, 83, 67, 69, 78, 69, 0, 44, 1, 0, 0, + 8,176, 14, 0, 0, 0, 0, 0, 0, 0, 44, 1, 0, 0, 9,176, 10, 0, 0, 0,128, 2, + 0, 0, 2,176,168, 0, 0, 0, 48,176, 8, 0, 0, 0, 0, 0, 16,176, 18, 0, 0, 0, + 66,111,120, 48, 49, 0, 0, 64, 0, 0,255,255, 19,176, 18, 0, 0, 0, 0, 0, 0,128, + 0, 0, 0,128, 0, 0, 0,128, 32,176, 38, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 53,169, 40, 65,176,205, 90,191, 0, 0, + 0, 0, 33,176, 42, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 34,176, 38, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0,128, 63, 0, 0,128, 63, 0, 0,128, 63, 3,176,143, 0, 0, 0, + 48,176, 8, 0, 0, 0, 1, 0, 16,176, 21, 0, 0, 0, 67, 97,109,101,114, 97, 48, 49, + 0, 0, 64, 0, 0,255,255, 32,176, 38, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,189, 19, 25,195,136,104, 81, 64,147, 56,182, + 65, 35,176, 30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 52, 66, 36,176, 40, 0, 0, 0, 0, 0, 0, 0, 0, 0,120, + 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0,120, 13, 90,189,120, 0, 0, 0, 0, + 0, 99,156,154,194, 4,176, 73, 0, 0, 0, 48,176, 8, 0, 0, 0, 2, 0, 16,176, 21, + 0, 0, 0, 67, 97,109,101,114, 97, 48, 49, 0, 0, 64, 0, 0,255,255, 32,176, 38, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 96,233, 20,194, 67,196, 97,190,147, 56,182, 65 }; +// clang-format on #define AIUT_DEF_ERROR_TEXT "sorry, this is a test" static const aiImporterDesc desc = { From d98787f35bdb7d9385f619e3130b7d445cda71ba Mon Sep 17 00:00:00 2001 From: luca <681992+lukka@users.noreply.github.com> Date: Sun, 26 Apr 2020 12:19:59 -0700 Subject: [PATCH 04/33] CI: use clang on Unix, msvc on Windows;Remove explicit flags in CMakeLists.txt; --- .github/workflows/ccpp.yml | 72 +++++++++++++++++++++----------------- CMakeLists.txt | 6 ++-- code/glTF/glTFAsset.h | 7 +++- code/glTF2/glTF2Asset.h | 8 ++++- 4 files changed, 55 insertions(+), 38 deletions(-) diff --git a/.github/workflows/ccpp.yml b/.github/workflows/ccpp.yml index 60bfba170..dca0c3bea 100644 --- a/.github/workflows/ccpp.yml +++ b/.github/workflows/ccpp.yml @@ -7,40 +7,46 @@ on: branches: [ master ] jobs: - linux: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - name: configure - run: cmake CMakeLists.txt - - name: build - run: cmake --build . - - name: test - run: cd bin && ./unit - - mac: - runs-on: macos-latest - - steps: - - uses: actions/checkout@v2 - - name: configure - run: cmake CMakeLists.txt - - name: build - run: cmake --build . - - name: test - run: cd bin && ./unit + job: + name: ${{ matrix.os }}-build-and-test + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + # For Windows msvc, for Linux and macOS let's use the clang compiler + include: + - os: windows-latest + cxx: cl.exe + cc: cl.exe + - os: ubuntu-latest + cxx: clang++ + cc: clang + - os: macos-latest + cxx: clang++ + cc: clang - windows: - runs-on: windows-latest - steps: - uses: actions/checkout@v2 - - name: configure - run: cmake CMakeLists.txt - - name: build - run: cmake --build . --config Release + + - uses: lukka/get-cmake@latest + + - uses: ilammy/msvc-dev-cmd@v1 + + - uses: lukka/set-shell-env@v1 + with: + CXX: ${{ matrix.cxx }} + CC: ${{ matrix.cc }} + + - name: configure and build + uses: lukka/run-cmake@v2 + with: + cmakeListsOrSettingsJson: CMakeListsTxtAdvanced + cmakeListsTxtPath: '${{ github.workspace }}/CMakeLists.txt' + cmakeAppendedArgs: '-GNinja -DCMAKE_BUILD_TYPE=Release' + buildWithCMakeArgs: '-- -v' + buildDirectory: '${{ github.workspace }}/build/' + - name: test - run: | - cd bin\Release - .\unit + run: cd build/bin && ./unit + shell: bash diff --git a/CMakeLists.txt b/CMakeLists.txt index 3bfd5800f..d15e58dd4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -267,10 +267,10 @@ ELSEIF(MSVC) SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /D_DEBUG /Zi /Od") ELSEIF ( "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" ) IF(NOT ASSIMP_HUNTER_ENABLED) - SET(CMAKE_CXX_FLAGS "-fPIC -std=c++11 ${CMAKE_CXX_FLAGS}") - SET(CMAKE_C_FLAGS "-fPIC ${CMAKE_C_FLAGS}") + SET(CMAKE_CXX_STANDARD 11) + SET(CMAKE_POSITION_INDEPENDENT_CODE ON) ENDIF() - SET(CMAKE_CXX_FLAGS "-g -fvisibility=hidden -fno-strict-aliasing -Wall -Wno-long-long ${CMAKE_CXX_FLAGS}" ) + SET(CMAKE_CXX_FLAGS "-fvisibility=hidden -fno-strict-aliasing -Wall -Wno-long-long ${CMAKE_CXX_FLAGS}" ) SET(CMAKE_C_FLAGS "-fno-strict-aliasing ${CMAKE_C_FLAGS}") ELSEIF( CMAKE_COMPILER_IS_MINGW ) IF (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.0) diff --git a/code/glTF/glTFAsset.h b/code/glTF/glTFAsset.h index cd2e3166b..9673624f5 100644 --- a/code/glTF/glTFAsset.h +++ b/code/glTF/glTFAsset.h @@ -382,7 +382,12 @@ namespace glTF { friend struct Accessor; - Accessor& accessor; + // This field is reported as not used, making it protectd is the easiest way to work around it without going to the bottom of what the problem is: + // ../code/glTF2/glTF2Asset.h:392:19: error: private field 'accessor' is not used [-Werror,-Wunused-private-field] + protected: + Accessor &accessor; + + private: uint8_t* data; size_t elemSize, stride; diff --git a/code/glTF2/glTF2Asset.h b/code/glTF2/glTF2Asset.h index a78d6b53a..f9add768e 100644 --- a/code/glTF2/glTF2Asset.h +++ b/code/glTF2/glTF2Asset.h @@ -389,12 +389,18 @@ struct Accessor : public Object { class Indexer { friend struct Accessor; + // This field is reported as not used, making it protectd is the easiest way to work around it without going to the bottom of what the problem is: + // ../code/glTF2/glTF2Asset.h:392:19: error: private field 'accessor' is not used [-Werror,-Wunused-private-field] + protected: Accessor &accessor; + + private: uint8_t *data; size_t elemSize, stride; Indexer(Accessor &acc); - + + public: //! Accesses the i-th value as defined by the accessor template From 4c3aee1968c9fdb8f01d3da5850b1550df959607 Mon Sep 17 00:00:00 2001 From: kimkulling Date: Mon, 27 Apr 2020 12:54:17 +0200 Subject: [PATCH 05/33] add opencollective to funding --- .github/FUNDING.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index e0c2bec9e..84e3123fe 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1,2 +1,3 @@ patreon: assimp custom: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=4JRJVPXC4QJM4 +open_collective: assimp From 7db73182b025a079f27c4dc5e63e7afd1257ece2 Mon Sep 17 00:00:00 2001 From: luca <681992+lukka@users.noreply.github.com> Date: Mon, 27 Apr 2020 09:51:02 -0700 Subject: [PATCH 06/33] enable gcc build on Linux --- .github/workflows/ccpp.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ccpp.yml b/.github/workflows/ccpp.yml index dca0c3bea..ccfe31db3 100644 --- a/.github/workflows/ccpp.yml +++ b/.github/workflows/ccpp.yml @@ -8,13 +8,13 @@ on: jobs: job: - name: ${{ matrix.os }}-build-and-test + name: ${{ matrix.os }}-${{ matrix.cxx }}-build-and-test runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: os: [ubuntu-latest, macos-latest, windows-latest] - # For Windows msvc, for Linux and macOS let's use the clang compiler + # For Windows msvc, for Linux and macOS let's use the clang compiler, use gcc for Linux. include: - os: windows-latest cxx: cl.exe @@ -22,6 +22,9 @@ jobs: - os: ubuntu-latest cxx: clang++ cc: clang + - os: ubuntu-latest + cxx: g++ + cc: gcc - os: macos-latest cxx: clang++ cc: clang From 603a1200a2e0e7bcd0a60744c0c75501db786408 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Mon, 27 Apr 2020 19:51:59 +0200 Subject: [PATCH 07/33] add gcc build target --- .github/workflows/ccpp.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ccpp.yml b/.github/workflows/ccpp.yml index dca0c3bea..bdc6c9ec0 100644 --- a/.github/workflows/ccpp.yml +++ b/.github/workflows/ccpp.yml @@ -19,9 +19,12 @@ jobs: - os: windows-latest cxx: cl.exe cc: cl.exe - - os: ubuntu-latest + - os: ubuntu-latest.clang cxx: clang++ cc: clang + - os: ubuntu-latest.gcc + cxx: g++ + cc: gcc - os: macos-latest cxx: clang++ cc: clang From c1c80801438d913b59a093d3bc043f5e97b15b39 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Mon, 27 Apr 2020 19:55:58 +0200 Subject: [PATCH 08/33] Use correct name --- .github/workflows/ccpp.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ccpp.yml b/.github/workflows/ccpp.yml index bdc6c9ec0..f61d99bb8 100644 --- a/.github/workflows/ccpp.yml +++ b/.github/workflows/ccpp.yml @@ -19,10 +19,10 @@ jobs: - os: windows-latest cxx: cl.exe cc: cl.exe - - os: ubuntu-latest.clang + - os: ubuntu-latest cxx: clang++ cc: clang - - os: ubuntu-latest.gcc + - os: ubuntu-latest cxx: g++ cc: gcc - os: macos-latest From 625cc9d096f59ff79c872ef3d7e1e5a1658ead0e Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Mon, 27 Apr 2020 21:30:06 +0200 Subject: [PATCH 09/33] Remove useless comparison --- contrib/irrXML/irrString.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/contrib/irrXML/irrString.h b/contrib/irrXML/irrString.h index 1abf22b78..246348891 100644 --- a/contrib/irrXML/irrString.h +++ b/contrib/irrXML/irrString.h @@ -635,9 +635,6 @@ private: s32 amount = used < new_size ? used : new_size; for (s32 i=0; i Date: Mon, 27 Apr 2020 22:39:13 -0700 Subject: [PATCH 10/33] build on Linux with gcc and clang; warning as error only for 'assimp' target --- .github/workflows/ccpp.yml | 18 +++++++++++------- CMakeLists.txt | 14 +++----------- code/ASE/ASEParser.cpp | 4 ++-- code/Blender/BlenderBMesh.cpp | 1 + code/CApi/AssimpCExport.cpp | 6 +++--- code/CMakeLists.txt | 7 +++++++ code/Common/SceneCombiner.cpp | 22 +++++++++++----------- code/M3D/m3d.h | 6 +++--- contrib/irrXML/irrString.h | 3 --- 9 files changed, 41 insertions(+), 40 deletions(-) diff --git a/.github/workflows/ccpp.yml b/.github/workflows/ccpp.yml index ccfe31db3..08292d55f 100644 --- a/.github/workflows/ccpp.yml +++ b/.github/workflows/ccpp.yml @@ -13,21 +13,25 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-latest, macos-latest, windows-latest] + name: [ubuntu-gcc, macos-clang, windows-msvc, ubuntu-clang] # For Windows msvc, for Linux and macOS let's use the clang compiler, use gcc for Linux. include: - - os: windows-latest + - name: windows-msvc + os: windows-latest cxx: cl.exe cc: cl.exe - - os: ubuntu-latest + - name: ubuntu-clang + os: ubuntu-latest cxx: clang++ cc: clang - - os: ubuntu-latest + - name: macos-clang + os: macos-latest + cxx: clang++ + cc: clang + - name: ubuntu-gcc + os: ubuntu-latest cxx: g++ cc: gcc - - os: macos-latest - cxx: clang++ - cc: clang steps: - uses: actions/checkout@v2 diff --git a/CMakeLists.txt b/CMakeLists.txt index d15e58dd4..c631b7685 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -239,22 +239,14 @@ IF( UNIX ) INCLUDE(GNUInstallDirs) ENDIF() -# enable warnings as errors ######################################## -IF (MSVC) - ADD_COMPILE_OPTIONS(/WX) -ELSE() - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror") - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror") -ENDIF() - # Grouped compiler settings ######################################## IF ((CMAKE_C_COMPILER_ID MATCHES "GNU") AND NOT CMAKE_COMPILER_IS_MINGW) IF(NOT ASSIMP_HUNTER_ENABLED) - SET(CMAKE_CXX_FLAGS "-fPIC -std=c++0x ${CMAKE_CXX_FLAGS}") - SET(CMAKE_C_FLAGS "-fPIC ${CMAKE_C_FLAGS}") + SET(CMAKE_CXX_STANDARD 11) + SET(CMAKE_POSITION_INDEPENDENT_CODE ON) ENDIF() # hide all not-exported symbols - SET(CMAKE_CXX_FLAGS "-g -fvisibility=hidden -fno-strict-aliasing -Wall ${CMAKE_CXX_FLAGS}") + SET(CMAKE_CXX_FLAGS "-fvisibility=hidden -fno-strict-aliasing -Wall ${CMAKE_CXX_FLAGS}") SET(CMAKE_C_FLAGS "-fno-strict-aliasing ${CMAKE_C_FLAGS}") SET(LIBSTDC++_LIBRARIES -lstdc++) ELSEIF(MSVC) diff --git a/code/ASE/ASEParser.cpp b/code/ASE/ASEParser.cpp index efc6ecd0d..72e8b3373 100644 --- a/code/ASE/ASEParser.cpp +++ b/code/ASE/ASEParser.cpp @@ -142,11 +142,11 @@ void Parser::LogWarning(const char* szWarn) { ai_assert(NULL != szWarn); - char szTemp[1024]; + char szTemp[2048]; #if _MSC_VER >= 1400 sprintf_s(szTemp, "Line %u: %s",iLineNumber,szWarn); #else - ai_snprintf(szTemp,1024,"Line %u: %s",iLineNumber,szWarn); + ai_snprintf(szTemp,sizeof(szTemp),"Line %u: %s",iLineNumber,szWarn); #endif // output the warning to the logger ... diff --git a/code/Blender/BlenderBMesh.cpp b/code/Blender/BlenderBMesh.cpp index 039302e12..174725e82 100644 --- a/code/Blender/BlenderBMesh.cpp +++ b/code/Blender/BlenderBMesh.cpp @@ -181,6 +181,7 @@ void BlenderBMeshConverter::AddFace( int v1, int v2, int v3, int v4 ) face.v2 = v2; face.v3 = v3; face.v4 = v4; + face.flag = 0; // TODO - Work out how materials work face.mat_nr = 0; triMesh->mface.push_back( face ); diff --git a/code/CApi/AssimpCExport.cpp b/code/CApi/AssimpCExport.cpp index 137cc2894..a6e7a304f 100644 --- a/code/CApi/AssimpCExport.cpp +++ b/code/CApi/AssimpCExport.cpp @@ -73,11 +73,11 @@ ASSIMP_API const aiExportFormatDesc* aiGetExportFormatDescription( size_t index) aiExportFormatDesc *desc = new aiExportFormatDesc; desc->description = new char[ strlen( orig->description ) + 1 ](); - ::strncpy( (char*) desc->description, orig->description, strlen( orig->description ) ); + ::memcpy( (char*) desc->description, orig->description, strlen( orig->description ) ); desc->fileExtension = new char[ strlen( orig->fileExtension ) + 1 ](); - ::strncpy( ( char* ) desc->fileExtension, orig->fileExtension, strlen( orig->fileExtension ) ); + ::memcpy( ( char* ) desc->fileExtension, orig->fileExtension, strlen( orig->fileExtension ) ); desc->id = new char[ strlen( orig->id ) + 1 ](); - ::strncpy( ( char* ) desc->id, orig->id, strlen( orig->id ) ); + ::memcpy( ( char* ) desc->id, orig->id, strlen( orig->id ) ); return desc; } diff --git a/code/CMakeLists.txt b/code/CMakeLists.txt index 49583c0c8..6afed40f9 100644 --- a/code/CMakeLists.txt +++ b/code/CMakeLists.txt @@ -1134,6 +1134,13 @@ ENDIF () ADD_LIBRARY( assimp ${assimp_src} ) ADD_LIBRARY(assimp::assimp ALIAS assimp) +# enable warnings as errors ######################################## +IF (MSVC) + TARGET_COMPILE_OPTIONS(assimp PRIVATE /WX) +ELSE() + TARGET_COMPILE_OPTIONS(assimp PRIVATE -Werror) +ENDIF() + TARGET_INCLUDE_DIRECTORIES ( assimp PUBLIC $ $ diff --git a/code/Common/SceneCombiner.cpp b/code/Common/SceneCombiner.cpp index b7511ff4e..62efe2ece 100644 --- a/code/Common/SceneCombiner.cpp +++ b/code/Common/SceneCombiner.cpp @@ -979,7 +979,7 @@ void GetArrayCopy(Type*& dest, ai_uint num ) { dest = new Type[num]; ::memcpy(dest, old, sizeof(Type) * num); -} + } // ------------------------------------------------------------------------------------------------ void SceneCombiner::CopySceneFlat(aiScene** _dest,const aiScene* src) { @@ -1065,7 +1065,7 @@ void SceneCombiner::Copy( aiMesh** _dest, const aiMesh* src ) { aiMesh* dest = *_dest = new aiMesh(); // get a flat copy - ::memcpy(dest,src,sizeof(aiMesh)); + *dest = *src; // and reallocate all arrays GetArrayCopy( dest->mVertices, dest->mNumVertices ); @@ -1104,7 +1104,7 @@ void SceneCombiner::Copy(aiAnimMesh** _dest, const aiAnimMesh* src) { aiAnimMesh* dest = *_dest = new aiAnimMesh(); // get a flat copy - ::memcpy(dest, src, sizeof(aiAnimMesh)); + *dest = *src; // and reallocate all arrays GetArrayCopy(dest->mVertices, dest->mNumVertices); @@ -1161,7 +1161,7 @@ void SceneCombiner::Copy(aiTexture** _dest, const aiTexture* src) { aiTexture* dest = *_dest = new aiTexture(); // get a flat copy - ::memcpy(dest,src,sizeof(aiTexture)); + *dest = *src; // and reallocate all arrays. We must do it manually here const char* old = (const char*)dest->pcData; @@ -1191,7 +1191,7 @@ void SceneCombiner::Copy( aiAnimation** _dest, const aiAnimation* src ) { aiAnimation* dest = *_dest = new aiAnimation(); // get a flat copy - ::memcpy(dest,src,sizeof(aiAnimation)); + *dest = *src; // and reallocate all arrays CopyPtrArray( dest->mChannels, src->mChannels, dest->mNumChannels ); @@ -1207,7 +1207,7 @@ void SceneCombiner::Copy(aiNodeAnim** _dest, const aiNodeAnim* src) { aiNodeAnim* dest = *_dest = new aiNodeAnim(); // get a flat copy - ::memcpy(dest,src,sizeof(aiNodeAnim)); + *dest = *src; // and reallocate all arrays GetArrayCopy( dest->mPositionKeys, dest->mNumPositionKeys ); @@ -1223,7 +1223,7 @@ void SceneCombiner::Copy(aiMeshMorphAnim** _dest, const aiMeshMorphAnim* src) { aiMeshMorphAnim* dest = *_dest = new aiMeshMorphAnim(); // get a flat copy - ::memcpy(dest,src,sizeof(aiMeshMorphAnim)); + *dest = *src; // and reallocate all arrays GetArrayCopy( dest->mKeys, dest->mNumKeys ); @@ -1244,7 +1244,7 @@ void SceneCombiner::Copy( aiCamera** _dest,const aiCamera* src) { aiCamera* dest = *_dest = new aiCamera(); // get a flat copy, that's already OK - ::memcpy(dest,src,sizeof(aiCamera)); + *dest = *src; } // ------------------------------------------------------------------------------------------------ @@ -1256,7 +1256,7 @@ void SceneCombiner::Copy(aiLight** _dest, const aiLight* src) { aiLight* dest = *_dest = new aiLight(); // get a flat copy, that's already OK - ::memcpy(dest,src,sizeof(aiLight)); + *dest = *src; } // ------------------------------------------------------------------------------------------------ @@ -1268,7 +1268,7 @@ void SceneCombiner::Copy(aiBone** _dest, const aiBone* src) { aiBone* dest = *_dest = new aiBone(); // get a flat copy - ::memcpy(dest,src,sizeof(aiBone)); + *dest = *src; // and reallocate all arrays GetArrayCopy( dest->mWeights, dest->mNumWeights ); @@ -1282,7 +1282,7 @@ void SceneCombiner::Copy (aiNode** _dest, const aiNode* src) aiNode* dest = *_dest = new aiNode(); // get a flat copy - ::memcpy(dest,src,sizeof(aiNode)); + *dest = *src; if (src->mMetaData) { Copy(&dest->mMetaData, src->mMetaData); diff --git a/code/M3D/m3d.h b/code/M3D/m3d.h index 83c8d8a52..75bcdfeb7 100644 --- a/code/M3D/m3d.h +++ b/code/M3D/m3d.h @@ -1556,7 +1556,7 @@ static int _m3dstbi__create_png_image(_m3dstbi__png *a, unsigned char *image_dat return 1; } -static int _m3dstbi__compute_transparency(_m3dstbi__png *z, unsigned char tc[3], int out_n) { +static int _m3dstbi__compute_transparency(_m3dstbi__png *z, unsigned char* tc, int out_n) { _m3dstbi__context *s = z->s; _m3dstbi__uint32 i, pixel_count = s->img_x * s->img_y; unsigned char *p = z->out; @@ -1639,7 +1639,7 @@ static int _m3dstbi__expand_png_palette(_m3dstbi__png *a, unsigned char *palette static int _m3dstbi__parse_png_file(_m3dstbi__png *z, int scan, int req_comp) { unsigned char palette[1024], pal_img_n = 0; - unsigned char has_trans = 0, tc[3]; + unsigned char has_trans = 0, tc[3] = {}; _m3dstbi__uint16 tc16[3]; _m3dstbi__uint32 ioff = 0, idata_limit = 0, i, pal_len = 0; int first = 1, k, interlace = 0, color = 0; @@ -4350,7 +4350,7 @@ unsigned char *m3d_save(m3d_t *model, int quality, int flags, unsigned int *size M3D_INDEX last, *vrtxidx = NULL, *mtrlidx = NULL, *tmapidx = NULL, *skinidx = NULL; uint32_t idx, numcmap = 0, *cmap = NULL, numvrtx = 0, maxvrtx = 0, numtmap = 0, maxtmap = 0, numproc = 0; uint32_t numskin = 0, maxskin = 0, numstr = 0, maxt = 0, maxbone = 0, numgrp = 0, maxgrp = 0, *grpidx = NULL; - uint8_t *opa; + uint8_t *opa = nullptr; m3dcd_t *cd; m3dc_t *cmd; m3dstr_t *str = NULL; diff --git a/contrib/irrXML/irrString.h b/contrib/irrXML/irrString.h index 1abf22b78..246348891 100644 --- a/contrib/irrXML/irrString.h +++ b/contrib/irrXML/irrString.h @@ -635,9 +635,6 @@ private: s32 amount = used < new_size ? used : new_size; for (s32 i=0; i Date: Tue, 28 Apr 2020 09:14:53 +0200 Subject: [PATCH 11/33] Retrigger build --- code/Blender/BlenderBMesh.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/code/Blender/BlenderBMesh.cpp b/code/Blender/BlenderBMesh.cpp index 174725e82..937d9d073 100644 --- a/code/Blender/BlenderBMesh.cpp +++ b/code/Blender/BlenderBMesh.cpp @@ -42,7 +42,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * @brief Conversion of Blender's new BMesh stuff */ - #ifndef ASSIMP_BUILD_NO_BLEND_IMPORTER #include "BlenderDNA.h" From 9107402bda805fee74da3e7fea9261b4d304548e Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Tue, 28 Apr 2020 14:22:00 +0200 Subject: [PATCH 12/33] Add sanitizer job --- .github/workflows/ccpp.yml | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ccpp.yml b/.github/workflows/ccpp.yml index 08292d55f..46f060836 100644 --- a/.github/workflows/ccpp.yml +++ b/.github/workflows/ccpp.yml @@ -7,13 +7,13 @@ on: branches: [ master ] jobs: - job: + job-build: name: ${{ matrix.os }}-${{ matrix.cxx }}-build-and-test runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: - name: [ubuntu-gcc, macos-clang, windows-msvc, ubuntu-clang] + name: [ubuntu-gcc, macos-clang, windows-msvc, ubuntu-clang, ubuntu-memory-sanitizer] # For Windows msvc, for Linux and macOS let's use the clang compiler, use gcc for Linux. include: - name: windows-msvc @@ -57,3 +57,27 @@ jobs: - name: test run: cd build/bin && ./unit shell: bash + + job-sanitizer: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: lukka/get-cmake@latest + - uses: ilammy/msvc-dev-cmd@v1 + - uses: lukka/set-shell-env@v1 + with: + CXX: clang++ + CC: clang + + - name: configure and build + uses: lukka/run-cmake@v2 + with: + cmakeListsOrSettingsJson: CMakeListsTxtAdvanced + cmakeListsTxtPath: '${{ github.workspace }}/CMakeLists.txt' + cmakeAppendedArgs: '-GNinja -DCMAKE_BUILD_TYPE=Release -DASSIMP_ASAN=ON' + buildWithCMakeArgs: '-- -v' + buildDirectory: '${{ github.workspace }}/build/' + + - name: test + run: cd build/bin && ./unit + shell: bash From 24fc16336ac8d5089c530008d288e740f5f03112 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Tue, 28 Apr 2020 14:24:21 +0200 Subject: [PATCH 13/33] Add build-dependency --- .github/workflows/ccpp.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ccpp.yml b/.github/workflows/ccpp.yml index 46f060836..a1d81d0cc 100644 --- a/.github/workflows/ccpp.yml +++ b/.github/workflows/ccpp.yml @@ -59,6 +59,7 @@ jobs: shell: bash job-sanitizer: + needs: job-build runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 From 43df1d676a1871de9147f8ac6ea696c64b38db78 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Tue, 28 Apr 2020 14:27:02 +0200 Subject: [PATCH 14/33] Fix dependency --- .github/workflows/ccpp.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ccpp.yml b/.github/workflows/ccpp.yml index a1d81d0cc..c96a628ce 100644 --- a/.github/workflows/ccpp.yml +++ b/.github/workflows/ccpp.yml @@ -7,7 +7,7 @@ on: branches: [ master ] jobs: - job-build: + job: name: ${{ matrix.os }}-${{ matrix.cxx }}-build-and-test runs-on: ${{ matrix.os }} strategy: @@ -58,8 +58,7 @@ jobs: run: cd build/bin && ./unit shell: bash - job-sanitizer: - needs: job-build + sanitizer: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 From 8240a11e1578c05aee6de9fa0bce68963a1b4eb9 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Tue, 28 Apr 2020 14:41:44 +0200 Subject: [PATCH 15/33] Add undefined behavior sanitizer job --- .github/workflows/ccpp.yml | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ccpp.yml b/.github/workflows/ccpp.yml index c96a628ce..0a3ca72ec 100644 --- a/.github/workflows/ccpp.yml +++ b/.github/workflows/ccpp.yml @@ -58,7 +58,31 @@ jobs: run: cd build/bin && ./unit shell: bash - sanitizer: + adress-sanitizer: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: lukka/get-cmake@latest + - uses: ilammy/msvc-dev-cmd@v1 + - uses: lukka/set-shell-env@v1 + with: + CXX: clang++ + CC: clang + + - name: configure and build + uses: lukka/run-cmake@v2 + with: + cmakeListsOrSettingsJson: CMakeListsTxtAdvanced + cmakeListsTxtPath: '${{ github.workspace }}/CMakeLists.txt' + cmakeAppendedArgs: '-GNinja -DCMAKE_BUILD_TYPE=Release -DASSIMP_ASAN=ON' + buildWithCMakeArgs: '-- -v' + buildDirectory: '${{ github.workspace }}/build/' + + - name: test + run: cd build/bin && ./unit + shell: bash + + undefined-behavior-sanitizer: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 From 5cb4ac843d8434a6aaf9c5356f00324a34b55d11 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Tue, 28 Apr 2020 14:43:12 +0200 Subject: [PATCH 16/33] Update ccpp.yml --- .github/workflows/ccpp.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ccpp.yml b/.github/workflows/ccpp.yml index 0a3ca72ec..418c100f3 100644 --- a/.github/workflows/ccpp.yml +++ b/.github/workflows/ccpp.yml @@ -7,7 +7,7 @@ on: branches: [ master ] jobs: - job: + builds: name: ${{ matrix.os }}-${{ matrix.cxx }}-build-and-test runs-on: ${{ matrix.os }} strategy: From 8085e7555e378e7e975d123949b7d69517edf5b6 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Tue, 28 Apr 2020 14:53:19 +0200 Subject: [PATCH 17/33] try something out to get builds back to job-list --- .github/workflows/ccpp.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ccpp.yml b/.github/workflows/ccpp.yml index 418c100f3..0a3ca72ec 100644 --- a/.github/workflows/ccpp.yml +++ b/.github/workflows/ccpp.yml @@ -7,7 +7,7 @@ on: branches: [ master ] jobs: - builds: + job: name: ${{ matrix.os }}-${{ matrix.cxx }}-build-and-test runs-on: ${{ matrix.os }} strategy: From 8224cbeaad58c2d0b4d83af9e4ff85fecff1a53e Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Tue, 28 Apr 2020 20:25:48 +0200 Subject: [PATCH 18/33] Try a different naming schema --- .github/workflows/ccpp.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ccpp.yml b/.github/workflows/ccpp.yml index 0a3ca72ec..6d54e289e 100644 --- a/.github/workflows/ccpp.yml +++ b/.github/workflows/ccpp.yml @@ -7,7 +7,7 @@ on: branches: [ master ] jobs: - job: + job1: name: ${{ matrix.os }}-${{ matrix.cxx }}-build-and-test runs-on: ${{ matrix.os }} strategy: @@ -58,7 +58,8 @@ jobs: run: cd build/bin && ./unit shell: bash - adress-sanitizer: + job2: + name: adress-sanitizer runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -82,7 +83,8 @@ jobs: run: cd build/bin && ./unit shell: bash - undefined-behavior-sanitizer: + job3: + name: undefined-behavior-sanitizer runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 From 8888495d124636d8ca0d44febe87996a62cb0d72 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Tue, 28 Apr 2020 20:30:59 +0200 Subject: [PATCH 19/33] Create sanitizer.yml --- .github/workflows/sanitizer.yml | 58 +++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 .github/workflows/sanitizer.yml diff --git a/.github/workflows/sanitizer.yml b/.github/workflows/sanitizer.yml new file mode 100644 index 000000000..d6f09367f --- /dev/null +++ b/.github/workflows/sanitizer.yml @@ -0,0 +1,58 @@ +name: C/C++ CI + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + job1: + name: adress-sanitizer + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: lukka/get-cmake@latest + - uses: ilammy/msvc-dev-cmd@v1 + - uses: lukka/set-shell-env@v1 + with: + CXX: clang++ + CC: clang + + - name: configure and build + uses: lukka/run-cmake@v2 + with: + cmakeListsOrSettingsJson: CMakeListsTxtAdvanced + cmakeListsTxtPath: '${{ github.workspace }}/CMakeLists.txt' + cmakeAppendedArgs: '-GNinja -DCMAKE_BUILD_TYPE=Release -DASSIMP_ASAN=ON' + buildWithCMakeArgs: '-- -v' + buildDirectory: '${{ github.workspace }}/build/' + + - name: test + run: cd build/bin && ./unit + shell: bash + + job2: + name: undefined-behavior-sanitizer + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: lukka/get-cmake@latest + - uses: ilammy/msvc-dev-cmd@v1 + - uses: lukka/set-shell-env@v1 + with: + CXX: clang++ + CC: clang + + - name: configure and build + uses: lukka/run-cmake@v2 + with: + cmakeListsOrSettingsJson: CMakeListsTxtAdvanced + cmakeListsTxtPath: '${{ github.workspace }}/CMakeLists.txt' + cmakeAppendedArgs: '-GNinja -DCMAKE_BUILD_TYPE=Release -DASSIMP_ASAN=ON' + buildWithCMakeArgs: '-- -v' + buildDirectory: '${{ github.workspace }}/build/' + + - name: test + run: cd build/bin && ./unit + shell: bash From a5a38c02a5b7d70facf97a58dc90271982fd0b00 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Tue, 28 Apr 2020 20:31:42 +0200 Subject: [PATCH 20/33] move sanitizer into its own file --- .github/workflows/ccpp.yml | 50 -------------------------------------- 1 file changed, 50 deletions(-) diff --git a/.github/workflows/ccpp.yml b/.github/workflows/ccpp.yml index 6d54e289e..d46dbe6a0 100644 --- a/.github/workflows/ccpp.yml +++ b/.github/workflows/ccpp.yml @@ -57,53 +57,3 @@ jobs: - name: test run: cd build/bin && ./unit shell: bash - - job2: - name: adress-sanitizer - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: lukka/get-cmake@latest - - uses: ilammy/msvc-dev-cmd@v1 - - uses: lukka/set-shell-env@v1 - with: - CXX: clang++ - CC: clang - - - name: configure and build - uses: lukka/run-cmake@v2 - with: - cmakeListsOrSettingsJson: CMakeListsTxtAdvanced - cmakeListsTxtPath: '${{ github.workspace }}/CMakeLists.txt' - cmakeAppendedArgs: '-GNinja -DCMAKE_BUILD_TYPE=Release -DASSIMP_ASAN=ON' - buildWithCMakeArgs: '-- -v' - buildDirectory: '${{ github.workspace }}/build/' - - - name: test - run: cd build/bin && ./unit - shell: bash - - job3: - name: undefined-behavior-sanitizer - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: lukka/get-cmake@latest - - uses: ilammy/msvc-dev-cmd@v1 - - uses: lukka/set-shell-env@v1 - with: - CXX: clang++ - CC: clang - - - name: configure and build - uses: lukka/run-cmake@v2 - with: - cmakeListsOrSettingsJson: CMakeListsTxtAdvanced - cmakeListsTxtPath: '${{ github.workspace }}/CMakeLists.txt' - cmakeAppendedArgs: '-GNinja -DCMAKE_BUILD_TYPE=Release -DASSIMP_ASAN=ON' - buildWithCMakeArgs: '-- -v' - buildDirectory: '${{ github.workspace }}/build/' - - - name: test - run: cd build/bin && ./unit - shell: bash From 4afbe35e0775de4b31f88c790db5ee76b28cf93f Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Tue, 28 Apr 2020 20:32:55 +0200 Subject: [PATCH 21/33] Use unique name for the sanitizer check --- .github/workflows/sanitizer.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sanitizer.yml b/.github/workflows/sanitizer.yml index d6f09367f..7a8eb17fa 100644 --- a/.github/workflows/sanitizer.yml +++ b/.github/workflows/sanitizer.yml @@ -1,4 +1,4 @@ -name: C/C++ CI +name: C/C++ Sanitizer on: push: From 7b4ff0cb1c9775ee1fe899ea8e9b9ed8485afec0 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Tue, 28 Apr 2020 20:39:13 +0200 Subject: [PATCH 22/33] Fix name --- .github/workflows/ccpp.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ccpp.yml b/.github/workflows/ccpp.yml index d46dbe6a0..36fca3f29 100644 --- a/.github/workflows/ccpp.yml +++ b/.github/workflows/ccpp.yml @@ -7,7 +7,7 @@ on: branches: [ master ] jobs: - job1: + job: name: ${{ matrix.os }}-${{ matrix.cxx }}-build-and-test runs-on: ${{ matrix.os }} strategy: From 68efdcde883cf5f9e1b9cb42b4da211e443ee1fb Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Tue, 28 Apr 2020 20:41:02 +0200 Subject: [PATCH 23/33] Remove deprecated step --- .github/workflows/ccpp.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ccpp.yml b/.github/workflows/ccpp.yml index 36fca3f29..08292d55f 100644 --- a/.github/workflows/ccpp.yml +++ b/.github/workflows/ccpp.yml @@ -13,7 +13,7 @@ jobs: strategy: fail-fast: false matrix: - name: [ubuntu-gcc, macos-clang, windows-msvc, ubuntu-clang, ubuntu-memory-sanitizer] + name: [ubuntu-gcc, macos-clang, windows-msvc, ubuntu-clang] # For Windows msvc, for Linux and macOS let's use the clang compiler, use gcc for Linux. include: - name: windows-msvc From 1a440834ae455bf4d592500959cbee7559b1a69b Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Tue, 28 Apr 2020 21:11:21 +0200 Subject: [PATCH 24/33] Use debug configuration --- .github/workflows/sanitizer.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/sanitizer.yml b/.github/workflows/sanitizer.yml index 7a8eb17fa..bfcad7867 100644 --- a/.github/workflows/sanitizer.yml +++ b/.github/workflows/sanitizer.yml @@ -24,7 +24,7 @@ jobs: with: cmakeListsOrSettingsJson: CMakeListsTxtAdvanced cmakeListsTxtPath: '${{ github.workspace }}/CMakeLists.txt' - cmakeAppendedArgs: '-GNinja -DCMAKE_BUILD_TYPE=Release -DASSIMP_ASAN=ON' + cmakeAppendedArgs: '-GNinja -DCMAKE_BUILD_TYPE=Debug -DASSIMP_ASAN=ON' buildWithCMakeArgs: '-- -v' buildDirectory: '${{ github.workspace }}/build/' @@ -49,7 +49,7 @@ jobs: with: cmakeListsOrSettingsJson: CMakeListsTxtAdvanced cmakeListsTxtPath: '${{ github.workspace }}/CMakeLists.txt' - cmakeAppendedArgs: '-GNinja -DCMAKE_BUILD_TYPE=Release -DASSIMP_ASAN=ON' + cmakeAppendedArgs: '-GNinja -DCMAKE_BUILD_TYPE=Debug -DASSIMP_ASAN=ON' buildWithCMakeArgs: '-- -v' buildDirectory: '${{ github.workspace }}/build/' From fcdf88a74a948cf7c47e583bc0de524c3da15355 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Wed, 29 Apr 2020 13:41:40 +0200 Subject: [PATCH 25/33] Use correct sanitizer --- .github/workflows/sanitizer.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sanitizer.yml b/.github/workflows/sanitizer.yml index bfcad7867..c1fa62ff3 100644 --- a/.github/workflows/sanitizer.yml +++ b/.github/workflows/sanitizer.yml @@ -49,7 +49,7 @@ jobs: with: cmakeListsOrSettingsJson: CMakeListsTxtAdvanced cmakeListsTxtPath: '${{ github.workspace }}/CMakeLists.txt' - cmakeAppendedArgs: '-GNinja -DCMAKE_BUILD_TYPE=Debug -DASSIMP_ASAN=ON' + cmakeAppendedArgs: '-GNinja -DCMAKE_BUILD_TYPE=Debug -DASSIMP_UBSAN=ON' buildWithCMakeArgs: '-- -v' buildDirectory: '${{ github.workspace }}/build/' From b9c597d0553d5996c54ce414efb572d4c7778453 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Wed, 29 Apr 2020 13:46:01 +0200 Subject: [PATCH 26/33] Fix review finding. --- .github/workflows/sanitizer.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/sanitizer.yml b/.github/workflows/sanitizer.yml index c1fa62ff3..9bba5f6fd 100644 --- a/.github/workflows/sanitizer.yml +++ b/.github/workflows/sanitizer.yml @@ -13,7 +13,6 @@ jobs: steps: - uses: actions/checkout@v2 - uses: lukka/get-cmake@latest - - uses: ilammy/msvc-dev-cmd@v1 - uses: lukka/set-shell-env@v1 with: CXX: clang++ @@ -38,7 +37,6 @@ jobs: steps: - uses: actions/checkout@v2 - uses: lukka/get-cmake@latest - - uses: ilammy/msvc-dev-cmd@v1 - uses: lukka/set-shell-env@v1 with: CXX: clang++ From c6131ce38ada7dd1d74b693e3979cb04a83d0df2 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Wed, 29 Apr 2020 20:43:23 +0200 Subject: [PATCH 27/33] scenecombiner: fix leak. --- code/Common/SceneCombiner.cpp | 5 +---- include/assimp/mesh.h | 5 ++++- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/code/Common/SceneCombiner.cpp b/code/Common/SceneCombiner.cpp index 62efe2ece..4d2a411f2 100644 --- a/code/Common/SceneCombiner.cpp +++ b/code/Common/SceneCombiner.cpp @@ -979,7 +979,7 @@ void GetArrayCopy(Type*& dest, ai_uint num ) { dest = new Type[num]; ::memcpy(dest, old, sizeof(Type) * num); - } +} // ------------------------------------------------------------------------------------------------ void SceneCombiner::CopySceneFlat(aiScene** _dest,const aiScene* src) { @@ -1269,9 +1269,6 @@ void SceneCombiner::Copy(aiBone** _dest, const aiBone* src) { // get a flat copy *dest = *src; - - // and reallocate all arrays - GetArrayCopy( dest->mWeights, dest->mNumWeights ); } // ------------------------------------------------------------------------------------------------ diff --git a/include/assimp/mesh.h b/include/assimp/mesh.h index bd987bc88..4b5af97ce 100644 --- a/include/assimp/mesh.h +++ b/include/assimp/mesh.h @@ -308,7 +308,10 @@ struct aiBone { //! Copy constructor aiBone(const aiBone &other) : - mName(other.mName), mNumWeights(other.mNumWeights), mWeights(nullptr), mOffsetMatrix(other.mOffsetMatrix) { + mName(other.mName), + mNumWeights(other.mNumWeights), + mWeights(nullptr), + mOffsetMatrix(other.mOffsetMatrix) { if (other.mWeights && other.mNumWeights) { mWeights = new aiVertexWeight[mNumWeights]; ::memcpy(mWeights, other.mWeights, mNumWeights * sizeof(aiVertexWeight)); From f808ed9fb5879f4b11d46ace3599e262a6ef50ec Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Wed, 29 Apr 2020 20:52:49 +0200 Subject: [PATCH 28/33] fbxconverter: fix memoryleak. --- code/FBX/FBXConverter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/FBX/FBXConverter.cpp b/code/FBX/FBXConverter.cpp index 880b5de76..c22e3a50b 100644 --- a/code/FBX/FBXConverter.cpp +++ b/code/FBX/FBXConverter.cpp @@ -3392,7 +3392,7 @@ void FBXConverter::ConvertGlobalSettings() { const bool hasGenerator = !doc.Creator().empty(); - mSceneOut->mMetaData = aiMetadata::Alloc(16 + (hasGenerator ? 1 : 0)); + mSceneOut->mMetaData = aiMetadata::Alloc(17 + (hasGenerator ? 1 : 0)); mSceneOut->mMetaData->Set(0, "UpAxis", doc.GlobalSettings().UpAxis()); mSceneOut->mMetaData->Set(1, "UpAxisSign", doc.GlobalSettings().UpAxisSign()); mSceneOut->mMetaData->Set(2, "FrontAxis", doc.GlobalSettings().FrontAxis()); From da2bf5c7a43eacc7c1b4583790e0115951bfd560 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Wed, 29 Apr 2020 21:13:46 +0200 Subject: [PATCH 29/33] fix wrong size --- code/FBX/FBXConverter.cpp | 2 +- include/assimp/metadata.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/code/FBX/FBXConverter.cpp b/code/FBX/FBXConverter.cpp index c22e3a50b..880b5de76 100644 --- a/code/FBX/FBXConverter.cpp +++ b/code/FBX/FBXConverter.cpp @@ -3392,7 +3392,7 @@ void FBXConverter::ConvertGlobalSettings() { const bool hasGenerator = !doc.Creator().empty(); - mSceneOut->mMetaData = aiMetadata::Alloc(17 + (hasGenerator ? 1 : 0)); + mSceneOut->mMetaData = aiMetadata::Alloc(16 + (hasGenerator ? 1 : 0)); mSceneOut->mMetaData->Set(0, "UpAxis", doc.GlobalSettings().UpAxis()); mSceneOut->mMetaData->Set(1, "UpAxisSign", doc.GlobalSettings().UpAxisSign()); mSceneOut->mMetaData->Set(2, "FrontAxis", doc.GlobalSettings().FrontAxis()); diff --git a/include/assimp/metadata.h b/include/assimp/metadata.h index 28ddce567..cd7569ffe 100644 --- a/include/assimp/metadata.h +++ b/include/assimp/metadata.h @@ -320,7 +320,7 @@ struct aiMetadata { } template - inline bool Set( const std::string &key, const T &value ) { + inline bool Set(const std::string &key, const T &value) { if (key.empty()) { return false; } From e0bc0f7fade58376a54a1374bf1e2cd0f0e15e69 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Wed, 29 Apr 2020 21:19:15 +0200 Subject: [PATCH 30/33] try to fix double memleak. --- code/FBX/FBXConverter.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/code/FBX/FBXConverter.cpp b/code/FBX/FBXConverter.cpp index 880b5de76..e46e45c28 100644 --- a/code/FBX/FBXConverter.cpp +++ b/code/FBX/FBXConverter.cpp @@ -3401,7 +3401,8 @@ void FBXConverter::ConvertGlobalSettings() { mSceneOut->mMetaData->Set(5, "CoordAxisSign", doc.GlobalSettings().CoordAxisSign()); mSceneOut->mMetaData->Set(6, "OriginalUpAxis", doc.GlobalSettings().OriginalUpAxis()); mSceneOut->mMetaData->Set(7, "OriginalUpAxisSign", doc.GlobalSettings().OriginalUpAxisSign()); - mSceneOut->mMetaData->Set(8, "UnitScaleFactor", (double)doc.GlobalSettings().UnitScaleFactor()); + const double unitScaleFactor = (double)doc.GlobalSettings().UnitScaleFactor(); + mSceneOut->mMetaData->Set(8, "UnitScaleFactor", unitScaleFactor); mSceneOut->mMetaData->Set(9, "OriginalUnitScaleFactor", doc.GlobalSettings().OriginalUnitScaleFactor()); mSceneOut->mMetaData->Set(10, "AmbientColor", doc.GlobalSettings().AmbientColor()); mSceneOut->mMetaData->Set(11, "FrameRate", (int)doc.GlobalSettings().TimeMode()); From 1c30b7bf8ed2a4cc02a1b33f52e46c05be815c60 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Wed, 29 Apr 2020 21:31:01 +0200 Subject: [PATCH 31/33] tryout: check if leak is coupled to type double. --- code/FBX/FBXConverter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/FBX/FBXConverter.cpp b/code/FBX/FBXConverter.cpp index e46e45c28..296d30398 100644 --- a/code/FBX/FBXConverter.cpp +++ b/code/FBX/FBXConverter.cpp @@ -3402,7 +3402,7 @@ void FBXConverter::ConvertGlobalSettings() { mSceneOut->mMetaData->Set(6, "OriginalUpAxis", doc.GlobalSettings().OriginalUpAxis()); mSceneOut->mMetaData->Set(7, "OriginalUpAxisSign", doc.GlobalSettings().OriginalUpAxisSign()); const double unitScaleFactor = (double)doc.GlobalSettings().UnitScaleFactor(); - mSceneOut->mMetaData->Set(8, "UnitScaleFactor", unitScaleFactor); + mSceneOut->mMetaData->Set(8, "UnitScaleFactor", doc.GlobalSettings().UnitScaleFactor()); mSceneOut->mMetaData->Set(9, "OriginalUnitScaleFactor", doc.GlobalSettings().OriginalUnitScaleFactor()); mSceneOut->mMetaData->Set(10, "AmbientColor", doc.GlobalSettings().AmbientColor()); mSceneOut->mMetaData->Set(11, "FrameRate", (int)doc.GlobalSettings().TimeMode()); From 2d9d1120158197cb1e4a64d607b7aca413a1aa4f Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Wed, 29 Apr 2020 21:35:42 +0200 Subject: [PATCH 32/33] fix warning --- code/FBX/FBXConverter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/FBX/FBXConverter.cpp b/code/FBX/FBXConverter.cpp index 296d30398..1bf977189 100644 --- a/code/FBX/FBXConverter.cpp +++ b/code/FBX/FBXConverter.cpp @@ -3401,7 +3401,7 @@ void FBXConverter::ConvertGlobalSettings() { mSceneOut->mMetaData->Set(5, "CoordAxisSign", doc.GlobalSettings().CoordAxisSign()); mSceneOut->mMetaData->Set(6, "OriginalUpAxis", doc.GlobalSettings().OriginalUpAxis()); mSceneOut->mMetaData->Set(7, "OriginalUpAxisSign", doc.GlobalSettings().OriginalUpAxisSign()); - const double unitScaleFactor = (double)doc.GlobalSettings().UnitScaleFactor(); + //const double unitScaleFactor = (double)doc.GlobalSettings().UnitScaleFactor(); mSceneOut->mMetaData->Set(8, "UnitScaleFactor", doc.GlobalSettings().UnitScaleFactor()); mSceneOut->mMetaData->Set(9, "OriginalUnitScaleFactor", doc.GlobalSettings().OriginalUnitScaleFactor()); mSceneOut->mMetaData->Set(10, "AmbientColor", doc.GlobalSettings().AmbientColor()); From a639221ededeb186c3f903b932594f8e7b44bd4c Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Thu, 30 Apr 2020 09:14:42 +0200 Subject: [PATCH 33/33] Update to float - Temporary change to analyze leak. --- test/unit/utFBXImporterExporter.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/unit/utFBXImporterExporter.cpp b/test/unit/utFBXImporterExporter.cpp index 88a3e067e..2f1ea79e8 100644 --- a/test/unit/utFBXImporterExporter.cpp +++ b/test/unit/utFBXImporterExporter.cpp @@ -210,13 +210,13 @@ TEST_F(utFBXImporterExporter, importUnitScaleFactor) { EXPECT_NE(nullptr, scene); EXPECT_NE(nullptr, scene->mMetaData); - double factor(0.0); + float factor(0.0f); scene->mMetaData->Get("UnitScaleFactor", factor); - EXPECT_DOUBLE_EQ(500.0, factor); + EXPECT_EQ(500.0f, factor); - scene->mMetaData->Set("UnitScaleFactor", factor * 2); + scene->mMetaData->Set("UnitScaleFactor", factor * 2.0f); scene->mMetaData->Get("UnitScaleFactor", factor); - EXPECT_DOUBLE_EQ(1000.0, factor); + EXPECT_EQ(1000.0f, factor); } TEST_F(utFBXImporterExporter, importEmbeddedAsciiTest) {