Open source Star Ruler 2 source code!

This commit is contained in:
Lucas de Vries
2018-07-17 14:15:37 +02:00
commit cc307720ff
4342 changed files with 2365070 additions and 0 deletions
+37
View File
@@ -0,0 +1,37 @@
#pragma once
#include "plane.h"
#include "line3d.h"
#include "aabbox.h"
struct frustum {
//Planes are: Near, Left, Right, Top, Bottom, Far
planed planes[6];
AABBoxd bound;
frustum() {}
frustum(const line3dd& topLeft, const line3dd& topRight, const line3dd& botLeft, const line3dd& botRight) {
planes[0] = planed(topLeft.start, botLeft.start, topRight.start);
planes[1] = planed(topLeft.start, topLeft.end, botLeft.start);
planes[2] = planed(topRight.end, topRight.start, botRight.start);
planes[3] = planed(topLeft.start, topRight.start, topRight.end);
planes[4] = planed(botRight.start, botLeft.start, botRight.end);
planes[5] = planed(topLeft.end, topRight.end, botLeft.end);
bound.reset(topLeft);
bound.addLine(topRight);
bound.addLine(botLeft);
bound.addLine(botRight);
}
void operator=(const frustum& other) {
memcpy(this, &other, sizeof(frustum));
}
bool overlaps(const vec3d& center, double radius) const {
for(unsigned i = 0; i < 6; ++i)
if(planes[i].distanceFromPlane(center) <= -radius)
return false;
return true;
}
};