Jelajahi Sumber

Fixing FBX import issues:
- Mesh is now properly imported even if it has no materials assigned
- Mesh combining now works properly if not all meshes have the same vertex description

Animation component with no clip attached no longer crashes the program

BearishSun 9 tahun lalu
induk
melakukan
dc2c09c1d2

+ 3 - 0
Source/BansheeCore/Source/BsAnimation.cpp

@@ -435,6 +435,9 @@ namespace BansheeEngine
 				else
 					soInfo.hash = 0;
 
+				soInfo.layerIdx = (UINT32)-1;
+				soInfo.stateIdx = (UINT32)-1;
+
 				// If no bone mapping, find curves directly
 				if(soInfo.boneIdx == -1)
 				{

+ 3 - 0
Source/BansheeCore/Source/BsAnimationManager.cpp

@@ -188,6 +188,9 @@ namespace BansheeEngine
 				if (soInfo.boneIdx != -1)
 					continue;
 
+				if (soInfo.layerIdx == (UINT32)-1 || soInfo.stateIdx == (UINT32)-1)
+					continue;
+
 				const AnimationState& state = anim->layers[soInfo.layerIdx].states[soInfo.stateIdx];
 				if (state.disabled)
 					continue;

+ 1 - 1
Source/BansheeCore/Source/BsMeshData.cpp

@@ -157,7 +157,7 @@ namespace BansheeEngine
 
 				if(meshData->getVertexDesc()->hasElement(element.getSemantic(), element.getSemanticIdx(), element.getStreamIdx()))
 				{
-					UINT32 srcVertexStride = vertexData->getVertexStride(element.getStreamIdx());
+					UINT32 srcVertexStride = meshData->getVertexDesc()->getVertexStride(element.getStreamIdx());
 					UINT8* srcData = meshData->getElementData(element.getSemantic(), element.getSemanticIdx(), element.getStreamIdx());
 
 					for(UINT32 i = 0; i < numSrcVertices; i++)

+ 4 - 0
Source/BansheeFBXImporter/Source/BsFBXImporter.cpp

@@ -1136,6 +1136,10 @@ namespace BansheeEngine
 					importMesh->materials.push_back(materialIdx);
 				}
 			}
+			else
+			{
+				importMesh->materials.resize(importMesh->indices.size(), 0);
+			}
 		}
 	}