------------------------------------------------------------------------------------------------ Execute step
| 98 | // ------------------------------------------------------------------------------------------------ |
| 99 | // Execute step |
| 100 | void OptimizeMeshesProcess::Execute( aiScene* pScene) |
| 101 | { |
| 102 | const unsigned int num_old = pScene->mNumMeshes; |
| 103 | if (num_old <= 1) { |
| 104 | ASSIMP_LOG_DEBUG("Skipping OptimizeMeshesProcess"); |
| 105 | return; |
| 106 | } |
| 107 | |
| 108 | ASSIMP_LOG_DEBUG("OptimizeMeshesProcess begin"); |
| 109 | mScene = pScene; |
| 110 | |
| 111 | // need to clear persistent members from previous runs |
| 112 | merge_list.resize( 0 ); |
| 113 | output.resize( 0 ); |
| 114 | |
| 115 | // ensure we have the right sizes |
| 116 | merge_list.reserve(pScene->mNumMeshes); |
| 117 | output.reserve(pScene->mNumMeshes); |
| 118 | |
| 119 | // Prepare lookup tables |
| 120 | meshes.resize(pScene->mNumMeshes); |
| 121 | FindInstancedMeshes(pScene->mRootNode); |
| 122 | if( max_verts == DeadBeef ) /* undo the magic hack */ |
| 123 | max_verts = NotSet; |
| 124 | |
| 125 | // ... instanced meshes are immediately processed and added to the output list |
| 126 | for (unsigned int i = 0, n = 0; i < pScene->mNumMeshes;++i) { |
| 127 | meshes[i].vertex_format = GetMeshVFormatUnique(pScene->mMeshes[i]); |
| 128 | |
| 129 | if (meshes[i].instance_cnt > 1 && meshes[i].output_id == NotSet ) { |
| 130 | meshes[i].output_id = n++; |
| 131 | output.push_back(mScene->mMeshes[i]); |
| 132 | } |
| 133 | } |
| 134 | |
| 135 | // and process all nodes in the scenegraph recursively |
| 136 | ProcessNode(pScene->mRootNode); |
| 137 | if (!output.size()) { |
| 138 | throw DeadlyImportError("OptimizeMeshes: No meshes remaining; there's definitely something wrong"); |
| 139 | } |
| 140 | |
| 141 | meshes.resize( 0 ); |
| 142 | ai_assert(output.size() <= num_old); |
| 143 | |
| 144 | mScene->mNumMeshes = static_cast<unsigned int>(output.size()); |
| 145 | std::copy(output.begin(),output.end(),mScene->mMeshes); |
| 146 | |
| 147 | if (output.size() != num_old) { |
| 148 | ASSIMP_LOG_DEBUG("OptimizeMeshesProcess finished. Input meshes: ", num_old, ", Output meshes: ", pScene->mNumMeshes); |
| 149 | } else { |
| 150 | ASSIMP_LOG_DEBUG( "OptimizeMeshesProcess finished" ); |
| 151 | } |
| 152 | } |
| 153 | |
| 154 | // ------------------------------------------------------------------------------------------------ |
| 155 | // Process meshes for a single node |
nothing calls this directly
no test coverage detected