CMake Option and moving more functions to optional double support
parent
2f7e3dcdcc
commit
5adb0e899c
|
@ -80,6 +80,15 @@ IF(NOT GIT_COMMIT_HASH)
|
|||
SET(GIT_COMMIT_HASH 0)
|
||||
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(
|
||||
${CMAKE_CURRENT_LIST_DIR}/revision.h.in
|
||||
# ${CMAKE_CURRENT_SOURCE_DIR}/revision.h.in
|
||||
|
|
|
@ -546,11 +546,11 @@ ASSIMP_API void aiSetImportPropertyInteger(aiPropertyStore* p, const char* szNam
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// 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();
|
||||
PropertyMap* pp = reinterpret_cast<PropertyMap*>(p);
|
||||
SetGenericProperty<float>(pp->floats,szName,value);
|
||||
SetGenericProperty<ai_real>(pp->floats,szName,value);
|
||||
ASSIMP_END_EXCEPTION_REGION(void);
|
||||
}
|
||||
|
||||
|
|
|
@ -534,9 +534,9 @@ bool ExportProperties :: SetPropertyInteger(const char* szName, int iValue)
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// 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
|
||||
float ExportProperties :: GetPropertyFloat(const char* szName,
|
||||
float iErrorReturn /*= 10e10*/) const
|
||||
ai_real ExportProperties :: GetPropertyFloat(const char* szName,
|
||||
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
|
||||
bool ExportProperties :: HasPropertyFloat(const char* szName) const
|
||||
{
|
||||
return HasGenericProperty<float>(mFloatProperties, szName);
|
||||
return HasGenericProperty<ai_real>(mFloatProperties, szName);
|
||||
};
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -78,8 +78,8 @@ bool GenVertexNormalsProcess::IsActive( unsigned int pFlags) const
|
|||
void GenVertexNormalsProcess::SetupProperties(const Importer* pImp)
|
||||
{
|
||||
// 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 = AI_DEG_TO_RAD(std::max(std::min(configMaxAngle,175.0f),0.0f));
|
||||
configMaxAngle = pImp->GetPropertyFloat(AI_CONFIG_PP_GSN_MAX_SMOOTHING_ANGLE,(ai_real)175.0);
|
||||
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
|
||||
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];
|
||||
|
||||
// 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.
|
||||
SpatialSort* vertexFinder = NULL;
|
||||
SpatialSort _vertexFinder;
|
||||
float posEpsilon = 1e-5f;
|
||||
ai_real posEpsilon = 1e-5;
|
||||
if (shared) {
|
||||
std::vector<std::pair<SpatialSort,float> >* avf;
|
||||
std::vector<std::pair<SpatialSort,ai_real> >* avf;
|
||||
shared->GetProperty(AI_SPP_SPATIAL_SORT,avf);
|
||||
if (avf)
|
||||
{
|
||||
std::pair<SpatialSort,float>& blubb = avf->operator [] (meshIndex);
|
||||
std::pair<SpatialSort,ai_real>& blubb = avf->operator [] (meshIndex);
|
||||
vertexFinder = &blubb.first;
|
||||
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
|
||||
// the effect, this one is the most straightforward one.
|
||||
else {
|
||||
const float fLimit = std::cos(configMaxAngle);
|
||||
const ai_real fLimit = std::cos(configMaxAngle);
|
||||
for (unsigned int i = 0; i < pMesh->mNumVertices;++i) {
|
||||
// Get all vertices that share this one ...
|
||||
vertexFinder->FindPositions( pMesh->mVertices[i] , posEpsilon, verticesFound);
|
||||
|
||||
aiVector3D vr = pMesh->mNormals[i];
|
||||
float vrlen = vr.Length();
|
||||
ai_real vrlen = vr.Length();
|
||||
|
||||
aiVector3D pcNor;
|
||||
for (unsigned int a = 0; a < verticesFound.size(); ++a) {
|
||||
|
|
|
@ -86,7 +86,7 @@ public:
|
|||
|
||||
|
||||
// setter for configMaxAngle
|
||||
inline void SetMaxSmoothAngle(float f)
|
||||
inline void SetMaxSmoothAngle(ai_real f)
|
||||
{
|
||||
configMaxAngle =f;
|
||||
}
|
||||
|
@ -104,10 +104,9 @@ public:
|
|||
private:
|
||||
|
||||
/** Configuration option: maximum smoothing angle, in radians*/
|
||||
float configMaxAngle;
|
||||
ai_real configMaxAngle;
|
||||
};
|
||||
|
||||
} // end of namespace Assimp
|
||||
|
||||
#endif // !!AI_GENVERTEXNORMALPROCESS_H_INC
|
||||
|
||||
|
|
|
@ -1017,11 +1017,11 @@ bool Importer::SetPropertyInteger(const char* szName, int iValue)
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Set a configuration property
|
||||
bool Importer::SetPropertyFloat(const char* szName, float iValue)
|
||||
bool Importer::SetPropertyFloat(const char* szName, ai_real iValue)
|
||||
{
|
||||
bool exising;
|
||||
ASSIMP_BEGIN_EXCEPTION_REGION();
|
||||
exising = SetGenericProperty<float>(pimpl->mFloatProperties, szName,iValue);
|
||||
exising = SetGenericProperty<ai_real>(pimpl->mFloatProperties, szName,iValue);
|
||||
ASSIMP_END_EXCEPTION_REGION(bool);
|
||||
return exising;
|
||||
}
|
||||
|
@ -1058,10 +1058,10 @@ int Importer::GetPropertyInteger(const char* szName,
|
|||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Get a configuration property
|
||||
float Importer::GetPropertyFloat(const char* szName,
|
||||
float iErrorReturn /*= 10e10*/) const
|
||||
ai_real Importer::GetPropertyFloat(const char* szName,
|
||||
ai_real iErrorReturn /*= 10e10*/) const
|
||||
{
|
||||
return GetGenericProperty<float>(pimpl->mFloatProperties,szName,iErrorReturn);
|
||||
return GetGenericProperty<ai_real>(pimpl->mFloatProperties,szName,iErrorReturn);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -223,7 +223,7 @@ PlyExporter::~PlyExporter() {
|
|||
// ------------------------------------------------------------------------------------------------
|
||||
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,
|
||||
// then default values are written for meshes that do not contain this component.
|
||||
|
|
|
@ -690,7 +690,7 @@ void PretransformVertices::Execute( aiScene* pScene)
|
|||
|
||||
// find the dominant axis
|
||||
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;
|
||||
for (unsigned int a = 0; a < pScene->mNumMeshes; ++a) {
|
||||
|
@ -721,4 +721,3 @@ void PretransformVertices::Execute( aiScene* pScene)
|
|||
DefaultLogger::get()->info(buffer);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
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 );
|
||||
|
||||
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
|
||||
aiVector3D minVec, maxVec, mi, ma;
|
||||
|
|
|
@ -231,7 +231,7 @@ inline void ArrayBounds(const T* in, unsigned int size, T& min, T& max)
|
|||
* @param pColor1 First color
|
||||
* @param pColor2 second color
|
||||
* @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);
|
||||
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
|
||||
float ComputePositionEpsilon(const aiMesh* pMesh);
|
||||
ai_real ComputePositionEpsilon(const aiMesh* pMesh);
|
||||
|
||||
|
||||
// -------------------------------------------------------------------------------
|
||||
// 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)
|
||||
{
|
||||
typedef std::pair<SpatialSort, float> _Type;
|
||||
typedef std::pair<SpatialSort, ai_real> _Type;
|
||||
DefaultLogger::get()->debug("Generate spatially-sorted vertex cache");
|
||||
|
||||
std::vector<_Type>* p = new std::vector<_Type>(pScene->mNumMeshes);
|
||||
|
|
Loading…
Reference in New Issue