erebus
view liberebus/src/bvol.cc @ 34:d15ee526daa6
- changed the UI font, made it a bit smaller
- fixed the text positioning in the status bar
- added ThreadPool::clear to remove all pending jobs
- fixed the TargetCamera matrix calculation to avoid singularities when the
camera looks straight up or down.
- fixed ommited normalization in TargetCamera's matrix calculation
- added paths/sec display in the status bar
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sun, 08 Jun 2014 08:12:05 +0300 |
parents | 4abdce1361b9 |
children | c4d48a21bc4a |
line source
1 #include "bvol.h"
3 bool AABox::intersect(const Ray &ray) const
4 {
5 Vector3 param[2] = {vmin, vmax};
6 Vector3 inv_dir(1.0 / ray.dir.x, 1.0 / ray.dir.y, 1.0 / ray.dir.z);
7 int sign[3] = {inv_dir.x < 0, inv_dir.y < 0, inv_dir.z < 0};
9 float tmin = (param[sign[0]].x - ray.origin.x) * inv_dir.x;
10 float tmax = (param[1 - sign[0]].x - ray.origin.x) * inv_dir.x;
11 float tymin = (param[sign[1]].y - ray.origin.y) * inv_dir.y;
12 float tymax = (param[1 - sign[1]].y - ray.origin.y) * inv_dir.y;
14 if(tmin > tymax || tymin > tmax) {
15 return false;
16 }
17 if(tymin > tmin) {
18 tmin = tymin;
19 }
20 if(tymax < tmax) {
21 tmax = tymax;
22 }
24 float tzmin = (param[sign[2]].z - ray.origin.z) * inv_dir.z;
25 float tzmax = (param[1 - sign[2]].z - ray.origin.z) * inv_dir.z;
27 if(tmin > tzmax || tzmin > tmax) {
28 return false;
29 }
30 if(tzmin > tmin) {
31 tmin = tzmin;
32 }
33 if(tzmax < tmax) {
34 tmax = tzmax;
35 }
37 return true;
38 }