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);
165 int carr_len = array_len;
168 const float step_size = 1.0f /
float(array_len - 1);
169 for (
int i = 0; i < array_len; i++, c++) {
173 c->
pos = i * step_size;
176 carr[0].
prev =
nullptr;
177 carr[array_len - 1].
next =
nullptr;
182 for (
int i = 0; i < array_len; i++, c++) {
197 c_prev->
next = c_next;
198 c_next->
prev = c_prev;
204 for (
int i = 0; i < 2; i++) {
206 if (c_other->
node !=
nullptr) {
213 c_other->
node =
nullptr;
224 if (filter_samples ==
false) {
225 for (c = carr; c !=
nullptr; c = c->
next, i++) {
232 for (c = carr; c !=
nullptr; c = c->
next, i++) {
233 const int steps_prev = c->
prev ? (c - c->
prev) - 1 : 0;
234 const int steps_next = c->
next ? (c->
next - c) - 1 : 0;
235 if (steps_prev == 0 && steps_next == 0) {
240 float rgba_accum = 1;
244 const float step_size = 1.0 /
float(steps_prev + 1);
247 const float step_pos =
float(j) * step_size;
248 BLI_assert(step_pos > 0.0f && step_pos < 1.0f);
255 const float step_size = 1.0 /
float(steps_next + 1);
258 const float step_pos =
float(j) * step_size;
259 BLI_assert(step_pos > 0.0f && step_pos < 1.0f);
280 const float (*
array)[4],
311 const int ipotype_hue,
const float mfac,
const float fac,
float h1,
float h2)
316#define HUE_INTERP(h_a, h_b) ((mfac * (h_a)) + (fac * (h_b)))
317#define HUE_MOD(h) (((h) < 1.0f) ? (h) : (h)-1.0f)
325 switch (ipotype_hue) {
327 if ((h1 < h2) && (h2 - h1) > +0.5f) {
330 else if ((h1 > h2) && (h2 - h1) < -0.5f) {
343 else if ((h1 < h2) && (h2 - h1) < +0.5f) {
346 else if ((h1 > h2) && (h2 - h1) > -0.5f) {
388 BLI_assert(h_interp >= 0.0f && h_interp < 1.0f);
398 const CBData *cbd1, *cbd2, *cbd0, *cbd3;
403 if (coba ==
nullptr || coba->
tot == 0) {
414 if (coba->
tot == 1) {
420 else if ((in <= cbd1->
pos) &&
433 for (a = 0; a < coba->
tot; a++, cbd1++) {
434 if (cbd1->
pos > in) {
439 if (a == coba->
tot) {
454 if ((a == coba->
tot) &&
471 if (cbd2->
pos != cbd1->
pos) {
472 fac = (in - cbd1->
pos) / (cbd2->
pos - cbd1->
pos);
477 fac = (a != coba->
tot) ? 0.0f : 1.0f;
484 if (a >= coba->
tot - 1) {
497 CLAMP(fac, 0.0f, 1.0f);
506 out[0] = t[3] * cbd3->
r + t[2] * cbd2->
r + t[1] * cbd1->
r + t[0] * cbd0->
r;
507 out[1] = t[3] * cbd3->
g + t[2] * cbd2->
g + t[1] * cbd1->
g + t[0] * cbd0->
g;
508 out[2] = t[3] * cbd3->
b + t[2] * cbd2->
b + t[1] * cbd1->
b + t[0] * cbd0->
b;
509 out[3] = t[3] * cbd3->
a + t[2] * cbd2->
a + t[1] * cbd1->
a + t[0] * cbd0->
a;
514 const float fac2 = fac * fac;
515 fac = 3.0f * fac2 - 2.0f * fac2 * fac;
517 const float mfac = 1.0f - fac;
520 float col1[3], col2[3];
526 out[1] = mfac * col1[1] + fac * col2[1];
527 out[2] = mfac * col1[2] + fac * col2[2];
528 out[3] = mfac * cbd1->
a + fac * cbd2->
a;
533 float col1[3], col2[3];
539 out[1] = mfac * col1[1] + fac * col2[1];
540 out[2] = mfac * col1[2] + fac * col2[2];
541 out[3] = mfac * cbd1->
a + fac * cbd2->
a;
547 out[0] = mfac * cbd1->
r + fac * cbd2->
r;
548 out[1] = mfac * cbd1->
g + fac * cbd2->
g;
549 out[2] = mfac * cbd1->
b + fac * cbd2->
b;
550 out[3] = mfac * cbd1->
a + fac * cbd2->
a;
564 *
array =
static_cast<float *
>(
MEM_callocN(
sizeof(
float) * (*size) * 4,
"ColorBand"));
566 for (a = 0; a < *
size; a++) {
573 const CBData *x1 =
static_cast<const CBData *
>(a1), *x2 =
static_cast<const CBData *
>(a2);
575 if (x1->
pos > x2->pos) {
578 if (x1->
pos < x2->pos) {
592 for (a = 0; a < coba->
tot; a++) {
598 for (a = 0; a < coba->
tot; a++) {
615 xnew->
pos = position;
617 if (coba->
tot != 0) {
625 coba->
cur = coba->
tot - 1;
638 if (index < 0 || index >= coba->
tot) {
643 for (
int a = index; a < coba->
tot; a++) {
void key_curve_position_weights(float t, float data[4], int 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)
draw_view in_light_buf[] float
draw_view push_constant(Type::INT, "radiance_src") .push_constant(Type capture_info_buf storage_buf(1, Qualifier::READ, "ObjectBounds", "bounds_buf[]") .push_constant(Type draw_view int
void *(* MEM_mallocN)(size_t len, const char *str)
void MEM_freeN(void *vmemh)
void *(* MEM_callocN)(size_t len, const char *str)