MCPcopy Create free account
hub / github.com/GPUOpen-Effects/GeometryFX / LoadGeometry

Function LoadGeometry

amd_geometryfx_sample/src/GeometryFX_Sample.cpp:396–451  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

394}
395
396std::vector<AMD::GeometryFX_Filter::MeshHandle> LoadGeometry(
397 const char *filename, AMD::GeometryFX_Filter &meshManager, const int chunkSize = 65535)
398{
399 const auto propertyStore = aiCreatePropertyStore ();
400 aiSetImportPropertyInteger (propertyStore,
401 AI_CONFIG_PP_SLM_TRIANGLE_LIMIT, chunkSize);
402 aiSetImportPropertyInteger (propertyStore,
403 AI_CONFIG_PP_SBP_REMOVE, aiPrimitiveType_LINE | aiPrimitiveType_POINT);
404 aiSetImportPropertyInteger (propertyStore,
405 AI_CONFIG_PP_PTV_NORMALIZE, 1);
406
407 const auto pScene = aiImportFileExWithProperties (filename,
408 aiProcess_Triangulate | aiProcess_ConvertToLeftHanded | aiProcess_SortByPType |
409 aiProcess_JoinIdenticalVertices | aiProcess_SplitLargeMeshes |
410 aiProcess_PreTransformVertices,
411 nullptr,
412 propertyStore);
413
414 if (pScene)
415 {
416 std::vector<int> indexCounts;
417 std::vector<int> vertexCounts;
418 for (unsigned int i = 0; i < pScene->mNumMeshes; ++i)
419 {
420 indexCounts.push_back(pScene->mMeshes[i]->mNumFaces * 3);
421 vertexCounts.push_back(pScene->mMeshes[i]->mNumVertices);
422 }
423
424 auto handles =
425 meshManager.RegisterMeshes(pScene->mNumMeshes, vertexCounts.data(), indexCounts.data());
426
427 for (unsigned int i = 0; i < pScene->mNumMeshes; ++i)
428 {
429 // The mesh is triangulated, so we can use 3 indices per face here
430 std::vector<int> indices(pScene->mMeshes[i]->mNumFaces * 3);
431 for (unsigned j = 0; j < pScene->mMeshes[i]->mNumFaces; ++j)
432 {
433 for (int k = 0; k < 3; ++k)
434 {
435 indices[j * 3 + k] = pScene->mMeshes[i]->mFaces[j].mIndices[k];
436 }
437 }
438
439 meshManager.SetMeshData(handles[i], pScene->mMeshes[i]->mVertices, indices.data());
440 }
441
442 aiReleaseImport (pScene);
443 aiReleasePropertyStore (propertyStore);
444
445 return handles;
446 }
447
448 aiReleasePropertyStore (propertyStore);
449
450 return std::vector<AMD::GeometryFX_Filter::MeshHandle>();
451}
452
453class Application

Callers 1

CreateMethod · 0.85

Calls 2

RegisterMeshesMethod · 0.45
SetMeshDataMethod · 0.45

Tested by

no test coverage detected