From 40453dbca1ee07dc1ecc4a8ad148b8c20e622270 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sun, 8 May 2016 01:54:35 +0200 Subject: Code refactor: use dynamic shader node array lengths now that OSL supports them. --- intern/cycles/blender/blender_util.h | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'intern/cycles/blender/blender_util.h') diff --git a/intern/cycles/blender/blender_util.h b/intern/cycles/blender/blender_util.h index cefc01bfa91..d856982fddb 100644 --- a/intern/cycles/blender/blender_util.h +++ b/intern/cycles/blender/blender_util.h @@ -58,14 +58,19 @@ static inline BL::Mesh object_to_mesh(BL::BlendData& data, } static inline void colorramp_to_array(BL::ColorRamp& ramp, - float4 *data, + array& ramp_color, + array& ramp_alpha, int size) { + ramp_color.resize(size); + ramp_alpha.resize(size); + for(int i = 0; i < size; i++) { float color[4]; ramp.evaluate((float)i/(float)(size-1), color); - data[i] = make_float4(color[0], color[1], color[2], color[3]); + ramp_color[i] = make_float3(color[0], color[1], color[2]); + ramp_alpha[i] = color[3]; } } @@ -105,7 +110,7 @@ static inline void curvemapping_to_array(BL::CurveMapping& cumap, } static inline void curvemapping_color_to_array(BL::CurveMapping& cumap, - float4 *data, + array& data, int size, bool rgb_curve) { @@ -132,6 +137,8 @@ static inline void curvemapping_color_to_array(BL::CurveMapping& cumap, BL::CurveMap mapG = cumap.curves[1]; BL::CurveMap mapB = cumap.curves[2]; + data.resize(size); + if(rgb_curve) { BL::CurveMap mapI = cumap.curves[3]; -- cgit v1.2.3