--- a/src/raytracer.cc Fri Nov 30 00:44:51 2007 +0100
+++ b/src/raytracer.cc Mon Dec 03 01:49:23 2007 +0100
@@ -15,9 +15,9 @@
// Hammersley spherical point distribution
// http://www.cse.cuhk.edu.hk/~ttwong/papers/udpoint/udpoints.html
-Vector3 Raytracer::SphereDistribute(int i, int n, float extent, Vector3 &normal)
+Vector3 Raytracer::SphereDistribute(int i, int n, Float extent, Vector3 &normal)
{
- float p, t, st, phi, phirad;
+ Float p, t, st, phi, phirad;
int kk;
t = 0;
@@ -31,7 +31,7 @@
st = sqrt(1.0 - t*t);
- float x, y, z, xx, yy, zz, q;
+ Float x, y, z, xx, yy, zz, q;
x = st * cos(phirad);
y = st * sin(phirad);
z = t;
@@ -75,8 +75,8 @@
Colour I = Colour();
Vector3 L = light.pos - P;
L.normalize();
- float L_dot_N = dot(L, N);
- float R_dot_V = dot(R, V);
+ Float L_dot_N = dot(L, N);
+ Float R_dot_V = dot(R, V);
Colour col = mat.texture.colour; //mat.texture.evaluate(P);
@@ -91,7 +91,7 @@
Colour Raytracer::raytrace(Ray &ray, int depth, Shape *origin_shape)
{
- float nearest_distance = FLT_MAX; //Infinity
+ Float nearest_distance = Inf;
Shape *nearest_shape = top->nearest_intersection(origin_shape, ray, nearest_distance);
if (nearest_shape == NULL) {
@@ -106,12 +106,12 @@
for (light = lights.begin(); light != lights.end(); light++) {
Vector3 jo, L = (*light)->pos - P; // direction vector to light
L.normalize();
- float L_dot_N = dot(L, normal);
+ Float L_dot_N = dot(L, normal);
if (L_dot_N > 0) {
// test if this light is occluded (sharp shadows)
if ((*light)->cast_shadows) {
Ray shadow_ray = Ray(P, L);
- float dist = FLT_MAX;
+ Float dist = FLT_MAX;
if (top->nearest_intersection(nearest_shape, shadow_ray, dist))
continue;
}
@@ -137,18 +137,18 @@
// ambient occlusion
if (ao_samples)
{
- float miss = 0;
+ Float miss = 0;
for (int i = 0; i < ao_samples; i++) {
Vector3 dir = SphereDistribute(i, ao_samples, ao_angle, normal);
Ray ao_ray = Ray(P, dir);
- float dist = ao_distance;
+ Float dist = ao_distance;
Shape *shape_in_way = top->nearest_intersection(nearest_shape, ao_ray, dist);
if (shape_in_way == NULL)
miss += 1.0;
else
miss += dist / ao_distance;
}
- float ao_intensity = miss / ao_samples;
+ Float ao_intensity = miss / ao_samples;
acc = acc * ao_intensity;
}
@@ -160,7 +160,7 @@
{
RenderrowData *d = (RenderrowData*) data;
int subsample = d->rt->getSubsample();
- float subsample2 = 1.0/(subsample*subsample);
+ Float subsample2 = 1.0/(subsample*subsample);
int ww = d->w*3;
Vector3 dir = d->dfix;
for (int x = 0; x < d->w; x += subsample) {
@@ -171,8 +171,8 @@
for (int i = 0; i < 5; i++)
{
- float osax[] = {0.0, -0.4, +0.4, +0.4, -0.4};
- float osay[] = {0.0, -0.4, -0.4, +0.4, +0.4};
+ Float osax[] = {0.0, -0.4, +0.4, +0.4, -0.4};
+ Float osay[] = {0.0, -0.4, -0.4, +0.4, +0.4};
Vector3 tmpdir = dir + osax[i]*d->dx + osay[i]*d->dy;
tmpdir.normalize();
Ray ray(d->eye, tmpdir);
@@ -204,14 +204,14 @@
ray.dir = tmpdir;
Colour c3 = d->rt->raytrace(ray, 0, NULL);
// are the colors similar?
- float m = (c-c2).mag2();
+ Float m = (c-c2).mag2();
m = max(m, (c2-c3).mag2());
m = max(m, (c3-c4).mag2());
m = max(m, (c4-c).mag2());
if (m < 0.001)
{
// interpolate
- float *i = d->iter;
+ Float *i = d->iter;
for (int x = 0; x < subsample; x++)
{
for (int y = 0; y < subsample; y++)
@@ -302,14 +302,14 @@
return (void *)d;
}
-void Raytracer::render(int w, int h, float *buffer)
+void Raytracer::render(int w, int h, Float *buffer)
{
if (!camera || !top || !buffer)
return;
RenderrowData *d;
- float S = 0.5/w;
+ Float S = 0.5/w;
Vector3 dfix = camera->u*(-w/2.0*S/camera->f)
+ camera->v*(h/2.0*S/camera->f) + camera->p;
Vector3 dx = camera->u * (S/camera->f);
@@ -372,7 +372,7 @@
lights.push_back(light);
}
-void Raytracer::ambientocclusion(int samples, float distance, float angle)
+void Raytracer::ambientocclusion(int samples, Float distance, Float angle)
{
ao_samples = samples;
ao_distance = distance;