FIX: AseLoader is no stateless and can thus be called repeatedly.

Shut up gcc in LWOMaterial.cpp by adding an assertion, not all enumeration values handled.

git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@625 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
pull/1/head
aramis_acg 2010-03-23 18:22:45 +00:00
parent c58dcee5b9
commit 63d6ca8669
3 changed files with 40 additions and 30 deletions

View File

@ -194,8 +194,9 @@ void ASEImporter::InternReadFile( const std::string& pFile,
// ------------------------------------------------------------------
// Copy all scene graph nodes - lights, cameras, dummies and meshes
// into one large array. FIXME: do this during parsing ...
// into one huge list.
//------------------------------------------------------------------
std::vector<BaseNode*> nodes;
nodes.reserve(mParser->m_vMeshes.size() +mParser->m_vLights.size()
+ mParser->m_vCameras.size() + mParser->m_vDummies.size());
@ -213,10 +214,10 @@ void ASEImporter::InternReadFile( const std::string& pFile,
end = mParser->m_vDummies.end();it != end; ++it)nodes.push_back(&(*it));
// build the final node graph
BuildNodes();
BuildNodes(nodes);
// build output animations
BuildAnimations();
BuildAnimations(nodes);
// build output cameras
BuildCameras();
@ -261,10 +262,10 @@ void ASEImporter::GenerateDefaultMaterial()
}
// ------------------------------------------------------------------------------------------------
void ASEImporter::BuildAnimations()
void ASEImporter::BuildAnimations(const std::vector<BaseNode*>& nodes)
{
// check whether we have at least one mesh which has animations
std::vector<ASE::BaseNode*>::iterator i = nodes.begin();
std::vector<ASE::BaseNode*>::const_iterator i = nodes.begin();
unsigned int iNum = 0;
for (;i != nodes.end();++i) {
@ -425,8 +426,7 @@ void ASEImporter::BuildLights()
pcScene->mNumLights = (unsigned int)mParser->m_vLights.size();
pcScene->mLights = new aiLight*[pcScene->mNumLights];
for (unsigned int i = 0; i < pcScene->mNumLights;++i)
{
for (unsigned int i = 0; i < pcScene->mNumLights;++i) {
aiLight* out = pcScene->mLights[i] = new aiLight();
ASE::Light& in = mParser->m_vLights[i];
@ -459,7 +459,7 @@ void ASEImporter::BuildLights()
}
// ------------------------------------------------------------------------------------------------
void ASEImporter::AddNodes(std::vector<BaseNode*>& nodes,
void ASEImporter::AddNodes(const std::vector<BaseNode*>& nodes,
aiNode* pcParent,const char* szName)
{
aiMatrix4x4 m;
@ -521,7 +521,7 @@ void ASEImporter::AddMeshes(const ASE::BaseNode* snode,aiNode* node)
// ------------------------------------------------------------------------------------------------
// Add child nodes to a given parent node
void ASEImporter::AddNodes (std::vector<BaseNode*>& nodes,
void ASEImporter::AddNodes (const std::vector<BaseNode*>& nodes,
aiNode* pcParent, const char* szName,
const aiMatrix4x4& mat)
{
@ -617,7 +617,7 @@ void ASEImporter::AddNodes (std::vector<BaseNode*>& nodes,
// ------------------------------------------------------------------------------------------------
// Build the output node graph
void ASEImporter::BuildNodes() {
void ASEImporter::BuildNodes(std::vector<BaseNode*>& nodes) {
ai_assert(NULL != pcScene);
// allocate the one and only root node
@ -1294,7 +1294,7 @@ bool ASEImporter::GenerateNormals(ASE::Mesh& mesh) {
}
}
}
// The array <EFBFBD>s reused
// The array is reused.
ComputeNormalsWithSmoothingsGroups<ASE::Face>(mesh);
return false;
}

View File

@ -53,15 +53,11 @@ struct aiNode;
namespace Assimp {
class MaterialHelper;
using namespace ASE;
// --------------------------------------------------------------------------------
/** Importer class for the 3DS ASE ASCII format
/** Importer class for the 3DS ASE ASCII format.
*
* fixme: consider code cleanup
*/
class ASEImporter : public BaseImporter
{
class ASEImporter : public BaseImporter {
friend class Importer;
protected:
@ -88,6 +84,7 @@ protected:
*/
void GetExtensionList(std::set<std::string>& extensions);
// -------------------------------------------------------------------
/** Imports the given file into the given scene structure.
* See BaseImporter::InternReadFile() for details
@ -95,6 +92,7 @@ protected:
void InternReadFile( const std::string& pFile, aiScene* pScene,
IOSystem* pIOHandler);
// -------------------------------------------------------------------
/** Called prior to ReadFile().
* The function is a request to the importer to update its configuration
@ -102,6 +100,9 @@ protected:
*/
void SetupProperties(const Importer* pImp);
private:
// -------------------------------------------------------------------
/** Generate normal vectors basing on smoothing groups
* (in some cases the normal are already contained in the file)
@ -110,6 +111,7 @@ protected:
*/
bool GenerateNormals(ASE::Mesh& mesh);
// -------------------------------------------------------------------
/** Create valid vertex/normal/UV/color/face lists.
* All elements are unique, faces have only one set of indices
@ -118,42 +120,50 @@ protected:
*/
void BuildUniqueRepresentation(ASE::Mesh& mesh);
/** Create one-material-per-mesh meshes ;-)
* \param mesh Mesh to work with
* \param Receives the list of all created meshes
*/
void ConvertMeshes(ASE::Mesh& mesh, std::vector<aiMesh*>& avOut);
// -------------------------------------------------------------------
/** Convert a material to a MaterialHelper object
* \param mat Input material
*/
void ConvertMaterial(ASE::Material& mat);
// -------------------------------------------------------------------
/** Setup the final material indices for each mesh
*/
void BuildMaterialIndices();
// -------------------------------------------------------------------
/** Build the node graph
*/
void BuildNodes();
void BuildNodes(std::vector<ASE::BaseNode*>& nodes);
// -------------------------------------------------------------------
/** Build output cameras
*/
void BuildCameras();
// -------------------------------------------------------------------
/** Build output lights
*/
void BuildLights();
// -------------------------------------------------------------------
/** Build output animations
*/
void BuildAnimations();
void BuildAnimations(const std::vector<ASE::BaseNode*>& nodes);
// -------------------------------------------------------------------
/** Add sub nodes to a node
@ -161,10 +171,10 @@ protected:
* \param szName Name of the parent node
* \param matrix Current transform
*/
void AddNodes(std::vector<BaseNode*>& nodes,
void AddNodes(const std::vector<ASE::BaseNode*>& nodes,
aiNode* pcParent,const char* szName);
void AddNodes(std::vector<BaseNode*>& nodes,
void AddNodes(const std::vector<ASE::BaseNode*>& nodes,
aiNode* pcParent,const char* szName,
const aiMatrix4x4& matrix);
@ -188,8 +198,6 @@ protected:
/** Scene to be filled */
aiScene* pcScene;
std::vector<BaseNode*> nodes;
/** Config options: Recompute the normals in every case - WA
for 3DS Max broken ASE normal export */
bool configRecomputeNormals;

View File

@ -132,6 +132,8 @@ bool LWOImporter::HandleTextures(MaterialHelper* pcMat, const TextureList& in, a
mapping = aiTextureMapping_UV;
}
break;
default:
ai_assert(false);
};
if (mapping != aiTextureMapping_UV) {