Merge branch 'master' into kimkulling/fix_memleak_in_xmlparser
commit
636d8bffe5
3
Build.md
3
Build.md
|
@ -14,7 +14,8 @@ The assimp port in vcpkg is kept up to date by Microsoft team members and commun
|
||||||
## Install on Ubuntu
|
## Install on Ubuntu
|
||||||
You can install the Asset-Importer-Lib via apt:
|
You can install the Asset-Importer-Lib via apt:
|
||||||
```
|
```
|
||||||
sudo apt-get install assimp
|
sudp apt-get update
|
||||||
|
sudo apt-get install libassimp-dev
|
||||||
```
|
```
|
||||||
|
|
||||||
## Install pyassimp
|
## Install pyassimp
|
||||||
|
|
|
@ -90,7 +90,7 @@ OPTION( ASSIMP_BUILD_ZLIB
|
||||||
)
|
)
|
||||||
OPTION( ASSIMP_BUILD_ASSIMP_TOOLS
|
OPTION( ASSIMP_BUILD_ASSIMP_TOOLS
|
||||||
"If the supplementary tools for Assimp are built in addition to the library."
|
"If the supplementary tools for Assimp are built in addition to the library."
|
||||||
ON
|
OFF
|
||||||
)
|
)
|
||||||
OPTION ( ASSIMP_BUILD_SAMPLES
|
OPTION ( ASSIMP_BUILD_SAMPLES
|
||||||
"If the official samples are built as well (needs Glut)."
|
"If the official samples are built as well (needs Glut)."
|
||||||
|
|
|
@ -151,45 +151,46 @@ namespace Grammar {
|
||||||
}
|
}
|
||||||
|
|
||||||
static TokenType matchTokenType(const char *tokenType) {
|
static TokenType matchTokenType(const char *tokenType) {
|
||||||
if (MetricType == tokenType) {
|
const size_t len = std::strlen(tokenType);
|
||||||
|
if (0 == strncmp(MetricType, tokenType, len)) {
|
||||||
return MetricToken;
|
return MetricToken;
|
||||||
} else if (NameType == tokenType) {
|
} else if (0 == strncmp(NameType, tokenType, len)) {
|
||||||
return NameToken;
|
return NameToken;
|
||||||
} else if (ObjectRefType == tokenType) {
|
} else if (0 == strncmp(ObjectRefType, tokenType, len)) {
|
||||||
return ObjectRefToken;
|
return ObjectRefToken;
|
||||||
} else if (MaterialRefType == tokenType) {
|
} else if (0 == strncmp(MaterialRefType, tokenType, len)) {
|
||||||
return MaterialRefToken;
|
return MaterialRefToken;
|
||||||
} else if (MetricKeyType == tokenType) {
|
} else if (0 == strncmp(MetricKeyType, tokenType, len)) {
|
||||||
return MetricKeyToken;
|
return MetricKeyToken;
|
||||||
} else if (GeometryNodeType == tokenType) {
|
} else if (0 == strncmp(GeometryNodeType, tokenType, len)) {
|
||||||
return GeometryNodeToken;
|
return GeometryNodeToken;
|
||||||
} else if (CameraNodeType == tokenType) {
|
} else if (0 == strncmp(CameraNodeType, tokenType, len)) {
|
||||||
return CameraNodeToken;
|
return CameraNodeToken;
|
||||||
} else if (LightNodeType == tokenType) {
|
} else if (0 == strncmp(LightNodeType, tokenType, len)) {
|
||||||
return LightNodeToken;
|
return LightNodeToken;
|
||||||
} else if (GeometryObjectType == tokenType) {
|
} else if (0 == strncmp(GeometryObjectType, tokenType, len)) {
|
||||||
return GeometryObjectToken;
|
return GeometryObjectToken;
|
||||||
} else if (CameraObjectType == tokenType) {
|
} else if (0 == strncmp(CameraObjectType, tokenType, len)) {
|
||||||
return CameraObjectToken;
|
return CameraObjectToken;
|
||||||
} else if (LightObjectType == tokenType) {
|
} else if (0 == strncmp(LightObjectType, tokenType, len)) {
|
||||||
return LightObjectToken;
|
return LightObjectToken;
|
||||||
} else if (TransformType == tokenType) {
|
} else if (0 == strncmp(TransformType, tokenType, len)) {
|
||||||
return TransformToken;
|
return TransformToken;
|
||||||
} else if (MeshType == tokenType) {
|
} else if (0 == strncmp(MeshType, tokenType, len)) {
|
||||||
return MeshToken;
|
return MeshToken;
|
||||||
} else if (VertexArrayType == tokenType) {
|
} else if (0 == strncmp(VertexArrayType, tokenType, len)) {
|
||||||
return VertexArrayToken;
|
return VertexArrayToken;
|
||||||
} else if (IndexArrayType == tokenType) {
|
} else if (0 == strncmp(IndexArrayType, tokenType, len)) {
|
||||||
return IndexArrayToken;
|
return IndexArrayToken;
|
||||||
} else if (MaterialType == tokenType) {
|
} else if (0 == strncmp(MaterialType, tokenType, len)) {
|
||||||
return MaterialToken;
|
return MaterialToken;
|
||||||
} else if (ColorType == tokenType) {
|
} else if (0 == strncmp(ColorType, tokenType, len)) {
|
||||||
return ColorToken;
|
return ColorToken;
|
||||||
} else if (ParamType == tokenType) {
|
} else if (0 == strncmp(ParamType, tokenType, len)) {
|
||||||
return ParamToken;
|
return ParamToken;
|
||||||
} else if (TextureType == tokenType) {
|
} else if (0 == strncmp(TextureType, tokenType, len)) {
|
||||||
return TextureToken;
|
return TextureToken;
|
||||||
} else if (AttenType == tokenType) {
|
} else if (0 == strncmp(AttenType, tokenType, len)) {
|
||||||
return AttenToken;
|
return AttenToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -256,11 +257,6 @@ OpenGEXImporter::RefInfo::RefInfo(aiNode *node, Type type, std::vector<std::stri
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------------------
|
|
||||||
OpenGEXImporter::RefInfo::~RefInfo() {
|
|
||||||
// empty
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------------
|
||||||
OpenGEXImporter::OpenGEXImporter() :
|
OpenGEXImporter::OpenGEXImporter() :
|
||||||
m_root(nullptr),
|
m_root(nullptr),
|
||||||
|
@ -285,10 +281,6 @@ OpenGEXImporter::OpenGEXImporter() :
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------------------
|
|
||||||
OpenGEXImporter::~OpenGEXImporter() {
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------------------
|
||||||
bool OpenGEXImporter::CanRead(const std::string &file, IOSystem *pIOHandler, bool /*checkSig*/) const {
|
bool OpenGEXImporter::CanRead(const std::string &file, IOSystem *pIOHandler, bool /*checkSig*/) const {
|
||||||
static const char *tokens[] = { "Metric", "GeometryNode", "VertexArray (attrib", "IndexArray" };
|
static const char *tokens[] = { "Metric", "GeometryNode", "VertexArray (attrib", "IndexArray" };
|
||||||
|
|
|
@ -79,12 +79,7 @@ struct MetricInfo {
|
||||||
float m_floatValue;
|
float m_floatValue;
|
||||||
int m_intValue;
|
int m_intValue;
|
||||||
|
|
||||||
MetricInfo()
|
MetricInfo(): m_stringValue( ), m_floatValue( 0.0f ), m_intValue( -1 ) {}
|
||||||
: m_stringValue( )
|
|
||||||
, m_floatValue( 0.0f )
|
|
||||||
, m_intValue( -1 ) {
|
|
||||||
// empty
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/** @brief This class is used to implement the OpenGEX importer
|
/** @brief This class is used to implement the OpenGEX importer
|
||||||
|
@ -97,7 +92,7 @@ public:
|
||||||
OpenGEXImporter();
|
OpenGEXImporter();
|
||||||
|
|
||||||
/// The class destructor.
|
/// The class destructor.
|
||||||
~OpenGEXImporter() override;
|
~OpenGEXImporter() override = default;
|
||||||
|
|
||||||
/// BaseImporter override.
|
/// BaseImporter override.
|
||||||
bool CanRead( const std::string &file, IOSystem *pIOHandler, bool checkSig ) const override;
|
bool CanRead( const std::string &file, IOSystem *pIOHandler, bool checkSig ) const override;
|
||||||
|
@ -170,7 +165,7 @@ private:
|
||||||
std::vector<std::string> m_Names;
|
std::vector<std::string> m_Names;
|
||||||
|
|
||||||
RefInfo( aiNode *node, Type type, std::vector<std::string> &names );
|
RefInfo( aiNode *node, Type type, std::vector<std::string> &names );
|
||||||
~RefInfo();
|
~RefInfo() = default;
|
||||||
|
|
||||||
RefInfo( const RefInfo & ) = delete;
|
RefInfo( const RefInfo & ) = delete;
|
||||||
RefInfo &operator = ( const RefInfo & ) = delete;
|
RefInfo &operator = ( const RefInfo & ) = delete;
|
||||||
|
|
|
@ -63,7 +63,7 @@ inline int select_fseek(FILE *file, int64_t offset, int origin) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if defined _WIN64 && (!defined __GNUC__ || __MSVCRT_VERSION__ >= 0x0601)
|
#if defined _WIN32 && (!defined __GNUC__ || !defined __CLANG__ && __MSVCRT_VERSION__ >= 0x0601)
|
||||||
template <>
|
template <>
|
||||||
inline size_t select_ftell<8>(FILE *file) {
|
inline size_t select_ftell<8>(FILE *file) {
|
||||||
return (size_t)::_ftelli64(file);
|
return (size_t)::_ftelli64(file);
|
||||||
|
@ -74,7 +74,7 @@ inline int select_fseek<8>(FILE *file, int64_t offset, int origin) {
|
||||||
return ::_fseeki64(file, offset, origin);
|
return ::_fseeki64(file, offset, origin);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // #if defined _WIN32 && (!defined __GNUC__ || __MSVCRT_VERSION__ >= 0x0601)
|
#endif
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
@ -149,13 +149,20 @@ size_t DefaultIOStream::FileSize() const {
|
||||||
//
|
//
|
||||||
// See here for details:
|
// See here for details:
|
||||||
// https://www.securecoding.cert.org/confluence/display/seccode/FIO19-C.+Do+not+use+fseek()+and+ftell()+to+compute+the+size+of+a+regular+file
|
// https://www.securecoding.cert.org/confluence/display/seccode/FIO19-C.+Do+not+use+fseek()+and+ftell()+to+compute+the+size+of+a+regular+file
|
||||||
#if defined _WIN64 && (!defined __GNUC__ || __MSVCRT_VERSION__ >= 0x0601)
|
#if defined _WIN32 && (!defined __GNUC__ || !defined __CLANG__ && __MSVCRT_VERSION__ >= 0x0601)
|
||||||
struct __stat64 fileStat;
|
struct __stat64 fileStat;
|
||||||
//using fileno + fstat avoids having to handle the filename
|
//using fileno + fstat avoids having to handle the filename
|
||||||
int err = _fstat64(_fileno(mFile), &fileStat);
|
int err = _fstat64(_fileno(mFile), &fileStat);
|
||||||
if (0 != err)
|
if (0 != err)
|
||||||
return 0;
|
return 0;
|
||||||
mCachedSize = (size_t)(fileStat.st_size);
|
mCachedSize = (size_t)(fileStat.st_size);
|
||||||
|
#elif defined _WIN32
|
||||||
|
struct _stat32 fileStat;
|
||||||
|
//using fileno + fstat avoids having to handle the filename
|
||||||
|
int err = _fstat32(_fileno(mFile), &fileStat);
|
||||||
|
if (0 != err)
|
||||||
|
return 0;
|
||||||
|
mCachedSize = (size_t)(fileStat.st_size);
|
||||||
#elif defined __GNUC__ || defined __APPLE__ || defined __MACH__ || defined __FreeBSD__
|
#elif defined __GNUC__ || defined __APPLE__ || defined __MACH__ || defined __FreeBSD__
|
||||||
struct stat fileStat;
|
struct stat fileStat;
|
||||||
int err = stat(mFilename.c_str(), &fileStat);
|
int err = stat(mFilename.c_str(), &fileStat);
|
||||||
|
|
|
@ -128,7 +128,7 @@ bool EmbedTexturesProcess::addTexture(aiScene *pScene, const std::string &path)
|
||||||
|
|
||||||
aiTexel* imageContent = new aiTexel[ 1ul + static_cast<unsigned long>( imageSize ) / sizeof(aiTexel)];
|
aiTexel* imageContent = new aiTexel[ 1ul + static_cast<unsigned long>( imageSize ) / sizeof(aiTexel)];
|
||||||
pFile->Seek(0, aiOrigin_SET);
|
pFile->Seek(0, aiOrigin_SET);
|
||||||
pFile->Read(reinterpret_cast<char*>(imageContent), imageSize, 1);
|
pFile->Read(reinterpret_cast<char*>(imageContent), static_cast<size_t>(imageSize), 1);
|
||||||
mIOHandler->Close(pFile);
|
mIOHandler->Close(pFile);
|
||||||
|
|
||||||
// Enlarging the textures table
|
// Enlarging the textures table
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
#include "revision.h"
|
#include "revision.h"
|
||||||
|
#ifdef __GNUC__
|
||||||
|
#include "winresrc.h"
|
||||||
|
#else
|
||||||
#include "winres.h"
|
#include "winres.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
|
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
|
||||||
#pragma code_page(1252)
|
#pragma code_page(1252)
|
||||||
|
|
|
@ -40,6 +40,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "AbstractImportExportBase.h"
|
#include "AbstractImportExportBase.h"
|
||||||
|
|
||||||
|
#include <assimp/scene.h>
|
||||||
#include "UnitTestPCH.h"
|
#include "UnitTestPCH.h"
|
||||||
|
|
||||||
#include <assimp/Importer.hpp>
|
#include <assimp/Importer.hpp>
|
||||||
|
@ -51,11 +53,12 @@ public:
|
||||||
bool importerTest() override {
|
bool importerTest() override {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/OpenGEX/Example.ogex", 0);
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/OpenGEX/Example.ogex", 0);
|
||||||
|
EXPECT_EQ(1u, scene->mNumMeshes);
|
||||||
return nullptr != scene;
|
return nullptr != scene;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_F(utOpenGEXImportExport, importLWSFromFileTest) {
|
TEST_F(utOpenGEXImportExport, importOpenGexFromFileTest) {
|
||||||
EXPECT_TRUE(importerTest());
|
EXPECT_TRUE(importerTest());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue