pull/2656/head
Kim Kulling 2019-09-15 19:25:37 +02:00
parent 2be0eba1ab
commit 8b95479bb0
4 changed files with 28 additions and 18 deletions

View File

@ -45,6 +45,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "ColladaExporter.h" #include "ColladaExporter.h"
#include <assimp/Bitmap.h> #include <assimp/Bitmap.h>
#include <assimp/MathFunctions.h>
#include <assimp/fast_atof.h> #include <assimp/fast_atof.h>
#include <assimp/SceneCombiner.h> #include <assimp/SceneCombiner.h>
#include <assimp/StringUtils.h> #include <assimp/StringUtils.h>
@ -155,7 +156,7 @@ void ColladaExporter::WriteFile() {
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Writes the asset header // Writes the asset header
void ColladaExporter::WriteHeader() { void ColladaExporter::WriteHeader() {
static const ai_real epsilon = ai_real( 0.00001 ); static const ai_real epsilon = Math::getEpsilon<ai_real>();
static const aiQuaternion x_rot(aiMatrix3x3( static const aiQuaternion x_rot(aiMatrix3x3(
0, -1, 0, 0, -1, 0,
1, 0, 0, 1, 0, 0,

View File

@ -55,6 +55,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "FBXImporter.h" #include "FBXImporter.h"
#include <assimp/StringComparison.h> #include <assimp/StringComparison.h>
#include <assimp/MathFunctions.h>
#include <assimp/scene.h> #include <assimp/scene.h>
@ -553,7 +554,7 @@ namespace Assimp {
return; return;
} }
const float angle_epsilon = 1e-6f; const float angle_epsilon = Math::getEpsilon<float>();
out = aiMatrix4x4(); out = aiMatrix4x4();

View File

@ -39,22 +39,24 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
*/ */
#pragma once
/** @file MathFunctions.h /** @file MathFunctions.h
* @brief Implementation of the math functions (gcd and lcm) * @brief Implementation of math utility functions.
* *
* Copied from BoostWorkaround/math */
*/
#include <limits>
namespace Assimp { namespace Assimp {
namespace Math { namespace Math {
// TODO: use binary GCD for unsigned integers .... // TODO: use binary GCD for unsigned integers ....
template < typename IntegerType > template < typename IntegerType >
IntegerType gcd( IntegerType a, IntegerType b ) inline
{ IntegerType gcd( IntegerType a, IntegerType b ) {
const IntegerType zero = (IntegerType)0; const IntegerType zero = (IntegerType)0;
while ( true ) while ( true ) {
{
if ( a == zero ) if ( a == zero )
return b; return b;
b %= a; b %= a;
@ -66,12 +68,19 @@ IntegerType gcd( IntegerType a, IntegerType b )
} }
template < typename IntegerType > template < typename IntegerType >
IntegerType lcm( IntegerType a, IntegerType b ) inline
{ IntegerType lcm( IntegerType a, IntegerType b ) {
const IntegerType t = gcd (a,b); const IntegerType t = gcd (a,b);
if (!t)return t; if (!t)
return t;
return a / t * b; return a / t * b;
} }
template<class T>
inline
T getEpsilon() {
return std::numeric_limits<T>::epsilon();
}
} }
} }

View File

@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
Copyright (c) 2006-2019, assimp team Copyright (c) 2006-2019, assimp team
All rights reserved. All rights reserved.
Redistribution and use of this software in source and binary forms, Redistribution and use of this software in source and binary forms,
@ -53,6 +51,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "matrix4x4.h" #include "matrix4x4.h"
#include "matrix3x3.h" #include "matrix3x3.h"
#include "quaternion.h" #include "quaternion.h"
#include "MathFunctions.h"
#include <algorithm> #include <algorithm>
#include <limits> #include <limits>
@ -420,8 +419,8 @@ inline void aiMatrix4x4t<TReal>::Decompose (aiVector3t<TReal>& pScaling, aiQuate
} }
template <typename TReal> template <typename TReal>
inline void aiMatrix4x4t<TReal>::Decompose(aiVector3t<TReal>& pScaling, aiVector3t<TReal>& pRotation, aiVector3t<TReal>& pPosition) const inline
{ void aiMatrix4x4t<TReal>::Decompose(aiVector3t<TReal>& pScaling, aiVector3t<TReal>& pRotation, aiVector3t<TReal>& pPosition) const {
ASSIMP_MATRIX4_4_DECOMPOSE_PART; ASSIMP_MATRIX4_4_DECOMPOSE_PART;
/* /*
@ -442,7 +441,7 @@ inline void aiMatrix4x4t<TReal>::Decompose(aiVector3t<TReal>& pScaling, aiVector
*/ */
// Use a small epsilon to solve floating-point inaccuracies // Use a small epsilon to solve floating-point inaccuracies
const TReal epsilon = 10e-3f; const TReal epsilon = Math::getEpsilon<TReal>();
pRotation.y = std::asin(-vCols[0].z);// D. Angle around oY. pRotation.y = std::asin(-vCols[0].z);// D. Angle around oY.