summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
Diffstat (limited to 'scene')
-rw-r--r--scene/2d/navigation2d.cpp28
-rw-r--r--scene/3d/navigation.cpp40
-rw-r--r--scene/3d/navigation.h1
-rw-r--r--scene/gui/file_dialog.cpp2
-rw-r--r--scene/gui/label.cpp9
-rw-r--r--scene/gui/tree.cpp4
-rw-r--r--scene/main/node.cpp12
-rw-r--r--scene/resources/font.cpp1
-rw-r--r--scene/resources/shader.cpp11
-rw-r--r--scene/resources/shader.h2
-rw-r--r--scene/resources/visual_shader.cpp4
-rw-r--r--scene/resources/visual_shader.h2
12 files changed, 102 insertions, 14 deletions
diff --git a/scene/2d/navigation2d.cpp b/scene/2d/navigation2d.cpp
index 9eec8e6cc3..1b789bab9d 100644
--- a/scene/2d/navigation2d.cpp
+++ b/scene/2d/navigation2d.cpp
@@ -388,10 +388,34 @@ Vector<Vector2> Navigation2D::get_simple_path(const Vector2 &p_start, const Vect
Polygon *p = E->get();
float cost = p->distance;
- cost += p->center.distance_to(end_point);
- if (cost < least_cost) {
+#ifdef USE_ENTRY_POINT
+ int es = p->edges.size();
+ float shortest_distance = 1e30;
+
+ for (int i = 0; i < es; i++) {
+ Polygon::Edge &e = p->edges.write[i];
+
+ if (!e.C)
+ continue;
+
+ Vector2 edge[2] = {
+ _get_vertex(p->edges[i].point),
+ _get_vertex(p->edges[(i + 1) % es].point)
+ };
+
+ Vector2 edge_point = Geometry::get_closest_point_to_segment_2d(p->entry, edge);
+ float dist = p->entry.distance_to(edge_point);
+ if (dist < shortest_distance)
+ shortest_distance = dist;
+ }
+
+ cost += shortest_distance;
+#else
+ cost += p->center.distance_to(end_point);
+#endif
+ if (cost < least_cost) {
least_cost_poly = E;
least_cost = cost;
}
diff --git a/scene/3d/navigation.cpp b/scene/3d/navigation.cpp
index 8d84d2408c..54f74c2df3 100644
--- a/scene/3d/navigation.cpp
+++ b/scene/3d/navigation.cpp
@@ -30,6 +30,8 @@
#include "navigation.h"
+#define USE_ENTRY_POINT
+
void Navigation::_navmesh_link(int p_id) {
ERR_FAIL_COND(!navmesh_map.has(p_id));
@@ -331,7 +333,18 @@ Vector<Vector3> Navigation::get_simple_path(const Vector3 &p_start, const Vector
if (begin_poly->edges[i].C) {
begin_poly->edges[i].C->prev_edge = begin_poly->edges[i].C_edge;
+#ifdef USE_ENTRY_POINT
+ Vector3 edge[2] = {
+ _get_vertex(begin_poly->edges[i].point),
+ _get_vertex(begin_poly->edges[(i + 1) % begin_poly->edges.size()].point)
+ };
+
+ Vector3 entry = Geometry::get_closest_point_to_segment(begin_poly->entry, edge);
+ begin_poly->edges[i].C->distance = begin_poly->entry.distance_to(entry);
+ begin_poly->edges[i].C->entry = entry;
+#else
begin_poly->edges[i].C->distance = begin_poly->center.distance_to(begin_poly->edges[i].C->center);
+#endif
open_list.push_back(begin_poly->edges[i].C);
if (begin_poly->edges[i].C == end_poly) {
@@ -356,10 +369,33 @@ Vector<Vector3> Navigation::get_simple_path(const Vector3 &p_start, const Vector
Polygon *p = E->get();
float cost = p->distance;
- cost += p->center.distance_to(end_point);
+#ifdef USE_ENTRY_POINT
+ int es = p->edges.size();
- if (cost < least_cost) {
+ float shortest_distance = 1e30;
+
+ for (int i = 0; i < es; i++) {
+ Polygon::Edge &e = p->edges.write[i];
+
+ if (!e.C)
+ continue;
+ Vector3 edge[2] = {
+ _get_vertex(p->edges[i].point),
+ _get_vertex(p->edges[(i + 1) % es].point)
+ };
+
+ Vector3 edge_point = Geometry::get_closest_point_to_segment(p->entry, edge);
+ float dist = p->entry.distance_to(edge_point);
+ if (dist < shortest_distance)
+ shortest_distance = dist;
+ }
+
+ cost += shortest_distance;
+#else
+ cost += p->center.distance_to(end_point);
+#endif
+ if (cost < least_cost) {
least_cost_poly = E;
least_cost = cost;
}
diff --git a/scene/3d/navigation.h b/scene/3d/navigation.h
index 5a501039c8..8f200997cd 100644
--- a/scene/3d/navigation.h
+++ b/scene/3d/navigation.h
@@ -94,6 +94,7 @@ class Navigation : public Spatial {
Vector<Edge> edges;
Vector3 center;
+ Vector3 entry;
float distance;
int prev_edge;
diff --git a/scene/gui/file_dialog.cpp b/scene/gui/file_dialog.cpp
index 5f162a3652..283d66d8de 100644
--- a/scene/gui/file_dialog.cpp
+++ b/scene/gui/file_dialog.cpp
@@ -349,7 +349,7 @@ void FileDialog::_tree_selected() {
file->set_text(d["name"]);
} else if (mode == MODE_OPEN_DIR) {
- get_ok()->set_text(RTR("Select this Folder"));
+ get_ok()->set_text(RTR("Select This Folder"));
}
get_ok()->set_disabled(_is_open_should_be_disabled());
diff --git a/scene/gui/label.cpp b/scene/gui/label.cpp
index ce8de38b74..91dab27930 100644
--- a/scene/gui/label.cpp
+++ b/scene/gui/label.cpp
@@ -295,14 +295,13 @@ Size2 Label::get_minimum_size() const {
Size2 min_style = get_stylebox("normal")->get_minimum_size();
+ // don't want to mutable everything
+ if (word_cache_dirty)
+ const_cast<Label *>(this)->regenerate_word_cache();
+
if (autowrap)
return Size2(1, clip ? 1 : minsize.height) + min_style;
else {
-
- // don't want to mutable everything
- if (word_cache_dirty)
- const_cast<Label *>(this)->regenerate_word_cache();
-
Size2 ms = minsize;
if (clip)
ms.width = 1;
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp
index 365a6a5cae..24b9083964 100644
--- a/scene/gui/tree.cpp
+++ b/scene/gui/tree.cpp
@@ -2239,13 +2239,13 @@ void Tree::_gui_input(Ref<InputEvent> p_event) {
_go_left();
}
- } else if (p_event->is_action("ui_up") && p_event->is_pressed()) {
+ } else if (p_event->is_action("ui_up") && p_event->is_pressed() && !k->get_command()) {
if (!cursor_can_exit_tree) accept_event();
_go_up();
- } else if (p_event->is_action("ui_down") && p_event->is_pressed()) {
+ } else if (p_event->is_action("ui_down") && p_event->is_pressed() && !k->get_command()) {
if (!cursor_can_exit_tree) accept_event();
diff --git a/scene/main/node.cpp b/scene/main/node.cpp
index 12a71fe158..d3282c6ada 100644
--- a/scene/main/node.cpp
+++ b/scene/main/node.cpp
@@ -2129,6 +2129,12 @@ void Node::_duplicate_and_reown(Node *p_new_parent, const Map<Node *, Node *> &p
node->set(name, value);
}
+ List<GroupInfo> groups;
+ get_groups(&groups);
+
+ for (List<GroupInfo>::Element *E = groups.front(); E; E = E->next())
+ node->add_to_group(E->get().name, E->get().persistent);
+
node->set_name(get_name());
p_new_parent->add_child(node);
@@ -2223,6 +2229,12 @@ Node *Node::duplicate_and_reown(const Map<Node *, Node *> &p_reown_map) const {
node->set(name, get(name));
}
+ List<GroupInfo> groups;
+ get_groups(&groups);
+
+ for (List<GroupInfo>::Element *E = groups.front(); E; E = E->next())
+ node->add_to_group(E->get().name, E->get().persistent);
+
for (int i = 0; i < get_child_count(); i++) {
get_child(i)->_duplicate_and_reown(node, p_reown_map);
diff --git a/scene/resources/font.cpp b/scene/resources/font.cpp
index 50bf8f38f7..b78b3a6ffb 100644
--- a/scene/resources/font.cpp
+++ b/scene/resources/font.cpp
@@ -178,6 +178,7 @@ PoolVector<int> BitmapFont::_get_kernings() const {
void BitmapFont::_set_textures(const Vector<Variant> &p_textures) {
+ textures.clear();
for (int i = 0; i < p_textures.size(); i++) {
Ref<Texture> tex = p_textures[i];
ERR_CONTINUE(!tex.is_valid());
diff --git a/scene/resources/shader.cpp b/scene/resources/shader.cpp
index 1bfc41bd92..66bf3b4991 100644
--- a/scene/resources/shader.cpp
+++ b/scene/resources/shader.cpp
@@ -126,6 +126,11 @@ void Shader::get_default_texture_param_list(List<StringName> *r_textures) const
r_textures->push_back(E->key());
}
}
+
+bool Shader::is_text_shader() const {
+ return true;
+}
+
bool Shader::has_param(const StringName &p_param) const {
return params_cache.has(p_param);
@@ -235,8 +240,10 @@ Error ResourceFormatSaverShader::save(const String &p_path, const RES &p_resourc
void ResourceFormatSaverShader::get_recognized_extensions(const RES &p_resource, List<String> *p_extensions) const {
- if (Object::cast_to<Shader>(*p_resource)) {
- p_extensions->push_back("shader");
+ if (const Shader *shader = Object::cast_to<Shader>(*p_resource)) {
+ if (shader->is_text_shader()) {
+ p_extensions->push_back("shader");
+ }
}
}
bool ResourceFormatSaverShader::recognize(const RES &p_resource) const {
diff --git a/scene/resources/shader.h b/scene/resources/shader.h
index 6c91205c0c..c2c205237f 100644
--- a/scene/resources/shader.h
+++ b/scene/resources/shader.h
@@ -79,6 +79,8 @@ public:
Ref<Texture> get_default_texture_param(const StringName &p_param) const;
void get_default_texture_param_list(List<StringName> *r_textures) const;
+ virtual bool is_text_shader() const;
+
_FORCE_INLINE_ StringName remap_param(const StringName &p_param) const {
if (params_cache_dirty)
get_param_list(NULL);
diff --git a/scene/resources/visual_shader.cpp b/scene/resources/visual_shader.cpp
index 6bfb6ec5bf..f12ea8f2bb 100644
--- a/scene/resources/visual_shader.cpp
+++ b/scene/resources/visual_shader.cpp
@@ -414,6 +414,10 @@ Shader::Mode VisualShader::get_mode() const {
return shader_mode;
}
+bool VisualShader::is_text_shader() const {
+ return false;
+}
+
String VisualShader::generate_preview_shader(Type p_type, int p_node, int p_port, Vector<DefaultTextureParam> &default_tex_params) const {
Ref<VisualShaderNode> node = get_node(p_type, p_node);
diff --git a/scene/resources/visual_shader.h b/scene/resources/visual_shader.h
index 70d2425304..2867daac3a 100644
--- a/scene/resources/visual_shader.h
+++ b/scene/resources/visual_shader.h
@@ -141,6 +141,8 @@ public:
void set_mode(Mode p_mode);
virtual Mode get_mode() const;
+ virtual bool is_text_shader() const;
+
void set_graph_offset(const Vector2 &p_offset);
Vector2 get_graph_offset() const;