summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
Diffstat (limited to 'scene')
-rw-r--r--scene/gui/file_dialog.cpp31
-rw-r--r--scene/gui/file_dialog.h1
-rw-r--r--scene/gui/rich_text_label.cpp3
-rw-r--r--scene/main/viewport.cpp63
-rw-r--r--scene/main/viewport.h13
-rw-r--r--scene/resources/material.cpp5
-rw-r--r--scene/resources/material.h1
7 files changed, 89 insertions, 28 deletions
diff --git a/scene/gui/file_dialog.cpp b/scene/gui/file_dialog.cpp
index 6be74d8d29..905af399b3 100644
--- a/scene/gui/file_dialog.cpp
+++ b/scene/gui/file_dialog.cpp
@@ -46,9 +46,9 @@ VBoxContainer *FileDialog::get_vbox() {
void FileDialog::_theme_changed() {
- Color font_color = vbc->get_theme_color("font_color", "ToolButton");
- Color font_color_hover = vbc->get_theme_color("font_color_hover", "ToolButton");
- Color font_color_pressed = vbc->get_theme_color("font_color_pressed", "ToolButton");
+ Color font_color = vbox->get_theme_color("font_color", "ToolButton");
+ Color font_color_hover = vbox->get_theme_color("font_color_hover", "ToolButton");
+ Color font_color_pressed = vbox->get_theme_color("font_color_pressed", "ToolButton");
dir_up->add_theme_color_override("icon_color_normal", font_color);
dir_up->add_theme_color_override("icon_color_hover", font_color_hover);
@@ -73,9 +73,9 @@ void FileDialog::_notification(int p_what) {
}
if (p_what == NOTIFICATION_ENTER_TREE) {
- dir_up->set_icon(vbc->get_theme_icon("parent_folder"));
- refresh->set_icon(vbc->get_theme_icon("reload"));
- show_hidden->set_icon(vbc->get_theme_icon("toggle_hidden"));
+ dir_up->set_icon(vbox->get_theme_icon("parent_folder", "FileDialog"));
+ refresh->set_icon(vbox->get_theme_icon("reload", "FileDialog"));
+ show_hidden->set_icon(vbox->get_theme_icon("toggle_hidden", "FileDialog"));
_theme_changed();
}
}
@@ -429,8 +429,8 @@ void FileDialog::update_file_list() {
dir_access->list_dir_begin();
TreeItem *root = tree->create_item();
- Ref<Texture2D> folder = vbc->get_theme_icon("folder");
- const Color folder_color = vbc->get_theme_color("folder_icon_modulate");
+ Ref<Texture2D> folder = vbox->get_theme_icon("folder", "FileDialog");
+ const Color folder_color = vbox->get_theme_color("folder_icon_modulate", "FileDialog");
List<String> files;
List<String> dirs;
@@ -528,7 +528,7 @@ void FileDialog::update_file_list() {
}
if (mode == FILE_MODE_OPEN_DIR) {
- ti->set_custom_color(0, vbc->get_theme_color("files_disabled"));
+ ti->set_custom_color(0, vbox->get_theme_color("files_disabled", "FileDialog"));
ti->set_selectable(0, false);
}
Dictionary d;
@@ -888,9 +888,9 @@ FileDialog::FileDialog() {
mode_overrides_title = true;
- vbc = memnew(VBoxContainer);
- add_child(vbc);
- vbc->connect("theme_changed", callable_mp(this, &FileDialog::_theme_changed));
+ vbox = memnew(VBoxContainer);
+ add_child(vbox);
+ vbox->connect("theme_changed", callable_mp(this, &FileDialog::_theme_changed));
mode = FILE_MODE_SAVE_FILE;
set_title(RTR("Save a File"));
@@ -933,11 +933,11 @@ FileDialog::FileDialog() {
makedir->set_text(RTR("Create Folder"));
makedir->connect("pressed", callable_mp(this, &FileDialog::_make_dir));
hbc->add_child(makedir);
- vbc->add_child(hbc);
+ vbox->add_child(hbc);
tree = memnew(Tree);
tree->set_hide_root(true);
- vbc->add_margin_child(RTR("Directories & Files:"), tree, true);
+ vbox->add_margin_child(RTR("Directories & Files:"), tree, true);
file_box = memnew(HBoxContainer);
file_box->add_child(memnew(Label(RTR("File:"))));
@@ -950,7 +950,7 @@ FileDialog::FileDialog() {
filter->set_h_size_flags(Control::SIZE_EXPAND_FILL);
filter->set_clip_text(true); // too many extensions overflows it
file_box->add_child(filter);
- vbc->add_child(file_box);
+ vbox->add_child(file_box);
dir_access = DirAccess::create(DirAccess::ACCESS_RESOURCES);
access = ACCESS_RESOURCES;
@@ -993,7 +993,6 @@ FileDialog::FileDialog() {
update_dir();
set_hide_on_ok(false);
- vbox = vbc;
invalidated = true;
if (register_func)
diff --git a/scene/gui/file_dialog.h b/scene/gui/file_dialog.h
index 295ae023d1..6faf02d55d 100644
--- a/scene/gui/file_dialog.h
+++ b/scene/gui/file_dialog.h
@@ -70,7 +70,6 @@ private:
ConfirmationDialog *makedialog;
LineEdit *makedirname;
- VBoxContainer *vbc;
Button *makedir;
Access access;
//Button *action;
diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp
index 5fb2243aff..3ab5e5427d 100644
--- a/scene/gui/rich_text_label.cpp
+++ b/scene/gui/rich_text_label.cpp
@@ -582,13 +582,14 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &
} else {
cw = drawer.draw_char(ci, p_ofs + Point2(align_ofs + pofs, y + lh - line_descent) + fx_offset, fx_char, c[i + 1], fx_color);
}
- } else if (previously_visible) {
+ } else if (previously_visible && c[i] != '\t') {
backtrack += font->get_char_size(fx_char, c[i + 1]).x;
}
p_char_count++;
if (c[i] == '\t') {
cw = tab_size * font->get_char_size(' ').width;
+ backtrack = MAX(0, backtrack - cw);
}
ofs += cw;
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp
index 5fcd4bf009..06d6e81786 100644
--- a/scene/main/viewport.cpp
+++ b/scene/main/viewport.cpp
@@ -879,13 +879,14 @@ void Viewport::update_canvas_items() {
_update_canvas_items(this);
}
-void Viewport::_set_size(const Size2i &p_size, const Size2i &p_size_override, const Rect2i &p_to_screen_rect, const Transform2D &p_stretch_transform, bool p_allocated) {
+void Viewport::_set_size(const Size2i &p_size, const Size2i &p_size_2d_override, const Rect2i &p_to_screen_rect, const Transform2D &p_stretch_transform, bool p_allocated) {
- if (size == p_size && size_allocated == p_allocated && stretch_transform == p_stretch_transform && p_size_override == size_override && to_screen_rect != p_to_screen_rect)
+ if (size == p_size && size_allocated == p_allocated && stretch_transform == p_stretch_transform && p_size_2d_override == size_2d_override && to_screen_rect != p_to_screen_rect)
return;
+
size = p_size;
size_allocated = p_allocated;
- size_override = p_size_override;
+ size_2d_override = p_size_2d_override;
stretch_transform = p_stretch_transform;
to_screen_rect = p_to_screen_rect;
@@ -904,6 +905,9 @@ void Viewport::_set_size(const Size2i &p_size, const Size2i &p_size_override, co
Size2i Viewport::_get_size() const {
return size;
}
+Size2i Viewport::_get_size_2d_override() const {
+ return size_2d_override;
+}
bool Viewport::_is_size_allocated() const {
return size_allocated;
}
@@ -918,8 +922,8 @@ Rect2 Viewport::get_visible_rect() const {
r = Rect2(Point2(), size);
}
- if (size_override != Size2i()) {
- r.size = size_override;
+ if (size_2d_override != Size2i()) {
+ r.size = size_2d_override;
}
return r;
@@ -3614,18 +3618,40 @@ void SubViewport::set_use_arvr(bool p_use_arvr) {
RS::get_singleton()->viewport_set_use_arvr(get_viewport_rid(), arvr);
}
-
bool SubViewport::is_using_arvr() {
return arvr;
}
void SubViewport::set_size(const Size2i &p_size) {
- _set_size(p_size, Size2i(), Rect2i(), Transform2D(), true);
+ _set_size(p_size, _get_size_2d_override(), Rect2i(), _stretch_transform(), true);
}
Size2i SubViewport::get_size() const {
return _get_size();
}
+void SubViewport::set_size_2d_override(const Size2i &p_size) {
+
+ _set_size(_get_size(), p_size, Rect2i(), _stretch_transform(), true);
+}
+Size2i SubViewport::get_size_2d_override() const {
+
+ return _get_size_2d_override();
+}
+
+void SubViewport::set_size_2d_override_stretch(bool p_enable) {
+
+ if (p_enable == size_2d_override_stretch) {
+ return;
+ }
+
+ size_2d_override_stretch = p_enable;
+ _set_size(_get_size(), _get_size_2d_override(), Rect2i(), _stretch_transform(), true);
+}
+bool SubViewport::is_size_2d_override_stretch_enabled() const {
+
+ return size_2d_override_stretch;
+}
+
void SubViewport::set_update_mode(UpdateMode p_mode) {
update_mode = p_mode;
@@ -3641,7 +3667,6 @@ void SubViewport::set_clear_mode(ClearMode p_mode) {
clear_mode = p_mode;
RS::get_singleton()->viewport_set_clear_mode(get_viewport_rid(), RS::ViewportClearMode(p_mode));
}
-
SubViewport::ClearMode SubViewport::get_clear_mode() const {
return clear_mode;
@@ -3651,6 +3676,18 @@ DisplayServer::WindowID SubViewport::get_window_id() const {
return DisplayServer::INVALID_WINDOW_ID;
}
+Transform2D SubViewport::_stretch_transform() {
+
+ Transform2D transform = Transform2D();
+ Size2i view_size_2d_override = _get_size_2d_override();
+ if (size_2d_override_stretch && view_size_2d_override.width > 0 && view_size_2d_override.height > 0) {
+ Size2 scale = _get_size() / view_size_2d_override;
+ transform.scale(scale);
+ }
+
+ return transform;
+}
+
void SubViewport::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE) {
@@ -3668,6 +3705,12 @@ void SubViewport::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_size", "size"), &SubViewport::set_size);
ClassDB::bind_method(D_METHOD("get_size"), &SubViewport::get_size);
+ ClassDB::bind_method(D_METHOD("set_size_2d_override", "size"), &SubViewport::set_size_2d_override);
+ ClassDB::bind_method(D_METHOD("get_size_2d_override"), &SubViewport::get_size_2d_override);
+
+ ClassDB::bind_method(D_METHOD("set_size_2d_override_stretch", "enable"), &SubViewport::set_size_2d_override_stretch);
+ ClassDB::bind_method(D_METHOD("is_size_2d_override_stretch_enabled"), &SubViewport::is_size_2d_override_stretch_enabled);
+
ClassDB::bind_method(D_METHOD("set_update_mode", "mode"), &SubViewport::set_update_mode);
ClassDB::bind_method(D_METHOD("get_update_mode"), &SubViewport::get_update_mode);
@@ -3675,6 +3718,9 @@ void SubViewport::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_clear_mode"), &SubViewport::get_clear_mode);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "arvr"), "set_use_arvr", "is_using_arvr");
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "size"), "set_size", "get_size");
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "size_2d_override"), "set_size_2d_override", "get_size_2d_override");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "size_2d_override_stretch"), "set_size_2d_override_stretch", "is_size_2d_override_stretch_enabled");
ADD_GROUP("Render Target", "render_target_");
ADD_PROPERTY(PropertyInfo(Variant::INT, "render_target_clear_mode", PROPERTY_HINT_ENUM, "Always,Never,Next Frame"), "set_clear_mode", "get_clear_mode");
ADD_PROPERTY(PropertyInfo(Variant::INT, "render_target_update_mode", PROPERTY_HINT_ENUM, "Disabled,Once,When Visible,Always"), "set_update_mode", "get_update_mode");
@@ -3692,6 +3738,7 @@ void SubViewport::_bind_methods() {
SubViewport::SubViewport() {
arvr = false;
+ size_2d_override_stretch = false;
update_mode = UPDATE_WHEN_VISIBLE;
clear_mode = CLEAR_MODE_ALWAYS;
}
diff --git a/scene/main/viewport.h b/scene/main/viewport.h
index 8982869783..d603294ed5 100644
--- a/scene/main/viewport.h
+++ b/scene/main/viewport.h
@@ -203,7 +203,7 @@ private:
Transform2D stretch_transform;
Size2i size;
- Size2i size_override;
+ Size2i size_2d_override;
bool size_allocated;
RID contact_2d_debug;
@@ -434,9 +434,10 @@ private:
SubWindowResize _sub_window_get_resize_margin(Window *p_subwindow, const Point2 &p_point);
protected:
- void _set_size(const Size2i &p_size, const Size2i &p_size_override, const Rect2i &p_to_screen_rect, const Transform2D &p_stretch_transform, bool p_allocated);
+ void _set_size(const Size2i &p_size, const Size2i &p_size_2d_override, const Rect2i &p_to_screen_rect, const Transform2D &p_stretch_transform, bool p_allocated);
Size2i _get_size() const;
+ Size2i _get_size_2d_override() const;
bool _is_size_allocated() const;
void _notification(int p_what);
@@ -589,19 +590,27 @@ private:
UpdateMode update_mode;
ClearMode clear_mode;
bool arvr;
+ bool size_2d_override_stretch;
protected:
static void _bind_methods();
virtual DisplayServer::WindowID get_window_id() const;
+ Transform2D _stretch_transform();
void _notification(int p_what);
public:
void set_size(const Size2i &p_size);
Size2i get_size() const;
+ void set_size_2d_override(const Size2i &p_size);
+ Size2i get_size_2d_override() const;
+
void set_use_arvr(bool p_use_arvr);
bool is_using_arvr();
+ void set_size_2d_override_stretch(bool p_enable);
+ bool is_size_2d_override_stretch_enabled() const;
+
void set_update_mode(UpdateMode p_mode);
UpdateMode get_update_mode() const;
diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp
index 84c1c9d734..85adc8c5f1 100644
--- a/scene/resources/material.cpp
+++ b/scene/resources/material.cpp
@@ -444,6 +444,9 @@ void BaseMaterial3D::_update_shader() {
case DEPTH_DRAW_DISABLED: code += ",depth_draw_never"; break;
}
+ if (features[FEATURE_SUBSURACE_SCATTERING] && flags[FLAG_SUBSURFACE_MODE_SKIN]) {
+ code += ",sss_mode_skin";
+ }
if (transparency == TRANSPARENCY_ALPHA_DEPTH_PRE_PASS) {
code += ",depth_prepass_alpha";
}
@@ -2284,6 +2287,7 @@ void BaseMaterial3D::_bind_methods() {
ADD_GROUP("Subsurf Scatter", "subsurf_scatter_");
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "subsurf_scatter_enabled"), "set_feature", "get_feature", FEATURE_SUBSURACE_SCATTERING);
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "subsurf_scatter_strength", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_subsurface_scattering_strength", "get_subsurface_scattering_strength");
+ ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "subsurf_scatter_skin_mode"), "set_flag", "get_flag", FLAG_SUBSURFACE_MODE_SKIN);
ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "subsurf_scatter_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_texture", "get_texture", TEXTURE_SUBSURFACE_SCATTERING);
ADD_GROUP("Transmission", "transmission_");
@@ -2436,6 +2440,7 @@ void BaseMaterial3D::_bind_methods() {
BIND_ENUM_CONSTANT(FLAG_USE_SHADOW_TO_OPACITY);
BIND_ENUM_CONSTANT(FLAG_USE_TEXTURE_REPEAT);
BIND_ENUM_CONSTANT(FLAG_INVERT_HEIGHTMAP);
+ BIND_ENUM_CONSTANT(FLAG_SUBSURFACE_MODE_SKIN);
BIND_ENUM_CONSTANT(FLAG_MAX);
BIND_ENUM_CONSTANT(DIFFUSE_BURLEY);
diff --git a/scene/resources/material.h b/scene/resources/material.h
index 0c9352baf4..57f9038bf5 100644
--- a/scene/resources/material.h
+++ b/scene/resources/material.h
@@ -218,6 +218,7 @@ public:
FLAG_USE_SHADOW_TO_OPACITY,
FLAG_USE_TEXTURE_REPEAT,
FLAG_INVERT_HEIGHTMAP,
+ FLAG_SUBSURFACE_MODE_SKIN,
FLAG_MAX
};