![]() |
Shadowrun: Awakened 29 September 2011 - Build 871
|
#include "machine.h"#include "types.h"#include "macros.h"#include "vector.h"#include "intersect.h"#include "util.h"#include "sphere.h"
Include dependency graph for sphere.cpp:Go to the source code of this file.
Defines | |
| #define | SPHERE_PRIVATE |
Functions | |
| object * | newsphere (void *tex, vector ctr, flt rad) |
| static int | sphere_bbox (void *obj, vector *min, vector *max) |
| static void | sphere_intersect (sphere *spr, ray *ry) |
| static void | sphere_normal (sphere *spr, vector *pnt, ray *incident, vector *N) |
Variables | |
| static object_methods | sphere_methods |
| #define SPHERE_PRIVATE |
Definition at line 71 of file sphere.cpp.
Definition at line 81 of file sphere.cpp.
References rt_getmem(), test::s, and sphere_methods.
Referenced by rt_sphere().
{
sphere * s;
s=(sphere *) rt_getmem(sizeof(sphere));
memset(s, 0, sizeof(sphere));
s->methods = &sphere_methods;
s->tex=(texture *)tex;
s->ctr=ctr;
s->rad=rad;
return (object *) s;
}
Definition at line 95 of file sphere.cpp.
| static void sphere_intersect | ( | sphere * | spr, |
| ray * | ry | ||
| ) | [static] |
Definition at line 108 of file sphere.cpp.
References add_intersection(), ray::d, ray::o, SPEPSILON, V, VDOT, and VSUB.
{
flt b, disc, t1, t2, temp;
vector V;
VSUB(spr->ctr, ry->o, V);
VDOT(b, V, ry->d);
VDOT(temp, V, V);
disc=b*b + spr->rad*spr->rad - temp;
if (disc<=0.0) return;
disc=sqrt(disc);
t2=b+disc;
if (t2 <= SPEPSILON)
return;
add_intersection(t2, (object *) spr, ry);
t1=b-disc;
if (t1 > SPEPSILON)
add_intersection(t1, (object *) spr, ry);
}
object_methods sphere_methods [static] |
{
(void (*)(void *, void *))(sphere_intersect),
(void (*)(void *, void *, void *, void *))(sphere_normal),
sphere_bbox,
free
}
Definition at line 74 of file sphere.cpp.
Referenced by newsphere().
Copyright © 2007-2010 by The Shadowrun: Awakened Team. This work is licensed under the GNU Lesser General Public License 3.