summaryrefslogtreecommitdiffstats
path: root/libdimension
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2014-05-30 18:51:59 -0400
committerTavian Barnes <tavianator@tavianator.com>2014-05-30 18:51:59 -0400
commit4781d3a2a7ec463ee712c8de6362d8b6c872c31b (patch)
tree7bc2b7c8605f25e300a9be3d85230173d35a5fa9 /libdimension
parent57ee9bfb0dddba7ea06fd0e09c8aa2d80b8eb46d (diff)
downloaddimension-4781d3a2a7ec463ee712c8de6362d8b6c872c31b.tar.xz
interior: Use pool.
Diffstat (limited to 'libdimension')
-rw-r--r--libdimension/dimension/interior.h11
-rw-r--r--libdimension/interior.c15
-rw-r--r--libdimension/object.c1
-rw-r--r--libdimension/scene.c3
-rw-r--r--libdimension/tests/render.c10
5 files changed, 10 insertions, 30 deletions
diff --git a/libdimension/dimension/interior.h b/libdimension/dimension/interior.h
index 69d3ebf..0ff697d 100644
--- a/libdimension/dimension/interior.h
+++ b/libdimension/dimension/interior.h
@@ -26,21 +26,14 @@
/** An interior. */
typedef struct dmnsn_interior {
double ior; /**< Refractive index. */
-
- DMNSN_REFCOUNT; /**< Reference count. */
} dmnsn_interior;
/**
* Create an interior object.
+ * @param[in] pool The memory pool to allocate from.
* @return The new interior.
*/
-dmnsn_interior *dmnsn_new_interior(void);
-
-/**
- * Delete an interior.
- * @param[in,out] interior The interior to delete.
- */
-void dmnsn_delete_interior(dmnsn_interior *interior);
+dmnsn_interior *dmnsn_new_interior(dmnsn_pool *pool);
/**
* Fill missing interior properties from a default interior.
diff --git a/libdimension/interior.c b/libdimension/interior.c
index 7d7af85..7657461 100644
--- a/libdimension/interior.c
+++ b/libdimension/interior.c
@@ -28,23 +28,13 @@
/* Allocate an interior */
dmnsn_interior *
-dmnsn_new_interior(void)
+dmnsn_new_interior(dmnsn_pool *pool)
{
- dmnsn_interior *interior = DMNSN_MALLOC(dmnsn_interior);
+ dmnsn_interior *interior = DMNSN_PALLOC(pool, dmnsn_interior);
interior->ior = 1.0;
- DMNSN_REFCOUNT_INIT(interior);
return interior;
}
-/* Free a interior */
-void
-dmnsn_delete_interior(dmnsn_interior *interior)
-{
- if (DMNSN_DECREF(interior)) {
- dmnsn_free(interior);
- }
-}
-
/* Cascade a interior */
void
dmnsn_interior_cascade(dmnsn_interior *default_interior,
@@ -52,6 +42,5 @@ dmnsn_interior_cascade(dmnsn_interior *default_interior,
{
if (!*interiorp) {
*interiorp = default_interior;
- DMNSN_INCREF(*interiorp);
}
}
diff --git a/libdimension/object.c b/libdimension/object.c
index 52b9558..bf84cfe 100644
--- a/libdimension/object.c
+++ b/libdimension/object.c
@@ -68,7 +68,6 @@ dmnsn_delete_object(dmnsn_object *object)
dmnsn_delete_object(*child);
}
dmnsn_delete_array(object->children);
- dmnsn_delete_interior(object->interior);
dmnsn_delete_texture(object->texture);
object->free_fn(object);
}
diff --git a/libdimension/scene.c b/libdimension/scene.c
index ea605e6..6500707 100644
--- a/libdimension/scene.c
+++ b/libdimension/scene.c
@@ -34,7 +34,7 @@ dmnsn_new_scene(dmnsn_pool *pool)
scene->background = NULL;
scene->default_texture = dmnsn_new_texture();
- scene->default_interior = dmnsn_new_interior();
+ scene->default_interior = dmnsn_new_interior(pool);
scene->canvas = NULL;
scene->region_x = 0;
scene->region_y = 0;
@@ -63,7 +63,6 @@ dmnsn_delete_scene(dmnsn_scene *scene)
dmnsn_delete_array(scene->lights);
dmnsn_delete_array(scene->objects);
- dmnsn_delete_interior(scene->default_interior);
dmnsn_delete_texture(scene->default_texture);
dmnsn_delete_pigment(scene->background);
}
diff --git a/libdimension/tests/render.c b/libdimension/tests/render.c
index ebdc557..3c551da 100644
--- a/libdimension/tests/render.c
+++ b/libdimension/tests/render.c
@@ -117,7 +117,7 @@ dmnsn_test_scene_add_lights(dmnsn_pool *pool, dmnsn_scene *scene)
}
static void
-dmnsn_test_scene_add_hollow_cube(dmnsn_scene *scene)
+dmnsn_test_scene_add_hollow_cube(dmnsn_pool *pool, dmnsn_scene *scene)
{
dmnsn_object *cube = dmnsn_new_cube();
cube->trans = dmnsn_rotation_matrix(
@@ -133,7 +133,7 @@ dmnsn_test_scene_add_hollow_cube(dmnsn_scene *scene)
cube->texture->finish.reflection =
dmnsn_new_basic_reflection(dmnsn_black, reflect, 1.0);
- cube->interior = dmnsn_new_interior();
+ cube->interior = dmnsn_new_interior(pool);
cube->interior->ior = 1.1;
dmnsn_object *sphere = dmnsn_new_sphere();
@@ -290,9 +290,9 @@ dmnsn_test_scene_add_ground(dmnsn_scene *scene)
}
static void
-dmnsn_test_scene_add_objects(dmnsn_scene *scene)
+dmnsn_test_scene_add_objects(dmnsn_pool *pool, dmnsn_scene *scene)
{
- dmnsn_test_scene_add_hollow_cube(scene);
+ dmnsn_test_scene_add_hollow_cube(pool, scene);
dmnsn_test_scene_add_spike(scene);
dmnsn_test_scene_add_triangle_strip(scene);
dmnsn_test_scene_add_ground(scene);
@@ -310,7 +310,7 @@ dmnsn_new_test_scene(dmnsn_pool *pool)
dmnsn_test_scene_add_camera(pool, scene);
dmnsn_test_scene_add_background(pool, scene);
dmnsn_test_scene_add_lights(pool, scene);
- dmnsn_test_scene_add_objects(scene);
+ dmnsn_test_scene_add_objects(pool, scene);
return scene;
}