Added Ray, AABB structs, and basic rayVsAABB test function.

This commit is contained in:
William Moberg
2015-12-02 14:24:21 +01:00
parent fa0ace8c68
commit c698149bdd
3 changed files with 58 additions and 22 deletions
+26 -1
View File
@@ -1,9 +1,34 @@
#ifndef Collision_h__
#define Collision_h__
#include "../GLM.h"
namespace Collision
{
//bool RayAABBIntr(float3 origin, float3 direction, float3 center, float3 h);
struct Ray
{
glm::vec3 Origin;
glm::vec3 Direction;
};
class AABB
{
public:
AABB() = default;
AABB(const glm::vec3& minPos, const glm::vec3& maxPos);
const glm::vec3& MinCorner() const { return m_MinCorner; }
const glm::vec3& MaxCorner() const { return m_MaxCorner; }
const glm::vec3& Center() const { return m_Center; }
const glm::vec3& HalfSize() const { return m_HalfSize; }
private:
glm::vec3 m_MinCorner;
glm::vec3 m_MaxCorner;
glm::vec3 m_Center;
glm::vec3 m_HalfSize;
};
bool RayAABBIntr(const Ray& ray, const AABB& box);
}
#endif