![]() |
Shadowrun: Awakened 29 September 2011 - Build 871
|
#include "machine.h"#include "types.h"#include "macros.h"#include "box.h"#include "vector.h"#include "intersect.h"#include "util.h"
Include dependency graph for box.cpp:Go to the source code of this file.
Functions | |
| int | box_bbox (void *obj, vector *min, vector *max) |
| void | box_intersect (box *bx, ray *ry) |
| void | box_normal (box *bx, vector *pnt, ray *incident, vector *N) |
| box * | newbox (void *tex, vector min, vector max) |
Variables | |
| static object_methods | box_methods |
Definition at line 101 of file box.cpp.
References add_intersection(), ray::d, FHUGE, box::max, box::min, ray::o, vector::x, vector::y, and vector::z.
{
flt a, tx1, tx2, ty1, ty2, tz1, tz2;
flt tnear, tfar;
tnear= -FHUGE;
tfar= FHUGE;
if (ry->d.x == 0.0) {
if ((ry->o.x < bx->min.x) || (ry->o.x > bx->max.x)) return;
}
else {
tx1 = (bx->min.x - ry->o.x) / ry->d.x;
tx2 = (bx->max.x - ry->o.x) / ry->d.x;
if (tx1 > tx2) { a=tx1; tx1=tx2; tx2=a; }
if (tx1 > tnear) tnear=tx1;
if (tx2 < tfar) tfar=tx2;
}
if (tnear > tfar) return;
if (tfar < 0.0) return;
if (ry->d.y == 0.0) {
if ((ry->o.y < bx->min.y) || (ry->o.y > bx->max.y)) return;
}
else {
ty1 = (bx->min.y - ry->o.y) / ry->d.y;
ty2 = (bx->max.y - ry->o.y) / ry->d.y;
if (ty1 > ty2) { a=ty1; ty1=ty2; ty2=a; }
if (ty1 > tnear) tnear=ty1;
if (ty2 < tfar) tfar=ty2;
}
if (tnear > tfar) return;
if (tfar < 0.0) return;
if (ry->d.z == 0.0) {
if ((ry->o.z < bx->min.z) || (ry->o.z > bx->max.z)) return;
}
else {
tz1 = (bx->min.z - ry->o.z) / ry->d.z;
tz2 = (bx->max.z - ry->o.z) / ry->d.z;
if (tz1 > tz2) { a=tz1; tz1=tz2; tz2=a; }
if (tz1 > tnear) tnear=tz1;
if (tz2 < tfar) tfar=tz2;
}
if (tnear > tfar) return;
if (tfar < 0.0) return;
add_intersection(tnear, (object *) bx, ry);
add_intersection(tfar, (object *) bx, ry);
}
Definition at line 151 of file box.cpp.
References box::max, box::min, MYMAX, VNorm(), VSub(), vector::x, vector::y, and vector::z.
{
vector a, b, c;
flt t;
c.x=(bx->max.x + bx->min.x) / 2.0;
c.y=(bx->max.y + bx->min.y) / 2.0;
c.z=(bx->max.z + bx->min.z) / 2.0;
VSub((vector *) pnt, &c, N);
b=(*N);
a.x=fabs(N->x);
a.y=fabs(N->y);
a.z=fabs(N->z);
N->x=0.0; N->y=0.0; N->z=0.0;
t=MYMAX(a.x, MYMAX(a.y, a.z));
if (t==a.x) N->x=b.x;
if (t==a.y) N->y=b.y;
if (t==a.z) N->z=b.z;
VNorm(N);
}
Definition at line 88 of file box.cpp.
References box_methods, box::max, box::methods, box::min, rt_getmem(), and box::tex.
Referenced by newscalarvol(), and rt_box().
object_methods box_methods [static] |
{
(void (*)(void *, void *))(box_intersect),
(void (*)(void *, void *, void *, void *))(box_normal),
box_bbox,
free
}
Definition at line 81 of file box.cpp.
Referenced by newbox().
Copyright © 2007-2010 by The Shadowrun: Awakened Team. This work is licensed under the GNU Lesser General Public License 3.