------------------------------------------------------------------------------------------------ Executes the post processing step on the given imported data.
| 169 | // ------------------------------------------------------------------------------------------------ |
| 170 | // Executes the post processing step on the given imported data. |
| 171 | bool RemoveVCProcess::ProcessMesh(aiMesh *pMesh) { |
| 172 | bool ret = false; |
| 173 | |
| 174 | // if all materials have been deleted let the material |
| 175 | // index of the mesh point to the created default material |
| 176 | if (configDeleteFlags & aiComponent_MATERIALS) |
| 177 | pMesh->mMaterialIndex = 0; |
| 178 | |
| 179 | // handle normals |
| 180 | if (configDeleteFlags & aiComponent_NORMALS && pMesh->mNormals) { |
| 181 | delete[] pMesh->mNormals; |
| 182 | pMesh->mNormals = nullptr; |
| 183 | ret = true; |
| 184 | } |
| 185 | |
| 186 | // handle tangents and bitangents |
| 187 | if (configDeleteFlags & aiComponent_TANGENTS_AND_BITANGENTS && pMesh->mTangents) { |
| 188 | delete[] pMesh->mTangents; |
| 189 | pMesh->mTangents = nullptr; |
| 190 | |
| 191 | delete[] pMesh->mBitangents; |
| 192 | pMesh->mBitangents = nullptr; |
| 193 | ret = true; |
| 194 | } |
| 195 | |
| 196 | // handle texture coordinates |
| 197 | bool b = (0 != (configDeleteFlags & aiComponent_TEXCOORDS)); |
| 198 | for (unsigned int i = 0, real = 0; real < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++real) { |
| 199 | if (!pMesh->mTextureCoords[i]) break; |
| 200 | if (configDeleteFlags & aiComponent_TEXCOORDSn(real) || b) { |
| 201 | delete[] pMesh->mTextureCoords[i]; |
| 202 | pMesh->mTextureCoords[i] = nullptr; |
| 203 | ret = true; |
| 204 | |
| 205 | if (!b) { |
| 206 | // collapse the rest of the array |
| 207 | for (unsigned int a = i + 1; a < AI_MAX_NUMBER_OF_TEXTURECOORDS; ++a) |
| 208 | pMesh->mTextureCoords[a - 1] = pMesh->mTextureCoords[a]; |
| 209 | |
| 210 | pMesh->mTextureCoords[AI_MAX_NUMBER_OF_TEXTURECOORDS - 1] = nullptr; |
| 211 | continue; |
| 212 | } |
| 213 | } |
| 214 | ++i; |
| 215 | } |
| 216 | |
| 217 | // handle vertex colors |
| 218 | b = (0 != (configDeleteFlags & aiComponent_COLORS)); |
| 219 | for (unsigned int i = 0, real = 0; real < AI_MAX_NUMBER_OF_COLOR_SETS; ++real) { |
| 220 | if (!pMesh->mColors[i]) break; |
| 221 | if (configDeleteFlags & aiComponent_COLORSn(i) || b) { |
| 222 | delete[] pMesh->mColors[i]; |
| 223 | pMesh->mColors[i] = nullptr; |
| 224 | ret = true; |
| 225 | |
| 226 | if (!b) { |
| 227 | // collapse the rest of the array |
| 228 | for (unsigned int a = i + 1; a < AI_MAX_NUMBER_OF_COLOR_SETS; ++a) |
nothing calls this directly
no test coverage detected