summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2010-02-25 15:28:23 -0500
committerTavian Barnes <tavianator@gmail.com>2010-02-25 15:28:23 -0500
commitb27ad82573bc70d84bc4213ba00771f4746b36bc (patch)
tree6d4b6390da29cb29759b4d469c6869d6180e0680
parent9e117cb576f55e3215cb46dcd8d2ad3b52124eb4 (diff)
downloaddimension-b27ad82573bc70d84bc4213ba00771f4746b36bc.tar.xz
Add the dmnsn_interior* to dmnsn_intersection*.
-rw-r--r--libdimension/cube.c9
-rw-r--r--libdimension/dimension/object.h7
-rw-r--r--libdimension/sphere.c9
3 files changed, 14 insertions, 11 deletions
diff --git a/libdimension/cube.c b/libdimension/cube.c
index da7f206..9815eb6 100644
--- a/libdimension/cube.c
+++ b/libdimension/cube.c
@@ -124,10 +124,11 @@ dmnsn_cube_intersection_fn(const dmnsn_object *cube, dmnsn_line line)
if (t >= 0.0) {
intersection = dmnsn_new_intersection();
- intersection->ray = line;
- intersection->t = t;
- intersection->normal = normal;
- intersection->texture = cube->texture;
+ intersection->ray = line;
+ intersection->t = t;
+ intersection->normal = normal;
+ intersection->texture = cube->texture;
+ intersection->interior = cube->interior;
}
return intersection;
diff --git a/libdimension/dimension/object.h b/libdimension/dimension/object.h
index 4c1980d..e607d8c 100644
--- a/libdimension/dimension/object.h
+++ b/libdimension/dimension/object.h
@@ -26,7 +26,7 @@
#define DIMENSION_OBJECT_H
/* A type to represent a ray-object intersection */
-typedef struct {
+typedef struct dmnsn_intersection {
/* The ray and point which intersected */
dmnsn_line ray;
double t;
@@ -34,8 +34,9 @@ typedef struct {
/* The surface normal at the intersection point */
dmnsn_vector normal;
- /* The texture at the intersection point */
- const dmnsn_texture *texture;
+ /* The object properties at the intersection point */
+ const dmnsn_texture *texture;
+ const dmnsn_interior *interior;
} dmnsn_intersection;
/* Intersection allocation cannot fail */
diff --git a/libdimension/sphere.c b/libdimension/sphere.c
index c238192..d994248 100644
--- a/libdimension/sphere.c
+++ b/libdimension/sphere.c
@@ -69,10 +69,11 @@ dmnsn_sphere_intersection_fn(const dmnsn_object *sphere, dmnsn_line line)
if (t >= 0.0) {
intersection = dmnsn_new_intersection();
- intersection->ray = line;
- intersection->t = t;
- intersection->normal = dmnsn_line_point(line, t);
- intersection->texture = sphere->texture;
+ intersection->ray = line;
+ intersection->t = t;
+ intersection->normal = dmnsn_line_point(line, t);
+ intersection->texture = sphere->texture;
+ intersection->interior = sphere->interior;
/* Flip the normal if we're inside the sphere */
if (dmnsn_vector_dot(line.n, intersection->normal) > 0.0)