39 lines
1.3 KiB
C
39 lines
1.3 KiB
C
#ifndef frustum_h
|
|
#define frustum_h
|
|
|
|
#include "raylib.h"
|
|
#include <stdbool.h>
|
|
|
|
#define number_of_planes 6
|
|
|
|
typedef struct frustum_plane_struct
|
|
{
|
|
Vector3 normal;
|
|
float distance;
|
|
} frustum_plane_struct;
|
|
|
|
/**
|
|
* Extracts the six clipping planes from a combined View-Projection matrix.
|
|
* * This function utilizes the Gribb-Hartmann method to derive plane equations
|
|
* directly from the matrix rows. The resulting planes are normalized to ensure
|
|
* that the distance calculations in visibility tests are accurate.
|
|
*/
|
|
void extract_frustum_planes(frustum_plane_struct planes[number_of_planes],
|
|
Matrix view_projection);
|
|
|
|
|
|
/**
|
|
* Checks if an Axis-Aligned Bounding Box (AABB) is within the view frustum.
|
|
* * This function performs a fast visibility test by finding the "positive vertex"
|
|
* of the box (the corner most aligned with the plane normal). If this vertex
|
|
* is outside any of the six planes, the entire box is considered culled.
|
|
*/
|
|
bool is_axis_aligned_bounding_box_in_frustum( const frustum_plane_struct planes
|
|
[
|
|
number_of_planes
|
|
],
|
|
BoundingBox bounds);
|
|
|
|
#endif
|
|
|