Skip to content

Commit

Permalink
improve auto camera changed
Browse files Browse the repository at this point in the history
  • Loading branch information
kerautret committed Apr 6, 2017
1 parent 8edc911 commit 2893bec
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 9 deletions.
2 changes: 2 additions & 0 deletions src/DGtal/io/Display3D.h
Original file line number Diff line number Diff line change
Expand Up @@ -896,6 +896,8 @@ namespace DGtal
///
std::set<SelectCallbackFctStore> mySelectCallBackFcts;

bool myBoundingPtChangedTag = false;

//----end of protected datas

// ------------------------- Internals ------------------------------------
Expand Down
40 changes: 33 additions & 7 deletions src/DGtal/io/Display3D.ih
Original file line number Diff line number Diff line change
Expand Up @@ -1191,16 +1191,42 @@ DGtal::Display3D< Space ,KSpace >::updateBoundingBox(const RealPoint &p)
myBoundingPtUp[1]= p[1];
myBoundingPtUp[2]= p[2];
myBoundingPtEmptyTag = false;
myBoundingPtChangedTag = true;
}
else
{
if(p[0] <myBoundingPtLow[0]) myBoundingPtLow[0]= p[0];
if(p[1] <myBoundingPtLow[1]) myBoundingPtLow[1]= p[1];
if(p[2] <myBoundingPtLow[2]) myBoundingPtLow[2]= p[2];

if(p[0] >myBoundingPtUp[0]) myBoundingPtUp[0]= p[0];
if(p[1] >myBoundingPtUp[1]) myBoundingPtUp[1]= p[1];
if(p[2] >myBoundingPtUp[2]) myBoundingPtUp[2]= p[2];
if(p[0] <myBoundingPtLow[0])
{
myBoundingPtLow[0]= p[0];
myBoundingPtChangedTag = true;
}
if(p[1] <myBoundingPtLow[1])
{
myBoundingPtLow[1]= p[1];
myBoundingPtChangedTag = true;
}

if(p[2] <myBoundingPtLow[2])
{
myBoundingPtLow[2]= p[2];
myBoundingPtChangedTag = true;
}

if(p[0] >myBoundingPtUp[0])
{
myBoundingPtUp[0]= p[0];
myBoundingPtChangedTag = true;
}
if(p[1] >myBoundingPtUp[1])
{
myBoundingPtUp[1]= p[1];
myBoundingPtChangedTag = true;
}
if(p[2] >myBoundingPtUp[2])
{
myBoundingPtUp[2]= p[2];
myBoundingPtChangedTag = true;
}
}
}

Expand Down
5 changes: 3 additions & 2 deletions src/DGtal/io/viewers/Viewer3D.ih
Original file line number Diff line number Diff line change
Expand Up @@ -1098,8 +1098,7 @@ DGtal::Viewer3D<TSpace, TKSpace>::updateList ( bool needToUpdateBoundingBox )
// Seventh list: Textured images.
glUpdateTextureImages(myGSImageList);


if ( needToUpdateBoundingBox )
if ( needToUpdateBoundingBox && Viewer3D<TSpace, TKSpace>::myBoundingPtChangedTag )
{
setSceneBoundingBox ( qglviewer::Vec ( Viewer3D<TSpace, TKSpace>::myBoundingPtLow[0],
Viewer3D<TSpace, TKSpace>::myBoundingPtLow[1],
Expand All @@ -1108,7 +1107,9 @@ DGtal::Viewer3D<TSpace, TKSpace>::updateList ( bool needToUpdateBoundingBox )
Viewer3D<TSpace, TKSpace>::myBoundingPtUp[1],
Viewer3D<TSpace, TKSpace>::myBoundingPtUp[2] ) );
showEntireScene();
Viewer3D<TSpace, TKSpace>::myBoundingPtChangedTag = false;
}
updateGL();
glPopMatrix();
}

Expand Down

0 comments on commit 2893bec

Please sign in to comment.