Merge branch 'master' into scene_combiner_crash

pull/1580/head
Kim Kulling 2017-11-22 13:46:14 +01:00 committed by GitHub
commit e35f789ace
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
37 changed files with 197 additions and 66 deletions

View File

@ -91,7 +91,7 @@ protected:
// -------------------------------------------------------------------
/** Report a validation warning. This won't throw an exception,
* control will return to the callera.
* control will return to the caller.
* @param msg Format string for sprintf().*/
void ReportWarning(const char* msg,...);
@ -165,7 +165,7 @@ private:
inline void DoValidation(T** array, unsigned int size,
const char* firstName, const char* secondName);
// extended version: checks whethr T::mName occurs twice
// extended version: checks whether T::mName occurs twice
template <typename T>
inline void DoValidationEx(T** array, unsigned int size,
const char* firstName, const char* secondName);

View File

@ -192,15 +192,31 @@ namespace glTF2
#include "./../include/assimp/Compiler/pushpack1.h"
#endif
//! For binary .glb files
//! 12-byte header (+ the JSON + a "body" data section)
struct GLB_Header
{
uint8_t magic[4]; //!< Magic number: "glTF"
uint32_t version; //!< Version number (always 2 as of the last update)
uint32_t length; //!< Total length of the Binary glTF, including header, scene, and body, in bytes
} PACK_STRUCT;
struct GLB_Chunk
{
uint32_t chunkLength;
uint32_t chunkType;
} PACK_STRUCT;
#ifdef ASSIMP_API
#include "./../include/assimp/Compiler/poppack1.h"
#endif
//! Values for the GLB_Header::sceneFormat field
enum SceneFormat
//! Values for the GLB_Chunk::chunkType field
enum ChunkType
{
SceneFormat_JSON = 0
ChunkType_JSON = 0x4E4F534A,
ChunkType_BIN = 0x004E4942
};
//! Values for the mesh primitive modes
@ -420,7 +436,6 @@ namespace glTF2
{
Ref<BufferView> bufferView; //!< The ID of the bufferView. (required)
unsigned int byteOffset; //!< The offset relative to the start of the bufferView in bytes. (required)
unsigned int byteStride; //!< The stride, in bytes, between attributes referenced by this accessor. (default: 0)
ComponentType componentType; //!< The datatype of components in the attribute. (required)
unsigned int count; //!< The number of attributes referenced by this accessor. (required)
AttribType::Value type; //!< Specifies if the attribute is a scalar, vector, or matrix. (required)
@ -611,6 +626,7 @@ namespace glTF2
Ref<Buffer> buffer; //! The ID of the buffer. (required)
size_t byteOffset; //! The offset into the buffer in bytes. (required)
size_t byteLength; //! The length of the bufferView in bytes. (default: 0)
unsigned int byteStride; //!< The stride, in bytes, between attributes referenced by this accessor. (default: 0)
BufferViewTarget target; //! The target that the WebGL buffer should be bound to.
@ -1086,7 +1102,10 @@ namespace glTF2
}
//! Main function
void Load(const std::string& file);
void Load(const std::string& file, bool isBinary = false);
//! Enables binary encoding on the asset
void SetAsBinary();
//! Search for an available name, starting from the given strings
std::string FindUniqueID(const std::string& str, const char* suffix);
@ -1095,6 +1114,8 @@ namespace glTF2
{ return mBodyBuffer; }
private:
void ReadBinaryHeader(IOStream& stream, std::vector<char>& sceneData);
void ReadExtensionsUsed(Document& doc);
IOStream* OpenFile(std::string path, const char* mode, bool absolute = false);

View File

@ -512,6 +512,7 @@ inline void BufferView::Read(Value& obj, Asset& r)
byteOffset = MemberOrDefault(obj, "byteOffset", 0u);
byteLength = MemberOrDefault(obj, "byteLength", 0u);
byteStride = MemberOrDefault(obj, "byteStride", 0u);
}
//
@ -526,7 +527,6 @@ inline void Accessor::Read(Value& obj, Asset& r)
}
byteOffset = MemberOrDefault(obj, "byteOffset", 0u);
byteStride = MemberOrDefault(obj, "byteStride", 0u);
componentType = MemberOrDefault(obj, "componentType", ComponentType_BYTE);
count = MemberOrDefault(obj, "count", 0u);
@ -601,7 +601,7 @@ bool Accessor::ExtractData(T*& outData)
const size_t elemSize = GetElementSize();
const size_t totalSize = elemSize * count;
const size_t stride = byteStride ? byteStride : elemSize;
const size_t stride = bufferView && bufferView->byteStride ? bufferView->byteStride : elemSize;
const size_t targetElemSize = sizeof(T);
ai_assert(elemSize <= targetElemSize);
@ -641,7 +641,7 @@ inline Accessor::Indexer::Indexer(Accessor& acc)
: accessor(acc)
, data(acc.GetPointer())
, elemSize(acc.GetElementSize())
, stride(acc.byteStride ? acc.byteStride : elemSize)
, stride(acc.bufferView && acc.bufferView->byteStride ? acc.bufferView->byteStride : elemSize)
{
}
@ -1037,7 +1037,72 @@ inline void AssetMetadata::Read(Document& doc)
// Asset methods implementation
//
inline void Asset::Load(const std::string& pFile)
inline void Asset::ReadBinaryHeader(IOStream& stream, std::vector<char>& sceneData)
{
GLB_Header header;
if (stream.Read(&header, sizeof(header), 1) != 1) {
throw DeadlyImportError("GLTF: Unable to read the file header");
}
if (strncmp((char*)header.magic, AI_GLB_MAGIC_NUMBER, sizeof(header.magic)) != 0) {
throw DeadlyImportError("GLTF: Invalid binary glTF file");
}
AI_SWAP4(header.version);
asset.version = to_string(header.version);
if (header.version != 2) {
throw DeadlyImportError("GLTF: Unsupported binary glTF version");
}
GLB_Chunk chunk;
if (stream.Read(&chunk, sizeof(chunk), 1) != 1) {
throw DeadlyImportError("GLTF: Unable to read JSON chunk");
}
AI_SWAP4(chunk.chunkLength);
AI_SWAP4(chunk.chunkType);
if (chunk.chunkType != ChunkType_JSON) {
throw DeadlyImportError("GLTF: JSON chunk missing");
}
// read the scene data
mSceneLength = chunk.chunkLength;
sceneData.resize(mSceneLength + 1);
sceneData[mSceneLength] = '\0';
if (stream.Read(&sceneData[0], 1, mSceneLength) != mSceneLength) {
throw DeadlyImportError("GLTF: Could not read the file contents");
}
uint32_t padding = ((chunk.chunkLength + 3) & ~3) - chunk.chunkLength;
if (padding > 0) {
stream.Seek(padding, aiOrigin_CUR);
}
AI_SWAP4(header.length);
mBodyOffset = 12 + 8 + chunk.chunkLength + padding + 8;
if (header.length >= mBodyOffset) {
if (stream.Read(&chunk, sizeof(chunk), 1) != 1) {
throw DeadlyImportError("GLTF: Unable to read BIN chunk");
}
AI_SWAP4(chunk.chunkLength);
AI_SWAP4(chunk.chunkType);
if (chunk.chunkType != ChunkType_BIN) {
throw DeadlyImportError("GLTF: BIN chunk missing");
}
mBodyLength = chunk.chunkLength;
}
else {
mBodyOffset = mBodyLength = 0;
}
}
inline void Asset::Load(const std::string& pFile, bool isBinary)
{
mCurrentAssetDir.clear();
int pos = std::max(int(pFile.rfind('/')), int(pFile.rfind('\\')));
@ -1048,17 +1113,26 @@ inline void Asset::Load(const std::string& pFile)
throw DeadlyImportError("GLTF: Could not open file for reading");
}
// is binary? then read the header
std::vector<char> sceneData;
if (isBinary) {
SetAsBinary(); // also creates the body buffer
ReadBinaryHeader(*stream, sceneData);
}
else {
mSceneLength = stream->FileSize();
mBodyLength = 0;
// read the scene data
std::vector<char> sceneData(mSceneLength + 1);
sceneData.resize(mSceneLength + 1);
sceneData[mSceneLength] = '\0';
if (stream->Read(&sceneData[0], 1, mSceneLength) != mSceneLength) {
throw DeadlyImportError("GLTF: Could not read the file contents");
}
}
// parse the JSON document
@ -1110,6 +1184,15 @@ inline void Asset::Load(const std::string& pFile)
}
}
inline void Asset::SetAsBinary()
{
if (!mBodyBuffer) {
mBodyBuffer = buffers.Create("binary_glTF");
mBodyBuffer->MarkAsSpecial();
}
}
inline void Asset::ReadExtensionsUsed(Document& doc)
{
Value* extsUsed = FindArray(doc, "extensionsUsed");

View File

@ -98,10 +98,6 @@ namespace glTF2 {
obj.AddMember("bufferView", a.bufferView->index, w.mAl);
obj.AddMember("byteOffset", a.byteOffset, w.mAl);
if (a.byteStride != 0) {
obj.AddMember("byteStride", a.byteStride, w.mAl);
}
obj.AddMember("componentType", int(a.componentType), w.mAl);
obj.AddMember("count", a.count, w.mAl);
obj.AddMember("type", StringRef(AttribType::ToString(a.type)), w.mAl);
@ -168,6 +164,9 @@ namespace glTF2 {
obj.AddMember("buffer", bv.buffer->index, w.mAl);
obj.AddMember("byteOffset", static_cast<uint64_t>(bv.byteOffset), w.mAl);
obj.AddMember("byteLength", static_cast<uint64_t>(bv.byteLength), w.mAl);
if (bv.byteStride != 0) {
obj.AddMember("byteStride", bv.byteStride, w.mAl);
}
obj.AddMember("target", int(bv.target), w.mAl);
}

View File

@ -170,13 +170,13 @@ inline Ref<Accessor> ExportData(Asset& a, std::string& meshName, Ref<Buffer>& bu
bv->buffer = buffer;
bv->byteOffset = unsigned(offset);
bv->byteLength = length; //! The target that the WebGL buffer should be bound to.
bv->byteStride = 0;
bv->target = isIndices ? BufferViewTarget_ELEMENT_ARRAY_BUFFER : BufferViewTarget_ARRAY_BUFFER;
// accessor
Ref<Accessor> acc = a.accessors.Create(a.FindUniqueID(meshName, "accessor"));
acc->bufferView = bv;
acc->byteOffset = 0;
acc->byteStride = 0;
acc->componentType = compType;
acc->count = count;
acc->type = typeOut;

View File

@ -74,7 +74,7 @@ static const aiImporterDesc desc = {
"",
"",
"",
aiImporterFlags_SupportTextFlavour | aiImporterFlags_LimitedSupport | aiImporterFlags_Experimental,
aiImporterFlags_SupportTextFlavour | aiImporterFlags_SupportBinaryFlavour | aiImporterFlags_LimitedSupport | aiImporterFlags_Experimental,
0,
0,
0,
@ -103,13 +103,13 @@ bool glTF2Importer::CanRead(const std::string& pFile, IOSystem* pIOHandler, bool
{
const std::string &extension = GetExtension(pFile);
if (extension != "gltf") // We currently can't read glTF2 binary files (.glb), yet
if (extension != "gltf" && extension != "glb")
return false;
if (checkSig && pIOHandler) {
glTF2::Asset asset(pIOHandler);
try {
asset.Load(pFile);
asset.Load(pFile, extension == "glb");
std::string version = asset.asset.version;
return !version.empty() && version[0] == '2';
} catch (...) {
@ -639,7 +639,7 @@ void glTF2Importer::InternReadFile(const std::string& pFile, aiScene* pScene, IO
// read the asset file
glTF2::Asset asset(pIOHandler);
asset.Load(pFile);
asset.Load(pFile, GetExtension(pFile) == "glb");
//
// Copy the data out

View File

@ -45,6 +45,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "AbstractImportExportBase.h"
#include <assimp/Importer.hpp>
#include <assimp/postprocess.h>
using namespace Assimp;
@ -52,7 +53,7 @@ class ut3DImportExport : public AbstractImportExportBase {
public:
virtual bool importerTest() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/3D/box_a.3d", 0 );
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/3D/box_a.3d", aiProcess_ValidateDataStructure );
return nullptr != scene;
}
};

View File

@ -45,6 +45,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "AbstractImportExportBase.h"
#include <assimp/Importer.hpp>
#include <assimp/postprocess.h>
using namespace Assimp;
@ -52,7 +53,7 @@ class ut3DSImportExport : public AbstractImportExportBase {
public:
virtual bool importerTest() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/3DS/fels.3ds", 0 );
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/3DS/fels.3ds", aiProcess_ValidateDataStructure );
#ifndef ASSIMP_BUILD_NO_3DS_IMPORTER
return nullptr != scene;
#else

View File

@ -45,6 +45,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "AbstractImportExportBase.h"
#include <assimp/Importer.hpp>
#include <assimp/postprocess.h>
using namespace Assimp;
@ -52,7 +53,7 @@ class utACImportExport : public AbstractImportExportBase {
public:
virtual bool importerTest() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/AC/Wuson.ac", 0 );
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/AC/Wuson.ac", aiProcess_ValidateDataStructure );
return nullptr != scene;
}
};

View File

@ -45,6 +45,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "AbstractImportExportBase.h"
#include <assimp/Importer.hpp>
#include <assimp/postprocess.h>
using namespace Assimp;
@ -52,7 +53,7 @@ class utAMFImportExport : public AbstractImportExportBase {
public:
virtual bool importerTest() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/AMF/test1.amf", 0 );
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/AMF/test1.amf", aiProcess_ValidateDataStructure );
return nullptr != scene;
}
};

View File

@ -45,6 +45,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "AbstractImportExportBase.h"
#include <assimp/Importer.hpp>
#include <assimp/postprocess.h>
using namespace Assimp;
@ -52,7 +53,7 @@ class utASEImportExport : public AbstractImportExportBase {
public:
virtual bool importerTest() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/ASE/ThreeCubesGreen.ASE", 0 );
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/ASE/ThreeCubesGreen.ASE", aiProcess_ValidateDataStructure );
#ifndef ASSIMP_BUILD_NO_3DS_IMPORTER
return nullptr != scene;
#else

View File

@ -45,6 +45,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "AbstractImportExportBase.h"
#include <assimp/Importer.hpp>
#include <assimp/postprocess.h>
using namespace Assimp;
@ -52,7 +53,7 @@ class utB3DImportExport : public AbstractImportExportBase {
public:
virtual bool importerTest() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/B3D/WusonBlitz.b3d", 0 );
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/B3D/WusonBlitz.b3d", aiProcess_ValidateDataStructure );
return nullptr != scene;
}
};

View File

@ -43,6 +43,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "AbstractImportExportBase.h"
#include <assimp/Importer.hpp>
#include <assimp/postprocess.h>
using namespace Assimp;
@ -50,7 +51,7 @@ class utBVHImportExport : public AbstractImportExportBase {
public:
virtual bool importerTest() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/BVH/01_01.bvh", 0 );
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/BVH/01_01.bvh", aiProcess_ValidateDataStructure );
return nullptr != scene;
}
};

View File

@ -45,6 +45,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/Exporter.hpp>
#include <assimp/Importer.hpp>
#include <assimp/scene.h>
#include <assimp/postprocess.h>
class BlendImportAreaLight : public ::testing::Test {
public:
@ -67,7 +68,7 @@ protected:
// ------------------------------------------------------------------------------------------------
TEST_F(BlendImportAreaLight, testImportLight)
{
const aiScene* pTest = im->ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/AreaLight_269.blend",0);
const aiScene* pTest = im->ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/AreaLight_269.blend", aiProcess_ValidateDataStructure);
ASSERT_TRUE(pTest != NULL);
ASSERT_TRUE(pTest->HasLights());

View File

@ -44,6 +44,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/cexport.h>
#include <assimp/Importer.hpp>
#include <assimp/scene.h>
#include <assimp/postprocess.h>
class BlendImportMaterials : public ::testing::Test {
public:
@ -66,7 +67,7 @@ protected:
// ------------------------------------------------------------------------------------------------
TEST_F(BlendImportMaterials, testImportMaterial)
{
const aiScene* pTest = im->ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/BlenderMaterial_269.blend", 0);
const aiScene* pTest = im->ReadFile(ASSIMP_TEST_MODELS_DIR "/BLEND/BlenderMaterial_269.blend", aiProcess_ValidateDataStructure);
ASSERT_TRUE(pTest != NULL);
ASSERT_TRUE(pTest->HasMaterials());

View File

@ -43,6 +43,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "AbstractImportExportBase.h"
#include <assimp/Importer.hpp>
#include <assimp/postprocess.h>
using namespace Assimp;
@ -50,7 +51,7 @@ class utBlenderImporterExporter : public AbstractImportExportBase {
public:
virtual bool importerTest() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/BLEND/box.blend", 0 );
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/BLEND/box.blend", aiProcess_ValidateDataStructure );
return nullptr != scene;
}
};

View File

@ -43,6 +43,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "AbstractImportExportBase.h"
#include <assimp/Importer.hpp>
#include <assimp/postprocess.h>
using namespace Assimp;
@ -50,7 +51,7 @@ class utCSMImportExport : public AbstractImportExportBase {
public:
virtual bool importerTest() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/CSM/ThomasFechten.csm", 0 );
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/CSM/ThomasFechten.csm", aiProcess_ValidateDataStructure );
return nullptr != scene;
}
};

View File

@ -45,6 +45,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/Exporter.hpp>
#include <assimp/Importer.hpp>
#include <assimp/scene.h>
#include <assimp/postprocess.h>
#ifndef ASSIMP_BUILD_NO_EXPORT
@ -73,7 +74,7 @@ TEST_F(ColladaExportCamera, testExportCamera)
{
const char* file = "cameraExp.dae";
const aiScene* pTest = im->ReadFile(ASSIMP_TEST_MODELS_DIR "/Collada/cameras.dae",0);
const aiScene* pTest = im->ReadFile(ASSIMP_TEST_MODELS_DIR "/Collada/cameras.dae", aiProcess_ValidateDataStructure);
ASSERT_TRUE(pTest!=NULL);
ASSERT_TRUE(pTest->HasCameras());
@ -95,7 +96,7 @@ TEST_F(ColladaExportCamera, testExportCamera)
names[ i ] = orig->mName;
pos[ i ] = orig->mPosition;
}
const aiScene* imported = im->ReadFile(file,0);
const aiScene* imported = im->ReadFile(file, aiProcess_ValidateDataStructure);
ASSERT_TRUE(imported!=NULL);

View File

@ -45,6 +45,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/Exporter.hpp>
#include <assimp/Importer.hpp>
#include <assimp/scene.h>
#include <assimp/postprocess.h>
#ifndef ASSIMP_BUILD_NO_EXPORT
@ -72,7 +73,7 @@ TEST_F(ColladaExportLight, testExportLight)
{
const char* file = "lightsExp.dae";
const aiScene* pTest = im->ReadFile(ASSIMP_TEST_MODELS_DIR "/Collada/lights.dae",0);
const aiScene* pTest = im->ReadFile(ASSIMP_TEST_MODELS_DIR "/Collada/lights.dae", aiProcess_ValidateDataStructure);
ASSERT_TRUE(pTest!=NULL);
ASSERT_TRUE(pTest->HasLights());
@ -86,7 +87,7 @@ TEST_F(ColladaExportLight, testExportLight)
EXPECT_EQ(AI_SUCCESS,ex->Export(pTest,"collada",file));
const aiScene* imported = im->ReadFile(file,0);
const aiScene* imported = im->ReadFile(file, aiProcess_ValidateDataStructure);
ASSERT_TRUE(imported!=NULL);

View File

@ -43,6 +43,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "AbstractImportExportBase.h"
#include <assimp/Importer.hpp>
#include <assimp/postprocess.h>
using namespace Assimp;
@ -50,7 +51,7 @@ class utColladaImportExport : public AbstractImportExportBase {
public:
virtual bool importerTest() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/Collada/duck.dae", 0 );
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/Collada/duck.dae", aiProcess_ValidateDataStructure );
return nullptr != scene;
}
};

View File

@ -44,12 +44,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/Importer.hpp>
#include <assimp/scene.h>
#include <assimp/postprocess.h>
class utD3MFImporterExporter : public AbstractImportExportBase {
public:
virtual bool importerTest() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/3MF/box.3mf", 0);
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/3MF/box.3mf", aiProcess_ValidateDataStructure);
EXPECT_EQ( 1u, scene->mNumMeshes );
aiMesh *mesh = scene->mMeshes[ 0 ];
EXPECT_NE( nullptr, mesh );

View File

@ -45,6 +45,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "AbstractImportExportBase.h"
#include <assimp/Importer.hpp>
#include <assimp/postprocess.h>
using namespace Assimp;
@ -52,7 +53,7 @@ class utDXFImporterExporter : public AbstractImportExportBase {
public:
virtual bool importerTest() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/DXF/PinkEggFromLW.dxf", 0 );
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/DXF/PinkEggFromLW.dxf", aiProcess_ValidateDataStructure );
return nullptr != scene;
}
};

View File

@ -14,7 +14,7 @@ public:
ex = new Assimp::Exporter();
im = new Assimp::Importer();
pTest = im->ReadFile(ASSIMP_TEST_MODELS_DIR "/X/test.x",0);
pTest = im->ReadFile(ASSIMP_TEST_MODELS_DIR "/X/test.x", aiProcess_ValidateDataStructure);
}
virtual void TearDown()
@ -37,7 +37,7 @@ TEST_F(ExporterTest, testExportToFile)
EXPECT_EQ(AI_SUCCESS,ex->Export(pTest,"collada",file));
// check if we can read it again
EXPECT_TRUE(im->ReadFile(file,0));
EXPECT_TRUE(im->ReadFile(file, aiProcess_ValidateDataStructure));
}
// ------------------------------------------------------------------------------------------------

View File

@ -45,6 +45,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "AbstractImportExportBase.h"
#include <assimp/Importer.hpp>
#include <assimp/postprocess.h>
using namespace Assimp;
@ -52,7 +53,7 @@ class utFBXImporterExporter : public AbstractImportExportBase {
public:
virtual bool importerTest() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/FBX/spider.fbx", 0 );
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/FBX/spider.fbx", aiProcess_ValidateDataStructure );
return nullptr != scene;
}
};

View File

@ -43,6 +43,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "AbstractImportExportBase.h"
#include <assimp/Importer.hpp>
#include <assimp/postprocess.h>
using namespace Assimp;
@ -50,7 +51,7 @@ class utHMPImportExport : public AbstractImportExportBase {
public:
virtual bool importerTest() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/HMP/terrain.hmp", 0 );
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/HMP/terrain.hmp", aiProcess_ValidateDataStructure );
return nullptr != scene;
return true;

View File

@ -43,6 +43,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "AbstractImportExportBase.h"
#include <assimp/Importer.hpp>
#include <assimp/postprocess.h>
using namespace Assimp;
@ -50,7 +51,7 @@ class utIFCImportExport : public AbstractImportExportBase {
public:
virtual bool importerTest() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/IFC/AC14-FZK-Haus.ifc", 0 );
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/IFC/AC14-FZK-Haus.ifc", aiProcess_ValidateDataStructure );
return nullptr != scene;
return true;

View File

@ -44,6 +44,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/scene.h>
#include <assimp/Importer.hpp>
#include <assimp/Exporter.hpp>
#include <assimp/postprocess.h>
#include "TestModelFactory.h"
@ -66,7 +67,7 @@ TEST_F( utIssues, OpacityBugWhenExporting_727 ) {
EXPECT_NE( desc, nullptr );
path.append( desc->fileExtension );
EXPECT_EQ( AI_SUCCESS, exporter.Export( scene, desc->id, path ) );
const aiScene *newScene( importer.ReadFile( path, 0 ) );
const aiScene *newScene( importer.ReadFile( path, aiProcess_ValidateDataStructure ) );
EXPECT_TRUE( NULL != newScene );
float newOpacity;
if ( newScene->mNumMaterials > 0 ) {

View File

@ -193,7 +193,7 @@ protected:
virtual bool importerTest() {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/OBJ/spider.obj", 0 );
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/OBJ/spider.obj", aiProcess_ValidateDataStructure );
return nullptr != scene;
}
@ -202,7 +202,7 @@ protected:
virtual bool exporterTest() {
::Assimp::Importer importer;
::Assimp::Exporter exporter;
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/OBJ/spider.obj", 0 );
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/OBJ/spider.obj", aiProcess_ValidateDataStructure );
EXPECT_NE( nullptr, scene );
EXPECT_EQ( aiReturn_SUCCESS, exporter.Export( scene, "obj", ASSIMP_TEST_MODELS_DIR "/OBJ/spider_test.obj" ) );
EXPECT_EQ( aiReturn_SUCCESS, exporter.Export( scene, "objnomtl", ASSIMP_TEST_MODELS_DIR "/OBJ/spider_nomtl_test.obj" ) );
@ -257,7 +257,7 @@ TEST_F( utObjImportExport, issue1111_no_mat_name_Test ) {
TEST_F( utObjImportExport, issue809_vertex_color_Test ) {
::Assimp::Importer importer;
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/OBJ/cube_with_vertexcolors.obj", 0 );
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/OBJ/cube_with_vertexcolors.obj", aiProcess_ValidateDataStructure );
EXPECT_NE( nullptr, scene );
#ifndef ASSIMP_BUILD_NO_EXPORT

View File

@ -52,7 +52,7 @@ class utPMXImporter : public AbstractImportExportBase {
public:
virtual bool importerTest() {
Assimp::Importer importer;
/*const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/../models-nonbsd/MMD/Alicia_blade.pmx", 0 );
/*const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/../models-nonbsd/MMD/Alicia_blade.pmx", aiProcess_ValidateDataStructure );
return nullptr != scene;*/
return true;
}

View File

@ -44,6 +44,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "AbstractImportExportBase.h"
#include <assimp/Importer.hpp>
#include <assimp/postprocess.h>
using namespace Assimp;
@ -51,7 +52,7 @@ class utQ3DImportExport : public AbstractImportExportBase {
public:
virtual bool importerTest() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/Q3D/earth.q3o", 0 );
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/Q3D/earth.q3o", aiProcess_ValidateDataStructure );
return nullptr != scene;
}
};

View File

@ -43,6 +43,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "SIBImporter.h"
#include <assimp/Importer.hpp>
#include <assimp/postprocess.h>
#include "AbstractImportExportBase.h"
using namespace ::Assimp;
@ -51,7 +52,7 @@ class utSIBImporter : public AbstractImportExportBase {
public:
virtual bool importerTest() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/SIB/heffalump.sib", 0 );
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/SIB/heffalump.sib", aiProcess_ValidateDataStructure );
return nullptr != scene;
}
};

View File

@ -43,6 +43,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "SMDLoader.h"
#include <assimp/Importer.hpp>
#include <assimp/postprocess.h>
#include "AbstractImportExportBase.h"
using namespace ::Assimp;
@ -51,7 +52,7 @@ class utSMDImporter : public AbstractImportExportBase {
public:
virtual bool importerTest() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/SMD/triangle.smd", 0 );
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/SMD/triangle.smd", aiProcess_ValidateDataStructure );
return nullptr != scene;
}
};
@ -73,6 +74,6 @@ TEST_F( utSMDImporter, importTest ) {
TEST_F( utSMDImporter, issue_899_Texture_garbage_at_end_of_string_Test ) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/SMD/holy_grailref.smd", 0 );
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/SMD/holy_grailref.smd", aiProcess_ValidateDataStructure );
EXPECT_NE( nullptr, scene );
}

View File

@ -45,6 +45,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "AbstractImportExportBase.h"
#include <assimp/Importer.hpp>
#include <assimp/postprocess.h>
using namespace Assimp;
@ -52,7 +53,7 @@ class utSTLImporterExporter : public AbstractImportExportBase {
public:
virtual bool importerTest() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/STL/Spider_ascii.stl", 0 );
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/STL/Spider_ascii.stl", aiProcess_ValidateDataStructure );
return nullptr != scene;
}
};
@ -63,6 +64,6 @@ TEST_F( utSTLImporterExporter, importXFromFileTest ) {
TEST_F( utSTLImporterExporter, test_with_two_solids ) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/STL/triangle_with_two_solids.stl", 0 );
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/STL/triangle_with_two_solids.stl", aiProcess_ValidateDataStructure );
EXPECT_NE( nullptr, scene );
}

View File

@ -45,6 +45,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "AbstractImportExportBase.h"
#include <assimp/Importer.hpp>
#include <assimp/postprocess.h>
using namespace Assimp;
@ -52,7 +53,7 @@ class utX3DImportExport : public AbstractImportExportBase {
public:
virtual bool importerTest() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/X3D/ComputerKeyboard.x3d", 0 );
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/X3D/ComputerKeyboard.x3d", aiProcess_ValidateDataStructure );
return nullptr != scene;
}
};

View File

@ -45,6 +45,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "AbstractImportExportBase.h"
#include <assimp/Importer.hpp>
#include <assimp/postprocess.h>
using namespace Assimp;
@ -52,7 +53,7 @@ class utXImporterExporter : public AbstractImportExportBase {
public:
virtual bool importerTest() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/X/test.x", 0 );
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/X/test.x", aiProcess_ValidateDataStructure );
return nullptr != scene;
}
};

View File

@ -44,6 +44,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/Importer.hpp>
#include <assimp/Exporter.hpp>
#include <assimp/postprocess.h>
using namespace Assimp;
@ -51,7 +52,7 @@ class utglTF2ImportExport : public AbstractImportExportBase {
public:
virtual bool importerTest() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/glTF2/BoxTextured-glTF/BoxTextured.gltf", 0);
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/glTF2/BoxTextured-glTF/BoxTextured.gltf", aiProcess_ValidateDataStructure);
return nullptr != scene;
}
@ -59,7 +60,7 @@ public:
virtual bool exporterTest() {
Assimp::Importer importer;
Assimp::Exporter exporter;
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/glTF2/BoxTextured-glTF/BoxTextured.gltf", 0 );
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/glTF2/BoxTextured-glTF/BoxTextured.gltf", aiProcess_ValidateDataStructure );
EXPECT_NE( nullptr, scene );
EXPECT_EQ( aiReturn_SUCCESS, exporter.Export( scene, "gltf2", ASSIMP_TEST_MODELS_DIR "/glTF2/BoxTextured-glTF/BoxTextured_out.gltf" ) );

View File

@ -43,6 +43,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "AbstractImportExportBase.h"
#include <assimp/Importer.hpp>
#include <assimp/postprocess.h>
using namespace Assimp;
@ -50,7 +51,7 @@ class utglTFImportExport : public AbstractImportExportBase {
public:
virtual bool importerTest() {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/glTF/TwoBoxes/TwoBoxes.gltf", 0 );
const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/glTF/TwoBoxes/TwoBoxes.gltf", aiProcess_ValidateDataStructure );
return nullptr != scene;
}
};