Merge branch 'master' into coverity_scan

pull/1007/head
Kim Kulling 2016-07-16 11:38:27 +02:00
commit e3dcbcc766
91 changed files with 970 additions and 807 deletions

1
.gitignore vendored
View File

@ -18,6 +18,7 @@ assimp.pc
revision.h
contrib/zlib/zconf.h
contrib/zlib/zlib.pc
include/assimp/config.h
# CMake
CMakeCache.txt

View File

@ -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)
@ -136,11 +151,11 @@ IF ( CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR )
ENDIF ( CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR )
# Cache these to allow the user to override them manually.
SET( ASSIMP_LIB_INSTALL_DIR "lib" CACHE PATH
SET( ASSIMP_LIB_INSTALL_DIR "lib" CACHE STRING
"Path the built library files are installed to." )
SET( ASSIMP_INCLUDE_INSTALL_DIR "include" CACHE PATH
SET( ASSIMP_INCLUDE_INSTALL_DIR "include" CACHE STRING
"Path the header files are installed to." )
SET( ASSIMP_BIN_INSTALL_DIR "bin" CACHE PATH
SET( ASSIMP_BIN_INSTALL_DIR "bin" CACHE STRING
"Path the tool executables are installed to." )
IF (CMAKE_BUILD_TYPE STREQUAL "Debug")

View File

@ -1,5 +1,5 @@
prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=@CMAKE_INSTALL_PREFIX@/@ASSIMP_BIN_INSTALL_DIR@
exec_prefix=@CMAKE_INSTALL_PREFIX@/
libdir=@CMAKE_INSTALL_PREFIX@/@ASSIMP_LIB_INSTALL_DIR@
includedir=@CMAKE_INSTALL_PREFIX@/@ASSIMP_INCLUDE_INSTALL_DIR@/assimp

View File

@ -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<float>( &texture.mTextureBlend, 1, AI_MATKEY_TEXBLEND(type,0));
mat.AddProperty<ai_real>( &texture.mTextureBlend, 1, AI_MATKEY_TEXBLEND(type,0));
// Setup the texture mapping mode
mat.AddProperty<int>((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<float>(&texture.mOffsetU,5,AI_MATKEY_UVTRANSFORM(type,0));
mat.AddProperty<ai_real>(&texture.mOffsetU,5,AI_MATKEY_UVTRANSFORM(type,0));
}
// ------------------------------------------------------------------------------------------------
@ -265,10 +265,10 @@ void Discreet3DSImporter::ConvertMaterial(D3DS::Material& oldMat,
}
// Opacity
mat.AddProperty<float>( &oldMat.mTransparency,1,AI_MATKEY_OPACITY);
mat.AddProperty<ai_real>( &oldMat.mTransparency,1,AI_MATKEY_OPACITY);
// Bump height scaling
mat.AddProperty<float>( &oldMat.mBumpHeight,1,AI_MATKEY_BUMPSCALING);
mat.AddProperty<ai_real>( &oldMat.mBumpHeight,1,AI_MATKEY_BUMPSCALING);
// Two sided rendering?
if (oldMat.mTwoSided)

View File

@ -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<D3DS::Face>
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

View File

@ -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;

View File

@ -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;

View File

@ -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<float>( &texture.mTextureBlend, 1, AI_MATKEY_TEXBLEND(type,0));
mat.AddProperty<ai_real>( &texture.mTextureBlend, 1, AI_MATKEY_TEXBLEND(type,0));
// Setup texture UV transformations
mat.AddProperty<float>(&texture.mOffsetU,5,AI_MATKEY_UVTRANSFORM(type,0));
mat.AddProperty<ai_real>(&texture.mOffsetU,5,AI_MATKEY_UVTRANSFORM(type,0));
}
// ------------------------------------------------------------------------------------------------
@ -865,7 +865,7 @@ void ASEImporter::ConvertMaterial(ASE::Material& mat)
}
// opacity
mat.pcInstance->AddProperty<float>( &mat.mTransparency,1,AI_MATKEY_OPACITY);
mat.pcInstance->AddProperty<ai_real>( &mat.mTransparency,1,AI_MATKEY_OPACITY);
// Two sided rendering?
if (mat.mTwoSided)

View File

@ -431,7 +431,7 @@ void Parser::ParseLV1SoftSkinBlock()
ParseString(bone,"*MESH_SOFTSKINVERTS.Bone");
// Find the bone in the mesh's list
std::pair<int,float> me;
std::pair<int,ai_real> 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<int,float> 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<float>(filePtr,fOut);
filePtr = fast_atoreal_move<ai_real>(filePtr,fOut);
}
// ------------------------------------------------------------------------------------------------
void Parser::ParseLV4MeshLong(unsigned int& iOut)

View File

@ -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

View File

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

View File

@ -53,7 +53,8 @@ using namespace Assimp;
using namespace Assimp::Blender;
using namespace Assimp::Formatter;
bool match4(StreamReaderAny& stream, const char* string) {
static bool match4(StreamReaderAny& stream, const char* string) {
ai_assert( nullptr != string );
char tmp[] = {
(stream).GetI1(),
(stream).GetI1(),
@ -69,7 +70,7 @@ struct Type {
};
// ------------------------------------------------------------------------------------------------
void DNAParser :: Parse ()
void DNAParser::Parse ()
{
StreamReaderAny& stream = *db.reader.get();
DNA& dna = db.dna;

View File

@ -50,7 +50,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "BlenderBMesh.h"
#include "BlenderTessellator.h"
#include <stddef.h>
#include <stddef.h>
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 );

View File

@ -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 <<"<falloff_angle sid=\"fall_off_angle\">"
<< fallOffAngle
<<"</falloff_angle>" << 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 )

View File

@ -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)
{}
};

View File

@ -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<float> mValues;
std::vector<ai_real> mValues;
std::vector<std::string> 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;

View File

@ -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<Collada::ChannelEntry>::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<Collada::ChannelEntry>::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<Collada::ChannelEntry>::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<int>(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<int>(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<int>( &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;

View File

@ -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

View File

@ -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<float>( content, pController.mBindShapeMatrix[a]);
content = fast_atoreal_move<ai_real>( 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<float>( content, (float&)pLight.mColor.r);
content = fast_atoreal_move<ai_real>( content, (ai_real&)pLight.mColor.r);
SkipSpacesAndLineEnd( &content);
content = fast_atoreal_move<float>( content, (float&)pLight.mColor.g);
content = fast_atoreal_move<ai_real>( content, (ai_real&)pLight.mColor.g);
SkipSpacesAndLineEnd( &content);
content = fast_atoreal_move<float>( content, (float&)pLight.mColor.b);
content = fast_atoreal_move<ai_real>( 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<float>( content, (float&)pColor.r);
content = fast_atoreal_move<ai_real>( content, (ai_real&)pColor.r);
SkipSpacesAndLineEnd( &content);
content = fast_atoreal_move<float>( content, (float&)pColor.g);
content = fast_atoreal_move<ai_real>( content, (ai_real&)pColor.g);
SkipSpacesAndLineEnd( &content);
content = fast_atoreal_move<float>( content, (float&)pColor.b);
content = fast_atoreal_move<ai_real>( content, (ai_real&)pColor.b);
SkipSpacesAndLineEnd( &content);
content = fast_atoreal_move<float>( content, (float&)pColor.a);
content = fast_atoreal_move<ai_real>( 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<float>( content, pFloat);
content = fast_atoreal_move<ai_real>( 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<float>( content, value);
content = fast_atoreal_move<ai_real>( 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<float>( content, tf.f[a]);
content = fast_atoreal_move<ai_real>( content, tf.f[a]);
// skip whitespace after it
SkipSpacesAndLineEnd( &content);
}
@ -3075,7 +3075,7 @@ aiMatrix4x4 ColladaParser::CalculateResultTransform( const std::vector<Transform
case TF_ROTATE:
{
aiMatrix4x4 rot;
float angle = tf.f[3] * float( AI_MATH_PI) / 180.0f;
ai_real angle = tf.f[3] * ai_real( AI_MATH_PI) / 180.0;
aiVector3D axis( tf.f[0], tf.f[1], tf.f[2]);
aiMatrix4x4::Rotation( angle, axis, rot);
res *= rot;

View File

@ -147,7 +147,7 @@ namespace Assimp
void ReadEffectColor( aiColor4D& pColor, Collada::Sampler& pSampler);
/** Reads an effect entry containing a float */
void ReadEffectFloat( float& pFloat);
void ReadEffectFloat( ai_real& pFloat);
/** Reads an effect parameter specification of any kind */
void ReadEffectParam( Collada::EffectParam& pParam);
@ -259,7 +259,7 @@ namespace Assimp
bool ReadBoolFromTextContent();
/** Reads a single float from current text content */
float ReadFloatFromTextContent();
ai_real ReadFloatFromTextContent();
/** Calculates the resulting transformation from all the given transform steps */
aiMatrix4x4 CalculateResultTransform( const std::vector<Collada::Transform>& 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;

View File

@ -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);
}
}

View File

@ -55,7 +55,7 @@ namespace Assimp {
//! @note An instance of this class can exist without a valid file handle
//! attached to it. All calls fail, but the instance can nevertheless be
//! used with no restrictions.
class DefaultIOStream : public IOStream
class ASSIMP_API DefaultIOStream : public IOStream
{
friend class DefaultIOSystem;
#if __ANDROID__

View File

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

View File

@ -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<double>( ( time - timeA ) / ( timeB - timeA ) );
const float interpValue = static_cast<float>( valueA + ( valueB - valueA ) * factor );
const ai_real interpValue = static_cast<ai_real>( valueA + ( valueB - valueA ) * factor );
result[ std::get<2>(kfl) ] = interpValue;
}

View File

@ -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 <typename T>
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<aiVectorKey>(const aiVectorKey& n, const aiVectorKey& s, float epsilon) {
bool EpsilonCompare<aiVectorKey>(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<aiVectorKey>(const aiVectorKey& n, const aiVectorKey& s, flo
// ------------------------------------------------------------------------------------------------
template <>
bool EpsilonCompare<aiQuatKey>(const aiQuatKey& n, const aiQuatKey& s, float epsilon) {
bool EpsilonCompare<aiQuatKey>(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<aiQuatKey>(const aiQuatKey& n, const aiQuatKey& s, float eps
// ------------------------------------------------------------------------------------------------
template <typename T>
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;

View File

@ -97,7 +97,7 @@ public:
void ProcessAnimationChannel (aiNodeAnim* anim);
private:
float configEpsilon;
ai_real configEpsilon;
};
} // end of namespace Assimp

View File

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

View File

@ -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

View File

@ -207,54 +207,54 @@ void IRRImporter::BuildSkybox(std::vector<aiMesh*>& meshes, std::vector<aiMateri
// by six single planes with different textures, so we'll
// need to build six meshes.
const float l = 10.f; // the size used by Irrlicht
const ai_real l = 10.0; // the size used by Irrlicht
// FRONT 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()-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::vector<aiNode
aiVectorKey& key = anim->mPositionKeys[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::vector<aiNode
anim->mPositionKeys = 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::vector<aiNode
for (unsigned int i = 0; i < anim->mNumPositionKeys;++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::vector<aiNode
{
aiVectorKey& key = anim->mPositionKeys[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<aiNode
const aiVector3D& p3 = in.splineKeys[ ClampSpline( idx + 2, size ) ].mValue;
// compute polynomials
const float u2 = u*u;
const float u3 = u2*2;
const ai_real u2 = u*u;
const ai_real u3 = u2*2;
const float h1 = 2.0f * u3 - 3.0f * u2 + 1.0f;
const float h2 = -2.0f * u3 + 3.0f * u3;
const float h3 = u3 - 2.0f * u3;
const float h4 = u3 - u2;
const ai_real h1 = 2.0 * u3 - 3.0 * u2 + 1.0;
const ai_real h2 = -2.0 * u3 + 3.0 * u3;
const ai_real h3 = u3 - 2.0 * u3;
const ai_real h4 = u3 - u2;
// compute the spline tangents
const aiVector3D t1 = ( p2 - p0 ) * in.tightness;

View File

@ -116,9 +116,9 @@ private:
explicit Animator(AT t = UNKNOWN)
: type (t)
, speed (0.001f)
, direction (0.f,1.f,0.f)
, circleRadius (1.f)
, speed (0.001)
, direction (0.0,1.0,0.0)
, circleRadius (1.0)
, tightness (0.5f)
, loop (true)
, timeForWay (100)
@ -127,15 +127,15 @@ private:
// common parameters
float speed;
ai_real speed;
aiVector3D direction;
// FLY_CIRCLE
aiVector3D circleCenter;
float circleRadius;
ai_real circleRadius;
// FOLLOW_SPLINE
float tightness;
ai_real tightness;
std::vector<aiVectorKey> 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<aiMaterial*, unsigned int> > 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;

View File

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

View File

@ -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<KeyType, int> IntPropertyMap;
typedef std::map<KeyType, float> FloatPropertyMap;
typedef std::map<KeyType, ai_real> FloatPropertyMap;
typedef std::map<KeyType, std::string> StringPropertyMap;
typedef std::map<KeyType, aiMatrix4x4> MatrixPropertyMap;

View File

@ -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<aiColor3D>(&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 "

View File

@ -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

View File

@ -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;

View File

@ -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);

View File

@ -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] ;

View File

@ -657,7 +657,7 @@ void MDLImporter::ParseSkinLump_3DGS_MDL7(
if (is_not_qnan(clrTexture.r)) {
clrTemp.r *= clrTexture.a;
}
pcMatOut->AddProperty<float>(&clrTemp.r,1,AI_MATKEY_OPACITY);
pcMatOut->AddProperty<ai_real>(&clrTemp.r,1,AI_MATKEY_OPACITY);
// read phong power
int iShadingMode = (int)aiShadingMode_Gouraud;

View File

@ -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];

View File

@ -161,9 +161,9 @@ void OFFImporter::InternReadFile( const std::string& pFile,
aiVector3D& v = tempPositions[i];
sz = line; SkipSpaces(&sz);
sz = fast_atoreal_move<float>(sz,(float&)v.x); SkipSpaces(&sz);
sz = fast_atoreal_move<float>(sz,(float&)v.y); SkipSpaces(&sz);
fast_atoreal_move<float>(sz,(float&)v.z);
sz = fast_atoreal_move<ai_real>(sz,(ai_real&)v.x); SkipSpaces(&sz);
sz = fast_atoreal_move<ai_real>(sz,(ai_real&)v.y); SkipSpaces(&sz);
fast_atoreal_move<ai_real>(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;

View File

@ -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;
}

View File

@ -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)

View File

@ -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<DataArrayIt>( 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<DataArrayIt>( m_DataIt, m_DataItEnd, m_buffer, BUFFERSIZE );
value = (float) fast_atof(m_buffer);
value = (ai_real) fast_atof(m_buffer);
}
// -------------------------------------------------------------------

View File

@ -41,6 +41,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <vector>
#include <string>
#include <assimp/defs.h>
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.

View File

@ -279,23 +279,23 @@ size_t ObjFileParser::getNumComponentsInLine() {
// -------------------------------------------------------------------
void ObjFileParser::getVector( std::vector<aiVector3D> &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<aiVector3D> &point3d_array ) {
// -------------------------------------------------------------------
// Get values for a new 3D vector instance
void ObjFileParser::getVector3( std::vector<aiVector3D> &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<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
@ -323,26 +323,26 @@ void ObjFileParser::getVector3( std::vector<aiVector3D> &point3d_array ) {
// -------------------------------------------------------------------
// Get values for two 3D vectors on the same line
void ObjFileParser::getTwoVectors3( std::vector<aiVector3D> &point3d_array_a, std::vector<aiVector3D> &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<aiVector3D> &point3d_array_a, st
// -------------------------------------------------------------------
// Get values for a new 2D vector instance
void ObjFileParser::getVector2( std::vector<aiVector2D> &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));

View File

@ -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<class char_t>
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<char_t>( it, end, buffer, BUFFERSIZE );
value = (float) fast_atof( buffer );
value = (ai_real) fast_atof( buffer );
return it;
}

View File

@ -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 <typename T> 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<float>::infinity();
static const ai_real inf = std::numeric_limits<ai_real>::infinity();
// If a component (for instance normal vectors) is present in at least one mesh in the scene,
// then default values are written for meshes that do not contain this component.

View File

@ -326,7 +326,7 @@ void PLYImporter::ConvertMeshes(std::vector<PLY::Face>* 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<aiVector2D>* pvOut)
if (0xFFFFFFFF != aiPositions[0])
{
vOut.x = PLY::PropertyInstance::ConvertTo<float>(
vOut.x = PLY::PropertyInstance::ConvertTo<ai_real>(
GetProperty((*i).alProperties, aiPositions[0]).avList.front(),aiTypes[0]);
}
if (0xFFFFFFFF != aiPositions[1])
{
vOut.y = PLY::PropertyInstance::ConvertTo<float>(
vOut.y = PLY::PropertyInstance::ConvertTo<ai_real>(
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<aiVector3D>* 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<aiVector3D>* pvOut, bool p_bNormals)
if (0xFFFFFFFF != aiPositions[0])
{
vOut.x = PLY::PropertyInstance::ConvertTo<float>(
vOut.x = PLY::PropertyInstance::ConvertTo<ai_real>(
GetProperty((*i).alProperties, aiPositions[0]).avList.front(),aiTypes[0]);
}
if (0xFFFFFFFF != aiPositions[1])
{
vOut.y = PLY::PropertyInstance::ConvertTo<float>(
vOut.y = PLY::PropertyInstance::ConvertTo<ai_real>(
GetProperty((*i).alProperties, aiPositions[1]).avList.front(),aiTypes[1]);
}
if (0xFFFFFFFF != aiPositions[2])
{
vOut.z = PLY::PropertyInstance::ConvertTo<float>(
vOut.z = PLY::PropertyInstance::ConvertTo<ai_real>(
GetProperty((*i).alProperties, aiPositions[2]).avList.front(),aiTypes[2]);
}
@ -615,7 +615,7 @@ void PLYImporter::LoadVertices(std::vector<aiVector3D>* 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<aiColor4D>* 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<aiMaterial*>* pvOut)
// handle phong power and shading mode
int iMode;
if (0xFFFFFFFF != iPhong) {
float fSpec = PLY::PropertyInstance::ConvertTo<float>(GetProperty((*i).alProperties, iPhong).avList.front(),ePhong);
ai_real fSpec = PLY::PropertyInstance::ConvertTo<ai_real>(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<float>(&fSpec, 1, AI_MATKEY_SHININESS);
pcHelper->AddProperty<ai_real>(&fSpec, 1, AI_MATKEY_SHININESS);
iMode = (int)aiShadingMode_Phong;
}
@ -1094,8 +1094,8 @@ void PLYImporter::LoadMaterial(std::vector<aiMaterial*>* pvOut)
// handle opacity
if (0xFFFFFFFF != iOpacity) {
float fOpacity = PLY::PropertyInstance::ConvertTo<float>(GetProperty((*i).alProperties, iPhong).avList.front(),eOpacity);
pcHelper->AddProperty<float>(&fOpacity, 1, AI_MATKEY_OPACITY);
ai_real fOpacity = PLY::PropertyInstance::ConvertTo<ai_real>(GetProperty((*i).alProperties, iPhong).avList.front(),eOpacity);
pcHelper->AddProperty<ai_real>(&fOpacity, 1, AI_MATKEY_OPACITY);
}
// The face order is absolutely undefined for PLY, so we have to

View File

@ -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);

View File

@ -819,15 +819,18 @@ bool PLY::PropertyInstance::ParseValue(
break;
case EDT_Float:
pCur = fast_atoreal_move<float>(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<ai_real>(pCur,f);
out->fFloat = (ai_real)f;
break;
case EDT_Double:
float f;
pCur = fast_atoreal_move<float>(pCur,f);
out->fDouble = (double)f;
double d;
pCur = fast_atoreal_move<double>(pCur,d);
out->fDouble = (double)d;
break;
default:

View File

@ -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);
}
}

View File

@ -77,8 +77,8 @@ void ConvertListToStrings(const std::string& in, std::list<std::string>& 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;

View File

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

View File

@ -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<char>(( chunk.Tag>>24 ) & 0xff),
static_cast<char>(( chunk.Tag>>16 ) & 0xff),
static_cast<char>(( chunk.Tag>>8 ) & 0xff),
static_cast<char>(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<numPoints;i++,idx+=N)
{
uint32_t next = idx[POS];
@ -398,7 +398,7 @@ static void ConnectFaces(SIBMesh* mesh)
static aiVector3D CalculateVertexNormal(SIBMesh* mesh, uint32_t faceIdx, uint32_t pos,
const std::vector<aiVector3D>& 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;n<meshes.size();n++)
@ -697,8 +697,8 @@ static void ReadLightInfo(aiLight* light, StreamReaderLE* stream)
light->mColorDiffuse = 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));

View File

@ -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);
}

View File

@ -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<float>(sz, (float&)vn->x );
sz = fast_atoreal_move<ai_real>(sz, (ai_real&)vn->x );
SkipSpaces(&sz);
sz = fast_atoreal_move<float>(sz, (float&)vn->y );
sz = fast_atoreal_move<ai_real>(sz, (ai_real&)vn->y );
SkipSpaces(&sz);
sz = fast_atoreal_move<float>(sz, (float&)vn->z );
sz = fast_atoreal_move<ai_real>(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<float>(sz, (float&)vn->x );
sz = fast_atoreal_move<ai_real>(sz, (ai_real&)vn->x );
SkipSpaces(&sz);
sz = fast_atoreal_move<float>(sz, (float&)vn->y );
sz = fast_atoreal_move<ai_real>(sz, (ai_real&)vn->y );
SkipSpaces(&sz);
sz = fast_atoreal_move<float>(sz, (float&)vn->z );
sz = fast_atoreal_move<ai_real>(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;

View File

@ -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<float*>(in.mData));
break;
case AI_DOUBLE:
out.mData = new double(*static_cast<double*>(in.mData));
break;
case AI_AISTRING:
out.mData = new aiString(*static_cast<aiString*>(in.mData));
break;

View File

@ -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;

View File

@ -107,7 +107,7 @@ void SpatialSort::Append( const aiVector3D* pPositions, unsigned int pNumPositio
const aiVector3D* vec = reinterpret_cast<const aiVector3D*> (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<unsigned int>& poResults) const
ai_real pRadius, std::vector<unsigned int>& 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<Entry>::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<BinFloat const &>(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<unsigned int>& fill,float pRadius) const
unsigned int SpatialSort::GenerateMappingTable(std::vector<unsigned int>& 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<unsigned int>& fill,f
#endif
return t;
}

View File

@ -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<unsigned int>& poResults) const;
// ------------------------------------------------------------------------------------
@ -139,7 +139,7 @@ public:
* be counted in.
* @return Number of unique vertices (n). */
unsigned int GenerateMappingTable(std::vector<unsigned int>& 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)
{ }

View File

@ -95,7 +95,7 @@ namespace Assimp {
void Subdivide(std::vector<aiVector3D>& 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<aiVector3D>& 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<aiVector3D>& 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<aiVector3D>& 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<aiVector3D>& 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<aiVector3D>& 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<aiVector3D>& 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<aiVector3D>& 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<aiVector3D>& 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));
}
}

View File

@ -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<aiVector3D>& 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<aiVector3D>& positions);
};

View File

@ -83,7 +83,7 @@ KeyIterator::KeyIterator(const std::vector<aiVectorKey>* _objPos,
// ------------------------------------------------------------------------------------------------
template <class T>
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<aiVectorKey>* distanceTrack)
// diff vector
aiVector3D diff = tposition - position;
float f = diff.Length();
ai_real f = diff.Length();
// output distance vector
if (f)

View File

@ -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 <template <typename, typename, typename> class op> static Vertex BinaryOp(const Vertex& v0, float f) {
template <template <typename, typename, typename> class op> static Vertex BinaryOp(const Vertex& v0, ai_real f) {
// this is a heavy task for the compiler to optimize ... *pray*
Vertex res;
res.position = op<aiVector3D,float,aiVector3D>()(v0.position,f);
res.normal = op<aiVector3D,float,aiVector3D>()(v0.normal,f);
res.tangent = op<aiVector3D,float,aiVector3D>()(v0.tangent,f);
res.bitangent = op<aiVector3D,float,aiVector3D>()(v0.bitangent,f);
res.position = op<aiVector3D,ai_real,aiVector3D>()(v0.position,f);
res.normal = op<aiVector3D,ai_real,aiVector3D>()(v0.normal,f);
res.tangent = op<aiVector3D,ai_real,aiVector3D>()(v0.tangent,f);
res.bitangent = op<aiVector3D,ai_real,aiVector3D>()(v0.bitangent,f);
for (unsigned int i = 0; i < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++i) {
res.texcoords[i] = op<aiVector3D,float,aiVector3D>()(v0.texcoords[i],f);
res.texcoords[i] = op<aiVector3D,ai_real,aiVector3D>()(v0.texcoords[i],f);
}
for (unsigned int i = 0; i < AI_MAX_NUMBER_OF_COLOR_SETS; ++i) {
res.colors[i] = op<aiColor4D,float,aiColor4D>()(v0.colors[i],f);
res.colors[i] = op<aiColor4D,ai_real,aiColor4D>()(v0.colors[i],f);
}
return res;
}
// ----------------------------------------------------------------------------
/** This time binary arithmetics of v0 with a floating-point number */
template <template <typename, typename, typename> class op> static Vertex BinaryOp(float f, const Vertex& v0) {
template <template <typename, typename, typename> class op> static Vertex BinaryOp(ai_real f, const Vertex& v0) {
// this is a heavy task for the compiler to optimize ... *pray*
Vertex res;
res.position = op<float,aiVector3D,aiVector3D>()(f,v0.position);
res.normal = op<float,aiVector3D,aiVector3D>()(f,v0.normal);
res.tangent = op<float,aiVector3D,aiVector3D>()(f,v0.tangent);
res.bitangent = op<float,aiVector3D,aiVector3D>()(f,v0.bitangent);
res.position = op<ai_real,aiVector3D,aiVector3D>()(f,v0.position);
res.normal = op<ai_real,aiVector3D,aiVector3D>()(f,v0.normal);
res.tangent = op<ai_real,aiVector3D,aiVector3D>()(f,v0.tangent);
res.bitangent = op<ai_real,aiVector3D,aiVector3D>()(f,v0.bitangent);
for (unsigned int i = 0; i < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++i) {
res.texcoords[i] = op<float,aiVector3D,aiVector3D>()(f,v0.texcoords[i]);
res.texcoords[i] = op<ai_real,aiVector3D,aiVector3D>()(f,v0.texcoords[i]);
}
for (unsigned int i = 0; i < AI_MAX_NUMBER_OF_COLOR_SETS; ++i) {
res.colors[i] = op<float,aiColor4D,aiColor4D>()(f,v0.colors[i]);
res.colors[i] = op<ai_real,aiColor4D,aiColor4D>()(f,v0.colors[i]);
}
return res;
}
@ -279,41 +279,41 @@ AI_FORCE_INLINE Vertex operator - (const Vertex& v0,const Vertex& v1) {
// ------------------------------------------------------------------------------------------------
/*
AI_FORCE_INLINE Vertex operator + (const Vertex& v0,float f) {
AI_FORCE_INLINE Vertex operator + (const Vertex& v0,ai_real f) {
return Vertex::BinaryOp<Intern::plus>(v0,f);
}
AI_FORCE_INLINE Vertex operator - (const Vertex& v0,float f) {
AI_FORCE_INLINE Vertex operator - (const Vertex& v0,ai_real f) {
return Vertex::BinaryOp<Intern::minus>(v0,f);
}
*/
AI_FORCE_INLINE Vertex operator * (const Vertex& v0,float f) {
AI_FORCE_INLINE Vertex operator * (const Vertex& v0,ai_real f) {
return Vertex::BinaryOp<Intern::multiplies>(v0,f);
}
AI_FORCE_INLINE Vertex operator / (const Vertex& v0,float f) {
AI_FORCE_INLINE Vertex operator / (const Vertex& v0,ai_real f) {
return Vertex::BinaryOp<Intern::multiplies>(v0,1.f/f);
}
// ------------------------------------------------------------------------------------------------
/*
AI_FORCE_INLINE Vertex operator + (float f,const Vertex& v0) {
AI_FORCE_INLINE Vertex operator + (ai_real f,const Vertex& v0) {
return Vertex::BinaryOp<Intern::plus>(f,v0);
}
AI_FORCE_INLINE Vertex operator - (float f,const Vertex& v0) {
AI_FORCE_INLINE Vertex operator - (ai_real f,const Vertex& v0) {
return Vertex::BinaryOp<Intern::minus>(f,v0);
}
*/
AI_FORCE_INLINE Vertex operator * (float f,const Vertex& v0) {
AI_FORCE_INLINE Vertex operator * (ai_real f,const Vertex& v0) {
return Vertex::BinaryOp<Intern::multiplies>(f,v0);
}
/*
AI_FORCE_INLINE Vertex operator / (float f,const Vertex& v0) {
AI_FORCE_INLINE Vertex operator / (ai_real f,const Vertex& v0) {
return Vertex::BinaryOp<Intern::divides>(f,v0);
}
*/

View File

@ -82,7 +82,7 @@ struct Material
std::string mName;
bool mIsReference; // if true, mName holds a name by which the actual material can be found in the material list
aiColor4D mDiffuse;
float mSpecularExponent;
ai_real mSpecularExponent;
aiColor3D mSpecular;
aiColor3D mEmissive;
std::vector<TexEntry> mTextures;
@ -100,7 +100,7 @@ struct Material
struct BoneWeight
{
unsigned int mVertex;
float mWeight;
ai_real mWeight;
};
/** Helper structure to represent a bone in a mesh */

View File

@ -373,7 +373,7 @@ void XFileImporter::CreateMeshes( aiScene* pScene, aiNode* pNode, const std::vec
{
const XFile::Bone& obone = bones[c];
// set up a vertex-linear array of the weights for quick searching if a bone influences a vertex
std::vector<float> oldWeights( sourceMesh->mPositions.size(), 0.0f);
std::vector<ai_real> oldWeights( sourceMesh->mPositions.size(), 0.0);
for( unsigned int d = 0; d < obone.mWeights.size(); d++)
oldWeights[obone.mWeights[d].mVertex] = obone.mWeights[d].mWeight;
@ -383,8 +383,8 @@ void XFileImporter::CreateMeshes( aiScene* pScene, aiNode* pNode, const std::vec
for( unsigned int d = 0; d < orgPoints.size(); d++)
{
// does the new vertex stem from an old vertex which was influenced by this bone?
float w = oldWeights[orgPoints[d]];
if( w > 0.0f)
ai_real w = oldWeights[orgPoints[d]];
if( w > 0.0)
newWeights.push_back( aiVertexWeight( d, w));
}
@ -713,4 +713,3 @@ void XFileImporter::ConvertMaterials( aiScene* pScene, std::vector<XFile::Materi
}
#endif // !! ASSIMP_BUILD_NO_X_IMPORTER

View File

@ -1326,7 +1326,7 @@ unsigned int XFileParser::ReadInt()
}
// ------------------------------------------------------------------------------------------------
float XFileParser::ReadFloat()
ai_real XFileParser::ReadFloat()
{
if( mIsBinaryFormat)
{
@ -1343,7 +1343,7 @@ float XFileParser::ReadFloat()
if( mBinaryFloatSize == 8)
{
if( End - P >= 8) {
float result = (float) (*(double*) P);
ai_real result = (ai_real) (*(double*) P);
P += 8;
return result;
} else {
@ -1353,7 +1353,7 @@ float XFileParser::ReadFloat()
} else
{
if( End - P >= 4) {
float result = *(float*) P;
ai_real result = *(ai_real*) P;
P += 4;
return result;
} else {
@ -1372,17 +1372,17 @@ float XFileParser::ReadFloat()
{
P += 9;
CheckForSeparator();
return 0.0f;
return 0.0;
} else
if( strncmp( P, "1.#QNAN0", 8) == 0)
{
P += 8;
CheckForSeparator();
return 0.0f;
return 0.0;
}
float result = 0.0f;
P = fast_atoreal_move<float>( P, result);
ai_real result = 0.0;
P = fast_atoreal_move<ai_real>( P, result);
CheckForSeparator();

View File

@ -127,7 +127,7 @@ protected:
unsigned short ReadBinWord();
unsigned int ReadBinDWord();
unsigned int ReadInt();
float ReadFloat();
ai_real ReadFloat();
aiVector2D ReadVector2();
aiVector3D ReadVector3();
aiColor3D ReadRGB();

View File

@ -19,6 +19,7 @@
#include <limits>
#include <stdint.h>
#include <stdexcept>
#include <assimp/defs.h>
#include "StringComparison.h"
@ -350,51 +351,26 @@ inline const char* fast_atoreal_move(const char* c, Real& out, bool check_comma
// ------------------------------------------------------------------------------------
// The same but more human.
inline float fast_atof(const char* c)
inline ai_real fast_atof(const char* c)
{
float ret;
fast_atoreal_move<float>(c, ret);
ai_real ret;
fast_atoreal_move<ai_real>(c, ret);
return ret;
}
inline float fast_atof( const char* c, const char** cout)
inline ai_real fast_atof( const char* c, const char** cout)
{
float ret;
*cout = fast_atoreal_move<float>(c, ret);
ai_real ret;
*cout = fast_atoreal_move<ai_real>(c, ret);
return ret;
}
inline float fast_atof( const char** inout)
inline ai_real fast_atof( const char** inout)
{
float ret;
*inout = fast_atoreal_move<float>(*inout, ret);
return ret;
}
inline double fast_atod(const char* c)
{
double ret;
fast_atoreal_move<double>(c, ret);
return ret;
}
inline double fast_atod( const char* c, const char** cout)
{
double ret;
*cout = fast_atoreal_move<double>(c, ret);
return ret;
}
inline double fast_atod( const char** inout)
{
double ret;
*inout = fast_atoreal_move<double>(*inout, ret);
ai_real ret;
*inout = fast_atoreal_move<ai_real>(*inout, ret);
return ret;
}
@ -402,4 +378,3 @@ inline double fast_atod( const char** inout)
} // end of namespace Assimp
#endif

View File

@ -369,7 +369,7 @@ namespace glTF
//! A typed view into a BufferView. A BufferView contains raw binary data.
//! An accessor provides a typed view into a BufferView or a subset of a BufferView
// !similar to how WebGL's vertexAttribPointer() defines an attribute in a buffer.
//! similar to how WebGL's vertexAttribPointer() defines an attribute in a buffer.
struct Accessor : public Object
{
Ref<BufferView> bufferView; //!< The ID of the bufferView. (required)

View File

@ -68,7 +68,21 @@ union _IEEESingle
uint32_t Exp : 8;
uint32_t Sign : 1;
} IEEE;
} ;
};
// ---------------------------------------------------------------------------
/** Data structure to represent the bit pattern of a 64 Bit
* IEEE 754 floating-point number. */
union _IEEEDouble
{
double Double;
struct
{
uint64_t Frac : 52;
uint64_t Exp : 11;
uint64_t Sign : 1;
} IEEE;
};
// ---------------------------------------------------------------------------
/** Check whether a given float is qNaN.
@ -87,11 +101,19 @@ AI_FORCE_INLINE bool is_qnan(float in)
}
// ---------------------------------------------------------------------------
/** Check whether a float is NOT qNaN.
/** Check whether a given double is qNaN.
* @param in Input value */
AI_FORCE_INLINE bool is_not_qnan(float in)
AI_FORCE_INLINE bool is_qnan(double in)
{
return !is_qnan(in);
// the straightforward solution does not work:
// return (in != in);
// compiler generates code like this
// load <in> to <register-with-different-width>
// compare <register-with-different-width> against <in>
// FIXME: Use <float> stuff instead? I think fpclassify needs C99
return (reinterpret_cast<_IEEEDouble*>(&in)->IEEE.Exp == (1u << 11)-1 &&
reinterpret_cast<_IEEEDouble*>(&in)->IEEE.Frac);
}
// ---------------------------------------------------------------------------
@ -105,10 +127,29 @@ AI_FORCE_INLINE bool is_special_float(float in)
}
// ---------------------------------------------------------------------------
/** @brief Get a fresh qnan. */
AI_FORCE_INLINE float get_qnan()
/** @brief check whether a double is either NaN or (+/-) INF.
*
* Denorms return false, they're treated like normal values.
* @param in Input value */
AI_FORCE_INLINE bool is_special_float(double in)
{
return std::numeric_limits<float>::quiet_NaN();
return (reinterpret_cast<_IEEEDouble*>(&in)->IEEE.Exp == (1u << 11)-1);
}
// ---------------------------------------------------------------------------
/** Check whether a float is NOT qNaN.
* @param in Input value */
template<class TReal>
AI_FORCE_INLINE bool is_not_qnan(TReal in)
{
return !is_qnan(in);
}
// ---------------------------------------------------------------------------
/** @brief Get a fresh qnan. */
AI_FORCE_INLINE ai_real get_qnan()
{
return std::numeric_limits<ai_real>::quiet_NaN();
}
#endif // !! AI_QNAN_H_INCLUDED

View File

@ -330,7 +330,7 @@ public:
// typedefs for our four configuration maps.
// We don't need more, so there is no need for a generic solution
typedef std::map<KeyType, int> IntPropertyMap;
typedef std::map<KeyType, float> FloatPropertyMap;
typedef std::map<KeyType, ai_real> FloatPropertyMap;
typedef std::map<KeyType, std::string> StringPropertyMap;
typedef std::map<KeyType, aiMatrix4x4> MatrixPropertyMap;
@ -380,7 +380,7 @@ public:
/** Set a floating-point configuration property.
* @see SetPropertyInteger()
*/
bool SetPropertyFloat(const char* szName, float fValue);
bool SetPropertyFloat(const char* szName, ai_real fValue);
// -------------------------------------------------------------------
/** Set a string configuration property.
@ -425,8 +425,8 @@ public:
/** Get a floating-point configuration property
* @see GetPropertyInteger()
*/
float GetPropertyFloat(const char* szName,
float fErrorReturn = 10e10f) const;
ai_real GetPropertyFloat(const char* szName,
ai_real fErrorReturn = 10e10f) const;
// -------------------------------------------------------------------
/** Get a string configuration property

View File

@ -51,8 +51,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#endif // __cplusplus
// Public ASSIMP data structures
#include "types.h"
#include "config.h"
#include <assimp/types.h>
#include <assimp/config.h>
namespace Assimp {
// =======================================================================
@ -119,7 +119,7 @@ public:
/**
* @brief The upper limit for hints.
*/
static const unsigned int MaxLenHint = 200;
static const unsigned int MaxLenHint = 200;
public:
@ -224,7 +224,7 @@ public:
/** Set a floating-point configuration property.
* @see SetPropertyInteger()
*/
bool SetPropertyFloat(const char* szName, float fValue);
bool SetPropertyFloat(const char* szName, ai_real fValue);
// -------------------------------------------------------------------
/** Set a string configuration property.
@ -269,8 +269,8 @@ public:
/** Get a floating-point configuration property
* @see GetPropertyInteger()
*/
float GetPropertyFloat(const char* szName,
float fErrorReturn = 10e10f) const;
ai_real GetPropertyFloat(const char* szName,
ai_real fErrorReturn = 10e10) const;
// -------------------------------------------------------------------
/** Get a string configuration property

View File

@ -421,7 +421,7 @@ struct Interpolator
* The interpolation algorithm depends on the type of the operands.
* aiQuaternion's and aiQuatKey's SLERP, the rest does a simple
* linear interpolation. */
void operator () (T& out,const T& a, const T& b, float d) const {
void operator () (T& out,const T& a, const T& b, ai_real d) const {
out = a + (b-a)*d;
}
}; // ! Interpolator <T>
@ -431,7 +431,7 @@ struct Interpolator
template <>
struct Interpolator <aiQuaternion> {
void operator () (aiQuaternion& out,const aiQuaternion& a,
const aiQuaternion& b, float d) const
const aiQuaternion& b, ai_real d) const
{
aiQuaternion::Interpolate(out,a,b,d);
}
@ -440,7 +440,7 @@ struct Interpolator <aiQuaternion> {
template <>
struct Interpolator <unsigned int> {
void operator () (unsigned int& out,unsigned int a,
unsigned int b, float d) const
unsigned int b, ai_real d) const
{
out = d>0.5f ? b : a;
}
@ -449,7 +449,7 @@ struct Interpolator <unsigned int> {
template <>
struct Interpolator <aiVectorKey> {
void operator () (aiVector3D& out,const aiVectorKey& a,
const aiVectorKey& b, float d) const
const aiVectorKey& b, ai_real d) const
{
Interpolator<aiVector3D> ipl;
ipl(out,a.mValue,b.mValue,d);
@ -459,7 +459,7 @@ struct Interpolator <aiVectorKey> {
template <>
struct Interpolator <aiQuatKey> {
void operator () (aiQuaternion& out, const aiQuatKey& a,
const aiQuatKey& b, float d) const
const aiQuatKey& b, ai_real d) const
{
Interpolator<aiQuaternion> ipl;
ipl(out,a.mValue,b.mValue,d);
@ -469,7 +469,7 @@ struct Interpolator <aiQuatKey> {
template <>
struct Interpolator <aiMeshKey> {
void operator () (unsigned int& out, const aiMeshKey& a,
const aiMeshKey& b, float d) const
const aiMeshKey& b, ai_real d) const
{
Interpolator<unsigned int> ipl;
ipl(out,a.mValue,b.mValue,d);

View File

@ -46,6 +46,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define AI_COLOR4D_H_INC
#include "./Compiler/pushpack1.h"
#include "defs.h"
#ifdef __cplusplus
@ -90,12 +91,12 @@ public:
TReal r, g, b, a;
} PACK_STRUCT; // !struct aiColor4D
typedef aiColor4t<float> aiColor4D;
typedef aiColor4t<ai_real> aiColor4D;
#else
struct aiColor4D {
float r, g, b, a;
ai_real r, g, b, a;
} PACK_STRUCT;
#endif // __cplusplus

View File

@ -905,4 +905,14 @@ enum aiComponent
#define AI_CONFIG_EXPORT_XFILE_64BIT "EXPORT_XFILE_64BIT"
// ---------- All the Build/Compile-time defines ------------
/** @brief Specifies if double precision is supported inside assimp
*
* Property type: Bool. Default value: undefined.
*/
#cmakedefine AI_DOUBLE_PRECISION 1
#endif // !! AI_CONFIG_H_INC

View File

@ -228,6 +228,21 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# define ASSIMP_BUILD_DEBUG
#endif
//////////////////////////////////////////////////////////////////////////
/* Define AI_DOUBLE_PRECISION to compile assimp
* with double precision support (64-bit). */
//////////////////////////////////////////////////////////////////////////
#ifdef AI_DOUBLE_PRECISION
typedef double ai_real;
typedef signed long long int ai_int;
typedef unsigned long long int ai_uint;
#else // AI_DOUBLE_PRECISION
typedef float ai_real;
typedef signed int ai_int;
typedef unsigned int ai_uint;
#endif // AI_DOUBLE_PRECISION
//////////////////////////////////////////////////////////////////////////
/* Useful constants */
//////////////////////////////////////////////////////////////////////////
@ -243,8 +258,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define AI_MATH_HALF_PI_F (AI_MATH_PI_F * 0.5f)
/* Tiny macro to convert from radians to degrees and back */
#define AI_DEG_TO_RAD(x) ((x)*0.0174532925f)
#define AI_RAD_TO_DEG(x) ((x)*57.2957795f)
#define AI_DEG_TO_RAD(x) ((x)*(ai_real)0.0174532925)
#define AI_RAD_TO_DEG(x) ((x)*(ai_real)57.2957795)
/* Support for big-endian builds */
#if defined(__BYTE_ORDER__)
@ -269,5 +284,4 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#define AI_MAX_ALLOC(type) ((256U * 1024 * 1024) / sizeof(type))
#endif // !! AI_DEFINES_H_INC

View File

@ -477,13 +477,14 @@ struct aiUVTransform
* rotation center is 0.5f|0.5f. The default value
* 0.f.
*/
float mRotation;
ai_real mRotation;
#ifdef __cplusplus
aiUVTransform()
: mScaling (1.f,1.f)
, mRotation (0.f)
: mTranslation (0.0,0.0)
, mScaling (1.0,1.0)
, mRotation (0.0)
{
// nothing to be done here ...
}
@ -508,6 +509,14 @@ enum aiPropertyTypeInfo
*/
aiPTI_Float = 0x1,
/** Array of double-precision (64 Bit) floats
*
* It is possible to use aiGetMaterialInteger[Array]() (or the C++-API
* aiMaterial::Get()) to query properties stored in floating-point format.
* The material system performs the type conversion automatically.
*/
aiPTI_Double = 0x2,
/** The material property is an aiString.
*
* Arrays of strings aren't possible, aiGetMaterialString() (or the
@ -817,6 +826,12 @@ public:
unsigned int type = 0,
unsigned int index = 0);
aiReturn AddProperty (const double* pInput,
unsigned int pNumValues,
const char* pKey,
unsigned int type = 0,
unsigned int index = 0);
aiReturn AddProperty (const aiUVTransform* pInput,
unsigned int pNumValues,
const char* pKey,

View File

@ -201,6 +201,18 @@ inline aiReturn aiMaterial::AddProperty(const float* pInput,
pKey,type,index,aiPTI_Float);
}
// ---------------------------------------------------------------------------
inline aiReturn aiMaterial::AddProperty(const double* pInput,
const unsigned int pNumValues,
const char* pKey,
unsigned int type,
unsigned int index)
{
return AddBinaryProperty((const void*)pInput,
pNumValues * sizeof(float),
pKey,type,index,aiPTI_Double);
}
// ---------------------------------------------------------------------------
inline aiReturn aiMaterial::AddProperty(const aiUVTransform* pInput,
const unsigned int pNumValues,

View File

@ -47,6 +47,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define AI_MATRIX3X3_H_INC
#include "./Compiler/pushpack1.h"
#include "defs.h"
#ifdef __cplusplus
@ -166,14 +167,14 @@ public:
TReal c1, c2, c3;
} PACK_STRUCT;
typedef aiMatrix3x3t<float> aiMatrix3x3;
typedef aiMatrix3x3t<ai_real> aiMatrix3x3;
#else
struct aiMatrix3x3 {
float a1, a2, a3;
float b1, b2, b3;
float c1, c2, c3;
ai_real a1, a2, a3;
ai_real b1, b2, b3;
ai_real c1, c2, c3;
} PACK_STRUCT;
#endif // __cplusplus

View File

@ -47,6 +47,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "vector3.h"
#include "./Compiler/pushpack1.h"
#include "defs.h"
#ifdef __cplusplus
@ -229,15 +230,15 @@ public:
TReal d1, d2, d3, d4;
} PACK_STRUCT;
typedef aiMatrix4x4t<float> aiMatrix4x4;
typedef aiMatrix4x4t<ai_real> aiMatrix4x4;
#else
struct aiMatrix4x4 {
float a1, a2, a3, a4;
float b1, b2, b3, b4;
float c1, c2, c3, c4;
float d1, d2, d3, d4;
ai_real a1, a2, a3, a4;
ai_real b1, b2, b3, b4;
ai_real c1, c2, c3, c4;
ai_real d1, d2, d3, d4;
} PACK_STRUCT;

View File

@ -68,8 +68,9 @@ typedef enum aiMetadataType
AI_INT = 1,
AI_UINT64 = 2,
AI_FLOAT = 3,
AI_AISTRING = 4,
AI_AIVECTOR3D = 5,
AI_DOUBLE = 4,
AI_AISTRING = 5,
AI_AIVECTOR3D = 6,
#ifndef SWIG
FORCE_32BIT = INT_MAX
@ -108,6 +109,7 @@ inline aiMetadataType GetAiType( bool ) { return AI_BOOL; }
inline aiMetadataType GetAiType( int ) { return AI_INT; }
inline aiMetadataType GetAiType( uint64_t ) { return AI_UINT64; }
inline aiMetadataType GetAiType( float ) { return AI_FLOAT; }
inline aiMetadataType GetAiType( double ) { return AI_DOUBLE; }
inline aiMetadataType GetAiType( aiString ) { return AI_AISTRING; }
inline aiMetadataType GetAiType( aiVector3D ) { return AI_AIVECTOR3D; }
@ -172,6 +174,9 @@ struct aiMetadata
case AI_FLOAT:
delete static_cast<float*>(data);
break;
case AI_DOUBLE:
delete static_cast<double*>(data);
break;
case AI_AISTRING:
delete static_cast<aiString*>(data);
break;
@ -248,5 +253,3 @@ struct aiMetadata
};
#endif // AI_METADATA_H_INC

View File

@ -47,6 +47,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifdef __cplusplus
#include "defs.h"
template <typename TReal> class aiVector3t;
template <typename TReal> class aiMatrix3x3t;
@ -113,12 +115,12 @@ public:
TReal w, x, y, z;
} ;
typedef aiQuaterniont<float> aiQuaternion;
typedef aiQuaterniont<ai_real> aiQuaternion;
#else
struct aiQuaternion {
float w, x, y, z;
ai_real w, x, y, z;
};
#endif

View File

@ -124,7 +124,7 @@ struct aiPlane
{
#ifdef __cplusplus
aiPlane () : a(0.f), b(0.f), c(0.f), d(0.f) {}
aiPlane (float _a, float _b, float _c, float _d)
aiPlane (ai_real _a, ai_real _b, ai_real _c, ai_real _d)
: a(_a), b(_b), c(_c), d(_d) {}
aiPlane (const aiPlane& o) : a(o.a), b(o.b), c(o.c), d(o.d) {}
@ -132,7 +132,7 @@ struct aiPlane
#endif // !__cplusplus
//! Plane equation
float a,b,c,d;
ai_real a,b,c,d;
} PACK_STRUCT; // !struct aiPlane
// ----------------------------------------------------------------------------------
@ -160,8 +160,8 @@ struct aiColor3D
{
#ifdef __cplusplus
aiColor3D () : r(0.0f), g(0.0f), b(0.0f) {}
aiColor3D (float _r, float _g, float _b) : r(_r), g(_g), b(_b) {}
explicit aiColor3D (float _r) : r(_r), g(_r), b(_r) {}
aiColor3D (ai_real _r, ai_real _g, ai_real _b) : r(_r), g(_g), b(_b) {}
explicit aiColor3D (ai_real _r) : r(_r), g(_r), b(_r) {}
aiColor3D (const aiColor3D& o) : r(o.r), g(o.g), b(o.b) {}
/** Component-wise comparison */
@ -200,30 +200,30 @@ struct aiColor3D
}
/** Multiply with a scalar */
aiColor3D operator*(float f) const {
aiColor3D operator*(ai_real f) const {
return aiColor3D(r*f,g*f,b*f);
}
/** Access a specific color component */
float operator[](unsigned int i) const {
ai_real operator[](unsigned int i) const {
return *(&r + i);
}
/** Access a specific color component */
float& operator[](unsigned int i) {
ai_real& operator[](unsigned int i) {
return *(&r + i);
}
/** Check whether a color is black */
bool IsBlack() const {
static const float epsilon = 10e-3f;
static const ai_real epsilon = 10e-3;
return std::fabs( r ) < epsilon && std::fabs( g ) < epsilon && std::fabs( b ) < epsilon;
}
#endif // !__cplusplus
//! Red, green and blue color values
float r, g, b;
ai_real r, g, b;
} PACK_STRUCT; // !struct aiColor3D
#include "./Compiler/poppack1.h"

View File

@ -52,6 +52,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#endif
#include "./Compiler/pushpack1.h"
#include "defs.h"
// ----------------------------------------------------------------------------------
/** Represents a two-dimensional vector.
@ -99,12 +100,12 @@ public:
TReal x, y;
} PACK_STRUCT;
typedef aiVector2t<float> aiVector2D;
typedef aiVector2t<ai_real> aiVector2D;
#else
struct aiVector2D {
float x, y;
ai_real x, y;
};
#endif // __cplusplus

View File

@ -52,6 +52,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#endif
#include "./Compiler/pushpack1.h"
#include "defs.h"
#ifdef __cplusplus
@ -130,12 +131,12 @@ public:
} PACK_STRUCT;
typedef aiVector3t<float> aiVector3D;
typedef aiVector3t<ai_real> aiVector3D;
#else
struct aiVector3D {
float x, y, z;
ai_real x, y, z;
} PACK_STRUCT;
#endif // __cplusplus

View File

@ -58,6 +58,7 @@ SET( TEST_SRCS
unit/utBlendImportMaterials.cpp
unit/utColladaExportCamera.cpp
unit/utColladaExportLight.cpp
unit/utDefaultIOStream.cpp
unit/utFastAtof.cpp
unit/utFindDegenerates.cpp
unit/utFindInvalidData.cpp
@ -99,7 +100,7 @@ if(AddGTest_FOUND)
)
add_definitions(-DASSIMP_TEST_MODELS_DIR="${CMAKE_CURRENT_LIST_DIR}/models")
SET_PROPERTY( TARGET assimp PROPERTY DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX} )
add_dependencies( unit gtest )

View File

@ -0,0 +1,64 @@
/*-------------------------------------------------------------------------
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
Copyright (c) 2006-2016, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of the assimp team, nor the names of its
contributors may be used to endorse or promote products
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-------------------------------------------------------------------------*/
#include <gtest/gtest.h>
#include "DefaultIOStream.h"
using namespace ::Assimp;
class utDefaultIOStream : public ::testing::Test {
// empty
};
class TestDefaultIOStream : public DefaultIOStream {
public:
TestDefaultIOStream()
: DefaultIOStream() {
// empty
}
virtual ~TestDefaultIOStream() {
// empty
}
};
TEST_F( utDefaultIOStream, FileSizeTest ) {
TestDefaultIOStream myStream;
size_t size = myStream.FileSize();
EXPECT_EQ( size, 0 );
}

View File

@ -179,19 +179,10 @@ protected:
};
struct FastAtofWrapper {
float operator()(const char* str) { return Assimp::fast_atof(str); }
};
struct FastAtodWrapper {
double operator()(const char* str) { return Assimp::fast_atod(str); }
ai_real operator()(const char* str) { return Assimp::fast_atof(str); }
};
TEST_F(FastAtofTest, FastAtof)
{
RunTest<float>(FastAtofWrapper());
}
TEST_F(FastAtofTest, FastAtod)
{
RunTest<double>(FastAtodWrapper());
RunTest<ai_real>(FastAtofWrapper());
}

View File

@ -49,45 +49,45 @@ class utMatrix4x4Test : public ::testing::Test {
TEST_F( utMatrix4x4Test, badIndexOperatorTest ) {
aiMatrix4x4 m;
float *a0 = m[ 4 ];
ai_real *a0 = m[ 4 ];
EXPECT_EQ( NULL, a0 );
}
TEST_F( utMatrix4x4Test, indexOperatorTest ) {
aiMatrix4x4 m;
float *a0 = m[ 0 ];
EXPECT_FLOAT_EQ( 1.0f, *a0 );
float *a1 = a0+1;
EXPECT_FLOAT_EQ( 0.0f, *a1 );
float *a2 = a0 + 2;
EXPECT_FLOAT_EQ( 0.0f, *a2 );
float *a3 = a0 + 3;
EXPECT_FLOAT_EQ( 0.0f, *a3 );
ai_real *a0 = m[ 0 ];
EXPECT_FLOAT_EQ( 1.0, *a0 );
ai_real *a1 = a0+1;
EXPECT_FLOAT_EQ( 0.0, *a1 );
ai_real *a2 = a0 + 2;
EXPECT_FLOAT_EQ( 0.0, *a2 );
ai_real *a3 = a0 + 3;
EXPECT_FLOAT_EQ( 0.0, *a3 );
float *a4 = m[ 1 ];
EXPECT_FLOAT_EQ( 0.0f, *a4 );
float *a5 = a4 + 1;
EXPECT_FLOAT_EQ( 1.0f, *a5 );
float *a6 = a4 + 2;
EXPECT_FLOAT_EQ( 0.0f, *a6 );
float *a7 = a4 + 3;
EXPECT_FLOAT_EQ( 0.0f, *a7 );
ai_real *a4 = m[ 1 ];
EXPECT_FLOAT_EQ( 0.0, *a4 );
ai_real *a5 = a4 + 1;
EXPECT_FLOAT_EQ( 1.0, *a5 );
ai_real *a6 = a4 + 2;
EXPECT_FLOAT_EQ( 0.0, *a6 );
ai_real *a7 = a4 + 3;
EXPECT_FLOAT_EQ( 0.0, *a7 );
float *a8 = m[ 2 ];
EXPECT_FLOAT_EQ( 0.0f, *a8 );
float *a9 = a8 + 1;
EXPECT_FLOAT_EQ( 0.0f, *a9 );
float *a10 = a8 + 2;
EXPECT_FLOAT_EQ( 1.0f, *a10 );
float *a11 = a8 + 3;
EXPECT_FLOAT_EQ( 0.0f, *a11 );
ai_real *a8 = m[ 2 ];
EXPECT_FLOAT_EQ( 0.0, *a8 );
ai_real *a9 = a8 + 1;
EXPECT_FLOAT_EQ( 0.0, *a9 );
ai_real *a10 = a8 + 2;
EXPECT_FLOAT_EQ( 1.0, *a10 );
ai_real *a11 = a8 + 3;
EXPECT_FLOAT_EQ( 0.0, *a11 );
float *a12 = m[ 3 ];
EXPECT_FLOAT_EQ( 0.0f, *a12 );
float *a13 = a12 + 1;
EXPECT_FLOAT_EQ( 0.0f, *a13 );
float *a14 = a12 + 2;
EXPECT_FLOAT_EQ( 0.0f, *a14 );
float *a15 = a12 + 3;
EXPECT_FLOAT_EQ( 1.0f, *a15 );
}
ai_real *a12 = m[ 3 ];
EXPECT_FLOAT_EQ( 0.0, *a12 );
ai_real *a13 = a12 + 1;
EXPECT_FLOAT_EQ( 0.0, *a13 );
ai_real *a14 = a12 + 2;
EXPECT_FLOAT_EQ( 0.0, *a14 );
ai_real *a15 = a12 + 3;
EXPECT_FLOAT_EQ( 1.0, *a15 );
}

View File

@ -7,8 +7,8 @@ Copyright (c) 2006-2016, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
@ -25,16 +25,16 @@ conditions are met:
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
@ -44,7 +44,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "Main.h"
const char* AICMD_MSG_INFO_HELP_E =
const char* AICMD_MSG_INFO_HELP_E =
"assimp info <file> [-r]\n"
"\tPrint basic structure of a 3D model\n"
"\t-r,--raw: No postprocessing, do a raw import\n";
@ -150,11 +150,11 @@ void FindSpecialPoints(const aiScene* scene,const aiNode* root,aiVector3D specia
// -----------------------------------------------------------------------------------
void FindSpecialPoints(const aiScene* scene,aiVector3D special_points[3])
{
special_points[0] = aiVector3D(1e10f,1e10f,1e10f);
special_points[1] = aiVector3D(-1e10f,-1e10f,-1e10f);
special_points[0] = aiVector3D(1e10,1e10,1e10);
special_points[1] = aiVector3D(-1e10,-1e10,-1e10);
FindSpecialPoints(scene,scene->mRootNode,special_points);
special_points[2] = 0.5f*(special_points[0]+special_points[1]);
special_points[2] = (special_points[0]+special_points[1])*(ai_real)0.5;
}
// -----------------------------------------------------------------------------------
@ -181,7 +181,7 @@ std::string FindPTypes(const aiScene* scene)
}
// -----------------------------------------------------------------------------------
void PrintHierarchy(const aiNode* root, unsigned int maxnest, unsigned int maxline,
void PrintHierarchy(const aiNode* root, unsigned int maxnest, unsigned int maxline,
unsigned int cline, unsigned int cnest=0)
{
if (cline++ >= maxline || cnest >= maxnest) {
@ -245,7 +245,7 @@ int Assimp_Info (const char* const* params, unsigned int num)
globalImporter->GetMemoryRequirements(mem);
static const char* format_string =
static const char* format_string =
"Memory consumption: %i B\n"
"Nodes: %i\n"
"Maximum depth %i\n"
@ -349,4 +349,3 @@ int Assimp_Info (const char* const* params, unsigned int num)
printf("\n");
return 0;
}