From 93b65ec6df40380bcfde6be4dc4ccc3c2a6e92fa Mon Sep 17 00:00:00 2001 From: Guido Ranzuglia granzuglia Date: Wed, 9 Oct 2013 12:18:31 +0000 Subject: [PATCH] - updated the plugins code using the new per mesh rendering system. This code will be changed again as soon as possible in order to prevent any possible concurrent access to the mesh rendering map. --- .../decorate_raster_proj.cpp | 4 +++- .../decorate_shadow/shadow_mapping.cpp | 4 +++- src/meshlabplugins/decorate_shadow/ssao.cpp | 4 +++- .../variance_shadow_mapping.cpp | 4 +++- .../variance_shadow_mapping_blur.cpp | 4 +++- src/meshlabplugins/edit_align/edit_align.cpp | 21 ++++++++++++------- src/meshlabplugins/edit_arc3D/edit_arc3D.cpp | 4 +++- src/meshlabplugins/edit_paint/edit_paint.cpp | 15 +++++++++---- 8 files changed, 43 insertions(+), 17 deletions(-) diff --git a/src/meshlabplugins/decorate_raster_proj/decorate_raster_proj.cpp b/src/meshlabplugins/decorate_raster_proj/decorate_raster_proj.cpp index ab24338ed..49afac0cd 100644 --- a/src/meshlabplugins/decorate_raster_proj/decorate_raster_proj.cpp +++ b/src/meshlabplugins/decorate_raster_proj/decorate_raster_proj.cpp @@ -617,6 +617,8 @@ void DecorateRasterProjPlugin::decorateDoc( QAction *act, { case DP_PROJECT_RASTER: { + if ((gla == NULL) || (gla->getCurrentRenderMode())) + return; glPushAttrib( GL_ALL_ATTRIB_BITS ); updateCurrentMesh( m, *par ); @@ -624,7 +626,7 @@ void DecorateRasterProjPlugin::decorateDoc( QAction *act, glEnable( GL_DEPTH_TEST ); - RenderMode rm = gla->getCurrentRenderMode(); + RenderMode rm = *gla->getCurrentRenderMode(); bool notDrawn = false; switch( rm.drawMode ) { diff --git a/src/meshlabplugins/decorate_shadow/shadow_mapping.cpp b/src/meshlabplugins/decorate_shadow/shadow_mapping.cpp index 824d30702..cd2cfa9e8 100644 --- a/src/meshlabplugins/decorate_shadow/shadow_mapping.cpp +++ b/src/meshlabplugins/decorate_shadow/shadow_mapping.cpp @@ -114,6 +114,8 @@ void ShadowMapping::renderingFromLightUnsetup(){ void ShadowMapping::runShader(MeshDocument& md, GLArea* gla){ GLfloat g_mModelView[16]; GLfloat g_mProjection[16]; + if ((gla == NULL) || (gla->getCurrentRenderMode() == NULL)) + return; this->renderingFromLightSetup(md, gla); @@ -133,7 +135,7 @@ void ShadowMapping::runShader(MeshDocument& md, GLArea* gla){ //binding the FBO this->bind(); - RenderMode rm = gla->getCurrentRenderMode(); + RenderMode rm = *gla->getCurrentRenderMode(); foreach(MeshModel *m, md.meshList) if(m->visible) { diff --git a/src/meshlabplugins/decorate_shadow/ssao.cpp b/src/meshlabplugins/decorate_shadow/ssao.cpp index 83b21ffa6..8078f9dd9 100644 --- a/src/meshlabplugins/decorate_shadow/ssao.cpp +++ b/src/meshlabplugins/decorate_shadow/ssao.cpp @@ -113,9 +113,11 @@ void SSAO::runShader(MeshDocument& md, GLArea* gla){ /***********************************************************/ //NORMAL MAP and DEPTH MAP generation /***********************************************************/ + if ((gla == NULL) || (gla->getCurrentRenderMode() == NULL)) + return; this->bind(); glUseProgram(this->_normalMapShaderProgram); - RenderMode rm = gla->getCurrentRenderMode(); + RenderMode rm = *gla->getCurrentRenderMode(); vcg::Matrix44f mProj, mInverseProj; glMatrixMode(GL_PROJECTION); diff --git a/src/meshlabplugins/decorate_shadow/variance_shadow_mapping.cpp b/src/meshlabplugins/decorate_shadow/variance_shadow_mapping.cpp index c2b004f47..362e9dd76 100644 --- a/src/meshlabplugins/decorate_shadow/variance_shadow_mapping.cpp +++ b/src/meshlabplugins/decorate_shadow/variance_shadow_mapping.cpp @@ -70,6 +70,8 @@ bool VarianceShadowMapping::init() void VarianceShadowMapping::runShader(MeshDocument& md, GLArea* gla){ GLfloat g_mModelView[16]; GLfloat g_mProjection[16]; + if ((gla == NULL) || (gla->getCurrentRenderMode() == NULL)) + return; this->renderingFromLightSetup(md, gla); @@ -87,7 +89,7 @@ void VarianceShadowMapping::runShader(MeshDocument& md, GLArea* gla){ this->bind(); glUseProgram(this->_depthShaderProgram); - RenderMode rm = gla->getCurrentRenderMode(); + RenderMode rm = *gla->getCurrentRenderMode(); foreach(MeshModel *m, md.meshList) if(m->visible) { diff --git a/src/meshlabplugins/decorate_shadow/variance_shadow_mapping_blur.cpp b/src/meshlabplugins/decorate_shadow/variance_shadow_mapping_blur.cpp index e9f893ef3..8daf17e32 100644 --- a/src/meshlabplugins/decorate_shadow/variance_shadow_mapping_blur.cpp +++ b/src/meshlabplugins/decorate_shadow/variance_shadow_mapping_blur.cpp @@ -76,6 +76,8 @@ void VarianceShadowMappingBlur::runShader(MeshDocument& md, GLArea* gla){ GLfloat g_mModelView[16]; GLfloat g_mProjection[16]; + if ((gla == NULL) || (gla->getCurrentRenderMode() == NULL)) + return; this->renderingFromLightSetup(md, gla); glMatrixMode(GL_PROJECTION); glGetFloatv(GL_PROJECTION_MATRIX, g_mProjection); @@ -89,7 +91,7 @@ void VarianceShadowMappingBlur::runShader(MeshDocument& md, GLArea* gla){ this->bind(); glUseProgram(this->_depthShaderProgram); - RenderMode rm = gla->getCurrentRenderMode(); + RenderMode rm = *gla->getCurrentRenderMode(); glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); foreach(MeshModel *m, md.meshList) diff --git a/src/meshlabplugins/edit_align/edit_align.cpp b/src/meshlabplugins/edit_align/edit_align.cpp index 52fcac926..5a7af7baa 100644 --- a/src/meshlabplugins/edit_align/edit_align.cpp +++ b/src/meshlabplugins/edit_align/edit_align.cpp @@ -57,12 +57,15 @@ void EditAlignPlugin::Decorate(MeshModel &m, GLArea * gla) case ALIGN_MOVE: { // Draw the editing mesh - gla->rm.colorMode=GLW::CMPerMesh; + QMap::iterator it = gla->rendermodemap.find(m.id()); + if (it == gla->rendermodemap.end()) + return; + it.value().colorMode = GLW::CMPerMesh; m.visible=false; glPushMatrix(); trackball.GetView(); trackball.Apply(); - m.render(GLW::DMFlat,GLW::CMPerMesh,gla->rm.textureMode); + m.render(GLW::DMFlat,GLW::CMPerMesh,it.value().textureMode); glPopMatrix(); break; } @@ -100,7 +103,8 @@ bool EditAlignPlugin::StartEdit(MeshDocument &_md, GLArea *_gla ) mm->cm.C()=Color4b::Scatter(51, mm->id()%50, .2f, .7f); meshTree.nodeList.push_back(new MeshNode(mm)); } - gla->rm.colorMode=GLW::CMPerMesh; + for(QMap::iterator it = _gla->rendermodemap.begin();it != _gla->rendermodemap.end();++it) + it.value().colorMode=GLW::CMPerMesh; gla->setCursor(QCursor(QPixmap(":/images/cur_align.png"),1,1)); if(alignDialog==0) @@ -487,9 +491,12 @@ void EditAlignPlugin::DrawArc(vcg::AlignPair::Result *A ) void EditAlignPlugin::toggledColors(int colorstate) { - if(colorstate == Qt::Checked) - gla->rm.colorMode=GLW::CMPerMesh; - else - gla->rm.colorMode=GLW::CMPerVert; + for(QMap::iterator it = gla->rendermodemap.begin();it != gla->rendermodemap.end();++it) + { + if(colorstate == Qt::Checked) + it.value().colorMode=GLW::CMPerMesh; + else + it.value().colorMode=GLW::CMPerVert; + } gla->update(); } diff --git a/src/meshlabplugins/edit_arc3D/edit_arc3D.cpp b/src/meshlabplugins/edit_arc3D/edit_arc3D.cpp index 2e0012d13..763382780 100644 --- a/src/meshlabplugins/edit_arc3D/edit_arc3D.cpp +++ b/src/meshlabplugins/edit_arc3D/edit_arc3D.cpp @@ -139,6 +139,8 @@ This is the main function, which generates the final mesh (and the rasters) base void EditArc3DPlugin::ExportPly() { + if ((gla == NULL) || (gla->getCurrentRenderMode() == NULL)) + return; md->setBusy(true); md->addNewMesh("",er.name,true); MeshModel* m=md->mm(); @@ -244,7 +246,7 @@ void EditArc3DPlugin::ExportPly() md->mm()->visible=true; md->setBusy(false); - gla->rm.colorMode=GLW::CMPerVert; + gla->getCurrentRenderMode()->colorMode=GLW::CMPerVert; emit this->resetTrackBall(); gla->update(); diff --git a/src/meshlabplugins/edit_paint/edit_paint.cpp b/src/meshlabplugins/edit_paint/edit_paint.cpp index 7c0a114ca..075978c3d 100644 --- a/src/meshlabplugins/edit_paint/edit_paint.cpp +++ b/src/meshlabplugins/edit_paint/edit_paint.cpp @@ -68,8 +68,10 @@ bool EditPaintPlugin::StartEdit(MeshModel& m, GLArea * parent) } tri::InitFaceIMark(m.cm); tri::InitVertexIMark(m.cm); - - parent->getCurrentRenderMode().colorMode=vcg::GLW::CMPerVert; + QMap::iterator it = parent->rendermodemap.find(m.id()); + if (it == parent->rendermodemap.end()) + return false; + it.value().colorMode=vcg::GLW::CMPerVert; QObject::connect(paintbox, SIGNAL(undo()), this, SLOT(update())); QObject::connect(paintbox, SIGNAL(redo()), this, SLOT(update())); @@ -290,7 +292,10 @@ void EditPaintPlugin::Decorate(MeshModel &m, GLArea * gla) if (color_buffer != NULL) delete color_buffer; if (clone_zbuffer != NULL) delete clone_zbuffer; color_buffer = NULL, clone_zbuffer = NULL; - glarea->getCurrentRenderMode().lighting = false; + QMap::iterator it = glarea->rendermodemap.find(m.id()); + if (it == glarea->rendermodemap.end()) + return; + it.value().lighting = false; current_options &= ~EPP_DRAW_CURSOR; glarea->update(); } @@ -642,7 +647,9 @@ inline void EditPaintPlugin::capture() image.setPixel(x, glarea->height() - y -1, qRgba((int)color_buffer[index], (int)color_buffer[index + 1], (int)color_buffer[index + 2], (int)color_buffer[index + 3])); } } - glarea->getCurrentRenderMode().lighting = true; + if (glarea->getCurrentRenderMode() == NULL) + return; + glarea->getCurrentRenderMode()->lighting = true; current_options |= EPP_DRAW_CURSOR; paintbox->setClonePixmap(image); paintbox->setPixmapDelta(source_delta.x(), source_delta.y());