diff --git a/CMakeLists.txt b/CMakeLists.txt index 5c496c190..f0736da74 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -269,9 +269,13 @@ option ( ASSIMP_BUILD_ASSIMP_TOOLS ON ) IF ( ASSIMP_BUILD_ASSIMP_TOOLS ) - IF ( WIN32 AND DirectX_FOUND ) - ADD_SUBDIRECTORY( tools/assimp_view/ ) - ENDIF ( WIN32 AND DirectX_FOUND ) + IF ( WIN32 ) + option ( ASSIMP_BUILD_ASSIMP_VIEW "If the Assimp view tool is built. (requires DirectX)" ${DirectX_FOUND} ) + IF ( ASSIMP_BUILD_ASSIMP_VIEW ) + ADD_SUBDIRECTORY( tools/assimp_view/ ) + ENDIF ( ASSIMP_BUILD_ASSIMP_VIEW ) + ENDIF ( WIN32 ) + ADD_SUBDIRECTORY( tools/assimp_cmd/ ) ENDIF ( ASSIMP_BUILD_ASSIMP_TOOLS ) diff --git a/code/CMakeLists.txt b/code/CMakeLists.txt index a6afb54dd..89bcdf9e1 100644 --- a/code/CMakeLists.txt +++ b/code/CMakeLists.txt @@ -446,6 +446,9 @@ ADD_ASSIMP_IMPORTER(IFC STEPFileEncoding.cpp STEPFileEncoding.h ) +if (MSVC AND ASSIMP_BUILD_IFC_IMPORTER) + set_source_files_properties(IFCReaderGen.cpp PROPERTIES COMPILE_FLAGS "/bigobj") +endif (MSVC AND ASSIMP_BUILD_IFC_IMPORTER) ADD_ASSIMP_IMPORTER(XGL XGLLoader.cpp diff --git a/code/glTFAsset.h b/code/glTFAsset.h index cb6bcc989..427695eda 100644 --- a/code/glTFAsset.h +++ b/code/glTFAsset.h @@ -754,12 +754,12 @@ namespace glTF virtual void WriteObjects(AssetWriter& writer) = 0; }; - //! (Stub class that is specialized in glTFAssetWriter.h) template - struct LazyDictWriter - { - static void Write(T& d, AssetWriter& w) {} - }; + class LazyDict; + + //! (Implemented in glTFAssetWriter.h) + template + void WriteLazyDict(LazyDict& d, AssetWriter& w); //! Manages lazy loading of the glTF top-level objects, and keeps a reference to them by ID //! It is the owner the loaded objects, so when it is destroyed it also deletes them @@ -782,7 +782,7 @@ namespace glTF void DetachFromDocument(); void WriteObjects(AssetWriter& writer) - { LazyDictWriter< LazyDict >::Write(*this, writer); } + { WriteLazyDict(*this, writer); } Ref Add(T* obj); @@ -810,14 +810,14 @@ namespace glTF { std::string copyright; //!< A copyright message suitable for display to credit the content creator. std::string generator; //!< Tool that generated this glTF model.Useful for debugging. - bool premultipliedAlpha; //!< Specifies if the shaders were generated with premultiplied alpha. (default: false) + bool premultipliedAlpha = false; //!< Specifies if the shaders were generated with premultiplied alpha. (default: false) struct { std::string api; //!< Specifies the target rendering API (default: "WebGL") std::string version; //!< Specifies the target rendering API (default: "1.0.3") } profile; //!< Specifies the target rendering API and version, e.g., WebGL 1.0.3. (default: {}) - int version; //!< The glTF format version (should be 1) + int version = 0; //!< The glTF format version (should be 1) void Read(Document& doc); }; @@ -894,6 +894,7 @@ namespace glTF public: Asset(IOSystem* io = 0) : mIOSystem(io) + , asset() , accessors (*this, "accessors") , animations (*this, "animations") , buffers (*this, "buffers") @@ -913,7 +914,6 @@ namespace glTF , lights (*this, "lights", "KHR_materials_common") { memset(&extensionsUsed, 0, sizeof(extensionsUsed)); - memset(&asset, 0, sizeof(asset)); } //! Main function diff --git a/code/glTFAsset.inl b/code/glTFAsset.inl index 858788b43..e38d72c03 100644 --- a/code/glTFAsset.inl +++ b/code/glTFAsset.inl @@ -71,11 +71,11 @@ namespace { }}; template<> struct ReadHelper { static bool Read(Value& val, const char*& out) { - return val.IsString() ? out = val.GetString(), true : false; + return val.IsString() ? (out = val.GetString(), true) : false; }}; template<> struct ReadHelper { static bool Read(Value& val, std::string& out) { - return val.IsString() ? out = val.GetString(), true : false; + return val.IsString() ? (out = std::string(val.GetString(), val.GetStringLength()), true) : false; }}; template struct ReadHelper< Nullable > { static bool Read(Value& val, Nullable& out) { @@ -842,7 +842,7 @@ inline void AssetMetadata::Read(Document& doc) if (version != 1) { char msg[128]; - ai_snprintf(msg, 128, "Unsupported glTF version: %d", version); + ai_snprintf(msg, 128, "Unsupported glTF version: %d", version); throw DeadlyImportError(msg); } } @@ -1013,30 +1013,26 @@ inline std::string Asset::FindUniqueID(const std::string& str, const char* suffi { std::string id = str; - Asset::IdMap::iterator it; + if (!id.empty()) { + if (mUsedIds.find(id) == mUsedIds.end()) + return id; - do { - if (!id.empty()) { - it = mUsedIds.find(id); - if (it == mUsedIds.end()) break; + id += "_"; + } - id += "_"; - } + id += suffix; - id += suffix; + Asset::IdMap::iterator it = mUsedIds.find(id); + if (it == mUsedIds.end()) + return id; + char buffer[256]; + int offset = ai_snprintf(buffer, sizeof(buffer), "%s_", id.c_str()); + for (int i = 0; it != mUsedIds.end(); ++i) { + ai_snprintf(buffer + offset, sizeof(buffer) - offset, "%d", i); + id = buffer; it = mUsedIds.find(id); - if (it == mUsedIds.end()) break; - - char buffer[256]; - int offset = ai_snprintf(buffer, 256, "%s_", id.c_str()); - for (int i = 0; it != mUsedIds.end(); ++i) { - ai_snprintf(buffer + offset, 256, "%d", i); - - id = buffer; - it = mUsedIds.find(id); - } - } while (false); // fake loop to allow using "break" + } return id; } diff --git a/code/glTFAssetWriter.h b/code/glTFAssetWriter.h index 4ddae7d53..370d2c0ab 100644 --- a/code/glTFAssetWriter.h +++ b/code/glTFAssetWriter.h @@ -58,7 +58,7 @@ using rapidjson::MemoryPoolAllocator; class AssetWriter { template - friend struct LazyDictWriter; + friend void WriteLazyDict(LazyDict& d, AssetWriter& w); private: diff --git a/code/glTFAssetWriter.inl b/code/glTFAssetWriter.inl index 1bbad9c56..ca2daeee6 100644 --- a/code/glTFAssetWriter.inl +++ b/code/glTFAssetWriter.inl @@ -484,13 +484,10 @@ namespace glTF { } template - struct LazyDictWriter< LazyDict > + void WriteLazyDict(LazyDict& d, AssetWriter& w) { - static void Write(LazyDict& d, AssetWriter& w) - { - w.WriteObjects(d); - } - }; + w.WriteObjects(d); + } } diff --git a/code/glTFImporter.cpp b/code/glTFImporter.cpp index 631c109d7..7b21da10a 100644 --- a/code/glTFImporter.cpp +++ b/code/glTFImporter.cpp @@ -50,6 +50,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include +#include "MakeVerboseFormat.h" + #include "glTFAsset.h" using namespace Assimp; @@ -617,7 +619,10 @@ void glTFImporter::InternReadFile(const std::string& pFile, aiScene* pScene, IOS ImportNodes(asset); // TODO: it does not split the loaded vertices, should it? - pScene->mFlags |= AI_SCENE_FLAGS_NON_VERBOSE_FORMAT; + //pScene->mFlags |= AI_SCENE_FLAGS_NON_VERBOSE_FORMAT; + Assimp::MakeVerboseFormatProcess process; + process.Execute(pScene); + if (pScene->mNumMeshes == 0) { pScene->mFlags |= AI_SCENE_FLAGS_INCOMPLETE;