summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/bind/core_bind.cpp13
-rw-r--r--core/bind/core_bind.h109
-rw-r--r--core/io/resource_format_binary.cpp3
-rw-r--r--core/math/geometry.cpp146
-rw-r--r--core/math/geometry.h217
-rw-r--r--core/math/transform.h32
-rw-r--r--core/math/transform_2d.h31
-rw-r--r--core/safe_refcount.h16
-rw-r--r--core/variant_call.cpp4
-rw-r--r--doc/classes/AudioStreamGenerator.xml1
-rw-r--r--doc/classes/AudioStreamGeneratorPlayback.xml1
-rw-r--r--doc/classes/AudioStreamSample.xml1
-rw-r--r--doc/classes/Geometry.xml25
-rw-r--r--doc/classes/GraphNode.xml2
-rw-r--r--doc/classes/Transform.xml4
-rw-r--r--doc/classes/Transform2D.xml4
-rw-r--r--doc/classes/VisualShaderNodeCustom.xml1
-rw-r--r--drivers/png/resource_saver_png.cpp4
-rw-r--r--editor/code_editor.cpp40
-rw-r--r--editor/collada/collada.cpp4
-rw-r--r--editor/collada/collada.h4
-rw-r--r--editor/create_dialog.cpp55
-rw-r--r--editor/editor_help.cpp1
-rw-r--r--editor/editor_inspector.cpp12
-rw-r--r--editor/editor_node.cpp64
-rw-r--r--editor/editor_node.h9
-rw-r--r--editor/editor_plugin.cpp2
-rw-r--r--editor/editor_plugin_settings.cpp88
-rw-r--r--editor/editor_properties.cpp3
-rw-r--r--editor/editor_properties_array_dict.cpp6
-rw-r--r--editor/editor_sectioned_inspector.cpp2
-rw-r--r--editor/editor_settings.cpp40
-rw-r--r--editor/editor_themes.cpp48
-rw-r--r--editor/export_template_manager.cpp135
-rw-r--r--editor/export_template_manager.h2
-rw-r--r--editor/import/resource_importer_wav.cpp4
-rw-r--r--editor/plugins/animation_blend_tree_editor_plugin.cpp1
-rw-r--r--editor/plugins/asset_library_editor_plugin.cpp1
-rw-r--r--editor/plugins/editor_preview_plugins.cpp1
-rw-r--r--editor/plugins/script_editor_plugin.cpp36
-rw-r--r--editor/plugins/script_text_editor.cpp10
-rw-r--r--editor/plugins/shader_editor_plugin.cpp6
-rw-r--r--editor/plugins/spatial_editor_plugin.cpp12
-rw-r--r--editor/plugins/visual_shader_editor_plugin.cpp1
-rw-r--r--editor/project_export.cpp1
-rw-r--r--editor/project_manager.cpp2
-rw-r--r--editor/project_settings_editor.cpp1
-rw-r--r--modules/mono/mono_gd/gd_mono.cpp7
-rw-r--r--modules/visual_script/visual_script_editor.cpp1
-rw-r--r--platform/android/SCsub22
-rw-r--r--platform/android/export/export.cpp9
-rw-r--r--scene/2d/canvas_item.cpp9
-rw-r--r--scene/2d/collision_object_2d.cpp7
-rw-r--r--scene/3d/collision_object.cpp3
-rw-r--r--scene/gui/graph_edit.cpp10
-rw-r--r--scene/gui/graph_node.cpp3
-rw-r--r--scene/gui/rich_text_label.cpp5
-rw-r--r--scene/gui/spin_box.cpp21
-rw-r--r--scene/gui/tab_container.cpp14
-rw-r--r--scene/gui/tab_container.h3
-rw-r--r--scene/gui/text_edit.cpp24
-rw-r--r--scene/gui/viewport_container.cpp1
-rw-r--r--scene/main/http_request.cpp4
-rw-r--r--scene/resources/default_theme/default_theme.cpp1
-rw-r--r--scene/resources/visual_shader.cpp3
-rw-r--r--version.py2
66 files changed, 733 insertions, 621 deletions
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp
index b5e84d49a0..5161f8bab2 100644
--- a/core/bind/core_bind.cpp
+++ b/core/bind/core_bind.cpp
@@ -1432,6 +1432,11 @@ PoolVector<Plane> _Geometry::build_capsule_planes(float p_radius, float p_height
return Geometry::build_capsule_planes(p_radius, p_height, p_sides, p_lats, p_axis);
}
+bool _Geometry::is_point_in_circle(const Vector2 &p_point, const Vector2 &p_circle_pos, real_t p_circle_radius) {
+
+ return Geometry::is_point_in_circle(p_point, p_circle_pos, p_circle_radius);
+}
+
real_t _Geometry::segment_intersects_circle(const Vector2 &p_from, const Vector2 &p_to, const Vector2 &p_circle_pos, real_t p_circle_radius) {
return Geometry::segment_intersects_circle(p_from, p_to, p_circle_pos, p_circle_radius);
@@ -1684,11 +1689,6 @@ Array _Geometry::offset_polyline_2d(const Vector<Vector2> &p_polygon, real_t p_d
return ret;
}
-Vector<Point2> _Geometry::transform_points_2d(const Vector<Point2> &p_points, const Transform2D &p_mat) {
-
- return Geometry::transform_points_2d(p_points, p_mat);
-}
-
Dictionary _Geometry::make_atlas(const Vector<Size2> &p_rects) {
Dictionary ret;
@@ -1727,6 +1727,7 @@ void _Geometry::_bind_methods() {
ClassDB::bind_method(D_METHOD("build_box_planes", "extents"), &_Geometry::build_box_planes);
ClassDB::bind_method(D_METHOD("build_cylinder_planes", "radius", "height", "sides", "axis"), &_Geometry::build_cylinder_planes, DEFVAL(Vector3::AXIS_Z));
ClassDB::bind_method(D_METHOD("build_capsule_planes", "radius", "height", "sides", "lats", "axis"), &_Geometry::build_capsule_planes, DEFVAL(Vector3::AXIS_Z));
+ ClassDB::bind_method(D_METHOD("is_point_in_circle", "point", "circle_position", "circle_radius"), &_Geometry::is_point_in_circle);
ClassDB::bind_method(D_METHOD("segment_intersects_circle", "segment_from", "segment_to", "circle_position", "circle_radius"), &_Geometry::segment_intersects_circle);
ClassDB::bind_method(D_METHOD("segment_intersects_segment_2d", "from_a", "to_a", "from_b", "to_b"), &_Geometry::segment_intersects_segment_2d);
ClassDB::bind_method(D_METHOD("line_intersects_line_2d", "from_a", "dir_a", "from_b", "dir_b"), &_Geometry::line_intersects_line_2d);
@@ -1767,8 +1768,6 @@ void _Geometry::_bind_methods() {
ClassDB::bind_method(D_METHOD("offset_polygon_2d", "polygon", "delta", "join_type"), &_Geometry::offset_polygon_2d, DEFVAL(JOIN_SQUARE));
ClassDB::bind_method(D_METHOD("offset_polyline_2d", "polyline", "delta", "join_type", "end_type"), &_Geometry::offset_polyline_2d, DEFVAL(JOIN_SQUARE), DEFVAL(END_SQUARE));
- ClassDB::bind_method(D_METHOD("transform_points_2d", "points", "transform"), &_Geometry::transform_points_2d);
-
ClassDB::bind_method(D_METHOD("make_atlas", "sizes"), &_Geometry::make_atlas);
BIND_ENUM_CONSTANT(OPERATION_UNION);
diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h
index 76ba2dc0a5..693b85710a 100644
--- a/core/bind/core_bind.h
+++ b/core/bind/core_bind.h
@@ -109,11 +109,11 @@ public:
};
enum PowerState {
- POWERSTATE_UNKNOWN, /**< cannot determine power status */
- POWERSTATE_ON_BATTERY, /**< Not plugged in, running on the battery */
- POWERSTATE_NO_BATTERY, /**< Plugged in, no battery available */
- POWERSTATE_CHARGING, /**< Plugged in, charging battery */
- POWERSTATE_CHARGED /**< Plugged in, battery charged */
+ POWERSTATE_UNKNOWN, // Cannot determine power status.
+ POWERSTATE_ON_BATTERY, // Not plugged in, running on the battery.
+ POWERSTATE_NO_BATTERY, // Plugged in, no battery available.
+ POWERSTATE_CHARGING, // Plugged in, charging battery.
+ POWERSTATE_CHARGED // Plugged in, battery charged.
};
enum Weekday {
@@ -127,8 +127,8 @@ public:
};
enum Month {
- /// Start at 1 to follow Windows SYSTEMTIME structure
- /// https://msdn.microsoft.com/en-us/library/windows/desktop/ms724950(v=vs.85).aspx
+ // Start at 1 to follow Windows SYSTEMTIME structure
+ // https://msdn.microsoft.com/en-us/library/windows/desktop/ms724950(v=vs.85).aspx
MONTH_JANUARY = 1,
MONTH_FEBRUARY,
MONTH_MARCH,
@@ -264,24 +264,6 @@ public:
bool is_scancode_unicode(uint32_t p_unicode) const;
int find_scancode_from_string(const String &p_code) const;
- /*
- struct Date {
-
- int year;
- Month month;
- int day;
- Weekday weekday;
- bool dst;
- };
-
- struct Time {
-
- int hour;
- int min;
- int sec;
- };
-*/
-
void set_use_file_access_save_and_swap(bool p_enable);
void set_native_icon(const String &p_filename);
@@ -409,6 +391,7 @@ public:
PoolVector<Vector3> segment_intersects_sphere(const Vector3 &p_from, const Vector3 &p_to, const Vector3 &p_sphere_pos, real_t p_sphere_radius);
PoolVector<Vector3> segment_intersects_cylinder(const Vector3 &p_from, const Vector3 &p_to, float p_height, float p_radius);
PoolVector<Vector3> segment_intersects_convex(const Vector3 &p_from, const Vector3 &p_to, const Vector<Plane> &p_planes);
+ bool is_point_in_circle(const Vector2 &p_point, const Vector2 &p_circle_pos, real_t p_circle_radius);
real_t segment_intersects_circle(const Vector2 &p_from, const Vector2 &p_to, const Vector2 &p_circle_pos, real_t p_circle_radius);
int get_uv84_normal_bit(const Vector3 &p_vector);
@@ -425,17 +408,17 @@ public:
OPERATION_INTERSECTION,
OPERATION_XOR
};
- // 2D polygon boolean operations
- Array merge_polygons_2d(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b); // union (add)
- Array clip_polygons_2d(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b); // difference (subtract)
- Array intersect_polygons_2d(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b); // common area (multiply)
- Array exclude_polygons_2d(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b); // all but common area (xor)
+ // 2D polygon boolean operations.
+ Array merge_polygons_2d(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b); // Union (add).
+ Array clip_polygons_2d(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b); // Difference (subtract).
+ Array intersect_polygons_2d(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b); // Common area (multiply).
+ Array exclude_polygons_2d(const Vector<Vector2> &p_polygon_a, const Vector<Vector2> &p_polygon_b); // All but common area (xor).
- // 2D polyline vs polygon operations
- Array clip_polyline_with_polygon_2d(const Vector<Vector2> &p_polyline, const Vector<Vector2> &p_polygon); // cut
- Array intersect_polyline_with_polygon_2d(const Vector<Vector2> &p_polyline, const Vector<Vector2> &p_polygon); // chop
+ // 2D polyline vs polygon operations.
+ Array clip_polyline_with_polygon_2d(const Vector<Vector2> &p_polyline, const Vector<Vector2> &p_polygon); // Cut.
+ Array intersect_polyline_with_polygon_2d(const Vector<Vector2> &p_polyline, const Vector<Vector2> &p_polygon); // Chop.
- // 2D offset polygons/polylines
+ // 2D offset polygons/polylines.
enum PolyJoinType {
JOIN_SQUARE,
JOIN_ROUND,
@@ -451,8 +434,6 @@ public:
Array offset_polygon_2d(const Vector<Vector2> &p_polygon, real_t p_delta, PolyJoinType p_join_type = JOIN_SQUARE);
Array offset_polyline_2d(const Vector<Vector2> &p_polygon, real_t p_delta, PolyJoinType p_join_type = JOIN_SQUARE, PolyEndType p_end_type = END_SQUARE);
- Vector<Point2> transform_points_2d(const Vector<Point2> &p_points, const Transform2D &p_mat);
-
Dictionary make_atlas(const Vector<Size2> &p_rects);
_Geometry();
@@ -491,24 +472,24 @@ public:
Error open_encrypted_pass(const String &p_path, ModeFlags p_mode_flags, const String &p_pass);
Error open_compressed(const String &p_path, ModeFlags p_mode_flags, CompressionMode p_compress_mode = COMPRESSION_FASTLZ);
- Error open(const String &p_path, ModeFlags p_mode_flags); ///< open a file
- void close(); ///< close a file
- bool is_open() const; ///< true when file is open
+ Error open(const String &p_path, ModeFlags p_mode_flags); // open a file.
+ void close(); // Close a file.
+ bool is_open() const; // True when file is open.
- String get_path() const; /// returns the path for the current open file
- String get_path_absolute() const; /// returns the absolute path for the current open file
+ String get_path() const; // Returns the path for the current open file.
+ String get_path_absolute() const; // Returns the absolute path for the current open file.
- void seek(int64_t p_position); ///< seek to a given position
- void seek_end(int64_t p_position = 0); ///< seek from the end of file
- int64_t get_position() const; ///< get position in the file
- int64_t get_len() const; ///< get size of the file
+ void seek(int64_t p_position); // Seek to a given position.
+ void seek_end(int64_t p_position = 0); // Seek from the end of file.
+ int64_t get_position() const; // Get position in the file.
+ int64_t get_len() const; // Get size of the file.
- bool eof_reached() const; ///< reading passed EOF
+ bool eof_reached() const; // Reading passed EOF.
- uint8_t get_8() const; ///< get a byte
- uint16_t get_16() const; ///< get 16 bits uint
- uint32_t get_32() const; ///< get 32 bits uint
- uint64_t get_64() const; ///< get 64 bits uint
+ uint8_t get_8() const; // Get a byte.
+ uint16_t get_16() const; // Get 16 bits uint.
+ uint32_t get_32() const; // Get 32 bits uint.
+ uint64_t get_64() const; // Get 64 bits uint.
float get_float() const;
double get_double() const;
@@ -516,27 +497,27 @@ public:
Variant get_var(bool p_allow_objects = false) const;
- PoolVector<uint8_t> get_buffer(int p_length) const; ///< get an array of bytes
+ PoolVector<uint8_t> get_buffer(int p_length) const; // Get an array of bytes.
String get_line() const;
Vector<String> get_csv_line(const String &p_delim = ",") const;
String get_as_text() const;
String get_md5(const String &p_path) const;
String get_sha256(const String &p_path) const;
- /**< use this for files WRITTEN in _big_ endian machines (ie, amiga/mac)
+ /* Use this for files WRITTEN in _big_ endian machines (ie, amiga/mac).
* It's not about the current CPU type but file formats.
- * this flags get reset to false (little endian) on each open
+ * This flags get reset to false (little endian) on each open.
*/
void set_endian_swap(bool p_swap);
bool get_endian_swap();
- Error get_error() const; ///< get last error
+ Error get_error() const; // Get last error.
- void store_8(uint8_t p_dest); ///< store a byte
- void store_16(uint16_t p_dest); ///< store 16 bits uint
- void store_32(uint32_t p_dest); ///< store 32 bits uint
- void store_64(uint64_t p_dest); ///< store 64 bits uint
+ void store_8(uint8_t p_dest); // Store a byte.
+ void store_16(uint16_t p_dest); // Store 16 bits uint.
+ void store_32(uint32_t p_dest); // Store 32 bits uint.
+ void store_64(uint64_t p_dest); // Store 64 bits uint.
void store_float(float p_dest);
void store_double(double p_dest);
@@ -549,11 +530,11 @@ public:
virtual void store_pascal_string(const String &p_string);
virtual String get_pascal_string();
- void store_buffer(const PoolVector<uint8_t> &p_buffer); ///< store an array of bytes
+ void store_buffer(const PoolVector<uint8_t> &p_buffer); // Store an array of bytes.
void store_var(const Variant &p_var, bool p_full_objects = false);
- bool file_exists(const String &p_name) const; ///< return true if a file exists
+ bool file_exists(const String &p_name) const; // Return true if a file exists.
uint64_t get_modified_time(const String &p_file) const;
@@ -575,18 +556,18 @@ protected:
public:
Error open(const String &p_path);
- Error list_dir_begin(bool p_skip_navigational = false, bool p_skip_hidden = false); ///< This starts dir listing
+ Error list_dir_begin(bool p_skip_navigational = false, bool p_skip_hidden = false); // This starts dir listing.
String get_next();
bool current_is_dir() const;
- void list_dir_end(); ///<
+ void list_dir_end();
int get_drive_count();
String get_drive(int p_drive);
int get_current_drive();
- Error change_dir(String p_dir); ///< can be relative or absolute, return false on success
- String get_current_dir(); ///< return current dir location
+ Error change_dir(String p_dir); // Can be relative or absolute, return false on success.
+ String get_current_dir(); // Return current dir location.
Error make_dir(String p_dir);
Error make_dir_recursive(String p_dir);
diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp
index de10fe1376..0ad2479b05 100644
--- a/core/io/resource_format_binary.cpp
+++ b/core/io/resource_format_binary.cpp
@@ -1786,6 +1786,7 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path, const RES &p
if (f->get_error() != OK && f->get_error() != ERR_FILE_EOF) {
f->close();
+ memdelete(f);
return ERR_CANT_CREATE;
}
@@ -1938,10 +1939,12 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path, const RES &p
if (f->get_error() != OK && f->get_error() != ERR_FILE_EOF) {
f->close();
+ memdelete(f);
return ERR_CANT_CREATE;
}
f->close();
+ memdelete(f);
return OK;
}
diff --git a/core/math/geometry.cpp b/core/math/geometry.cpp
index 8314cb827c..f37db90929 100644
--- a/core/math/geometry.cpp
+++ b/core/math/geometry.cpp
@@ -34,9 +34,10 @@
#include "thirdparty/misc/clipper.hpp"
#include "thirdparty/misc/triangulator.h"
-#define SCALE_FACTOR 100000.0 // based on CMP_EPSILON
+#define SCALE_FACTOR 100000.0 // Based on CMP_EPSILON.
-/* this implementation is very inefficient, commenting unless bugs happen. See the other one.
+// This implementation is very inefficient, commenting unless bugs happen. See the other one.
+/*
bool Geometry::is_point_in_polygon(const Vector2 &p_point, const Vector<Vector2> &p_polygon) {
Vector<int> indices = Geometry::triangulate_polygon(p_polygon);
@@ -124,8 +125,8 @@ struct _FaceClassify {
};
static bool _connect_faces(_FaceClassify *p_faces, int len, int p_group) {
- /* connect faces, error will occur if an edge is shared between more than 2 faces */
- /* clear connections */
+ // Connect faces, error will occur if an edge is shared between more than 2 faces.
+ // Clear connections.
bool error = false;
@@ -195,13 +196,6 @@ static bool _connect_faces(_FaceClassify *p_faces, int len, int p_group) {
if (p_faces[i].links[j].face == -1)
p_faces[i].valid = false;
}
- /*printf("face %i is valid: %i, group %i. connected to %i:%i,%i:%i,%i:%i\n",i,p_faces[i].valid,p_faces[i].group,
- p_faces[i].links[0].face,
- p_faces[i].links[0].edge,
- p_faces[i].links[1].face,
- p_faces[i].links[1].edge,
- p_faces[i].links[2].face,
- p_faces[i].links[2].edge);*/
}
return error;
}
@@ -249,10 +243,10 @@ PoolVector<PoolVector<Face3> > Geometry::separate_objects(PoolVector<Face3> p_ar
if (error) {
- ERR_FAIL_COND_V(error, PoolVector<PoolVector<Face3> >()); // invalid geometry
+ ERR_FAIL_COND_V(error, PoolVector<PoolVector<Face3> >()); // Invalid geometry.
}
- /* group connected faces in separate objects */
+ // Group connected faces in separate objects.
int group = 0;
for (int i = 0; i < len; i++) {
@@ -264,7 +258,7 @@ PoolVector<PoolVector<Face3> > Geometry::separate_objects(PoolVector<Face3> p_ar
}
}
- /* group connected faces in separate objects */
+ // Group connected faces in separate objects.
for (int i = 0; i < len; i++) {
@@ -376,7 +370,7 @@ static inline void _plot_face(uint8_t ***p_cell_status, int x, int y, int z, int
static inline void _mark_outside(uint8_t ***p_cell_status, int x, int y, int z, int len_x, int len_y, int len_z) {
if (p_cell_status[x][y][z] & 3)
- return; // nothing to do, already used and/or visited
+ return; // Nothing to do, already used and/or visited.
p_cell_status[x][y][z] = _CELL_PREV_FIRST;
@@ -384,29 +378,20 @@ static inline void _mark_outside(uint8_t ***p_cell_status, int x, int y, int z,
uint8_t &c = p_cell_status[x][y][z];
- //printf("at %i,%i,%i\n",x,y,z);
-
if ((c & _CELL_STEP_MASK) == _CELL_STEP_NONE) {
- /* Haven't been in here, mark as outside */
+ // Haven't been in here, mark as outside.
p_cell_status[x][y][z] |= _CELL_EXTERIOR;
- //printf("not marked as anything, marking exterior\n");
}
- //printf("cell step is %i\n",(c&_CELL_STEP_MASK));
-
if ((c & _CELL_STEP_MASK) != _CELL_STEP_DONE) {
- /* if not done, increase step */
+ // If not done, increase step.
c += 1 << 2;
- //printf("incrementing cell step\n");
}
if ((c & _CELL_STEP_MASK) == _CELL_STEP_DONE) {
- /* Go back */
- //printf("done, going back a cell\n");
-
+ // Go back.
switch (c & _CELL_PREV_MASK) {
case _CELL_PREV_FIRST: {
- //printf("at end, finished marking\n");
return;
} break;
case _CELL_PREV_Y_POS: {
@@ -440,8 +425,6 @@ static inline void _mark_outside(uint8_t ***p_cell_status, int x, int y, int z,
continue;
}
- //printf("attempting new cell!\n");
-
int next_x = x, next_y = y, next_z = z;
uint8_t prev = 0;
@@ -475,8 +458,6 @@ static inline void _mark_outside(uint8_t ***p_cell_status, int x, int y, int z,
default: ERR_FAIL();
}
- //printf("testing if new cell will be ok...!\n");
-
if (next_x < 0 || next_x >= len_x)
continue;
if (next_y < 0 || next_y >= len_y)
@@ -484,13 +465,9 @@ static inline void _mark_outside(uint8_t ***p_cell_status, int x, int y, int z,
if (next_z < 0 || next_z >= len_z)
continue;
- //printf("testing if new cell is traversable\n");
-
if (p_cell_status[next_x][next_y][next_z] & 3)
continue;
- //printf("move to it\n");
-
x = next_x;
y = next_y;
z = next_z;
@@ -507,17 +484,6 @@ static inline void _build_faces(uint8_t ***p_cell_status, int x, int y, int z, i
if (p_cell_status[x][y][z] & _CELL_EXTERIOR)
return;
-/* static const Vector3 vertices[8]={
- Vector3(0,0,0),
- Vector3(0,0,1),
- Vector3(0,1,0),
- Vector3(0,1,1),
- Vector3(1,0,0),
- Vector3(1,0,1),
- Vector3(1,1,0),
- Vector3(1,1,1),
- };
-*/
#define vert(m_idx) Vector3(((m_idx)&4) >> 2, ((m_idx)&2) >> 1, (m_idx)&1)
static const uint8_t indices[6][4] = {
@@ -529,22 +495,6 @@ static inline void _build_faces(uint8_t ***p_cell_status, int x, int y, int z, i
{ 0, 4, 6, 2 },
};
- /*
-
- {0,1,2,3},
- {0,1,4,5},
- {0,2,4,6},
- {4,5,6,7},
- {2,3,7,6},
- {1,3,5,7},
-
- {0,2,3,1},
- {0,1,5,4},
- {0,4,6,2},
- {7,6,4,5},
- {7,3,2,6},
- {7,5,1,3},
-*/
for (int i = 0; i < 6; i++) {
@@ -607,9 +557,9 @@ PoolVector<Face3> Geometry::wrap_geometry(PoolVector<Face3> p_array, real_t *p_e
}
}
- global_aabb.grow_by(0.01); // avoid numerical error
+ global_aabb.grow_by(0.01); // Avoid numerical error.
- // determine amount of cells in grid axis
+ // Determine amount of cells in grid axis.
int div_x, div_y, div_z;
if (global_aabb.size.x / _MIN_SIZE < _MAX_LENGTH)
@@ -632,7 +582,7 @@ PoolVector<Face3> Geometry::wrap_geometry(PoolVector<Face3> p_array, real_t *p_e
voxelsize.y /= div_y;
voxelsize.z /= div_z;
- // create and initialize cells to zero
+ // Create and initialize cells to zero.
uint8_t ***cell_status = memnew_arr(uint8_t **, div_x);
for (int i = 0; i < div_x; i++) {
@@ -650,7 +600,7 @@ PoolVector<Face3> Geometry::wrap_geometry(PoolVector<Face3> p_array, real_t *p_e
}
}
- // plot faces into cells
+ // Plot faces into cells.
for (int i = 0; i < face_count; i++) {
@@ -662,7 +612,7 @@ PoolVector<Face3> Geometry::wrap_geometry(PoolVector<Face3> p_array, real_t *p_e
_plot_face(cell_status, 0, 0, 0, div_x, div_y, div_z, voxelsize, f);
}
- // determine which cells connect to the outside by traversing the outside and recursively flood-fill marking
+ // Determine which cells connect to the outside by traversing the outside and recursively flood-fill marking.
for (int i = 0; i < div_x; i++) {
@@ -691,7 +641,7 @@ PoolVector<Face3> Geometry::wrap_geometry(PoolVector<Face3> p_array, real_t *p_e
}
}
- // build faces for the inside-outside cell divisors
+ // Build faces for the inside-outside cell divisors.
PoolVector<Face3> wrapped_faces;
@@ -706,7 +656,7 @@ PoolVector<Face3> Geometry::wrap_geometry(PoolVector<Face3> p_array, real_t *p_e
}
}
- // transform face vertices to global coords
+ // Transform face vertices to global coords.
int wrapped_faces_count = wrapped_faces.size();
PoolVector<Face3>::Write wrapped_facesw = wrapped_faces.write();
@@ -753,7 +703,7 @@ Vector<Vector<Vector2> > Geometry::decompose_polygon_in_convex(Vector<Point2> po
inp.SetOrientation(TRIANGULATOR_CCW);
in_poly.push_back(inp);
TriangulatorPartition tpart;
- if (tpart.ConvexPartition_HM(&in_poly, &out_poly) == 0) { //failed!
+ if (tpart.ConvexPartition_HM(&in_poly, &out_poly) == 0) { // Failed.
ERR_PRINT("Convex decomposing failed!");
return decomp;
}
@@ -781,7 +731,7 @@ Geometry::MeshData Geometry::build_convex_mesh(const PoolVector<Plane> &p_planes
#define SUBPLANE_SIZE 1024.0
- real_t subplane_size = 1024.0; // should compute this from the actual plane
+ real_t subplane_size = 1024.0; // Should compute this from the actual plane.
for (int i = 0; i < p_planes.size(); i++) {
Plane p = p_planes[i];
@@ -789,7 +739,7 @@ Geometry::MeshData Geometry::build_convex_mesh(const PoolVector<Plane> &p_planes
Vector3 ref = Vector3(0.0, 1.0, 0.0);
if (ABS(p.normal.dot(ref)) > 0.95)
- ref = Vector3(0.0, 0.0, 1.0); // change axis
+ ref = Vector3(0.0, 0.0, 1.0); // Change axis.
Vector3 right = p.normal.cross(ref).normalized();
Vector3 up = p.normal.cross(right).normalized();
@@ -827,20 +777,20 @@ Geometry::MeshData Geometry::build_convex_mesh(const PoolVector<Plane> &p_planes
real_t dist0 = clip.distance_to(edge0_A);
real_t dist1 = clip.distance_to(edge1_A);
- if (dist0 <= 0) { // behind plane
+ if (dist0 <= 0) { // Behind plane.
new_vertices.push_back(vertices[k]);
}
- // check for different sides and non coplanar
+ // Check for different sides and non coplanar.
if ((dist0 * dist1) < 0) {
- // calculate intersection
+ // Calculate intersection.
Vector3 rel = edge1_A - edge0_A;
real_t den = clip.normal.dot(rel);
if (Math::is_zero_approx(den))
- continue; // point too short
+ continue; // Point too short.
real_t dist = -(clip.normal.dot(edge0_A) - clip.d) / den;
Vector3 inters = edge0_A + rel * dist;
@@ -854,11 +804,11 @@ Geometry::MeshData Geometry::build_convex_mesh(const PoolVector<Plane> &p_planes
if (vertices.size() < 3)
continue;
- //result is a clockwise face
+ // Result is a clockwise face.
MeshData::Face face;
- // add face indices
+ // Add face indices.
for (int j = 0; j < vertices.size(); j++) {
int idx = -1;
@@ -882,7 +832,7 @@ Geometry::MeshData Geometry::build_convex_mesh(const PoolVector<Plane> &p_planes
face.plane = p;
mesh.faces.push_back(face);
- //add edge
+ // Add edge.
for (int j = 0; j < face.indices.size(); j++) {
@@ -972,7 +922,7 @@ PoolVector<Plane> Geometry::build_sphere_planes(real_t p_radius, int p_lats, int
for (int j = 1; j <= p_lats; j++) {
- //todo this is stupid, fix
+ // FIXME: This is stupid.
Vector3 angle = normal.linear_interpolate(axis, j / (real_t)p_lats).normalized();
Vector3 pos = angle * p_radius;
planes.push_back(Plane(pos, angle));
@@ -1032,12 +982,12 @@ struct _AtlasWorkRectResult {
void Geometry::make_atlas(const Vector<Size2i> &p_rects, Vector<Point2i> &r_result, Size2i &r_size) {
- //super simple, almost brute force scanline stacking fitter
- //it's pretty basic for now, but it tries to make sure that the aspect ratio of the
- //resulting atlas is somehow square. This is necessary because video cards have limits
- //on texture size (usually 2048 or 4096), so the more square a texture, the more chances
- //it will work in every hardware.
- // for example, it will prioritize a 1024x1024 atlas (works everywhere) instead of a
+ // Super simple, almost brute force scanline stacking fitter.
+ // It's pretty basic for now, but it tries to make sure that the aspect ratio of the
+ // resulting atlas is somehow square. This is necessary because video cards have limits.
+ // On texture size (usually 2048 or 4096), so the more square a texture, the more chances.
+ // It will work in every hardware.
+ // For example, it will prioritize a 1024x1024 atlas (works everywhere) instead of a
// 256x8192 atlas (won't work anywhere).
ERR_FAIL_COND(p_rects.size() == 0);
@@ -1066,7 +1016,7 @@ void Geometry::make_atlas(const Vector<Size2i> &p_rects, Vector<Point2i> &r_resu
for (int j = 0; j < w; j++)
hmax.write[j] = 0;
- //place them
+ // Place them.
int ofs = 0;
int limit_h = 0;
for (int j = 0; j < wrects.size(); j++) {
@@ -1101,7 +1051,7 @@ void Geometry::make_atlas(const Vector<Size2i> &p_rects, Vector<Point2i> &r_resu
if (end_w > max_w)
max_w = end_w;
- if (ofs == 0 || end_h > limit_h) //while h limit not reached, keep stacking
+ if (ofs == 0 || end_h > limit_h) // While h limit not reached, keep stacking.
ofs += wrects[j].s.width;
}
@@ -1112,7 +1062,7 @@ void Geometry::make_atlas(const Vector<Size2i> &p_rects, Vector<Point2i> &r_resu
results.push_back(result);
}
- //find the result with the best aspect ratio
+ // Find the result with the best aspect ratio.
int best = -1;
real_t best_aspect = 1e20;
@@ -1152,7 +1102,7 @@ Vector<Vector<Point2> > Geometry::_polypaths_do_operation(PolyBooleanOperation p
}
Path path_a, path_b;
- // Need to scale points (Clipper's requirement for robust computation)
+ // Need to scale points (Clipper's requirement for robust computation).
for (int i = 0; i != p_polypath_a.size(); ++i) {
path_a << IntPoint(p_polypath_a[i].x * SCALE_FACTOR, p_polypath_a[i].y * SCALE_FACTOR);
}
@@ -1160,19 +1110,19 @@ Vector<Vector<Point2> > Geometry::_polypaths_do_operation(PolyBooleanOperation p
path_b << IntPoint(p_polypath_b[i].x * SCALE_FACTOR, p_polypath_b[i].y * SCALE_FACTOR);
}
Clipper clp;
- clp.AddPath(path_a, ptSubject, !is_a_open); // forward compatible with Clipper 10.0.0
- clp.AddPath(path_b, ptClip, true); // polylines cannot be set as clip
+ clp.AddPath(path_a, ptSubject, !is_a_open); // Forward compatible with Clipper 10.0.0.
+ clp.AddPath(path_b, ptClip, true); // Polylines cannot be set as clip.
Paths paths;
if (is_a_open) {
- PolyTree tree; // needed to populate polylines
+ PolyTree tree; // Needed to populate polylines.
clp.Execute(op, tree);
OpenPathsFromPolyTree(tree, paths);
} else {
- clp.Execute(op, paths); // works on closed polygons only
+ clp.Execute(op, paths); // Works on closed polygons only.
}
- // Have to scale points down now
+ // Have to scale points down now.
Vector<Vector<Point2> > polypaths;
for (Paths::size_type i = 0; i < paths.size(); ++i) {
@@ -1214,16 +1164,16 @@ Vector<Vector<Point2> > Geometry::_polypath_offset(const Vector<Point2> &p_polyp
ClipperOffset co;
Path path;
- // Need to scale points (Clipper's requirement for robust computation)
+ // Need to scale points (Clipper's requirement for robust computation).
for (int i = 0; i != p_polypath.size(); ++i) {
path << IntPoint(p_polypath[i].x * SCALE_FACTOR, p_polypath[i].y * SCALE_FACTOR);
}
co.AddPath(path, jt, et);
Paths paths;
- co.Execute(paths, p_delta * SCALE_FACTOR); // inflate/deflate
+ co.Execute(paths, p_delta * SCALE_FACTOR); // Inflate/deflate.
- // Have to scale points down now
+ // Have to scale points down now.
Vector<Vector<Point2> > polypaths;
for (Paths::size_type i = 0; i < paths.size(); ++i) {
diff --git a/core/math/geometry.h b/core/math/geometry.h
index 82d9884e9b..8b0a51c651 100644
--- a/core/math/geometry.h
+++ b/core/math/geometry.h
@@ -47,37 +47,37 @@ class Geometry {
public:
static real_t get_closest_points_between_segments(const Vector2 &p1, const Vector2 &q1, const Vector2 &p2, const Vector2 &q2, Vector2 &c1, Vector2 &c2) {
- Vector2 d1 = q1 - p1; // Direction vector of segment S1
- Vector2 d2 = q2 - p2; // Direction vector of segment S2
+ Vector2 d1 = q1 - p1; // Direction vector of segment S1.
+ Vector2 d2 = q2 - p2; // Direction vector of segment S2.
Vector2 r = p1 - p2;
- real_t a = d1.dot(d1); // Squared length of segment S1, always nonnegative
- real_t e = d2.dot(d2); // Squared length of segment S2, always nonnegative
+ real_t a = d1.dot(d1); // Squared length of segment S1, always nonnegative.
+ real_t e = d2.dot(d2); // Squared length of segment S2, always nonnegative.
real_t f = d2.dot(r);
real_t s, t;
- // Check if either or both segments degenerate into points
+ // Check if either or both segments degenerate into points.
if (a <= CMP_EPSILON && e <= CMP_EPSILON) {
- // Both segments degenerate into points
+ // Both segments degenerate into points.
c1 = p1;
c2 = p2;
return Math::sqrt((c1 - c2).dot(c1 - c2));
}
if (a <= CMP_EPSILON) {
- // First segment degenerates into a point
+ // First segment degenerates into a point.
s = 0.0;
t = f / e; // s = 0 => t = (b*s + f) / e = f / e
t = CLAMP(t, 0.0, 1.0);
} else {
real_t c = d1.dot(r);
if (e <= CMP_EPSILON) {
- // Second segment degenerates into a point
+ // Second segment degenerates into a point.
t = 0.0;
s = CLAMP(-c / a, 0.0, 1.0); // t = 0 => s = (b*t - c) / a = -c / a
} else {
- // The general nondegenerate case starts here
+ // The general nondegenerate case starts here.
real_t b = d1.dot(d2);
- real_t denom = a * e - b * b; // Always nonnegative
+ real_t denom = a * e - b * b; // Always nonnegative.
// If segments not parallel, compute closest point on L1 to L2 and
- // clamp to segment S1. Else pick arbitrary s (here 0)
+ // clamp to segment S1. Else pick arbitrary s (here 0).
if (denom != 0.0) {
s = CLAMP((b * f - c * e) / denom, 0.0, 1.0);
} else
@@ -88,7 +88,7 @@ public:
//If t in [0,1] done. Else clamp t, recompute s for the new value
// of t using s = Dot((P2 + D2*t) - P1,D1) / Dot(D1,D1)= (t*b - c) / a
- // and clamp s to [0, 1]
+ // and clamp s to [0, 1].
if (t < 0.0) {
t = 0.0;
s = CLAMP(-c / a, 0.0, 1.0);
@@ -105,14 +105,14 @@ public:
static void get_closest_points_between_segments(const Vector3 &p1, const Vector3 &p2, const Vector3 &q1, const Vector3 &q2, Vector3 &c1, Vector3 &c2) {
-//do the function 'd' as defined by pb. I think is is dot product of some sort
+// Do the function 'd' as defined by pb. I think is is dot product of some sort.
#define d_of(m, n, o, p) ((m.x - n.x) * (o.x - p.x) + (m.y - n.y) * (o.y - p.y) + (m.z - n.z) * (o.z - p.z))
- //calculate the parametric position on the 2 curves, mua and mub
+ // Calculate the parametric position on the 2 curves, mua and mub.
real_t mua = (d_of(p1, q1, q2, q1) * d_of(q2, q1, p2, p1) - d_of(p1, q1, p2, p1) * d_of(q2, q1, q2, q1)) / (d_of(p2, p1, p2, p1) * d_of(q2, q1, q2, q1) - d_of(q2, q1, p2, p1) * d_of(q2, q1, p2, p1));
real_t mub = (d_of(p1, q1, q2, q1) + mua * d_of(q2, q1, p2, p1)) / d_of(q2, q1, q2, q1);
- //clip the value between [0..1] constraining the solution to lie on the original curves
+ // Clip the value between [0..1] constraining the solution to lie on the original curves.
if (mua < 0) mua = 0;
if (mub < 0) mub = 0;
if (mua > 1) mua = 1;
@@ -125,38 +125,38 @@ public:
Vector3 u = p_to_a - p_from_a;
Vector3 v = p_to_b - p_from_b;
Vector3 w = p_from_a - p_to_a;
- real_t a = u.dot(u); // always >= 0
+ real_t a = u.dot(u); // Always >= 0
real_t b = u.dot(v);
- real_t c = v.dot(v); // always >= 0
+ real_t c = v.dot(v); // Always >= 0
real_t d = u.dot(w);
real_t e = v.dot(w);
- real_t D = a * c - b * b; // always >= 0
+ real_t D = a * c - b * b; // Always >= 0
real_t sc, sN, sD = D; // sc = sN / sD, default sD = D >= 0
real_t tc, tN, tD = D; // tc = tN / tD, default tD = D >= 0
- // compute the line parameters of the two closest points
- if (D < CMP_EPSILON) { // the lines are almost parallel
- sN = 0.0; // force using point P0 on segment S1
- sD = 1.0; // to prevent possible division by 0.0 later
+ // Compute the line parameters of the two closest points.
+ if (D < CMP_EPSILON) { // The lines are almost parallel.
+ sN = 0.0; // Force using point P0 on segment S1
+ sD = 1.0; // to prevent possible division by 0.0 later.
tN = e;
tD = c;
- } else { // get the closest points on the infinite lines
+ } else { // Get the closest points on the infinite lines
sN = (b * e - c * d);
tN = (a * e - b * d);
- if (sN < 0.0) { // sc < 0 => the s=0 edge is visible
+ if (sN < 0.0) { // sc < 0 => the s=0 edge is visible.
sN = 0.0;
tN = e;
tD = c;
- } else if (sN > sD) { // sc > 1 => the s=1 edge is visible
+ } else if (sN > sD) { // sc > 1 => the s=1 edge is visible.
sN = sD;
tN = e + b;
tD = c;
}
}
- if (tN < 0.0) { // tc < 0 => the t=0 edge is visible
+ if (tN < 0.0) { // tc < 0 => the t=0 edge is visible.
tN = 0.0;
- // recompute sc for this edge
+ // Recompute sc for this edge.
if (-d < 0.0)
sN = 0.0;
else if (-d > a)
@@ -165,9 +165,9 @@ public:
sN = -d;
sD = a;
}
- } else if (tN > tD) { // tc > 1 => the t=1 edge is visible
+ } else if (tN > tD) { // tc > 1 => the t=1 edge is visible.
tN = tD;
- // recompute sc for this edge
+ // Recompute sc for this edge.
if ((-d + b) < 0.0)
sN = 0;
else if ((-d + b) > a)
@@ -177,14 +177,14 @@ public:
sD = a;
}
}
- // finally do the division to get sc and tc
+ // Finally do the division to get sc and tc.
sc = (Math::is_zero_approx(sN) ? 0.0 : sN / sD);
tc = (Math::is_zero_approx(tN) ? 0.0 : tN / tD);
- // get the difference of the two closest points
+ // Get the difference of the two closest points.
Vector3 dP = w + (sc * u) - (tc * v); // = S1(sc) - S2(tc)
- return dP.length(); // return the closest distance
+ return dP.length(); // Return the closest distance.
}
static inline bool ray_intersects_triangle(const Vector3 &p_from, const Vector3 &p_dir, const Vector3 &p_v0, const Vector3 &p_v1, const Vector3 &p_v2, Vector3 *r_res = 0) {
@@ -192,7 +192,7 @@ public:
Vector3 e2 = p_v2 - p_v0;
Vector3 h = p_dir.cross(e2);
real_t a = e1.dot(h);
- if (Math::is_zero_approx(a)) // parallel test
+ if (Math::is_zero_approx(a)) // Parallel test.
return false;
real_t f = 1.0 / a;
@@ -210,16 +210,15 @@ public:
if (v < 0.0 || u + v > 1.0)
return false;
- // at this stage we can compute t to find out where
- // the intersection point is on the line
+ // At this stage we can compute t to find out where
+ // the intersection point is on the line.
real_t t = f * e2.dot(q);
if (t > 0.00001) { // ray intersection
if (r_res)
*r_res = p_from + p_dir * t;
return true;
- } else // this means that there is a line intersection
- // but not a ray intersection
+ } else // This means that there is a line intersection but not a ray intersection.
return false;
}
@@ -230,7 +229,7 @@ public:
Vector3 e2 = p_v2 - p_v0;
Vector3 h = rel.cross(e2);
real_t a = e1.dot(h);
- if (Math::is_zero_approx(a)) // parallel test
+ if (Math::is_zero_approx(a)) // Parallel test.
return false;
real_t f = 1.0 / a;
@@ -248,16 +247,15 @@ public:
if (v < 0.0 || u + v > 1.0)
return false;
- // at this stage we can compute t to find out where
- // the intersection point is on the line
+ // At this stage we can compute t to find out where
+ // the intersection point is on the line.
real_t t = f * e2.dot(q);
- if (t > CMP_EPSILON && t <= 1.0) { // ray intersection
+ if (t > CMP_EPSILON && t <= 1.0) { // Ray intersection.
if (r_res)
*r_res = p_from + rel * t;
return true;
- } else // this means that there is a line intersection
- // but not a ray intersection
+ } else // This means that there is a line intersection but not a ray intersection.
return false;
}
@@ -267,13 +265,11 @@ public:
Vector3 rel = (p_to - p_from);
real_t rel_l = rel.length();
if (rel_l < CMP_EPSILON)
- return false; // both points are the same
+ return false; // Both points are the same.
Vector3 normal = rel / rel_l;
real_t sphere_d = normal.dot(sphere_pos);
- //Vector3 ray_closest=normal*sphere_d;
-
real_t ray_distance = sphere_pos.distance_to(normal * sphere_d);
if (ray_distance >= p_sphere_radius)
@@ -285,7 +281,7 @@ public:
if (inters_d2 >= CMP_EPSILON)
inters_d -= Math::sqrt(inters_d2);
- // check in segment
+ // Check in segment.
if (inters_d < 0 || inters_d > rel_l)
return false;
@@ -304,9 +300,9 @@ public:
Vector3 rel = (p_to - p_from);
real_t rel_l = rel.length();
if (rel_l < CMP_EPSILON)
- return false; // both points are the same
+ return false; // Both points are the same.
- // first check if they are parallel
+ // First check if they are parallel.
Vector3 normal = (rel / rel_l);
Vector3 crs = normal.cross(Vector3(0, 0, 1));
real_t crs_l = crs.length();
@@ -314,8 +310,7 @@ public:
Vector3 z_dir;
if (crs_l < CMP_EPSILON) {
- //blahblah parallel
- z_dir = Vector3(1, 0, 0); //any x/y vector ok
+ z_dir = Vector3(1, 0, 0); // Any x/y vector OK.
} else {
z_dir = crs / crs_l;
}
@@ -323,12 +318,12 @@ public:
real_t dist = z_dir.dot(p_from);
if (dist >= p_radius)
- return false; // too far away
+ return false; // Too far away.
- // convert to 2D
+ // Convert to 2D.
real_t w2 = p_radius * p_radius - dist * dist;
if (w2 < CMP_EPSILON)
- return false; //avoid numerical error
+ return false; // Avoid numerical error.
Size2 size(Math::sqrt(w2), p_height * 0.5);
Vector3 x_dir = z_dir.cross(Vector3(0, 0, 1)).normalized();
@@ -375,7 +370,7 @@ public:
return false;
}
- // convert to 3D again
+ // Convert to 3D again.
Vector3 result = p_from + (rel * min);
Vector3 res_normal = result;
@@ -416,19 +411,18 @@ public:
real_t den = p.normal.dot(dir);
- //printf("den is %i\n",den);
if (Math::abs(den) <= CMP_EPSILON)
- continue; // ignore parallel plane
+ continue; // Ignore parallel plane.
real_t dist = -p.distance_to(p_from) / den;
if (den > 0) {
- //backwards facing plane
+ // Backwards facing plane.
if (dist < max)
max = dist;
} else {
- //front facing plane
+ // Front facing plane.
if (dist > min) {
min = dist;
min_index = i;
@@ -436,8 +430,8 @@ public:
}
}
- if (max <= min || min < 0 || min > rel_l || min_index == -1) // exit conditions
- return false; // no intersection
+ if (max <= min || min < 0 || min > rel_l || min_index == -1) // Exit conditions.
+ return false; // No intersection.
if (p_res)
*p_res = p_from + dir * min;
@@ -453,16 +447,16 @@ public:
Vector3 n = p_segment[1] - p_segment[0];
real_t l2 = n.length_squared();
if (l2 < 1e-20)
- return p_segment[0]; // both points are the same, just give any
+ return p_segment[0]; // Both points are the same, just give any.
real_t d = n.dot(p) / l2;
if (d <= 0.0)
- return p_segment[0]; // before first point
+ return p_segment[0]; // Before first point.
else if (d >= 1.0)
- return p_segment[1]; // after first point
+ return p_segment[1]; // After first point.
else
- return p_segment[0] + n * d; // inside
+ return p_segment[0] + n * d; // Inside.
}
static Vector3 get_closest_point_to_segment_uncapped(const Vector3 &p_point, const Vector3 *p_segment) {
@@ -471,11 +465,11 @@ public:
Vector3 n = p_segment[1] - p_segment[0];
real_t l2 = n.length_squared();
if (l2 < 1e-20)
- return p_segment[0]; // both points are the same, just give any
+ return p_segment[0]; // Both points are the same, just give any.
real_t d = n.dot(p) / l2;
- return p_segment[0] + n * d; // inside
+ return p_segment[0] + n * d; // Inside.
}
static Vector2 get_closest_point_to_segment_2d(const Vector2 &p_point, const Vector2 *p_segment) {
@@ -484,16 +478,16 @@ public:
Vector2 n = p_segment[1] - p_segment[0];
real_t l2 = n.length_squared();
if (l2 < 1e-20)
- return p_segment[0]; // both points are the same, just give any
+ return p_segment[0]; // Both points are the same, just give any.
real_t d = n.dot(p) / l2;
if (d <= 0.0)
- return p_segment[0]; // before first point
+ return p_segment[0]; // Before first point.
else if (d >= 1.0)
- return p_segment[1]; // after first point
+ return p_segment[1]; // After first point.
else
- return p_segment[0] + n * d; // inside
+ return p_segment[0] + n * d; // Inside.
}
static bool is_point_in_triangle(const Vector2 &s, const Vector2 &a, const Vector2 &b, const Vector2 &c) {
@@ -508,27 +502,25 @@ public:
return (cn.cross(an) > 0) == orientation;
}
- //static bool is_point_in_polygon(const Vector2 &p_point, const Vector<Vector2> &p_polygon);
-
static Vector2 get_closest_point_to_segment_uncapped_2d(const Vector2 &p_point, const Vector2 *p_segment) {
Vector2 p = p_point - p_segment[0];
Vector2 n = p_segment[1] - p_segment[0];
real_t l2 = n.length_squared();
if (l2 < 1e-20)
- return p_segment[0]; // both points are the same, just give any
+ return p_segment[0]; // Both points are the same, just give any.
real_t d = n.dot(p) / l2;
- return p_segment[0] + n * d; // inside
+ return p_segment[0] + n * d; // Inside.
}
static bool line_intersects_line_2d(const Vector2 &p_from_a, const Vector2 &p_dir_a, const Vector2 &p_from_b, const Vector2 &p_dir_b, Vector2 &r_result) {
- // see http://paulbourke.net/geometry/pointlineplane/
+ // See http://paulbourke.net/geometry/pointlineplane/
const real_t denom = p_dir_b.y * p_dir_a.x - p_dir_b.x * p_dir_a.y;
- if (Math::is_zero_approx(denom)) { // parallel?
+ if (Math::is_zero_approx(denom)) { // Parallel?
return false;
}
@@ -556,11 +548,11 @@ public:
real_t ABpos = D.x + (C.x - D.x) * D.y / (D.y - C.y);
- // Fail if segment C-D crosses line A-B outside of segment A-B.
+ // Fail if segment C-D crosses line A-B outside of segment A-B.
if (ABpos < 0 || ABpos > 1.0)
return false;
- // (4) Apply the discovered position to line A-B in the original coordinate system.
+ // (4) Apply the discovered position to line A-B in the original coordinate system.
if (r_result)
*r_result = p_from_a + B * ABpos;
@@ -593,7 +585,7 @@ public:
real_t d = p_normal.dot(p_sphere_pos) - p_normal.dot(p_triangle[0]);
- if (d > p_sphere_radius || d < -p_sphere_radius) // not touching the plane of the face, return
+ if (d > p_sphere_radius || d < -p_sphere_radius) // Not touching the plane of the face, return.
return false;
Vector3 contact = p_sphere_pos - (p_normal * d);
@@ -613,25 +605,25 @@ public:
for (int i = 0; i < 3; i++) {
- // check edge cylinder
+ // Check edge cylinder.
Vector3 n1 = verts[i] - verts[i + 1];
Vector3 n2 = p_sphere_pos - verts[i + 1];
- ///@TODO i could discard by range here to make the algorithm quicker? dunno..
+ ///@TODO Maybe discard by range here to make the algorithm quicker.
- // check point within cylinder radius
+ // Check point within cylinder radius.
Vector3 axis = n1.cross(n2).cross(n1);
- axis.normalize(); // ugh
+ axis.normalize();
real_t ad = axis.dot(n2);
if (ABS(ad) > p_sphere_radius) {
- // no chance with this edge, too far away
+ // No chance with this edge, too far away.
continue;
}
- // check point within edge capsule cylinder
+ // Check point within edge capsule cylinder.
/** 4th TEST INSIDE EDGE POINTS **/
real_t sphere_at = n1.dot(n2);
@@ -640,8 +632,7 @@ public:
r_triangle_contact = p_sphere_pos - axis * (axis.dot(n2));
r_sphere_contact = p_sphere_pos - axis * p_sphere_radius;
- // point inside here
- //printf("solved inside edge\n");
+ // Point inside here.
return true;
}
@@ -651,48 +642,51 @@ public:
Vector3 n = (p_sphere_pos - verts[i + 1]).normalized();
- //r_triangle_contact=verts[i+1]+n*p_sphere_radius;p_sphere_pos+axis*(p_sphere_radius-axis.dot(n2));
r_triangle_contact = verts[i + 1];
r_sphere_contact = p_sphere_pos - n * p_sphere_radius;
- //printf("solved inside point segment 1\n");
return true;
}
if (n2.distance_squared_to(n1) < r2) {
Vector3 n = (p_sphere_pos - verts[i]).normalized();
- //r_triangle_contact=verts[i]+n*p_sphere_radius;p_sphere_pos+axis*(p_sphere_radius-axis.dot(n2));
r_triangle_contact = verts[i];
r_sphere_contact = p_sphere_pos - n * p_sphere_radius;
- //printf("solved inside point segment 1\n");
return true;
}
- break; // It's pointless to continue at this point, so save some cpu cycles
+ break; // It's pointless to continue at this point, so save some CPU cycles.
}
return false;
}
+ static inline bool is_point_in_circle(const Vector2 &p_point, const Vector2 &p_circle_pos, real_t p_circle_radius) {
+
+ return p_point.distance_squared_to(p_circle_pos) <= p_circle_radius * p_circle_radius;
+ }
+
static real_t segment_intersects_circle(const Vector2 &p_from, const Vector2 &p_to, const Vector2 &p_circle_pos, real_t p_circle_radius) {
Vector2 line_vec = p_to - p_from;
Vector2 vec_to_line = p_from - p_circle_pos;
- /* create a quadratic formula of the form ax^2 + bx + c = 0 */
+ // Create a quadratic formula of the form ax^2 + bx + c = 0
real_t a, b, c;
a = line_vec.dot(line_vec);
b = 2 * vec_to_line.dot(line_vec);
c = vec_to_line.dot(vec_to_line) - p_circle_radius * p_circle_radius;
- /* solve for t */
+ // Solve for t.
real_t sqrtterm = b * b - 4 * a * c;
- /* if the term we intend to square root is less than 0 then the answer won't be real, so it definitely won't be t in the range 0 to 1 */
+ // If the term we intend to square root is less than 0 then the answer won't be real,
+ // so it definitely won't be t in the range 0 to 1.
if (sqrtterm < 0) return -1;
- /* if we can assume that the line segment starts outside the circle (e.g. for continuous time collision detection) then the following can be skipped and we can just return the equivalent of res1 */
+ // If we can assume that the line segment starts outside the circle (e.g. for continuous time collision detection)
+ // then the following can be skipped and we can just return the equivalent of res1.
sqrtterm = Math::sqrt(sqrtterm);
real_t res1 = (-b - sqrtterm) / (2 * a);
real_t res2 = (-b + sqrtterm) / (2 * a);
@@ -718,7 +712,6 @@ public:
int outside_count = 0;
for (int a = 0; a < polygon.size(); a++) {
- //real_t p_plane.d = (*this) * polygon[a];
real_t dist = p_plane.distance_to(polygon[a]);
if (dist < -CMP_POINT_IN_PLANE_EPSILON) {
location_cache[a] = LOC_INSIDE;
@@ -735,11 +728,11 @@ public:
if (outside_count == 0) {
- return polygon; // no changes
+ return polygon; // No changes.
} else if (inside_count == 0) {
- return Vector<Vector3>(); //empty
+ return Vector<Vector3>(); // Empty.
}
long previous = polygon.size() - 1;
@@ -839,16 +832,6 @@ public:
return _polypath_offset(p_polygon, p_delta, p_join_type, p_end_type);
}
- static Vector<Point2> transform_points_2d(const Vector<Point2> &p_points, const Transform2D &p_mat) {
-
- Vector<Point2> points;
-
- for (int i = 0; i < p_points.size(); ++i) {
- points.push_back(p_mat.xform(p_points[i]));
- }
- return points;
- }
-
static Vector<int> triangulate_delaunay_2d(const Vector<Vector2> &p_points) {
Vector<Delaunay2D::Triangle> tr = Delaunay2D::triangulate(p_points);
@@ -894,7 +877,7 @@ public:
return sum > 0.0f;
}
- /* alternate implementation that should be faster */
+ // Alternate implementation that should be faster.
static bool is_point_in_polygon(const Vector2 &p_point, const Vector<Vector2> &p_polygon) {
int c = p_polygon.size();
if (c < 3)
@@ -910,7 +893,8 @@ public:
further_away_opposite.y = MIN(p[i].y, further_away_opposite.y);
}
- further_away += (further_away - further_away_opposite) * Vector2(1.221313, 1.512312); // make point outside that won't intersect with points in segment from p_point
+ // Make point outside that won't intersect with points in segment from p_point.
+ further_away += (further_away - further_away_opposite) * Vector2(1.221313, 1.512312);
int intersections = 0;
for (int i = 0; i < c; i++) {
@@ -926,7 +910,8 @@ public:
static PoolVector<PoolVector<Face3> > separate_objects(PoolVector<Face3> p_array);
- static PoolVector<Face3> wrap_geometry(PoolVector<Face3> p_array, real_t *p_error = NULL); ///< create a "wrap" that encloses the given geometry
+ // Create a "wrap" that encloses the given geometry.
+ static PoolVector<Face3> wrap_geometry(PoolVector<Face3> p_array, real_t *p_error = NULL);
struct MeshData {
@@ -1008,17 +993,17 @@ public:
Vector<Point2> H;
H.resize(2 * n);
- // Sort points lexicographically
+ // Sort points lexicographically.
P.sort();
- // Build lower hull
+ // Build lower hull.
for (int i = 0; i < n; ++i) {
while (k >= 2 && vec2_cross(H[k - 2], H[k - 1], P[i]) <= 0)
k--;
H.write[k++] = P[i];
}
- // Build upper hull
+ // Build upper hull.
for (int i = n - 2, t = k + 1; i >= 0; i--) {
while (k >= t && vec2_cross(H[k - 2], H[k - 1], P[i]) <= 0)
k--;
diff --git a/core/math/transform.h b/core/math/transform.h
index 4c8d915305..1fdc6398a1 100644
--- a/core/math/transform.h
+++ b/core/math/transform.h
@@ -34,6 +34,7 @@
#include "core/math/aabb.h"
#include "core/math/basis.h"
#include "core/math/plane.h"
+#include "core/pool_vector.h"
class Transform {
public:
@@ -82,6 +83,9 @@ public:
_FORCE_INLINE_ AABB xform(const AABB &p_aabb) const;
_FORCE_INLINE_ AABB xform_inv(const AABB &p_aabb) const;
+ _FORCE_INLINE_ PoolVector<Vector3> xform(const PoolVector<Vector3> &p_array) const;
+ _FORCE_INLINE_ PoolVector<Vector3> xform_inv(const PoolVector<Vector3> &p_array) const;
+
void operator*=(const Transform &p_transform);
Transform operator*(const Transform &p_transform) const;
@@ -198,4 +202,32 @@ _FORCE_INLINE_ AABB Transform::xform_inv(const AABB &p_aabb) const {
return ret;
}
+PoolVector<Vector3> Transform::xform(const PoolVector<Vector3> &p_array) const {
+
+ PoolVector<Vector3> array;
+ array.resize(p_array.size());
+
+ PoolVector<Vector3>::Read r = p_array.read();
+ PoolVector<Vector3>::Write w = array.write();
+
+ for (int i = 0; i < p_array.size(); ++i) {
+ w[i] = xform(r[i]);
+ }
+ return array;
+}
+
+PoolVector<Vector3> Transform::xform_inv(const PoolVector<Vector3> &p_array) const {
+
+ PoolVector<Vector3> array;
+ array.resize(p_array.size());
+
+ PoolVector<Vector3>::Read r = p_array.read();
+ PoolVector<Vector3>::Write w = array.write();
+
+ for (int i = 0; i < p_array.size(); ++i) {
+ w[i] = xform_inv(r[i]);
+ }
+ return array;
+}
+
#endif // TRANSFORM_H
diff --git a/core/math/transform_2d.h b/core/math/transform_2d.h
index c44678674a..e8b44ab197 100644
--- a/core/math/transform_2d.h
+++ b/core/math/transform_2d.h
@@ -32,6 +32,7 @@
#define TRANSFORM_2D_H
#include "core/math/rect2.h" // also includes vector2, math_funcs, and ustring
+#include "core/pool_vector.h"
struct Transform2D {
// Warning #1: basis of Transform2D is stored differently from Basis. In terms of elements array, the basis matrix looks like "on paper":
@@ -110,6 +111,8 @@ struct Transform2D {
_FORCE_INLINE_ Vector2 xform_inv(const Vector2 &p_vec) const;
_FORCE_INLINE_ Rect2 xform(const Rect2 &p_rect) const;
_FORCE_INLINE_ Rect2 xform_inv(const Rect2 &p_rect) const;
+ _FORCE_INLINE_ PoolVector<Vector2> xform(const PoolVector<Vector2> &p_array) const;
+ _FORCE_INLINE_ PoolVector<Vector2> xform_inv(const PoolVector<Vector2> &p_array) const;
operator String() const;
@@ -199,4 +202,32 @@ Rect2 Transform2D::xform_inv(const Rect2 &p_rect) const {
return new_rect;
}
+PoolVector<Vector2> Transform2D::xform(const PoolVector<Vector2> &p_array) const {
+
+ PoolVector<Vector2> array;
+ array.resize(p_array.size());
+
+ PoolVector<Vector2>::Read r = p_array.read();
+ PoolVector<Vector2>::Write w = array.write();
+
+ for (int i = 0; i < p_array.size(); ++i) {
+ w[i] = xform(r[i]);
+ }
+ return array;
+}
+
+PoolVector<Vector2> Transform2D::xform_inv(const PoolVector<Vector2> &p_array) const {
+
+ PoolVector<Vector2> array;
+ array.resize(p_array.size());
+
+ PoolVector<Vector2>::Read r = p_array.read();
+ PoolVector<Vector2>::Write w = array.write();
+
+ for (int i = 0; i < p_array.size(); ++i) {
+ w[i] = xform_inv(r[i]);
+ }
+ return array;
+}
+
#endif // TRANSFORM_2D_H
diff --git a/core/safe_refcount.h b/core/safe_refcount.h
index 0b65ffb9ca..54f540b0c7 100644
--- a/core/safe_refcount.h
+++ b/core/safe_refcount.h
@@ -97,8 +97,8 @@ static _ALWAYS_INLINE_ T atomic_exchange_if_greater(volatile T *pw, volatile V v
/* Implementation for GCC & Clang */
-#include <stdbool.h>
-#include <atomic>
+// GCC guarantees atomic intrinsics for sizes of 1, 2, 4 and 8 bytes.
+// Clang states it supports GCC atomic builtins.
template <class T>
static _ALWAYS_INLINE_ T atomic_conditional_increment(volatile T *pw) {
@@ -107,7 +107,7 @@ static _ALWAYS_INLINE_ T atomic_conditional_increment(volatile T *pw) {
T tmp = static_cast<T const volatile &>(*pw);
if (tmp == 0)
return 0; // if zero, can't add to it anymore
- if (__atomic_compare_exchange_n(pw, &tmp, tmp + 1, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST) == true)
+ if (__sync_val_compare_and_swap(pw, tmp, tmp + 1) == tmp)
return tmp + 1;
}
}
@@ -115,25 +115,25 @@ static _ALWAYS_INLINE_ T atomic_conditional_increment(volatile T *pw) {
template <class T>
static _ALWAYS_INLINE_ T atomic_decrement(volatile T *pw) {
- return __atomic_sub_fetch(pw, 1, __ATOMIC_SEQ_CST);
+ return __sync_sub_and_fetch(pw, 1);
}
template <class T>
static _ALWAYS_INLINE_ T atomic_increment(volatile T *pw) {
- return __atomic_add_fetch(pw, 1, __ATOMIC_SEQ_CST);
+ return __sync_add_and_fetch(pw, 1);
}
template <class T, class V>
static _ALWAYS_INLINE_ T atomic_sub(volatile T *pw, volatile V val) {
- return __atomic_sub_fetch(pw, val, __ATOMIC_SEQ_CST);
+ return __sync_sub_and_fetch(pw, val);
}
template <class T, class V>
static _ALWAYS_INLINE_ T atomic_add(volatile T *pw, volatile V val) {
- return __atomic_add_fetch(pw, val, __ATOMIC_SEQ_CST);
+ return __sync_add_and_fetch(pw, val);
}
template <class T, class V>
@@ -143,7 +143,7 @@ static _ALWAYS_INLINE_ T atomic_exchange_if_greater(volatile T *pw, volatile V v
T tmp = static_cast<T const volatile &>(*pw);
if (tmp >= val)
return tmp; // already greater, or equal
- if (__atomic_compare_exchange_n(pw, &tmp, val, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST) == true)
+ if (__sync_val_compare_and_swap(pw, tmp, val) == tmp)
return val;
}
}
diff --git a/core/variant_call.cpp b/core/variant_call.cpp
index 05ef51cecd..5e3876d6a4 100644
--- a/core/variant_call.cpp
+++ b/core/variant_call.cpp
@@ -751,6 +751,7 @@ struct _VariantCall {
case Variant::VECTOR2: r_ret = reinterpret_cast<Transform2D *>(p_self._data._ptr)->xform(p_args[0]->operator Vector2()); return;
case Variant::RECT2: r_ret = reinterpret_cast<Transform2D *>(p_self._data._ptr)->xform(p_args[0]->operator Rect2()); return;
+ case Variant::POOL_VECTOR2_ARRAY: r_ret = reinterpret_cast<Transform2D *>(p_self._data._ptr)->xform(p_args[0]->operator PoolVector2Array()); return;
default: r_ret = Variant();
}
}
@@ -761,6 +762,7 @@ struct _VariantCall {
case Variant::VECTOR2: r_ret = reinterpret_cast<Transform2D *>(p_self._data._ptr)->xform_inv(p_args[0]->operator Vector2()); return;
case Variant::RECT2: r_ret = reinterpret_cast<Transform2D *>(p_self._data._ptr)->xform_inv(p_args[0]->operator Rect2()); return;
+ case Variant::POOL_VECTOR2_ARRAY: r_ret = reinterpret_cast<Transform2D *>(p_self._data._ptr)->xform_inv(p_args[0]->operator PoolVector2Array()); return;
default: r_ret = Variant();
}
}
@@ -817,6 +819,7 @@ struct _VariantCall {
case Variant::VECTOR3: r_ret = reinterpret_cast<Transform *>(p_self._data._ptr)->xform(p_args[0]->operator Vector3()); return;
case Variant::PLANE: r_ret = reinterpret_cast<Transform *>(p_self._data._ptr)->xform(p_args[0]->operator Plane()); return;
case Variant::AABB: r_ret = reinterpret_cast<Transform *>(p_self._data._ptr)->xform(p_args[0]->operator ::AABB()); return;
+ case Variant::POOL_VECTOR3_ARRAY: r_ret = reinterpret_cast<Transform *>(p_self._data._ptr)->xform(p_args[0]->operator ::PoolVector3Array()); return;
default: r_ret = Variant();
}
}
@@ -828,6 +831,7 @@ struct _VariantCall {
case Variant::VECTOR3: r_ret = reinterpret_cast<Transform *>(p_self._data._ptr)->xform_inv(p_args[0]->operator Vector3()); return;
case Variant::PLANE: r_ret = reinterpret_cast<Transform *>(p_self._data._ptr)->xform_inv(p_args[0]->operator Plane()); return;
case Variant::AABB: r_ret = reinterpret_cast<Transform *>(p_self._data._ptr)->xform_inv(p_args[0]->operator ::AABB()); return;
+ case Variant::POOL_VECTOR3_ARRAY: r_ret = reinterpret_cast<Transform *>(p_self._data._ptr)->xform_inv(p_args[0]->operator ::PoolVector3Array()); return;
default: r_ret = Variant();
}
}
diff --git a/doc/classes/AudioStreamGenerator.xml b/doc/classes/AudioStreamGenerator.xml
index 9d67b88c71..9a1e4432f1 100644
--- a/doc/classes/AudioStreamGenerator.xml
+++ b/doc/classes/AudioStreamGenerator.xml
@@ -5,6 +5,7 @@
<description>
</description>
<tutorials>
+ <link>https://github.com/godotengine/godot-demo-projects/tree/master/audio/generator</link>
</tutorials>
<methods>
</methods>
diff --git a/doc/classes/AudioStreamGeneratorPlayback.xml b/doc/classes/AudioStreamGeneratorPlayback.xml
index 310b58c4e5..448284e670 100644
--- a/doc/classes/AudioStreamGeneratorPlayback.xml
+++ b/doc/classes/AudioStreamGeneratorPlayback.xml
@@ -5,6 +5,7 @@
<description>
</description>
<tutorials>
+ <link>https://github.com/godotengine/godot-demo-projects/tree/master/audio/generator</link>
</tutorials>
<methods>
<method name="can_push_buffer" qualifiers="const">
diff --git a/doc/classes/AudioStreamSample.xml b/doc/classes/AudioStreamSample.xml
index 6d03301749..a496902ded 100644
--- a/doc/classes/AudioStreamSample.xml
+++ b/doc/classes/AudioStreamSample.xml
@@ -24,6 +24,7 @@
<members>
<member name="data" type="PoolByteArray" setter="set_data" getter="get_data" default="PoolByteArray( )">
Contains the audio data in bytes.
+ [b]Note:[/b] This property expects signed PCM8 data. To convert unsigned PCM8 to signed PCM8, subtract 128 from each byte.
</member>
<member name="format" type="int" setter="set_format" getter="get_format" enum="AudioStreamSample.Format" default="0">
Audio format. See [code]FORMAT_*[/code] constants for values.
diff --git a/doc/classes/Geometry.xml b/doc/classes/Geometry.xml
index 3cbbe6da56..3824baa4dc 100644
--- a/doc/classes/Geometry.xml
+++ b/doc/classes/Geometry.xml
@@ -216,6 +216,19 @@
Intersects [code]polyline[/code] with [code]polygon[/code] and returns an array of intersected polylines. This performs [constant OPERATION_INTERSECTION] between the polyline and the polygon. This operation can be thought of as chopping a line with a closed shape.
</description>
</method>
+ <method name="is_point_in_circle">
+ <return type="bool">
+ </return>
+ <argument index="0" name="point" type="Vector2">
+ </argument>
+ <argument index="1" name="circle_position" type="Vector2">
+ </argument>
+ <argument index="2" name="circle_radius" type="float">
+ </argument>
+ <description>
+ Returns [code]true[/code] if [code]point[/code] is inside the circle or if it's located exactly [i]on[/i] the circle's boundary, otherwise returns [code]false[/code].
+ </description>
+ </method>
<method name="is_point_in_polygon">
<return type="bool">
</return>
@@ -428,18 +441,6 @@
Tests if the segment ([code]from[/code], [code]to[/code]) intersects the triangle [code]a[/code], [code]b[/code], [code]c[/code]. If yes, returns the point of intersection as [Vector3]. If no intersection takes place, an empty [Variant] is returned.
</description>
</method>
- <method name="transform_points_2d">
- <return type="PoolVector2Array">
- </return>
- <argument index="0" name="points" type="PoolVector2Array">
- </argument>
- <argument index="1" name="transform" type="Transform2D">
- </argument>
- <description>
- Transforms an array of points by [code]transform[/code] and returns the result.
- Can be useful in conjunction with performing polygon boolean operations in a CSG-like manner, see [method merge_polygons_2d], [method clip_polygons_2d], [method intersect_polygons_2d], [method exclude_polygons_2d].
- </description>
- </method>
<method name="triangulate_delaunay_2d">
<return type="PoolIntArray">
</return>
diff --git a/doc/classes/GraphNode.xml b/doc/classes/GraphNode.xml
index 6bc09e5289..8aefa41f8a 100644
--- a/doc/classes/GraphNode.xml
+++ b/doc/classes/GraphNode.xml
@@ -257,6 +257,8 @@
</theme_item>
<theme_item name="resizer" type="Texture">
</theme_item>
+ <theme_item name="resizer_color" type="Color" default="Color( 0, 0, 0, 1 )">
+ </theme_item>
<theme_item name="selectedframe" type="StyleBox">
</theme_item>
<theme_item name="separation" type="int" default="1">
diff --git a/doc/classes/Transform.xml b/doc/classes/Transform.xml
index 9916d25af5..6ebc389ed7 100644
--- a/doc/classes/Transform.xml
+++ b/doc/classes/Transform.xml
@@ -144,7 +144,7 @@
<argument index="0" name="v" type="Variant">
</argument>
<description>
- Transforms the given [Vector3], [Plane], or [AABB] by this transform.
+ Transforms the given [Vector3], [Plane], [AABB], or [PoolVector3Array] by this transform.
</description>
</method>
<method name="xform_inv">
@@ -153,7 +153,7 @@
<argument index="0" name="v" type="Variant">
</argument>
<description>
- Inverse-transforms the given [Vector3], [Plane], or [AABB] by this transform.
+ Inverse-transforms the given [Vector3], [Plane], [AABB], or [PoolVector3Array] by this transform.
</description>
</method>
</methods>
diff --git a/doc/classes/Transform2D.xml b/doc/classes/Transform2D.xml
index f6fce1aaa1..580da080b3 100644
--- a/doc/classes/Transform2D.xml
+++ b/doc/classes/Transform2D.xml
@@ -146,7 +146,7 @@
<argument index="0" name="v" type="Variant">
</argument>
<description>
- Transforms the given [Vector2] or [Rect2] by this transform.
+ Transforms the given [Vector2], [Rect2], or [PoolVector2Array] by this transform.
</description>
</method>
<method name="xform_inv">
@@ -155,7 +155,7 @@
<argument index="0" name="v" type="Variant">
</argument>
<description>
- Inverse-transforms the given [Vector2] or [Rect2] by this transform.
+ Inverse-transforms the given [Vector2], [Rect2], or [PoolVector2Array] by this transform.
</description>
</method>
</methods>
diff --git a/doc/classes/VisualShaderNodeCustom.xml b/doc/classes/VisualShaderNodeCustom.xml
index 9067097f0b..9e58abae97 100644
--- a/doc/classes/VisualShaderNodeCustom.xml
+++ b/doc/classes/VisualShaderNodeCustom.xml
@@ -13,6 +13,7 @@
[/codeblock]
</description>
<tutorials>
+ <link>http://docs.godotengine.org/en/latest/tutorials/plugins/editor/visual_shader_plugins.html</link>
</tutorials>
<methods>
<method name="_get_category" qualifiers="virtual">
diff --git a/drivers/png/resource_saver_png.cpp b/drivers/png/resource_saver_png.cpp
index 7a2eeafdc3..3b3f1506dc 100644
--- a/drivers/png/resource_saver_png.cpp
+++ b/drivers/png/resource_saver_png.cpp
@@ -53,9 +53,9 @@ Error ResourceSaverPNG::save_image(const String &p_path, const Ref<Image> &p_img
PoolVector<uint8_t> buffer;
Error err = PNGDriverCommon::image_to_png(p_img, buffer);
- ERR_FAIL_COND_V(err, err);
+ ERR_FAIL_COND_V_MSG(err, err, "Can't convert image to PNG.");
FileAccess *file = FileAccess::open(p_path, FileAccess::WRITE, &err);
- ERR_FAIL_COND_V(err, err);
+ ERR_FAIL_COND_V_MSG(err, err, vformat("Can't save PNG at path: '%s'.", p_path));
PoolVector<uint8_t>::Read reader = buffer.read();
diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp
index 61adff7c9c..606b619cac 100644
--- a/editor/code_editor.cpp
+++ b/editor/code_editor.cpp
@@ -887,33 +887,33 @@ bool CodeTextEditor::_add_font_size(int p_delta) {
void CodeTextEditor::update_editor_settings() {
- text_editor->set_auto_brace_completion(EditorSettings::get_singleton()->get("text_editor/completion/auto_brace_complete"));
- text_editor->set_scroll_pass_end_of_file(EditorSettings::get_singleton()->get("text_editor/cursor/scroll_past_end_of_file"));
+ text_editor->set_syntax_coloring(EditorSettings::get_singleton()->get("text_editor/highlighting/syntax_highlighting"));
+ text_editor->set_highlight_all_occurrences(EditorSettings::get_singleton()->get("text_editor/highlighting/highlight_all_occurrences"));
+ text_editor->set_highlight_current_line(EditorSettings::get_singleton()->get("text_editor/highlighting/highlight_current_line"));
text_editor->set_indent_using_spaces(EditorSettings::get_singleton()->get("text_editor/indent/type"));
text_editor->set_indent_size(EditorSettings::get_singleton()->get("text_editor/indent/size"));
text_editor->set_auto_indent(EditorSettings::get_singleton()->get("text_editor/indent/auto_indent"));
text_editor->set_draw_tabs(EditorSettings::get_singleton()->get("text_editor/indent/draw_tabs"));
text_editor->set_draw_spaces(EditorSettings::get_singleton()->get("text_editor/indent/draw_spaces"));
- text_editor->set_show_line_numbers(EditorSettings::get_singleton()->get("text_editor/line_numbers/show_line_numbers"));
- text_editor->set_line_numbers_zero_padded(EditorSettings::get_singleton()->get("text_editor/line_numbers/line_numbers_zero_padded"));
- text_editor->set_show_line_length_guideline(EditorSettings::get_singleton()->get("text_editor/line_numbers/show_line_length_guideline"));
- text_editor->set_line_length_guideline_column(EditorSettings::get_singleton()->get("text_editor/line_numbers/line_length_guideline_column"));
- text_editor->set_syntax_coloring(EditorSettings::get_singleton()->get("text_editor/highlighting/syntax_highlighting"));
- text_editor->set_highlight_all_occurrences(EditorSettings::get_singleton()->get("text_editor/highlighting/highlight_all_occurrences"));
- text_editor->set_highlight_current_line(EditorSettings::get_singleton()->get("text_editor/highlighting/highlight_current_line"));
+ text_editor->set_smooth_scroll_enabled(EditorSettings::get_singleton()->get("text_editor/navigation/smooth_scrolling"));
+ text_editor->set_v_scroll_speed(EditorSettings::get_singleton()->get("text_editor/navigation/v_scroll_speed"));
+ text_editor->set_draw_minimap(EditorSettings::get_singleton()->get("text_editor/navigation/show_minimap"));
+ text_editor->set_minimap_width(EditorSettings::get_singleton()->get("text_editor/navigation/minimap_width"));
+ text_editor->set_show_line_numbers(EditorSettings::get_singleton()->get("text_editor/appearance/show_line_numbers"));
+ text_editor->set_line_numbers_zero_padded(EditorSettings::get_singleton()->get("text_editor/appearance/line_numbers_zero_padded"));
+ text_editor->set_bookmark_gutter_enabled(EditorSettings::get_singleton()->get("text_editor/appearance/show_bookmark_gutter"));
+ text_editor->set_breakpoint_gutter_enabled(EditorSettings::get_singleton()->get("text_editor/appearance/show_breakpoint_gutter"));
+ text_editor->set_draw_info_gutter(EditorSettings::get_singleton()->get("text_editor/appearance/show_info_gutter"));
+ text_editor->set_hiding_enabled(EditorSettings::get_singleton()->get("text_editor/appearance/code_folding"));
+ text_editor->set_draw_fold_gutter(EditorSettings::get_singleton()->get("text_editor/appearance/code_folding"));
+ text_editor->set_wrap_enabled(EditorSettings::get_singleton()->get("text_editor/appearance/word_wrap"));
+ text_editor->set_show_line_length_guideline(EditorSettings::get_singleton()->get("text_editor/appearance/show_line_length_guideline"));
+ text_editor->set_line_length_guideline_column(EditorSettings::get_singleton()->get("text_editor/appearance/line_length_guideline_column"));
+ text_editor->set_scroll_pass_end_of_file(EditorSettings::get_singleton()->get("text_editor/cursor/scroll_past_end_of_file"));
+ text_editor->cursor_set_block_mode(EditorSettings::get_singleton()->get("text_editor/cursor/block_caret"));
text_editor->cursor_set_blink_enabled(EditorSettings::get_singleton()->get("text_editor/cursor/caret_blink"));
text_editor->cursor_set_blink_speed(EditorSettings::get_singleton()->get("text_editor/cursor/caret_blink_speed"));
- text_editor->set_bookmark_gutter_enabled(EditorSettings::get_singleton()->get("text_editor/line_numbers/show_bookmark_gutter"));
- text_editor->set_breakpoint_gutter_enabled(EditorSettings::get_singleton()->get("text_editor/line_numbers/show_breakpoint_gutter"));
- text_editor->set_hiding_enabled(EditorSettings::get_singleton()->get("text_editor/line_numbers/code_folding"));
- text_editor->set_draw_fold_gutter(EditorSettings::get_singleton()->get("text_editor/line_numbers/code_folding"));
- text_editor->set_wrap_enabled(EditorSettings::get_singleton()->get("text_editor/line_numbers/word_wrap"));
- text_editor->set_draw_minimap(EditorSettings::get_singleton()->get("text_editor/line_numbers/draw_minimap"));
- text_editor->set_minimap_width(EditorSettings::get_singleton()->get("text_editor/line_numbers/minimap_width"));
- text_editor->set_draw_info_gutter(EditorSettings::get_singleton()->get("text_editor/line_numbers/show_info_gutter"));
- text_editor->cursor_set_block_mode(EditorSettings::get_singleton()->get("text_editor/cursor/block_caret"));
- text_editor->set_smooth_scroll_enabled(EditorSettings::get_singleton()->get("text_editor/open_scripts/smooth_scrolling"));
- text_editor->set_v_scroll_speed(EditorSettings::get_singleton()->get("text_editor/open_scripts/v_scroll_speed"));
+ text_editor->set_auto_brace_completion(EditorSettings::get_singleton()->get("text_editor/completion/auto_brace_complete"));
}
void CodeTextEditor::trim_trailing_whitespace() {
diff --git a/editor/collada/collada.cpp b/editor/collada/collada.cpp
index aea7f461f1..1bb49a4167 100644
--- a/editor/collada/collada.cpp
+++ b/editor/collada/collada.cpp
@@ -28,8 +28,6 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifdef TOOLS_ENABLED
-
#include "collada.h"
#include <stdio.h>
@@ -2576,5 +2574,3 @@ Error Collada::load(const String &p_path, int p_flags) {
Collada::Collada() {
}
-
-#endif
diff --git a/editor/collada/collada.h b/editor/collada/collada.h
index 9ed62b46b7..317c3f1d37 100644
--- a/editor/collada/collada.h
+++ b/editor/collada/collada.h
@@ -28,8 +28,6 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifdef TOOLS_ENABLED
-
#ifndef COLLADA_H
#define COLLADA_H
@@ -647,5 +645,3 @@ private: // private stuff
};
#endif // COLLADA_H
-
-#endif
diff --git a/editor/create_dialog.cpp b/editor/create_dialog.cpp
index 8a8d52c6f1..d5f0dc01ee 100644
--- a/editor/create_dialog.cpp
+++ b/editor/create_dialog.cpp
@@ -191,34 +191,41 @@ void CreateDialog::add_type(const String &p_type, HashMap<String, TreeItem *> &p
item->set_custom_color(0, get_color("disabled_font_color", "Editor"));
item->set_selectable(0, false);
} else if (!(*to_select && (*to_select)->get_text(0) == search_box->get_text())) {
- bool current_type_prefered = _is_type_prefered(p_type);
- bool selected_type_prefered = *to_select ? _is_type_prefered((*to_select)->get_text(0).split(" ")[0]) : false;
-
String search_term = search_box->get_text().to_lower();
- bool is_subsequence_of_type = search_box->get_text().is_subsequence_ofi(p_type);
- bool is_substring_of_type = p_type.to_lower().find(search_term) >= 0;
- bool is_substring_of_selected = false;
- bool is_subsequence_of_selected = false;
- bool is_selected_equal = false;
-
- if (*to_select) {
- String name = (*to_select)->get_text(0).split(" ")[0].to_lower();
- is_substring_of_selected = name.find(search_term) >= 0;
- is_subsequence_of_selected = search_term.is_subsequence_of(name);
- is_selected_equal = name == search_term;
- }
- if (is_subsequence_of_type && !is_selected_equal) {
- if (is_substring_of_type) {
- if (!is_substring_of_selected || (current_type_prefered && !selected_type_prefered)) {
- *to_select = item;
- }
- } else {
- // substring results weigh more than subsequences, so let's make sure we don't override them
- if (!is_substring_of_selected) {
- if (!is_subsequence_of_selected || (current_type_prefered && !selected_type_prefered)) {
+ // if the node name matches exactly as the search, the node should be selected.
+ // this also fixes when the user clicks on recent nodes.
+ if (p_type.to_lower() == search_term) {
+ *to_select = item;
+ } else {
+ bool current_type_prefered = _is_type_prefered(p_type);
+ bool selected_type_prefered = *to_select ? _is_type_prefered((*to_select)->get_text(0).split(" ")[0]) : false;
+
+ bool is_subsequence_of_type = search_box->get_text().is_subsequence_ofi(p_type);
+ bool is_substring_of_type = p_type.to_lower().find(search_term) >= 0;
+ bool is_substring_of_selected = false;
+ bool is_subsequence_of_selected = false;
+ bool is_selected_equal = false;
+
+ if (*to_select) {
+ String name = (*to_select)->get_text(0).split(" ")[0].to_lower();
+ is_substring_of_selected = name.find(search_term) >= 0;
+ is_subsequence_of_selected = search_term.is_subsequence_of(name);
+ is_selected_equal = name == search_term;
+ }
+
+ if (is_subsequence_of_type && !is_selected_equal) {
+ if (is_substring_of_type) {
+ if (!is_substring_of_selected || (current_type_prefered && !selected_type_prefered)) {
*to_select = item;
}
+ } else {
+ // substring results weigh more than subsequences, so let's make sure we don't override them
+ if (!is_substring_of_selected) {
+ if (!is_subsequence_of_selected || (current_type_prefered && !selected_type_prefered)) {
+ *to_select = item;
+ }
+ }
}
}
}
diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp
index 2e8f8ec646..e6df00b48c 100644
--- a/editor/editor_help.cpp
+++ b/editor/editor_help.cpp
@@ -54,6 +54,7 @@ void EditorHelp::_init_colors() {
qualifier_color = text_color * Color(1, 1, 1, 0.8);
type_color = get_color("accent_color", "Editor").linear_interpolate(text_color, 0.5);
class_desc->add_color_override("selection_color", get_color("accent_color", "Editor") * Color(1, 1, 1, 0.4));
+ class_desc->add_constant_override("line_separation", Math::round(5 * EDSCALE));
}
void EditorHelp::_unhandled_key_input(const Ref<InputEvent> &p_ev) {
diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp
index 8b3e108690..a76d34e122 100644
--- a/editor/editor_inspector.cpp
+++ b/editor/editor_inspector.cpp
@@ -1044,7 +1044,6 @@ void EditorInspectorSection::_notification(int p_what) {
Ref<Font> font = get_font("font", "Tree");
Ref<Texture> arrow;
-#ifdef TOOLS_ENABLED
if (foldable) {
if (object->editor_is_section_unfolded(section)) {
arrow = get_icon("arrow_up", "Tree");
@@ -1052,7 +1051,6 @@ void EditorInspectorSection::_notification(int p_what) {
arrow = get_icon("arrow", "Tree");
}
}
-#endif
Size2 size = get_size();
Point2 offset;
@@ -1087,7 +1085,6 @@ void EditorInspectorSection::_notification(int p_what) {
Ref<Texture> arrow;
-#ifdef TOOLS_ENABLED
if (foldable) {
if (object->editor_is_section_unfolded(section)) {
arrow = get_icon("arrow_up", "Tree");
@@ -1095,7 +1092,6 @@ void EditorInspectorSection::_notification(int p_what) {
arrow = get_icon("arrow", "Tree");
}
}
-#endif
Ref<Font> font = get_font("font", "Tree");
@@ -1155,7 +1151,6 @@ void EditorInspectorSection::setup(const String &p_section, const String &p_labe
vbox_added = true;
}
-#ifdef TOOLS_ENABLED
if (foldable) {
_test_unfold();
if (object->editor_is_section_unfolded(section)) {
@@ -1164,7 +1159,6 @@ void EditorInspectorSection::setup(const String &p_section, const String &p_labe
vbox->hide();
}
}
-#endif
}
void EditorInspectorSection::_gui_input(const Ref<InputEvent> &p_event) {
@@ -1172,7 +1166,6 @@ void EditorInspectorSection::_gui_input(const Ref<InputEvent> &p_event) {
if (!foldable)
return;
-#ifdef TOOLS_ENABLED
Ref<InputEventMouseButton> mb = p_event;
if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == BUTTON_LEFT) {
@@ -1191,7 +1184,6 @@ void EditorInspectorSection::_gui_input(const Ref<InputEvent> &p_event) {
vbox->hide();
}
}
-#endif
}
VBoxContainer *EditorInspectorSection::get_vbox() {
@@ -1205,11 +1197,9 @@ void EditorInspectorSection::unfold() {
_test_unfold();
-#ifdef TOOLS_ENABLED
object->editor_set_section_unfold(section, true);
vbox->show();
update();
-#endif
}
void EditorInspectorSection::fold() {
@@ -1219,11 +1209,9 @@ void EditorInspectorSection::fold() {
if (!vbox_added)
return; //kinda pointless
-#ifdef TOOLS_ENABLED
object->editor_set_section_unfold(section, false);
vbox->hide();
update();
-#endif
}
void EditorInspectorSection::_bind_methods() {
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index 635f6d4fc7..8ed6cec779 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -2632,11 +2632,8 @@ void EditorNode::_exit_editor() {
resource_preview->stop(); //stop early to avoid crashes
_save_docks();
- // Dim the editor window while it's quitting to make it clearer that it's busy.
- // No transition is applied, as the effect needs to be visible immediately
- float c = 0.4f;
- Color dim_color = Color(c, c, c);
- gui_base->set_modulate(dim_color);
+ // Dim the editor window while it's quitting to make it clearer that it's busy
+ dim_editor(true, true);
get_tree()->quit();
}
@@ -5133,46 +5130,12 @@ void EditorNode::_open_imported() {
load_scene(open_import_request, true, false, true, true);
}
-void EditorNode::dim_editor(bool p_dimming) {
- static int dim_count = 0;
- bool dim_ui = EditorSettings::get_singleton()->get("interface/editor/dim_editor_on_dialog_popup");
- if (p_dimming) {
- if (dim_ui && dim_count == 0) {
- _start_dimming(true);
- }
- dim_count++;
- } else {
- if (dim_count == 1) {
- _start_dimming(false);
- }
- if (dim_count > 0) {
- dim_count--;
- } else {
- ERR_PRINT("Undimmed before dimming!");
- }
- }
-}
-
-void EditorNode::_start_dimming(bool p_dimming) {
- _dimming = p_dimming;
- _dim_time = 0.0f;
- _dim_timer->start();
-}
-
-void EditorNode::_dim_timeout() {
-
- _dim_time += _dim_timer->get_wait_time();
- float wait_time = 0.08f;
- float c = 0.4f;
-
- Color base = _dimming ? Color(1, 1, 1) : Color(c, c, c);
- Color final = _dimming ? Color(c, c, c) : Color(1, 1, 1);
-
- if (_dim_time + _dim_timer->get_wait_time() >= wait_time) {
- gui_base->set_modulate(final);
- _dim_timer->stop();
+void EditorNode::dim_editor(bool p_dimming, bool p_force_dim) {
+ // Dimming can be forced regardless of the editor setting, which is useful when quitting the editor
+ if ((p_force_dim || EditorSettings::get_singleton()->get("interface/editor/dim_editor_on_dialog_popup")) && p_dimming) {
+ gui_base->set_modulate(Color(0.5, 0.5, 0.5));
} else {
- gui_base->set_modulate(base.linear_interpolate(final, _dim_time / wait_time));
+ gui_base->set_modulate(Color(1, 1, 1));
}
}
@@ -5356,7 +5319,6 @@ void EditorNode::_bind_methods() {
ClassDB::bind_method(D_METHOD("_open_imported"), &EditorNode::_open_imported);
ClassDB::bind_method(D_METHOD("_inherit_imported"), &EditorNode::_inherit_imported);
- ClassDB::bind_method(D_METHOD("_dim_timeout"), &EditorNode::_dim_timeout);
ClassDB::bind_method("_copy_warning", &EditorNode::_copy_warning);
@@ -5818,6 +5780,7 @@ EditorNode::EditorNode() {
dock_slot[i]->set_drag_to_rearrange_enabled(true);
dock_slot[i]->set_tabs_rearrange_group(1);
dock_slot[i]->connect("tab_changed", this, "_dock_tab_changed");
+ dock_slot[i]->set_use_hidden_tabs_for_min_size(true);
}
dock_drag_timer = memnew(Timer);
@@ -6411,13 +6374,13 @@ EditorNode::EditorNode() {
gui_base->add_child(custom_build_manage_templates);
install_android_build_template = memnew(ConfirmationDialog);
- install_android_build_template->set_text(TTR("This will install the Android project for custom builds.\nNote that, in order to use it, it needs to be enabled per export preset."));
+ install_android_build_template->set_text(TTR("This will set up your project for custom Android builds by installing the source template to \"res://android/build\".\nYou can then apply modifications and build your own custom APK on export (adding modules, changing the AndroidManifest.xml, etc.).\nNote that in order to make custom builds instead of using pre-built APKs, the \"Use Custom Build\" option should be enabled in the Android export preset."));
install_android_build_template->get_ok()->set_text(TTR("Install"));
install_android_build_template->connect("confirmed", this, "_menu_confirm_current");
gui_base->add_child(install_android_build_template);
remove_android_build_template = memnew(ConfirmationDialog);
- remove_android_build_template->set_text(TTR("Android build template is already installed and it won't be overwritten.\nRemove the \"build\" directory manually before attempting this operation again."));
+ remove_android_build_template->set_text(TTR("The Android build template is already installed in this project and it won't be overwritten.\nRemove the \"res://android/build\" directory manually before attempting this operation again."));
remove_android_build_template->get_ok()->set_text(TTR("Show in File Manager"));
remove_android_build_template->connect("confirmed", this, "_menu_option", varray(FILE_EXPLORE_ANDROID_BUILD_TEMPLATES));
gui_base->add_child(remove_android_build_template);
@@ -6687,13 +6650,6 @@ EditorNode::EditorNode() {
waiting_for_first_scan = true;
- _dimming = false;
- _dim_time = 0.0f;
- _dim_timer = memnew(Timer);
- _dim_timer->set_wait_time(0.01666f);
- _dim_timer->connect("timeout", this, "_dim_timeout");
- add_child(_dim_timer);
-
print_handler.printfunc = _print_handler;
print_handler.userdata = this;
add_print_handler(&print_handler);
diff --git a/editor/editor_node.h b/editor/editor_node.h
index 61bbb7b86d..54bcf14c1b 100644
--- a/editor/editor_node.h
+++ b/editor/editor_node.h
@@ -633,13 +633,6 @@ private:
static int build_callback_count;
static EditorBuildCallback build_callbacks[MAX_BUILD_CALLBACKS];
- bool _dimming;
- float _dim_time;
- Timer *_dim_timer;
-
- void _start_dimming(bool p_dimming);
- void _dim_timeout();
-
void _license_tree_selected();
void _update_update_spinner();
@@ -849,7 +842,7 @@ public:
void save_scene_list(Vector<String> p_scene_filenames);
void restart_editor();
- void dim_editor(bool p_dimming);
+ void dim_editor(bool p_dimming, bool p_force_dim = false);
void edit_current() { _edit_current(); };
diff --git a/editor/editor_plugin.cpp b/editor/editor_plugin.cpp
index e27f1ab9eb..d9fd0659aa 100644
--- a/editor/editor_plugin.cpp
+++ b/editor/editor_plugin.cpp
@@ -238,7 +238,7 @@ Control *EditorInterface::get_base_control() {
}
void EditorInterface::set_plugin_enabled(const String &p_plugin, bool p_enabled) {
- EditorNode::get_singleton()->set_addon_plugin_enabled(p_plugin, p_enabled);
+ EditorNode::get_singleton()->set_addon_plugin_enabled(p_plugin, p_enabled, true);
}
bool EditorInterface::is_plugin_enabled(const String &p_plugin) const {
diff --git a/editor/editor_plugin_settings.cpp b/editor/editor_plugin_settings.cpp
index 09577e39e1..514b3ff5d2 100644
--- a/editor/editor_plugin_settings.cpp
+++ b/editor/editor_plugin_settings.cpp
@@ -96,45 +96,59 @@ void EditorPluginSettings::update_plugins() {
if (err2 != OK) {
WARN_PRINTS("Can't load plugin config: " + path);
- } else if (!cf->has_section_key("plugin", "name")) {
- WARN_PRINTS("Plugin misses plugin/name: " + path);
- } else if (!cf->has_section_key("plugin", "author")) {
- WARN_PRINTS("Plugin misses plugin/author: " + path);
- } else if (!cf->has_section_key("plugin", "version")) {
- WARN_PRINTS("Plugin misses plugin/version: " + path);
- } else if (!cf->has_section_key("plugin", "description")) {
- WARN_PRINTS("Plugin misses plugin/description: " + path);
- } else if (!cf->has_section_key("plugin", "script")) {
- WARN_PRINTS("Plugin misses plugin/script: " + path);
} else {
+ bool key_missing = false;
- String d2 = plugins[i];
- String name = cf->get_value("plugin", "name");
- String author = cf->get_value("plugin", "author");
- String version = cf->get_value("plugin", "version");
- String description = cf->get_value("plugin", "description");
- String script = cf->get_value("plugin", "script");
-
- TreeItem *item = plugin_list->create_item(root);
- item->set_text(0, name);
- item->set_tooltip(0, "Name: " + name + "\nPath: " + path + "\nMain Script: " + script + "\nDescription: " + description);
- item->set_metadata(0, d2);
- item->set_text(1, version);
- item->set_metadata(1, script);
- item->set_text(2, author);
- item->set_metadata(2, description);
- item->set_cell_mode(3, TreeItem::CELL_MODE_RANGE);
- item->set_range_config(3, 0, 1, 1);
- item->set_text(3, "Inactive,Active");
- item->set_editable(3, true);
- item->add_button(4, get_icon("Edit", "EditorIcons"), BUTTON_PLUGIN_EDIT, false, TTR("Edit Plugin"));
-
- if (EditorNode::get_singleton()->is_addon_plugin_enabled(d2)) {
- item->set_custom_color(3, get_color("success_color", "Editor"));
- item->set_range(3, 1);
- } else {
- item->set_custom_color(3, get_color("disabled_font_color", "Editor"));
- item->set_range(3, 0);
+ if (!cf->has_section_key("plugin", "name")) {
+ WARN_PRINTS("Plugin config misses \"plugin/name\" key: " + path);
+ key_missing = true;
+ }
+ if (!cf->has_section_key("plugin", "author")) {
+ WARN_PRINTS("Plugin config misses \"plugin/author\" key: " + path);
+ key_missing = true;
+ }
+ if (!cf->has_section_key("plugin", "version")) {
+ WARN_PRINTS("Plugin config misses \"plugin/version\" key: " + path);
+ key_missing = true;
+ }
+ if (!cf->has_section_key("plugin", "description")) {
+ WARN_PRINTS("Plugin config misses \"plugin/description\" key: " + path);
+ key_missing = true;
+ }
+ if (!cf->has_section_key("plugin", "script")) {
+ WARN_PRINTS("Plugin config misses \"plugin/script\" key: " + path);
+ key_missing = true;
+ }
+
+ if (!key_missing) {
+ String d2 = plugins[i];
+ String name = cf->get_value("plugin", "name");
+ String author = cf->get_value("plugin", "author");
+ String version = cf->get_value("plugin", "version");
+ String description = cf->get_value("plugin", "description");
+ String script = cf->get_value("plugin", "script");
+
+ TreeItem *item = plugin_list->create_item(root);
+ item->set_text(0, name);
+ item->set_tooltip(0, TTR("Name:") + " " + name + "\n" + TTR("Path:") + " " + path + "\n" + TTR("Main Script:") + " " + script + "\n" + TTR("Description:") + " " + description);
+ item->set_metadata(0, d2);
+ item->set_text(1, version);
+ item->set_metadata(1, script);
+ item->set_text(2, author);
+ item->set_metadata(2, description);
+ item->set_cell_mode(3, TreeItem::CELL_MODE_RANGE);
+ item->set_range_config(3, 0, 1, 1);
+ item->set_text(3, "Inactive,Active");
+ item->set_editable(3, true);
+ item->add_button(4, get_icon("Edit", "EditorIcons"), BUTTON_PLUGIN_EDIT, false, TTR("Edit Plugin"));
+
+ if (EditorNode::get_singleton()->is_addon_plugin_enabled(d2)) {
+ item->set_custom_color(3, get_color("success_color", "Editor"));
+ item->set_range(3, 1);
+ } else {
+ item->set_custom_color(3, get_color("disabled_font_color", "Editor"));
+ item->set_range(3, 0);
+ }
}
}
}
diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp
index 378dd34e39..d7b3c7733b 100644
--- a/editor/editor_properties.cpp
+++ b/editor/editor_properties.cpp
@@ -2540,7 +2540,7 @@ void EditorPropertyResource::update_property() {
if (res.is_valid() != assign->is_toggle_mode()) {
assign->set_toggle_mode(res.is_valid());
}
-#ifdef TOOLS_ENABLED
+
if (res.is_valid() && get_edited_object()->editor_is_section_unfolded(get_edited_property())) {
if (!sub_inspector) {
@@ -2609,7 +2609,6 @@ void EditorPropertyResource::update_property() {
}
}
}
-#endif
}
preview->set_texture(Ref<Texture>());
diff --git a/editor/editor_properties_array_dict.cpp b/editor/editor_properties_array_dict.cpp
index d1371a04b1..ff19be8bd5 100644
--- a/editor/editor_properties_array_dict.cpp
+++ b/editor/editor_properties_array_dict.cpp
@@ -271,8 +271,6 @@ void EditorPropertyArray::update_property() {
edit->set_text(arrtype + " (size " + itos(array.call("size")) + ")");
-#ifdef TOOLS_ENABLED
-
bool unfolded = get_edited_object()->editor_is_section_unfolded(get_edited_property());
if (edit->is_pressed() != unfolded) {
edit->set_pressed(unfolded);
@@ -397,7 +395,6 @@ void EditorPropertyArray::update_property() {
vbox = NULL;
}
}
-#endif
}
void EditorPropertyArray::_remove_pressed(int p_index) {
@@ -643,8 +640,6 @@ void EditorPropertyDictionary::update_property() {
edit->set_text("Dictionary (size " + itos(dict.size()) + ")");
-#ifdef TOOLS_ENABLED
-
bool unfolded = get_edited_object()->editor_is_section_unfolded(get_edited_property());
if (edit->is_pressed() != unfolded) {
edit->set_pressed(unfolded);
@@ -959,7 +954,6 @@ void EditorPropertyDictionary::update_property() {
vbox = NULL;
}
}
-#endif
}
void EditorPropertyDictionary::_object_id_selected(const String &p_property, ObjectID p_id) {
diff --git a/editor/editor_sectioned_inspector.cpp b/editor/editor_sectioned_inspector.cpp
index ad6b280b6d..abff8190af 100644
--- a/editor/editor_sectioned_inspector.cpp
+++ b/editor/editor_sectioned_inspector.cpp
@@ -316,7 +316,7 @@ SectionedInspector::SectionedInspector() :
add_constant_override("autohide", 1); // Fixes the dragger always showing up
VBoxContainer *left_vb = memnew(VBoxContainer);
- left_vb->set_custom_minimum_size(Size2(170, 0) * EDSCALE);
+ left_vb->set_custom_minimum_size(Size2(190, 0) * EDSCALE);
add_child(left_vb);
sections->set_v_size_flags(SIZE_EXPAND_FILL);
diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp
index ea6361665c..479fe5f0cb 100644
--- a/editor/editor_settings.cpp
+++ b/editor/editor_settings.cpp
@@ -440,25 +440,27 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
_initial_set("text_editor/indent/draw_tabs", true);
_initial_set("text_editor/indent/draw_spaces", false);
- // Line numbers
- _initial_set("text_editor/line_numbers/show_line_numbers", true);
- _initial_set("text_editor/line_numbers/line_numbers_zero_padded", false);
- _initial_set("text_editor/line_numbers/show_bookmark_gutter", true);
- _initial_set("text_editor/line_numbers/show_breakpoint_gutter", true);
- _initial_set("text_editor/line_numbers/show_info_gutter", true);
- _initial_set("text_editor/line_numbers/code_folding", true);
- _initial_set("text_editor/line_numbers/word_wrap", false);
- _initial_set("text_editor/line_numbers/draw_minimap", true);
- _initial_set("text_editor/line_numbers/minimap_width", 80);
- hints["text_editor/line_numbers/minimap_width"] = PropertyInfo(Variant::INT, "text_editor/line_numbers/minimap_width", PROPERTY_HINT_RANGE, "50,250,1");
- _initial_set("text_editor/line_numbers/show_line_length_guideline", false);
- _initial_set("text_editor/line_numbers/line_length_guideline_column", 80);
- hints["text_editor/line_numbers/line_length_guideline_column"] = PropertyInfo(Variant::INT, "text_editor/line_numbers/line_length_guideline_column", PROPERTY_HINT_RANGE, "20, 160, 1");
-
- // Open scripts
- _initial_set("text_editor/open_scripts/smooth_scrolling", true);
- _initial_set("text_editor/open_scripts/v_scroll_speed", 80);
- _initial_set("text_editor/open_scripts/show_members_overview", true);
+ // Navigation
+ _initial_set("text_editor/navigation/smooth_scrolling", true);
+ _initial_set("text_editor/navigation/v_scroll_speed", 80);
+ _initial_set("text_editor/navigation/show_minimap", true);
+ _initial_set("text_editor/navigation/minimap_width", 80);
+ hints["text_editor/navigation/minimap_width"] = PropertyInfo(Variant::INT, "text_editor/navigation/minimap_width", PROPERTY_HINT_RANGE, "50,250,1");
+
+ // Appearance
+ _initial_set("text_editor/appearance/show_line_numbers", true);
+ _initial_set("text_editor/appearance/line_numbers_zero_padded", false);
+ _initial_set("text_editor/appearance/show_bookmark_gutter", true);
+ _initial_set("text_editor/appearance/show_breakpoint_gutter", true);
+ _initial_set("text_editor/appearance/show_info_gutter", true);
+ _initial_set("text_editor/appearance/code_folding", true);
+ _initial_set("text_editor/appearance/word_wrap", false);
+ _initial_set("text_editor/appearance/show_line_length_guideline", false);
+ _initial_set("text_editor/appearance/line_length_guideline_column", 80);
+ hints["text_editor/appearance/line_length_guideline_column"] = PropertyInfo(Variant::INT, "text_editor/appearance/line_length_guideline_column", PROPERTY_HINT_RANGE, "20, 160, 1");
+
+ // Script list
+ _initial_set("text_editor/script_list/show_members_overview", true);
// Files
_initial_set("text_editor/files/trim_trailing_whitespace_on_save", false);
diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp
index 56eed96e31..e29e44caa2 100644
--- a/editor/editor_themes.cpp
+++ b/editor/editor_themes.cpp
@@ -108,16 +108,17 @@ void editor_register_and_generate_icons(Ref<Theme> p_theme, bool p_dark_theme =
#ifdef SVG_ENABLED
Dictionary dark_icon_color_dictionary;
if (!p_dark_theme) {
- //convert color: FROM TO
- ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#e0e0e0", "#4f4f4f"); // common icon color
- ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#ffffff", "#000000"); // white
- ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#b4b4b4", "#000000"); // script darker color
+ // convert color: FROM TO
+ ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#e0e0e0", "#5a5a5a"); // common icon color
+ ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#ffffff", "#414141"); // white
+ ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#b4b4b4", "#363636"); // script darker color
+ ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#f9f9f9", "#606060"); // scrollbar grabber highlight color
ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#cea4f1", "#a85de9"); // animation
ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#fc9c9c", "#cd3838"); // spatial
ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#a5b7f3", "#3d64dd"); // 2d
ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#708cea", "#1a3eac"); // 2d dark
- ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#a5efac", "#2aa235"); // control
+ ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#a5efac", "#2fa139"); // control
// rainbow
ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#ff7070", "#ff2929"); // red
@@ -145,9 +146,14 @@ void editor_register_and_generate_icons(Ref<Theme> p_theme, bool p_dark_theme =
ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#ea9568", "#bd5e2c"); // 3D Transform track
ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#66f376", "#16a827"); // Call Method track
ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#5792f6", "#236be6"); // Bezier Curve track
- ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#eae668", "#aea923"); // Audio Playback track
+ ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#eae668", "#9f9722"); // Audio Playback track
ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#b76ef0", "#9853ce"); // Animation Playback track
+ // TileSet editor icons
+ ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#fce844", "#aa8d24"); // New Single Tile
+ ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#4490fc", "#0350bd"); // New Autotile
+ ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#c9cfd4", "#828f9b"); // New Atlas
+
ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#69ecbd", "#25e3a0"); // VS variant
ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#8da6f0", "#6d8eeb"); // VS bool
ADD_CONVERT_COLOR(dark_icon_color_dictionary, "#7dc6ef", "#4fb2e9"); // VS int
@@ -339,6 +345,13 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
const Color color_disabled = mono_color.inverted().linear_interpolate(base_color, 0.7);
const Color color_disabled_bg = mono_color.inverted().linear_interpolate(base_color, 0.9);
+ Color icon_color_hover = Color(1, 1, 1) * (dark_theme ? 1.15 : 1.45);
+ icon_color_hover.a = 1.0;
+ // Make the pressed icon color overbright because icons are not completely white on a dark theme.
+ // On a light theme, icons are dark, so we need to modulate them with an even brighter color.
+ Color icon_color_pressed = accent_color * (dark_theme ? 1.15 : 3.5);
+ icon_color_pressed.a = 1.0;
+
const Color separator_color = Color(mono_color.r, mono_color.g, mono_color.b, 0.1);
const Color highlight_color = Color(mono_color.r, mono_color.g, mono_color.b, 0.2);
@@ -565,9 +578,8 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
theme->set_color("font_color_hover", "Button", font_color_hl);
theme->set_color("font_color_pressed", "Button", accent_color);
theme->set_color("font_color_disabled", "Button", font_color_disabled);
- theme->set_color("icon_color_hover", "Button", font_color_hl);
- // make icon color value bigger because icon image is not complete white
- theme->set_color("icon_color_pressed", "Button", Color(accent_color.r * 1.15, accent_color.g * 1.15, accent_color.b * 1.15, accent_color.a));
+ theme->set_color("icon_color_hover", "Button", icon_color_hover);
+ theme->set_color("icon_color_pressed", "Button", icon_color_pressed);
// OptionButton
theme->set_stylebox("normal", "OptionButton", style_widget);
@@ -580,7 +592,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
theme->set_color("font_color_hover", "OptionButton", font_color_hl);
theme->set_color("font_color_pressed", "OptionButton", accent_color);
theme->set_color("font_color_disabled", "OptionButton", font_color_disabled);
- theme->set_color("icon_color_hover", "OptionButton", font_color_hl);
+ theme->set_color("icon_color_hover", "OptionButton", icon_color_hover);
theme->set_icon("arrow", "OptionButton", theme->get_icon("GuiOptionArrow", "EditorIcons"));
theme->set_constant("arrow_margin", "OptionButton", default_margin_size * EDSCALE);
theme->set_constant("modulate_arrow", "OptionButton", true);
@@ -601,7 +613,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
theme->set_color("font_color_hover", "CheckButton", font_color_hl);
theme->set_color("font_color_pressed", "CheckButton", accent_color);
theme->set_color("font_color_disabled", "CheckButton", font_color_disabled);
- theme->set_color("icon_color_hover", "CheckButton", font_color_hl);
+ theme->set_color("icon_color_hover", "CheckButton", icon_color_hover);
theme->set_constant("hseparation", "CheckButton", 4 * EDSCALE);
theme->set_constant("check_vadjust", "CheckButton", 0 * EDSCALE);
@@ -626,7 +638,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
theme->set_color("font_color_hover", "CheckBox", font_color_hl);
theme->set_color("font_color_pressed", "CheckBox", accent_color);
theme->set_color("font_color_disabled", "CheckBox", font_color_disabled);
- theme->set_color("icon_color_hover", "CheckBox", font_color_hl);
+ theme->set_color("icon_color_hover", "CheckBox", icon_color_hover);
theme->set_constant("hseparation", "CheckBox", 4 * EDSCALE);
theme->set_constant("check_vadjust", "CheckBox", 0 * EDSCALE);
@@ -983,8 +995,13 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
// GraphEdit
theme->set_stylebox("bg", "GraphEdit", style_tree_bg);
- theme->set_color("grid_major", "GraphEdit", Color(1.0, 1.0, 1.0, 0.15));
- theme->set_color("grid_minor", "GraphEdit", Color(1.0, 1.0, 1.0, 0.07));
+ if (dark_theme) {
+ theme->set_color("grid_major", "GraphEdit", Color(1.0, 1.0, 1.0, 0.15));
+ theme->set_color("grid_minor", "GraphEdit", Color(1.0, 1.0, 1.0, 0.07));
+ } else {
+ theme->set_color("grid_major", "GraphEdit", Color(0.0, 0.0, 0.0, 0.15));
+ theme->set_color("grid_minor", "GraphEdit", Color(0.0, 0.0, 0.0, 0.07));
+ }
theme->set_color("activity", "GraphEdit", accent_color);
theme->set_icon("minus", "GraphEdit", theme->get_icon("ZoomLess", "EditorIcons"));
theme->set_icon("more", "GraphEdit", theme->get_icon("ZoomMore", "EditorIcons"));
@@ -1049,6 +1066,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
theme->set_color("title_color", "GraphNode", default_node_color);
default_node_color.a = 0.7;
theme->set_color("close_color", "GraphNode", default_node_color);
+ theme->set_color("resizer_color", "GraphNode", default_node_color);
theme->set_constant("port_offset", "GraphNode", 14 * EDSCALE);
theme->set_constant("title_h_offset", "GraphNode", -16 * EDSCALE);
@@ -1068,7 +1086,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
theme->set_icon("folder", "FileDialog", theme->get_icon("Folder", "EditorIcons"));
// Use a different color for folder icons to make them easier to distinguish from files.
// On a light theme, the icon will be dark, so we need to lighten it before blending it with the accent color.
- theme->set_color("folder_icon_modulate", "FileDialog", (dark_theme ? Color(1, 1, 1) : Color(5, 5, 5)).linear_interpolate(accent_color, 0.7));
+ theme->set_color("folder_icon_modulate", "FileDialog", (dark_theme ? Color(1, 1, 1) : Color(4.25, 4.25, 4.25)).linear_interpolate(accent_color, 0.7));
theme->set_color("files_disabled", "FileDialog", font_color_disabled);
// color picker
diff --git a/editor/export_template_manager.cpp b/editor/export_template_manager.cpp
index 1447a143d4..536cfaa1dd 100644
--- a/editor/export_template_manager.cpp
+++ b/editor/export_template_manager.cpp
@@ -542,7 +542,6 @@ void ExportTemplateManager::_notification(int p_what) {
template_list_state->set_text(status);
if (errored) {
set_process(false);
- ;
}
}
@@ -555,25 +554,33 @@ void ExportTemplateManager::_notification(int p_what) {
bool ExportTemplateManager::can_install_android_template() {
- return FileAccess::exists(EditorSettings::get_singleton()->get_templates_dir().plus_file(VERSION_FULL_CONFIG).plus_file("android_source.zip"));
+ const String templates_dir = EditorSettings::get_singleton()->get_templates_dir().plus_file(VERSION_FULL_CONFIG);
+ return FileAccess::exists(templates_dir.plus_file("android_source.zip")) &&
+ FileAccess::exists(templates_dir.plus_file("android_release.apk")) &&
+ FileAccess::exists(templates_dir.plus_file("android_debug.apk"));
}
Error ExportTemplateManager::install_android_template() {
+ // To support custom Android builds, we install various things to the project's res://android folder.
+ // First is the Java source code and buildsystem from android_source.zip.
+ // Then we extract the Godot Android libraries from pre-build android_release.apk
+ // and android_debug.apk, to place them in the libs folder.
+
DirAccessRef da = DirAccess::open("res://");
ERR_FAIL_COND_V(!da, ERR_CANT_CREATE);
- //make android dir (if it does not exist)
+ // Make res://android dir (if it does not exist).
da->make_dir("android");
{
- //add an empty .gdignore file to avoid scan
+ // Add an empty .gdignore file to avoid scan.
FileAccessRef f = FileAccess::open("res://android/.gdignore", FileAccess::WRITE);
ERR_FAIL_COND_V(!f, ERR_CANT_CREATE);
f->store_line("");
f->close();
}
{
- //add version, to ensure building won't work if template and Godot version don't match
+ // Add version, to ensure building won't work if template and Godot version don't match.
FileAccessRef f = FileAccess::open("res://android/.build_version", FileAccess::WRITE);
ERR_FAIL_COND_V(!f, ERR_CANT_CREATE);
f->store_line(VERSION_FULL_CONFIG);
@@ -583,7 +590,10 @@ Error ExportTemplateManager::install_android_template() {
Error err = da->make_dir_recursive("android/build");
ERR_FAIL_COND_V(err != OK, err);
- String source_zip = EditorSettings::get_singleton()->get_templates_dir().plus_file(VERSION_FULL_CONFIG).plus_file("android_source.zip");
+ // Uncompress source template.
+
+ const String &templates_path = EditorSettings::get_singleton()->get_templates_dir().plus_file(VERSION_FULL_CONFIG);
+ const String &source_zip = templates_path.plus_file("android_source.zip");
ERR_FAIL_COND_V(!FileAccess::exists(source_zip), ERR_CANT_OPEN);
FileAccess *src_f = NULL;
@@ -593,37 +603,33 @@ Error ExportTemplateManager::install_android_template() {
ERR_FAIL_COND_V_MSG(!pkg, ERR_CANT_OPEN, "Android sources not in ZIP format.");
int ret = unzGoToFirstFile(pkg);
-
int total_files = 0;
- //count files
+ // Count files to unzip.
while (ret == UNZ_OK) {
total_files++;
ret = unzGoToNextFile(pkg);
}
-
ret = unzGoToFirstFile(pkg);
- //decompress files
- ProgressDialog::get_singleton()->add_task("uncompress", TTR("Uncompressing Android Build Sources"), total_files);
- Set<String> dirs_tested;
+ ProgressDialog::get_singleton()->add_task("uncompress_src", TTR("Uncompressing Android Build Sources"), total_files);
+ Set<String> dirs_tested;
int idx = 0;
while (ret == UNZ_OK) {
- //get filename
+ // Get file path.
unz_file_info info;
- char fname[16384];
- ret = unzGetCurrentFileInfo(pkg, &info, fname, 16384, NULL, 0, NULL, 0);
-
- String name = fname;
+ char fpath[16384];
+ ret = unzGetCurrentFileInfo(pkg, &info, fpath, 16384, NULL, 0, NULL, 0);
- String base_dir = name.get_base_dir();
+ String path = fpath;
+ String base_dir = path.get_base_dir();
- if (!name.ends_with("/")) {
+ if (!path.ends_with("/")) {
Vector<uint8_t> data;
data.resize(info.uncompressed_size);
- //read
+ // Read.
unzOpenCurrentFile(pkg);
unzReadCurrentFile(pkg, data.ptrw(), data.size());
unzCloseCurrentFile(pkg);
@@ -633,7 +639,7 @@ Error ExportTemplateManager::install_android_template() {
dirs_tested.insert(base_dir);
}
- String to_write = String("res://android/build").plus_file(name);
+ String to_write = String("res://android/build").plus_file(path);
FileAccess *f = FileAccess::open(to_write, FileAccess::WRITE);
if (f) {
f->store_buffer(data.ptr(), data.size());
@@ -646,13 +652,96 @@ Error ExportTemplateManager::install_android_template() {
}
}
- ProgressDialog::get_singleton()->task_step("uncompress", name, idx);
+ ProgressDialog::get_singleton()->task_step("uncompress_src", path, idx);
+
+ idx++;
+ ret = unzGoToNextFile(pkg);
+ }
+
+ ProgressDialog::get_singleton()->end_task("uncompress_src");
+ unzClose(pkg);
+
+ // Extract libs from pre-built APKs.
+ err = _extract_libs_from_apk("release");
+ ERR_FAIL_COND_V_MSG(err != OK, err, "Can't extract Android libs from android_release.apk.");
+ err = _extract_libs_from_apk("debug");
+ ERR_FAIL_COND_V_MSG(err != OK, err, "Can't extract Android libs from android_debug.apk.");
+
+ return OK;
+}
+
+Error ExportTemplateManager::_extract_libs_from_apk(const String &p_target_name) {
+
+ const String &templates_path = EditorSettings::get_singleton()->get_templates_dir().plus_file(VERSION_FULL_CONFIG);
+ const String &apk_file = templates_path.plus_file("android_" + p_target_name + ".apk");
+ ERR_FAIL_COND_V(!FileAccess::exists(apk_file), ERR_CANT_OPEN);
+
+ FileAccess *src_f = NULL;
+ zlib_filefunc_def io = zipio_create_io_from_file(&src_f);
+
+ unzFile pkg = unzOpen2(apk_file.utf8().get_data(), &io);
+ ERR_FAIL_COND_V_MSG(!pkg, ERR_CANT_OPEN, "Android APK can't be extracted.");
+
+ DirAccessRef da = DirAccess::open("res://");
+ ERR_FAIL_COND_V(!da, ERR_CANT_CREATE);
+
+ // 8 steps because 4 arches, 2 libs per arch.
+ ProgressDialog::get_singleton()->add_task("extract_libs_from_apk", TTR("Extracting Android Libraries From APKs"), 8);
+
+ int ret = unzGoToFirstFile(pkg);
+ Set<String> dirs_tested;
+ int idx = 0;
+ while (ret == UNZ_OK) {
+ // Get file path.
+ unz_file_info info;
+ char fpath[16384];
+ ret = unzGetCurrentFileInfo(pkg, &info, fpath, 16384, NULL, 0, NULL, 0);
+
+ String path = fpath;
+ String base_dir = path.get_base_dir();
+ String file = path.get_file();
+
+ if (!base_dir.begins_with("lib") || path.ends_with("/")) {
+ ret = unzGoToNextFile(pkg);
+ continue;
+ }
+
+ Vector<uint8_t> data;
+ data.resize(info.uncompressed_size);
+
+ // Read.
+ unzOpenCurrentFile(pkg);
+ unzReadCurrentFile(pkg, data.ptrw(), data.size());
+ unzCloseCurrentFile(pkg);
+
+ // We have a "lib" folder in the APK, but it should be "libs/{release,debug}" in the source dir.
+ String target_base_dir = base_dir.replace_first("lib", String("libs").plus_file(p_target_name));
+
+ if (!dirs_tested.has(base_dir)) {
+ da->make_dir_recursive(String("android/build").plus_file(target_base_dir));
+ dirs_tested.insert(base_dir);
+ }
+
+ String to_write = String("res://android/build").plus_file(target_base_dir.plus_file(path.get_file()));
+ FileAccess *f = FileAccess::open(to_write, FileAccess::WRITE);
+ if (f) {
+ f->store_buffer(data.ptr(), data.size());
+ memdelete(f);
+#ifndef WINDOWS_ENABLED
+ // We can't retrieve Unix permissions from the APK it seems, so simply set 0755 as should be.
+ FileAccess::set_unix_permissions(to_write, 0755);
+#endif
+ } else {
+ ERR_PRINTS("Can't uncompress file: " + to_write);
+ }
+
+ ProgressDialog::get_singleton()->task_step("extract_libs_from_apk", path, idx);
idx++;
ret = unzGoToNextFile(pkg);
}
- ProgressDialog::get_singleton()->end_task("uncompress");
+ ProgressDialog::get_singleton()->end_task("extract_libs_from_apk");
unzClose(pkg);
return OK;
diff --git a/editor/export_template_manager.h b/editor/export_template_manager.h
index ad3ab507b3..ecb8e85b21 100644
--- a/editor/export_template_manager.h
+++ b/editor/export_template_manager.h
@@ -72,6 +72,8 @@ class ExportTemplateManager : public ConfirmationDialog {
virtual void ok_pressed();
bool _install_from_file(const String &p_file, bool p_use_progress = true);
+ Error _extract_libs_from_apk(const String &p_target_name);
+
void _http_download_mirror_completed(int p_status, int p_code, const PoolStringArray &headers, const PoolByteArray &p_data);
void _http_download_templates_completed(int p_status, int p_code, const PoolStringArray &headers, const PoolByteArray &p_data);
diff --git a/editor/import/resource_importer_wav.cpp b/editor/import/resource_importer_wav.cpp
index 4fd4ab2f2e..f1de71e25e 100644
--- a/editor/import/resource_importer_wav.cpp
+++ b/editor/import/resource_importer_wav.cpp
@@ -83,8 +83,8 @@ void ResourceImporterWAV::get_import_options(List<ImportOption> *r_options, int
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "force/mono"), false));
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "force/max_rate", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), false));
r_options->push_back(ImportOption(PropertyInfo(Variant::REAL, "force/max_rate_hz", PROPERTY_HINT_EXP_RANGE, "11025,192000,1"), 44100));
- r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "edit/trim"), true));
- r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "edit/normalize"), true));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "edit/trim"), false));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "edit/normalize"), false));
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "edit/loop"), false));
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "compress/mode", PROPERTY_HINT_ENUM, "Disabled,RAM (Ima-ADPCM)"), 0));
}
diff --git a/editor/plugins/animation_blend_tree_editor_plugin.cpp b/editor/plugins/animation_blend_tree_editor_plugin.cpp
index 574f906cfa..235c204265 100644
--- a/editor/plugins/animation_blend_tree_editor_plugin.cpp
+++ b/editor/plugins/animation_blend_tree_editor_plugin.cpp
@@ -249,6 +249,7 @@ void AnimationNodeBlendTreeEditor::_update_graph() {
node->add_color_override("title_color", c);
c.a = 0.7;
node->add_color_override("close_color", c);
+ node->add_color_override("resizer_color", c);
}
}
diff --git a/editor/plugins/asset_library_editor_plugin.cpp b/editor/plugins/asset_library_editor_plugin.cpp
index cb68f5eaaf..894e5c7298 100644
--- a/editor/plugins/asset_library_editor_plugin.cpp
+++ b/editor/plugins/asset_library_editor_plugin.cpp
@@ -290,6 +290,7 @@ EditorAssetLibraryItemDescription::EditorAssetLibraryItemDescription() {
desc_vbox->add_child(description);
description->set_v_size_flags(SIZE_EXPAND_FILL);
description->connect("meta_clicked", this, "_link_click");
+ description->add_constant_override("line_separation", Math::round(5 * EDSCALE));
VBoxContainer *previews_vbox = memnew(VBoxContainer);
hbox->add_child(previews_vbox);
diff --git a/editor/plugins/editor_preview_plugins.cpp b/editor/plugins/editor_preview_plugins.cpp
index c8ffc2744a..8acc41a2c7 100644
--- a/editor/plugins/editor_preview_plugins.cpp
+++ b/editor/plugins/editor_preview_plugins.cpp
@@ -624,6 +624,7 @@ Ref<Texture> EditorAudioStreamPreviewPlugin::generate(const RES &p_from, const S
uint8_t *imgw = imgdata.ptr();
Ref<AudioStreamPlayback> playback = stream->instance_playback();
+ ERR_FAIL_COND_V(playback.is_null(), Ref<Texture>());
float len_s = stream->get_length();
if (len_s == 0) {
diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp
index 76c7545874..413843d536 100644
--- a/editor/plugins/script_editor_plugin.cpp
+++ b/editor/plugins/script_editor_plugin.cpp
@@ -1741,10 +1741,10 @@ void ScriptEditor::_update_help_overview() {
void ScriptEditor::_update_script_colors() {
- bool script_temperature_enabled = EditorSettings::get_singleton()->get("text_editor/open_scripts/script_temperature_enabled");
- bool highlight_current = EditorSettings::get_singleton()->get("text_editor/open_scripts/highlight_current_script");
+ bool script_temperature_enabled = EditorSettings::get_singleton()->get("text_editor/script_list/script_temperature_enabled");
+ bool highlight_current = EditorSettings::get_singleton()->get("text_editor/script_list/highlight_current_script");
- int hist_size = EditorSettings::get_singleton()->get("text_editor/open_scripts/script_temperature_history_size");
+ int hist_size = EditorSettings::get_singleton()->get("text_editor/script_list/script_temperature_history_size");
Color hot_color = get_color("accent_color", "Editor");
Color cold_color = get_color("font_color", "Editor");
@@ -1759,7 +1759,7 @@ void ScriptEditor::_update_script_colors() {
bool current = tab_container->get_current_tab() == c;
if (current && highlight_current) {
- script_list->set_item_custom_bg_color(i, EditorSettings::get_singleton()->get("text_editor/open_scripts/current_script_background_color"));
+ script_list->set_item_custom_bg_color(i, EditorSettings::get_singleton()->get("text_editor/script_list/current_script_background_color"));
} else if (script_temperature_enabled) {
@@ -1792,9 +1792,9 @@ void ScriptEditor::_update_script_names() {
}
script_list->clear();
- bool split_script_help = EditorSettings::get_singleton()->get("text_editor/open_scripts/group_help_pages");
- ScriptSortBy sort_by = (ScriptSortBy)(int)EditorSettings::get_singleton()->get("text_editor/open_scripts/sort_scripts_by");
- ScriptListName display_as = (ScriptListName)(int)EditorSettings::get_singleton()->get("text_editor/open_scripts/list_script_names_as");
+ bool split_script_help = EditorSettings::get_singleton()->get("text_editor/script_list/group_help_pages");
+ ScriptSortBy sort_by = (ScriptSortBy)(int)EditorSettings::get_singleton()->get("text_editor/script_list/sort_scripts_by");
+ ScriptListName display_as = (ScriptListName)(int)EditorSettings::get_singleton()->get("text_editor/script_list/list_script_names_as");
Vector<_ScriptEditorItemData> sedata;
@@ -2318,7 +2318,7 @@ void ScriptEditor::_editor_settings_changed() {
convert_indent_on_save = EditorSettings::get_singleton()->get("text_editor/indent/convert_indent_on_save");
use_space_indentation = EditorSettings::get_singleton()->get("text_editor/indent/type");
- members_overview_enabled = EditorSettings::get_singleton()->get("text_editor/open_scripts/show_members_overview");
+ members_overview_enabled = EditorSettings::get_singleton()->get("text_editor/script_list/show_members_overview");
help_overview_enabled = EditorSettings::get_singleton()->get("text_editor/help/show_help_index");
_update_members_overview_visibility();
_update_help_overview_visibility();
@@ -3129,7 +3129,7 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) {
waiting_update_names = false;
pending_auto_reload = false;
auto_reload_running_scripts = true;
- members_overview_enabled = EditorSettings::get_singleton()->get("text_editor/open_scripts/show_members_overview");
+ members_overview_enabled = EditorSettings::get_singleton()->get("text_editor/script_list/show_members_overview");
help_overview_enabled = EditorSettings::get_singleton()->get("text_editor/help/show_help_index");
editor = p_editor;
@@ -3554,15 +3554,15 @@ ScriptEditorPlugin::ScriptEditorPlugin(EditorNode *p_node) {
EDITOR_DEF("text_editor/files/open_dominant_script_on_scene_change", true);
EDITOR_DEF("text_editor/external/use_external_editor", false);
EDITOR_DEF("text_editor/external/exec_path", "");
- EDITOR_DEF("text_editor/open_scripts/script_temperature_enabled", true);
- EDITOR_DEF("text_editor/open_scripts/highlight_current_script", true);
- EDITOR_DEF("text_editor/open_scripts/script_temperature_history_size", 15);
- EDITOR_DEF("text_editor/open_scripts/current_script_background_color", Color(1, 1, 1, 0.3));
- EDITOR_DEF("text_editor/open_scripts/group_help_pages", true);
- EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::INT, "text_editor/open_scripts/sort_scripts_by", PROPERTY_HINT_ENUM, "Name,Path,None"));
- EDITOR_DEF("text_editor/open_scripts/sort_scripts_by", 0);
- EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::INT, "text_editor/open_scripts/list_script_names_as", PROPERTY_HINT_ENUM, "Name,Parent Directory And Name,Full Path"));
- EDITOR_DEF("text_editor/open_scripts/list_script_names_as", 0);
+ EDITOR_DEF("text_editor/script_list/script_temperature_enabled", true);
+ EDITOR_DEF("text_editor/script_list/highlight_current_script", true);
+ EDITOR_DEF("text_editor/script_list/script_temperature_history_size", 15);
+ EDITOR_DEF("text_editor/script_list/current_script_background_color", Color(1, 1, 1, 0.3));
+ EDITOR_DEF("text_editor/script_list/group_help_pages", true);
+ EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::INT, "text_editor/script_list/sort_scripts_by", PROPERTY_HINT_ENUM, "Name,Path,None"));
+ EDITOR_DEF("text_editor/script_list/sort_scripts_by", 0);
+ EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::INT, "text_editor/script_list/list_script_names_as", PROPERTY_HINT_ENUM, "Name,Parent Directory And Name,Full Path"));
+ EDITOR_DEF("text_editor/script_list/list_script_names_as", 0);
EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING, "text_editor/external/exec_path", PROPERTY_HINT_GLOBAL_FILE));
EDITOR_DEF("text_editor/external/exec_flags", "{file}");
EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING, "text_editor/external/exec_flags", PROPERTY_HINT_PLACEHOLDER_TEXT, "Call flags with placeholders: {project}, {file}, {col}, {line}."));
diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp
index bded590351..edc454ad1c 100644
--- a/editor/plugins/script_text_editor.cpp
+++ b/editor/plugins/script_text_editor.cpp
@@ -1436,8 +1436,6 @@ bool ScriptTextEditor::can_drop_data_fw(const Point2 &p_point, const Variant &p_
return false;
}
-#ifdef TOOLS_ENABLED
-
static Node *_find_script_node(Node *p_edited_scene, Node *p_current_node, const Ref<Script> &script) {
if (p_edited_scene != p_current_node && p_current_node->get_owner() != p_edited_scene)
@@ -1457,14 +1455,6 @@ static Node *_find_script_node(Node *p_edited_scene, Node *p_current_node, const
return NULL;
}
-#else
-
-static Node *_find_script_node(Node *p_edited_scene, Node *p_current_node, const Ref<Script> &script) {
-
- return NULL;
-}
-#endif
-
void ScriptTextEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) {
Dictionary d = p_data;
diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp
index 938dc8a1e7..e81c97d5dd 100644
--- a/editor/plugins/shader_editor_plugin.cpp
+++ b/editor/plugins/shader_editor_plugin.cpp
@@ -372,7 +372,7 @@ void ShaderEditor::_editor_settings_changed() {
shader_editor->get_text_edit()->set_indent_using_spaces(EditorSettings::get_singleton()->get("text_editor/indent/type"));
shader_editor->get_text_edit()->set_auto_indent(EditorSettings::get_singleton()->get("text_editor/indent/auto_indent"));
shader_editor->get_text_edit()->set_draw_tabs(EditorSettings::get_singleton()->get("text_editor/indent/draw_tabs"));
- shader_editor->get_text_edit()->set_show_line_numbers(EditorSettings::get_singleton()->get("text_editor/line_numbers/show_line_numbers"));
+ shader_editor->get_text_edit()->set_show_line_numbers(EditorSettings::get_singleton()->get("text_editor/appearance/show_line_numbers"));
shader_editor->get_text_edit()->set_syntax_coloring(EditorSettings::get_singleton()->get("text_editor/highlighting/syntax_highlighting"));
shader_editor->get_text_edit()->set_highlight_all_occurrences(EditorSettings::get_singleton()->get("text_editor/highlighting/highlight_all_occurrences"));
shader_editor->get_text_edit()->set_highlight_current_line(EditorSettings::get_singleton()->get("text_editor/highlighting/highlight_current_line"));
@@ -380,8 +380,8 @@ void ShaderEditor::_editor_settings_changed() {
shader_editor->get_text_edit()->cursor_set_blink_speed(EditorSettings::get_singleton()->get("text_editor/cursor/caret_blink_speed"));
shader_editor->get_text_edit()->add_constant_override("line_spacing", EditorSettings::get_singleton()->get("text_editor/theme/line_spacing"));
shader_editor->get_text_edit()->cursor_set_block_mode(EditorSettings::get_singleton()->get("text_editor/cursor/block_caret"));
- shader_editor->get_text_edit()->set_smooth_scroll_enabled(EditorSettings::get_singleton()->get("text_editor/open_scripts/smooth_scrolling"));
- shader_editor->get_text_edit()->set_v_scroll_speed(EditorSettings::get_singleton()->get("text_editor/open_scripts/v_scroll_speed"));
+ shader_editor->get_text_edit()->set_smooth_scroll_enabled(EditorSettings::get_singleton()->get("text_editor/navigation/smooth_scrolling"));
+ shader_editor->get_text_edit()->set_v_scroll_speed(EditorSettings::get_singleton()->get("text_editor/navigation/v_scroll_speed"));
}
void ShaderEditor::_bind_methods() {
diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp
index 2eb3ce1ec3..ecc631d045 100644
--- a/editor/plugins/spatial_editor_plugin.cpp
+++ b/editor/plugins/spatial_editor_plugin.cpp
@@ -74,14 +74,6 @@
#define MIN_FOV 0.01
#define MAX_FOV 179
-#ifdef TOOLS_ENABLED
-#define get_global_gizmo_transform get_global_gizmo_transform
-#define get_local_gizmo_transform get_local_gizmo_transform
-#else
-#define get_global_gizmo_transform get_global_transform
-#define get_local_gizmo_transform get_transform
-#endif
-
void SpatialEditorViewport::_update_camera(float p_interp_delta) {
bool is_orthogonal = camera->get_projection() == Camera::PROJECTION_ORTHOGONAL;
@@ -5298,6 +5290,10 @@ void SpatialEditor::_notification(int p_what) {
tool_button[SpatialEditor::TOOL_MODE_ROTATE]->set_icon(get_icon("ToolRotate", "EditorIcons"));
tool_button[SpatialEditor::TOOL_MODE_SCALE]->set_icon(get_icon("ToolScale", "EditorIcons"));
tool_button[SpatialEditor::TOOL_MODE_LIST_SELECT]->set_icon(get_icon("ListSelect", "EditorIcons"));
+ tool_button[SpatialEditor::TOOL_LOCK_SELECTED]->set_icon(get_icon("Lock", "EditorIcons"));
+ tool_button[SpatialEditor::TOOL_UNLOCK_SELECTED]->set_icon(get_icon("Unlock", "EditorIcons"));
+ tool_button[SpatialEditor::TOOL_GROUP_SELECTED]->set_icon(get_icon("Group", "EditorIcons"));
+ tool_button[SpatialEditor::TOOL_UNGROUP_SELECTED]->set_icon(get_icon("Ungroup", "EditorIcons"));
tool_option_button[SpatialEditor::TOOL_OPT_LOCAL_COORDS]->set_icon(get_icon("Object", "EditorIcons"));
tool_option_button[SpatialEditor::TOOL_OPT_USE_SNAP]->set_icon(get_icon("Snap", "EditorIcons"));
diff --git a/editor/plugins/visual_shader_editor_plugin.cpp b/editor/plugins/visual_shader_editor_plugin.cpp
index 66fbc32b1c..6b338ca02b 100644
--- a/editor/plugins/visual_shader_editor_plugin.cpp
+++ b/editor/plugins/visual_shader_editor_plugin.cpp
@@ -410,6 +410,7 @@ void VisualShaderEditor::_update_created_node(GraphNode *node) {
node->add_color_override("title_color", c);
c.a = 0.7;
node->add_color_override("close_color", c);
+ node->add_color_override("resizer_color", c);
}
}
diff --git a/editor/project_export.cpp b/editor/project_export.cpp
index 956da92c35..c54103f6f7 100644
--- a/editor/project_export.cpp
+++ b/editor/project_export.cpp
@@ -1116,6 +1116,7 @@ ProjectExportDialog::ProjectExportDialog() {
sections = memnew(TabContainer);
sections->set_tab_align(TabContainer::ALIGN_LEFT);
+ sections->set_use_hidden_tabs_for_min_size(true);
settings_vb->add_child(sections);
sections->set_v_size_flags(SIZE_EXPAND_FILL);
diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp
index 98335c8367..c6e3dc1e32 100644
--- a/editor/project_manager.cpp
+++ b/editor/project_manager.cpp
@@ -1754,7 +1754,7 @@ void ProjectManager::_dim_window() {
// Dim the project manager window while it's quitting to make it clearer that it's busy.
// No transition is applied, as the effect needs to be visible immediately
- float c = 0.4f;
+ float c = 0.5f;
Color dim_color = Color(c, c, c);
gui_base->set_modulate(dim_color);
}
diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp
index 1c588a45f1..a0d2332ffc 100644
--- a/editor/project_settings_editor.cpp
+++ b/editor/project_settings_editor.cpp
@@ -1674,6 +1674,7 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) {
tab_container = memnew(TabContainer);
tab_container->set_tab_align(TabContainer::ALIGN_LEFT);
+ tab_container->set_use_hidden_tabs_for_min_size(true);
add_child(tab_container);
VBoxContainer *props_base = memnew(VBoxContainer);
diff --git a/modules/mono/mono_gd/gd_mono.cpp b/modules/mono/mono_gd/gd_mono.cpp
index aa69803a58..cd111abd4d 100644
--- a/modules/mono/mono_gd/gd_mono.cpp
+++ b/modules/mono/mono_gd/gd_mono.cpp
@@ -317,6 +317,13 @@ void GDMono::initialize() {
return;
#endif
+#if !defined(WINDOWS_ENABLED) && !defined(NO_MONO_THREADS_SUSPEND_WORKAROUND)
+ // FIXME: Temporary workaround. See: https://github.com/godotengine/godot/issues/29812
+ if (!OS::get_singleton()->has_environment("MONO_THREADS_SUSPEND")) {
+ OS::get_singleton()->set_environment("MONO_THREADS_SUSPEND", "preemptive");
+ }
+#endif
+
root_domain = mono_jit_init_version("GodotEngine.RootDomain", "v4.0.30319");
ERR_FAIL_NULL_MSG(root_domain, "Mono: Failed to initialize runtime.");
diff --git a/modules/visual_script/visual_script_editor.cpp b/modules/visual_script/visual_script_editor.cpp
index eef3f0f8ae..8faa342bbe 100644
--- a/modules/visual_script/visual_script_editor.cpp
+++ b/modules/visual_script/visual_script_editor.cpp
@@ -591,6 +591,7 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
gnode->add_color_override("title_color", c);
c.a = 0.7;
gnode->add_color_override("close_color", c);
+ gnode->add_color_override("resizer_color", c);
gnode->add_style_override("frame", sbf);
}
diff --git a/platform/android/SCsub b/platform/android/SCsub
index d2f27817c6..1bd8161fa7 100644
--- a/platform/android/SCsub
+++ b/platform/android/SCsub
@@ -55,3 +55,25 @@ if lib_arch_dir != '':
stl_lib_path = str(env['ANDROID_NDK_ROOT']) + '/sources/cxx-stl/llvm-libc++/libs/' + lib_arch_dir + '/libc++_shared.so'
env_android.Command(out_dir + '/libc++_shared.so', stl_lib_path, Copy("$TARGET", "$SOURCE"))
+
+# Zip android/java folder for the source export template.
+print("Archiving platform/android/java as bin/android_source.zip...")
+import os
+import zipfile
+# Change dir to avoid have zipped paths start from the android/java folder.
+olddir = os.getcwd()
+os.chdir(Dir('#platform/android/java').abspath)
+bindir = Dir('#bin').abspath
+# Make 'bin' dir if missing, can happen on fresh clone.
+if not os.path.exists(bindir):
+ os.makedirs(bindir)
+zipf = zipfile.ZipFile(os.path.join(bindir, 'android_source.zip'), 'w', zipfile.ZIP_DEFLATED)
+exclude_dirs = ['.gradle', 'build', 'libs', 'patches']
+for root, dirs, files in os.walk('.', topdown=True):
+ # Change 'dirs' in place to exclude folders we don't want.
+ # https://stackoverflow.com/a/19859907
+ dirs[:] = [d for d in dirs if d not in exclude_dirs]
+ for f in files:
+ zipf.write(os.path.join(root, f))
+zipf.close()
+os.chdir(olddir)
diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp
index 16e49e8a38..441fa38bff 100644
--- a/platform/android/export/export.cpp
+++ b/platform/android/export/export.cpp
@@ -1610,19 +1610,16 @@ public:
valid = false;
} else {
Error errn;
- DirAccess *da = DirAccess::open(sdk_path.plus_file("tools"), &errn);
+ DirAccessRef da = DirAccess::open(sdk_path.plus_file("tools"), &errn);
if (errn != OK) {
err += TTR("Invalid Android SDK path for custom build in Editor Settings.") + "\n";
valid = false;
}
- if (da) {
- memdelete(da);
- }
}
if (!FileAccess::exists("res://android/build/build.gradle")) {
- err += TTR("Android project is not installed for compiling. Install from Editor menu.") + "\n";
+ err += TTR("Android build template not installed in the project. Install it from the Project menu.") + "\n";
valid = false;
}
}
@@ -2513,7 +2510,7 @@ void register_android_exporter() {
EDITOR_DEF("export/android/debug_keystore_pass", "android");
EDITOR_DEF("export/android/force_system_user", false);
EDITOR_DEF("export/android/custom_build_sdk_path", "");
- EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING, "export/android/custom_build_sdk_path", PROPERTY_HINT_GLOBAL_DIR, "*.keystore"));
+ EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING, "export/android/custom_build_sdk_path", PROPERTY_HINT_GLOBAL_DIR));
EDITOR_DEF("export/android/timestamping_authority_url", "");
EDITOR_DEF("export/android/shutdown_adb_on_exit", true);
diff --git a/scene/2d/canvas_item.cpp b/scene/2d/canvas_item.cpp
index b605be47df..fc5e5cbba2 100644
--- a/scene/2d/canvas_item.cpp
+++ b/scene/2d/canvas_item.cpp
@@ -641,6 +641,9 @@ void CanvasItem::update() {
void CanvasItem::set_modulate(const Color &p_modulate) {
+ if (modulate == p_modulate)
+ return;
+
modulate = p_modulate;
VisualServer::get_singleton()->canvas_item_set_modulate(canvas_item, modulate);
}
@@ -679,6 +682,9 @@ CanvasItem *CanvasItem::get_parent_item() const {
void CanvasItem::set_self_modulate(const Color &p_self_modulate) {
+ if (self_modulate == p_self_modulate)
+ return;
+
self_modulate = p_self_modulate;
VisualServer::get_singleton()->canvas_item_set_self_modulate(canvas_item, self_modulate);
}
@@ -689,6 +695,9 @@ Color CanvasItem::get_self_modulate() const {
void CanvasItem::set_light_mask(int p_light_mask) {
+ if (light_mask == p_light_mask)
+ return;
+
light_mask = p_light_mask;
VS::get_singleton()->canvas_item_set_light_mask(canvas_item, p_light_mask);
}
diff --git a/scene/2d/collision_object_2d.cpp b/scene/2d/collision_object_2d.cpp
index 202c7c9cf2..228b67990c 100644
--- a/scene/2d/collision_object_2d.cpp
+++ b/scene/2d/collision_object_2d.cpp
@@ -376,11 +376,12 @@ void CollisionObject2D::set_only_update_transform_changes(bool p_enable) {
void CollisionObject2D::_update_pickable() {
if (!is_inside_tree())
return;
- bool pickable = this->pickable && is_inside_tree() && is_visible_in_tree();
+
+ bool is_pickable = pickable && is_visible_in_tree();
if (area)
- Physics2DServer::get_singleton()->area_set_pickable(rid, pickable);
+ Physics2DServer::get_singleton()->area_set_pickable(rid, is_pickable);
else
- Physics2DServer::get_singleton()->body_set_pickable(rid, pickable);
+ Physics2DServer::get_singleton()->body_set_pickable(rid, is_pickable);
}
String CollisionObject2D::get_configuration_warning() const {
diff --git a/scene/3d/collision_object.cpp b/scene/3d/collision_object.cpp
index 63301fc226..735b393171 100644
--- a/scene/3d/collision_object.cpp
+++ b/scene/3d/collision_object.cpp
@@ -105,7 +105,8 @@ void CollisionObject::_mouse_exit() {
void CollisionObject::_update_pickable() {
if (!is_inside_tree())
return;
- bool pickable = ray_pickable && is_inside_tree() && is_visible_in_tree();
+
+ bool pickable = ray_pickable && is_visible_in_tree();
if (area)
PhysicsServer::get_singleton()->area_set_ray_pickable(rid, pickable);
else
diff --git a/scene/gui/graph_edit.cpp b/scene/gui/graph_edit.cpp
index fdffb26cb5..7827c66841 100644
--- a/scene/gui/graph_edit.cpp
+++ b/scene/gui/graph_edit.cpp
@@ -276,6 +276,11 @@ void GraphEdit::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) {
port_grab_distance_horizontal = get_constant("port_grab_distance_horizontal");
port_grab_distance_vertical = get_constant("port_grab_distance_vertical");
+
+ zoom_minus->set_icon(get_icon("minus"));
+ zoom_reset->set_icon(get_icon("reset"));
+ zoom_plus->set_icon(get_icon("more"));
+ snap_button->set_icon(get_icon("snap"));
}
if (p_what == NOTIFICATION_READY) {
Size2 hmin = h_scroll->get_combined_minimum_size();
@@ -290,11 +295,6 @@ void GraphEdit::_notification(int p_what) {
h_scroll->set_anchor_and_margin(MARGIN_RIGHT, ANCHOR_END, 0);
h_scroll->set_anchor_and_margin(MARGIN_TOP, ANCHOR_END, -hmin.height);
h_scroll->set_anchor_and_margin(MARGIN_BOTTOM, ANCHOR_END, 0);
-
- zoom_minus->set_icon(get_icon("minus"));
- zoom_reset->set_icon(get_icon("reset"));
- zoom_plus->set_icon(get_icon("more"));
- snap_button->set_icon(get_icon("snap"));
}
if (p_what == NOTIFICATION_DRAW) {
diff --git a/scene/gui/graph_node.cpp b/scene/gui/graph_node.cpp
index f7bef4ed39..5b2f8812d5 100644
--- a/scene/gui/graph_node.cpp
+++ b/scene/gui/graph_node.cpp
@@ -210,6 +210,7 @@ void GraphNode::_notification(int p_what) {
int close_offset = get_constant("close_offset");
int close_h_offset = get_constant("close_h_offset");
Color close_color = get_color("close_color");
+ Color resizer_color = get_color("resizer_color");
Ref<Font> title_font = get_font("title_font");
int title_offset = get_constant("title_offset");
int title_h_offset = get_constant("title_h_offset");
@@ -274,7 +275,7 @@ void GraphNode::_notification(int p_what) {
}
if (resizable) {
- draw_texture(resizer, get_size() - resizer->get_size());
+ draw_texture(resizer, get_size() - resizer->get_size(), resizer_color);
}
} break;
diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp
index 8223ea6d1e..1aed858c94 100644
--- a/scene/gui/rich_text_label.cpp
+++ b/scene/gui/rich_text_label.cpp
@@ -916,9 +916,12 @@ void RichTextLabel::_find_click(ItemFrame *p_frame, const Point2i &p_click, Item
Control::CursorShape RichTextLabel::get_cursor_shape(const Point2 &p_pos) const {
- if (!underline_meta || selection.click)
+ if (!underline_meta)
return CURSOR_ARROW;
+ if (selection.click)
+ return CURSOR_IBEAM;
+
if (main->first_invalid_line < main->lines.size())
return CURSOR_ARROW; //invalid
diff --git a/scene/gui/spin_box.cpp b/scene/gui/spin_box.cpp
index 6ada0cba97..172c366c41 100644
--- a/scene/gui/spin_box.cpp
+++ b/scene/gui/spin_box.cpp
@@ -29,6 +29,7 @@
/*************************************************************************/
#include "spin_box.h"
+#include "core/math/expression.h"
#include "core/os/input.h"
Size2 SpinBox::get_minimum_size() const {
@@ -50,15 +51,19 @@ void SpinBox::_value_changed(double) {
void SpinBox::_text_entered(const String &p_string) {
- /*
- if (!p_string.is_numeric())
+ Ref<Expression> expr;
+ expr.instance();
+ // Ignore the prefix and suffix in the expression
+ Error err = expr->parse(p_string.trim_prefix(prefix + " ").trim_suffix(" " + suffix));
+ if (err != OK) {
return;
- */
- String value = p_string;
- if (prefix != "" && p_string.begins_with(prefix))
- value = p_string.substr(prefix.length(), p_string.length() - prefix.length());
- set_value(value.to_double());
- _value_changed(0);
+ }
+
+ Variant value = expr->execute(Array(), NULL, false);
+ if (value.get_type() != Variant::NIL) {
+ set_value(value);
+ _value_changed(0);
+ }
}
LineEdit *SpinBox::get_line_edit() {
diff --git a/scene/gui/tab_container.cpp b/scene/gui/tab_container.cpp
index be8f1cf36e..292d80be9d 100644
--- a/scene/gui/tab_container.cpp
+++ b/scene/gui/tab_container.cpp
@@ -840,7 +840,7 @@ Size2 TabContainer::get_minimum_size() const {
Control *c = tabs[i];
- if (!c->is_visible_in_tree())
+ if (!c->is_visible_in_tree() && !use_hidden_tabs_for_min_size)
continue;
Size2 cms = c->get_combined_minimum_size();
@@ -887,6 +887,13 @@ int TabContainer::get_tabs_rearrange_group() const {
return tabs_rearrange_group;
}
+void TabContainer::set_use_hidden_tabs_for_min_size(bool p_use_hidden_tabs) {
+ use_hidden_tabs_for_min_size = p_use_hidden_tabs;
+}
+
+bool TabContainer::get_use_hidden_tabs_for_min_size() const {
+ return use_hidden_tabs_for_min_size;
+}
void TabContainer::_bind_methods() {
ClassDB::bind_method(D_METHOD("_gui_input"), &TabContainer::_gui_input);
@@ -913,6 +920,9 @@ void TabContainer::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_tabs_rearrange_group", "group_id"), &TabContainer::set_tabs_rearrange_group);
ClassDB::bind_method(D_METHOD("get_tabs_rearrange_group"), &TabContainer::get_tabs_rearrange_group);
+ ClassDB::bind_method(D_METHOD("set_use_hidden_tabs_for_min_size", "enabled"), &TabContainer::set_use_hidden_tabs_for_min_size);
+ ClassDB::bind_method(D_METHOD("get_use_hidden_tabs_for_min_size"), &TabContainer::get_use_hidden_tabs_for_min_size);
+
ClassDB::bind_method(D_METHOD("_child_renamed_callback"), &TabContainer::_child_renamed_callback);
ClassDB::bind_method(D_METHOD("_on_theme_changed"), &TabContainer::_on_theme_changed);
ClassDB::bind_method(D_METHOD("_update_current_tab"), &TabContainer::_update_current_tab);
@@ -925,6 +935,7 @@ void TabContainer::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::INT, "current_tab", PROPERTY_HINT_RANGE, "-1,4096,1", PROPERTY_USAGE_EDITOR), "set_current_tab", "get_current_tab");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "tabs_visible"), "set_tabs_visible", "are_tabs_visible");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "drag_to_rearrange_enabled"), "set_drag_to_rearrange_enabled", "get_drag_to_rearrange_enabled");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_hidden_tabs_for_min_size"), "set_use_hidden_tabs_for_min_size", "get_use_hidden_tabs_for_min_size");
BIND_ENUM_CONSTANT(ALIGN_LEFT);
BIND_ENUM_CONSTANT(ALIGN_CENTER);
@@ -945,4 +956,5 @@ TabContainer::TabContainer() {
popup = NULL;
drag_to_rearrange_enabled = false;
tabs_rearrange_group = -1;
+ use_hidden_tabs_for_min_size = false;
}
diff --git a/scene/gui/tab_container.h b/scene/gui/tab_container.h
index f7a9fb64fd..0314f86837 100644
--- a/scene/gui/tab_container.h
+++ b/scene/gui/tab_container.h
@@ -59,6 +59,7 @@ private:
int _get_top_margin() const;
Popup *popup;
bool drag_to_rearrange_enabled;
+ bool use_hidden_tabs_for_min_size;
int tabs_rearrange_group;
Vector<Control *> _get_tabs() const;
@@ -118,6 +119,8 @@ public:
bool get_drag_to_rearrange_enabled() const;
void set_tabs_rearrange_group(int p_group_id);
int get_tabs_rearrange_group() const;
+ void set_use_hidden_tabs_for_min_size(bool p_use_hidden_tabs);
+ bool get_use_hidden_tabs_for_min_size() const;
TabContainer();
};
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index 1d434e5a2a..ab5ed3166c 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -596,8 +596,14 @@ void TextEdit::_update_minimap_drag() {
return;
}
+ int control_height = _get_control_height();
+ int scroll_height = v_scroll->get_max() * (minimap_char_size.y + minimap_line_spacing);
+ if (control_height > scroll_height) {
+ control_height = scroll_height;
+ }
+
Point2 mp = get_local_mouse_position();
- double diff = (mp.y - minimap_scroll_click_pos) / _get_control_height();
+ double diff = (mp.y - minimap_scroll_click_pos) / control_height;
v_scroll->set_as_ratio(minimap_scroll_ratio + diff);
}
@@ -2194,12 +2200,6 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
int row, col;
_get_mouse_pos(Point2i(mb->get_position().x, mb->get_position().y), row, col);
- if (mb->get_command() && highlighted_word != String()) {
-
- emit_signal("symbol_lookup", highlighted_word, row, col);
- return;
- }
-
// Toggle breakpoint on gutter click.
if (draw_breakpoint_gutter) {
int gutter = cache.style_normal->get_margin(MARGIN_LEFT);
@@ -2368,6 +2368,14 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
} else {
if (mb->get_button_index() == BUTTON_LEFT) {
+ if (mb->get_command() && highlighted_word != String()) {
+ int row, col;
+ _get_mouse_pos(Point2i(mb->get_position().x, mb->get_position().y), row, col);
+
+ emit_signal("symbol_lookup", highlighted_word, row, col);
+ return;
+ }
+
dragging_minimap = false;
dragging_selection = false;
can_drag_minimap = false;
@@ -4613,7 +4621,7 @@ Control::CursorShape TextEdit::get_cursor_shape(const Point2 &p_pos) const {
return CURSOR_ARROW;
} else {
int xmargin_end = get_size().width - cache.style_normal->get_margin(MARGIN_RIGHT);
- if (p_pos.x > xmargin_end - minimap_width && p_pos.x <= xmargin_end) {
+ if (draw_minimap && p_pos.x > xmargin_end - minimap_width && p_pos.x <= xmargin_end) {
return CURSOR_ARROW;
}
diff --git a/scene/gui/viewport_container.cpp b/scene/gui/viewport_container.cpp
index 3f7a110c1b..35696a0459 100644
--- a/scene/gui/viewport_container.cpp
+++ b/scene/gui/viewport_container.cpp
@@ -211,4 +211,5 @@ ViewportContainer::ViewportContainer() {
stretch = false;
shrink = 1;
set_process_input(true);
+ set_process_unhandled_input(true);
}
diff --git a/scene/main/http_request.cpp b/scene/main/http_request.cpp
index e21e47f8a8..6c922adbd2 100644
--- a/scene/main/http_request.cpp
+++ b/scene/main/http_request.cpp
@@ -60,10 +60,10 @@ Error HTTPRequest::_parse_url(const String &p_url) {
use_ssl = true;
port = 443;
} else {
- ERR_FAIL_V_MSG(ERR_INVALID_PARAMETER, "Malformed URL.");
+ ERR_FAIL_V_MSG(ERR_INVALID_PARAMETER, "Malformed URL: " + url + ".");
}
- ERR_FAIL_COND_V_MSG(url.length() < 1, ERR_INVALID_PARAMETER, "URL too short.");
+ ERR_FAIL_COND_V_MSG(url.length() < 1, ERR_INVALID_PARAMETER, "URL too short: " + url + ".");
int slash_pos = url.find("/");
diff --git a/scene/resources/default_theme/default_theme.cpp b/scene/resources/default_theme/default_theme.cpp
index 1a5f57ce48..d761eb01fe 100644
--- a/scene/resources/default_theme/default_theme.cpp
+++ b/scene/resources/default_theme/default_theme.cpp
@@ -611,6 +611,7 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const
theme->set_font("title_font", "GraphNode", default_font);
theme->set_color("title_color", "GraphNode", Color(0, 0, 0, 1));
theme->set_color("close_color", "GraphNode", Color(0, 0, 0, 1));
+ theme->set_color("resizer_color", "GraphNode", Color(0, 0, 0, 1));
theme->set_constant("title_offset", "GraphNode", 20 * scale);
theme->set_constant("close_offset", "GraphNode", 18 * scale);
theme->set_constant("port_offset", "GraphNode", 3 * scale);
diff --git a/scene/resources/visual_shader.cpp b/scene/resources/visual_shader.cpp
index 699410719c..e85609468b 100644
--- a/scene/resources/visual_shader.cpp
+++ b/scene/resources/visual_shader.cpp
@@ -2463,6 +2463,7 @@ String VisualShaderNodeExpression::generate_code(Shader::Mode p_mode, VisualShad
if (pre_symbols.empty()) {
pre_symbols.push_back("\t");
pre_symbols.push_back(",");
+ pre_symbols.push_back(";");
pre_symbols.push_back("{");
pre_symbols.push_back("[");
pre_symbols.push_back("(");
@@ -2479,9 +2480,9 @@ String VisualShaderNodeExpression::generate_code(Shader::Mode p_mode, VisualShad
static Vector<String> post_symbols;
if (post_symbols.empty()) {
- post_symbols.push_back("\0");
post_symbols.push_back("\t");
post_symbols.push_back("\n");
+ post_symbols.push_back(",");
post_symbols.push_back(";");
post_symbols.push_back("}");
post_symbols.push_back("]");
diff --git a/version.py b/version.py
index 09219f60ad..45817ed69f 100644
--- a/version.py
+++ b/version.py
@@ -2,7 +2,7 @@ short_name = "godot"
name = "Godot Engine"
major = 3
minor = 2
-status = "dev"
+status = "alpha"
module_config = ""
year = 2019
website = "https://godotengine.org"