From bc07a00def027222f6a78ddb7e95dc964c583e1c Mon Sep 17 00:00:00 2001 From: alemuntoni Date: Thu, 15 Jul 2021 18:52:45 +0200 Subject: [PATCH] bugfix on edge rendering bo manager --- ..._mesh_attributes_multi_viewer_bo_manager.h | 32 ++++++++++--------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/wrap/gl/gl_mesh_attributes_multi_viewer_bo_manager.h b/wrap/gl/gl_mesh_attributes_multi_viewer_bo_manager.h index 30feb0ef..e0fd053e 100644 --- a/wrap/gl/gl_mesh_attributes_multi_viewer_bo_manager.h +++ b/wrap/gl/gl_mesh_attributes_multi_viewer_bo_manager.h @@ -35,7 +35,7 @@ #include #include #include -#include +#include #include @@ -1158,25 +1158,27 @@ namespace vcg triangles += cit->second - cit->first + 1; } - if ((attributestobeupdated[INT_ATT_NAMES::ATT_EDGEINDICES]) && (_edge.size() > 0)) - { - for (typename std::vector::iterator it = _edge.begin(); it != _edge.end(); ++it) - { - it->_v[0] = vpatlas[it->_v[0]]; - it->_v[1] = vpatlas[it->_v[1]]; - } - - GLBufferObject* buffobj = _bo[INT_ATT_NAMES::ATT_EDGEINDICES]; - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buffobj->_bohandle); - glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, buffobj->_components * buffobj->getSizeOfGLType() * _edge.size(), &_edge[0]); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); - } - if (attributestobeupdated[INT_ATT_NAMES::ATT_WEDGETEXTURE] || attributestobeupdated[INT_ATT_NAMES::ATT_VERTTEXTURE]) _texindnumtriangles[t] = std::make_pair(mit->first, triangles); ++t; } + if ((attributestobeupdated[INT_ATT_NAMES::ATT_EDGEINDICES]) && (_edge.size() > 0)) + { + unsigned int i = 0; + for (EdgeVertInd& e : _edge) + { + e._v[0] = vpatlas[e._v[0]]; + e._v[1] = vpatlas[e._v[1]]; + ++i; + } + + GLBufferObject* buffobj = _bo[INT_ATT_NAMES::ATT_EDGEINDICES]; + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buffobj->_bohandle); + glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, buffobj->_components * buffobj->getSizeOfGLType() * _edge.size(), &_edge[0]); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); + } + //return (k != tn) // throw MeshLabException("Mesh has not been properly partitioned"); return true;