Skip to content

Instantly share code, notes, and snippets.

@Kinwailo
Kinwailo / ExtractPlanes.cpp
Created May 18, 2017 09:39
Extract planes from projection matrix
struct Matrix4x4
{
// The elements of the 4x4 matrix are stored in
// column-major order (see "OpenGL Programming Guide",
// 3rd edition, pp 106, glLoadMatrix).
float _11, _21, _31, _41;
float _12, _22, _32, _42;
float _13, _23, _33, _43;
float _14, _24, _34, _44;
};
@Kinwailo
Kinwailo / FrustumAABBIntersect.cpp
Last active May 28, 2024 12:49
Frustum AABB Intersect
// Returns: INTERSECT : 0
// INSIDE : 1
// OUTSIDE : 2
int FrustumAABBIntersect(Plane *planes, Vector &mins, Vector &maxs) {
int ret = INSIDE;
Vector vmin, vmax;
for(int i = 0; i < 6; ++i) {
// X axis
if(planes[i].normal.x > 0) {