MCPcopy Create free account
hub / github.com/PyMesh/PyMesh / finalize_textures

Method finalize_textures

src/IO/OBJParser.cpp:511–547  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

509}
510
511void OBJParser::finalize_textures() {
512 const size_t num_faces = m_faces.size();
513 if (m_textures.size() != num_faces || m_corner_textures.size() == 0)
514 return;
515
516 m_texture_dim = 2;
517 bool bad_texture = false;
518 const size_t num_corner_textures = m_corner_textures.size();
519 for (const auto& t : m_textures) {
520 if (t.size() != m_vertex_per_face) {
521 std::cerr << "Texture and face type mismatch." << std::endl;
522 bad_texture = true;
523 break;
524 }
525 }
526
527 if (bad_texture) {
528 m_textures.clear();
529 return;
530 }
531
532 TextureVector textures;
533 const Vector2F INVALID_UV {
534 std::numeric_limits<Float>::quiet_NaN(),
535 std::numeric_limits<Float>::quiet_NaN()};
536 for (const auto& t : m_textures) {
537 for (size_t i=0; i<m_vertex_per_face; i++) {
538 if (t[i] >= 0 && t[i] < num_corner_textures) {
539 textures.emplace_back(m_corner_textures[t[i]]);
540 } else {
541 textures.emplace_back(INVALID_UV);
542 }
543 }
544 }
545 std::swap(textures, m_corner_textures);
546 assert(m_corner_textures.size() == num_faces * m_vertex_per_face);
547}
548
549void OBJParser::finalize_normals() {
550 if (m_normals.size() != m_faces.size() || m_corner_normals.size() == 0)

Callers

nothing calls this directly

Calls 2

sizeMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected