CMake Option and moving more functions to optional double support

pull/947/head
Chris Russ 2016-07-15 13:20:16 +10:00
parent 2f7e3dcdcc
commit 5adb0e899c
10 changed files with 42 additions and 35 deletions

View File

@ -80,6 +80,15 @@ IF(NOT GIT_COMMIT_HASH)
SET(GIT_COMMIT_HASH 0) SET(GIT_COMMIT_HASH 0)
ENDIF(NOT GIT_COMMIT_HASH) ENDIF(NOT GIT_COMMIT_HASH)
OPTION(ASSIMP_DOUBLE_PRECISION
"Set to ON to enable double precision processing"
OFF
)
IF(ASSIMP_DOUBLE_PRECISION)
ADD_DEFINITIONS(-DAI_DOUBLE_PRECISION)
ENDIF(ASSIMP_DOUBLE_PRECISION)
configure_file( configure_file(
${CMAKE_CURRENT_LIST_DIR}/revision.h.in ${CMAKE_CURRENT_LIST_DIR}/revision.h.in
# ${CMAKE_CURRENT_SOURCE_DIR}/revision.h.in # ${CMAKE_CURRENT_SOURCE_DIR}/revision.h.in

View File

@ -546,11 +546,11 @@ ASSIMP_API void aiSetImportPropertyInteger(aiPropertyStore* p, const char* szNam
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Importer::SetPropertyFloat // Importer::SetPropertyFloat
ASSIMP_API void aiSetImportPropertyFloat(aiPropertyStore* p, const char* szName, float value) ASSIMP_API void aiSetImportPropertyFloat(aiPropertyStore* p, const char* szName, ai_real value)
{ {
ASSIMP_BEGIN_EXCEPTION_REGION(); ASSIMP_BEGIN_EXCEPTION_REGION();
PropertyMap* pp = reinterpret_cast<PropertyMap*>(p); PropertyMap* pp = reinterpret_cast<PropertyMap*>(p);
SetGenericProperty<float>(pp->floats,szName,value); SetGenericProperty<ai_real>(pp->floats,szName,value);
ASSIMP_END_EXCEPTION_REGION(void); ASSIMP_END_EXCEPTION_REGION(void);
} }

View File

@ -534,9 +534,9 @@ bool ExportProperties :: SetPropertyInteger(const char* szName, int iValue)
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Set a configuration property // Set a configuration property
bool ExportProperties :: SetPropertyFloat(const char* szName, float iValue) bool ExportProperties :: SetPropertyFloat(const char* szName, ai_real iValue)
{ {
return SetGenericProperty<float>(mFloatProperties, szName,iValue); return SetGenericProperty<ai_real>(mFloatProperties, szName,iValue);
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
@ -563,10 +563,10 @@ int ExportProperties :: GetPropertyInteger(const char* szName,
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Get a configuration property // Get a configuration property
float ExportProperties :: GetPropertyFloat(const char* szName, ai_real ExportProperties :: GetPropertyFloat(const char* szName,
float iErrorReturn /*= 10e10*/) const ai_real iErrorReturn /*= 10e10*/) const
{ {
return GetGenericProperty<float>(mFloatProperties,szName,iErrorReturn); return GetGenericProperty<ai_real>(mFloatProperties,szName,iErrorReturn);
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
@ -603,7 +603,7 @@ bool ExportProperties :: HasPropertyBool(const char* szName) const
// Has a configuration property // Has a configuration property
bool ExportProperties :: HasPropertyFloat(const char* szName) const bool ExportProperties :: HasPropertyFloat(const char* szName) const
{ {
return HasGenericProperty<float>(mFloatProperties, szName); return HasGenericProperty<ai_real>(mFloatProperties, szName);
}; };
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------

View File

@ -78,8 +78,8 @@ bool GenVertexNormalsProcess::IsActive( unsigned int pFlags) const
void GenVertexNormalsProcess::SetupProperties(const Importer* pImp) void GenVertexNormalsProcess::SetupProperties(const Importer* pImp)
{ {
// Get the current value of the AI_CONFIG_PP_GSN_MAX_SMOOTHING_ANGLE property // Get the current value of the AI_CONFIG_PP_GSN_MAX_SMOOTHING_ANGLE property
configMaxAngle = pImp->GetPropertyFloat(AI_CONFIG_PP_GSN_MAX_SMOOTHING_ANGLE,175.f); configMaxAngle = pImp->GetPropertyFloat(AI_CONFIG_PP_GSN_MAX_SMOOTHING_ANGLE,(ai_real)175.0);
configMaxAngle = AI_DEG_TO_RAD(std::max(std::min(configMaxAngle,175.0f),0.0f)); configMaxAngle = AI_DEG_TO_RAD(std::max(std::min(configMaxAngle,(ai_real)175.0),(ai_real)0.0));
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
@ -123,7 +123,7 @@ bool GenVertexNormalsProcess::GenMeshVertexNormals (aiMesh* pMesh, unsigned int
} }
// Allocate the array to hold the output normals // Allocate the array to hold the output normals
const float qnan = std::numeric_limits<float>::quiet_NaN(); const float qnan = std::numeric_limits<ai_real>::quiet_NaN();
pMesh->mNormals = new aiVector3D[pMesh->mNumVertices]; pMesh->mNormals = new aiVector3D[pMesh->mNumVertices];
// Compute per-face normals but store them per-vertex // Compute per-face normals but store them per-vertex
@ -154,13 +154,13 @@ bool GenVertexNormalsProcess::GenMeshVertexNormals (aiMesh* pMesh, unsigned int
// check whether we can reuse the SpatialSort of a previous step. // check whether we can reuse the SpatialSort of a previous step.
SpatialSort* vertexFinder = NULL; SpatialSort* vertexFinder = NULL;
SpatialSort _vertexFinder; SpatialSort _vertexFinder;
float posEpsilon = 1e-5f; ai_real posEpsilon = 1e-5;
if (shared) { if (shared) {
std::vector<std::pair<SpatialSort,float> >* avf; std::vector<std::pair<SpatialSort,ai_real> >* avf;
shared->GetProperty(AI_SPP_SPATIAL_SORT,avf); shared->GetProperty(AI_SPP_SPATIAL_SORT,avf);
if (avf) if (avf)
{ {
std::pair<SpatialSort,float>& blubb = avf->operator [] (meshIndex); std::pair<SpatialSort,ai_real>& blubb = avf->operator [] (meshIndex);
vertexFinder = &blubb.first; vertexFinder = &blubb.first;
posEpsilon = blubb.second; posEpsilon = blubb.second;
} }
@ -205,13 +205,13 @@ bool GenVertexNormalsProcess::GenMeshVertexNormals (aiMesh* pMesh, unsigned int
// Slower code path if a smooth angle is set. There are many ways to achieve // Slower code path if a smooth angle is set. There are many ways to achieve
// the effect, this one is the most straightforward one. // the effect, this one is the most straightforward one.
else { else {
const float fLimit = std::cos(configMaxAngle); const ai_real fLimit = std::cos(configMaxAngle);
for (unsigned int i = 0; i < pMesh->mNumVertices;++i) { for (unsigned int i = 0; i < pMesh->mNumVertices;++i) {
// Get all vertices that share this one ... // Get all vertices that share this one ...
vertexFinder->FindPositions( pMesh->mVertices[i] , posEpsilon, verticesFound); vertexFinder->FindPositions( pMesh->mVertices[i] , posEpsilon, verticesFound);
aiVector3D vr = pMesh->mNormals[i]; aiVector3D vr = pMesh->mNormals[i];
float vrlen = vr.Length(); ai_real vrlen = vr.Length();
aiVector3D pcNor; aiVector3D pcNor;
for (unsigned int a = 0; a < verticesFound.size(); ++a) { for (unsigned int a = 0; a < verticesFound.size(); ++a) {

View File

@ -86,7 +86,7 @@ public:
// setter for configMaxAngle // setter for configMaxAngle
inline void SetMaxSmoothAngle(float f) inline void SetMaxSmoothAngle(ai_real f)
{ {
configMaxAngle =f; configMaxAngle =f;
} }
@ -104,10 +104,9 @@ public:
private: private:
/** Configuration option: maximum smoothing angle, in radians*/ /** Configuration option: maximum smoothing angle, in radians*/
float configMaxAngle; ai_real configMaxAngle;
}; };
} // end of namespace Assimp } // end of namespace Assimp
#endif // !!AI_GENVERTEXNORMALPROCESS_H_INC #endif // !!AI_GENVERTEXNORMALPROCESS_H_INC

View File

@ -1017,11 +1017,11 @@ bool Importer::SetPropertyInteger(const char* szName, int iValue)
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Set a configuration property // Set a configuration property
bool Importer::SetPropertyFloat(const char* szName, float iValue) bool Importer::SetPropertyFloat(const char* szName, ai_real iValue)
{ {
bool exising; bool exising;
ASSIMP_BEGIN_EXCEPTION_REGION(); ASSIMP_BEGIN_EXCEPTION_REGION();
exising = SetGenericProperty<float>(pimpl->mFloatProperties, szName,iValue); exising = SetGenericProperty<ai_real>(pimpl->mFloatProperties, szName,iValue);
ASSIMP_END_EXCEPTION_REGION(bool); ASSIMP_END_EXCEPTION_REGION(bool);
return exising; return exising;
} }
@ -1058,10 +1058,10 @@ int Importer::GetPropertyInteger(const char* szName,
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Get a configuration property // Get a configuration property
float Importer::GetPropertyFloat(const char* szName, ai_real Importer::GetPropertyFloat(const char* szName,
float iErrorReturn /*= 10e10*/) const ai_real iErrorReturn /*= 10e10*/) const
{ {
return GetGenericProperty<float>(pimpl->mFloatProperties,szName,iErrorReturn); return GetGenericProperty<ai_real>(pimpl->mFloatProperties,szName,iErrorReturn);
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------

View File

@ -223,7 +223,7 @@ PlyExporter::~PlyExporter() {
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void PlyExporter::WriteMeshVerts(const aiMesh* m, unsigned int components) void PlyExporter::WriteMeshVerts(const aiMesh* m, unsigned int components)
{ {
static const float inf = std::numeric_limits<float>::infinity(); static const ai_real inf = std::numeric_limits<ai_real>::infinity();
// If a component (for instance normal vectors) is present in at least one mesh in the scene, // If a component (for instance normal vectors) is present in at least one mesh in the scene,
// then default values are written for meshes that do not contain this component. // then default values are written for meshes that do not contain this component.

View File

@ -690,7 +690,7 @@ void PretransformVertices::Execute( aiScene* pScene)
// find the dominant axis // find the dominant axis
aiVector3D d = max-min; aiVector3D d = max-min;
const float div = std::max(d.x,std::max(d.y,d.z))*0.5f; const ai_real div = std::max(d.x,std::max(d.y,d.z))*0.5;
d = min+d*0.5f; d = min+d*0.5f;
for (unsigned int a = 0; a < pScene->mNumMeshes; ++a) { for (unsigned int a = 0; a < pScene->mNumMeshes; ++a) {
@ -721,4 +721,3 @@ void PretransformVertices::Execute( aiScene* pScene)
DefaultLogger::get()->info(buffer); DefaultLogger::get()->info(buffer);
} }
} }

View File

@ -142,9 +142,9 @@ void FindMeshCenterTransformed (aiMesh* mesh, aiVector3D& out,
} }
// ------------------------------------------------------------------------------- // -------------------------------------------------------------------------------
float ComputePositionEpsilon(const aiMesh* pMesh) ai_real ComputePositionEpsilon(const aiMesh* pMesh)
{ {
const float epsilon = 1e-4f; const ai_real epsilon = 1e-4;
// calculate the position bounds so we have a reliable epsilon to check position differences against // calculate the position bounds so we have a reliable epsilon to check position differences against
aiVector3D minVec, maxVec; aiVector3D minVec, maxVec;
@ -153,11 +153,11 @@ float ComputePositionEpsilon(const aiMesh* pMesh)
} }
// ------------------------------------------------------------------------------- // -------------------------------------------------------------------------------
float ComputePositionEpsilon(const aiMesh* const* pMeshes, size_t num) ai_real ComputePositionEpsilon(const aiMesh* const* pMeshes, size_t num)
{ {
ai_assert( NULL != pMeshes ); ai_assert( NULL != pMeshes );
const float epsilon = 1e-4f; const ai_real epsilon = 1e-4;
// calculate the position bounds so we have a reliable epsilon to check position differences against // calculate the position bounds so we have a reliable epsilon to check position differences against
aiVector3D minVec, maxVec, mi, ma; aiVector3D minVec, maxVec, mi, ma;

View File

@ -231,7 +231,7 @@ inline void ArrayBounds(const T* in, unsigned int size, T& min, T& max)
* @param pColor1 First color * @param pColor1 First color
* @param pColor2 second color * @param pColor2 second color
* @return Quadratic color difference */ * @return Quadratic color difference */
inline float GetColorDifference( const aiColor4D& pColor1, const aiColor4D& pColor2) inline ai_real GetColorDifference( const aiColor4D& pColor1, const aiColor4D& pColor2)
{ {
const aiColor4D c (pColor1.r - pColor2.r, pColor1.g - pColor2.g, pColor1.b - pColor2.b, pColor1.a - pColor2.a); const aiColor4D c (pColor1.r - pColor2.r, pColor1.g - pColor2.g, pColor1.b - pColor2.b, pColor1.a - pColor2.a);
return c.r*c.r + c.g*c.g + c.b*c.b + c.a*c.a; return c.r*c.r + c.g*c.g + c.b*c.b + c.a*c.a;
@ -293,12 +293,12 @@ void FindMeshCenterTransformed (aiMesh* mesh, aiVector3D& out,const aiMatrix4x4&
// ------------------------------------------------------------------------------- // -------------------------------------------------------------------------------
// Compute a good epsilon value for position comparisons on a mesh // Compute a good epsilon value for position comparisons on a mesh
float ComputePositionEpsilon(const aiMesh* pMesh); ai_real ComputePositionEpsilon(const aiMesh* pMesh);
// ------------------------------------------------------------------------------- // -------------------------------------------------------------------------------
// Compute a good epsilon value for position comparisons on a array of meshes // Compute a good epsilon value for position comparisons on a array of meshes
float ComputePositionEpsilon(const aiMesh* const* pMeshes, size_t num); ai_real ComputePositionEpsilon(const aiMesh* const* pMeshes, size_t num);
// ------------------------------------------------------------------------------- // -------------------------------------------------------------------------------
@ -345,7 +345,7 @@ class ComputeSpatialSortProcess : public BaseProcess
void Execute( aiScene* pScene) void Execute( aiScene* pScene)
{ {
typedef std::pair<SpatialSort, float> _Type; typedef std::pair<SpatialSort, ai_real> _Type;
DefaultLogger::get()->debug("Generate spatially-sorted vertex cache"); DefaultLogger::get()->debug("Generate spatially-sorted vertex cache");
std::vector<_Type>* p = new std::vector<_Type>(pScene->mNumMeshes); std::vector<_Type>* p = new std::vector<_Type>(pScene->mNumMeshes);