diff --git a/code/3DSHelper.h b/code/3DSHelper.h index b1de4ee77..7a2ad3f8a 100644 --- a/code/3DSHelper.h +++ b/code/3DSHelper.h @@ -369,14 +369,13 @@ struct Material { //! Default constructor. Builds a default name for the material Material() - : - 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.0), - mBumpHeight (1.0), - mTwoSided (false) + : mDiffuse ( ai_real( 0.6 ), ai_real( 0.6 ), ai_real( 0.6 ) ) // FIX ... we won't want object to be black + , mSpecularExponent ( ai_real( 0.0 ) ) + , mShininessStrength ( ai_real( 1.0 ) ) + , mShading(Discreet3DS::Gouraud) + , mTransparency ( ai_real( 1.0 ) ) + , mBumpHeight ( ai_real( 1.0 ) ) + , mTwoSided (false) { static int iCnt = 0; diff --git a/code/3DSLoader.cpp b/code/3DSLoader.cpp index bae3cb1e6..0a1fe776b 100644 --- a/code/3DSLoader.cpp +++ b/code/3DSLoader.cpp @@ -1166,14 +1166,15 @@ void Discreet3DSImporter::ParseMaterialChunk() case Discreet3DS::CHUNK_MAT_TRANSPARENCY: { - // This is the material's transparency - ai_real* pcf = &mScene->mMaterials.back().mTransparency; - *pcf = ParsePercentageChunk(); + // This is the material's transparency + ai_real* pcf = &mScene->mMaterials.back().mTransparency; + *pcf = ParsePercentageChunk(); - // NOTE: transparency, not opacity - if (is_qnan(*pcf)) - *pcf = 1.0; - else *pcf = 1.0 - *pcf * (ai_real)0xFFFF / 100.0; + // NOTE: transparency, not opacity + if (is_qnan(*pcf)) + *pcf = ai_real( 1.0 ); + else + *pcf = ai_real( 1.0 ) - *pcf * (ai_real)0xFFFF / ai_real( 100.0 ); } break; @@ -1199,21 +1200,23 @@ void Discreet3DSImporter::ParseMaterialChunk() case Discreet3DS::CHUNK_MAT_SHININESS_PERCENT: { // This is the shininess strength of the material - ai_real* pcf = &mScene->mMaterials.back().mShininessStrength; - *pcf = ParsePercentageChunk(); - if (is_qnan(*pcf)) - *pcf = 0.0; - else *pcf *= (ai_real)0xffff / 100.0; + ai_real* pcf = &mScene->mMaterials.back().mShininessStrength; + *pcf = ParsePercentageChunk(); + if (is_qnan(*pcf)) + *pcf = ai_real( 0.0 ); + else + *pcf *= (ai_real)0xffff / ai_real( 100.0 ); } break; case Discreet3DS::CHUNK_MAT_SELF_ILPCT: { // This is the self illumination strength of the material - ai_real f = ParsePercentageChunk(); - if (is_qnan(f)) - f = 0.0; - else f *= (ai_real)0xFFFF / 100.0; - mScene->mMaterials.back().mEmissive = aiColor3D(f,f,f); + ai_real f = ParsePercentageChunk(); + if (is_qnan(f)) + f = ai_real( 0.0 ); + else + f *= (ai_real)0xFFFF / ai_real( 100.0 ); + mScene->mMaterials.back().mEmissive = aiColor3D(f,f,f); } break; @@ -1272,7 +1275,7 @@ void Discreet3DSImporter::ParseTextureChunk(D3DS::Texture* pcOut) case Discreet3DS::CHUNK_PERCENTD: // Manually parse the blend factor - pcOut->mTextureBlend = stream->GetF8(); + pcOut->mTextureBlend = ai_real( stream->GetF8() ); break; case Discreet3DS::CHUNK_PERCENTF: @@ -1282,7 +1285,7 @@ void Discreet3DSImporter::ParseTextureChunk(D3DS::Texture* pcOut) case Discreet3DS::CHUNK_PERCENTW: // Manually parse the blend factor - pcOut->mTextureBlend = (ai_real)((uint16_t)stream->GetI2()) / 100.0; + pcOut->mTextureBlend = (ai_real)((uint16_t)stream->GetI2()) / ai_real( 100.0 ); break; case Discreet3DS::CHUNK_MAT_MAP_USCALE: @@ -1355,8 +1358,7 @@ ai_real Discreet3DSImporter::ParsePercentageChunk() // ------------------------------------------------------------------------------------------------ // Read a color chunk. If a percentage chunk is found instead it is read as a grayscale color -void Discreet3DSImporter::ParseColorChunk(aiColor3D* out, - bool acceptPercent) +void Discreet3DSImporter::ParseColorChunk( aiColor3D* out, bool acceptPercent ) { ai_assert(out != NULL); @@ -1389,13 +1391,16 @@ void Discreet3DSImporter::ParseColorChunk(aiColor3D* out, case Discreet3DS::CHUNK_LINRGBB: bGamma = true; case Discreet3DS::CHUNK_RGBB: - if (sizeof(char) * 3 > diff) { - *out = clrError; - return; + { + if ( sizeof( char ) * 3 > diff ) { + *out = clrError; + return; + } + const ai_real invVal = ai_real( 1.0 ) / ai_real( 255.0 ); + out->r = ( ai_real ) ( uint8_t ) stream->GetI1() * invVal; + out->g = ( ai_real ) ( uint8_t ) stream->GetI1() * invVal; + out->b = ( ai_real ) ( uint8_t ) stream->GetI1() * invVal; } - 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. @@ -1409,7 +1414,7 @@ void Discreet3DSImporter::ParseColorChunk(aiColor3D* out, case Discreet3DS::CHUNK_PERCENTW: if (acceptPercent && 1 <= diff) { - out->g = out->b = out->r = (ai_real)(uint8_t)stream->GetI1() / 255.0; + out->g = out->b = out->r = (ai_real)(uint8_t)stream->GetI1() / ai_real( 255.0 ); break; } *out = clrError; diff --git a/code/AMFImporter_Postprocess.cpp b/code/AMFImporter_Postprocess.cpp index 69aad1a66..41b16035e 100644 --- a/code/AMFImporter_Postprocess.cpp +++ b/code/AMFImporter_Postprocess.cpp @@ -227,7 +227,7 @@ std::string TextureConverted_ID; // check that all textures has same size if(src_texture_4check.size() > 1) { - for(uint8_t i = 0, i_e = (src_texture_4check.size() - 1); i < i_e; i++) + for (size_t i = 0, i_e = (src_texture_4check.size() - 1); i < i_e; i++) { if((src_texture_4check[i]->Width != src_texture_4check[i + 1]->Width) || (src_texture_4check[i]->Height != src_texture_4check[i + 1]->Height) || (src_texture_4check[i]->Depth != src_texture_4check[i + 1]->Depth)) diff --git a/code/ASEParser.cpp b/code/ASEParser.cpp index d34da2578..3b3b696e5 100644 --- a/code/ASEParser.cpp +++ b/code/ASEParser.cpp @@ -618,7 +618,8 @@ void Parser::ParseLV2MaterialBlock(ASE::Material& mat) if (TokenMatch(filePtr,"MATERIAL_TRANSPARENCY",21)) { ParseLV4MeshFloat(mat.mTransparency); - mat.mTransparency = 1.0 - mat.mTransparency;continue; + mat.mTransparency = ai_real( 1.0 ) - mat.mTransparency; + continue; } // material self illumination if (TokenMatch(filePtr,"MATERIAL_SELFILLUM",18)) diff --git a/code/ColladaExporter.cpp b/code/ColladaExporter.cpp index eb94b4e9c..fdb31903f 100644 --- a/code/ColladaExporter.cpp +++ b/code/ColladaExporter.cpp @@ -150,7 +150,7 @@ void ColladaExporter::WriteFile() // Writes the asset header void ColladaExporter::WriteHeader() { - static const ai_real epsilon = 0.00001; + static const ai_real epsilon = ai_real( 0.00001 ); static const aiQuaternion x_rot(aiMatrix3x3( 0, -1, 0, 1, 0, 0, diff --git a/code/ColladaLoader.cpp b/code/ColladaLoader.cpp index 681f9965a..81a43754e 100644 --- a/code/ColladaLoader.cpp +++ b/code/ColladaLoader.cpp @@ -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 - ai_real startTime = 1e20, endTime = -1e20; + ai_real startTime = ai_real( 1e20 ), endTime = ai_real( -1e20 ); for( std::vector::iterator it = entries.begin(); it != entries.end(); ++it) { Collada::ChannelEntry& e = *it; @@ -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 - ai_real nextTime = 1e20; + ai_real nextTime = ai_real( 1e20 ); for( std::vector::iterator it = entries.begin(); it != entries.end(); ++it) { Collada::ChannelEntry& channelElement = *it; diff --git a/code/ColladaParser.cpp b/code/ColladaParser.cpp index aaccfad40..1fd762e40 100644 --- a/code/ColladaParser.cpp +++ b/code/ColladaParser.cpp @@ -3075,7 +3075,7 @@ aiMatrix4x4 ColladaParser::CalculateResultTransform( const std::vectormNumFaces;++fidx) { diff --git a/code/GenVertexNormalsProcess.cpp b/code/GenVertexNormalsProcess.cpp index 14b7962c0..c205ac5ac 100644 --- a/code/GenVertexNormalsProcess.cpp +++ b/code/GenVertexNormalsProcess.cpp @@ -154,7 +154,7 @@ bool GenVertexNormalsProcess::GenMeshVertexNormals (aiMesh* pMesh, unsigned int // check whether we can reuse the SpatialSort of a previous step. SpatialSort* vertexFinder = NULL; SpatialSort _vertexFinder; - ai_real posEpsilon = 1e-5; + ai_real posEpsilon = ai_real( 1e-5 ); if (shared) { std::vector >* avf; shared->GetProperty(AI_SPP_SPATIAL_SORT,avf); diff --git a/code/IRRLoader.cpp b/code/IRRLoader.cpp index a1cfaf28b..6e2a9a5b5 100644 --- a/code/IRRLoader.cpp +++ b/code/IRRLoader.cpp @@ -542,7 +542,7 @@ void IRRImporter::ComputeAnimations(Node* root, aiNode* real, std::vectormPositionKeys[i]; - const ai_real dt = (i * in.speed * 0.001 ); + const ai_real dt = (i * in.speed * ai_real( 0.001 ) ); const ai_real u = dt - std::floor(dt); const int idx = (int)std::floor(dt) % size; @@ -556,9 +556,9 @@ void IRRImporter::ComputeAnimations(Node* root, aiNode* real, std::vectorAddProperty(&clr,1,AI_MATKEY_COLOR_EMISSIVE); // opacity ... either additive or default-blended, please diff --git a/code/MD3FileData.h b/code/MD3FileData.h index a8869264a..3a59d0d1d 100644 --- a/code/MD3FileData.h +++ b/code/MD3FileData.h @@ -261,13 +261,13 @@ inline void LatLngNormalToVec3(uint16_t p_iNormal, ai_real* p_afOut) { 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; + const ai_real invVal( ai_real( 1.0 ) / ai_real( 128.0 ) ); + lat *= ai_real( 3.141926 ) * invVal; + lng *= ai_real( 3.141926 ) * invVal; - p_afOut[0] = std::cos(lat) * std::sin(lng); - p_afOut[1] = std::sin(lat) * std::sin(lng); - p_afOut[2] = std::cos(lng); - return; + p_afOut[ 0 ] = std::cos(lat) * std::sin(lng); + p_afOut[ 1 ] = std::sin(lat) * std::sin(lng); + p_afOut[ 2 ] = std::cos(lng); } diff --git a/code/MDCLoader.cpp b/code/MDCLoader.cpp index 50a3d9422..d97215864 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.0-pcUVs[quak].v; // DX to OGL + pcUVCur->y = ai_real( 1.0 )-pcUVs[quak].v; // DX to OGL } pcVertCur->x += pcFrame->localOrigin[0] ; pcVertCur->y += pcFrame->localOrigin[1] ; diff --git a/code/OFFLoader.cpp b/code/OFFLoader.cpp index 3139bc238..cb2226bf6 100644 --- a/code/OFFLoader.cpp +++ b/code/OFFLoader.cpp @@ -242,7 +242,7 @@ void OFFImporter::InternReadFile( const std::string& pFile, pScene->mMaterials = new aiMaterial*[pScene->mNumMaterials]; aiMaterial* pcMat = new aiMaterial(); - aiColor4D clr(0.6,0.6,0.6,1.0); + aiColor4D clr( ai_real( 0.6 ), ai_real( 0.6 ), ai_real( 0.6 ), ai_real( 1.0 ) ); pcMat->AddProperty(&clr,1,AI_MATKEY_COLOR_DIFFUSE); pScene->mMaterials[0] = pcMat; diff --git a/code/ObjFileData.h b/code/ObjFileData.h index 4fc262760..23b50ef2d 100644 --- a/code/ObjFileData.h +++ b/code/ObjFileData.h @@ -201,11 +201,11 @@ struct Material //! Constructor Material() - : diffuse (0.6,0.6,0.6) - , alpha (1.0) - , shineness (0.0) + : diffuse ( ai_real( 0.6 ), ai_real( 0.6 ), ai_real( 0.6 ) ) + , alpha (ai_real( 1.0 ) ) + , shineness ( ai_real( 0.0) ) , illumination_model (1) - , ior (1.0) + , ior ( ai_real( 1.0 ) ) { // empty for (size_t i = 0; i < TextureTypeCount; ++i) diff --git a/code/OgreMaterial.cpp b/code/OgreMaterial.cpp index f9da9d584..a221ab274 100644 --- a/code/OgreMaterial.cpp +++ b/code/OgreMaterial.cpp @@ -93,7 +93,7 @@ void OgreImporter::ReadMaterials(const std::string &pFile, Assimp::IOSystem *pIO // Create materials that can be found and parsed via the IOSystem. for (size_t i=0, len=mesh->NumSubMeshes(); iGetSubMesh(i); + SubMeshXml *submesh = mesh->GetSubMesh( static_cast(i)); if (submesh && !submesh->materialRef.empty()) { aiMaterial *material = ReadMaterial(pFile, pIOHandler, submesh->materialRef); diff --git a/code/PretransformVertices.cpp b/code/PretransformVertices.cpp index 48a3e6f61..90a58e321 100644 --- a/code/PretransformVertices.cpp +++ b/code/PretransformVertices.cpp @@ -690,7 +690,7 @@ void PretransformVertices::Execute( aiScene* pScene) // find the dominant axis aiVector3D d = max-min; - const ai_real div = std::max(d.x,std::max(d.y,d.z))*0.5; + const ai_real div = std::max(d.x,std::max(d.y,d.z))*ai_real( 0.5); d = min + d * (ai_real)0.5; for (unsigned int a = 0; a < pScene->mNumMeshes; ++a) { diff --git a/code/ProcessHelper.cpp b/code/ProcessHelper.cpp index c77049061..4bfbbd5a3 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 (10e10, 10e10, 10e10); - max = aiVector3D (-10e10,-10e10,-10e10); + min = aiVector3D ( ai_real( 10e10 ), ai_real( 10e10 ), ai_real( 10e10 ) ); + max = aiVector3D ( ai_real( -10e10 ), ai_real( -10e10 ), ai_real( -10e10 ) ); for (unsigned int i = 0;i < mesh->mNumVertices;++i) { const aiVector3D v = m * mesh->mVertices[i]; @@ -144,7 +144,7 @@ void FindMeshCenterTransformed (aiMesh* mesh, aiVector3D& out, // ------------------------------------------------------------------------------- ai_real ComputePositionEpsilon(const aiMesh* pMesh) { - const ai_real epsilon = 1e-4; + const ai_real epsilon = ai_real( 1e-4 ); // calculate the position bounds so we have a reliable epsilon to check position differences against aiVector3D minVec, maxVec; @@ -157,7 +157,7 @@ ai_real ComputePositionEpsilon(const aiMesh* const* pMeshes, size_t num) { ai_assert( NULL != pMeshes ); - const ai_real epsilon = 1e-4; + const ai_real epsilon = ai_real( 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/SIBImporter.cpp b/code/SIBImporter.cpp index 75a7ccf8e..05afb5198 100644 --- a/code/SIBImporter.cpp +++ b/code/SIBImporter.cpp @@ -709,7 +709,7 @@ static void ReadLightInfo(aiLight* light, StreamReaderLE* stream) // 99% and 1% percentiles. // OpenGL: I = cos(angle)^E // Solving: angle = acos(I^(1/E)) - ai_real E = 1.0 / std::max(spotExponent, (ai_real)0.00001); + ai_real E = ai_real( 1.0 ) / std::max(spotExponent, (ai_real)0.00001); ai_real inner = std::acos(std::pow((ai_real)0.99, E)); ai_real outer = std::acos(std::pow((ai_real)0.01, E)); diff --git a/code/STLLoader.cpp b/code/STLLoader.cpp index 647bd8a96..c2cffdb03 100644 --- a/code/STLLoader.cpp +++ b/code/STLLoader.cpp @@ -168,8 +168,7 @@ void addFacesToMesh(aiMesh* pMesh) // ------------------------------------------------------------------------------------------------ // Imports the given file into the given scene structure. -void STLImporter::InternReadFile( const std::string& pFile, - aiScene* pScene, IOSystem* pIOHandler) +void STLImporter::InternReadFile( const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler ) { std::unique_ptr file( pIOHandler->Open( pFile, "rb")); @@ -189,7 +188,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.6; + clrColorDefault.r = clrColorDefault.g = clrColorDefault.b = clrColorDefault.a = (ai_real) 0.6; // allocate a single node pScene->mRootNode = new aiNode(); @@ -217,13 +216,13 @@ void STLImporter::InternReadFile( const std::string& pFile, s.Set(AI_DEFAULT_MATERIAL_NAME); pcMat->AddProperty(&s, AI_MATKEY_NAME); - aiColor4D clrDiffuse(0.6,0.6,0.6,1.0); + aiColor4D clrDiffuse(ai_real(0.6),ai_real(0.6),ai_real(0.6),ai_real(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.05,0.05,0.05,1.0); + clrDiffuse = aiColor4D( ai_real( 0.05), ai_real( 0.05), ai_real( 0.05), ai_real( 1.0)); pcMat->AddProperty(&clrDiffuse,1,AI_MATKEY_COLOR_AMBIENT); pScene->mNumMaterials = 1; @@ -416,10 +415,11 @@ 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.0; - clrColorDefault.g = (*sz2++) / 255.0; - clrColorDefault.b = (*sz2++) / 255.0; - clrColorDefault.a = (*sz2++) / 255.0; + const ai_real invByte = (ai_real)1.0 / ( ai_real )255.0; + clrColorDefault.r = (*sz2++) * invByte; + clrColorDefault.g = (*sz2++) * invByte; + clrColorDefault.b = (*sz2++) * invByte; + clrColorDefault.a = (*sz2++) * invByte; break; } } @@ -481,17 +481,18 @@ bool STLImporter::LoadBinaryFile() } aiColor4D* clr = &pMesh->mColors[0][i*3]; clr->a = 1.0; + const ai_real invVal( (ai_real)1.0 / ( ai_real )31.0 ); if (bIsMaterialise) // this is reversed { - clr->r = (color & 0x31u) / 31.0; - clr->g = ((color & (0x31u<<5))>>5u) / 31.0; - clr->b = ((color & (0x31u<<10))>>10u) / 31.0; + clr->r = (color & 0x31u) *invVal; + clr->g = ((color & (0x31u<<5))>>5u) *invVal; + clr->b = ((color & (0x31u<<10))>>10u) *invVal; } else { - clr->b = (color & 0x31u) / 31.0; - clr->g = ((color & (0x31u<<5))>>5u) / 31.0; - clr->r = ((color & (0x31u<<10))>>10u) / 31.0; + clr->b = (color & 0x31u) *invVal; + clr->g = ((color & (0x31u<<5))>>5u) *invVal; + clr->r = ((color & (0x31u<<10))>>10u) *invVal; } // assign the color to all vertices of the face *(clr+1) = *clr; diff --git a/code/SkeletonMeshBuilder.cpp b/code/SkeletonMeshBuilder.cpp index c564cbc95..d929ac361 100644 --- a/code/SkeletonMeshBuilder.cpp +++ b/code/SkeletonMeshBuilder.cpp @@ -132,7 +132,7 @@ 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); - ai_real sizeEstimate = ownpos.Length() * 0.18; + ai_real sizeEstimate = ownpos.Length() * ai_real( 0.18 ); mVertices.push_back( aiVector3D( -sizeEstimate, 0.0, 0.0)); mVertices.push_back( aiVector3D( 0.0, sizeEstimate, 0.0)); diff --git a/code/StandardShapes.cpp b/code/StandardShapes.cpp index 8b0b32336..eed8ddabc 100644 --- a/code/StandardShapes.cpp +++ b/code/StandardShapes.cpp @@ -193,8 +193,8 @@ unsigned int StandardShapes::MakeIcosahedron(std::vector& positions) { positions.reserve(positions.size()+60); - const ai_real t = (1.0 + 2.236067977)/2.0; - const ai_real s = std::sqrt(1.0 + t*t); + const ai_real t = ( ai_real( 1.0 )+ ai_real( 2.236067977 ) ) / ai_real( 2.0 ); + const ai_real s = std::sqrt(ai_real(1.0) + t*t); const aiVector3D v0 = aiVector3D(t,1.0, 0.0)/s; const aiVector3D v1 = aiVector3D(-t,1.0, 0.0)/s; @@ -243,9 +243,9 @@ unsigned int StandardShapes::MakeDodecahedron(std::vector& positions { positions.reserve(positions.size()+108); - 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 ai_real a = ai_real( 1.0 ) / ai_real(1.7320508); + const ai_real b = std::sqrt(( ai_real( 3.0 )- ai_real( 2.23606797))/ ai_real( 6.0) ); + const ai_real c = std::sqrt(( ai_real( 3.0 )+ ai_real( 2.23606797f))/ ai_real( 6.0) ); const aiVector3D v0 = aiVector3D(a,a,a); const aiVector3D v1 = aiVector3D(a,a,-a); @@ -315,13 +315,14 @@ unsigned int StandardShapes::MakeTetrahedron(std::vector& positions) { positions.reserve(positions.size()+9); - const ai_real a = 1.41421/3.0; - const ai_real b = 2.4494/3.0; + const ai_real invThree = ai_real( 1.0 ) / ai_real( 3.0 ); + const ai_real a = ai_real( 1.41421 ) * invThree; + const ai_real b = ai_real( 2.4494 ) * invThree; 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); + const aiVector3D v1 = aiVector3D(2*a,0,-invThree ); + const aiVector3D v2 = aiVector3D(-a,b,-invThree ); + const aiVector3D v3 = aiVector3D(-a,-b,-invThree ); ADD_TRIANGLE(v0,v1,v2); ADD_TRIANGLE(v0,v2,v3); @@ -336,7 +337,7 @@ unsigned int StandardShapes::MakeHexahedron(std::vector& positions, bool polygons /*= false*/) { positions.reserve(positions.size()+36); - const ai_real length = 1.0/1.73205080; + const ai_real length = ai_real(1.0)/ai_real(1.73205080); const aiVector3D v0 = aiVector3D(-1.0,-1.0,-1.0)*length; const aiVector3D v1 = aiVector3D(1.0,-1.0,-1.0)*length; @@ -395,7 +396,7 @@ void StandardShapes::MakeCone(ai_real height,ai_real radius1, radius1 = std::fabs(radius1); radius2 = std::fabs(radius2); - ai_real halfHeight = height / 2.0; + ai_real halfHeight = height / ai_real(2.0); // radius1 is always the smaller one if (radius2 > radius1) diff --git a/contrib/Open3DGC/o3dgcCommon.h b/contrib/Open3DGC/o3dgcCommon.h index a9be4d885..13af4153d 100644 --- a/contrib/Open3DGC/o3dgcCommon.h +++ b/contrib/Open3DGC/o3dgcCommon.h @@ -376,7 +376,7 @@ namespace o3dgc if (quantMode == O3DGC_SC3DMC_DIAG_BB) { - Real diag = 0.0; + Real diag = Real( 0.0 ); Real r; for(unsigned long d = 0; d < dim; ++d) {