30 coba->
data[0].
r = 0.0;
31 coba->
data[0].
g = 0.0;
32 coba->
data[0].
b = 0.0;
33 coba->
data[0].
a = 0.0;
35 coba->
data[1].
r = 1.0;
36 coba->
data[1].
g = 1.0;
37 coba->
data[1].
b = 1.0;
38 coba->
data[1].
a = 1.0;
41 coba->
data[0].
r = 0.0;
42 coba->
data[0].
g = 0.0;
43 coba->
data[0].
b = 0.0;
44 coba->
data[0].
a = 1.0;
46 coba->
data[1].
r = 1.0;
47 coba->
data[1].
g = 1.0;
48 coba->
data[1].
b = 1.0;
49 coba->
data[1].
a = 1.0;
53 coba->
data[a].
r = 0.5;
54 coba->
data[a].
g = 0.5;
55 coba->
data[a].
b = 0.5;
56 coba->
data[a].
a = 1.0;
67 const float (*
array)[4],
71 const float eps = (1.0f / 255.0f) + 1e-6f;
75 const float step_size = 1.0f / float(
max_ii(stops - 1, 1));
77 for (
int i_step = 0; i_step < stops; i_step++) {
83 coba->
data[i_curr].
pos = i_step * step_size;
84 coba->
data[i_curr].
cur = i_curr;
86 coba->
tot = i_curr + 1;
92 coba->
data[0].
a = 1.0f;
119 if (c->
next ==
nullptr || c->
prev ==
nullptr) {
124 float xy_prev[2], xy_curr[2], xy_next[2];
128 for (
int i = 0;
i < 4;
i++) {
130 xy_curr[1] = c->
rgba[
i];
138 for (
int i = 0;
i < 4;
i++) {
141 area +=
fabsf((xpc * ycn) + (ypc * xnc));
150 const float gaussfac = 1.6f;
151 const float two_gaussfac2 = 2.0f * gaussfac * gaussfac;
152 x *= 3.0f * gaussfac;
153 return 1.0f /
sqrtf(
float(
M_PI) * two_gaussfac2) *
expf(-
x *
x / two_gaussfac2);
157 const float (*
array)[4],
162 const float eps_2x = ((1.0f / 255.0f) + 1e-6f);
164 int carr_len = array_len;
167 const float step_size = 1.0f / float(array_len - 1);
168 for (
int i = 0;
i < array_len;
i++, c++) {
172 c->
pos =
i * step_size;
175 carr[0].
prev =
nullptr;
176 carr[array_len - 1].
next =
nullptr;
181 for (
int i = 0;
i < array_len;
i++, c++) {
196 c_prev->
next = c_next;
197 c_next->
prev = c_prev;
203 for (
int i = 0;
i < 2;
i++) {
205 if (c_other->
node !=
nullptr) {
212 c_other->
node =
nullptr;
223 if (filter_samples ==
false) {
224 for (c = carr; c !=
nullptr; c = c->
next,
i++) {
231 for (c = carr; c !=
nullptr; c = c->
next,
i++) {
232 const int steps_prev = c->
prev ? (c - c->
prev) - 1 : 0;
233 const int steps_next = c->
next ? (c->
next - c) - 1 : 0;
234 if (steps_prev == 0 && steps_next == 0) {
239 float rgba_accum = 1;
243 const float step_size = 1.0 / float(steps_prev + 1);
246 const float step_pos = float(j) * step_size;
247 BLI_assert(step_pos > 0.0f && step_pos < 1.0f);
254 const float step_size = 1.0 / float(steps_next + 1);
257 const float step_pos = float(j) * step_size;
258 BLI_assert(step_pos > 0.0f && step_pos < 1.0f);
279 const float (*
array)[4],
310 const int ipotype_hue,
const float mfac,
const float fac,
float h1,
float h2)
315#define HUE_INTERP(h_a, h_b) ((mfac * (h_a)) + (fac * (h_b)))
316#define HUE_MOD(h) (((h) < 1.0f) ? (h) : (h)-1.0f)
324 switch (ipotype_hue) {
326 if ((h1 < h2) && (h2 - h1) > +0.5f) {
329 else if ((h1 > h2) && (h2 - h1) < -0.5f) {
342 else if ((h1 < h2) && (h2 - h1) < +0.5f) {
345 else if ((h1 > h2) && (h2 - h1) > -0.5f) {
387 BLI_assert(h_interp >= 0.0f && h_interp < 1.0f);
397 const CBData *cbd1, *cbd2, *cbd0, *cbd3;
402 if (coba ==
nullptr || coba->
tot == 0) {
413 if (coba->
tot == 1) {
432 for (a = 0; a < coba->
tot; a++, cbd1++) {
433 if (cbd1->
pos >
in) {
438 if (a == coba->
tot) {
453 if ((a == coba->
tot) &&
470 if (cbd2->
pos != cbd1->
pos) {
476 fac = (a != coba->
tot) ? 0.0f : 1.0f;
483 if (a >= coba->
tot - 1) {
496 CLAMP(fac, 0.0f, 1.0f);
505 out[0] = t[3] * cbd3->
r + t[2] * cbd2->
r + t[1] * cbd1->
r + t[0] * cbd0->
r;
506 out[1] = t[3] * cbd3->
g + t[2] * cbd2->
g + t[1] * cbd1->
g + t[0] * cbd0->
g;
507 out[2] = t[3] * cbd3->
b + t[2] * cbd2->
b + t[1] * cbd1->
b + t[0] * cbd0->
b;
508 out[3] = t[3] * cbd3->
a + t[2] * cbd2->
a + t[1] * cbd1->
a + t[0] * cbd0->
a;
513 const float fac2 = fac * fac;
514 fac = 3.0f * fac2 - 2.0f * fac2 * fac;
516 const float mfac = 1.0f - fac;
519 float col1[3], col2[3];
525 out[1] = mfac * col1[1] + fac * col2[1];
526 out[2] = mfac * col1[2] + fac * col2[2];
527 out[3] = mfac * cbd1->
a + fac * cbd2->
a;
532 float col1[3], col2[3];
538 out[1] = mfac * col1[1] + fac * col2[1];
539 out[2] = mfac * col1[2] + fac * col2[2];
540 out[3] = mfac * cbd1->
a + fac * cbd2->
a;
546 out[0] = mfac * cbd1->
r + fac * cbd2->
r;
547 out[1] = mfac * cbd1->
g + fac * cbd2->
g;
548 out[2] = mfac * cbd1->
b + fac * cbd2->
b;
549 out[3] = mfac * cbd1->
a + fac * cbd2->
a;
565 for (a = 0; a < *
size; a++) {
572 const CBData *x1 =
static_cast<const CBData *
>(a1), *x2 =
static_cast<const CBData *
>(a2);
574 if (x1->
pos > x2->pos) {
577 if (x1->
pos < x2->pos) {
591 for (a = 0; a < coba->
tot; a++) {
597 for (a = 0; a < coba->
tot; a++) {
614 xnew->
pos = position;
616 if (coba->
tot != 0) {
624 coba->
cur = coba->
tot - 1;
637 if (index < 0 || index >= coba->
tot) {
642 for (
int a = index; a < coba->
tot; a++) {
void key_curve_position_weights(float t, float data[4], KeyInterpolationType type)
A min-heap / priority queue ADT.
void BLI_heap_free(Heap *heap, HeapFreeFP ptrfreefp) ATTR_NONNULL(1)
Heap * BLI_heap_new_ex(unsigned int reserve_num) ATTR_WARN_UNUSED_RESULT
void void bool BLI_heap_is_empty(const Heap *heap) ATTR_NONNULL(1)
float BLI_heap_top_value(const Heap *heap) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void BLI_heap_node_value_update(Heap *heap, HeapNode *node, float value) ATTR_NONNULL(1
void * BLI_heap_pop_min(Heap *heap) ATTR_NONNULL(1)
HeapNode * BLI_heap_insert(Heap *heap, float value, void *ptr) ATTR_NONNULL(1)
void void BLI_heap_remove(Heap *heap, HeapNode *node) ATTR_NONNULL(1
MINLINE int min_ii(int a, int b)
MINLINE int max_ii(int a, int b)
void hsv_to_rgb_v(const float hsv[3], float r_rgb[3])
void rgb_to_hsv_v(const float rgb[3], float r_hsv[3])
void hsl_to_rgb_v(const float hsl[3], float r_rgb[3])
void rgb_to_hsl_v(const float rgb[3], float r_hsl[3])
MINLINE float cross_tri_v2(const float v1[2], const float v2[2], const float v3[2])
MINLINE void copy_v4_v4(float r[4], const float a[4])
MINLINE void clamp_v4(float vec[4], float min, float max)
MINLINE bool compare_v4v4(const float v1[4], const float v2[4], float limit) ATTR_WARN_UNUSED_RESULT
MINLINE void mul_v4_v4fl(float r[4], const float a[4], float f)
MINLINE void zero_v4(float r[4])
MINLINE void madd_v4_v4fl(float r[4], const float a[4], float f)
MINLINE void zero_v3(float r[3])
@ COLBAND_INTERP_CONSTANT
@ COLBAND_INTERP_B_SPLINE
@ COLBAND_INTERP_CARDINAL
Read Guarded memory(de)allocation.
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
void BKE_colorband_evaluate_table_rgba(const ColorBand *coba, float **array, int *size)
CBData * BKE_colorband_element_add(ColorBand *coba, float position)
void BKE_colorband_init_from_table_rgba(ColorBand *coba, const float(*array)[4], const int array_len, bool filter_samples)
static float colorband_hue_interp(const int ipotype_hue, const float mfac, const float fac, float h1, float h2)
static void colorband_init_from_table_rgba_resample(ColorBand *coba, const float(*array)[4], const int array_len, bool filter_samples)
void BKE_colorband_update_sort(ColorBand *coba)
bool BKE_colorband_evaluate(const ColorBand *coba, float in, float out[4])
#define HUE_INTERP(h_a, h_b)
static float color_sample_remove_cost(const ColorResampleElem *c)
static float filter_gauss(float x)
ColorBand * BKE_colorband_add(bool rangetype)
bool BKE_colorband_element_remove(ColorBand *coba, int index)
void BKE_colorband_init(ColorBand *coba, bool rangetype)
static int vergcband(const void *a1, const void *a2)
static void colorband_init_from_table_rgba_simple(ColorBand *coba, const float(*array)[4], const int array_len)
void * MEM_calloc_arrayN(size_t len, size_t size, const char *str)
void * MEM_callocN(size_t len, const char *str)
void * MEM_malloc_arrayN(size_t len, size_t size, const char *str)
void MEM_freeN(void *vmemh)