From c3129e55d2f1a9d9b7db08fc3db29d8d549edaec Mon Sep 17 00:00:00 2001 From: Marc-Anton Boehm-von Thenen Date: Mon, 18 Feb 2019 14:10:32 +0100 Subject: [PATCH 1/9] [Issue_2340] Added ASSIMP_ANDROID_JNIIOSYSTEM precheck to only remain set to ON in proper ANDROID enabled toolchain environment --- code/CMakeLists.txt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/code/CMakeLists.txt b/code/CMakeLists.txt index 1726fda72..a677269f0 100644 --- a/code/CMakeLists.txt +++ b/code/CMakeLists.txt @@ -47,6 +47,11 @@ cmake_minimum_required( VERSION 2.6 ) SET( HEADER_PATH ../include/assimp ) +if(NOT (ANDROID AND ASSIMP_ANDROID_JNIIOSYSTEM)) + message(WARNING "Requesting Android JNI I/O-System in non-Android toolchain. Resetting ASSIMP_ANDROID_JNIIOSYSTEM to OFF.") + set(ASSIMP_ANDROID_JNIIOSYSTEM OFF) +endif(NOT (ANDROID AND ASSIMP_ANDROID_JNIIOSYSTEM)) + SET( COMPILER_HEADERS ${HEADER_PATH}/Compiler/pushpack1.h ${HEADER_PATH}/Compiler/poppack1.h @@ -932,11 +937,11 @@ TARGET_INCLUDE_DIRECTORIES ( assimp PUBLIC TARGET_LINK_LIBRARIES(assimp ${ZLIB_LIBRARIES} ${OPENDDL_PARSER_LIBRARIES} ${IRRXML_LIBRARY} ) -if(ANDROID AND ASSIMP_ANDROID_JNIIOSYSTEM) +if(ASSIMP_ANDROID_JNIIOSYSTEM) set(ASSIMP_ANDROID_JNIIOSYSTEM_PATH port/AndroidJNI) add_subdirectory(../${ASSIMP_ANDROID_JNIIOSYSTEM_PATH}/ ../${ASSIMP_ANDROID_JNIIOSYSTEM_PATH}/) target_link_libraries(assimp android_jniiosystem) -endif(ANDROID AND ASSIMP_ANDROID_JNIIOSYSTEM) +endif(ASSIMP_ANDROID_JNIIOSYSTEM) IF (ASSIMP_BUILD_NONFREE_C4D_IMPORTER) TARGET_LINK_LIBRARIES(assimp optimized ${C4D_RELEASE_LIBRARIES}) From a94c8bf3f69fd072d9896e2e2881a0fcc0636e88 Mon Sep 17 00:00:00 2001 From: Marc-Anton Boehm-von Thenen Date: Mon, 18 Feb 2019 14:14:27 +0100 Subject: [PATCH 2/9] [Issue_2340] Wrong precondition layout... missed ANDROID=ON and ASSIMP_ANDROID_JNIIOSYSTEM=OFFvalid constellation --- code/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/CMakeLists.txt b/code/CMakeLists.txt index a677269f0..2c48f3742 100644 --- a/code/CMakeLists.txt +++ b/code/CMakeLists.txt @@ -47,7 +47,7 @@ cmake_minimum_required( VERSION 2.6 ) SET( HEADER_PATH ../include/assimp ) -if(NOT (ANDROID AND ASSIMP_ANDROID_JNIIOSYSTEM)) +if(NOT ANDROID AND ASSIMP_ANDROID_JNIIOSYSTEM) message(WARNING "Requesting Android JNI I/O-System in non-Android toolchain. Resetting ASSIMP_ANDROID_JNIIOSYSTEM to OFF.") set(ASSIMP_ANDROID_JNIIOSYSTEM OFF) endif(NOT (ANDROID AND ASSIMP_ANDROID_JNIIOSYSTEM)) From 4d0740a12000b0ae8ed202639690173eecd09b78 Mon Sep 17 00:00:00 2001 From: Marc-Anton Boehm-von Thenen Date: Mon, 18 Feb 2019 14:15:39 +0100 Subject: [PATCH 3/9] [Issue_2340] Proper closing endif()... --- code/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/CMakeLists.txt b/code/CMakeLists.txt index 2c48f3742..37ad34b85 100644 --- a/code/CMakeLists.txt +++ b/code/CMakeLists.txt @@ -50,7 +50,7 @@ SET( HEADER_PATH ../include/assimp ) if(NOT ANDROID AND ASSIMP_ANDROID_JNIIOSYSTEM) message(WARNING "Requesting Android JNI I/O-System in non-Android toolchain. Resetting ASSIMP_ANDROID_JNIIOSYSTEM to OFF.") set(ASSIMP_ANDROID_JNIIOSYSTEM OFF) -endif(NOT (ANDROID AND ASSIMP_ANDROID_JNIIOSYSTEM)) +endif(NOT ANDROID AND ASSIMP_ANDROID_JNIIOSYSTEM) SET( COMPILER_HEADERS ${HEADER_PATH}/Compiler/pushpack1.h From ae41ae32119f8c8105d154f1c96326632cd92fd4 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Mon, 18 Feb 2019 21:43:45 +0100 Subject: [PATCH 4/9] closes https://github.com/assimp/assimp/issues/305': fix viewer --- code/FBXConverter.cpp | 3 +-- code/FBXImporter.cpp | 13 ++++++++----- tools/assimp_view/assimp_view.cpp | 23 ++++++++++++++++------- 3 files changed, 25 insertions(+), 14 deletions(-) diff --git a/code/FBXConverter.cpp b/code/FBXConverter.cpp index d88a3cacd..1bfc90b6d 100644 --- a/code/FBXConverter.cpp +++ b/code/FBXConverter.cpp @@ -1291,8 +1291,7 @@ namespace Assimp { unsigned int cursor = 0, in_cursor = 0; itf = faces.begin(); - for (MatIndexArray::const_iterator it = mindices.begin(), - end = mindices.end(); it != end; ++it, ++itf) + for (MatIndexArray::const_iterator it = mindices.begin(), end = mindices.end(); it != end; ++it, ++itf) { const unsigned int pcount = *itf; if ((*it) != index) { diff --git a/code/FBXImporter.cpp b/code/FBXImporter.cpp index 72f8eea8e..2cc8bffc2 100644 --- a/code/FBXImporter.cpp +++ b/code/FBXImporter.cpp @@ -60,11 +60,13 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include namespace Assimp { - template<> const char* LogFunctions::Prefix() - { - static auto prefix = "FBX: "; - return prefix; - } + +template<> +const char* LogFunctions::Prefix() { + static auto prefix = "FBX: "; + return prefix; +} + } using namespace Assimp; @@ -72,6 +74,7 @@ using namespace Assimp::Formatter; using namespace Assimp::FBX; namespace { + static const aiImporterDesc desc = { "Autodesk FBX Importer", "", diff --git a/tools/assimp_view/assimp_view.cpp b/tools/assimp_view/assimp_view.cpp index 355287e0d..1bcdce967 100644 --- a/tools/assimp_view/assimp_view.cpp +++ b/tools/assimp_view/assimp_view.cpp @@ -508,19 +508,28 @@ int CreateAssetData() unsigned int nidx; switch (mesh->mPrimitiveTypes) { case aiPrimitiveType_POINT: - nidx = 1;break; + nidx = 1; + break; case aiPrimitiveType_LINE: - nidx = 2;break; + nidx = 2; + break; case aiPrimitiveType_TRIANGLE: - nidx = 3;break; - default: ai_assert(false); + nidx = 3; + break; + default: + ai_assert(false); + break; }; + unsigned int numIndices = mesh->mNumFaces * 3; + if (0 == numIndices && nidx == 1) { + numIndices = mesh->mNumVertices; + } // check whether we can use 16 bit indices - if (mesh->mNumFaces * 3 >= 65536) { + if (numIndices >= 65536) { // create 32 bit index buffer if(FAILED( g_piDevice->CreateIndexBuffer( 4 * - mesh->mNumFaces * nidx, + numIndices, D3DUSAGE_WRITEONLY | dwUsage, D3DFMT_INDEX32, D3DPOOL_DEFAULT, @@ -546,7 +555,7 @@ int CreateAssetData() else { // create 16 bit index buffer if(FAILED( g_piDevice->CreateIndexBuffer( 2 * - mesh->mNumFaces * nidx, + numIndices, D3DUSAGE_WRITEONLY | dwUsage, D3DFMT_INDEX16, D3DPOOL_DEFAULT, From ea2e6936e5c2881e3fb220c2df5a869f796e8a08 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Mon, 18 Feb 2019 21:44:07 +0100 Subject: [PATCH 5/9] Add test file. --- test/models/PLY/points.ply | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 test/models/PLY/points.ply diff --git a/test/models/PLY/points.ply b/test/models/PLY/points.ply new file mode 100644 index 000000000..91f4bb83b --- /dev/null +++ b/test/models/PLY/points.ply @@ -0,0 +1,17 @@ +ply +format ascii 1.0 +element vertex 4 +property float x +property float y +property float z +property uchar red +property uchar green +property uchar blue +property float nx +property float ny +property float nz +end_header +0.0 0.0 0.0 255 255 255 0.0 1.0 0.0 +0.0 0.0 1.0 255 0 255 0.0 0.0 1.0 +0.0 1.0 0.0 255 255 0 1.0 0.0 0.0 +0.0 1.0 1.0 0 255 255 1.0 1.0 0.0 From b0f94c4620b63fefada6e57864f6bd4356a12b94 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Tue, 19 Feb 2019 11:19:53 +0100 Subject: [PATCH 6/9] Update appveyor.yml Disable vs2015-test --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 2b5f212f9..c14553708 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -15,7 +15,7 @@ matrix: image: - Visual Studio 2013 - - Visual Studio 2015 +# - Visual Studio 2015 - Visual Studio 2017 platform: From ebf9deb6e0f04116ded902d89e309ef1109d3d0e Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Tue, 19 Feb 2019 11:28:15 +0100 Subject: [PATCH 7/9] Update appveyor.yml Disable vs2017 --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index c14553708..a1890b9cb 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -16,7 +16,7 @@ matrix: image: - Visual Studio 2013 # - Visual Studio 2015 - - Visual Studio 2017 +# - Visual Studio 2017 platform: - Win32 From adbc7e8f7036f92c6102af2a2a598c37491be771 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Tue, 19 Feb 2019 20:23:20 +0100 Subject: [PATCH 8/9] closes https://github.com/assimp/assimp/issues/2115: rollback setup of FBX-camera. --- code/ColladaLoader.cpp | 16 +++++++++------- code/FBXConverter.cpp | 13 +++++++++++-- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/code/ColladaLoader.cpp b/code/ColladaLoader.cpp index 0c87330a9..2a3412ac2 100644 --- a/code/ColladaLoader.cpp +++ b/code/ColladaLoader.cpp @@ -109,13 +109,13 @@ ColladaLoader::~ColladaLoader() { // ------------------------------------------------------------------------------------------------ // Returns whether the class can handle the format of the given file. -bool ColladaLoader::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool checkSig) const -{ +bool ColladaLoader::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool checkSig) const { // check file extension std::string extension = GetExtension(pFile); - if( extension == "dae") + if (extension == "dae") { return true; + } // XML - too generic, we need to open the file and search for typical keywords if( extension == "xml" || !extension.length() || checkSig) { @@ -123,10 +123,13 @@ bool ColladaLoader::CanRead( const std::string& pFile, IOSystem* pIOHandler, boo * support a specific file extension in general pIOHandler * might be NULL and it's our duty to return true here. */ - if (!pIOHandler)return true; + if (!pIOHandler) { + return true; + } const char* tokens[] = {"mRootNode->mTransformation *= aiMatrix4x4(parser.mUnitSize, 0, 0, 0, 0, parser.mUnitSize, 0, 0, 0, 0, parser.mUnitSize, 0, diff --git a/code/FBXConverter.cpp b/code/FBXConverter.cpp index 1bfc90b6d..a81f1e615 100644 --- a/code/FBXConverter.cpp +++ b/code/FBXConverter.cpp @@ -390,9 +390,18 @@ namespace Assimp { out_camera->mAspect = cam.AspectWidth() / cam.AspectHeight(); //cameras are defined along positive x direction - out_camera->mPosition = cam.Position(); + /*out_camera->mPosition = cam.Position(); out_camera->mLookAt = (cam.InterestPosition() - out_camera->mPosition).Normalize(); - out_camera->mUp = cam.UpVector(); + out_camera->mUp = cam.UpVector();*/ + + out_camera->mPosition = aiVector3D(0.0f); + out_camera->mLookAt = aiVector3D(1.0f, 0.0f, 0.0f); + out_camera->mUp = aiVector3D(0.0f, 1.0f, 0.0f); + + out_camera->mHorizontalFOV = AI_DEG_TO_RAD(cam.FieldOfView()); + + out_camera->mClipPlaneNear = cam.NearPlane(); + out_camera->mClipPlaneFar = cam.FarPlane(); out_camera->mHorizontalFOV = AI_DEG_TO_RAD(cam.FieldOfView()); out_camera->mClipPlaneNear = cam.NearPlane(); From f59f3976c04ceb74744386915331e1142cab60a5 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Wed, 20 Feb 2019 00:02:19 +0100 Subject: [PATCH 9/9] closes https://github.com/assimp/assimp/issues/1593: fix computation of percentf for 3DS. --- code/3DSLoader.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/code/3DSLoader.cpp b/code/3DSLoader.cpp index 24626d936..96b80c962 100644 --- a/code/3DSLoader.cpp +++ b/code/3DSLoader.cpp @@ -249,13 +249,14 @@ void Discreet3DSImporter::ApplyMasterScale(aiScene* pScene) // Reads a new chunk from the file void Discreet3DSImporter::ReadChunk(Discreet3DS::Chunk* pcOut) { - ai_assert(pcOut != NULL); + ai_assert(pcOut != nullptr); pcOut->Flag = stream->GetI2(); pcOut->Size = stream->GetI4(); - if (pcOut->Size - sizeof(Discreet3DS::Chunk) > stream->GetRemainingSize()) + if (pcOut->Size - sizeof(Discreet3DS::Chunk) > stream->GetRemainingSize()) { throw DeadlyImportError("Chunk is too large"); + } if (pcOut->Size - sizeof(Discreet3DS::Chunk) > stream->GetRemainingSizeToLimit()) { ASSIMP_LOG_ERROR("3DS: Chunk overflow"); @@ -1343,15 +1344,16 @@ void Discreet3DSImporter::ParseTextureChunk(D3DS::Texture* pcOut) // ------------------------------------------------------------------------------------------------ // Read a percentage chunk -ai_real Discreet3DSImporter::ParsePercentageChunk() -{ +ai_real Discreet3DSImporter::ParsePercentageChunk() { Discreet3DS::Chunk chunk; ReadChunk(&chunk); - if (Discreet3DS::CHUNK_PERCENTF == chunk.Flag) - return stream->GetF4(); - else if (Discreet3DS::CHUNK_PERCENTW == chunk.Flag) + if (Discreet3DS::CHUNK_PERCENTF == chunk.Flag) { + return stream->GetF4() * ai_real(100) / ai_real(0xFFFF); + } else if (Discreet3DS::CHUNK_PERCENTW == chunk.Flag) { return (ai_real)((uint16_t)stream->GetI2()) / (ai_real)0xFFFF; + } + return get_qnan(); }