src/types/boundingbox.cpp

changeset 189
815fbaae9cb2
parent 33
4c41bfe2ec6e
child 196
6bcb284679d4
equal deleted inserted replaced
188:64ea7282611e 189:815fbaae9cb2
16 * along with this program. If not, see <http://www.gnu.org/licenses/>. 16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */ 17 */
18 18
19 #include "boundingbox.h" 19 #include "boundingbox.h"
20 20
21 BoundingBox& BoundingBox::operator<<(const glm::vec3& vertex) 21 /**
22 * @brief Resizes @c box so that @c vertex fits inside
23 * @param box
24 * @param vertex
25 */
26 void addPointToBox(BoundingBox &box, const glm::vec3 &vertex)
22 { 27 {
23 this->consider(vertex); 28 box.minimum.x = math::min(vertex.x, box.minimum.x);
24 return *this; 29 box.minimum.y = math::min(vertex.y, box.minimum.y);
25 } 30 box.minimum.z = math::min(vertex.z, box.minimum.z);
26 31 box.maximum.x = math::max(vertex.x, box.maximum.x);
27 void BoundingBox::consider(const glm::vec3& vertex) 32 box.maximum.y = math::max(vertex.y, box.maximum.y);
28 { 33 box.maximum.z = math::max(vertex.z, box.maximum.z);
29 this->minimum.x = math::min(vertex.x, this->minimum.x);
30 this->minimum.y = math::min(vertex.y, this->minimum.y);
31 this->minimum.z = math::min(vertex.z, this->minimum.z);
32 this->maximum.x = math::max(vertex.x, this->maximum.x);
33 this->maximum.y = math::max(vertex.y, this->maximum.y);
34 this->maximum.z = math::max(vertex.z, this->maximum.z);
35 } 34 }
36 35
37 /* 36 /*
38 * Returns the length of the bounding box on the longest measure. 37 * Returns the length of the bounding box on the longest measure.
39 */ 38 */

mercurial