summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/image.cpp6
-rw-r--r--core/io/file_access_compressed.cpp20
-rw-r--r--core/io/marshalls.cpp206
-rw-r--r--core/io/marshalls.h21
-rw-r--r--core/io/packet_peer.cpp20
-rw-r--r--core/io/packet_peer.h2
-rw-r--r--core/math/geometry.cpp4
-rw-r--r--core/math/rect3.h4
-rw-r--r--core/object.cpp12
-rw-r--r--core/object.h4
-rw-r--r--core/register_core_types.cpp3
-rw-r--r--core/script_debugger_remote.cpp60
-rw-r--r--core/script_debugger_remote.h2
-rw-r--r--core/typedefs.h21
-rw-r--r--core/vector.h4
-rw-r--r--doc/base/classes.xml13
-rw-r--r--drivers/alsa/audio_driver_alsa.cpp2
-rw-r--r--drivers/gles2/rasterizer_gles2.cpp18
-rw-r--r--drivers/gles3/rasterizer_canvas_gles3.cpp7
-rw-r--r--drivers/gles3/rasterizer_scene_gles3.cpp50
-rw-r--r--drivers/gles3/rasterizer_scene_gles3.h4
-rw-r--r--drivers/gles3/rasterizer_storage_gles3.cpp12
-rw-r--r--drivers/gles3/rasterizer_storage_gles3.h2
-rw-r--r--drivers/pulseaudio/audio_driver_pulseaudio.cpp2
-rw-r--r--drivers/rtaudio/audio_driver_rtaudio.cpp2
-rw-r--r--drivers/xaudio2/audio_driver_xaudio2.cpp2
-rw-r--r--editor/code_editor.cpp12
-rw-r--r--editor/connections_dialog.h3
-rw-r--r--editor/editor_audio_buses.cpp2
-rw-r--r--editor/editor_autoload_settings.cpp2
-rw-r--r--editor/editor_file_system.cpp70
-rw-r--r--editor/editor_file_system.h7
-rw-r--r--editor/editor_node.cpp6
-rw-r--r--editor/editor_settings.cpp1
-rw-r--r--editor/import/resource_importer_scene.cpp22
-rw-r--r--editor/io_plugins/editor_font_import_plugin.cpp4
-rw-r--r--editor/io_plugins/editor_texture_import_plugin.cpp4
-rw-r--r--editor/node_dock.cpp5
-rw-r--r--editor/node_dock.h2
-rw-r--r--editor/plugins/baked_light_baker.cpp4
-rw-r--r--editor/plugins/path_editor_plugin.cpp18
-rw-r--r--editor/plugins/script_editor_plugin.cpp17
-rw-r--r--editor/plugins/script_editor_plugin.h1
-rw-r--r--editor/plugins/script_text_editor.cpp1
-rw-r--r--editor/plugins/sprite_frames_editor_plugin.cpp2
-rw-r--r--editor/property_editor.cpp29
-rw-r--r--editor/scene_tree_dock.cpp2
-rw-r--r--editor/scene_tree_editor.cpp6
-rw-r--r--editor/script_editor_debugger.cpp14
-rw-r--r--editor/spatial_editor_gizmos.cpp2
-rw-r--r--modules/etc/image_etc.cpp2
-rw-r--r--modules/gdnative/godot/string.h2
-rw-r--r--modules/gdscript/gd_functions.cpp2
-rw-r--r--modules/visual_script/visual_script.cpp11
-rw-r--r--modules/visual_script/visual_script_builtin_funcs.cpp2
-rw-r--r--modules/visual_script/visual_script_editor.cpp15
-rw-r--r--platform/android/audio_driver_jandroid.cpp2
-rw-r--r--platform/haiku/audio_driver_media_kit.cpp2
-rw-r--r--platform/osx/audio_driver_osx.cpp102
-rw-r--r--platform/osx/audio_driver_osx.h4
-rw-r--r--platform/windows/detect.py61
-rw-r--r--platform/windows/os_windows.cpp7
-rw-r--r--platform/x11/context_gl_x11.cpp14
-rw-r--r--platform/x11/os_x11.cpp11
-rw-r--r--scene/2d/canvas_item.cpp12
-rw-r--r--scene/2d/canvas_item.h4
-rw-r--r--scene/2d/polygon_2d.cpp20
-rw-r--r--scene/2d/polygon_2d.h4
-rw-r--r--scene/3d/light.cpp16
-rw-r--r--scene/3d/light.h4
-rw-r--r--scene/3d/visual_instance.cpp19
-rw-r--r--scene/3d/visual_instance.h1
-rw-r--r--scene/gui/button.cpp4
-rw-r--r--scene/gui/dialogs.cpp2
-rw-r--r--scene/gui/file_dialog.cpp2
-rw-r--r--scene/gui/label.cpp9
-rw-r--r--scene/gui/line_edit.cpp2
-rw-r--r--scene/gui/popup_menu.cpp14
-rw-r--r--scene/gui/scroll_bar.cpp54
-rw-r--r--scene/gui/scroll_bar.h7
-rw-r--r--scene/gui/tab_container.cpp4
-rw-r--r--scene/gui/text_edit.cpp103
-rw-r--r--scene/gui/text_edit.h7
-rw-r--r--scene/gui/tree.cpp32
-rw-r--r--scene/gui/tree.h9
-rw-r--r--scene/main/scene_tree.cpp79
-rw-r--r--scene/resources/dynamic_font.cpp2
-rw-r--r--scene/resources/dynamic_font_stb.cpp2
-rw-r--r--scene/resources/material.cpp3
-rw-r--r--scene/resources/packed_scene.cpp8
-rw-r--r--scene/resources/sky_box.cpp63
-rw-r--r--scene/resources/sky_box.h11
-rw-r--r--scene/resources/style_box.cpp17
-rw-r--r--servers/audio/audio_driver_dummy.cpp2
-rw-r--r--servers/audio_server.cpp74
-rw-r--r--servers/audio_server.h2
-rw-r--r--servers/visual/rasterizer.h2
-rw-r--r--servers/visual/visual_server_canvas.cpp9
-rw-r--r--servers/visual/visual_server_canvas.h2
-rw-r--r--servers/visual/visual_server_raster.cpp2
-rw-r--r--servers/visual/visual_server_raster.h3
-rw-r--r--servers/visual/visual_server_scene.cpp22
-rw-r--r--servers/visual/visual_server_wrap_mt.h3
-rw-r--r--servers/visual_server.cpp14
-rw-r--r--servers/visual_server.h4
-rw-r--r--thirdparty/README.md3
-rw-r--r--thirdparty/minizip/LICENSE-InfoZip.txt60
-rw-r--r--thirdparty/minizip/LICENSE-MiniZip.txt32
-rw-r--r--thirdparty/minizip/MiniZip_info.txt74
-rw-r--r--thirdparty/minizip/godot-zlib-1.2.4-minizip-seek.patch295
-rw-r--r--thirdparty/minizip/ioapi.c10
-rw-r--r--thirdparty/minizip/ioapi.h49
-rw-r--r--thirdparty/minizip/unzip.c241
-rw-r--r--thirdparty/minizip/unzip.h85
-rw-r--r--thirdparty/minizip/zip.c33
-rw-r--r--thirdparty/minizip/zip.h71
116 files changed, 1708 insertions, 874 deletions
diff --git a/core/image.cpp b/core/image.cpp
index 2db9cb1571..a4864458b5 100644
--- a/core/image.cpp
+++ b/core/image.cpp
@@ -676,8 +676,8 @@ void Image::resize_to_po2(bool p_square) {
ERR_FAIL();
}
- int w = nearest_power_of_2(width);
- int h = nearest_power_of_2(height);
+ int w = next_power_of_2(width);
+ int h = next_power_of_2(height);
if (w == width && h == height) {
@@ -1060,7 +1060,7 @@ Error Image::generate_mipmaps() {
PoolVector<uint8_t>::Write wp = data.write();
- if (nearest_power_of_2(width) == uint32_t(width) && nearest_power_of_2(height) == uint32_t(height)) {
+ if (next_power_of_2(width) == uint32_t(width) && next_power_of_2(height) == uint32_t(height)) {
//use fast code for powers of 2
int prev_ofs = 0;
int prev_h = height;
diff --git a/core/io/file_access_compressed.cpp b/core/io/file_access_compressed.cpp
index 4e802579c6..34bce3f04f 100644
--- a/core/io/file_access_compressed.cpp
+++ b/core/io/file_access_compressed.cpp
@@ -43,16 +43,16 @@ void FileAccessCompressed::configure(const String &p_magic, Compression::Mode p_
block_size = p_block_size;
}
-#define WRITE_FIT(m_bytes) \
- { \
- if (write_pos + (m_bytes) > write_max) { \
- write_max = write_pos + (m_bytes); \
- } \
- if (write_max > write_buffer_size) { \
- write_buffer_size = nearest_power_of_2(write_max); \
- buffer.resize(write_buffer_size); \
- write_ptr = buffer.ptr(); \
- } \
+#define WRITE_FIT(m_bytes) \
+ { \
+ if (write_pos + (m_bytes) > write_max) { \
+ write_max = write_pos + (m_bytes); \
+ } \
+ if (write_max > write_buffer_size) { \
+ write_buffer_size = next_power_of_2(write_max); \
+ buffer.resize(write_buffer_size); \
+ write_ptr = buffer.ptr(); \
+ } \
}
Error FileAccessCompressed::open_after_magic(FileAccess *p_base) {
diff --git a/core/io/marshalls.cpp b/core/io/marshalls.cpp
index 8eb40b61d7..c5d59f786d 100644
--- a/core/io/marshalls.cpp
+++ b/core/io/marshalls.cpp
@@ -33,8 +33,28 @@
#include "reference.h"
#include <stdio.h>
+void EncodedObjectAsID::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("set_object_id", "id"), &EncodedObjectAsID::set_object_id);
+ ClassDB::bind_method(D_METHOD("get_object_id"), &EncodedObjectAsID::get_object_id);
+}
+
+void EncodedObjectAsID::set_object_id(ObjectID p_id) {
+ id = p_id;
+}
+
+ObjectID EncodedObjectAsID::get_object_id() const {
+
+ return id;
+}
+
+EncodedObjectAsID::EncodedObjectAsID() {
+
+ id = 0;
+}
+
#define ENCODE_MASK 0xFF
#define ENCODE_FLAG_64 1 << 16
+#define ENCODE_FLAG_OBJECT_AS_ID 1 << 16
static Error _decode_string(const uint8_t *&buf, int &len, int *r_len, String &r_string) {
ERR_FAIL_COND_V(len < 4, ERR_INVALID_DATA);
@@ -381,56 +401,74 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
} break;
case Variant::OBJECT: {
- ERR_FAIL_COND_V(!p_allow_objects, ERR_UNAUTHORIZED);
-
- String str;
- Error err = _decode_string(buf, len, r_len, str);
- if (err)
- return err;
+ if (type & ENCODE_FLAG_OBJECT_AS_ID) {
+ //this _is_ allowed
+ ObjectID val = decode_uint64(buf);
+ if (r_len)
+ (*r_len) += 8;
- if (str == String()) {
- r_variant = (Object *)NULL;
- } else {
+ if (val == 0) {
+ r_variant = (Object *)NULL;
+ } else {
+ Ref<EncodedObjectAsID> obj_as_id;
+ obj_as_id.instance();
+ obj_as_id->set_object_id(val);
- Object *obj = ClassDB::instance(str);
+ r_variant = obj_as_id;
+ }
- ERR_FAIL_COND_V(!obj, ERR_UNAVAILABLE);
- ERR_FAIL_COND_V(len < 4, ERR_INVALID_DATA);
+ } else {
+ ERR_FAIL_COND_V(!p_allow_objects, ERR_UNAUTHORIZED);
- int32_t count = decode_uint32(buf);
- buf += 4;
- len -= 4;
- if (r_len) {
- (*r_len) += 4;
- }
+ String str;
+ Error err = _decode_string(buf, len, r_len, str);
+ if (err)
+ return err;
- for (int i = 0; i < count; i++) {
+ if (str == String()) {
+ r_variant = (Object *)NULL;
+ } else {
- str = String();
- err = _decode_string(buf, len, r_len, str);
- if (err)
- return err;
+ Object *obj = ClassDB::instance(str);
- Variant value;
- int used;
- err = decode_variant(value, buf, len, &used, p_allow_objects);
- if (err)
- return err;
+ ERR_FAIL_COND_V(!obj, ERR_UNAVAILABLE);
+ ERR_FAIL_COND_V(len < 4, ERR_INVALID_DATA);
- buf += used;
- len -= used;
+ int32_t count = decode_uint32(buf);
+ buf += 4;
+ len -= 4;
if (r_len) {
- (*r_len) += used;
+ (*r_len) += 4;
}
- obj->set(str, value);
- }
+ for (int i = 0; i < count; i++) {
- if (obj->cast_to<Reference>()) {
- REF ref = REF(obj->cast_to<Reference>());
- r_variant = ref;
- } else {
- r_variant = obj;
+ str = String();
+ err = _decode_string(buf, len, r_len, str);
+ if (err)
+ return err;
+
+ Variant value;
+ int used;
+ err = decode_variant(value, buf, len, &used, p_allow_objects);
+ if (err)
+ return err;
+
+ buf += used;
+ len -= used;
+ if (r_len) {
+ (*r_len) += used;
+ }
+
+ obj->set(str, value);
+ }
+
+ if (obj->cast_to<Reference>()) {
+ REF ref = REF(obj->cast_to<Reference>());
+ r_variant = ref;
+ } else {
+ r_variant = obj;
+ }
}
}
@@ -776,7 +814,7 @@ static void _encode_string(const String &p_string, uint8_t *&buf, int &r_len) {
r_len++; //pad
}
-Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len) {
+Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bool p_object_as_id) {
uint8_t *buf = r_buffer;
@@ -800,6 +838,11 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len) {
flags |= ENCODE_FLAG_64; //always encode real as double
}
} break;
+ case Variant::OBJECT: {
+ if (p_object_as_id) {
+ flags |= ENCODE_FLAG_OBJECT_AS_ID;
+ }
+ } break;
}
if (buf) {
@@ -1071,49 +1114,66 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len) {
} break;
case Variant::OBJECT: {
- Object *obj = p_variant;
- if (!obj) {
+ if (p_object_as_id) {
+
if (buf) {
- encode_uint32(0, buf);
- buf += 4;
- r_len += 4;
+
+ Object *obj = p_variant;
+ ObjectID id = 0;
+ if (obj && ObjectDB::instance_validate(obj)) {
+ id = obj->get_instance_id();
+ }
+
+ encode_uint64(id, buf);
}
+
+ r_len += 8;
+
} else {
- _encode_string(obj->get_class(), buf, r_len);
+ Object *obj = p_variant;
+ if (!obj) {
+ if (buf) {
+ encode_uint32(0, buf);
+ buf += 4;
+ r_len += 4;
+ }
+ } else {
+ _encode_string(obj->get_class(), buf, r_len);
- List<PropertyInfo> props;
- obj->get_property_list(&props);
+ List<PropertyInfo> props;
+ obj->get_property_list(&props);
- int pc = 0;
- for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) {
+ int pc = 0;
+ for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) {
- if (!(E->get().usage & PROPERTY_USAGE_STORAGE))
- continue;
- pc++;
- }
+ if (!(E->get().usage & PROPERTY_USAGE_STORAGE))
+ continue;
+ pc++;
+ }
- if (buf) {
- encode_uint32(pc, buf);
- buf += 4;
- }
+ if (buf) {
+ encode_uint32(pc, buf);
+ buf += 4;
+ }
- r_len += 4;
+ r_len += 4;
- for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) {
+ for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) {
- if (!(E->get().usage & PROPERTY_USAGE_STORAGE))
- continue;
+ if (!(E->get().usage & PROPERTY_USAGE_STORAGE))
+ continue;
- _encode_string(E->get().name, buf, r_len);
+ _encode_string(E->get().name, buf, r_len);
- int len;
- Error err = encode_variant(obj->get(E->get().name), buf, len);
- if (err)
- return err;
- ERR_FAIL_COND_V(len % 4, ERR_BUG);
- r_len += len;
- if (buf)
- buf += len;
+ int len;
+ Error err = encode_variant(obj->get(E->get().name), buf, len, p_object_as_id);
+ if (err)
+ return err;
+ ERR_FAIL_COND_V(len % 4, ERR_BUG);
+ r_len += len;
+ if (buf)
+ buf += len;
+ }
}
}
@@ -1147,12 +1207,12 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len) {
r_len++; //pad
*/
int len;
- encode_variant(E->get(), buf, len);
+ encode_variant(E->get(), buf, len, p_object_as_id);
ERR_FAIL_COND_V(len % 4, ERR_BUG);
r_len += len;
if (buf)
buf += len;
- encode_variant(d[E->get()], buf, len);
+ encode_variant(d[E->get()], buf, len, p_object_as_id);
ERR_FAIL_COND_V(len % 4, ERR_BUG);
r_len += len;
if (buf)
@@ -1174,7 +1234,7 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len) {
for (int i = 0; i < v.size(); i++) {
int len;
- encode_variant(v.get(i), buf, len);
+ encode_variant(v.get(i), buf, len, p_object_as_id);
ERR_FAIL_COND_V(len % 4, ERR_BUG);
r_len += len;
if (buf)
diff --git a/core/io/marshalls.h b/core/io/marshalls.h
index a6cc72b691..234ae3b183 100644
--- a/core/io/marshalls.h
+++ b/core/io/marshalls.h
@@ -32,8 +32,8 @@
#include "typedefs.h"
+#include "reference.h"
#include "variant.h"
-
/**
* Miscellaneous helpers for marshalling data types, and encoding
* in an endian independent way
@@ -183,7 +183,22 @@ static inline double decode_double(const uint8_t *p_arr) {
return md.d;
}
-Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int *r_len = NULL, bool p_allow_objects=true);
-Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len);
+class EncodedObjectAsID : public Reference {
+ GDCLASS(EncodedObjectAsID, Reference);
+
+ ObjectID id;
+
+protected:
+ static void _bind_methods();
+
+public:
+ void set_object_id(ObjectID p_id);
+ ObjectID get_object_id() const;
+
+ EncodedObjectAsID();
+};
+
+Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int *r_len = NULL, bool p_allow_objects = true);
+Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bool p_object_as_id = false);
#endif
diff --git a/core/io/packet_peer.cpp b/core/io/packet_peer.cpp
index f62ffd7183..ca00b8b480 100644
--- a/core/io/packet_peer.cpp
+++ b/core/io/packet_peer.cpp
@@ -92,7 +92,7 @@ Error PacketPeer::get_var(Variant &r_variant) const {
Error PacketPeer::put_var(const Variant &p_packet) {
int len;
- Error err = encode_variant(p_packet, NULL, len); // compute len first
+ Error err = encode_variant(p_packet, NULL, len, !allow_object_decoding); // compute len first
if (err)
return err;
@@ -101,7 +101,7 @@ Error PacketPeer::put_var(const Variant &p_packet) {
uint8_t *buf = (uint8_t *)alloca(len);
ERR_FAIL_COND_V(!buf, ERR_OUT_OF_MEMORY);
- err = encode_variant(p_packet, buf, len);
+ err = encode_variant(p_packet, buf, len, !allow_object_decoding);
ERR_FAIL_COND_V(err, err);
return put_packet(buf, len);
@@ -155,6 +155,8 @@ void PacketPeerStream::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_stream_peer", "peer"), &PacketPeerStream::_set_stream_peer);
ClassDB::bind_method(D_METHOD("set_input_buffer_max_size", "max_size_bytes"), &PacketPeerStream::set_input_buffer_max_size);
ClassDB::bind_method(D_METHOD("set_output_buffer_max_size", "max_size_bytes"), &PacketPeerStream::set_output_buffer_max_size);
+ ClassDB::bind_method(D_METHOD("get_input_buffer_max_size"), &PacketPeerStream::get_input_buffer_max_size);
+ ClassDB::bind_method(D_METHOD("get_output_buffer_max_size"), &PacketPeerStream::get_output_buffer_max_size);
}
Error PacketPeerStream::_poll_buffer() const {
@@ -265,12 +267,22 @@ void PacketPeerStream::set_input_buffer_max_size(int p_max_size) {
ERR_EXPLAIN("Buffer in use, resizing would cause loss of data");
ERR_FAIL_COND(ring_buffer.data_left());
ring_buffer.resize(nearest_shift(p_max_size + 4));
- input_buffer.resize(nearest_power_of_2(p_max_size + 4));
+ input_buffer.resize(next_power_of_2(p_max_size + 4));
+}
+
+int PacketPeerStream::get_input_buffer_max_size() const {
+
+ return input_buffer.size() - 4;
}
void PacketPeerStream::set_output_buffer_max_size(int p_max_size) {
- output_buffer.resize(nearest_power_of_2(p_max_size + 4));
+ output_buffer.resize(next_power_of_2(p_max_size + 4));
+}
+
+int PacketPeerStream::get_output_buffer_max_size() const {
+
+ return output_buffer.size() - 4;
}
PacketPeerStream::PacketPeerStream() {
diff --git a/core/io/packet_peer.h b/core/io/packet_peer.h
index 3bd6876aa7..597119f7f4 100644
--- a/core/io/packet_peer.h
+++ b/core/io/packet_peer.h
@@ -98,7 +98,9 @@ public:
void set_stream_peer(const Ref<StreamPeer> &p_peer);
void set_input_buffer_max_size(int p_max_size);
+ int get_input_buffer_max_size() const;
void set_output_buffer_max_size(int p_max_size);
+ int get_output_buffer_max_size() const;
PacketPeerStream();
};
diff --git a/core/math/geometry.cpp b/core/math/geometry.cpp
index 2bea514d37..9a5811244a 100644
--- a/core/math/geometry.cpp
+++ b/core/math/geometry.cpp
@@ -1076,8 +1076,8 @@ void Geometry::make_atlas(const Vector<Size2i> &p_rects, Vector<Point2i> &r_resu
for (int i = 0; i < results.size(); i++) {
- real_t h = nearest_power_of_2(results[i].max_h);
- real_t w = nearest_power_of_2(results[i].max_w);
+ real_t h = next_power_of_2(results[i].max_h);
+ real_t w = next_power_of_2(results[i].max_w);
real_t aspect = h > w ? h / w : w / h;
if (aspect < best_aspect) {
best = i;
diff --git a/core/math/rect3.h b/core/math/rect3.h
index 7c971f5ac7..4890a19d99 100644
--- a/core/math/rect3.h
+++ b/core/math/rect3.h
@@ -47,12 +47,12 @@ public:
real_t get_area() const; /// get area
_FORCE_INLINE_ bool has_no_area() const {
- return (size.x <= CMP_EPSILON || size.y <= CMP_EPSILON || size.z <= CMP_EPSILON);
+ return (size.x <= 0 || size.y <= 0 || size.z <= 0);
}
_FORCE_INLINE_ bool has_no_surface() const {
- return (size.x <= CMP_EPSILON && size.y <= CMP_EPSILON && size.z <= CMP_EPSILON);
+ return (size.x <= 0 && size.y <= 0 && size.z <= 0);
}
const Vector3 &get_position() const { return position; }
diff --git a/core/object.cpp b/core/object.cpp
index 62b2b5d545..06c2603b74 100644
--- a/core/object.cpp
+++ b/core/object.cpp
@@ -1560,7 +1560,7 @@ void Object::initialize_class() {
initialized = true;
}
-StringName Object::XL_MESSAGE(const StringName &p_message) const {
+StringName Object::tr(const StringName &p_message) const {
if (!_can_translate || !TranslationServer::get_singleton())
return p_message;
@@ -1568,11 +1568,6 @@ StringName Object::XL_MESSAGE(const StringName &p_message) const {
return TranslationServer::get_singleton()->translate(p_message);
}
-StringName Object::tr(const StringName &p_message) const {
-
- return XL_MESSAGE(p_message);
-}
-
void Object::_clear_internal_resource_paths(const Variant &p_var) {
switch (p_var.get_type()) {
@@ -1712,11 +1707,10 @@ void Object::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_block_signals", "enable"), &Object::set_block_signals);
ClassDB::bind_method(D_METHOD("is_blocking_signals"), &Object::is_blocking_signals);
- ClassDB::bind_method(D_METHOD("set_message_translation", "enable"), &Object::set_message_translation);
- ClassDB::bind_method(D_METHOD("can_translate_messages"), &Object::can_translate_messages);
ClassDB::bind_method(D_METHOD("property_list_changed_notify"), &Object::property_list_changed_notify);
- ClassDB::bind_method(D_METHOD("XL_MESSAGE", "message"), &Object::XL_MESSAGE);
+ ClassDB::bind_method(D_METHOD("set_message_translation", "enable"), &Object::set_message_translation);
+ ClassDB::bind_method(D_METHOD("can_translate_messages"), &Object::can_translate_messages);
ClassDB::bind_method(D_METHOD("tr", "message"), &Object::tr);
ClassDB::bind_method(D_METHOD("is_queued_for_deletion"), &Object::is_queued_for_deletion);
diff --git a/core/object.h b/core/object.h
index 4648d9d90e..8a858b5b00 100644
--- a/core/object.h
+++ b/core/object.h
@@ -83,6 +83,7 @@ enum PropertyHint {
PROPERTY_HINT_PROPERTY_OF_BASE_TYPE, ///< a property of a base type
PROPERTY_HINT_PROPERTY_OF_INSTANCE, ///< a property of an instance
PROPERTY_HINT_PROPERTY_OF_SCRIPT, ///< a property of a script & base
+ PROPERTY_HINT_OBJECT_TOO_BIG, ///< object is too big to send
PROPERTY_HINT_MAX,
};
@@ -678,8 +679,7 @@ public:
virtual void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const;
- StringName XL_MESSAGE(const StringName &p_message) const; //translate message (internationalization)
- StringName tr(const StringName &p_message) const; //translate message (alternative)
+ StringName tr(const StringName &p_message) const; // translate message (internationalization)
bool _is_queued_for_deletion; // set to true by SceneTree::queue_delete()
bool is_queued_for_deletion() const;
diff --git a/core/register_core_types.cpp b/core/register_core_types.cpp
index 43f781af55..fca9afbf5e 100644
--- a/core/register_core_types.cpp
+++ b/core/register_core_types.cpp
@@ -39,6 +39,7 @@
#include "input_map.h"
#include "io/config_file.h"
#include "io/http_client.h"
+#include "io/marshalls.h"
#include "io/packet_peer.h"
#include "io/packet_peer_udp.h"
#include "io/pck_packer.h"
@@ -56,7 +57,6 @@
#include "project_settings.h"
#include "translation.h"
#include "undo_redo.h"
-
static ResourceFormatSaverBinary *resource_saver_binary = NULL;
static ResourceFormatLoaderBinary *resource_loader_binary = NULL;
static ResourceFormatImporter *resource_format_importer = NULL;
@@ -157,6 +157,7 @@ void register_core_types() {
ClassDB::register_class<PackedDataContainer>();
ClassDB::register_virtual_class<PackedDataContainerRef>();
ClassDB::register_class<AStar>();
+ ClassDB::register_class<EncodedObjectAsID>();
ip = IP::create();
diff --git a/core/script_debugger_remote.cpp b/core/script_debugger_remote.cpp
index 44e86bca6a..25f0044cc6 100644
--- a/core/script_debugger_remote.cpp
+++ b/core/script_debugger_remote.cpp
@@ -30,10 +30,10 @@
#include "script_debugger_remote.h"
#include "io/ip.h"
+#include "io/marshalls.h"
#include "os/input.h"
#include "os/os.h"
#include "project_settings.h"
-
void ScriptDebuggerRemote::_send_video_memory() {
List<ResourceUsage> usage;
@@ -120,6 +120,18 @@ static ObjectID safe_get_instance_id(const Variant &p_v) {
}
}
+void ScriptDebuggerRemote::_put_variable(const String &p_name, const Variant &p_variable) {
+
+ packet_peer_stream->put_var(p_name);
+ int len = 0;
+ Error err = encode_variant(p_variable, NULL, len);
+ if (len > packet_peer_stream->get_output_buffer_max_size()) { //limit to max size
+ packet_peer_stream->put_var(Variant());
+ } else {
+ packet_peer_stream->put_var(p_variable);
+ }
+}
+
void ScriptDebuggerRemote::debug(ScriptLanguage *p_script, bool p_can_continue) {
//this function is called when there is a debugger break (bug on script)
@@ -210,14 +222,7 @@ void ScriptDebuggerRemote::debug(ScriptLanguage *p_script, bool p_can_continue)
while (E) {
- if (F->get().get_type() == Variant::OBJECT) {
- packet_peer_stream->put_var("*" + E->get());
- String pretty_print = F->get().operator String();
- packet_peer_stream->put_var(pretty_print.ascii().get_data());
- } else {
- packet_peer_stream->put_var(E->get());
- packet_peer_stream->put_var(F->get());
- }
+ _put_variable(E->get(), F->get());
E = E->next();
F = F->next();
@@ -231,15 +236,7 @@ void ScriptDebuggerRemote::debug(ScriptLanguage *p_script, bool p_can_continue)
List<Variant>::Element *F = local_vals.front();
while (E) {
-
- if (F->get().get_type() == Variant::OBJECT) {
- packet_peer_stream->put_var("*" + E->get());
- String pretty_print = F->get().operator String();
- packet_peer_stream->put_var(pretty_print.ascii().get_data());
- } else {
- packet_peer_stream->put_var(E->get());
- packet_peer_stream->put_var(F->get());
- }
+ _put_variable(E->get(), F->get());
E = E->next();
F = F->next();
@@ -566,30 +563,19 @@ void ScriptDebuggerRemote::_send_object_id(ObjectID p_id) {
}
Variant var = obj->get(E->get().name);
+ packet_peer_stream->put_var(E->get().type);
+ //only send information that can be sent..
- if (E->get().type == Variant::OBJECT || var.get_type() == Variant::OBJECT) {
-
- ObjectID id2;
- Object *obj = var;
- if (obj) {
- id2 = obj->get_instance_id();
- } else {
- id2 = 0;
- }
+ int len = 0; //test how big is this to encode
+ encode_variant(var, NULL, len);
- packet_peer_stream->put_var(Variant::INT); //hint string
- packet_peer_stream->put_var(PROPERTY_HINT_OBJECT_ID); //hint
- packet_peer_stream->put_var(E->get().hint_string); //hint string
- packet_peer_stream->put_var(id2); //value
+ if (len > packet_peer_stream->get_output_buffer_max_size()) { //limit to max size
+ packet_peer_stream->put_var(PROPERTY_HINT_OBJECT_TOO_BIG);
+ packet_peer_stream->put_var("");
+ packet_peer_stream->put_var(Variant());
} else {
- packet_peer_stream->put_var(E->get().type);
packet_peer_stream->put_var(E->get().hint);
packet_peer_stream->put_var(E->get().hint_string);
- //only send information that can be sent..
-
- if (var.get_type() >= Variant::DICTIONARY) {
- var = Array(); //send none for now, may be to big
- }
packet_peer_stream->put_var(var);
}
}
diff --git a/core/script_debugger_remote.h b/core/script_debugger_remote.h
index 924e3774a2..cf75c0eb4a 100644
--- a/core/script_debugger_remote.h
+++ b/core/script_debugger_remote.h
@@ -126,6 +126,8 @@ class ScriptDebuggerRemote : public ScriptDebugger {
Vector<FrameData> profile_frame_data;
+ void _put_variable(const String &p_name, const Variant &p_variable);
+
public:
struct ResourceUsage {
diff --git a/core/typedefs.h b/core/typedefs.h
index 40d9ea37b5..34a1a93a3b 100644
--- a/core/typedefs.h
+++ b/core/typedefs.h
@@ -162,9 +162,9 @@ inline void __swap_tmpl(T &x, T &y) {
#define _add_overflow __builtin_add_overflow
#endif
-/** Function to find the nearest (bigger) power of 2 to an integer */
+/** Function to find the next power of 2 to an integer */
-static _FORCE_INLINE_ unsigned int nearest_power_of_2(unsigned int x) {
+static _FORCE_INLINE_ unsigned int next_power_of_2(unsigned int x) {
--x;
x |= x >> 1;
@@ -176,6 +176,23 @@ static _FORCE_INLINE_ unsigned int nearest_power_of_2(unsigned int x) {
return ++x;
}
+static _FORCE_INLINE_ unsigned int previous_power_of_2(unsigned int x) {
+
+ x |= x >> 1;
+ x |= x >> 2;
+ x |= x >> 4;
+ x |= x >> 8;
+ x |= x >> 16;
+ return x - (x >> 1);
+}
+
+static _FORCE_INLINE_ unsigned int closest_power_of_2(unsigned int x) {
+
+ unsigned int nx = next_power_of_2(x);
+ unsigned int px = previous_power_of_2(x);
+ return (nx - x) > (x - px) ? px : nx;
+}
+
// We need this definition inside the function below.
static inline int get_shift_from_power_of_2(unsigned int p_pixel);
diff --git a/core/vector.h b/core/vector.h
index 9f523c567c..966832ac50 100644
--- a/core/vector.h
+++ b/core/vector.h
@@ -71,7 +71,7 @@ class Vector {
_FORCE_INLINE_ size_t _get_alloc_size(size_t p_elements) const {
//return nearest_power_of_2_templated(p_elements*sizeof(T)+sizeof(SafeRefCount)+sizeof(int));
- return nearest_power_of_2(p_elements * sizeof(T));
+ return next_power_of_2(p_elements * sizeof(T));
}
_FORCE_INLINE_ bool _get_alloc_size_checked(size_t p_elements, size_t *out) const {
@@ -79,7 +79,7 @@ class Vector {
size_t o;
size_t p;
if (_mul_overflow(p_elements, sizeof(T), &o)) return false;
- *out = nearest_power_of_2(o);
+ *out = next_power_of_2(o);
if (_add_overflow(o, static_cast<size_t>(32), &p)) return false; //no longer allocated here
return true;
#else
diff --git a/doc/base/classes.xml b/doc/base/classes.xml
index e9902badea..f21fa2c7c0 100644
--- a/doc/base/classes.xml
+++ b/doc/base/classes.xml
@@ -28002,15 +28002,6 @@
Objects also receive notifications ([method _notification]). Notifications are a simple way to notify the object about simple events, so they can all be handled together.
</description>
<methods>
- <method name="XL_MESSAGE" qualifiers="const">
- <return type="String">
- </return>
- <argument index="0" name="message" type="String">
- </argument>
- <description>
- Deprecated, will go away.
- </description>
- </method>
<method name="_get" qualifiers="virtual">
<argument index="0" name="property" type="String">
</argument>
@@ -28301,7 +28292,7 @@
<argument index="0" name="enable" type="bool">
</argument>
<description>
- Set true if this object can translate strings (in calls to tr() ). Default is true.
+ Define whether this object can translate strings (with calls to [method tr]). Default is true.
</description>
</method>
<method name="set_meta">
@@ -28326,7 +28317,7 @@
<argument index="0" name="message" type="String">
</argument>
<description>
- Translate a message. Only works in message translation is enabled (which is by default). See [method set_message_translation].
+ Translate a message. Only works if message translation is enabled (which it is by default). See [method set_message_translation].
</description>
</method>
</methods>
diff --git a/drivers/alsa/audio_driver_alsa.cpp b/drivers/alsa/audio_driver_alsa.cpp
index 4e6739e8c0..a6b9748129 100644
--- a/drivers/alsa/audio_driver_alsa.cpp
+++ b/drivers/alsa/audio_driver_alsa.cpp
@@ -87,7 +87,7 @@ Error AudioDriverALSA::init() {
CHECK_FAIL(status < 0);
int latency = GLOBAL_DEF("audio/output_latency", 25);
- buffer_size = nearest_power_of_2(latency * mix_rate / 1000);
+ buffer_size = closest_power_of_2(latency * mix_rate / 1000);
// set buffer size from project settings
status = snd_pcm_hw_params_set_buffer_size_near(pcm_handle, hwparams, &buffer_size);
diff --git a/drivers/gles2/rasterizer_gles2.cpp b/drivers/gles2/rasterizer_gles2.cpp
index 7ad08ed7d5..6a6611ff81 100644
--- a/drivers/gles2/rasterizer_gles2.cpp
+++ b/drivers/gles2/rasterizer_gles2.cpp
@@ -857,8 +857,8 @@ void RasterizerGLES2::texture_allocate(RID p_texture, int p_width, int p_height,
GLenum internal_format;
bool compressed;
- int po2_width = nearest_power_of_2(p_width);
- int po2_height = nearest_power_of_2(p_height);
+ int po2_width = next_power_of_2(p_width);
+ int po2_height = next_power_of_2(p_height);
if (p_flags & VS::TEXTURE_FLAG_VIDEO_SURFACE) {
p_flags &= ~VS::TEXTURE_FLAG_MIPMAPS; // no mipies for video
@@ -977,7 +977,7 @@ void RasterizerGLES2::texture_set_data(RID p_texture, const Image &p_image, VS::
glTexParameteri(texture->target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); // raw Filtering
}
- bool force_clamp_to_edge = !(texture->flags & VS::TEXTURE_FLAG_MIPMAPS && !texture->ignore_mipmaps) && (nearest_power_of_2(texture->alloc_height) != texture->alloc_height || nearest_power_of_2(texture->alloc_width) != texture->alloc_width);
+ bool force_clamp_to_edge = !(texture->flags & VS::TEXTURE_FLAG_MIPMAPS && !texture->ignore_mipmaps) && (next_power_of_2(texture->alloc_height) != texture->alloc_height || next_power_of_2(texture->alloc_width) != texture->alloc_width);
if (!force_clamp_to_edge && (texture->flags & VS::TEXTURE_FLAG_REPEAT || texture->flags & VS::TEXTURE_FLAG_MIRRORED_REPEAT) && texture->target != GL_TEXTURE_CUBE_MAP) {
@@ -1234,7 +1234,7 @@ void RasterizerGLES2::texture_set_flags(RID p_texture, uint32_t p_flags) {
uint32_t cube = texture->flags & VS::TEXTURE_FLAG_CUBEMAP;
texture->flags = p_flags | cube; // can't remove a cube from being a cube
- bool force_clamp_to_edge = !(p_flags & VS::TEXTURE_FLAG_MIPMAPS && !texture->ignore_mipmaps) && (nearest_power_of_2(texture->alloc_height) != texture->alloc_height || nearest_power_of_2(texture->alloc_width) != texture->alloc_width);
+ bool force_clamp_to_edge = !(p_flags & VS::TEXTURE_FLAG_MIPMAPS && !texture->ignore_mipmaps) && (next_power_of_2(texture->alloc_height) != texture->alloc_height || next_power_of_2(texture->alloc_width) != texture->alloc_width);
if (!force_clamp_to_edge && (texture->flags & VS::TEXTURE_FLAG_REPEAT || texture->flags & VS::TEXTURE_FLAG_MIRRORED_REPEAT) && texture->target != GL_TEXTURE_CUBE_MAP) {
@@ -2701,7 +2701,7 @@ void RasterizerGLES2::multimesh_set_instance_count(RID p_multimesh, int p_count)
if (use_texture_instancing) {
- if (nearest_power_of_2(p_count) != nearest_power_of_2(multimesh->elements.size())) {
+ if (next_power_of_2(p_count) != next_power_of_2(multimesh->elements.size())) {
if (multimesh->tex_id) {
glDeleteTextures(1, &multimesh->tex_id);
multimesh->tex_id = 0;
@@ -2709,7 +2709,7 @@ void RasterizerGLES2::multimesh_set_instance_count(RID p_multimesh, int p_count)
if (p_count) {
- uint32_t po2 = nearest_power_of_2(p_count);
+ uint32_t po2 = next_power_of_2(p_count);
if (po2 & 0xAAAAAAAA) {
//half width
@@ -3333,7 +3333,7 @@ void RasterizerGLES2::skeleton_resize(RID p_skeleton, int p_bones) {
};
if (use_hw_skeleton_xform) {
- if (nearest_power_of_2(p_bones) != nearest_power_of_2(skeleton->bones.size())) {
+ if (next_power_of_2(p_bones) != next_power_of_2(skeleton->bones.size())) {
if (skeleton->tex_id) {
glDeleteTextures(1, &skeleton->tex_id);
skeleton->tex_id = 0;
@@ -3344,7 +3344,7 @@ void RasterizerGLES2::skeleton_resize(RID p_skeleton, int p_bones) {
glGenTextures(1, &skeleton->tex_id);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, skeleton->tex_id);
- int ps = nearest_power_of_2(p_bones * 3);
+ int ps = next_power_of_2(p_bones * 3);
#ifdef GLEW_ENABLED
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, ps, 1, 0, GL_RGBA, GL_FLOAT, skel_default.ptr());
#else
@@ -3998,7 +3998,7 @@ void RasterizerGLES2::begin_frame() {
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, s->tex_id);
- glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, nearest_power_of_2(s->bones.size() * 3), 1, GL_RGBA, GL_FLOAT, sk_float);
+ glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, next_power_of_2(s->bones.size() * 3), 1, GL_RGBA, GL_FLOAT, sk_float);
_skeleton_dirty_list.remove(_skeleton_dirty_list.first());
}
diff --git a/drivers/gles3/rasterizer_canvas_gles3.cpp b/drivers/gles3/rasterizer_canvas_gles3.cpp
index e6ffa39197..376a208559 100644
--- a/drivers/gles3/rasterizer_canvas_gles3.cpp
+++ b/drivers/gles3/rasterizer_canvas_gles3.cpp
@@ -691,6 +691,13 @@ void RasterizerCanvasGLES3::_canvas_item_render_commands(Item *p_item, Item *cur
state.canvas_shader.set_uniform(CanvasShaderGLES3::COLOR_TEXPIXEL_SIZE, texpixel_size);
}
_draw_polygon(polygon->indices.ptr(), polygon->count, polygon->points.size(), polygon->points.ptr(), polygon->uvs.ptr(), polygon->colors.ptr(), polygon->colors.size() == 1);
+#ifdef GLES_OVER_GL
+ if (polygon->antialiased) {
+ glEnable(GL_LINE_SMOOTH);
+ _draw_generic(GL_LINE_LOOP, polygon->points.size(), polygon->points.ptr(), polygon->uvs.ptr(), polygon->colors.ptr(), polygon->colors.size() == 1);
+ glDisable(GL_LINE_SMOOTH);
+ }
+#endif
} break;
case Item::Command::TYPE_PARTICLES: {
diff --git a/drivers/gles3/rasterizer_scene_gles3.cpp b/drivers/gles3/rasterizer_scene_gles3.cpp
index 30c0d65ff3..6e8303563f 100644
--- a/drivers/gles3/rasterizer_scene_gles3.cpp
+++ b/drivers/gles3/rasterizer_scene_gles3.cpp
@@ -120,7 +120,7 @@ void RasterizerSceneGLES3::shadow_atlas_set_size(RID p_atlas, int p_size) {
ERR_FAIL_COND(!shadow_atlas);
ERR_FAIL_COND(p_size < 0);
- p_size = nearest_power_of_2(p_size);
+ p_size = next_power_of_2(p_size);
if (p_size == shadow_atlas->size)
return;
@@ -185,7 +185,7 @@ void RasterizerSceneGLES3::shadow_atlas_set_quadrant_subdivision(RID p_atlas, in
ERR_FAIL_INDEX(p_quadrant, 4);
ERR_FAIL_INDEX(p_subdivision, 16384);
- uint32_t subdiv = nearest_power_of_2(p_subdivision);
+ uint32_t subdiv = next_power_of_2(p_subdivision);
if (subdiv & 0xaaaaaaaa) { //sqrt(subdiv) must be integer
subdiv <<= 1;
}
@@ -310,7 +310,7 @@ bool RasterizerSceneGLES3::shadow_atlas_update_light(RID p_atlas, RID p_light_in
}
uint32_t quad_size = shadow_atlas->size >> 1;
- int desired_fit = MIN(quad_size / shadow_atlas->smallest_subdiv, nearest_power_of_2(quad_size * p_coverage));
+ int desired_fit = MIN(quad_size / shadow_atlas->smallest_subdiv, next_power_of_2(quad_size * p_coverage));
int valid_quadrants[4];
int valid_quadrant_count = 0;
@@ -479,7 +479,7 @@ void RasterizerSceneGLES3::reflection_atlas_set_size(RID p_ref_atlas, int p_size
ReflectionAtlas *reflection_atlas = reflection_atlas_owner.getornull(p_ref_atlas);
ERR_FAIL_COND(!reflection_atlas);
- int size = nearest_power_of_2(p_size);
+ int size = next_power_of_2(p_size);
if (size == reflection_atlas->size)
return;
@@ -554,7 +554,7 @@ void RasterizerSceneGLES3::reflection_atlas_set_subdivision(RID p_ref_atlas, int
ReflectionAtlas *reflection_atlas = reflection_atlas_owner.getornull(p_ref_atlas);
ERR_FAIL_COND(!reflection_atlas);
- uint32_t subdiv = nearest_power_of_2(p_subdiv);
+ uint32_t subdiv = next_power_of_2(p_subdiv);
if (subdiv & 0xaaaaaaaa) { //sqrt(subdiv) must be integer
subdiv <<= 1;
}
@@ -1088,11 +1088,12 @@ void RasterizerSceneGLES3::gi_probe_instance_set_bounds(RID p_probe, const Vecto
bool RasterizerSceneGLES3::_setup_material(RasterizerStorageGLES3::Material *p_material, bool p_alpha_pass) {
+ /* this is handled outside
if (p_material->shader->spatial.cull_mode == RasterizerStorageGLES3::Shader::Spatial::CULL_MODE_DISABLED) {
glDisable(GL_CULL_FACE);
} else {
glEnable(GL_CULL_FACE);
- }
+ } */
if (state.current_line_width != p_material->line_width) {
//glLineWidth(MAX(p_material->line_width,1.0));
@@ -1857,12 +1858,21 @@ void RasterizerSceneGLES3::_setup_light(RenderList::Element *e, const Transform
}
}
-void RasterizerSceneGLES3::_set_cull(bool p_front, bool p_reverse_cull) {
+void RasterizerSceneGLES3::_set_cull(bool p_front, bool p_disabled, bool p_reverse_cull) {
bool front = p_front;
if (p_reverse_cull)
front = !front;
+ if (p_disabled != state.cull_disabled) {
+ if (p_disabled)
+ glDisable(GL_CULL_FACE);
+ else
+ glEnable(GL_CULL_FACE);
+
+ state.cull_disabled = p_disabled;
+ }
+
if (front != state.cull_front) {
glCullFace(front ? GL_FRONT : GL_BACK);
@@ -1900,7 +1910,9 @@ void RasterizerSceneGLES3::_render_list(RenderList::Element **p_elements, int p_
}
state.cull_front = false;
+ state.cull_disabled = false;
glCullFace(GL_BACK);
+ glEnable(GL_CULL_FACE);
state.current_depth_test = true;
glEnable(GL_DEPTH_TEST);
@@ -2101,7 +2113,7 @@ void RasterizerSceneGLES3::_render_list(RenderList::Element **p_elements, int p_
storage->info.render.surface_switch_count++;
}
- _set_cull(e->sort_key & RenderList::SORT_KEY_MIRROR_FLAG, p_reverse_cull);
+ _set_cull(e->sort_key & RenderList::SORT_KEY_MIRROR_FLAG, e->sort_key & RenderList::SORT_KEY_CULL_DISABLED_FLAG, p_reverse_cull);
state.scene_shader.set_uniform(SceneShaderGLES3::NORMAL_MULT, e->instance->mirror ? -1.0 : 1.0);
state.scene_shader.set_uniform(SceneShaderGLES3::WORLD_TRANSFORM, e->instance->transform);
@@ -2188,8 +2200,12 @@ void RasterizerSceneGLES3::_add_geometry_with_material(RasterizerStorageGLES3::G
bool shadow = false;
bool mirror = p_instance->mirror;
+ bool no_cull = false;
- if (p_material->shader->spatial.cull_mode == RasterizerStorageGLES3::Shader::Spatial::CULL_MODE_FRONT) {
+ if (p_material->shader->spatial.cull_mode == RasterizerStorageGLES3::Shader::Spatial::CULL_MODE_DISABLED) {
+ no_cull = true;
+ mirror = false;
+ } else if (p_material->shader->spatial.cull_mode == RasterizerStorageGLES3::Shader::Spatial::CULL_MODE_FRONT) {
mirror = !mirror;
}
@@ -2208,10 +2224,13 @@ void RasterizerSceneGLES3::_add_geometry_with_material(RasterizerStorageGLES3::G
if (!p_material->shader->spatial.uses_alpha_scissor && !p_material->shader->spatial.writes_modelview_or_projection && !p_material->shader->spatial.uses_vertex && !p_material->shader->spatial.uses_discard && p_material->shader->spatial.depth_draw_mode != RasterizerStorageGLES3::Shader::Spatial::DEPTH_DRAW_ALPHA_PREPASS) {
//shader does not use discard and does not write a vertex position, use generic material
- if (p_instance->cast_shadows == VS::SHADOW_CASTING_SETTING_DOUBLE_SIDED)
+ if (p_instance->cast_shadows == VS::SHADOW_CASTING_SETTING_DOUBLE_SIDED) {
p_material = storage->material_owner.getptr(default_material_twosided);
- else
+ no_cull = true;
+ mirror = false;
+ } else {
p_material = storage->material_owner.getptr(default_material);
+ }
}
has_alpha = false;
@@ -2275,6 +2294,10 @@ void RasterizerSceneGLES3::_add_geometry_with_material(RasterizerStorageGLES3::G
e->sort_key |= RenderList::SORT_KEY_MIRROR_FLAG;
}
+ if (no_cull) {
+ e->sort_key |= RenderList::SORT_KEY_CULL_DISABLED_FLAG;
+ }
+
//e->light_type=0xFF; // no lights!
if (shadow || p_material->shader->spatial.unshaded || state.debug_draw == VS::VIEWPORT_DEBUG_DRAW_UNSHADED) {
@@ -4535,6 +4558,9 @@ void RasterizerSceneGLES3::render_shadow(RID p_light, RID p_shadow_atlas, int p_
state.scene_shader.set_conditional(SceneShaderGLES3::RENDER_DEPTH, true);
+ if (light->reverse_cull) {
+ flip_facing = !flip_facing;
+ }
_render_list(render_list.elements, render_list.element_count, light_transform, light_projection, 0, flip_facing, false, true, false, false);
state.scene_shader.set_conditional(SceneShaderGLES3::RENDER_DEPTH, false);
@@ -4757,7 +4783,7 @@ void RasterizerSceneGLES3::initialize() {
{
//directional light shadow
directional_shadow.light_count = 0;
- directional_shadow.size = nearest_power_of_2(GLOBAL_GET("rendering/quality/directional_shadow/size"));
+ directional_shadow.size = next_power_of_2(GLOBAL_GET("rendering/quality/directional_shadow/size"));
glGenFramebuffers(1, &directional_shadow.fbo);
glBindFramebuffer(GL_FRAMEBUFFER, directional_shadow.fbo);
glGenTextures(1, &directional_shadow.depth);
diff --git a/drivers/gles3/rasterizer_scene_gles3.h b/drivers/gles3/rasterizer_scene_gles3.h
index e1d96f23dd..740d277a3a 100644
--- a/drivers/gles3/rasterizer_scene_gles3.h
+++ b/drivers/gles3/rasterizer_scene_gles3.h
@@ -187,6 +187,7 @@ public:
int reflection_probe_count;
bool cull_front;
+ bool cull_disabled;
bool used_sss;
bool used_screen_texture;
bool using_contact_shadows;
@@ -654,6 +655,7 @@ public:
SORT_KEY_MATERIAL_INDEX_SHIFT = 40,
SORT_KEY_GEOMETRY_INDEX_SHIFT = 20,
SORT_KEY_GEOMETRY_TYPE_SHIFT = 15,
+ SORT_KEY_CULL_DISABLED_FLAG = 4,
SORT_KEY_SKELETON_FLAG = 2,
SORT_KEY_MIRROR_FLAG = 1
@@ -779,7 +781,7 @@ public:
RenderList render_list;
- _FORCE_INLINE_ void _set_cull(bool p_front, bool p_reverse_cull);
+ _FORCE_INLINE_ void _set_cull(bool p_front, bool p_disabled, bool p_reverse_cull);
_FORCE_INLINE_ bool _setup_material(RasterizerStorageGLES3::Material *p_material, bool p_alpha_pass);
_FORCE_INLINE_ void _setup_geometry(RenderList::Element *e, const Transform &p_view_transform);
diff --git a/drivers/gles3/rasterizer_storage_gles3.cpp b/drivers/gles3/rasterizer_storage_gles3.cpp
index 24fa117051..11d5bcb207 100644
--- a/drivers/gles3/rasterizer_storage_gles3.cpp
+++ b/drivers/gles3/rasterizer_storage_gles3.cpp
@@ -2143,7 +2143,7 @@ _FORCE_INLINE_ static void _fill_std140_variant_ubo_value(ShaderLanguage::DataTy
gui[0] = v.normal.x;
gui[1] = v.normal.y;
- gui[2] = v.normal.x;
+ gui[2] = v.normal.z;
gui[3] = v.d;
}
} break;
@@ -4451,7 +4451,7 @@ RID RasterizerStorageGLES3::light_create(VS::LightType p_type) {
light->omni_shadow_mode = VS::LIGHT_OMNI_SHADOW_DUAL_PARABOLOID;
light->omni_shadow_detail = VS::LIGHT_OMNI_SHADOW_DETAIL_VERTICAL;
light->directional_blend_splits = false;
-
+ light->reverse_cull = false;
light->version = 0;
return light_owner.make_rid(light);
@@ -4530,6 +4530,14 @@ void RasterizerStorageGLES3::light_set_cull_mask(RID p_light, uint32_t p_mask) {
light->instance_change_notify();
}
+void RasterizerStorageGLES3::light_set_reverse_cull_face_mode(RID p_light, bool p_enabled) {
+
+ Light *light = light_owner.getornull(p_light);
+ ERR_FAIL_COND(!light);
+
+ light->reverse_cull = p_enabled;
+}
+
void RasterizerStorageGLES3::light_omni_set_shadow_mode(RID p_light, VS::LightOmniShadowMode p_mode) {
Light *light = light_owner.getornull(p_light);
diff --git a/drivers/gles3/rasterizer_storage_gles3.h b/drivers/gles3/rasterizer_storage_gles3.h
index 3c7ea000ba..f612d9e879 100644
--- a/drivers/gles3/rasterizer_storage_gles3.h
+++ b/drivers/gles3/rasterizer_storage_gles3.h
@@ -868,6 +868,7 @@ public:
RID projector;
bool shadow;
bool negative;
+ bool reverse_cull;
uint32_t cull_mask;
VS::LightOmniShadowMode omni_shadow_mode;
VS::LightOmniShadowDetail omni_shadow_detail;
@@ -887,6 +888,7 @@ public:
virtual void light_set_projector(RID p_light, RID p_texture);
virtual void light_set_negative(RID p_light, bool p_enable);
virtual void light_set_cull_mask(RID p_light, uint32_t p_mask);
+ virtual void light_set_reverse_cull_face_mode(RID p_light, bool p_enabled);
virtual void light_omni_set_shadow_mode(RID p_light, VS::LightOmniShadowMode p_mode);
virtual void light_omni_set_shadow_detail(RID p_light, VS::LightOmniShadowDetail p_detail);
diff --git a/drivers/pulseaudio/audio_driver_pulseaudio.cpp b/drivers/pulseaudio/audio_driver_pulseaudio.cpp
index fb04ef0088..5acf9bf46e 100644
--- a/drivers/pulseaudio/audio_driver_pulseaudio.cpp
+++ b/drivers/pulseaudio/audio_driver_pulseaudio.cpp
@@ -54,7 +54,7 @@ Error AudioDriverPulseAudio::init() {
spec.rate = mix_rate;
int latency = GLOBAL_DEF("audio/output_latency", 25);
- buffer_size = nearest_power_of_2(latency * mix_rate / 1000);
+ buffer_size = closest_power_of_2(latency * mix_rate / 1000);
pa_buffer_attr attr;
// set to appropriate buffer size from global settings
diff --git a/drivers/rtaudio/audio_driver_rtaudio.cpp b/drivers/rtaudio/audio_driver_rtaudio.cpp
index 3de25c32ad..8466f55afc 100644
--- a/drivers/rtaudio/audio_driver_rtaudio.cpp
+++ b/drivers/rtaudio/audio_driver_rtaudio.cpp
@@ -118,7 +118,7 @@ Error AudioDriverRtAudio::init() {
int latency = GLOBAL_DEF("audio/output_latency", 25);
// calculate desired buffer_size, taking the desired numberOfBuffers into account (latency depends on numberOfBuffers*buffer_size)
- unsigned int buffer_size = nearest_power_of_2(latency * mix_rate / 1000 / target_number_of_buffers);
+ unsigned int buffer_size = closest_power_of_2(latency * mix_rate / 1000 / target_number_of_buffers);
if (OS::get_singleton()->is_stdout_verbose()) {
print_line("audio buffer size: " + itos(buffer_size));
diff --git a/drivers/xaudio2/audio_driver_xaudio2.cpp b/drivers/xaudio2/audio_driver_xaudio2.cpp
index a1ca2c678e..42c4c40300 100644
--- a/drivers/xaudio2/audio_driver_xaudio2.cpp
+++ b/drivers/xaudio2/audio_driver_xaudio2.cpp
@@ -50,7 +50,7 @@ Error AudioDriverXAudio2::init() {
channels = 2;
int latency = GLOBAL_DEF("audio/output_latency", 25);
- buffer_size = nearest_power_of_2(latency * mix_rate / 1000);
+ buffer_size = closest_power_of_2(latency * mix_rate / 1000);
samples_in = memnew_arr(int32_t, buffer_size * channels);
for (int i = 0; i < AUDIO_BUFFERS; i++) {
diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp
index 07c0945114..c33340ce69 100644
--- a/editor/code_editor.cpp
+++ b/editor/code_editor.cpp
@@ -1087,6 +1087,7 @@ void CodeTextEditor::update_editor_settings() {
text_editor->cursor_set_blink_speed(EditorSettings::get_singleton()->get("text_editor/cursor/caret_blink_speed"));
text_editor->set_draw_breakpoint_gutter(EditorSettings::get_singleton()->get("text_editor/line_numbers/show_breakpoint_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"));
}
void CodeTextEditor::set_error(const String &p_error) {
@@ -1222,10 +1223,11 @@ CodeTextEditor::CodeTextEditor() {
error = memnew(Label);
status_bar->add_child(error);
error->hide();
+ error->set_clip_text(true); //do not change, or else very long errors can push the whole container to the right
error->set_valign(Label::VALIGN_CENTER);
error->add_color_override("font_color", Color(1, 0.7, 0.6, 0.9));
-
- status_bar->add_spacer();
+ error->set_h_size_flags(SIZE_EXPAND_FILL); //required for it to display, given now it's clipping contents, do not touch
+ //status_bar->add_spacer();
Label *line_txt = memnew(Label);
status_bar->add_child(line_txt);
@@ -1238,7 +1240,8 @@ CodeTextEditor::CodeTextEditor() {
status_bar->add_child(line_nb);
line_nb->set_valign(Label::VALIGN_CENTER);
line_nb->set_v_size_flags(SIZE_FILL);
- line_nb->set_autowrap(true); // workaround to prevent resizing the label on each change
+ line_nb->set_autowrap(true); // workaround to prevent resizing the label on each change, do not touch
+ line_nb->set_clip_text(true); // workaround to prevent resizing the label on each change, do not touch
line_nb->set_custom_minimum_size(Size2(40, 1) * EDSCALE);
Label *col_txt = memnew(Label);
@@ -1252,7 +1255,8 @@ CodeTextEditor::CodeTextEditor() {
status_bar->add_child(col_nb);
col_nb->set_valign(Label::VALIGN_CENTER);
col_nb->set_v_size_flags(SIZE_FILL);
- col_nb->set_autowrap(true); // workaround to prevent resizing the label on each change
+ col_nb->set_autowrap(true); // workaround to prevent resizing the label on each change, do not touch
+ col_nb->set_clip_text(true); // workaround to prevent resizing the label on each change, do not touch
col_nb->set_custom_minimum_size(Size2(40, 1) * EDSCALE);
text_editor->connect("gui_input", this, "_text_editor_gui_input");
diff --git a/editor/connections_dialog.h b/editor/connections_dialog.h
index bff85941cb..849bb880d4 100644
--- a/editor/connections_dialog.h
+++ b/editor/connections_dialog.h
@@ -103,8 +103,6 @@ class ConnectionsDock : public VBoxContainer {
ConfirmationDialog *remove_confirm;
ConnectDialog *connect_dialog;
- void update_tree();
-
void _close();
void _connect();
void _something_selected();
@@ -121,6 +119,7 @@ public:
void set_node(Node *p_node);
String get_selected_type();
+ void update_tree();
ConnectionsDock(EditorNode *p_editor = NULL);
~ConnectionsDock();
diff --git a/editor/editor_audio_buses.cpp b/editor/editor_audio_buses.cpp
index 993429a5a4..282055be4a 100644
--- a/editor/editor_audio_buses.cpp
+++ b/editor/editor_audio_buses.cpp
@@ -705,8 +705,8 @@ EditorAudioBus::EditorAudioBus(EditorAudioBuses *p_buses) {
effects->set_drag_forwarding(this);
effects->connect("item_rmb_selected", this, "_effect_rmb");
effects->set_allow_rmb_select(true);
- effects->set_single_select_cell_editing_only_when_already_selected(true);
effects->set_focus_mode(FOCUS_CLICK);
+ effects->set_allow_reselect(true);
send = memnew(OptionButton);
send->set_clip_text(true);
diff --git a/editor/editor_autoload_settings.cpp b/editor/editor_autoload_settings.cpp
index dde94cb334..0d7874818c 100644
--- a/editor/editor_autoload_settings.cpp
+++ b/editor/editor_autoload_settings.cpp
@@ -580,7 +580,7 @@ EditorAutoloadSettings::EditorAutoloadSettings() {
tree = memnew(Tree);
tree->set_hide_root(true);
tree->set_select_mode(Tree::SELECT_MULTI);
- tree->set_single_select_cell_editing_only_when_already_selected(true);
+ tree->set_allow_reselect(true);
tree->set_drag_forwarding(this);
diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp
index 2f4ac02703..9d194e0501 100644
--- a/editor/editor_file_system.cpp
+++ b/editor/editor_file_system.cpp
@@ -230,6 +230,28 @@ void EditorFileSystem::_scan_filesystem() {
memdelete(f);
}
+ String update_cache = EditorSettings::get_singleton()->get_project_settings_path().plus_file("filesystem_update2");
+
+ print_line("try to see fs update2");
+ if (FileAccess::exists(update_cache)) {
+
+ print_line("it exists");
+
+ {
+ FileAccessRef f = FileAccess::open(update_cache, FileAccess::READ);
+ String l = f->get_line().strip_edges();
+ while (l != String()) {
+
+ print_line("erased cache for: " + l + " " + itos(file_cache.has(l)));
+ file_cache.erase(l); //erase cache for this, so it gets updated
+ l = f->get_line().strip_edges();
+ }
+ }
+
+ DirAccessRef d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
+ d->remove(update_cache); //bye bye update cache
+ }
+
EditorProgressBG scan_progress("efs", "ScanFS", 1000);
ScanProgress sp;
@@ -597,11 +619,13 @@ void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir, DirAccess
if (fc && fc->modification_time == mt && fc->import_modification_time == import_mt && _check_missing_imported_files(path)) {
fi->type = fc->type;
+ fi->deps = fc->deps;
fi->modified_time = fc->modification_time;
fi->import_modified_time = fc->import_modification_time;
if (fc->type == String()) {
fi->type = ResourceLoader::get_resource_type(path);
//there is also the chance that file type changed due to reimport, must probably check this somehow here (or kind of note it for next time in another file?)
+ //note: I think this should not happen any longer..
}
} else {
@@ -620,6 +644,7 @@ void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir, DirAccess
}
fi->type = ResourceFormatImporter::get_singleton()->get_resource_type(path);
+ //fi->deps = ResourceLoader::get_dependencies(path); pointless because it will be reimported, but..
print_line("import extension tried resource type for " + path + " and its " + fi->type);
fi->modified_time = 0;
fi->import_modified_time = 0;
@@ -631,14 +656,17 @@ void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir, DirAccess
scan_actions.push_back(ia);
}
} else {
- //not imported, so just update type if changed
- if (fc && fc->modification_time == mt) {
+ if (fc && fc->modification_time == mt) {
+ //not imported, so just update type if changed
fi->type = fc->type;
fi->modified_time = fc->modification_time;
+ fi->deps = fc->deps;
fi->import_modified_time = 0;
} else {
+ //new or modified time
fi->type = ResourceLoader::get_resource_type(path);
+ fi->deps = _get_dependencies(path);
print_line("regular import tried resource type for " + path + " and its " + fi->type);
fi->modified_time = mt;
fi->import_modified_time = 0;
@@ -1187,12 +1215,34 @@ EditorFileSystemDirectory *EditorFileSystem::get_filesystem_path(const String &p
return fs;
}
+void EditorFileSystem::_save_late_updated_files() {
+ //files that already existed, and were modified, need re-scanning for dependencies upon project restart. This is done via saving this special file
+ String fscache = EditorSettings::get_singleton()->get_project_settings_path().plus_file("filesystem_update2");
+ FileAccessRef f = FileAccess::open(fscache, FileAccess::WRITE);
+ for (Set<String>::Element *E = late_update_files.front(); E; E = E->next()) {
+ f->store_line(E->get());
+ }
+}
+
void EditorFileSystem::_resource_saved(const String &p_path) {
//print_line("resource saved: "+p_path);
EditorFileSystem::get_singleton()->update_file(p_path);
}
+Vector<String> EditorFileSystem::_get_dependencies(const String &p_path) {
+
+ List<String> deps;
+ ResourceLoader::get_dependencies(p_path, &deps);
+
+ Vector<String> ret;
+ for (List<String>::Element *E = deps.front(); E; E = E->next()) {
+ ret.push_back(E->get());
+ }
+
+ return ret;
+}
+
void EditorFileSystem::update_file(const String &p_file) {
EditorFileSystemDirectory *fs = NULL;
@@ -1217,6 +1267,9 @@ void EditorFileSystem::update_file(const String &p_file) {
if (cpos == -1) {
+ //the file did not exist, it was added
+
+ late_added_files.insert(p_file); //remember that it was added. This mean it will be scanned and imported on editor restart
int idx = 0;
for (int i = 0; i < fs->files.size(); i++) {
@@ -1236,11 +1289,18 @@ void EditorFileSystem::update_file(const String &p_file) {
fs->files.insert(idx, fi);
}
cpos = idx;
+ } else {
+
+ //the file exists and it was updated, and was not added in this step.
+ //this means we must force upon next restart to scan it again, to get proper type and dependencies
+ late_update_files.insert(p_file);
+ _save_late_updated_files(); //files need to be updated in the re-scan
}
//print_line("UPDATING: "+p_file);
fs->files[cpos]->type = type;
fs->files[cpos]->modified_time = FileAccess::get_modified_time(p_file);
+ fs->files[cpos]->deps = _get_dependencies(p_file);
//if (FileAccess::exists(p_file+".import")) {
// fs->files[cpos]->import_modified_time=FileAccess::get_modified_time(p_file+".import");
//}
@@ -1276,6 +1336,9 @@ void EditorFileSystem::_reimport_file(const String &p_file) {
}
importer_name = cf->get_value("remap", "importer");
}
+
+ } else {
+ late_added_files.insert(p_file); //imported files do not call update_file(), but just in case..
}
Ref<ResourceImporter> importer;
@@ -1357,6 +1420,7 @@ void EditorFileSystem::_reimport_file(const String &p_file) {
}
f->store_line("");
+
if (gen_files.size()) {
f->store_line("[gen]");
Array genf;
@@ -1389,6 +1453,8 @@ void EditorFileSystem::_reimport_file(const String &p_file) {
//update modified times, to avoid reimport
fs->files[cpos]->modified_time = FileAccess::get_modified_time(p_file);
fs->files[cpos]->import_modified_time = FileAccess::get_modified_time(p_file + ".import");
+ fs->files[cpos]->deps = _get_dependencies(p_file);
+ fs->files[cpos]->type = importer->get_resource_type();
//if file is currently up, maybe the source it was loaded from changed, so import math must be updated for it
//to reload properly
diff --git a/editor/editor_file_system.h b/editor/editor_file_system.h
index f98758fd03..fd62b06d07 100644
--- a/editor/editor_file_system.h
+++ b/editor/editor_file_system.h
@@ -137,6 +137,11 @@ class EditorFileSystem : public Node {
void _scan_filesystem();
+ Set<String> late_added_files; //keep track of files that were added, these will be re-scanned
+ Set<String> late_update_files;
+
+ void _save_late_updated_files();
+
EditorFileSystemDirectory *filesystem;
static EditorFileSystem *singleton;
@@ -196,6 +201,8 @@ class EditorFileSystem : public Node {
bool reimport_on_missing_imported_files;
+ Vector<String> _get_dependencies(const String &p_path);
+
protected:
void _notification(int p_what);
static void _bind_methods();
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index 242648d4a9..a5f0478854 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -371,6 +371,7 @@ void EditorNode::_fs_changed() {
if (preset->get_name() == export_defer.preset) {
break;
}
+ preset.unref();
}
if (preset.is_null()) {
String err = "Unknown export preset: " + export_defer.preset;
@@ -385,7 +386,7 @@ void EditorNode::_fs_changed() {
}
}
- export_defer.preset = "";
+ get_tree()->quit();
}
{
@@ -3939,6 +3940,7 @@ void EditorNode::_dock_select_input(const Ref<InputEvent> &p_input) {
splits[i]->hide();
}
+ _edit_current();
_save_docks();
}
}
@@ -3966,6 +3968,7 @@ void EditorNode::_dock_move_left() {
dock_slot[dock_popup_selected]->move_child(current, prev->get_index());
dock_slot[dock_popup_selected]->set_current_tab(dock_slot[dock_popup_selected]->get_current_tab() - 1);
dock_select->update();
+ _edit_current();
_save_docks();
}
@@ -3978,6 +3981,7 @@ void EditorNode::_dock_move_right() {
dock_slot[dock_popup_selected]->move_child(next, current->get_index());
dock_slot[dock_popup_selected]->set_current_tab(dock_slot[dock_popup_selected]->get_current_tab() + 1);
dock_select->update();
+ _edit_current();
_save_docks();
}
diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp
index 70367f1e07..8494c7199e 100644
--- a/editor/editor_settings.cpp
+++ b/editor/editor_settings.cpp
@@ -615,6 +615,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
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, 10");
+ set("text_editor/open_scripts/smooth_scrolling", true);
set("text_editor/open_scripts/show_members_overview", true);
set("text_editor/files/trim_trailing_whitespace_on_save", false);
diff --git a/editor/import/resource_importer_scene.cpp b/editor/import/resource_importer_scene.cpp
index ae89dfd77f..798f57f8c3 100644
--- a/editor/import/resource_importer_scene.cpp
+++ b/editor/import/resource_importer_scene.cpp
@@ -104,7 +104,7 @@ bool ResourceImporterScene::get_option_visibility(const String &p_option, const
}
}
- if (p_option == "materials/keep_files" && int(p_options["materials/storage"]) == 0) {
+ if (p_option == "materials/keep_on_reimport" && int(p_options["materials/storage"]) == 0) {
return false;
}
@@ -986,6 +986,8 @@ void ResourceImporterScene::_make_external_resources(Node *p_node, const String
List<PropertyInfo> pi;
+ print_line("node: " + String(p_node->get_name()));
+
p_node->get_property_list(&pi);
for (List<PropertyInfo>::Element *E = pi.front(); E; E = E->next()) {
@@ -993,6 +995,7 @@ void ResourceImporterScene::_make_external_resources(Node *p_node, const String
if (E->get().type == Variant::OBJECT) {
Ref<Material> mat = p_node->get(E->get().name);
+
if (p_make_materials && mat.is_valid() && mat->get_name() != "") {
if (!p_materials.has(mat)) {
@@ -1045,7 +1048,8 @@ void ResourceImporterScene::_make_external_resources(Node *p_node, const String
if (!p_materials.has(mat)) {
- String ext_name = p_base_path + "." + _make_extname(mat->get_name()) + ".material";
+ String ext_name = p_base_path.plus_file(_make_extname(mat->get_name()) + ".material");
+ ;
if (FileAccess::exists(ext_name)) {
//if exists, use it
Ref<Material> existing = ResourceLoader::load(ext_name);
@@ -1103,10 +1107,10 @@ void ResourceImporterScene::get_import_options(List<ImportOption> *r_options, in
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "nodes/storage", PROPERTY_HINT_ENUM, "Single Scene,Instanced Sub-Scenes"), scenes_out ? 1 : 0));
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "materials/location", PROPERTY_HINT_ENUM, "Node,Mesh"), meshes_out ? 1 : 0));
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "materials/storage", PROPERTY_HINT_ENUM, "Built-In,Files", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), materials_out ? 1 : 0));
- r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "materials/keep_files"), materials_out ? true : false));
- r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "geometry/compress"), true));
- r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "geometry/ensure_tangents"), true));
- r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "geometry/storage", PROPERTY_HINT_ENUM, "Built-In,Files"), meshes_out ? true : false));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "materials/keep_on_reimport"), materials_out ? true : false));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "meshes/compress"), true));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "meshes/ensure_tangents"), true));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "meshes/storage", PROPERTY_HINT_ENUM, "Built-In,Files"), meshes_out ? true : false));
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "external_files/store_in_subdir"), true));
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "animation/import", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), true));
r_options->push_back(ImportOption(PropertyInfo(Variant::REAL, "animation/fps", PROPERTY_HINT_RANGE, "1,120,1"), 15));
@@ -1176,7 +1180,7 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p
if (bool(p_options["animation/import"]))
import_flags |= EditorSceneImporter::IMPORT_ANIMATION;
- if (bool(p_options["geometry/ensure_tangents"]))
+ if (bool(p_options["meshes/ensure_tangents"]))
import_flags |= EditorSceneImporter::IMPORT_GENERATE_TANGENT_ARRAYS;
if (int(p_options["materials/location"]) == 0)
@@ -1250,7 +1254,7 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p
}
bool external_materials = p_options["materials/storage"];
- bool external_meshes = p_options["geometry/storage"];
+ bool external_meshes = p_options["meshes/storage"];
bool external_scenes = int(p_options["nodes/storage"]) == 1;
String base_path = p_source_file.get_base_dir();
@@ -1272,7 +1276,7 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p
Map<Ref<Material>, Ref<Material> > mat_map;
Map<Ref<ArrayMesh>, Ref<ArrayMesh> > mesh_map;
- bool keep_materials = bool(p_options["materials/keep_files"]);
+ bool keep_materials = bool(p_options["materials/keep_on_reimport"]);
_make_external_resources(scene, base_path, external_materials, keep_materials, external_meshes, mat_map, mesh_map);
}
diff --git a/editor/io_plugins/editor_font_import_plugin.cpp b/editor/io_plugins/editor_font_import_plugin.cpp
index 9831e08cf1..25d8a5b7eb 100644
--- a/editor/io_plugins/editor_font_import_plugin.cpp
+++ b/editor/io_plugins/editor_font_import_plugin.cpp
@@ -1536,8 +1536,8 @@ Ref<BitmapFont> EditorFontImportPlugin::generate_font(const Ref<ResourceImportMe
Vector<Point2i> res;
Size2i res_size;
EditorAtlas::fit(sizes,res,res_size);
- res_size.x=nearest_power_of_2(res_size.x);
- res_size.y=nearest_power_of_2(res_size.y);
+ res_size.x=next_power_of_2(res_size.x);
+ res_size.y=next_power_of_2(res_size.y);
print_line("Atlas size: "+res_size);
Image atlas(res_size.x,res_size.y,0,Image::FORMAT_RGBA8);
diff --git a/editor/io_plugins/editor_texture_import_plugin.cpp b/editor/io_plugins/editor_texture_import_plugin.cpp
index 095bc02fa0..1dc2641474 100644
--- a/editor/io_plugins/editor_texture_import_plugin.cpp
+++ b/editor/io_plugins/editor_texture_import_plugin.cpp
@@ -1280,8 +1280,8 @@ Error EditorTextureImportPlugin::import2(const String& p_path, const Ref<Resourc
int atlas_w=dst_size.width;
int atlas_h=dst_size.height;
if (blit_to_po2) {
- atlas_w=nearest_power_of_2(dst_size.width);
- atlas_h=nearest_power_of_2(dst_size.height);
+ atlas_w=next_power_of_2(dst_size.width);
+ atlas_h=next_power_of_2(dst_size.height);
}
Image atlas;
atlas.create(atlas_w,atlas_h,0,alpha?Image::FORMAT_RGBA8:Image::FORMAT_RGB8);
diff --git a/editor/node_dock.cpp b/editor/node_dock.cpp
index 0f3f4b96f5..b1a538ed2e 100644
--- a/editor/node_dock.cpp
+++ b/editor/node_dock.cpp
@@ -63,6 +63,11 @@ void NodeDock::_notification(int p_what) {
NodeDock *NodeDock::singleton = NULL;
+void NodeDock::update_lists() {
+
+ connections->update_tree();
+}
+
void NodeDock::set_node(Node *p_node) {
connections->set_node(p_node);
diff --git a/editor/node_dock.h b/editor/node_dock.h
index 0af65719c9..29e5dc5169 100644
--- a/editor/node_dock.h
+++ b/editor/node_dock.h
@@ -59,6 +59,8 @@ public:
void show_groups();
void show_connections();
+ void update_lists();
+
NodeDock();
};
diff --git a/editor/plugins/baked_light_baker.cpp b/editor/plugins/baked_light_baker.cpp
index 036229a7af..bef35647d4 100644
--- a/editor/plugins/baked_light_baker.cpp
+++ b/editor/plugins/baked_light_baker.cpp
@@ -1460,7 +1460,7 @@ void BakedLightBaker::_make_octree_texture() {
} else {
baked_light_texture_w=otex_w;
- baked_light_texture_h=nearest_power_of_2(row);
+ baked_light_texture_h=next_power_of_2(row);
print_line("w: "+itos(otex_w));
print_line("h: "+itos(row));
break;
@@ -1558,7 +1558,7 @@ void BakedLightBaker::_make_octree_texture() {
}
- baked_octree_texture_h=nearest_power_of_2(baked_octree_texture_h);
+ baked_octree_texture_h=next_power_of_2(baked_octree_texture_h);
print_line("RESULT! "+itos(baked_octree_texture_w)+","+itos(baked_octree_texture_h));
}
diff --git a/editor/plugins/path_editor_plugin.cpp b/editor/plugins/path_editor_plugin.cpp
index c32ed1064f..96a98f3c48 100644
--- a/editor/plugins/path_editor_plugin.cpp
+++ b/editor/plugins/path_editor_plugin.cpp
@@ -222,8 +222,10 @@ void PathSpatialGizmo::redraw() {
//v3p.push_back(r[i]+Vector3(0,0.2,0));
}
- add_lines(v3p, PathEditorPlugin::singleton->path_material);
- add_collision_segments(v3p);
+ if (v3p.size() > 1) {
+ add_lines(v3p, PathEditorPlugin::singleton->path_material);
+ add_collision_segments(v3p);
+ }
if (PathEditorPlugin::singleton->get_edited_path() == path) {
v3p.clear();
@@ -247,9 +249,15 @@ void PathSpatialGizmo::redraw() {
}
}
- add_lines(v3p, PathEditorPlugin::singleton->path_thin_material);
- add_handles(handles);
- add_handles(sec_handles, false, true);
+ if (v3p.size() > 1) {
+ add_lines(v3p, PathEditorPlugin::singleton->path_thin_material);
+ }
+ if (handles.size()) {
+ add_handles(handles);
+ }
+ if (sec_handles.size()) {
+ add_handles(sec_handles, false, true);
+ }
}
}
diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp
index 1873a3f58b..6db732ba5d 100644
--- a/editor/plugins/script_editor_plugin.cpp
+++ b/editor/plugins/script_editor_plugin.cpp
@@ -34,18 +34,19 @@
#include "editor/script_editor_debugger.h"
#include "io/resource_loader.h"
#include "io/resource_saver.h"
+#include "node_dock.h"
#include "os/file_access.h"
#include "os/input.h"
#include "os/keyboard.h"
#include "os/os.h"
#include "project_settings.h"
#include "scene/main/viewport.h"
-
/*** SCRIPT EDITOR ****/
void ScriptEditorBase::_bind_methods() {
ADD_SIGNAL(MethodInfo("name_changed"));
+ ADD_SIGNAL(MethodInfo("script_changed"));
ADD_SIGNAL(MethodInfo("request_help_search", PropertyInfo(Variant::STRING, "topic")));
ADD_SIGNAL(MethodInfo("request_help_index"));
ADD_SIGNAL(MethodInfo("request_open_script_at_line", PropertyInfo(Variant::OBJECT, "script"), PropertyInfo(Variant::INT, "line")));
@@ -1125,10 +1126,6 @@ void ScriptEditor::_notification(int p_what) {
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
tab_container->add_style_override("panel", editor->get_gui_base()->get_stylebox("ScriptPanel", "EditorStyles"));
-
- Ref<StyleBox> sb = editor->get_gui_base()->get_stylebox("panel", "TabContainer")->duplicate();
- sb->set_default_margin(MARGIN_TOP, 0);
- add_style_override("panel", sb);
} break;
default:
@@ -1714,6 +1711,7 @@ bool ScriptEditor::edit(const Ref<Script> &p_script, int p_line, int p_col, bool
_update_script_names();
_save_layout();
se->connect("name_changed", this, "_update_script_names");
+ se->connect("script_changed", this, "_script_changed");
se->connect("request_help_search", this, "_help_search");
se->connect("request_open_script_at_line", this, "_goto_script_line");
se->connect("go_to_help", this, "_help_class_goto");
@@ -2200,6 +2198,11 @@ void ScriptEditor::register_create_script_editor_function(CreateScriptEditorFunc
script_editor_funcs[script_editor_func_count++] = p_func;
}
+void ScriptEditor::_script_changed() {
+
+ NodeDock::singleton->update_lists();
+}
+
void ScriptEditor::_bind_methods() {
ClassDB::bind_method("_file_dialog_action", &ScriptEditor::_file_dialog_action);
@@ -2241,6 +2244,7 @@ void ScriptEditor::_bind_methods() {
ClassDB::bind_method("_history_back", &ScriptEditor::_history_back);
ClassDB::bind_method("_live_auto_reload_running_scripts", &ScriptEditor::_live_auto_reload_running_scripts);
ClassDB::bind_method("_unhandled_input", &ScriptEditor::_unhandled_input);
+ ClassDB::bind_method("_script_changed", &ScriptEditor::_script_changed);
ClassDB::bind_method(D_METHOD("get_current_script"), &ScriptEditor::_get_current_script);
ClassDB::bind_method(D_METHOD("get_open_scripts"), &ScriptEditor::_get_open_scripts);
@@ -2261,9 +2265,6 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) {
members_overview_enabled = true;
editor = p_editor;
- Ref<StyleBox> sb = p_editor->get_gui_base()->get_stylebox("panel", "TabContainer")->duplicate();
- sb->set_default_margin(MARGIN_TOP, 0);
- add_style_override("panel", sb);
VBoxContainer *main_container = memnew(VBoxContainer);
add_child(main_container);
diff --git a/editor/plugins/script_editor_plugin.h b/editor/plugins/script_editor_plugin.h
index 4614a41605..f87a20a1f0 100644
--- a/editor/plugins/script_editor_plugin.h
+++ b/editor/plugins/script_editor_plugin.h
@@ -318,6 +318,7 @@ class ScriptEditor : public PanelContainer {
void _update_script_colors();
void _update_modified_scripts_for_external_editor(Ref<Script> p_for_script = Ref<Script>());
+ void _script_changed();
int file_dialog_option;
void _file_dialog_action(String p_file);
diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp
index 422c656351..1aa9f04484 100644
--- a/editor/plugins/script_text_editor.cpp
+++ b/editor/plugins/script_text_editor.cpp
@@ -524,6 +524,7 @@ void ScriptTextEditor::_validate_script() {
}
emit_signal("name_changed");
+ emit_signal("script_changed");
}
static Node *_find_node_for_script(Node *p_base, Node *p_current, const Ref<Script> &p_script) {
diff --git a/editor/plugins/sprite_frames_editor_plugin.cpp b/editor/plugins/sprite_frames_editor_plugin.cpp
index 0f008552d0..0608ecec58 100644
--- a/editor/plugins/sprite_frames_editor_plugin.cpp
+++ b/editor/plugins/sprite_frames_editor_plugin.cpp
@@ -747,7 +747,7 @@ SpriteFramesEditor::SpriteFramesEditor() {
animations->set_hide_root(true);
animations->connect("cell_selected", this, "_animation_select");
animations->connect("item_edited", this, "_animation_name_edited");
- animations->set_single_select_cell_editing_only_when_already_selected(true);
+ animations->set_allow_reselect(true);
anim_speed = memnew(SpinBox);
vbc_animlist->add_margin_child(TTR("Speed (FPS):"), anim_speed);
diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp
index 90af4f1de1..1bd748a083 100644
--- a/editor/property_editor.cpp
+++ b/editor/property_editor.cpp
@@ -38,6 +38,7 @@
#include "editor_node.h"
#include "editor_settings.h"
#include "io/image_loader.h"
+#include "io/marshalls.h"
#include "io/resource_loader.h"
#include "multi_node_edit.h"
#include "os/input.h"
@@ -2318,7 +2319,15 @@ void PropertyEditor::set_item_text(TreeItem *p_item, int p_type, const String &p
} break;
case Variant::OBJECT: {
- if (obj->get(p_name).get_type() == Variant::NIL || obj->get(p_name).operator RefPtr().is_null()) {
+ Ref<EncodedObjectAsID> encoded = obj->get(p_name); //for debugger and remote tools
+
+ if (encoded.is_valid()) {
+
+ p_item->set_text(1, "Object: " + itos(encoded->get_object_id()));
+ p_item->set_icon(1, Ref<Texture>());
+ p_item->set_custom_as_button(1, true);
+
+ } else if (obj->get(p_name).get_type() == Variant::NIL || obj->get(p_name).operator RefPtr().is_null()) {
p_item->set_text(1, "<null>");
p_item->set_icon(1, Ref<Texture>());
p_item->set_custom_as_button(1, false);
@@ -3608,7 +3617,16 @@ void PropertyEditor::update_tree() {
RES res = obj->get(p.name).operator RefPtr();
- if (obj->get(p.name).get_type() == Variant::NIL || res.is_null()) {
+ Ref<EncodedObjectAsID> encoded = obj->get(p.name); //for debugger and remote tools
+
+ if (encoded.is_valid()) {
+
+ item->set_text(1, "Object: " + itos(encoded->get_object_id()));
+ item->set_icon(1, Ref<Texture>());
+ item->set_custom_as_button(1, true);
+ item->set_editable(1, true);
+
+ } else if (obj->get(p.name).get_type() == Variant::NIL || res.is_null()) {
item->set_text(1, "<null>");
item->set_icon(1, Ref<Texture>());
item->set_custom_as_button(1, false);
@@ -3937,6 +3955,13 @@ void PropertyEditor::_item_edited() {
if (!item->is_custom_set_as_button(1))
break;
+ Ref<EncodedObjectAsID> encoded = obj->get(name); //for debugger and remote tools
+
+ if (encoded.is_valid()) {
+
+ emit_signal("object_id_selected", encoded->get_object_id());
+ }
+
RES res = obj->get(name);
if (res.is_valid()) {
emit_signal("resource_selected", res.get_ref_ptr(), name);
diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp
index ce3b85332f..e984098bd4 100644
--- a/editor/scene_tree_dock.cpp
+++ b/editor/scene_tree_dock.cpp
@@ -2030,6 +2030,7 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor, Node *p_scene_root, EditorSel
tb->set_tooltip(TTR("Attach a new or existing script for the selected node."));
tb->set_shortcut(ED_GET_SHORTCUT("scene_tree/attach_script"));
filter_hbc->add_child(tb);
+ tb->hide();
button_create_script = tb;
tb = memnew(ToolButton);
@@ -2038,6 +2039,7 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor, Node *p_scene_root, EditorSel
tb->set_shortcut(ED_GET_SHORTCUT("scene_tree/clear_script"));
filter_hbc->add_child(tb);
button_clear_script = tb;
+ tb->hide();
scene_tree = memnew(SceneTreeEditor(false, true, true));
vbc->add_child(scene_tree);
diff --git a/editor/scene_tree_editor.cpp b/editor/scene_tree_editor.cpp
index 94ef712c25..2fab78e8c0 100644
--- a/editor/scene_tree_editor.cpp
+++ b/editor/scene_tree_editor.cpp
@@ -573,8 +573,10 @@ void SceneTreeEditor::set_selected(Node *p_node, bool p_emit_selected) {
selected = NULL;
_update_tree();
selected = p_node;
- if (p_emit_selected)
- emit_signal("node_selected");
+ }
+
+ if (p_emit_selected) {
+ emit_signal("node_selected");
}
}
diff --git a/editor/script_editor_debugger.cpp b/editor/script_editor_debugger.cpp
index 01cfdc1b57..bcf24b98f6 100644
--- a/editor/script_editor_debugger.cpp
+++ b/editor/script_editor_debugger.cpp
@@ -372,7 +372,13 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da
if (has_icon(p_data[i + 2], "EditorIcons"))
it->set_icon(0, get_icon(p_data[i + 2], "EditorIcons"));
it->set_metadata(0, id);
+
if (id == inspected_object_id) {
+ TreeItem *cti = it->get_parent(); //ensure selected is always uncollapsed
+ while (cti) {
+ cti->set_collapsed(false);
+ cti = cti->get_parent();
+ }
it->select(0);
}
@@ -385,6 +391,7 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da
it->set_collapsed(true);
}
}
+
lv[level] = it;
}
updating_scene_tree = false;
@@ -439,11 +446,8 @@ void ScriptEditorDebugger::_parse_message(const String &p_msg, const Array &p_da
inspected_object->last_edited_id = id;
- if (tabs->get_current_tab() == 2) {
- inspect_properties->edit(inspected_object);
- } else {
- editor->push_item(inspected_object);
- }
+ tabs->set_current_tab(inspect_info->get_index());
+ inspect_properties->edit(inspected_object);
} else if (p_msg == "message:video_mem") {
diff --git a/editor/spatial_editor_gizmos.cpp b/editor/spatial_editor_gizmos.cpp
index 24be2095ce..0e6e7420e2 100644
--- a/editor/spatial_editor_gizmos.cpp
+++ b/editor/spatial_editor_gizmos.cpp
@@ -1150,7 +1150,7 @@ CameraSpatialGizmo::CameraSpatialGizmo(Camera *p_camera) {
void MeshInstanceSpatialGizmo::redraw() {
- Ref<ArrayMesh> m = mesh->get_mesh();
+ Ref<Mesh> m = mesh->get_mesh();
if (!m.is_valid())
return; //none
diff --git a/modules/etc/image_etc.cpp b/modules/etc/image_etc.cpp
index 353bd1274a..ccc1733c43 100644
--- a/modules/etc/image_etc.cpp
+++ b/modules/etc/image_etc.cpp
@@ -118,7 +118,7 @@ static void _compress_etc(Image *p_img, float p_lossy_quality, bool force_etc1_f
}
int imgw = p_img->get_width(), imgh = p_img->get_height();
- ERR_FAIL_COND(nearest_power_of_2(imgw) != imgw || nearest_power_of_2(imgh) != imgh);
+ ERR_FAIL_COND(next_power_of_2(imgw) != imgw || next_power_of_2(imgh) != imgh);
Image::Format etc_format = force_etc1_format ? Image::FORMAT_ETC : _get_etc2_mode(detected_channels);
diff --git a/modules/gdnative/godot/string.h b/modules/gdnative/godot/string.h
index c901ce36e6..7695cd7931 100644
--- a/modules/gdnative/godot/string.h
+++ b/modules/gdnative/godot/string.h
@@ -172,7 +172,7 @@ void GDAPI godot_string_utf8(godot_string *p_self, char *result);
godot_bool GDAPI godot_string_parse_utf8(godot_string *p_self, const char *p_utf8);
godot_bool GDAPI godot_string_parse_utf8_with_len(godot_string *p_self, const char *p_utf8, godot_int p_len);
godot_string GDAPI godot_string_chars_to_utf8(const char *p_utf8);
-godot_string GDAPI godot_string_chars_utf8_with_len(const char *p_utf8, godot_int p_len);
+godot_string GDAPI godot_string_chars_to_utf8_with_len(const char *p_utf8, godot_int p_len);
uint32_t GDAPI godot_string_hash(const godot_string *p_self);
uint64_t GDAPI godot_string_hash64(const godot_string *p_self);
diff --git a/modules/gdscript/gd_functions.cpp b/modules/gdscript/gd_functions.cpp
index 209bdadd67..094dd287e6 100644
--- a/modules/gdscript/gd_functions.cpp
+++ b/modules/gdscript/gd_functions.cpp
@@ -446,7 +446,7 @@ void GDFunctions::call(Function p_func, const Variant **p_args, int p_arg_count,
VALIDATE_ARG_COUNT(1);
VALIDATE_ARG_NUM(0);
int64_t num = *p_args[0];
- r_ret = nearest_power_of_2(num);
+ r_ret = next_power_of_2(num);
} break;
case OBJ_WEAKREF: {
VALIDATE_ARG_COUNT(1);
diff --git a/modules/visual_script/visual_script.cpp b/modules/visual_script/visual_script.cpp
index d1cf0f1dce..8cbfb8f3fd 100644
--- a/modules/visual_script/visual_script.cpp
+++ b/modules/visual_script/visual_script.cpp
@@ -1578,12 +1578,15 @@ Variant VisualScriptInstance::_call_internal(const StringName &p_method, void *p
VisualScriptNodeInstance::StartMode start_mode;
{
- if (p_resuming_yield)
+ if (p_resuming_yield) {
start_mode = VisualScriptNodeInstance::START_MODE_RESUME_YIELD;
- else if (!flow_stack || !(flow_stack[flow_stack_pos] & VisualScriptNodeInstance::FLOW_STACK_PUSHED_BIT)) //if there is a push bit, it means we are continuing a sequence
- start_mode = VisualScriptNodeInstance::START_MODE_BEGIN_SEQUENCE;
- else
+ p_resuming_yield = false; // should resume only the first time
+ } else if (flow_stack && (flow_stack[flow_stack_pos] & VisualScriptNodeInstance::FLOW_STACK_PUSHED_BIT)) {
+ //if there is a push bit, it means we are continuing a sequence
start_mode = VisualScriptNodeInstance::START_MODE_CONTINUE_SEQUENCE;
+ } else {
+ start_mode = VisualScriptNodeInstance::START_MODE_BEGIN_SEQUENCE;
+ }
}
VSDEBUG("STEP - STARTSEQ: " + itos(start_mode));
diff --git a/modules/visual_script/visual_script_builtin_funcs.cpp b/modules/visual_script/visual_script_builtin_funcs.cpp
index 203e0bb483..9cbd70d4ca 100644
--- a/modules/visual_script/visual_script_builtin_funcs.cpp
+++ b/modules/visual_script/visual_script_builtin_funcs.cpp
@@ -915,7 +915,7 @@ void VisualScriptBuiltinFunc::exec_func(BuiltinFunc p_func, const Variant **p_in
VALIDATE_ARG_NUM(0);
int64_t num = *p_inputs[0];
- *r_return = nearest_power_of_2(num);
+ *r_return = next_power_of_2(num);
} break;
case VisualScriptBuiltinFunc::OBJ_WEAKREF: {
diff --git a/modules/visual_script/visual_script_editor.cpp b/modules/visual_script/visual_script_editor.cpp
index 75175b217a..b9e7a6ffc4 100644
--- a/modules/visual_script/visual_script_editor.cpp
+++ b/modules/visual_script/visual_script_editor.cpp
@@ -886,6 +886,8 @@ void VisualScriptEditor::_member_edited() {
undo_redo->add_undo_method(this, "_update_members");
undo_redo->add_do_method(this, "_update_graph");
undo_redo->add_undo_method(this, "_update_graph");
+ undo_redo->add_do_method(this, "emit_signal", "script_changed");
+ undo_redo->add_undo_method(this, "emit_signal", "script_changed");
undo_redo->commit_action();
// _update_graph();
@@ -901,6 +903,8 @@ void VisualScriptEditor::_member_edited() {
undo_redo->add_undo_method(script.ptr(), "rename_variable", new_name, name);
undo_redo->add_do_method(this, "_update_members");
undo_redo->add_undo_method(this, "_update_members");
+ undo_redo->add_do_method(this, "emit_signal", "script_changed");
+ undo_redo->add_undo_method(this, "emit_signal", "script_changed");
undo_redo->commit_action();
return; //or crash because it will become invalid
@@ -914,6 +918,8 @@ void VisualScriptEditor::_member_edited() {
undo_redo->add_undo_method(script.ptr(), "rename_custom_signal", new_name, name);
undo_redo->add_do_method(this, "_update_members");
undo_redo->add_undo_method(this, "_update_members");
+ undo_redo->add_do_method(this, "emit_signal", "script_changed");
+ undo_redo->add_undo_method(this, "emit_signal", "script_changed");
undo_redo->commit_action();
return; //or crash because it will become invalid
@@ -1051,7 +1057,8 @@ void VisualScriptEditor::_member_button(Object *p_item, int p_column, int p_butt
undo_redo->add_undo_method(this, "_update_members");
undo_redo->add_do_method(this, "_update_graph");
undo_redo->add_undo_method(this, "_update_graph");
-
+ undo_redo->add_do_method(this, "emit_signal", "script_changed");
+ undo_redo->add_undo_method(this, "emit_signal", "script_changed");
undo_redo->commit_action();
_update_graph();
@@ -1070,6 +1077,8 @@ void VisualScriptEditor::_member_button(Object *p_item, int p_column, int p_butt
undo_redo->add_undo_method(script.ptr(), "remove_variable", name);
undo_redo->add_do_method(this, "_update_members");
undo_redo->add_undo_method(this, "_update_members");
+ undo_redo->add_do_method(this, "emit_signal", "script_changed");
+ undo_redo->add_undo_method(this, "emit_signal", "script_changed");
undo_redo->commit_action();
return; //or crash because it will become invalid
}
@@ -1084,6 +1093,8 @@ void VisualScriptEditor::_member_button(Object *p_item, int p_column, int p_butt
undo_redo->add_undo_method(script.ptr(), "remove_custom_signal", name);
undo_redo->add_do_method(this, "_update_members");
undo_redo->add_undo_method(this, "_update_members");
+ undo_redo->add_do_method(this, "emit_signal", "script_changed");
+ undo_redo->add_undo_method(this, "emit_signal", "script_changed");
undo_redo->commit_action();
return; //or crash because it will become invalid
}
@@ -3223,7 +3234,7 @@ VisualScriptEditor::VisualScriptEditor() {
members->connect("button_pressed", this, "_member_button");
members->connect("item_edited", this, "_member_edited");
members->connect("cell_selected", this, "_member_selected", varray(), CONNECT_DEFERRED);
- members->set_single_select_cell_editing_only_when_already_selected(true);
+ members->set_allow_reselect(true);
members->set_hide_folding(true);
members->set_drag_forwarding(this);
diff --git a/platform/android/audio_driver_jandroid.cpp b/platform/android/audio_driver_jandroid.cpp
index d293f3ed30..763eff2863 100644
--- a/platform/android/audio_driver_jandroid.cpp
+++ b/platform/android/audio_driver_jandroid.cpp
@@ -81,7 +81,7 @@ Error AudioDriverAndroid::init() {
int latency = GLOBAL_DEF("audio/output_latency", 25);
latency = 50;
- unsigned int buffer_size = nearest_power_of_2(latency * mix_rate / 1000);
+ unsigned int buffer_size = next_power_of_2(latency * mix_rate / 1000);
if (OS::get_singleton()->is_stdout_verbose()) {
print_line("audio buffer size: " + itos(buffer_size));
}
diff --git a/platform/haiku/audio_driver_media_kit.cpp b/platform/haiku/audio_driver_media_kit.cpp
index 93351e0799..802f6b2d32 100644
--- a/platform/haiku/audio_driver_media_kit.cpp
+++ b/platform/haiku/audio_driver_media_kit.cpp
@@ -43,7 +43,7 @@ Error AudioDriverMediaKit::init() {
channels = 2;
int latency = GLOBAL_DEF("audio/output_latency", 25);
- buffer_size = nearest_power_of_2(latency * mix_rate / 1000);
+ buffer_size = next_power_of_2(latency * mix_rate / 1000);
samples_in = memnew_arr(int32_t, buffer_size * channels);
media_raw_audio_format format;
diff --git a/platform/osx/audio_driver_osx.cpp b/platform/osx/audio_driver_osx.cpp
index d7a91b1653..da5cd8f65e 100644
--- a/platform/osx/audio_driver_osx.cpp
+++ b/platform/osx/audio_driver_osx.cpp
@@ -30,6 +30,10 @@
#ifdef OSX_ENABLED
#include "audio_driver_osx.h"
+#include "core/project_settings.h"
+#include "os/os.h"
+
+#define kOutputBus 0
static OSStatus outputDeviceAddressCB(AudioObjectID inObjectID, UInt32 inNumberAddresses, const AudioObjectPropertyAddress *inAddresses, void *__nullable inClientData) {
AudioDriverOSX *driver = (AudioDriverOSX *)inClientData;
@@ -40,42 +44,69 @@ static OSStatus outputDeviceAddressCB(AudioObjectID inObjectID, UInt32 inNumberA
}
Error AudioDriverOSX::initDevice() {
+ AudioComponentDescription desc;
+ zeromem(&desc, sizeof(desc));
+ desc.componentType = kAudioUnitType_Output;
+ desc.componentSubType = kAudioUnitSubType_HALOutput;
+ desc.componentManufacturer = kAudioUnitManufacturer_Apple;
+
+ AudioComponent comp = AudioComponentFindNext(NULL, &desc);
+ ERR_FAIL_COND_V(comp == NULL, FAILED);
+
+ OSStatus result = AudioComponentInstanceNew(comp, &audio_unit);
+ ERR_FAIL_COND_V(result != noErr, FAILED);
+
AudioStreamBasicDescription strdesc;
+
+ // TODO: Implement this
+ /*zeromem(&strdesc, sizeof(strdesc));
+ UInt32 size = sizeof(strdesc);
+ result = AudioUnitGetProperty(audio_unit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Output, kOutputBus, &strdesc, &size);
+ ERR_FAIL_COND_V(result != noErr, FAILED);
+
+ switch (strdesc.mChannelsPerFrame) {
+ case 2: // Stereo
+ case 6: // Surround 5.1
+ case 8: // Surround 7.1
+ channels = strdesc.mChannelsPerFrame;
+ break;
+
+ default:
+ // Unknown number of channels, default to stereo
+ channels = 2;
+ break;
+ }*/
+
+ mix_rate = GLOBAL_DEF("audio/mix_rate", 44100);
+
+ zeromem(&strdesc, sizeof(strdesc));
strdesc.mFormatID = kAudioFormatLinearPCM;
strdesc.mFormatFlags = kLinearPCMFormatFlagIsSignedInteger | kLinearPCMFormatFlagIsPacked;
strdesc.mChannelsPerFrame = channels;
- strdesc.mSampleRate = 44100;
+ strdesc.mSampleRate = mix_rate;
strdesc.mFramesPerPacket = 1;
strdesc.mBitsPerChannel = 16;
strdesc.mBytesPerFrame = strdesc.mBitsPerChannel * strdesc.mChannelsPerFrame / 8;
strdesc.mBytesPerPacket = strdesc.mBytesPerFrame * strdesc.mFramesPerPacket;
- OSStatus result;
- AURenderCallbackStruct callback;
- AudioComponentDescription desc;
- AudioComponent comp = NULL;
- const AudioUnitElement output_bus = 0;
- const AudioUnitElement bus = output_bus;
- const AudioUnitScope scope = kAudioUnitScope_Input;
-
- zeromem(&desc, sizeof(desc));
- desc.componentType = kAudioUnitType_Output;
- desc.componentSubType = kAudioUnitSubType_HALOutput;
- desc.componentManufacturer = kAudioUnitManufacturer_Apple;
+ result = AudioUnitSetProperty(audio_unit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, kOutputBus, &strdesc, sizeof(strdesc));
+ ERR_FAIL_COND_V(result != noErr, FAILED);
- comp = AudioComponentFindNext(NULL, &desc);
- ERR_FAIL_COND_V(comp == NULL, FAILED);
+ int latency = GLOBAL_DEF("audio/output_latency", 25);
+ unsigned int buffer_size = closest_power_of_2(latency * mix_rate / 1000);
- result = AudioComponentInstanceNew(comp, &audio_unit);
- ERR_FAIL_COND_V(result != noErr, FAILED);
+ if (OS::get_singleton()->is_stdout_verbose()) {
+ print_line("audio buffer size: " + itos(buffer_size) + " calculated latency: " + itos(buffer_size * 1000 / mix_rate));
+ }
- result = AudioUnitSetProperty(audio_unit, kAudioUnitProperty_StreamFormat, scope, bus, &strdesc, sizeof(strdesc));
- ERR_FAIL_COND_V(result != noErr, FAILED);
+ samples_in.resize(buffer_size);
+ buffer_frames = buffer_size / channels;
+ AURenderCallbackStruct callback;
zeromem(&callback, sizeof(AURenderCallbackStruct));
callback.inputProc = &AudioDriverOSX::output_callback;
callback.inputProcRefCon = this;
- result = AudioUnitSetProperty(audio_unit, kAudioUnitProperty_SetRenderCallback, scope, bus, &callback, sizeof(callback));
+ result = AudioUnitSetProperty(audio_unit, kAudioUnitProperty_SetRenderCallback, kAudioUnitScope_Input, kOutputBus, &callback, sizeof(callback));
ERR_FAIL_COND_V(result != noErr, FAILED);
result = AudioUnitInitialize(audio_unit);
@@ -114,15 +145,10 @@ Error AudioDriverOSX::init() {
result = AudioObjectAddPropertyListener(kAudioObjectSystemObject, &outputDeviceAddress, &outputDeviceAddressCB, this);
ERR_FAIL_COND_V(result != noErr, FAILED);
- const int samples = 1024;
- samples_in = memnew_arr(int32_t, samples); // whatever
- buffer_frames = samples / channels;
-
return initDevice();
};
Error AudioDriverOSX::reopen() {
- Error err;
bool restart = false;
lock();
@@ -131,7 +157,7 @@ Error AudioDriverOSX::reopen() {
restart = true;
}
- err = finishDevice();
+ Error err = finishDevice();
if (err != OK) {
ERR_PRINT("finishDevice failed");
unlock();
@@ -179,7 +205,7 @@ OSStatus AudioDriverOSX::output_callback(void *inRefCon,
while (frames_left) {
int frames = MIN(frames_left, ad->buffer_frames);
- ad->audio_server_process(frames, ad->samples_in);
+ ad->audio_server_process(frames, ad->samples_in.ptr());
for (int j = 0; j < frames * ad->channels; j++) {
@@ -232,29 +258,33 @@ bool AudioDriverOSX::try_lock() {
}
void AudioDriverOSX::finish() {
- OSStatus result;
-
finishDevice();
- result = AudioObjectRemovePropertyListener(kAudioObjectSystemObject, &outputDeviceAddress, &outputDeviceAddressCB, this);
+ OSStatus result = AudioObjectRemovePropertyListener(kAudioObjectSystemObject, &outputDeviceAddress, &outputDeviceAddressCB, this);
if (result != noErr) {
ERR_PRINT("AudioObjectRemovePropertyListener failed");
}
+ AURenderCallbackStruct callback;
+ zeromem(&callback, sizeof(AURenderCallbackStruct));
+ result = AudioUnitSetProperty(audio_unit, kAudioUnitProperty_SetRenderCallback, kAudioUnitScope_Input, kOutputBus, &callback, sizeof(callback));
+ if (result != noErr) {
+ ERR_PRINT("AudioUnitSetProperty failed");
+ }
+
if (mutex) {
memdelete(mutex);
mutex = NULL;
}
-
- if (samples_in) {
- memdelete_arr(samples_in);
- samples_in = NULL;
- }
};
AudioDriverOSX::AudioDriverOSX() {
+ active = false;
mutex = NULL;
- samples_in = NULL;
+
+ mix_rate = 44100;
+ channels = 2;
+ samples_in.clear();
};
AudioDriverOSX::~AudioDriverOSX(){};
diff --git a/platform/osx/audio_driver_osx.h b/platform/osx/audio_driver_osx.h
index 287c9d6cbf..4576100690 100644
--- a/platform/osx/audio_driver_osx.h
+++ b/platform/osx/audio_driver_osx.h
@@ -44,10 +44,12 @@ class AudioDriverOSX : public AudioDriver {
bool active;
Mutex *mutex;
+ int mix_rate;
int channels;
- int32_t *samples_in;
int buffer_frames;
+ Vector<int32_t> samples_in;
+
static OSStatus output_callback(void *inRefCon,
AudioUnitRenderActionFlags *ioActionFlags,
const AudioTimeStamp *inTimeStamp,
diff --git a/platform/windows/detect.py b/platform/windows/detect.py
index 4d93b3f244..882e1a808e 100644
--- a/platform/windows/detect.py
+++ b/platform/windows/detect.py
@@ -14,69 +14,56 @@ def get_name():
def can_build():
if (os.name == "nt"):
- # building natively on windows!
- if (os.getenv("VCINSTALLDIR")):
+ # Building natively on Windows
+ if (os.getenv("VCINSTALLDIR")): # MSVC
return True
- else:
- print("\nMSVC not detected, attempting MinGW.")
- mingw32 = ""
- mingw64 = ""
- if (os.getenv("MINGW32_PREFIX")):
- mingw32 = os.getenv("MINGW32_PREFIX")
- if (os.getenv("MINGW64_PREFIX")):
- mingw64 = os.getenv("MINGW64_PREFIX")
-
- test = "gcc --version > NUL 2>&1"
- if os.system(test) != 0 and os.system(mingw32 + test) != 0 and os.system(mingw64 + test) != 0:
- print("- could not detect gcc.")
- print("Please, make sure a path to a MinGW /bin directory is accessible into the environment PATH.\n")
- return False
- else:
- print("- gcc detected.")
+ print("MSVC not detected (no VCINSTALLDIR environment variable), attempting MinGW.")
+ mingw32 = ""
+ mingw64 = ""
+ if (os.getenv("MINGW32_PREFIX")):
+ mingw32 = os.getenv("MINGW32_PREFIX")
+ if (os.getenv("MINGW64_PREFIX")):
+ mingw64 = os.getenv("MINGW64_PREFIX")
+
+ test = "gcc --version > NUL 2>&1"
+ if (os.system(test) == 0 or os.system(mingw32 + test) == 0 or os.system(mingw64 + test) == 0):
return True
if (os.name == "posix"):
-
- mingw = "i586-mingw32msvc-"
- mingw64 = "x86_64-w64-mingw32-"
+ # Cross-compiling with MinGW-w64 (old MinGW32 is not supported)
mingw32 = "i686-w64-mingw32-"
+ mingw64 = "x86_64-w64-mingw32-"
if (os.getenv("MINGW32_PREFIX")):
mingw32 = os.getenv("MINGW32_PREFIX")
- mingw = mingw32
if (os.getenv("MINGW64_PREFIX")):
mingw64 = os.getenv("MINGW64_PREFIX")
test = "gcc --version > /dev/null 2>&1"
- if (os.system(mingw + test) == 0 or os.system(mingw64 + test) == 0 or os.system(mingw32 + test) == 0):
+ if (os.system(mingw64 + test) == 0 or os.system(mingw32 + test) == 0):
return True
+ print("Could not detect MinGW. Ensure its binaries are in your PATH or that MINGW32_PREFIX or MINGW64_PREFIX are properly defined.")
return False
def get_opts():
- mingw = ""
mingw32 = ""
mingw64 = ""
if (os.name == "posix"):
- mingw = "i586-mingw32msvc-"
mingw32 = "i686-w64-mingw32-"
mingw64 = "x86_64-w64-mingw32-"
- if os.system(mingw32 + "gcc --version > /dev/null 2>&1") != 0:
- mingw32 = mingw
-
if (os.getenv("MINGW32_PREFIX")):
mingw32 = os.getenv("MINGW32_PREFIX")
- mingw = mingw32
if (os.getenv("MINGW64_PREFIX")):
mingw64 = os.getenv("MINGW64_PREFIX")
return [
- ('mingw_prefix', 'MinGW Prefix', mingw32),
- ('mingw_prefix_64', 'MinGW Prefix 64 bits', mingw64),
+ ('mingw_prefix_32', 'MinGW prefix (Win32)', mingw32),
+ ('mingw_prefix_64', 'MinGW prefix (Win64)', mingw64),
]
@@ -88,12 +75,10 @@ def get_flags():
def build_res_file(target, source, env):
- cmdbase = ""
if (env["bits"] == "32"):
- cmdbase = env['mingw_prefix']
+ cmdbase = env['mingw_prefix_32']
else:
cmdbase = env['mingw_prefix_64']
- CPPPATH = env['CPPPATH']
cmdbase = cmdbase + 'windres --include-dir . '
import subprocess
for x in range(len(source)):
@@ -111,8 +96,10 @@ def configure(env):
env.Append(CPPPATH=['#platform/windows'])
- # Targeted Windows version: Vista (and later)
- winver = "0x0600" # Windows Vista is the minimum target for windows builds
+ # Targeted Windows version: 7 (and later), minimum supported version
+ # XP support dropped after EOL due to missing API for IPv6 and other issues
+ # Vista support dropped after EOL due to GH-10243
+ winver = "0x0601"
if (os.name == "nt" and os.getenv("VCINSTALLDIR")): # MSVC
@@ -247,7 +234,7 @@ def configure(env):
env.Append(LINKFLAGS=['-static'])
env.Append(LINKFLAGS=['-static-libgcc'])
env.Append(LINKFLAGS=['-static-libstdc++'])
- mingw_prefix = env["mingw_prefix"]
+ mingw_prefix = env["mingw_prefix_32"]
else:
env.Append(LINKFLAGS=['-static'])
mingw_prefix = env["mingw_prefix_64"]
diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp
index 54021b8172..72f6068eb6 100644
--- a/platform/windows/os_windows.cpp
+++ b/platform/windows/os_windows.cpp
@@ -63,12 +63,11 @@ __attribute__((visibility("default"))) DWORD NvOptimusEnablement = 0x00000001;
#endif
}
-#ifndef WM_MOUSEHWHEEL
-#define WM_MOUSEHWHEEL 0x020e
+// Workaround mingw-w64 < 4.0 bug
+#ifndef WM_TOUCH
+#define WM_TOUCH 576
#endif
-//#define STDOUT_FILE
-
extern HINSTANCE godot_hinstance;
void RedirectIOToConsole() {
diff --git a/platform/x11/context_gl_x11.cpp b/platform/x11/context_gl_x11.cpp
index ddf17481b1..f055d730db 100644
--- a/platform/x11/context_gl_x11.cpp
+++ b/platform/x11/context_gl_x11.cpp
@@ -83,6 +83,19 @@ static int ctxErrorHandler(Display *dpy, XErrorEvent *ev) {
return 0;
}
+static void set_class_hint(Display *p_display, Window p_window) {
+ XClassHint *classHint;
+
+ /* set the name and class hints for the window manager to use */
+ classHint = XAllocClassHint();
+ if (classHint) {
+ classHint->res_name = (char *)"Godot_Engine";
+ classHint->res_class = (char *)"Godot";
+ }
+ XSetClassHint(p_display, p_window, classHint);
+ XFree(classHint);
+}
+
Error ContextGL_X11::initialize() {
GLXCREATECONTEXTATTRIBSARBPROC glXCreateContextAttribsARB = NULL;
@@ -127,6 +140,7 @@ Error ContextGL_X11::initialize() {
*/
x11_window = XCreateWindow(x11_display, RootWindow(x11_display, vi->screen), 0, 0, OS::get_singleton()->get_video_mode().width, OS::get_singleton()->get_video_mode().height, 0, vi->depth, InputOutput, vi->visual, CWBorderPixel | CWColormap | CWEventMask, &swa);
ERR_FAIL_COND_V(!x11_window, ERR_UNCONFIGURED);
+ set_class_hint(x11_display, x11_window);
XMapWindow(x11_display, x11_window);
//};
diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp
index ade3a0a0c5..a23f2f1320 100644
--- a/platform/x11/os_x11.cpp
+++ b/platform/x11/os_x11.cpp
@@ -351,20 +351,9 @@ void OS_X11::initialize(const VideoMode &p_desired, int p_video_driver, int p_au
XChangeWindowAttributes(x11_display, x11_window, CWEventMask, &new_attr);
- XClassHint *classHint;
-
/* set the titlebar name */
XStoreName(x11_display, x11_window, "Godot");
- /* set the name and class hints for the window manager to use */
- classHint = XAllocClassHint();
- if (classHint) {
- classHint->res_name = (char *)"Godot_Engine";
- classHint->res_class = (char *)"Godot";
- }
- XSetClassHint(x11_display, x11_window, classHint);
- XFree(classHint);
-
wm_delete = XInternAtom(x11_display, "WM_DELETE_WINDOW", true);
XSetWMProtocols(x11_display, x11_window, &wm_delete, 1);
diff --git a/scene/2d/canvas_item.cpp b/scene/2d/canvas_item.cpp
index 3d0b5047ae..cdd8fdf350 100644
--- a/scene/2d/canvas_item.cpp
+++ b/scene/2d/canvas_item.cpp
@@ -734,7 +734,7 @@ void CanvasItem::draw_set_transform_matrix(const Transform2D &p_matrix) {
VisualServer::get_singleton()->canvas_item_add_set_transform(canvas_item, p_matrix);
}
-void CanvasItem::draw_polygon(const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, Ref<Texture> p_texture, const Ref<Texture> &p_normal_map) {
+void CanvasItem::draw_polygon(const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, Ref<Texture> p_texture, const Ref<Texture> &p_normal_map, bool p_antialiased) {
if (!drawing) {
ERR_EXPLAIN("Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal.");
@@ -744,10 +744,10 @@ void CanvasItem::draw_polygon(const Vector<Point2> &p_points, const Vector<Color
RID rid = p_texture.is_valid() ? p_texture->get_rid() : RID();
RID rid_normal = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID();
- VisualServer::get_singleton()->canvas_item_add_polygon(canvas_item, p_points, p_colors, p_uvs, rid, rid_normal);
+ VisualServer::get_singleton()->canvas_item_add_polygon(canvas_item, p_points, p_colors, p_uvs, rid, rid_normal, p_antialiased);
}
-void CanvasItem::draw_colored_polygon(const Vector<Point2> &p_points, const Color &p_color, const Vector<Point2> &p_uvs, Ref<Texture> p_texture, const Ref<Texture> &p_normal_map) {
+void CanvasItem::draw_colored_polygon(const Vector<Point2> &p_points, const Color &p_color, const Vector<Point2> &p_uvs, Ref<Texture> p_texture, const Ref<Texture> &p_normal_map, bool p_antialiased) {
if (!drawing) {
ERR_EXPLAIN("Drawing is only allowed inside NOTIFICATION_DRAW, _draw() function or 'draw' signal.");
@@ -759,7 +759,7 @@ void CanvasItem::draw_colored_polygon(const Vector<Point2> &p_points, const Colo
RID rid = p_texture.is_valid() ? p_texture->get_rid() : RID();
RID rid_normal = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID();
- VisualServer::get_singleton()->canvas_item_add_polygon(canvas_item, p_points, colors, p_uvs, rid, rid_normal);
+ VisualServer::get_singleton()->canvas_item_add_polygon(canvas_item, p_points, colors, p_uvs, rid, rid_normal, p_antialiased);
}
void CanvasItem::draw_string(const Ref<Font> &p_font, const Point2 &p_pos, const String &p_text, const Color &p_modulate, int p_clip_w) {
@@ -985,8 +985,8 @@ void CanvasItem::_bind_methods() {
ClassDB::bind_method(D_METHOD("draw_texture_rect_region", "texture", "rect", "src_rect", "modulate", "transpose", "normal_map", "clip_uv"), &CanvasItem::draw_texture_rect_region, DEFVAL(Color(1, 1, 1)), DEFVAL(false), DEFVAL(Variant()), DEFVAL(true));
ClassDB::bind_method(D_METHOD("draw_style_box", "style_box", "rect"), &CanvasItem::draw_style_box);
ClassDB::bind_method(D_METHOD("draw_primitive", "points", "colors", "uvs", "texture", "width", "normal_map"), &CanvasItem::draw_primitive, DEFVAL(Variant()), DEFVAL(1.0), DEFVAL(Variant()));
- ClassDB::bind_method(D_METHOD("draw_polygon", "points", "colors", "uvs", "texture", "normal_map"), &CanvasItem::draw_polygon, DEFVAL(PoolVector2Array()), DEFVAL(Variant()), DEFVAL(Variant()));
- ClassDB::bind_method(D_METHOD("draw_colored_polygon", "points", "color", "uvs", "texture", "normal_map"), &CanvasItem::draw_colored_polygon, DEFVAL(PoolVector2Array()), DEFVAL(Variant()), DEFVAL(Variant()));
+ ClassDB::bind_method(D_METHOD("draw_polygon", "points", "colors", "uvs", "texture", "normal_map", "antialiased"), &CanvasItem::draw_polygon, DEFVAL(PoolVector2Array()), DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("draw_colored_polygon", "points", "color", "uvs", "texture", "normal_map", "antialiased"), &CanvasItem::draw_colored_polygon, DEFVAL(PoolVector2Array()), DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(false));
ClassDB::bind_method(D_METHOD("draw_string", "font", "pos", "text", "modulate", "clip_w"), &CanvasItem::draw_string, DEFVAL(Color(1, 1, 1)), DEFVAL(-1));
ClassDB::bind_method(D_METHOD("draw_char", "font", "pos", "char", "next", "modulate"), &CanvasItem::draw_char, DEFVAL(Color(1, 1, 1)));
diff --git a/scene/2d/canvas_item.h b/scene/2d/canvas_item.h
index 660ddcf930..c6180e07b6 100644
--- a/scene/2d/canvas_item.h
+++ b/scene/2d/canvas_item.h
@@ -251,8 +251,8 @@ public:
void draw_texture_rect_region(const Ref<Texture> &p_texture, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture> &p_normal_map = Ref<Texture>(), bool p_clip_uv = true);
void draw_style_box(const Ref<StyleBox> &p_style_box, const Rect2 &p_rect);
void draw_primitive(const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, Ref<Texture> p_texture = Ref<Texture>(), float p_width = 1, const Ref<Texture> &p_normal_map = Ref<Texture>());
- void draw_polygon(const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs = Vector<Point2>(), Ref<Texture> p_texture = Ref<Texture>(), const Ref<Texture> &p_normal_map = Ref<Texture>());
- void draw_colored_polygon(const Vector<Point2> &p_points, const Color &p_color, const Vector<Point2> &p_uvs = Vector<Point2>(), Ref<Texture> p_texture = Ref<Texture>(), const Ref<Texture> &p_normal_map = Ref<Texture>());
+ void draw_polygon(const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs = Vector<Point2>(), Ref<Texture> p_texture = Ref<Texture>(), const Ref<Texture> &p_normal_map = Ref<Texture>(), bool p_antialiased = false);
+ void draw_colored_polygon(const Vector<Point2> &p_points, const Color &p_color, const Vector<Point2> &p_uvs = Vector<Point2>(), Ref<Texture> p_texture = Ref<Texture>(), const Ref<Texture> &p_normal_map = Ref<Texture>(), bool p_antialiased = false);
void draw_string(const Ref<Font> &p_font, const Point2 &p_pos, const String &p_text, const Color &p_modulate = Color(1, 1, 1), int p_clip_w = -1);
float draw_char(const Ref<Font> &p_font, const Point2 &p_pos, const String &p_char, const String &p_next = "", const Color &p_modulate = Color(1, 1, 1));
diff --git a/scene/2d/polygon_2d.cpp b/scene/2d/polygon_2d.cpp
index 5c1c953a37..7e2d6d1b5a 100644
--- a/scene/2d/polygon_2d.cpp
+++ b/scene/2d/polygon_2d.cpp
@@ -176,9 +176,10 @@ void Polygon2D::_notification(int p_what) {
}
}
- Vector<int> indices = Geometry::triangulate_polygon(points);
+ // Vector<int> indices = Geometry::triangulate_polygon(points);
+ // VS::get_singleton()->canvas_item_add_triangle_array(get_canvas_item(), indices, points, colors, uvs, texture.is_valid() ? texture->get_rid() : RID());
- VS::get_singleton()->canvas_item_add_triangle_array(get_canvas_item(), indices, points, colors, uvs, texture.is_valid() ? texture->get_rid() : RID());
+ VS::get_singleton()->canvas_item_add_polygon(get_canvas_item(), points, colors, uvs, texture.is_valid() ? texture->get_rid() : RID(), RID(), antialiased);
} break;
}
@@ -294,6 +295,16 @@ bool Polygon2D::get_invert() const {
return invert;
}
+void Polygon2D::set_antialiased(bool p_antialiased) {
+
+ antialiased = p_antialiased;
+ update();
+}
+bool Polygon2D::get_antialiased() const {
+
+ return antialiased;
+}
+
void Polygon2D::set_invert_border(float p_invert_border) {
invert_border = p_invert_border;
@@ -348,6 +359,9 @@ void Polygon2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_invert", "invert"), &Polygon2D::set_invert);
ClassDB::bind_method(D_METHOD("get_invert"), &Polygon2D::get_invert);
+ ClassDB::bind_method(D_METHOD("set_antialiased", "antialiased"), &Polygon2D::set_antialiased);
+ ClassDB::bind_method(D_METHOD("get_antialiased"), &Polygon2D::get_antialiased);
+
ClassDB::bind_method(D_METHOD("set_invert_border", "invert_border"), &Polygon2D::set_invert_border);
ClassDB::bind_method(D_METHOD("get_invert_border"), &Polygon2D::get_invert_border);
@@ -359,6 +373,7 @@ void Polygon2D::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "color"), "set_color", "get_color");
ADD_PROPERTY(PropertyInfo(Variant::POOL_COLOR_ARRAY, "vertex_colors"), "set_vertex_colors", "get_vertex_colors");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "offset"), "set_offset", "get_offset");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "antialiased"), "set_antialiased", "get_antialiased");
ADD_GROUP("Texture", "");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture");
ADD_GROUP("Texture", "texture_");
@@ -375,6 +390,7 @@ Polygon2D::Polygon2D() {
invert = 0;
invert_border = 100;
+ antialiased = false;
tex_rot = 0;
tex_tile = true;
tex_scale = Vector2(1, 1);
diff --git a/scene/2d/polygon_2d.h b/scene/2d/polygon_2d.h
index 3cc9db28b6..eb47f4d8d1 100644
--- a/scene/2d/polygon_2d.h
+++ b/scene/2d/polygon_2d.h
@@ -47,6 +47,7 @@ class Polygon2D : public Node2D {
float tex_rot;
bool invert;
float invert_border;
+ bool antialiased;
Vector2 offset;
mutable bool rect_cache_dirty;
@@ -87,6 +88,9 @@ public:
void set_invert(bool p_invert);
bool get_invert() const;
+ void set_antialiased(bool p_antialiased);
+ bool get_antialiased() const;
+
void set_invert_border(float p_invert_border);
float get_invert_border() const;
diff --git a/scene/3d/light.cpp b/scene/3d/light.cpp
index 977f1f81a7..1304954cf3 100644
--- a/scene/3d/light.cpp
+++ b/scene/3d/light.cpp
@@ -106,6 +106,16 @@ Color Light::get_shadow_color() const {
return shadow_color;
}
+void Light::set_shadow_reverse_cull_face(bool p_enable) {
+ reverse_cull = p_enable;
+ VS::get_singleton()->light_set_reverse_cull_face_mode(light, reverse_cull);
+}
+
+bool Light::get_shadow_reverse_cull_face() const {
+
+ return reverse_cull;
+}
+
Rect3 Light::get_aabb() const {
if (type == VisualServer::LIGHT_DIRECTIONAL) {
@@ -202,6 +212,9 @@ void Light::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_color", "color"), &Light::set_color);
ClassDB::bind_method(D_METHOD("get_color"), &Light::get_color);
+ ClassDB::bind_method(D_METHOD("set_shadow_reverse_cull_face", "enable"), &Light::set_shadow_reverse_cull_face);
+ ClassDB::bind_method(D_METHOD("get_shadow_reverse_cull_face"), &Light::get_shadow_reverse_cull_face);
+
ClassDB::bind_method(D_METHOD("set_shadow_color", "shadow_color"), &Light::set_shadow_color);
ClassDB::bind_method(D_METHOD("get_shadow_color"), &Light::get_shadow_color);
@@ -217,6 +230,7 @@ void Light::_bind_methods() {
ADD_PROPERTYI(PropertyInfo(Variant::REAL, "shadow_bias", PROPERTY_HINT_RANGE, "-16,16,0.01"), "set_param", "get_param", PARAM_SHADOW_BIAS);
ADD_PROPERTYI(PropertyInfo(Variant::REAL, "shadow_contact", PROPERTY_HINT_RANGE, "0,16,0.01"), "set_param", "get_param", PARAM_CONTACT_SHADOW_SIZE);
ADD_PROPERTYI(PropertyInfo(Variant::REAL, "shadow_max_distance", PROPERTY_HINT_RANGE, "0,65536,0.1"), "set_param", "get_param", PARAM_SHADOW_MAX_DISTANCE);
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "shadow_reverse_cull_face"), "set_shadow_reverse_cull_face", "get_shadow_reverse_cull_face");
ADD_GROUP("Editor", "");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "editor_only"), "set_editor_only", "is_editor_only");
ADD_GROUP("", "");
@@ -244,6 +258,8 @@ Light::Light(VisualServer::LightType p_type) {
light = VisualServer::get_singleton()->light_create(p_type);
VS::get_singleton()->instance_set_base(get_instance(), light);
+ reverse_cull = false;
+
editor_only = false;
set_color(Color(1, 1, 1, 1));
set_shadow(false);
diff --git a/scene/3d/light.h b/scene/3d/light.h
index 22ff5c0763..788e948536 100644
--- a/scene/3d/light.h
+++ b/scene/3d/light.h
@@ -69,6 +69,7 @@ private:
Color shadow_color;
bool shadow;
bool negative;
+ bool reverse_cull;
uint32_t cull_mask;
VS::LightType type;
bool editor_only;
@@ -110,6 +111,9 @@ public:
void set_shadow_color(const Color &p_shadow_color);
Color get_shadow_color() const;
+ void set_shadow_reverse_cull_face(bool p_enable);
+ bool get_shadow_reverse_cull_face() const;
+
virtual Rect3 get_aabb() const;
virtual PoolVector<Face3> get_faces(uint32_t p_usage_flags) const;
diff --git a/scene/3d/visual_instance.cpp b/scene/3d/visual_instance.cpp
index 1a294d016a..7d61006529 100644
--- a/scene/3d/visual_instance.cpp
+++ b/scene/3d/visual_instance.cpp
@@ -231,14 +231,6 @@ void GeometryInstance::_notification(int p_what) {
void GeometryInstance::set_flag(Flags p_flag, bool p_value) {
ERR_FAIL_INDEX(p_flag, FLAG_MAX);
- if (p_flag == FLAG_CAST_SHADOW) {
- if (p_value == true) {
- set_cast_shadows_setting(SHADOW_CASTING_SETTING_ON);
- } else {
- set_cast_shadows_setting(SHADOW_CASTING_SETTING_OFF);
- }
- }
-
if (flags[p_flag] == p_value)
return;
@@ -252,14 +244,6 @@ bool GeometryInstance::get_flag(Flags p_flag) const {
ERR_FAIL_INDEX_V(p_flag, FLAG_MAX, false);
- if (p_flag == FLAG_CAST_SHADOW) {
- if (shadow_casting_setting == SHADOW_CASTING_SETTING_OFF) {
- return false;
- } else {
- return true;
- }
- }
-
return flags[p_flag];
}
@@ -330,7 +314,6 @@ void GeometryInstance::_bind_methods() {
//ADD_SIGNAL( MethodInfo("visibility_changed"));
- BIND_CONSTANT(FLAG_CAST_SHADOW);
BIND_CONSTANT(FLAG_VISIBLE_IN_ALL_ROOMS);
BIND_CONSTANT(FLAG_MAX);
@@ -350,8 +333,6 @@ GeometryInstance::GeometryInstance() {
flags[i] = false;
}
- flags[FLAG_CAST_SHADOW] = true;
-
shadow_casting_setting = SHADOW_CASTING_SETTING_ON;
extra_cull_margin = 0;
//VS::get_singleton()->instance_geometry_set_baked_light_texture_index(get_instance(),0);
diff --git a/scene/3d/visual_instance.h b/scene/3d/visual_instance.h
index 9318198e54..694d0c2499 100644
--- a/scene/3d/visual_instance.h
+++ b/scene/3d/visual_instance.h
@@ -84,7 +84,6 @@ class GeometryInstance : public VisualInstance {
public:
enum Flags {
- FLAG_CAST_SHADOW = VS::INSTANCE_FLAG_CAST_SHADOW,
FLAG_VISIBLE_IN_ALL_ROOMS = VS::INSTANCE_FLAG_VISIBLE_IN_ALL_ROOMS,
FLAG_USE_BAKED_LIGHT = VS::INSTANCE_FLAG_USE_BAKED_LIGHT,
FLAG_MAX = VS::INSTANCE_FLAG_MAX,
diff --git a/scene/gui/button.cpp b/scene/gui/button.cpp
index 9a0b3b3c89..5036e4f7f6 100644
--- a/scene/gui/button.cpp
+++ b/scene/gui/button.cpp
@@ -59,7 +59,7 @@ void Button::_notification(int p_what) {
if (p_what == NOTIFICATION_TRANSLATION_CHANGED) {
- xl_text = XL_MESSAGE(text);
+ xl_text = tr(text);
minimum_size_changed();
update();
}
@@ -172,7 +172,7 @@ void Button::set_text(const String &p_text) {
if (text == p_text)
return;
text = p_text;
- xl_text = XL_MESSAGE(p_text);
+ xl_text = tr(p_text);
update();
_change_notify("text");
minimum_size_changed();
diff --git a/scene/gui/dialogs.cpp b/scene/gui/dialogs.cpp
index 8232a7a466..ef8b0adfa9 100644
--- a/scene/gui/dialogs.cpp
+++ b/scene/gui/dialogs.cpp
@@ -271,7 +271,7 @@ int WindowDialog::_drag_hit_test(const Point2 &pos) const {
void WindowDialog::set_title(const String &p_title) {
- title = XL_MESSAGE(p_title);
+ title = tr(p_title);
update();
}
String WindowDialog::get_title() const {
diff --git a/scene/gui/file_dialog.cpp b/scene/gui/file_dialog.cpp
index 74255b38bf..b3530c2971 100644
--- a/scene/gui/file_dialog.cpp
+++ b/scene/gui/file_dialog.cpp
@@ -464,7 +464,7 @@ void FileDialog::update_filters() {
String flt = filters[i].get_slice(";", 0).strip_edges();
String desc = filters[i].get_slice(";", 1).strip_edges();
if (desc.length())
- filter->add_item(String(XL_MESSAGE(desc)) + " ( " + flt + " )");
+ filter->add_item(String(tr(desc)) + " ( " + flt + " )");
else
filter->add_item("( " + flt + " )");
}
diff --git a/scene/gui/label.cpp b/scene/gui/label.cpp
index 874156821e..84074f96a8 100644
--- a/scene/gui/label.cpp
+++ b/scene/gui/label.cpp
@@ -63,7 +63,7 @@ void Label::_notification(int p_what) {
if (p_what == NOTIFICATION_TRANSLATION_CHANGED) {
- String new_text = XL_MESSAGE(text);
+ String new_text = tr(text);
if (new_text == xl_text)
return; //nothing new
xl_text = new_text;
@@ -493,7 +493,10 @@ void Label::regenerate_word_cache() {
minsize.height = (font->get_height() * line_count) + (line_spacing * (line_count - 1));
}
- minimum_size_changed();
+ if (!autowrap || !clip) {
+ //helps speed up some labels that may change a lot, as no resizing is requested. Do not change.
+ minimum_size_changed();
+ }
word_cache_dirty = false;
}
@@ -526,7 +529,7 @@ void Label::set_text(const String &p_string) {
if (text == p_string)
return;
text = p_string;
- xl_text = XL_MESSAGE(p_string);
+ xl_text = tr(p_string);
word_cache_dirty = true;
if (percent_visible < 1)
visible_chars = get_total_character_count() * percent_visible;
diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp
index c1784fb7ba..e91f8add31 100644
--- a/scene/gui/line_edit.cpp
+++ b/scene/gui/line_edit.cpp
@@ -991,7 +991,7 @@ String LineEdit::get_text() const {
void LineEdit::set_placeholder(String p_text) {
- placeholder = XL_MESSAGE(p_text);
+ placeholder = tr(p_text);
update();
}
diff --git a/scene/gui/popup_menu.cpp b/scene/gui/popup_menu.cpp
index 46aa0e5054..1ba936c4e9 100644
--- a/scene/gui/popup_menu.cpp
+++ b/scene/gui/popup_menu.cpp
@@ -395,7 +395,7 @@ void PopupMenu::_notification(int p_what) {
case NOTIFICATION_TRANSLATION_CHANGED: {
for (int i = 0; i < items.size(); i++) {
- items[i].xl_text = XL_MESSAGE(items[i].text);
+ items[i].xl_text = tr(items[i].text);
}
minimum_size_changed();
@@ -513,7 +513,7 @@ void PopupMenu::add_icon_item(const Ref<Texture> &p_icon, const String &p_label,
Item item;
item.icon = p_icon;
item.text = p_label;
- item.xl_text = XL_MESSAGE(p_label);
+ item.xl_text = tr(p_label);
item.accel = p_accel;
item.ID = p_ID;
items.push_back(item);
@@ -523,7 +523,7 @@ void PopupMenu::add_item(const String &p_label, int p_ID, uint32_t p_accel) {
Item item;
item.text = p_label;
- item.xl_text = XL_MESSAGE(p_label);
+ item.xl_text = tr(p_label);
item.accel = p_accel;
item.ID = p_ID;
items.push_back(item);
@@ -534,7 +534,7 @@ void PopupMenu::add_submenu_item(const String &p_label, const String &p_submenu,
Item item;
item.text = p_label;
- item.xl_text = XL_MESSAGE(p_label);
+ item.xl_text = tr(p_label);
item.ID = p_ID;
item.submenu = p_submenu;
items.push_back(item);
@@ -546,7 +546,7 @@ void PopupMenu::add_icon_check_item(const Ref<Texture> &p_icon, const String &p_
Item item;
item.icon = p_icon;
item.text = p_label;
- item.xl_text = XL_MESSAGE(p_label);
+ item.xl_text = tr(p_label);
item.accel = p_accel;
item.ID = p_ID;
item.checkable = true;
@@ -557,7 +557,7 @@ void PopupMenu::add_check_item(const String &p_label, int p_ID, uint32_t p_accel
Item item;
item.text = p_label;
- item.xl_text = XL_MESSAGE(p_label);
+ item.xl_text = tr(p_label);
item.accel = p_accel;
item.ID = p_ID;
item.checkable = true;
@@ -628,7 +628,7 @@ void PopupMenu::set_item_text(int p_idx, const String &p_text) {
ERR_FAIL_INDEX(p_idx, items.size());
items[p_idx].text = p_text;
- items[p_idx].xl_text = XL_MESSAGE(p_text);
+ items[p_idx].xl_text = tr(p_text);
update();
}
diff --git a/scene/gui/scroll_bar.cpp b/scene/gui/scroll_bar.cpp
index 2ccdbb05a9..6519cde6d3 100644
--- a/scene/gui/scroll_bar.cpp
+++ b/scene/gui/scroll_bar.cpp
@@ -98,7 +98,18 @@ void ScrollBar::_gui_input(Ref<InputEvent> p_event) {
if (ofs < grabber_ofs) {
- set_value(get_value() - get_page());
+ if (scrolling) {
+ target_scroll = target_scroll - get_page();
+ } else {
+ target_scroll = get_value() - get_page();
+ }
+
+ if (smooth_scroll_enabled) {
+ scrolling = true;
+ set_fixed_process(true);
+ } else {
+ set_value(target_scroll);
+ }
return;
}
@@ -111,8 +122,18 @@ void ScrollBar::_gui_input(Ref<InputEvent> p_event) {
drag.value_at_click = get_as_ratio();
update();
} else {
+ if (scrolling) {
+ target_scroll = target_scroll + get_page();
+ } else {
+ target_scroll = get_value() + get_page();
+ }
- set_value(get_value() + get_page());
+ if (smooth_scroll_enabled) {
+ scrolling = true;
+ set_fixed_process(true);
+ } else {
+ set_value(target_scroll);
+ }
}
} else {
@@ -311,7 +332,22 @@ void ScrollBar::_notification(int p_what) {
if (p_what == NOTIFICATION_FIXED_PROCESS) {
- if (drag_slave_touching) {
+ if (scrolling) {
+ if (get_value() != target_scroll) {
+ double target = target_scroll - get_value();
+ double dist = sqrt(target * target);
+ double vel = ((target / dist) * 500) * get_fixed_process_delta_time();
+
+ if (vel >= dist) {
+ set_value(target_scroll);
+ } else {
+ set_value(get_value() + vel);
+ }
+ } else {
+ scrolling = false;
+ set_fixed_process(false);
+ }
+ } else if (drag_slave_touching) {
if (drag_slave_touching_deaccel) {
@@ -639,6 +675,14 @@ NodePath ScrollBar::get_drag_slave() const {
return drag_slave_path;
}
+void ScrollBar::set_smooth_scroll_enabled(bool p_enable) {
+ smooth_scroll_enabled = p_enable;
+}
+
+bool ScrollBar::is_smooth_scroll_enabled() const {
+ return smooth_scroll_enabled;
+}
+
#if 0
void ScrollBar::mouse_button(const Point2& p_pos, int b->get_button_index(),bool b->is_pressed(),int p_modifier_mask) {
@@ -795,6 +839,10 @@ ScrollBar::ScrollBar(Orientation p_orientation) {
drag_slave_touching = false;
drag_slave_touching_deaccel = false;
+ scrolling = false;
+ target_scroll = 0;
+ smooth_scroll_enabled = false;
+
if (focus_by_default)
set_focus_mode(FOCUS_ALL);
set_step(0);
diff --git a/scene/gui/scroll_bar.h b/scene/gui/scroll_bar.h
index 8310e12590..e22d4da46d 100644
--- a/scene/gui/scroll_bar.h
+++ b/scene/gui/scroll_bar.h
@@ -83,6 +83,10 @@ class ScrollBar : public Range {
bool drag_slave_touching_deaccel;
bool click_handled;
+ bool scrolling;
+ double target_scroll;
+ bool smooth_scroll_enabled;
+
void _drag_slave_exit();
void _drag_slave_input(const Ref<InputEvent> &p_input);
@@ -100,6 +104,9 @@ public:
void set_drag_slave(const NodePath &p_path);
NodePath get_drag_slave() const;
+ void set_smooth_scroll_enabled(bool p_enable);
+ bool is_smooth_scroll_enabled() const;
+
virtual Size2 get_minimum_size() const;
ScrollBar(Orientation p_orientation = VERTICAL);
~ScrollBar();
diff --git a/scene/gui/tab_container.cpp b/scene/gui/tab_container.cpp
index 1352569f33..d32b899de7 100644
--- a/scene/gui/tab_container.cpp
+++ b/scene/gui/tab_container.cpp
@@ -231,7 +231,7 @@ void TabContainer::_notification(int p_what) {
// Draw the tab contents.
Control *control = tabs[i + first_tab_cache]->cast_to<Control>();
- String text = control->has_meta("_tab_name") ? String(XL_MESSAGE(String(control->get_meta("_tab_name")))) : String(control->get_name());
+ String text = control->has_meta("_tab_name") ? String(tr(String(control->get_meta("_tab_name")))) : String(control->get_name());
int x_content = tab_rect.position.x + tab_style->get_margin(MARGIN_LEFT);
int top_margin = tab_style->get_margin(MARGIN_TOP);
@@ -299,7 +299,7 @@ int TabContainer::_get_tab_width(int p_index) const {
// Get the width of the text displayed on the tab.
Ref<Font> font = get_font("font");
- String text = control->has_meta("_tab_name") ? String(XL_MESSAGE(String(control->get_meta("_tab_name")))) : String(control->get_name());
+ String text = control->has_meta("_tab_name") ? String(tr(String(control->get_meta("_tab_name")))) : String(control->get_name());
int width = font->get_string_size(text).width;
// Add space for a tab icon.
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index 2b47539c42..650fdfbc5f 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -338,6 +338,11 @@ void TextEdit::_update_scrollbars() {
v_scroll->show();
v_scroll->set_max(total_rows);
v_scroll->set_page(visible_rows);
+ if (smooth_scroll_enabled) {
+ v_scroll->set_step(0.25);
+ } else {
+ v_scroll->set_step(1);
+ }
if (fabs(v_scroll->get_value() - (double)cursor.line_ofs) >= 1) {
v_scroll->set_value(cursor.line_ofs);
@@ -420,6 +425,24 @@ void TextEdit::_notification(int p_what) {
draw_caret = false;
update();
} break;
+ case NOTIFICATION_FIXED_PROCESS: {
+ if (scrolling && v_scroll->get_value() != target_v_scroll) {
+ double target_y = target_v_scroll - v_scroll->get_value();
+ double dist = sqrt(target_y * target_y);
+ double vel = ((target_y / dist) * 50) * get_fixed_process_delta_time();
+
+ if (vel >= dist) {
+ v_scroll->set_value(target_v_scroll);
+ scrolling = false;
+ set_fixed_process(false);
+ } else {
+ v_scroll->set_value(v_scroll->get_value() + vel);
+ }
+ } else {
+ scrolling = false;
+ set_fixed_process(false);
+ }
+ } break;
case NOTIFICATION_DRAW: {
if ((!has_focus() && !menu->has_focus()) || !window_has_focus) {
@@ -454,6 +477,7 @@ void TextEdit::_notification(int p_what) {
_update_scrollbars();
RID ci = get_canvas_item();
+ VisualServer::get_singleton()->canvas_item_set_clip(get_canvas_item(), true);
int xmargin_beg = cache.style_normal->get_margin(MARGIN_LEFT) + cache.line_number_w + cache.breakpoint_gutter_width;
int xmargin_end = cache.size.width - cache.style_normal->get_margin(MARGIN_RIGHT);
//let's do it easy for now:
@@ -674,7 +698,11 @@ void TextEdit::_notification(int p_what) {
int char_margin = xmargin_beg - cursor.x_ofs;
int char_ofs = 0;
- int ofs_y = i * get_row_height() + cache.line_spacing / 2;
+ int ofs_y = (i * get_row_height() + cache.line_spacing / 2);
+ if (smooth_scroll_enabled) {
+ ofs_y -= (v_scroll->get_value() - cursor.line_ofs) * get_row_height();
+ }
+
bool prev_is_char = false;
bool prev_is_number = false;
bool in_keyword = false;
@@ -1028,6 +1056,8 @@ void TextEdit::_notification(int p_what) {
if (cursor.column == j && cursor.line == line && block_caret && draw_caret && !insert_mode) {
color = cache.caret_background_color;
+ } else if (!syntax_coloring && block_caret) {
+ color = cache.font_color;
}
if (str[j] >= 32) {
@@ -1498,7 +1528,7 @@ void TextEdit::_get_mouse_pos(const Point2i &p_mouse, int &r_row, int &r_col) co
float rows = p_mouse.y;
rows -= cache.style_normal->get_margin(MARGIN_TOP);
rows /= get_row_height();
- int row = cursor.line_ofs + rows;
+ int row = cursor.line_ofs + (rows + (v_scroll->get_value() - cursor.line_ofs));
if (row < 0)
row = 0;
@@ -1564,10 +1594,43 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
if (mb->is_pressed()) {
if (mb->get_button_index() == BUTTON_WHEEL_UP && !mb->get_command()) {
- v_scroll->set_value(v_scroll->get_value() - (3 * mb->get_factor()));
+ if (scrolling) {
+ target_v_scroll = (target_v_scroll - (3 * mb->get_factor()));
+ } else {
+ target_v_scroll = (v_scroll->get_value() - (3 * mb->get_factor()));
+ }
+
+ if (smooth_scroll_enabled) {
+ if (target_v_scroll <= 0) {
+ target_v_scroll = 0;
+ }
+ scrolling = true;
+ set_fixed_process(true);
+ } else {
+ v_scroll->set_value(target_v_scroll);
+ }
}
if (mb->get_button_index() == BUTTON_WHEEL_DOWN && !mb->get_command()) {
- v_scroll->set_value(v_scroll->get_value() + (3 * mb->get_factor()));
+ if (scrolling) {
+ target_v_scroll = (target_v_scroll + (3 * mb->get_factor()));
+ } else {
+ target_v_scroll = (v_scroll->get_value() + (3 * mb->get_factor()));
+ }
+
+ if (smooth_scroll_enabled) {
+ int max_v_scroll = get_line_count() - 1;
+ if (!scroll_past_end_of_file_enabled) {
+ max_v_scroll -= get_visible_rows() - 1;
+ }
+
+ if (target_v_scroll > max_v_scroll) {
+ target_v_scroll = max_v_scroll;
+ }
+ scrolling = true;
+ set_fixed_process(true);
+ } else {
+ v_scroll->set_value(target_v_scroll);
+ }
}
if (mb->get_button_index() == BUTTON_WHEEL_LEFT) {
h_scroll->set_value(h_scroll->get_value() - (100 * mb->get_factor()));
@@ -2248,6 +2311,13 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
#endif
bool prev_char = false;
int cc = cursor.column;
+
+ if (cc == 0 && cursor.line > 0) {
+ cursor_set_line(cursor.line - 1);
+ cursor_set_column(text[cursor.line].length());
+ break;
+ }
+
while (cc > 0) {
bool ischar = _is_text_char(text[cursor.line][cc - 1]);
@@ -2305,6 +2375,13 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
#endif
bool prev_char = false;
int cc = cursor.column;
+
+ if (cc == text[cursor.line].length() && cursor.line < text.size() - 1) {
+ cursor_set_line(cursor.line + 1);
+ cursor_set_column(0);
+ break;
+ }
+
while (cc < text[cursor.line].length()) {
bool ischar = _is_text_char(text[cursor.line][cc]);
@@ -3076,7 +3153,7 @@ int TextEdit::get_visible_rows() const {
int total = cache.size.height;
total -= cache.style_normal->get_minimum_size().height;
total /= get_row_height();
- return total;
+ return total + 1;
}
void TextEdit::adjust_viewport_to_cursor() {
@@ -4178,6 +4255,15 @@ void TextEdit::set_h_scroll(int p_scroll) {
h_scroll->set_value(p_scroll);
}
+void TextEdit::set_smooth_scroll_enabled(bool p_enable) {
+ v_scroll->set_smooth_scroll_enabled(p_enable);
+ smooth_scroll_enabled = p_enable;
+}
+
+bool TextEdit::is_smooth_scroll_enabled() const {
+ return smooth_scroll_enabled;
+}
+
void TextEdit::set_completion(bool p_enabled, const Vector<String> &p_prefixes) {
completion_prefixes.clear();
@@ -4678,6 +4764,9 @@ void TextEdit::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_syntax_coloring", "enable"), &TextEdit::set_syntax_coloring);
ClassDB::bind_method(D_METHOD("is_syntax_coloring_enabled"), &TextEdit::is_syntax_coloring_enabled);
+ ClassDB::bind_method(D_METHOD("set_smooth_scroll_enable", "enable"), &TextEdit::set_smooth_scroll_enabled);
+ ClassDB::bind_method(D_METHOD("is_smooth_scroll_enabled"), &TextEdit::is_smooth_scroll_enabled);
+
ClassDB::bind_method(D_METHOD("add_keyword_color", "keyword", "color"), &TextEdit::add_keyword_color);
ClassDB::bind_method(D_METHOD("add_color_region", "begin_key", "end_key", "color", "line_only"), &TextEdit::add_color_region, DEFVAL(false));
ClassDB::bind_method(D_METHOD("clear_colors"), &TextEdit::clear_colors);
@@ -4687,6 +4776,7 @@ void TextEdit::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "syntax_highlighting"), "set_syntax_coloring", "is_syntax_coloring_enabled");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "show_line_numbers"), "set_show_line_numbers", "is_show_line_numbers_enabled");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "highlight_all_occurrences"), "set_highlight_all_occurrences", "is_highlight_all_occurrences_enabled");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "smooth_scrolling"), "set_smooth_scroll_enable", "is_smooth_scroll_enabled");
ADD_GROUP("Caret", "caret_");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "caret_block_mode"), "cursor_set_block_mode", "cursor_is_block_mode");
@@ -4823,6 +4913,9 @@ TextEdit::TextEdit() {
insert_mode = false;
window_has_focus = true;
select_identifiers_enabled = false;
+ smooth_scroll_enabled = false;
+ scrolling = false;
+ target_v_scroll = 0;
raised_from_completion = false;
diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h
index 4c17347a5d..c4e0700531 100644
--- a/scene/gui/text_edit.h
+++ b/scene/gui/text_edit.h
@@ -256,6 +256,10 @@ class TextEdit : public Control {
bool insert_mode;
bool select_identifiers_enabled;
+ bool smooth_scroll_enabled;
+ bool scrolling;
+ float target_v_scroll;
+
bool raised_from_completion;
String highlighted_word;
@@ -487,6 +491,9 @@ public:
int get_h_scroll() const;
void set_h_scroll(int p_scroll);
+ void set_smooth_scroll_enabled(bool p_enable);
+ bool is_smooth_scroll_enabled() const;
+
uint32_t get_version() const;
uint32_t get_saved_version() const;
void tag_saved_version();
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp
index fa499ff277..3e8d8aed8a 100644
--- a/scene/gui/tree.cpp
+++ b/scene/gui/tree.cpp
@@ -1455,7 +1455,7 @@ void Tree::select_single_item(TreeItem *p_selected, TreeItem *p_current, int p_c
if (select_mode == SELECT_ROW) {
- if (p_selected == p_current && !c.selected) {
+ if (p_selected == p_current && (!c.selected || allow_reselect)) {
c.selected = true;
selected_item = p_selected;
selected_col = 0;
@@ -1478,7 +1478,7 @@ void Tree::select_single_item(TreeItem *p_selected, TreeItem *p_current, int p_c
if (!r_in_range && &selected_cell == &c) {
- if (!selected_cell.selected || force_select_on_already_selected) {
+ if (!selected_cell.selected || allow_reselect) {
selected_cell.selected = true;
@@ -1743,7 +1743,7 @@ int Tree::propagate_mouse_event(const Point2i &p_pos, int x_ofs, int y_ofs, bool
/* editing */
- bool bring_up_editor = force_select_on_already_selected ? (c.selected && already_selected) : c.selected;
+ bool bring_up_editor = allow_reselect ? (c.selected && already_selected) : c.selected;
String editor_text = c.text;
switch (c.mode) {
@@ -3557,16 +3557,6 @@ int Tree::get_drop_mode_flags() const {
return drop_mode_flags;
}
-void Tree::set_single_select_cell_editing_only_when_already_selected(bool p_enable) {
-
- force_select_on_already_selected = p_enable;
-}
-
-bool Tree::get_single_select_cell_editing_only_when_already_selected() const {
-
- return force_select_on_already_selected;
-}
-
void Tree::set_edit_checkbox_cell_only_when_checkbox_is_pressed(bool p_enable) {
force_edit_checkbox_only_on_checkbox = p_enable;
@@ -3587,6 +3577,15 @@ bool Tree::get_allow_rmb_select() const {
return allow_rmb_select;
}
+void Tree::set_allow_reselect(bool p_allow) {
+ allow_reselect = p_allow;
+}
+
+bool Tree::get_allow_reselect() const {
+
+ return allow_reselect;
+}
+
void Tree::_bind_methods() {
ClassDB::bind_method(D_METHOD("_range_click_timeout"), &Tree::_range_click_timeout);
@@ -3640,8 +3639,8 @@ void Tree::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_allow_rmb_select", "allow"), &Tree::set_allow_rmb_select);
ClassDB::bind_method(D_METHOD("get_allow_rmb_select"), &Tree::get_allow_rmb_select);
- ClassDB::bind_method(D_METHOD("set_single_select_cell_editing_only_when_already_selected", "enable"), &Tree::set_single_select_cell_editing_only_when_already_selected);
- ClassDB::bind_method(D_METHOD("get_single_select_cell_editing_only_when_already_selected"), &Tree::get_single_select_cell_editing_only_when_already_selected);
+ ClassDB::bind_method(D_METHOD("set_allow_reselect", "allow"), &Tree::set_allow_reselect);
+ ClassDB::bind_method(D_METHOD("get_allow_reselect"), &Tree::get_allow_reselect);
ADD_SIGNAL(MethodInfo("item_selected"));
ADD_SIGNAL(MethodInfo("cell_selected"));
@@ -3751,7 +3750,6 @@ Tree::Tree() {
drop_mode_over = NULL;
drop_mode_section = 0;
single_select_defer = NULL;
- force_select_on_already_selected = false;
allow_rmb_select = false;
force_edit_checkbox_only_on_checkbox = false;
@@ -3760,6 +3758,8 @@ Tree::Tree() {
cache.hover_item = NULL;
cache.hover_cell = -1;
+
+ allow_reselect = false;
}
Tree::~Tree() {
diff --git a/scene/gui/tree.h b/scene/gui/tree.h
index 81880122a9..1e46956cd9 100644
--- a/scene/gui/tree.h
+++ b/scene/gui/tree.h
@@ -490,7 +490,8 @@ private:
bool allow_rmb_select;
bool scrolling;
- bool force_select_on_already_selected;
+ bool allow_reselect;
+
bool force_edit_checkbox_only_on_checkbox;
bool hide_folding;
@@ -566,15 +567,15 @@ public:
void set_drop_mode_flags(int p_flags);
int get_drop_mode_flags() const;
- void set_single_select_cell_editing_only_when_already_selected(bool p_enable);
- bool get_single_select_cell_editing_only_when_already_selected() const;
-
void set_edit_checkbox_cell_only_when_checkbox_is_pressed(bool p_enable);
bool get_edit_checkbox_cell_only_when_checkbox_is_pressed() const;
void set_allow_rmb_select(bool p_allow);
bool get_allow_rmb_select() const;
+ void set_allow_reselect(bool p_allow);
+ bool get_allow_reselect() const;
+
void set_value_evaluator(ValueEvaluator *p_evaluator);
Tree();
diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp
index 66eafa1070..2e67a1feaf 100644
--- a/scene/main/scene_tree.cpp
+++ b/scene/main/scene_tree.cpp
@@ -392,86 +392,11 @@ void SceneTree::input_event(const Ref<InputEvent> &p_event) {
Ref<InputEvent> ev = p_event;
ev->set_id(++last_id); //this should work better
-#if 0
- switch(ev.type) {
-
- case InputEvent::MOUSE_BUTTON: {
-
- Matrix32 ai = root->get_final_transform().affine_inverse();
- Vector2 g = ai.xform(Vector2(ev.mouse_button.global_x,ev.mouse_button.global_y));
- Vector2 l = ai.xform(Vector2(ev->get_pos().x,ev->get_pos().y));
- ev->get_pos().x=l.x;
- ev->get_pos().y=l.y;
- ev.mouse_button.global_x=g.x;
- ev.mouse_button.global_y=g.y;
-
- } break;
- case InputEvent::MOUSE_MOTION: {
-
- Matrix32 ai = root->get_final_transform().affine_inverse();
- Vector2 g = ai.xform(Vector2(ev.mouse_motion.global_x,ev.mouse_motion.global_y));
- Vector2 l = ai.xform(Vector2(ev.mouse_motion.x,ev.mouse_motion.y));
- Vector2 r = ai.xform(Vector2(ev->get_relative().x,ev->get_relative().y));
- ev.mouse_motion.x=l.x;
- ev.mouse_motion.y=l.y;
- ev.mouse_motion.global_x=g.x;
- ev.mouse_motion.global_y=g.y;
- ev->get_relative().x=r.x;
- ev->get_relative().y=r.y;
-
- } break;
- case InputEvent::SCREEN_TOUCH: {
-
- Matrix32 ai = root->get_final_transform().affine_inverse();
- Vector2 t = ai.xform(Vector2(ev.screen_touch.x,ev.screen_touch.y));
- ev.screen_touch.x=t.x;
- ev.screen_touch.y=t.y;
-
- } break;
- case InputEvent::SCREEN_DRAG: {
-
- Matrix32 ai = root->get_final_transform().affine_inverse();
- Vector2 t = ai.xform(Vector2(ev.screen_drag.x,ev.screen_drag.y));
- Vector2 r = ai.xform(Vector2(ev.screen_drag.relative_x,ev.screen_drag.relative_y));
- Vector2 s = ai.xform(Vector2(ev.screen_drag.speed_x,ev.screen_drag.speed_y));
- ev.screen_drag.x=t.x;
- ev.screen_drag.y=t.y;
- ev.screen_drag.relative_x=r.x;
- ev.screen_drag.relative_y=r.y;
- ev.screen_drag.speed_x=s.x;
- ev.screen_drag.speed_y=s.y;
- } break;
- }
-
-#endif
MainLoop::input_event(ev);
-#if 0
- _call_input_pause("input","_input",ev);
-
- call_group(GROUP_CALL_REVERSE|GROUP_CALL_REALTIME|GROUP_CALL_MULIILEVEL,"_gui_input","_gui_input",p_event); //special one for GUI, as controls use their own process check
-
- //call_group(GROUP_CALL_REVERSE|GROUP_CALL_REALTIME|GROUP_CALL_MULIILEVEL,"input","_input",ev);
-
- /*
- if (ev.type==InputEvent::KEY && ev->is_pressed() && !ev->is_echo() && ev->get_scancode()==KEY_F12) {
-
- print_line("RAM: "+itos(Memory::get_static_mem_usage()));
- print_line("DRAM: "+itos(Memory::get_dynamic_mem_usage()));
- }
- if (ev.type==InputEvent::KEY && ev->is_pressed() && !ev->is_echo() && ev->get_scancode()==KEY_F11) {
-
- Memory::dump_static_mem_to_file("memdump.txt");
- }
- */
-
- //transform for the rest
-#else
call_group_flags(GROUP_CALL_REALTIME, "_viewports", "_vp_input", ev); //special one for GUI, as controls use their own process check
-#endif
-
if (ScriptDebugger::get_singleton() && ScriptDebugger::get_singleton()->is_remote()) {
//quit from game window using F8
Ref<InputEventKey> k = ev;
@@ -482,7 +407,7 @@ void SceneTree::input_event(const Ref<InputEvent> &p_event) {
_flush_ugc();
root_lock--;
- MessageQueue::get_singleton()->flush(); //small little hack
+ //MessageQueue::get_singleton()->flush(); //flushing here causes UI and other places slowness
root_lock++;
@@ -503,7 +428,7 @@ void SceneTree::input_event(const Ref<InputEvent> &p_event) {
input_handled = true;
_flush_ugc();
root_lock--;
- MessageQueue::get_singleton()->flush(); //small little hack
+ //MessageQueue::get_singleton()->flush(); //flushing here causes UI and other places slowness
} else {
input_handled = true;
root_lock--;
diff --git a/scene/resources/dynamic_font.cpp b/scene/resources/dynamic_font.cpp
index fc0d80a9b7..e424ee48a8 100644
--- a/scene/resources/dynamic_font.cpp
+++ b/scene/resources/dynamic_font.cpp
@@ -524,7 +524,7 @@ void DynamicFontAtSize::_update_char(CharType p_char) {
if (mh > texsize)
texsize = mh; //special case, adapt to it?
- texsize = nearest_power_of_2(texsize);
+ texsize = next_power_of_2(texsize);
texsize = MIN(texsize, 4096);
diff --git a/scene/resources/dynamic_font_stb.cpp b/scene/resources/dynamic_font_stb.cpp
index 8efad94b9a..fa8cf4723b 100644
--- a/scene/resources/dynamic_font_stb.cpp
+++ b/scene/resources/dynamic_font_stb.cpp
@@ -289,7 +289,7 @@ void DynamicFontAtSize::_update_char(CharType p_char) {
if (mh > texsize)
texsize = mh; //special case, adapt to it?
- texsize = nearest_power_of_2(texsize);
+ texsize = next_power_of_2(texsize);
texsize = MIN(texsize, 4096);
diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp
index bc23a41ede..a111f64e06 100644
--- a/scene/resources/material.cpp
+++ b/scene/resources/material.cpp
@@ -1384,7 +1384,7 @@ static Plane _get_texture_mask(SpatialMaterial::TextureChannel p_channel) {
}
void SpatialMaterial::set_metallic_texture_channel(TextureChannel p_channel) {
-
+ ERR_FAIL_INDEX(p_channel, 5);
metallic_texture_channel = p_channel;
VS::get_singleton()->material_set_param(_get_material(), shader_names->metallic_texture_channel, _get_texture_mask(p_channel));
}
@@ -1395,6 +1395,7 @@ SpatialMaterial::TextureChannel SpatialMaterial::get_metallic_texture_channel()
void SpatialMaterial::set_roughness_texture_channel(TextureChannel p_channel) {
+ ERR_FAIL_INDEX(p_channel, 5);
roughness_texture_channel = p_channel;
VS::get_singleton()->material_set_param(_get_material(), shader_names->roughness_texture_channel, _get_texture_mask(p_channel));
}
diff --git a/scene/resources/packed_scene.cpp b/scene/resources/packed_scene.cpp
index 169c956546..4dfc23fa67 100644
--- a/scene/resources/packed_scene.cpp
+++ b/scene/resources/packed_scene.cpp
@@ -242,7 +242,8 @@ Node *SceneState::instance(GenEditState p_edit_state) const {
value = local_dupe;
}
- res->setup_local_to_scene();
+ //this here may reference nodes not iniialized so this line is commented and used after loading all nodes
+ //res->setup_local_to_scene();
}
//must make a copy, because this res is local to scene
}
@@ -293,6 +294,11 @@ Node *SceneState::instance(GenEditState p_edit_state) const {
}
}
+ for (Map<Ref<Resource>, Ref<Resource> >::Element *E = resources_local_to_scene.front(); E; E = E->next()) {
+
+ E->get()->setup_local_to_scene();
+ }
+
//do connections
int cc = connections.size();
diff --git a/scene/resources/sky_box.cpp b/scene/resources/sky_box.cpp
index 5750960845..cc3cfe4dc0 100644
--- a/scene/resources/sky_box.cpp
+++ b/scene/resources/sky_box.cpp
@@ -128,7 +128,7 @@ void ProceduralSky::_radiance_changed() {
VS::get_singleton()->sky_set_texture(sky, texture, size[get_radiance_size()]);
}
-void ProceduralSky::_update_sky() {
+Ref<Image> ProceduralSky::_generate_sky() {
update_queued = false;
@@ -215,9 +215,7 @@ void ProceduralSky::_update_sky() {
image.instance();
image->create(w, h, false, Image::FORMAT_RGBE9995, imgdata);
- VS::get_singleton()->texture_allocate(texture, w, h, Image::FORMAT_RGBE9995, VS::TEXTURE_FLAG_FILTER | VS::TEXTURE_FLAG_REPEAT);
- VS::get_singleton()->texture_set_data(texture, image);
- _radiance_changed();
+ return image;
}
void ProceduralSky::set_sky_top_color(const Color &p_sky_top) {
@@ -385,6 +383,33 @@ RID ProceduralSky::get_rid() const {
return sky;
}
+void ProceduralSky::_update_sky() {
+
+ bool use_thread = true;
+ if (first_time) {
+ use_thread = false;
+ first_time = false;
+ }
+#ifdef NO_THREADS
+ use_thread = false;
+#endif
+ if (use_thread) {
+
+ if (!sky_thread) {
+ sky_thread = Thread::create(_thread_function, this);
+ regen_queued = false;
+ } else {
+ regen_queued = true;
+ }
+
+ } else {
+ Ref<Image> image = _generate_sky();
+ VS::get_singleton()->texture_allocate(texture, image->get_width(), image->get_height(), Image::FORMAT_RGBE9995, VS::TEXTURE_FLAG_FILTER | VS::TEXTURE_FLAG_REPEAT);
+ VS::get_singleton()->texture_set_data(texture, image);
+ _radiance_changed();
+ }
+}
+
void ProceduralSky::_queue_update() {
if (update_queued)
@@ -394,6 +419,26 @@ void ProceduralSky::_queue_update() {
call_deferred("_update_sky");
}
+void ProceduralSky::_thread_done(const Ref<Image> &image) {
+
+ VS::get_singleton()->texture_allocate(texture, image->get_width(), image->get_height(), Image::FORMAT_RGBE9995, VS::TEXTURE_FLAG_FILTER | VS::TEXTURE_FLAG_REPEAT);
+ VS::get_singleton()->texture_set_data(texture, image);
+ _radiance_changed();
+ Thread::wait_to_finish(sky_thread);
+ memdelete(sky_thread);
+ sky_thread = NULL;
+ if (regen_queued) {
+ sky_thread = Thread::create(_thread_function, this);
+ regen_queued = false;
+ }
+}
+
+void ProceduralSky::_thread_function(void *p_ud) {
+
+ ProceduralSky *psky = (ProceduralSky *)p_ud;
+ psky->call_deferred("_thread_done", psky->_generate_sky());
+}
+
void ProceduralSky::_bind_methods() {
ClassDB::bind_method(D_METHOD("_update_sky"), &ProceduralSky::_update_sky);
@@ -446,6 +491,8 @@ void ProceduralSky::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_texture_size", "size"), &ProceduralSky::set_texture_size);
ClassDB::bind_method(D_METHOD("get_texture_size"), &ProceduralSky::get_texture_size);
+ ClassDB::bind_method(D_METHOD("_thread_done", "image"), &ProceduralSky::_thread_done);
+
ADD_GROUP("Sky", "sky_");
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "sky_top_color"), "set_sky_top_color", "get_sky_top_color");
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "sky_horizon_color"), "set_sky_horizon_color", "get_sky_horizon_color");
@@ -503,12 +550,20 @@ ProceduralSky::ProceduralSky() {
sun_energy = 16;
texture_size = TEXTURE_SIZE_1024;
+ sky_thread = NULL;
+ regen_queued = false;
+ first_time = true;
_queue_update();
}
ProceduralSky::~ProceduralSky() {
+ if (sky_thread) {
+ Thread::wait_to_finish(sky_thread);
+ memdelete(sky_thread);
+ sky_thread = NULL;
+ }
VS::get_singleton()->free(sky);
VS::get_singleton()->free(texture);
}
diff --git a/scene/resources/sky_box.h b/scene/resources/sky_box.h
index 8298d1b3c0..9bd60cddaf 100644
--- a/scene/resources/sky_box.h
+++ b/scene/resources/sky_box.h
@@ -30,8 +30,8 @@
#ifndef Sky_H
#define Sky_H
+#include "os/thread.h"
#include "scene/resources/texture.h"
-
class Sky : public Resource {
GDCLASS(Sky, Resource);
@@ -97,6 +97,7 @@ public:
};
private:
+ Thread *sky_thread;
Color sky_top_color;
Color sky_horizon_color;
float sky_curve;
@@ -121,12 +122,20 @@ private:
RID texture;
bool update_queued;
+ bool regen_queued;
+
+ bool first_time;
+
+ void _thread_done(const Ref<Image> &p_image);
+ static void _thread_function(void *p_ud);
protected:
static void _bind_methods();
virtual void _radiance_changed();
+ Ref<Image> _generate_sky();
void _update_sky();
+
void _queue_update();
public:
diff --git a/scene/resources/style_box.cpp b/scene/resources/style_box.cpp
index 48efa242e9..d6a730647f 100644
--- a/scene/resources/style_box.cpp
+++ b/scene/resources/style_box.cpp
@@ -463,7 +463,7 @@ bool StyleBoxFlat::is_anti_aliased() const {
}
void StyleBoxFlat::set_aa_size(const int &p_aa_size) {
- aa_size = p_aa_size;
+ aa_size = CLAMP(p_aa_size, 1, 5);
emit_changed();
}
int StyleBoxFlat::get_aa_size() const {
@@ -471,7 +471,7 @@ int StyleBoxFlat::get_aa_size() const {
}
void StyleBoxFlat::set_corner_detail(const int &p_corner_detail) {
- corner_detail = p_corner_detail;
+ corner_detail = CLAMP(p_corner_detail, 1, 128);
emit_changed();
}
int StyleBoxFlat::get_corner_detail() const {
@@ -514,6 +514,7 @@ inline void draw_ring(Vector<Vector2> &verts, Vector<int> &indices, Vector<Color
if (!vert_offset) {
vert_offset = 0;
}
+ int adapted_corner_detail = (corner_radius[0] == 0 && corner_radius[1] == 0 && corner_radius[2] == 0 && corner_radius[3] == 0) ? 1 : corner_detail;
int rings = (border_width[0] == 0 && border_width[1] == 0 && border_width[2] == 0 && border_width[3] == 0) ? 1 : 2;
rings = 2;
@@ -540,7 +541,7 @@ inline void draw_ring(Vector<Vector2> &verts, Vector<int> &indices, Vector<Color
//calculate the vert array
for (int corner_index = 0; corner_index < 4; corner_index++) {
- for (int detail = 0; detail <= corner_detail; detail++) {
+ for (int detail = 0; detail <= adapted_corner_detail; detail++) {
for (int inner_outer = (2 - rings); inner_outer < 2; inner_outer++) {
float radius;
Color color;
@@ -554,8 +555,8 @@ inline void draw_ring(Vector<Vector2> &verts, Vector<int> &indices, Vector<Color
color = *outer_color;
corner_point = outer_points[corner_index];
}
- float x = radius * (float)cos((double)corner_index * Math_PI / 2.0 + (double)detail / (double)corner_detail * Math_PI / 2.0 + Math_PI) + corner_point.x;
- float y = radius * (float)sin((double)corner_index * Math_PI / 2.0 + (double)detail / (double)corner_detail * Math_PI / 2.0 + Math_PI) + corner_point.y;
+ float x = radius * (float)cos((double)corner_index * Math_PI / 2.0 + (double)detail / (double)adapted_corner_detail * Math_PI / 2.0 + Math_PI) + corner_point.x;
+ float y = radius * (float)sin((double)corner_index * Math_PI / 2.0 + (double)detail / (double)adapted_corner_detail * Math_PI / 2.0 + Math_PI) + corner_point.y;
verts.push_back(Vector2(x, y));
colors.push_back(color);
}
@@ -563,7 +564,7 @@ inline void draw_ring(Vector<Vector2> &verts, Vector<int> &indices, Vector<Color
}
if (rings == 2) {
- int vert_count = (corner_detail + 1) * 4 * rings;
+ int vert_count = (adapted_corner_detail + 1) * 4 * rings;
//fill the indices and the colors for the border
for (int i = 0; i < vert_count; i++) {
//poly 1
@@ -717,7 +718,7 @@ void StyleBoxFlat::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_bg_color"), &StyleBoxFlat::get_bg_color);
ClassDB::bind_method(D_METHOD("set_border_color", "color"), &StyleBoxFlat::set_border_color_all);
- ClassDB::bind_method(D_METHOD("get_border_color", "color"), &StyleBoxFlat::get_border_color_all);
+ ClassDB::bind_method(D_METHOD("get_border_color"), &StyleBoxFlat::get_border_color_all);
ClassDB::bind_method(D_METHOD("set_border_width_all", "width"), &StyleBoxFlat::set_border_width_all);
ClassDB::bind_method(D_METHOD("get_border_width_min"), &StyleBoxFlat::get_border_width_min);
@@ -776,7 +777,7 @@ void StyleBoxFlat::_bind_methods() {
ADD_PROPERTYI(PropertyInfo(Variant::INT, "corner_radius_bottom_right", PROPERTY_HINT_RANGE, "0,1024,1"), "set_corner_radius", "get_corner_radius", CORNER_BOTTOM_RIGHT);
ADD_PROPERTYI(PropertyInfo(Variant::INT, "corner_radius_bottom_left", PROPERTY_HINT_RANGE, "0,1024,1"), "set_corner_radius", "get_corner_radius", CORNER_BOTTOM_LEFT);
- ADD_PROPERTY(PropertyInfo(Variant::INT, "corner_detail"), "set_corner_detail", "get_corner_detail");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "corner_detail", PROPERTY_HINT_RANGE, "1,128,1"), "set_corner_detail", "get_corner_detail");
ADD_GROUP("Expand Margin", "expand_margin_");
ADD_PROPERTYI(PropertyInfo(Variant::REAL, "expand_margin_left", PROPERTY_HINT_RANGE, "0,2048,1"), "set_expand_margin", "get_expand_margin", MARGIN_LEFT);
diff --git a/servers/audio/audio_driver_dummy.cpp b/servers/audio/audio_driver_dummy.cpp
index 0f15b43b41..dfb6406b38 100644
--- a/servers/audio/audio_driver_dummy.cpp
+++ b/servers/audio/audio_driver_dummy.cpp
@@ -45,7 +45,7 @@ Error AudioDriverDummy::init() {
channels = 2;
int latency = GLOBAL_DEF("audio/output_latency", 25);
- buffer_size = nearest_power_of_2(latency * mix_rate / 1000);
+ buffer_size = next_power_of_2(latency * mix_rate / 1000);
samples_in = memnew_arr(int32_t, buffer_size * channels);
diff --git a/servers/audio_server.cpp b/servers/audio_server.cpp
index 3547f86eb3..f9fdd9432d 100644
--- a/servers/audio_server.cpp
+++ b/servers/audio_server.cpp
@@ -159,6 +159,8 @@ void AudioServer::_driver_process(int p_frames, int32_t *p_buffer) {
void AudioServer::_mix_step() {
+ bool solo_mode = false;
+
for (int i = 0; i < buses.size(); i++) {
Bus *bus = buses[i];
bus->index_cache = i; //might be moved around by editor, so..
@@ -166,6 +168,33 @@ void AudioServer::_mix_step() {
bus->channels[k].used = false;
}
+
+ if (bus->solo) {
+ //solo chain
+ solo_mode = true;
+ bus->soloed = true;
+ do {
+
+ if (bus != buses[0]) {
+ //everything has a send save for master bus
+ if (!bus_map.has(bus->send)) {
+ bus = buses[0]; //send to master
+ } else {
+ bus = bus_map[bus->send];
+ if (bus->index_cache >= bus->index_cache) { //invalid, send to master
+ bus = buses[0];
+ }
+ }
+
+ bus->soloed = true;
+ } else {
+ bus = NULL;
+ }
+
+ } while (bus);
+ } else {
+ bus->soloed = false;
+ }
}
//make callbacks for mixing the audio
@@ -192,24 +221,26 @@ void AudioServer::_mix_step() {
}
//process effects
- for (int j = 0; j < bus->effects.size(); j++) {
+ if (!bus->bypass) {
+ for (int j = 0; j < bus->effects.size(); j++) {
- if (!bus->effects[j].enabled)
- continue;
+ if (!bus->effects[j].enabled)
+ continue;
- for (int k = 0; k < bus->channels.size(); k++) {
+ for (int k = 0; k < bus->channels.size(); k++) {
- if (!bus->channels[k].active)
- continue;
- bus->channels[k].effect_instances[j]->process(bus->channels[k].buffer.ptr(), temp_buffer[k].ptr(), buffer_size);
- }
+ if (!bus->channels[k].active)
+ continue;
+ bus->channels[k].effect_instances[j]->process(bus->channels[k].buffer.ptr(), temp_buffer[k].ptr(), buffer_size);
+ }
- //swap buffers, so internal buffer always has the right data
- for (int k = 0; k < bus->channels.size(); k++) {
+ //swap buffers, so internal buffer always has the right data
+ for (int k = 0; k < bus->channels.size(); k++) {
- if (!buses[i]->channels[k].active)
- continue;
- SWAP(bus->channels[k].buffer, temp_buffer[k]);
+ if (!buses[i]->channels[k].active)
+ continue;
+ SWAP(bus->channels[k].buffer, temp_buffer[k]);
+ }
}
}
@@ -237,7 +268,24 @@ void AudioServer::_mix_step() {
AudioFrame *buf = bus->channels[k].buffer.ptr();
AudioFrame peak = AudioFrame(0, 0);
+
+ float volume = Math::db2linear(bus->volume_db);
+
+ if (solo_mode) {
+ if (!bus->soloed) {
+ volume = 0.0;
+ }
+ } else {
+ if (bus->mute) {
+ volume = 0.0;
+ }
+ }
+
+ //apply volume and compute peak
for (uint32_t j = 0; j < buffer_size; j++) {
+
+ buf[j] *= volume;
+
float l = ABS(buf[j].l);
if (l > peak.l) {
peak.l = l;
diff --git a/servers/audio_server.h b/servers/audio_server.h
index caa07891f7..c92ff6d3a0 100644
--- a/servers/audio_server.h
+++ b/servers/audio_server.h
@@ -125,6 +125,8 @@ private:
bool mute;
bool bypass;
+ bool soloed;
+
//Each channel is a stereo pair.
struct Channel {
bool used;
diff --git a/servers/visual/rasterizer.h b/servers/visual/rasterizer.h
index 9405f6e012..3b4ba313e6 100644
--- a/servers/visual/rasterizer.h
+++ b/servers/visual/rasterizer.h
@@ -331,6 +331,7 @@ public:
virtual void light_set_projector(RID p_light, RID p_texture) = 0;
virtual void light_set_negative(RID p_light, bool p_enable) = 0;
virtual void light_set_cull_mask(RID p_light, uint32_t p_mask) = 0;
+ virtual void light_set_reverse_cull_face_mode(RID p_light, bool p_enabled) = 0;
virtual void light_omni_set_shadow_mode(RID p_light, VS::LightOmniShadowMode p_mode) = 0;
virtual void light_omni_set_shadow_detail(RID p_light, VS::LightOmniShadowDetail p_detail) = 0;
@@ -712,6 +713,7 @@ public:
RID texture;
RID normal_map;
int count;
+ bool antialiased;
CommandPolygon() {
type = TYPE_POLYGON;
diff --git a/servers/visual/visual_server_canvas.cpp b/servers/visual/visual_server_canvas.cpp
index dcc16794e7..13517fa409 100644
--- a/servers/visual/visual_server_canvas.cpp
+++ b/servers/visual/visual_server_canvas.cpp
@@ -632,7 +632,7 @@ void VisualServerCanvas::canvas_item_add_primitive(RID p_item, const Vector<Poin
canvas_item->commands.push_back(prim);
}
-void VisualServerCanvas::canvas_item_add_polygon(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, RID p_texture, RID p_normal_map) {
+void VisualServerCanvas::canvas_item_add_polygon(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, RID p_texture, RID p_normal_map, bool p_antialiased) {
Item *canvas_item = canvas_item_owner.getornull(p_item);
ERR_FAIL_COND(!canvas_item);
@@ -661,6 +661,7 @@ void VisualServerCanvas::canvas_item_add_polygon(RID p_item, const Vector<Point2
polygon->colors = p_colors;
polygon->indices = indices;
polygon->count = indices.size();
+ polygon->antialiased = p_antialiased;
canvas_item->rect_dirty = true;
canvas_item->commands.push_back(polygon);
@@ -745,6 +746,7 @@ void VisualServerCanvas::canvas_item_add_particles(RID p_item, RID p_particles,
//take the chance and request processing for them, at least once until they become visible again
VSG::storage->particles_request_process(p_particles);
+ canvas_item->rect_dirty = true;
canvas_item->commands.push_back(part);
}
@@ -758,6 +760,7 @@ void VisualServerCanvas::canvas_item_add_multimesh(RID p_item, RID p_mesh, RID p
mm->multimesh = p_mesh;
mm->skeleton = p_skeleton;
+ canvas_item->rect_dirty = true;
canvas_item->commands.push_back(mm);
}
@@ -1001,11 +1004,11 @@ void VisualServerCanvas::canvas_light_set_shadow_buffer_size(RID p_light, int p_
RasterizerCanvas::Light *clight = canvas_light_owner.get(p_light);
ERR_FAIL_COND(!clight);
- int new_size = nearest_power_of_2(p_size);
+ int new_size = next_power_of_2(p_size);
if (new_size == clight->shadow_buffer_size)
return;
- clight->shadow_buffer_size = nearest_power_of_2(p_size);
+ clight->shadow_buffer_size = next_power_of_2(p_size);
if (clight->shadow_buffer.is_valid()) {
VSG::storage->free(clight->shadow_buffer);
diff --git a/servers/visual/visual_server_canvas.h b/servers/visual/visual_server_canvas.h
index 25d4973cb7..b9ad88286d 100644
--- a/servers/visual/visual_server_canvas.h
+++ b/servers/visual/visual_server_canvas.h
@@ -178,7 +178,7 @@ public:
void canvas_item_add_texture_rect_region(RID p_item, const Rect2 &p_rect, RID p_texture, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, RID p_normal_map = RID(), bool p_clip_uv = true);
void canvas_item_add_nine_patch(RID p_item, const Rect2 &p_rect, const Rect2 &p_source, RID p_texture, const Vector2 &p_topleft, const Vector2 &p_bottomright, VS::NinePatchAxisMode p_x_axis_mode = VS::NINE_PATCH_STRETCH, VS::NinePatchAxisMode p_y_axis_mode = VS::NINE_PATCH_STRETCH, bool p_draw_center = true, const Color &p_modulate = Color(1, 1, 1), RID p_normal_map = RID());
void canvas_item_add_primitive(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, RID p_texture, float p_width = 1.0, RID p_normal_map = RID());
- void canvas_item_add_polygon(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs = Vector<Point2>(), RID p_texture = RID(), RID p_normal_map = RID());
+ void canvas_item_add_polygon(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs = Vector<Point2>(), RID p_texture = RID(), RID p_normal_map = RID(), bool p_antialiased = false);
void canvas_item_add_triangle_array(RID p_item, const Vector<int> &p_indices, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs = Vector<Point2>(), RID p_texture = RID(), int p_count = -1, RID p_normal_map = RID());
void canvas_item_add_mesh(RID p_item, const RID &p_mesh, RID p_skeleton = RID());
void canvas_item_add_multimesh(RID p_item, RID p_mesh, RID p_skeleton = RID());
diff --git a/servers/visual/visual_server_raster.cpp b/servers/visual/visual_server_raster.cpp
index 4f16ae4125..e66c8a1e21 100644
--- a/servers/visual/visual_server_raster.cpp
+++ b/servers/visual/visual_server_raster.cpp
@@ -4376,7 +4376,7 @@ void VisualServerRaster::canvas_light_set_shadow_buffer_size(RID p_light, int p_
ERR_FAIL_COND(p_size<32 || p_size>16384);
- clight->shadow_buffer_size=nearest_power_of_2(p_size);
+ clight->shadow_buffer_size=next_power_of_2(p_size);
if (clight->shadow_buffer.is_valid()) {
diff --git a/servers/visual/visual_server_raster.h b/servers/visual/visual_server_raster.h
index 596dd5c10e..fff37a71b3 100644
--- a/servers/visual/visual_server_raster.h
+++ b/servers/visual/visual_server_raster.h
@@ -786,6 +786,7 @@ public:
BIND2(light_set_projector, RID, RID)
BIND2(light_set_negative, RID, bool)
BIND2(light_set_cull_mask, RID, uint32_t)
+ BIND2(light_set_reverse_cull_face_mode, RID, bool)
BIND2(light_omni_set_shadow_mode, RID, LightOmniShadowMode)
BIND2(light_omni_set_shadow_detail, RID, LightOmniShadowDetail)
@@ -1059,7 +1060,7 @@ public:
BIND8(canvas_item_add_texture_rect_region, RID, const Rect2 &, RID, const Rect2 &, const Color &, bool, RID, bool)
BIND11(canvas_item_add_nine_patch, RID, const Rect2 &, const Rect2 &, RID, const Vector2 &, const Vector2 &, NinePatchAxisMode, NinePatchAxisMode, bool, const Color &, RID)
BIND7(canvas_item_add_primitive, RID, const Vector<Point2> &, const Vector<Color> &, const Vector<Point2> &, RID, float, RID)
- BIND6(canvas_item_add_polygon, RID, const Vector<Point2> &, const Vector<Color> &, const Vector<Point2> &, RID, RID)
+ BIND7(canvas_item_add_polygon, RID, const Vector<Point2> &, const Vector<Color> &, const Vector<Point2> &, RID, RID, bool)
BIND8(canvas_item_add_triangle_array, RID, const Vector<int> &, const Vector<Point2> &, const Vector<Color> &, const Vector<Point2> &, RID, int, RID)
BIND3(canvas_item_add_mesh, RID, const RID &, RID)
BIND3(canvas_item_add_multimesh, RID, RID, RID)
diff --git a/servers/visual/visual_server_scene.cpp b/servers/visual/visual_server_scene.cpp
index 5faf0e67ca..fb298e3ed7 100644
--- a/servers/visual/visual_server_scene.cpp
+++ b/servers/visual/visual_server_scene.cpp
@@ -978,16 +978,6 @@ void VisualServerScene::instance_geometry_set_flag(RID p_instance, VS::InstanceF
switch (p_flags) {
- case VS::INSTANCE_FLAG_CAST_SHADOW: {
- if (p_enabled == true) {
- instance->cast_shadows = VS::SHADOW_CASTING_SETTING_ON;
- } else {
- instance->cast_shadows = VS::SHADOW_CASTING_SETTING_OFF;
- }
-
- instance->base_material_changed(); // to actually compute if shadows are visible or not
-
- } break;
case VS::INSTANCE_FLAG_VISIBLE_IN_ALL_ROOMS: {
instance->visible_in_all_rooms = p_enabled;
@@ -1001,6 +991,12 @@ void VisualServerScene::instance_geometry_set_flag(RID p_instance, VS::InstanceF
}
}
void VisualServerScene::instance_geometry_set_cast_shadows_setting(RID p_instance, VS::ShadowCastingSetting p_shadow_casting_setting) {
+
+ Instance *instance = instance_owner.get(p_instance);
+ ERR_FAIL_COND(!instance);
+
+ instance->cast_shadows = p_shadow_casting_setting;
+ instance->base_material_changed(); // to actually compute if shadows are visible or not
}
void VisualServerScene::instance_geometry_set_material_override(RID p_instance, RID p_material) {
@@ -1048,8 +1044,9 @@ void VisualServerScene::_update_instance(Instance *p_instance) {
VSG::storage->particles_set_emission_transform(p_instance->base, p_instance->transform);
}
- if (p_instance->aabb.has_no_surface())
+ if (p_instance->aabb.has_no_surface()) {
return;
+ }
#if 0
if (p_instance->base_type == VS::INSTANCE_PARTICLES) {
@@ -3278,8 +3275,9 @@ void VisualServerScene::render_probes() {
void VisualServerScene::_update_dirty_instance(Instance *p_instance) {
- if (p_instance->update_aabb)
+ if (p_instance->update_aabb) {
_update_instance_aabb(p_instance);
+ }
if (p_instance->update_materials) {
diff --git a/servers/visual/visual_server_wrap_mt.h b/servers/visual/visual_server_wrap_mt.h
index 20223f9651..ca040e9355 100644
--- a/servers/visual/visual_server_wrap_mt.h
+++ b/servers/visual/visual_server_wrap_mt.h
@@ -225,6 +225,7 @@ public:
FUNC2(light_set_projector, RID, RID)
FUNC2(light_set_negative, RID, bool)
FUNC2(light_set_cull_mask, RID, uint32_t)
+ FUNC2(light_set_reverse_cull_face_mode, RID, bool)
FUNC2(light_omni_set_shadow_mode, RID, LightOmniShadowMode)
FUNC2(light_omni_set_shadow_detail, RID, LightOmniShadowDetail)
@@ -482,7 +483,7 @@ public:
FUNC8(canvas_item_add_texture_rect_region, RID, const Rect2 &, RID, const Rect2 &, const Color &, bool, RID, bool)
FUNC11(canvas_item_add_nine_patch, RID, const Rect2 &, const Rect2 &, RID, const Vector2 &, const Vector2 &, NinePatchAxisMode, NinePatchAxisMode, bool, const Color &, RID)
FUNC7(canvas_item_add_primitive, RID, const Vector<Point2> &, const Vector<Color> &, const Vector<Point2> &, RID, float, RID)
- FUNC6(canvas_item_add_polygon, RID, const Vector<Point2> &, const Vector<Color> &, const Vector<Point2> &, RID, RID)
+ FUNC7(canvas_item_add_polygon, RID, const Vector<Point2> &, const Vector<Color> &, const Vector<Point2> &, RID, RID, bool)
FUNC8(canvas_item_add_triangle_array, RID, const Vector<int> &, const Vector<Point2> &, const Vector<Color> &, const Vector<Point2> &, RID, int, RID)
FUNC3(canvas_item_add_mesh, RID, const RID &, RID)
FUNC3(canvas_item_add_multimesh, RID, RID, RID)
diff --git a/servers/visual_server.cpp b/servers/visual_server.cpp
index 65dd4d7661..cb1f96c23f 100644
--- a/servers/visual_server.cpp
+++ b/servers/visual_server.cpp
@@ -298,6 +298,9 @@ RID VisualServer::get_white_texture() {
return white_texture;
}
+#define SMALL_VEC2 Vector2(0.00001, 0.00001)
+#define SMALL_VEC3 Vector3(0.00001, 0.00001, 0.00001)
+
Error VisualServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint32_t *p_offsets, uint32_t p_stride, PoolVector<uint8_t> &r_vertex_array, int p_vertex_array_len, PoolVector<uint8_t> &r_index_array, int p_index_array_len, Rect3 &r_aabb, Vector<Rect3> r_bone_aabb) {
PoolVector<uint8_t>::Write vw = r_vertex_array.write();
@@ -339,7 +342,7 @@ Error VisualServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint32_
if (i == 0) {
- aabb = Rect2(src[i], Vector2());
+ aabb = Rect2(src[i], SMALL_VEC2); //must have a bit of size
} else {
aabb.expand_to(src[i]);
@@ -355,7 +358,7 @@ Error VisualServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint32_
if (i == 0) {
- aabb = Rect2(src[i], Vector2());
+ aabb = Rect2(src[i], SMALL_VEC2); //must have a bit of size
} else {
aabb.expand_to(src[i]);
@@ -385,7 +388,7 @@ Error VisualServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint32_
if (i == 0) {
- aabb = Rect3(src[i], Vector3());
+ aabb = Rect3(src[i], SMALL_VEC3);
} else {
aabb.expand_to(src[i]);
@@ -401,7 +404,7 @@ Error VisualServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint32_
if (i == 0) {
- aabb = Rect3(src[i], Vector3());
+ aabb = Rect3(src[i], SMALL_VEC3);
} else {
aabb.expand_to(src[i]);
@@ -733,8 +736,7 @@ Error VisualServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint32_
if (bptr->size.x < 0) {
//first
- bptr[idx] = Rect3();
- bptr[idx].position = v;
+ bptr[idx] = Rect3(v, SMALL_VEC3);
any_valid = true;
} else {
bptr[idx].expand_to(v);
diff --git a/servers/visual_server.h b/servers/visual_server.h
index ddf32a9ea1..5e0a390a21 100644
--- a/servers/visual_server.h
+++ b/servers/visual_server.h
@@ -371,6 +371,7 @@ public:
virtual void light_set_projector(RID p_light, RID p_texture) = 0;
virtual void light_set_negative(RID p_light, bool p_enable) = 0;
virtual void light_set_cull_mask(RID p_light, uint32_t p_mask) = 0;
+ virtual void light_set_reverse_cull_face_mode(RID p_light, bool p_enabled) = 0;
// omni light
enum LightOmniShadowMode {
@@ -743,7 +744,6 @@ public:
virtual Vector<ObjectID> instances_cull_convex(const Vector<Plane> &p_convex, RID p_scenario = RID()) const = 0;
enum InstanceFlags {
- INSTANCE_FLAG_CAST_SHADOW,
INSTANCE_FLAG_VISIBLE_IN_ALL_ROOMS,
INSTANCE_FLAG_USE_BAKED_LIGHT,
INSTANCE_FLAG_MAX
@@ -798,7 +798,7 @@ public:
virtual void canvas_item_add_texture_rect_region(RID p_item, const Rect2 &p_rect, RID p_texture, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, RID p_normal_map = RID(), bool p_clip_uv = true) = 0;
virtual void canvas_item_add_nine_patch(RID p_item, const Rect2 &p_rect, const Rect2 &p_source, RID p_texture, const Vector2 &p_topleft, const Vector2 &p_bottomright, NinePatchAxisMode p_x_axis_mode = NINE_PATCH_STRETCH, NinePatchAxisMode p_y_axis_mode = NINE_PATCH_STRETCH, bool p_draw_center = true, const Color &p_modulate = Color(1, 1, 1), RID p_normal_map = RID()) = 0;
virtual void canvas_item_add_primitive(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, RID p_texture, float p_width = 1.0, RID p_normal_map = RID()) = 0;
- virtual void canvas_item_add_polygon(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs = Vector<Point2>(), RID p_texture = RID(), RID p_normal_map = RID()) = 0;
+ virtual void canvas_item_add_polygon(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs = Vector<Point2>(), RID p_texture = RID(), RID p_normal_map = RID(), bool p_antialiased = false) = 0;
virtual void canvas_item_add_triangle_array(RID p_item, const Vector<int> &p_indices, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs = Vector<Point2>(), RID p_texture = RID(), int p_count = -1, RID p_normal_map = RID()) = 0;
virtual void canvas_item_add_mesh(RID p_item, const RID &p_mesh, RID p_skeleton = RID()) = 0;
virtual void canvas_item_add_multimesh(RID p_item, RID p_mesh, RID p_skeleton = RID()) = 0;
diff --git a/thirdparty/README.md b/thirdparty/README.md
index 4ed17168e8..804395f8d3 100644
--- a/thirdparty/README.md
+++ b/thirdparty/README.md
@@ -180,7 +180,8 @@ Files extracted from the upstream source:
- contrib/minizip/{crypt.h,ioapi.{c,h},zip.{c,h},unzip.{c,h}}
Important: Some files have Godot-made changes for use in core/io.
-TODO: Properly sync with version 1.2.4 and document changes.
+They are marked with `/* GODOT start */` and `/* GODOT end */`
+comments and a patch is provided in the minizip/ folder.
## misc
diff --git a/thirdparty/minizip/LICENSE-InfoZip.txt b/thirdparty/minizip/LICENSE-InfoZip.txt
deleted file mode 100644
index bcfe47e978..0000000000
--- a/thirdparty/minizip/LICENSE-InfoZip.txt
+++ /dev/null
@@ -1,60 +0,0 @@
-This is version 2007-Mar-4 of the Info-ZIP license.
-The definitive version of this document should be available at
-ftp://ftp.info-zip.org/pub/infozip/license.html indefinitely and
-a copy at http://www.info-zip.org/pub/infozip/license.html.
-
-
-Copyright (c) 1990-2007 Info-ZIP. All rights reserved.
-
-For the purposes of this copyright and license, "Info-ZIP" is defined as
-the following set of individuals:
-
- Mark Adler, John Bush, Karl Davis, Harald Denker, Jean-Michel Dubois,
- Jean-loup Gailly, Hunter Goatley, Ed Gordon, Ian Gorman, Chris Herborth,
- Dirk Haase, Greg Hartwig, Robert Heath, Jonathan Hudson, Paul Kienitz,
- David Kirschbaum, Johnny Lee, Onno van der Linden, Igor Mandrichenko,
- Steve P. Miller, Sergio Monesi, Keith Owens, George Petrov, Greg Roelofs,
- Kai Uwe Rommel, Steve Salisbury, Dave Smith, Steven M. Schweda,
- Christian Spieler, Cosmin Truta, Antoine Verheijen, Paul von Behren,
- Rich Wales, Mike White.
-
-This software is provided "as is," without warranty of any kind, express
-or implied. In no event shall Info-ZIP or its contributors be held liable
-for any direct, indirect, incidental, special or consequential damages
-arising out of the use of or inability to use this software.
-
-Permission is granted to anyone to use this software for any purpose,
-including commercial applications, and to alter it and redistribute it
-freely, subject to the above disclaimer and the following restrictions:
-
- 1. Redistributions of source code (in whole or in part) must retain
- the above copyright notice, definition, disclaimer, and this list
- of conditions.
-
- 2. Redistributions in binary form (compiled executables and libraries)
- must reproduce the above copyright notice, definition, disclaimer,
- and this list of conditions in documentation and/or other materials
- provided with the distribution. The sole exception to this condition
- is redistribution of a standard UnZipSFX binary (including SFXWiz) as
- part of a self-extracting archive; that is permitted without inclusion
- of this license, as long as the normal SFX banner has not been removed
- from the binary or disabled.
-
- 3. Altered versions--including, but not limited to, ports to new operating
- systems, existing ports with new graphical interfaces, versions with
- modified or added functionality, and dynamic, shared, or static library
- versions not from Info-ZIP--must be plainly marked as such and must not
- be misrepresented as being the original source or, if binaries,
- compiled from the original source. Such altered versions also must not
- be misrepresented as being Info-ZIP releases--including, but not
- limited to, labeling of the altered versions with the names "Info-ZIP"
- (or any variation thereof, including, but not limited to, different
- capitalizations), "Pocket UnZip," "WiZ" or "MacZip" without the
- explicit permission of Info-ZIP. Such altered versions are further
- prohibited from misrepresentative use of the Zip-Bugs or Info-ZIP
- e-mail addresses or the Info-ZIP URL(s), such as to imply Info-ZIP
- will provide support for the altered versions.
-
- 4. Info-ZIP retains the right to use the names "Info-ZIP," "Zip," "UnZip,"
- "UnZipSFX," "WiZ," "Pocket UnZip," "Pocket Zip," and "MacZip" for its
- own source and binary releases.
diff --git a/thirdparty/minizip/LICENSE-MiniZip.txt b/thirdparty/minizip/LICENSE-MiniZip.txt
deleted file mode 100644
index 0e8950f86f..0000000000
--- a/thirdparty/minizip/LICENSE-MiniZip.txt
+++ /dev/null
@@ -1,32 +0,0 @@
-Credits
-
- Gilles Vollant - Original MiniZip author
- Even Rouault - ZIP64 unzip Support
- Daniel Borca - BZip Compression method support in unzip
- Mathias Svensson - ZIP64 zip support
- Mathias Svensson - BZip Compression method support in zip
-
- This version has been modified for Godot Engine
-
-
-License
-----------------------------------------------------------------------------
- Condition of use and distribution are the same than zlib :
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-
-----------------------------------------------------------------------------
diff --git a/thirdparty/minizip/MiniZip_info.txt b/thirdparty/minizip/MiniZip_info.txt
new file mode 100644
index 0000000000..57d7152420
--- /dev/null
+++ b/thirdparty/minizip/MiniZip_info.txt
@@ -0,0 +1,74 @@
+MiniZip - Copyright (c) 1998-2010 - by Gilles Vollant - version 1.1 64 bits from Mathias Svensson
+
+Introduction
+---------------------
+MiniZip 1.1 is built from MiniZip 1.0 by Gilles Vollant ( http://www.winimage.com/zLibDll/minizip.html )
+
+When adding ZIP64 support into minizip it would result into risk of breaking compatibility with minizip 1.0.
+All possible work was done for compatibility.
+
+
+Background
+---------------------
+When adding ZIP64 support Mathias Svensson found that Even Rouault have added ZIP64
+support for unzip.c into minizip for a open source project called gdal ( http://www.gdal.org/ )
+
+That was used as a starting point. And after that ZIP64 support was added to zip.c
+some refactoring and code cleanup was also done.
+
+
+Changed from MiniZip 1.0 to MiniZip 1.1
+---------------------------------------
+* Added ZIP64 support for unzip ( by Even Rouault )
+* Added ZIP64 support for zip ( by Mathias Svensson )
+* Reverted some changed that Even Rouault did.
+* Bunch of patches received from Gulles Vollant that he received for MiniZip from various users.
+* Added unzip patch for BZIP Compression method (patch create by Daniel Borca)
+* Added BZIP Compress method for zip
+* Did some refactoring and code cleanup
+
+
+Credits
+
+ Gilles Vollant - Original MiniZip author
+ Even Rouault - ZIP64 unzip Support
+ Daniel Borca - BZip Compression method support in unzip
+ Mathias Svensson - ZIP64 zip support
+ Mathias Svensson - BZip Compression method support in zip
+
+ Resources
+
+ ZipLayout http://result42.com/projects/ZipFileLayout
+ Command line tool for Windows that shows the layout and information of the headers in a zip archive.
+ Used when debugging and validating the creation of zip files using MiniZip64
+
+
+ ZIP App Note http://www.pkware.com/documents/casestudies/APPNOTE.TXT
+ Zip File specification
+
+
+Notes.
+ * To be able to use BZip compression method in zip64.c or unzip64.c the BZIP2 lib is needed and HAVE_BZIP2 need to be defined.
+
+License
+----------------------------------------------------------
+ Condition of use and distribution are the same than zlib :
+
+ This software is provided 'as-is', without any express or implied
+ warranty. In no event will the authors be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+ 3. This notice may not be removed or altered from any source distribution.
+
+----------------------------------------------------------
+
diff --git a/thirdparty/minizip/godot-zlib-1.2.4-minizip-seek.patch b/thirdparty/minizip/godot-zlib-1.2.4-minizip-seek.patch
new file mode 100644
index 0000000000..8e66416a43
--- /dev/null
+++ b/thirdparty/minizip/godot-zlib-1.2.4-minizip-seek.patch
@@ -0,0 +1,295 @@
+diff --git a/thirdparty/minizip/ioapi.c b/thirdparty/minizip/ioapi.c
+index 49958f61f..0afbdc06a 100644
+--- a/thirdparty/minizip/ioapi.c
++++ b/thirdparty/minizip/ioapi.c
+@@ -68,8 +68,15 @@ void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filef
+ p_filefunc64_32->zfile_func64.opaque = p_filefunc32->opaque;
+ p_filefunc64_32->zseek32_file = p_filefunc32->zseek_file;
+ p_filefunc64_32->ztell32_file = p_filefunc32->ztell_file;
++ /* GODOT start */
++ p_filefunc64_32->zfile_func64.alloc_mem = p_filefunc32->alloc_mem;
++ p_filefunc64_32->zfile_func64.free_mem = p_filefunc32->free_mem;
++ /* GODOT end */
+ }
+
++/* GODOT start */
++/*
++// GODOT end
+
+
+ static voidpf ZCALLBACK fopen_file_func OF((voidpf opaque, const char* filename, int mode));
+@@ -233,3 +240,6 @@ void fill_fopen64_filefunc (zlib_filefunc64_def* pzlib_filefunc_def)
+ pzlib_filefunc_def->zerror_file = ferror_file_func;
+ pzlib_filefunc_def->opaque = NULL;
+ }
++// GODOT start
++*/
++/* GODOT end */
+diff --git a/thirdparty/minizip/ioapi.h b/thirdparty/minizip/ioapi.h
+index 8309c4cf8..f25ab6464 100644
+--- a/thirdparty/minizip/ioapi.h
++++ b/thirdparty/minizip/ioapi.h
+@@ -145,6 +145,10 @@ typedef struct zlib_filefunc_def_s
+ close_file_func zclose_file;
+ testerror_file_func zerror_file;
+ voidpf opaque;
++ /* GODOT start */
++ alloc_func alloc_mem;
++ free_func free_mem;
++ /* GODOT end */
+ } zlib_filefunc_def;
+
+ typedef ZPOS64_T (ZCALLBACK *tell64_file_func) OF((voidpf opaque, voidpf stream));
+@@ -161,6 +165,10 @@ typedef struct zlib_filefunc64_def_s
+ close_file_func zclose_file;
+ testerror_file_func zerror_file;
+ voidpf opaque;
++ /* GODOT start */
++ alloc_func alloc_mem;
++ free_func free_mem;
++ /* GODOT end */
+ } zlib_filefunc64_def;
+
+ void fill_fopen64_filefunc OF((zlib_filefunc64_def* pzlib_filefunc_def));
+diff --git a/thirdparty/minizip/unzip.c b/thirdparty/minizip/unzip.c
+index 7617f41f1..32e27bd65 100644
+--- a/thirdparty/minizip/unzip.c
++++ b/thirdparty/minizip/unzip.c
+@@ -157,6 +157,9 @@ typedef struct
+ uLong compression_method; /* compression method (0==store) */
+ ZPOS64_T byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/
+ int raw;
++ /* GODOT start */
++ int extra_size;
++ /* GODOT end */
+ } file_in_zip64_read_info_s;
+
+
+@@ -606,9 +609,10 @@ local unzFile unzOpenInternal (const void *path,
+ us.z_filefunc.zseek32_file = NULL;
+ us.z_filefunc.ztell32_file = NULL;
+ if (pzlib_filefunc64_32_def==NULL)
+- fill_fopen64_filefunc(&us.z_filefunc.zfile_func64);
+- else
+- us.z_filefunc = *pzlib_filefunc64_32_def;
++ /* GODOT start */
++ return NULL; // standard i/o not supported
++ us.z_filefunc = *pzlib_filefunc64_32_def;
++ /* GODOT end */
+ us.is64bitOpenFunction = is64bitOpenFunction;
+
+
+@@ -800,6 +804,18 @@ extern unzFile ZEXPORT unzOpen64 (const void *path)
+ return unzOpenInternal(path, NULL, 1);
+ }
+
++/* GODOT start */
++extern void* unzGetOpaque(unzFile file) {
++
++ unz64_s* s;
++ if (file==NULL)
++ return NULL;
++ s=(unz64_s*)file;
++
++ return s->z_filefunc.zfile_func64.opaque;
++};
++/* GODOT end */
++
+ /*
+ Close a ZipFile opened with unzipOpen.
+ If there is files inside the .Zip opened with unzipOpenCurrentFile (see later),
+@@ -1018,10 +1034,20 @@ local int unz64local_GetCurrentFileInfoInternal (unzFile file,
+
+ if (lSeek!=0)
+ {
+- if (ZSEEK64(s->z_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0)
+- lSeek=0;
+- else
+- err=UNZ_ERRNO;
++ /* GODOT start */
++ if (lSeek<0) {
++ // WORKAROUND for backwards seeking
++ z_off_t pos = ZTELL64(s->z_filefunc, s->filestream);
++ if (ZSEEK64(s->z_filefunc, s->filestream,pos+lSeek,ZLIB_FILEFUNC_SEEK_SET)==0)
++ lSeek=0;
++ else
++ err=UNZ_ERRNO;
++ } else {
++ if (ZSEEK64(s->z_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0)
++ lSeek=0;
++ else
++ err=UNZ_ERRNO;
++ }
+ }
+
+ while(acc < file_info.size_file_extra)
+@@ -1575,8 +1601,10 @@ extern int ZEXPORT unzOpenCurrentFile3 (unzFile file, int* method,
+ }
+ else if ((s->cur_file_info.compression_method==Z_DEFLATED) && (!raw))
+ {
+- pfile_in_zip_read_info->stream.zalloc = (alloc_func)0;
+- pfile_in_zip_read_info->stream.zfree = (free_func)0;
++ /* GODOT start */
++ pfile_in_zip_read_info->stream.zalloc = s->z_filefunc.zfile_func64.alloc_mem;
++ pfile_in_zip_read_info->stream.zfree = s->z_filefunc.zfile_func64.free_mem;
++ /* GODOT end */
+ pfile_in_zip_read_info->stream.opaque = (voidpf)0;
+ pfile_in_zip_read_info->stream.next_in = 0;
+ pfile_in_zip_read_info->stream.avail_in = 0;
+@@ -1608,6 +1636,9 @@ extern int ZEXPORT unzOpenCurrentFile3 (unzFile file, int* method,
+ iSizeVar;
+
+ pfile_in_zip_read_info->stream.avail_in = (uInt)0;
++ /* GODOT start */
++ pfile_in_zip_read_info->extra_size = iSizeVar;
++ /* GODOT end */
+
+ s->pfile_in_zip_read = pfile_in_zip_read_info;
+ s->encrypted = 0;
+@@ -1638,6 +1669,85 @@ extern int ZEXPORT unzOpenCurrentFile3 (unzFile file, int* method,
+ return UNZ_OK;
+ }
+
++/* GODOT start */
++extern int ZEXPORT unzSeekCurrentFile(unzFile file, int pos) {
++
++ unz64_s* s;
++ file_in_zip64_read_info_s* pfile_in_zip_read_info;
++ if (file==NULL)
++ return UNZ_PARAMERROR;
++ s=(unz64_s*)file;
++ pfile_in_zip_read_info=s->pfile_in_zip_read;
++
++ if (pfile_in_zip_read_info==NULL)
++ return UNZ_PARAMERROR;
++
++ if (pfile_in_zip_read_info->compression_method==Z_BZIP2ED) { // don't know how to support bzip
++ return UNZ_INTERNALERROR;
++ };
++
++ if ((pfile_in_zip_read_info->compression_method==0) || (pfile_in_zip_read_info->raw)) {
++
++ pfile_in_zip_read_info->rest_read_compressed =
++ s->cur_file_info.compressed_size - pos;
++ pfile_in_zip_read_info->rest_read_uncompressed =
++ s->cur_file_info.uncompressed_size - pos;
++
++ pfile_in_zip_read_info->pos_in_zipfile =
++ s->cur_file_info_internal.offset_curfile + SIZEZIPLOCALHEADER +
++ pfile_in_zip_read_info->extra_size + pos;
++
++ pfile_in_zip_read_info->stream.avail_in = (uInt)0;
++ pfile_in_zip_read_info->stream.total_out = pos;
++
++ return ZSEEK64(pfile_in_zip_read_info->z_filefunc,
++ pfile_in_zip_read_info->filestream,
++ pfile_in_zip_read_info->byte_before_the_zipfile + pfile_in_zip_read_info->pos_in_zipfile,
++ ZLIB_FILEFUNC_SEEK_SET);
++
++ } else { // gzip
++
++ if (pos < pfile_in_zip_read_info->stream.total_out) { // negative seek, rewind
++
++ pfile_in_zip_read_info->rest_read_compressed =
++ s->cur_file_info.compressed_size ;
++ pfile_in_zip_read_info->rest_read_uncompressed =
++ s->cur_file_info.uncompressed_size ;
++
++ pfile_in_zip_read_info->pos_in_zipfile =
++ s->cur_file_info_internal.offset_curfile + SIZEZIPLOCALHEADER +
++ pfile_in_zip_read_info->extra_size;
++
++ (void)inflateReset(&pfile_in_zip_read_info->stream);
++
++ pfile_in_zip_read_info->stream.avail_in = (uInt)0;
++ pfile_in_zip_read_info->stream.total_out = 0;
++ pfile_in_zip_read_info->stream.next_in = 0;
++ };
++
++ // not sure where to read, so read on the stack
++ {
++ char buf[512];
++ int to_read = pos - pfile_in_zip_read_info->stream.total_out;
++ while (to_read) {
++
++ int len = to_read > sizeof(buf)?sizeof(buf):to_read;
++ int read = unzReadCurrentFile(file, buf, len);
++ if (read < 0) {
++ return read;
++ };
++ to_read -= read;
++ if (read == UNZ_EOF) {
++ return pos;
++ };
++ };
++ };
++ };
++
++ return pos;
++};
++/* GODOT end */
++
+ extern int ZEXPORT unzOpenCurrentFile (unzFile file)
+ {
+ return unzOpenCurrentFile3(file, NULL, NULL, 0, NULL);
+diff --git a/thirdparty/minizip/unzip.h b/thirdparty/minizip/unzip.h
+index 3183968b7..54e65ad8a 100644
+--- a/thirdparty/minizip/unzip.h
++++ b/thirdparty/minizip/unzip.h
+@@ -202,6 +202,10 @@ extern int ZEXPORT unzClose OF((unzFile file));
+ these files MUST be closed with unzipCloseCurrentFile before call unzipClose.
+ return UNZ_OK if there is no problem. */
+
++/* GODOT start */
++extern void* unzGetOpaque(unzFile file);
++/* GODOT end */
++
+ extern int ZEXPORT unzGetGlobalInfo OF((unzFile file,
+ unz_global_info *pglobal_info));
+
+@@ -390,6 +394,13 @@ extern int ZEXPORT unzReadCurrentFile OF((unzFile file,
+ (UNZ_ERRNO for IO error, or zLib error for uncompress error)
+ */
+
++/* GODOT start */
++extern int ZEXPORT unzSeekCurrentFile(unzFile file, int pos);
++/*
++ Seek to position in uncompressed data
++*/
++/* GODOT end */
++
+ extern z_off_t ZEXPORT unztell OF((unzFile file));
+
+ extern ZPOS64_T ZEXPORT unztell64 OF((unzFile file));
+diff --git a/thirdparty/minizip/zip.c b/thirdparty/minizip/zip.c
+index 3c34fc8bd..d7093e745 100644
+--- a/thirdparty/minizip/zip.c
++++ b/thirdparty/minizip/zip.c
+@@ -854,9 +854,11 @@ extern zipFile ZEXPORT zipOpen3 (const void *pathname, int append, zipcharpc* gl
+
+ ziinit.z_filefunc.zseek32_file = NULL;
+ ziinit.z_filefunc.ztell32_file = NULL;
+- if (pzlib_filefunc64_32_def==NULL)
+- fill_fopen64_filefunc(&ziinit.z_filefunc.zfile_func64);
+- else
++ /* GODOT start */
++ if (pzlib_filefunc64_32_def==NULL) {
++ //fill_fopen64_filefunc(&ziinit.z_filefunc.zfile_func64);
++ } else
++ /* GODOT end */
+ ziinit.z_filefunc = *pzlib_filefunc64_32_def;
+
+ ziinit.filestream = ZOPEN64(ziinit.z_filefunc,
+@@ -1210,8 +1212,10 @@ extern int ZEXPORT zipOpenNewFileInZip4_64 (zipFile file, const char* filename,
+ {
+ if(zi->ci.method == Z_DEFLATED)
+ {
+- zi->ci.stream.zalloc = (alloc_func)0;
+- zi->ci.stream.zfree = (free_func)0;
++ /* GODOT start */
++ zi->ci.stream.zalloc = zi->z_filefunc.zfile_func64.alloc_mem;
++ zi->ci.stream.zfree = zi->z_filefunc.zfile_func64.free_mem;
++ /* GODOT end */
+ zi->ci.stream.opaque = (voidpf)0;
+
+ if (windowBits>0)
diff --git a/thirdparty/minizip/ioapi.c b/thirdparty/minizip/ioapi.c
index d6063a5fe6..2b42df4abd 100644
--- a/thirdparty/minizip/ioapi.c
+++ b/thirdparty/minizip/ioapi.c
@@ -6,7 +6,7 @@
Modifications for Zip64 support
Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
- For more info read LICENSE-MiniZip.txt
+ For more info read MiniZip_info.txt
*/
@@ -68,11 +68,15 @@ void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filef
p_filefunc64_32->zfile_func64.opaque = p_filefunc32->opaque;
p_filefunc64_32->zseek32_file = p_filefunc32->zseek_file;
p_filefunc64_32->ztell32_file = p_filefunc32->ztell_file;
+ /* GODOT start */
p_filefunc64_32->zfile_func64.alloc_mem = p_filefunc32->alloc_mem;
p_filefunc64_32->zfile_func64.free_mem = p_filefunc32->free_mem;
+ /* GODOT end */
}
+/* GODOT start */
/*
+// GODOT end
static voidpf ZCALLBACK fopen_file_func OF((voidpf opaque, const char* filename, int mode));
@@ -119,6 +123,7 @@ static voidpf ZCALLBACK fopen64_file_func (voidpf opaque, const void* filename,
return file;
}
+
static uLong ZCALLBACK fread_file_func (voidpf opaque, voidpf stream, void* buf, uLong size)
{
uLong ret;
@@ -140,6 +145,7 @@ static long ZCALLBACK ftell_file_func (voidpf opaque, voidpf stream)
return ret;
}
+
static ZPOS64_T ZCALLBACK ftell64_file_func (voidpf opaque, voidpf stream)
{
ZPOS64_T ret;
@@ -234,4 +240,6 @@ void fill_fopen64_filefunc (zlib_filefunc64_def* pzlib_filefunc_def)
pzlib_filefunc_def->zerror_file = ferror_file_func;
pzlib_filefunc_def->opaque = NULL;
}
+// GODOT start
*/
+/* GODOT end */
diff --git a/thirdparty/minizip/ioapi.h b/thirdparty/minizip/ioapi.h
index cb6cb7e766..f25ab6464f 100644
--- a/thirdparty/minizip/ioapi.h
+++ b/thirdparty/minizip/ioapi.h
@@ -1,11 +1,12 @@
-/* this file is part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
+/* ioapi.h -- IO base function header for compress/uncompress .zip
+ part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )
Modifications for Zip64 support
Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
- For more info read LICENSE-MiniZip.txt
+ For more info read MiniZip_info.txt
Changes
@@ -40,6 +41,7 @@
#endif
#include <stdio.h>
+#include <stdlib.h>
#include "zlib.h"
#if defined(USE_FILE32API)
@@ -122,14 +124,14 @@ extern "C" {
-typedef voidpf (ZCALLBACK *open_file_func) (voidpf opaque, const char* filename, int mode);
-typedef uLong (ZCALLBACK *read_file_func) (voidpf opaque, voidpf stream, void* buf, uLong size);
-typedef uLong (ZCALLBACK *write_file_func) (voidpf opaque, voidpf stream, const void* buf, uLong size);
-typedef int (ZCALLBACK *close_file_func) (voidpf opaque, voidpf stream);
-typedef int (ZCALLBACK *testerror_file_func) (voidpf opaque, voidpf stream);
+typedef voidpf (ZCALLBACK *open_file_func) OF((voidpf opaque, const char* filename, int mode));
+typedef uLong (ZCALLBACK *read_file_func) OF((voidpf opaque, voidpf stream, void* buf, uLong size));
+typedef uLong (ZCALLBACK *write_file_func) OF((voidpf opaque, voidpf stream, const void* buf, uLong size));
+typedef int (ZCALLBACK *close_file_func) OF((voidpf opaque, voidpf stream));
+typedef int (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf stream));
-typedef long (ZCALLBACK *tell_file_func) (voidpf opaque, voidpf stream);
-typedef long (ZCALLBACK *seek_file_func) (voidpf opaque, voidpf stream, uLong offset, int origin);
+typedef long (ZCALLBACK *tell_file_func) OF((voidpf opaque, voidpf stream));
+typedef long (ZCALLBACK *seek_file_func) OF((voidpf opaque, voidpf stream, uLong offset, int origin));
/* here is the "old" 32 bits structure structure */
@@ -143,13 +145,15 @@ typedef struct zlib_filefunc_def_s
close_file_func zclose_file;
testerror_file_func zerror_file;
voidpf opaque;
- alloc_func alloc_mem;
- free_func free_mem;
+ /* GODOT start */
+ alloc_func alloc_mem;
+ free_func free_mem;
+ /* GODOT end */
} zlib_filefunc_def;
-typedef ZPOS64_T (ZCALLBACK *tell64_file_func) (voidpf opaque, voidpf stream);
-typedef long (ZCALLBACK *seek64_file_func) (voidpf opaque, voidpf stream, ZPOS64_T offset, int origin);
-typedef voidpf (ZCALLBACK *open64_file_func) (voidpf opaque, const void* filename, int mode);
+typedef ZPOS64_T (ZCALLBACK *tell64_file_func) OF((voidpf opaque, voidpf stream));
+typedef long (ZCALLBACK *seek64_file_func) OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin));
+typedef voidpf (ZCALLBACK *open64_file_func) OF((voidpf opaque, const void* filename, int mode));
typedef struct zlib_filefunc64_def_s
{
@@ -161,13 +165,14 @@ typedef struct zlib_filefunc64_def_s
close_file_func zclose_file;
testerror_file_func zerror_file;
voidpf opaque;
- alloc_func alloc_mem;
- free_func free_mem;
-
+ /* GODOT start */
+ alloc_func alloc_mem;
+ free_func free_mem;
+ /* GODOT end */
} zlib_filefunc64_def;
-void fill_fopen64_filefunc (zlib_filefunc64_def* pzlib_filefunc_def);
-void fill_fopen_filefunc (zlib_filefunc_def* pzlib_filefunc_def);
+void fill_fopen64_filefunc OF((zlib_filefunc64_def* pzlib_filefunc_def));
+void fill_fopen_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def));
/* now internal definition, only for zip.c and unzip.h */
typedef struct zlib_filefunc64_32_def_s
@@ -186,9 +191,9 @@ typedef struct zlib_filefunc64_32_def_s
#define ZCLOSE64(filefunc,filestream) ((*((filefunc).zfile_func64.zclose_file)) ((filefunc).zfile_func64.opaque,filestream))
#define ZERROR64(filefunc,filestream) ((*((filefunc).zfile_func64.zerror_file)) ((filefunc).zfile_func64.opaque,filestream))
-voidpf call_zopen64 (const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode);
-long call_zseek64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin);
-ZPOS64_T call_ztell64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream);
+voidpf call_zopen64 OF((const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode));
+long call_zseek64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin));
+ZPOS64_T call_ztell64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf filestream));
void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filefunc64_32,const zlib_filefunc_def* p_filefunc32);
diff --git a/thirdparty/minizip/unzip.c b/thirdparty/minizip/unzip.c
index 7aa0a86d13..32e27bd657 100644
--- a/thirdparty/minizip/unzip.c
+++ b/thirdparty/minizip/unzip.c
@@ -10,7 +10,7 @@
Modifications for Zip64 support on both zip and unzip
Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
- For more info read LICENSE-MiniZip.txt
+ For more info read MiniZip_info.txt
------------------------------------------------------------------------------------
@@ -157,7 +157,9 @@ typedef struct
uLong compression_method; /* compression method (0==store) */
ZPOS64_T byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/
int raw;
- int extra_size;
+ /* GODOT start */
+ int extra_size;
+ /* GODOT end */
} file_in_zip64_read_info_s;
@@ -205,10 +207,10 @@ typedef struct
*/
-local int unz64local_getByte (
+local int unz64local_getByte OF((
const zlib_filefunc64_32_def* pzlib_filefunc_def,
voidpf filestream,
- int *pi);
+ int *pi));
local int unz64local_getByte(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, int *pi)
{
@@ -232,10 +234,10 @@ local int unz64local_getByte(const zlib_filefunc64_32_def* pzlib_filefunc_def, v
/* ===========================================================================
Reads a long in LSB order from the given gz_stream. Sets
*/
-local int unz64local_getShort (
+local int unz64local_getShort OF((
const zlib_filefunc64_32_def* pzlib_filefunc_def,
voidpf filestream,
- uLong *pX);
+ uLong *pX));
local int unz64local_getShort (const zlib_filefunc64_32_def* pzlib_filefunc_def,
voidpf filestream,
@@ -259,10 +261,10 @@ local int unz64local_getShort (const zlib_filefunc64_32_def* pzlib_filefunc_def,
return err;
}
-local int unz64local_getLong (
+local int unz64local_getLong OF((
const zlib_filefunc64_32_def* pzlib_filefunc_def,
voidpf filestream,
- uLong *pX);
+ uLong *pX));
local int unz64local_getLong (const zlib_filefunc64_32_def* pzlib_filefunc_def,
voidpf filestream,
@@ -294,10 +296,10 @@ local int unz64local_getLong (const zlib_filefunc64_32_def* pzlib_filefunc_def,
return err;
}
-local int unz64local_getLong64 (
+local int unz64local_getLong64 OF((
const zlib_filefunc64_32_def* pzlib_filefunc_def,
voidpf filestream,
- ZPOS64_T *pX);
+ ZPOS64_T *pX));
local int unz64local_getLong64 (const zlib_filefunc64_32_def* pzlib_filefunc_def,
@@ -410,7 +412,7 @@ extern int ZEXPORT unzStringFileNameCompare (const char* fileName1,
Locate the Central directory of a zipfile (at the end, just before
the global comment)
*/
-local ZPOS64_T unz64local_SearchCentralDir (const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream);
+local ZPOS64_T unz64local_SearchCentralDir OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream));
local ZPOS64_T unz64local_SearchCentralDir(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream)
{
unsigned char* buf;
@@ -472,9 +474,9 @@ local ZPOS64_T unz64local_SearchCentralDir(const zlib_filefunc64_32_def* pzlib_f
Locate the Central directory 64 of a zipfile (at the end, just before
the global comment)
*/
-local ZPOS64_T unz64local_SearchCentralDir64 (
+local ZPOS64_T unz64local_SearchCentralDir64 OF((
const zlib_filefunc64_32_def* pzlib_filefunc_def,
- voidpf filestream);
+ voidpf filestream));
local ZPOS64_T unz64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib_filefunc_def,
voidpf filestream)
@@ -606,9 +608,11 @@ local unzFile unzOpenInternal (const void *path,
us.z_filefunc.zseek32_file = NULL;
us.z_filefunc.ztell32_file = NULL;
- if (pzlib_filefunc64_32_def==NULL)
- return NULL; // standard i/o not supported
- us.z_filefunc = *pzlib_filefunc64_32_def;
+ if (pzlib_filefunc64_32_def==NULL)
+ /* GODOT start */
+ return NULL; // standard i/o not supported
+ us.z_filefunc = *pzlib_filefunc64_32_def;
+ /* GODOT end */
us.is64bitOpenFunction = is64bitOpenFunction;
@@ -617,10 +621,8 @@ local unzFile unzOpenInternal (const void *path,
path,
ZLIB_FILEFUNC_MODE_READ |
ZLIB_FILEFUNC_MODE_EXISTING);
- if (us.filestream==NULL) {
- printf("no stream\n");
+ if (us.filestream==NULL)
return NULL;
- };
central_pos = unz64local_SearchCentralDir64(&us.z_filefunc,us.filestream);
if (central_pos)
@@ -743,7 +745,6 @@ local unzFile unzOpenInternal (const void *path,
if (err!=UNZ_OK)
{
- printf("err is %i, %x\n", err, err);
ZCLOSE64(us.z_filefunc, us.filestream);
return NULL;
}
@@ -803,15 +804,17 @@ extern unzFile ZEXPORT unzOpen64 (const void *path)
return unzOpenInternal(path, NULL, 1);
}
+/* GODOT start */
extern void* unzGetOpaque(unzFile file) {
- unz64_s* s;
- if (file==NULL)
- return NULL;
- s=(unz64_s*)file;
+ unz64_s* s;
+ if (file==NULL)
+ return NULL;
+ s=(unz64_s*)file;
- return s->z_filefunc.zfile_func64.opaque;
+ return s->z_filefunc.zfile_func64.opaque;
};
+/* GODOT end */
/*
Close a ZipFile opened with unzipOpen.
@@ -878,7 +881,7 @@ local void unz64local_DosDateToTmuDate (ZPOS64_T ulDosDate, tm_unz* ptm)
/*
Get Info about the current file in the zipfile, with internal only info
*/
-local int unz64local_GetCurrentFileInfoInternal (unzFile file,
+local int unz64local_GetCurrentFileInfoInternal OF((unzFile file,
unz_file_info64 *pfile_info,
unz_file_info64_internal
*pfile_info_internal,
@@ -887,7 +890,7 @@ local int unz64local_GetCurrentFileInfoInternal (unzFile file,
void *extraField,
uLong extraFieldBufferSize,
char *szComment,
- uLong commentBufferSize);
+ uLong commentBufferSize));
local int unz64local_GetCurrentFileInfoInternal (unzFile file,
unz_file_info64 *pfile_info,
@@ -1031,19 +1034,20 @@ local int unz64local_GetCurrentFileInfoInternal (unzFile file,
if (lSeek!=0)
{
- if (lSeek<0) {
- // WORKAROUND for backwards seeking
- z_off_t pos = ZTELL64(s->z_filefunc, s->filestream);
- if (ZSEEK64(s->z_filefunc, s->filestream,pos+lSeek,ZLIB_FILEFUNC_SEEK_SET)==0)
- lSeek=0;
- else
- err=UNZ_ERRNO;
- } else {
- if (ZSEEK64(s->z_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0)
- lSeek=0;
- else
- err=UNZ_ERRNO;
- }
+ /* GODOT start */
+ if (lSeek<0) {
+ // WORKAROUND for backwards seeking
+ z_off_t pos = ZTELL64(s->z_filefunc, s->filestream);
+ if (ZSEEK64(s->z_filefunc, s->filestream,pos+lSeek,ZLIB_FILEFUNC_SEEK_SET)==0)
+ lSeek=0;
+ else
+ err=UNZ_ERRNO;
+ } else {
+ if (ZSEEK64(s->z_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0)
+ lSeek=0;
+ else
+ err=UNZ_ERRNO;
+ }
}
while(acc < file_info.size_file_extra)
@@ -1597,8 +1601,10 @@ extern int ZEXPORT unzOpenCurrentFile3 (unzFile file, int* method,
}
else if ((s->cur_file_info.compression_method==Z_DEFLATED) && (!raw))
{
+ /* GODOT start */
pfile_in_zip_read_info->stream.zalloc = s->z_filefunc.zfile_func64.alloc_mem;
pfile_in_zip_read_info->stream.zfree = s->z_filefunc.zfile_func64.free_mem;
+ /* GODOT end */
pfile_in_zip_read_info->stream.opaque = (voidpf)0;
pfile_in_zip_read_info->stream.next_in = 0;
pfile_in_zip_read_info->stream.avail_in = 0;
@@ -1608,7 +1614,6 @@ extern int ZEXPORT unzOpenCurrentFile3 (unzFile file, int* method,
pfile_in_zip_read_info->stream_initialised=Z_DEFLATED;
else
{
- printf("NO OPEN ZLIB %i\n",err);
TRYFREE(pfile_in_zip_read_info);
return err;
}
@@ -1631,7 +1636,9 @@ extern int ZEXPORT unzOpenCurrentFile3 (unzFile file, int* method,
iSizeVar;
pfile_in_zip_read_info->stream.avail_in = (uInt)0;
- pfile_in_zip_read_info->extra_size = iSizeVar;
+ /* GODOT start */
+ pfile_in_zip_read_info->extra_size = iSizeVar;
+ /* GODOT end */
s->pfile_in_zip_read = pfile_in_zip_read_info;
s->encrypted = 0;
@@ -1662,82 +1669,84 @@ extern int ZEXPORT unzOpenCurrentFile3 (unzFile file, int* method,
return UNZ_OK;
}
+/* GODOT start */
extern int ZEXPORT unzSeekCurrentFile(unzFile file, int pos) {
- unz64_s* s;
- file_in_zip64_read_info_s* pfile_in_zip_read_info;
- if (file==NULL)
- return UNZ_PARAMERROR;
- s=(unz64_s*)file;
- pfile_in_zip_read_info=s->pfile_in_zip_read;
-
- if (pfile_in_zip_read_info==NULL)
- return UNZ_PARAMERROR;
-
- if (pfile_in_zip_read_info->compression_method==Z_BZIP2ED) { // don't know how to support bzip
- return UNZ_INTERNALERROR;
- };
-
- if ((pfile_in_zip_read_info->compression_method==0) || (pfile_in_zip_read_info->raw)) {
-
- pfile_in_zip_read_info->rest_read_compressed =
- s->cur_file_info.compressed_size - pos;
- pfile_in_zip_read_info->rest_read_uncompressed =
- s->cur_file_info.uncompressed_size - pos;
-
- pfile_in_zip_read_info->pos_in_zipfile =
- s->cur_file_info_internal.offset_curfile + SIZEZIPLOCALHEADER +
- pfile_in_zip_read_info->extra_size + pos;
-
- pfile_in_zip_read_info->stream.avail_in = (uInt)0;
- pfile_in_zip_read_info->stream.total_out = pos;
-
- return ZSEEK64(pfile_in_zip_read_info->z_filefunc,
- pfile_in_zip_read_info->filestream,
- pfile_in_zip_read_info->byte_before_the_zipfile + pfile_in_zip_read_info->pos_in_zipfile,
- ZLIB_FILEFUNC_SEEK_SET);
-
- } else { // gzip
-
- if (pos < pfile_in_zip_read_info->stream.total_out) { // negative seek, rewind
-
- pfile_in_zip_read_info->rest_read_compressed =
- s->cur_file_info.compressed_size ;
- pfile_in_zip_read_info->rest_read_uncompressed =
- s->cur_file_info.uncompressed_size ;
-
- pfile_in_zip_read_info->pos_in_zipfile =
- s->cur_file_info_internal.offset_curfile + SIZEZIPLOCALHEADER +
- pfile_in_zip_read_info->extra_size;
-
- (void)inflateReset(&pfile_in_zip_read_info->stream);
-
- pfile_in_zip_read_info->stream.avail_in = (uInt)0;
- pfile_in_zip_read_info->stream.total_out = 0;
- pfile_in_zip_read_info->stream.next_in = 0;
- };
-
- // not sure where to read, so read on the stack
- {
- char buf[512];
- int to_read = pos - pfile_in_zip_read_info->stream.total_out;
- while (to_read) {
-
- int len = to_read > sizeof(buf)?sizeof(buf):to_read;
- int read = unzReadCurrentFile(file, buf, len);
- if (read < 0) {
- return read;
- };
- to_read -= read;
- if (read == UNZ_EOF) {
- return pos;
- };
- };
- };
- };
-
- return pos;
+ unz64_s* s;
+ file_in_zip64_read_info_s* pfile_in_zip_read_info;
+ if (file==NULL)
+ return UNZ_PARAMERROR;
+ s=(unz64_s*)file;
+ pfile_in_zip_read_info=s->pfile_in_zip_read;
+
+ if (pfile_in_zip_read_info==NULL)
+ return UNZ_PARAMERROR;
+
+ if (pfile_in_zip_read_info->compression_method==Z_BZIP2ED) { // don't know how to support bzip
+ return UNZ_INTERNALERROR;
+ };
+
+ if ((pfile_in_zip_read_info->compression_method==0) || (pfile_in_zip_read_info->raw)) {
+
+ pfile_in_zip_read_info->rest_read_compressed =
+ s->cur_file_info.compressed_size - pos;
+ pfile_in_zip_read_info->rest_read_uncompressed =
+ s->cur_file_info.uncompressed_size - pos;
+
+ pfile_in_zip_read_info->pos_in_zipfile =
+ s->cur_file_info_internal.offset_curfile + SIZEZIPLOCALHEADER +
+ pfile_in_zip_read_info->extra_size + pos;
+
+ pfile_in_zip_read_info->stream.avail_in = (uInt)0;
+ pfile_in_zip_read_info->stream.total_out = pos;
+
+ return ZSEEK64(pfile_in_zip_read_info->z_filefunc,
+ pfile_in_zip_read_info->filestream,
+ pfile_in_zip_read_info->byte_before_the_zipfile + pfile_in_zip_read_info->pos_in_zipfile,
+ ZLIB_FILEFUNC_SEEK_SET);
+
+ } else { // gzip
+
+ if (pos < pfile_in_zip_read_info->stream.total_out) { // negative seek, rewind
+
+ pfile_in_zip_read_info->rest_read_compressed =
+ s->cur_file_info.compressed_size ;
+ pfile_in_zip_read_info->rest_read_uncompressed =
+ s->cur_file_info.uncompressed_size ;
+
+ pfile_in_zip_read_info->pos_in_zipfile =
+ s->cur_file_info_internal.offset_curfile + SIZEZIPLOCALHEADER +
+ pfile_in_zip_read_info->extra_size;
+
+ (void)inflateReset(&pfile_in_zip_read_info->stream);
+
+ pfile_in_zip_read_info->stream.avail_in = (uInt)0;
+ pfile_in_zip_read_info->stream.total_out = 0;
+ pfile_in_zip_read_info->stream.next_in = 0;
+ };
+
+ // not sure where to read, so read on the stack
+ {
+ char buf[512];
+ int to_read = pos - pfile_in_zip_read_info->stream.total_out;
+ while (to_read) {
+
+ int len = to_read > sizeof(buf)?sizeof(buf):to_read;
+ int read = unzReadCurrentFile(file, buf, len);
+ if (read < 0) {
+ return read;
+ };
+ to_read -= read;
+ if (read == UNZ_EOF) {
+ return pos;
+ };
+ };
+ };
+ };
+
+ return pos;
};
+/* GODOT end */
extern int ZEXPORT unzOpenCurrentFile (unzFile file)
{
@@ -1797,7 +1806,7 @@ extern int ZEXPORT unzReadCurrentFile (unzFile file, voidp buf, unsigned len)
return UNZ_PARAMERROR;
- if (pfile_in_zip_read_info->read_buffer==NULL)
+ if ((pfile_in_zip_read_info->read_buffer == NULL))
return UNZ_END_OF_LIST_OF_FILE;
if (len==0)
return 0;
diff --git a/thirdparty/minizip/unzip.h b/thirdparty/minizip/unzip.h
index f67c3b2fa8..54e65ad8ab 100644
--- a/thirdparty/minizip/unzip.h
+++ b/thirdparty/minizip/unzip.h
@@ -10,7 +10,7 @@
Modifications for Zip64 support on both zip and unzip
Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
- For more info read LICENSE-MiniZip.txt
+ For more info read MiniZip_info.txt
---------------------------------------------------------------------------------
@@ -150,9 +150,9 @@ typedef struct unz_file_info_s
tm_unz tmu_date;
} unz_file_info;
-extern int ZEXPORT unzStringFileNameCompare (const char* fileName1,
+extern int ZEXPORT unzStringFileNameCompare OF ((const char* fileName1,
const char* fileName2,
- int iCaseSensitivity);
+ int iCaseSensitivity));
/*
Compare two filename (fileName1,fileName2).
If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp)
@@ -163,8 +163,8 @@ extern int ZEXPORT unzStringFileNameCompare (const char* fileName1,
*/
-extern unzFile ZEXPORT unzOpen (const char *path);
-extern unzFile ZEXPORT unzOpen64 (const void *path);
+extern unzFile ZEXPORT unzOpen OF((const char *path));
+extern unzFile ZEXPORT unzOpen64 OF((const void *path));
/*
Open a Zip file. path contain the full pathname (by example,
on a Windows XP computer "c:\\zlib\\zlib113.zip" or on an Unix computer
@@ -181,44 +181,45 @@ extern unzFile ZEXPORT unzOpen64 (const void *path);
*/
-extern unzFile ZEXPORT unzOpen2 (const char *path,
- zlib_filefunc_def* pzlib_filefunc_def);
+extern unzFile ZEXPORT unzOpen2 OF((const char *path,
+ zlib_filefunc_def* pzlib_filefunc_def));
/*
Open a Zip file, like unzOpen, but provide a set of file low level API
for read/write the zip file (see ioapi.h)
*/
-extern unzFile ZEXPORT unzOpen2_64 (const void *path,
- zlib_filefunc64_def* pzlib_filefunc_def);
+extern unzFile ZEXPORT unzOpen2_64 OF((const void *path,
+ zlib_filefunc64_def* pzlib_filefunc_def));
/*
Open a Zip file, like unz64Open, but provide a set of file low level API
for read/write the zip file (see ioapi.h)
*/
-extern int ZEXPORT unzClose (unzFile file);
+extern int ZEXPORT unzClose OF((unzFile file));
/*
Close a ZipFile opened with unzipOpen.
If there is files inside the .Zip opened with unzOpenCurrentFile (see later),
these files MUST be closed with unzipCloseCurrentFile before call unzipClose.
return UNZ_OK if there is no problem. */
+/* GODOT start */
extern void* unzGetOpaque(unzFile file);
+/* GODOT end */
+extern int ZEXPORT unzGetGlobalInfo OF((unzFile file,
+ unz_global_info *pglobal_info));
-extern int ZEXPORT unzGetGlobalInfo (unzFile file,
- unz_global_info *pglobal_info);
-
-extern int ZEXPORT unzGetGlobalInfo64 (unzFile file,
- unz_global_info64 *pglobal_info);
+extern int ZEXPORT unzGetGlobalInfo64 OF((unzFile file,
+ unz_global_info64 *pglobal_info));
/*
Write info about the ZipFile in the *pglobal_info structure.
No preparation of the structure is needed
return UNZ_OK if there is no problem. */
-extern int ZEXPORT unzGetGlobalComment (unzFile file,
+extern int ZEXPORT unzGetGlobalComment OF((unzFile file,
char *szComment,
- uLong uSizeBuf);
+ uLong uSizeBuf));
/*
Get the global comment string of the ZipFile, in the szComment buffer.
uSizeBuf is the size of the szComment buffer.
@@ -229,22 +230,22 @@ extern int ZEXPORT unzGetGlobalComment (unzFile file,
/***************************************************************************/
/* Unzip package allow you browse the directory of the zipfile */
-extern int ZEXPORT unzGoToFirstFile (unzFile file);
+extern int ZEXPORT unzGoToFirstFile OF((unzFile file));
/*
Set the current file of the zipfile to the first file.
return UNZ_OK if there is no problem
*/
-extern int ZEXPORT unzGoToNextFile (unzFile file);
+extern int ZEXPORT unzGoToNextFile OF((unzFile file));
/*
Set the current file of the zipfile to the next file.
return UNZ_OK if there is no problem
return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest.
*/
-extern int ZEXPORT unzLocateFile (unzFile file,
+extern int ZEXPORT unzLocateFile OF((unzFile file,
const char *szFileName,
- int iCaseSensitivity);
+ int iCaseSensitivity));
/*
Try locate the file szFileName in the zipfile.
For the iCaseSensitivity signification, see unzStringFileNameCompare
@@ -288,23 +289,23 @@ extern int ZEXPORT unzGoToFilePos64(
/* ****************************************** */
-extern int ZEXPORT unzGetCurrentFileInfo64 (unzFile file,
+extern int ZEXPORT unzGetCurrentFileInfo64 OF((unzFile file,
unz_file_info64 *pfile_info,
char *szFileName,
uLong fileNameBufferSize,
void *extraField,
uLong extraFieldBufferSize,
char *szComment,
- uLong commentBufferSize);
+ uLong commentBufferSize));
-extern int ZEXPORT unzGetCurrentFileInfo (unzFile file,
+extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file,
unz_file_info *pfile_info,
char *szFileName,
uLong fileNameBufferSize,
void *extraField,
uLong extraFieldBufferSize,
char *szComment,
- uLong commentBufferSize);
+ uLong commentBufferSize));
/*
Get Info about the current file
if pfile_info!=NULL, the *pfile_info structure will contain somes info about
@@ -321,7 +322,7 @@ extern int ZEXPORT unzGetCurrentFileInfo (unzFile file,
/** Addition for GDAL : START */
-extern ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64 (unzFile file);
+extern ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64 OF((unzFile file));
/** Addition for GDAL : END */
@@ -331,24 +332,24 @@ extern ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64 (unzFile file);
from it, and close it (you can close it before reading all the file)
*/
-extern int ZEXPORT unzOpenCurrentFile (unzFile file);
+extern int ZEXPORT unzOpenCurrentFile OF((unzFile file));
/*
Open for reading data the current file in the zipfile.
If there is no error, the return value is UNZ_OK.
*/
-extern int ZEXPORT unzOpenCurrentFilePassword (unzFile file,
- const char* password);
+extern int ZEXPORT unzOpenCurrentFilePassword OF((unzFile file,
+ const char* password));
/*
Open for reading data the current file in the zipfile.
password is a crypting password
If there is no error, the return value is UNZ_OK.
*/
-extern int ZEXPORT unzOpenCurrentFile2 (unzFile file,
+extern int ZEXPORT unzOpenCurrentFile2 OF((unzFile file,
int* method,
int* level,
- int raw);
+ int raw));
/*
Same than unzOpenCurrentFile, but open for read raw the file (not uncompress)
if raw==1
@@ -358,11 +359,11 @@ extern int ZEXPORT unzOpenCurrentFile2 (unzFile file,
but you CANNOT set method parameter as NULL
*/
-extern int ZEXPORT unzOpenCurrentFile3 (unzFile file,
+extern int ZEXPORT unzOpenCurrentFile3 OF((unzFile file,
int* method,
int* level,
int raw,
- const char* password);
+ const char* password));
/*
Same than unzOpenCurrentFile, but open for read raw the file (not uncompress)
if raw==1
@@ -373,15 +374,15 @@ extern int ZEXPORT unzOpenCurrentFile3 (unzFile file,
*/
-extern int ZEXPORT unzCloseCurrentFile (unzFile file);
+extern int ZEXPORT unzCloseCurrentFile OF((unzFile file));
/*
Close the file in zip opened with unzOpenCurrentFile
Return UNZ_CRCERROR if all the file was read but the CRC is not good
*/
-extern int ZEXPORT unzReadCurrentFile (unzFile file,
+extern int ZEXPORT unzReadCurrentFile OF((unzFile file,
voidp buf,
- unsigned len);
+ unsigned len));
/*
Read bytes from the current file (opened by unzOpenCurrentFile)
buf contain buffer where data must be copied
@@ -393,26 +394,28 @@ extern int ZEXPORT unzReadCurrentFile (unzFile file,
(UNZ_ERRNO for IO error, or zLib error for uncompress error)
*/
+/* GODOT start */
extern int ZEXPORT unzSeekCurrentFile(unzFile file, int pos);
/*
Seek to position in uncompressed data
*/
+/* GODOT end */
-extern z_off_t ZEXPORT unztell (unzFile file);
+extern z_off_t ZEXPORT unztell OF((unzFile file));
-extern ZPOS64_T ZEXPORT unztell64 (unzFile file);
+extern ZPOS64_T ZEXPORT unztell64 OF((unzFile file));
/*
Give the current position in uncompressed data
*/
-extern int ZEXPORT unzeof (unzFile file);
+extern int ZEXPORT unzeof OF((unzFile file));
/*
return 1 if the end of file was reached, 0 elsewhere
*/
-extern int ZEXPORT unzGetLocalExtrafield (unzFile file,
+extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file,
voidp buf,
- unsigned len);
+ unsigned len));
/*
Read extra field from the current file (opened by unzOpenCurrentFile)
This is the local-header version of the extra field (sometimes, there is
diff --git a/thirdparty/minizip/zip.c b/thirdparty/minizip/zip.c
index 27a3d3cdc1..d7093e7457 100644
--- a/thirdparty/minizip/zip.c
+++ b/thirdparty/minizip/zip.c
@@ -7,7 +7,7 @@
Modifications for Zip64 support
Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
- For more info read LICENSE-MiniZip.txt
+ For more info read MiniZip_info.txt
Changes
Oct-2009 - Mathias Svensson - Remove old C style function prototypes
@@ -283,7 +283,7 @@ local int add_data_in_datablock(linkedlist_data* ll, const void* buf, uLong len)
nbByte == 1, 2 ,4 or 8 (byte, short or long, ZPOS64_T)
*/
-local int zip64local_putValue (const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, ZPOS64_T x, int nbByte);
+local int zip64local_putValue OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, ZPOS64_T x, int nbByte));
local int zip64local_putValue (const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, ZPOS64_T x, int nbByte)
{
unsigned char buf[8];
@@ -307,7 +307,7 @@ local int zip64local_putValue (const zlib_filefunc64_32_def* pzlib_filefunc_def,
return ZIP_OK;
}
-local void zip64local_putValue_inmemory (void* dest, ZPOS64_T x, int nbByte);
+local void zip64local_putValue_inmemory OF((void* dest, ZPOS64_T x, int nbByte));
local void zip64local_putValue_inmemory (void* dest, ZPOS64_T x, int nbByte)
{
unsigned char* buf=(unsigned char*)dest;
@@ -344,7 +344,7 @@ local uLong zip64local_TmzDateToDosDate(const tm_zip* ptm)
/****************************************************************************/
-local int zip64local_getByte (const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, int *pi);
+local int zip64local_getByte OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, int *pi));
local int zip64local_getByte(const zlib_filefunc64_32_def* pzlib_filefunc_def,voidpf filestream,int* pi)
{
@@ -368,7 +368,7 @@ local int zip64local_getByte(const zlib_filefunc64_32_def* pzlib_filefunc_def,vo
/* ===========================================================================
Reads a long in LSB order from the given gz_stream. Sets
*/
-local int zip64local_getShort (const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, uLong *pX);
+local int zip64local_getShort OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, uLong *pX));
local int zip64local_getShort (const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, uLong* pX)
{
@@ -390,7 +390,7 @@ local int zip64local_getShort (const zlib_filefunc64_32_def* pzlib_filefunc_def,
return err;
}
-local int zip64local_getLong (const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, uLong *pX);
+local int zip64local_getLong OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, uLong *pX));
local int zip64local_getLong (const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, uLong* pX)
{
@@ -420,7 +420,7 @@ local int zip64local_getLong (const zlib_filefunc64_32_def* pzlib_filefunc_def,
return err;
}
-local int zip64local_getLong64 (const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, ZPOS64_T *pX);
+local int zip64local_getLong64 OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, ZPOS64_T *pX));
local int zip64local_getLong64 (const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream, ZPOS64_T *pX)
@@ -475,7 +475,7 @@ local int zip64local_getLong64 (const zlib_filefunc64_32_def* pzlib_filefunc_def
Locate the Central directory of a zipfile (at the end, just before
the global comment)
*/
-local ZPOS64_T zip64local_SearchCentralDir (const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream);
+local ZPOS64_T zip64local_SearchCentralDir OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream));
local ZPOS64_T zip64local_SearchCentralDir(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream)
{
@@ -537,7 +537,7 @@ local ZPOS64_T zip64local_SearchCentralDir(const zlib_filefunc64_32_def* pzlib_f
Locate the End of Zip64 Central directory locator and from there find the CD of a zipfile (at the end, just before
the global comment)
*/
-local ZPOS64_T zip64local_SearchCentralDir64 (const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream);
+local ZPOS64_T zip64local_SearchCentralDir64 OF((const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream));
local ZPOS64_T zip64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream)
{
@@ -854,9 +854,11 @@ extern zipFile ZEXPORT zipOpen3 (const void *pathname, int append, zipcharpc* gl
ziinit.z_filefunc.zseek32_file = NULL;
ziinit.z_filefunc.ztell32_file = NULL;
+ /* GODOT start */
if (pzlib_filefunc64_32_def==NULL) {
- //fill_fopen64_filefunc(&ziinit.z_filefunc.zfile_func64);
+ //fill_fopen64_filefunc(&ziinit.z_filefunc.zfile_func64);
} else
+ /* GODOT end */
ziinit.z_filefunc = *pzlib_filefunc64_32_def;
ziinit.filestream = ZOPEN64(ziinit.z_filefunc,
@@ -1114,9 +1116,9 @@ extern int ZEXPORT zipOpenNewFileInZip4_64 (zipFile file, const char* filename,
zi->ci.flag = flagBase;
if ((level==8) || (level==9))
zi->ci.flag |= 2;
- if (level==2)
+ if ((level==2))
zi->ci.flag |= 4;
- if (level==1)
+ if ((level==1))
zi->ci.flag |= 6;
if (password != NULL)
zi->ci.flag |= 1;
@@ -1210,9 +1212,10 @@ extern int ZEXPORT zipOpenNewFileInZip4_64 (zipFile file, const char* filename,
{
if(zi->ci.method == Z_DEFLATED)
{
- zi->ci.stream.zalloc = zi->z_filefunc.zfile_func64.alloc_mem;
- zi->ci.stream.zfree = zi->z_filefunc.zfile_func64.free_mem;
-
+ /* GODOT start */
+ zi->ci.stream.zalloc = zi->z_filefunc.zfile_func64.alloc_mem;
+ zi->ci.stream.zfree = zi->z_filefunc.zfile_func64.free_mem;
+ /* GODOT end */
zi->ci.stream.opaque = (voidpf)0;
if (windowBits>0)
diff --git a/thirdparty/minizip/zip.h b/thirdparty/minizip/zip.h
index 37478b34c0..8aaebb6234 100644
--- a/thirdparty/minizip/zip.h
+++ b/thirdparty/minizip/zip.h
@@ -1,4 +1,5 @@
-/* Version 1.1, February 14h, 2010
+/* zip.h -- IO on .zip files using zlib
+ Version 1.1, February 14h, 2010
part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html )
Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html )
@@ -6,7 +7,7 @@
Modifications for Zip64 support
Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com )
- For more info read LICENSE-MiniZip.txt
+ For more info read MiniZip_info.txt
---------------------------------------------------------------------------
@@ -39,8 +40,6 @@
#ifndef _zip12_H
#define _zip12_H
-#include <stdlib.h>
-
#ifdef __cplusplus
extern "C" {
#endif
@@ -114,8 +113,8 @@ typedef const char* zipcharpc;
#define APPEND_STATUS_CREATEAFTER (1)
#define APPEND_STATUS_ADDINZIP (2)
-extern zipFile ZEXPORT zipOpen (const char *pathname, int append);
-extern zipFile ZEXPORT zipOpen64 (const void *pathname, int append);
+extern zipFile ZEXPORT zipOpen OF((const char *pathname, int append));
+extern zipFile ZEXPORT zipOpen64 OF((const void *pathname, int append));
/*
Create a zipfile.
pathname contain on Windows XP a filename like "c:\\zlib\\zlib113.zip" or on
@@ -135,17 +134,17 @@ extern zipFile ZEXPORT zipOpen64 (const void *pathname, int append);
Of couse, you can use RAW reading and writing to copy the file you did not want delte
*/
-extern zipFile ZEXPORT zipOpen2 (const char *pathname,
+extern zipFile ZEXPORT zipOpen2 OF((const char *pathname,
int append,
zipcharpc* globalcomment,
- zlib_filefunc_def* pzlib_filefunc_def);
+ zlib_filefunc_def* pzlib_filefunc_def));
-extern zipFile ZEXPORT zipOpen2_64 (const void *pathname,
+extern zipFile ZEXPORT zipOpen2_64 OF((const void *pathname,
int append,
zipcharpc* globalcomment,
- zlib_filefunc64_def* pzlib_filefunc_def);
+ zlib_filefunc64_def* pzlib_filefunc_def));
-extern int ZEXPORT zipOpenNewFileInZip (zipFile file,
+extern int ZEXPORT zipOpenNewFileInZip OF((zipFile file,
const char* filename,
const zip_fileinfo* zipfi,
const void* extrafield_local,
@@ -154,9 +153,9 @@ extern int ZEXPORT zipOpenNewFileInZip (zipFile file,
uInt size_extrafield_global,
const char* comment,
int method,
- int level);
+ int level));
-extern int ZEXPORT zipOpenNewFileInZip64 (zipFile file,
+extern int ZEXPORT zipOpenNewFileInZip64 OF((zipFile file,
const char* filename,
const zip_fileinfo* zipfi,
const void* extrafield_local,
@@ -166,7 +165,7 @@ extern int ZEXPORT zipOpenNewFileInZip64 (zipFile file,
const char* comment,
int method,
int level,
- int zip64);
+ int zip64));
/*
Open a file in the ZIP for writing.
@@ -185,7 +184,7 @@ extern int ZEXPORT zipOpenNewFileInZip64 (zipFile file,
*/
-extern int ZEXPORT zipOpenNewFileInZip2 (zipFile file,
+extern int ZEXPORT zipOpenNewFileInZip2 OF((zipFile file,
const char* filename,
const zip_fileinfo* zipfi,
const void* extrafield_local,
@@ -195,10 +194,10 @@ extern int ZEXPORT zipOpenNewFileInZip2 (zipFile file,
const char* comment,
int method,
int level,
- int raw);
+ int raw));
-extern int ZEXPORT zipOpenNewFileInZip2_64 (zipFile file,
+extern int ZEXPORT zipOpenNewFileInZip2_64 OF((zipFile file,
const char* filename,
const zip_fileinfo* zipfi,
const void* extrafield_local,
@@ -209,12 +208,12 @@ extern int ZEXPORT zipOpenNewFileInZip2_64 (zipFile file,
int method,
int level,
int raw,
- int zip64);
+ int zip64));
/*
Same than zipOpenNewFileInZip, except if raw=1, we write raw file
*/
-extern int ZEXPORT zipOpenNewFileInZip3 (zipFile file,
+extern int ZEXPORT zipOpenNewFileInZip3 OF((zipFile file,
const char* filename,
const zip_fileinfo* zipfi,
const void* extrafield_local,
@@ -229,9 +228,9 @@ extern int ZEXPORT zipOpenNewFileInZip3 (zipFile file,
int memLevel,
int strategy,
const char* password,
- uLong crcForCrypting);
+ uLong crcForCrypting));
-extern int ZEXPORT zipOpenNewFileInZip3_64 (zipFile file,
+extern int ZEXPORT zipOpenNewFileInZip3_64 OF((zipFile file,
const char* filename,
const zip_fileinfo* zipfi,
const void* extrafield_local,
@@ -248,7 +247,7 @@ extern int ZEXPORT zipOpenNewFileInZip3_64 (zipFile file,
const char* password,
uLong crcForCrypting,
int zip64
- );
+ ));
/*
Same than zipOpenNewFileInZip2, except
@@ -257,7 +256,7 @@ extern int ZEXPORT zipOpenNewFileInZip3_64 (zipFile file,
crcForCrypting : crc of file to compress (needed for crypting)
*/
-extern int ZEXPORT zipOpenNewFileInZip4 (zipFile file,
+extern int ZEXPORT zipOpenNewFileInZip4 OF((zipFile file,
const char* filename,
const zip_fileinfo* zipfi,
const void* extrafield_local,
@@ -275,10 +274,10 @@ extern int ZEXPORT zipOpenNewFileInZip4 (zipFile file,
uLong crcForCrypting,
uLong versionMadeBy,
uLong flagBase
- );
+ ));
-extern int ZEXPORT zipOpenNewFileInZip4_64 (zipFile file,
+extern int ZEXPORT zipOpenNewFileInZip4_64 OF((zipFile file,
const char* filename,
const zip_fileinfo* zipfi,
const void* extrafield_local,
@@ -297,7 +296,7 @@ extern int ZEXPORT zipOpenNewFileInZip4_64 (zipFile file,
uLong versionMadeBy,
uLong flagBase,
int zip64
- );
+ ));
/*
Same than zipOpenNewFileInZip4, except
versionMadeBy : value for Version made by field
@@ -305,25 +304,25 @@ extern int ZEXPORT zipOpenNewFileInZip4_64 (zipFile file,
*/
-extern int ZEXPORT zipWriteInFileInZip (zipFile file,
+extern int ZEXPORT zipWriteInFileInZip OF((zipFile file,
const void* buf,
- unsigned len);
+ unsigned len));
/*
Write data in the zipfile
*/
-extern int ZEXPORT zipCloseFileInZip (zipFile file);
+extern int ZEXPORT zipCloseFileInZip OF((zipFile file));
/*
Close the current file in the zipfile
*/
-extern int ZEXPORT zipCloseFileInZipRaw (zipFile file,
+extern int ZEXPORT zipCloseFileInZipRaw OF((zipFile file,
uLong uncompressed_size,
- uLong crc32);
+ uLong crc32));
-extern int ZEXPORT zipCloseFileInZipRaw64 (zipFile file,
+extern int ZEXPORT zipCloseFileInZipRaw64 OF((zipFile file,
ZPOS64_T uncompressed_size,
- uLong crc32);
+ uLong crc32));
/*
Close the current file in the zipfile, for file opened with
@@ -331,14 +330,14 @@ extern int ZEXPORT zipCloseFileInZipRaw64 (zipFile file,
uncompressed_size and crc32 are value for the uncompressed size
*/
-extern int ZEXPORT zipClose (zipFile file,
- const char* global_comment);
+extern int ZEXPORT zipClose OF((zipFile file,
+ const char* global_comment));
/*
Close the zipfile
*/
-extern int ZEXPORT zipRemoveExtraInfoBlock (char* pData, int* dataLen, short sHeader);
+extern int ZEXPORT zipRemoveExtraInfoBlock OF((char* pData, int* dataLen, short sHeader));
/*
zipRemoveExtraInfoBlock - Added by Mathias Svensson