From 54071b8fb2d38b60cda00151b01ad02f1c980d98 Mon Sep 17 00:00:00 2001 From: Guido Ranzuglia granzuglia Date: Fri, 5 Dec 2014 01:00:01 +0000 Subject: [PATCH] - fixed "render empty mesh" bug --- src/common/meshmodel.cpp | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/common/meshmodel.cpp b/src/common/meshmodel.cpp index 1f61710a3..0a8484730 100644 --- a/src/common/meshmodel.cpp +++ b/src/common/meshmodel.cpp @@ -173,7 +173,8 @@ If it is a newly created one the fullpath is an empty string and the user has to MeshModel * MeshDocument::addOrGetMesh(QString fullPath, QString label, bool setAsCurrent,const RenderMode& rm) { MeshModel*newMM = this->getMesh(label); - if(newMM==0) newMM=this->addNewMesh(fullPath,label,setAsCurrent,rm); + if(newMM==0) + newMM=this->addNewMesh(fullPath,label,setAsCurrent,rm); return newMM; } @@ -746,8 +747,9 @@ int MeshModel::dataMask() const } BufferObjectsRendering::BufferObjectsRendering(bool highprecmode) - :QObject(),_lock(QReadWriteLock::Recursive) + :QObject(),_lock(QReadWriteLock::Recursive),vn(0),tn(0) { + QReadLocker locker(&_lock); this->HighPrecisionMode =highprecmode; } @@ -921,6 +923,8 @@ void BufferObjectsRendering::DrawTriangles(vcg::GLW::ColorMode colm, vcg::GLW::N void BufferObjectsRendering::render(const Box3m &bbDoc, vcg::GLW::DrawMode drawm,vcg::GLW::NormalMode norm,vcg::GLW::ColorMode colm,vcg::GLW::TextureMode textm ) { QReadLocker locker(&_lock); + if (vn == 0) + return; glPushMatrix(); if(!HighPrecisionMode) { @@ -966,7 +970,8 @@ void BufferObjectsRendering::render(const Box3m &bbDoc, vcg::GLW::DrawMode drawm bool BufferObjectsRendering::update(CMeshO& mm, int updateattributesmask,vcg::GLW::DrawMode drawm, vcg::GLW::NormalMode nolm,vcg::GLW::ColorMode colm, vcg::GLW::TextureMode textm ) { - if (updateattributesmask == MeshModel::MM_NONE) + QWriteLocker locker(&_lock); + if ((updateattributesmask == MeshModel::MM_NONE) || (mm.vn == 0)) return false; tri::Allocator::CompactEveryVector(mm); @@ -1112,6 +1117,13 @@ bool BufferObjectsRendering::updateIndexedAttributesPipeline(CMeshO& mm, int upd ++ii; } + + long long unsigned int mem = 0; + for(std::map< short, std::vector >::iterator it = ti.begin();it != ti.end();++it) + mem += it->second.size() * sizeof(GLuint); + + mem += pv.size() * 3 *sizeof(GLfloat) + nv.size() * 3 *sizeof(GLfloat) + cv.size() * 4 *sizeof(GLfloat) + tv.size() * sizeof(GLfloat); + qDebug("occupied video graphics: %llu\n",mem); return true; } @@ -1223,14 +1235,12 @@ bool BufferObjectsRendering::updateReplicatedAttributesPipeline(CMeshO& mm, int rtv[k*6+5]=mm.face[indf].V(2)->T().V(); } - ++k; } ++t; } - if (k != tn) throw MeshLabException("Mesh has not been properly partitioned"); @@ -1302,6 +1312,8 @@ bool BufferObjectsRendering::updateReplicatedAttributesPipeline(CMeshO& mm, int glBindBuffer(GL_ARRAY_BUFFER, 0); } + long long unsigned int mem = rpv.size() * 3 *sizeof(GLfloat) + rnv.size() * 3 *sizeof(GLfloat) + rcv.size() * sizeof(GLuint) + rtv.size() * sizeof(GLfloat); + qDebug("occupied video graphics: %llu\n",mem); return true; }