Merge branch 'master' of https://github.com/assimp/assimp into implementation_warning_fix

# Conflicts:
#	code/ObjFileImporter.cpp
pull/1083/head
Jared Mulconry 2016-11-27 13:00:33 +11:00
commit 98e7eb476d
16 changed files with 267 additions and 99 deletions

View File

@ -150,7 +150,7 @@ void ReportSceneNotFoundError()
DefaultLogger::get()->error("Unable to find the Assimp::Importer for this aiScene. " DefaultLogger::get()->error("Unable to find the Assimp::Importer for this aiScene. "
"The C-API does not accept scenes produced by the C++ API and vice versa"); "The C-API does not accept scenes produced by the C++ API and vice versa");
assert(false); ai_assert(false);
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------

View File

@ -59,7 +59,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <memory> #include <memory>
using namespace Assimp; using namespace Assimp;
using namespace Assimp::Collada; using namespace Assimp::Collada;
using namespace Assimp::Formatter; using namespace Assimp::Formatter;

View File

@ -268,8 +268,7 @@ namespace Assimp
Collada::InputType GetTypeForSemantic( const std::string& pSemantic); Collada::InputType GetTypeForSemantic( const std::string& pSemantic);
/** Finds the item in the given library by its reference, throws if not found */ /** Finds the item in the given library by its reference, throws if not found */
template <typename Type> const Type& ResolveLibraryReference( template <typename Type> const Type& ResolveLibraryReference( const std::map<std::string, Type>& pLibrary, const std::string& pURL) const;
const std::map<std::string, Type>& pLibrary, const std::string& pURL) const;
protected: protected:
/** Filename, for a verbose error message */ /** Filename, for a verbose error message */

View File

@ -602,28 +602,28 @@ bool ExportProperties :: HasPropertyInteger(const char* szName) const
bool ExportProperties :: HasPropertyBool(const char* szName) const bool ExportProperties :: HasPropertyBool(const char* szName) const
{ {
return HasGenericProperty<int>(mIntProperties, szName); return HasGenericProperty<int>(mIntProperties, szName);
}; }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Has a configuration property // Has a configuration property
bool ExportProperties :: HasPropertyFloat(const char* szName) const bool ExportProperties :: HasPropertyFloat(const char* szName) const
{ {
return HasGenericProperty<ai_real>(mFloatProperties, szName); return HasGenericProperty<ai_real>(mFloatProperties, szName);
}; }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Has a configuration property // Has a configuration property
bool ExportProperties :: HasPropertyString(const char* szName) const bool ExportProperties :: HasPropertyString(const char* szName) const
{ {
return HasGenericProperty<std::string>(mStringProperties, szName); return HasGenericProperty<std::string>(mStringProperties, szName);
}; }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Has a configuration property // Has a configuration property
bool ExportProperties :: HasPropertyMatrix(const char* szName) const bool ExportProperties :: HasPropertyMatrix(const char* szName) const
{ {
return HasGenericProperty<aiMatrix4x4>(mMatrixProperties, szName); return HasGenericProperty<aiMatrix4x4>(mMatrixProperties, szName);
}; }
#endif // !ASSIMP_BUILD_NO_EXPORT #endif // !ASSIMP_BUILD_NO_EXPORT

View File

@ -62,7 +62,6 @@ namespace Assimp
class ASSIMP_API JoinVerticesProcess : public BaseProcess class ASSIMP_API JoinVerticesProcess : public BaseProcess
{ {
public: public:
JoinVerticesProcess(); JoinVerticesProcess();
~JoinVerticesProcess(); ~JoinVerticesProcess();

View File

@ -149,10 +149,10 @@ void ObjFileImporter::InternReadFile( const std::string &file, aiScene* pScene,
// This next stage takes ~ 1/3th of the total readFile task // This next stage takes ~ 1/3th of the total readFile task
// so should amount for 1/3th of the progress // so should amount for 1/3th of the progress
// only update every 100KB or it'll be too slow // only update every 100KB or it'll be too slow
unsigned int progress = 0; /*unsigned int progress = 0;
unsigned int progressCounter = 0; unsigned int progressCounter = 0;
const unsigned int updateProgressEveryBytes = 100 * 1024; const unsigned int updateProgressEveryBytes = 100 * 1024;
const unsigned int progressTotal = static_cast<unsigned int>(3*m_Buffer.size()/updateProgressEveryBytes); const unsigned int progressTotal = static_cast<unsigned int>(3*m_Buffer.size()/updateProgressEveryBytes);*/
// process all '\' // process all '\'
/*std::vector<char> ::iterator iter = m_Buffer.begin(); /*std::vector<char> ::iterator iter = m_Buffer.begin();
while (iter != m_Buffer.end()) while (iter != m_Buffer.end())
@ -600,9 +600,6 @@ void ObjFileImporter::createMaterials(const ObjFile::Model* pModel, aiScene* pSc
mat->AddProperty<int>( &sm, 1, AI_MATKEY_SHADING_MODEL); mat->AddProperty<int>( &sm, 1, AI_MATKEY_SHADING_MODEL);
// multiplying the specular exponent with 2 seems to yield better results
pCurrentMaterial->shineness *= 4.f;
// Adding material colors // Adding material colors
mat->AddProperty( &pCurrentMaterial->ambient, 1, AI_MATKEY_COLOR_AMBIENT ); mat->AddProperty( &pCurrentMaterial->ambient, 1, AI_MATKEY_COLOR_AMBIENT );
mat->AddProperty( &pCurrentMaterial->diffuse, 1, AI_MATKEY_COLOR_DIFFUSE ); mat->AddProperty( &pCurrentMaterial->diffuse, 1, AI_MATKEY_COLOR_DIFFUSE );

View File

@ -102,7 +102,7 @@ ObjFile::Model *ObjFileParser::GetModel() const {
// File parsing method. // File parsing method.
void ObjFileParser::parseFile( IOStreamBuffer<char> &streamBuffer ) { void ObjFileParser::parseFile( IOStreamBuffer<char> &streamBuffer ) {
// only update every 100KB or it'll be too slow // only update every 100KB or it'll be too slow
const unsigned int updateProgressEveryBytes = 100 * 1024; //const unsigned int updateProgressEveryBytes = 100 * 1024;
unsigned int progressCounter = 0; unsigned int progressCounter = 0;
const unsigned int bytesToProcess = static_cast<unsigned int>(streamBuffer.size()); const unsigned int bytesToProcess = static_cast<unsigned int>(streamBuffer.size());
const unsigned int progressTotal = 3 * bytesToProcess; const unsigned int progressTotal = 3 * bytesToProcess;

View File

@ -197,13 +197,15 @@ static aiString ReadString(StreamReaderLE* stream, uint32_t numWChars)
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Constructor to be privately used by Importer // Constructor to be privately used by Importer
SIBImporter::SIBImporter() SIBImporter::SIBImporter() {
{} // empty
}
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Destructor, private as well // Destructor, private as well
SIBImporter::~SIBImporter() SIBImporter::~SIBImporter() {
{} // empty
}
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// Returns whether the class can handle the format of the given file. // Returns whether the class can handle the format of the given file.
@ -508,7 +510,7 @@ struct TempMesh
std::vector<aiVector3D> vtx; std::vector<aiVector3D> vtx;
std::vector<aiVector3D> nrm; std::vector<aiVector3D> nrm;
std::vector<aiVector3D> uv; std::vector<aiVector3D> uv;
std::vector<aiFace> faces; std::vector<aiFace> faces;
}; };
static void ReadShape(SIB* sib, StreamReaderLE* stream) static void ReadShape(SIB* sib, StreamReaderLE* stream)
@ -546,7 +548,7 @@ static void ReadShape(SIB* sib, StreamReaderLE* stream)
stream->SetReadLimit(oldLimit); stream->SetReadLimit(oldLimit);
} }
assert(smesh.faceStart.size() == smesh.mtls.size()); // sanity check ai_assert(smesh.faceStart.size() == smesh.mtls.size()); // sanity check
// Silo doesn't store any normals in the file - we need to compute // Silo doesn't store any normals in the file - we need to compute
// them ourselves. We can't let AssImp handle it as AssImp doesn't // them ourselves. We can't let AssImp handle it as AssImp doesn't
@ -792,8 +794,9 @@ static void ReadInstance(SIB* sib, StreamReaderLE* stream)
stream->SetReadLimit(oldLimit); stream->SetReadLimit(oldLimit);
} }
if (shapeIndex >= sib->objs.size()) if ( shapeIndex >= sib->objs.size() ) {
throw DeadlyImportError("SIB: Invalid shape index."); throw DeadlyImportError( "SIB: Invalid shape index." );
}
const SIBObject& src = sib->objs[shapeIndex]; const SIBObject& src = sib->objs[shapeIndex];
inst.meshIdx = src.meshIdx; inst.meshIdx = src.meshIdx;
@ -805,8 +808,9 @@ static void ReadInstance(SIB* sib, StreamReaderLE* stream)
static void CheckVersion(StreamReaderLE* stream) static void CheckVersion(StreamReaderLE* stream)
{ {
uint32_t version = stream->GetU4(); uint32_t version = stream->GetU4();
if (version != 1) if ( version != 1 ) {
throw DeadlyImportError("SIB: Unsupported file version."); throw DeadlyImportError( "SIB: Unsupported file version." );
}
} }
static void ReadScene(SIB* sib, StreamReaderLE* stream) static void ReadScene(SIB* sib, StreamReaderLE* stream)

View File

@ -53,15 +53,13 @@ namespace Assimp {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
/** Importer class for the Nevercenter Silo SIB scene format /** Importer class for the Nevercenter Silo SIB scene format
*/ */
class SIBImporter : public BaseImporter class ASSIMP_API SIBImporter : public BaseImporter
{ {
public: public:
SIBImporter(); SIBImporter();
~SIBImporter(); ~SIBImporter();
public: public:
// ------------------------------------------------------------------- // -------------------------------------------------------------------
/** Returns whether the class can handle the format of the given file. /** Returns whether the class can handle the format of the given file.
* See BaseImporter::CanRead() for details. * See BaseImporter::CanRead() for details.
@ -70,7 +68,6 @@ public:
bool checkSig) const; bool checkSig) const;
protected: protected:
// ------------------------------------------------------------------- // -------------------------------------------------------------------
/** Return importer meta information. /** Return importer meta information.
* See #BaseImporter::GetInfo for the details * See #BaseImporter::GetInfo for the details
@ -85,7 +82,6 @@ protected:
IOSystem* pIOHandler); IOSystem* pIOHandler);
private: private:
struct MeshInformation struct MeshInformation
{ {
explicit MeshInformation(const std::string& _name) explicit MeshInformation(const std::string& _name)

View File

@ -57,9 +57,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* - dump all polygons and their triangulation sequences to * - dump all polygons and their triangulation sequences to
* a file * a file
*/ */
#ifndef ASSIMP_BUILD_NO_TRIANGULATE_PROCESS #ifndef ASSIMP_BUILD_NO_TRIANGULATE_PROCESS
#include "TriangulateProcess.h" #include "TriangulateProcess.h"
#include "ProcessHelper.h" #include "ProcessHelper.h"
@ -106,11 +103,15 @@ void TriangulateProcess::Execute( aiScene* pScene)
bool bHas = false; bool bHas = false;
for( unsigned int a = 0; a < pScene->mNumMeshes; a++) for( unsigned int a = 0; a < pScene->mNumMeshes; a++)
{ {
if( TriangulateMesh( pScene->mMeshes[a])) if ( TriangulateMesh( pScene->mMeshes[ a ] ) ) {
bHas = true; bHas = true;
}
}
if ( bHas ) {
DefaultLogger::get()->info( "TriangulateProcess finished. All polygons have been triangulated." );
} else {
DefaultLogger::get()->debug( "TriangulateProcess finished. There was nothing to be done." );
} }
if (bHas)DefaultLogger::get()->info ("TriangulateProcess finished. All polygons have been triangulated.");
else DefaultLogger::get()->debug("TriangulateProcess finished. There was nothing to be done.");
} }
@ -155,7 +156,7 @@ bool TriangulateProcess::TriangulateMesh( aiMesh* pMesh)
} }
// Just another check whether aiMesh::mPrimitiveTypes is correct // Just another check whether aiMesh::mPrimitiveTypes is correct
assert(numOut != pMesh->mNumFaces); ai_assert(numOut != pMesh->mNumFaces);
aiVector3D* nor_out = NULL; aiVector3D* nor_out = NULL;
@ -184,7 +185,6 @@ bool TriangulateProcess::TriangulateMesh( aiMesh* pMesh)
aiColor4D* clr = pMesh->mColors[0]; aiColor4D* clr = pMesh->mColors[0];
#endif #endif
#ifdef AI_BUILD_TRIANGULATE_DEBUG_POLYS #ifdef AI_BUILD_TRIANGULATE_DEBUG_POLYS
FILE* fout = fopen(POLY_OUTPUT_FILE,"a"); FILE* fout = fopen(POLY_OUTPUT_FILE,"a");
#endif #endif
@ -276,7 +276,7 @@ bool TriangulateProcess::TriangulateMesh( aiMesh* pMesh)
{ {
// A polygon with more than 3 vertices can be either concave or convex. // A polygon with more than 3 vertices can be either concave or convex.
// Usually everything we're getting is convex and we could easily // Usually everything we're getting is convex and we could easily
// triangulate by trifanning. However, LightWave is probably the only // triangulate by tri-fanning. However, LightWave is probably the only
// modeling suite to make extensive use of highly concave, monster polygons ... // modeling suite to make extensive use of highly concave, monster polygons ...
// so we need to apply the full 'ear cutting' algorithm to get it right. // so we need to apply the full 'ear cutting' algorithm to get it right.
@ -325,7 +325,6 @@ bool TriangulateProcess::TriangulateMesh( aiMesh* pMesh)
done[tmp] = false; done[tmp] = false;
} }
#ifdef AI_BUILD_TRIANGULATE_DEBUG_POLYS #ifdef AI_BUILD_TRIANGULATE_DEBUG_POLYS
// plot the plane onto which we mapped the polygon to a 2D ASCII pic // plot the plane onto which we mapped the polygon to a 2D ASCII pic
aiVector2D bmin,bmax; aiVector2D bmin,bmax;
@ -404,14 +403,13 @@ bool TriangulateProcess::TriangulateMesh( aiMesh* pMesh)
if (num_found == 2) { if (num_found == 2) {
// Due to the 'two ear theorem', every simple polygon with more than three points must // Due to the 'two ear theorem', every simple polygon with more than three points must
// have 2 'ears'. Here's definitely someting wrong ... but we don't give up yet. // have 2 'ears'. Here's definitely something wrong ... but we don't give up yet.
// //
// Instead we're continuting with the standard trifanning algorithm which we'd // Instead we're continuing with the standard tri-fanning algorithm which we'd
// use if we had only convex polygons. That's life. // use if we had only convex polygons. That's life.
DefaultLogger::get()->error("Failed to triangulate polygon (no ear found). Probably not a simple polygon?"); DefaultLogger::get()->error("Failed to triangulate polygon (no ear found). Probably not a simple polygon?");
#ifdef AI_BUILD_TRIANGULATE_DEBUG_POLYS #ifdef AI_BUILD_TRIANGULATE_DEBUG_POLYS
fprintf(fout,"critical error here, no ear found! "); fprintf(fout,"critical error here, no ear found! ");
#endif #endif

View File

@ -158,7 +158,7 @@ string tstr;
AttrHelper_FloatToString(pValue, tstr); AttrHelper_FloatToString(pValue, tstr);
pList.push_back({pName, tstr}); pList.push_back({pName, tstr});
}; }
void X3DExporter::NodeHelper_OpenNode(const string& pNodeName, const size_t pTabLevel, const bool pEmptyElement, const list<SAttribute>& pAttrList) void X3DExporter::NodeHelper_OpenNode(const string& pNodeName, const size_t pTabLevel, const bool pEmptyElement, const list<SAttribute>& pAttrList)
{ {

View File

@ -39,16 +39,17 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
*/ */
/** @file anim.h /**
* @brief Defines the data structures in which the imported animations * @file anim.h
* are returned. * @brief Defines the data structures in which the imported animations
*/ * are returned.
*/
#pragma once #pragma once
#ifndef AI_ANIM_H_INC #ifndef AI_ANIM_H_INC
#define AI_ANIM_H_INC #define AI_ANIM_H_INC
#include "types.h" #include <assimp/types.h>
#include "quaternion.h" #include <assimp/quaternion.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@ -66,16 +67,20 @@ struct aiVectorKey
#ifdef __cplusplus #ifdef __cplusplus
//! Default constructor /// @brief The default constructor.
aiVectorKey(){} aiVectorKey()
: mTime( 0.0 )
, mValue() {
// empty
}
/// @brief Construction from a given time and key value.
//! Construction from a given time and key value
aiVectorKey(double time, const aiVector3D& value) aiVectorKey(double time, const aiVector3D& value)
: mTime (time) : mTime (time)
, mValue (value) , mValue (value)
{} {}
typedef aiVector3D elem_type; typedef aiVector3D elem_type;
// Comparison operators. For use with std::find(); // Comparison operators. For use with std::find();
@ -93,7 +98,7 @@ struct aiVectorKey
bool operator > (const aiVectorKey& o) const { bool operator > (const aiVectorKey& o) const {
return mTime > o.mTime; return mTime > o.mTime;
} }
#endif #endif // __cplusplus
}; };
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@ -108,7 +113,10 @@ struct aiQuatKey
C_STRUCT aiQuaternion mValue; C_STRUCT aiQuaternion mValue;
#ifdef __cplusplus #ifdef __cplusplus
aiQuatKey(){ aiQuatKey()
: mTime( 0.0 )
, mValue() {
// empty
} }
/** Construction from a given time and key value */ /** Construction from a given time and key value */
@ -145,7 +153,7 @@ struct aiMeshKey
double mTime; double mTime;
/** Index into the aiMesh::mAnimMeshes array of the /** Index into the aiMesh::mAnimMeshes array of the
* mesh coresponding to the #aiMeshAnim hosting this * mesh corresponding to the #aiMeshAnim hosting this
* key frame. The referenced anim mesh is evaluated * key frame. The referenced anim mesh is evaluated
* according to the rules defined in the docs for #aiAnimMesh.*/ * according to the rules defined in the docs for #aiAnimMesh.*/
unsigned int mValue; unsigned int mValue;
@ -204,8 +212,6 @@ enum aiAnimBehaviour
* time is t, use the value at (t-n) % (|m-n|).*/ * time is t, use the value at (t-n) % (|m-n|).*/
aiAnimBehaviour_REPEAT = 0x3, aiAnimBehaviour_REPEAT = 0x3,
/** This value is not used, it is just here to force the /** This value is not used, it is just here to force the
* the compiler to map this enum to a 32 Bit integer */ * the compiler to map this enum to a 32 Bit integer */
#ifndef SWIG #ifndef SWIG
@ -228,8 +234,7 @@ enum aiAnimBehaviour
* Duplicate keys don't pass the validation step. Most likely there * Duplicate keys don't pass the validation step. Most likely there
* will be no negative time values, but they are not forbidden also ( so * will be no negative time values, but they are not forbidden also ( so
* implementations need to cope with them! ) */ * implementations need to cope with them! ) */
struct aiNodeAnim struct aiNodeAnim {
{
/** The name of the node affected by this animation. The node /** The name of the node affected by this animation. The node
* must exist and it must be unique.*/ * must exist and it must be unique.*/
C_STRUCT aiString mNodeName; C_STRUCT aiString mNodeName;
@ -280,17 +285,19 @@ struct aiNodeAnim
C_ENUM aiAnimBehaviour mPostState; C_ENUM aiAnimBehaviour mPostState;
#ifdef __cplusplus #ifdef __cplusplus
aiNodeAnim() aiNodeAnim()
{ : mNumPositionKeys( 0 )
mNumPositionKeys = 0; mPositionKeys = NULL; , mPositionKeys( NULL )
mNumRotationKeys = 0; mRotationKeys = NULL; , mNumRotationKeys( 0 )
mNumScalingKeys = 0; mScalingKeys = NULL; , mRotationKeys( NULL )
, mNumScalingKeys( 0 )
mPreState = mPostState = aiAnimBehaviour_DEFAULT; , mScalingKeys( NULL )
, mPreState( aiAnimBehaviour_DEFAULT )
, mPostState( aiAnimBehaviour_DEFAULT ) {
// empty
} }
~aiNodeAnim() ~aiNodeAnim() {
{
delete [] mPositionKeys; delete [] mPositionKeys;
delete [] mRotationKeys; delete [] mRotationKeys;
delete [] mScalingKeys; delete [] mScalingKeys;
@ -308,7 +315,7 @@ struct aiMeshAnim
{ {
/** Name of the mesh to be animated. An empty string is not allowed, /** Name of the mesh to be animated. An empty string is not allowed,
* animated meshes need to be named (not necessarily uniquely, * animated meshes need to be named (not necessarily uniquely,
* the name can basically serve as wildcard to select a group * the name can basically serve as wild-card to select a group
* of meshes with similar animation setup)*/ * of meshes with similar animation setup)*/
C_STRUCT aiString mName; C_STRUCT aiString mName;
@ -334,10 +341,9 @@ struct aiMeshAnim
}; };
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
/** An animation consists of keyframe data for a number of nodes. For /** An animation consists of key-frame data for a number of nodes. For
* each node affected by the animation a separate series of data is given.*/ * each node affected by the animation a separate series of data is given.*/
struct aiAnimation struct aiAnimation {
{
/** The name of the animation. If the modeling package this data was /** The name of the animation. If the modeling package this data was
* exported from does support only a single animation channel, this * exported from does support only a single animation channel, this
* name is usually empty (length is zero). */ * name is usually empty (length is zero). */
@ -368,48 +374,49 @@ struct aiAnimation
#ifdef __cplusplus #ifdef __cplusplus
aiAnimation() aiAnimation()
: mDuration(-1.) : mDuration(-1.)
, mTicksPerSecond() , mTicksPerSecond(0.)
, mNumChannels() , mNumChannels(0)
, mChannels() , mChannels(nullptr)
, mNumMeshChannels() , mNumMeshChannels(0)
, mMeshChannels() , mMeshChannels(nullptr) {
{ // empty
} }
~aiAnimation() ~aiAnimation() {
{
// DO NOT REMOVE THIS ADDITIONAL CHECK // DO NOT REMOVE THIS ADDITIONAL CHECK
if (mNumChannels && mChannels) { if ( mNumChannels && mChannels ) {
for( unsigned int a = 0; a < mNumChannels; a++) { for( unsigned int a = 0; a < mNumChannels; a++) {
delete mChannels[a]; delete mChannels[ a ];
} }
delete [] mChannels; delete [] mChannels;
} }
if (mNumMeshChannels && mMeshChannels) { if (mNumMeshChannels && mMeshChannels) {
for( unsigned int a = 0; a < mNumMeshChannels; a++) { for( unsigned int a = 0; a < mNumMeshChannels; a++) {
delete mMeshChannels[a]; delete mMeshChannels[a];
} }
delete [] mMeshChannels; delete [] mMeshChannels;
} }
} }
#endif // __cplusplus #endif // __cplusplus
}; };
#ifdef __cplusplus #ifdef __cplusplus
} }
/// @brief Some C++ utilities for inter- and extrapolation
// some C++ utilities for inter- and extrapolation
namespace Assimp { namespace Assimp {
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
/** @brief CPP-API: Utility class to simplify interpolations of various data types. /**
* * @brief CPP-API: Utility class to simplify interpolations of various data types.
* The type of interpolation is chosen automatically depending on the *
* types of the arguments. */ * The type of interpolation is chosen automatically depending on the
* types of the arguments.
*/
template <typename T> template <typename T>
struct Interpolator struct Interpolator
{ {
@ -445,7 +452,7 @@ struct Interpolator <unsigned int> {
}; // ! Interpolator <aiQuaternion> }; // ! Interpolator <aiQuaternion>
template <> template <>
struct Interpolator <aiVectorKey> { struct Interpolator<aiVectorKey> {
void operator () (aiVector3D& out,const aiVectorKey& a, void operator () (aiVector3D& out,const aiVectorKey& a,
const aiVectorKey& b, ai_real d) const const aiVectorKey& b, ai_real d) const
{ {
@ -455,7 +462,7 @@ struct Interpolator <aiVectorKey> {
}; // ! Interpolator <aiVectorKey> }; // ! Interpolator <aiVectorKey>
template <> template <>
struct Interpolator <aiQuatKey> { struct Interpolator<aiQuatKey> {
void operator () (aiQuaternion& out, const aiQuatKey& a, void operator () (aiQuaternion& out, const aiQuatKey& a,
const aiQuatKey& b, ai_real d) const const aiQuatKey& b, ai_real d) const
{ {
@ -465,7 +472,7 @@ struct Interpolator <aiQuatKey> {
}; // ! Interpolator <aiQuatKey> }; // ! Interpolator <aiQuatKey>
template <> template <>
struct Interpolator <aiMeshKey> { struct Interpolator<aiMeshKey> {
void operator () (unsigned int& out, const aiMeshKey& a, void operator () (unsigned int& out, const aiMeshKey& a,
const aiMeshKey& b, ai_real d) const const aiMeshKey& b, ai_real d) const
{ {
@ -475,9 +482,9 @@ struct Interpolator <aiMeshKey> {
}; // ! Interpolator <aiQuatKey> }; // ! Interpolator <aiQuatKey>
//! @endcond //! @endcond
} // ! end namespace Assimp } // ! end namespace Assimp
#endif // __cplusplus #endif // __cplusplus
#endif // AI_ANIM_H_INC #endif // AI_ANIM_H_INC

View File

@ -109,7 +109,8 @@ extern "C" {
/** Maximum dimension for strings, ASSIMP strings are zero terminated. */ /** Maximum dimension for strings, ASSIMP strings are zero terminated. */
#ifdef __cplusplus #ifdef __cplusplus
static const size_t MAXLEN = 1024; static
const size_t MAXLEN = 1024;
#else #else
# define MAXLEN 1024 # define MAXLEN 1024
#endif #endif

View File

@ -56,6 +56,7 @@ SOURCE_GROUP( unit FILES
SET( TEST_SRCS SET( TEST_SRCS
unit/TestIOSystem.h unit/TestIOSystem.h
unit/utAnim.cpp
unit/AssimpAPITest.cpp unit/AssimpAPITest.cpp
unit/utBatchLoader.cpp unit/utBatchLoader.cpp
unit/utBlenderIntermediate.cpp unit/utBlenderIntermediate.cpp
@ -82,6 +83,7 @@ SET( TEST_SRCS
unit/utMetadata.cpp unit/utMetadata.cpp
unit/SceneDiffer.h unit/SceneDiffer.h
unit/SceneDiffer.cpp unit/SceneDiffer.cpp
unit/utSIBImporter.cpp
unit/utObjImportExport.cpp unit/utObjImportExport.cpp
unit/utPretransformVertices.cpp unit/utPretransformVertices.cpp
unit/utRemoveComments.cpp unit/utRemoveComments.cpp

View File

@ -0,0 +1,107 @@
/*
---------------------------------------------------------------------------
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 "UnitTestPCH.h"
#include <assimp/anim.h>
using namespace Assimp;
class utAnim : public ::testing::Test {
// empty
};
TEST_F( utAnim, aiVectorKeyCreationTest ) {
aiVectorKey defaultConstTest;
EXPECT_DOUBLE_EQ( 0.0, defaultConstTest.mTime );
aiVector3D v( 1, 2, 3 );
aiVectorKey constrWithValuesTest( 1, v );
EXPECT_DOUBLE_EQ( 1.0, constrWithValuesTest.mTime );
EXPECT_EQ( v, constrWithValuesTest.mValue );
EXPECT_NE( defaultConstTest, constrWithValuesTest );
EXPECT_TRUE( defaultConstTest != constrWithValuesTest );
defaultConstTest.mTime = 1;
constrWithValuesTest.mTime = 2;
EXPECT_TRUE( defaultConstTest < constrWithValuesTest );
}
TEST_F( utAnim, aiQuatKeyTest ) {
aiQuatKey defaultConstrTest;
EXPECT_DOUBLE_EQ( 0.0, defaultConstrTest.mTime );
aiQuaternion q;
aiQuatKey constrWithValuesTest( 1.0, q );
EXPECT_DOUBLE_EQ( 1.0, constrWithValuesTest.mTime );
EXPECT_EQ( q, constrWithValuesTest.mValue );
}
TEST_F( utAnim, aiNodeAnimTest ) {
bool ok( true );
try {
aiNodeAnim myAnim;
EXPECT_EQ( aiAnimBehaviour_DEFAULT, myAnim.mPreState );
EXPECT_EQ( aiAnimBehaviour_DEFAULT, myAnim.mPostState );
} catch ( ... ) {
ok = false;
}
EXPECT_TRUE( ok );
}
TEST_F( utAnim, aiMeshAnimTest ) {
bool ok( true );
try {
aiMeshAnim myMeshAnim;
} catch ( ... ) {
ok = false;
}
EXPECT_TRUE( ok );
}
TEST_F( utAnim, aiAnimationTest ) {
bool ok( true );
try {
aiAnimation myAnimation;
} catch ( ... ) {
ok = false;
}
EXPECT_TRUE( ok );
}

View File

@ -0,0 +1,59 @@
/*
---------------------------------------------------------------------------
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 "UnitTestPCH.h"
#include "SIBImporter.h"
using namespace ::Assimp;
class utSIBImporter : public ::testing::Test {
// empty
};
TEST_F( utSIBImporter, createTest ) {
bool ok( true );
try {
SIBImporter myImporter;
} catch ( ... ) {
ok = false;
}
EXPECT_TRUE( ok );
}