Added another c_stor and operator += Fixed 'add' functions
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
diff --git a/include/FTBBox.h b/include/FTBBox.h
index 5c0d63d..ff2ba05 100755
--- a/include/FTBBox.h
+++ b/include/FTBBox.h
@@ -28,6 +28,18 @@ class FTGL_EXPORT FTBBox
{}
/**
+ * Constructor.
+ */
+ FTBBox( float lx, float ly, float lz, float ux, float uy, float uz)
+ : lowerX(lx),
+ lowerY(ly),
+ lowerZ(lz),
+ upperX(ux),
+ upperY(uy),
+ upperZ(uz)
+ {}
+
+ /**
* Constructor. Extracts a bounding box from a freetype glyph. Uses
* the control box for the glyph. <code>FT_Glyph_Get_CBox()</code>
*
@@ -38,11 +50,11 @@ class FTGL_EXPORT FTBBox
FT_BBox bbox;
FT_Glyph_Get_CBox( glyph, ft_glyph_bbox_subpixels, &bbox );
- lowerX = static_cast<float>( bbox.xMin) / 64;
- lowerY = static_cast<float>( bbox.yMin) / 64;
+ lowerX = static_cast<float>( bbox.xMin) / 64.0f;
+ lowerY = static_cast<float>( bbox.yMin) / 64.0f;
lowerZ = 0.0f;
- upperX = static_cast<float>( bbox.xMax) / 64;
- upperY = static_cast<float>( bbox.yMax) / 64;
+ upperX = static_cast<float>( bbox.xMax) / 64.0f;
+ upperY = static_cast<float>( bbox.yMax) / 64.0f;
upperZ = 0.0f;
}
@@ -58,7 +70,7 @@ class FTGL_EXPORT FTBBox
*
* @param distance The distance to move the bbox in 3D space.
*/
- FTBBox Move( FTPoint distance)
+ FTBBox& Move( FTPoint distance)
{
lowerX += distance.x;
lowerY += distance.y;
@@ -78,6 +90,18 @@ class FTGL_EXPORT FTBBox
*/
friend FTBBox operator + ( const FTBBox &a, const FTBBox &b);
+ FTBBox& operator += ( const FTBBox& bbox)
+ {
+ lowerX = bbox.lowerX < lowerX? bbox.lowerX: lowerX;
+ lowerY = bbox.lowerY < lowerY? bbox.lowerY: lowerY;
+ lowerZ = bbox.lowerZ < lowerZ? bbox.lowerZ: lowerZ;
+ upperX = bbox.upperX > upperX? bbox.upperX: upperX;
+ upperY = bbox.upperY > upperY? bbox.upperY: upperY;
+ upperZ = bbox.upperZ > upperZ? bbox.upperZ: upperZ;
+
+ return *this;
+ }
+
/**
* The bounds of the box
*/
diff --git a/src/FTBBox.cpp b/src/FTBBox.cpp
index b6cde9f..9028039 100755
--- a/src/FTBBox.cpp
+++ b/src/FTBBox.cpp
@@ -8,9 +8,9 @@ FTBBox operator + ( const FTBBox &a, const FTBBox &b)
compositeBox.lowerX = a.lowerX < b.lowerX? a.lowerX: b.lowerX;
compositeBox.lowerY = a.lowerY < b.lowerY? a.lowerY: b.lowerY;
compositeBox.lowerZ = a.lowerZ < b.lowerZ? a.lowerZ: b.lowerZ;
- compositeBox.upperX = a.upperX < b.upperX? a.upperX: b.upperX;
- compositeBox.upperY = a.upperY < b.upperY? a.upperY: b.upperY;
- compositeBox.upperZ = a.upperZ < b.upperZ? a.upperZ: b.upperZ;
+ compositeBox.upperX = a.upperX > b.upperX? a.upperX: b.upperX;
+ compositeBox.upperY = a.upperY > b.upperY? a.upperY: b.upperY;
+ compositeBox.upperZ = a.upperZ > b.upperZ? a.upperZ: b.upperZ;
return compositeBox;