[Bf-blender-cvs] [58aa31a9ec0] master: Cleanup: minor edits to last commit

Campbell Barton noreply at git.blender.org
Tue Dec 12 03:37:19 CET 2017


Commit: 58aa31a9ec0fc5b7dbef02b4308a826b49abf3d8
Author: Campbell Barton
Date:   Tue Dec 12 13:37:21 2017 +1100
Branches: master
https://developer.blender.org/rB58aa31a9ec0fc5b7dbef02b4308a826b49abf3d8

Cleanup: minor edits to last commit

===================================================================

M	source/blender/blenkernel/intern/colorband.c

===================================================================

diff --git a/source/blender/blenkernel/intern/colorband.c b/source/blender/blenkernel/intern/colorband.c
index e6f3ce575ce..0655c51f26c 100644
--- a/source/blender/blenkernel/intern/colorband.c
+++ b/source/blender/blenkernel/intern/colorband.c
@@ -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;



More information about the Bf-blender-cvs mailing list