Added stream serialisation to Region.
This commit is contained in:
parent
055539ef75
commit
2a839e583d
@ -207,8 +207,13 @@ namespace PolyVox
|
|||||||
int32_t m_iUpperZ;
|
int32_t m_iUpperZ;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Non-member functions
|
||||||
bool intersects(const Region& a, const Region& b);
|
bool intersects(const Region& a, const Region& b);
|
||||||
|
|
||||||
|
// Non-member overloaded operators.
|
||||||
|
/// Stream insertion operator.
|
||||||
|
std::ostream& operator<<(std::ostream& os, const Region& region);
|
||||||
|
|
||||||
// Functions to be inlined to to be in the header rather than the .cpp.
|
// Functions to be inlined to to be in the header rather than the .cpp.
|
||||||
// 'inline' keyword is used for the definition rather than the declaration.
|
// 'inline' keyword is used for the definition rather than the declaration.
|
||||||
// See also http://www.parashift.com/c++-faq-lite/inline-functions.html
|
// See also http://www.parashift.com/c++-faq-lite/inline-functions.html
|
||||||
|
@ -470,6 +470,7 @@ namespace PolyVox
|
|||||||
/**
|
/**
|
||||||
* This function only returns true if the regions are really intersecting and not simply touching.
|
* This function only returns true if the regions are really intersecting and not simply touching.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
bool intersects(const Region& a, const Region& b)
|
bool intersects(const Region& a, const Region& b)
|
||||||
{
|
{
|
||||||
// No intersection if seperated along an axis.
|
// No intersection if seperated along an axis.
|
||||||
@ -480,4 +481,17 @@ namespace PolyVox
|
|||||||
// Overlapping on all axes means Regions are intersecting.
|
// Overlapping on all axes means Regions are intersecting.
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enables the Region to be used intuitively with output streams such as cout.
|
||||||
|
* \param os The output stream to write to.
|
||||||
|
* \param region The Region to write to the stream.
|
||||||
|
* \return A reference to the output stream to allow chaining.
|
||||||
|
*/
|
||||||
|
std::ostream& operator<<(std::ostream& os, const Region& region)
|
||||||
|
{
|
||||||
|
os << "(" << region.getLowerX() << "," << region.getLowerY() << "," << region.getLowerZ() <<
|
||||||
|
") to (" << region.getUpperX() << "," << region.getUpperY() << "," << region.getUpperZ() << ")";
|
||||||
|
return os;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user