Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2017-12-13 16:24:44 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2017-12-13 16:24:44 +0300
commit3d6cc77cbd8fc1dbd92d186486d038857e6eda62 (patch)
tree0a615d7dcce64a8ba19dd70a1448a37d4312865d /source/blender
parent32f85c8322e872951c7029fece0dc7d9102ed2b5 (diff)
parent4838512e7d495cb74ac599a8cd4c788d006c843c (diff)
Merge branch 'master' into blender2.8
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenkernel/BKE_colorband.h2
-rw-r--r--source/blender/blenkernel/intern/colorband.c95
-rw-r--r--source/blender/depsgraph/intern/builder/deg_builder_relations.cc10
-rw-r--r--source/blender/editors/interface/interface_eyedropper_colorband.c4
-rw-r--r--source/blender/editors/mesh/editmesh_rip.c2
-rw-r--r--source/blender/makesrna/intern/rna_ui_api.c4
6 files changed, 90 insertions, 27 deletions
diff --git a/source/blender/blenkernel/BKE_colorband.h b/source/blender/blenkernel/BKE_colorband.h
index 6841d94d360..edb724d2aec 100644
--- a/source/blender/blenkernel/BKE_colorband.h
+++ b/source/blender/blenkernel/BKE_colorband.h
@@ -37,7 +37,7 @@ struct ColorBand;
void BKE_colorband_init(struct ColorBand *coba, bool rangetype);
void BKE_colorband_init_from_table_rgba(
- struct ColorBand *coba, const float (*array)[4], const int array_len);
+ struct ColorBand *coba, const float (*array)[4], const int array_len, bool filter_sample);
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);
diff --git a/source/blender/blenkernel/intern/colorband.c b/source/blender/blenkernel/intern/colorband.c
index 0655c51f26c..d35e797ddac 100644
--- a/source/blender/blenkernel/intern/colorband.c
+++ b/source/blender/blenkernel/intern/colorband.c
@@ -163,22 +163,33 @@ static float color_sample_remove_cost(const struct ColorResampleElem *c)
return area;
}
+/* TODO(campbell): create BLI_math_filter? */
+static float filter_gauss(float x)
+{
+ const float gaussfac = 1.6f;
+ const float two_gaussfac2 = 2.0f * gaussfac * gaussfac;
+ x *= 3.0f * gaussfac;
+ return 1.0f / sqrtf((float)M_PI * two_gaussfac2) * expf(-x * x / two_gaussfac2);
+}
+
static void colorband_init_from_table_rgba_resample(
ColorBand *coba,
- const float (*array)[4], const int array_len)
+ const float (*array)[4], const int array_len,
+ bool filter_samples)
{
- BLI_assert(array_len >= MAXCOLORBAND);
- /* 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;
+ BLI_assert(array_len >= 2);
+ const float eps_2x = ((1.0f / 255.0f) + 1e-6f);
struct ColorResampleElem *c, *carr = MEM_mallocN(sizeof(*carr) * array_len, __func__);
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 * step_size;
+ {
+ 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 * step_size;
+ }
}
carr[0].prev = NULL;
carr[array_len - 1].next = NULL;
@@ -225,13 +236,56 @@ static void colorband_init_from_table_rgba_resample(
}
BLI_heap_free(heap, NULL);
- BLI_assert(carr_len < MAXCOLORBAND);
- int i = 0;
/* 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;
- coba->data[i].cur = i;
+ int i = 0;
+ BLI_assert(carr_len < MAXCOLORBAND);
+ if (filter_samples == false) {
+ for (c = carr; c != NULL; c = c->next, i++) {
+ copy_v4_v4(&coba->data[i].r, c->rgba);
+ coba->data[i].pos = c->pos;
+ coba->data[i].cur = i;
+ }
+ }
+ else {
+ for (c = carr; c != NULL; c = c->next, i++) {
+ const int steps_prev = c->prev ? (c - c->prev) - 1 : 0;
+ const int steps_next = c->next ? (c->next - c) - 1 : 0;
+ if (steps_prev == 0 && steps_next == 0) {
+ copy_v4_v4(&coba->data[i].r, c->rgba);
+ }
+ else {
+ float rgba[4];
+ float rgba_accum = 1;
+ copy_v4_v4(rgba, c->rgba);
+
+ if (steps_prev) {
+ const float step_size = 1.0 / (float)(steps_prev + 1);
+ int j = steps_prev;
+ for (struct ColorResampleElem *c_other = c - 1; c_other != c->prev; c_other--, j--) {
+ const float step_pos = (float)j * step_size;
+ BLI_assert(step_pos > 0.0f && step_pos < 1.0f);
+ const float f = filter_gauss(step_pos);
+ madd_v4_v4fl(rgba, c_other->rgba, f);
+ rgba_accum += f;
+ }
+ }
+ if (steps_next) {
+ const float step_size = 1.0 / (float)(steps_next + 1);
+ int j = steps_next;
+ for (struct ColorResampleElem *c_other = c + 1; c_other != c->next; c_other++, j--) {
+ const float step_pos = (float)j * step_size;
+ BLI_assert(step_pos > 0.0f && step_pos < 1.0f);
+ const float f = filter_gauss(step_pos);
+ madd_v4_v4fl(rgba, c_other->rgba, f);
+ rgba_accum += f;
+ }
+ }
+
+ mul_v4_v4fl(&coba->data[i].r, rgba, 1.0f / rgba_accum);
+ }
+ coba->data[i].pos = c->pos;
+ coba->data[i].cur = i;
+ }
}
BLI_assert(i == carr_len);
coba->tot = i;
@@ -242,15 +296,18 @@ static void colorband_init_from_table_rgba_resample(
void BKE_colorband_init_from_table_rgba(
ColorBand *coba,
- const float (*array)[4], const int array_len)
+ const float (*array)[4], const int array_len,
+ bool filter_samples)
{
- if (array_len < MAXCOLORBAND) {
+ /* Note, we could use MAXCOLORBAND here, but results of re-sampling are nicer,
+ * avoid different behavior when limit is hit. */
+ if (array_len < 2) {
/* No Re-sample, just de-duplicate. */
colorband_init_from_table_rgba_simple(coba, array, array_len);
}
else {
/* Re-sample */
- colorband_init_from_table_rgba_resample(coba, array, array_len);
+ colorband_init_from_table_rgba_resample(coba, array, array_len, filter_samples);
}
}
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
index 2caa0d4ed5a..870c3c13c22 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
@@ -1351,9 +1351,6 @@ void DepsgraphRelationBuilder::build_particles(Object *object)
OperationKey eval_init_key(&object->id,
DEG_NODE_TYPE_EVAL_PARTICLES,
DEG_OPCODE_PARTICLE_SYSTEM_EVAL_INIT);
- if (object_particles_depends_on_time(object)) {
- add_relation(time_src_key, eval_init_key, "TimeSrc -> PSys");
- }
/* particle systems */
LINKLIST_FOREACH (ParticleSystem *, psys, &object->particlesystem) {
@@ -1452,6 +1449,13 @@ void DepsgraphRelationBuilder::build_particles(Object *object)
if (part->ren_as == PART_DRAW_OB && part->dup_ob) {
ComponentKey dup_ob_key(&part->dup_ob->id, DEG_NODE_TYPE_TRANSFORM);
add_relation(dup_ob_key, psys_key, "Particle Object Visualization");
+ if (part->dup_ob->type == OB_MBALL) {
+ ComponentKey dup_geometry_key(&part->dup_ob->id,
+ DEG_NODE_TYPE_GEOMETRY);
+ add_relation(psys_key,
+ dup_geometry_key,
+ "Particle MBall Visualization");
+ }
}
}
diff --git a/source/blender/editors/interface/interface_eyedropper_colorband.c b/source/blender/editors/interface/interface_eyedropper_colorband.c
index 655c2c46c6c..85339ff0322 100644
--- a/source/blender/editors/interface/interface_eyedropper_colorband.c
+++ b/source/blender/editors/interface/interface_eyedropper_colorband.c
@@ -165,7 +165,9 @@ static void eyedropper_colorband_exit(bContext *C, wmOperator *op)
static void eyedropper_colorband_apply(bContext *C, wmOperator *op)
{
EyedropperColorband *eye = op->customdata;
- BKE_colorband_init_from_table_rgba(eye->color_band, eye->color_buffer, eye->color_buffer_len);
+ /* Always filter, avoids noise in resulting color-band. */
+ bool filter_samples = true;
+ BKE_colorband_init_from_table_rgba(eye->color_band, eye->color_buffer, eye->color_buffer_len, filter_samples);
RNA_property_update(C, &eye->ptr, eye->prop);
}
diff --git a/source/blender/editors/mesh/editmesh_rip.c b/source/blender/editors/mesh/editmesh_rip.c
index 1a2f9fdb62b..0c8bd560bb2 100644
--- a/source/blender/editors/mesh/editmesh_rip.c
+++ b/source/blender/editors/mesh/editmesh_rip.c
@@ -590,7 +590,7 @@ static int edbm_rip_invoke__vert(bContext *C, wmOperator *op, const wmEvent *eve
}
}
- if (e_best && (is_manifold_region == false)) {
+ if (e_best && e_best->l && (is_manifold_region == false)) {
/* Try to split off a non-manifold fan (when we have multiple disconnected fans) */
BMLoop *l_sep = e_best->l->v == v ? e_best->l : e_best->l->next;
BMVert *v_new;
diff --git a/source/blender/makesrna/intern/rna_ui_api.c b/source/blender/makesrna/intern/rna_ui_api.c
index 0b44809cf48..9263395cd66 100644
--- a/source/blender/makesrna/intern/rna_ui_api.c
+++ b/source/blender/makesrna/intern/rna_ui_api.c
@@ -549,7 +549,7 @@ void RNA_api_ui_layout(StructRNA *srna)
RNA_def_boolean(func, "icon_only", false, "", "Draw only icons in buttons, no text");
RNA_def_boolean(func, "event", false, "", "Use button to input key events");
RNA_def_boolean(func, "full_event", false, "", "Use button to input full events including modifiers");
- RNA_def_boolean(func, "emboss", true, "", "Draw the button itself, just the icon/text");
+ RNA_def_boolean(func, "emboss", true, "", "Draw the button itself, not just the icon/text");
RNA_def_int(func, "index", -1, -2, INT_MAX, "",
"The index of this button, when set a single member of an array can be accessed, "
"when set to -1 all array members are used", -2, INT_MAX); /* RNA_NO_INDEX == -1 */
@@ -582,7 +582,7 @@ void RNA_api_ui_layout(StructRNA *srna)
RNA_def_function(srna, "operator_menu_hold", "rna_uiItemOMenuHold") :
RNA_def_function(srna, "operator", "rna_uiItemO");
api_ui_item_op_common(func);
- RNA_def_boolean(func, "emboss", true, "", "Draw the button itself, just the icon/text");
+ RNA_def_boolean(func, "emboss", true, "", "Draw the button itself, not just the icon/text");
RNA_def_boolean(func, "depress", false, "", "Draw pressed in");
parm = RNA_def_property(func, "icon_value", PROP_INT, PROP_UNSIGNED);
RNA_def_property_ui_text(parm, "Icon Value", "Override automatic icon of the item");