Code simplifications
1. Viewport::get_visible_rect().position is always zero. So Control::get_window_rect is identical to Control::get_global_rect. Remove Control::get_window_rect since it is not used in the source code. 2. sqrt(a * a) = abs(a) for doubles 3. Simplify affine_inverse combination 4. Simplify calculation in shaders
This commit is contained in:
parent
2e3662acbd
commit
b8031bb7d6
|
@ -1367,7 +1367,7 @@ void ColorPicker::_screen_input(const Ref<InputEvent> &p_event) {
|
||||||
|
|
||||||
Ref<Image> img = r->get_texture()->get_image();
|
Ref<Image> img = r->get_texture()->get_image();
|
||||||
if (img.is_valid() && !img->is_empty()) {
|
if (img.is_valid() && !img->is_empty()) {
|
||||||
Vector2 ofs = mev->get_global_position() - r->get_visible_rect().get_position();
|
Vector2 ofs = mev->get_global_position();
|
||||||
Color c = img->get_pixel(ofs.x, ofs.y);
|
Color c = img->get_pixel(ofs.x, ofs.y);
|
||||||
|
|
||||||
set_pick_color(c);
|
set_pick_color(c);
|
||||||
|
|
|
@ -1436,13 +1436,6 @@ Rect2 Control::get_screen_rect() const {
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
Rect2 Control::get_window_rect() const {
|
|
||||||
ERR_FAIL_COND_V(!is_inside_tree(), Rect2());
|
|
||||||
Rect2 gr = get_global_rect();
|
|
||||||
gr.position += get_viewport()->get_visible_rect().position;
|
|
||||||
return gr;
|
|
||||||
}
|
|
||||||
|
|
||||||
Rect2 Control::get_anchorable_rect() const {
|
Rect2 Control::get_anchorable_rect() const {
|
||||||
return Rect2(Point2(), get_size());
|
return Rect2(Point2(), get_size());
|
||||||
}
|
}
|
||||||
|
|
|
@ -445,7 +445,6 @@ public:
|
||||||
Rect2 get_rect() const;
|
Rect2 get_rect() const;
|
||||||
Rect2 get_global_rect() const;
|
Rect2 get_global_rect() const;
|
||||||
Rect2 get_screen_rect() const;
|
Rect2 get_screen_rect() const;
|
||||||
Rect2 get_window_rect() const; ///< use with care, as it blocks waiting for the rendering server
|
|
||||||
Rect2 get_anchorable_rect() const override;
|
Rect2 get_anchorable_rect() const override;
|
||||||
|
|
||||||
void set_scale(const Vector2 &p_scale);
|
void set_scale(const Vector2 &p_scale);
|
||||||
|
|
|
@ -338,7 +338,7 @@ void ScrollBar::_notification(int p_what) {
|
||||||
if (scrolling) {
|
if (scrolling) {
|
||||||
if (get_value() != target_scroll) {
|
if (get_value() != target_scroll) {
|
||||||
double target = target_scroll - get_value();
|
double target = target_scroll - get_value();
|
||||||
double dist = sqrt(target * target);
|
double dist = abs(target);
|
||||||
double vel = ((target / dist) * 500) * get_physics_process_delta_time();
|
double vel = ((target / dist) * 500) * get_physics_process_delta_time();
|
||||||
|
|
||||||
if (Math::abs(vel) >= dist) {
|
if (Math::abs(vel) >= dist) {
|
||||||
|
|
|
@ -464,7 +464,7 @@ void TextEdit::_notification(int p_what) {
|
||||||
case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: {
|
case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: {
|
||||||
if (scrolling && get_v_scroll() != target_v_scroll) {
|
if (scrolling && get_v_scroll() != target_v_scroll) {
|
||||||
double target_y = target_v_scroll - get_v_scroll();
|
double target_y = target_v_scroll - get_v_scroll();
|
||||||
double dist = sqrt(target_y * target_y);
|
double dist = abs(target_y);
|
||||||
// To ensure minimap is responsive override the speed setting.
|
// To ensure minimap is responsive override the speed setting.
|
||||||
double vel = ((target_y / dist) * ((minimap_clicked) ? 3000 : v_scroll_speed)) * get_physics_process_delta_time();
|
double vel = ((target_y / dist) * ((minimap_clicked) ? 3000 : v_scroll_speed)) * get_physics_process_delta_time();
|
||||||
|
|
||||||
|
|
|
@ -2866,7 +2866,8 @@ void GI::VoxelGIInstance::update(bool p_update_light_instances, const Vector<RID
|
||||||
|
|
||||||
{
|
{
|
||||||
Transform3D to_cell = gi->voxel_gi_get_to_cell_xform(probe);
|
Transform3D to_cell = gi->voxel_gi_get_to_cell_xform(probe);
|
||||||
Transform3D to_probe_xform = (transform * to_cell.affine_inverse()).affine_inverse();
|
Transform3D to_probe_xform = to_cell * transform.affine_inverse();
|
||||||
|
|
||||||
//update lights
|
//update lights
|
||||||
|
|
||||||
for (uint32_t i = 0; i < light_count; i++) {
|
for (uint32_t i = 0; i < light_count; i++) {
|
||||||
|
|
|
@ -655,20 +655,7 @@ void main() {
|
||||||
if (i >= light_count) {
|
if (i >= light_count) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
uint light_base;
|
uint light_base = draw_data.lights[i >> 2];
|
||||||
if (i < 8) {
|
|
||||||
if (i < 4) {
|
|
||||||
light_base = draw_data.lights[0];
|
|
||||||
} else {
|
|
||||||
light_base = draw_data.lights[1];
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (i < 12) {
|
|
||||||
light_base = draw_data.lights[2];
|
|
||||||
} else {
|
|
||||||
light_base = draw_data.lights[3];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
light_base >>= (i & 3) * 8;
|
light_base >>= (i & 3) * 8;
|
||||||
light_base &= 0xFF;
|
light_base &= 0xFF;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue