diff options
author | LaG1924 <12997935+LaG1924@users.noreply.github.com> | 2018-03-29 12:03:58 +0200 |
---|---|---|
committer | LaG1924 <12997935+LaG1924@users.noreply.github.com> | 2018-03-30 01:01:51 +0200 |
commit | bf0f56a01b67e3cc13c4ba4cb8d539a0295e5e06 (patch) | |
tree | ff2dc007c07960afa3e121cfd97c82a0de67e795 /src/Frustum.hpp | |
parent | Num of parsing threads now depends from num of CPU cores (diff) | |
download | AltCraft-bf0f56a01b67e3cc13c4ba4cb8d539a0295e5e06.tar AltCraft-bf0f56a01b67e3cc13c4ba4cb8d539a0295e5e06.tar.gz AltCraft-bf0f56a01b67e3cc13c4ba4cb8d539a0295e5e06.tar.bz2 AltCraft-bf0f56a01b67e3cc13c4ba4cb8d539a0295e5e06.tar.lz AltCraft-bf0f56a01b67e3cc13c4ba4cb8d539a0295e5e06.tar.xz AltCraft-bf0f56a01b67e3cc13c4ba4cb8d539a0295e5e06.tar.zst AltCraft-bf0f56a01b67e3cc13c4ba4cb8d539a0295e5e06.zip |
Diffstat (limited to '')
-rw-r--r-- | src/Frustum.hpp | 33 |
1 files changed, 14 insertions, 19 deletions
diff --git a/src/Frustum.hpp b/src/Frustum.hpp index 4817cd4..15ea7e0 100644 --- a/src/Frustum.hpp +++ b/src/Frustum.hpp @@ -1,35 +1,30 @@ #pragma once #include <glm/glm.hpp> -#include "Vector.hpp" class Frustum { enum FrustumSide { - RIGHT = 0, + RIGHT, LEFT, BOTTOM, TOP, - BACK, - FRONT, - }; - enum PlaneData { - A = 0, - B, - C, - D, + FAR, + NEAR, + SIDE_COUNT, }; - glm::mat4 vp; - float frustum[6][4]; - void NormalizePlane(FrustumSide side); + glm::vec4 planes[SIDE_COUNT]; + +public: + Frustum(const glm::mat4 &vpMat); -public: - Frustum() = default; + ~Frustum() = default; - ~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; + } - void UpdateFrustum(const glm::mat4& vpmat); + bool TestPoint(const glm::vec3 &pos); - //Return true, if tested point is visible - bool TestPoint(VectorF point); + bool TestSphere(const glm::vec3 &pos, float radius); };
\ No newline at end of file |