summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libdimension-python/dimension.pxd3
-rw-r--r--libdimension-python/dimension.pyx9
-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
7 files changed, 12 insertions, 40 deletions
diff --git a/libdimension-python/dimension.pxd b/libdimension-python/dimension.pxd
index 55d47ab..61b5060 100644
--- a/libdimension-python/dimension.pxd
+++ b/libdimension-python/dimension.pxd
@@ -317,8 +317,7 @@ cdef extern from "../libdimension/dimension.h":
ctypedef struct dmnsn_interior:
double ior
- dmnsn_interior *dmnsn_new_interior()
- void dmnsn_delete_interior(dmnsn_interior *interior)
+ dmnsn_interior *dmnsn_new_interior(dmnsn_pool *pool)
###########
# Objects #
diff --git a/libdimension-python/dimension.pyx b/libdimension-python/dimension.pyx
index da45f32..7466b9e 100644
--- a/libdimension-python/dimension.pyx
+++ b/libdimension-python/dimension.pyx
@@ -1045,12 +1045,9 @@ cdef class Interior:
Keyword arguments:
ior -- index of reflection
"""
- self._interior = dmnsn_new_interior()
+ self._interior = dmnsn_new_interior(_get_pool())
self._interior.ior = ior
- def __dealloc__(self):
- dmnsn_delete_interior(self._interior)
-
property ior:
"""Index of reflection."""
def __get__(self):
@@ -1062,7 +1059,6 @@ cdef Interior _Interior(dmnsn_interior *interior):
"""Wrap an Interior object around a dmnsn_interior *."""
cdef Interior self = Interior.__new__(Interior)
self._interior = interior
- DMNSN_INCREF(self._interior)
return self
###########
@@ -1134,7 +1130,6 @@ cdef class Object(_Transformable):
return _Interior(self._object.interior)
def __set__(self, Interior interior not None):
self._object.interior = interior._interior
- DMNSN_INCREF(self._object.interior)
def transform(self, Matrix trans not None):
"""Transform an object."""
@@ -1561,9 +1556,7 @@ cdef class Scene:
def __get__(self):
return _Interior(self._scene.default_interior)
def __set__(self, Interior interior not None):
- dmnsn_delete_interior(self._scene.default_interior)
self._scene.default_interior = interior._interior
- DMNSN_INCREF(self._scene.default_interior)
property background:
"""The background pigment of the scene (default: Black)."""
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;
}