diff --git a/.gitignore b/.gitignore index 1b6acd509..d0d5e9631 100644 --- a/.gitignore +++ b/.gitignore @@ -18,6 +18,7 @@ assimp.pc revision.h contrib/zlib/zconf.h contrib/zlib/zlib.pc +include/assimp/config.h # CMake CMakeCache.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 2b398e0ff..67fd67f94 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -80,15 +80,30 @@ 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 ${CMAKE_CURRENT_BINARY_DIR}/revision.h ) +configure_file( + ${CMAKE_CURRENT_LIST_DIR}/include/assimp/config.h.in + ${CMAKE_CURRENT_LIST_DIR}/include/assimp/config.h +) + include_directories( ./ ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_BINARY_DIR}/include ) OPTION(ASSIMP_OPT_BUILD_PACKAGES "Set to ON to generate CPack configuration files and packaging targets" OFF) diff --git a/code/3DSConverter.cpp b/code/3DSConverter.cpp index cb6fd9077..619360524 100644 --- a/code/3DSConverter.cpp +++ b/code/3DSConverter.cpp @@ -197,7 +197,7 @@ void CopyTexture(aiMaterial& mat, D3DS::Texture& texture, aiTextureType type) // Setup the texture blend factor if (is_not_qnan(texture.mTextureBlend)) - mat.AddProperty( &texture.mTextureBlend, 1, AI_MATKEY_TEXBLEND(type,0)); + mat.AddProperty( &texture.mTextureBlend, 1, AI_MATKEY_TEXBLEND(type,0)); // Setup the texture mapping mode mat.AddProperty((int*)&texture.mMapMode,1,AI_MATKEY_MAPPINGMODE_U(type,0)); @@ -207,14 +207,14 @@ void CopyTexture(aiMaterial& mat, D3DS::Texture& texture, aiTextureType type) // FIXME: this is not really correct ... if (texture.mMapMode == aiTextureMapMode_Mirror) { - texture.mScaleU *= 2.f; - texture.mScaleV *= 2.f; - texture.mOffsetU /= 2.f; - texture.mOffsetV /= 2.f; + texture.mScaleU *= 2.0; + texture.mScaleV *= 2.0; + texture.mOffsetU /= 2.0; + texture.mOffsetV /= 2.0; } // Setup texture UV transformations - mat.AddProperty(&texture.mOffsetU,5,AI_MATKEY_UVTRANSFORM(type,0)); + mat.AddProperty(&texture.mOffsetU,5,AI_MATKEY_UVTRANSFORM(type,0)); } // ------------------------------------------------------------------------------------------------ @@ -265,10 +265,10 @@ void Discreet3DSImporter::ConvertMaterial(D3DS::Material& oldMat, } // Opacity - mat.AddProperty( &oldMat.mTransparency,1,AI_MATKEY_OPACITY); + mat.AddProperty( &oldMat.mTransparency,1,AI_MATKEY_OPACITY); // Bump height scaling - mat.AddProperty( &oldMat.mBumpHeight,1,AI_MATKEY_BUMPSCALING); + mat.AddProperty( &oldMat.mBumpHeight,1,AI_MATKEY_BUMPSCALING); // Two sided rendering? if (oldMat.mTwoSided) diff --git a/code/3DSHelper.h b/code/3DSHelper.h index 5911b9d47..e2979bd0f 100644 --- a/code/3DSHelper.h +++ b/code/3DSHelper.h @@ -327,11 +327,11 @@ struct Texture { //! Default constructor Texture() - : mOffsetU (0.0f) - , mOffsetV (0.0f) - , mScaleU (1.0f) - , mScaleV (1.0f) - , mRotation (0.0f) + : mOffsetU (0.0) + , mOffsetV (0.0) + , mScaleU (1.0) + , mScaleV (1.0) + , mRotation (0.0) , mMapMode (aiTextureMapMode_Wrap) , bPrivate() , iUVSrc (0) @@ -340,17 +340,17 @@ struct Texture } //! Specifies the blend factor for the texture - float mTextureBlend; + ai_real mTextureBlend; //! Specifies the filename of the texture std::string mMapName; //! Specifies texture coordinate offsets/scaling/rotations - float mOffsetU; - float mOffsetV; - float mScaleU; - float mScaleV; - float mRotation; + ai_real mOffsetU; + ai_real mOffsetV; + ai_real mScaleU; + ai_real mScaleV; + ai_real mRotation; //! Specifies the mapping mode to be used for the texture aiTextureMapMode mMapMode; @@ -369,12 +369,12 @@ struct Material //! Default constructor. Builds a default name for the material Material() : - mDiffuse (0.6f,0.6f,0.6f), // FIX ... we won't want object to be black - mSpecularExponent (0.0f), - mShininessStrength (1.0f), + mDiffuse (0.6,0.6,0.6), // FIX ... we won't want object to be black + mSpecularExponent (0.0), + mShininessStrength (1.0), mShading(Discreet3DS::Gouraud), - mTransparency (1.0f), - mBumpHeight (1.0f), + mTransparency (1.0), + mBumpHeight (1.0), mTwoSided (false) { static int iCnt = 0; @@ -389,9 +389,9 @@ struct Material //! Diffuse color of the material aiColor3D mDiffuse; //! Specular exponent - float mSpecularExponent; + ai_real mSpecularExponent; //! Shininess strength, in percent - float mShininessStrength; + ai_real mShininessStrength; //! Specular color of the material aiColor3D mSpecular; //! Ambient color of the material @@ -399,7 +399,7 @@ struct Material //! Shading type to be used Discreet3DS::shadetype3ds mShading; //! Opacity of the material - float mTransparency; + ai_real mTransparency; //! Diffuse texture channel Texture sTexDiffuse; //! Opacity texture channel @@ -415,7 +415,7 @@ struct Material //! Shininess texture channel Texture sTexShininess; //! Scaling factor for the bump values - float mBumpHeight; + ai_real mBumpHeight; //! Emissive color aiColor3D mEmissive; //! Ambient texture channel @@ -459,7 +459,7 @@ struct Mesh : public MeshWithSmoothingGroups struct aiFloatKey { double mTime; ///< The time of this key - float mValue; ///< The value of this key + ai_real mValue; ///< The value of this key #ifdef __cplusplus diff --git a/code/3DSLoader.cpp b/code/3DSLoader.cpp index a2b73b2cb..59d598f20 100644 --- a/code/3DSLoader.cpp +++ b/code/3DSLoader.cpp @@ -458,20 +458,20 @@ void Discreet3DSImporter::ParseChunk(const char* name, unsigned int num) camera->mLookAt.x = stream->GetF4() - camera->mPosition.x; camera->mLookAt.y = stream->GetF4() - camera->mPosition.y; camera->mLookAt.z = stream->GetF4() - camera->mPosition.z; - float len = camera->mLookAt.Length(); - if (len < 1e-5f) { + ai_real len = camera->mLookAt.Length(); + if (len < 1e-5) { // There are some files with lookat == position. Don't know why or whether it's ok or not. DefaultLogger::get()->error("3DS: Unable to read proper camera look-at vector"); - camera->mLookAt = aiVector3D(0.f,1.f,0.f); + camera->mLookAt = aiVector3D(0.0,1.0,0.0); } else camera->mLookAt /= len; // And finally - the camera rotation angle, in counter clockwise direction - const float angle = AI_DEG_TO_RAD( stream->GetF4() ); + const ai_real angle = AI_DEG_TO_RAD( stream->GetF4() ); aiQuaternion quat(camera->mLookAt,angle); - camera->mUp = quat.GetMatrix() * aiVector3D(0.f,1.f,0.f); + camera->mUp = quat.GetMatrix() * aiVector3D(0.0,1.0,0.0); // Read the lense angle camera->mHorizontalFOV = AI_DEG_TO_RAD ( stream->GetF4() ); @@ -1167,13 +1167,13 @@ void Discreet3DSImporter::ParseMaterialChunk() case Discreet3DS::CHUNK_MAT_TRANSPARENCY: { // This is the material's transparency - float* pcf = &mScene->mMaterials.back().mTransparency; + ai_real* pcf = &mScene->mMaterials.back().mTransparency; *pcf = ParsePercentageChunk(); // NOTE: transparency, not opacity if (is_qnan(*pcf)) - *pcf = 1.0f; - else *pcf = 1.0f - *pcf * (float)0xFFFF / 100.0f; + *pcf = 1.0; + else *pcf = 1.0 - *pcf * (ai_real)0xFFFF / 100.0; } break; @@ -1189,30 +1189,30 @@ void Discreet3DSImporter::ParseMaterialChunk() case Discreet3DS::CHUNK_MAT_SHININESS: { // This is the shininess of the material - float* pcf = &mScene->mMaterials.back().mSpecularExponent; + ai_real* pcf = &mScene->mMaterials.back().mSpecularExponent; *pcf = ParsePercentageChunk(); if (is_qnan(*pcf)) - *pcf = 0.0f; - else *pcf *= (float)0xFFFF; + *pcf = 0.0; + else *pcf *= (ai_real)0xFFFF; } break; case Discreet3DS::CHUNK_MAT_SHININESS_PERCENT: { // This is the shininess strength of the material - float* pcf = &mScene->mMaterials.back().mShininessStrength; + ai_real* pcf = &mScene->mMaterials.back().mShininessStrength; *pcf = ParsePercentageChunk(); if (is_qnan(*pcf)) - *pcf = 0.0f; - else *pcf *= (float)0xffff / 100.0f; + *pcf = 0.0; + else *pcf *= (ai_real)0xffff / 100.0; } break; case Discreet3DS::CHUNK_MAT_SELF_ILPCT: { // This is the self illumination strength of the material - float f = ParsePercentageChunk(); + ai_real f = ParsePercentageChunk(); if (is_qnan(f)) - f = 0.0f; - else f *= (float)0xFFFF / 100.0f; + f = 0.0; + else f *= (ai_real)0xFFFF / 100.0; mScene->mMaterials.back().mEmissive = aiColor3D(f,f,f); } break; @@ -1277,7 +1277,7 @@ void Discreet3DSImporter::ParseTextureChunk(D3DS::Texture* pcOut) case Discreet3DS::CHUNK_PERCENTW: // Manually parse the blend factor - pcOut->mTextureBlend = (float)((uint16_t)stream->GetI2()) / 100.0f; + pcOut->mTextureBlend = (ai_real)((uint16_t)stream->GetI2()) / 100.0; break; case Discreet3DS::CHUNK_MAT_MAP_USCALE: @@ -1336,7 +1336,7 @@ void Discreet3DSImporter::ParseTextureChunk(D3DS::Texture* pcOut) // ------------------------------------------------------------------------------------------------ // Read a percentage chunk -float Discreet3DSImporter::ParsePercentageChunk() +ai_real Discreet3DSImporter::ParsePercentageChunk() { Discreet3DS::Chunk chunk; ReadChunk(&chunk); @@ -1344,7 +1344,7 @@ float Discreet3DSImporter::ParsePercentageChunk() if (Discreet3DS::CHUNK_PERCENTF == chunk.Flag) return stream->GetF4(); else if (Discreet3DS::CHUNK_PERCENTW == chunk.Flag) - return (float)((uint16_t)stream->GetI2()) / (float)0xFFFF; + return (ai_real)((uint16_t)stream->GetI2()) / (ai_real)0xFFFF; return get_qnan(); } @@ -1356,7 +1356,7 @@ void Discreet3DSImporter::ParseColorChunk(aiColor3D* out, ai_assert(out != NULL); // error return value - const float qnan = get_qnan(); + const ai_real qnan = get_qnan(); static const aiColor3D clrError = aiColor3D(qnan,qnan,qnan); Discreet3DS::Chunk chunk; @@ -1372,7 +1372,7 @@ void Discreet3DSImporter::ParseColorChunk(aiColor3D* out, bGamma = true; case Discreet3DS::CHUNK_RGBF: - if (sizeof(float) * 3 > diff) { + if (sizeof(ai_real) * 3 > diff) { *out = clrError; return; } @@ -1388,9 +1388,9 @@ void Discreet3DSImporter::ParseColorChunk(aiColor3D* out, *out = clrError; return; } - out->r = (float)(uint8_t)stream->GetI1() / 255.0f; - out->g = (float)(uint8_t)stream->GetI1() / 255.0f; - out->b = (float)(uint8_t)stream->GetI1() / 255.0f; + out->r = (ai_real)(uint8_t)stream->GetI1() / 255.0; + out->g = (ai_real)(uint8_t)stream->GetI1() / 255.0; + out->b = (ai_real)(uint8_t)stream->GetI1() / 255.0; break; // Percentage chunks are accepted, too. @@ -1404,7 +1404,7 @@ void Discreet3DSImporter::ParseColorChunk(aiColor3D* out, case Discreet3DS::CHUNK_PERCENTW: if (acceptPercent && 1 <= diff) { - out->g = out->b = out->r = (float)(uint8_t)stream->GetI1() / 255.0f; + out->g = out->b = out->r = (ai_real)(uint8_t)stream->GetI1() / 255.0; break; } *out = clrError; diff --git a/code/3DSLoader.h b/code/3DSLoader.h index 437ec94b4..26b2a935e 100644 --- a/code/3DSLoader.h +++ b/code/3DSLoader.h @@ -119,7 +119,7 @@ protected: * chunk behind afterwards. If no percentage chunk is found * QNAN is returned. */ - float ParsePercentageChunk(); + ai_real ParsePercentageChunk(); // ------------------------------------------------------------------- /** Parse a color chunk. mCurrent will point to the next @@ -265,7 +265,7 @@ protected: aiColor3D mClrAmbient; /** Master scaling factor of the scene */ - float mMasterScale; + ai_real mMasterScale; /** Path to the background image of the scene */ std::string mBackgroundImage; diff --git a/code/ASELoader.cpp b/code/ASELoader.cpp index 39a33e9fd..ed01c17e1 100644 --- a/code/ASELoader.cpp +++ b/code/ASELoader.cpp @@ -819,10 +819,10 @@ void CopyASETexture(aiMaterial& mat, ASE::Texture& texture, aiTextureType type) // Setup the texture blend factor if (is_not_qnan(texture.mTextureBlend)) - mat.AddProperty( &texture.mTextureBlend, 1, AI_MATKEY_TEXBLEND(type,0)); + mat.AddProperty( &texture.mTextureBlend, 1, AI_MATKEY_TEXBLEND(type,0)); // Setup texture UV transformations - mat.AddProperty(&texture.mOffsetU,5,AI_MATKEY_UVTRANSFORM(type,0)); + mat.AddProperty(&texture.mOffsetU,5,AI_MATKEY_UVTRANSFORM(type,0)); } // ------------------------------------------------------------------------------------------------ @@ -865,7 +865,7 @@ void ASEImporter::ConvertMaterial(ASE::Material& mat) } // opacity - mat.pcInstance->AddProperty( &mat.mTransparency,1,AI_MATKEY_OPACITY); + mat.pcInstance->AddProperty( &mat.mTransparency,1,AI_MATKEY_OPACITY); // Two sided rendering? if (mat.mTwoSided) diff --git a/code/ASEParser.cpp b/code/ASEParser.cpp index 204f8bf62..01c58d259 100644 --- a/code/ASEParser.cpp +++ b/code/ASEParser.cpp @@ -431,7 +431,7 @@ void Parser::ParseLV1SoftSkinBlock() ParseString(bone,"*MESH_SOFTSKINVERTS.Bone"); // Find the bone in the mesh's list - std::pair me; + std::pair me; me.first = -1; for (unsigned int n = 0; n < curMesh->mBones.size();++n) @@ -618,12 +618,12 @@ void Parser::ParseLV2MaterialBlock(ASE::Material& mat) if (TokenMatch(filePtr,"MATERIAL_TRANSPARENCY",21)) { ParseLV4MeshFloat(mat.mTransparency); - mat.mTransparency = 1.0f - mat.mTransparency;continue; + mat.mTransparency = 1.0 - mat.mTransparency;continue; } // material self illumination if (TokenMatch(filePtr,"MATERIAL_SELFILLUM",18)) { - float f = 0.0f; + ai_real f = 0.0; ParseLV4MeshFloat(f); mat.mEmissive.r = f; @@ -1251,7 +1251,7 @@ void Parser::ParseLV3RotAnimationBlock(ASE::Animation& anim) { anim.akeyRotations.push_back(aiQuatKey()); aiQuatKey& key = anim.akeyRotations.back(); - aiVector3D v;float f; + aiVector3D v;ai_real f; ParseLV4MeshFloatTriple(&v.x,iIndex); ParseLV4MeshFloat(f); key.mTime = (double)iIndex; @@ -1604,7 +1604,7 @@ void Parser::ParseLV4MeshBonesVertices(unsigned int iNumVertices,ASE::Mesh& mesh } // --- ignored - float afVert[3]; + ai_real afVert[3]; ParseLV4MeshFloatTriple(afVert); std::pair pairOut; @@ -2102,7 +2102,7 @@ void Parser::ParseLV4MeshLongTriple(unsigned int* apOut, unsigned int& rIndexOut ParseLV4MeshLongTriple(apOut); } // ------------------------------------------------------------------------------------------------ -void Parser::ParseLV4MeshFloatTriple(float* apOut, unsigned int& rIndexOut) +void Parser::ParseLV4MeshFloatTriple(ai_real* apOut, unsigned int& rIndexOut) { ai_assert(NULL != apOut); @@ -2113,7 +2113,7 @@ void Parser::ParseLV4MeshFloatTriple(float* apOut, unsigned int& rIndexOut) ParseLV4MeshFloatTriple(apOut); } // ------------------------------------------------------------------------------------------------ -void Parser::ParseLV4MeshFloatTriple(float* apOut) +void Parser::ParseLV4MeshFloatTriple(ai_real* apOut) { ai_assert(NULL != apOut); @@ -2121,19 +2121,19 @@ void Parser::ParseLV4MeshFloatTriple(float* apOut) ParseLV4MeshFloat(apOut[i]); } // ------------------------------------------------------------------------------------------------ -void Parser::ParseLV4MeshFloat(float& fOut) +void Parser::ParseLV4MeshFloat(ai_real& fOut) { // skip spaces and tabs if(!SkipSpaces(&filePtr)) { // LOG LogWarning("Unable to parse float: unexpected EOL [#1]"); - fOut = 0.0f; + fOut = 0.0; ++iLineNumber; return; } // parse the first float - filePtr = fast_atoreal_move(filePtr,fOut); + filePtr = fast_atoreal_move(filePtr,fOut); } // ------------------------------------------------------------------------------------------------ void Parser::ParseLV4MeshLong(unsigned int& iOut) diff --git a/code/ASEParser.h b/code/ASEParser.h index 667c7c5a0..095d089d4 100644 --- a/code/ASEParser.h +++ b/code/ASEParser.h @@ -222,7 +222,7 @@ struct BaseNode mName = szTemp; // Set mTargetPosition to qnan - const float qnan = get_qnan(); + const ai_real qnan = get_qnan(); mTargetPosition.x = qnan; } @@ -317,9 +317,9 @@ struct Light : public BaseNode LightType mLightType; aiColor3D mColor; - float mIntensity; - float mAngle; // in degrees - float mFalloff; + ai_real mIntensity; + ai_real mAngle; // in degrees + ai_real mFalloff; }; // --------------------------------------------------------------------------- @@ -342,7 +342,7 @@ struct Camera : public BaseNode { } - float mFOV, mNear, mFar; + ai_real mFOV, mNear, mFar; CameraType mCameraType; }; @@ -544,13 +544,13 @@ private: //! (also works for MESH_TVERT, MESH_CFACE, MESH_VERTCOL ...) //! \param apOut Output buffer (3 floats) //! \param rIndexOut Output index - void ParseLV4MeshFloatTriple(float* apOut, unsigned int& rIndexOut); + void ParseLV4MeshFloatTriple(ai_real* apOut, unsigned int& rIndexOut); // ------------------------------------------------------------------- //! Parse a *MESH_VERT block in a file //! (also works for MESH_TVERT, MESH_CFACE, MESH_VERTCOL ...) //! \param apOut Output buffer (3 floats) - void ParseLV4MeshFloatTriple(float* apOut); + void ParseLV4MeshFloatTriple(ai_real* apOut); // ------------------------------------------------------------------- //! Parse a *MESH_TFACE block in a file @@ -568,7 +568,7 @@ private: // ------------------------------------------------------------------- //! Parse a single float element //! \param fOut Output float - void ParseLV4MeshFloat(float& fOut); + void ParseLV4MeshFloat(ai_real& fOut); // ------------------------------------------------------------------- //! Parse a single int element diff --git a/code/Assimp.cpp b/code/Assimp.cpp index 8507c8641..c28da95ee 100644 --- a/code/Assimp.cpp +++ b/code/Assimp.cpp @@ -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(p); - SetGenericProperty(pp->floats,szName,value); + SetGenericProperty(pp->floats,szName,value); ASSIMP_END_EXCEPTION_REGION(void); } diff --git a/code/BlenderTessellator.cpp b/code/BlenderTessellator.cpp index bea00e228..c29b27de1 100644 --- a/code/BlenderTessellator.cpp +++ b/code/BlenderTessellator.cpp @@ -50,7 +50,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "BlenderBMesh.h" #include "BlenderTessellator.h" -#include +#include static const unsigned int BLEND_TESS_MAGIC = 0x83ed9ac3; @@ -470,19 +470,19 @@ PlaneP2T BlenderTessellatorP2T::FindLLSQPlane( const std::vector< PointP2T >& po { PlaneP2T result; - aiVector3D sum( 0.0f ); + aiVector3D sum( 0.0 ); for ( size_t i = 0; i < points.size( ); ++i ) { sum += points[ i ].point3D; } - result.centre = sum * ( 1.0f / points.size( ) ); + result.centre = sum * (ai_real)( 1.0 / points.size( ) ); - float sumXX = 0.0f; - float sumXY = 0.0f; - float sumXZ = 0.0f; - float sumYY = 0.0f; - float sumYZ = 0.0f; - float sumZZ = 0.0f; + ai_real sumXX = 0.0; + ai_real sumXY = 0.0; + ai_real sumXZ = 0.0; + ai_real sumYY = 0.0; + ai_real sumYZ = 0.0; + ai_real sumZZ = 0.0; for ( size_t i = 0; i < points.size( ); ++i ) { aiVector3D offset = points[ i ].point3D - result.centre; @@ -496,7 +496,7 @@ PlaneP2T BlenderTessellatorP2T::FindLLSQPlane( const std::vector< PointP2T >& po aiMatrix3x3 mtx( sumXX, sumXY, sumXZ, sumXY, sumYY, sumYZ, sumXZ, sumYZ, sumZZ ); - const float det = mtx.Determinant( ); + const ai_real det = mtx.Determinant( ); if ( det == 0.0f ) { result.normal = aiVector3D( 0.0f ); diff --git a/code/ColladaExporter.cpp b/code/ColladaExporter.cpp index 1f666bb5a..48629ce05 100644 --- a/code/ColladaExporter.cpp +++ b/code/ColladaExporter.cpp @@ -149,7 +149,7 @@ void ColladaExporter::WriteFile() // Writes the asset header void ColladaExporter::WriteHeader() { - static const float epsilon = 0.00001f; + static const ai_real epsilon = 0.00001; static const aiQuaternion x_rot(aiMatrix3x3( 0, -1, 0, 1, 0, 0, @@ -176,9 +176,9 @@ void ColladaExporter::WriteHeader() bool add_root_node = false; - float scale = 1.0; + ai_real scale = 1.0; if(std::abs(scaling.x - scaling.y) <= epsilon && std::abs(scaling.x - scaling.z) <= epsilon && std::abs(scaling.y - scaling.z) <= epsilon) { - scale = (float) ((((double) scaling.x) + ((double) scaling.y) + ((double) scaling.z)) / 3.0); + scale = (ai_real) ((((double) scaling.x) + ((double) scaling.y) + ((double) scaling.z)) / 3.0); } else { add_root_node = true; } @@ -450,7 +450,7 @@ void ColladaExporter::WriteSpotLight(const aiLight *const light){ srcLight->mFalloffAngle); */ - const float fallOffAngle = AI_RAD_TO_DEG(light->mAngleInnerCone); + const ai_real fallOffAngle = AI_RAD_TO_DEG(light->mAngleInnerCone); mOutput << startstr <<"" << fallOffAngle <<"" << endstr; @@ -803,10 +803,10 @@ void ColladaExporter::WriteGeometry( size_t pIndex) PushTag(); // Positions - WriteFloatArray( idstr + "-positions", FloatType_Vector, (float*) mesh->mVertices, mesh->mNumVertices); + WriteFloatArray( idstr + "-positions", FloatType_Vector, (ai_real*) mesh->mVertices, mesh->mNumVertices); // Normals, if any if( mesh->HasNormals() ) - WriteFloatArray( idstr + "-normals", FloatType_Vector, (float*) mesh->mNormals, mesh->mNumVertices); + WriteFloatArray( idstr + "-normals", FloatType_Vector, (ai_real*) mesh->mNormals, mesh->mNumVertices); // texture coords for( size_t a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++a) @@ -814,7 +814,7 @@ void ColladaExporter::WriteGeometry( size_t pIndex) if( mesh->HasTextureCoords( a) ) { WriteFloatArray( idstr + "-tex" + std::to_string(a), mesh->mNumUVComponents[a] == 3 ? FloatType_TexCoord3 : FloatType_TexCoord2, - (float*) mesh->mTextureCoords[a], mesh->mNumVertices); + (ai_real*) mesh->mTextureCoords[a], mesh->mNumVertices); } } @@ -822,7 +822,7 @@ void ColladaExporter::WriteGeometry( size_t pIndex) for( size_t a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++a) { if( mesh->HasVertexColors( a) ) - WriteFloatArray( idstr + "-color" + std::to_string(a), FloatType_Color, (float*) mesh->mColors[a], mesh->mNumVertices); + WriteFloatArray( idstr + "-color" + std::to_string(a), FloatType_Color, (ai_real*) mesh->mColors[a], mesh->mNumVertices); } // assemble vertex structure @@ -917,7 +917,7 @@ void ColladaExporter::WriteGeometry( size_t pIndex) // ------------------------------------------------------------------------------------------------ // Writes a float array of the given type -void ColladaExporter::WriteFloatArray( const std::string& pIdString, FloatDataType pType, const float* pData, size_t pElementCount) +void ColladaExporter::WriteFloatArray( const std::string& pIdString, FloatDataType pType, const ai_real* pData, size_t pElementCount) { size_t floatsPerElement = 0; switch( pType ) diff --git a/code/ColladaExporter.h b/code/ColladaExporter.h index 5e73628eb..ffb841b0e 100644 --- a/code/ColladaExporter.h +++ b/code/ColladaExporter.h @@ -108,7 +108,7 @@ protected: enum FloatDataType { FloatType_Vector, FloatType_TexCoord2, FloatType_TexCoord3, FloatType_Color }; /// Writes a float array of the given type - void WriteFloatArray( const std::string& pIdString, FloatDataType pType, const float* pData, size_t pElementCount); + void WriteFloatArray( const std::string& pIdString, FloatDataType pType, const ai_real* pData, size_t pElementCount); /// Writes the scene library void WriteSceneLibrary(); @@ -160,10 +160,10 @@ protected: struct Property { bool exist; - float value; + ai_real value; Property() : exist(false) - , value(0.0f) + , value(0.0) {} }; diff --git a/code/ColladaHelper.h b/code/ColladaHelper.h index 5a516429c..a3cba264b 100644 --- a/code/ColladaHelper.h +++ b/code/ColladaHelper.h @@ -94,7 +94,7 @@ struct Transform { std::string mID; ///< SID of the transform step, by which anim channels address their target node TransformType mType; - float f[16]; ///< Interpretation of data depends on the type of the transformation + ai_real f[16]; ///< Interpretation of data depends on the type of the transformation }; /** A collada camera. */ @@ -116,16 +116,16 @@ struct Camera bool mOrtho; //! Horizontal field of view in degrees - float mHorFov; + ai_real mHorFov; //! Vertical field of view in degrees - float mVerFov; + ai_real mVerFov; //! Screen aspect - float mAspect; + ai_real mAspect; //! Near& far z - float mZNear, mZFar; + ai_real mZNear, mZFar; }; #define ASSIMP_COLLADA_LIGHT_ANGLE_NOT_SET 1e9f @@ -152,21 +152,21 @@ struct Light aiColor3D mColor; //! Light attenuation - float mAttConstant,mAttLinear,mAttQuadratic; + ai_real mAttConstant,mAttLinear,mAttQuadratic; //! Spot light falloff - float mFalloffAngle; - float mFalloffExponent; + ai_real mFalloffAngle; + ai_real mFalloffExponent; // ----------------------------------------------------- // FCOLLADA extension from here //! ... related stuff from maja and max extensions - float mPenumbraAngle; - float mOuterAngle; + ai_real mPenumbraAngle; + ai_real mOuterAngle; //! Common light intensity - float mIntensity; + ai_real mIntensity; }; /** Short vertex index description */ @@ -275,7 +275,7 @@ struct Node struct Data { bool mIsStringArray; - std::vector mValues; + std::vector mValues; std::vector mStrings; }; @@ -387,7 +387,7 @@ struct Controller std::string mJointNameSource; ///< The bind shape matrix, as array of floats. I'm not sure what this matrix actually describes, but it can't be ignored in all cases - float mBindShapeMatrix[16]; + ai_real mBindShapeMatrix[16]; // accessor URL of the joint inverse bind matrices std::string mJointOffsetMatrixSource; @@ -490,11 +490,11 @@ struct Sampler /** Weighting factor */ - float mWeighting; + ai_real mWeighting; /** Mixing factor from OKINO */ - float mMixWithPrevious; + ai_real mMixWithPrevious; }; /** A collada effect. Can contain about anything according to the Collada spec, @@ -513,8 +513,8 @@ struct Effect mTexTransparent, mTexBump, mTexReflective; // Scalar factory - float mShininess, mRefractIndex, mReflectivity; - float mTransparency; + ai_real mShininess, mRefractIndex, mReflectivity; + ai_real mTransparency; bool mHasTransparency; bool mRGBTransparency; bool mInvertTransparency; diff --git a/code/ColladaLoader.cpp b/code/ColladaLoader.cpp index 6cc0f858a..04fcfd507 100644 --- a/code/ColladaLoader.cpp +++ b/code/ColladaLoader.cpp @@ -704,7 +704,7 @@ aiMesh* ColladaLoader::CreateMesh( const ColladaParser& pParser, const Collada:: size_t jointIndex = iit->first; size_t vertexIndex = iit->second; - float weight = ReadFloat( weightsAcc, weights, vertexIndex, 0); + ai_real weight = ReadFloat( weightsAcc, weights, vertexIndex, 0); // one day I gonna kill that XSI Collada exporter if( weight > 0.0f) @@ -1071,7 +1071,7 @@ void ColladaLoader::CreateAnimation( aiScene* pScene, const ColladaParser& pPars continue; // resolve the data pointers for all anim channels. Find the minimum time while we're at it - float startTime = 1e20f, endTime = -1e20f; + ai_real startTime = 1e20, endTime = -1e20; for( std::vector::iterator it = entries.begin(); it != entries.end(); ++it) { Collada::ChannelEntry& e = *it; @@ -1100,7 +1100,7 @@ void ColladaLoader::CreateAnimation( aiScene* pScene, const ColladaParser& pPars // now for every unique point in time, find or interpolate the key values for that time // and apply them to the transform chain. Then the node's present transformation can be calculated. - float time = startTime; + ai_real time = startTime; while( 1) { for( std::vector::iterator it = entries.begin(); it != entries.end(); ++it) @@ -1109,7 +1109,7 @@ void ColladaLoader::CreateAnimation( aiScene* pScene, const ColladaParser& pPars // find the keyframe behind the current point in time size_t pos = 0; - float postTime = 0.f; + ai_real postTime = 0.0; while( 1) { if( pos >= e.mTimeAccessor->mCount) @@ -1123,19 +1123,19 @@ void ColladaLoader::CreateAnimation( aiScene* pScene, const ColladaParser& pPars pos = std::min( pos, e.mTimeAccessor->mCount-1); // read values from there - float temp[16]; + ai_real temp[16]; for( size_t c = 0; c < e.mValueAccessor->mSize; ++c) temp[c] = ReadFloat( *e.mValueAccessor, *e.mValueData, pos, c); // if not exactly at the key time, interpolate with previous value set if( postTime > time && pos > 0) { - float preTime = ReadFloat( *e.mTimeAccessor, *e.mTimeData, pos-1, 0); - float factor = (time - postTime) / (preTime - postTime); + ai_real preTime = ReadFloat( *e.mTimeAccessor, *e.mTimeData, pos-1, 0); + ai_real factor = (time - postTime) / (preTime - postTime); for( size_t c = 0; c < e.mValueAccessor->mSize; ++c) { - float v = ReadFloat( *e.mValueAccessor, *e.mValueData, pos-1, c); + ai_real v = ReadFloat( *e.mValueAccessor, *e.mValueData, pos-1, c); temp[c] += (v - temp[c]) * factor; } } @@ -1152,7 +1152,7 @@ void ColladaLoader::CreateAnimation( aiScene* pScene, const ColladaParser& pPars resultTrafos.push_back( mat); // find next point in time to evaluate. That's the closest frame larger than the current in any channel - float nextTime = 1e20f; + ai_real nextTime = 1e20; for( std::vector::iterator it = entries.begin(); it != entries.end(); ++it) { Collada::ChannelEntry& channelElement = *it; @@ -1161,7 +1161,7 @@ void ColladaLoader::CreateAnimation( aiScene* pScene, const ColladaParser& pPars size_t pos = 0; while( pos < channelElement.mTimeAccessor->mCount) { - const float t = ReadFloat( *channelElement.mTimeAccessor, *channelElement.mTimeData, pos, 0); + const ai_real t = ReadFloat( *channelElement.mTimeAccessor, *channelElement.mTimeData, pos, 0); if( t > time) { nextTime = std::min( nextTime, t); @@ -1174,16 +1174,16 @@ void ColladaLoader::CreateAnimation( aiScene* pScene, const ColladaParser& pPars // Sub-sample axis-angle channels if the delta between two consecutive // key-frame angles is >= 180 degrees. if (transforms[channelElement.mTransformIndex].mType == Collada::TF_ROTATE && channelElement.mSubElement == 3 && pos > 0 && pos < channelElement.mTimeAccessor->mCount) { - const float cur_key_angle = ReadFloat(*channelElement.mValueAccessor, *channelElement.mValueData, pos, 0); - const float last_key_angle = ReadFloat(*channelElement.mValueAccessor, *channelElement.mValueData, pos - 1, 0); - const float cur_key_time = ReadFloat(*channelElement.mTimeAccessor, *channelElement.mTimeData, pos, 0); - const float last_key_time = ReadFloat(*channelElement.mTimeAccessor, *channelElement.mTimeData, pos - 1, 0); - const float last_eval_angle = last_key_angle + (cur_key_angle - last_key_angle) * (time - last_key_time) / (cur_key_time - last_key_time); - const float delta = std::fabs(cur_key_angle - last_eval_angle); - if (delta >= 180.0f) { - const int subSampleCount = static_cast(floorf(delta / 90.0f)); + const ai_real cur_key_angle = ReadFloat(*channelElement.mValueAccessor, *channelElement.mValueData, pos, 0); + const ai_real last_key_angle = ReadFloat(*channelElement.mValueAccessor, *channelElement.mValueData, pos - 1, 0); + const ai_real cur_key_time = ReadFloat(*channelElement.mTimeAccessor, *channelElement.mTimeData, pos, 0); + const ai_real last_key_time = ReadFloat(*channelElement.mTimeAccessor, *channelElement.mTimeData, pos - 1, 0); + const ai_real last_eval_angle = last_key_angle + (cur_key_angle - last_key_angle) * (time - last_key_time) / (cur_key_time - last_key_time); + const ai_real delta = std::abs(cur_key_angle - last_eval_angle); + if (delta >= 180.0) { + const int subSampleCount = static_cast(floorf(delta / 90.0)); if (cur_key_time != time) { - const float nextSampleTime = time + (cur_key_time - time) / subSampleCount; + const ai_real nextSampleTime = time + (cur_key_time - time) / subSampleCount; nextTime = std::min(nextTime, nextSampleTime); } } @@ -1289,7 +1289,7 @@ void ColladaLoader::AddTexture ( aiMaterial& mat, const ColladaParser& pParser, _AI_MATKEY_TEXBLEND_BASE, type, idx); // Blend factor - mat.AddProperty((float*)&sampler.mWeighting , 1, + mat.AddProperty((ai_real*)&sampler.mWeighting , 1, _AI_MATKEY_TEXBLEND_BASE, type, idx); // UV source index ... if we didn't resolve the mapping, it is actually just @@ -1464,11 +1464,11 @@ void ColladaLoader::BuildMaterials( ColladaParser& pParser, aiScene* /*pScene*/) const int shadeMode = aiShadingMode_Phong; mat->AddProperty( &shadeMode, 1, AI_MATKEY_SHADING_MODEL); - aiColor4D colAmbient( 0.2f, 0.2f, 0.2f, 1.0f), colDiffuse( 0.8f, 0.8f, 0.8f, 1.0f), colSpecular( 0.5f, 0.5f, 0.5f, 0.5f); + aiColor4D colAmbient( 0.2, 0.2, 0.2, 1.0), colDiffuse( 0.8, 0.8, 0.8, 1.0), colSpecular( 0.5, 0.5, 0.5, 0.5); mat->AddProperty( &colAmbient, 1, AI_MATKEY_COLOR_AMBIENT); mat->AddProperty( &colDiffuse, 1, AI_MATKEY_COLOR_DIFFUSE); mat->AddProperty( &colSpecular, 1, AI_MATKEY_COLOR_SPECULAR); - const float specExp = 5.0f; + const ai_real specExp = 5.0; mat->AddProperty( &specExp, 1, AI_MATKEY_SHININESS); } #endif @@ -1587,7 +1587,7 @@ void ColladaLoader::ConvertPath (aiString& ss) // ------------------------------------------------------------------------------------------------ // Reads a float value from an accessor and its data array. -float ColladaLoader::ReadFloat( const Collada::Accessor& pAccessor, const Collada::Data& pData, size_t pIndex, size_t pOffset) const +ai_real ColladaLoader::ReadFloat( const Collada::Accessor& pAccessor, const Collada::Data& pData, size_t pIndex, size_t pOffset) const { // FIXME: (thom) Test for data type here in every access? For the moment, I leave this to the caller size_t pos = pAccessor.mStride * pIndex + pAccessor.mOffset + pOffset; diff --git a/code/ColladaLoader.h b/code/ColladaLoader.h index 313608cc2..716b437d8 100644 --- a/code/ColladaLoader.h +++ b/code/ColladaLoader.h @@ -190,7 +190,7 @@ protected: * @param pOffset Offset into the element, for multipart elements such as vectors or matrices * @return the specified value */ - float ReadFloat( const Collada::Accessor& pAccessor, const Collada::Data& pData, size_t pIndex, size_t pOffset) const; + ai_real ReadFloat( const Collada::Accessor& pAccessor, const Collada::Data& pData, size_t pIndex, size_t pOffset) const; /** Reads a string value from an accessor and its data array. * @param pAccessor The accessor to use for reading diff --git a/code/ColladaParser.cpp b/code/ColladaParser.cpp index 527e2ed5f..4fb30675f 100644 --- a/code/ColladaParser.cpp +++ b/code/ColladaParser.cpp @@ -128,7 +128,7 @@ bool ColladaParser::ReadBoolFromTextContent() // ------------------------------------------------------------------------------------------------ // Read float from text contents of current element -float ColladaParser::ReadFloatFromTextContent() +ai_real ColladaParser::ReadFloatFromTextContent() { const char* cur = GetTextContent(); return fast_atof(cur); @@ -674,7 +674,7 @@ void ColladaParser::ReadController( Collada::Controller& pController) for( unsigned int a = 0; a < 16; a++) { // read a number - content = fast_atoreal_move( content, pController.mBindShapeMatrix[a]); + content = fast_atoreal_move( content, pController.mBindShapeMatrix[a]); // skip whitespace after it SkipSpacesAndLineEnd( &content); } @@ -1179,13 +1179,13 @@ void ColladaParser::ReadLight( Collada::Light& pLight) // text content contains 3 floats const char* content = GetTextContent(); - content = fast_atoreal_move( content, (float&)pLight.mColor.r); + content = fast_atoreal_move( content, (ai_real&)pLight.mColor.r); SkipSpacesAndLineEnd( &content); - content = fast_atoreal_move( content, (float&)pLight.mColor.g); + content = fast_atoreal_move( content, (ai_real&)pLight.mColor.g); SkipSpacesAndLineEnd( &content); - content = fast_atoreal_move( content, (float&)pLight.mColor.b); + content = fast_atoreal_move( content, (ai_real&)pLight.mColor.b); SkipSpacesAndLineEnd( &content); TestClosing( "color"); @@ -1578,16 +1578,16 @@ void ColladaParser::ReadEffectColor( aiColor4D& pColor, Sampler& pSampler) // text content contains 4 floats const char* content = GetTextContent(); - content = fast_atoreal_move( content, (float&)pColor.r); + content = fast_atoreal_move( content, (ai_real&)pColor.r); SkipSpacesAndLineEnd( &content); - content = fast_atoreal_move( content, (float&)pColor.g); + content = fast_atoreal_move( content, (ai_real&)pColor.g); SkipSpacesAndLineEnd( &content); - content = fast_atoreal_move( content, (float&)pColor.b); + content = fast_atoreal_move( content, (ai_real&)pColor.b); SkipSpacesAndLineEnd( &content); - content = fast_atoreal_move( content, (float&)pColor.a); + content = fast_atoreal_move( content, (ai_real&)pColor.a); SkipSpacesAndLineEnd( &content); TestClosing( "color"); } @@ -1636,7 +1636,7 @@ void ColladaParser::ReadEffectColor( aiColor4D& pColor, Sampler& pSampler) // ------------------------------------------------------------------------------------------------ // Reads an effect entry containing a float -void ColladaParser::ReadEffectFloat( float& pFloat) +void ColladaParser::ReadEffectFloat( ai_real& pFloat) { while( mReader->read()) { @@ -1645,7 +1645,7 @@ void ColladaParser::ReadEffectFloat( float& pFloat) { // text content contains a single floats const char* content = GetTextContent(); - content = fast_atoreal_move( content, pFloat); + content = fast_atoreal_move( content, pFloat); SkipSpacesAndLineEnd( &content); TestClosing( "float"); @@ -1943,9 +1943,9 @@ void ColladaParser::ReadDataArray() if( *content == 0) ThrowException( "Expected more values while reading float_array contents."); - float value; + ai_real value; // read a number - content = fast_atoreal_move( content, value); + content = fast_atoreal_move( content, value); data.mValues.push_back( value); // skip whitespace after it SkipSpacesAndLineEnd( &content); @@ -2456,11 +2456,11 @@ void ColladaParser::ExtractDataObjectFromChannel( const InputChannel& pInput, si ThrowException( format() << "Invalid data index (" << pLocalIndex << "/" << acc.mCount << ") in primitive specification" ); // get a pointer to the start of the data object referred to by the accessor and the local index - const float* dataObject = &(acc.mData->mValues[0]) + acc.mOffset + pLocalIndex* acc.mStride; + const ai_real* dataObject = &(acc.mData->mValues[0]) + acc.mOffset + pLocalIndex* acc.mStride; // assemble according to the accessors component sub-offset list. We don't care, yet, // what kind of object exactly we're extracting here - float obj[4]; + ai_real obj[4]; for( size_t c = 0; c < 4; ++c) obj[c] = dataObject[acc.mSubOffset[c]]; @@ -2764,7 +2764,7 @@ void ColladaParser::ReadNodeTransformation( Node* pNode, TransformType pType) for( unsigned int a = 0; a < sNumParameters[pType]; a++) { // read a number - content = fast_atoreal_move( content, tf.f[a]); + content = fast_atoreal_move( content, tf.f[a]); // skip whitespace after it SkipSpacesAndLineEnd( &content); } @@ -3075,7 +3075,7 @@ aiMatrix4x4 ColladaParser::CalculateResultTransform( const std::vector& pTransforms) const; @@ -335,7 +335,7 @@ namespace Assimp Collada::Animation mAnims; /** Size unit: how large compared to a meter */ - float mUnitSize; + ai_real mUnitSize; /** Which is the up vector */ enum { UP_X, UP_Y, UP_Z } mUpDirection; diff --git a/code/ComputeUVMappingProcess.cpp b/code/ComputeUVMappingProcess.cpp index 2bbb30be8..33a6f4edb 100644 --- a/code/ComputeUVMappingProcess.cpp +++ b/code/ComputeUVMappingProcess.cpp @@ -49,10 +49,10 @@ using namespace Assimp; namespace { - const static aiVector3D base_axis_y(0.f,1.f,0.f); - const static aiVector3D base_axis_x(1.f,0.f,0.f); - const static aiVector3D base_axis_z(0.f,0.f,1.f); - const static float angle_epsilon = 0.95f; + const static aiVector3D base_axis_y(0.0,1.0,0.0); + const static aiVector3D base_axis_x(1.0,0.0,0.0); + const static aiVector3D base_axis_z(0.0,0.0,1.0); + const static ai_real angle_epsilon = 0.95; } // ------------------------------------------------------------------------------------------------ @@ -81,9 +81,9 @@ bool ComputeUVMappingProcess::IsActive( unsigned int pFlags) const inline bool PlaneIntersect(const aiRay& ray, const aiVector3D& planePos, const aiVector3D& planeNormal, aiVector3D& pos) { - const float b = planeNormal * (planePos - ray.pos); - float h = ray.dir * planeNormal; - if ((h < 10e-5f && h > -10e-5f) || (h = b/h) < 0) + const ai_real b = planeNormal * (planePos - ray.pos); + ai_real h = ray.dir * planeNormal; + if ((h < 10e-5 && h > -10e-5) || (h = b/h) < 0) return false; pos = ray.pos + (ray.dir * h); @@ -109,11 +109,11 @@ void RemoveUVSeams (aiMesh* mesh, aiVector3D* out) // much easier, but I don't know how and am currently too tired to // to think about a better solution. - const static float LOWER_LIMIT = 0.1f; - const static float UPPER_LIMIT = 0.9f; + const static ai_real LOWER_LIMIT = 0.1; + const static ai_real UPPER_LIMIT = 0.9; - const static float LOWER_EPSILON = 10e-3f; - const static float UPPER_EPSILON = 1.f-10e-3f; + const static ai_real LOWER_EPSILON = 10e-3; + const static ai_real UPPER_EPSILON = 1.0-10e-3; for (unsigned int fidx = 0; fidx < mesh->mNumFaces;++fidx) { @@ -156,12 +156,12 @@ void RemoveUVSeams (aiMesh* mesh, aiVector3D* out) // If the u value is over the upper limit and no other u // value of that face is 0, round it to 0 if (out[face.mIndices[n]].x > UPPER_LIMIT && !zero) - out[face.mIndices[n]].x = 0.f; + out[face.mIndices[n]].x = 0.0; // If the u value is below the lower limit and no other u // value of that face is 1, round it to 1 else if (out[face.mIndices[n]].x < LOWER_LIMIT && !one) - out[face.mIndices[n]].x = 1.f; + out[face.mIndices[n]].x = 1.0; // The face contains both 0 and 1 as UV coords. This can occur // for faces which have an edge that lies directly on the seam. @@ -171,9 +171,9 @@ void RemoveUVSeams (aiMesh* mesh, aiVector3D* out) else if (one && zero) { if (round_to_zero && out[face.mIndices[n]].x >= UPPER_EPSILON) - out[face.mIndices[n]].x = 0.f; + out[face.mIndices[n]].x = 0.0; else if (!round_to_zero && out[face.mIndices[n]].x <= LOWER_EPSILON) - out[face.mIndices[n]].x = 1.f; + out[face.mIndices[n]].x = 1.0; } } } @@ -207,7 +207,7 @@ void ComputeUVMappingProcess::ComputeSphereMapping(aiMesh* mesh,const aiVector3D for (unsigned int pnt = 0; pnt < mesh->mNumVertices;++pnt) { const aiVector3D diff = (mesh->mVertices[pnt]-center).Normalize(); out[pnt] = aiVector3D((atan2 (diff.z, diff.y) + AI_MATH_PI_F ) / AI_MATH_TWO_PI_F, - (std::asin (diff.x) + AI_MATH_HALF_PI_F) / AI_MATH_PI_F, 0.f); + (std::asin (diff.x) + AI_MATH_HALF_PI_F) / AI_MATH_PI_F, 0.0); } } else if (axis * base_axis_y >= angle_epsilon) { @@ -215,7 +215,7 @@ void ComputeUVMappingProcess::ComputeSphereMapping(aiMesh* mesh,const aiVector3D for (unsigned int pnt = 0; pnt < mesh->mNumVertices;++pnt) { const aiVector3D diff = (mesh->mVertices[pnt]-center).Normalize(); out[pnt] = aiVector3D((atan2 (diff.x, diff.z) + AI_MATH_PI_F ) / AI_MATH_TWO_PI_F, - (std::asin (diff.y) + AI_MATH_HALF_PI_F) / AI_MATH_PI_F, 0.f); + (std::asin (diff.y) + AI_MATH_HALF_PI_F) / AI_MATH_PI_F, 0.0); } } else if (axis * base_axis_z >= angle_epsilon) { @@ -223,7 +223,7 @@ void ComputeUVMappingProcess::ComputeSphereMapping(aiMesh* mesh,const aiVector3D for (unsigned int pnt = 0; pnt < mesh->mNumVertices;++pnt) { const aiVector3D diff = (mesh->mVertices[pnt]-center).Normalize(); out[pnt] = aiVector3D((atan2 (diff.y, diff.x) + AI_MATH_PI_F ) / AI_MATH_TWO_PI_F, - (std::asin (diff.z) + AI_MATH_HALF_PI_F) / AI_MATH_PI_F, 0.f); + (std::asin (diff.z) + AI_MATH_HALF_PI_F) / AI_MATH_PI_F, 0.0); } } // slower code path in case the mapping axis is not one of the coordinate system axes @@ -235,7 +235,7 @@ void ComputeUVMappingProcess::ComputeSphereMapping(aiMesh* mesh,const aiVector3D for (unsigned int pnt = 0; pnt < mesh->mNumVertices;++pnt) { const aiVector3D diff = ((mTrafo*mesh->mVertices[pnt])-center).Normalize(); out[pnt] = aiVector3D((atan2 (diff.y, diff.x) + AI_MATH_PI_F ) / AI_MATH_TWO_PI_F, - (asin (diff.z) + AI_MATH_HALF_PI_F) / AI_MATH_PI_F, 0.f); + (asin (diff.z) + AI_MATH_HALF_PI_F) / AI_MATH_PI_F, 0.0); } } @@ -257,7 +257,7 @@ void ComputeUVMappingProcess::ComputeCylinderMapping(aiMesh* mesh,const aiVector // thus changing the mapping axis) if (axis * base_axis_x >= angle_epsilon) { FindMeshCenter(mesh, center, min, max); - const float diff = max.x - min.x; + const ai_real diff = max.x - min.x; // If the main axis is 'z', the z coordinate of a point 'p' is mapped // directly to the texture V axis. The other axis is derived from @@ -268,12 +268,12 @@ void ComputeUVMappingProcess::ComputeCylinderMapping(aiMesh* mesh,const aiVector aiVector3D& uv = out[pnt]; uv.y = (pos.x - min.x) / diff; - uv.x = (atan2 ( pos.z - center.z, pos.y - center.y) +(float)AI_MATH_PI ) / (float)AI_MATH_TWO_PI; + uv.x = (atan2 ( pos.z - center.z, pos.y - center.y) +(ai_real)AI_MATH_PI ) / (ai_real)AI_MATH_TWO_PI; } } else if (axis * base_axis_y >= angle_epsilon) { FindMeshCenter(mesh, center, min, max); - const float diff = max.y - min.y; + const ai_real diff = max.y - min.y; // just the same ... for (unsigned int pnt = 0; pnt < mesh->mNumVertices;++pnt) { @@ -281,12 +281,12 @@ void ComputeUVMappingProcess::ComputeCylinderMapping(aiMesh* mesh,const aiVector aiVector3D& uv = out[pnt]; uv.y = (pos.y - min.y) / diff; - uv.x = (atan2 ( pos.x - center.x, pos.z - center.z) +(float)AI_MATH_PI ) / (float)AI_MATH_TWO_PI; + uv.x = (atan2 ( pos.x - center.x, pos.z - center.z) +(ai_real)AI_MATH_PI ) / (ai_real)AI_MATH_TWO_PI; } } else if (axis * base_axis_z >= angle_epsilon) { FindMeshCenter(mesh, center, min, max); - const float diff = max.z - min.z; + const ai_real diff = max.z - min.z; // just the same ... for (unsigned int pnt = 0; pnt < mesh->mNumVertices;++pnt) { @@ -294,7 +294,7 @@ void ComputeUVMappingProcess::ComputeCylinderMapping(aiMesh* mesh,const aiVector aiVector3D& uv = out[pnt]; uv.y = (pos.z - min.z) / diff; - uv.x = (atan2 ( pos.y - center.y, pos.x - center.x) +(float)AI_MATH_PI ) / (float)AI_MATH_TWO_PI; + uv.x = (atan2 ( pos.y - center.y, pos.x - center.x) +(ai_real)AI_MATH_PI ) / (ai_real)AI_MATH_TWO_PI; } } // slower code path in case the mapping axis is not one of the coordinate system axes @@ -302,7 +302,7 @@ void ComputeUVMappingProcess::ComputeCylinderMapping(aiMesh* mesh,const aiVector aiMatrix4x4 mTrafo; aiMatrix4x4::FromToMatrix(axis,base_axis_y,mTrafo); FindMeshCenterTransformed(mesh, center, min, max,mTrafo); - const float diff = max.y - min.y; + const ai_real diff = max.y - min.y; // again the same, except we're applying a transformation now for (unsigned int pnt = 0; pnt < mesh->mNumVertices;++pnt){ @@ -310,7 +310,7 @@ void ComputeUVMappingProcess::ComputeCylinderMapping(aiMesh* mesh,const aiVector aiVector3D& uv = out[pnt]; uv.y = (pos.y - min.y) / diff; - uv.x = (atan2 ( pos.x - center.x, pos.z - center.z) +(float)AI_MATH_PI ) / (float)AI_MATH_TWO_PI; + uv.x = (atan2 ( pos.x - center.x, pos.z - center.z) +(ai_real)AI_MATH_PI ) / (ai_real)AI_MATH_TWO_PI; } } @@ -323,7 +323,7 @@ void ComputeUVMappingProcess::ComputeCylinderMapping(aiMesh* mesh,const aiVector // ------------------------------------------------------------------------------------------------ void ComputeUVMappingProcess::ComputePlaneMapping(aiMesh* mesh,const aiVector3D& axis, aiVector3D* out) { - float diffu,diffv; + ai_real diffu,diffv; aiVector3D center, min, max; // If the axis is one of x,y,z run a faster code path. It's worth the extra effort ... @@ -337,7 +337,7 @@ void ComputeUVMappingProcess::ComputePlaneMapping(aiMesh* mesh,const aiVector3D& for (unsigned int pnt = 0; pnt < mesh->mNumVertices;++pnt) { const aiVector3D& pos = mesh->mVertices[pnt]; - out[pnt].Set((pos.z - min.z) / diffu,(pos.y - min.y) / diffv,0.f); + out[pnt].Set((pos.z - min.z) / diffu,(pos.y - min.y) / diffv,0.0); } } else if (axis * base_axis_y >= angle_epsilon) { @@ -347,7 +347,7 @@ void ComputeUVMappingProcess::ComputePlaneMapping(aiMesh* mesh,const aiVector3D& for (unsigned int pnt = 0; pnt < mesh->mNumVertices;++pnt) { const aiVector3D& pos = mesh->mVertices[pnt]; - out[pnt].Set((pos.x - min.x) / diffu,(pos.z - min.z) / diffv,0.f); + out[pnt].Set((pos.x - min.x) / diffu,(pos.z - min.z) / diffv,0.0); } } else if (axis * base_axis_z >= angle_epsilon) { @@ -357,7 +357,7 @@ void ComputeUVMappingProcess::ComputePlaneMapping(aiMesh* mesh,const aiVector3D& for (unsigned int pnt = 0; pnt < mesh->mNumVertices;++pnt) { const aiVector3D& pos = mesh->mVertices[pnt]; - out[pnt].Set((pos.y - min.y) / diffu,(pos.x - min.x) / diffv,0.f); + out[pnt].Set((pos.y - min.y) / diffu,(pos.x - min.x) / diffv,0.0); } } // slower code path in case the mapping axis is not one of the coordinate system axes @@ -372,7 +372,7 @@ void ComputeUVMappingProcess::ComputePlaneMapping(aiMesh* mesh,const aiVector3D& // again the same, except we're applying a transformation now for (unsigned int pnt = 0; pnt < mesh->mNumVertices;++pnt) { const aiVector3D pos = mTrafo * mesh->mVertices[pnt]; - out[pnt].Set((pos.x - min.x) / diffu,(pos.z - min.z) / diffv,0.f); + out[pnt].Set((pos.x - min.x) / diffu,(pos.z - min.z) / diffv,0.0); } } diff --git a/code/Exporter.cpp b/code/Exporter.cpp index af2267a62..0707a4f56 100644 --- a/code/Exporter.cpp +++ b/code/Exporter.cpp @@ -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(mFloatProperties, szName,iValue); + return SetGenericProperty(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(mFloatProperties,szName,iErrorReturn); + return GetGenericProperty(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(mFloatProperties, szName); + return HasGenericProperty(mFloatProperties, szName); }; // ------------------------------------------------------------------------------------------------ diff --git a/code/FBXConverter.cpp b/code/FBXConverter.cpp index 692cda836..d0f1c0de4 100644 --- a/code/FBXConverter.cpp +++ b/code/FBXConverter.cpp @@ -3037,7 +3037,7 @@ void Converter::InterpolateKeys( aiVectorKey* valOut, const KeyTimeList& keys, c next_pos.resize( inputs.size(), 0 ); for( KeyTimeList::value_type time : keys ) { - float result[ 3 ] = { def_value.x, def_value.y, def_value.z }; + ai_real result[ 3 ] = { def_value.x, def_value.y, def_value.z }; for ( size_t i = 0; i < count; ++i ) { const KeyFrameList& kfl = inputs[ i ]; @@ -3060,7 +3060,7 @@ void Converter::InterpolateKeys( aiVectorKey* valOut, const KeyTimeList& keys, c // do the actual interpolation in double-precision arithmetics // because it is a bit sensitive to rounding errors. const double factor = timeB == timeA ? 0. : static_cast( ( time - timeA ) / ( timeB - timeA ) ); - const float interpValue = static_cast( valueA + ( valueB - valueA ) * factor ); + const ai_real interpValue = static_cast( valueA + ( valueB - valueA ) * factor ); result[ std::get<2>(kfl) ] = interpValue; } diff --git a/code/FindInvalidDataProcess.cpp b/code/FindInvalidDataProcess.cpp index bb87f8dd8..bed2eee06 100644 --- a/code/FindInvalidDataProcess.cpp +++ b/code/FindInvalidDataProcess.cpp @@ -58,7 +58,7 @@ using namespace Assimp; // ------------------------------------------------------------------------------------------------ // Constructor to be privately used by Importer FindInvalidDataProcess::FindInvalidDataProcess() - : configEpsilon(0.0f) + : configEpsilon(0.0) { // nothing to do here } @@ -221,16 +221,16 @@ inline bool ProcessArray(T*& in, unsigned int num,const char* name, // ------------------------------------------------------------------------------------------------ template -AI_FORCE_INLINE bool EpsilonCompare(const T& n, const T& s, float epsilon); +AI_FORCE_INLINE bool EpsilonCompare(const T& n, const T& s, ai_real epsilon); // ------------------------------------------------------------------------------------------------ -AI_FORCE_INLINE bool EpsilonCompare(float n, float s, float epsilon) { +AI_FORCE_INLINE bool EpsilonCompare(ai_real n, ai_real s, ai_real epsilon) { return std::fabs(n-s)>epsilon; } // ------------------------------------------------------------------------------------------------ template <> -bool EpsilonCompare(const aiVectorKey& n, const aiVectorKey& s, float epsilon) { +bool EpsilonCompare(const aiVectorKey& n, const aiVectorKey& s, ai_real epsilon) { return EpsilonCompare(n.mValue.x,s.mValue.x,epsilon) && EpsilonCompare(n.mValue.y,s.mValue.y,epsilon) && @@ -239,7 +239,7 @@ bool EpsilonCompare(const aiVectorKey& n, const aiVectorKey& s, flo // ------------------------------------------------------------------------------------------------ template <> -bool EpsilonCompare(const aiQuatKey& n, const aiQuatKey& s, float epsilon) { +bool EpsilonCompare(const aiQuatKey& n, const aiQuatKey& s, ai_real epsilon) { return EpsilonCompare(n.mValue.x,s.mValue.x,epsilon) && EpsilonCompare(n.mValue.y,s.mValue.y,epsilon) && @@ -249,7 +249,7 @@ bool EpsilonCompare(const aiQuatKey& n, const aiQuatKey& s, float eps // ------------------------------------------------------------------------------------------------ template -inline bool AllIdentical(T* in, unsigned int num, float epsilon) +inline bool AllIdentical(T* in, unsigned int num, ai_real epsilon) { if (num <= 1) { return true; diff --git a/code/FindInvalidDataProcess.h b/code/FindInvalidDataProcess.h index 371569380..8a1df21fd 100644 --- a/code/FindInvalidDataProcess.h +++ b/code/FindInvalidDataProcess.h @@ -97,7 +97,7 @@ public: void ProcessAnimationChannel (aiNodeAnim* anim); private: - float configEpsilon; + ai_real configEpsilon; }; } // end of namespace Assimp diff --git a/code/GenVertexNormalsProcess.cpp b/code/GenVertexNormalsProcess.cpp index 165c3f8fb..14b7962c0 100644 --- a/code/GenVertexNormalsProcess.cpp +++ b/code/GenVertexNormalsProcess.cpp @@ -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::quiet_NaN(); + const float qnan = std::numeric_limits::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 >* avf; + std::vector >* avf; shared->GetProperty(AI_SPP_SPATIAL_SORT,avf); if (avf) { - std::pair& blubb = avf->operator [] (meshIndex); + std::pair& 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) { diff --git a/code/GenVertexNormalsProcess.h b/code/GenVertexNormalsProcess.h index 5d8b61ead..caa327aa3 100644 --- a/code/GenVertexNormalsProcess.h +++ b/code/GenVertexNormalsProcess.h @@ -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 - diff --git a/code/IRRLoader.cpp b/code/IRRLoader.cpp index 2d702523d..a1cfaf28b 100644 --- a/code/IRRLoader.cpp +++ b/code/IRRLoader.cpp @@ -207,54 +207,54 @@ void IRRImporter::BuildSkybox(std::vector& meshes, std::vectormMaterialIndex = materials.size()-6u; // LEFT SIDE meshes.push_back( BuildSingleQuadMesh( - SkyboxVertex( l,-l,-l, -1, 0, 0, 1.f,1.f), - SkyboxVertex( l,-l, l, -1, 0, 0, 0.f,1.f), - SkyboxVertex( l, l, l, -1, 0, 0, 0.f,0.f), - SkyboxVertex( l, l,-l, -1, 0, 0, 1.f,0.f)) ); + SkyboxVertex( l,-l,-l, -1, 0, 0, 1.0,1.0), + SkyboxVertex( l,-l, l, -1, 0, 0, 0.0,1.0), + SkyboxVertex( l, l, l, -1, 0, 0, 0.0,0.0), + SkyboxVertex( l, l,-l, -1, 0, 0, 1.0,0.0)) ); meshes.back()->mMaterialIndex = materials.size()-5u; // BACK SIDE meshes.push_back( BuildSingleQuadMesh( - SkyboxVertex( l,-l, l, 0, 0, -1, 1.f,1.f), - SkyboxVertex(-l,-l, l, 0, 0, -1, 0.f,1.f), - SkyboxVertex(-l, l, l, 0, 0, -1, 0.f,0.f), - SkyboxVertex( l, l, l, 0, 0, -1, 1.f,0.f)) ); + SkyboxVertex( l,-l, l, 0, 0, -1, 1.0,1.0), + SkyboxVertex(-l,-l, l, 0, 0, -1, 0.0,1.0), + SkyboxVertex(-l, l, l, 0, 0, -1, 0.0,0.0), + SkyboxVertex( l, l, l, 0, 0, -1, 1.0,0.0)) ); meshes.back()->mMaterialIndex = materials.size()-4u; // RIGHT SIDE meshes.push_back( BuildSingleQuadMesh( - SkyboxVertex(-l,-l, l, 1, 0, 0, 1.f,1.f), - SkyboxVertex(-l,-l,-l, 1, 0, 0, 0.f,1.f), - SkyboxVertex(-l, l,-l, 1, 0, 0, 0.f,0.f), - SkyboxVertex(-l, l, l, 1, 0, 0, 1.f,0.f)) ); + SkyboxVertex(-l,-l, l, 1, 0, 0, 1.0,1.0), + SkyboxVertex(-l,-l,-l, 1, 0, 0, 0.0,1.0), + SkyboxVertex(-l, l,-l, 1, 0, 0, 0.0,0.0), + SkyboxVertex(-l, l, l, 1, 0, 0, 1.0,0.0)) ); meshes.back()->mMaterialIndex = materials.size()-3u; // TOP SIDE meshes.push_back( BuildSingleQuadMesh( - SkyboxVertex( l, l,-l, 0, -1, 0, 1.f,1.f), - SkyboxVertex( l, l, l, 0, -1, 0, 0.f,1.f), - SkyboxVertex(-l, l, l, 0, -1, 0, 0.f,0.f), - SkyboxVertex(-l, l,-l, 0, -1, 0, 1.f,0.f)) ); + SkyboxVertex( l, l,-l, 0, -1, 0, 1.0,1.0), + SkyboxVertex( l, l, l, 0, -1, 0, 0.0,1.0), + SkyboxVertex(-l, l, l, 0, -1, 0, 0.0,0.0), + SkyboxVertex(-l, l,-l, 0, -1, 0, 1.0,0.0)) ); meshes.back()->mMaterialIndex = materials.size()-2u; // BOTTOM SIDE meshes.push_back( BuildSingleQuadMesh( - SkyboxVertex( l,-l, l, 0, 1, 0, 0.f,0.f), - SkyboxVertex( l,-l,-l, 0, 1, 0, 1.f,0.f), - SkyboxVertex(-l,-l,-l, 0, 1, 0, 1.f,1.f), - SkyboxVertex(-l,-l, l, 0, 1, 0, 0.f,1.f)) ); + SkyboxVertex( l,-l, l, 0, 1, 0, 0.0,0.0), + SkyboxVertex( l,-l,-l, 0, 1, 0, 1.0,0.0), + SkyboxVertex(-l,-l,-l, 0, 1, 0, 1.0,1.0), + SkyboxVertex(-l,-l, l, 0, 1, 0, 0.0,1.0)) ); meshes.back()->mMaterialIndex = materials.size()-1u; } @@ -479,7 +479,7 @@ void IRRImporter::ComputeAnimations(Node* root, aiNode* real, std::vectormPositionKeys[i]; key.mTime = i * tdelta; - const float t = (float) ( in.speed * key.mTime ); + const ai_real t = (ai_real) ( in.speed * key.mTime ); key.mValue = in.circleCenter + in.circleRadius * ((vecU * std::cos(t)) + (vecV * std::sin(t))); } @@ -498,7 +498,7 @@ void IRRImporter::ComputeAnimations(Node* root, aiNode* real, std::vectormPositionKeys = new aiVectorKey[anim->mNumPositionKeys]; aiVector3D diff = in.direction - in.circleCenter; - const float lengthOfWay = diff.Length(); + const ai_real lengthOfWay = diff.Length(); diff.Normalize(); const double timeFactor = lengthOfWay / in.timeForWay; @@ -507,7 +507,7 @@ void IRRImporter::ComputeAnimations(Node* root, aiNode* real, std::vectormNumPositionKeys;++i) { aiVectorKey& key = anim->mPositionKeys[i]; key.mTime = i * tdelta; - key.mValue = in.circleCenter + diff * float(timeFactor * key.mTime); + key.mValue = in.circleCenter + diff * ai_real(timeFactor * key.mTime); } } break; @@ -542,8 +542,8 @@ void IRRImporter::ComputeAnimations(Node* root, aiNode* real, std::vectormPositionKeys[i]; - const float dt = (i * in.speed * 0.001f ); - const float u = dt - std::floor(dt); + const ai_real dt = (i * in.speed * 0.001 ); + const ai_real u = dt - std::floor(dt); const int idx = (int)std::floor(dt) % size; // get the 4 current points to evaluate the spline @@ -553,13 +553,13 @@ void IRRImporter::ComputeAnimations(Node* root, aiNode* real, std::vector splineKeys; // ROTATION (angles given in direction) @@ -166,11 +166,11 @@ private: explicit Node(ET t) : type (t) - , scaling (1.f,1.f,1.f) // assume uniform scaling by default + , scaling (1.0,1.0,1.0) // assume uniform scaling by default , parent() - , framesPerSecond (0.f) + , framesPerSecond (0.0) , id() - , sphereRadius (1.f) + , sphereRadius (1.0) , spherePolyCountX (100) , spherePolyCountY (100) { @@ -202,7 +202,7 @@ private: // Animated meshes: frames per second // 0.f if not specified - float framesPerSecond; + ai_real framesPerSecond; // Meshes: path to the mesh to be loaded std::string meshPath; @@ -213,7 +213,7 @@ private: std::vector< std::pair > materials; // Spheres: radius of the sphere to be generates - float sphereRadius; + ai_real sphereRadius; // Spheres: Number of polygons in the x,y direction unsigned int spherePolyCountX,spherePolyCountY; @@ -230,13 +230,13 @@ private: {} //! Construction from single vertex components - SkyboxVertex(float px, float py, float pz, - float nx, float ny, float nz, - float uvx, float uvy) + SkyboxVertex(ai_real px, ai_real py, ai_real pz, + ai_real nx, ai_real ny, ai_real nz, + ai_real uvx, ai_real uvy) : position (px,py,pz) , normal (nx,ny,nz) - , uv (uvx,uvy,0.f) + , uv (uvx,uvy,0.0) {} aiVector3D position, normal, uv; diff --git a/code/Importer.cpp b/code/Importer.cpp index 3599138eb..978f7c7d4 100644 --- a/code/Importer.cpp +++ b/code/Importer.cpp @@ -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(pimpl->mFloatProperties, szName,iValue); + exising = SetGenericProperty(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(pimpl->mFloatProperties,szName,iErrorReturn); + return GetGenericProperty(pimpl->mFloatProperties,szName,iErrorReturn); } // ------------------------------------------------------------------------------------------------ diff --git a/code/Importer.h b/code/Importer.h index 750b9bbbd..a35fb80d9 100644 --- a/code/Importer.h +++ b/code/Importer.h @@ -75,7 +75,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 IntPropertyMap; - typedef std::map FloatPropertyMap; + typedef std::map FloatPropertyMap; typedef std::map StringPropertyMap; typedef std::map MatrixPropertyMap; diff --git a/code/LWOMaterial.cpp b/code/LWOMaterial.cpp index 24a2458cf..494f70033 100644 --- a/code/LWOMaterial.cpp +++ b/code/LWOMaterial.cpp @@ -141,13 +141,13 @@ bool LWOImporter::HandleTextures(aiMaterial* pcMat, const TextureList& in, aiTex aiVector3D v; switch (texture.majorAxis) { case Texture::AXIS_X: - v = aiVector3D(1.f,0.f,0.f); + v = aiVector3D(1.0,0.0,0.0); break; case Texture::AXIS_Y: - v = aiVector3D(0.f,1.f,0.f); + v = aiVector3D(0.0,1.0,0.0); break; default: // case Texture::AXIS_Z: - v = aiVector3D(0.f,0.f,1.f); + v = aiVector3D(0.0,0.0,1.0); break; } @@ -159,7 +159,7 @@ bool LWOImporter::HandleTextures(aiMaterial* pcMat, const TextureList& in, aiTex trafo.mScaling.x = texture.wrapAmountW; trafo.mScaling.y = texture.wrapAmountH; - static_assert(sizeof(aiUVTransform)/sizeof(float) == 5, "sizeof(aiUVTransform)/sizeof(float) == 5"); + static_assert(sizeof(aiUVTransform)/sizeof(ai_real) == 5, "sizeof(aiUVTransform)/sizeof(ai_real) == 5"); pcMat->AddProperty(&trafo,1,AI_MATKEY_UVTRANSFORM(type,cur)); } DefaultLogger::get()->debug("LWO2: Setting up non-UV mapping"); @@ -286,17 +286,17 @@ void LWOImporter::ConvertMaterial(const LWO::Surface& surf,aiMaterial* pcMat) { float fGloss; if (mIsLWO2) { - fGloss = std::pow( surf.mGlossiness*10.0f+2.0f, 2.0f); + fGloss = std::pow( surf.mGlossiness*10.0+2.0, 2.0); } else { - if (16.0f >= surf.mGlossiness) - fGloss = 6.0f; - else if (64.0f >= surf.mGlossiness) - fGloss = 20.0f; - else if (256.0f >= surf.mGlossiness) - fGloss = 50.0f; - else fGloss = 80.0f; + if (16.0 >= surf.mGlossiness) + fGloss = 6.0; + else if (64.0 >= surf.mGlossiness) + fGloss = 20.0; + else if (256.0 >= surf.mGlossiness) + fGloss = 50.0; + else fGloss = 80.0; } pcMat->AddProperty(&surf.mSpecularValue,1,AI_MATKEY_SHININESS_STRENGTH); @@ -306,17 +306,17 @@ void LWOImporter::ConvertMaterial(const LWO::Surface& surf,aiMaterial* pcMat) else m = aiShadingMode_Gouraud; // specular color - aiColor3D clr = lerp( aiColor3D(1.f,1.f,1.f), surf.mColor, surf.mColorHighlights ); + aiColor3D clr = lerp( aiColor3D(1.0,1.0,1.0), surf.mColor, surf.mColorHighlights ); pcMat->AddProperty(&clr,1,AI_MATKEY_COLOR_SPECULAR); pcMat->AddProperty(&surf.mSpecularValue,1,AI_MATKEY_SHININESS_STRENGTH); // emissive color // luminosity is not really the same but it affects the surface in a similar way. Some scaling looks good. - clr.g = clr.b = clr.r = surf.mLuminosity*0.8f; + clr.g = clr.b = clr.r = surf.mLuminosity*0.8; pcMat->AddProperty(&clr,1,AI_MATKEY_COLOR_EMISSIVE); // opacity ... either additive or default-blended, please - if (0.f != surf.mAdditiveTransparency) { + if (0.0 != surf.mAdditiveTransparency) { const int add = aiBlendMode_Additive; pcMat->AddProperty(&surf.mAdditiveTransparency,1,AI_MATKEY_OPACITY); @@ -361,13 +361,13 @@ void LWOImporter::ConvertMaterial(const LWO::Surface& surf,aiMaterial* pcMat) DefaultLogger::get()->warn("LWO2: Unknown surface shader: " + shader.functionName); } } - if (surf.mMaximumSmoothAngle <= 0.0f) + if (surf.mMaximumSmoothAngle <= 0.0) m = aiShadingMode_Flat; pcMat->AddProperty((int*)&m,1,AI_MATKEY_SHADING_MODEL); // (the diffuse value is just a scaling factor) // If a diffuse texture is set, we set this value to 1.0 - clr = (b && false ? aiColor3D(1.f,1.f,1.f) : surf.mColor); + clr = (b && false ? aiColor3D(1.0,1.0,1.0) : surf.mColor); clr.r *= surf.mDiffuseValue; clr.g *= surf.mDiffuseValue; clr.b *= surf.mDiffuseValue; @@ -497,7 +497,7 @@ void LWOImporter::FindVCChannels(const LWO::Surface& surf, LWO::SortedRep& sorte for (unsigned int n = 0; n < face.mNumIndices; ++n) { unsigned int idx = face.mIndices[n]; - if (vc.abAssigned[idx] && ((aiColor4D*)&vc.rawData[0])[idx] != aiColor4D(0.f,0.f,0.f,1.f)) { + if (vc.abAssigned[idx] && ((aiColor4D*)&vc.rawData[0])[idx] != aiColor4D(0.0,0.0,0.0,1.0)) { if (next >= AI_MAX_NUMBER_OF_COLOR_SETS) { DefaultLogger::get()->error("LWO: Maximum number of vertex color channels for " diff --git a/code/MD3FileData.h b/code/MD3FileData.h index 88a40f230..51a573959 100644 --- a/code/MD3FileData.h +++ b/code/MD3FileData.h @@ -136,7 +136,7 @@ struct Frame aiVector3D origin; //! radius of bounding sphere - float radius; + ai_real radius; //! name of frame char name[ AI_MD3_MAXFRAME ]; @@ -154,7 +154,7 @@ struct Tag //! Local tag origin and orientation aiVector3D origin; - float orientation[3][3]; + ai_real orientation[3][3]; } PACK_STRUCT; @@ -231,7 +231,7 @@ struct Triangle struct TexCoord { //! UV coordinates - float U,V; + ai_real U,V; } PACK_STRUCT; @@ -257,12 +257,12 @@ struct Vertex * * @note This has been taken from q3 source (misc_model.c) */ -inline void LatLngNormalToVec3(uint16_t p_iNormal, float* p_afOut) +inline void LatLngNormalToVec3(uint16_t p_iNormal, ai_real* p_afOut) { - float lat = (float)(( p_iNormal >> 8u ) & 0xff); - float lng = (float)(( p_iNormal & 0xff )); - lat *= 3.141926f/128.0f; - lng *= 3.141926f/128.0f; + ai_real lat = (ai_real)(( p_iNormal >> 8u ) & 0xff); + ai_real lng = (ai_real)(( p_iNormal & 0xff )); + lat *= 3.141926/128.0; + lng *= 3.141926/128.0; p_afOut[0] = std::cos(lat) * std::sin(lng); p_afOut[1] = std::sin(lat) * std::sin(lng); @@ -313,4 +313,3 @@ inline void Vec3NormalToLatLng( const aiVector3D& p_vIn, uint16_t& p_iOut ) } #endif // !! AI_MD3FILEHELPER_H_INC - diff --git a/code/MD3Loader.cpp b/code/MD3Loader.cpp index 8294da489..a99fb06b1 100644 --- a/code/MD3Loader.cpp +++ b/code/MD3Loader.cpp @@ -1018,7 +1018,7 @@ void MD3Importer::InternReadFile( const std::string& pFile, // Convert the normal vector to uncompressed float3 format aiVector3D& nor = pcMesh->mNormals[iCurrent]; - LatLngNormalToVec3(pcVertices[pcTriangles->INDEXES[c]].NORMAL,(float*)&nor); + LatLngNormalToVec3(pcVertices[pcTriangles->INDEXES[c]].NORMAL,(ai_real*)&nor); // Read texture coordinates pcMesh->mTextureCoords[0][iCurrent].x = pcUVs[ pcTriangles->INDEXES[c]].U; diff --git a/code/MD5Loader.cpp b/code/MD5Loader.cpp index 7927c9ab1..8c66f6507 100644 --- a/code/MD5Loader.cpp +++ b/code/MD5Loader.cpp @@ -475,7 +475,7 @@ void MD5Importer::LoadMD5MeshFile () *pv = aiVector3D(); // there are models which have weights which don't sum to 1 ... - float fSum = 0.0f; + ai_real fSum = 0.0; for (unsigned int jub = (*iter).mFirstWeight, w = jub; w < jub + (*iter).mNumWeights;++w) fSum += meshSrc.mWeights[w].mWeight; if (!fSum) { @@ -493,7 +493,7 @@ void MD5Importer::LoadMD5MeshFile () continue; } - const float fNewWeight = desc.mWeight / fSum; + const ai_real fNewWeight = desc.mWeight / fSum; // transform the local position into worldspace MD5::BoneDesc& boneSrc = meshParser.mJoints[desc.mBone]; @@ -501,7 +501,7 @@ void MD5Importer::LoadMD5MeshFile () // use the original weight to compute the vertex position // (some MD5s seem to depend on the invalid weight values ...) - *pv += ((boneSrc.mPositionXYZ+v)* desc.mWeight); + *pv += ((boneSrc.mPositionXYZ+v)* (ai_real)desc.mWeight); aiBone* bone = mesh->mBones[boneSrc.mMap]; *bone->mWeights++ = aiVertexWeight((unsigned int)(pv-mesh->mVertices),fNewWeight); diff --git a/code/MDCLoader.cpp b/code/MDCLoader.cpp index 661447acf..50a3d9422 100644 --- a/code/MDCLoader.cpp +++ b/code/MDCLoader.cpp @@ -408,7 +408,7 @@ void MDCImporter::InternReadFile( // copy texture coordinates pcUVCur->x = pcUVs[quak].u; - pcUVCur->y = 1.0f-pcUVs[quak].v; // DX to OGL + pcUVCur->y = 1.0-pcUVs[quak].v; // DX to OGL } pcVertCur->x += pcFrame->localOrigin[0] ; pcVertCur->y += pcFrame->localOrigin[1] ; diff --git a/code/MDLMaterialLoader.cpp b/code/MDLMaterialLoader.cpp index d1502d6fb..4c36c3329 100644 --- a/code/MDLMaterialLoader.cpp +++ b/code/MDLMaterialLoader.cpp @@ -657,7 +657,7 @@ void MDLImporter::ParseSkinLump_3DGS_MDL7( if (is_not_qnan(clrTexture.r)) { clrTemp.r *= clrTexture.a; } - pcMatOut->AddProperty(&clrTemp.r,1,AI_MATKEY_OPACITY); + pcMatOut->AddProperty(&clrTemp.r,1,AI_MATKEY_OPACITY); // read phong power int iShadingMode = (int)aiShadingMode_Gouraud; diff --git a/code/NFFLoader.cpp b/code/NFFLoader.cpp index 8bec63ea3..8cc1624d5 100644 --- a/code/NFFLoader.cpp +++ b/code/NFFLoader.cpp @@ -965,7 +965,7 @@ void NFFImporter::InternReadFile( const std::string& pFile, // compute the center point of the cone/cylinder - // it is its local transformation origin currentMesh.dir = center2-center1; - currentMesh.center = center1+currentMesh.dir/2.f; + currentMesh.center = center1+currentMesh.dir/(ai_real)2.0; float f; if (( f = currentMesh.dir.Length()) < 10e-3f ) @@ -1159,7 +1159,7 @@ void NFFImporter::InternReadFile( const std::string& pFile, ++ppcChildren; } else { *pMeshes++ = m; - } + } // copy vertex positions mesh->mVertices = new aiVector3D[mesh->mNumVertices]; diff --git a/code/OFFLoader.cpp b/code/OFFLoader.cpp index fd0542fdf..3139bc238 100644 --- a/code/OFFLoader.cpp +++ b/code/OFFLoader.cpp @@ -161,9 +161,9 @@ void OFFImporter::InternReadFile( const std::string& pFile, aiVector3D& v = tempPositions[i]; sz = line; SkipSpaces(&sz); - sz = fast_atoreal_move(sz,(float&)v.x); SkipSpaces(&sz); - sz = fast_atoreal_move(sz,(float&)v.y); SkipSpaces(&sz); - fast_atoreal_move(sz,(float&)v.z); + sz = fast_atoreal_move(sz,(ai_real&)v.x); SkipSpaces(&sz); + sz = fast_atoreal_move(sz,(ai_real&)v.y); SkipSpaces(&sz); + fast_atoreal_move(sz,(ai_real&)v.z); } @@ -242,7 +242,7 @@ void OFFImporter::InternReadFile( const std::string& pFile, pScene->mMaterials = new aiMaterial*[pScene->mNumMaterials]; aiMaterial* pcMat = new aiMaterial(); - aiColor4D clr(0.6f,0.6f,0.6f,1.0f); + aiColor4D clr(0.6,0.6,0.6,1.0); pcMat->AddProperty(&clr,1,AI_MATKEY_COLOR_DIFFUSE); pScene->mMaterials[0] = pcMat; diff --git a/code/ObjExporter.cpp b/code/ObjExporter.cpp index ca07730bc..aada4efd7 100644 --- a/code/ObjExporter.cpp +++ b/code/ObjExporter.cpp @@ -167,7 +167,7 @@ void ObjExporter::WriteMaterialFile() mOutputMat << "Ke " << c.r << " " << c.g << " " << c.b << endl; } - float o; + ai_real o; if(AI_SUCCESS == mat->Get(AI_MATKEY_OPACITY,o)) { mOutputMat << "d " << o << endl; } diff --git a/code/ObjFileData.h b/code/ObjFileData.h index f4abd643f..65d982997 100644 --- a/code/ObjFileData.h +++ b/code/ObjFileData.h @@ -191,21 +191,21 @@ struct Material //! Emissive color aiColor3D emissive; //! Alpha value - float alpha; + ai_real alpha; //! Shineness factor - float shineness; + ai_real shineness; //! Illumination model int illumination_model; //! Index of refraction - float ior; + ai_real ior; //! Constructor Material() - : diffuse (0.6f,0.6f,0.6f) - , alpha (1.f) - , shineness (0.0f) + : diffuse (0.6,0.6,0.6) + , alpha (1.0) + , shineness (0.0) , illumination_model (1) - , ior (1.f) + , ior (1.0) { // empty for (size_t i = 0; i < TextureTypeCount; ++i) @@ -244,7 +244,7 @@ struct Mesh { bool m_hasVertexColors; /// Constructor - explicit Mesh( const std::string &name ) + explicit Mesh( const std::string &name ) : m_name( name ) , m_pMaterial(NULL) , m_uiNumIndices(0) diff --git a/code/ObjFileMtlImporter.cpp b/code/ObjFileMtlImporter.cpp index 2b3847bbb..0228ef224 100644 --- a/code/ObjFileMtlImporter.cpp +++ b/code/ObjFileMtlImporter.cpp @@ -164,7 +164,7 @@ void ObjFileMtlImporter::load() } break; - case 'd': + case 'd': { if( *(m_DataIt+1) == 'i' && *( m_DataIt + 2 ) == 's' && *( m_DataIt + 3 ) == 'p' ) { // A displacement map @@ -232,7 +232,7 @@ void ObjFileMtlImporter::getColorRGBA( aiColor3D *pColor ) { ai_assert( NULL != pColor ); - float r( 0.0f ), g( 0.0f ), b( 0.0f ); + ai_real r( 0.0 ), g( 0.0 ), b( 0.0 ); m_DataIt = getFloat( m_DataIt, m_DataItEnd, r ); pColor->r = r; @@ -255,10 +255,10 @@ void ObjFileMtlImporter::getIlluminationModel( int &illum_model ) // ------------------------------------------------------------------- // Loads a single float value. -void ObjFileMtlImporter::getFloatValue( float &value ) +void ObjFileMtlImporter::getFloatValue( ai_real &value ) { m_DataIt = CopyNextWord( m_DataIt, m_DataItEnd, m_buffer, BUFFERSIZE ); - value = (float) fast_atof(m_buffer); + value = (ai_real) fast_atof(m_buffer); } // ------------------------------------------------------------------- diff --git a/code/ObjFileMtlImporter.h b/code/ObjFileMtlImporter.h index f2c1ba820..54e4b7cef 100644 --- a/code/ObjFileMtlImporter.h +++ b/code/ObjFileMtlImporter.h @@ -41,6 +41,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include +#include struct aiColor3D; struct aiString; @@ -85,7 +86,7 @@ private: /// Get illumination model from loaded data void getIlluminationModel( int &illum_model ); /// Gets a float value from data. - void getFloatValue( float &value ); + void getFloatValue( ai_real &value ); /// Creates a new material from loaded data. void createMaterial(); /// Get texture name from loaded data. diff --git a/code/ObjFileParser.cpp b/code/ObjFileParser.cpp index 79bc299bc..a2e96834f 100644 --- a/code/ObjFileParser.cpp +++ b/code/ObjFileParser.cpp @@ -279,23 +279,23 @@ size_t ObjFileParser::getNumComponentsInLine() { // ------------------------------------------------------------------- void ObjFileParser::getVector( std::vector &point3d_array ) { size_t numComponents = getNumComponentsInLine(); - float x, y, z; + ai_real x, y, z; if( 2 == numComponents ) { copyNextWord( m_buffer, Buffersize ); - x = ( float ) fast_atof( m_buffer ); + x = ( ai_real ) fast_atof( m_buffer ); copyNextWord( m_buffer, Buffersize ); - y = ( float ) fast_atof( m_buffer ); + y = ( ai_real ) fast_atof( m_buffer ); z = 0.0; } else if( 3 == numComponents ) { copyNextWord( m_buffer, Buffersize ); - x = ( float ) fast_atof( m_buffer ); + x = ( ai_real ) fast_atof( m_buffer ); copyNextWord( m_buffer, Buffersize ); - y = ( float ) fast_atof( m_buffer ); + y = ( ai_real ) fast_atof( m_buffer ); copyNextWord( m_buffer, Buffersize ); - z = ( float ) fast_atof( m_buffer ); + z = ( ai_real ) fast_atof( m_buffer ); } else { throw DeadlyImportError( "OBJ: Invalid number of components" ); } @@ -306,15 +306,15 @@ void ObjFileParser::getVector( std::vector &point3d_array ) { // ------------------------------------------------------------------- // Get values for a new 3D vector instance void ObjFileParser::getVector3( std::vector &point3d_array ) { - float x, y, z; + ai_real x, y, z; copyNextWord(m_buffer, Buffersize); - x = (float) fast_atof(m_buffer); + x = (ai_real) fast_atof(m_buffer); copyNextWord(m_buffer, Buffersize); - y = (float) fast_atof(m_buffer); + y = (ai_real) fast_atof(m_buffer); copyNextWord( m_buffer, Buffersize ); - z = ( float ) fast_atof( m_buffer ); + z = ( ai_real ) fast_atof( m_buffer ); point3d_array.push_back( aiVector3D( x, y, z ) ); m_DataIt = skipLine( m_DataIt, m_DataItEnd, m_uiLine ); @@ -323,26 +323,26 @@ void ObjFileParser::getVector3( std::vector &point3d_array ) { // ------------------------------------------------------------------- // Get values for two 3D vectors on the same line void ObjFileParser::getTwoVectors3( std::vector &point3d_array_a, std::vector &point3d_array_b ) { - float x, y, z; + ai_real x, y, z; copyNextWord(m_buffer, Buffersize); - x = (float) fast_atof(m_buffer); + x = (ai_real) fast_atof(m_buffer); copyNextWord(m_buffer, Buffersize); - y = (float) fast_atof(m_buffer); + y = (ai_real) fast_atof(m_buffer); copyNextWord( m_buffer, Buffersize ); - z = ( float ) fast_atof( m_buffer ); + z = ( ai_real ) fast_atof( m_buffer ); point3d_array_a.push_back( aiVector3D( x, y, z ) ); copyNextWord(m_buffer, Buffersize); - x = (float) fast_atof(m_buffer); + x = (ai_real) fast_atof(m_buffer); copyNextWord(m_buffer, Buffersize); - y = (float) fast_atof(m_buffer); + y = (ai_real) fast_atof(m_buffer); copyNextWord( m_buffer, Buffersize ); - z = ( float ) fast_atof( m_buffer ); + z = ( ai_real ) fast_atof( m_buffer ); point3d_array_b.push_back( aiVector3D( x, y, z ) ); @@ -352,12 +352,12 @@ void ObjFileParser::getTwoVectors3( std::vector &point3d_array_a, st // ------------------------------------------------------------------- // Get values for a new 2D vector instance void ObjFileParser::getVector2( std::vector &point2d_array ) { - float x, y; + ai_real x, y; copyNextWord(m_buffer, Buffersize); - x = (float) fast_atof(m_buffer); + x = (ai_real) fast_atof(m_buffer); copyNextWord(m_buffer, Buffersize); - y = (float) fast_atof(m_buffer); + y = (ai_real) fast_atof(m_buffer); point2d_array.push_back(aiVector2D(x, y)); diff --git a/code/ObjTools.h b/code/ObjTools.h index 311965ce3..649ac5a51 100644 --- a/code/ObjTools.h +++ b/code/ObjTools.h @@ -196,12 +196,12 @@ inline char_t CopyNextWord( char_t it, char_t end, char *pBuffer, size_t length * @return Current-iterator with new position */ template -inline char_t getFloat( char_t it, char_t end, float &value ) +inline char_t getFloat( char_t it, char_t end, ai_real &value ) { static const size_t BUFFERSIZE = 1024; char buffer[ BUFFERSIZE ]; it = CopyNextWord( it, end, buffer, BUFFERSIZE ); - value = (float) fast_atof( buffer ); + value = (ai_real) fast_atof( buffer ); return it; } diff --git a/code/PlyExporter.cpp b/code/PlyExporter.cpp index e69c5e386..af4d0d372 100644 --- a/code/PlyExporter.cpp +++ b/code/PlyExporter.cpp @@ -56,6 +56,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. //using namespace Assimp; namespace Assimp { +// make sure typeof returns consistent output across different platforms +// also consider using: typeid(VAR).name() +template const char* typeof(T&) { return "unknown"; } +template<> const char* typeof(float&) { return "float"; } +template<> const char* typeof(double&) { return "double"; } + // ------------------------------------------------------------------------------------------------ // Worker function for exporting a scene to PLY. Prototyped and registered in Exporter.cpp void ExportScenePly(const char* pFile,IOSystem* pIOSystem, const aiScene* pScene, const ExportProperties* pProperties) @@ -136,15 +142,21 @@ PlyExporter::PlyExporter(const char* _filename, const aiScene* pScene, bool bina << aiGetVersionMajor() << '.' << aiGetVersionMinor() << '.' << aiGetVersionRevision() << ")" << endl; + // TODO: probably want to check here rather than just assume something + // definitely not good to always write float even if we might have double precision + + ai_real tmp = 0.0; + const char * typeName = typeof(tmp); + mOutput << "element vertex " << vertices << endl; - mOutput << "property float x" << endl; - mOutput << "property float y" << endl; - mOutput << "property float z" << endl; + mOutput << "property " << typeName << " x" << endl; + mOutput << "property " << typeName << " y" << endl; + mOutput << "property " << typeName << " z" << endl; if(components & PLY_EXPORT_HAS_NORMALS) { - mOutput << "property float nx" << endl; - mOutput << "property float ny" << endl; - mOutput << "property float nz" << endl; + mOutput << "property " << typeName << " nx" << endl; + mOutput << "property " << typeName << " ny" << endl; + mOutput << "property " << typeName << " nz" << endl; } // write texcoords first, just in case an importer does not support tangents @@ -154,37 +166,37 @@ PlyExporter::PlyExporter(const char* _filename, const aiScene* pScene, bool bina // and texture coordinates). for (unsigned int n = PLY_EXPORT_HAS_TEXCOORDS, c = 0; (components & n) && c != AI_MAX_NUMBER_OF_TEXTURECOORDS; n <<= 1, ++c) { if (!c) { - mOutput << "property float s" << endl; - mOutput << "property float t" << endl; + mOutput << "property " << typeName << " s" << endl; + mOutput << "property " << typeName << " t" << endl; } else { - mOutput << "property float s" << c << endl; - mOutput << "property float t" << c << endl; + mOutput << "property " << typeName << " s" << c << endl; + mOutput << "property " << typeName << " t" << c << endl; } } for (unsigned int n = PLY_EXPORT_HAS_COLORS, c = 0; (components & n) && c != AI_MAX_NUMBER_OF_COLOR_SETS; n <<= 1, ++c) { if (!c) { - mOutput << "property float r" << endl; - mOutput << "property float g" << endl; - mOutput << "property float b" << endl; - mOutput << "property float a" << endl; + mOutput << "property " << typeName << " r" << endl; + mOutput << "property " << typeName << " g" << endl; + mOutput << "property " << typeName << " b" << endl; + mOutput << "property " << typeName << " a" << endl; } else { - mOutput << "property float r" << c << endl; - mOutput << "property float g" << c << endl; - mOutput << "property float b" << c << endl; - mOutput << "property float a" << c << endl; + mOutput << "property " << typeName << " r" << c << endl; + mOutput << "property " << typeName << " g" << c << endl; + mOutput << "property " << typeName << " b" << c << endl; + mOutput << "property " << typeName << " a" << c << endl; } } if(components & PLY_EXPORT_HAS_TANGENTS_BITANGENTS) { - mOutput << "property float tx" << endl; - mOutput << "property float ty" << endl; - mOutput << "property float tz" << endl; - mOutput << "property float bx" << endl; - mOutput << "property float by" << endl; - mOutput << "property float bz" << endl; + mOutput << "property " << typeName << " tx" << endl; + mOutput << "property " << typeName << " ty" << endl; + mOutput << "property " << typeName << " tz" << endl; + mOutput << "property " << typeName << " bx" << endl; + mOutput << "property " << typeName << " by" << endl; + mOutput << "property " << typeName << " bz" << endl; } mOutput << "element face " << faces << endl; @@ -223,7 +235,7 @@ PlyExporter::~PlyExporter() { // ------------------------------------------------------------------------------------------------ void PlyExporter::WriteMeshVerts(const aiMesh* m, unsigned int components) { - static const float inf = std::numeric_limits::infinity(); + static const ai_real inf = std::numeric_limits::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. diff --git a/code/PlyLoader.cpp b/code/PlyLoader.cpp index d4dc2f864..dc002531f 100644 --- a/code/PlyLoader.cpp +++ b/code/PlyLoader.cpp @@ -326,7 +326,7 @@ void PLYImporter::ConvertMeshes(std::vector* avFaces, iNum += (unsigned int)(*avFaces)[aiSplit[p][i]].mIndices.size(); } p_pcOut->mNumVertices = iNum; - if( 0 == iNum ) { // nothing to do + if( 0 == iNum ) { // nothing to do delete[] aiSplit; // cleanup delete p_pcOut; return; @@ -481,13 +481,13 @@ void PLYImporter::LoadTextureCoordinates(std::vector* pvOut) if (0xFFFFFFFF != aiPositions[0]) { - vOut.x = PLY::PropertyInstance::ConvertTo( + vOut.x = PLY::PropertyInstance::ConvertTo( GetProperty((*i).alProperties, aiPositions[0]).avList.front(),aiTypes[0]); } if (0xFFFFFFFF != aiPositions[1]) { - vOut.y = PLY::PropertyInstance::ConvertTo( + vOut.y = PLY::PropertyInstance::ConvertTo( GetProperty((*i).alProperties, aiPositions[1]).avList.front(),aiTypes[1]); } // and add them to our nice list @@ -502,7 +502,7 @@ void PLYImporter::LoadVertices(std::vector* pvOut, bool p_bNormals) { ai_assert(NULL != pvOut); - unsigned int aiPositions[3] = {0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF}; + ai_uint aiPositions[3] = {0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF}; PLY::EDataType aiTypes[3] = {EDT_Char,EDT_Char,EDT_Char}; PLY::ElementInstanceList* pcList = NULL; unsigned int cnt = 0; @@ -591,19 +591,19 @@ void PLYImporter::LoadVertices(std::vector* pvOut, bool p_bNormals) if (0xFFFFFFFF != aiPositions[0]) { - vOut.x = PLY::PropertyInstance::ConvertTo( + vOut.x = PLY::PropertyInstance::ConvertTo( GetProperty((*i).alProperties, aiPositions[0]).avList.front(),aiTypes[0]); } if (0xFFFFFFFF != aiPositions[1]) { - vOut.y = PLY::PropertyInstance::ConvertTo( + vOut.y = PLY::PropertyInstance::ConvertTo( GetProperty((*i).alProperties, aiPositions[1]).avList.front(),aiTypes[1]); } if (0xFFFFFFFF != aiPositions[2]) { - vOut.z = PLY::PropertyInstance::ConvertTo( + vOut.z = PLY::PropertyInstance::ConvertTo( GetProperty((*i).alProperties, aiPositions[2]).avList.front(),aiTypes[2]); } @@ -615,7 +615,7 @@ void PLYImporter::LoadVertices(std::vector* pvOut, bool p_bNormals) // ------------------------------------------------------------------------------------------------ // Convert a color component to [0...1] -float PLYImporter::NormalizeColorValue (PLY::PropertyInstance::ValueUnion val, +ai_real PLYImporter::NormalizeColorValue (PLY::PropertyInstance::ValueUnion val, PLY::EDataType eType) { switch (eType) @@ -623,20 +623,20 @@ float PLYImporter::NormalizeColorValue (PLY::PropertyInstance::ValueUnion val, case EDT_Float: return val.fFloat; case EDT_Double: - return (float)val.fDouble; + return (ai_real)val.fDouble; case EDT_UChar: - return (float)val.iUInt / (float)0xFF; + return (ai_real)val.iUInt / (ai_real)0xFF; case EDT_Char: - return (float)(val.iInt+(0xFF/2)) / (float)0xFF; + return (ai_real)(val.iInt+(0xFF/2)) / (ai_real)0xFF; case EDT_UShort: - return (float)val.iUInt / (float)0xFFFF; + return (ai_real)val.iUInt / (ai_real)0xFFFF; case EDT_Short: - return (float)(val.iInt+(0xFFFF/2)) / (float)0xFFFF; + return (ai_real)(val.iInt+(0xFFFF/2)) / (ai_real)0xFFFF; case EDT_UInt: - return (float)val.iUInt / (float)0xFFFF; + return (ai_real)val.iUInt / (ai_real)0xFFFF; case EDT_Int: - return ((float)val.iInt / (float)0xFF) + 0.5f; + return ((ai_real)val.iInt / (ai_real)0xFF) + 0.5f; default: ; }; return 0.0f; @@ -727,7 +727,7 @@ void PLYImporter::LoadVertexColor(std::vector* pvOut) } // assume 1.0 for the alpha channel ifit is not set - if (0xFFFFFFFF == aiPositions[3])vOut.a = 1.0f; + if (0xFFFFFFFF == aiPositions[3])vOut.a = 1.0; else { vOut.a = NormalizeColorValue(GetProperty((*i).alProperties, @@ -1076,14 +1076,14 @@ void PLYImporter::LoadMaterial(std::vector* pvOut) // handle phong power and shading mode int iMode; if (0xFFFFFFFF != iPhong) { - float fSpec = PLY::PropertyInstance::ConvertTo(GetProperty((*i).alProperties, iPhong).avList.front(),ePhong); + ai_real fSpec = PLY::PropertyInstance::ConvertTo(GetProperty((*i).alProperties, iPhong).avList.front(),ePhong); // if shininess is 0 (and the pow() calculation would therefore always // become 1, not depending on the angle), use gouraud lighting if (fSpec) { // scale this with 15 ... hopefully this is correct fSpec *= 15; - pcHelper->AddProperty(&fSpec, 1, AI_MATKEY_SHININESS); + pcHelper->AddProperty(&fSpec, 1, AI_MATKEY_SHININESS); iMode = (int)aiShadingMode_Phong; } @@ -1094,8 +1094,8 @@ void PLYImporter::LoadMaterial(std::vector* pvOut) // handle opacity if (0xFFFFFFFF != iOpacity) { - float fOpacity = PLY::PropertyInstance::ConvertTo(GetProperty((*i).alProperties, iPhong).avList.front(),eOpacity); - pcHelper->AddProperty(&fOpacity, 1, AI_MATKEY_OPACITY); + ai_real fOpacity = PLY::PropertyInstance::ConvertTo(GetProperty((*i).alProperties, iPhong).avList.front(),eOpacity); + pcHelper->AddProperty(&fOpacity, 1, AI_MATKEY_OPACITY); } // The face order is absolutely undefined for PLY, so we have to diff --git a/code/PlyLoader.h b/code/PlyLoader.h index 71b483c57..3297524a9 100644 --- a/code/PlyLoader.h +++ b/code/PlyLoader.h @@ -155,7 +155,7 @@ protected: /** Static helper to parse a color channel value. The input value * is normalized to 0-1. */ - static float NormalizeColorValue ( + static ai_real NormalizeColorValue ( PLY::PropertyInstance::ValueUnion val, PLY::EDataType eType); diff --git a/code/PlyParser.cpp b/code/PlyParser.cpp index 06e4038f4..9168170e8 100644 --- a/code/PlyParser.cpp +++ b/code/PlyParser.cpp @@ -819,15 +819,18 @@ bool PLY::PropertyInstance::ParseValue( break; case EDT_Float: - - pCur = fast_atoreal_move(pCur,out->fFloat); + // technically this should cast to float, but people tend to use float descriptors for double data + // this is the best way to not risk loosing precision on import and it doesn't hurt to do this + ai_real f; + pCur = fast_atoreal_move(pCur,f); + out->fFloat = (ai_real)f; break; case EDT_Double: - float f; - pCur = fast_atoreal_move(pCur,f); - out->fDouble = (double)f; + double d; + pCur = fast_atoreal_move(pCur,d); + out->fDouble = (double)d; break; default: diff --git a/code/PretransformVertices.cpp b/code/PretransformVertices.cpp index 8158bdd6f..48a3e6f61 100644 --- a/code/PretransformVertices.cpp +++ b/code/PretransformVertices.cpp @@ -690,9 +690,9 @@ 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; + d = min + d * (ai_real)0.5; for (unsigned int a = 0; a < pScene->mNumMeshes; ++a) { aiMesh* m = pScene->mMeshes[a]; for (unsigned int i = 0; i < m->mNumVertices;++i) { @@ -721,4 +721,3 @@ void PretransformVertices::Execute( aiScene* pScene) DefaultLogger::get()->info(buffer); } } - diff --git a/code/ProcessHelper.cpp b/code/ProcessHelper.cpp index e18d54c30..c77049061 100644 --- a/code/ProcessHelper.cpp +++ b/code/ProcessHelper.cpp @@ -77,8 +77,8 @@ void ConvertListToStrings(const std::string& in, std::list& out) void FindAABBTransformed (const aiMesh* mesh, aiVector3D& min, aiVector3D& max, const aiMatrix4x4& m) { - min = aiVector3D (10e10f, 10e10f, 10e10f); - max = aiVector3D (-10e10f,-10e10f,-10e10f); + min = aiVector3D (10e10, 10e10, 10e10); + max = aiVector3D (-10e10,-10e10,-10e10); for (unsigned int i = 0;i < mesh->mNumVertices;++i) { const aiVector3D v = m * mesh->mVertices[i]; @@ -91,7 +91,7 @@ void FindAABBTransformed (const aiMesh* mesh, aiVector3D& min, aiVector3D& max, void FindMeshCenter (aiMesh* mesh, aiVector3D& out, aiVector3D& min, aiVector3D& max) { ArrayBounds(mesh->mVertices,mesh->mNumVertices, min,max); - out = min + (max-min)*0.5f; + out = min + (max-min)*(ai_real)0.5; } // ------------------------------------------------------------------------------- @@ -114,7 +114,7 @@ void FindSceneCenter (aiScene* scene, aiVector3D& out, aiVector3D& min, aiVector if (max[1] < tmax[1]) max[1] = tmax[1]; if (max[2] < tmax[2]) max[2] = tmax[2]; } - out = min + (max-min)*0.5f; + out = min + (max-min)*(ai_real)0.5; } @@ -123,7 +123,7 @@ void FindMeshCenterTransformed (aiMesh* mesh, aiVector3D& out, aiVector3D& min, aiVector3D& max, const aiMatrix4x4& m) { FindAABBTransformed(mesh,min,max,m); - out = min + (max-min)*0.5f; + out = min + (max-min)*(ai_real)0.5; } // ------------------------------------------------------------------------------- @@ -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; diff --git a/code/ProcessHelper.h b/code/ProcessHelper.h index 3f50a46c6..c70e23f5f 100644 --- a/code/ProcessHelper.h +++ b/code/ProcessHelper.h @@ -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 _Type; + typedef std::pair _Type; DefaultLogger::get()->debug("Generate spatially-sorted vertex cache"); std::vector<_Type>* p = new std::vector<_Type>(pScene->mNumMeshes); diff --git a/code/SIBImporter.cpp b/code/SIBImporter.cpp index b972f28d6..8dfacc106 100644 --- a/code/SIBImporter.cpp +++ b/code/SIBImporter.cpp @@ -163,13 +163,13 @@ static aiColor3D ReadColor(StreamReaderLE* stream) static void UnknownChunk(StreamReaderLE* stream, const SIBChunk& chunk) { - char temp[5] = { + char temp[5] = { static_cast(( chunk.Tag>>24 ) & 0xff), static_cast(( chunk.Tag>>16 ) & 0xff), static_cast(( chunk.Tag>>8 ) & 0xff), static_cast(chunk.Tag & 0xff), '\0' }; - + DefaultLogger::get()->warn((Formatter::format(), "SIB: Skipping unknown '",temp,"' chunk.")); } @@ -373,7 +373,7 @@ static void ConnectFaces(SIBMesh* mesh) uint32_t *idx = &mesh->idx[mesh->faceStart[faceIdx]]; uint32_t numPoints = *idx++; uint32_t prev = idx[(numPoints-1)*N+POS]; - + for (uint32_t i=0;i& faceNormals) { - // Creased edges complicate this. We need to find the start/end range of the + // Creased edges complicate this. We need to find the start/end range of the // ring of faces that touch this position. // We do this in two passes. The first pass is to find the end of the range, // the second is to work backwards to the start and calculate the final normal. @@ -449,7 +449,7 @@ static aiVector3D CalculateVertexNormal(SIBMesh* mesh, uint32_t faceIdx, uint32_ prevFaceIdx = faceIdx; faceIdx = nextFaceIdx; - } + } } // Normalize it. @@ -610,7 +610,7 @@ static void ReadShape(SIB* sib, StreamReaderLE* stream) obj.name = name; obj.axis = smesh.axis; obj.meshIdx = sib->meshes.size(); - + // Now that we know the size of everything, // we can build the final one-material-per-mesh data. for (size_t n=0;nmColorDiffuse = ReadColor(stream); light->mColorAmbient = ReadColor(stream); light->mColorSpecular = ReadColor(stream); - float spotExponent = stream->GetF4(); - float spotCutoff = stream->GetF4(); + ai_real spotExponent = stream->GetF4(); + ai_real spotCutoff = stream->GetF4(); light->mAttenuationConstant = stream->GetF4(); light->mAttenuationLinear = stream->GetF4(); light->mAttenuationQuadratic = stream->GetF4(); @@ -709,9 +709,9 @@ static void ReadLightInfo(aiLight* light, StreamReaderLE* stream) // 99% and 1% percentiles. // OpenGL: I = cos(angle)^E // Solving: angle = acos(I^(1/E)) - float E = 1.0f / std::max(spotExponent, 0.00001f); - float inner = acosf(powf(0.99f, E)); - float outer = acosf(powf(0.01f, E)); + ai_real E = 1.0 / std::max(spotExponent, (ai_real)0.00001); + ai_real inner = acos(pow((ai_real)0.99, E)); + ai_real outer = acos(pow((ai_real)0.01, E)); // Apply the cutoff. outer = std::min(outer, AI_DEG_TO_RAD(spotCutoff)); diff --git a/code/STLExporter.cpp b/code/STLExporter.cpp index 09e01626d..3905cbcaf 100644 --- a/code/STLExporter.cpp +++ b/code/STLExporter.cpp @@ -162,12 +162,12 @@ void STLExporter :: WriteMeshBinary(const aiMesh* m) } nor.Normalize(); } - float nx = nor.x, ny = nor.y, nz = nor.z; + ai_real nx = nor.x, ny = nor.y, nz = nor.z; AI_SWAP4(nx); AI_SWAP4(ny); AI_SWAP4(nz); mOutput.write((char *)&nx, 4); mOutput.write((char *)&ny, 4); mOutput.write((char *)&nz, 4); for(unsigned int a = 0; a < f.mNumIndices; ++a) { const aiVector3D& v = m->mVertices[f.mIndices[a]]; - float vx = v.x, vy = v.y, vz = v.z; + ai_real vx = v.x, vy = v.y, vz = v.z; AI_SWAP4(vx); AI_SWAP4(vy); AI_SWAP4(vz); mOutput.write((char *)&vx, 4); mOutput.write((char *)&vy, 4); mOutput.write((char *)&vz, 4); } diff --git a/code/STLLoader.cpp b/code/STLLoader.cpp index 95fce47e2..647bd8a96 100644 --- a/code/STLLoader.cpp +++ b/code/STLLoader.cpp @@ -144,7 +144,7 @@ bool STLImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool const char* tokens[] = {"STL","solid"}; return SearchFileHeaderForToken(pIOHandler,pFile,tokens,2); } - + return false; } @@ -189,7 +189,7 @@ void STLImporter::InternReadFile( const std::string& pFile, this->mBuffer = &mBuffer2[0]; // the default vertex color is light gray. - clrColorDefault.r = clrColorDefault.g = clrColorDefault.b = clrColorDefault.a = 0.6f; + clrColorDefault.r = clrColorDefault.g = clrColorDefault.b = clrColorDefault.a = 0.6; // allocate a single node pScene->mRootNode = new aiNode(); @@ -217,13 +217,13 @@ void STLImporter::InternReadFile( const std::string& pFile, s.Set(AI_DEFAULT_MATERIAL_NAME); pcMat->AddProperty(&s, AI_MATKEY_NAME); - aiColor4D clrDiffuse(0.6f,0.6f,0.6f,1.0f); + aiColor4D clrDiffuse(0.6,0.6,0.6,1.0); if (bMatClr) { clrDiffuse = clrColorDefault; } pcMat->AddProperty(&clrDiffuse,1,AI_MATKEY_COLOR_DIFFUSE); pcMat->AddProperty(&clrDiffuse,1,AI_MATKEY_COLOR_SPECULAR); - clrDiffuse = aiColor4D(0.05f,0.05f,0.05f,1.0f); + clrDiffuse = aiColor4D(0.05,0.05,0.05,1.0); pcMat->AddProperty(&clrDiffuse,1,AI_MATKEY_COLOR_AMBIENT); pScene->mNumMaterials = 1; @@ -307,11 +307,11 @@ void STLImporter::LoadASCIIFile() } sz += 7; SkipSpaces(&sz); - sz = fast_atoreal_move(sz, (float&)vn->x ); + sz = fast_atoreal_move(sz, (ai_real&)vn->x ); SkipSpaces(&sz); - sz = fast_atoreal_move(sz, (float&)vn->y ); + sz = fast_atoreal_move(sz, (ai_real&)vn->y ); SkipSpaces(&sz); - sz = fast_atoreal_move(sz, (float&)vn->z ); + sz = fast_atoreal_move(sz, (ai_real&)vn->z ); normalBuffer.push_back(*vn); normalBuffer.push_back(*vn); } @@ -332,11 +332,11 @@ void STLImporter::LoadASCIIFile() SkipSpaces(&sz); positionBuffer.push_back(aiVector3D()); aiVector3D* vn = &positionBuffer.back(); - sz = fast_atoreal_move(sz, (float&)vn->x ); + sz = fast_atoreal_move(sz, (ai_real&)vn->x ); SkipSpaces(&sz); - sz = fast_atoreal_move(sz, (float&)vn->y ); + sz = fast_atoreal_move(sz, (ai_real&)vn->y ); SkipSpaces(&sz); - sz = fast_atoreal_move(sz, (float&)vn->z ); + sz = fast_atoreal_move(sz, (ai_real&)vn->z ); faceVertexCounter++; } } @@ -416,10 +416,10 @@ bool STLImporter::LoadBinaryFile() // read the default vertex color for facets bIsMaterialise = true; DefaultLogger::get()->info("STL: Taking code path for Materialise files"); - clrColorDefault.r = (*sz2++) / 255.0f; - clrColorDefault.g = (*sz2++) / 255.0f; - clrColorDefault.b = (*sz2++) / 255.0f; - clrColorDefault.a = (*sz2++) / 255.0f; + clrColorDefault.r = (*sz2++) / 255.0; + clrColorDefault.g = (*sz2++) / 255.0; + clrColorDefault.b = (*sz2++) / 255.0; + clrColorDefault.a = (*sz2++) / 255.0; break; } } @@ -480,18 +480,18 @@ bool STLImporter::LoadBinaryFile() DefaultLogger::get()->info("STL: Mesh has vertex colors"); } aiColor4D* clr = &pMesh->mColors[0][i*3]; - clr->a = 1.0f; + clr->a = 1.0; if (bIsMaterialise) // this is reversed { - clr->r = (color & 0x31u) / 31.0f; - clr->g = ((color & (0x31u<<5))>>5u) / 31.0f; - clr->b = ((color & (0x31u<<10))>>10u) / 31.0f; + clr->r = (color & 0x31u) / 31.0; + clr->g = ((color & (0x31u<<5))>>5u) / 31.0; + clr->b = ((color & (0x31u<<10))>>10u) / 31.0; } else { - clr->b = (color & 0x31u) / 31.0f; - clr->g = ((color & (0x31u<<5))>>5u) / 31.0f; - clr->r = ((color & (0x31u<<10))>>10u) / 31.0f; + clr->b = (color & 0x31u) / 31.0; + clr->g = ((color & (0x31u<<5))>>5u) / 31.0; + clr->r = ((color & (0x31u<<10))>>10u) / 31.0; } // assign the color to all vertices of the face *(clr+1) = *clr; diff --git a/code/SceneCombiner.cpp b/code/SceneCombiner.cpp index b39adbf78..51541a34b 100644 --- a/code/SceneCombiner.cpp +++ b/code/SceneCombiner.cpp @@ -1132,7 +1132,7 @@ void SceneCombiner::Copy( aiAnimation** _dest, const aiAnimation* src ) { ai_assert( NULL != _dest ); ai_assert( NULL != src ); - + aiAnimation* dest = *_dest = new aiAnimation(); // get a flat copy @@ -1246,6 +1246,9 @@ void SceneCombiner::Copy (aiMetadata** _dest, const aiMetadata* src) case AI_FLOAT: out.mData = new float(*static_cast(in.mData)); break; + case AI_DOUBLE: + out.mData = new double(*static_cast(in.mData)); + break; case AI_AISTRING: out.mData = new aiString(*static_cast(in.mData)); break; diff --git a/code/SkeletonMeshBuilder.cpp b/code/SkeletonMeshBuilder.cpp index ec7aa8985..c564cbc95 100644 --- a/code/SkeletonMeshBuilder.cpp +++ b/code/SkeletonMeshBuilder.cpp @@ -96,31 +96,31 @@ void SkeletonMeshBuilder::CreateGeometry( const aiNode* pNode) // find a suitable coordinate system const aiMatrix4x4& childTransform = pNode->mChildren[a]->mTransformation; aiVector3D childpos( childTransform.a4, childTransform.b4, childTransform.c4); - float distanceToChild = childpos.Length(); - if( distanceToChild < 0.0001f) + ai_real distanceToChild = childpos.Length(); + if( distanceToChild < 0.0001) continue; aiVector3D up = aiVector3D( childpos).Normalize(); - aiVector3D orth( 1.0f, 0.0f, 0.0f); - if( std::fabs( orth * up) > 0.99f) - orth.Set( 0.0f, 1.0f, 0.0f); + aiVector3D orth( 1.0, 0.0, 0.0); + if( std::fabs( orth * up) > 0.99) + orth.Set( 0.0, 1.0, 0.0); aiVector3D front = (up ^ orth).Normalize(); aiVector3D side = (front ^ up).Normalize(); unsigned int localVertexStart = mVertices.size(); - mVertices.push_back( -front * distanceToChild * 0.1f); + mVertices.push_back( -front * distanceToChild * (ai_real)0.1); mVertices.push_back( childpos); - mVertices.push_back( -side * distanceToChild * 0.1f); - mVertices.push_back( -side * distanceToChild * 0.1f); + mVertices.push_back( -side * distanceToChild * (ai_real)0.1); + mVertices.push_back( -side * distanceToChild * (ai_real)0.1); mVertices.push_back( childpos); - mVertices.push_back( front * distanceToChild * 0.1f); - mVertices.push_back( front * distanceToChild * 0.1f); + mVertices.push_back( front * distanceToChild * (ai_real)0.1); + mVertices.push_back( front * distanceToChild * (ai_real)0.1); mVertices.push_back( childpos); - mVertices.push_back( side * distanceToChild * 0.1f); - mVertices.push_back( side * distanceToChild * 0.1f); + mVertices.push_back( side * distanceToChild * (ai_real)0.1); + mVertices.push_back( side * distanceToChild * (ai_real)0.1); mVertices.push_back( childpos); - mVertices.push_back( -front * distanceToChild * 0.1f); + mVertices.push_back( -front * distanceToChild * (ai_real)0.1); mFaces.push_back( Face( localVertexStart + 0, localVertexStart + 1, localVertexStart + 2)); mFaces.push_back( Face( localVertexStart + 3, localVertexStart + 4, localVertexStart + 5)); @@ -132,33 +132,33 @@ void SkeletonMeshBuilder::CreateGeometry( const aiNode* pNode) { // if the node has no children, it's an end node. Put a little knob there instead aiVector3D ownpos( pNode->mTransformation.a4, pNode->mTransformation.b4, pNode->mTransformation.c4); - float sizeEstimate = ownpos.Length() * 0.18f; + ai_real sizeEstimate = ownpos.Length() * 0.18; - mVertices.push_back( aiVector3D( -sizeEstimate, 0.0f, 0.0f)); - mVertices.push_back( aiVector3D( 0.0f, sizeEstimate, 0.0f)); - mVertices.push_back( aiVector3D( 0.0f, 0.0f, -sizeEstimate)); - mVertices.push_back( aiVector3D( 0.0f, sizeEstimate, 0.0f)); - mVertices.push_back( aiVector3D( sizeEstimate, 0.0f, 0.0f)); - mVertices.push_back( aiVector3D( 0.0f, 0.0f, -sizeEstimate)); - mVertices.push_back( aiVector3D( sizeEstimate, 0.0f, 0.0f)); - mVertices.push_back( aiVector3D( 0.0f, -sizeEstimate, 0.0f)); - mVertices.push_back( aiVector3D( 0.0f, 0.0f, -sizeEstimate)); - mVertices.push_back( aiVector3D( 0.0f, -sizeEstimate, 0.0f)); - mVertices.push_back( aiVector3D( -sizeEstimate, 0.0f, 0.0f)); - mVertices.push_back( aiVector3D( 0.0f, 0.0f, -sizeEstimate)); + mVertices.push_back( aiVector3D( -sizeEstimate, 0.0, 0.0)); + mVertices.push_back( aiVector3D( 0.0, sizeEstimate, 0.0)); + mVertices.push_back( aiVector3D( 0.0, 0.0, -sizeEstimate)); + mVertices.push_back( aiVector3D( 0.0, sizeEstimate, 0.0)); + mVertices.push_back( aiVector3D( sizeEstimate, 0.0, 0.0)); + mVertices.push_back( aiVector3D( 0.0, 0.0, -sizeEstimate)); + mVertices.push_back( aiVector3D( sizeEstimate, 0.0, 0.0)); + mVertices.push_back( aiVector3D( 0.0, -sizeEstimate, 0.0)); + mVertices.push_back( aiVector3D( 0.0, 0.0, -sizeEstimate)); + mVertices.push_back( aiVector3D( 0.0, -sizeEstimate, 0.0)); + mVertices.push_back( aiVector3D( -sizeEstimate, 0.0, 0.0)); + mVertices.push_back( aiVector3D( 0.0, 0.0, -sizeEstimate)); - mVertices.push_back( aiVector3D( -sizeEstimate, 0.0f, 0.0f)); - mVertices.push_back( aiVector3D( 0.0f, 0.0f, sizeEstimate)); - mVertices.push_back( aiVector3D( 0.0f, sizeEstimate, 0.0f)); - mVertices.push_back( aiVector3D( 0.0f, sizeEstimate, 0.0f)); - mVertices.push_back( aiVector3D( 0.0f, 0.0f, sizeEstimate)); - mVertices.push_back( aiVector3D( sizeEstimate, 0.0f, 0.0f)); - mVertices.push_back( aiVector3D( sizeEstimate, 0.0f, 0.0f)); - mVertices.push_back( aiVector3D( 0.0f, 0.0f, sizeEstimate)); - mVertices.push_back( aiVector3D( 0.0f, -sizeEstimate, 0.0f)); - mVertices.push_back( aiVector3D( 0.0f, -sizeEstimate, 0.0f)); - mVertices.push_back( aiVector3D( 0.0f, 0.0f, sizeEstimate)); - mVertices.push_back( aiVector3D( -sizeEstimate, 0.0f, 0.0f)); + mVertices.push_back( aiVector3D( -sizeEstimate, 0.0, 0.0)); + mVertices.push_back( aiVector3D( 0.0, 0.0, sizeEstimate)); + mVertices.push_back( aiVector3D( 0.0, sizeEstimate, 0.0)); + mVertices.push_back( aiVector3D( 0.0, sizeEstimate, 0.0)); + mVertices.push_back( aiVector3D( 0.0, 0.0, sizeEstimate)); + mVertices.push_back( aiVector3D( sizeEstimate, 0.0, 0.0)); + mVertices.push_back( aiVector3D( sizeEstimate, 0.0, 0.0)); + mVertices.push_back( aiVector3D( 0.0, 0.0, sizeEstimate)); + mVertices.push_back( aiVector3D( 0.0, -sizeEstimate, 0.0)); + mVertices.push_back( aiVector3D( 0.0, -sizeEstimate, 0.0)); + mVertices.push_back( aiVector3D( 0.0, 0.0, sizeEstimate)); + mVertices.push_back( aiVector3D( -sizeEstimate, 0.0, 0.0)); mFaces.push_back( Face( vertexStartIndex + 0, vertexStartIndex + 1, vertexStartIndex + 2)); mFaces.push_back( Face( vertexStartIndex + 3, vertexStartIndex + 4, vertexStartIndex + 5)); @@ -187,7 +187,7 @@ void SkeletonMeshBuilder::CreateGeometry( const aiNode* pNode) bone->mNumWeights = numVertices; bone->mWeights = new aiVertexWeight[numVertices]; for( unsigned int a = 0; a < numVertices; a++) - bone->mWeights[a] = aiVertexWeight( vertexStartIndex + a, 1.0f); + bone->mWeights[a] = aiVertexWeight( vertexStartIndex + a, 1.0); // HACK: (thom) transform all vertices to the bone's local space. Should be done before adding // them to the array, but I'm tired now and I'm annoyed. @@ -232,8 +232,8 @@ aiMesh* SkeletonMeshBuilder::CreateMesh() aiVector3D nor = ((mVertices[inface.mIndices[2]] - mVertices[inface.mIndices[0]]) ^ (mVertices[inface.mIndices[1]] - mVertices[inface.mIndices[0]])); - if (nor.Length() < 1e-5f) /* ensure that FindInvalidData won't remove us ...*/ - nor = aiVector3D(1.f,0.f,0.f); + if (nor.Length() < 1e-5) /* ensure that FindInvalidData won't remove us ...*/ + nor = aiVector3D(1.0,0.0,0.0); for (unsigned int n = 0; n < 3; ++n) mesh->mNormals[inface.mIndices[n]] = nor; diff --git a/code/SpatialSort.cpp b/code/SpatialSort.cpp index c4e4ef2d5..722ec5f24 100644 --- a/code/SpatialSort.cpp +++ b/code/SpatialSort.cpp @@ -107,7 +107,7 @@ void SpatialSort::Append( const aiVector3D* pPositions, unsigned int pNumPositio const aiVector3D* vec = reinterpret_cast (tempPointer + a * pElementOffset); // store position by index and distance - float distance = *vec * mPlaneNormal; + ai_real distance = *vec * mPlaneNormal; mPositions.push_back( Entry( a+initial, *vec, distance)); } @@ -120,10 +120,10 @@ 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, - float pRadius, std::vector& poResults) const + ai_real pRadius, std::vector& poResults) const { - const float dist = pPosition * mPlaneNormal; - const float minDist = dist - pRadius, maxDist = dist + pRadius; + const ai_real dist = pPosition * mPlaneNormal; + const ai_real minDist = dist - pRadius, maxDist = dist + pRadius; // clear the array in this strange fashion because a simple clear() would also deallocate // the array which we want to avoid @@ -160,7 +160,7 @@ void SpatialSort::FindPositions( const aiVector3D& pPosition, // 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 float pSquared = pRadius*pRadius; + const ai_real pSquared = pRadius*pRadius; while( it->mDistance < maxDist) { if( (it->mPosition - pPosition).SquareLength() < pSquared) @@ -182,23 +182,23 @@ namespace { // 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 signed int BinFloat; + typedef ai_int BinFloat; // -------------------------------------------------------------------------------------------- // Converts the bit pattern of a floating-point number to its signed integer representation. - BinFloat ToBinary( const float & pValue) { + 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(float), "sizeof(BinFloat) >= sizeof(float)"); + 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(float), "sizeof(BinFloat) == sizeof(float)"); + 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); @@ -206,7 +206,7 @@ namespace { // 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 { - float asFloat; + ai_real asFloat; BinFloat asBin; } conversion; conversion.asBin = 0; // zero empty space in case sizeof(BinFloat) > sizeof(float) @@ -308,13 +308,13 @@ void SpatialSort::FindIdenticalPositions( const aiVector3D& pPosition, } // ------------------------------------------------------------------------------------------------ -unsigned int SpatialSort::GenerateMappingTable(std::vector& fill,float pRadius) const +unsigned int SpatialSort::GenerateMappingTable(std::vector& fill, ai_real pRadius) const { fill.resize(mPositions.size(),UINT_MAX); - float dist, maxDist; + ai_real dist, maxDist; unsigned int t=0; - const float pSquared = pRadius*pRadius; + const ai_real pSquared = pRadius*pRadius; for (size_t i = 0; i < mPositions.size();) { dist = mPositions[i].mPosition * mPlaneNormal; maxDist = dist + pRadius; @@ -339,4 +339,3 @@ unsigned int SpatialSort::GenerateMappingTable(std::vector& fill,f #endif return t; } - diff --git a/code/SpatialSort.h b/code/SpatialSort.h index b594fc6d1..367e0f6a6 100644 --- a/code/SpatialSort.h +++ b/code/SpatialSort.h @@ -117,7 +117,7 @@ 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, float pRadius, + void FindPositions( const aiVector3D& pPosition, ai_real pRadius, std::vector& poResults) const; // ------------------------------------------------------------------------------------ @@ -139,7 +139,7 @@ public: * be counted in. * @return Number of unique vertices (n). */ unsigned int GenerateMappingTable(std::vector& fill, - float pRadius) const; + ai_real pRadius) const; protected: /** Normal of the sorting plane, normalized. The center is always at (0, 0, 0) */ @@ -151,10 +151,10 @@ protected: { unsigned int mIndex; ///< The vertex referred by this entry aiVector3D mPosition; ///< Position - float mDistance; ///< Distance of this vertex to the sorting plane + ai_real mDistance; ///< Distance of this vertex to the sorting plane Entry() { /** intentionally not initialized.*/ } - Entry( unsigned int pIndex, const aiVector3D& pPosition, float pDistance) + Entry( unsigned int pIndex, const aiVector3D& pPosition, ai_real pDistance) : mIndex( pIndex), mPosition( pPosition), mDistance( pDistance) { } diff --git a/code/StandardShapes.cpp b/code/StandardShapes.cpp index d547c04a7..943b73920 100644 --- a/code/StandardShapes.cpp +++ b/code/StandardShapes.cpp @@ -95,7 +95,7 @@ namespace Assimp { void Subdivide(std::vector& positions) { // assume this to be constant - (fixme: must be 1.0? I think so) - const float fl1 = positions[0].Length(); + const ai_real fl1 = positions[0].Length(); unsigned int origSize = (unsigned int)positions.size(); for (unsigned int i = 0 ; i < origSize ; i+=3) @@ -194,21 +194,21 @@ unsigned int StandardShapes::MakeIcosahedron(std::vector& positions) { positions.reserve(positions.size()+60); - const float t = (1.f + 2.236067977f)/2.f; - const float s = std::sqrt(1.f + t*t); + const ai_real t = (1.0 + 2.236067977)/2.0; + const ai_real s = std::sqrt(1.0 + t*t); - const aiVector3D v0 = aiVector3D(t,1.f, 0.f)/s; - const aiVector3D v1 = aiVector3D(-t,1.f, 0.f)/s; - const aiVector3D v2 = aiVector3D(t,-1.f, 0.f)/s; - const aiVector3D v3 = aiVector3D(-t,-1.f, 0.f)/s; - const aiVector3D v4 = aiVector3D(1.f, 0.f, t)/s; - const aiVector3D v5 = aiVector3D(1.f, 0.f,-t)/s; - const aiVector3D v6 = aiVector3D(-1.f, 0.f,t)/s; - const aiVector3D v7 = aiVector3D(-1.f, 0.f,-t)/s; - const aiVector3D v8 = aiVector3D(0.f, t, 1.f)/s; - const aiVector3D v9 = aiVector3D(0.f,-t, 1.f)/s; - const aiVector3D v10 = aiVector3D(0.f, t,-1.f)/s; - const aiVector3D v11 = aiVector3D(0.f,-t,-1.f)/s; + const aiVector3D v0 = aiVector3D(t,1.0, 0.0)/s; + const aiVector3D v1 = aiVector3D(-t,1.0, 0.0)/s; + const aiVector3D v2 = aiVector3D(t,-1.0, 0.0)/s; + const aiVector3D v3 = aiVector3D(-t,-1.0, 0.0)/s; + const aiVector3D v4 = aiVector3D(1.0, 0.0, t)/s; + const aiVector3D v5 = aiVector3D(1.0, 0.0,-t)/s; + const aiVector3D v6 = aiVector3D(-1.0, 0.0,t)/s; + const aiVector3D v7 = aiVector3D(-1.0, 0.0,-t)/s; + const aiVector3D v8 = aiVector3D(0.0, t, 1.0)/s; + const aiVector3D v9 = aiVector3D(0.0,-t, 1.0)/s; + const aiVector3D v10 = aiVector3D(0.0, t,-1.0)/s; + const aiVector3D v11 = aiVector3D(0.0,-t,-1.0)/s; ADD_TRIANGLE(v0,v8,v4); ADD_TRIANGLE(v0,v5,v10); @@ -244,9 +244,9 @@ unsigned int StandardShapes::MakeDodecahedron(std::vector& positions { positions.reserve(positions.size()+108); - const float a = 1.f / 1.7320508f; - const float b = std::sqrt((3.f-2.23606797f)/6.f); - const float c = std::sqrt((3.f+2.23606797f)/6.f); + const ai_real a = 1.0 / 1.7320508; + const ai_real b = std::sqrt((3.0-2.23606797f)/6.0); + const ai_real c = std::sqrt((3.0+2.23606797f)/6.0); const aiVector3D v0 = aiVector3D(a,a,a); const aiVector3D v1 = aiVector3D(a,a,-a); @@ -256,18 +256,18 @@ unsigned int StandardShapes::MakeDodecahedron(std::vector& positions const aiVector3D v5 = aiVector3D(-a,a,-a); const aiVector3D v6 = aiVector3D(-a,-a,a); const aiVector3D v7 = aiVector3D(-a,-a,-a); - const aiVector3D v8 = aiVector3D(b,c,0.f); - const aiVector3D v9 = aiVector3D(-b,c,0.f); - const aiVector3D v10 = aiVector3D(b,-c,0.f); - const aiVector3D v11 = aiVector3D(-b,-c,0.f); - const aiVector3D v12 = aiVector3D(c, 0.f, b); - const aiVector3D v13 = aiVector3D(c, 0.f, -b); - const aiVector3D v14 = aiVector3D(-c, 0.f, b); - const aiVector3D v15 = aiVector3D(-c, 0.f, -b); - const aiVector3D v16 = aiVector3D(0.f, b, c); - const aiVector3D v17 = aiVector3D(0.f, -b, c); - const aiVector3D v18 = aiVector3D(0.f, b, -c); - const aiVector3D v19 = aiVector3D(0.f, -b, -c); + const aiVector3D v8 = aiVector3D(b,c,0.0); + const aiVector3D v9 = aiVector3D(-b,c,0.0); + const aiVector3D v10 = aiVector3D(b,-c,0.0); + const aiVector3D v11 = aiVector3D(-b,-c,0.0); + const aiVector3D v12 = aiVector3D(c, 0.0, b); + const aiVector3D v13 = aiVector3D(c, 0.0, -b); + const aiVector3D v14 = aiVector3D(-c, 0.0, b); + const aiVector3D v15 = aiVector3D(-c, 0.0, -b); + const aiVector3D v16 = aiVector3D(0.0, b, c); + const aiVector3D v17 = aiVector3D(0.0, -b, c); + const aiVector3D v18 = aiVector3D(0.0, b, -c); + const aiVector3D v19 = aiVector3D(0.0, -b, -c); ADD_PENTAGON(v0, v8, v9, v4, v16); ADD_PENTAGON(v0, v12, v13, v1, v8); @@ -291,12 +291,12 @@ unsigned int StandardShapes::MakeOctahedron(std::vector& positions) { positions.reserve(positions.size()+24); - const aiVector3D v0 = aiVector3D(1.0f, 0.f, 0.f) ; - const aiVector3D v1 = aiVector3D(-1.0f, 0.f, 0.f); - const aiVector3D v2 = aiVector3D(0.f, 1.0f, 0.f); - const aiVector3D v3 = aiVector3D(0.f, -1.0f, 0.f); - const aiVector3D v4 = aiVector3D(0.f, 0.f, 1.0f); - const aiVector3D v5 = aiVector3D(0.f, 0.f, -1.0f); + const aiVector3D v0 = aiVector3D(1.0, 0.0, 0.0) ; + const aiVector3D v1 = aiVector3D(-1.0, 0.0, 0.0); + const aiVector3D v2 = aiVector3D(0.0, 1.0, 0.0); + const aiVector3D v3 = aiVector3D(0.0, -1.0, 0.0); + const aiVector3D v4 = aiVector3D(0.0, 0.0, 1.0); + const aiVector3D v5 = aiVector3D(0.0, 0.0, -1.0); ADD_TRIANGLE(v4,v0,v2); ADD_TRIANGLE(v4,v2,v1); @@ -316,13 +316,13 @@ unsigned int StandardShapes::MakeTetrahedron(std::vector& positions) { positions.reserve(positions.size()+9); - const float a = 1.41421f/3.f; - const float b = 2.4494f/3.f; + const ai_real a = 1.41421/3.0; + const ai_real b = 2.4494/3.0; - const aiVector3D v0 = aiVector3D(0.f,0.f,1.f); - const aiVector3D v1 = aiVector3D(2*a,0,-1.f/3.f); - const aiVector3D v2 = aiVector3D(-a,b,-1.f/3.f); - const aiVector3D v3 = aiVector3D(-a,-b,-1.f/3.f); + const aiVector3D v0 = aiVector3D(0.0,0.0,1.0); + const aiVector3D v1 = aiVector3D(2*a,0,-1.0/3.0); + const aiVector3D v2 = aiVector3D(-a,b,-1.0/3.0); + const aiVector3D v3 = aiVector3D(-a,-b,-1.0/3.0); ADD_TRIANGLE(v0,v1,v2); ADD_TRIANGLE(v0,v2,v3); @@ -337,16 +337,16 @@ unsigned int StandardShapes::MakeHexahedron(std::vector& positions, bool polygons /*= false*/) { positions.reserve(positions.size()+36); - const float length = 1.f/1.73205080f; + const ai_real length = 1.0/1.73205080; - const aiVector3D v0 = aiVector3D(-1.f,-1.f,-1.f)*length; - const aiVector3D v1 = aiVector3D(1.f,-1.f,-1.f)*length; - const aiVector3D v2 = aiVector3D(1.f,1.f,-1.f)*length; - const aiVector3D v3 = aiVector3D(-1.f,1.f,-1.f)*length; - const aiVector3D v4 = aiVector3D(-1.f,-1.f,1.f)*length; - const aiVector3D v5 = aiVector3D(1.f,-1.f,1.f)*length; - const aiVector3D v6 = aiVector3D(1.f,1.f,1.f)*length; - const aiVector3D v7 = aiVector3D(-1.f,1.f,1.f)*length; + const aiVector3D v0 = aiVector3D(-1.0,-1.0,-1.0)*length; + const aiVector3D v1 = aiVector3D(1.0,-1.0,-1.0)*length; + const aiVector3D v2 = aiVector3D(1.0,1.0,-1.0)*length; + const aiVector3D v3 = aiVector3D(-1.0,1.0,-1.0)*length; + const aiVector3D v4 = aiVector3D(-1.0,-1.0,1.0)*length; + const aiVector3D v5 = aiVector3D(1.0,-1.0,1.0)*length; + const aiVector3D v6 = aiVector3D(1.0,1.0,1.0)*length; + const aiVector3D v7 = aiVector3D(-1.0,1.0,1.0)*length; ADD_QUAD(v0,v3,v2,v1); ADD_QUAD(v0,v1,v5,v4); @@ -382,8 +382,8 @@ void StandardShapes::MakeSphere(unsigned int tess, // ------------------------------------------------------------------------------------------------ // Build a cone -void StandardShapes::MakeCone(float height,float radius1, - float radius2,unsigned int tess, +void StandardShapes::MakeCone(ai_real height,ai_real radius1, + ai_real radius2,unsigned int tess, std::vector& positions,bool bOpen /*= false */) { // Sorry, a cone with less than 3 segments makes ABSOLUTELY NO SENSE @@ -396,7 +396,7 @@ void StandardShapes::MakeCone(float height,float radius1, radius1 = std::fabs(radius1); radius2 = std::fabs(radius2); - float halfHeight = height / 2; + ai_real halfHeight = height / 2.0; // radius1 is always the smaller one if (radius2 > radius1) @@ -407,7 +407,7 @@ void StandardShapes::MakeCone(float height,float radius1, else old = SIZE_MAX; // Use a large epsilon to check whether the cone is pointy - if (radius1 < (radius2-radius1)*10e-3f)radius1 = 0.f; + if (radius1 < (radius2-radius1)*10e-3)radius1 = 0.0; // We will need 3*2 verts per segment + 3*2 verts per segment // if the cone is closed @@ -415,20 +415,20 @@ void StandardShapes::MakeCone(float height,float radius1, positions.reserve(positions.size () + mem); // Now construct all segments - const float angle_delta = (float)AI_MATH_TWO_PI / tess; - const float angle_max = (float)AI_MATH_TWO_PI; + const ai_real angle_delta = (ai_real)AI_MATH_TWO_PI / tess; + const ai_real angle_max = (ai_real)AI_MATH_TWO_PI; - float s = 1.f; // std::cos(angle == 0); - float t = 0.f; // std::sin(angle == 0); + ai_real s = 1.0; // std::cos(angle == 0); + ai_real t = 0.0; // std::sin(angle == 0); - for (float angle = 0.f; angle < angle_max; ) + for (ai_real angle = 0.0; angle < angle_max; ) { const aiVector3D v1 = aiVector3D (s * radius1, -halfHeight, t * radius1 ); const aiVector3D v2 = aiVector3D (s * radius2, halfHeight, t * radius2 ); - const float next = angle + angle_delta; - float s2 = std::cos(next); - float t2 = std::sin(next); + const ai_real next = angle + angle_delta; + ai_real s2 = std::cos(next); + ai_real t2 = std::sin(next); const aiVector3D v3 = aiVector3D (s2 * radius2, halfHeight, t2 * radius2 ); const aiVector3D v4 = aiVector3D (s2 * radius1, -halfHeight, t2 * radius1 ); @@ -445,7 +445,7 @@ void StandardShapes::MakeCone(float height,float radius1, // generate the end 'cap' positions.push_back(aiVector3D(s * radius2, halfHeight, t * radius2 )); positions.push_back(aiVector3D(s2 * radius2, halfHeight, t2 * radius2 )); - positions.push_back(aiVector3D(0.f, halfHeight, 0.f)); + positions.push_back(aiVector3D(0.0, halfHeight, 0.0)); if (radius1) @@ -453,7 +453,7 @@ void StandardShapes::MakeCone(float height,float radius1, // generate the other end 'cap' positions.push_back(aiVector3D(s * radius1, -halfHeight, t * radius1 )); positions.push_back(aiVector3D(s2 * radius1, -halfHeight, t2 * radius1 )); - positions.push_back(aiVector3D(0.f, -halfHeight, 0.f)); + positions.push_back(aiVector3D(0.0, -halfHeight, 0.0)); } } @@ -472,7 +472,7 @@ void StandardShapes::MakeCone(float height,float radius1, // ------------------------------------------------------------------------------------------------ // Build a circle -void StandardShapes::MakeCircle(float radius, unsigned int tess, +void StandardShapes::MakeCircle(ai_real radius, unsigned int tess, std::vector& positions) { // Sorry, a circle with less than 3 segments makes ABSOLUTELY NO SENSE @@ -484,21 +484,21 @@ void StandardShapes::MakeCircle(float radius, unsigned int tess, // We will need 3 vertices per segment positions.reserve(positions.size()+tess*3); - const float angle_delta = (float)AI_MATH_TWO_PI / tess; - const float angle_max = (float)AI_MATH_TWO_PI; + const ai_real angle_delta = (ai_real)AI_MATH_TWO_PI / tess; + const ai_real angle_max = (ai_real)AI_MATH_TWO_PI; - float s = 1.f; // std::cos(angle == 0); - float t = 0.f; // std::sin(angle == 0); + ai_real s = 1.0; // std::cos(angle == 0); + ai_real t = 0.0; // std::sin(angle == 0); - for (float angle = 0.f; angle < angle_max; ) + for (ai_real angle = 0.0; angle < angle_max; ) { - positions.push_back(aiVector3D(s * radius,0.f,t * radius)); + positions.push_back(aiVector3D(s * radius,0.0,t * radius)); angle += angle_delta; s = std::cos(angle); t = std::sin(angle); - positions.push_back(aiVector3D(s * radius,0.f,t * radius)); + positions.push_back(aiVector3D(s * radius,0.0,t * radius)); - positions.push_back(aiVector3D(0.f,0.f,0.f)); + positions.push_back(aiVector3D(0.0,0.0,0.0)); } } diff --git a/code/StandardShapes.h b/code/StandardShapes.h index ec53ca30d..faa250a2e 100644 --- a/code/StandardShapes.h +++ b/code/StandardShapes.h @@ -174,8 +174,8 @@ public: * no 'end caps' * @param positions Receives output triangles */ - static void MakeCone(float height,float radius1, - float radius2,unsigned int tess, + static void MakeCone(ai_real height,ai_real radius1, + ai_real radius2,unsigned int tess, std::vector& positions,bool bOpen= false); @@ -189,7 +189,7 @@ public: * @param tess Number of segments. * @param positions Receives output triangles. */ - static void MakeCircle(float radius, unsigned int tess, + static void MakeCircle(ai_real radius, unsigned int tess, std::vector& positions); }; diff --git a/code/TargetAnimation.cpp b/code/TargetAnimation.cpp index a78f66bea..97b15edbb 100644 --- a/code/TargetAnimation.cpp +++ b/code/TargetAnimation.cpp @@ -83,7 +83,7 @@ KeyIterator::KeyIterator(const std::vector* _objPos, // ------------------------------------------------------------------------------------------------ template -inline T Interpolate(const T& one, const T& two, float val) +inline T Interpolate(const T& one, const T& two, ai_real val) { return one + (two-one)*val; } @@ -134,7 +134,7 @@ void KeyIterator::operator ++() const aiVectorKey& last = targetObjPos->at(nextTargetObjPos); const aiVectorKey& first = targetObjPos->at(nextTargetObjPos-1); - curTargetPosition = Interpolate(first.mValue, last.mValue, (float) ( + curTargetPosition = Interpolate(first.mValue, last.mValue, (ai_real) ( (curTime-first.mTime) / (last.mTime-first.mTime) )); } @@ -155,7 +155,7 @@ void KeyIterator::operator ++() const aiVectorKey& last = objPos->at(nextObjPos); const aiVectorKey& first = objPos->at(nextObjPos-1); - curPosition = Interpolate(first.mValue, last.mValue, (float) ( + curPosition = Interpolate(first.mValue, last.mValue, (ai_real) ( (curTime-first.mTime) / (last.mTime-first.mTime))); } @@ -220,7 +220,7 @@ void TargetAnimationHelper::Process(std::vector* distanceTrack) // diff vector aiVector3D diff = tposition - position; - float f = diff.Length(); + ai_real f = diff.Length(); // output distance vector if (f) diff --git a/code/Vertex.h b/code/Vertex.h index 5e2cf6986..88840eab7 100644 --- a/code/Vertex.h +++ b/code/Vertex.h @@ -94,15 +94,15 @@ class Vertex friend Vertex operator + (const Vertex&,const Vertex&); friend Vertex operator - (const Vertex&,const Vertex&); -// friend Vertex operator + (const Vertex&,float); -// friend Vertex operator - (const Vertex&,float); - friend Vertex operator * (const Vertex&,float); - friend Vertex operator / (const Vertex&,float); +// friend Vertex operator + (const Vertex&,ai_real); +// friend Vertex operator - (const Vertex&,ai_real); + friend Vertex operator * (const Vertex&,ai_real); + friend Vertex operator / (const Vertex&,ai_real); -// friend Vertex operator + (float, const Vertex&); -// friend Vertex operator - (float, const Vertex&); - friend Vertex operator * (float, const Vertex&); -// friend Vertex operator / (float, const Vertex&); +// friend Vertex operator + (ai_real, const Vertex&); +// friend Vertex operator - (ai_real, const Vertex&); + friend Vertex operator * (ai_real, const Vertex&); +// friend Vertex operator / (ai_real, const Vertex&); public: @@ -146,22 +146,22 @@ public: /* - Vertex& operator += (float v) { + Vertex& operator += (ai_real v) { *this = *this+v; return *this; } - Vertex& operator -= (float v) { + Vertex& operator -= (ai_real v) { *this = *this-v; return *this; } */ - Vertex& operator *= (float v) { + Vertex& operator *= (ai_real v) { *this = *this*v; return *this; } - Vertex& operator /= (float v) { + Vertex& operator /= (ai_real v) { *this = *this/v; return *this; } @@ -217,40 +217,40 @@ private: // ---------------------------------------------------------------------------- /** This time binary arithmetics of v0 with a floating-point number */ - template