diff --git a/code/AssetLib/B3D/B3DImporter.cpp b/code/AssetLib/B3D/B3DImporter.cpp index e87744603..bf8145798 100644 --- a/code/AssetLib/B3D/B3DImporter.cpp +++ b/code/AssetLib/B3D/B3DImporter.cpp @@ -418,7 +418,6 @@ void B3DImporter::ReadTRIS(int v0) { ASSIMP_LOG_ERROR("Bad triangle index: i0=", i0, ", i1=", i1, ", i2=", i2); #endif Fail("Bad triangle index"); - continue; } face->mNumIndices = 3; face->mIndices = new unsigned[3]; diff --git a/code/AssetLib/FBX/FBXConverter.cpp b/code/AssetLib/FBX/FBXConverter.cpp index 257845384..d742af447 100644 --- a/code/AssetLib/FBX/FBXConverter.cpp +++ b/code/AssetLib/FBX/FBXConverter.cpp @@ -152,7 +152,7 @@ void FBXConverter::ConvertRootNode() { mSceneOut->mRootNode->mName.Set(unique_name); // root has ID 0 - ConvertNodes(0L, mSceneOut->mRootNode, mSceneOut->mRootNode); + ConvertNodes(0L, mSceneOut->mRootNode, mSceneOut->mRootNode, aiMatrix4x4()); } static std::string getAncestorBaseName(const aiNode *node) { @@ -196,7 +196,7 @@ struct FBXConverter::PotentialNode { /// todo: get bone from stack /// todo: make map of aiBone* to aiNode* /// then update convert clusters to the new format -void FBXConverter::ConvertNodes(uint64_t id, aiNode *parent, aiNode *root_node) { +void FBXConverter::ConvertNodes(uint64_t id, aiNode *parent, aiNode *root_node, const aiMatrix4x4 &globalTransform) { const std::vector &conns = doc.GetConnectionsByDestinationSequenced(id, "Model"); std::vector nodes; @@ -290,14 +290,15 @@ void FBXConverter::ConvertNodes(uint64_t id, aiNode *parent, aiNode *root_node) } // recursion call - child nodes - ConvertNodes(model->ID(), last_parent, root_node); + aiMatrix4x4 newGlobalMatrix = globalTransform * nodes_chain.front().mNode->mTransformation; + ConvertNodes(model->ID(), last_parent, root_node, newGlobalMatrix); if (doc.Settings().readLights) { ConvertLights(*model, node_name); } if (doc.Settings().readCameras) { - ConvertCameras(*model, node_name); + ConvertCameras(*model, node_name, newGlobalMatrix); } nodes.push_back(std::move(nodes_chain.front())); @@ -327,12 +328,14 @@ void FBXConverter::ConvertLights(const Model &model, const std::string &orig_nam } } -void FBXConverter::ConvertCameras(const Model &model, const std::string &orig_name) { +void FBXConverter::ConvertCameras(const Model &model, + const std::string &orig_name, + const aiMatrix4x4 &transform) { const std::vector &node_attrs = model.GetAttributes(); for (const NodeAttribute *attr : node_attrs) { const Camera *const cam = dynamic_cast(attr); if (cam) { - ConvertCamera(*cam, orig_name); + ConvertCamera(*cam, orig_name, transform); } } } @@ -413,7 +416,9 @@ void FBXConverter::ConvertLight(const Light &light, const std::string &orig_name } } -void FBXConverter::ConvertCamera(const Camera &cam, const std::string &orig_name) { +void FBXConverter::ConvertCamera(const Camera &cam, + const std::string &orig_name, + aiMatrix4x4 transform) { cameras.push_back(new aiCamera()); aiCamera *const out_camera = cameras.back(); @@ -421,9 +426,16 @@ void FBXConverter::ConvertCamera(const Camera &cam, const std::string &orig_name out_camera->mAspect = cam.AspectWidth() / cam.AspectHeight(); + aiVector3D pos = cam.Position(); + out_camera->mLookAt = cam.InterestPosition(); + out_camera->mUp = pos + cam.UpVector(); + transform.Inverse(); + pos *= transform; + out_camera->mLookAt *= transform; + out_camera->mUp *= transform; + out_camera->mLookAt -= pos; + out_camera->mUp -= pos; 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()); diff --git a/code/AssetLib/FBX/FBXConverter.h b/code/AssetLib/FBX/FBXConverter.h index 41acb6ffe..b9b6c46b0 100644 --- a/code/AssetLib/FBX/FBXConverter.h +++ b/code/AssetLib/FBX/FBXConverter.h @@ -134,19 +134,22 @@ private: // ------------------------------------------------------------------------------------------------ // collect and assign child nodes - void ConvertNodes(uint64_t id, aiNode *parent, aiNode *root_node); + void ConvertNodes(uint64_t id, aiNode *parent, aiNode *root_node, + const aiMatrix4x4 &globalTransform); // ------------------------------------------------------------------------------------------------ void ConvertLights(const Model& model, const std::string &orig_name ); // ------------------------------------------------------------------------------------------------ - void ConvertCameras(const Model& model, const std::string &orig_name ); + void ConvertCameras(const Model& model, const std::string &orig_name, + const aiMatrix4x4 &transform); // ------------------------------------------------------------------------------------------------ void ConvertLight( const Light& light, const std::string &orig_name ); // ------------------------------------------------------------------------------------------------ - void ConvertCamera( const Camera& cam, const std::string &orig_name ); + void ConvertCamera(const Camera& cam, const std::string &orig_name, + aiMatrix4x4 transform); // ------------------------------------------------------------------------------------------------ void GetUniqueName( const std::string &name, std::string& uniqueName ); diff --git a/code/AssetLib/LWO/LWOMaterial.cpp b/code/AssetLib/LWO/LWOMaterial.cpp index 50bac884b..8d83dfb67 100644 --- a/code/AssetLib/LWO/LWOMaterial.cpp +++ b/code/AssetLib/LWO/LWOMaterial.cpp @@ -345,7 +345,7 @@ void LWOImporter::ConvertMaterial(const LWO::Surface &surf, aiMaterial *pcMat) { // (the diffuse value is just a scaling factor) // If a diffuse texture is set, we set this value to 1.0 - clr = (b && false ? aiColor3D(1.0, 1.0, 1.0) : surf.mColor); + clr = (b ? aiColor3D(1.0, 1.0, 1.0) : surf.mColor); clr.r *= surf.mDiffuseValue; clr.g *= surf.mDiffuseValue; clr.b *= surf.mDiffuseValue; diff --git a/code/AssetLib/glTF2/glTF2Importer.cpp b/code/AssetLib/glTF2/glTF2Importer.cpp index 428763798..394264a12 100644 --- a/code/AssetLib/glTF2/glTF2Importer.cpp +++ b/code/AssetLib/glTF2/glTF2Importer.cpp @@ -1213,11 +1213,6 @@ aiNode *ImportNode(aiScene *pScene, glTF2::Asset &r, std::vector & if (node.camera) { pScene->mCameras[node.camera.GetIndex()]->mName = ainode->mName; - if (node.translation.isPresent) { - aiVector3D trans; - CopyValue(node.translation.value, trans); - pScene->mCameras[node.camera.GetIndex()]->mPosition = trans; - } } if (node.light) { diff --git a/code/CMakeLists.txt b/code/CMakeLists.txt index d2c59d756..6f74823df 100644 --- a/code/CMakeLists.txt +++ b/code/CMakeLists.txt @@ -1245,11 +1245,9 @@ IF (ASSIMP_WARNINGS_AS_ERRORS) -Wno-deprecated-copy-with-dtor -Wno-deprecated -Wno-format-nonliteral - -Wno-format-non-iso -Wno-comma -Wno-unreachable-code-break -Wno-unreachable-code-return - -Wno-unreachable-code -Wno-implicit-fallthrough -Wno-unused-template -Wno-undefined-func-template diff --git a/code/Common/ImporterRegistry.cpp b/code/Common/ImporterRegistry.cpp index 78c02d96d..c67fee936 100644 --- a/code/Common/ImporterRegistry.cpp +++ b/code/Common/ImporterRegistry.cpp @@ -214,7 +214,12 @@ void GetImporterInstanceList(std::vector &out) { // Some importers may be unimplemented or otherwise unsuitable for general use // in their current state. Devs can set ASSIMP_ENABLE_DEV_IMPORTERS in their // local environment to enable them, otherwise they're left out of the registry. +#if defined(WINAPI_FAMILY) && WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP + // not supported under uwp const char *envStr = std::getenv("ASSIMP_ENABLE_DEV_IMPORTERS"); +#else + const char *envStr = { "0" }; +#endif bool devImportersEnabled = envStr && strcmp(envStr, "0"); // Ensure no unused var warnings if all uses are #ifndef'd away below: @@ -377,9 +382,6 @@ void GetImporterInstanceList(std::vector &out) { #ifndef ASSIMP_BUILD_NO_IQM_IMPORTER out.push_back(new IQMImporter()); #endif - //#ifndef ASSIMP_BUILD_NO_STEP_IMPORTER - // out.push_back(new StepFile::StepFileImporter()); - //#endif } /** will delete all registered importers. */ diff --git a/code/PostProcessing/PretransformVertices.cpp b/code/PostProcessing/PretransformVertices.cpp index b6bb6155e..16548f09c 100644 --- a/code/PostProcessing/PretransformVertices.cpp +++ b/code/PostProcessing/PretransformVertices.cpp @@ -577,7 +577,7 @@ void PretransformVertices::Execute(aiScene *pScene) { // multiply all properties of the camera with the absolute // transformation of the corresponding node cam->mPosition = nd->mTransformation * cam->mPosition; - cam->mLookAt = aiMatrix3x3(nd->mTransformation) * cam->mLookAt; + cam->mLookAt = nd->mTransformation * cam->mLookAt; cam->mUp = aiMatrix3x3(nd->mTransformation) * cam->mUp; } diff --git a/contrib/poly2tri/poly2tri/sweep/sweep.cc b/contrib/poly2tri/poly2tri/sweep/sweep.cc index 8e3d794c0..565a198d8 100644 --- a/contrib/poly2tri/poly2tri/sweep/sweep.cc +++ b/contrib/poly2tri/poly2tri/sweep/sweep.cc @@ -118,8 +118,8 @@ void Sweep::EdgeEvent(SweepContext& tcx, Point& ep, Point& eq, Triangle* triangl Point* p1 = triangle->PointCCW(point); Orientation o1 = Orient2d(eq, *p1, ep); if (o1 == COLLINEAR) { - // ASSIMP_CHANGE (aramis_acg) - throw std::runtime_error("EdgeEvent - collinear points not supported"); + + if( triangle->Contains(&eq, p1)) { triangle->MarkConstrainedEdge(&eq, p1 ); // We are modifying the constraint maybe it would be better to @@ -137,8 +137,8 @@ void Sweep::EdgeEvent(SweepContext& tcx, Point& ep, Point& eq, Triangle* triangl Point* p2 = triangle->PointCW(point); Orientation o2 = Orient2d(eq, *p2, ep); if (o2 == COLLINEAR) { - // ASSIMP_CHANGE (aramis_acg) - throw std::runtime_error("EdgeEvent - collinear points not supported"); + + if( triangle->Contains(&eq, p2)) { triangle->MarkConstrainedEdge(&eq, p2 ); diff --git a/include/assimp/StringUtils.h b/include/assimp/StringUtils.h index 59c6e9ead..cd8726785 100644 --- a/include/assimp/StringUtils.h +++ b/include/assimp/StringUtils.h @@ -56,7 +56,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include -#ifdef _MSC_VER +#if defined(_MSC_VER) && !defined(__clang__) #define AI_SIZEFMT "%Iu" #else #define AI_SIZEFMT "%zu"