ソースを参照

Merge branch 'master' into use_log_macros

Kim Kulling 7 年 前
コミット
8f26b9d840

+ 1 - 1
CMakeLists.txt

@@ -311,7 +311,7 @@ IF ( NOT ASSIMP_BUILD_ZLIB )
 ENDIF( NOT ASSIMP_BUILD_ZLIB )
 ENDIF( NOT ASSIMP_BUILD_ZLIB )
 
 
 IF( NOT ZLIB_FOUND )
 IF( NOT ZLIB_FOUND )
-  MESSAGE(STATUS "compiling zlib from souces")
+  MESSAGE(STATUS "compiling zlib from sources")
   INCLUDE(CheckIncludeFile)
   INCLUDE(CheckIncludeFile)
   INCLUDE(CheckTypeSize)
   INCLUDE(CheckTypeSize)
   INCLUDE(CheckFunctionExists)
   INCLUDE(CheckFunctionExists)

+ 1 - 4
assimp-config.cmake.in

@@ -10,10 +10,7 @@
 # ASSIMP_LIBRARY_DIRS - link directories
 # ASSIMP_LIBRARY_DIRS - link directories
 # ASSIMP_LIBRARIES - libraries to link plugins with
 # ASSIMP_LIBRARIES - libraries to link plugins with
 # ASSIMP_Boost_VERSION - the boost version assimp was compiled with
 # ASSIMP_Boost_VERSION - the boost version assimp was compiled with
-get_filename_component(_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH)
-get_filename_component(_PREFIX "${_PREFIX}" PATH)
-get_filename_component(_PREFIX "${_PREFIX}" PATH)
-get_filename_component(ASSIMP_ROOT_DIR "${_PREFIX}" PATH)
+get_filename_component(ASSIMP_ROOT_DIR "@CMAKE_INSTALL_PREFIX@" REALPATH)
 
 
 if( MSVC )
 if( MSVC )
   # in order to prevent DLL hell, each of the DLLs have to be suffixed with the major version and msvc prefix
   # in order to prevent DLL hell, each of the DLLs have to be suffixed with the major version and msvc prefix

+ 8 - 5
code/ImproveCacheLocality.cpp

@@ -272,8 +272,9 @@ float ImproveCacheLocalityProcess::ProcessMesh( aiMesh* pMesh, unsigned int mesh
 
 
                 // so iterate through all vertices of the current triangle
                 // so iterate through all vertices of the current triangle
                 const aiFace* pcFace = &pMesh->mFaces[ fidx ];
                 const aiFace* pcFace = &pMesh->mFaces[ fidx ];
-                for (unsigned int* p = pcFace->mIndices, *p2 = pcFace->mIndices+3;p != p2;++p)  {
-                    const unsigned int dp = *p;
+                unsigned nind = pcFace->mNumIndices;
+                for (unsigned ind = 0; ind < nind; ind++) {
+                    unsigned dp = pcFace->mIndices[ind];
 
 
                     // the current vertex won't have any free triangles after this step
                     // the current vertex won't have any free triangles after this step
                     if (ivdx != (int)dp) {
                     if (ivdx != (int)dp) {
@@ -367,9 +368,11 @@ float ImproveCacheLocalityProcess::ProcessMesh( aiMesh* pMesh, unsigned int mesh
     // sort the output index buffer back to the input array
     // sort the output index buffer back to the input array
     piCSIter = piIBOutput;
     piCSIter = piIBOutput;
     for (aiFace* pcFace = pMesh->mFaces; pcFace != pcEnd;++pcFace)  {
     for (aiFace* pcFace = pMesh->mFaces; pcFace != pcEnd;++pcFace)  {
-        pcFace->mIndices[0] = *piCSIter++;
-        pcFace->mIndices[1] = *piCSIter++;
-        pcFace->mIndices[2] = *piCSIter++;
+        unsigned nind = pcFace->mNumIndices;
+        unsigned * ind = pcFace->mIndices;
+        if (nind > 0) ind[0] = *piCSIter++;
+        if (nind > 1) ind[1] = *piCSIter++;
+        if (nind > 2) ind[2] = *piCSIter++;
     }
     }
 
 
     // delete temporary storage
     // delete temporary storage

+ 12 - 12
code/VertexTriangleAdjacency.cpp

@@ -88,10 +88,13 @@ VertexTriangleAdjacency::VertexTriangleAdjacency(aiFace *pcFaces,
     *piEnd++ = 0u;
     *piEnd++ = 0u;
 
 
     // first pass: compute the number of faces referencing each vertex
     // first pass: compute the number of faces referencing each vertex
-    for (aiFace* pcFace = pcFaces; pcFace != pcFaceEnd; ++pcFace) {
-        pi[pcFace->mIndices[0]]++;
-        pi[pcFace->mIndices[1]]++;
-        pi[pcFace->mIndices[2]]++;
+    for (aiFace* pcFace = pcFaces; pcFace != pcFaceEnd; ++pcFace)
+    {
+        unsigned nind = pcFace->mNumIndices;
+        unsigned * ind = pcFace->mIndices;
+        if (nind > 0) pi[ind[0]]++;
+        if (nind > 1) pi[ind[1]]++;
+        if (nind > 2) pi[ind[2]]++;
     }
     }
 
 
     // second pass: compute the final offset table
     // second pass: compute the final offset table
@@ -109,15 +112,12 @@ VertexTriangleAdjacency::VertexTriangleAdjacency(aiFace *pcFaces,
     this->mAdjacencyTable = new unsigned int[iSum];
     this->mAdjacencyTable = new unsigned int[iSum];
     iSum = 0;
     iSum = 0;
     for (aiFace* pcFace = pcFaces; pcFace != pcFaceEnd; ++pcFace,++iSum)    {
     for (aiFace* pcFace = pcFaces; pcFace != pcFaceEnd; ++pcFace,++iSum)    {
+        unsigned nind = pcFace->mNumIndices;
+        unsigned * ind = pcFace->mIndices;
 
 
-        unsigned int idx = pcFace->mIndices[0];
-        mAdjacencyTable[pi[idx]++] = iSum;
-
-        idx = pcFace->mIndices[1];
-        mAdjacencyTable[pi[idx]++] = iSum;
-
-        idx = pcFace->mIndices[2];
-        mAdjacencyTable[pi[idx]++] = iSum;
+        if (nind > 0) mAdjacencyTable[pi[ind[0]]++] = iSum;
+        if (nind > 1) mAdjacencyTable[pi[ind[1]]++] = iSum;
+        if (nind > 2) mAdjacencyTable[pi[ind[2]]++] = iSum;
     }
     }
     // fourth pass: undo the offset computations made during the third pass
     // fourth pass: undo the offset computations made during the third pass
     // We could do this in a separate buffer, but this would be TIMES slower.
     // We could do this in a separate buffer, but this would be TIMES slower.

+ 8 - 0
code/glTF2Exporter.cpp

@@ -732,6 +732,14 @@ void glTF2Exporter::ExportMeshes()
 			}
 			}
 		}
 		}
 
 
+		/*************** Vertex colors ****************/
+		for (unsigned int indexColorChannel = 0; indexColorChannel < aim->GetNumColorChannels(); ++indexColorChannel)
+		{
+			Ref<Accessor> c = ExportData(*mAsset, meshId, b, aim->mNumVertices, aim->mColors[indexColorChannel], AttribType::VEC4, AttribType::VEC4, ComponentType_FLOAT, false);
+			if (c)
+				p.attributes.color.push_back(c);
+		}
+		
 		/*************** Vertices indices ****************/
 		/*************** Vertices indices ****************/
 		if (aim->mNumFaces > 0) {
 		if (aim->mNumFaces > 0) {
 			std::vector<IndicesType> indices;
 			std::vector<IndicesType> indices;

+ 3 - 0
test/unit/utVertexTriangleAdjacency.cpp

@@ -101,8 +101,11 @@ TEST_F(VTAdjacencyTest, smallDataSet)
 
 
     mesh.mFaces = new aiFace[3];
     mesh.mFaces = new aiFace[3];
     mesh.mFaces[0].mIndices = new unsigned int[3];
     mesh.mFaces[0].mIndices = new unsigned int[3];
+    mesh.mFaces[0].mNumIndices = 3;
     mesh.mFaces[1].mIndices = new unsigned int[3];
     mesh.mFaces[1].mIndices = new unsigned int[3];
+    mesh.mFaces[1].mNumIndices = 3;
     mesh.mFaces[2].mIndices = new unsigned int[3];
     mesh.mFaces[2].mIndices = new unsigned int[3];
+    mesh.mFaces[2].mNumIndices = 3;
 
 
     mesh.mFaces[0].mIndices[0] = 1;
     mesh.mFaces[0].mIndices[0] = 1;
     mesh.mFaces[0].mIndices[1] = 3;
     mesh.mFaces[0].mIndices[1] = 3;