I found this code snippet in this forum when looking for a way to define 2d bounding boxes:
Code: Select all
const Vector3* corners = box.getAllCorners();
int minx, miny, maxx, maxy;
minx = miny = INT_MAX;
maxx = maxy = INT_MIN;
Ogre::Camera* cam = getCamera();
for(int i = 0 ; i < 7; i++)
{
Ogre::Vector2 pt = toRelativeScreenCoordinates(corners[i], cam, winw, winh);
if(minx > pt.x) minx = pt.x;
if(miny > pt.y) miny = pt.y;
if(maxx < pt.x) maxx = pt.x;
if(maxy < pt.y) maxy = pt.y;
}
w = maxx - minx;
h = maxy - miny;
x = minx;
y = miny;
"INT_MIN: Minimum value for an object of type int. Value: -32767 or less."
"INT_MAX: Maximum value for an object of type int. Value: 32767 or greater."
While stating the obvious, I still found no descriptions/tutorials about the purpose of these, or in which situations are they used.
For example, let's see a part of the code snippet above:
Code: Select all
minx = miny = INT_MAX;
Would someone be kind enough to explain the purpose of these? (There are _MIN and _MAX for many numeric datatypes, but the principle is the same as for int.)
Thank you in advance.