Merge branch 'master' into blender2.8

This commit is contained in:
2017-12-13 14:24:44 +01:00
7 changed files with 97 additions and 33 deletions

View File

@@ -10,16 +10,17 @@ def run(cmd):
BASEDIR = os.path.abspath(os.path.dirname(__file__)) + os.sep
inkscape_path = 'inkscape'
inkscape_bin = "inkscape"
blender_bin = "blender"
if sys.platform == 'darwin':
inkscape_app_path = '/Applications/Inkscape.app/Contents/Resources/script'
if os.path.exists(inkscape_app_path):
inkscape_path = inkscape_app_path
inkscape_bin = inkscape_app_path
cmd = inkscape_path + ' "%sblender_icons.svg" --export-dpi=90 --without-gui --export-png="%sblender_icons16.png"' % (BASEDIR, BASEDIR)
cmd = inkscape_bin + ' "%sblender_icons.svg" --export-width=602 --export-height=640 --without-gui --export-png="%sblender_icons16.png"' % (BASEDIR, BASEDIR)
run(cmd)
cmd = inkscape_path + ' "%sblender_icons.svg" --export-dpi=180 --without-gui --export-png="%sblender_icons32.png"' % (BASEDIR, BASEDIR)
cmd = inkscape_bin + ' "%sblender_icons.svg" --export-width=1204 --export-height=1280 --without-gui --export-png="%sblender_icons32.png"' % (BASEDIR, BASEDIR)
run(cmd)
@@ -31,7 +32,7 @@ datatoc_icon_split_py = os.path.join(BASEDIR, "..", "..", "source", "blender", "
# create .dat pixmaps (which are stored in git)
cmd = (
"blender "
blender_bin + " "
"--background -noaudio "
"--python " + datatoc_icon_split_py + " -- "
"--image=" + BASEDIR + "blender_icons16.png "
@@ -46,7 +47,7 @@ cmd = (
run(cmd)
cmd = (
"blender "
blender_bin + " "
"--background -noaudio "
"--python " + datatoc_icon_split_py + " -- "
"--image=" + BASEDIR + "blender_icons32.png "

View File

@@ -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);

View File

@@ -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);
}
}

View File

@@ -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");
}
}
}

View File

@@ -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);
}

View File

@@ -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;

View File

@@ -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");