Cleanup: minor edits to last commit
This commit is contained in:
parent
f7a1a1a700
commit
58aa31a9ec
|
@ -113,6 +113,16 @@ static void colorband_init_from_table_rgba_simple(
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Color Ramp Re-Sample
|
||||
*
|
||||
* Local functions for #BKE_colorband_init_from_table_rgba
|
||||
* \{ */
|
||||
|
||||
/**
|
||||
* Used for calculating which samples of a color-band to remove (when simplifying).
|
||||
*/
|
||||
struct ColorResampleElem {
|
||||
struct ColorResampleElem *next, *prev;
|
||||
HeapNode *node;
|
||||
|
@ -120,6 +130,9 @@ struct ColorResampleElem {
|
|||
float pos;
|
||||
};
|
||||
|
||||
/**
|
||||
* Measure the 'area' of each channel and combine to use as a cost for this samples removal.
|
||||
*/
|
||||
static float color_sample_remove_cost(const struct ColorResampleElem *c)
|
||||
{
|
||||
if (c->next == NULL || c->prev == NULL) {
|
||||
|
@ -158,14 +171,14 @@ static void colorband_init_from_table_rgba_resample(
|
|||
/* Use 2x to avoid noise having too much impact, since this is RGBA accumulated. */
|
||||
const float eps_2x = ((1.0f / 255.0f) + 1e-6f) * 2.0f;
|
||||
struct ColorResampleElem *c, *carr = MEM_mallocN(sizeof(*carr) * array_len, __func__);
|
||||
float color_fac = 1.0f / (float)(array_len - 1);
|
||||
int carr_len = array_len;
|
||||
c = carr;
|
||||
const float step_size = 1.0f / (float)(array_len - 1);
|
||||
for (int i = 0; i < array_len; i++, c++) {
|
||||
copy_v4_v4(carr[i].rgba, array[i]);
|
||||
c->next = c + 1;
|
||||
c->prev = c - 1;
|
||||
c->pos = i * color_fac;
|
||||
c->pos = i * step_size;
|
||||
}
|
||||
carr[0].prev = NULL;
|
||||
carr[array_len - 1].next = NULL;
|
||||
|
@ -214,7 +227,7 @@ static void colorband_init_from_table_rgba_resample(
|
|||
|
||||
BLI_assert(carr_len < MAXCOLORBAND);
|
||||
int i = 0;
|
||||
/* fist member is never removed. */
|
||||
/* First member is never removed. */
|
||||
for (c = carr; c != NULL; c = c->next, i++) {
|
||||
copy_v4_v4(&coba->data[i].r, c->rgba);
|
||||
coba->data[i].pos = c->pos;
|
||||
|
@ -241,6 +254,8 @@ void BKE_colorband_init_from_table_rgba(
|
|||
}
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
||||
ColorBand *BKE_colorband_add(bool rangetype)
|
||||
{
|
||||
ColorBand *coba;
|
||||
|
|
Loading…
Reference in New Issue