MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / ImportMesh

Function ImportMesh

Source/Engine/Tools/ModelTool/ModelTool.OpenFBX.cpp:1019–1072  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1017}
1018
1019bool ImportMesh(ModelData& result, OpenFbxImporterData& data, const ofbx::Mesh* aMesh, String& errorMsg, int partitionIndex)
1020{
1021 PROFILE_CPU();
1022
1023 // Find the parent node
1024 int32 nodeIndex = data.FindNode(aMesh);
1025
1026 // Special case for some models without nodes structure (only root but with some meshes inside)
1027 if (nodeIndex == -1 && data.Nodes[0].FbxObj->resolveObjectLink(0) == nullptr)
1028 {
1029 nodeIndex = data.Nodes.Count();
1030
1031 // Create dummy node
1032 FbxNode node;
1033 node.ParentIndex = 0;
1034 node.Name = aMesh->name;
1035 node.FbxObj = nullptr;
1036
1037 // Pick node LOD index
1038 if (!data.Options.ImportLODs)
1039 {
1040 node.LodIndex = 0;
1041 }
1042 else
1043 {
1044 node.LodIndex = data.Nodes[0].LodIndex;
1045 if (node.LodIndex == 0)
1046 node.LodIndex = ModelTool::DetectLodIndex(node.Name);
1047 ASSERT(Math::IsInRange(node.LodIndex, 0, MODEL_MAX_LODS - 1));
1048 }
1049 node.LocalTransform = Transform::Identity;
1050 data.Nodes.Add(node);
1051 }
1052 if (nodeIndex == -1)
1053 {
1054 LOG(Warning, "Invalid mesh linkage. Mesh: {0}. Skipping...", String(aMesh->name));
1055 return false;
1056 }
1057
1058 // Import mesh data
1059 MeshData* meshData = New<MeshData>();
1060 if (ProcessMesh(result, data, aMesh, *meshData, errorMsg, partitionIndex))
1061 return true;
1062
1063 // Link mesh
1064 auto& node = data.Nodes[nodeIndex];
1065 const int32 lodIndex = node.LodIndex;
1066 meshData->NodeIndex = nodeIndex;
1067 if (result.LODs.Count() <= lodIndex)
1068 result.LODs.Resize(lodIndex + 1);
1069 result.LODs[lodIndex].Meshes.Add(meshData);
1070
1071 return false;
1072}
1073
1074bool ImportMesh(int32 index, ModelData& result, OpenFbxImporterData& data, String& errorMsg)
1075{

Callers 1

ImportDataOpenFBXMethod · 0.70

Calls 12

IsInRangeFunction · 0.85
getMeshMethod · 0.80
getPartitionCountMethod · 0.80
getPartitionMethod · 0.80
ProcessMeshFunction · 0.70
IsMeshInvalidFunction · 0.70
StringClass · 0.50
FindNodeMethod · 0.45
resolveObjectLinkMethod · 0.45
CountMethod · 0.45
AddMethod · 0.45
ResizeMethod · 0.45

Tested by

no test coverage detected