kick
|
00001 // 00002 // aabb.h 00003 // KickCPP 00004 // 00005 // Created by Morten Nobel-Jørgensen on 07/12/13. 00006 // Copyright (c) 2013 Morten Nobel-Joergensen. All rights reserved. 00007 // 00008 00009 #pragma once 00010 00011 #include "kick/math/ray.h" 00012 #include "glm/glm.hpp" 00013 #include <limits> 00014 00015 namespace kick { 00016 struct AABB { 00017 AABB(glm::vec3 min = glm::vec3(FLT_MAX), glm::vec3 max = glm::vec3(-FLT_MAX)); 00018 00022 AABB transform(glm::mat4 mat) const; 00023 00027 void clear(); 00028 00029 void addPoint(glm::vec3 point); 00030 glm::vec3 center() const; 00031 glm::vec3 diagonal() const; 00032 glm::vec3 min; 00033 glm::vec3 max; 00034 00035 bool operator==(const AABB &other) const; 00036 bool operator!=(const AABB &other) const; 00037 void operator=(const AABB &other); 00038 00042 bool uninitialized(); 00043 00047 bool empty(); 00048 00049 bool intersect(const Ray &r, float &tNear, float &tFar, int &nearAxis, int &farAxis); 00050 bool intersect(const AABB &aabb); 00051 00052 bool contains(glm::vec3 point); 00053 private: 00054 static const AABB mUninitialized; 00055 }; 00056 }; 00057