Basic changes to introduce optional double precision

This commit is contained in:
Chris Russ
2016-07-16 18:23:33 +10:00
parent 45fae27aed
commit 2f7e3dcdcc
18 changed files with 167 additions and 106 deletions
+4 -4
View File
@@ -330,7 +330,7 @@ public:
// typedefs for our four configuration maps.
// We don't need more, so there is no need for a generic solution
typedef std::map<KeyType, int> IntPropertyMap;
typedef std::map<KeyType, float> FloatPropertyMap;
typedef std::map<KeyType, ai_real> FloatPropertyMap;
typedef std::map<KeyType, std::string> StringPropertyMap;
typedef std::map<KeyType, aiMatrix4x4> MatrixPropertyMap;
@@ -380,7 +380,7 @@ public:
/** Set a floating-point configuration property.
* @see SetPropertyInteger()
*/
bool SetPropertyFloat(const char* szName, float fValue);
bool SetPropertyFloat(const char* szName, ai_real fValue);
// -------------------------------------------------------------------
/** Set a string configuration property.
@@ -425,8 +425,8 @@ public:
/** Get a floating-point configuration property
* @see GetPropertyInteger()
*/
float GetPropertyFloat(const char* szName,
float fErrorReturn = 10e10f) const;
ai_real GetPropertyFloat(const char* szName,
ai_real fErrorReturn = 10e10f) const;
// -------------------------------------------------------------------
/** Get a string configuration property
+6 -6
View File
@@ -421,7 +421,7 @@ struct Interpolator
* The interpolation algorithm depends on the type of the operands.
* aiQuaternion's and aiQuatKey's SLERP, the rest does a simple
* linear interpolation. */
void operator () (T& out,const T& a, const T& b, float d) const {
void operator () (T& out,const T& a, const T& b, ai_real d) const {
out = a + (b-a)*d;
}
}; // ! Interpolator <T>
@@ -431,7 +431,7 @@ struct Interpolator
template <>
struct Interpolator <aiQuaternion> {
void operator () (aiQuaternion& out,const aiQuaternion& a,
const aiQuaternion& b, float d) const
const aiQuaternion& b, ai_real d) const
{
aiQuaternion::Interpolate(out,a,b,d);
}
@@ -440,7 +440,7 @@ struct Interpolator <aiQuaternion> {
template <>
struct Interpolator <unsigned int> {
void operator () (unsigned int& out,unsigned int a,
unsigned int b, float d) const
unsigned int b, ai_real d) const
{
out = d>0.5f ? b : a;
}
@@ -449,7 +449,7 @@ struct Interpolator <unsigned int> {
template <>
struct Interpolator <aiVectorKey> {
void operator () (aiVector3D& out,const aiVectorKey& a,
const aiVectorKey& b, float d) const
const aiVectorKey& b, ai_real d) const
{
Interpolator<aiVector3D> ipl;
ipl(out,a.mValue,b.mValue,d);
@@ -459,7 +459,7 @@ struct Interpolator <aiVectorKey> {
template <>
struct Interpolator <aiQuatKey> {
void operator () (aiQuaternion& out, const aiQuatKey& a,
const aiQuatKey& b, float d) const
const aiQuatKey& b, ai_real d) const
{
Interpolator<aiQuaternion> ipl;
ipl(out,a.mValue,b.mValue,d);
@@ -469,7 +469,7 @@ struct Interpolator <aiQuatKey> {
template <>
struct Interpolator <aiMeshKey> {
void operator () (unsigned int& out, const aiMeshKey& a,
const aiMeshKey& b, float d) const
const aiMeshKey& b, ai_real d) const
{
Interpolator<unsigned int> ipl;
ipl(out,a.mValue,b.mValue,d);
+3 -2
View File
@@ -46,6 +46,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define AI_COLOR4D_H_INC
#include "./Compiler/pushpack1.h"
#include "defs.h"
#ifdef __cplusplus
@@ -90,12 +91,12 @@ public:
TReal r, g, b, a;
} PACK_STRUCT; // !struct aiColor4D
typedef aiColor4t<float> aiColor4D;
typedef aiColor4t<ai_real> aiColor4D;
#else
struct aiColor4D {
float r, g, b, a;
ai_real r, g, b, a;
} PACK_STRUCT;
#endif // __cplusplus
+11 -4
View File
@@ -242,10 +242,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define AI_MATH_TWO_PI_F (AI_MATH_PI_F * 2.0f)
#define AI_MATH_HALF_PI_F (AI_MATH_PI_F * 0.5f)
/* Tiny macro to convert from radians to degrees and back */
#define AI_DEG_TO_RAD(x) ((x)*0.0174532925f)
#define AI_RAD_TO_DEG(x) ((x)*57.2957795f)
/* Support for big-endian builds */
#if defined(__BYTE_ORDER__)
# if (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
@@ -269,5 +265,16 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#define AI_MAX_ALLOC(type) ((256U * 1024 * 1024) / sizeof(type))
#ifdef AI_DOUBLE_PRECISION
typedef double ai_real;
/* Tiny macro to convert from radians to degrees and back */
#define AI_DEG_TO_RAD(x) ((x)*0.0174532925)
#define AI_RAD_TO_DEG(x) ((x)*57.2957795)
#else
typedef float ai_real;
/* Tiny macro to convert from radians to degrees and back */
#define AI_DEG_TO_RAD(x) ((x)*0.0174532925f)
#define AI_RAD_TO_DEG(x) ((x)*57.2957795f)
#endif // AI_SINGLEPRECISION
#endif // !! AI_DEFINES_H_INC
+4 -3
View File
@@ -477,13 +477,14 @@ struct aiUVTransform
* rotation center is 0.5f|0.5f. The default value
* 0.f.
*/
float mRotation;
ai_real mRotation;
#ifdef __cplusplus
aiUVTransform()
: mScaling (1.f,1.f)
, mRotation (0.f)
: mTranslation (0.0,0.0)
, mScaling (1.0,1.0)
, mRotation (0.0)
{
// nothing to be done here ...
}
+5 -4
View File
@@ -47,6 +47,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define AI_MATRIX3X3_H_INC
#include "./Compiler/pushpack1.h"
#include "defs.h"
#ifdef __cplusplus
@@ -166,14 +167,14 @@ public:
TReal c1, c2, c3;
} PACK_STRUCT;
typedef aiMatrix3x3t<float> aiMatrix3x3;
typedef aiMatrix3x3t<ai_real> aiMatrix3x3;
#else
struct aiMatrix3x3 {
float a1, a2, a3;
float b1, b2, b3;
float c1, c2, c3;
ai_real a1, a2, a3;
ai_real b1, b2, b3;
ai_real c1, c2, c3;
} PACK_STRUCT;
#endif // __cplusplus
+6 -5
View File
@@ -47,6 +47,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "vector3.h"
#include "./Compiler/pushpack1.h"
#include "defs.h"
#ifdef __cplusplus
@@ -229,15 +230,15 @@ public:
TReal d1, d2, d3, d4;
} PACK_STRUCT;
typedef aiMatrix4x4t<float> aiMatrix4x4;
typedef aiMatrix4x4t<ai_real> aiMatrix4x4;
#else
struct aiMatrix4x4 {
float a1, a2, a3, a4;
float b1, b2, b3, b4;
float c1, c2, c3, c4;
float d1, d2, d3, d4;
ai_real a1, a2, a3, a4;
ai_real b1, b2, b3, b4;
ai_real c1, c2, c3, c4;
ai_real d1, d2, d3, d4;
} PACK_STRUCT;
+7 -4
View File
@@ -68,8 +68,9 @@ typedef enum aiMetadataType
AI_INT = 1,
AI_UINT64 = 2,
AI_FLOAT = 3,
AI_AISTRING = 4,
AI_AIVECTOR3D = 5,
AI_DOUBLE = 4,
AI_AISTRING = 5,
AI_AIVECTOR3D = 6,
#ifndef SWIG
FORCE_32BIT = INT_MAX
@@ -108,6 +109,7 @@ inline aiMetadataType GetAiType( bool ) { return AI_BOOL; }
inline aiMetadataType GetAiType( int ) { return AI_INT; }
inline aiMetadataType GetAiType( uint64_t ) { return AI_UINT64; }
inline aiMetadataType GetAiType( float ) { return AI_FLOAT; }
inline aiMetadataType GetAiType( double ) { return AI_DOUBLE; }
inline aiMetadataType GetAiType( aiString ) { return AI_AISTRING; }
inline aiMetadataType GetAiType( aiVector3D ) { return AI_AIVECTOR3D; }
@@ -172,6 +174,9 @@ struct aiMetadata
case AI_FLOAT:
delete static_cast<float*>(data);
break;
case AI_DOUBLE:
delete static_cast<double*>(data);
break;
case AI_AISTRING:
delete static_cast<aiString*>(data);
break;
@@ -248,5 +253,3 @@ struct aiMetadata
};
#endif // AI_METADATA_H_INC
+4 -2
View File
@@ -47,6 +47,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifdef __cplusplus
#include "defs.h"
template <typename TReal> class aiVector3t;
template <typename TReal> class aiMatrix3x3t;
@@ -113,12 +115,12 @@ public:
TReal w, x, y, z;
} ;
typedef aiQuaterniont<float> aiQuaternion;
typedef aiQuaterniont<ai_real> aiQuaternion;
#else
struct aiQuaternion {
float w, x, y, z;
ai_real w, x, y, z;
};
#endif
+9 -9
View File
@@ -124,7 +124,7 @@ struct aiPlane
{
#ifdef __cplusplus
aiPlane () : a(0.f), b(0.f), c(0.f), d(0.f) {}
aiPlane (float _a, float _b, float _c, float _d)
aiPlane (ai_real _a, ai_real _b, ai_real _c, ai_real _d)
: a(_a), b(_b), c(_c), d(_d) {}
aiPlane (const aiPlane& o) : a(o.a), b(o.b), c(o.c), d(o.d) {}
@@ -132,7 +132,7 @@ struct aiPlane
#endif // !__cplusplus
//! Plane equation
float a,b,c,d;
ai_real a,b,c,d;
} PACK_STRUCT; // !struct aiPlane
// ----------------------------------------------------------------------------------
@@ -160,8 +160,8 @@ struct aiColor3D
{
#ifdef __cplusplus
aiColor3D () : r(0.0f), g(0.0f), b(0.0f) {}
aiColor3D (float _r, float _g, float _b) : r(_r), g(_g), b(_b) {}
explicit aiColor3D (float _r) : r(_r), g(_r), b(_r) {}
aiColor3D (ai_real _r, ai_real _g, ai_real _b) : r(_r), g(_g), b(_b) {}
explicit aiColor3D (ai_real _r) : r(_r), g(_r), b(_r) {}
aiColor3D (const aiColor3D& o) : r(o.r), g(o.g), b(o.b) {}
/** Component-wise comparison */
@@ -200,30 +200,30 @@ struct aiColor3D
}
/** Multiply with a scalar */
aiColor3D operator*(float f) const {
aiColor3D operator*(ai_real f) const {
return aiColor3D(r*f,g*f,b*f);
}
/** Access a specific color component */
float operator[](unsigned int i) const {
ai_real operator[](unsigned int i) const {
return *(&r + i);
}
/** Access a specific color component */
float& operator[](unsigned int i) {
ai_real& operator[](unsigned int i) {
return *(&r + i);
}
/** Check whether a color is black */
bool IsBlack() const {
static const float epsilon = 10e-3f;
static const ai_real epsilon = 10e-3;
return std::fabs( r ) < epsilon && std::fabs( g ) < epsilon && std::fabs( b ) < epsilon;
}
#endif // !__cplusplus
//! Red, green and blue color values
float r, g, b;
ai_real r, g, b;
} PACK_STRUCT; // !struct aiColor3D
#include "./Compiler/poppack1.h"
+3 -2
View File
@@ -52,6 +52,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#endif
#include "./Compiler/pushpack1.h"
#include "defs.h"
// ----------------------------------------------------------------------------------
/** Represents a two-dimensional vector.
@@ -99,12 +100,12 @@ public:
TReal x, y;
} PACK_STRUCT;
typedef aiVector2t<float> aiVector2D;
typedef aiVector2t<ai_real> aiVector2D;
#else
struct aiVector2D {
float x, y;
ai_real x, y;
};
#endif // __cplusplus
+3 -2
View File
@@ -52,6 +52,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#endif
#include "./Compiler/pushpack1.h"
#include "defs.h"
#ifdef __cplusplus
@@ -130,12 +131,12 @@ public:
} PACK_STRUCT;
typedef aiVector3t<float> aiVector3D;
typedef aiVector3t<ai_real> aiVector3D;
#else
struct aiVector3D {
float x, y, z;
ai_real x, y, z;
} PACK_STRUCT;
#endif // __cplusplus