diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2014-05-31 14:08:36 -0400 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2014-05-31 14:13:38 -0400 |
commit | c42fd6547afed0b65260ae6a8a07cf9dcf084b67 (patch) | |
tree | d0cf947f8b7a2c4ae0e5f6151da3ff656f663f57 /libdimension-python | |
parent | c10255ab3da17507d63bdc7e1fdfc809ffd32f7f (diff) | |
download | dimension-c42fd6547afed0b65260ae6a8a07cf9dcf084b67.tar.xz |
finish: Use pool.
Diffstat (limited to 'libdimension-python')
-rw-r--r-- | libdimension-python/dimension.pxd | 18 | ||||
-rw-r--r-- | libdimension-python/dimension.pyx | 16 |
2 files changed, 11 insertions, 23 deletions
diff --git a/libdimension-python/dimension.pxd b/libdimension-python/dimension.pxd index 45a081f..b822827 100644 --- a/libdimension-python/dimension.pxd +++ b/libdimension-python/dimension.pxd @@ -272,23 +272,19 @@ cdef extern from "../libdimension/dimension.h": ctypedef struct dmnsn_reflection ctypedef struct dmnsn_finish: - dmnsn_ambient *ambient - dmnsn_diffuse *diffuse - dmnsn_specular *specular + dmnsn_ambient *ambient + dmnsn_diffuse *diffuse + dmnsn_specular *specular dmnsn_reflection *reflection dmnsn_finish dmnsn_new_finish() - void dmnsn_delete_finish(dmnsn_finish finish) - - void dmnsn_finish_incref(dmnsn_finish *finish) void dmnsn_finish_cascade(dmnsn_finish *default_finish, dmnsn_finish *finish) - dmnsn_ambient *dmnsn_new_ambient(dmnsn_color ambient) - dmnsn_diffuse *dmnsn_new_lambertian(double diffuse) - dmnsn_specular *dmnsn_new_phong(double specular, double exp) - dmnsn_reflection *dmnsn_new_basic_reflection(dmnsn_color min, dmnsn_color max, - double falloff) + dmnsn_ambient *dmnsn_new_ambient(dmnsn_pool *pool, dmnsn_color ambient) + dmnsn_diffuse *dmnsn_new_lambertian(dmnsn_pool *pool, double diffuse) + dmnsn_specular *dmnsn_new_phong(dmnsn_pool *pool, double specular, double exp) + dmnsn_reflection *dmnsn_new_basic_reflection(dmnsn_pool *pool, dmnsn_color min, dmnsn_color max, double falloff) ############ # Textures # diff --git a/libdimension-python/dimension.pyx b/libdimension-python/dimension.pyx index 0a90b07..7c951d6 100644 --- a/libdimension-python/dimension.pyx +++ b/libdimension-python/dimension.pyx @@ -879,9 +879,6 @@ cdef class Finish: def __cinit__(self): self._finish = dmnsn_new_finish() - def __dealloc__(self): - dmnsn_delete_finish(self._finish) - def __add__(Finish lhs not None, Finish rhs not None): """ Combine two finishes. @@ -898,7 +895,6 @@ cdef Finish _Finish(dmnsn_finish finish): """Wrap a Finish object around a dmnsn_finish.""" cdef Finish self = Finish.__new__(Finish) self._finish = finish - dmnsn_finish_incref(&self._finish) return self cdef class Ambient(Finish): @@ -910,7 +906,7 @@ cdef class Ambient(Finish): Keyword arguments: color -- the color and intensity of the ambient light """ - self._finish.ambient = dmnsn_new_ambient(Color(color)._c) + self._finish.ambient = dmnsn_new_ambient(_get_pool(), Color(color)._c) cdef class Diffuse(Finish): """Lambertian diffuse reflection.""" @@ -921,7 +917,7 @@ cdef class Diffuse(Finish): Keyword arguments: diffuse -- the intensity of the diffuse reflection """ - self._finish.diffuse = dmnsn_new_lambertian(Color(diffuse).intensity()) + self._finish.diffuse = dmnsn_new_lambertian(_get_pool(), Color(diffuse).intensity()) cdef class Phong(Finish): """Phong specular highlight.""" @@ -933,7 +929,7 @@ cdef class Phong(Finish): strength -- the strength of the Phong highlight size -- the "shininess" of the material """ - self._finish.specular = dmnsn_new_phong(Color(strength).intensity(), size) + self._finish.specular = dmnsn_new_phong(_get_pool(), Color(strength).intensity(), size) cdef class Reflection(Finish): """Reflective finish.""" @@ -949,9 +945,7 @@ cdef class Reflection(Finish): if max is None: max = min - self._finish.reflection = dmnsn_new_basic_reflection(Color(min)._c, - Color(max)._c, - falloff) + self._finish.reflection = dmnsn_new_basic_reflection(_get_pool(), Color(min)._c, Color(max)._c, falloff) ############ # Textures # @@ -1000,9 +994,7 @@ cdef class Texture(_Transformable): def __get__(self): return _Finish(self._texture.finish) def __set__(self, Finish finish not None): - dmnsn_delete_finish(self._texture.finish) self._texture.finish = finish._finish - dmnsn_finish_incref(&self._texture.finish) def transform(self, Matrix trans not None): """Transform a texture.""" |