Commit e33b7a81 authored by Frédéric Larue's avatar Frédéric Larue

Corners() function of Box2/3f returns a CornerSet instead of taking one as parameter.

parent be7648fc
...@@ -166,7 +166,7 @@ public: ...@@ -166,7 +166,7 @@ public:
* *
* \return Set of corner points. * \return Set of corner points.
*/ */
inline void Corners( CornerSet &corners ) const; inline CornerSet Corners() const;
/** Explicit specification of the box boundaries. /** Explicit specification of the box boundaries.
* *
...@@ -284,12 +284,14 @@ inline void Box2f::SetBoundaries( const float xMin, const float xMax, ...@@ -284,12 +284,14 @@ inline void Box2f::SetBoundaries( const float xMin, const float xMax,
} }
inline void Box2f::Corners( CornerSet &corners ) const inline Box2f::CornerSet Box2f::Corners() const
{ {
CornerSet corners;
corners.xy = m_Min; corners.xy = m_Min;
corners.Xy = QVector2D( m_Max.x(), m_Min.y() ); corners.Xy = QVector2D( m_Max.x(), m_Min.y() );
corners.xY = QVector2D( m_Min.x(), m_Max.y() ); corners.xY = QVector2D( m_Min.x(), m_Max.y() );
corners.XY = m_Max; corners.XY = m_Max;
return corners;
} }
...@@ -470,7 +472,7 @@ public: ...@@ -470,7 +472,7 @@ public:
* *
* \return Set of corner points. * \return Set of corner points.
*/ */
inline void Corners( CornerSet &corners ) const; inline CornerSet Corners() const;
/** Explicit specification of the box boundaries. /** Explicit specification of the box boundaries.
* *
...@@ -624,8 +626,9 @@ inline void Box3f::SetBoundaries( const float xMin, const float xMax, ...@@ -624,8 +626,9 @@ inline void Box3f::SetBoundaries( const float xMin, const float xMax,
} }
inline void Box3f::Corners( CornerSet &corners ) const inline Box3f::CornerSet Box3f::Corners() const
{ {
CornerSet corners;
corners.xyz = m_Min; corners.xyz = m_Min;
corners.xyZ = QVector3D( m_Min.x(), m_Min.y(), m_Max.z() ); corners.xyZ = QVector3D( m_Min.x(), m_Min.y(), m_Max.z() );
corners.xYz = QVector3D( m_Min.x(), m_Max.y(), m_Min.z() ); corners.xYz = QVector3D( m_Min.x(), m_Max.y(), m_Min.z() );
...@@ -634,6 +637,7 @@ inline void Box3f::Corners( CornerSet &corners ) const ...@@ -634,6 +637,7 @@ inline void Box3f::Corners( CornerSet &corners ) const
corners.XyZ = QVector3D( m_Max.x(), m_Min.y(), m_Max.z() ); corners.XyZ = QVector3D( m_Max.x(), m_Min.y(), m_Max.z() );
corners.XYz = QVector3D( m_Max.x(), m_Max.y(), m_Min.z() ); corners.XYz = QVector3D( m_Max.x(), m_Max.y(), m_Min.z() );
corners.XYZ = m_Max; corners.XYZ = m_Max;
return corners;
} }
......
...@@ -140,17 +140,13 @@ bool Frustum::IsOutside( const Box3f::CornerSet& corners ) const ...@@ -140,17 +140,13 @@ bool Frustum::IsOutside( const Box3f::CornerSet& corners ) const
bool Frustum::IsOutside( const Box3f& box ) const bool Frustum::IsOutside( const Box3f& box ) const
{ {
Box3f::CornerSet corners; return IsOutside( box.Corners() );
box.Corners( corners );
return IsOutside( corners );
} }
bool Frustum::IsOutside( const Box3f& box, const QMatrix4x4& model ) const bool Frustum::IsOutside( const Box3f& box, const QMatrix4x4& model ) const
{ {
Box3f::CornerSet corners; Box3f::CornerSet corners = box.Corners();
box.Corners( corners );
for( auto &c : corners ) for( auto &c : corners )
c = model.map( c ); c = model.map( c );
...@@ -180,8 +176,7 @@ bool Frustum::IsOutside( const QVector3D& sphereCenter, float sphereRadius, cons ...@@ -180,8 +176,7 @@ bool Frustum::IsOutside( const QVector3D& sphereCenter, float sphereRadius, cons
Frustum::VisibilityState Frustum::TestVisibility( const Box3f& box ) const Frustum::VisibilityState Frustum::TestVisibility( const Box3f& box ) const
{ {
Box3f::CornerSet corners; Box3f::CornerSet corners = box.Corners();
box.Corners( corners );
uint32_t outsideTotalCount = 0; uint32_t outsideTotalCount = 0;
for( int i=0; i<PLANE_COUNT; ++i ) for( int i=0; i<PLANE_COUNT; ++i )
......
...@@ -530,9 +530,7 @@ void GLViewer::frameItems( QList<GenericUIData*> &items ) ...@@ -530,9 +530,7 @@ void GLViewer::frameItems( QList<GenericUIData*> &items )
if( dispInfo != m_Displayables.end() ) if( dispInfo != m_Displayables.end() )
if( !dispInfo->second.boundingBox.IsNull() ) if( !dispInfo->second.boundingBox.IsNull() )
{ {
Box3f::CornerSet objectBoxCorners; Box3f::CornerSet objectBoxCorners = dispInfo->second.boundingBox.Corners();
dispInfo->second.boundingBox.Corners( objectBoxCorners );
for( auto c=objectBoxCorners.begin(); c!=objectBoxCorners.end(); ++c ) for( auto c=objectBoxCorners.begin(); c!=objectBoxCorners.end(); ++c )
box.Add( dispInfo->second.GetTransform().map(*c) ); box.Add( dispInfo->second.GetTransform().map(*c) );
} }
...@@ -557,13 +555,8 @@ Box3f GLViewer::sceneBox() const ...@@ -557,13 +555,8 @@ Box3f GLViewer::sceneBox() const
{ {
const Box3f &objectBox = dispInfo.second.boundingBox; const Box3f &objectBox = dispInfo.second.boundingBox;
if( !objectBox.IsNull() ) if( !objectBox.IsNull() )
{ for( auto &c : objectBox.Corners() )
Box3f::CornerSet objectBoxCorners;
objectBox.Corners( objectBoxCorners );
for( auto &c : objectBoxCorners )
box.Add( dispInfo.second.GetTransform().map(c) ); box.Add( dispInfo.second.GetTransform().map(c) );
}
} }
return box; return box;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment