Adding double precision import support for formats that can be exported
parent
fa1d6d8c55
commit
05a6ee6473
|
@ -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 )
|
||||
|
|
|
@ -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)
|
||||
{}
|
||||
};
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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));
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -825,8 +825,8 @@ bool PLY::PropertyInstance::ParseValue(
|
|||
|
||||
case EDT_Double:
|
||||
|
||||
float f;
|
||||
pCur = fast_atoreal_move<float>(pCur,f);
|
||||
double f;
|
||||
pCur = fast_atoreal_move<double>(pCur,f);
|
||||
out->fDouble = (double)f;
|
||||
break;
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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 */
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
@ -242,6 +257,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
#define AI_MATH_TWO_PI_F (AI_MATH_PI_F * 2.0f)
|
||||
#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)*(ai_real)0.0174532925)
|
||||
#define AI_RAD_TO_DEG(x) ((x)*(ai_real)57.2957795)
|
||||
|
||||
/* Support for big-endian builds */
|
||||
#if defined(__BYTE_ORDER__)
|
||||
# if (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
|
||||
|
@ -265,18 +284,4 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
*/
|
||||
#define AI_MAX_ALLOC(type) ((256U * 1024 * 1024) / sizeof(type))
|
||||
|
||||
#ifdef AI_DOUBLE_PRECISION
|
||||
typedef double ai_real;
|
||||
typedef signed long long int ai_int;
|
||||
/* Tiny macro to convert from radians to degrees and back */
|
||||
#define AI_DEG_TO_RAD(x) ((x)*0.0174532925)
|
||||
#define AI_RAD_TO_DEG(x) ((x)*57.2957795)
|
||||
#else
|
||||
typedef float ai_real;
|
||||
typedef signed int ai_int;
|
||||
/* 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)
|
||||
#endif // AI_SINGLEPRECISION
|
||||
|
||||
#endif // !! AI_DEFINES_H_INC
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue