summaryrefslogtreecommitdiffstats
path: root/src/Frustum.hpp
blob: 15ea7e0e968295a9b7646f78e283b6c070a01180 (plain) (blame)
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
#pragma once

#include <glm/glm.hpp>

class Frustum {
    enum FrustumSide {
        RIGHT,
        LEFT,
        BOTTOM,
        TOP,
		FAR,
        NEAR,
		SIDE_COUNT,
    };

	glm::vec4 planes[SIDE_COUNT];

public:    
	Frustum(const glm::mat4 &vpMat);

	~Frustum() = default;

	inline static float GetDistanceToPoint(const glm::vec4 &plane, const glm::vec3 &pos) {
		return plane.x * pos.x + plane.y * pos.y + plane.z * pos.z + plane.w;
	}

	bool TestPoint(const glm::vec3 &pos);

	bool TestSphere(const glm::vec3 &pos, float radius);
};