summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2010-04-06 01:28:29 -0400
committerTavian Barnes <tavianator@gmail.com>2010-04-06 01:28:29 -0400
commitffb8da7d94a130f2d152f706d1af113fc4640246 (patch)
tree2888622fe853c9a494c4ed6915b2e0a72538b349 /tests
parentb7405924923986314b09460995c2ebce3b717100 (diff)
downloaddimension-ffb8da7d94a130f2d152f706d1af113fc4640246.tar.xz
Add CSG unions to libdimension.
Diffstat (limited to 'tests')
-rw-r--r--tests/libdimension/tests.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/tests/libdimension/tests.c b/tests/libdimension/tests.c
index d5aeb69..47d9b7c 100644
--- a/tests/libdimension/tests.c
+++ b/tests/libdimension/tests.c
@@ -86,7 +86,6 @@ dmnsn_new_default_scene()
dmnsn_delete_scene(scene);
return NULL;
}
- dmnsn_array_push(scene->objects, &sphere);
sphere->texture = dmnsn_new_texture();
if (!sphere->texture) {
@@ -104,13 +103,14 @@ dmnsn_new_default_scene()
dmnsn_object *cube = dmnsn_new_cube();
if (!cube) {
+ dmnsn_delete_object(sphere);
dmnsn_delete_scene(scene);
return NULL;
}
- dmnsn_array_push(scene->objects, &cube);
cube->texture = dmnsn_new_texture();
if (!cube->texture) {
+ dmnsn_delete_object(sphere);
dmnsn_delete_scene(scene);
return NULL;
}
@@ -120,6 +120,7 @@ dmnsn_new_default_scene()
cube_color.trans = 0.5;
cube->texture->pigment = dmnsn_new_solid_pigment(cube_color);
if (!cube->texture->pigment) {
+ dmnsn_delete_object(sphere);
dmnsn_delete_scene(scene);
return NULL;
}
@@ -127,12 +128,14 @@ dmnsn_new_default_scene()
dmnsn_color reflect = dmnsn_color_mul(0.5, dmnsn_white);
cube->texture->finish = dmnsn_new_reflective_finish(reflect, reflect, 1.0);
if (!cube->texture->finish) {
+ dmnsn_delete_object(sphere);
dmnsn_delete_scene(scene);
return NULL;
}
cube->interior = dmnsn_new_interior();
if (!cube->interior) {
+ dmnsn_delete_object(sphere);
dmnsn_delete_scene(scene);
return NULL;
}
@@ -140,6 +143,13 @@ dmnsn_new_default_scene()
cube->trans = dmnsn_rotation_matrix(dmnsn_new_vector(0.75, 0.0, 0.0));
+ dmnsn_object *csg = dmnsn_new_csg_union(sphere, cube);
+ if (!csg) {
+ dmnsn_delete_scene(scene);
+ return NULL;
+ }
+ dmnsn_array_push(scene->objects, &csg);
+
/* Now make a light */
dmnsn_light *light = dmnsn_new_point_light(