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

Method Execute

code/PostProcessing/ComputeUVMappingProcess.cpp:345–450  ·  view source on GitHub ↗

------------------------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

343
344// ------------------------------------------------------------------------------------------------
345void ComputeUVMappingProcess::Execute(aiScene *pScene) {
346 ASSIMP_LOG_DEBUG("GenUVCoordsProcess begin");
347 char buffer[1024];
348
349 if (pScene->mFlags & AI_SCENE_FLAGS_NON_VERBOSE_FORMAT) {
350 throw DeadlyImportError("Post-processing order mismatch: expecting pseudo-indexed (\"verbose\") vertices here");
351 }
352
353 std::list<MappingInfo> mappingStack;
354
355 // Iterate through all materials and search for non-UV mapped textures
356 for (unsigned int i = 0; i < pScene->mNumMaterials; ++i) {
357 mappingStack.clear();
358 aiMaterial *mat = pScene->mMaterials[i];
359 if (mat == nullptr) {
360 ASSIMP_LOG_INFO("Material pointer in nullptr, skipping.");
361 continue;
362 }
363 for (unsigned int a = 0; a < mat->mNumProperties; ++a) {
364 aiMaterialProperty *prop = mat->mProperties[a];
365 if (!::strcmp(prop->mKey.data, "$tex.mapping")) {
366 aiTextureMapping &mapping = *((aiTextureMapping *)prop->mData);
367 if (aiTextureMapping_UV != mapping) {
368 if (!DefaultLogger::isNullLogger()) {
369 ai_snprintf(buffer, 1024, "Found non-UV mapped texture (%s,%u). Mapping type: %s",
370 aiTextureTypeToString((aiTextureType)prop->mSemantic), prop->mIndex,
371 MappingTypeToString(mapping));
372
373 ASSIMP_LOG_INFO(buffer);
374 }
375
376 if (aiTextureMapping_OTHER == mapping)
377 continue;
378
379 MappingInfo info(mapping);
380
381 // Get further properties - currently only the major axis
382 for (unsigned int a2 = 0; a2 < mat->mNumProperties; ++a2) {
383 aiMaterialProperty *prop2 = mat->mProperties[a2];
384 if (prop2->mSemantic != prop->mSemantic || prop2->mIndex != prop->mIndex)
385 continue;
386
387 if (!::strcmp(prop2->mKey.data, "$tex.mapaxis")) {
388 info.axis = *((aiVector3D *)prop2->mData);
389 break;
390 }
391 }
392
393 unsigned int idx(99999999);
394
395 // Check whether we have this mapping mode already
396 std::list<MappingInfo>::iterator it = std::find(mappingStack.begin(), mappingStack.end(), info);
397 if (mappingStack.end() != it) {
398 idx = (*it).uv;
399 } else {
400 /* We have found a non-UV mapped texture. Now
401 * we need to find all meshes using this material
402 * that we can compute UV channels for them.

Callers

nothing calls this directly

Calls 11

DeadlyImportErrorFunction · 0.85
ai_snprintfFunction · 0.85
aiTextureTypeToStringFunction · 0.85
MappingTypeToStringFunction · 0.85
findFunction · 0.85
FindEmptyUVChannelFunction · 0.85
clearMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
push_backMethod · 0.45
AddPropertyMethod · 0.45

Tested by

no test coverage detected