From 7d4646404b96c970eb141289c2aa8b3937282842 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Tue, 27 May 2014 19:08:09 -0400 Subject: finish: Remove ->ptr fields. --- libdimension/reflection.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) (limited to 'libdimension/reflection.c') diff --git a/libdimension/reflection.c b/libdimension/reflection.c index 934fcf6..ca279b8 100644 --- a/libdimension/reflection.c +++ b/libdimension/reflection.c @@ -27,11 +27,12 @@ #include #include -/** Reflective finish payload. */ -typedef struct dmnsn_reflection_params { +/** Basic reflective finish type. */ +typedef struct dmnsn_basic_reflection { + dmnsn_reflection reflection; dmnsn_color min, max; double falloff; -} dmnsn_reflection_params; +} dmnsn_basic_reflection; /** Reflective finish callback. */ static dmnsn_color @@ -39,11 +40,11 @@ dmnsn_basic_reflection_fn(const dmnsn_reflection *reflection, dmnsn_color reflect, dmnsn_color color, dmnsn_vector ray, dmnsn_vector normal) { - dmnsn_reflection_params *params = reflection->ptr; - double coeff = pow(fabs(dmnsn_vector_dot(ray, normal)), params->falloff); + const dmnsn_basic_reflection *basic = (const dmnsn_basic_reflection *)reflection; + double coeff = pow(fabs(dmnsn_vector_dot(ray, normal)), basic->falloff); return dmnsn_color_illuminate( - dmnsn_color_gradient(params->min, params->max, coeff), + dmnsn_color_gradient(basic->min, basic->max, coeff), reflect ); } @@ -51,16 +52,13 @@ dmnsn_basic_reflection_fn(const dmnsn_reflection *reflection, dmnsn_reflection * dmnsn_new_basic_reflection(dmnsn_color min, dmnsn_color max, double falloff) { - dmnsn_reflection *reflection = dmnsn_new_reflection(); - - dmnsn_reflection_params *params = DMNSN_MALLOC(dmnsn_reflection_params); - params->min = min; - params->max = max; - params->falloff = falloff; + dmnsn_basic_reflection *basic = DMNSN_MALLOC(dmnsn_basic_reflection); + basic->min = min; + basic->max = max; + basic->falloff = falloff; + dmnsn_reflection *reflection = &basic->reflection; + dmnsn_init_reflection(reflection); reflection->reflection_fn = dmnsn_basic_reflection_fn; - reflection->free_fn = dmnsn_free; - reflection->ptr = params; - return reflection; } -- cgit v1.2.3