summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/classes/Camera2D.xml2
-rw-r--r--editor/editor_inspector.cpp10
-rw-r--r--editor/editor_spin_slider.cpp79
-rw-r--r--scene/2d/camera_2d.cpp25
-rw-r--r--scene/3d/sprite_3d.cpp24
-rw-r--r--scene/resources/immediate_mesh.cpp16
-rw-r--r--servers/rendering/renderer_rd/renderer_storage_rd.cpp4
-rw-r--r--servers/rendering_server.cpp20
8 files changed, 115 insertions, 65 deletions
diff --git a/doc/classes/Camera2D.xml b/doc/classes/Camera2D.xml
index bf1a9cc929..4620b3d93c 100644
--- a/doc/classes/Camera2D.xml
+++ b/doc/classes/Camera2D.xml
@@ -161,6 +161,8 @@
</member>
<member name="limit_smoothed" type="bool" setter="set_limit_smoothing_enabled" getter="is_limit_smoothing_enabled" default="false">
If [code]true[/code], the camera smoothly stops when reaches its limits.
+ This has no effect if smoothing is disabled.
+ [b]Note:[/b] To immediately update the camera's position to be within limits without smoothing, even with this setting enabled, invoke [method reset_smoothing].
</member>
<member name="limit_top" type="int" setter="set_limit" getter="get_limit" default="-10000000">
Top scroll limit in pixels. The camera stops moving when reaching this value.
diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp
index cfce37ea1b..e6c4c14830 100644
--- a/editor/editor_inspector.cpp
+++ b/editor/editor_inspector.cpp
@@ -1182,15 +1182,19 @@ void EditorInspectorSection::_notification(int p_what) {
Size2 size = get_size();
Point2 offset;
+ Rect2 rect;
offset.y = font->get_height(font_size);
if (arrow.is_valid()) {
offset.y = MAX(offset.y, arrow->get_height());
}
offset.y += get_theme_constant("vseparation", "Tree");
- offset.x += get_theme_constant("inspector_margin", "Editor");
-
- Rect2 rect(offset, size - offset);
+ if (is_layout_rtl()) {
+ rect = Rect2(offset, size - offset - Vector2(get_theme_constant("inspector_margin", "Editor"), 0));
+ } else {
+ offset.x += get_theme_constant("inspector_margin", "Editor");
+ rect = Rect2(offset, size - offset);
+ }
//set children
for (int i = 0; i < get_child_count(); i++) {
diff --git a/editor/editor_spin_slider.cpp b/editor/editor_spin_slider.cpp
index c1540f2cdd..aa4a394d30 100644
--- a/editor/editor_spin_slider.cpp
+++ b/editor/editor_spin_slider.cpp
@@ -206,24 +206,34 @@ void EditorSpinSlider::_notification(int p_what) {
// EditorSpinSliders with a label have more space on the left, so add an
// higher margin to match the location where the text begins.
// The margin values below were determined by empirical testing.
- stylebox->set_default_margin(SIDE_LEFT, (get_label() != String() ? 23 : 16) * EDSCALE);
+ if (is_layout_rtl()) {
+ stylebox->set_default_margin(SIDE_LEFT, 0);
+ stylebox->set_default_margin(SIDE_RIGHT, (get_label() != String() ? 23 : 16) * EDSCALE);
+ } else {
+ stylebox->set_default_margin(SIDE_LEFT, (get_label() != String() ? 23 : 16) * EDSCALE);
+ stylebox->set_default_margin(SIDE_RIGHT, 0);
+ }
value_input->add_theme_style_override("normal", stylebox);
}
if (p_what == NOTIFICATION_DRAW) {
updown_offset = -1;
+ RID ci = get_canvas_item();
+ bool rtl = is_layout_rtl();
+ Vector2 size = get_size();
+
Ref<StyleBox> sb = get_theme_stylebox("normal", "LineEdit");
if (!flat) {
- draw_style_box(sb, Rect2(Vector2(), get_size()));
+ draw_style_box(sb, Rect2(Vector2(), size));
}
Ref<Font> font = get_theme_font("font", "LineEdit");
int font_size = get_theme_font_size("font_size", "LineEdit");
int sep_base = 4 * EDSCALE;
int sep = sep_base + sb->get_offset().x; //make it have the same margin on both sides, looks better
- int string_width = font->get_string_size(label, font_size).width;
- int number_width = get_size().width - sb->get_minimum_size().width - string_width - sep;
+ int label_width = font->get_string_size(label, font_size).width;
+ int number_width = size.width - sb->get_minimum_size().width - label_width - sep;
Ref<Texture2D> updown = get_theme_icon("updown", "SpinBox");
@@ -233,7 +243,7 @@ void EditorSpinSlider::_notification(int p_what) {
String numstr = get_text_value();
- int vofs = (get_size().height - font->get_height(font_size)) / 2 + font->get_ascent(font_size);
+ int vofs = (size.height - font->get_height(font_size)) / 2 + font->get_ascent(font_size);
Color fc = get_theme_color("font_color", "LineEdit");
Color lc;
@@ -245,30 +255,59 @@ void EditorSpinSlider::_notification(int p_what) {
if (flat && label != String()) {
Color label_bg_color = get_theme_color("dark_color_3", "Editor");
- draw_rect(Rect2(Vector2(), Vector2(sb->get_offset().x * 2 + string_width, get_size().height)), label_bg_color);
+ if (rtl) {
+ draw_rect(Rect2(Vector2(size.width - (sb->get_offset().x * 2 + label_width), 0), Vector2(sb->get_offset().x * 2 + label_width, size.height)), label_bg_color);
+ } else {
+ draw_rect(Rect2(Vector2(), Vector2(sb->get_offset().x * 2 + label_width, size.height)), label_bg_color);
+ }
}
if (has_focus()) {
Ref<StyleBox> focus = get_theme_stylebox("focus", "LineEdit");
- draw_style_box(focus, Rect2(Vector2(), get_size()));
+ draw_style_box(focus, Rect2(Vector2(), size));
}
- draw_string(font, Vector2(Math::round(sb->get_offset().x), vofs), label, HALIGN_LEFT, -1, font_size, lc * Color(1, 1, 1, 0.5));
-
- Vector2 text_ofs = Vector2(Math::round(sb->get_offset().x + string_width + sep), vofs);
- draw_string(font, text_ofs, numstr, HALIGN_LEFT, number_width, font_size, fc);
+ if (rtl) {
+ draw_string(font, Vector2(Math::round(size.width - sb->get_offset().x - label_width), vofs), label, HALIGN_RIGHT, -1, font_size, lc * Color(1, 1, 1, 0.5));
+ } else {
+ draw_string(font, Vector2(Math::round(sb->get_offset().x), vofs), label, HALIGN_LEFT, -1, font_size, lc * Color(1, 1, 1, 0.5));
+ }
- if (suffix != String()) {
- int sw = font->get_string_size(numstr).width;
- text_ofs.x += sw;
- fc.a *= 0.4;
- draw_string(font, text_ofs, suffix, HALIGN_LEFT, MAX(0, number_width - sw), font_size, fc);
+ int suffix_start = numstr.length();
+ RID num_rid = TS->create_shaped_text();
+ TS->shaped_text_add_string(num_rid, numstr + U"\u2009" + suffix, font->get_rids(), font_size);
+
+ float text_start = rtl ? Math::round(sb->get_offset().x) : Math::round(sb->get_offset().x + label_width + sep);
+ Vector2 text_ofs = rtl ? Vector2(text_start + (number_width - TS->shaped_text_get_width(num_rid)), vofs) : Vector2(text_start, vofs);
+ const Vector<TextServer::Glyph> visual = TS->shaped_text_get_glyphs(num_rid);
+ int v_size = visual.size();
+ const TextServer::Glyph *glyphs = visual.ptr();
+ for (int i = 0; i < v_size; i++) {
+ for (int j = 0; j < glyphs[i].repeat; j++) {
+ if (text_ofs.x >= text_start && (text_ofs.x + glyphs[i].advance) <= (text_start + number_width)) {
+ Color color = fc;
+ if (glyphs[i].start >= suffix_start) {
+ color.a *= 0.4;
+ }
+ if (glyphs[i].font_rid != RID()) {
+ TS->font_draw_glyph(glyphs[i].font_rid, ci, glyphs[i].font_size, text_ofs + Vector2(glyphs[i].x_off, glyphs[i].y_off), glyphs[i].index, color);
+ } else if ((glyphs[i].flags & TextServer::GRAPHEME_IS_VIRTUAL) != TextServer::GRAPHEME_IS_VIRTUAL) {
+ TS->draw_hex_code_box(ci, glyphs[i].font_size, text_ofs + Vector2(glyphs[i].x_off, glyphs[i].y_off), glyphs[i].index, color);
+ }
+ }
+ text_ofs.x += glyphs[i].advance;
+ }
}
+ TS->free(num_rid);
if (get_step() == 1) {
Ref<Texture2D> updown2 = get_theme_icon("updown", "SpinBox");
- int updown_vofs = (get_size().height - updown2->get_height()) / 2;
- updown_offset = get_size().width - sb->get_margin(SIDE_RIGHT) - updown2->get_width();
+ int updown_vofs = (size.height - updown2->get_height()) / 2;
+ if (rtl) {
+ updown_offset = sb->get_margin(SIDE_LEFT);
+ } else {
+ updown_offset = size.width - sb->get_margin(SIDE_RIGHT) - updown2->get_width();
+ }
Color c(1, 1, 1);
if (hover_updown) {
c *= Color(1.2, 1.2, 1.2);
@@ -279,9 +318,9 @@ void EditorSpinSlider::_notification(int p_what) {
}
} else if (!hide_slider) {
int grabber_w = 4 * EDSCALE;
- int width = get_size().width - sb->get_minimum_size().width - grabber_w;
+ int width = size.width - sb->get_minimum_size().width - grabber_w;
int ofs = sb->get_offset().x;
- int svofs = (get_size().height + vofs) / 2 - 1;
+ int svofs = (size.height + vofs) / 2 - 1;
Color c = fc;
c.a = 0.2;
diff --git a/scene/2d/camera_2d.cpp b/scene/2d/camera_2d.cpp
index 926997a715..f293081987 100644
--- a/scene/2d/camera_2d.cpp
+++ b/scene/2d/camera_2d.cpp
@@ -178,20 +178,23 @@ Transform2D Camera2D::get_camera_transform() {
}
Rect2 screen_rect(-screen_offset + ret_camera_pos, screen_size * zoom);
- if (screen_rect.position.x < limit[SIDE_LEFT]) {
- screen_rect.position.x = limit[SIDE_LEFT];
- }
- if (screen_rect.position.x + screen_rect.size.x > limit[SIDE_RIGHT]) {
- screen_rect.position.x = limit[SIDE_RIGHT] - screen_rect.size.x;
- }
+ if (!limit_smoothing_enabled) {
+ if (screen_rect.position.x < limit[SIDE_LEFT]) {
+ screen_rect.position.x = limit[SIDE_LEFT];
+ }
- if (screen_rect.position.y + screen_rect.size.y > limit[SIDE_BOTTOM]) {
- screen_rect.position.y = limit[SIDE_BOTTOM] - screen_rect.size.y;
- }
+ if (screen_rect.position.x + screen_rect.size.x > limit[SIDE_RIGHT]) {
+ screen_rect.position.x = limit[SIDE_RIGHT] - screen_rect.size.x;
+ }
+
+ if (screen_rect.position.y + screen_rect.size.y > limit[SIDE_BOTTOM]) {
+ screen_rect.position.y = limit[SIDE_BOTTOM] - screen_rect.size.y;
+ }
- if (screen_rect.position.y < limit[SIDE_TOP]) {
- screen_rect.position.y = limit[SIDE_TOP];
+ if (screen_rect.position.y < limit[SIDE_TOP]) {
+ screen_rect.position.y = limit[SIDE_TOP];
+ }
}
if (offset != Vector2()) {
diff --git a/scene/3d/sprite_3d.cpp b/scene/3d/sprite_3d.cpp
index 8a79b03ad4..13f8002721 100644
--- a/scene/3d/sprite_3d.cpp
+++ b/scene/3d/sprite_3d.cpp
@@ -565,11 +565,11 @@ void Sprite3D::_draw() {
v_tangent = value;
}
- uint16_t v_color[4] = {
- Math::make_half_float(color.r),
- Math::make_half_float(color.g),
- Math::make_half_float(color.b),
- Math::make_half_float(color.a),
+ uint8_t v_color[4] = {
+ uint8_t(CLAMP(color.r * 255.0, 0.0, 255.0)),
+ uint8_t(CLAMP(color.g * 255.0, 0.0, 255.0)),
+ uint8_t(CLAMP(color.b * 255.0, 0.0, 255.0)),
+ uint8_t(CLAMP(color.a * 255.0, 0.0, 255.0))
};
for (int i = 0; i < 4; i++) {
@@ -591,7 +591,7 @@ void Sprite3D::_draw() {
memcpy(&vertex_write_buffer[i * vertex_stride + mesh_surface_offsets[RS::ARRAY_VERTEX]], &v_vertex, sizeof(float) * 3);
memcpy(&vertex_write_buffer[i * vertex_stride + mesh_surface_offsets[RS::ARRAY_NORMAL]], &v_normal, 4);
memcpy(&vertex_write_buffer[i * vertex_stride + mesh_surface_offsets[RS::ARRAY_TANGENT]], &v_tangent, 4);
- memcpy(&attribute_write_buffer[i * attrib_stride + mesh_surface_offsets[RS::ARRAY_COLOR]], v_color, 8);
+ memcpy(&attribute_write_buffer[i * attrib_stride + mesh_surface_offsets[RS::ARRAY_COLOR]], v_color, 4);
}
RID mesh = get_mesh();
@@ -931,11 +931,11 @@ void AnimatedSprite3D::_draw() {
v_tangent = value;
}
- uint16_t v_color[4] = {
- Math::make_half_float(color.r),
- Math::make_half_float(color.g),
- Math::make_half_float(color.b),
- Math::make_half_float(color.a),
+ uint8_t v_color[4] = {
+ uint8_t(CLAMP(color.r * 255.0, 0.0, 255.0)),
+ uint8_t(CLAMP(color.g * 255.0, 0.0, 255.0)),
+ uint8_t(CLAMP(color.b * 255.0, 0.0, 255.0)),
+ uint8_t(CLAMP(color.a * 255.0, 0.0, 255.0))
};
for (int i = 0; i < 4; i++) {
@@ -956,7 +956,7 @@ void AnimatedSprite3D::_draw() {
memcpy(&vertex_write_buffer[i * vertex_stride + mesh_surface_offsets[RS::ARRAY_VERTEX]], &v_vertex, sizeof(float) * 3);
memcpy(&vertex_write_buffer[i * vertex_stride + mesh_surface_offsets[RS::ARRAY_NORMAL]], &v_normal, 4);
memcpy(&vertex_write_buffer[i * vertex_stride + mesh_surface_offsets[RS::ARRAY_TANGENT]], &v_tangent, 4);
- memcpy(&attribute_write_buffer[i * attrib_stride + mesh_surface_offsets[RS::ARRAY_COLOR]], v_color, 8);
+ memcpy(&attribute_write_buffer[i * attrib_stride + mesh_surface_offsets[RS::ARRAY_COLOR]], v_color, 4);
}
RID mesh = get_mesh();
diff --git a/scene/resources/immediate_mesh.cpp b/scene/resources/immediate_mesh.cpp
index 95de85aeba..ebe65605f8 100644
--- a/scene/resources/immediate_mesh.cpp
+++ b/scene/resources/immediate_mesh.cpp
@@ -223,7 +223,7 @@ void ImmediateMesh::surface_end() {
if (uses_colors) {
format |= ARRAY_FORMAT_COLOR;
- attribute_stride += sizeof(uint16_t) * 4;
+ attribute_stride += sizeof(uint8_t) * 4;
}
uint32_t uv_offset = 0;
if (uses_uvs) {
@@ -244,25 +244,25 @@ void ImmediateMesh::surface_end() {
for (uint32_t i = 0; i < vertices.size(); i++) {
if (uses_colors) {
- uint16_t *color16 = (uint16_t *)&surface_attribute_ptr[i * attribute_stride];
+ uint8_t *color8 = (uint8_t *)&surface_attribute_ptr[i * attribute_stride];
- color16[0] = Math::make_half_float(colors[i].r);
- color16[1] = Math::make_half_float(colors[i].g);
- color16[2] = Math::make_half_float(colors[i].b);
- color16[3] = Math::make_half_float(colors[i].a);
+ color8[0] = uint8_t(CLAMP(colors[i].r * 255.0, 0.0, 255.0));
+ color8[1] = uint8_t(CLAMP(colors[i].g * 255.0, 0.0, 255.0));
+ color8[2] = uint8_t(CLAMP(colors[i].b * 255.0, 0.0, 255.0));
+ color8[3] = uint8_t(CLAMP(colors[i].a * 255.0, 0.0, 255.0));
}
if (uses_uvs) {
float *uv = (float *)&surface_attribute_ptr[i * attribute_stride + uv_offset];
uv[0] = uvs[i].x;
- uv[0] = uvs[i].y;
+ uv[1] = uvs[i].y;
}
if (uses_uv2s) {
float *uv2 = (float *)&surface_attribute_ptr[i * attribute_stride + uv2_offset];
uv2[0] = uv2s[i].x;
- uv2[0] = uv2s[i].y;
+ uv2[1] = uv2s[i].y;
}
}
}
diff --git a/servers/rendering/renderer_rd/renderer_storage_rd.cpp b/servers/rendering/renderer_rd/renderer_storage_rd.cpp
index ee6fee6142..1db81d8584 100644
--- a/servers/rendering/renderer_rd/renderer_storage_rd.cpp
+++ b/servers/rendering/renderer_rd/renderer_storage_rd.cpp
@@ -3258,8 +3258,8 @@ void RendererStorageRD::_mesh_surface_generate_version_for_input_mask(Mesh::Surf
case RS::ARRAY_COLOR: {
vd.offset = attribute_stride;
- vd.format = RD::DATA_FORMAT_R16G16B16A16_SFLOAT;
- attribute_stride += sizeof(int16_t) * 4;
+ vd.format = RD::DATA_FORMAT_R8G8B8A8_UNORM;
+ attribute_stride += sizeof(int8_t) * 4;
buffer = s->attribute_buffer;
} break;
case RS::ARRAY_TEX_UV: {
diff --git a/servers/rendering_server.cpp b/servers/rendering_server.cpp
index b7e20631c9..75ae850acb 100644
--- a/servers/rendering_server.cpp
+++ b/servers/rendering_server.cpp
@@ -438,13 +438,14 @@ Error RenderingServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint
ERR_FAIL_COND_V(array.size() != p_vertex_array_len, ERR_INVALID_PARAMETER);
const Color *src = array.ptr();
- uint16_t color16[4];
for (int i = 0; i < p_vertex_array_len; i++) {
- color16[0] = Math::make_half_float(src[i].r);
- color16[1] = Math::make_half_float(src[i].g);
- color16[2] = Math::make_half_float(src[i].b);
- color16[3] = Math::make_half_float(src[i].a);
- memcpy(&aw[p_offsets[ai] + i * p_attrib_stride], color16, 8);
+ uint8_t color8[4] = {
+ uint8_t(CLAMP(src[i].r * 255.0, 0.0, 255.0)),
+ uint8_t(CLAMP(src[i].g * 255.0, 0.0, 255.0)),
+ uint8_t(CLAMP(src[i].b * 255.0, 0.0, 255.0)),
+ uint8_t(CLAMP(src[i].a * 255.0, 0.0, 255.0))
+ };
+ memcpy(&aw[p_offsets[ai] + i * p_attrib_stride], color8, 4);
}
} break;
case RS::ARRAY_TEX_UV: {
@@ -761,7 +762,7 @@ void RenderingServer::mesh_surface_make_offsets_from_format(uint32_t p_format, i
elem_size = 4;
} break;
case RS::ARRAY_COLOR: {
- elem_size = 8;
+ elem_size = 4;
} break;
case RS::ARRAY_TEX_UV: {
elem_size = 8;
@@ -1123,8 +1124,9 @@ Array RenderingServer::_get_array_from_surface(uint32_t p_format, Vector<uint8_t
Color *w = arr.ptrw();
for (int32_t j = 0; j < p_vertex_len; j++) {
- const uint16_t *v = (const uint16_t *)&ar[j * attrib_elem_size + offsets[i]];
- w[j] = Color(Math::half_to_float(v[0]), Math::half_to_float(v[1]), Math::half_to_float(v[2]), Math::half_to_float(v[3]));
+ const uint8_t *v = (const uint8_t *)&ar[j * attrib_elem_size + offsets[i]];
+
+ w[j] = Color(v[0] / 255.0, v[1] / 255.0, v[2] / 255.0, v[3] / 255.0);
}
ret[i] = arr;