소스 검색

Merge branch 'master' into fix-codacy-issues

Kim Kulling 6 년 전
부모
커밋
4b9cc1a484

+ 2 - 1
.travis.sh

@@ -7,7 +7,8 @@
 #
 #
 function generate() {
 function generate() {
     OPTIONS="-DASSIMP_WERROR=ON"
     OPTIONS="-DASSIMP_WERROR=ON"
-
+    OPTIONS="$OPTIONS -DASSIMP_NO_EXPORT=NO"
+    
     if [ "$DISABLE_EXPORTERS" = "YES" ] ; then
     if [ "$DISABLE_EXPORTERS" = "YES" ] ; then
         OPTIONS="$OPTIONS -DASSIMP_NO_EXPORT=YES"
         OPTIONS="$OPTIONS -DASSIMP_NO_EXPORT=YES"
     else
     else

+ 4 - 3
code/Collada/ColladaExporter.cpp

@@ -45,6 +45,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 
 #include "ColladaExporter.h"
 #include "ColladaExporter.h"
 #include <assimp/Bitmap.h>
 #include <assimp/Bitmap.h>
+#include <assimp/MathFunctions.h>
 #include <assimp/fast_atof.h>
 #include <assimp/fast_atof.h>
 #include <assimp/SceneCombiner.h>
 #include <assimp/SceneCombiner.h>
 #include <assimp/StringUtils.h>
 #include <assimp/StringUtils.h>
@@ -155,7 +156,7 @@ void ColladaExporter::WriteFile() {
 // ------------------------------------------------------------------------------------------------
 // ------------------------------------------------------------------------------------------------
 // Writes the asset header
 // Writes the asset header
 void ColladaExporter::WriteHeader() {
 void ColladaExporter::WriteHeader() {
-    static const ai_real epsilon = ai_real( 0.00001 );
+    static const ai_real epsilon = Math::getEpsilon<ai_real>();
     static const aiQuaternion x_rot(aiMatrix3x3(
     static const aiQuaternion x_rot(aiMatrix3x3(
         0, -1,  0,
         0, -1,  0,
         1,  0,  0,
         1,  0,  0,
@@ -317,7 +318,7 @@ void ColladaExporter::WriteTextures() {
 
 
             std::string name = mFile + "_texture_" + (i < 1000 ? "0" : "") + (i < 100 ? "0" : "") + (i < 10 ? "0" : "") + str + "." + ((const char*) texture->achFormatHint);
             std::string name = mFile + "_texture_" + (i < 1000 ? "0" : "") + (i < 100 ? "0" : "") + (i < 10 ? "0" : "") + str + "." + ((const char*) texture->achFormatHint);
 
 
-            std::unique_ptr<IOStream> outfile(mIOSystem->Open(mPath + name, "wb"));
+            std::unique_ptr<IOStream> outfile(mIOSystem->Open(mPath + mIOSystem->getOsSeparator() + name, "wb"));
             if(outfile == NULL) {
             if(outfile == NULL) {
                 throw DeadlyExportError("could not open output texture file: " + mPath + name);
                 throw DeadlyExportError("could not open output texture file: " + mPath + name);
             }
             }
@@ -1671,4 +1672,4 @@ void ColladaExporter::WriteNode( const aiScene* pScene, aiNode* pNode)
 }
 }
 
 
 #endif
 #endif
-#endif
+#endif

+ 4 - 3
code/FBX/FBXConverter.cpp

@@ -55,6 +55,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #include "FBXImporter.h"
 #include "FBXImporter.h"
 
 
 #include <assimp/StringComparison.h>
 #include <assimp/StringComparison.h>
+#include <assimp/MathFunctions.h>
 
 
 #include <assimp/scene.h>
 #include <assimp/scene.h>
 
 
@@ -553,7 +554,7 @@ namespace Assimp {
                 return;
                 return;
             }
             }
 
 
-            const float angle_epsilon = 1e-6f;
+            const float angle_epsilon = Math::getEpsilon<float>();
 
 
             out = aiMatrix4x4();
             out = aiMatrix4x4();
 
 
@@ -694,7 +695,7 @@ namespace Assimp {
             std::fill_n(chain, static_cast<unsigned int>(TransformationComp_MAXIMUM), aiMatrix4x4());
             std::fill_n(chain, static_cast<unsigned int>(TransformationComp_MAXIMUM), aiMatrix4x4());
 
 
             // generate transformation matrices for all the different transformation components
             // generate transformation matrices for all the different transformation components
-            const float zero_epsilon = 1e-6f;
+            const float zero_epsilon = Math::getEpsilon<float>();
             const aiVector3D all_ones(1.0f, 1.0f, 1.0f);
             const aiVector3D all_ones(1.0f, 1.0f, 1.0f);
 
 
             const aiVector3D& PreRotation = PropertyGet<aiVector3D>(props, "PreRotation", ok);
             const aiVector3D& PreRotation = PropertyGet<aiVector3D>(props, "PreRotation", ok);
@@ -2967,7 +2968,7 @@ void FBXConverter::SetShadingPropertiesRaw(aiMaterial* out_mat, const PropertyTa
                 TransformationCompDefaultValue(comp)
                 TransformationCompDefaultValue(comp)
                 );
                 );
 
 
-            const float epsilon = 1e-6f;
+            const float epsilon = Math::getEpsilon<float>();
             return (dyn_val - static_val).SquareLength() < epsilon;
             return (dyn_val - static_val).SquareLength() < epsilon;
         }
         }
 
 

+ 1 - 1
code/Importer/IFC/IFCCurve.cpp

@@ -499,7 +499,7 @@ bool Curve::InRange(IfcFloat u) const {
     if (IsClosed()) {
     if (IsClosed()) {
         return true;
         return true;
     }
     }
-    const IfcFloat epsilon = 1e-5;
+    const IfcFloat epsilon = Math::getEpsilon<float>();
     return u - range.first > -epsilon && range.second - u > -epsilon;
     return u - range.first > -epsilon && range.second - u > -epsilon;
 }
 }
 #endif
 #endif

+ 3 - 3
code/Importer/IFC/IFCOpenings.cpp

@@ -593,7 +593,7 @@ typedef std::vector<std::pair<
 bool BoundingBoxesAdjacent(const BoundingBox& bb, const BoundingBox& ibb)
 bool BoundingBoxesAdjacent(const BoundingBox& bb, const BoundingBox& ibb)
 {
 {
     // TODO: I'm pretty sure there is a much more compact way to check this
     // TODO: I'm pretty sure there is a much more compact way to check this
-    const IfcFloat epsilon = 1e-5f;
+    const IfcFloat epsilon = Math::getEpsilon<float>();
     return  (std::fabs(bb.second.x - ibb.first.x) < epsilon && bb.first.y <= ibb.second.y && bb.second.y >= ibb.first.y) ||
     return  (std::fabs(bb.second.x - ibb.first.x) < epsilon && bb.first.y <= ibb.second.y && bb.second.y >= ibb.first.y) ||
         (std::fabs(bb.first.x - ibb.second.x) < epsilon && ibb.first.y <= bb.second.y && ibb.second.y >= bb.first.y) ||
         (std::fabs(bb.first.x - ibb.second.x) < epsilon && ibb.first.y <= bb.second.y && ibb.second.y >= bb.first.y) ||
         (std::fabs(bb.second.y - ibb.first.y) < epsilon && bb.first.x <= ibb.second.x && bb.second.x >= ibb.first.x) ||
         (std::fabs(bb.second.y - ibb.first.y) < epsilon && bb.first.x <= ibb.second.x && bb.second.x >= ibb.first.x) ||
@@ -681,7 +681,7 @@ bool IntersectingLineSegments(const IfcVector2& n0, const IfcVector2& n1,
 // ------------------------------------------------------------------------------------------------
 // ------------------------------------------------------------------------------------------------
 void FindAdjacentContours(ContourVector::iterator current, const ContourVector& contours)
 void FindAdjacentContours(ContourVector::iterator current, const ContourVector& contours)
 {
 {
-    const IfcFloat sqlen_epsilon = static_cast<IfcFloat>(1e-8);
+    const IfcFloat sqlen_epsilon = static_cast<IfcFloat>(Math::getEpsilon<float>());
     const BoundingBox& bb = (*current).bb;
     const BoundingBox& bb = (*current).bb;
 
 
     // What is to be done here is to populate the skip lists for the contour
     // What is to be done here is to populate the skip lists for the contour
@@ -758,7 +758,7 @@ void FindAdjacentContours(ContourVector::iterator current, const ContourVector&
 // ------------------------------------------------------------------------------------------------
 // ------------------------------------------------------------------------------------------------
 AI_FORCE_INLINE bool LikelyBorder(const IfcVector2& vdelta)
 AI_FORCE_INLINE bool LikelyBorder(const IfcVector2& vdelta)
 {
 {
-    const IfcFloat dot_point_epsilon = static_cast<IfcFloat>(1e-5);
+    const IfcFloat dot_point_epsilon = static_cast<IfcFloat>(Math::getEpsilon<float>());
     return std::fabs(vdelta.x * vdelta.y) < dot_point_epsilon;
     return std::fabs(vdelta.x * vdelta.y) < dot_point_epsilon;
 }
 }
 
 

+ 2 - 1
code/MD5/MD5Loader.cpp

@@ -53,6 +53,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #include "MD5Loader.h"
 #include "MD5Loader.h"
 #include <assimp/StringComparison.h>
 #include <assimp/StringComparison.h>
 #include <assimp/fast_atof.h>
 #include <assimp/fast_atof.h>
+#include <assimp/MathFunctions.h>
 #include <assimp/SkeletonMeshBuilder.h>
 #include <assimp/SkeletonMeshBuilder.h>
 #include <assimp/Importer.hpp>
 #include <assimp/Importer.hpp>
 #include <assimp/scene.h>
 #include <assimp/scene.h>
@@ -64,7 +65,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 using namespace Assimp;
 using namespace Assimp;
 
 
 // Minimum weight value. Weights inside [-n ... n] are ignored
 // Minimum weight value. Weights inside [-n ... n] are ignored
-#define AI_MD5_WEIGHT_EPSILON 1e-5f
+#define AI_MD5_WEIGHT_EPSILON Math::getEpsilon<float>()
 
 
 
 
 static const aiImporterDesc desc = {
 static const aiImporterDesc desc = {

+ 16 - 25
code/MDL/MDLLoader.cpp

@@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
 
 
 Copyright (c) 2006-2019, assimp team
 Copyright (c) 2006-2019, assimp team
 
 
-
-
 All rights reserved.
 All rights reserved.
 
 
 Redistribution and use of this software in source and binary forms,
 Redistribution and use of this software in source and binary forms,
@@ -94,23 +92,24 @@ static const aiImporterDesc desc = {
 // ------------------------------------------------------------------------------------------------
 // ------------------------------------------------------------------------------------------------
 // Constructor to be privately used by Importer
 // Constructor to be privately used by Importer
 MDLImporter::MDLImporter()
 MDLImporter::MDLImporter()
-    : configFrameID(),
-    mBuffer(),
-    iGSFileVersion(),
-    pIOHandler(),
-    pScene(),
-    iFileSize()
-{}
+: configFrameID()
+, mBuffer()
+, iGSFileVersion()
+, pIOHandler()
+, pScene()
+, iFileSize() {
+    // empty
+}
 
 
 // ------------------------------------------------------------------------------------------------
 // ------------------------------------------------------------------------------------------------
 // Destructor, private as well
 // Destructor, private as well
-MDLImporter::~MDLImporter()
-{}
+MDLImporter::~MDLImporter() {
+    // empty
+}
 
 
 // ------------------------------------------------------------------------------------------------
 // ------------------------------------------------------------------------------------------------
 // Returns whether the class can handle the format of the given file.
 // Returns whether the class can handle the format of the given file.
-bool MDLImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool checkSig) const
-{
+bool MDLImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool checkSig) const {
     const std::string extension = GetExtension(pFile);
     const std::string extension = GetExtension(pFile);
 
 
     // if check for extension is not enough, check for the magic tokens
     // if check for extension is not enough, check for the magic tokens
@@ -404,23 +403,15 @@ void MDLImporter::InternReadFile_Quake1() {
 
 
     // now get a pointer to the first frame in the file
     // now get a pointer to the first frame in the file
     BE_NCONST MDL::Frame* pcFrames = (BE_NCONST MDL::Frame*)szCurrent;
     BE_NCONST MDL::Frame* pcFrames = (BE_NCONST MDL::Frame*)szCurrent;
-    BE_NCONST MDL::SimpleFrame* pcFirstFrame;
+    MDL::SimpleFrame* pcFirstFrame;
 
 
     if (0 == pcFrames->type) {
     if (0 == pcFrames->type) {
         // get address of single frame
         // get address of single frame
-        pcFirstFrame = &pcFrames->frame;
+        pcFirstFrame =( MDL::SimpleFrame*) &pcFrames->frame;
     } else {
     } else {
         // get the first frame in the group
         // get the first frame in the group
-
-#if 1
-        // FIXME: the cast is wrong and cause a warning on clang 5.0
-        // disable this code for now, fix it later
-        ai_assert(false && "Bad pointer cast");
-        pcFirstFrame = nullptr; // Workaround: msvc++ C4703 error
-#else
-        BE_NCONST MDL::GroupFrame* pcFrames2 = (BE_NCONST MDL::GroupFrame*)pcFrames;
-        pcFirstFrame = (BE_NCONST MDL::SimpleFrame*)(&pcFrames2->time + pcFrames->type);
-#endif
+        BE_NCONST MDL::GroupFrame* pcFrames2 = (BE_NCONST MDL::GroupFrame*) pcFrames;
+        pcFirstFrame = &(pcFrames2->frames[0]);
     }
     }
     BE_NCONST MDL::Vertex* pcVertices = (BE_NCONST MDL::Vertex*) ((pcFirstFrame->name) + sizeof(pcFirstFrame->name));
     BE_NCONST MDL::Vertex* pcVertices = (BE_NCONST MDL::Vertex*) ((pcFirstFrame->name) + sizeof(pcFirstFrame->name));
     VALIDATE_FILE_SIZE((const unsigned char*)(pcVertices + pcHeader->num_verts));
     VALIDATE_FILE_SIZE((const unsigned char*)(pcVertices + pcHeader->num_verts));

+ 1 - 17
code/MDL/MDLLoader.h

@@ -89,16 +89,12 @@ public:
     MDLImporter();
     MDLImporter();
     ~MDLImporter();
     ~MDLImporter();
 
 
-
-public:
-
     // -------------------------------------------------------------------
     // -------------------------------------------------------------------
     /** Returns whether the class can handle the format of the given file.
     /** Returns whether the class can handle the format of the given file.
     * See BaseImporter::CanRead() for details.  */
     * See BaseImporter::CanRead() for details.  */
     bool CanRead( const std::string& pFile, IOSystem* pIOHandler,
     bool CanRead( const std::string& pFile, IOSystem* pIOHandler,
         bool checkSig) const;
         bool checkSig) const;
 
 
-
     // -------------------------------------------------------------------
     // -------------------------------------------------------------------
     /** Called prior to ReadFile().
     /** Called prior to ReadFile().
     * The function is a request to the importer to update its configuration
     * The function is a request to the importer to update its configuration
@@ -107,8 +103,6 @@ public:
     void SetupProperties(const Importer* pImp);
     void SetupProperties(const Importer* pImp);
 
 
 protected:
 protected:
-
-
     // -------------------------------------------------------------------
     // -------------------------------------------------------------------
     /** Return importer meta information.
     /** Return importer meta information.
      * See #BaseImporter::GetInfo for the details
      * See #BaseImporter::GetInfo for the details
@@ -122,8 +116,6 @@ protected:
     void InternReadFile( const std::string& pFile, aiScene* pScene,
     void InternReadFile( const std::string& pFile, aiScene* pScene,
         IOSystem* pIOHandler);
         IOSystem* pIOHandler);
 
 
-protected:
-
     // -------------------------------------------------------------------
     // -------------------------------------------------------------------
     /** Import a quake 1 MDL file (IDPO)
     /** Import a quake 1 MDL file (IDPO)
     */
     */
@@ -154,7 +146,6 @@ protected:
     void SizeCheck(const void* szPos);
     void SizeCheck(const void* szPos);
     void SizeCheck(const void* szPos, const char* szFile, unsigned int iLine);
     void SizeCheck(const void* szPos, const char* szFile, unsigned int iLine);
 
 
-
     // -------------------------------------------------------------------
     // -------------------------------------------------------------------
     /** Validate the header data structure of a game studio MDL7 file
     /** Validate the header data structure of a game studio MDL7 file
      * \param pcHeader Input header to be validated
      * \param pcHeader Input header to be validated
@@ -167,7 +158,6 @@ protected:
      */
      */
     void ValidateHeader_Quake1(const MDL::Header* pcHeader);
     void ValidateHeader_Quake1(const MDL::Header* pcHeader);
 
 
-
     // -------------------------------------------------------------------
     // -------------------------------------------------------------------
     /** Try to load a  palette from the current directory (colormap.lmp)
     /** Try to load a  palette from the current directory (colormap.lmp)
      *  If it is not found the default palette of Quake1 is returned
      *  If it is not found the default palette of Quake1 is returned
@@ -179,9 +169,8 @@ protected:
      */
      */
     void FreePalette(const unsigned char* pszColorMap);
     void FreePalette(const unsigned char* pszColorMap);
 
 
-
     // -------------------------------------------------------------------
     // -------------------------------------------------------------------
-    /** Load a paletized texture from the file and convert it to 32bpp
+    /** Load a palletized texture from the file and convert it to 32bpp
     */
     */
     void CreateTextureARGB8_3DGS_MDL3(const unsigned char* szData);
     void CreateTextureARGB8_3DGS_MDL3(const unsigned char* szData);
 
 
@@ -195,7 +184,6 @@ protected:
         unsigned int iType,
         unsigned int iType,
         unsigned int* piSkip);
         unsigned int* piSkip);
 
 
-
     // -------------------------------------------------------------------
     // -------------------------------------------------------------------
     /** Used to load textures from MDL5
     /** Used to load textures from MDL5
      * \param szData Input data
      * \param szData Input data
@@ -206,7 +194,6 @@ protected:
         unsigned int iType,
         unsigned int iType,
         unsigned int* piSkip);
         unsigned int* piSkip);
 
 
-
     // -------------------------------------------------------------------
     // -------------------------------------------------------------------
     /** Checks whether a texture can be replaced with a single color
     /** Checks whether a texture can be replaced with a single color
      * This is useful for all file formats before MDL7 (all those
      * This is useful for all file formats before MDL7 (all those
@@ -218,14 +205,12 @@ protected:
     */
     */
     aiColor4D ReplaceTextureWithColor(const aiTexture* pcTexture);
     aiColor4D ReplaceTextureWithColor(const aiTexture* pcTexture);
 
 
-
     // -------------------------------------------------------------------
     // -------------------------------------------------------------------
     /** Converts the absolute texture coordinates in MDL5 files to
     /** Converts the absolute texture coordinates in MDL5 files to
      *  relative in a range between 0 and 1
      *  relative in a range between 0 and 1
     */
     */
     void CalculateUVCoordinates_MDL5();
     void CalculateUVCoordinates_MDL5();
 
 
-
     // -------------------------------------------------------------------
     // -------------------------------------------------------------------
     /** Read an UV coordinate from the file. If the file format is not
     /** Read an UV coordinate from the file. If the file format is not
      * MDL5, the function calculates relative texture coordinates
      * MDL5, the function calculates relative texture coordinates
@@ -245,7 +230,6 @@ protected:
      */
      */
     void SetupMaterialProperties_3DGS_MDL5_Quake1( );
     void SetupMaterialProperties_3DGS_MDL5_Quake1( );
 
 
-
     // -------------------------------------------------------------------
     // -------------------------------------------------------------------
     /** Parse a skin lump in a MDL7/HMP7 file with all of its features
     /** Parse a skin lump in a MDL7/HMP7 file with all of its features
      *  variant 1: Current cursor position is the beginning of the skin header
      *  variant 1: Current cursor position is the beginning of the skin header

+ 6 - 2
code/glTF/glTFAsset.inl

@@ -1180,8 +1180,12 @@ inline void Light::SetDefaults()
     falloffExponent = 0.f;
     falloffExponent = 0.f;
 }
 }
 
 
-inline void Node::Read(Value& obj, Asset& r)
-{
+inline 
+void Node::Read(Value& obj, Asset& r) {
+    if (name.empty()) {
+        name = id;
+    }
+
     if (Value* children = FindArray(obj, "children")) {
     if (Value* children = FindArray(obj, "children")) {
         this->children.reserve(children->Size());
         this->children.reserve(children->Size());
         for (unsigned int i = 0; i < children->Size(); ++i) {
         for (unsigned int i = 0; i < children->Size(); ++i) {

+ 5 - 2
code/glTF/glTFImporter.cpp

@@ -475,14 +475,17 @@ void glTFImporter::ImportCameras(glTF::Asset& r) {
 
 
         if (cam.type == Camera::Perspective) {
         if (cam.type == Camera::Perspective) {
             aicam->mAspect        = cam.perspective.aspectRatio;
             aicam->mAspect        = cam.perspective.aspectRatio;
-            aicam->mHorizontalFOV = cam.perspective.yfov * aicam->mAspect;
+            aicam->mHorizontalFOV = cam.perspective.yfov * ((aicam->mAspect == 0.f) ? 1.f : aicam->mAspect);
             aicam->mClipPlaneFar  = cam.perspective.zfar;
             aicam->mClipPlaneFar  = cam.perspective.zfar;
             aicam->mClipPlaneNear = cam.perspective.znear;
             aicam->mClipPlaneNear = cam.perspective.znear;
         } else {
         } else {
             aicam->mClipPlaneFar = cam.ortographic.zfar;
             aicam->mClipPlaneFar = cam.ortographic.zfar;
             aicam->mClipPlaneNear = cam.ortographic.znear;
             aicam->mClipPlaneNear = cam.ortographic.znear;
             aicam->mHorizontalFOV = 0.0;
             aicam->mHorizontalFOV = 0.0;
-            aicam->mAspect = cam.ortographic.xmag / cam.ortographic.ymag;
+            aicam->mAspect = 1.0f;
+            if (0.f != cam.ortographic.ymag) {
+                aicam->mAspect = cam.ortographic.xmag / cam.ortographic.ymag;
+            }
         }
         }
     }
     }
 }
 }

+ 5 - 2
code/glTF2/glTF2Asset.inl

@@ -1098,8 +1098,11 @@ inline void Light::Read(Value& obj, Asset& /*r*/)
     }
     }
 }
 }
 
 
-inline void Node::Read(Value& obj, Asset& r)
-{
+inline 
+void Node::Read(Value& obj, Asset& r) {
+    if (name.empty()) {
+        name = id;
+    }
 
 
     if (Value* children = FindArray(obj, "children")) {
     if (Value* children = FindArray(obj, "children")) {
         this->children.reserve(children->Size());
         this->children.reserve(children->Size());

+ 14 - 2
code/glTF2/glTF2Importer.cpp

@@ -702,14 +702,17 @@ void glTF2Importer::ImportCameras(glTF2::Asset& r)
         if (cam.type == Camera::Perspective) {
         if (cam.type == Camera::Perspective) {
 
 
             aicam->mAspect        = cam.cameraProperties.perspective.aspectRatio;
             aicam->mAspect        = cam.cameraProperties.perspective.aspectRatio;
-            aicam->mHorizontalFOV = cam.cameraProperties.perspective.yfov * aicam->mAspect;
+            aicam->mHorizontalFOV = cam.cameraProperties.perspective.yfov * ((aicam->mAspect == 0.f) ? 1.f : aicam->mAspect);
             aicam->mClipPlaneFar  = cam.cameraProperties.perspective.zfar;
             aicam->mClipPlaneFar  = cam.cameraProperties.perspective.zfar;
             aicam->mClipPlaneNear = cam.cameraProperties.perspective.znear;
             aicam->mClipPlaneNear = cam.cameraProperties.perspective.znear;
         } else {
         } else {
             aicam->mClipPlaneFar = cam.cameraProperties.ortographic.zfar;
             aicam->mClipPlaneFar = cam.cameraProperties.ortographic.zfar;
             aicam->mClipPlaneNear = cam.cameraProperties.ortographic.znear;
             aicam->mClipPlaneNear = cam.cameraProperties.ortographic.znear;
             aicam->mHorizontalFOV = 0.0;
             aicam->mHorizontalFOV = 0.0;
-            aicam->mAspect = cam.cameraProperties.ortographic.xmag / cam.cameraProperties.ortographic.ymag;
+            aicam->mAspect = 1.0f;
+            if (0.f != cam.cameraProperties.ortographic.ymag ) {
+                aicam->mAspect = cam.cameraProperties.ortographic.xmag / cam.cameraProperties.ortographic.ymag;
+            }
         }
         }
     }
     }
 }
 }
@@ -905,6 +908,9 @@ aiNode* ImportNode(aiScene* pScene, glTF2::Asset& r, std::vector<unsigned int>&
                 std::vector<std::vector<aiVertexWeight>> weighting(mesh->mNumBones);
                 std::vector<std::vector<aiVertexWeight>> weighting(mesh->mNumBones);
                 BuildVertexWeightMapping(node.meshes[0]->primitives[primitiveNo], weighting);
                 BuildVertexWeightMapping(node.meshes[0]->primitives[primitiveNo], weighting);
 
 
+                mat4* pbindMatrices = nullptr;
+                node.skin->inverseBindMatrices->ExtractData(pbindMatrices);
+
                 for (uint32_t i = 0; i < mesh->mNumBones; ++i) {
                 for (uint32_t i = 0; i < mesh->mNumBones; ++i) {
                     aiBone* bone = new aiBone();
                     aiBone* bone = new aiBone();
 
 
@@ -920,6 +926,8 @@ aiNode* ImportNode(aiScene* pScene, glTF2::Asset& r, std::vector<unsigned int>&
                     }
                     }
                     GetNodeTransform(bone->mOffsetMatrix, *joint);
                     GetNodeTransform(bone->mOffsetMatrix, *joint);
 
 
+                    CopyValue(pbindMatrices[i], bone->mOffsetMatrix);
+
                     std::vector<aiVertexWeight>& weights = weighting[i];
                     std::vector<aiVertexWeight>& weights = weighting[i];
 
 
                     bone->mNumWeights = static_cast<uint32_t>(weights.size());
                     bone->mNumWeights = static_cast<uint32_t>(weights.size());
@@ -935,6 +943,10 @@ aiNode* ImportNode(aiScene* pScene, glTF2::Asset& r, std::vector<unsigned int>&
                     }
                     }
                     mesh->mBones[i] = bone;
                     mesh->mBones[i] = bone;
                 }
                 }
+
+                if (pbindMatrices) {
+                    delete[] pbindMatrices;
+                }
             }
             }
         }
         }
 
 

+ 1 - 1
contrib/irrXML/irrXML.h

@@ -215,7 +215,7 @@ namespace io
 	two methods to read your data and give a pointer to an instance of
 	two methods to read your data and give a pointer to an instance of
 	your implementation when calling createIrrXMLReader(), 
 	your implementation when calling createIrrXMLReader(), 
 	createIrrXMLReaderUTF16() or createIrrXMLReaderUTF32() */
 	createIrrXMLReaderUTF16() or createIrrXMLReaderUTF32() */
-	class IFileReadCallBack
+	class IRRXML_API IFileReadCallBack
 	{
 	{
 	public:
 	public:
 
 

+ 19 - 10
include/assimp/MathFunctions.h

@@ -39,22 +39,24 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 ---------------------------------------------------------------------------
 ---------------------------------------------------------------------------
 */
 */
 
 
+#pragma once
+
 /** @file  MathFunctions.h
 /** @file  MathFunctions.h
- *  @brief Implementation of the math functions (gcd and lcm)
+*  @brief Implementation of math utility functions.
  *
  *
- *  Copied from BoostWorkaround/math
- */
+*/
+
+#include <limits>
 
 
 namespace Assimp {
 namespace Assimp {
 namespace Math {
 namespace Math {
 
 
 // TODO: use binary GCD for unsigned integers ....
 // TODO: use binary GCD for unsigned integers ....
 template < typename IntegerType >
 template < typename IntegerType >
-IntegerType  gcd( IntegerType a, IntegerType b )
-{
+inline
+IntegerType gcd( IntegerType a, IntegerType b ) {
 	const IntegerType zero = (IntegerType)0;
 	const IntegerType zero = (IntegerType)0;
-	while ( true )
-	{
+	while ( true ) {
 		if ( a == zero )
 		if ( a == zero )
 			return b;
 			return b;
 		b %= a;
 		b %= a;
@@ -66,12 +68,19 @@ IntegerType  gcd( IntegerType a, IntegerType b )
 }
 }
 
 
 template < typename IntegerType >
 template < typename IntegerType >
-IntegerType  lcm( IntegerType a, IntegerType b )
-{
+inline
+IntegerType lcm( IntegerType a, IntegerType b ) {
 	const IntegerType t = gcd (a,b);
 	const IntegerType t = gcd (a,b);
-	if (!t)return t;
+	if (!t)
+        return t;
 	return a / t * b;
 	return a / t * b;
 }
 }
 
 
+template<class T>
+inline
+T getEpsilon() {
+    return std::numeric_limits<T>::epsilon();
+}
+
 }
 }
 }
 }

+ 4 - 5
include/assimp/matrix4x4.inl

@@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
 
 
 Copyright (c) 2006-2019, assimp team
 Copyright (c) 2006-2019, assimp team
 
 
-
-
 All rights reserved.
 All rights reserved.
 
 
 Redistribution and use of this software in source and binary forms,
 Redistribution and use of this software in source and binary forms,
@@ -53,6 +51,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #include "matrix4x4.h"
 #include "matrix4x4.h"
 #include "matrix3x3.h"
 #include "matrix3x3.h"
 #include "quaternion.h"
 #include "quaternion.h"
+#include "MathFunctions.h"
 
 
 #include <algorithm>
 #include <algorithm>
 #include <limits>
 #include <limits>
@@ -420,8 +419,8 @@ inline void aiMatrix4x4t<TReal>::Decompose (aiVector3t<TReal>& pScaling, aiQuate
 }
 }
 
 
 template <typename TReal>
 template <typename TReal>
-inline void aiMatrix4x4t<TReal>::Decompose(aiVector3t<TReal>& pScaling, aiVector3t<TReal>& pRotation, aiVector3t<TReal>& pPosition) const
-{
+inline
+void aiMatrix4x4t<TReal>::Decompose(aiVector3t<TReal>& pScaling, aiVector3t<TReal>& pRotation, aiVector3t<TReal>& pPosition) const {
 	ASSIMP_MATRIX4_4_DECOMPOSE_PART;
 	ASSIMP_MATRIX4_4_DECOMPOSE_PART;
 
 
     /*
     /*
@@ -442,7 +441,7 @@ inline void aiMatrix4x4t<TReal>::Decompose(aiVector3t<TReal>& pScaling, aiVector
 	*/
 	*/
 
 
 	// Use a small epsilon to solve floating-point inaccuracies
 	// Use a small epsilon to solve floating-point inaccuracies
-    const TReal epsilon = 10e-3f;
+    const TReal epsilon = Assimp::Math::getEpsilon<TReal>();
 
 
 	pRotation.y  = std::asin(-vCols[0].z);// D. Angle around oY.
 	pRotation.y  = std::asin(-vCols[0].z);// D. Angle around oY.
 
 

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 1 - 0
test/models/FBX/transparentTest.fbx


+ 6 - 0
test/unit/utFBXImporterExporter.cpp

@@ -276,3 +276,9 @@ TEST_F(utFBXImporterExporter, importEmbeddedFragmentedAsciiTest) {
     ASSERT_TRUE(scene->mTextures[0]->pcData);
     ASSERT_TRUE(scene->mTextures[0]->pcData);
     ASSERT_EQ(968029u, scene->mTextures[0]->mWidth) << "FBX ASCII base64 compression splits data by 512Kb, it should be two parts for this texture";
     ASSERT_EQ(968029u, scene->mTextures[0]->mWidth) << "FBX ASCII base64 compression splits data by 512Kb, it should be two parts for this texture";
 }
 }
+
+TEST_F(utFBXImporterExporter, fbxTokenizeTestTest) {
+    //Assimp::Importer importer;
+    //const aiScene* scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/FBX/transparentTest2.fbx", aiProcess_ValidateDataStructure);
+    //EXPECT_NE(nullptr, scene);
+}

이 변경점에서 너무 많은 파일들이 변경되어 몇몇 파일들은 표시되지 않았습니다.