Index: ui/gfx/box_f.cc |
diff --git a/ui/gfx/box_f.cc b/ui/gfx/box_f.cc |
index efb579671457c9d78d3dbac1630207559ebd3d2a..6b6f2fd8fb906cd9d2f6233c82691094c64430e1 100644 |
--- a/ui/gfx/box_f.cc |
+++ b/ui/gfx/box_f.cc |
@@ -45,6 +45,29 @@ void BoxF::Union(const BoxF& box) { |
depth_ = max_z - min_z; |
} |
+void BoxF::ExpandTo(const Point3F& point) { |
+ Point3F max( |
+ origin_.x() + width_, origin_.y() + height_, origin_.z() + depth_); |
+ |
+ if (point.x() < origin_.x()) |
+ origin_.set_x(point.x()); |
+ if (point.y() < origin_.y()) |
+ origin_.set_y(point.y()); |
+ if (point.z() < origin_.z()) |
+ origin_.set_z(point.z()); |
+ |
+ if (point.x() > max.x()) |
+ max.set_x(point.x()); |
+ if (point.y() > max.y()) |
+ max.set_y(point.y()); |
+ if (point.z() > max.z()) |
+ max.set_z(point.z()); |
+ |
+ width_ = max.x() - origin_.x(); |
+ height_ = max.y() - origin_.y(); |
+ depth_ = max.z() - origin_.z(); |
ajuma
2013/10/01 13:21:02
How about putting the logic that ExpandTo and Unio
|
+} |
+ |
BoxF UnionBoxes(const BoxF& a, const BoxF& b) { |
BoxF result = a; |
result.Union(b); |