diff options
Diffstat (limited to 'source')
45 files changed, 584 insertions, 464 deletions
diff --git a/source/blender/blenkernel/BKE_colorband.h b/source/blender/blenkernel/BKE_colorband.h new file mode 100644 index 00000000000..aa64e793331 --- /dev/null +++ b/source/blender/blenkernel/BKE_colorband.h @@ -0,0 +1,50 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * ***** END GPL LICENSE BLOCK ***** + */ +#ifndef __BKE_COLORBAND_H__ +#define __BKE_COLORBAND_H__ + +/** \file BKE_colorband.h + */ + +#ifdef __cplusplus +extern "C" { +#endif + +struct ColorBand; + +/* in ColorBand struct */ +#define MAXCOLORBAND 32 + +void BKE_colorband_init(struct ColorBand *coba, bool rangetype); +struct ColorBand *BKE_colorband_add(bool rangetype); +bool BKE_colorband_evaluate(const struct ColorBand *coba, float in, float out[4]); +void BKE_colorband_evaluate_table_rgba(const struct ColorBand *coba, float **array, int *size); +struct CBData *BKE_colorband_element_add(struct ColorBand *coba, float position); +int BKE_colorband_element_remove(struct ColorBand *coba, int index); +void BKE_colorband_update_sort(struct ColorBand *coba); + +#ifdef __cplusplus +} +#endif + +#endif /* __BKE_COLORBAND_H__ */ diff --git a/source/blender/blenkernel/BKE_texture.h b/source/blender/blenkernel/BKE_texture.h index 8a9171673ea..4e98852c995 100644 --- a/source/blender/blenkernel/BKE_texture.h +++ b/source/blender/blenkernel/BKE_texture.h @@ -60,14 +60,6 @@ struct World; #define MAXCOLORBAND 32 -void init_colorband(struct ColorBand *coba, bool rangetype); -struct ColorBand *add_colorband(bool rangetype); -bool do_colorband(const struct ColorBand *coba, float in, float out[4]); -void colorband_table_RGBA(struct ColorBand *coba, float **array, int *size); -struct CBData *colorband_element_add(struct ColorBand *coba, float position); -int colorband_element_remove(struct ColorBand *coba, int index); -void colorband_update_sort(struct ColorBand *coba); - void BKE_texture_free(struct Tex *tex); void BKE_texture_default(struct Tex *tex); void BKE_texture_copy_data(struct Main *bmain, struct Tex *tex_dst, const struct Tex *tex_src, const int flag); diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt index c99c3d6ffa9..279068c440e 100644 --- a/source/blender/blenkernel/CMakeLists.txt +++ b/source/blender/blenkernel/CMakeLists.txt @@ -89,6 +89,7 @@ set(SRC intern/cloth.c intern/collection.c intern/collision.c + intern/colorband.c intern/colortools.c intern/constraint.c intern/context.c @@ -225,6 +226,7 @@ set(SRC BKE_cloth.h BKE_collection.h BKE_collision.h + BKE_colorband.h BKE_colortools.h BKE_constraint.h BKE_context.h diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 1367157c13c..01340b97807 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -52,6 +52,7 @@ #include "BLI_task.h" #include "BKE_cdderivedmesh.h" +#include "BKE_colorband.h" #include "BKE_editmesh.h" #include "BKE_key.h" #include "BKE_layer.h" @@ -64,7 +65,6 @@ #include "BKE_object.h" #include "BKE_object_deform.h" #include "BKE_paint.h" -#include "BKE_texture.h" #include "BKE_multires.h" #include "BKE_bvhutils.h" #include "BKE_deform.h" @@ -1379,7 +1379,7 @@ static void weightpaint_color(unsigned char r_col[4], DMWeightColorInfo *dm_wcin float colf[4]; if (dm_wcinfo && dm_wcinfo->coba) { - do_colorband(dm_wcinfo->coba, input, colf); + BKE_colorband_evaluate(dm_wcinfo->coba, input, colf); } else { weight_to_rgb(colf, input); diff --git a/source/blender/blenkernel/intern/colorband.c b/source/blender/blenkernel/intern/colorband.c new file mode 100644 index 00000000000..a9f4ae083d0 --- /dev/null +++ b/source/blender/blenkernel/intern/colorband.c @@ -0,0 +1,396 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. + * All rights reserved. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/blenkernel/intern/colorband.c + * \ingroup bke + */ + +#include "MEM_guardedalloc.h" + +#include "BLI_math.h" +#include "BLI_utildefines.h" +#include "BLI_math_color.h" + +#include "DNA_key_types.h" +#include "DNA_texture_types.h" + +#include "BKE_colorband.h" +#include "BKE_material.h" +#include "BKE_key.h" + +void BKE_colorband_init(ColorBand *coba, bool rangetype) +{ + int a; + + coba->data[0].pos = 0.0; + coba->data[1].pos = 1.0; + + if (rangetype == 0) { + coba->data[0].r = 0.0; + coba->data[0].g = 0.0; + coba->data[0].b = 0.0; + coba->data[0].a = 0.0; + + coba->data[1].r = 1.0; + coba->data[1].g = 1.0; + coba->data[1].b = 1.0; + coba->data[1].a = 1.0; + } + else { + coba->data[0].r = 0.0; + coba->data[0].g = 0.0; + coba->data[0].b = 0.0; + coba->data[0].a = 1.0; + + coba->data[1].r = 1.0; + coba->data[1].g = 1.0; + coba->data[1].b = 1.0; + coba->data[1].a = 1.0; + } + + for (a = 2; a < MAXCOLORBAND; a++) { + coba->data[a].r = 0.5; + coba->data[a].g = 0.5; + coba->data[a].b = 0.5; + coba->data[a].a = 1.0; + coba->data[a].pos = 0.5; + } + + coba->tot = 2; + coba->color_mode = COLBAND_BLEND_RGB; +} + +ColorBand *BKE_colorband_add(bool rangetype) +{ + ColorBand *coba; + + coba = MEM_callocN(sizeof(ColorBand), "colorband"); + BKE_colorband_init(coba, rangetype); + + return coba; +} + +/* ------------------------------------------------------------------------- */ + +static float colorband_hue_interp( + const int ipotype_hue, + const float mfac, const float fac, + float h1, float h2) +{ + float h_interp; + int mode = 0; + +#define HUE_INTERP(h_a, h_b) ((mfac * (h_a)) + (fac * (h_b))) +#define HUE_MOD(h) (((h) < 1.0f) ? (h) : (h) - 1.0f) + + h1 = HUE_MOD(h1); + h2 = HUE_MOD(h2); + + BLI_assert(h1 >= 0.0f && h1 < 1.0f); + BLI_assert(h2 >= 0.0f && h2 < 1.0f); + + switch (ipotype_hue) { + case COLBAND_HUE_NEAR: + { + if ((h1 < h2) && (h2 - h1) > +0.5f) mode = 1; + else if ((h1 > h2) && (h2 - h1) < -0.5f) mode = 2; + else mode = 0; + break; + } + case COLBAND_HUE_FAR: + { + if ((h1 < h2) && (h2 - h1) < +0.5f) mode = 1; + else if ((h1 > h2) && (h2 - h1) > -0.5f) mode = 2; + else mode = 0; + break; + } + case COLBAND_HUE_CCW: + { + if (h1 > h2) mode = 2; + else mode = 0; + break; + } + case COLBAND_HUE_CW: + { + if (h1 < h2) mode = 1; + else mode = 0; + break; + } + } + + switch (mode) { + case 0: + h_interp = HUE_INTERP(h1, h2); + break; + case 1: + h_interp = HUE_INTERP(h1 + 1.0f, h2); + h_interp = HUE_MOD(h_interp); + break; + case 2: + h_interp = HUE_INTERP(h1, h2 + 1.0f); + h_interp = HUE_MOD(h_interp); + break; + } + + BLI_assert(h_interp >= 0.0f && h_interp < 1.0f); + +#undef HUE_INTERP +#undef HUE_MOD + + return h_interp; +} + +bool BKE_colorband_evaluate(const ColorBand *coba, float in, float out[4]) +{ + const CBData *cbd1, *cbd2, *cbd0, *cbd3; + float fac; + int ipotype; + int a; + + if (coba == NULL || coba->tot == 0) return false; + + cbd1 = coba->data; + + ipotype = (coba->color_mode == COLBAND_BLEND_RGB) ? coba->ipotype : COLBAND_INTERP_LINEAR; + + if (coba->tot == 1) { + out[0] = cbd1->r; + out[1] = cbd1->g; + out[2] = cbd1->b; + out[3] = cbd1->a; + } + else if ((in <= cbd1->pos) && ELEM(ipotype, COLBAND_INTERP_LINEAR, COLBAND_INTERP_EASE)) { + out[0] = cbd1->r; + out[1] = cbd1->g; + out[2] = cbd1->b; + out[3] = cbd1->a; + } + else { + CBData left, right; + + /* we're looking for first pos > in */ + for (a = 0; a < coba->tot; a++, cbd1++) { + if (cbd1->pos > in) { + break; + } + } + + if (a == coba->tot) { + cbd2 = cbd1 - 1; + right = *cbd2; + right.pos = 1.0f; + cbd1 = &right; + } + else if (a == 0) { + left = *cbd1; + left.pos = 0.0f; + cbd2 = &left; + } + else { + cbd2 = cbd1 - 1; + } + + if ((in >= cbd1->pos) && ELEM(ipotype, COLBAND_INTERP_LINEAR, COLBAND_INTERP_EASE)) { + out[0] = cbd1->r; + out[1] = cbd1->g; + out[2] = cbd1->b; + out[3] = cbd1->a; + } + else { + + if (cbd2->pos != cbd1->pos) { + fac = (in - cbd1->pos) / (cbd2->pos - cbd1->pos); + } + else { + /* was setting to 0.0 in 2.56 & previous, but this + * is incorrect for the last element, see [#26732] */ + fac = (a != coba->tot) ? 0.0f : 1.0f; + } + + if (ipotype == COLBAND_INTERP_CONSTANT) { + /* constant */ + out[0] = cbd2->r; + out[1] = cbd2->g; + out[2] = cbd2->b; + out[3] = cbd2->a; + } + else if (ipotype >= COLBAND_INTERP_B_SPLINE) { + /* ipo from right to left: 3 2 1 0 */ + float t[4]; + + if (a >= coba->tot - 1) cbd0 = cbd1; + else cbd0 = cbd1 + 1; + if (a < 2) cbd3 = cbd2; + else cbd3 = cbd2 - 1; + + CLAMP(fac, 0.0f, 1.0f); + + if (ipotype == COLBAND_INTERP_CARDINAL) { + key_curve_position_weights(fac, t, KEY_CARDINAL); + } + else { + key_curve_position_weights(fac, t, KEY_BSPLINE); + } + + out[0] = t[3] * cbd3->r + t[2] * cbd2->r + t[1] * cbd1->r + t[0] * cbd0->r; + out[1] = t[3] * cbd3->g + t[2] * cbd2->g + t[1] * cbd1->g + t[0] * cbd0->g; + out[2] = t[3] * cbd3->b + t[2] * cbd2->b + t[1] * cbd1->b + t[0] * cbd0->b; + out[3] = t[3] * cbd3->a + t[2] * cbd2->a + t[1] * cbd1->a + t[0] * cbd0->a; + CLAMP(out[0], 0.0f, 1.0f); + CLAMP(out[1], 0.0f, 1.0f); + CLAMP(out[2], 0.0f, 1.0f); + CLAMP(out[3], 0.0f, 1.0f); + } + else { + float mfac; + + if (ipotype == COLBAND_INTERP_EASE) { + mfac = fac * fac; + fac = 3.0f * mfac - 2.0f * mfac * fac; + } + + mfac = 1.0f - fac; + + if (UNLIKELY(coba->color_mode == COLBAND_BLEND_HSV)) { + float col1[3], col2[3]; + + rgb_to_hsv_v(&cbd1->r, col1); + rgb_to_hsv_v(&cbd2->r, col2); + + out[0] = colorband_hue_interp(coba->ipotype_hue, mfac, fac, col1[0], col2[0]); + out[1] = mfac * col1[1] + fac * col2[1]; + out[2] = mfac * col1[2] + fac * col2[2]; + out[3] = mfac * cbd1->a + fac * cbd2->a; + + hsv_to_rgb_v(out, out); + } + else if (UNLIKELY(coba->color_mode == COLBAND_BLEND_HSL)) { + float col1[3], col2[3]; + + rgb_to_hsl_v(&cbd1->r, col1); + rgb_to_hsl_v(&cbd2->r, col2); + + out[0] = colorband_hue_interp(coba->ipotype_hue, mfac, fac, col1[0], col2[0]); + out[1] = mfac * col1[1] + fac * col2[1]; + out[2] = mfac * col1[2] + fac * col2[2]; + out[3] = mfac * cbd1->a + fac * cbd2->a; + + hsl_to_rgb_v(out, out); + } + else { + /* COLBAND_BLEND_RGB */ + out[0] = mfac * cbd1->r + fac * cbd2->r; + out[1] = mfac * cbd1->g + fac * cbd2->g; + out[2] = mfac * cbd1->b + fac * cbd2->b; + out[3] = mfac * cbd1->a + fac * cbd2->a; + } + } + } + } + return true; /* OK */ +} + +void BKE_colorband_evaluate_table_rgba(const ColorBand *coba, float **array, int *size) +{ + int a; + + *size = CM_TABLE + 1; + *array = MEM_callocN(sizeof(float) * (*size) * 4, "ColorBand"); + + for (a = 0; a < *size; a++) + BKE_colorband_evaluate(coba, (float)a / (float)CM_TABLE, &(*array)[a * 4]); +} + +static int vergcband(const void *a1, const void *a2) +{ + const CBData *x1 = a1, *x2 = a2; + + if (x1->pos > x2->pos) return 1; + else if (x1->pos < x2->pos) return -1; + return 0; +} + +void BKE_colorband_update_sort(ColorBand *coba) +{ + int a; + + if (coba->tot < 2) + return; + + for (a = 0; a < coba->tot; a++) + coba->data[a].cur = a; + + qsort(coba->data, coba->tot, sizeof(CBData), vergcband); + + for (a = 0; a < coba->tot; a++) { + if (coba->data[a].cur == coba->cur) { + coba->cur = a; + break; + } + } +} + +CBData *BKE_colorband_element_add(struct ColorBand *coba, float position) +{ + if (coba->tot == MAXCOLORBAND) { + return NULL; + } + else { + CBData *xnew; + + xnew = &coba->data[coba->tot]; + xnew->pos = position; + + if (coba->tot != 0) { + BKE_colorband_evaluate(coba, position, &xnew->r); + } + else { + zero_v4(&xnew->r); + } + } + + coba->tot++; + coba->cur = coba->tot - 1; + + BKE_colorband_update_sort(coba); + + return coba->data + coba->cur; +} + +int BKE_colorband_element_remove(struct ColorBand *coba, int index) +{ + int a; + + if (coba->tot < 2) + return 0; + + if (index < 0 || index >= coba->tot) + return 0; + + coba->tot--; + for (a = index; a < coba->tot; a++) { + coba->data[a] = coba->data[a + 1]; + } + if (coba->cur) coba->cur--; + return 1; +} diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c index 80a31697424..8d27fcd2835 100644 --- a/source/blender/blenkernel/intern/dynamicpaint.c +++ b/source/blender/blenkernel/intern/dynamicpaint.c @@ -55,6 +55,7 @@ #include "BKE_animsys.h" #include "BKE_armature.h" #include "BKE_bvhutils.h" /* bvh tree */ +#include "BKE_colorband.h" #include "BKE_cdderivedmesh.h" #include "BKE_constraint.h" #include "BKE_customdata.h" @@ -72,7 +73,6 @@ #include "BKE_particle.h" #include "BKE_pointcache.h" #include "BKE_scene.h" -#include "BKE_texture.h" #include "DEG_depsgraph.h" @@ -1085,7 +1085,7 @@ bool dynamicPaint_createType(struct DynamicPaintModifierData *pmd, int type, str { CBData *ramp; - brush->paint_ramp = add_colorband(false); + brush->paint_ramp = BKE_colorband_add(false); if (!brush->paint_ramp) return false; ramp = brush->paint_ramp->data; @@ -1101,7 +1101,7 @@ bool dynamicPaint_createType(struct DynamicPaintModifierData *pmd, int type, str { CBData *ramp; - brush->vel_ramp = add_colorband(false); + brush->vel_ramp = BKE_colorband_add(false); if (!brush->vel_ramp) return false; ramp = brush->vel_ramp->data; @@ -3459,7 +3459,7 @@ static void dynamicPaint_updatePointData( vel_factor /= brush->max_velocity; CLAMP(vel_factor, 0.0f, 1.0f); - if (do_colorband(brush->vel_ramp, vel_factor, coba_res)) { + if (BKE_colorband_evaluate(brush->vel_ramp, vel_factor, coba_res)) { if (brush->flags & MOD_DPAINT_VELOCITY_COLOR) { copy_v3_v3(paint, coba_res); } @@ -3906,7 +3906,7 @@ static void dynamic_paint_paint_mesh_cell_point_cb_ex( else if (hit_found == HIT_PROXIMITY) { /* apply falloff curve to the proximity_factor */ if (brush->proximity_falloff == MOD_DPAINT_PRFALL_RAMP && - do_colorband(brush->paint_ramp, (1.0f - proximity_factor), prox_colorband)) + BKE_colorband_evaluate(brush->paint_ramp, (1.0f - proximity_factor), prox_colorband)) { proximity_factor = prox_colorband[3]; } @@ -4470,7 +4470,7 @@ static void dynamic_paint_paint_single_point_cb_ex( /* color ramp */ if (brush->proximity_falloff == MOD_DPAINT_PRFALL_RAMP && - do_colorband(brush->paint_ramp, (1.0f - strength), colorband)) + BKE_colorband_evaluate(brush->paint_ramp, (1.0f - strength), colorband)) { strength = colorband[3]; } diff --git a/source/blender/blenkernel/intern/linestyle.c b/source/blender/blenkernel/intern/linestyle.c index 3a69eb2b86b..2fc4c81cb0b 100644 --- a/source/blender/blenkernel/intern/linestyle.c +++ b/source/blender/blenkernel/intern/linestyle.c @@ -44,13 +44,13 @@ #include "BLI_string_utils.h" #include "BLI_utildefines.h" +#include "BKE_colorband.h" #include "BKE_context.h" #include "BKE_freestyle.h" #include "BKE_global.h" #include "BKE_library.h" #include "BKE_linestyle.h" #include "BKE_node.h" -#include "BKE_texture.h" #include "BKE_colortools.h" #include "BKE_animsys.h" @@ -296,39 +296,39 @@ LineStyleModifier *BKE_linestyle_color_modifier_add(FreestyleLineStyle *linestyl switch (type) { case LS_MODIFIER_ALONG_STROKE: - ((LineStyleColorModifier_AlongStroke *)m)->color_ramp = add_colorband(1); + ((LineStyleColorModifier_AlongStroke *)m)->color_ramp = BKE_colorband_add(true); break; case LS_MODIFIER_DISTANCE_FROM_CAMERA: - ((LineStyleColorModifier_DistanceFromCamera *)m)->color_ramp = add_colorband(1); + ((LineStyleColorModifier_DistanceFromCamera *)m)->color_ramp = BKE_colorband_add(true); ((LineStyleColorModifier_DistanceFromCamera *)m)->range_min = 0.0f; ((LineStyleColorModifier_DistanceFromCamera *)m)->range_max = 10000.0f; break; case LS_MODIFIER_DISTANCE_FROM_OBJECT: ((LineStyleColorModifier_DistanceFromObject *)m)->target = NULL; - ((LineStyleColorModifier_DistanceFromObject *)m)->color_ramp = add_colorband(1); + ((LineStyleColorModifier_DistanceFromObject *)m)->color_ramp = BKE_colorband_add(true); ((LineStyleColorModifier_DistanceFromObject *)m)->range_min = 0.0f; ((LineStyleColorModifier_DistanceFromObject *)m)->range_max = 10000.0f; break; case LS_MODIFIER_MATERIAL: - ((LineStyleColorModifier_Material *)m)->color_ramp = add_colorband(1); + ((LineStyleColorModifier_Material *)m)->color_ramp = BKE_colorband_add(true); ((LineStyleColorModifier_Material *)m)->mat_attr = LS_MODIFIER_MATERIAL_LINE; break; case LS_MODIFIER_TANGENT: - ((LineStyleColorModifier_Tangent *)m)->color_ramp = add_colorband(1); + ((LineStyleColorModifier_Tangent *)m)->color_ramp = BKE_colorband_add(true); break; case LS_MODIFIER_NOISE: - ((LineStyleColorModifier_Noise *)m)->color_ramp = add_colorband(1); + ((LineStyleColorModifier_Noise *)m)->color_ramp = BKE_colorband_add(true); ((LineStyleColorModifier_Noise *)m)->amplitude = 10.0f; ((LineStyleColorModifier_Noise *)m)->period = 10.0f; ((LineStyleColorModifier_Noise *)m)->seed = 512; break; case LS_MODIFIER_CREASE_ANGLE: - ((LineStyleColorModifier_CreaseAngle *)m)->color_ramp = add_colorband(1); + ((LineStyleColorModifier_CreaseAngle *)m)->color_ramp = BKE_colorband_add(true); ((LineStyleColorModifier_CreaseAngle *)m)->min_angle = 0.0f; ((LineStyleColorModifier_CreaseAngle *)m)->max_angle = DEG2RADF(180.0f); break; case LS_MODIFIER_CURVATURE_3D: - ((LineStyleColorModifier_Curvature_3D *)m)->color_ramp = add_colorband(1); + ((LineStyleColorModifier_Curvature_3D *)m)->color_ramp = BKE_colorband_add(true); ((LineStyleColorModifier_Curvature_3D *)m)->min_curvature = 0.0f; ((LineStyleColorModifier_Curvature_3D *)m)->max_curvature = 0.5f; break; diff --git a/source/blender/blenkernel/intern/texture.c b/source/blender/blenkernel/intern/texture.c index 122b605f160..fcedd880615 100644 --- a/source/blender/blenkernel/intern/texture.c +++ b/source/blender/blenkernel/intern/texture.c @@ -58,6 +58,7 @@ #include "BKE_global.h" #include "BKE_main.h" +#include "BKE_colorband.h" #include "BKE_library.h" #include "BKE_library_query.h" #include "BKE_library_remap.h" @@ -185,7 +186,7 @@ void BKE_texture_colormapping_default(ColorMapping *colormap) { memset(colormap, 0, sizeof(ColorMapping)); - init_colorband(&colormap->coba, true); + BKE_colorband_init(&colormap->coba, true); colormap->bright = 1.0; colormap->contrast = 1.0; @@ -198,365 +199,6 @@ void BKE_texture_colormapping_default(ColorMapping *colormap) colormap->blend_factor = 0.0f; } -/* ****************** COLORBAND ******************* */ - -void init_colorband(ColorBand *coba, bool rangetype) -{ - int a; - - coba->data[0].pos = 0.0; - coba->data[1].pos = 1.0; - - if (rangetype == 0) { - coba->data[0].r = 0.0; - coba->data[0].g = 0.0; - coba->data[0].b = 0.0; - coba->data[0].a = 0.0; - - coba->data[1].r = 1.0; - coba->data[1].g = 1.0; - coba->data[1].b = 1.0; - coba->data[1].a = 1.0; - } - else { - coba->data[0].r = 0.0; - coba->data[0].g = 0.0; - coba->data[0].b = 0.0; - coba->data[0].a = 1.0; - - coba->data[1].r = 1.0; - coba->data[1].g = 1.0; - coba->data[1].b = 1.0; - coba->data[1].a = 1.0; - } - - for (a = 2; a < MAXCOLORBAND; a++) { - coba->data[a].r = 0.5; - coba->data[a].g = 0.5; - coba->data[a].b = 0.5; - coba->data[a].a = 1.0; - coba->data[a].pos = 0.5; - } - - coba->tot = 2; - coba->color_mode = COLBAND_BLEND_RGB; -} - -ColorBand *add_colorband(bool rangetype) -{ - ColorBand *coba; - - coba = MEM_callocN(sizeof(ColorBand), "colorband"); - init_colorband(coba, rangetype); - - return coba; -} - -/* ------------------------------------------------------------------------- */ - -static float colorband_hue_interp( - const int ipotype_hue, - const float mfac, const float fac, - float h1, float h2) -{ - float h_interp; - int mode = 0; - -#define HUE_INTERP(h_a, h_b) ((mfac * (h_a)) + (fac * (h_b))) -#define HUE_MOD(h) (((h) < 1.0f) ? (h) : (h) - 1.0f) - - h1 = HUE_MOD(h1); - h2 = HUE_MOD(h2); - - BLI_assert(h1 >= 0.0f && h1 < 1.0f); - BLI_assert(h2 >= 0.0f && h2 < 1.0f); - - switch (ipotype_hue) { - case COLBAND_HUE_NEAR: - { - if ((h1 < h2) && (h2 - h1) > +0.5f) mode = 1; - else if ((h1 > h2) && (h2 - h1) < -0.5f) mode = 2; - else mode = 0; - break; - } - case COLBAND_HUE_FAR: - { - if ((h1 < h2) && (h2 - h1) < +0.5f) mode = 1; - else if ((h1 > h2) && (h2 - h1) > -0.5f) mode = 2; - else mode = 0; - break; - } - case COLBAND_HUE_CCW: - { - if (h1 > h2) mode = 2; - else mode = 0; - break; - } - case COLBAND_HUE_CW: - { - if (h1 < h2) mode = 1; - else mode = 0; - break; - } - } - - switch (mode) { - case 0: - h_interp = HUE_INTERP(h1, h2); - break; - case 1: - h_interp = HUE_INTERP(h1 + 1.0f, h2); - h_interp = HUE_MOD(h_interp); - break; - case 2: - h_interp = HUE_INTERP(h1, h2 + 1.0f); - h_interp = HUE_MOD(h_interp); - break; - } - - BLI_assert(h_interp >= 0.0f && h_interp < 1.0f); - -#undef HUE_INTERP -#undef HUE_MOD - - return h_interp; -} - -bool do_colorband(const ColorBand *coba, float in, float out[4]) -{ - const CBData *cbd1, *cbd2, *cbd0, *cbd3; - float fac; - int ipotype; - int a; - - if (coba == NULL || coba->tot == 0) return false; - - cbd1 = coba->data; - - ipotype = (coba->color_mode == COLBAND_BLEND_RGB) ? coba->ipotype : COLBAND_INTERP_LINEAR; - - if (coba->tot == 1) { - out[0] = cbd1->r; - out[1] = cbd1->g; - out[2] = cbd1->b; - out[3] = cbd1->a; - } - else if ((in <= cbd1->pos) && ELEM(ipotype, COLBAND_INTERP_LINEAR, COLBAND_INTERP_EASE)) { - out[0] = cbd1->r; - out[1] = cbd1->g; - out[2] = cbd1->b; - out[3] = cbd1->a; - } - else { - CBData left, right; - - /* we're looking for first pos > in */ - for (a = 0; a < coba->tot; a++, cbd1++) { - if (cbd1->pos > in) { - break; - } - } - - if (a == coba->tot) { - cbd2 = cbd1 - 1; - right = *cbd2; - right.pos = 1.0f; - cbd1 = &right; - } - else if (a == 0) { - left = *cbd1; - left.pos = 0.0f; - cbd2 = &left; - } - else { - cbd2 = cbd1 - 1; - } - - if ((in >= cbd1->pos) && ELEM(ipotype, COLBAND_INTERP_LINEAR, COLBAND_INTERP_EASE)) { - out[0] = cbd1->r; - out[1] = cbd1->g; - out[2] = cbd1->b; - out[3] = cbd1->a; - } - else { - - if (cbd2->pos != cbd1->pos) { - fac = (in - cbd1->pos) / (cbd2->pos - cbd1->pos); - } - else { - /* was setting to 0.0 in 2.56 & previous, but this - * is incorrect for the last element, see [#26732] */ - fac = (a != coba->tot) ? 0.0f : 1.0f; - } - - if (ipotype == COLBAND_INTERP_CONSTANT) { - /* constant */ - out[0] = cbd2->r; - out[1] = cbd2->g; - out[2] = cbd2->b; - out[3] = cbd2->a; - } - else if (ipotype >= COLBAND_INTERP_B_SPLINE) { - /* ipo from right to left: 3 2 1 0 */ - float t[4]; - - if (a >= coba->tot - 1) cbd0 = cbd1; - else cbd0 = cbd1 + 1; - if (a < 2) cbd3 = cbd2; - else cbd3 = cbd2 - 1; - - CLAMP(fac, 0.0f, 1.0f); - - if (ipotype == COLBAND_INTERP_CARDINAL) { - key_curve_position_weights(fac, t, KEY_CARDINAL); - } - else { - key_curve_position_weights(fac, t, KEY_BSPLINE); - } - - out[0] = t[3] * cbd3->r + t[2] * cbd2->r + t[1] * cbd1->r + t[0] * cbd0->r; - out[1] = t[3] * cbd3->g + t[2] * cbd2->g + t[1] * cbd1->g + t[0] * cbd0->g; - out[2] = t[3] * cbd3->b + t[2] * cbd2->b + t[1] * cbd1->b + t[0] * cbd0->b; - out[3] = t[3] * cbd3->a + t[2] * cbd2->a + t[1] * cbd1->a + t[0] * cbd0->a; - CLAMP(out[0], 0.0f, 1.0f); - CLAMP(out[1], 0.0f, 1.0f); - CLAMP(out[2], 0.0f, 1.0f); - CLAMP(out[3], 0.0f, 1.0f); - } - else { - float mfac; - - if (ipotype == COLBAND_INTERP_EASE) { - mfac = fac * fac; - fac = 3.0f * mfac - 2.0f * mfac * fac; - } - - mfac = 1.0f - fac; - - if (UNLIKELY(coba->color_mode == COLBAND_BLEND_HSV)) { - float col1[3], col2[3]; - - rgb_to_hsv_v(&cbd1->r, col1); - rgb_to_hsv_v(&cbd2->r, col2); - - out[0] = colorband_hue_interp(coba->ipotype_hue, mfac, fac, col1[0], col2[0]); - out[1] = mfac * col1[1] + fac * col2[1]; - out[2] = mfac * col1[2] + fac * col2[2]; - out[3] = mfac * cbd1->a + fac * cbd2->a; - - hsv_to_rgb_v(out, out); - } - else if (UNLIKELY(coba->color_mode == COLBAND_BLEND_HSL)) { - float col1[3], col2[3]; - - rgb_to_hsl_v(&cbd1->r, col1); - rgb_to_hsl_v(&cbd2->r, col2); - - out[0] = colorband_hue_interp(coba->ipotype_hue, mfac, fac, col1[0], col2[0]); - out[1] = mfac * col1[1] + fac * col2[1]; - out[2] = mfac * col1[2] + fac * col2[2]; - out[3] = mfac * cbd1->a + fac * cbd2->a; - - hsl_to_rgb_v(out, out); - } - else { - /* COLBAND_BLEND_RGB */ - out[0] = mfac * cbd1->r + fac * cbd2->r; - out[1] = mfac * cbd1->g + fac * cbd2->g; - out[2] = mfac * cbd1->b + fac * cbd2->b; - out[3] = mfac * cbd1->a + fac * cbd2->a; - } - } - } - } - return true; /* OK */ -} - -void colorband_table_RGBA(ColorBand *coba, float **array, int *size) -{ - int a; - - *size = CM_TABLE + 1; - *array = MEM_callocN(sizeof(float) * (*size) * 4, "ColorBand"); - - for (a = 0; a < *size; a++) - do_colorband(coba, (float)a / (float)CM_TABLE, &(*array)[a * 4]); -} - -static int vergcband(const void *a1, const void *a2) -{ - const CBData *x1 = a1, *x2 = a2; - - if (x1->pos > x2->pos) return 1; - else if (x1->pos < x2->pos) return -1; - return 0; -} - -void colorband_update_sort(ColorBand *coba) -{ - int a; - - if (coba->tot < 2) - return; - - for (a = 0; a < coba->tot; a++) - coba->data[a].cur = a; - - qsort(coba->data, coba->tot, sizeof(CBData), vergcband); - - for (a = 0; a < coba->tot; a++) { - if (coba->data[a].cur == coba->cur) { - coba->cur = a; - break; - } - } -} - -CBData *colorband_element_add(struct ColorBand *coba, float position) -{ - if (coba->tot == MAXCOLORBAND) { - return NULL; - } - else { - CBData *xnew; - - xnew = &coba->data[coba->tot]; - xnew->pos = position; - - if (coba->tot != 0) { - do_colorband(coba, position, &xnew->r); - } - else { - zero_v4(&xnew->r); - } - } - - coba->tot++; - coba->cur = coba->tot - 1; - - colorband_update_sort(coba); - - return coba->data + coba->cur; -} - -int colorband_element_remove(struct ColorBand *coba, int index) -{ - int a; - - if (coba->tot < 2) - return 0; - - if (index < 0 || index >= coba->tot) - return 0; - - coba->tot--; - for (a = index; a < coba->tot; a++) { - coba->data[a] = coba->data[a + 1]; - } - if (coba->cur) coba->cur--; - return 1; -} - /* ******************* TEX ************************ */ /** Free (or release) any data used by this texture (does not free the texure itself). */ @@ -1357,7 +999,7 @@ void BKE_texture_pointdensity_init_data(PointDensity *pd) pd->noise_depth = 1; pd->noise_fac = 1.0f; pd->noise_influence = TEX_PD_NOISE_STATIC; - pd->coba = add_colorband(true); + pd->coba = BKE_colorband_add(true); pd->speed_scale = 1.0f; pd->totpoints = 0; pd->object = NULL; diff --git a/source/blender/collada/DocumentImporter.cpp b/source/blender/collada/DocumentImporter.cpp index d3e23f740c8..ec9a4169b26 100644 --- a/source/blender/collada/DocumentImporter.cpp +++ b/source/blender/collada/DocumentImporter.cpp @@ -62,7 +62,6 @@ extern "C" { #include "BKE_layer.h" #include "BKE_lamp.h" #include "BKE_library.h" -#include "BKE_texture.h" #include "BKE_fcurve.h" #include "BKE_scene.h" #include "BKE_global.h" diff --git a/source/blender/compositor/operations/COM_ColorRampOperation.cpp b/source/blender/compositor/operations/COM_ColorRampOperation.cpp index 84d36034ec6..c67f906b374 100644 --- a/source/blender/compositor/operations/COM_ColorRampOperation.cpp +++ b/source/blender/compositor/operations/COM_ColorRampOperation.cpp @@ -25,7 +25,7 @@ #ifdef __cplusplus extern "C" { #endif -# include "BKE_texture.h" +# include "BKE_colorband.h" #ifdef __cplusplus } #endif @@ -48,7 +48,7 @@ void ColorRampOperation::executePixelSampled(float output[4], float x, float y, float values[4]; this->m_inputProgram->readSampled(values, x, y, sampler); - do_colorband(this->m_colorBand, values[0], output); + BKE_colorband_evaluate(this->m_colorBand, values[0], output); } void ColorRampOperation::deinitExecution() diff --git a/source/blender/compositor/operations/COM_MovieClipAttributeOperation.cpp b/source/blender/compositor/operations/COM_MovieClipAttributeOperation.cpp index 0c2da8415f8..5d682352d46 100644 --- a/source/blender/compositor/operations/COM_MovieClipAttributeOperation.cpp +++ b/source/blender/compositor/operations/COM_MovieClipAttributeOperation.cpp @@ -35,6 +35,9 @@ MovieClipAttributeOperation::MovieClipAttributeOperation() : NodeOperation() void MovieClipAttributeOperation::initExecution() { + if (this->m_clip == NULL) { + return; + } float loc[2], scale, angle; loc[0] = 0.0f; loc[1] = 0.0f; diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc index 8fbd1e7a46d..342ce8e862b 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc @@ -92,7 +92,6 @@ extern "C" { #include "BKE_particle.h" #include "BKE_rigidbody.h" #include "BKE_sound.h" -#include "BKE_texture.h" #include "BKE_tracking.h" #include "BKE_world.h" diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc index 14dedef2601..890e6c050d0 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc @@ -89,7 +89,6 @@ extern "C" { #include "BKE_particle.h" #include "BKE_rigidbody.h" #include "BKE_sound.h" -#include "BKE_texture.h" #include "BKE_tracking.h" #include "BKE_world.h" diff --git a/source/blender/draw/intern/draw_cache_impl_lattice.c b/source/blender/draw/intern/draw_cache_impl_lattice.c index 20698fe6592..eed408de3cd 100644 --- a/source/blender/draw/intern/draw_cache_impl_lattice.c +++ b/source/blender/draw/intern/draw_cache_impl_lattice.c @@ -41,7 +41,7 @@ #include "BKE_lattice.h" #include "BKE_deform.h" -#include "BKE_texture.h" +#include "BKE_colorband.h" #include "GPU_batch.h" @@ -260,7 +260,7 @@ static void lattice_render_data_weight_col_get(const LatticeRenderData *rdata, c float weight = defvert_find_weight(rdata->dvert + vert_idx, actdef); if (U.flag & USER_CUSTOM_RANGE) { - do_colorband(&U.coba_weight, weight, r_col); + BKE_colorband_evaluate(&U.coba_weight, weight, r_col); } else { rgb_from_weight(r_col, weight); diff --git a/source/blender/draw/intern/draw_cache_impl_mesh.c b/source/blender/draw/intern/draw_cache_impl_mesh.c index 8cd0c13faec..54021e398c9 100644 --- a/source/blender/draw/intern/draw_cache_impl_mesh.c +++ b/source/blender/draw/intern/draw_cache_impl_mesh.c @@ -48,7 +48,7 @@ #include "BKE_editmesh_tangent.h" #include "BKE_mesh.h" #include "BKE_mesh_tangent.h" -#include "BKE_texture.h" +#include "BKE_colorband.h" #include "bmesh.h" @@ -1097,7 +1097,7 @@ static void mesh_render_data_ensure_vert_weight_color(MeshRenderData *rdata, con const MDeformVert *dvert = BM_ELEM_CD_GET_VOID_P(eve, cd_dvert_offset); float weight = defvert_find_weight(dvert, defgroup); if (U.flag & USER_CUSTOM_RANGE) { - do_colorband(&U.coba_weight, weight, vweight[i]); + BKE_colorband_evaluate(&U.coba_weight, weight, vweight[i]); } else { rgb_from_weight(vweight[i], weight); @@ -1113,7 +1113,7 @@ static void mesh_render_data_ensure_vert_weight_color(MeshRenderData *rdata, con for (int i = 0; i < rdata->vert_len; i++) { float weight = defvert_find_weight(&rdata->dvert[i], defgroup); if (U.flag & USER_CUSTOM_RANGE) { - do_colorband(&U.coba_weight, weight, vweight[i]); + BKE_colorband_evaluate(&U.coba_weight, weight, vweight[i]); } else { rgb_from_weight(vweight[i], weight); diff --git a/source/blender/draw/intern/draw_common.c b/source/blender/draw/intern/draw_common.c index b52c8e280b3..f24d7d13771 100644 --- a/source/blender/draw/intern/draw_common.c +++ b/source/blender/draw/intern/draw_common.c @@ -31,7 +31,7 @@ #include "UI_resources.h" #include "BKE_global.h" -#include "BKE_texture.h" +#include "BKE_colorband.h" #include "draw_common.h" @@ -130,7 +130,7 @@ void DRW_globals_update(void) ramp.data[2].r = 1.0f; ramp.data[2].pos = 1.0f; - colorband_table_RGBA(&ramp, &colors, &col_size); + BKE_colorband_evaluate_table_rgba(&ramp, &colors, &col_size); if (globals_ramp) { GPU_texture_free(globals_ramp); diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index e46c6a0e267..3ecb72353bc 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -40,9 +40,9 @@ #include "BLI_string.h" #include "BLI_utildefines.h" +#include "BKE_colorband.h" #include "BKE_colortools.h" #include "BKE_node.h" -#include "BKE_texture.h" #include "BKE_tracking.h" @@ -1335,7 +1335,7 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), const rcti immBegin(GWN_PRIM_TRI_STRIP, (sizex + 1) * 2); for (int a = 0; a <= sizex; a++) { float pos = ((float)a) / sizex; - do_colorband(coba, pos, colf); + BKE_colorband_evaluate(coba, pos, colf); if (display) IMB_colormanagement_scene_linear_to_display_v3(colf, display); @@ -1354,7 +1354,7 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), const rcti immBegin(GWN_PRIM_TRI_STRIP, (sizex + 1) * 2); for (int a = 0; a <= sizex; a++) { float pos = ((float)a) / sizex; - do_colorband(coba, pos, colf); + BKE_colorband_evaluate(coba, pos, colf); if (display) IMB_colormanagement_scene_linear_to_display_v3(colf, display); diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index a4ce0e2f4a8..f28a398a46a 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -61,6 +61,7 @@ #include "PIL_time.h" +#include "BKE_colorband.h" #include "BKE_blender_undo.h" #include "BKE_brush.h" #include "BKE_colortools.h" @@ -68,7 +69,6 @@ #include "BKE_idprop.h" #include "BKE_report.h" #include "BKE_screen.h" -#include "BKE_texture.h" #include "BKE_tracking.h" #include "BKE_unit.h" #include "BKE_paint.h" @@ -5930,7 +5930,7 @@ static bool ui_numedit_but_COLORBAND(uiBut *but, uiHandleButtonData *data, int m data->dragcbd->pos += dx; CLAMP(data->dragcbd->pos, 0.0f, 1.0f); - colorband_update_sort(data->coba); + BKE_colorband_update_sort(data->coba); data->dragcbd = data->coba->data + data->coba->cur; /* because qsort */ data->draglastx = mx; @@ -5960,7 +5960,7 @@ static int ui_do_but_COLORBAND( if (event->ctrl) { /* insert new key on mouse location */ float pos = ((float)(mx - but->rect.xmin)) / BLI_rctf_size_x(&but->rect); - colorband_element_add(coba, pos); + BKE_colorband_element_add(coba, pos); button_activate_state(C, but, BUTTON_STATE_EXIT); } else { diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 2546527d43b..7c58ac88a23 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -53,6 +53,7 @@ #include "BLF_api.h" #include "BLT_translation.h" +#include "BKE_colorband.h" #include "BKE_colortools.h" #include "BKE_context.h" #include "BKE_global.h" @@ -70,7 +71,6 @@ #include "BKE_report.h" #include "BKE_sca.h" #include "BKE_screen.h" -#include "BKE_texture.h" #include "DEG_depsgraph.h" #include "DEG_depsgraph_build.h" @@ -1714,7 +1714,7 @@ static void colorband_add_cb(bContext *C, void *cb_v, void *coba_v) else pos = (coba->data[coba->cur + 1].pos + coba->data[coba->cur].pos) * 0.5f; } - if (colorband_element_add(coba, pos)) { + if (BKE_colorband_element_add(coba, pos)) { rna_update_cb(C, cb_v, NULL); ED_undo_push(C, "Add colorband"); } @@ -1724,7 +1724,7 @@ static void colorband_del_cb(bContext *C, void *cb_v, void *coba_v) { ColorBand *coba = coba_v; - if (colorband_element_remove(coba, coba->cur)) { + if (BKE_colorband_element_remove(coba, coba->cur)) { ED_undo_push(C, "Delete colorband"); rna_update_cb(C, cb_v, NULL); } @@ -1760,7 +1760,7 @@ static void colorband_update_cb(bContext *UNUSED(C), void *bt_v, void *coba_v) /* sneaky update here, we need to sort the colorband points to be in order, * however the RNA pointer then is wrong, so we update it */ - colorband_update_sort(coba); + BKE_colorband_update_sort(coba); bt->rnapoin.data = coba->data + coba->cur; } diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index bf42316289f..2eae452debb 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -46,10 +46,10 @@ #include "BLI_math.h" #include "BKE_appdir.h" +#include "BKE_colorband.h" #include "BKE_DerivedMesh.h" #include "BKE_global.h" #include "BKE_main.h" -#include "BKE_texture.h" #include "BIF_gl.h" @@ -2000,7 +2000,7 @@ void init_userdef_do_versions(void) rgba_char_args_set(btheme->tv3d.editmesh_active, 255, 255, 255, 128); } if (U.coba_weight.tot == 0) - init_colorband(&U.coba_weight, true); + BKE_colorband_init(&U.coba_weight, true); } if (!USER_VERSION_ATLEAST(245, 3)) { bTheme *btheme; diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index e8807432328..98ee42f127b 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -92,7 +92,6 @@ #include "BKE_scene.h" #include "BKE_screen.h" #include "BKE_speaker.h" -#include "BKE_texture.h" #include "DEG_depsgraph.h" #include "DEG_depsgraph_build.h" diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index 2d1f0cb3b0d..aebd0c10e9c 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -50,6 +50,7 @@ #include "DNA_node_types.h" #include "DNA_object_types.h" +#include "BKE_colorband.h" #include "BKE_context.h" #include "BKE_DerivedMesh.h" #include "BKE_brush.h" @@ -58,7 +59,6 @@ #include "BKE_material.h" #include "BKE_node.h" #include "BKE_paint.h" -#include "BKE_texture.h" #include "DEG_depsgraph.h" @@ -666,17 +666,17 @@ void paint_brush_color_get(struct Scene *scene, struct Brush *br, bool color_cor float color_gr[4]; switch (br->gradient_stroke_mode) { case BRUSH_GRADIENT_PRESSURE: - do_colorband(br->gradient, pressure, color_gr); + BKE_colorband_evaluate(br->gradient, pressure, color_gr); break; case BRUSH_GRADIENT_SPACING_REPEAT: { float coord = fmod(distance / br->gradient_spacing, 1.0); - do_colorband(br->gradient, coord, color_gr); + BKE_colorband_evaluate(br->gradient, coord, color_gr); break; } case BRUSH_GRADIENT_SPACING_CLAMP: { - do_colorband(br->gradient, distance / br->gradient_spacing, color_gr); + BKE_colorband_evaluate(br->gradient, distance / br->gradient_spacing, color_gr); break; } } diff --git a/source/blender/editors/sculpt_paint/paint_image_2d.c b/source/blender/editors/sculpt_paint/paint_image_2d.c index 30830e4e7bc..603b8f9a185 100644 --- a/source/blender/editors/sculpt_paint/paint_image_2d.c +++ b/source/blender/editors/sculpt_paint/paint_image_2d.c @@ -44,12 +44,12 @@ #include "BLI_bitmap.h" #include "BLI_task.h" +#include "BKE_colorband.h" #include "BKE_context.h" #include "BKE_brush.h" #include "BKE_image.h" #include "BKE_paint.h" #include "BKE_report.h" -#include "BKE_texture.h" #include "DEG_depsgraph.h" @@ -1667,7 +1667,7 @@ void paint_2d_gradient_fill( break; } } - do_colorband(br->gradient, f, color_f); + BKE_colorband_evaluate(br->gradient, f, color_f); /* convert to premultiplied */ mul_v3_fl(color_f, color_f[3]); color_f[3] *= br->alpha; @@ -1697,7 +1697,7 @@ void paint_2d_gradient_fill( } } - do_colorband(br->gradient, f, color_f); + BKE_colorband_evaluate(br->gradient, f, color_f); linearrgb_to_srgb_v3_v3(color_f, color_f); rgba_float_to_uchar((unsigned char *)&color_b, color_f); ((unsigned char *)&color_b)[3] *= br->alpha; diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c index 900ca844dbf..7148469a9d8 100644 --- a/source/blender/editors/sculpt_paint/paint_image_proj.c +++ b/source/blender/editors/sculpt_paint/paint_image_proj.c @@ -62,6 +62,7 @@ #include "DNA_object_types.h" #include "BKE_camera.h" +#include "BKE_colorband.h" #include "BKE_context.h" #include "BKE_colortools.h" #include "BKE_DerivedMesh.h" @@ -4582,7 +4583,7 @@ static void *do_projectpaint_thread(void *ph_v) break; } } - do_colorband(brush->gradient, f, color_f); + BKE_colorband_evaluate(brush->gradient, f, color_f); color_f[3] *= ((float)projPixel->mask) * (1.0f / 65535.0f) * brush->alpha; if (is_floatbuf) { diff --git a/source/blender/editors/space_view3d/drawvolume.c b/source/blender/editors/space_view3d/drawvolume.c index 3a80624acd9..d39f3937a9d 100644 --- a/source/blender/editors/space_view3d/drawvolume.c +++ b/source/blender/editors/space_view3d/drawvolume.c @@ -41,7 +41,7 @@ #include "BLI_math.h" #include "BKE_DerivedMesh.h" -#include "BKE_texture.h" +#include "BKE_colorband.h" #include "BKE_particle.h" #include "smoke_API.h" @@ -111,7 +111,7 @@ static void create_flame_spectrum_texture(float *data) static void create_color_ramp(const ColorBand *coba, float *data) { for (int i = 0; i < TFUNC_WIDTH; i++) { - do_colorband(coba, (float)i / TFUNC_WIDTH, &data[i * 4]); + BKE_colorband_evaluate(coba, (float)i / TFUNC_WIDTH, &data[i * 4]); } } diff --git a/source/blender/freestyle/intern/python/BPy_Freestyle.cpp b/source/blender/freestyle/intern/python/BPy_Freestyle.cpp index f8aef2a08ae..0b09a3c2442 100644 --- a/source/blender/freestyle/intern/python/BPy_Freestyle.cpp +++ b/source/blender/freestyle/intern/python/BPy_Freestyle.cpp @@ -157,7 +157,7 @@ static PyObject *Freestyle_blendRamp(PyObject * /*self*/, PyObject *args) return Vector_CreatePyObject(a, 3, NULL); } -#include "BKE_texture.h" /* do_colorband() */ +#include "BKE_colorband.h" /* BKE_colorband_evaluate() */ static char Freestyle_evaluateColorRamp___doc__[] = ".. function:: evaluateColorRamp(ramp, in)\n" @@ -184,7 +184,7 @@ static PyObject *Freestyle_evaluateColorRamp(PyObject * /*self*/, PyObject *args return NULL; } coba = (ColorBand *)py_srna->ptr.data; - if (!do_colorband(coba, in, out)) { + if (!BKE_colorband_evaluate(coba, in, out)) { PyErr_SetString(PyExc_ValueError, "failed to evaluate the color ramp"); return NULL; } diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c index e2883b53047..2e6c1cbf9df 100644 --- a/source/blender/gpu/intern/gpu_material.c +++ b/source/blender/gpu/intern/gpu_material.c @@ -48,6 +48,7 @@ #include "BLI_rand.h" #include "BKE_anim.h" +#include "BKE_colorband.h" #include "BKE_colortools.h" #include "BKE_global.h" #include "BKE_image.h" @@ -55,7 +56,6 @@ #include "BKE_main.h" #include "BKE_node.h" #include "BKE_scene.h" -#include "BKE_texture.h" #include "BKE_group.h" #include "IMB_imbuf_types.h" @@ -994,7 +994,7 @@ static void ramp_blend( GPU_link(mat, names[type], fac, col1, col2, r_col); } -static void do_colorband_blend( +static void BKE_colorband_eval_blend( GPUMaterial *mat, ColorBand *coba, GPUNodeLink *fac, float rampfac, int type, GPUNodeLink *incol, GPUNodeLink **r_col) { @@ -1003,7 +1003,7 @@ static void do_colorband_blend( int size; /* do colorband */ - colorband_table_RGBA(coba, &array, &size); + BKE_colorband_evaluate_table_rgba(coba, &array, &size); GPU_link(mat, "valtorgb", fac, GPU_texture(size, array), &col, &tmp); /* use alpha in fac */ @@ -1026,7 +1026,7 @@ static void ramp_diffuse_result(GPUShadeInput *shi, GPUNodeLink **diff) GPU_link(mat, "ramp_rgbtobw", *diff, &fac); /* colorband + blend */ - do_colorband_blend(mat, ma->ramp_col, fac, ma->rampfac_col, ma->rampblend_col, *diff, diff); + BKE_colorband_eval_blend(mat, ma->ramp_col, fac, ma->rampfac_col, ma->rampblend_col, *diff, diff); } } } @@ -1063,7 +1063,7 @@ static void add_to_diffuse( } /* colorband + blend */ - do_colorband_blend(mat, ma->ramp_col, fac, ma->rampfac_col, ma->rampblend_col, shi->rgb, &addcol); + BKE_colorband_eval_blend(mat, ma->ramp_col, fac, ma->rampfac_col, ma->rampblend_col, shi->rgb, &addcol); } } else @@ -1085,7 +1085,7 @@ static void ramp_spec_result(GPUShadeInput *shi, GPUNodeLink **spec) GPU_link(mat, "ramp_rgbtobw", *spec, &fac); /* colorband + blend */ - do_colorband_blend(mat, ma->ramp_spec, fac, ma->rampfac_spec, ma->rampblend_spec, *spec, spec); + BKE_colorband_eval_blend(mat, ma->ramp_spec, fac, ma->rampfac_spec, ma->rampblend_spec, *spec, spec); } } @@ -1117,7 +1117,7 @@ static void do_specular_ramp(GPUShadeInput *shi, GPUNodeLink *is, GPUNodeLink *t } /* colorband + blend */ - do_colorband_blend(mat, ma->ramp_spec, fac, ma->rampfac_spec, ma->rampblend_spec, *spec, spec); + BKE_colorband_eval_blend(mat, ma->ramp_spec, fac, ma->rampfac_spec, ma->rampblend_spec, *spec, spec); } } diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h index 59d30d175a5..5dbfbaadf75 100644 --- a/source/blender/makesdna/DNA_modifier_types.h +++ b/source/blender/makesdna/DNA_modifier_types.h @@ -249,6 +249,7 @@ typedef struct ArrayModifierData { int flags; /* the number of duplicates to generate for MOD_ARR_FIXEDCOUNT */ int count; + float uv_offset[2]; } ArrayModifierData; /* ArrayModifierData->fit_type */ diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c index 3861f4d19b9..5336a63fb76 100644 --- a/source/blender/makesrna/intern/rna_brush.c +++ b/source/blender/makesrna/intern/rna_brush.c @@ -128,7 +128,7 @@ const EnumPropertyItem rna_enum_brush_image_tool_items[] = { #include "RNA_access.h" -#include "BKE_texture.h" +#include "BKE_colorband.h" #include "BKE_brush.h" #include "BKE_icons.h" #include "BKE_paint.h" @@ -474,7 +474,7 @@ static void rna_Brush_use_gradient_set(PointerRNA *ptr, int value) else br->flag &= ~BRUSH_USE_GRADIENT; if ((br->flag & BRUSH_USE_GRADIENT) && br->gradient == NULL) - br->gradient = add_colorband(true); + br->gradient = BKE_colorband_add(true); } static void rna_Brush_set_unprojected_radius(PointerRNA *ptr, float value) diff --git a/source/blender/makesrna/intern/rna_color.c b/source/blender/makesrna/intern/rna_color.c index ad2586635c9..d9b7a58de04 100644 --- a/source/blender/makesrna/intern/rna_color.c +++ b/source/blender/makesrna/intern/rna_color.c @@ -52,12 +52,12 @@ #include "MEM_guardedalloc.h" +#include "BKE_colorband.h" #include "BKE_colortools.h" #include "BKE_image.h" #include "BKE_movieclip.h" #include "BKE_node.h" #include "BKE_sequencer.h" -#include "BKE_texture.h" #include "BKE_linestyle.h" #include "DEG_depsgraph.h" @@ -362,12 +362,12 @@ static void rna_ColorRamp_update(Main *bmain, Scene *UNUSED(scene), PointerRNA * static void rna_ColorRamp_eval(struct ColorBand *coba, float position, float color[4]) { - do_colorband(coba, position, color); + BKE_colorband_evaluate(coba, position, color); } static CBData *rna_ColorRampElement_new(struct ColorBand *coba, ReportList *reports, float position) { - CBData *element = colorband_element_add(coba, position); + CBData *element = BKE_colorband_element_add(coba, position); if (element == NULL) BKE_reportf(reports, RPT_ERROR, "Unable to add element to colorband (limit %d)", MAXCOLORBAND); @@ -379,7 +379,7 @@ static void rna_ColorRampElement_remove(struct ColorBand *coba, ReportList *repo { CBData *element = element_ptr->data; int index = (int)(element - coba->data); - if (colorband_element_remove(coba, index) == false) { + if (BKE_colorband_element_remove(coba, index) == false) { BKE_report(reports, RPT_ERROR, "Element not found in element collection or last element"); return; } diff --git a/source/blender/makesrna/intern/rna_material.c b/source/blender/makesrna/intern/rna_material.c index a2845b3a2f8..440af0d0e8e 100644 --- a/source/blender/makesrna/intern/rna_material.c +++ b/source/blender/makesrna/intern/rna_material.c @@ -85,6 +85,7 @@ const EnumPropertyItem rna_enum_ramp_blend_items[] = { #include "DNA_screen_types.h" #include "DNA_space_types.h" +#include "BKE_colorband.h" #include "BKE_context.h" #include "BKE_main.h" #include "BKE_material.h" @@ -323,7 +324,7 @@ static void rna_Material_use_diffuse_ramp_set(PointerRNA *ptr, int value) else ma->mode &= ~MA_RAMP_COL; if ((ma->mode & MA_RAMP_COL) && ma->ramp_col == NULL) - ma->ramp_col = add_colorband(false); + ma->ramp_col = BKE_colorband_add(false); } static void rna_Material_use_specular_ramp_set(PointerRNA *ptr, int value) @@ -334,7 +335,7 @@ static void rna_Material_use_specular_ramp_set(PointerRNA *ptr, int value) else ma->mode &= ~MA_RAMP_SPEC; if ((ma->mode & MA_RAMP_SPEC) && ma->ramp_spec == NULL) - ma->ramp_spec = add_colorband(false); + ma->ramp_spec = BKE_colorband_add(false); } static void rna_Material_use_nodes_update(bContext *C, PointerRNA *ptr) diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index c443b68b209..1858b6db997 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -2124,6 +2124,20 @@ static void rna_def_modifier_array(BlenderRNA *brna) RNA_def_property_pointer_funcs(prop, NULL, "rna_ArrayModifier_end_cap_set", NULL, "rna_Mesh_object_poll"); RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK); RNA_def_property_update(prop, 0, "rna_Modifier_dependency_update"); + + prop = RNA_def_property(srna, "offset_u", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_sdna(prop, NULL, "uv_offset[0]"); + RNA_def_property_range(prop, -1, 1); + RNA_def_property_ui_range(prop, -1, 1, 2, 4); + RNA_def_property_ui_text(prop, "U Offset", "Amount to offset array UVs on the U axis"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + + prop = RNA_def_property(srna, "offset_v", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_sdna(prop, NULL, "uv_offset[1]"); + RNA_def_property_range(prop, -1, 1); + RNA_def_property_ui_range(prop, -1, 1, 2, 4); + RNA_def_property_ui_text(prop, "V Offset", "Amount to offset array UVs on the V axis"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); } static void rna_def_modifier_edgesplit(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_smoke.c b/source/blender/makesrna/intern/rna_smoke.c index 8c2a09f1186..ac13f9d8294 100644 --- a/source/blender/makesrna/intern/rna_smoke.c +++ b/source/blender/makesrna/intern/rna_smoke.c @@ -52,9 +52,9 @@ #ifdef RNA_RUNTIME +#include "BKE_colorband.h" #include "BKE_context.h" #include "BKE_particle.h" -#include "BKE_texture.h" #include "DEG_depsgraph.h" #include "DEG_depsgraph_build.h" @@ -395,7 +395,7 @@ static void rna_Smoke_use_color_ramp_set(PointerRNA *ptr, int value) sds->use_coba = value; if (value && sds->coba == NULL) { - sds->coba = add_colorband(false); + sds->coba = BKE_colorband_add(false); } } diff --git a/source/blender/makesrna/intern/rna_texture.c b/source/blender/makesrna/intern/rna_texture.c index 43fe7bd3f76..42e3e2c83fb 100644 --- a/source/blender/makesrna/intern/rna_texture.c +++ b/source/blender/makesrna/intern/rna_texture.c @@ -112,6 +112,7 @@ static const EnumPropertyItem blend_type_items[] = { #include "RNA_access.h" +#include "BKE_colorband.h" #include "BKE_context.h" #include "BKE_image.h" #include "BKE_texture.h" @@ -407,7 +408,7 @@ static void rna_Texture_use_color_ramp_set(PointerRNA *ptr, int value) else tex->flag &= ~TEX_COLORBAND; if ((tex->flag & TEX_COLORBAND) && tex->coba == NULL) - tex->coba = add_colorband(false); + tex->coba = BKE_colorband_add(false); } static void rna_Texture_use_nodes_update(bContext *C, PointerRNA *ptr) diff --git a/source/blender/modifiers/intern/MOD_array.c b/source/blender/modifiers/intern/MOD_array.c index 81ace75f2b1..cd19020d375 100644 --- a/source/blender/modifiers/intern/MOD_array.c +++ b/source/blender/modifiers/intern/MOD_array.c @@ -608,6 +608,26 @@ static DerivedMesh *arrayModifier_doArray( } } + /* handle UVs */ + if (chunk_nloops > 0 && is_zero_v2(amd->uv_offset) == false) { + const int totuv = CustomData_number_of_layers(&result->loopData, CD_MLOOPUV); + for (i = 0; i < totuv; i++) { + MLoopUV *dmloopuv = CustomData_get_layer_n(&result->loopData, CD_MLOOPUV, i); + dmloopuv += chunk_nloops; + for (c = 1; c < count; c++) { + const float uv_offset[2] = { + amd->uv_offset[0] * (float)c, + amd->uv_offset[1] * (float)c, + }; + int l_index = chunk_nloops; + for (; l_index-- != 0; dmloopuv++) { + dmloopuv->uv[0] += uv_offset[0]; + dmloopuv->uv[1] += uv_offset[1]; + } + } + } + } + last_chunk_start = (count - 1) * chunk_nverts; last_chunk_nverts = chunk_nverts; diff --git a/source/blender/nodes/composite/node_composite_util.h b/source/blender/nodes/composite/node_composite_util.h index 2dac0cc639a..22c5e6f9507 100644 --- a/source/blender/nodes/composite/node_composite_util.h +++ b/source/blender/nodes/composite/node_composite_util.h @@ -42,6 +42,7 @@ #include "BLT_translation.h" +#include "BKE_colorband.h" #include "BKE_colortools.h" #include "BKE_image.h" #include "BKE_texture.h" diff --git a/source/blender/nodes/composite/nodes/node_composite_valToRgb.c b/source/blender/nodes/composite/nodes/node_composite_valToRgb.c index 32d68550cd4..707f1d22efd 100644 --- a/source/blender/nodes/composite/nodes/node_composite_valToRgb.c +++ b/source/blender/nodes/composite/nodes/node_composite_valToRgb.c @@ -46,7 +46,7 @@ static bNodeSocketTemplate cmp_node_valtorgb_out[] = { static void node_composit_init_valtorgb(bNodeTree *UNUSED(ntree), bNode *node) { - node->storage = add_colorband(true); + node->storage = BKE_colorband_add(true); } void register_node_type_cmp_valtorgb(void) diff --git a/source/blender/nodes/shader/node_shader_util.h b/source/blender/nodes/shader/node_shader_util.h index 148888f7693..2363addb56a 100644 --- a/source/blender/nodes/shader/node_shader_util.h +++ b/source/blender/nodes/shader/node_shader_util.h @@ -55,6 +55,7 @@ #include "BLI_threads.h" #include "BLI_utildefines.h" +#include "BKE_colorband.h" #include "BKE_colortools.h" #include "BKE_global.h" #include "BKE_image.h" diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_pointdensity.c b/source/blender/nodes/shader/nodes/node_shader_tex_pointdensity.c index 8748c884a25..436eeeefb4a 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_pointdensity.c +++ b/source/blender/nodes/shader/nodes/node_shader_tex_pointdensity.c @@ -27,7 +27,6 @@ #include "../node_shader_util.h" -#include "BKE_texture.h" #include "RE_render_ext.h" diff --git a/source/blender/nodes/shader/nodes/node_shader_valToRgb.c b/source/blender/nodes/shader/nodes/node_shader_valToRgb.c index b5e32e294bf..39598eb8675 100644 --- a/source/blender/nodes/shader/nodes/node_shader_valToRgb.c +++ b/source/blender/nodes/shader/nodes/node_shader_valToRgb.c @@ -53,14 +53,14 @@ static void node_shader_exec_valtorgb(void *UNUSED(data), int UNUSED(thread), bN float fac; nodestack_get_vec(&fac, SOCK_FLOAT, in[0]); - do_colorband(node->storage, fac, out[0]->vec); + BKE_colorband_evaluate(node->storage, fac, out[0]->vec); out[1]->vec[0] = out[0]->vec[3]; } } static void node_shader_init_valtorgb(bNodeTree *UNUSED(ntree), bNode *node) { - node->storage = add_colorband(true); + node->storage = BKE_colorband_add(true); } static int gpu_shader_valtorgb(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out) @@ -68,7 +68,7 @@ static int gpu_shader_valtorgb(GPUMaterial *mat, bNode *node, bNodeExecData *UNU float *array; int size; - colorband_table_RGBA(node->storage, &array, &size); + BKE_colorband_evaluate_table_rgba(node->storage, &array, &size); return GPU_stack_link(mat, node, "valtorgb", in, out, GPU_texture(size, array)); } diff --git a/source/blender/nodes/texture/node_texture_util.h b/source/blender/nodes/texture/node_texture_util.h index 2263c271ccf..f6af5b1b6ca 100644 --- a/source/blender/nodes/texture/node_texture_util.h +++ b/source/blender/nodes/texture/node_texture_util.h @@ -53,6 +53,7 @@ #include "BLI_threads.h" #include "BLI_utildefines.h" +#include "BKE_colorband.h" #include "BKE_colortools.h" #include "BKE_global.h" #include "BKE_image.h" diff --git a/source/blender/nodes/texture/nodes/node_texture_valToRgb.c b/source/blender/nodes/texture/nodes/node_texture_valToRgb.c index a49d82d27a9..8b016c5aa50 100644 --- a/source/blender/nodes/texture/nodes/node_texture_valToRgb.c +++ b/source/blender/nodes/texture/nodes/node_texture_valToRgb.c @@ -49,7 +49,7 @@ static void valtorgb_colorfn(float *out, TexParams *p, bNode *node, bNodeStack * if (node->storage) { float fac = tex_input_value(in[0], p, thread); - do_colorband(node->storage, fac, out); + BKE_colorband_evaluate(node->storage, fac, out); } } @@ -60,7 +60,7 @@ static void valtorgb_exec(void *data, int UNUSED(thread), bNode *node, bNodeExec static void valtorgb_init(bNodeTree *UNUSED(ntree), bNode *node) { - node->storage = add_colorband(true); + node->storage = BKE_colorband_add(true); } void register_node_type_tex_valtorgb(void) diff --git a/source/blender/render/intern/source/pointdensity.c b/source/blender/render/intern/source/pointdensity.c index e94a452c94a..28d62f36ddd 100644 --- a/source/blender/render/intern/source/pointdensity.c +++ b/source/blender/render/intern/source/pointdensity.c @@ -48,6 +48,7 @@ #include "DNA_particle_types.h" #include "DNA_texture_types.h" +#include "BKE_colorband.h" #include "BKE_deform.h" #include "BKE_DerivedMesh.h" #include "BKE_lattice.h" @@ -55,7 +56,6 @@ #include "BKE_object.h" #include "BKE_particle.h" #include "BKE_scene.h" -#include "BKE_texture.h" #include "BKE_colortools.h" #include "DEG_depsgraph.h" @@ -786,7 +786,7 @@ static int pointdensity_color(PointDensity *pd, TexResult *texres, float age, co switch (pd->color_source) { case TEX_PD_COLOR_PARTAGE: if (pd->coba) { - if (do_colorband(pd->coba, age, rgba)) { + if (BKE_colorband_evaluate(pd->coba, age, rgba)) { texres->talpha = true; copy_v3_v3(&texres->tr, rgba); texres->tin *= rgba[3]; @@ -799,7 +799,7 @@ static int pointdensity_color(PointDensity *pd, TexResult *texres, float age, co float speed = len_v3(vec) * pd->speed_scale; if (pd->coba) { - if (do_colorband(pd->coba, speed, rgba)) { + if (BKE_colorband_evaluate(pd->coba, speed, rgba)) { texres->talpha = true; copy_v3_v3(&texres->tr, rgba); texres->tin *= rgba[3]; @@ -831,7 +831,7 @@ static int pointdensity_color(PointDensity *pd, TexResult *texres, float age, co break; case TEX_PD_COLOR_VERTWEIGHT: texres->talpha = true; - if (pd->coba && do_colorband(pd->coba, col[0], rgba)) { + if (pd->coba && BKE_colorband_evaluate(pd->coba, col[0], rgba)) { copy_v3_v3(&texres->tr, rgba); texres->tin *= rgba[3]; } diff --git a/source/blender/render/intern/source/render_texture.c b/source/blender/render/intern/source/render_texture.c index 91d1f63a1be..e6138842f09 100644 --- a/source/blender/render/intern/source/render_texture.c +++ b/source/blender/render/intern/source/render_texture.c @@ -54,6 +54,7 @@ #include "BKE_node.h" #include "BKE_animsys.h" +#include "BKE_colorband.h" #include "BKE_DerivedMesh.h" #include "BKE_global.h" #include "BKE_main.h" @@ -161,15 +162,15 @@ static void tex_normal_derivate(Tex *tex, TexResult *texres) { if (tex->flag & TEX_COLORBAND) { float col[4]; - if (do_colorband(tex->coba, texres->tin, col)) { + if (BKE_colorband_evaluate(tex->coba, texres->tin, col)) { float fac0, fac1, fac2, fac3; fac0= (col[0]+col[1]+col[2]); - do_colorband(tex->coba, texres->nor[0], col); + BKE_colorband_evaluate(tex->coba, texres->nor[0], col); fac1= (col[0]+col[1]+col[2]); - do_colorband(tex->coba, texres->nor[1], col); + BKE_colorband_evaluate(tex->coba, texres->nor[1], col); fac2= (col[0]+col[1]+col[2]); - do_colorband(tex->coba, texres->nor[2], col); + BKE_colorband_evaluate(tex->coba, texres->nor[2], col); fac3= (col[0]+col[1]+col[2]); texres->nor[0]= (fac0 - fac1) / 3.0f; @@ -1218,7 +1219,7 @@ static int multitex(Tex *tex, if (tex->flag & TEX_COLORBAND) { float col[4]; - if (do_colorband(tex->coba, texres->tin, col)) { + if (BKE_colorband_evaluate(tex->coba, texres->tin, col)) { texres->talpha = true; texres->tr= col[0]; texres->tg= col[1]; diff --git a/source/blender/render/intern/source/shadeoutput.c b/source/blender/render/intern/source/shadeoutput.c index 9279899ef66..c2d5c060530 100644 --- a/source/blender/render/intern/source/shadeoutput.c +++ b/source/blender/render/intern/source/shadeoutput.c @@ -27,7 +27,6 @@ * \ingroup render */ - #include <stdio.h> #include <float.h> #include <math.h> @@ -36,10 +35,9 @@ #include "BLI_math.h" #include "BLI_utildefines.h" +#include "BKE_colorband.h" #include "BKE_colortools.h" #include "BKE_material.h" -#include "BKE_texture.h" - #include "DNA_group_types.h" #include "DNA_lamp_types.h" @@ -942,7 +940,7 @@ static void ramp_diffuse_result(float *diff, ShadeInput *shi) if (ma->ramp_col) { if (ma->rampin_col==MA_RAMP_IN_RESULT) { float fac = IMB_colormanagement_get_luminance(diff); - do_colorband(ma->ramp_col, fac, col); + BKE_colorband_evaluate(ma->ramp_col, fac, col); /* blending method */ fac= col[3]*ma->rampfac_col; @@ -986,7 +984,7 @@ static void add_to_diffuse(float diff[3], const ShadeInput *shi, const float is, break; } - do_colorband(ma->ramp_col, fac, col); + BKE_colorband_evaluate(ma->ramp_col, fac, col); /* blending method */ fac = col[3] * ma->rampfac_col; @@ -1015,7 +1013,7 @@ static void ramp_spec_result(float spec_col[3], ShadeInput *shi) float col[4]; float fac = IMB_colormanagement_get_luminance(spec_col); - do_colorband(ma->ramp_spec, fac, col); + BKE_colorband_evaluate(ma->ramp_spec, fac, col); /* blending method */ fac= col[3]*ma->rampfac_spec; @@ -1055,7 +1053,7 @@ static void do_specular_ramp(ShadeInput *shi, float is, float t, float spec[3]) break; } - do_colorband(ma->ramp_spec, fac, col); + BKE_colorband_evaluate(ma->ramp_spec, fac, col); /* blending method */ fac= col[3]*ma->rampfac_spec; |