pull/682/head
Kim Kulling 2015-10-31 09:07:21 +01:00
commit 6f75ea5702
34 changed files with 80 additions and 54 deletions

View File

@ -138,7 +138,7 @@ struct Bone
} }
//! Construction from an existing name //! Construction from an existing name
Bone( const std::string& name) explicit Bone( const std::string& name)
: mName (name) : mName (name)
{} {}
@ -216,7 +216,7 @@ struct BaseNode
enum Type {Light, Camera, Mesh, Dummy} mType; enum Type {Light, Camera, Mesh, Dummy} mType;
//! Constructor. Creates a default name for the node //! Constructor. Creates a default name for the node
BaseNode(Type _mType) explicit BaseNode(Type _mType)
: mType (_mType) : mType (_mType)
, mProcessed (false) , mProcessed (false)
{ {

View File

@ -110,7 +110,7 @@ static boost::mutex gLogStreamMutex;
class LogToCallbackRedirector : public LogStream class LogToCallbackRedirector : public LogStream
{ {
public: public:
LogToCallbackRedirector(const aiLogStream& s) explicit LogToCallbackRedirector(const aiLogStream& s)
: stream (s) { : stream (s) {
ai_assert(NULL != s.callback); ai_assert(NULL != s.callback);
} }

View File

@ -83,7 +83,7 @@ class BVHLoader : public BaseImporter
std::vector<float> mChannelValues; // motion data values for that node. Of size NumChannels * NumFrames std::vector<float> mChannelValues; // motion data values for that node. Of size NumChannels * NumFrames
Node() { } Node() { }
Node( const aiNode* pNode) : mNode( pNode) { } explicit Node( const aiNode* pNode) : mNode( pNode) { }
}; };
public: public:

View File

@ -70,7 +70,7 @@ class IOStream;
template <typename T> template <typename T>
struct ScopeGuard struct ScopeGuard
{ {
ScopeGuard(T* obj) : obj(obj), mdismiss() {} explicit ScopeGuard(T* obj) : obj(obj), mdismiss() {}
~ScopeGuard () throw() { ~ScopeGuard () throw() {
if (!mdismiss) { if (!mdismiss) {
delete obj; delete obj;

View File

@ -74,7 +74,7 @@ public:
template <typename T> template <typename T>
struct THeapData : public Base struct THeapData : public Base
{ {
THeapData(T* in) explicit THeapData(T* in)
: data (in) : data (in)
{} {}
@ -89,7 +89,7 @@ public:
template <typename T> template <typename T>
struct TStaticData : public Base struct TStaticData : public Base
{ {
TStaticData(T in) explicit TStaticData(T in)
: data (in) : data (in)
{} {}

View File

@ -57,7 +57,7 @@ class CIOStreamWrapper : public IOStream
friend class CIOSystemWrapper; friend class CIOSystemWrapper;
public: public:
CIOStreamWrapper(aiFile* pFile) explicit CIOStreamWrapper(aiFile* pFile)
: mFile(pFile) : mFile(pFile)
{} {}
@ -110,7 +110,7 @@ private:
class CIOSystemWrapper : public IOSystem class CIOSystemWrapper : public IOSystem
{ {
public: public:
CIOSystemWrapper(aiFileIO* pFile) explicit CIOSystemWrapper(aiFileIO* pFile)
: mFileSystem(pFile) : mFileSystem(pFile)
{} {}

View File

@ -125,7 +125,7 @@ private:
// temporary structure to describe a mapping // temporary structure to describe a mapping
struct MappingInfo struct MappingInfo
{ {
MappingInfo(aiTextureMapping _type) explicit MappingInfo(aiTextureMapping _type)
: type (_type) : type (_type)
, axis (0.f,1.f,0.f) , axis (0.f,1.f,0.f)
, uv (0u) , uv (0u)

View File

@ -87,7 +87,7 @@ class TypedProperty : public Property
{ {
public: public:
TypedProperty(const T& value) explicit TypedProperty(const T& value)
: value(value) : value(value)
{ {
} }

View File

@ -113,7 +113,7 @@ private:
} type; } type;
Animator(AT t = UNKNOWN) explicit Animator(AT t = UNKNOWN)
: type (t) : type (t)
, speed (0.001f) , speed (0.001f)
, direction (0.f,1.f,0.f) , direction (0.f,1.f,0.f)
@ -163,7 +163,7 @@ private:
ANIMMESH ANIMMESH
} type; } type;
Node(ET t) explicit Node(ET t)
: type (t) : type (t)
, scaling (1.f,1.f,1.f) // assume uniform scaling by default , scaling (1.f,1.f,1.f) // assume uniform scaling by default
, parent() , parent()

View File

@ -167,7 +167,7 @@ public:
// ------------------------------------------------------------------- // -------------------------------------------------------------------
/** Construct a batch loader from a given IO system to be used /** Construct a batch loader from a given IO system to be used
* to acess external files */ * to acess external files */
BatchLoader(IOSystem* pIO); explicit BatchLoader(IOSystem* pIO);
~BatchLoader(); ~BatchLoader();

View File

@ -269,7 +269,7 @@ struct Face : public aiFace
{} {}
//! Construction from given type //! Construction from given type
Face(uint32_t _type) explicit Face(uint32_t _type)
: surfaceIndex (0) : surfaceIndex (0)
, smoothGroup (0) , smoothGroup (0)
, type (_type) , type (_type)
@ -305,7 +305,7 @@ struct Face : public aiFace
*/ */
struct VMapEntry struct VMapEntry
{ {
VMapEntry(unsigned int _dims) explicit VMapEntry(unsigned int _dims)
: dims(_dims) : dims(_dims)
{} {}

View File

@ -280,7 +280,7 @@ public:
* *
* @param mSections List of file sections (output of MD5Parser) * @param mSections List of file sections (output of MD5Parser)
*/ */
MD5MeshParser(SectionList& mSections); explicit MD5MeshParser(SectionList& mSections);
//! List of all meshes //! List of all meshes
MeshList mMeshes; MeshList mMeshes;
@ -305,7 +305,7 @@ public:
* *
* @param mSections List of file sections (output of MD5Parser) * @param mSections List of file sections (output of MD5Parser)
*/ */
MD5AnimParser(SectionList& mSections); explicit MD5AnimParser(SectionList& mSections);
//! Output frame rate //! Output frame rate
@ -337,7 +337,7 @@ public:
* *
* @param mSections List of file sections (output of MD5Parser) * @param mSections List of file sections (output of MD5Parser)
*/ */
MD5CameraParser(SectionList& mSections); explicit MD5CameraParser(SectionList& mSections);
//! Output frame rate //! Output frame rate

View File

@ -138,9 +138,15 @@ void OFFImporter::InternReadFile( const std::string& pFile,
throw DeadlyImportError("OFF: There are no valid faces"); throw DeadlyImportError("OFF: There are no valid faces");
} }
pScene->mMeshes = new aiMesh*[ pScene->mNumMeshes = 1 ]; pScene->mNumMeshes = 1;
aiMesh* mesh = pScene->mMeshes[0] = new aiMesh(); pScene->mMeshes = new aiMesh*[ pScene->mNumMeshes ];
aiFace* faces = mesh->mFaces = new aiFace [mesh->mNumFaces = numFaces];
aiMesh* mesh = new aiMesh();
pScene->mMeshes[0] = mesh;
mesh->mNumFaces = numFaces;
aiFace* faces = new aiFace [mesh->mNumFaces];
mesh->mFaces = faces;
std::vector<aiVector3D> tempPositions(numVertices); std::vector<aiVector3D> tempPositions(numVertices);
@ -171,7 +177,8 @@ void OFFImporter::InternReadFile( const std::string& pFile,
break; break;
} }
sz = line;SkipSpaces(&sz); sz = line;SkipSpaces(&sz);
if(!(faces->mNumIndices = strtoul10(sz,&sz)) || faces->mNumIndices > 9) faces->mNumIndices = strtoul10(sz,&sz);
if(!(faces->mNumIndices) || faces->mNumIndices > 9)
{ {
DefaultLogger::get()->error("OFF: Faces with zero indices aren't allowed"); DefaultLogger::get()->error("OFF: Faces with zero indices aren't allowed");
--mesh->mNumFaces; --mesh->mNumFaces;
@ -185,43 +192,54 @@ void OFFImporter::InternReadFile( const std::string& pFile,
throw DeadlyImportError("OFF: There are no valid faces"); throw DeadlyImportError("OFF: There are no valid faces");
// allocate storage for the output vertices // allocate storage for the output vertices
aiVector3D* verts = mesh->mVertices = new aiVector3D[mesh->mNumVertices]; std::vector<aiVector3D> verts;
verts.reserve(mesh->mNumVertices);
// second: now parse all face indices // second: now parse all face indices
buffer = old;faces = mesh->mFaces; buffer = old;
faces = mesh->mFaces;
for (unsigned int i = 0, p = 0; i< mesh->mNumFaces;) for (unsigned int i = 0, p = 0; i< mesh->mNumFaces;)
{ {
if(!GetNextLine(buffer,line))break; if(!GetNextLine(buffer,line))break;
unsigned int idx; unsigned int idx;
sz = line;SkipSpaces(&sz); sz = line;SkipSpaces(&sz);
if(!(idx = strtoul10(sz,&sz)) || idx > 9) idx = strtoul10(sz,&sz);
if(!(idx) || idx > 9)
continue; continue;
faces->mIndices = new unsigned int [faces->mNumIndices]; faces->mIndices = new unsigned int [faces->mNumIndices];
for (unsigned int m = 0; m < faces->mNumIndices;++m) for (unsigned int m = 0; m < faces->mNumIndices;++m)
{ {
SkipSpaces(&sz); SkipSpaces(&sz);
if ((idx = strtoul10(sz,&sz)) >= numVertices) idx = strtoul10(sz,&sz);
if ((idx) >= numVertices)
{ {
DefaultLogger::get()->error("OFF: Vertex index is out of range"); DefaultLogger::get()->error("OFF: Vertex index is out of range");
idx = numVertices-1; idx = numVertices-1;
} }
faces->mIndices[m] = p++; faces->mIndices[m] = p++;
*verts++ = tempPositions[idx]; verts.push_back(tempPositions[idx]);
} }
++i; ++i;
++faces; ++faces;
} }
if (mesh->mNumVertices != verts.size()) {
throw DeadlyImportError("OFF: Vertex count mismatch");
}
mesh->mVertices = new aiVector3D[verts.size()];
memcpy(mesh->mVertices, &verts[0], verts.size() * sizeof(aiVector3D));
// generate the output node graph // generate the output node graph
pScene->mRootNode = new aiNode(); pScene->mRootNode = new aiNode();
pScene->mRootNode->mName.Set("<OFFRoot>"); pScene->mRootNode->mName.Set("<OFFRoot>");
pScene->mRootNode->mMeshes = new unsigned int [pScene->mRootNode->mNumMeshes = 1]; pScene->mRootNode->mNumMeshes = 1;
pScene->mRootNode->mMeshes = new unsigned int [pScene->mRootNode->mNumMeshes];
pScene->mRootNode->mMeshes[0] = 0; pScene->mRootNode->mMeshes[0] = 0;
// generate a default material // generate a default material
pScene->mMaterials = new aiMaterial*[pScene->mNumMaterials = 1]; pScene->mNumMaterials = 1;
pScene->mMaterials = new aiMaterial*[pScene->mNumMaterials];
aiMaterial* pcMat = new aiMaterial(); aiMaterial* pcMat = new aiMaterial();
aiColor4D clr(0.6f,0.6f,0.6f,1.0f); aiColor4D clr(0.6f,0.6f,0.6f,1.0f);

View File

@ -242,7 +242,7 @@ struct Mesh {
bool m_hasNormals; bool m_hasNormals;
/// Constructor /// Constructor
Mesh( const std::string &name ) explicit Mesh( const std::string &name )
: m_name( name ) : m_name( name )
, m_pMaterial(NULL) , m_pMaterial(NULL)
, m_uiNumIndices(0) , m_uiNumIndices(0)

View File

@ -381,8 +381,8 @@ typedef std::vector<VertexAnimationTrack> VertexAnimationTrackList;
class Animation class Animation
{ {
public: public:
Animation(Skeleton *parent); explicit Animation(Skeleton *parent);
Animation(Mesh *parent); explicit Animation(Mesh *parent);
/// Returns the associated vertex data for a track in this animation. /// Returns the associated vertex data for a track in this animation.
/** @note Only valid to call when parent Mesh is set. */ /** @note Only valid to call when parent Mesh is set. */

View File

@ -69,7 +69,7 @@ public:
static bool ImportSkeleton(Assimp::IOSystem *pIOHandler, Mesh *mesh); static bool ImportSkeleton(Assimp::IOSystem *pIOHandler, Mesh *mesh);
private: private:
OgreXmlSerializer(XmlReader *reader) : explicit OgreXmlSerializer(XmlReader *reader) :
m_reader(reader) m_reader(reader)
{ {
} }

View File

@ -90,7 +90,7 @@ class ZipFile : public IOStream {
public: public:
ZipFile(size_t size); explicit ZipFile(size_t size);
~ZipFile(); ~ZipFile();

View File

@ -103,7 +103,7 @@ private:
struct Face struct Face
{ {
Face(unsigned int s) explicit Face(unsigned int s)
: indices (s) : indices (s)
, uvindices (s) , uvindices (s)
, mat (0) , mat (0)

View File

@ -88,7 +88,7 @@ private:
struct MeshInformation struct MeshInformation
{ {
MeshInformation(const std::string& _name) explicit MeshInformation(const std::string& _name)
: name(_name) : name(_name)
{ {
vertices.reserve(100); vertices.reserve(100);
@ -103,7 +103,7 @@ private:
struct GroupInformation struct GroupInformation
{ {
GroupInformation(const std::string& _name) explicit GroupInformation(const std::string& _name)
: name(_name) : name(_name)
{ {
meshes.reserve(10); meshes.reserve(10);

View File

@ -66,7 +66,7 @@ public:
/** Construction from a given face array, handling smoothing groups /** Construction from a given face array, handling smoothing groups
* properly * properly
*/ */
SGSpatialSort(const std::vector<aiVector3D>& vPositions); explicit SGSpatialSort(const std::vector<aiVector3D>& vPositions);
// ------------------------------------------------------------------- // -------------------------------------------------------------------
/** Add a vertex to the spatial sort /** Add a vertex to the spatial sort

View File

@ -166,7 +166,7 @@ struct SceneHelper
id[0] = 0; id[0] = 0;
} }
SceneHelper (aiScene* _scene) explicit SceneHelper (aiScene* _scene)
: scene (_scene) : scene (_scene)
, idlen (0) , idlen (0)
{ {

View File

@ -16,7 +16,7 @@ public:
/** @brief Construction from an existing std::ostream /** @brief Construction from an existing std::ostream
* @param _ostream Output stream to be used * @param _ostream Output stream to be used
*/ */
StdOStreamLogStream(std::ostream& _ostream); explicit StdOStreamLogStream(std::ostream& _ostream);
/** @brief Destructor */ /** @brief Destructor */
~StdOStreamLogStream(); ~StdOStreamLogStream();

View File

@ -97,7 +97,7 @@ public:
// being bound to const ref& function parameters. Copying streams is not permitted, though. // being bound to const ref& function parameters. Copying streams is not permitted, though.
// This workaround avoids this by manually specifying a copy ctor. // This workaround avoids this by manually specifying a copy ctor.
#if !defined(__GNUC__) || !defined(__APPLE__) || __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) #if !defined(__GNUC__) || !defined(__APPLE__) || __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
basic_formatter(const basic_formatter& other) { explicit basic_formatter(const basic_formatter& other) {
underlying << (string)other; underlying << (string)other;
} }
#endif #endif

View File

@ -87,7 +87,7 @@ struct TempMat {
, numFaces (0) , numFaces (0)
{} {}
TempMat(const Triangle& in) explicit TempMat(const Triangle& in)
: type ((Unreal::MeshFlags)in.mType) : type ((Unreal::MeshFlags)in.mType)
, tex (in.mTextureNum) , tex (in.mTextureNum)
, numFaces (0) , numFaces (0)

View File

@ -129,7 +129,7 @@ struct Mesh
std::vector<Bone> mBones; std::vector<Bone> mBones;
Mesh(const std::string &pName = "") { mName = pName; mNumTextures = 0; mNumColorSets = 0; } explicit Mesh(const std::string &pName = "") { mName = pName; mNumTextures = 0; mNumColorSets = 0; }
}; };
/** Helper structure to represent a XFile frame */ /** Helper structure to represent a XFile frame */
@ -142,7 +142,7 @@ struct Node
std::vector<Mesh*> mMeshes; std::vector<Mesh*> mMeshes;
Node() { mParent = NULL; } Node() { mParent = NULL; }
Node( Node* pParent) { mParent = pParent; } explicit Node( Node* pParent) { mParent = pParent; }
~Node() ~Node()
{ {
for( unsigned int a = 0; a < mChildren.size(); a++) for( unsigned int a = 0; a < mChildren.size(); a++)

View File

@ -68,7 +68,7 @@ public:
/** Constructor. Creates a data structure out of the XFile given in the memory block. /** Constructor. Creates a data structure out of the XFile given in the memory block.
* @param pBuffer Null-terminated memory buffer containing the XFile * @param pBuffer Null-terminated memory buffer containing the XFile
*/ */
XFileParser( const std::vector<char>& pBuffer); explicit XFileParser( const std::vector<char>& pBuffer);
/** Destructor. Destroys all imported data along with it */ /** Destructor. Destroys all imported data along with it */
~XFileParser(); ~XFileParser();

View File

@ -76,7 +76,7 @@ public:
// ---------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------
//! Construction from an existing IOStream //! Construction from an existing IOStream
CIrrXML_IOStreamReader(IOStream* _stream) explicit CIrrXML_IOStreamReader(IOStream* _stream)
: stream (_stream) : stream (_stream)
, t (0) , t (0)
{ {

View File

@ -135,7 +135,7 @@ private:
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
/** @briefPrivate construction for internal use by create(). /** @briefPrivate construction for internal use by create().
* @param severity Logging granularity */ * @param severity Logging granularity */
DefaultLogger(LogSeverity severity); explicit DefaultLogger(LogSeverity severity);
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
/** @briefDestructor */ /** @briefDestructor */

View File

@ -160,7 +160,7 @@ protected:
Logger(); Logger();
/** Construction with a given log severity */ /** Construction with a given log severity */
Logger(LogSeverity severity); explicit Logger(LogSeverity severity);
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
/** @brief Called as a request to write a specific debug message /** @brief Called as a request to write a specific debug message

View File

@ -59,7 +59,7 @@ public:
aiColor4t () : r(), g(), b(), a() {} aiColor4t () : r(), g(), b(), a() {}
aiColor4t (TReal _r, TReal _g, TReal _b, TReal _a) aiColor4t (TReal _r, TReal _g, TReal _b, TReal _a)
: r(_r), g(_g), b(_b), a(_a) {} : r(_r), g(_g), b(_b), a(_a) {}
aiColor4t (TReal _r) : r(_r), g(_r), b(_r), a(_r) {} explicit aiColor4t (TReal _r) : r(_r), g(_r), b(_r), a(_r) {}
aiColor4t (const aiColor4t& o) aiColor4t (const aiColor4t& o)
: r(o.r), g(o.g), b(o.b), a(o.a) {} : r(o.r), g(o.g), b(o.b), a(o.a) {}

View File

@ -60,7 +60,7 @@ public:
: w(pw), x(px), y(py), z(pz) {} : w(pw), x(px), y(py), z(pz) {}
/** Construct from rotation matrix. Result is undefined if the matrix is not orthonormal. */ /** Construct from rotation matrix. Result is undefined if the matrix is not orthonormal. */
aiQuaterniont( const aiMatrix3x3t<TReal>& pRotMatrix); explicit aiQuaterniont( const aiMatrix3x3t<TReal>& pRotMatrix);
/** Construct from euler angles */ /** Construct from euler angles */
aiQuaterniont( TReal rotx, TReal roty, TReal rotz); aiQuaterniont( TReal rotx, TReal roty, TReal rotz);
@ -69,7 +69,7 @@ public:
aiQuaterniont( aiVector3t<TReal> axis, TReal angle); aiQuaterniont( aiVector3t<TReal> axis, TReal angle);
/** Construct from a normalized quaternion stored in a vec3 */ /** Construct from a normalized quaternion stored in a vec3 */
aiQuaterniont( aiVector3t<TReal> normalized); explicit aiQuaterniont( aiVector3t<TReal> normalized);
/** Returns a matrix representation of the quaternion */ /** Returns a matrix representation of the quaternion */
aiMatrix3x3t<TReal> GetMatrix() const; aiMatrix3x3t<TReal> GetMatrix() const;

View File

@ -135,7 +135,7 @@ struct aiNode
/** Construction from a specific name */ /** Construction from a specific name */
aiNode(const std::string& name) explicit aiNode(const std::string& name)
// set all members to zero by default // set all members to zero by default
: mName(name) : mName(name)
, mParent(NULL) , mParent(NULL)

View File

@ -160,7 +160,7 @@ struct aiColor3D
#ifdef __cplusplus #ifdef __cplusplus
aiColor3D () : r(0.0f), g(0.0f), b(0.0f) {} aiColor3D () : r(0.0f), g(0.0f), b(0.0f) {}
aiColor3D (float _r, float _g, float _b) : r(_r), g(_g), b(_b) {} aiColor3D (float _r, float _g, float _b) : r(_r), g(_g), b(_b) {}
aiColor3D (float _r) : r(_r), g(_r), b(_r) {} explicit aiColor3D (float _r) : r(_r), g(_r), b(_r) {}
aiColor3D (const aiColor3D& o) : r(o.r), g(o.g), b(o.b) {} aiColor3D (const aiColor3D& o) : r(o.r), g(o.g), b(o.b) {}
/** Component-wise comparison */ /** Component-wise comparison */

View File

@ -0,0 +1,8 @@
OFF
3 4
0.1 0.2 0.3
0.2 0.3 0.4
0.3 0.4 0.5
0
2 20
4