Bugfix: made various internal structures namespace-local to avoid strange linker issues in case of name conflict
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@466 67173fc5-114c-0410-ac8e-9d2fd5bffc1fpull/1/head
parent
07428f37c7
commit
12070a1d52
|
@ -55,34 +55,38 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#endif
|
#endif
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
/** Stores the importer objects for all active import processes */
|
|
||||||
typedef std::map<const aiScene*, Assimp::Importer*> ImporterMap;
|
|
||||||
|
|
||||||
/** Stores the LogStream objects for all active C log streams */
|
namespace Assimp
|
||||||
struct mpred {
|
{
|
||||||
bool operator () (const aiLogStream& s0, const aiLogStream& s1) const {
|
/** Stores the importer objects for all active import processes */
|
||||||
return s0.callback<s1.callback&&s0.user<s1.user;
|
typedef std::map<const aiScene*, Assimp::Importer*> ImporterMap;
|
||||||
}
|
|
||||||
};
|
|
||||||
typedef std::map<aiLogStream, Assimp::LogStream*, mpred> LogStreamMap;
|
|
||||||
|
|
||||||
/** Stores the LogStream objects allocated by #aiGetPredefinedLogStream */
|
/** Stores the LogStream objects for all active C log streams */
|
||||||
typedef std::list<Assimp::LogStream*> PredefLogStreamMap;
|
struct mpred {
|
||||||
|
bool operator () (const aiLogStream& s0, const aiLogStream& s1) const {
|
||||||
|
return s0.callback<s1.callback&&s0.user<s1.user;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
typedef std::map<aiLogStream, Assimp::LogStream*, mpred> LogStreamMap;
|
||||||
|
|
||||||
/** Local storage of all active import processes */
|
/** Stores the LogStream objects allocated by #aiGetPredefinedLogStream */
|
||||||
static ImporterMap gActiveImports;
|
typedef std::list<Assimp::LogStream*> PredefLogStreamMap;
|
||||||
|
|
||||||
/** Local storage of all active log streams */
|
/** Local storage of all active import processes */
|
||||||
static LogStreamMap gActiveLogStreams;
|
static ImporterMap gActiveImports;
|
||||||
|
|
||||||
/** Local storage of LogStreams allocated by #aiGetPredefinedLogStream */
|
/** Local storage of all active log streams */
|
||||||
static PredefLogStreamMap gPredefinedStreams;
|
static LogStreamMap gActiveLogStreams;
|
||||||
|
|
||||||
/** Error message of the last failed import process */
|
/** Local storage of LogStreams allocated by #aiGetPredefinedLogStream */
|
||||||
static std::string gLastErrorString;
|
static PredefLogStreamMap gPredefinedStreams;
|
||||||
|
|
||||||
/** Verbose logging active or not? */
|
/** Error message of the last failed import process */
|
||||||
static aiBool gVerboseLogging = false;
|
static std::string gLastErrorString;
|
||||||
|
|
||||||
|
/** Verbose logging active or not? */
|
||||||
|
static aiBool gVerboseLogging = false;
|
||||||
|
}
|
||||||
|
|
||||||
/** Configuration properties */
|
/** Configuration properties */
|
||||||
static ImporterPimpl::IntPropertyMap gIntProperties;
|
static ImporterPimpl::IntPropertyMap gIntProperties;
|
||||||
|
|
|
@ -238,33 +238,31 @@ void BaseImporter::SetupProperties(const Importer* pImp)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Represents an import request
|
namespace Assimp
|
||||||
struct LoadRequest
|
|
||||||
{
|
{
|
||||||
LoadRequest(const std::string& _file, unsigned int _flags,const BatchLoader::PropertyMap* _map, unsigned int _id)
|
// Represents an import request
|
||||||
: file (_file)
|
struct LoadRequest
|
||||||
, flags (_flags)
|
|
||||||
, refCnt (1)
|
|
||||||
, scene (NULL)
|
|
||||||
, loaded (false)
|
|
||||||
, id (_id)
|
|
||||||
{
|
{
|
||||||
if (_map)
|
LoadRequest(const std::string& _file, unsigned int _flags,const BatchLoader::PropertyMap* _map, unsigned int _id)
|
||||||
map = *_map;
|
: file(_file), flags(_flags), refCnt(1),scene(NULL), loaded(false), id(_id)
|
||||||
}
|
{
|
||||||
|
if (_map)
|
||||||
|
map = *_map;
|
||||||
|
}
|
||||||
|
|
||||||
const std::string file;
|
const std::string file;
|
||||||
unsigned int flags;
|
unsigned int flags;
|
||||||
unsigned int refCnt;
|
unsigned int refCnt;
|
||||||
aiScene* scene;
|
aiScene* scene;
|
||||||
bool loaded;
|
bool loaded;
|
||||||
BatchLoader::PropertyMap map;
|
BatchLoader::PropertyMap map;
|
||||||
unsigned int id;
|
unsigned int id;
|
||||||
|
|
||||||
bool operator== (const std::string& f) {
|
bool operator== (const std::string& f) {
|
||||||
return file == f;
|
return file == f;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// BatchLoader::pimpl data structure
|
// BatchLoader::pimpl data structure
|
||||||
|
|
|
@ -572,6 +572,23 @@ struct Animation
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** Description of a collada animation channel which has been determined to affect the current node */
|
||||||
|
struct ChannelEntry
|
||||||
|
{
|
||||||
|
const Collada::AnimationChannel* mChannel; ///> the source channel
|
||||||
|
std::string mTransformId; // the ID of the transformation step of the node which is influenced
|
||||||
|
size_t mTransformIndex; // Index into the node's transform chain to apply the channel to
|
||||||
|
size_t mSubElement; // starting index inside the transform data
|
||||||
|
|
||||||
|
// resolved data references
|
||||||
|
const Collada::Accessor* mTimeAccessor; ///> Collada accessor to the time values
|
||||||
|
const Collada::Data* mTimeData; ///> Source data array for the time values
|
||||||
|
const Collada::Accessor* mValueAccessor; ///> Collada accessor to the key value values
|
||||||
|
const Collada::Data* mValueData; ///> Source datat array for the key value values
|
||||||
|
|
||||||
|
ChannelEntry() { mChannel = NULL; mSubElement = 0; }
|
||||||
|
};
|
||||||
|
|
||||||
} // end of namespace Collada
|
} // end of namespace Collada
|
||||||
} // end of namespace Assimp
|
} // end of namespace Assimp
|
||||||
|
|
||||||
|
|
|
@ -796,23 +796,6 @@ void ColladaLoader::StoreAnimations( aiScene* pScene, const ColladaParser& pPars
|
||||||
CreateAnimation( pScene, pParser, pSrcAnim, animName);
|
CreateAnimation( pScene, pParser, pSrcAnim, animName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Description of a collada animation channel which has been determined to affect the current node */
|
|
||||||
struct ChannelEntry
|
|
||||||
{
|
|
||||||
const Collada::AnimationChannel* mChannel; ///> the source channel
|
|
||||||
std::string mTransformId; // the ID of the transformation step of the node which is influenced
|
|
||||||
size_t mTransformIndex; // Index into the node's transform chain to apply the channel to
|
|
||||||
size_t mSubElement; // starting index inside the transform data
|
|
||||||
|
|
||||||
// resolved data references
|
|
||||||
const Collada::Accessor* mTimeAccessor; ///> Collada accessor to the time values
|
|
||||||
const Collada::Data* mTimeData; ///> Source data array for the time values
|
|
||||||
const Collada::Accessor* mValueAccessor; ///> Collada accessor to the key value values
|
|
||||||
const Collada::Data* mValueData; ///> Source datat array for the key value values
|
|
||||||
|
|
||||||
ChannelEntry() { mChannel = NULL; mSubElement = 0; }
|
|
||||||
};
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Constructs the animation for the given source anim
|
// Constructs the animation for the given source anim
|
||||||
void ColladaLoader::CreateAnimation( aiScene* pScene, const ColladaParser& pParser, const Collada::Animation* pSrcAnim, const std::string& pName)
|
void ColladaLoader::CreateAnimation( aiScene* pScene, const ColladaParser& pParser, const Collada::Animation* pSrcAnim, const std::string& pName)
|
||||||
|
@ -825,7 +808,7 @@ void ColladaLoader::CreateAnimation( aiScene* pScene, const ColladaParser& pPars
|
||||||
for( std::vector<const aiNode*>::const_iterator nit = nodes.begin(); nit != nodes.end(); ++nit)
|
for( std::vector<const aiNode*>::const_iterator nit = nodes.begin(); nit != nodes.end(); ++nit)
|
||||||
{
|
{
|
||||||
// find all the collada anim channels which refer to the current node
|
// find all the collada anim channels which refer to the current node
|
||||||
std::vector<ChannelEntry> entries;
|
std::vector<Collada::ChannelEntry> entries;
|
||||||
std::string nodeName = (*nit)->mName.data;
|
std::string nodeName = (*nit)->mName.data;
|
||||||
|
|
||||||
// find the collada node corresponding to the aiNode
|
// find the collada node corresponding to the aiNode
|
||||||
|
@ -839,7 +822,7 @@ void ColladaLoader::CreateAnimation( aiScene* pScene, const ColladaParser& pPars
|
||||||
cit != pSrcAnim->mChannels.end(); ++cit)
|
cit != pSrcAnim->mChannels.end(); ++cit)
|
||||||
{
|
{
|
||||||
const Collada::AnimationChannel& srcChannel = *cit;
|
const Collada::AnimationChannel& srcChannel = *cit;
|
||||||
ChannelEntry entry;
|
Collada::ChannelEntry entry;
|
||||||
|
|
||||||
// we except the animation target to be of type "nodeName/transformID.subElement". Ignore all others
|
// we except the animation target to be of type "nodeName/transformID.subElement". Ignore all others
|
||||||
// find the slash that separates the node name - there should be only one
|
// find the slash that separates the node name - there should be only one
|
||||||
|
@ -897,9 +880,9 @@ void ColladaLoader::CreateAnimation( aiScene* pScene, const ColladaParser& pPars
|
||||||
|
|
||||||
// resolve the data pointers for all anim channels. Find the minimum time while we're at it
|
// resolve the data pointers for all anim channels. Find the minimum time while we're at it
|
||||||
float startTime = 1e20f, endTime = -1e20f;
|
float startTime = 1e20f, endTime = -1e20f;
|
||||||
for( std::vector<ChannelEntry>::iterator it = entries.begin(); it != entries.end(); ++it)
|
for( std::vector<Collada::ChannelEntry>::iterator it = entries.begin(); it != entries.end(); ++it)
|
||||||
{
|
{
|
||||||
ChannelEntry& e = *it;
|
Collada::ChannelEntry& e = *it;
|
||||||
e.mTimeAccessor = &pParser.ResolveLibraryReference( pParser.mAccessorLibrary, e.mChannel->mSourceTimes);
|
e.mTimeAccessor = &pParser.ResolveLibraryReference( pParser.mAccessorLibrary, e.mChannel->mSourceTimes);
|
||||||
e.mTimeData = &pParser.ResolveLibraryReference( pParser.mDataLibrary, e.mTimeAccessor->mSource);
|
e.mTimeData = &pParser.ResolveLibraryReference( pParser.mDataLibrary, e.mTimeAccessor->mSource);
|
||||||
e.mValueAccessor = &pParser.ResolveLibraryReference( pParser.mAccessorLibrary, e.mChannel->mSourceValues);
|
e.mValueAccessor = &pParser.ResolveLibraryReference( pParser.mAccessorLibrary, e.mChannel->mSourceValues);
|
||||||
|
@ -923,9 +906,9 @@ void ColladaLoader::CreateAnimation( aiScene* pScene, const ColladaParser& pPars
|
||||||
std::vector<aiMatrix4x4> resultTrafos;
|
std::vector<aiMatrix4x4> resultTrafos;
|
||||||
while( 1)
|
while( 1)
|
||||||
{
|
{
|
||||||
for( std::vector<ChannelEntry>::iterator it = entries.begin(); it != entries.end(); ++it)
|
for( std::vector<Collada::ChannelEntry>::iterator it = entries.begin(); it != entries.end(); ++it)
|
||||||
{
|
{
|
||||||
ChannelEntry& e = *it;
|
Collada::ChannelEntry& e = *it;
|
||||||
|
|
||||||
// find the keyframe behind the current point in time
|
// find the keyframe behind the current point in time
|
||||||
size_t pos = 0;
|
size_t pos = 0;
|
||||||
|
@ -973,9 +956,9 @@ void ColladaLoader::CreateAnimation( aiScene* pScene, const ColladaParser& pPars
|
||||||
|
|
||||||
// find next point in time to evaluate. That's the closest frame larger than the current in any channel
|
// find next point in time to evaluate. That's the closest frame larger than the current in any channel
|
||||||
float nextTime = 1e20f;
|
float nextTime = 1e20f;
|
||||||
for( std::vector<ChannelEntry>::iterator it = entries.begin(); it != entries.end(); ++it)
|
for( std::vector<Collada::ChannelEntry>::iterator it = entries.begin(); it != entries.end(); ++it)
|
||||||
{
|
{
|
||||||
ChannelEntry& e = *it;
|
Collada::ChannelEntry& e = *it;
|
||||||
|
|
||||||
// find the next time value larger than the current
|
// find the next time value larger than the current
|
||||||
size_t pos = 0;
|
size_t pos = 0;
|
||||||
|
|
|
@ -51,15 +51,18 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
using namespace Assimp;
|
using namespace Assimp;
|
||||||
|
|
||||||
// Data structure to keep a vertex in an interlaced format
|
namespace Assimp
|
||||||
struct Vertex
|
|
||||||
{
|
{
|
||||||
aiVector3D mPosition;
|
// Data structure to keep a vertex in an interlaced format
|
||||||
aiVector3D mNormal;
|
struct Vertex
|
||||||
aiVector3D mTangent, mBitangent;
|
{
|
||||||
aiColor4D mColors [AI_MAX_NUMBER_OF_COLOR_SETS];
|
aiVector3D mPosition;
|
||||||
aiVector3D mTexCoords [AI_MAX_NUMBER_OF_TEXTURECOORDS];
|
aiVector3D mNormal;
|
||||||
};
|
aiVector3D mTangent, mBitangent;
|
||||||
|
aiColor4D mColors [AI_MAX_NUMBER_OF_COLOR_SETS];
|
||||||
|
aiVector3D mTexCoords [AI_MAX_NUMBER_OF_TEXTURECOORDS];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Constructor to be privately used by Importer
|
// Constructor to be privately used by Importer
|
||||||
|
@ -97,15 +100,16 @@ void JoinVerticesProcess::Execute( aiScene* pScene)
|
||||||
|
|
||||||
// execute the step
|
// execute the step
|
||||||
int iNumVertices = 0;
|
int iNumVertices = 0;
|
||||||
for( unsigned int a = 0; a < pScene->mNumMeshes; a++) {
|
for( unsigned int a = 0; a < pScene->mNumMeshes; a++)
|
||||||
iNumVertices += ProcessMesh( pScene->mMeshes[a],a);
|
iNumVertices += ProcessMesh( pScene->mMeshes[a],a);
|
||||||
}
|
|
||||||
|
|
||||||
// if logging is active, print detailed statistics
|
// if logging is active, print detailed statistics
|
||||||
if (!DefaultLogger::isNullLogger())
|
if (!DefaultLogger::isNullLogger())
|
||||||
{
|
{
|
||||||
if (iNumOldVertices == iNumVertices)DefaultLogger::get()->debug("JoinVerticesProcess finished ");
|
if (iNumOldVertices == iNumVertices)
|
||||||
else
|
{
|
||||||
|
DefaultLogger::get()->debug("JoinVerticesProcess finished ");
|
||||||
|
} else
|
||||||
{
|
{
|
||||||
char szBuff[128]; // should be sufficiently large in every case
|
char szBuff[128]; // should be sufficiently large in every case
|
||||||
sprintf(szBuff,"JoinVerticesProcess finished | Verts in: %i out: %i | ~%.1f%%",
|
sprintf(szBuff,"JoinVerticesProcess finished | Verts in: %i out: %i | ~%.1f%%",
|
||||||
|
@ -413,4 +417,4 @@ int JoinVerticesProcess::ProcessMesh( aiMesh* pMesh, unsigned int meshIndex)
|
||||||
return pMesh->mNumVertices;
|
return pMesh->mNumVertices;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // !! ASSIMP_BUILD_NO_JOINVERTICES_PROCESS
|
#endif // !! ASSIMP_BUILD_NO_JOINVERTICES_PROCESS
|
||||||
|
|
|
@ -47,11 +47,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "../include/aiTypes.h"
|
#include "../include/aiTypes.h"
|
||||||
|
|
||||||
struct aiMesh;
|
struct aiMesh;
|
||||||
class JoinVerticesTest;
|
|
||||||
|
|
||||||
namespace Assimp
|
namespace Assimp
|
||||||
{
|
{
|
||||||
|
|
||||||
|
class JoinVerticesTest;
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
/** The JoinVerticesProcess unites identical vertices in all imported meshes.
|
/** The JoinVerticesProcess unites identical vertices in all imported meshes.
|
||||||
* By default the importer returns meshes where each face addressed its own
|
* By default the importer returns meshes where each face addressed its own
|
||||||
|
@ -63,7 +64,7 @@ namespace Assimp
|
||||||
class ASSIMP_API JoinVerticesProcess : public BaseProcess
|
class ASSIMP_API JoinVerticesProcess : public BaseProcess
|
||||||
{
|
{
|
||||||
friend class Importer;
|
friend class Importer;
|
||||||
friend class ::JoinVerticesTest;
|
friend class JoinVerticesTest;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/** Constructor to be privately used by Importer */
|
/** Constructor to be privately used by Importer */
|
||||||
|
|
Loading…
Reference in New Issue