-Remove color operator clamping, which is unnecesary. Fixes #15184, fixes #14686.

-Refresh progress bar less often, makes baking, exporting, etc. faster.
This commit is contained in:
Juan Linietsky 2018-01-12 00:08:32 -03:00
parent c48aab2f05
commit 2cde466ebd
5 changed files with 62 additions and 63 deletions

View file

@ -413,96 +413,95 @@ Color::operator String() const {
Color Color::operator+(const Color &p_color) const {
return Color(
CLAMP(r + p_color.r, 0.0, 1.0),
CLAMP(g + p_color.g, 0.0, 1.0),
CLAMP(b + p_color.b, 0.0, 1.0),
CLAMP(a + p_color.a, 0.0, 1.0));
r + p_color.r,
g + p_color.g,
b + p_color.b,
a + p_color.a);
}
void Color::operator+=(const Color &p_color) {
r = CLAMP(r + p_color.r, 0.0, 1.0);
g = CLAMP(g + p_color.g, 0.0, 1.0);
b = CLAMP(b + p_color.b, 0.0, 1.0);
a = CLAMP(a + p_color.a, 0.0, 1.0);
r = r + p_color.r;
g = g + p_color.g;
b = b + p_color.b;
a = a + p_color.a;
}
Color Color::operator-(const Color &p_color) const {
return Color(
CLAMP(r - p_color.r, 0.0, 1.0),
CLAMP(g - p_color.g, 0.0, 1.0),
CLAMP(b - p_color.b, 0.0, 1.0),
CLAMP(a - p_color.a, 0.0, 1.0));
r - p_color.r,
g - p_color.g,
b - p_color.b,
a - p_color.a);
}
void Color::operator-=(const Color &p_color) {
r = CLAMP(r - p_color.r, 0.0, 1.0);
g = CLAMP(g - p_color.g, 0.0, 1.0);
b = CLAMP(b - p_color.b, 0.0, 1.0);
a = CLAMP(a - p_color.a, 0.0, 1.0);
r = r - p_color.r;
g = g - p_color.g;
b = b - p_color.b;
a = a - p_color.a;
}
Color Color::operator*(const Color &p_color) const {
return Color(
CLAMP(r * p_color.r, 0.0, 1.0),
CLAMP(g * p_color.g, 0.0, 1.0),
CLAMP(b * p_color.b, 0.0, 1.0),
CLAMP(a * p_color.a, 0.0, 1.0));
r * p_color.r,
g * p_color.g,
b * p_color.b,
a * p_color.a);
}
Color Color::operator*(const real_t &rvalue) const {
return Color(
CLAMP(r * rvalue, 0.0, 1.0),
CLAMP(g * rvalue, 0.0, 1.0),
CLAMP(b * rvalue, 0.0, 1.0),
CLAMP(a * rvalue, 0.0, 1.0));
r * rvalue,
g * rvalue,
b * rvalue,
a * rvalue);
}
void Color::operator*=(const Color &p_color) {
r = CLAMP(r * p_color.r, 0.0, 1.0);
g = CLAMP(g * p_color.g, 0.0, 1.0);
b = CLAMP(b * p_color.b, 0.0, 1.0);
a = CLAMP(a * p_color.a, 0.0, 1.0);
r = r * p_color.r;
g = g * p_color.g;
b = b * p_color.b;
a = a * p_color.a;
}
void Color::operator*=(const real_t &rvalue) {
r = CLAMP(r * rvalue, 0.0, 1.0);
g = CLAMP(g * rvalue, 0.0, 1.0);
b = CLAMP(b * rvalue, 0.0, 1.0);
a = CLAMP(a * rvalue, 0.0, 1.0);
};
r = r * rvalue;
g = g * rvalue;
b = b * rvalue;
a = a * rvalue;
}
Color Color::operator/(const Color &p_color) const {
return Color(
p_color.r == 0 ? 1 : CLAMP(r / p_color.r, 0.0, 1.0),
p_color.g == 0 ? 1 : CLAMP(g / p_color.g, 0.0, 1.0),
p_color.b == 0 ? 1 : CLAMP(b / p_color.b, 0.0, 1.0),
p_color.a == 0 ? 1 : CLAMP(a / p_color.a, 0.0, 1.0));
r / p_color.r,
g / p_color.g,
b / p_color.b,
a / p_color.a);
}
Color Color::operator/(const real_t &rvalue) const {
if (rvalue == 0) return Color(1.0, 1.0, 1.0, 1.0);
return Color(
CLAMP(r / rvalue, 0.0, 1.0),
CLAMP(g / rvalue, 0.0, 1.0),
CLAMP(b / rvalue, 0.0, 1.0),
CLAMP(a / rvalue, 0.0, 1.0));
r / rvalue,
g / rvalue,
b / rvalue,
a / rvalue);
}
void Color::operator/=(const Color &p_color) {
r = p_color.r == 0 ? 1 : CLAMP(r / p_color.r, 0.0, 1.0);
g = p_color.g == 0 ? 1 : CLAMP(g / p_color.g, 0.0, 1.0);
b = p_color.b == 0 ? 1 : CLAMP(b / p_color.b, 0.0, 1.0);
a = p_color.a == 0 ? 1 : CLAMP(a / p_color.a, 0.0, 1.0);
r = r / p_color.r;
g = g / p_color.g;
b = b / p_color.b;
a = a / p_color.a;
}
void Color::operator/=(const real_t &rvalue) {
@ -513,18 +512,18 @@ void Color::operator/=(const real_t &rvalue) {
b = 1.0;
a = 1.0;
} else {
r = CLAMP(r / rvalue, 0.0, 1.0);
g = CLAMP(g / rvalue, 0.0, 1.0);
b = CLAMP(b / rvalue, 0.0, 1.0);
a = CLAMP(a / rvalue, 0.0, 1.0);
r = r / rvalue;
g = g / rvalue;
b = b / rvalue;
a = a / rvalue;
}
};
Color Color::operator-() const {
return Color(
CLAMP(1.0 - r, 0.0, 1.0),
CLAMP(1.0 - g, 0.0, 1.0),
CLAMP(1.0 - b, 0.0, 1.0),
CLAMP(1.0 - a, 0.0, 1.0));
1.0 - r,
1.0 - g,
1.0 - b,
1.0 - a);
}

View file

@ -105,18 +105,18 @@ struct Color {
_FORCE_INLINE_ Color darkened(float p_amount) const {
Color res = *this;
res.r = CLAMP(res.r * (1.0f - p_amount), 0.0, 1.0);
res.g = CLAMP(res.g * (1.0f - p_amount), 0.0, 1.0);
res.b = CLAMP(res.b * (1.0f - p_amount), 0.0, 1.0);
res.r = res.r * (1.0f - p_amount);
res.g = res.g * (1.0f - p_amount);
res.b = res.b * (1.0f - p_amount);
return res;
}
_FORCE_INLINE_ Color lightened(float p_amount) const {
Color res = *this;
res.r = CLAMP(res.r + (1.0f - res.r) * p_amount, 0.0, 1.0);
res.g = CLAMP(res.g + (1.0f - res.g) * p_amount, 0.0, 1.0);
res.b = CLAMP(res.b + (1.0f - res.b) * p_amount, 0.0, 1.0);
res.r = res.r + (1.0f - res.r) * p_amount;
res.g = res.g + (1.0f - res.g) * p_amount;
res.b = res.b + (1.0f - res.b) * p_amount;
return res;
}

View file

@ -90,7 +90,7 @@ void BakedLightmapEditorPlugin::bake_func_begin(int p_steps) {
bool BakedLightmapEditorPlugin::bake_func_step(int p_step, const String &p_description) {
ERR_FAIL_COND_V(tmp_progress == NULL, false);
return tmp_progress->step(p_description, p_step);
return tmp_progress->step(p_description, p_step, false);
}
void BakedLightmapEditorPlugin::bake_func_end() {

View file

@ -73,7 +73,7 @@ void GIProbeEditorPlugin::bake_func_begin(int p_steps) {
void GIProbeEditorPlugin::bake_func_step(int p_step, const String &p_description) {
ERR_FAIL_COND(tmp_progress == NULL);
tmp_progress->step(p_description, p_step);
tmp_progress->step(p_description, p_step, false);
}
void GIProbeEditorPlugin::bake_func_end() {

View file

@ -200,7 +200,7 @@ bool ProgressDialog::task_step(const String &p_task, const String &p_state, int
if (!p_force_redraw) {
uint64_t tus = OS::get_singleton()->get_ticks_usec();
if (tus - last_progress_tick < 50000) //50ms
if (tus - last_progress_tick < 200000) //200ms
return cancelled;
}