move extracting planes to camera header

* since it related to view frustum / camera it should be in thie header or separate header called frustum.h
* update LICENSE to add authors of algorithm
This commit is contained in:
Recep Aslantas
2017-12-30 13:55:17 +03:00
parent d14627ac52
commit 99669a21a4
7 changed files with 60 additions and 43 deletions

View File

@@ -11,6 +11,7 @@
#include "common.h"
#include "mat4.h"
#include "vec4.h"
#include "vec3.h"
/*
Plane equation: Ax + By + Cz + D = 0;
@@ -21,7 +22,6 @@
/*
Functions:
CGLM_INLINE void glm_plane_normalize(vec4 plane);
CGLM_INLINE void glm_plane_extract(mat4 projView, vec4 dest[6]);
*/
/*!
@@ -35,36 +35,4 @@ glm_plane_normalize(vec4 plane) {
glm_vec4_scale(plane, 1.0f / glm_vec_norm(plane), plane);
}
/*!
* @brief extracts view frustum planes
*
* computing projView: glm_mat4_mul(proj, view, projView);
*
* exracted planes order: [left, right, bottom, top, near, far]
*
* @param[in] projView source
* @param[out] dest exracted view frustum planes (see brief)
*/
CGLM_INLINE
void
glm_plane_extract(mat4 projView, vec4 dest[6]) {
mat4 m;
glm_mat4_transpose_to(projView, m);
glm_vec4_add(m[3], m[0], dest[0]);
glm_vec4_sub(m[3], m[0], dest[1]);
glm_vec4_add(m[3], m[1], dest[2]);
glm_vec4_sub(m[3], m[1], dest[3]);
glm_vec4_add(m[3], m[2], dest[4]);
glm_vec4_sub(m[3], m[2], dest[5]);
glm_plane_normalize(dest[0]);
glm_plane_normalize(dest[1]);
glm_plane_normalize(dest[2]);
glm_plane_normalize(dest[3]);
glm_plane_normalize(dest[4]);
glm_plane_normalize(dest[5]);
}
#endif /* cglm_plane_h */