MCPcopy Create free account
hub / github.com/Illation/ETEngine / GetMeshContainers

Method GetMeshContainers

Engine/source/EtRendering/SceneStructure/GLTF.cpp:1326–1461  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1324}
1325
1326bool glTF::GetMeshContainers(glTFAsset& asset, std::vector<MeshDataContainer*>& meshContainers)
1327{
1328 for (const Mesh& mesh : asset.dom.meshes)
1329 {
1330 if (mesh.primitives.size() > 1)LOG("Currently ETEngine meshes only support one primitive", core::LogLevel::Warning);
1331 for (const Primitive& primitive : mesh.primitives)
1332 {
1333 MeshDataContainer* pMesh = new MeshDataContainer();
1334 pMesh->m_Name = mesh.name;
1335
1336 //Basic positions
1337 if (primitive.indices == -1)
1338 {
1339 LOG("ETEngine only supports indexed draw for meshes", core::LogLevel::Warning);
1340 continue;
1341 }
1342 else
1343 {
1344 if (primitive.indices >= (int32)asset.dom.accessors.size())
1345 {
1346 LOG("Accessor index out of range", core::LogLevel::Warning);
1347 delete pMesh;
1348 for (auto pEl : meshContainers)delete pEl;
1349 meshContainers.clear();
1350 return false;
1351 }
1352 Accessor& accessor = asset.dom.accessors[primitive.indices];
1353 if (accessor.type != Type::SCALAR)
1354 {
1355 LOG("Index accessor must be SCALAR", core::LogLevel::Warning);
1356 delete pMesh;
1357 for (auto pEl : meshContainers)delete pEl;
1358 meshContainers.clear();
1359 return false;
1360 }
1361 if (!GetAccessorScalarArray(asset, primitive.indices, pMesh->m_Indices))
1362 {
1363 delete pMesh;
1364 for (auto pEl : meshContainers)delete pEl;
1365 meshContainers.clear();
1366 return false;
1367 }
1368 }
1369 if (primitive.attributes.position != -1)
1370 {
1371 if(!GetAccessorVectorArray(asset, primitive.attributes.position, pMesh->m_Positions, true))
1372 {
1373 delete pMesh;
1374 for (auto pEl : meshContainers)delete pEl;
1375 meshContainers.clear();
1376 return false;
1377 }
1378 pMesh->m_VertexCount = pMesh->m_Positions.size();
1379 }
1380
1381 //Texcoords before normals in case tangents need to be generated
1382 if (primitive.attributes.texcoord0 != -1)
1383 {

Callers

nothing calls this directly

Calls 3

GetAccessorScalarArrayFunction · 0.85
GetAccessorVectorArrayFunction · 0.85
ConstructTangentSpaceMethod · 0.80

Tested by

no test coverage detected