Explorar o código

Merge branch 'master' into dev/gltf-KHR_materials

Danny-Kint %!s(int64=4) %!d(string=hai) anos
pai
achega
dbffe25c9d

+ 2 - 2
code/AssetLib/Collada/ColladaHelper.cpp

@@ -53,7 +53,7 @@ const MetaKeyPairVector MakeColladaAssimpMetaKeys() {
     result.emplace_back("authoring_tool", AI_METADATA_SOURCE_GENERATOR);
     result.emplace_back("copyright", AI_METADATA_SOURCE_COPYRIGHT);
     return result;
-};
+}
 
 const MetaKeyPairVector &GetColladaAssimpMetaKeys() {
     static const MetaKeyPairVector result = MakeColladaAssimpMetaKeys();
@@ -66,7 +66,7 @@ const MetaKeyPairVector MakeColladaAssimpMetaKeysCamelCase() {
         ToCamelCase(val.first);
     }
     return result;
-};
+}
 
 const MetaKeyPairVector &GetColladaAssimpMetaKeysCamelCase() {
     static const MetaKeyPairVector result = MakeColladaAssimpMetaKeysCamelCase();

+ 19 - 21
code/AssetLib/glTF2/glTF2Exporter.cpp

@@ -1305,9 +1305,6 @@ inline Ref<Accessor> GetSamplerInputRef(Asset& asset, std::string& animId, Ref<B
 inline void ExtractTranslationSampler(Asset& asset, std::string& animId, Ref<Buffer>& buffer, const aiNodeAnim* nodeChannel, float ticksPerSecond, Animation::Sampler& sampler)
 {
     const unsigned int numKeyframes = nodeChannel->mNumPositionKeys;
-    if (numKeyframes == 0) {
-        return;
-    }
 
     std::vector<float> times(numKeyframes);
     std::vector<float> values(numKeyframes * 3);
@@ -1328,9 +1325,6 @@ inline void ExtractTranslationSampler(Asset& asset, std::string& animId, Ref<Buf
 inline void ExtractScaleSampler(Asset& asset, std::string& animId, Ref<Buffer>& buffer, const aiNodeAnim* nodeChannel, float ticksPerSecond, Animation::Sampler& sampler)
 {
     const unsigned int numKeyframes = nodeChannel->mNumScalingKeys;
-    if (numKeyframes == 0) {
-        return;
-    }
 
     std::vector<float> times(numKeyframes);
     std::vector<float> values(numKeyframes * 3);
@@ -1351,9 +1345,6 @@ inline void ExtractScaleSampler(Asset& asset, std::string& animId, Ref<Buffer>&
 inline void ExtractRotationSampler(Asset& asset, std::string& animId, Ref<Buffer>& buffer, const aiNodeAnim* nodeChannel, float ticksPerSecond, Animation::Sampler& sampler)
 {
     const unsigned int numKeyframes = nodeChannel->mNumRotationKeys;
-    if (numKeyframes == 0) {
-        return;
-    }
 
     std::vector<float> times(numKeyframes);
     std::vector<float> values(numKeyframes * 4);
@@ -1394,29 +1385,36 @@ void glTF2Exporter::ExportAnimations()
         if (anim->mName.length > 0) {
             nameAnim = anim->mName.C_Str();
         }
+        Ref<Animation> animRef = mAsset->animations.Create(nameAnim);
 
         for (unsigned int channelIndex = 0; channelIndex < anim->mNumChannels; ++channelIndex) {
             const aiNodeAnim* nodeChannel = anim->mChannels[channelIndex];
 
-            // It appears that assimp stores this type of animation as multiple animations.
-            // where each aiNodeAnim in mChannels animates a specific node.
             std::string name = nameAnim + "_" + to_string(channelIndex);
             name = mAsset->FindUniqueID(name, "animation");
-            Ref<Animation> animRef = mAsset->animations.Create(name);
 
             Ref<Node> animNode = mAsset->nodes.Get(nodeChannel->mNodeName.C_Str());
 
-            Animation::Sampler translationSampler;
-            ExtractTranslationSampler(*mAsset, name, bufferRef, nodeChannel, ticksPerSecond, translationSampler);
-            AddSampler(animRef, animNode, translationSampler, AnimationPath_TRANSLATION);
+            if (nodeChannel->mNumPositionKeys > 0)
+            {
+                Animation::Sampler translationSampler;
+                ExtractTranslationSampler(*mAsset, name, bufferRef, nodeChannel, ticksPerSecond, translationSampler);
+                AddSampler(animRef, animNode, translationSampler, AnimationPath_TRANSLATION);
+            }
 
-            Animation::Sampler rotationSampler;
-            ExtractRotationSampler(*mAsset, name, bufferRef, nodeChannel, ticksPerSecond, rotationSampler);
-            AddSampler(animRef, animNode, rotationSampler, AnimationPath_ROTATION);
+            if (nodeChannel->mNumRotationKeys > 0)
+            {
+                Animation::Sampler rotationSampler;
+                ExtractRotationSampler(*mAsset, name, bufferRef, nodeChannel, ticksPerSecond, rotationSampler);
+                AddSampler(animRef, animNode, rotationSampler, AnimationPath_ROTATION);
+            }
 
-            Animation::Sampler scaleSampler;
-            ExtractScaleSampler(*mAsset, name, bufferRef, nodeChannel, ticksPerSecond, scaleSampler);
-            AddSampler(animRef, animNode, scaleSampler, AnimationPath_SCALE);
+            if (nodeChannel->mNumScalingKeys > 0)
+            {
+                Animation::Sampler scaleSampler;
+                ExtractScaleSampler(*mAsset, name, bufferRef, nodeChannel, ticksPerSecond, scaleSampler);
+                AddSampler(animRef, animNode, scaleSampler, AnimationPath_SCALE);
+            }
         }
 
         // Assimp documentation staes this is not used (not implemented)

+ 1 - 1
code/CMakeLists.txt

@@ -1015,7 +1015,7 @@ ENDIF()
 # RT-extensions is used in "contrib/Open3DGC/o3dgcTimer.h" for collecting statistics. Pointed file
 # has implementation for different platforms: WIN32, __MACH__ and other ("else" block).
 FIND_PACKAGE(RT QUIET)
-IF (NOT ASSIMP_HUNTER_ENABLED AND (RT_FOUND OR MSVC))
+IF (NOT ASSIMP_HUNTER_ENABLED AND (RT_FOUND OR WIN32))
   SET( ASSIMP_IMPORTER_GLTF_USE_OPEN3DGC 1 )
   ADD_DEFINITIONS( -DASSIMP_IMPORTER_GLTF_USE_OPEN3DGC=1 )
 ELSE ()

+ 3 - 2
code/Common/SceneCombiner.cpp

@@ -183,9 +183,10 @@ void SceneCombiner::MergeScenes(aiScene **_dest, std::vector<aiScene *> &src, un
             *_dest = src[0];
         return;
     }
-    if (*_dest)
+    if (*_dest) {
         (*_dest)->~aiScene();
-    else
+        new (*_dest) aiScene();
+    } else
         *_dest = new aiScene();
 
     // Create a dummy scene to serve as master for the others

+ 2 - 2
code/Common/ZipArchiveIOSystem.cpp

@@ -146,7 +146,7 @@ int IOSystem2Unzip::testerror(voidpf /*opaque*/, voidpf /*stream*/) {
 zlib_filefunc_def IOSystem2Unzip::get(IOSystem *pIOHandler) {
     zlib_filefunc_def mapping;
 
-#ifdef ASSIMP_USE_HUNTER
+#if defined (ASSIMP_USE_HUNTER) || defined (__MINGW32__) // GH#3144
     mapping.zopen_file = (open_file_func)open;
     mapping.zread_file = (read_file_func)read;
     mapping.zwrite_file = (write_file_func)write;
@@ -335,7 +335,7 @@ ZipArchiveIOSystem::Implement::Implement(IOSystem *pIOHandler, const char *pFile
     if (pFilename[0] == 0 || nullptr == pMode) {
         return;
     }
-    
+
     zlib_filefunc_def mapping = IOSystem2Unzip::get(pIOHandler);
     m_ZipFileHandle = unzOpen2(pFilename, &mapping);
 }

+ 2 - 2
contrib/Open3DGC/o3dgcVector.inl

@@ -175,7 +175,7 @@ namespace o3dgc
         m_data[2] = rhs.m_data[2];
     }
     template <typename T>
-    inline Vec3<T>::~Vec3(void){};
+    inline Vec3<T>::~Vec3(void){}
 
     template <typename T>
     inline Vec3<T>::Vec3() {}
@@ -308,7 +308,7 @@ namespace o3dgc
         m_data[1] = rhs.m_data[1];
     }
     template <typename T>
-    inline Vec2<T>::~Vec2(void){};
+    inline Vec2<T>::~Vec2(void){}
 
     template <typename T>
     inline Vec2<T>::Vec2() {}

+ 1 - 1
samples/SimpleTexturedOpenGL/SimpleTexturedOpenGL/src/model_loading.cpp

@@ -763,7 +763,7 @@ void cleanup()
 
 	if (g_hWnd)
 		KillGLWindow();
-};
+}
 
 LRESULT CALLBACK WndProc(HWND hWnd,				// Handles for this Window
 						 UINT uMsg,				// Message for this Window

+ 1 - 1
tools/assimp_view/MeshRenderer.cpp

@@ -161,4 +161,4 @@ int CMeshRenderer::DrawSorted(unsigned int iIndex,const aiMatrix4x4& mWorld) {
 
     return 1;
 }
-};
+}

+ 1 - 1
tools/assimp_view/MessageProc.cpp

@@ -2143,7 +2143,7 @@ INT_PTR CALLBACK AboutMessageProc(HWND hwndDlg,UINT uMsg,
         }
     return FALSE;
     }
-};
+}
 
 using namespace AssimpView;