FBXImporter: some refactorings to increase readability.

pull/814/head
Kim Kulling 2016-03-03 18:38:50 +01:00
parent 26fba14aaf
commit 53370d0d31
6 changed files with 29 additions and 32 deletions

View File

@ -54,13 +54,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "StringComparison.h"
#include "../include/assimp/scene.h"
#include <iterator>
#include <sstream>
#include <boost/tuple/tuple.hpp>
#include <vector>
#include <boost/foreach.hpp>
#include <boost/scoped_array.hpp>
#include <iterator>
#include <sstream>
#include <vector>
namespace Assimp {
namespace FBX {
@ -79,8 +79,9 @@ using namespace Util;
class Converter
{
public:
/** the different parts that make up the final local transformation of a fbx node */
/**
* The different parts that make up the final local transformation of a fbx-node
*/
enum TransformationComp
{
TransformationComp_Translation = 0,
@ -102,7 +103,6 @@ public:
};
public:
Converter(aiScene* out, const Document& doc)
: defaultMaterialIndex()
, out(out)
@ -858,7 +858,7 @@ private:
}
}
// faster codepath, just copy the data
// faster code-path, just copy the data
temp.push_back(ConvertMeshSingleMaterial(mesh, model, node_global_transform));
return temp;
}
@ -961,7 +961,8 @@ private:
}
if(binormals) {
ai_assert(tangents.size() == vertices.size() && binormals->size() == vertices.size());
ai_assert( tangents.size() == vertices.size() );
ai_assert( binormals->size() == vertices.size() );
out_mesh->mTangents = new aiVector3D[vertices.size()];
std::copy(tangents.begin(),tangents.end(),out_mesh->mTangents);
@ -1216,10 +1217,12 @@ private:
// ------------------------------------------------------------------------------------------------
/** - if materialIndex == NO_MATERIAL_SEPARATION, materials are not taken into
/**
* - if materialIndex == NO_MATERIAL_SEPARATION, materials are not taken into
* account when determining which weights to include.
* - outputVertStartIndices is only used when a material index is specified, it gives for
* each output vertex the DOM index it maps to. */
* each output vertex the DOM index it maps to.
*/
void ConvertWeights(aiMesh* out, const Model& model, const MeshGeometry& geo,
const aiMatrix4x4& node_global_transform = aiMatrix4x4(),
unsigned int materialIndex = NO_MATERIAL_SEPARATION,

View File

@ -51,15 +51,14 @@ namespace FBX {
class Document;
/** Convert a FBX #Document to #aiScene
/**
* Convert a FBX #Document to #aiScene
* @param out Empty scene to be populated
* @param doc Parsed FBX document */
* @param doc Parsed FBX document
*/
void ConvertToAssimpScene(aiScene* out, const Document& doc);
}
}
#endif
#endif // INCLUDED_AI_FBX_CONVERTER_H

View File

@ -86,7 +86,8 @@ static const aiImporterDesc desc = {
// ------------------------------------------------------------------------------------------------
// Constructor to be privately used by #Importer
FBXImporter::FBXImporter()
{}
{
}
// ------------------------------------------------------------------------------------------------
// Destructor, private as well
@ -104,7 +105,7 @@ bool FBXImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool
}
else if ((!extension.length() || checkSig) && pIOHandler) {
// at least ascii FBX files usually have a 'FBX' somewhere in their head
// at least ASCII-FBX files usually have a 'FBX' somewhere in their head
const char* tokens[] = {"fbx"};
return SearchFileHeaderForToken(pIOHandler,pFile,tokens,1);
}

View File

@ -56,7 +56,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
namespace Assimp {
namespace FBX {
using namespace Util;
using namespace Util;
// ------------------------------------------------------------------------------------------------
Model::Model(uint64_t id, const Element& element, const Document& doc, const std::string& name)

View File

@ -58,7 +58,8 @@ namespace FBX {
// ------------------------------------------------------------------------------------------------
NodeAttribute::NodeAttribute(uint64_t id, const Element& element, const Document& doc, const std::string& name)
: Object(id,element,name)
: Object(id,element,name)
, props()
{
const Scope& sc = GetRequiredScope(element);

View File

@ -65,15 +65,12 @@ namespace FBX {
class Property
{
protected:
Property();
public:
virtual ~Property();
public:
template <typename T>
const T* As() const {
return dynamic_cast<const T*>(this);
@ -85,14 +82,12 @@ template<typename T>
class TypedProperty : public Property
{
public:
explicit TypedProperty(const T& value)
: value(value)
{
}
public:
const T& Value() const {
return value;
}
@ -106,19 +101,18 @@ typedef std::fbx_unordered_map<std::string,boost::shared_ptr<Property> > DirectP
typedef std::fbx_unordered_map<std::string,const Property*> PropertyMap;
typedef std::fbx_unordered_map<std::string,const Element*> LazyPropertyMap;
/** Represents a property table as can be found in the newer FBX files (Properties60, Properties70)*/
/**
* Represents a property table as can be found in the newer FBX files (Properties60, Properties70)
*/
class PropertyTable
{
public:
// in-memory property table with no source element
PropertyTable();
PropertyTable(const Element& element, boost::shared_ptr<const PropertyTable> templateProps);
~PropertyTable();
public:
const Property* Get(const std::string& name) const;
// PropertyTable's need not be coupled with FBX elements so this can be NULL
@ -133,7 +127,6 @@ public:
DirectPropertyMap GetUnparsedProperties() const;
private:
LazyPropertyMap lazyProps;
mutable PropertyMap props;
const boost::shared_ptr<const PropertyTable> templateProps;
@ -187,4 +180,4 @@ inline T PropertyGet(const PropertyTable& in, const std::string& name,
} //! FBX
} //! Assimp
#endif //
#endif // INCLUDED_AI_FBX_PROPERTIES_H