- fixed "projects containing more than one textured mesh are not properly rendered" bug - added minFacesSmoothRendering global parameter

This commit is contained in:
Guido Ranzuglia 2016-11-09 13:15:39 +01:00
parent ead3a733e1
commit 05dc93bdd0
7 changed files with 27 additions and 14 deletions

View File

@ -4,8 +4,8 @@
#include "meshmodel.h"
MLSceneGLSharedDataContext::MLSceneGLSharedDataContext(MeshDocument& md,vcg::QtThreadSafeMemoryInfo& gpumeminfo,bool highprecision,size_t perbatchtriangles)
:QGLWidget(),_md(md),_gpumeminfo(gpumeminfo),_perbatchtriangles(perbatchtriangles),_highprecision(highprecision)
MLSceneGLSharedDataContext::MLSceneGLSharedDataContext(MeshDocument& md,vcg::QtThreadSafeMemoryInfo& gpumeminfo,bool highprecision,size_t perbatchtriangles, size_t minfacespersmoothrendering)
:QGLWidget(),_md(md),_gpumeminfo(gpumeminfo),_perbatchtriangles(perbatchtriangles),_highprecision(highprecision), _minfacessmoothrendering(minfacespersmoothrendering)
{
if (md.size() != 0)
throw MLException(QString("MLSceneGLSharedDataContext: MeshDocument is not empty when MLSceneGLSharedDataContext is constructed."));
@ -34,6 +34,11 @@ MLSceneGLSharedDataContext::~MLSceneGLSharedDataContext()
{
}
void MLSceneGLSharedDataContext::setMinFacesForSmoothRendering(size_t fcnum)
{
_minfacessmoothrendering = fcnum;
}
MLSceneGLSharedDataContext::PerMeshMultiViewManager* MLSceneGLSharedDataContext::meshAttributesMultiViewerManager( int mmid ) const
{
MeshIDManMap::const_iterator it = _meshboman.find(mmid);
@ -258,7 +263,7 @@ void MLSceneGLSharedDataContext::addView( QGLContext* viewerid,MLRenderingData&
MeshModel* mesh = _md.getMesh(it.key());
if (mesh != NULL)
{
MLPoliciesStandAloneFunctions::suggestedDefaultPerViewRenderingData(mesh,dt);
MLPoliciesStandAloneFunctions::suggestedDefaultPerViewRenderingData(mesh,dt, _minfacessmoothrendering);
setRenderingDataPerMeshView(it.key(),viewerid,dt);
manageBuffers(it.key());
}

View File

@ -250,10 +250,12 @@ class MLSceneGLSharedDataContext : public QGLWidget
public:
//parent is set to NULL in order to avoid QT bug on MAC (business as usual...).
//The QGLWidget are destroyed by hand in the MainWindow destructor...
MLSceneGLSharedDataContext(MeshDocument& md, vcg::QtThreadSafeMemoryInfo& gpumeminfo, bool highprecision, size_t perbatchtriangles);
MLSceneGLSharedDataContext(MeshDocument& md, vcg::QtThreadSafeMemoryInfo& gpumeminfo, bool highprecision, size_t perbatchtriangles, size_t minfacespersmoothrendering);
~MLSceneGLSharedDataContext();
void setMinFacesForSmoothRendering(size_t fcnum);
vcg::QtThreadSafeMemoryInfo& memoryInfoManager() const
{
return _gpumeminfo;
@ -332,6 +334,7 @@ private:
MeshIDManMap _meshboman;
vcg::QtThreadSafeMemoryInfo& _gpumeminfo;
size_t _perbatchtriangles;
size_t _minfacessmoothrendering;
bool _highprecision;
QTimer* _timer;

View File

@ -1245,6 +1245,7 @@ void MainWindowSetting::initGlobalParameterSet(RichParameterSet* glbset)
{
glbset->addParam(new RichInt(maximumDedicatedGPUMem(), 350, "Maximum GPU Memory Dedicated to MeshLab (Mb)", "Maximum GPU Memory Dedicated to MeshLab (megabyte) for the storing of the geometry attributes. The dedicated memory must NOT be all the GPU memory presents on the videocard."));
glbset->addParam(new RichInt(perBatchPrimitives(), 100000, "Per batch primitives loaded in GPU", "Per batch primitives (vertices and faces) loaded in the GPU memory. It's used in order to do not overwhelm the system memory with an entire temporary copy of a mesh."));
glbset->addParam(new RichInt(minPolygonNumberPerSmoothRendering(), 50000, "Default Face number per smooth rendering", "Minimum number of faces in order to automatically render a newly created mesh layer with the per vertex normal attribute activated."));
glbset->addParam(new RichBool(perMeshRenderingToolBar(), true, "Show Per-Mesh Rendering Side ToolBar", "If true the per-mesh rendering side toolbar will be redendered inside the layerdialog."));
@ -1261,6 +1262,7 @@ void MainWindowSetting::updateGlobalParameterSet(RichParameterSet& rps)
{
maxgpumem = (std::ptrdiff_t)rps.getInt(maximumDedicatedGPUMem()) * (float)(1024 * 1024);
perbatchprimitives = (size_t)rps.getInt(perBatchPrimitives());
minpolygonpersmoothrendering = (size_t)rps.getInt(minPolygonNumberPerSmoothRendering());
permeshtoolbar = rps.getBool(perMeshRenderingToolBar());
highprecision = false;
if (MeshLabScalarTest<Scalarm>::doublePrecision())

View File

@ -1369,7 +1369,7 @@ void MainWindow::updateSharedContextDataAfterFilterExecution(int postcondmask,in
//A new mesh has been created by the filter. I have to add it in the shared context data structure
newmeshcreated = true;
currentmeshnewlycreated = true;
MLPoliciesStandAloneFunctions::suggestedDefaultPerViewRenderingData(mm,dttoberendered);
MLPoliciesStandAloneFunctions::suggestedDefaultPerViewRenderingData(mm,dttoberendered,mwsettings.minpolygonpersmoothrendering);
if (mm == meshDoc()->mm())
{
/*HORRIBLE TRICK IN ORDER TO HAVE VALID ACTIONS ASSOCIATED WITH THE CURRENT WIRE RENDERING MODALITY*/
@ -2434,7 +2434,7 @@ void MainWindow::newProject(const QString& projName)
{
if (gpumeminfo == NULL)
return;
MultiViewer_Container *mvcont = new MultiViewer_Container(*gpumeminfo,mwsettings.highprecision,mwsettings.perbatchprimitives,mdiarea);
MultiViewer_Container *mvcont = new MultiViewer_Container(*gpumeminfo,mwsettings.highprecision,mwsettings.perbatchprimitives,mwsettings.minpolygonpersmoothrendering,mdiarea);
connect(&mvcont->meshDoc,SIGNAL(meshAdded(int)),this,SLOT(meshAdded(int)));
connect(&mvcont->meshDoc,SIGNAL(meshRemoved(int)),this,SLOT(meshRemoved(int)));
connect(&mvcont->meshDoc, SIGNAL(documentUpdated()), this, SLOT(documentUpdateRequested()));
@ -2660,8 +2660,8 @@ bool MainWindow::loadMesh(const QString& fileName, MeshIOInterface *pCurrentIOPl
saveRecentFileList(fileName);
if(!meshDoc()->mm()->cm.textures.empty())
updateTexture(meshDoc()->mm()->id());
if (!(mm->cm.textures.empty()))
updateTexture(mm->id());
// In case of polygonal meshes the normal should be updated accordingly
if( mask & vcg::tri::io::Mask::IOM_BITPOLYGONAL)
@ -2720,7 +2720,7 @@ void MainWindow::computeRenderingDataOnLoading(MeshModel* mm,bool isareload)
if ((shared != NULL) && (mm != NULL))
{
MLRenderingData defdt;
MLPoliciesStandAloneFunctions::suggestedDefaultPerViewRenderingData(mm, defdt);
MLPoliciesStandAloneFunctions::suggestedDefaultPerViewRenderingData(mm, defdt,mwsettings.minpolygonpersmoothrendering);
for (int glarid = 0; glarid < mv->viewerCounter(); ++glarid)
{
GLArea* ar = mv->getViewer(glarid);
@ -3800,7 +3800,7 @@ bool MainWindow::addRenderingDataIfNewlyGeneratedMesh(int meshid)
if ((meshDoc()->meshDocStateData().find(meshid) == meshDoc()->meshDocStateData().end()) && (mm != NULL))
{
MLRenderingData dttoberendered;
MLPoliciesStandAloneFunctions::suggestedDefaultPerViewRenderingData(mm, dttoberendered);
MLPoliciesStandAloneFunctions::suggestedDefaultPerViewRenderingData(mm, dttoberendered,mwsettings.minpolygonpersmoothrendering);
foreach(GLArea* gla, mvc->viewerList)
{
if (gla != NULL)

View File

@ -61,11 +61,11 @@ void SplitterHandle::mousePressEvent ( QMouseEvent * e )
}
}
MultiViewer_Container::MultiViewer_Container(vcg::QtThreadSafeMemoryInfo& meminfo, bool highprec,size_t perbatchprimitives,QWidget *parent)
MultiViewer_Container::MultiViewer_Container(vcg::QtThreadSafeMemoryInfo& meminfo, bool highprec,size_t perbatchprimitives, size_t minfacespersmoothrendering,QWidget *parent)
: Splitter(parent),meshDoc()
{
setChildrenCollapsible(false);
scenecontext = new MLSceneGLSharedDataContext(meshDoc,meminfo,highprec,perbatchprimitives);
scenecontext = new MLSceneGLSharedDataContext(meshDoc,meminfo,highprec,perbatchprimitives,minfacespersmoothrendering);
scenecontext->setHidden(true);
scenecontext->initializeGL();
currentId=-1;

View File

@ -75,7 +75,7 @@ class MultiViewer_Container : public Splitter
typedef vcg::Shot<double> Shot;
public:
MultiViewer_Container(vcg::QtThreadSafeMemoryInfo& meminfo,bool highprec,size_t perbatchprimitives,QWidget *parent);
MultiViewer_Container(vcg::QtThreadSafeMemoryInfo& meminfo,bool highprec,size_t perbatchprimitives,size_t minfacesforsmoothrendering,QWidget *parent);
~MultiViewer_Container();
bool isMultiViewerContainer() const { return true; }

View File

@ -13,7 +13,10 @@ CONFIG += ordered
SUBDIRS = common \
meshlab \ # the GUI framework
meshlabplugins/io_base\ # a few basic file formats (ply, obj, off), without this you cannot open anything
meshlabplugins/filter_meshing \
meshlabplugins/io_collada\
meshlabplugins/filter_meshing \
meshlabplugins/filter_create \
meshlabplugins/filter_sampling \
#
# Next some other useful, but still easy to be compiled, plugins
# Uncomment them if you succeed in compiling the above ones.