MCPcopy Create free account
hub / github.com/MeshInspector/MeshLib / copyTextureAndColors

Method copyTextureAndColors

source/MRMesh/MRObjectMeshHolder.cpp:424–457  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

422}
423
424void ObjectMeshHolder::copyTextureAndColors( const ObjectMeshHolder & src, const VertMap & thisToSrc, const FaceMap & thisToSrcFaces )
425{
426 MR_TIMER;
427 copyColors( src, thisToSrc, thisToSrcFaces );
428 setTextures( src.getTextures() );
429
430 const auto& srcTexPerFace = src.getTexturePerFace();
431 if ( !srcTexPerFace.empty() )
432 {
433 TexturePerFace texPerFace;
434 texPerFace.resizeNoInit( thisToSrcFaces.size() );
435 ParallelFor( texPerFace, [&] ( FaceId id )
436 {
437 texPerFace[id] = srcTexPerFace[thisToSrcFaces[id]];
438 } );
439 setTexturePerFace( std::move( texPerFace ) );
440 }
441
442 const auto& srcUVCoords = src.getUVCoords();
443 const auto lastVert = src.mesh()->topology.lastValidVert();
444 const bool updateUV = lastVert < srcUVCoords.size();
445
446 if ( !updateUV )
447 return;
448
449 VertUVCoords uvCoords;
450 uvCoords.resizeNoInit( thisToSrc.size() );
451 ParallelFor( uvCoords, [&]( VertId id )
452 {
453 uvCoords[id] = srcUVCoords[thisToSrc[id]];
454 } );
455
456 setUVCoords( std::move( uvCoords ) );
457}
458
459void ObjectMeshHolder::copyColors( const ObjectMeshHolder& src, const VertMap& thisToSrc, const FaceMap& thisToSrcFaces )
460{

Callers 1

cloneRegionFunction · 0.80

Calls 7

setTexturesFunction · 0.85
ParallelForFunction · 0.85
setTexturePerFaceFunction · 0.85
setUVCoordsFunction · 0.85
emptyMethod · 0.45
sizeMethod · 0.45
lastValidVertMethod · 0.45

Tested by

no test coverage detected