MCPcopy Create free account
hub / github.com/assimp/assimp / Execute

Method Execute

code/PostProcessing/PretransformVertices.cpp:430–690  ·  view source on GitHub ↗

------------------------------------------------------------------------------------------------ Executes the post processing step on the given imported data.

Source from the content-addressed store, hash-verified

428// ------------------------------------------------------------------------------------------------
429// Executes the post processing step on the given imported data.
430void PretransformVertices::Execute(aiScene *pScene) {
431 ASSIMP_LOG_DEBUG("PretransformVerticesProcess begin");
432
433 // Return immediately if we have no meshes
434 if (!pScene->mNumMeshes)
435 return;
436
437 const unsigned int oldMeshes = pScene->mNumMeshes;
438 const unsigned int oldAnimationChannels = pScene->mNumAnimations;
439 const unsigned int oldNodes = CountNodes(pScene->mRootNode);
440
441 if (mConfigTransform) {
442 pScene->mRootNode->mTransformation = mConfigTransformation * pScene->mRootNode->mTransformation;
443 }
444
445 // first compute absolute transformation matrices for all nodes
446 ComputeAbsoluteTransform(pScene->mRootNode);
447
448 // Delete aiMesh::mBones for all meshes. The bones are
449 // removed during this step and we need the pointer as
450 // temporary storage
451 for (unsigned int i = 0; i < pScene->mNumMeshes; ++i) {
452 aiMesh *mesh = pScene->mMeshes[i];
453
454 for (unsigned int a = 0; a < mesh->mNumBones; ++a)
455 delete mesh->mBones[a];
456
457 delete[] mesh->mBones;
458 mesh->mBones = nullptr;
459 }
460
461 // now build a list of output meshes
462 std::vector<aiMesh *> apcOutMeshes;
463
464 // Keep scene hierarchy? It's an easy job in this case ...
465 // we go on and transform all meshes, if one is referenced by nodes
466 // with different absolute transformations a depth copy of the mesh
467 // is required.
468 if (mConfigKeepHierarchy) {
469
470 // Hack: store the matrix we're transforming a mesh with in aiMesh::mBones
471 BuildWCSMeshes(apcOutMeshes, pScene->mMeshes, pScene->mNumMeshes, pScene->mRootNode);
472
473 // ... if new meshes have been generated, append them to the end of the scene
474 appendNewMeshesToScene(pScene, apcOutMeshes);
475
476 // now iterate through all meshes and transform them to world-space
477 for (unsigned int i = 0; i < pScene->mNumMeshes; ++i) {
478 ApplyTransform(pScene->mMeshes[i], *reinterpret_cast<aiMatrix4x4 *>(pScene->mMeshes[i]->mBones));
479
480 // prevent improper destruction
481 pScene->mMeshes[i]->mBones = nullptr;
482 pScene->mMeshes[i]->mNumBones = 0;
483 }
484 } else {
485 apcOutMeshes.reserve(static_cast<size_t>(pScene->mNumMaterials) << 1u);
486 std::list<unsigned int> aiVFormats;
487

Callers

nothing calls this directly

Calls 15

CountNodesFunction · 0.85
appendNewMeshesToSceneFunction · 0.85
GetVFormatListFunction · 0.85
DeadlyImportErrorFunction · 0.85
aiMatrix3x3Class · 0.85
ai_snprintfFunction · 0.85
sortMethod · 0.80
minFunction · 0.70
maxFunction · 0.70
reserveMethod · 0.45
clearMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected