summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/dds/register_types.cpp2
-rw-r--r--modules/dds/register_types.h2
-rw-r--r--modules/dds/texture_loader_dds.cpp2
-rw-r--r--modules/dds/texture_loader_dds.h2
-rw-r--r--modules/enet/networked_multiplayer_enet.cpp12
-rw-r--r--modules/enet/networked_multiplayer_enet.h2
-rw-r--r--modules/enet/register_types.cpp2
-rw-r--r--modules/enet/register_types.h2
-rw-r--r--modules/etc/SCsub4
-rw-r--r--modules/etc/image_etc.cpp4
-rw-r--r--modules/etc/image_etc.h2
-rw-r--r--modules/etc/register_types.cpp2
-rw-r--r--modules/etc/register_types.h2
-rw-r--r--modules/etc/texture_loader_pkm.cpp2
-rw-r--r--modules/etc/texture_loader_pkm.h2
-rw-r--r--modules/freetype/SCsub3
-rw-r--r--modules/freetype/register_types.cpp2
-rw-r--r--modules/freetype/register_types.h2
-rw-r--r--modules/freetype/uwpdef.h2
-rw-r--r--modules/gdnative/gdnative.cpp9
-rw-r--r--modules/gdnative/gdnative.h2
-rw-r--r--modules/gdnative/godot/array.cpp2
-rw-r--r--modules/gdnative/godot/array.h2
-rw-r--r--modules/gdnative/godot/basis.cpp20
-rw-r--r--modules/gdnative/godot/basis.h8
-rw-r--r--modules/gdnative/godot/color.cpp2
-rw-r--r--modules/gdnative/godot/color.h2
-rw-r--r--modules/gdnative/godot/dictionary.cpp2
-rw-r--r--modules/gdnative/godot/dictionary.h2
-rw-r--r--modules/gdnative/godot/gdnative.cpp2
-rw-r--r--modules/gdnative/godot/gdnative.h2
-rw-r--r--modules/gdnative/godot/node_path.cpp2
-rw-r--r--modules/gdnative/godot/node_path.h2
-rw-r--r--modules/gdnative/godot/plane.cpp2
-rw-r--r--modules/gdnative/godot/plane.h2
-rw-r--r--modules/gdnative/godot/pool_arrays.cpp2
-rw-r--r--modules/gdnative/godot/pool_arrays.h2
-rw-r--r--modules/gdnative/godot/quat.cpp2
-rw-r--r--modules/gdnative/godot/quat.h2
-rw-r--r--modules/gdnative/godot/rect2.cpp2
-rw-r--r--modules/gdnative/godot/rect2.h2
-rw-r--r--modules/gdnative/godot/rect3.cpp2
-rw-r--r--modules/gdnative/godot/rect3.h2
-rw-r--r--modules/gdnative/godot/rid.cpp4
-rw-r--r--modules/gdnative/godot/rid.h2
-rw-r--r--modules/gdnative/godot/string.cpp2
-rw-r--r--modules/gdnative/godot/string.h4
-rw-r--r--modules/gdnative/godot/transform.cpp2
-rw-r--r--modules/gdnative/godot/transform.h2
-rw-r--r--modules/gdnative/godot/transform2d.cpp2
-rw-r--r--modules/gdnative/godot/transform2d.h2
-rw-r--r--modules/gdnative/godot/variant.cpp2
-rw-r--r--modules/gdnative/godot/variant.h2
-rw-r--r--modules/gdnative/godot/vector2.cpp2
-rw-r--r--modules/gdnative/godot/vector2.h2
-rw-r--r--modules/gdnative/godot/vector3.cpp2
-rw-r--r--modules/gdnative/godot/vector3.h2
-rw-r--r--modules/gdnative/register_types.cpp2
-rw-r--r--modules/gdnative/register_types.h2
-rw-r--r--modules/gdscript/gd_compiler.cpp8
-rw-r--r--modules/gdscript/gd_compiler.h15
-rw-r--r--modules/gdscript/gd_editor.cpp491
-rw-r--r--modules/gdscript/gd_function.cpp26
-rw-r--r--modules/gdscript/gd_function.h5
-rw-r--r--modules/gdscript/gd_functions.cpp66
-rw-r--r--modules/gdscript/gd_functions.h4
-rw-r--r--modules/gdscript/gd_parser.cpp65
-rw-r--r--modules/gdscript/gd_parser.h6
-rw-r--r--modules/gdscript/gd_script.cpp125
-rw-r--r--modules/gdscript/gd_script.h4
-rw-r--r--modules/gdscript/gd_tokenizer.cpp56
-rw-r--r--modules/gdscript/gd_tokenizer.h2
-rw-r--r--modules/gdscript/register_types.cpp105
-rw-r--r--modules/gdscript/register_types.h2
-rw-r--r--modules/gridmap/grid_map.cpp940
-rw-r--r--modules/gridmap/grid_map.h89
-rw-r--r--modules/gridmap/grid_map_editor_plugin.cpp526
-rw-r--r--modules/gridmap/grid_map_editor_plugin.h20
-rw-r--r--modules/gridmap/register_types.cpp2
-rw-r--r--modules/gridmap/register_types.h2
-rw-r--r--modules/hdr/image_loader_hdr.cpp4
-rw-r--r--modules/hdr/image_loader_hdr.h4
-rw-r--r--modules/hdr/register_types.cpp2
-rw-r--r--modules/hdr/register_types.h2
-rw-r--r--modules/jpg/image_loader_jpegd.cpp4
-rw-r--r--modules/jpg/image_loader_jpegd.h4
-rw-r--r--modules/jpg/register_types.cpp2
-rw-r--r--modules/jpg/register_types.h2
-rw-r--r--modules/nativescript/api_generator.cpp87
-rw-r--r--modules/nativescript/api_generator.h2
-rw-r--r--modules/nativescript/godot_nativescript.cpp2
-rw-r--r--modules/nativescript/godot_nativescript.h2
-rw-r--r--modules/nativescript/nativescript.cpp8
-rw-r--r--modules/nativescript/nativescript.h2
-rw-r--r--modules/nativescript/register_types.cpp2
-rw-r--r--modules/nativescript/register_types.h2
-rw-r--r--modules/ogg/register_types.cpp2
-rw-r--r--modules/ogg/register_types.h2
-rw-r--r--modules/openssl/register_types.cpp2
-rw-r--r--modules/openssl/register_types.h2
-rw-r--r--modules/openssl/stream_peer_openssl.cpp34
-rw-r--r--modules/openssl/stream_peer_openssl.h2
-rw-r--r--modules/opus/audio_stream_opus.cpp2
-rw-r--r--modules/opus/audio_stream_opus.h2
-rw-r--r--modules/opus/register_types.cpp2
-rw-r--r--modules/opus/register_types.h2
-rw-r--r--modules/pbm/bitmap_loader_pbm.cpp5
-rw-r--r--modules/pbm/bitmap_loader_pbm.h2
-rw-r--r--modules/pbm/register_types.cpp2
-rw-r--r--modules/pbm/register_types.h2
-rw-r--r--modules/pvr/register_types.cpp2
-rw-r--r--modules/pvr/register_types.h2
-rw-r--r--modules/pvr/texture_loader_pvr.cpp2
-rw-r--r--modules/pvr/texture_loader_pvr.h2
-rw-r--r--modules/regex/SCsub47
-rw-r--r--modules/regex/regex.cpp1562
-rw-r--r--modules/regex/regex.h49
-rw-r--r--modules/regex/register_types.cpp2
-rw-r--r--modules/regex/register_types.h2
-rw-r--r--modules/register_module_types.h2
-rw-r--r--modules/squish/image_compress_squish.cpp2
-rw-r--r--modules/squish/image_compress_squish.h2
-rw-r--r--modules/squish/register_types.cpp2
-rw-r--r--modules/squish/register_types.h2
-rw-r--r--modules/stb_vorbis/audio_stream_ogg_vorbis.cpp17
-rw-r--r--modules/stb_vorbis/audio_stream_ogg_vorbis.h6
-rw-r--r--modules/stb_vorbis/register_types.cpp2
-rw-r--r--modules/stb_vorbis/register_types.h2
-rw-r--r--modules/stb_vorbis/resource_importer_ogg_vorbis.cpp5
-rw-r--r--modules/stb_vorbis/resource_importer_ogg_vorbis.h2
-rw-r--r--modules/svg/SCsub35
-rw-r--r--modules/svg/config.py7
-rw-r--r--modules/svg/image_loader_svg.cpp156
-rw-r--r--modules/svg/image_loader_svg.h68
-rw-r--r--modules/svg/register_types.cpp45
-rw-r--r--modules/svg/register_types.h31
-rw-r--r--modules/tga/image_loader_tga.cpp4
-rw-r--r--modules/tga/image_loader_tga.h4
-rw-r--r--modules/tga/register_types.cpp2
-rw-r--r--modules/tga/register_types.h2
-rw-r--r--modules/theora/register_types.cpp2
-rw-r--r--modules/theora/register_types.h2
-rw-r--r--modules/theora/video_stream_theora.cpp154
-rw-r--r--modules/theora/video_stream_theora.h2
-rw-r--r--modules/tinyexr/image_loader_tinyexr.cpp4
-rw-r--r--modules/tinyexr/image_loader_tinyexr.h4
-rw-r--r--modules/tinyexr/register_types.cpp2
-rw-r--r--modules/tinyexr/register_types.h2
-rw-r--r--modules/visual_script/register_types.cpp2
-rw-r--r--modules/visual_script/register_types.h2
-rw-r--r--modules/visual_script/visual_script.cpp35
-rw-r--r--modules/visual_script/visual_script.h2
-rw-r--r--modules/visual_script/visual_script_builtin_funcs.cpp4
-rw-r--r--modules/visual_script/visual_script_builtin_funcs.h2
-rw-r--r--modules/visual_script/visual_script_editor.cpp123
-rw-r--r--modules/visual_script/visual_script_editor.h3
-rw-r--r--modules/visual_script/visual_script_expression.cpp3
-rw-r--r--modules/visual_script/visual_script_expression.h2
-rw-r--r--modules/visual_script/visual_script_flow_control.cpp2
-rw-r--r--modules/visual_script/visual_script_flow_control.h2
-rw-r--r--modules/visual_script/visual_script_func_nodes.cpp56
-rw-r--r--modules/visual_script/visual_script_func_nodes.h2
-rw-r--r--modules/visual_script/visual_script_nodes.cpp33
-rw-r--r--modules/visual_script/visual_script_nodes.h4
-rw-r--r--modules/visual_script/visual_script_yield_nodes.cpp25
-rw-r--r--modules/visual_script/visual_script_yield_nodes.h2
-rw-r--r--modules/vorbis/audio_stream_ogg_vorbis.cpp2
-rw-r--r--modules/vorbis/audio_stream_ogg_vorbis.h2
-rw-r--r--modules/vorbis/register_types.cpp2
-rw-r--r--modules/vorbis/register_types.h2
-rw-r--r--modules/webm/register_types.cpp2
-rw-r--r--modules/webm/register_types.h2
-rw-r--r--modules/webm/video_stream_webm.cpp2
-rw-r--r--modules/webm/video_stream_webm.h2
-rw-r--r--modules/webp/image_loader_webp.cpp4
-rw-r--r--modules/webp/image_loader_webp.h4
-rw-r--r--modules/webp/register_types.cpp2
-rw-r--r--modules/webp/register_types.h2
178 files changed, 1970 insertions, 3523 deletions
diff --git a/modules/dds/register_types.cpp b/modules/dds/register_types.cpp
index 4a758fe033..22fb391b9a 100644
--- a/modules/dds/register_types.cpp
+++ b/modules/dds/register_types.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/dds/register_types.h b/modules/dds/register_types.h
index 4807c7dd5b..e48d56c898 100644
--- a/modules/dds/register_types.h
+++ b/modules/dds/register_types.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/dds/texture_loader_dds.cpp b/modules/dds/texture_loader_dds.cpp
index 71593ebfa9..95d93e6af6 100644
--- a/modules/dds/texture_loader_dds.cpp
+++ b/modules/dds/texture_loader_dds.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/dds/texture_loader_dds.h b/modules/dds/texture_loader_dds.h
index 3b36e7f1eb..c545d210b4 100644
--- a/modules/dds/texture_loader_dds.h
+++ b/modules/dds/texture_loader_dds.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/enet/networked_multiplayer_enet.cpp b/modules/enet/networked_multiplayer_enet.cpp
index 68d5c9e611..c50886ad3c 100644
--- a/modules/enet/networked_multiplayer_enet.cpp
+++ b/modules/enet/networked_multiplayer_enet.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -658,11 +658,11 @@ void NetworkedMultiplayerENet::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_compression_mode"), &NetworkedMultiplayerENet::get_compression_mode);
ClassDB::bind_method(D_METHOD("set_bind_ip", "ip"), &NetworkedMultiplayerENet::set_bind_ip);
- BIND_CONSTANT(COMPRESS_NONE);
- BIND_CONSTANT(COMPRESS_RANGE_CODER);
- BIND_CONSTANT(COMPRESS_FASTLZ);
- BIND_CONSTANT(COMPRESS_ZLIB);
- BIND_CONSTANT(COMPRESS_ZSTD);
+ BIND_ENUM_CONSTANT(COMPRESS_NONE);
+ BIND_ENUM_CONSTANT(COMPRESS_RANGE_CODER);
+ BIND_ENUM_CONSTANT(COMPRESS_FASTLZ);
+ BIND_ENUM_CONSTANT(COMPRESS_ZLIB);
+ BIND_ENUM_CONSTANT(COMPRESS_ZSTD);
}
NetworkedMultiplayerENet::NetworkedMultiplayerENet() {
diff --git a/modules/enet/networked_multiplayer_enet.h b/modules/enet/networked_multiplayer_enet.h
index f2c3b838e4..81d517147d 100644
--- a/modules/enet/networked_multiplayer_enet.h
+++ b/modules/enet/networked_multiplayer_enet.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/enet/register_types.cpp b/modules/enet/register_types.cpp
index a6e6c87c14..316aca6d94 100644
--- a/modules/enet/register_types.cpp
+++ b/modules/enet/register_types.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/enet/register_types.h b/modules/enet/register_types.h
index 9bcb35a92b..0775044bc7 100644
--- a/modules/enet/register_types.h
+++ b/modules/enet/register_types.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/etc/SCsub b/modules/etc/SCsub
index 8f5937017e..f0c1ee64b9 100644
--- a/modules/etc/SCsub
+++ b/modules/etc/SCsub
@@ -35,3 +35,7 @@ env_etc.add_source_files(env.modules_sources, "*.cpp")
# upstream uses c++11
env_etc.Append(CXXFLAGS="-std=gnu++11")
+# -ffast-math seems to be incompatible with ec2comp on recent versions of
+# GCC and Clang
+if '-ffast-math' in env_etc['CCFLAGS']:
+ env_etc['CCFLAGS'].remove('-ffast-math')
diff --git a/modules/etc/image_etc.cpp b/modules/etc/image_etc.cpp
index 353bd1274a..9a15beb6eb 100644
--- a/modules/etc/image_etc.cpp
+++ b/modules/etc/image_etc.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -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/etc/image_etc.h b/modules/etc/image_etc.h
index 3cbadef6fa..8cc0bdc08f 100644
--- a/modules/etc/image_etc.h
+++ b/modules/etc/image_etc.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/etc/register_types.cpp b/modules/etc/register_types.cpp
index e777859a8f..ef0a403e90 100644
--- a/modules/etc/register_types.cpp
+++ b/modules/etc/register_types.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/etc/register_types.h b/modules/etc/register_types.h
index 44399376f3..1d9a0e3b2c 100644
--- a/modules/etc/register_types.h
+++ b/modules/etc/register_types.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/etc/texture_loader_pkm.cpp b/modules/etc/texture_loader_pkm.cpp
index c04528d2a0..e8a5aced3e 100644
--- a/modules/etc/texture_loader_pkm.cpp
+++ b/modules/etc/texture_loader_pkm.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/etc/texture_loader_pkm.h b/modules/etc/texture_loader_pkm.h
index 8a0f06a51a..667870d7cc 100644
--- a/modules/etc/texture_loader_pkm.h
+++ b/modules/etc/texture_loader_pkm.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/freetype/SCsub b/modules/freetype/SCsub
index 6a89e8e087..f22df4407c 100644
--- a/modules/freetype/SCsub
+++ b/modules/freetype/SCsub
@@ -1,6 +1,7 @@
#!/usr/bin/env python
Import('env')
+from compat import isbasestring
# Not building in a separate env as scene needs it
@@ -74,7 +75,7 @@ if (env['builtin_freetype'] != 'no'):
# and then plain strings for system library. We insert between the two.
inserted = False
for idx, linklib in enumerate(env["LIBS"]):
- if isinstance(linklib, basestring): # first system lib such as "X11", otherwise SCons lib object
+ if isbasestring(linklib): # first system lib such as "X11", otherwise SCons lib object
env["LIBS"].insert(idx, lib)
inserted = True
break
diff --git a/modules/freetype/register_types.cpp b/modules/freetype/register_types.cpp
index 3f290c2138..de6e73a55e 100644
--- a/modules/freetype/register_types.cpp
+++ b/modules/freetype/register_types.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/freetype/register_types.h b/modules/freetype/register_types.h
index c3ba324ed1..ed8b5656b6 100644
--- a/modules/freetype/register_types.h
+++ b/modules/freetype/register_types.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/freetype/uwpdef.h b/modules/freetype/uwpdef.h
index c29b14dd12..ecde9946c7 100644
--- a/modules/freetype/uwpdef.h
+++ b/modules/freetype/uwpdef.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/gdnative/gdnative.cpp b/modules/gdnative/gdnative.cpp
index 440cc45479..7faf21c5a1 100644
--- a/modules/gdnative/gdnative.cpp
+++ b/modules/gdnative/gdnative.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -229,7 +229,7 @@ bool GDNative::initialize() {
godot_gdnative_init_options options;
- options.in_editor = SceneTree::get_singleton()->is_editor_hint();
+ options.in_editor = Engine::get_singleton()->is_editor_hint();
options.core_api_hash = ClassDB::get_api_hash(ClassDB::API_CORE);
options.editor_api_hash = ClassDB::get_api_hash(ClassDB::API_EDITOR);
options.no_api_hash = ClassDB::get_api_hash(ClassDB::API_NONE);
@@ -247,9 +247,8 @@ bool GDNative::terminate() {
return false;
}
- Error error = OK;
void *library_terminate;
- error = OS::get_singleton()->get_dynamic_library_symbol_handle(
+ Error error = OS::get_singleton()->get_dynamic_library_symbol_handle(
native_handle,
terminate_symbol,
library_terminate);
@@ -265,7 +264,7 @@ bool GDNative::terminate() {
// TODO(karroffel): remove this? Should be part of NativeScript, not
// GDNative IMO
godot_gdnative_terminate_options options;
- options.in_editor = SceneTree::get_singleton()->is_editor_hint();
+ options.in_editor = Engine::get_singleton()->is_editor_hint();
library_terminate_pointer(&options);
diff --git a/modules/gdnative/gdnative.h b/modules/gdnative/gdnative.h
index 003ec46a25..bec746a441 100644
--- a/modules/gdnative/gdnative.h
+++ b/modules/gdnative/gdnative.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/gdnative/godot/array.cpp b/modules/gdnative/godot/array.cpp
index 97c73dc253..c15ba30ca2 100644
--- a/modules/gdnative/godot/array.cpp
+++ b/modules/gdnative/godot/array.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/gdnative/godot/array.h b/modules/gdnative/godot/array.h
index 158170ba0e..434ce958c9 100644
--- a/modules/gdnative/godot/array.h
+++ b/modules/gdnative/godot/array.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/gdnative/godot/basis.cpp b/modules/gdnative/godot/basis.cpp
index 5cf379b7d5..1d7aa18a70 100644
--- a/modules/gdnative/godot/basis.cpp
+++ b/modules/gdnative/godot/basis.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -107,24 +107,6 @@ godot_basis GDAPI godot_basis_scaled(const godot_basis *p_self, const godot_vect
return dest;
}
-void GDAPI godot_basis_set_scale(godot_basis *p_self, const godot_vector3 *p_scale) {
- Basis *self = (Basis *)p_self;
- const Vector3 *scale = (const Vector3 *)p_scale;
- self->set_scale(*scale);
-}
-
-void GDAPI godot_basis_set_rotation_euler(godot_basis *p_self, const godot_vector3 *p_euler) {
- Basis *self = (Basis *)p_self;
- const Vector3 *euler = (const Vector3 *)p_euler;
- self->set_rotation_euler(*euler);
-}
-
-void GDAPI godot_basis_set_rotation_axis_angle(godot_basis *p_self, const godot_vector3 *p_axis, const godot_real p_angle) {
- Basis *self = (Basis *)p_self;
- const Vector3 *axis = (const Vector3 *)p_axis;
- self->set_rotation_axis_angle(*axis, p_angle);
-}
-
godot_vector3 GDAPI godot_basis_get_scale(const godot_basis *p_self) {
godot_vector3 dest;
const Basis *self = (const Basis *)p_self;
diff --git a/modules/gdnative/godot/basis.h b/modules/gdnative/godot/basis.h
index e96b8b730d..f36d2199de 100644
--- a/modules/gdnative/godot/basis.h
+++ b/modules/gdnative/godot/basis.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -67,12 +67,6 @@ godot_basis GDAPI godot_basis_rotated(const godot_basis *p_self, const godot_vec
godot_basis GDAPI godot_basis_scaled(const godot_basis *p_self, const godot_vector3 *p_scale);
-void GDAPI godot_basis_set_scale(godot_basis *p_self, const godot_vector3 *p_scale);
-
-void GDAPI godot_basis_set_rotation_euler(godot_basis *p_self, const godot_vector3 *p_euler);
-
-void GDAPI godot_basis_set_rotation_axis_angle(godot_basis *p_self, const godot_vector3 *p_axis, const godot_real p_angle);
-
godot_vector3 GDAPI godot_basis_get_scale(const godot_basis *p_self);
godot_vector3 GDAPI godot_basis_get_euler(const godot_basis *p_self);
diff --git a/modules/gdnative/godot/color.cpp b/modules/gdnative/godot/color.cpp
index a5ffee1e0b..3677fdc265 100644
--- a/modules/gdnative/godot/color.cpp
+++ b/modules/gdnative/godot/color.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/gdnative/godot/color.h b/modules/gdnative/godot/color.h
index 2cd6b48b48..5d550e40b3 100644
--- a/modules/gdnative/godot/color.h
+++ b/modules/gdnative/godot/color.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/gdnative/godot/dictionary.cpp b/modules/gdnative/godot/dictionary.cpp
index c538456432..2996cc78a3 100644
--- a/modules/gdnative/godot/dictionary.cpp
+++ b/modules/gdnative/godot/dictionary.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/gdnative/godot/dictionary.h b/modules/gdnative/godot/dictionary.h
index 594b02b4dd..bbe40f23c3 100644
--- a/modules/gdnative/godot/dictionary.h
+++ b/modules/gdnative/godot/dictionary.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/gdnative/godot/gdnative.cpp b/modules/gdnative/godot/gdnative.cpp
index 4cda1f4560..7cd52da34d 100644
--- a/modules/gdnative/godot/gdnative.cpp
+++ b/modules/gdnative/godot/gdnative.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/gdnative/godot/gdnative.h b/modules/gdnative/godot/gdnative.h
index d849999079..8b289da1f5 100644
--- a/modules/gdnative/godot/gdnative.h
+++ b/modules/gdnative/godot/gdnative.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/gdnative/godot/node_path.cpp b/modules/gdnative/godot/node_path.cpp
index f4179361be..2309588a81 100644
--- a/modules/gdnative/godot/node_path.cpp
+++ b/modules/gdnative/godot/node_path.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/gdnative/godot/node_path.h b/modules/gdnative/godot/node_path.h
index 4d3dc4e0ee..3e2a99e461 100644
--- a/modules/gdnative/godot/node_path.h
+++ b/modules/gdnative/godot/node_path.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/gdnative/godot/plane.cpp b/modules/gdnative/godot/plane.cpp
index 5c5b302345..f3d4b6971e 100644
--- a/modules/gdnative/godot/plane.cpp
+++ b/modules/gdnative/godot/plane.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/gdnative/godot/plane.h b/modules/gdnative/godot/plane.h
index 8519ac60c4..27548c8b0c 100644
--- a/modules/gdnative/godot/plane.h
+++ b/modules/gdnative/godot/plane.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/gdnative/godot/pool_arrays.cpp b/modules/gdnative/godot/pool_arrays.cpp
index fa460be8bc..2e533077f6 100644
--- a/modules/gdnative/godot/pool_arrays.cpp
+++ b/modules/gdnative/godot/pool_arrays.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/gdnative/godot/pool_arrays.h b/modules/gdnative/godot/pool_arrays.h
index 29517d21ac..ecd85ddfe8 100644
--- a/modules/gdnative/godot/pool_arrays.h
+++ b/modules/gdnative/godot/pool_arrays.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/gdnative/godot/quat.cpp b/modules/gdnative/godot/quat.cpp
index 37ee4d6b15..e6bea78b60 100644
--- a/modules/gdnative/godot/quat.cpp
+++ b/modules/gdnative/godot/quat.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/gdnative/godot/quat.h b/modules/gdnative/godot/quat.h
index 0979653d93..9a3238a337 100644
--- a/modules/gdnative/godot/quat.h
+++ b/modules/gdnative/godot/quat.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/gdnative/godot/rect2.cpp b/modules/gdnative/godot/rect2.cpp
index 023584c4f6..98e7855dc9 100644
--- a/modules/gdnative/godot/rect2.cpp
+++ b/modules/gdnative/godot/rect2.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/gdnative/godot/rect2.h b/modules/gdnative/godot/rect2.h
index cb1ddb58cf..8ceeddf1b4 100644
--- a/modules/gdnative/godot/rect2.h
+++ b/modules/gdnative/godot/rect2.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/gdnative/godot/rect3.cpp b/modules/gdnative/godot/rect3.cpp
index 708d2987f2..88952ab49c 100644
--- a/modules/gdnative/godot/rect3.cpp
+++ b/modules/gdnative/godot/rect3.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/gdnative/godot/rect3.h b/modules/gdnative/godot/rect3.h
index 69279351c4..ca96aadd5c 100644
--- a/modules/gdnative/godot/rect3.h
+++ b/modules/gdnative/godot/rect3.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/gdnative/godot/rid.cpp b/modules/gdnative/godot/rid.cpp
index eb9538e692..51c8aaa1b3 100644
--- a/modules/gdnative/godot/rid.cpp
+++ b/modules/gdnative/godot/rid.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -50,7 +50,7 @@ godot_int GDAPI godot_rid_get_id(const godot_rid *p_self) {
}
void GDAPI godot_rid_new_with_resource(godot_rid *r_dest, const godot_object *p_from) {
- const Resource *res_from = ((const Object *)p_from)->cast_to<Resource>();
+ const Resource *res_from = Object::cast_to<Resource>((Object *)p_from);
godot_rid_new(r_dest);
if (res_from) {
RID *dest = (RID *)r_dest;
diff --git a/modules/gdnative/godot/rid.h b/modules/gdnative/godot/rid.h
index ac5b5383d9..b685157cec 100644
--- a/modules/gdnative/godot/rid.h
+++ b/modules/gdnative/godot/rid.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/gdnative/godot/string.cpp b/modules/gdnative/godot/string.cpp
index 2235c12a2d..3790b6ea95 100644
--- a/modules/gdnative/godot/string.cpp
+++ b/modules/gdnative/godot/string.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/gdnative/godot/string.h b/modules/gdnative/godot/string.h
index c901ce36e6..f41626faa1 100644
--- a/modules/gdnative/godot/string.h
+++ b/modules/gdnative/godot/string.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -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/gdnative/godot/transform.cpp b/modules/gdnative/godot/transform.cpp
index 87fee918bd..a965067b77 100644
--- a/modules/gdnative/godot/transform.cpp
+++ b/modules/gdnative/godot/transform.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/gdnative/godot/transform.h b/modules/gdnative/godot/transform.h
index 30b9970f67..60788e3d57 100644
--- a/modules/gdnative/godot/transform.h
+++ b/modules/gdnative/godot/transform.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/gdnative/godot/transform2d.cpp b/modules/gdnative/godot/transform2d.cpp
index 65f9f8ee32..9fc44ecdfa 100644
--- a/modules/gdnative/godot/transform2d.cpp
+++ b/modules/gdnative/godot/transform2d.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/gdnative/godot/transform2d.h b/modules/gdnative/godot/transform2d.h
index 41c8ba982c..c0f5725eed 100644
--- a/modules/gdnative/godot/transform2d.h
+++ b/modules/gdnative/godot/transform2d.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/gdnative/godot/variant.cpp b/modules/gdnative/godot/variant.cpp
index d814ef913c..582544b3a0 100644
--- a/modules/gdnative/godot/variant.cpp
+++ b/modules/gdnative/godot/variant.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/gdnative/godot/variant.h b/modules/gdnative/godot/variant.h
index 1c19d2a25b..fda24db8d4 100644
--- a/modules/gdnative/godot/variant.h
+++ b/modules/gdnative/godot/variant.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/gdnative/godot/vector2.cpp b/modules/gdnative/godot/vector2.cpp
index 05d4b1acc8..78ed5f06a9 100644
--- a/modules/gdnative/godot/vector2.cpp
+++ b/modules/gdnative/godot/vector2.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/gdnative/godot/vector2.h b/modules/gdnative/godot/vector2.h
index 9db238b4fd..98e9700e32 100644
--- a/modules/gdnative/godot/vector2.h
+++ b/modules/gdnative/godot/vector2.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/gdnative/godot/vector3.cpp b/modules/gdnative/godot/vector3.cpp
index fe27e740e2..5faeac2864 100644
--- a/modules/gdnative/godot/vector3.cpp
+++ b/modules/gdnative/godot/vector3.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/gdnative/godot/vector3.h b/modules/gdnative/godot/vector3.h
index 8aba1d9a85..b76ca11a9c 100644
--- a/modules/gdnative/godot/vector3.h
+++ b/modules/gdnative/godot/vector3.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/gdnative/register_types.cpp b/modules/gdnative/register_types.cpp
index da50104e26..9ad05b7194 100644
--- a/modules/gdnative/register_types.cpp
+++ b/modules/gdnative/register_types.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/gdnative/register_types.h b/modules/gdnative/register_types.h
index 48e778cb2c..08da72016f 100644
--- a/modules/gdnative/register_types.h
+++ b/modules/gdnative/register_types.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/gdscript/gd_compiler.cpp b/modules/gdscript/gd_compiler.cpp
index d4ede4cb17..4803781c67 100644
--- a/modules/gdscript/gd_compiler.cpp
+++ b/modules/gdscript/gd_compiler.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -1451,15 +1451,13 @@ Error GDCompiler::_parse_function(GDScript *p_script, const GDParser::ClassNode
codegen.opcodes.push_back(GDFunction::OPCODE_END);
- GDFunction *gdfunc = NULL;
-
/*
if (String(p_func->name)=="") { //initializer func
gdfunc = &p_script->initializer;
*/
//} else { //regular func
p_script->member_functions[func_name] = memnew(GDFunction);
- gdfunc = p_script->member_functions[func_name];
+ GDFunction *gdfunc = p_script->member_functions[func_name];
//}
if (p_func) {
@@ -1973,7 +1971,7 @@ Error GDCompiler::_parse_class(GDScript *p_script, GDScript *p_owner, const GDPa
p_script->placeholders.erase(psi); //remove placeholder
GDInstance *instance = memnew(GDInstance);
- instance->base_ref = E->get()->cast_to<Reference>();
+ instance->base_ref = Object::cast_to<Reference>(E->get());
instance->members.resize(p_script->member_indices.size());
instance->script = Ref<GDScript>(p_script);
instance->owner = E->get();
diff --git a/modules/gdscript/gd_compiler.h b/modules/gdscript/gd_compiler.h
index b7ff092eba..ac713ae75b 100644
--- a/modules/gdscript/gd_compiler.h
+++ b/modules/gdscript/gd_compiler.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -91,7 +91,6 @@ class GDCompiler {
}
}
- //int get_identifier_pos(const StringName& p_dentifier) const;
HashMap<Variant, int, VariantHasher, VariantComparator> constant_map;
Map<StringName, int> name_map;
@@ -127,17 +126,6 @@ class GDCompiler {
int call_max;
};
-#if 0
- void _create_index(const GDParser::OperatorNode *on);
- void _create_call(const GDParser::OperatorNode *on);
-
-
- int _parse_expression(const GDParser::Node *p_expr,CodeGen& codegen);
- void _parse_block(GDParser::BlockNode *p_block);
- void _parse_function(GDParser::FunctionNode *p_func);
- Ref<GDScript> _parse_class(GDParser::ClassNode *p_class);
-#endif
-
bool _is_class_member_property(CodeGen &codegen, const StringName &p_name);
bool _is_class_member_property(GDScript *owner, const StringName &p_name);
@@ -146,7 +134,6 @@ class GDCompiler {
bool _create_unary_operator(CodeGen &codegen, const GDParser::OperatorNode *on, Variant::Operator op, int p_stack_level);
bool _create_binary_operator(CodeGen &codegen, const GDParser::OperatorNode *on, Variant::Operator op, int p_stack_level, bool p_initializer = false);
- //int _parse_subexpression(CodeGen& codegen,const GDParser::BlockNode *p_block,const GDParser::Node *p_expression);
int _parse_assign_right_expression(CodeGen &codegen, const GDParser::OperatorNode *p_expression, int p_stack_level);
int _parse_expression(CodeGen &codegen, const GDParser::Node *p_expression, int p_stack_level, bool p_root = false, bool p_initializer = false);
Error _parse_block(CodeGen &codegen, const GDParser::BlockNode *p_block, int p_stack_level = 0, int p_break_addr = -1, int p_continue_addr = -1);
diff --git a/modules/gdscript/gd_editor.cpp b/modules/gdscript/gd_editor.cpp
index f8b45af85a..70e7da5748 100644
--- a/modules/gdscript/gd_editor.cpp
+++ b/modules/gdscript/gd_editor.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -27,14 +27,18 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+#include "gd_script.h"
+
#include "editor/editor_settings.h"
#include "gd_compiler.h"
-#include "gd_script.h"
+#include "global_constants.h"
#include "os/file_access.h"
#include "project_settings.h"
+
#ifdef TOOLS_ENABLED
#include "editor/editor_file_system.h"
#include "editor/editor_settings.h"
+#include "engine.h"
#endif
void GDScriptLanguage::get_comment_delimiters(List<String> *p_delimiters) const {
@@ -293,23 +297,25 @@ void GDScriptLanguage::get_public_functions(List<MethodInfo> *p_functions) const
//not really "functions", but..
{
MethodInfo mi;
- mi.name = "preload:Resource";
+ mi.name = "preload";
mi.arguments.push_back(PropertyInfo(Variant::STRING, "path"));
mi.return_val = PropertyInfo(Variant::OBJECT, "", PROPERTY_HINT_RESOURCE_TYPE, "Resource");
p_functions->push_back(mi);
}
{
MethodInfo mi;
- mi.name = "yield:GDFunctionState";
+ mi.name = "yield";
mi.arguments.push_back(PropertyInfo(Variant::OBJECT, "object"));
mi.arguments.push_back(PropertyInfo(Variant::STRING, "signal"));
mi.default_arguments.push_back(Variant::NIL);
mi.default_arguments.push_back(Variant::STRING);
+ mi.return_val = PropertyInfo(Variant::OBJECT, "", PROPERTY_HINT_RESOURCE_TYPE, "GDFunctionState");
p_functions->push_back(mi);
}
{
MethodInfo mi;
mi.name = "assert";
+ mi.return_val.type = Variant::NIL;
mi.arguments.push_back(PropertyInfo(Variant::BOOL, "condition"));
p_functions->push_back(mi);
}
@@ -354,13 +360,14 @@ String GDScriptLanguage::make_function(const String &p_class, const String &p_na
struct GDCompletionIdentifier {
+ String enumeration;
StringName obj_type;
Ref<GDScript> script;
Variant::Type type;
Variant value; //im case there is a value, also return it
};
-static GDCompletionIdentifier _get_type_from_variant(const Variant &p_variant) {
+static GDCompletionIdentifier _get_type_from_variant(const Variant &p_variant, bool p_allow_gdnative_class = false) {
GDCompletionIdentifier t;
t.type = p_variant.get_type();
@@ -368,14 +375,14 @@ static GDCompletionIdentifier _get_type_from_variant(const Variant &p_variant) {
if (p_variant.get_type() == Variant::OBJECT) {
Object *obj = p_variant;
if (obj) {
- /*
- if (obj->cast_to<GDNativeClass>()) {
- t.obj_type=obj->cast_to<GDNativeClass>()->get_name();
- t.value=Variant();
+
+ if (p_allow_gdnative_class && Object::cast_to<GDNativeClass>(obj)) {
+ t.obj_type = Object::cast_to<GDNativeClass>(obj)->get_name();
+ t.value = Variant();
} else {
- */
- t.obj_type = obj->get_class();
- //}
+
+ t.obj_type = obj->get_class();
+ }
}
}
return t;
@@ -508,9 +515,9 @@ static GDCompletionIdentifier _get_native_class(GDCompletionContext &context) {
return id;
}
-static bool _guess_identifier_type(GDCompletionContext &context, int p_line, const StringName &p_identifier, GDCompletionIdentifier &r_type);
+static bool _guess_identifier_type(GDCompletionContext &context, int p_line, const StringName &p_identifier, GDCompletionIdentifier &r_type, bool p_for_indexing);
-static bool _guess_expression_type(GDCompletionContext &context, const GDParser::Node *p_node, int p_line, GDCompletionIdentifier &r_type) {
+static bool _guess_expression_type(GDCompletionContext &context, const GDParser::Node *p_node, int p_line, GDCompletionIdentifier &r_type, bool p_for_indexing = false) {
if (p_node->type == GDParser::Node::TYPE_CONSTANT) {
@@ -561,7 +568,7 @@ static bool _guess_expression_type(GDCompletionContext &context, const GDParser:
return true;
} else if (p_node->type == GDParser::Node::TYPE_IDENTIFIER) {
- return _guess_identifier_type(context, p_line - 1, static_cast<const GDParser::IdentifierNode *>(p_node)->name, r_type);
+ return _guess_identifier_type(context, p_line - 1, static_cast<const GDParser::IdentifierNode *>(p_node)->name, r_type, p_for_indexing);
} else if (p_node->type == GDParser::Node::TYPE_SELF) {
//eeh...
@@ -572,6 +579,7 @@ static bool _guess_expression_type(GDCompletionContext &context, const GDParser:
const GDParser::OperatorNode *op = static_cast<const GDParser::OperatorNode *>(p_node);
if (op->op == GDParser::OperatorNode::OP_CALL) {
+
if (op->arguments[0]->type == GDParser::Node::TYPE_TYPE) {
const GDParser::TypeNode *tn = static_cast<const GDParser::TypeNode *>(op->arguments[0]);
@@ -584,22 +592,45 @@ static bool _guess_expression_type(GDCompletionContext &context, const GDParser:
} else if (op->arguments.size() > 1 && op->arguments[1]->type == GDParser::Node::TYPE_IDENTIFIER) {
+ StringName id = static_cast<const GDParser::IdentifierNode *>(op->arguments[1])->name;
+
+ if (op->arguments[0]->type == GDParser::Node::TYPE_IDENTIFIER && String(id) == "new") {
+
+ //shortcut
+ StringName identifier = static_cast<const GDParser::IdentifierNode *>(op->arguments[0])->name;
+
+ if (ClassDB::class_exists(identifier)) {
+ r_type.type = Variant::OBJECT;
+ r_type.value = Variant();
+ r_type.obj_type = identifier;
+ return true;
+ }
+ }
+
GDCompletionIdentifier base;
if (!_guess_expression_type(context, op->arguments[0], p_line, base))
return false;
- StringName id = static_cast<const GDParser::IdentifierNode *>(op->arguments[1])->name;
-
if (base.type == Variant::OBJECT) {
if (id.operator String() == "new" && base.value.get_type() == Variant::OBJECT) {
+
Object *obj = base.value;
- if (obj && obj->cast_to<GDNativeClass>()) {
- GDNativeClass *gdnc = obj->cast_to<GDNativeClass>();
+ if (obj && Object::cast_to<GDNativeClass>(obj)) {
+ GDNativeClass *gdnc = Object::cast_to<GDNativeClass>(obj);
r_type.type = Variant::OBJECT;
r_type.value = Variant();
r_type.obj_type = gdnc->get_name();
return true;
+ } else {
+
+ if (base.obj_type != StringName()) {
+
+ r_type.type = Variant::OBJECT;
+ r_type.value = Variant();
+ r_type.obj_type = base.obj_type;
+ return true;
+ }
}
}
@@ -607,7 +638,7 @@ static bool _guess_expression_type(GDCompletionContext &context, const GDParser:
#ifdef TOOLS_ENABLED
MethodBind *mb = ClassDB::get_method(base.obj_type, id);
- PropertyInfo pi = mb->get_argument_info(-1);
+ PropertyInfo pi = mb->get_return_info();
//try calling the function if constant and all args are constant, should not crash..
Object *baseptr = base.value;
@@ -808,6 +839,47 @@ static bool _guess_expression_type(GDCompletionContext &context, const GDParser:
if (p1.value.get_type() == Variant::OBJECT) {
//??
+
+ if (p1.obj_type != StringName() && p2.type == Variant::STRING) {
+
+ StringName base_type = p1.obj_type;
+
+ if (p1.obj_type == "GDNativeClass") {
+ //native enum
+ Ref<GDNativeClass> gdn = p1.value;
+ if (gdn.is_valid()) {
+
+ base_type = gdn->get_name();
+ }
+ }
+ StringName index = p2.value;
+ bool valid;
+ Variant::Type t = ClassDB::get_property_type(base_type, index, &valid);
+ if (t != Variant::NIL && valid) {
+ r_type.type = t;
+ if (t == Variant::INT || t == Variant::OBJECT) {
+//check for enum!
+#if defined(DEBUG_METHODS_ENABLED) && defined(TOOLS_ENABLED)
+
+ StringName getter = ClassDB::get_property_getter(base_type, index);
+ if (getter != StringName()) {
+ MethodBind *mb = ClassDB::get_method(base_type, getter);
+ if (mb) {
+ PropertyInfo rt = mb->get_return_info();
+ if (rt.usage & PROPERTY_USAGE_CLASS_IS_ENUM && t == Variant::INT) {
+ r_type.enumeration = rt.class_name;
+ } else if (t == Variant::OBJECT) {
+
+ r_type.obj_type = rt.class_name;
+ }
+ }
+ }
+#endif
+ }
+
+ return true;
+ }
+ }
} else if (p1.value.get_type() != Variant::NIL) {
bool valid;
@@ -901,12 +973,42 @@ static bool _guess_expression_type(GDCompletionContext &context, const GDParser:
static bool _guess_identifier_type_in_block(GDCompletionContext &context, int p_line, const StringName &p_identifier, GDCompletionIdentifier &r_type) {
+ if (context.block->if_condition && context.block->if_condition->type == GDParser::Node::TYPE_OPERATOR && static_cast<const GDParser::OperatorNode *>(context.block->if_condition)->op == GDParser::OperatorNode::OP_IS) {
+ //is used, check if identifier is in there! this helps resolve in blocks that are (if (identifier is value)): which are very common..
+ //super dirty hack, but very useful
+ //credit: Zylann
+ //TODO: this could be hacked to detect ANDed conditions too..
+ const GDParser::OperatorNode *op = static_cast<const GDParser::OperatorNode *>(context.block->if_condition);
+ if (op->arguments[0]->type == GDParser::Node::TYPE_IDENTIFIER && static_cast<const GDParser::IdentifierNode *>(op->arguments[0])->name == p_identifier) {
+ //bingo
+ if (_guess_expression_type(context, op->arguments[1], op->line, r_type)) {
+ return true;
+ }
+ }
+ }
+
GDCompletionIdentifier gdi = _get_native_class(context);
if (gdi.obj_type != StringName()) {
bool valid;
Variant::Type t = ClassDB::get_property_type(gdi.obj_type, p_identifier, &valid);
if (t != Variant::NIL && valid) {
r_type.type = t;
+ if (t == Variant::INT) {
+//check for enum!
+#if defined(DEBUG_METHODS_ENABLED) && defined(TOOLS_ENABLED)
+
+ StringName getter = ClassDB::get_property_getter(gdi.obj_type, p_identifier);
+ if (getter != StringName()) {
+ MethodBind *mb = ClassDB::get_method(gdi.obj_type, getter);
+ if (mb) {
+ PropertyInfo rt = mb->get_return_info();
+ if (rt.usage & PROPERTY_USAGE_CLASS_IS_ENUM) {
+ r_type.enumeration = rt.class_name;
+ }
+ }
+ }
+#endif
+ }
return true;
}
}
@@ -996,7 +1098,7 @@ static bool _guess_identifier_from_assignment_in_function(GDCompletionContext &c
return false;
}
-static bool _guess_identifier_type(GDCompletionContext &context, int p_line, const StringName &p_identifier, GDCompletionIdentifier &r_type) {
+static bool _guess_identifier_type(GDCompletionContext &context, int p_line, const StringName &p_identifier, GDCompletionIdentifier &r_type, bool p_for_indexing) {
//go to block first
@@ -1040,11 +1142,11 @@ static bool _guess_identifier_type(GDCompletionContext &context, int p_line, con
PropertyInfo arg = E->get().arguments[argindex];
- int scp = arg.name.find(":");
+ int scp = String(arg.name).find(":");
if (scp != -1) {
r_type.type = Variant::OBJECT;
- r_type.obj_type = arg.name.substr(scp + 1, arg.name.length());
+ r_type.obj_type = String(arg.name).substr(scp + 1, String(arg.name).length());
return true;
} else {
@@ -1150,7 +1252,7 @@ static bool _guess_identifier_type(GDCompletionContext &context, int p_line, con
for (Map<StringName, int>::Element *E = GDScriptLanguage::get_singleton()->get_global_map().front(); E; E = E->next()) {
if (E->key() == p_identifier) {
- r_type = _get_type_from_variant(GDScriptLanguage::get_singleton()->get_global_array()[E->get()]);
+ r_type = _get_type_from_variant(GDScriptLanguage::get_singleton()->get_global_array()[E->get()], !p_for_indexing);
return true;
}
}
@@ -1270,7 +1372,7 @@ static void _find_identifiers_in_class(GDCompletionContext &context, bool p_stat
for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) {
if (E->get().usage & (PROPERTY_USAGE_GROUP | PROPERTY_USAGE_CATEGORY))
continue;
- if (E->get().name.find("/") != -1)
+ if (String(E->get().name).find("/") != -1)
continue;
result.insert(E->get().name);
}
@@ -1435,7 +1537,7 @@ void get_directory_contents(EditorFileSystemDirectory *p_dir, Set<String> &r_lis
}
}
-static void _find_type_arguments(GDCompletionContext &context, const GDParser::Node *p_node, int p_line, const StringName &p_method, const GDCompletionIdentifier &id, int p_argidx, Set<String> &result, String &arghint) {
+static void _find_type_arguments(GDCompletionContext &context, const GDParser::Node *p_node, int p_line, const StringName &p_method, const GDCompletionIdentifier &id, int p_argidx, Set<String> &result, bool &r_forced, String &arghint) {
//print_line("find type arguments?");
if (id.type == Variant::OBJECT && id.obj_type != StringName()) {
@@ -1450,46 +1552,45 @@ static void _find_type_arguments(GDCompletionContext &context, const GDParser::N
if (id.value.get_type()) {
Object *obj = id.value;
- if (obj) {
-
- GDScript *scr = obj->cast_to<GDScript>();
- if (scr) {
- while (scr) {
+ GDScript *scr = Object::cast_to<GDScript>(obj);
+ if (scr) {
+ while (scr) {
- for (const Map<StringName, GDFunction *>::Element *E = scr->get_member_functions().front(); E; E = E->next()) {
- if (E->get()->is_static() && p_method == E->get()->get_name()) {
- arghint = "static func " + String(p_method) + "(";
- for (int i = 0; i < E->get()->get_argument_count(); i++) {
- if (i > 0)
- arghint += ", ";
- else
- arghint += " ";
- if (i == p_argidx) {
- arghint += String::chr(0xFFFF);
- }
- arghint += "var " + E->get()->get_argument_name(i);
- int deffrom = E->get()->get_argument_count() - E->get()->get_default_argument_count();
- if (i >= deffrom) {
- int defidx = deffrom - i;
- if (defidx >= 0 && defidx < E->get()->get_default_argument_count()) {
- arghint += "=" + E->get()->get_default_argument(defidx).get_construct_string();
- }
- }
- if (i == p_argidx) {
- arghint += String::chr(0xFFFF);
+ for (const Map<StringName, GDFunction *>::Element *E = scr->get_member_functions().front(); E; E = E->next()) {
+ if (E->get()->is_static() && p_method == E->get()->get_name()) {
+ arghint = "static func " + String(p_method) + "(";
+ for (int i = 0; i < E->get()->get_argument_count(); i++) {
+ if (i > 0)
+ arghint += ", ";
+ else
+ arghint += " ";
+ if (i == p_argidx) {
+ arghint += String::chr(0xFFFF);
+ }
+ arghint += "var " + E->get()->get_argument_name(i);
+ int deffrom = E->get()->get_argument_count() - E->get()->get_default_argument_count();
+ if (i >= deffrom) {
+ int defidx = deffrom - i;
+ if (defidx >= 0 && defidx < E->get()->get_default_argument_count()) {
+ arghint += "=" + E->get()->get_default_argument(defidx).get_construct_string();
}
}
- arghint += ")";
- return; //found
+ if (i == p_argidx) {
+ arghint += String::chr(0xFFFF);
+ }
}
+ arghint += ")";
+ return; //found
}
-
- if (scr->get_base().is_valid())
- scr = scr->get_base().ptr();
- else
- scr = NULL;
}
- } else {
+
+ if (scr->get_base().is_valid())
+ scr = scr->get_base().ptr();
+ else
+ scr = NULL;
+ }
+ } else {
+ if (obj) {
on_script = obj->get_script();
}
}
@@ -1615,21 +1716,6 @@ static void _find_type_arguments(GDCompletionContext &context, const GDParser::N
return; //found
}
}
-#if 0
- //use class directly, no code was found
- if (!isfunction) {
- for (const Map<StringName,Variant>::Element *E=scr->get_constants().front();E;E=E->next()) {
- options.insert(E->key());
- }
- }
- for (const Map<StringName,GDFunction>::Element *E=scr->get_member_functions().front();E;E=E->next()) {
- options.insert(String(E->key())+"(");
- }
-
- for (const Set<StringName>::Element *E=scr->get_members().front();E;E=E->next()) {
- options.insert(E->get());
- }
-#endif
}
if (scr->get_base().is_valid())
@@ -1641,8 +1727,43 @@ static void _find_type_arguments(GDCompletionContext &context, const GDParser::N
}
} else {
- //regular method
+//regular method
+#if defined(DEBUG_METHODS_ENABLED) && defined(TOOLS_ENABLED)
+ if (p_argidx < m->get_argument_count()) {
+ PropertyInfo pi = m->get_argument_info(p_argidx);
+
+ if (pi.usage & PROPERTY_USAGE_CLASS_IS_ENUM) {
+ String enumeration = pi.class_name;
+ if (enumeration.find(".") != -1) {
+ //class constant
+ List<StringName> constants;
+ String cls = enumeration.get_slice(".", 0);
+ String enm = enumeration.get_slice(".", 1);
+
+ ClassDB::get_enum_constants(cls, enm, &constants);
+ //constants.sort_custom<StringName::AlphCompare>();
+ for (List<StringName>::Element *E = constants.front(); E; E = E->next()) {
+ String add = cls + "." + E->get();
+ result.insert(add);
+ r_forced = true;
+ }
+ } else {
+
+ //global constant
+ StringName current_enum = enumeration;
+
+ for (int i = 0; i < GlobalConstants::get_global_constant_count(); i++) {
+ if (GlobalConstants::get_global_constant_enum(i) == current_enum) {
+ result.insert(GlobalConstants::get_global_constant_name(i));
+ r_forced = true;
+ }
+ }
+ //global
+ }
+ }
+ }
+#endif
if (p_method.operator String() == "connect" || (p_method.operator String() == "emit_signal" && p_argidx == 0)) {
if (p_argidx == 0) {
@@ -1663,6 +1784,7 @@ static void _find_type_arguments(GDCompletionContext &context, const GDParser::N
for (List<MethodInfo>::Element *E = sigs.front(); E; E = E->next()) {
result.insert("\"" + E->get().name + "\"");
+ r_forced = true;
}
} else if (p_argidx == 2) {
@@ -1670,6 +1792,7 @@ static void _find_type_arguments(GDCompletionContext &context, const GDParser::N
if (context._class) {
for (int i = 0; i < context._class->functions.size(); i++) {
result.insert("\"" + context._class->functions[i]->name + "\"");
+ r_forced = true;
}
}
}
@@ -1695,6 +1818,7 @@ static void _find_type_arguments(GDCompletionContext &context, const GDParser::N
//print_line("found "+s);
String name = s.get_slice("/", 1);
result.insert("\"/root/" + name + "\"");
+ r_forced = true;
}
}
@@ -1706,11 +1830,12 @@ static void _find_type_arguments(GDCompletionContext &context, const GDParser::N
for (List<String>::Element *E = options.front(); E; E = E->next()) {
result.insert(E->get());
+ r_forced = true;
}
}
}
- arghint = _get_visual_datatype(m->get_argument_info(-1), false) + " " + p_method.operator String() + String("(");
+ arghint = _get_visual_datatype(m->get_return_info(), false) + " " + p_method.operator String() + String("(");
for (int i = 0; i < m->get_argument_count(); i++) {
if (i > 0)
@@ -1749,7 +1874,7 @@ static void _find_type_arguments(GDCompletionContext &context, const GDParser::N
}
}
-static void _find_call_arguments(GDCompletionContext &context, const GDParser::Node *p_node, int p_line, int p_argidx, Set<String> &result, String &arghint) {
+static void _find_call_arguments(GDCompletionContext &context, const GDParser::Node *p_node, int p_line, int p_argidx, Set<String> &result, bool &r_forced, String &arghint) {
if (!p_node || p_node->type != GDParser::Node::TYPE_OPERATOR) {
@@ -1778,11 +1903,11 @@ static void _find_call_arguments(GDCompletionContext &context, const GDParser::N
arghint += ", ";
else
arghint += " ";
- if (i == p_argidx) {
+ if (i == p_argidx || (mi.flags & METHOD_FLAG_VARARG && i > p_argidx)) {
arghint += String::chr(0xFFFF);
}
arghint += _get_visual_datatype(mi.arguments[i]) + " " + mi.arguments[i].name;
- if (i == p_argidx) {
+ if (i == p_argidx || (mi.flags & METHOD_FLAG_VARARG && i > p_argidx)) {
arghint += String::chr(0xFFFF);
}
}
@@ -1904,7 +2029,7 @@ static void _find_call_arguments(GDCompletionContext &context, const GDParser::N
if (!context._class->owner)
ci.value = context.base;
- _find_type_arguments(context, p_node, p_line, id->name, ci, p_argidx, result, arghint);
+ _find_type_arguments(context, p_node, p_line, id->name, ci, p_argidx, result, r_forced, arghint);
//guess type..
/*
List<MethodInfo> methods;
@@ -1926,114 +2051,21 @@ static void _find_call_arguments(GDCompletionContext &context, const GDParser::N
GDCompletionIdentifier ci;
if (_guess_expression_type(context, op->arguments[0], p_line, ci)) {
- _find_type_arguments(context, p_node, p_line, id->name, ci, p_argidx, result, arghint);
+ _find_type_arguments(context, p_node, p_line, id->name, ci, p_argidx, result, r_forced, arghint);
return;
}
}
}
-#if 0
- bool _static=context.function->_static;
-
-
-
-
- for(int i=0;i<context._class->static_functions.size();i++) {
- if (context._class->static_functions[i]->arguments.size())
- result.insert(context._class->static_functions[i]->name.operator String()+"(");
- else
- result.insert(context._class->static_functions[i]->name.operator String()+"()");
- }
-
- if (!p_static) {
-
- for(int i=0;i<context._class->functions.size();i++) {
- if (context._class->functions[i]->arguments.size())
- result.insert(context._class->functions[i]->name.operator String()+"(");
- else
- result.insert(context._class->functions[i]->name.operator String()+"()");
- }
- }
-
- Ref<Reference> base = _get_parent_class(context);
-
- while(true) {
-
- Ref<GDScript> script = base;
- Ref<GDNativeClass> nc = base;
- if (script.is_valid()) {
-
- if (!p_static && !p_only_functions) {
- for (const Set<StringName>::Element *E=script->get_members().front();E;E=E->next()) {
- result.insert(E->get().operator String());
- }
- }
-
- if (!p_only_functions) {
- for (const Map<StringName,Variant>::Element *E=script->get_constants().front();E;E=E->next()) {
- result.insert(E->key().operator String());
- }
- }
-
- for (const Map<StringName,GDFunction>::Element *E=script->get_member_functions().front();E;E=E->next()) {
- if (!p_static || E->get().is_static()) {
- if (E->get().get_argument_count())
- result.insert(E->key().operator String()+"(");
- else
- result.insert(E->key().operator String()+"()");
- }
- }
-
- if (!p_only_functions) {
- for (const Map<StringName,Ref<GDScript> >::Element *E=script->get_subclasses().front();E;E=E->next()) {
- result.insert(E->key().operator String());
- }
- }
-
- base=script->get_base();
- if (base.is_null())
- base=script->get_native();
- } else if (nc.is_valid()) {
-
- if (!p_only_functions) {
-
- StringName type = nc->get_name();
- List<String> constants;
- ClassDB::get_integer_constant_list(type,&constants);
- for(List<String>::Element *E=constants.front();E;E=E->next()) {
- result.insert(E->get());
- }
-
- List<MethodInfo> methods;
- ClassDB::get_method_list(type,&methods);
- for(List<MethodInfo>::Element *E=methods.front();E;E=E->next()) {
- if (E->get().arguments.size())
- result.insert(E->get().name+"(");
- else
- result.insert(E->get().name+"()");
- }
- }
- break;
- } else
- break;
-
- }
-
- for(int i=0;i<GDFunctions::FUNC_MAX;i++) {
-
- result.insert(GDFunctions::get_func_name(GDFunctions::Function(i)));
- }
-
-#endif
}
-Error GDScriptLanguage::complete_code(const String &p_code, const String &p_base_path, Object *p_owner, List<String> *r_options, String &r_call_hint) {
+Error GDScriptLanguage::complete_code(const String &p_code, const String &p_base_path, Object *p_owner, List<String> *r_options, bool &r_forced, String &r_call_hint) {
GDParser p;
p.parse(p_code, p_base_path, false, "", true);
bool isfunction = false;
Set<String> options;
-
+ r_forced = false;
GDCompletionContext context;
context._class = p.get_completion_class();
context.block = p.get_completion_block();
@@ -2072,6 +2104,7 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_base
String opt = E->get().strip_edges();
if (opt.begins_with("\"") && opt.ends_with("\"")) {
+ r_forced = true;
String idopt = opt.substr(1, opt.length() - 2);
if (idopt.replace("/", "_").is_valid_identifier()) {
options.insert(idopt);
@@ -2091,7 +2124,7 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_base
break;
GDCompletionIdentifier t;
- if (_guess_expression_type(context, static_cast<const GDParser::OperatorNode *>(node)->arguments[0], p.get_completion_line(), t)) {
+ if (_guess_expression_type(context, static_cast<const GDParser::OperatorNode *>(node)->arguments[0], p.get_completion_line(), t, true)) {
if (t.type == Variant::OBJECT && t.obj_type == "GDNativeClass") {
//native enum
@@ -2110,7 +2143,7 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_base
for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) {
if (E->get().usage & (PROPERTY_USAGE_GROUP | PROPERTY_USAGE_CATEGORY))
continue;
- if (E->get().name.find("/") != -1)
+ if (String(E->get().name).find("/") != -1)
continue;
options.insert(E->get().name);
}
@@ -2122,28 +2155,27 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_base
if (t.value.get_type()) {
Object *obj = t.value;
- if (obj) {
-
- GDScript *scr = obj->cast_to<GDScript>();
- if (scr) {
- while (scr) {
+ GDScript *scr = Object::cast_to<GDScript>(obj);
+ if (scr) {
+ while (scr) {
- if (!isfunction) {
- for (const Map<StringName, Variant>::Element *E = scr->get_constants().front(); E; E = E->next()) {
- options.insert(E->key());
- }
+ if (!isfunction) {
+ for (const Map<StringName, Variant>::Element *E = scr->get_constants().front(); E; E = E->next()) {
+ options.insert(E->key());
}
- for (const Map<StringName, GDFunction *>::Element *E = scr->get_member_functions().front(); E; E = E->next()) {
- if (E->get()->is_static())
- options.insert(E->key());
- }
-
- if (scr->get_base().is_valid())
- scr = scr->get_base().ptr();
- else
- scr = NULL;
}
- } else {
+ for (const Map<StringName, GDFunction *>::Element *E = scr->get_member_functions().front(); E; E = E->next()) {
+ if (E->get()->is_static())
+ options.insert(E->key());
+ }
+
+ if (scr->get_base().is_valid())
+ scr = scr->get_base().ptr();
+ else
+ scr = NULL;
+ }
+ } else {
+ if (obj) {
on_script = obj->get_script();
}
}
@@ -2244,7 +2276,7 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_base
for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) {
if (E->get().usage & (PROPERTY_USAGE_GROUP | PROPERTY_USAGE_CATEGORY))
continue;
- if (E->get().name.find("/") != -1)
+ if (String(E->get().name).find("/") != -1)
continue;
r_options->push_back(E->get().name);
}
@@ -2276,7 +2308,7 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_base
t.value.get_property_list(&pl);
for (List<PropertyInfo>::Element *E = pl.front(); E; E = E->next()) {
- if (E->get().name.find("/") == -1)
+ if (String(E->get().name).find("/") == -1)
options.insert(E->get().name);
}
}
@@ -2296,7 +2328,7 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_base
} break;
case GDParser::COMPLETION_CALL_ARGUMENTS: {
- _find_call_arguments(context, p.get_completion_node(), p.get_completion_line(), p.get_completion_argument_index(), options, r_call_hint);
+ _find_call_arguments(context, p.get_completion_node(), p.get_completion_line(), p.get_completion_argument_index(), options, r_forced, r_call_hint);
} break;
case GDParser::COMPLETION_VIRTUAL_FUNC: {
@@ -2343,6 +2375,7 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_base
ClassDB::get_signal_list(t.obj_type, &sigs);
for (List<MethodInfo>::Element *E = sigs.front(); E; E = E->next()) {
options.insert("\"" + E->get().name + "\"");
+ r_forced = true;
}
}
@@ -2352,6 +2385,42 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_base
if (EditorSettings::get_singleton()->get("text_editor/completion/complete_file_paths"))
get_directory_contents(EditorFileSystem::get_singleton()->get_filesystem(), options);
} break;
+ case GDParser::COMPLETION_ASSIGN: {
+#if defined(DEBUG_METHODS_ENABLED) && defined(TOOLS_ENABLED)
+
+ GDCompletionIdentifier ci;
+ if (_guess_expression_type(context, p.get_completion_node(), p.get_completion_line(), ci)) {
+
+ String enumeration = ci.enumeration;
+ if (enumeration.find(".") != -1) {
+ //class constant
+ List<StringName> constants;
+ String cls = enumeration.get_slice(".", 0);
+ String enm = enumeration.get_slice(".", 1);
+
+ ClassDB::get_enum_constants(cls, enm, &constants);
+ //constants.sort_custom<StringName::AlphCompare>();
+ for (List<StringName>::Element *E = constants.front(); E; E = E->next()) {
+ String add = cls + "." + E->get();
+ r_options->push_back(add);
+ r_forced = true;
+ }
+ } else {
+
+ //global constant
+ StringName current_enum = enumeration;
+
+ for (int i = 0; i < GlobalConstants::get_global_constant_count(); i++) {
+ if (GlobalConstants::get_global_constant_enum(i) == current_enum) {
+ r_options->push_back(GlobalConstants::get_global_constant_name(i));
+ r_forced = true;
+ }
+ }
+ //global
+ }
+ }
+#endif
+ } break;
}
for (Set<String>::Element *E = options.front(); E; E = E->next()) {
@@ -2363,7 +2432,7 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_base
#else
-Error GDScriptLanguage::complete_code(const String &p_code, const String &p_base_path, Object *p_owner, List<String> *r_options, String &r_call_hint) {
+Error GDScriptLanguage::complete_code(const String &p_code, const String &p_base_path, Object *p_owner, List<String> *r_options, bool &r_forced, String &r_call_hint) {
return OK;
}
@@ -2371,7 +2440,7 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_base
String GDScriptLanguage::_get_indentation() const {
#ifdef TOOLS_ENABLED
- if (SceneTree::get_singleton()->is_editor_hint()) {
+ if (Engine::get_singleton()->is_editor_hint()) {
bool use_space_indentation = EDITOR_DEF("text_editor/indent/type", 0);
if (use_space_indentation) {
@@ -2700,9 +2769,9 @@ Error GDScriptLanguage::lookup_code(const String &p_code, const String &p_symbol
Object *obj = value;
if (obj) {
- if (obj->cast_to<GDNativeClass>()) {
+ if (Object::cast_to<GDNativeClass>(obj)) {
r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS;
- r_result.class_name = obj->cast_to<GDNativeClass>()->get_name();
+ r_result.class_name = Object::cast_to<GDNativeClass>(obj)->get_name();
} else {
r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS;
@@ -2719,18 +2788,6 @@ Error GDScriptLanguage::lookup_code(const String &p_code, const String &p_symbol
}
}
}
-#if 0
- GDCompletionIdentifier identifier;
- if (_guess_identifier_type(context,p.get_completion_line(),p_symbol,identifier)) {
-
- print_line("var type: "+Variant::get_type_name(identifier.type));
- if (identifier.script.is_valid()) {
- print_line("var script: "+identifier.script->get_path());
- }
- print_line("obj type: "+String(identifier.obj_type));
- print_line("value: "+String(identifier.value));
- }
-#endif
}
} break;
diff --git a/modules/gdscript/gd_function.cpp b/modules/gdscript/gd_function.cpp
index 13a7480a36..e6f65fe0c2 100644
--- a/modules/gdscript/gd_function.cpp
+++ b/modules/gdscript/gd_function.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -371,7 +371,7 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a
Object *obj_A = *a;
Object *obj_B = *b;
- GDScript *scr_B = obj_B->cast_to<GDScript>();
+ GDScript *scr_B = Object::cast_to<GDScript>(obj_B);
bool extends_ok = false;
@@ -397,7 +397,7 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a
} else {
- GDNativeClass *nc = obj_B->cast_to<GDNativeClass>();
+ GDNativeClass *nc = Object::cast_to<GDNativeClass>(obj_B);
if (!nc) {
@@ -1319,22 +1319,6 @@ void GDFunction::debug_get_stack_member_state(int p_line, List<Pair<StringName,
}
}
-#if 0
-void GDFunction::clear() {
-
- name=StringName();
- constants.clear();
- _stack_size=0;
- code.clear();
- _constants_ptr=NULL;
- _constant_count=0;
- _global_names_ptr=NULL;
- _global_names_count=0;
- _code_ptr=NULL;
- _code_size=0;
-
-}
-#endif
GDFunction::GDFunction()
: function_list(this) {
@@ -1434,7 +1418,7 @@ Variant GDFunctionState::_signal_callback(const Variant **p_args, int p_argcount
// If the return value is a GDFunctionState reference,
// then the function did yield again after resuming.
if (ret.is_ref()) {
- GDFunctionState *gdfs = ret.operator Object *()->cast_to<GDFunctionState>();
+ GDFunctionState *gdfs = Object::cast_to<GDFunctionState>(ret);
if (gdfs && gdfs->function == function)
completed = false;
}
@@ -1490,7 +1474,7 @@ Variant GDFunctionState::resume(const Variant &p_arg) {
// If the return value is a GDFunctionState reference,
// then the function did yield again after resuming.
if (ret.is_ref()) {
- GDFunctionState *gdfs = ret.operator Object *()->cast_to<GDFunctionState>();
+ GDFunctionState *gdfs = Object::cast_to<GDFunctionState>(ret);
if (gdfs && gdfs->function == function)
completed = false;
}
diff --git a/modules/gdscript/gd_function.h b/modules/gdscript/gd_function.h
index 6d20b19777..bf5ff5f8da 100644
--- a/modules/gdscript/gd_function.h
+++ b/modules/gdscript/gd_function.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -210,8 +210,9 @@ public:
#ifdef TOOLS_ENABLED
ERR_FAIL_INDEX_V(p_idx, arg_names.size(), StringName());
return arg_names[p_idx];
-#endif
+#else
return StringName();
+#endif
}
Variant get_default_argument(int p_idx) const {
ERR_FAIL_INDEX_V(p_idx, default_arguments.size(), Variant());
diff --git a/modules/gdscript/gd_functions.cpp b/modules/gdscript/gd_functions.cpp
index 209bdadd67..f0cfdd6258 100644
--- a/modules/gdscript/gd_functions.cpp
+++ b/modules/gdscript/gd_functions.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -70,6 +70,8 @@ const char *GDFunctions::get_func_name(Function p_func) {
"decimals",
"stepify",
"lerp",
+ "inverse_lerp",
+ "range_lerp",
"dectime",
"randomize",
"randi",
@@ -326,6 +328,22 @@ void GDFunctions::call(Function p_func, const Variant **p_args, int p_arg_count,
VALIDATE_ARG_NUM(2);
r_ret = Math::lerp((double)*p_args[0], (double)*p_args[1], (double)*p_args[2]);
} break;
+ case MATH_INVERSE_LERP: {
+ VALIDATE_ARG_COUNT(3);
+ VALIDATE_ARG_NUM(0);
+ VALIDATE_ARG_NUM(1);
+ VALIDATE_ARG_NUM(2);
+ r_ret = Math::inverse_lerp((double)*p_args[0], (double)*p_args[1], (double)*p_args[2]);
+ } break;
+ case MATH_RANGE_LERP: {
+ VALIDATE_ARG_COUNT(5);
+ VALIDATE_ARG_NUM(0);
+ VALIDATE_ARG_NUM(1);
+ VALIDATE_ARG_NUM(2);
+ VALIDATE_ARG_NUM(3);
+ VALIDATE_ARG_NUM(4);
+ r_ret = Math::range_lerp((double)*p_args[0], (double)*p_args[1], (double)*p_args[2], (double)*p_args[3], (double)*p_args[4]);
+ } break;
case MATH_DECTIME: {
VALIDATE_ARG_COUNT(3);
VALIDATE_ARG_NUM(0);
@@ -446,7 +464,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);
@@ -1252,6 +1270,8 @@ bool GDFunctions::is_deterministic(Function p_func) {
case MATH_DECIMALS:
case MATH_STEPIFY:
case MATH_LERP:
+ case MATH_INVERSE_LERP:
+ case MATH_RANGE_LERP:
case MATH_DECTIME:
case MATH_DEG2RAD:
case MATH_RAD2DEG:
@@ -1420,6 +1440,16 @@ MethodInfo GDFunctions::get_info(Function p_func) {
mi.return_val.type = Variant::REAL;
return mi;
} break;
+ case MATH_INVERSE_LERP: {
+ MethodInfo mi("inverse_lerp", PropertyInfo(Variant::REAL, "from"), PropertyInfo(Variant::REAL, "to"), PropertyInfo(Variant::REAL, "value"));
+ mi.return_val.type = Variant::REAL;
+ return mi;
+ } break;
+ case MATH_RANGE_LERP: {
+ MethodInfo mi("range_lerp", PropertyInfo(Variant::REAL, "value"), PropertyInfo(Variant::REAL, "istart"), PropertyInfo(Variant::REAL, "istop"), PropertyInfo(Variant::REAL, "ostart"), PropertyInfo(Variant::REAL, "ostop"));
+ mi.return_val.type = Variant::REAL;
+ return mi;
+ } break;
case MATH_DECTIME: {
MethodInfo mi("dectime", PropertyInfo(Variant::REAL, "value"), PropertyInfo(Variant::REAL, "amount"), PropertyInfo(Variant::REAL, "step"));
mi.return_val.type = Variant::REAL;
@@ -1542,43 +1572,49 @@ MethodInfo GDFunctions::get_info(Function p_func) {
} break;
case TEXT_STR: {
- MethodInfo mi("str", PropertyInfo(Variant::NIL, "what"), PropertyInfo(Variant::NIL, "..."));
+ MethodInfo mi("str");
mi.return_val.type = Variant::STRING;
+ mi.flags |= METHOD_FLAG_VARARG;
return mi;
} break;
case TEXT_PRINT: {
- MethodInfo mi("print", PropertyInfo(Variant::NIL, "what"), PropertyInfo(Variant::NIL, "..."));
+ MethodInfo mi("print");
mi.return_val.type = Variant::NIL;
+ mi.flags |= METHOD_FLAG_VARARG;
return mi;
} break;
case TEXT_PRINT_TABBED: {
- MethodInfo mi("printt", PropertyInfo(Variant::NIL, "what"), PropertyInfo(Variant::NIL, "..."));
+ MethodInfo mi("printt");
mi.return_val.type = Variant::NIL;
+ mi.flags |= METHOD_FLAG_VARARG;
return mi;
} break;
case TEXT_PRINT_SPACED: {
- MethodInfo mi("prints", PropertyInfo(Variant::NIL, "what"), PropertyInfo(Variant::NIL, "..."));
+ MethodInfo mi("prints");
mi.return_val.type = Variant::NIL;
+ mi.flags |= METHOD_FLAG_VARARG;
return mi;
} break;
case TEXT_PRINTERR: {
- MethodInfo mi("printerr", PropertyInfo(Variant::NIL, "what"), PropertyInfo(Variant::NIL, "..."));
+ MethodInfo mi("printerr");
mi.return_val.type = Variant::NIL;
+ mi.flags |= METHOD_FLAG_VARARG;
return mi;
} break;
case TEXT_PRINTRAW: {
- MethodInfo mi("printraw", PropertyInfo(Variant::NIL, "what"), PropertyInfo(Variant::NIL, "..."));
+ MethodInfo mi("printraw");
mi.return_val.type = Variant::NIL;
+ mi.flags |= METHOD_FLAG_VARARG;
return mi;
} break;
@@ -1590,8 +1626,9 @@ MethodInfo GDFunctions::get_info(Function p_func) {
} break;
case STR_TO_VAR: {
- MethodInfo mi("str2var:Variant", PropertyInfo(Variant::STRING, "string"));
+ MethodInfo mi(Variant::NIL, "str2var", PropertyInfo(Variant::STRING, "string"));
mi.return_val.type = Variant::NIL;
+ mi.return_val.usage |= PROPERTY_USAGE_NIL_IS_VARIANT;
return mi;
} break;
case VAR_TO_BYTES: {
@@ -1602,14 +1639,16 @@ MethodInfo GDFunctions::get_info(Function p_func) {
} break;
case BYTES_TO_VAR: {
- MethodInfo mi("bytes2var:Variant", PropertyInfo(Variant::POOL_BYTE_ARRAY, "bytes"));
+ MethodInfo mi(Variant::NIL, "bytes2var", PropertyInfo(Variant::POOL_BYTE_ARRAY, "bytes"));
mi.return_val.type = Variant::NIL;
+ mi.return_val.usage |= PROPERTY_USAGE_NIL_IS_VARIANT;
return mi;
} break;
case GEN_RANGE: {
- MethodInfo mi("range", PropertyInfo(Variant::NIL, "..."));
+ MethodInfo mi("range");
mi.return_val.type = Variant::ARRAY;
+ mi.flags |= METHOD_FLAG_VARARG;
return mi;
} break;
case RESOURCE_LOAD: {
@@ -1633,14 +1672,15 @@ MethodInfo GDFunctions::get_info(Function p_func) {
} break;
case VALIDATE_JSON: {
- MethodInfo mi("validate_json:Variant", PropertyInfo(Variant::STRING, "json"));
+ MethodInfo mi("validate_json", PropertyInfo(Variant::STRING, "json"));
mi.return_val.type = Variant::STRING;
return mi;
} break;
case PARSE_JSON: {
- MethodInfo mi("parse_json:Variant", PropertyInfo(Variant::STRING, "json"));
+ MethodInfo mi(Variant::NIL, "parse_json", PropertyInfo(Variant::STRING, "json"));
mi.return_val.type = Variant::NIL;
+ mi.return_val.usage |= PROPERTY_USAGE_NIL_IS_VARIANT;
return mi;
} break;
case TO_JSON: {
diff --git a/modules/gdscript/gd_functions.h b/modules/gdscript/gd_functions.h
index 93cb524118..a568c8f1cf 100644
--- a/modules/gdscript/gd_functions.h
+++ b/modules/gdscript/gd_functions.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -62,6 +62,8 @@ public:
MATH_DECIMALS,
MATH_STEPIFY,
MATH_LERP,
+ MATH_INVERSE_LERP,
+ MATH_RANGE_LERP,
MATH_DECTIME,
MATH_RANDOMIZE,
MATH_RAND,
diff --git a/modules/gdscript/gd_parser.cpp b/modules/gdscript/gd_parser.cpp
index 9023fd4bf4..072937a521 100644
--- a/modules/gdscript/gd_parser.cpp
+++ b/modules/gdscript/gd_parser.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -1044,6 +1044,7 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool
return NULL; \
} \
p_allow_assign = false;
+
switch (tokenizer->get_token()) { //see operator
case GDTokenizer::TK_OP_IN: op = OperatorNode::OP_IN; break;
@@ -1065,7 +1066,22 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool
//case GDTokenizer::TK_OP_NEG: op=OperatorNode::OP_NEG ; break;
case GDTokenizer::TK_OP_SHIFT_LEFT: op = OperatorNode::OP_SHIFT_LEFT; break;
case GDTokenizer::TK_OP_SHIFT_RIGHT: op = OperatorNode::OP_SHIFT_RIGHT; break;
- case GDTokenizer::TK_OP_ASSIGN: _VALIDATE_ASSIGN op = OperatorNode::OP_ASSIGN; break;
+ case GDTokenizer::TK_OP_ASSIGN: {
+ _VALIDATE_ASSIGN op = OperatorNode::OP_ASSIGN;
+
+ if (tokenizer->get_token(1) == GDTokenizer::TK_CURSOR) {
+ //code complete assignment
+ completion_type = COMPLETION_ASSIGN;
+ completion_node = expr;
+ completion_class = current_class;
+ completion_function = current_function;
+ completion_line = tokenizer->get_token_line();
+ completion_block = current_block;
+ completion_found = true;
+ tokenizer->advance();
+ }
+
+ } break;
case GDTokenizer::TK_OP_ASSIGN_ADD: _VALIDATE_ASSIGN op = OperatorNode::OP_ASSIGN_ADD; break;
case GDTokenizer::TK_OP_ASSIGN_SUB: _VALIDATE_ASSIGN op = OperatorNode::OP_ASSIGN_SUB; break;
case GDTokenizer::TK_OP_ASSIGN_MUL: _VALIDATE_ASSIGN op = OperatorNode::OP_ASSIGN_MUL; break;
@@ -1894,7 +1910,26 @@ GDParser::PatternNode *GDParser::_parse_pattern(bool p_static) {
return NULL;
}
- if (value->type != Node::TYPE_IDENTIFIER && value->type != Node::TYPE_CONSTANT) {
+ if (value->type == Node::TYPE_OPERATOR) {
+ // Maybe it's SomeEnum.VALUE
+ Node *current_value = value;
+
+ while (current_value->type == Node::TYPE_OPERATOR) {
+ OperatorNode *op_node = static_cast<OperatorNode *>(current_value);
+
+ if (op_node->op != OperatorNode::OP_INDEX_NAMED) {
+ _set_error("Invalid operator in pattern. Only index (`A.B`) is allowed");
+ return NULL;
+ }
+ current_value = op_node->arguments[0];
+ }
+
+ if (current_value->type != Node::TYPE_IDENTIFIER) {
+ _set_error("Only constant expression or variables allowed in a pattern");
+ return NULL;
+ }
+
+ } else if (value->type != Node::TYPE_IDENTIFIER && value->type != Node::TYPE_CONSTANT) {
_set_error("Only constant expressions or variables allowed in a pattern");
return NULL;
}
@@ -2381,9 +2416,7 @@ void GDParser::_parse_block(BlockNode *p_block, bool p_static) {
if (tokenizer->get_token() == GDTokenizer::TK_OP_ASSIGN) {
tokenizer->advance();
- Node *subexpr = NULL;
-
- subexpr = _parse_and_reduce_expression(p_block, p_static);
+ Node *subexpr = _parse_and_reduce_expression(p_block, p_static);
if (!subexpr) {
if (_recover_from_completion()) {
break;
@@ -2437,6 +2470,8 @@ void GDParser::_parse_block(BlockNode *p_block, bool p_static) {
cf_if->body = alloc_node<BlockNode>();
cf_if->body->parent_block = p_block;
+ cf_if->body->if_condition = condition; //helps code completion
+
p_block->sub_blocks.push_back(cf_if->body);
if (!_enter_indent_block(cf_if->body)) {
@@ -3135,9 +3170,7 @@ void GDParser::_parse_class(ClassNode *p_class) {
if (tokenizer->get_token() == GDTokenizer::TK_OP_ASSIGN) {
defaulting = true;
tokenizer->advance(1);
- Node *defval = NULL;
-
- defval = _parse_and_reduce_expression(p_class, _static);
+ Node *defval = _parse_and_reduce_expression(p_class, _static);
if (!defval || error_set)
return;
@@ -3875,9 +3908,7 @@ void GDParser::_parse_class(ClassNode *p_class) {
#endif
tokenizer->advance();
- Node *subexpr = NULL;
-
- subexpr = _parse_and_reduce_expression(p_class, false, autoexport);
+ Node *subexpr = _parse_and_reduce_expression(p_class, false, autoexport);
if (!subexpr) {
if (_recover_from_completion()) {
break;
@@ -3928,7 +3959,7 @@ void GDParser::_parse_class(ClassNode *p_class) {
member._export.usage |= PROPERTY_USAGE_SCRIPT_VARIABLE;
if (cn->value.get_type() == Variant::OBJECT) {
Object *obj = cn->value;
- Resource *res = obj->cast_to<Resource>();
+ Resource *res = Object::cast_to<Resource>(obj);
if (res == NULL) {
_set_error("Exported constant not a type or resource.");
return;
@@ -4035,9 +4066,7 @@ void GDParser::_parse_class(ClassNode *p_class) {
tokenizer->advance();
- Node *subexpr = NULL;
-
- subexpr = _parse_and_reduce_expression(p_class, true, true);
+ Node *subexpr = _parse_and_reduce_expression(p_class, true, true);
if (!subexpr) {
if (_recover_from_completion()) {
break;
@@ -4103,9 +4132,7 @@ void GDParser::_parse_class(ClassNode *p_class) {
if (tokenizer->get_token() == GDTokenizer::TK_OP_ASSIGN) {
tokenizer->advance();
- Node *subexpr = NULL;
-
- subexpr = _parse_and_reduce_expression(p_class, true, true);
+ Node *subexpr = _parse_and_reduce_expression(p_class, true, true);
if (!subexpr) {
if (_recover_from_completion()) {
break;
diff --git a/modules/gdscript/gd_parser.h b/modules/gdscript/gd_parser.h
index 3ad3466624..7e88fd9746 100644
--- a/modules/gdscript/gd_parser.h
+++ b/modules/gdscript/gd_parser.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -146,10 +146,13 @@ public:
Vector<StringName> variables;
Vector<int> variable_lines;
+ Node *if_condition; //tiny hack to improve code completion on if () blocks
+
//the following is useful for code completion
List<BlockNode *> sub_blocks;
int end_line;
BlockNode() {
+ if_condition = NULL;
type = TYPE_BLOCK;
end_line = -1;
parent_block = NULL;
@@ -441,6 +444,7 @@ public:
COMPLETION_INDEX,
COMPLETION_VIRTUAL_FUNC,
COMPLETION_YIELD,
+ COMPLETION_ASSIGN,
};
private:
diff --git a/modules/gdscript/gd_script.cpp b/modules/gdscript/gd_script.cpp
index 2d06c0f5d2..cf6529d5ae 100644
--- a/modules/gdscript/gd_script.cpp
+++ b/modules/gdscript/gd_script.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -28,6 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "gd_script.h"
+
#include "gd_compiler.h"
#include "global_constants.h"
#include "io/file_access_encrypted.h"
@@ -42,11 +43,6 @@ GDNativeClass::GDNativeClass(const StringName &p_name) {
name = p_name;
}
-/*void GDNativeClass::call_multilevel(const StringName& p_method,const Variant** p_args,int p_argcount){
-
-
-}*/
-
bool GDNativeClass::_get(const StringName &p_name, Variant &r_ret) const {
bool ok;
@@ -73,7 +69,7 @@ Variant GDNativeClass::_new() {
ERR_FAIL_COND_V(!o, Variant());
}
- Reference *ref = o->cast_to<Reference>();
+ Reference *ref = Object::cast_to<Reference>(o);
if (ref) {
return REF(ref);
} else {
@@ -161,7 +157,7 @@ Variant GDScript::_new(const Variant **p_args, int p_argcount, Variant::CallErro
owner = memnew(Reference); //by default, no base means use reference
}
- Reference *r = owner->cast_to<Reference>();
+ Reference *r = Object::cast_to<Reference>(owner);
if (r) {
ref = REF(r);
}
@@ -183,7 +179,6 @@ Variant GDScript::_new(const Variant **p_args, int p_argcount, Variant::CallErro
bool GDScript::can_instance() const {
- //return valid; //any script in GDscript can instance
return valid || (!tool && !ScriptServer::is_scripting_enabled());
}
@@ -218,49 +213,6 @@ void GDScript::_placeholder_erased(PlaceHolderScriptInstance *p_placeholder) {
placeholders.erase(p_placeholder);
}
-
-/*
-void GDScript::_update_placeholder(PlaceHolderScriptInstance *p_placeholder) {
-
-
- List<PropertyInfo> plist;
- GDScript *scr=this;
-
- Map<StringName,Variant> default_values;
- while(scr) {
-
- Vector<_GDScriptMemberSort> msort;
- for(Map<StringName,PropertyInfo>::Element *E=scr->member_info.front();E;E=E->next()) {
-
- _GDScriptMemberSort ms;
- ERR_CONTINUE(!scr->member_indices.has(E->key()));
- ms.index=scr->member_indices[E->key()].index;
- ms.name=E->key();
-
- msort.push_back(ms);
-
- }
-
- msort.sort();
- msort.invert();
- for(int i=0;i<msort.size();i++) {
-
- plist.push_front(scr->member_info[msort[i].name]);
- if (scr->member_default_values.has(msort[i].name))
- default_values[msort[i].name]=scr->member_default_values[msort[i].name];
- else {
- Variant::CallError err;
- default_values[msort[i].name]=Variant::construct(scr->member_info[msort[i].name].type,NULL,0,err);
- }
- }
-
- scr=scr->_base;
- }
-
-
- p_placeholder->update(plist,default_values);
-
-}*/
#endif
void GDScript::get_script_method_list(List<MethodInfo> *p_list) const {
@@ -397,7 +349,7 @@ ScriptInstance *GDScript::instance_create(Object *p_this) {
}
Variant::CallError unchecked_error;
- return _create_instance(NULL, 0, p_this, p_this->cast_to<Reference>(), unchecked_error);
+ return _create_instance(NULL, 0, p_this, Object::cast_to<Reference>(p_this), unchecked_error);
}
bool GDScript::instance_has(const Object *p_this) const {
@@ -428,7 +380,6 @@ void GDScript::set_source_code(const String &p_code) {
source = p_code;
#ifdef TOOLS_ENABLED
source_changed_cache = true;
-//print_line("SC CHANGED "+get_path());
#endif
}
@@ -559,8 +510,9 @@ bool GDScript::_update_exports() {
return changed;
-#endif
+#else
return false;
+#endif
}
void GDScript::update_exports() {
@@ -574,9 +526,7 @@ void GDScript::update_exports() {
//print_line("update exports for "+get_path()+" ic: "+itos(copy.size()));
for (Set<ObjectID>::Element *E = copy.front(); E; E = E->next()) {
Object *id = ObjectDB::get_instance(E->get());
- if (!id)
- continue;
- GDScript *s = id->cast_to<GDScript>();
+ GDScript *s = Object::cast_to<GDScript>(id);
if (!s)
continue;
s->update_exports();
@@ -615,7 +565,7 @@ Error GDScript::reload(bool p_keep_state) {
if (basedir != "")
basedir = basedir.get_base_dir();
- if (basedir != "" && basedir.find("res://") == -1 && basedir.find("user://") == -1) {
+ if (source.find("%BASE%") != -1) {
//loading a template, don't parse
return OK;
}
@@ -656,12 +606,6 @@ Error GDScript::reload(bool p_keep_state) {
_set_subclass_path(E->get(), path);
}
-#ifdef TOOLS_ENABLED
-/*for (Set<PlaceHolderScriptInstance*>::Element *E=placeholders.front();E;E=E->next()) {
-
- _update_placeholder(E->get());
- }*/
-#endif
return OK;
}
@@ -1142,53 +1086,10 @@ void GDInstance::get_property_list(List<PropertyInfo> *p_properties) const {
props.push_front(sptr->member_info[msort[i].name]);
}
-#if 0
- if (sptr->member_functions.has("_get_property_list")) {
-
- Variant::CallError err;
- GDFunction *f = const_cast<GDFunction*>(sptr->member_functions["_get_property_list"]);
- Variant plv = f->call(const_cast<GDInstance*>(this),NULL,0,err);
-
- if (plv.get_type()!=Variant::ARRAY) {
-
- ERR_PRINT("_get_property_list: expected array returned");
- } else {
-
- Array pl=plv;
-
- for(int i=0;i<pl.size();i++) {
-
- Dictionary p = pl[i];
- PropertyInfo pinfo;
- if (!p.has("name")) {
- ERR_PRINT("_get_property_list: expected 'name' key of type string.")
- continue;
- }
- if (!p.has("type")) {
- ERR_PRINT("_get_property_list: expected 'type' key of type integer.")
- continue;
- }
- pinfo.name=p["name"];
- pinfo.type=Variant::Type(int(p["type"]));
- if (p.has("hint"))
- pinfo.hint=PropertyHint(int(p["hint"]));
- if (p.has("hint_string"))
- pinfo.hint_string=p["hint_string"];
- if (p.has("usage"))
- pinfo.usage=p["usage"];
-
-
- props.push_back(pinfo);
- }
- }
- }
-#endif
sptr = sptr->_base;
}
- //props.invert();
-
for (List<PropertyInfo>::Element *E = props.front(); E; E = E->next()) {
p_properties->push_back(E->get());
@@ -1391,10 +1292,6 @@ GDInstance::~GDInstance() {
}
/************* SCRIPT LANGUAGE **************/
-/************* SCRIPT LANGUAGE **************/
-/************* SCRIPT LANGUAGE **************/
-/************* SCRIPT LANGUAGE **************/
-/************* SCRIPT LANGUAGE **************/
GDScriptLanguage *GDScriptLanguage::singleton = NULL;
@@ -2005,11 +1902,11 @@ Error ResourceFormatSaverGDScript::save(const String &p_path, const RES &p_resou
void ResourceFormatSaverGDScript::get_recognized_extensions(const RES &p_resource, List<String> *p_extensions) const {
- if (p_resource->cast_to<GDScript>()) {
+ if (Object::cast_to<GDScript>(*p_resource)) {
p_extensions->push_back("gd");
}
}
bool ResourceFormatSaverGDScript::recognize(const RES &p_resource) const {
- return p_resource->cast_to<GDScript>() != NULL;
+ return Object::cast_to<GDScript>(*p_resource) != NULL;
}
diff --git a/modules/gdscript/gd_script.h b/modules/gdscript/gd_script.h
index 17e7b0bc03..6f05a4770b 100644
--- a/modules/gdscript/gd_script.h
+++ b/modules/gdscript/gd_script.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -390,7 +390,7 @@ public:
virtual int find_function(const String &p_function, const String &p_code) const;
virtual String make_function(const String &p_class, const String &p_name, const PoolStringArray &p_args) const;
virtual Error open_in_external_editor(const Ref<Script> &p_script, int p_line, int p_col) { return OK; }
- virtual Error complete_code(const String &p_code, const String &p_base_path, Object *p_owner, List<String> *r_options, String &r_call_hint);
+ virtual Error complete_code(const String &p_code, const String &p_base_path, Object *p_owner, List<String> *r_options, bool &r_forced, String &r_call_hint);
#ifdef TOOLS_ENABLED
virtual Error lookup_code(const String &p_code, const String &p_symbol, const String &p_base_path, Object *p_owner, LookupResult &r_result);
#endif
diff --git a/modules/gdscript/gd_tokenizer.cpp b/modules/gdscript/gd_tokenizer.cpp
index 5803046185..5f85158232 100644
--- a/modules/gdscript/gd_tokenizer.cpp
+++ b/modules/gdscript/gd_tokenizer.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -28,6 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "gd_tokenizer.h"
+
#include "gd_functions.h"
#include "io/marshalls.h"
#include "map.h"
@@ -504,7 +505,6 @@ void GDTokenizerText::_advance() {
_make_newline(i);
return;
}
-#if 1 //py style tokenizer
case '#': { // line comment skip
while (GETCHAR(0) != '\n') {
@@ -526,57 +526,9 @@ void GDTokenizerText::_advance() {
return;
} break;
-#endif
case '/': {
switch (GETCHAR(1)) {
-#if 0 // c style tokenizer
- case '*': { // block comment
- int pos = code_pos+2;
- int new_line=line;
- int new_col=column+2;
-
- while(true) {
- if (_code[pos]=='0') {
- _make_error("Unterminated Comment");
- code_pos=pos;
- return;
- }
- if (_code[pos]=='*' && _code[pos+1]=='/') {
- new_col+=2;
- pos+=2; //compensate
- break;
- } else if (_code[pos]=='\n') {
- new_line++;
- new_col=1;
- } else {
- new_col++;
- }
- pos++;
- }
-
- column=new_col;
- line=new_line;
- code_pos=pos;
- continue;
-
- } break;
- case '/': { // line comment skip
-
- while(GETCHAR(0)!='\n') {
- code_pos++;
- if (GETCHAR(0)==0) { //end of file
- _make_error("Unterminated Comment");
- return;
- }
- }
- INCPOS(1);
- column=1;
- line++;
- continue;
-
- } break;
-#endif
case '=': { // diveq
_make_token(TK_OP_ASSIGN_DIV);
@@ -1187,9 +1139,7 @@ Error GDTokenizerBuffer::set_code_buffer(const Vector<uint8_t> &p_buffer) {
int line_count = decode_uint32(&buf[16]);
int token_count = decode_uint32(&buf[20]);
- const uint8_t *b = buf;
-
- b = &buf[24];
+ const uint8_t *b = &buf[24];
total_len -= 24;
identifiers.resize(identifier_count);
diff --git a/modules/gdscript/gd_tokenizer.h b/modules/gdscript/gd_tokenizer.h
index 4e868301a3..c935ce45a1 100644
--- a/modules/gdscript/gd_tokenizer.h
+++ b/modules/gdscript/gd_tokenizer.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/gdscript/register_types.cpp b/modules/gdscript/register_types.cpp
index 41ea0c2a26..036274c8f2 100644
--- a/modules/gdscript/register_types.cpp
+++ b/modules/gdscript/register_types.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -37,103 +37,7 @@
GDScriptLanguage *script_language_gd = NULL;
ResourceFormatLoaderGDScript *resource_loader_gd = NULL;
ResourceFormatSaverGDScript *resource_saver_gd = NULL;
-#if 0
-#ifdef TOOLS_ENABLED
-#include "editor/editor_import_export.h"
-#include "editor/editor_node.h"
-#include "editor/editor_settings.h"
-#include "gd_tokenizer.h"
-
-class EditorExportGDScript : public EditorExportPlugin {
-
- GDCLASS(EditorExportGDScript,EditorExportPlugin);
-
-public:
-
- virtual Vector<uint8_t> custom_export(String& p_path,const Ref<EditorExportPlatform> &p_platform) {
- //compile gdscript to bytecode
-
- if (EditorImportExport::get_singleton()->script_get_action()!=EditorImportExport::SCRIPT_ACTION_NONE) {
-
- if (p_path.ends_with(".gd")) {
- Vector<uint8_t> file = FileAccess::get_file_as_array(p_path);
- if (file.empty())
- return file;
- String txt;
- txt.parse_utf8((const char*)file.ptr(),file.size());
- file = GDTokenizerBuffer::parse_code_string(txt);
-
- if (!file.empty()) {
-
- if (EditorImportExport::get_singleton()->script_get_action()==EditorImportExport::SCRIPT_ACTION_ENCRYPT) {
-
- String tmp_path=EditorSettings::get_singleton()->get_settings_path().plus_file("tmp/script.gde");
- FileAccess *fa = FileAccess::open(tmp_path,FileAccess::WRITE);
- String skey=EditorImportExport::get_singleton()->script_get_encryption_key().to_lower();
- Vector<uint8_t> key;
- key.resize(32);
- for(int i=0;i<32;i++) {
- int v=0;
- if (i*2<skey.length()) {
- CharType ct = skey[i*2];
- if (ct>='0' && ct<='9')
- ct=ct-'0';
- else if (ct>='a' && ct<='f')
- ct=10+ct-'a';
- v|=ct<<4;
- }
-
- if (i*2+1<skey.length()) {
- CharType ct = skey[i*2+1];
- if (ct>='0' && ct<='9')
- ct=ct-'0';
- else if (ct>='a' && ct<='f')
- ct=10+ct-'a';
- v|=ct;
- }
- key[i]=v;
- }
- FileAccessEncrypted *fae=memnew(FileAccessEncrypted);
- Error err = fae->open_and_parse(fa,key,FileAccessEncrypted::MODE_WRITE_AES256);
- if (err==OK) {
-
- fae->store_buffer(file.ptr(),file.size());
- p_path=p_path.get_basename()+".gde";
- }
-
- memdelete(fae);
-
- file=FileAccess::get_file_as_array(tmp_path);
- return file;
-
-
- } else {
-
- p_path=p_path.get_basename()+".gdc";
- return file;
- }
- }
-
- }
- }
-
- return Vector<uint8_t>();
- }
-
-
- EditorExportGDScript(){}
-
-};
-
-static void register_editor_plugin() {
-
- Ref<EditorExportGDScript> egd = memnew( EditorExportGDScript );
- EditorImportExport::get_singleton()->add_export_plugin(egd);
-}
-
-#endif
-#endif
void register_gdscript_types() {
ClassDB::register_class<GDScript>();
@@ -146,13 +50,8 @@ void register_gdscript_types() {
ResourceLoader::add_resource_format_loader(resource_loader_gd);
resource_saver_gd = memnew(ResourceFormatSaverGDScript);
ResourceSaver::add_resource_format_saver(resource_saver_gd);
-#if 0
-#ifdef TOOLS_ENABLED
-
- EditorNode::add_init_callback(register_editor_plugin);
-#endif
-#endif
}
+
void unregister_gdscript_types() {
ScriptServer::unregister_language(script_language_gd);
diff --git a/modules/gdscript/register_types.h b/modules/gdscript/register_types.h
index 4e969f5bd4..a674877f37 100644
--- a/modules/gdscript/register_types.h
+++ b/modules/gdscript/register_types.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/gridmap/grid_map.cpp b/modules/gridmap/grid_map.cpp
index 1205776882..1b932f040e 100644
--- a/modules/gridmap/grid_map.cpp
+++ b/modules/gridmap/grid_map.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -46,7 +46,13 @@ bool GridMap::_set(const StringName &p_name, const Variant &p_value) {
set_theme(p_value);
} else if (name == "cell_size") {
- set_cell_size(p_value);
+ if (p_value.get_type() == Variant::INT || p_value.get_type() == Variant::REAL) {
+ //compatibility
+ float cs = p_value;
+ set_cell_size(Vector3(cs, cs, cs));
+ } else {
+ set_cell_size(p_value);
+ }
} else if (name == "cell_octant_size") {
set_octant_size(p_value);
} else if (name == "cell_center_x") {
@@ -96,25 +102,6 @@ bool GridMap::_set(const StringName &p_name, const Variant &p_value) {
}
_recreate_octant_data();
- } else if (name.begins_with("areas/")) {
- int which = name.get_slicec('/', 1).to_int();
- String what = name.get_slicec('/', 2);
- if (what == "bounds") {
- ERR_FAIL_COND_V(area_map.has(which), false);
- create_area(which, p_value);
- return true;
- }
-
- ERR_FAIL_COND_V(!area_map.has(which), false);
-
- if (what == "name")
- area_set_name(which, p_value);
- else if (what == "disable_distance")
- area_set_portal_disable_distance(which, p_value);
- else if (what == "exterior_portal")
- area_set_portal_disable_color(which, p_value);
- else
- return false;
} else
return false;
@@ -158,19 +145,6 @@ bool GridMap::_get(const StringName &p_name, Variant &r_ret) const {
d["cells"] = cells;
r_ret = d;
- } else if (name.begins_with("areas/")) {
- int which = name.get_slicec('/', 1).to_int();
- String what = name.get_slicec('/', 2);
- if (what == "bounds")
- r_ret = area_get_bounds(which);
- else if (what == "name")
- r_ret = area_get_name(which);
- else if (what == "disable_distance")
- r_ret = area_get_portal_disable_distance(which);
- else if (what == "exterior_portal")
- r_ret = area_is_exterior_portal(which);
- else
- return false;
} else
return false;
@@ -181,7 +155,7 @@ void GridMap::_get_property_list(List<PropertyInfo> *p_list) const {
p_list->push_back(PropertyInfo(Variant::OBJECT, "theme", PROPERTY_HINT_RESOURCE_TYPE, "MeshLibrary"));
p_list->push_back(PropertyInfo(Variant::NIL, "Cell", PROPERTY_HINT_NONE, "cell_", PROPERTY_USAGE_GROUP));
- p_list->push_back(PropertyInfo(Variant::REAL, "cell_size", PROPERTY_HINT_RANGE, "0.01,16384,0.01"));
+ p_list->push_back(PropertyInfo(Variant::VECTOR3, "cell_size"));
p_list->push_back(PropertyInfo(Variant::INT, "cell_octant_size", PROPERTY_HINT_RANGE, "1,1024,1"));
p_list->push_back(PropertyInfo(Variant::BOOL, "cell_center_x"));
p_list->push_back(PropertyInfo(Variant::BOOL, "cell_center_y"));
@@ -189,16 +163,6 @@ void GridMap::_get_property_list(List<PropertyInfo> *p_list) const {
p_list->push_back(PropertyInfo(Variant::REAL, "cell_scale"));
p_list->push_back(PropertyInfo(Variant::DICTIONARY, "data", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE));
-
- for (const Map<int, Area *>::Element *E = area_map.front(); E; E = E->next()) {
-
- String base = "areas/" + itos(E->key()) + "/";
- p_list->push_back(PropertyInfo(Variant::RECT3, base + "bounds", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE));
- p_list->push_back(PropertyInfo(Variant::STRING, base + "name", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE));
- p_list->push_back(PropertyInfo(Variant::REAL, base + "disable_distance", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE));
- p_list->push_back(PropertyInfo(Variant::COLOR, base + "disable_color", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE));
- p_list->push_back(PropertyInfo(Variant::BOOL, base + "exterior_portal", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE));
- }
}
void GridMap::set_theme(const Ref<MeshLibrary> &p_theme) {
@@ -218,12 +182,13 @@ Ref<MeshLibrary> GridMap::get_theme() const {
return theme;
}
-void GridMap::set_cell_size(float p_size) {
+void GridMap::set_cell_size(const Vector3 &p_size) {
+ ERR_FAIL_COND(p_size.x < 0.001 || p_size.y < 0.001 || p_size.z < 0.001);
cell_size = p_size;
_recreate_octant_data();
}
-float GridMap::get_cell_size() const {
+Vector3 GridMap::get_cell_size() const {
return cell_size;
}
@@ -268,20 +233,6 @@ bool GridMap::get_center_z() const {
return center_z;
}
-int GridMap::_find_area(const IndexKey &p_pos) const {
-
- for (const Map<int, Area *>::Element *E = area_map.front(); E; E = E->next()) {
- //this should somehow be faster...
- const Area &a = *E->get();
- if (p_pos.x >= a.from.x && p_pos.x < a.to.x &&
- p_pos.y >= a.from.y && p_pos.y < a.to.y &&
- p_pos.z >= a.from.z && p_pos.z < a.to.z) {
- return E->key();
- }
- }
-
- return 0;
-}
void GridMap::set_cell_item(int p_x, int p_y, int p_z, int p_item, int p_rot) {
ERR_FAIL_INDEX(ABS(p_x), 1 << 20);
@@ -297,58 +248,30 @@ void GridMap::set_cell_item(int p_x, int p_y, int p_z, int p_item, int p_rot) {
ok.x = p_x / octant_size;
ok.y = p_y / octant_size;
ok.z = p_z / octant_size;
- ok.area = _find_area(key);
-
- if (cell_map.has(key)) {
-
- int prev_item = cell_map[key].item;
- OctantKey octantkey = ok;
-
- ERR_FAIL_COND(!octant_map.has(octantkey));
- Octant &g = *octant_map[octantkey];
- ERR_FAIL_COND(!g.items.has(prev_item));
- ERR_FAIL_COND(!g.items[prev_item].cells.has(key));
-
- g.items[prev_item].cells.erase(key);
- if (g.items[prev_item].cells.size() == 0) {
- VS::get_singleton()->free(g.items[prev_item].multimesh_instance);
- g.items.erase(prev_item);
- }
- if (g.items.empty()) {
-
- PhysicsServer::get_singleton()->free(g.static_body);
- if (g.collision_debug.is_valid()) {
- PhysicsServer::get_singleton()->free(g.collision_debug);
- PhysicsServer::get_singleton()->free(g.collision_debug_instance);
- }
-
- memdelete(&g);
- octant_map.erase(octantkey);
- } else {
+ if (p_item < 0) {
+ //erase
+ if (cell_map.has(key)) {
+ OctantKey octantkey = ok;
+ ERR_FAIL_COND(!octant_map.has(octantkey));
+ Octant &g = *octant_map[octantkey];
+ g.cells.erase(key);
g.dirty = true;
+ cell_map.erase(key);
+ _queue_octants_dirty();
}
- cell_map.erase(key);
-
- _queue_dirty_map();
- }
-
- if (p_item < 0)
return;
+ }
OctantKey octantkey = ok;
- //add later
if (!octant_map.has(octantkey)) {
-
+ //create octant because it does not exist
Octant *g = memnew(Octant);
g->dirty = true;
g->static_body = PhysicsServer::get_singleton()->body_create(PhysicsServer::BODY_MODE_STATIC);
PhysicsServer::get_singleton()->body_attach_object_instance_id(g->static_body, get_instance_id());
- if (is_inside_world())
- PhysicsServer::get_singleton()->body_set_space(g->static_body, get_world()->get_space());
-
SceneTree *st = SceneTree::get_singleton();
if (st && st->is_debugging_collisions_hint()) {
@@ -356,45 +279,26 @@ void GridMap::set_cell_item(int p_x, int p_y, int p_z, int p_item, int p_rot) {
g->collision_debug = VisualServer::get_singleton()->mesh_create();
g->collision_debug_instance = VisualServer::get_singleton()->instance_create();
VisualServer::get_singleton()->instance_set_base(g->collision_debug_instance, g->collision_debug);
- if (is_inside_world()) {
- VisualServer::get_singleton()->instance_set_scenario(g->collision_debug_instance, get_world()->get_scenario());
- VisualServer::get_singleton()->instance_set_transform(g->collision_debug_instance, get_global_transform());
- }
}
octant_map[octantkey] = g;
- }
-
- Octant &g = *octant_map[octantkey];
- if (!g.items.has(p_item)) {
- Octant::ItemInstances ii;
- if (theme.is_valid() && theme->has_item(p_item)) {
- ii.mesh = theme->get_item_mesh(p_item);
- ii.shape = theme->get_item_shape(p_item);
- ii.navmesh = theme->get_item_navmesh(p_item);
+ if (is_inside_world()) {
+ _octant_enter_world(octantkey);
+ _octant_transform(octantkey);
}
- ii.multimesh = Ref<MultiMesh>(memnew(MultiMesh));
- ii.multimesh->set_color_format(MultiMesh::COLOR_NONE);
- ii.multimesh->set_transform_format(MultiMesh::TRANSFORM_3D);
- ii.multimesh->set_mesh(ii.mesh);
- ii.multimesh_instance = VS::get_singleton()->instance_create();
- VS::get_singleton()->instance_set_base(ii.multimesh_instance, ii.multimesh->get_rid());
- VS::get_singleton()->instance_geometry_set_flag(ii.multimesh_instance, VS::INSTANCE_FLAG_USE_BAKED_LIGHT, true);
-
- g.items[p_item] = ii;
}
- Octant::ItemInstances &ii = g.items[p_item];
- ii.cells.insert(key);
+ Octant &g = *octant_map[octantkey];
+ g.cells.insert(key);
g.dirty = true;
+ _queue_octants_dirty();
- _queue_dirty_map();
-
- cell_map[key] = Cell();
- Cell &c = cell_map[key];
+ Cell c;
c.item = p_item;
c.rot = p_rot;
+
+ cell_map[key] = c;
}
int GridMap::get_cell_item(int p_x, int p_y, int p_z) const {
@@ -429,122 +333,57 @@ int GridMap::get_cell_item_orientation(int p_x, int p_y, int p_z) const {
return cell_map[key].rot;
}
-void GridMap::_octant_enter_tree(const OctantKey &p_key) {
- ERR_FAIL_COND(!octant_map.has(p_key));
- if (navigation) {
- Octant &g = *octant_map[p_key];
-
- Vector3 ofs(cell_size * 0.5 * int(center_x), cell_size * 0.5 * int(center_y), cell_size * 0.5 * int(center_z));
- _octant_clear_navmesh(p_key);
-
- for (Map<int, Octant::ItemInstances>::Element *E = g.items.front(); E; E = E->next()) {
- Octant::ItemInstances &ii = E->get();
-
- for (Set<IndexKey>::Element *F = ii.cells.front(); F; F = F->next()) {
-
- IndexKey ik = F->get();
- Map<IndexKey, Cell>::Element *C = cell_map.find(ik);
- ERR_CONTINUE(!C);
-
- Vector3 cellpos = Vector3(ik.x, ik.y, ik.z);
-
- Transform xform;
-
- if (clip && ((clip_above && cellpos[clip_axis] > clip_floor) || (!clip_above && cellpos[clip_axis] < clip_floor))) {
-
- xform.basis.set_zero();
-
- } else {
-
- xform.basis.set_orthogonal_index(C->get().rot);
- }
-
- xform.set_origin(cellpos * cell_size + ofs);
- xform.basis.scale(Vector3(cell_scale, cell_scale, cell_scale));
- // add the item's navmesh at given xform to GridMap's Navigation ancestor
- if (ii.navmesh.is_valid()) {
- int nm_id = navigation->navmesh_create(ii.navmesh, xform, this);
- Octant::NavMesh nm;
- nm.id = nm_id;
- nm.xform = xform;
- g.navmesh_ids[ik] = nm;
- }
- }
- }
- }
-}
-
-void GridMap::_octant_enter_world(const OctantKey &p_key) {
+void GridMap::_octant_transform(const OctantKey &p_key) {
ERR_FAIL_COND(!octant_map.has(p_key));
Octant &g = *octant_map[p_key];
PhysicsServer::get_singleton()->body_set_state(g.static_body, PhysicsServer::BODY_STATE_TRANSFORM, get_global_transform());
- PhysicsServer::get_singleton()->body_set_space(g.static_body, get_world()->get_space());
- //print_line("BODYPOS: "+get_global_transform());
if (g.collision_debug_instance.is_valid()) {
- VS::get_singleton()->instance_set_scenario(g.collision_debug_instance, get_world()->get_scenario());
VS::get_singleton()->instance_set_transform(g.collision_debug_instance, get_global_transform());
- if (area_map.has(p_key.area)) {
- VS::get_singleton()->instance_set_room(g.collision_debug_instance, area_map[p_key.area]->instance);
- }
}
- for (Map<int, Octant::ItemInstances>::Element *E = g.items.front(); E; E = E->next()) {
-
- VS::get_singleton()->instance_set_scenario(E->get().multimesh_instance, get_world()->get_scenario());
- VS::get_singleton()->instance_set_transform(E->get().multimesh_instance, get_global_transform());
- //print_line("INSTANCEPOS: "+get_global_transform());
- if (area_map.has(p_key.area)) {
- VS::get_singleton()->instance_set_room(E->get().multimesh_instance, area_map[p_key.area]->instance);
- }
+ for (int i = 0; i < g.multimesh_instances.size(); i++) {
+ VS::get_singleton()->instance_set_transform(g.multimesh_instances[i].instance, get_global_transform());
}
}
-void GridMap::_octant_transform(const OctantKey &p_key) {
-
- ERR_FAIL_COND(!octant_map.has(p_key));
+bool GridMap::_octant_update(const OctantKey &p_key) {
+ ERR_FAIL_COND_V(!octant_map.has(p_key), false);
Octant &g = *octant_map[p_key];
- PhysicsServer::get_singleton()->body_set_state(g.static_body, PhysicsServer::BODY_STATE_TRANSFORM, get_global_transform());
+ if (!g.dirty)
+ return false;
- if (g.collision_debug_instance.is_valid()) {
- VS::get_singleton()->instance_set_transform(g.collision_debug_instance, get_global_transform());
- }
+ //erase body shapes
+ PhysicsServer::get_singleton()->body_clear_shapes(g.static_body);
- for (Map<int, Octant::ItemInstances>::Element *E = g.items.front(); E; E = E->next()) {
+ //erase body shapes debug
+ if (g.collision_debug.is_valid()) {
- VS::get_singleton()->instance_set_transform(E->get().multimesh_instance, get_global_transform());
- //print_line("UPDATEPOS: "+get_global_transform());
+ VS::get_singleton()->mesh_clear(g.collision_debug);
}
-}
-void GridMap::_octant_clear_navmesh(const OctantKey &p_key) {
- Octant &g = *octant_map[p_key];
+ //erase navigation
if (navigation) {
for (Map<IndexKey, Octant::NavMesh>::Element *E = g.navmesh_ids.front(); E; E = E->next()) {
- Octant::NavMesh *nvm = &E->get();
- if (nvm && nvm->id) {
- navigation->navmesh_remove(E->get().id);
- }
+ navigation->navmesh_remove(E->get().id);
}
g.navmesh_ids.clear();
}
-}
-void GridMap::_octant_update(const OctantKey &p_key) {
- ERR_FAIL_COND(!octant_map.has(p_key));
- Octant &g = *octant_map[p_key];
- if (!g.dirty)
- return;
-
- Ref<Mesh> mesh;
+ //erase multimeshes
- _octant_clear_navmesh(p_key);
- PhysicsServer::get_singleton()->body_clear_shapes(g.static_body);
+ for (int i = 0; i < g.multimesh_instances.size(); i++) {
- if (g.collision_debug.is_valid()) {
+ VS::get_singleton()->free(g.multimesh_instances[i].instance);
+ VS::get_singleton()->free(g.multimesh_instances[i].multimesh);
+ }
+ g.multimesh_instances.clear();
- VS::get_singleton()->mesh_clear(g.collision_debug);
+ if (g.cells.size() == 0) {
+ //octant no longer needed
+ _octant_clean_up(p_key);
+ return true;
}
PoolVector<Vector3> col_debug;
@@ -554,80 +393,111 @@ void GridMap::_octant_update(const OctantKey &p_key) {
* set item's multimesh's instance count to number of cells which have this item
* and set said multimesh bounding box to one containing all cells which have this item
*/
- for (Map<int, Octant::ItemInstances>::Element *E = g.items.front(); E; E = E->next()) {
- Octant::ItemInstances &ii = E->get();
+ Map<int, List<Pair<Transform, IndexKey> > > multimesh_items;
+
+ print_line("updating octant " + itos(p_key.x) + ", " + itos(p_key.y) + ", " + itos(p_key.z) + " cells: " + itos(g.cells.size()));
- ii.multimesh->set_instance_count(ii.cells.size());
+ for (Set<IndexKey>::Element *E = g.cells.front(); E; E = E->next()) {
- Rect3 aabb;
- Rect3 mesh_aabb = ii.mesh.is_null() ? Rect3() : ii.mesh->get_aabb();
+ ERR_CONTINUE(!cell_map.has(E->get()));
+ const Cell &c = cell_map[E->get()];
- Vector3 ofs(cell_size * 0.5 * int(center_x), cell_size * 0.5 * int(center_y), cell_size * 0.5 * int(center_z));
+ if (!theme.is_valid() || !theme->has_item(c.item))
+ continue;
//print_line("OCTANT, CELLS: "+itos(ii.cells.size()));
- int idx = 0;
- // foreach cell containing this item type
- for (Set<IndexKey>::Element *F = ii.cells.front(); F; F = F->next()) {
- IndexKey ik = F->get();
- Map<IndexKey, Cell>::Element *C = cell_map.find(ik);
- ERR_CONTINUE(!C);
- Vector3 cellpos = Vector3(ik.x, ik.y, ik.z);
+ Vector3 cellpos = Vector3(E->get().x, E->get().y, E->get().z);
+ Vector3 ofs(cell_size.x * 0.5 * int(center_x), cell_size.y * 0.5 * int(center_y), cell_size.z * 0.5 * int(center_z));
- Transform xform;
+ Transform xform;
- if (clip && ((clip_above && cellpos[clip_axis] > clip_floor) || (!clip_above && cellpos[clip_axis] < clip_floor))) {
+ if (clip && ((clip_above && cellpos[clip_axis] > clip_floor) || (!clip_above && cellpos[clip_axis] < clip_floor))) {
- xform.basis.set_zero();
+ } else {
+ }
- } else {
+ xform.basis.set_orthogonal_index(c.rot);
+ xform.set_origin(cellpos * cell_size + ofs);
+ xform.basis.scale(Vector3(cell_scale, cell_scale, cell_scale));
- xform.basis.set_orthogonal_index(C->get().rot);
+ if (theme->get_item_mesh(c.item).is_valid()) {
+ if (!multimesh_items.has(c.item)) {
+ multimesh_items[c.item] = List<Pair<Transform, IndexKey> >();
}
- xform.set_origin(cellpos * cell_size + ofs);
- xform.basis.scale(Vector3(cell_scale, cell_scale, cell_scale));
+ Pair<Transform, IndexKey> p;
+ p.first = xform;
+ p.second = E->get();
+ multimesh_items[c.item].push_back(p);
+ }
- ii.multimesh->set_instance_transform(idx, xform);
- //ii.multimesh->set_instance_transform(idx,Transform() );
- //ii.multimesh->set_instance_color(idx,Color(1,1,1,1));
- //print_line("MMINST: "+xform);
+ Vector<MeshLibrary::ShapeData> shapes = theme->get_item_shapes(c.item);
+ // add the item's shape at given xform to octant's static_body
+ for (int i = 0; i < shapes.size(); i++) {
+ // add the item's shape
+ if (!shapes[i].shape.is_valid())
+ continue;
+ PhysicsServer::get_singleton()->body_add_shape(g.static_body, shapes[i].shape->get_rid(), xform * shapes[i].local_transform);
+ if (g.collision_debug.is_valid()) {
+ shapes[i].shape->add_vertices_to_array(col_debug, xform * shapes[i].local_transform);
+ }
+
+ //print_line("PHIS x: "+xform);
+ }
- if (idx == 0) {
+ // add the item's navmesh at given xform to GridMap's Navigation ancestor
+ Ref<NavigationMesh> navmesh = theme->get_item_navmesh(c.item);
+ if (navmesh.is_valid()) {
+ Octant::NavMesh nm;
+ nm.xform = xform;
- aabb = xform.xform(mesh_aabb);
+ if (navigation) {
+ nm.id = navigation->navmesh_create(navmesh, xform, this);
} else {
-
- aabb.merge_with(xform.xform(mesh_aabb));
+ nm.id = -1;
}
+ g.navmesh_ids[E->get()] = nm;
+ }
+ }
- // add the item's shape at given xform to octant's static_body
- if (ii.shape.is_valid()) {
- // add the item's shape
- PhysicsServer::get_singleton()->body_add_shape(g.static_body, ii.shape->get_rid(), xform);
- if (g.collision_debug.is_valid()) {
- ii.shape->add_vertices_to_array(col_debug, xform);
- }
+ //update multimeshes
+ for (Map<int, List<Pair<Transform, IndexKey> > >::Element *E = multimesh_items.front(); E; E = E->next()) {
+ print_line("multimesh item " + itos(E->key()) + " transforms " + itos(E->get().size()));
+ Octant::MultimeshInstance mmi;
- //print_line("PHIS x: "+xform);
- }
+ RID mm = VS::get_singleton()->multimesh_create();
+ VS::get_singleton()->multimesh_allocate(mm, E->get().size(), VS::MULTIMESH_TRANSFORM_3D, VS::MULTIMESH_COLOR_NONE);
+ VS::get_singleton()->multimesh_set_mesh(mm, theme->get_item_mesh(E->key())->get_rid());
- // add the item's navmesh at given xform to GridMap's Navigation ancestor
- if (navigation) {
- if (ii.navmesh.is_valid()) {
- int nm_id = navigation->navmesh_create(ii.navmesh, xform, this);
- Octant::NavMesh nm;
- nm.id = nm_id;
- nm.xform = xform;
- g.navmesh_ids[ik] = nm;
- }
- }
+ int idx = 0;
+ for (List<Pair<Transform, IndexKey> >::Element *F = E->get().front(); F; F = F->next()) {
+ VS::get_singleton()->multimesh_instance_set_transform(mm, idx, F->get().first);
+#ifdef TOOLS_ENABLED
+
+ Octant::MultimeshInstance::Item it;
+ it.index = idx;
+ it.transform = F->get().first;
+ it.key = F->get().second;
+ mmi.items.push_back(it);
+#endif
idx++;
}
- //ii.multimesh->set_aabb(aabb);
+ RID instance = VS::get_singleton()->instance_create();
+ VS::get_singleton()->instance_set_base(instance, mm);
+
+ if (is_inside_tree()) {
+ VS::get_singleton()->instance_set_scenario(instance, get_world()->get_scenario());
+ VS::get_singleton()->instance_set_transform(instance, get_global_transform());
+ }
+
+ mmi.multimesh = mm;
+ mmi.instance = instance;
+
+ g.multimesh_instances.push_back(mmi);
}
if (col_debug.size()) {
@@ -644,6 +514,39 @@ void GridMap::_octant_update(const OctantKey &p_key) {
}
g.dirty = false;
+
+ return false;
+}
+
+void GridMap::_octant_enter_world(const OctantKey &p_key) {
+
+ ERR_FAIL_COND(!octant_map.has(p_key));
+ Octant &g = *octant_map[p_key];
+ PhysicsServer::get_singleton()->body_set_state(g.static_body, PhysicsServer::BODY_STATE_TRANSFORM, get_global_transform());
+ PhysicsServer::get_singleton()->body_set_space(g.static_body, get_world()->get_space());
+ //print_line("BODYPOS: "+get_global_transform());
+
+ if (g.collision_debug_instance.is_valid()) {
+ VS::get_singleton()->instance_set_scenario(g.collision_debug_instance, get_world()->get_scenario());
+ VS::get_singleton()->instance_set_transform(g.collision_debug_instance, get_global_transform());
+ }
+
+ for (int i = 0; i < g.multimesh_instances.size(); i++) {
+ VS::get_singleton()->instance_set_scenario(g.multimesh_instances[i].instance, get_world()->get_scenario());
+ VS::get_singleton()->instance_set_transform(g.multimesh_instances[i].instance, get_global_transform());
+ }
+
+ if (navigation && theme.is_valid()) {
+ for (Map<IndexKey, Octant::NavMesh>::Element *F = g.navmesh_ids.front(); F; F = F->next()) {
+
+ if (cell_map.has(F->key()) && F->get().id < 0) {
+ Ref<NavigationMesh> nm = theme->get_item_navmesh(cell_map[F->key()].item);
+ if (nm.is_valid()) {
+ F->get().id = navigation->navmesh_create(nm, F->get().xform, this);
+ }
+ }
+ }
+ }
}
void GridMap::_octant_exit_world(const OctantKey &p_key) {
@@ -655,16 +558,52 @@ void GridMap::_octant_exit_world(const OctantKey &p_key) {
if (g.collision_debug_instance.is_valid()) {
- VS::get_singleton()->instance_set_room(g.collision_debug_instance, RID());
VS::get_singleton()->instance_set_scenario(g.collision_debug_instance, RID());
}
- for (Map<int, Octant::ItemInstances>::Element *E = g.items.front(); E; E = E->next()) {
+ for (int i = 0; i < g.multimesh_instances.size(); i++) {
+ VS::get_singleton()->instance_set_scenario(g.multimesh_instances[i].instance, RID());
+ }
+
+ if (navigation) {
+ for (Map<IndexKey, Octant::NavMesh>::Element *F = g.navmesh_ids.front(); F; F = F->next()) {
+
+ if (F->get().id >= 0) {
+ navigation->navmesh_remove(F->get().id);
+ F->get().id = -1;
+ }
+ }
+ }
+}
+
+void GridMap::_octant_clean_up(const OctantKey &p_key) {
+
+ ERR_FAIL_COND(!octant_map.has(p_key));
+ Octant &g = *octant_map[p_key];
+
+ if (g.collision_debug.is_valid())
+ VS::get_singleton()->free(g.collision_debug);
+ if (g.collision_debug_instance.is_valid())
+ VS::get_singleton()->free(g.collision_debug_instance);
+
+ PhysicsServer::get_singleton()->free(g.static_body);
+
+ //erase navigation
+ if (navigation) {
+ for (Map<IndexKey, Octant::NavMesh>::Element *E = g.navmesh_ids.front(); E; E = E->next()) {
+ navigation->navmesh_remove(E->get().id);
+ }
+ g.navmesh_ids.clear();
+ }
+
+ //erase multimeshes
+
+ for (int i = 0; i < g.multimesh_instances.size(); i++) {
- VS::get_singleton()->instance_set_scenario(E->get().multimesh_instance, RID());
- //VS::get_singleton()->instance_set_transform(E->get().multimesh_instance,get_global_transform());
- VS::get_singleton()->instance_set_room(E->get().multimesh_instance, RID());
+ VS::get_singleton()->free(g.multimesh_instances[i].instance);
+ VS::get_singleton()->free(g.multimesh_instances[i].multimesh);
}
+ g.multimesh_instances.clear();
}
void GridMap::_notification(int p_what) {
@@ -673,19 +612,22 @@ void GridMap::_notification(int p_what) {
case NOTIFICATION_ENTER_WORLD: {
- _update_area_instances();
+ Spatial *c = this;
+ while (c) {
+ navigation = Object::cast_to<Navigation>(c);
+ if (navigation) {
+ break;
+ }
+
+ c = Object::cast_to<Spatial>(c->get_parent());
+ }
+
+ last_transform = get_global_transform();
for (Map<OctantKey, Octant *>::Element *E = octant_map.front(); E; E = E->next()) {
- //IndexKey ik;
- //ik.key = E->key().indexkey;
_octant_enter_world(E->key());
- _octant_update(E->key());
}
- awaiting_update = false;
-
- last_transform = get_global_transform();
-
} break;
case NOTIFICATION_TRANSFORM_CHANGED: {
@@ -706,104 +648,47 @@ void GridMap::_notification(int p_what) {
_octant_exit_world(E->key());
}
- //_queue_dirty_map(MAP_DIRTY_INSTANCES|MAP_DIRTY_TRANSFORMS);
- //_update_dirty_map_callback();
- //_update_area_instances();
-
- } break;
- case NOTIFICATION_ENTER_TREE: {
-
- Spatial *c = this;
- while (c) {
- navigation = c->cast_to<Navigation>();
- if (navigation) {
- break;
- }
-
- c = c->get_parent()->cast_to<Spatial>();
- }
-
- if (navigation) {
- for (Map<OctantKey, Octant *>::Element *E = octant_map.front(); E; E = E->next()) {
- if (navigation) {
- _octant_enter_tree(E->key());
- }
- }
- }
-
- _queue_dirty_map();
- } break;
- case NOTIFICATION_EXIT_TREE: {
- for (Map<OctantKey, Octant *>::Element *E = octant_map.front(); E; E = E->next()) {
- if (navigation) {
- _octant_clear_navmesh(E->key());
- }
- }
-
navigation = NULL;
+ //_queue_octants_dirty(MAP_DIRTY_INSTANCES|MAP_DIRTY_TRANSFORMS);
+ //_update_octants_callback();
+ //_update_area_instances();
+
} break;
}
}
-void GridMap::_queue_dirty_map() {
+void GridMap::_queue_octants_dirty() {
if (awaiting_update)
return;
- if (is_inside_world()) {
-
- MessageQueue::get_singleton()->push_call(this, "_update_dirty_map_callback");
- awaiting_update = true;
- }
+ MessageQueue::get_singleton()->push_call(this, "_update_octants_callback");
+ awaiting_update = true;
}
void GridMap::_recreate_octant_data() {
Map<IndexKey, Cell> cell_copy = cell_map;
- _clear_internal(true);
+ _clear_internal();
for (Map<IndexKey, Cell>::Element *E = cell_copy.front(); E; E = E->next()) {
set_cell_item(E->key().x, E->key().y, E->key().z, E->get().item, E->get().rot);
}
}
-void GridMap::_clear_internal(bool p_keep_areas) {
+void GridMap::_clear_internal() {
for (Map<OctantKey, Octant *>::Element *E = octant_map.front(); E; E = E->next()) {
if (is_inside_world())
_octant_exit_world(E->key());
- for (Map<int, Octant::ItemInstances>::Element *F = E->get()->items.front(); F; F = F->next()) {
-
- VS::get_singleton()->free(F->get().multimesh_instance);
- }
-
- if (E->get()->collision_debug.is_valid())
- VS::get_singleton()->free(E->get()->collision_debug);
- if (E->get()->collision_debug_instance.is_valid())
- VS::get_singleton()->free(E->get()->collision_debug_instance);
-
- PhysicsServer::get_singleton()->free(E->get()->static_body);
+ _octant_clean_up(E->key());
memdelete(E->get());
}
octant_map.clear();
cell_map.clear();
-
- if (p_keep_areas)
- return;
-
- for (Map<int, Area *>::Element *E = area_map.front(); E; E = E->next()) {
-
- VS::get_singleton()->free(E->get()->base_portal);
- VS::get_singleton()->free(E->get()->instance);
- for (int i = 0; i < E->get()->portals.size(); i++) {
- VS::get_singleton()->free(E->get()->portals[i].instance);
- }
-
- memdelete(E->get());
- }
}
void GridMap::clear() {
@@ -816,13 +701,23 @@ void GridMap::resource_changed(const RES &p_res) {
_recreate_octant_data();
}
-void GridMap::_update_dirty_map_callback() {
+void GridMap::_update_octants_callback() {
if (!awaiting_update)
return;
+ List<OctantKey> to_delete;
for (Map<OctantKey, Octant *>::Element *E = octant_map.front(); E; E = E->next()) {
- _octant_update(E->key());
+
+ if (_octant_update(E->key())) {
+ to_delete.push_back(E->key());
+ }
+ }
+
+ while (to_delete.front()) {
+ memdelete(octant_map[to_delete.front()->get()]);
+ octant_map.erase(to_delete.front()->get());
+ to_delete.pop_back();
}
awaiting_update = false;
@@ -844,7 +739,7 @@ void GridMap::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_cell_item_orientation", "x", "y", "z"), &GridMap::get_cell_item_orientation);
//ClassDB::bind_method(D_METHOD("_recreate_octants"),&GridMap::_recreate_octants);
- ClassDB::bind_method(D_METHOD("_update_dirty_map_callback"), &GridMap::_update_dirty_map_callback);
+ ClassDB::bind_method(D_METHOD("_update_octants_callback"), &GridMap::_update_octants_callback);
ClassDB::bind_method(D_METHOD("resource_changed", "resource"), &GridMap::resource_changed);
ClassDB::bind_method(D_METHOD("set_center_x", "enable"), &GridMap::set_center_x);
@@ -856,19 +751,6 @@ void GridMap::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_clip", "enabled", "clipabove", "floor", "axis"), &GridMap::set_clip, DEFVAL(true), DEFVAL(0), DEFVAL(Vector3::AXIS_X));
- ClassDB::bind_method(D_METHOD("create_area", "id", "area"), &GridMap::create_area);
- ClassDB::bind_method(D_METHOD("area_get_bounds", "area"), &GridMap::area_get_bounds);
- ClassDB::bind_method(D_METHOD("area_set_exterior_portal", "area", "enable"), &GridMap::area_set_exterior_portal);
- ClassDB::bind_method(D_METHOD("area_set_name", "area", "name"), &GridMap::area_set_name);
- ClassDB::bind_method(D_METHOD("area_get_name", "area"), &GridMap::area_get_name);
- ClassDB::bind_method(D_METHOD("area_is_exterior_portal", "area"), &GridMap::area_is_exterior_portal);
- ClassDB::bind_method(D_METHOD("area_set_portal_disable_distance", "area", "distance"), &GridMap::area_set_portal_disable_distance);
- ClassDB::bind_method(D_METHOD("area_get_portal_disable_distance", "area"), &GridMap::area_get_portal_disable_distance);
- ClassDB::bind_method(D_METHOD("area_set_portal_disable_color", "area", "color"), &GridMap::area_set_portal_disable_color);
- ClassDB::bind_method(D_METHOD("area_get_portal_disable_color", "area"), &GridMap::area_get_portal_disable_color);
- ClassDB::bind_method(D_METHOD("erase_area", "area"), &GridMap::erase_area);
- ClassDB::bind_method(D_METHOD("get_unused_area_id"), &GridMap::get_unused_area_id);
-
ClassDB::bind_method(D_METHOD("clear"), &GridMap::clear);
ClassDB::bind_method(D_METHOD("get_meshes"), &GridMap::get_meshes);
@@ -895,341 +777,13 @@ void GridMap::set_clip(bool p_enabled, bool p_clip_above, int p_floor, Vector3::
g->dirty = true;
}
awaiting_update = true;
- _update_dirty_map_callback();
-}
-
-void GridMap::_update_areas() {
-
- //clear the portals
- for (Map<int, Area *>::Element *E = area_map.front(); E; E = E->next()) {
- //this should somehow be faster...
- Area &a = *E->get();
- a.portals.clear();
- if (a.instance.is_valid()) {
- VisualServer::get_singleton()->free(a.instance);
- a.instance = RID();
- }
- }
-
- //test all areas against all areas and create portals - this sucks (slow :( )
- for (Map<int, Area *>::Element *E = area_map.front(); E; E = E->next()) {
- Area &a = *E->get();
- if (a.exterior_portal) //that's pretty much all it does... yes it is
- continue;
- Vector3 from_a(a.from.x, a.from.y, a.from.z);
- Vector3 to_a(a.to.x, a.to.y, a.to.z);
-
- for (Map<int, Area *>::Element *F = area_map.front(); F; F = F->next()) {
-
- Area &b = *F->get();
- Vector3 from_b(b.from.x, b.from.y, b.from.z);
- Vector3 to_b(b.to.x, b.to.y, b.to.z);
-
- // initially test intersection and discards
- int axis = -1;
- float sign = 0;
- bool valid = true;
- Vector3 axmin, axmax;
-
- for (int i = 0; i < 3; i++) {
-
- if (from_a[i] == to_b[i]) {
-
- if (axis != -1) {
- valid = false;
- break;
- }
-
- axis = i;
- sign = -1;
- } else if (from_b[i] == to_a[i]) {
-
- if (axis != -1) {
- valid = false;
- break;
- }
- axis = i;
- sign = +1;
- }
-
- if (from_a[i] > to_b[i] || to_a[i] < from_b[i]) {
- valid = false;
- break;
- } else {
-
- axmin[i] = (from_a[i] > from_b[i]) ? from_a[i] : from_b[i];
- axmax[i] = (to_a[i] < to_b[i]) ? to_a[i] : to_b[i];
- }
- }
-
- if (axis == -1 || !valid)
- continue;
-
- Transform xf;
-
- for (int i = 0; i < 3; i++) {
-
- int ax = (axis + i) % 3;
- Vector3 axis_vec;
- float scale = (i == 0) ? sign : ((axmax[ax] - axmin[ax]) * cell_size);
- axis_vec[ax] = scale;
- xf.basis.set_axis((2 + i) % 3, axis_vec);
- xf.origin[i] = axmin[i] * cell_size;
- }
-
- Area::Portal portal;
- portal.xform = xf;
- a.portals.push_back(portal);
- }
- }
-
- _update_area_instances();
-}
-
-void GridMap::_update_area_instances() {
-
- Transform base_xform;
- if (_in_tree)
- base_xform = get_global_transform();
-
- for (Map<int, Area *>::Element *E = area_map.front(); E; E = E->next()) {
- //this should somehow be faster...
- Area &a = *E->get();
- if (a.instance.is_valid() != _in_tree) {
-
- if (!_in_tree) {
-
- for (int i = 0; i < a.portals.size(); i++) {
-
- Area::Portal &p = a.portals[i];
- ERR_CONTINUE(!p.instance.is_valid());
- VisualServer::get_singleton()->free(p.instance);
- p.instance = RID();
- }
-
- VisualServer::get_singleton()->free(a.instance);
- a.instance = RID();
-
- } else {
-
- //a.instance = VisualServer::get_singleton()->instance_create2(base_room,get_world()->get_scenario());
- for (int i = 0; i < a.portals.size(); i++) {
-
- Area::Portal &p = a.portals[i];
- ERR_CONTINUE(p.instance.is_valid());
- p.instance = VisualServer::get_singleton()->instance_create2(a.base_portal, get_world()->get_scenario());
- VisualServer::get_singleton()->instance_set_room(p.instance, a.instance);
- }
- }
- }
-
- if (a.instance.is_valid()) {
- Transform xform;
-
- Vector3 from_a(a.from.x, a.from.y, a.from.z);
- Vector3 to_a(a.to.x, a.to.y, a.to.z);
-
- for (int i = 0; i < 3; i++) {
- xform.origin[i] = from_a[i] * cell_size;
- Vector3 s;
- s[i] = (to_a[i] - from_a[i]) * cell_size;
- xform.basis.set_axis(i, s);
- }
-
- VisualServer::get_singleton()->instance_set_transform(a.instance, base_xform * xform);
-
- for (int i = 0; i < a.portals.size(); i++) {
-
- Area::Portal &p = a.portals[i];
- ERR_CONTINUE(!p.instance.is_valid());
-
- VisualServer::get_singleton()->instance_set_transform(p.instance, base_xform * xform);
- }
- }
- }
-}
-
-Error GridMap::create_area(int p_id, const Rect3 &p_area) {
-
- ERR_FAIL_COND_V(area_map.has(p_id), ERR_ALREADY_EXISTS);
- ERR_EXPLAIN("ID 0 is taken as global area, start from 1");
- ERR_FAIL_COND_V(p_id == 0, ERR_INVALID_PARAMETER);
- ERR_FAIL_COND_V(p_area.has_no_area(), ERR_INVALID_PARAMETER);
-
- // FIRST VALIDATE AREA
- IndexKey from, to;
- from.x = p_area.position.x;
- from.y = p_area.position.y;
- from.z = p_area.position.z;
- to.x = p_area.position.x + p_area.size.x;
- to.y = p_area.position.y + p_area.size.y;
- to.z = p_area.position.z + p_area.size.z;
-
- for (Map<int, Area *>::Element *E = area_map.front(); E; E = E->next()) {
- //this should somehow be faster...
- Area &a = *E->get();
-
- //does it interset with anything else?
-
- if (from.x >= a.to.x ||
- to.x <= a.from.x ||
- from.y >= a.to.y ||
- to.y <= a.from.y ||
- from.z >= a.to.z ||
- to.z <= a.from.z) {
-
- // all good
- } else {
-
- return ERR_INVALID_PARAMETER;
- }
- }
-
- Area *area = memnew(Area);
- area->from = from;
- area->to = to;
- area->portal_disable_distance = 0;
- area->exterior_portal = false;
- area->name = "Area " + itos(p_id);
- area_map[p_id] = area;
- _recreate_octant_data();
- return OK;
-}
-
-Rect3 GridMap::area_get_bounds(int p_area) const {
-
- ERR_FAIL_COND_V(!area_map.has(p_area), Rect3());
-
- const Area *a = area_map[p_area];
- Rect3 aabb;
- aabb.position = Vector3(a->from.x, a->from.y, a->from.z);
- aabb.size = Vector3(a->to.x, a->to.y, a->to.z) - aabb.position;
-
- return aabb;
-}
-
-void GridMap::area_set_name(int p_area, const String &p_name) {
-
- ERR_FAIL_COND(!area_map.has(p_area));
-
- Area *a = area_map[p_area];
- a->name = p_name;
-}
-
-String GridMap::area_get_name(int p_area) const {
-
- ERR_FAIL_COND_V(!area_map.has(p_area), "");
-
- const Area *a = area_map[p_area];
- return a->name;
-}
-
-void GridMap::area_set_exterior_portal(int p_area, bool p_enable) {
-
- ERR_FAIL_COND(!area_map.has(p_area));
-
- Area *a = area_map[p_area];
- if (a->exterior_portal == p_enable)
- return;
- a->exterior_portal = p_enable;
-
- _recreate_octant_data();
-}
-
-bool GridMap::area_is_exterior_portal(int p_area) const {
-
- ERR_FAIL_COND_V(!area_map.has(p_area), false);
-
- const Area *a = area_map[p_area];
- return a->exterior_portal;
-}
-
-void GridMap::area_set_portal_disable_distance(int p_area, float p_distance) {
-
- ERR_FAIL_COND(!area_map.has(p_area));
-
- Area *a = area_map[p_area];
- a->portal_disable_distance = p_distance;
-}
-
-float GridMap::area_get_portal_disable_distance(int p_area) const {
-
- ERR_FAIL_COND_V(!area_map.has(p_area), 0);
-
- const Area *a = area_map[p_area];
- return a->portal_disable_distance;
-}
-
-void GridMap::area_set_portal_disable_color(int p_area, Color p_color) {
-
- ERR_FAIL_COND(!area_map.has(p_area));
-
- Area *a = area_map[p_area];
- a->portal_disable_color = p_color;
-}
-
-Color GridMap::area_get_portal_disable_color(int p_area) const {
-
- ERR_FAIL_COND_V(!area_map.has(p_area), Color());
-
- const Area *a = area_map[p_area];
- return a->portal_disable_color;
-}
-
-void GridMap::get_area_list(List<int> *p_areas) const {
-
- for (const Map<int, Area *>::Element *E = area_map.front(); E; E = E->next()) {
-
- p_areas->push_back(E->key());
- }
-}
-
-GridMap::Area::Portal::~Portal() {
-
- if (instance.is_valid())
- VisualServer::get_singleton()->free(instance);
-}
-
-GridMap::Area::Area() {
-
- base_portal = VisualServer::get_singleton()->portal_create();
- Vector<Point2> points;
- points.push_back(Point2(0, 1));
- points.push_back(Point2(1, 1));
- points.push_back(Point2(1, 0));
- points.push_back(Point2(0, 0));
- VisualServer::get_singleton()->portal_set_shape(base_portal, points);
-}
-
-GridMap::Area::~Area() {
-
- if (instance.is_valid())
- VisualServer::get_singleton()->free(instance);
- VisualServer::get_singleton()->free(base_portal);
-}
-
-void GridMap::erase_area(int p_area) {
-
- ERR_FAIL_COND(!area_map.has(p_area));
-
- Area *a = area_map[p_area];
- memdelete(a);
- area_map.erase(p_area);
- _recreate_octant_data();
-}
-
-int GridMap::get_unused_area_id() const {
-
- if (area_map.empty())
- return 1;
- else
- return area_map.back()->key() + 1;
+ _update_octants_callback();
}
void GridMap::set_cell_scale(float p_scale) {
cell_scale = p_scale;
- _queue_dirty_map();
+ _queue_octants_dirty();
}
float GridMap::get_cell_scale() const {
@@ -1242,7 +796,7 @@ Array GridMap::get_meshes() {
if (theme.is_null())
return Array();
- Vector3 ofs(cell_size * 0.5 * int(center_x), cell_size * 0.5 * int(center_y), cell_size * 0.5 * int(center_z));
+ Vector3 ofs(cell_size.x * 0.5 * int(center_x), cell_size.y * 0.5 * int(center_y), cell_size.z * 0.5 * int(center_z));
Array meshes;
for (Map<IndexKey, Cell>::Element *E = cell_map.front(); E; E = E->next()) {
@@ -1274,7 +828,7 @@ Array GridMap::get_meshes() {
GridMap::GridMap() {
- cell_size = 2;
+ cell_size = Vector3(2, 2, 2);
octant_size = 4;
awaiting_update = false;
_in_tree = false;
diff --git a/modules/gridmap/grid_map.h b/modules/gridmap/grid_map.h
index 106bf82dc2..9e1d250680 100644
--- a/modules/gridmap/grid_map.h
+++ b/modules/gridmap/grid_map.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -38,8 +38,6 @@
//heh heh, godotsphir!! this shares no code and the design is completely different with previous projects i've done..
//should scale better with hardware that supports instancing
-class BakedLightInstance;
-
class GridMap : public Spatial {
GDCLASS(GridMap, Spatial);
@@ -96,21 +94,25 @@ class GridMap : public Spatial {
Transform xform;
};
- struct ItemInstances {
- Set<IndexKey> cells;
- Ref<Mesh> mesh;
- Ref<Shape> shape;
- Ref<MultiMesh> multimesh;
- RID multimesh_instance;
- Ref<NavigationMesh> navmesh;
+ struct MultimeshInstance {
+ RID instance;
+ RID multimesh;
+ struct Item {
+ int index;
+ Transform transform;
+ IndexKey key;
+ };
+
+ Vector<Item> items; //tools only, for changing visibility
};
+ Vector<MultimeshInstance> multimesh_instances;
+ Set<IndexKey> cells;
RID collision_debug;
RID collision_debug_instance;
bool dirty;
RID static_body;
- Map<int, ItemInstances> items;
Map<IndexKey, NavMesh> navmesh_ids;
};
@@ -120,7 +122,7 @@ class GridMap : public Spatial {
int16_t x;
int16_t y;
int16_t z;
- int16_t area;
+ int16_t empty;
};
uint64_t key;
@@ -137,7 +139,7 @@ class GridMap : public Spatial {
Transform last_transform;
bool _in_tree;
- float cell_size;
+ Vector3 cell_size;
int octant_size;
bool center_x, center_y, center_z;
float cell_scale;
@@ -148,35 +150,10 @@ class GridMap : public Spatial {
int clip_floor;
Vector3::Axis clip_axis;
- /**
- * @brief An Area is something like a room: it has doors, and Octants can choose to belong to it.
- */
- struct Area {
-
- String name;
- RID base_portal;
- RID instance;
- IndexKey from;
- IndexKey to;
- struct Portal {
- Transform xform;
- RID instance;
- ~Portal();
- };
- Vector<Portal> portals;
- float portal_disable_distance;
- Color portal_disable_color;
- bool exterior_portal;
-
- Area();
- ~Area();
- };
-
Ref<MeshLibrary> theme;
Map<OctantKey, Octant *> octant_map;
Map<IndexKey, Cell> cell_map;
- Map<int, Area *> area_map;
void _recreate_octant_data();
@@ -188,30 +165,24 @@ class GridMap : public Spatial {
float param[VS::LIGHT_PARAM_MAX];
};
- _FORCE_INLINE_ int _find_area(const IndexKey &p_pos) const;
-
_FORCE_INLINE_ Vector3 _octant_get_offset(const OctantKey &p_key) const {
return Vector3(p_key.x, p_key.y, p_key.z) * cell_size * octant_size;
}
void _octant_enter_world(const OctantKey &p_key);
- void _octant_enter_tree(const OctantKey &p_key);
void _octant_exit_world(const OctantKey &p_key);
- void _octant_update(const OctantKey &p_key);
+ bool _octant_update(const OctantKey &p_key);
+ void _octant_clean_up(const OctantKey &p_key);
void _octant_transform(const OctantKey &p_key);
- void _octant_clear_navmesh(const GridMap::OctantKey &);
bool awaiting_update;
- void _queue_dirty_map();
- void _update_dirty_map_callback();
+ void _queue_octants_dirty();
+ void _update_octants_callback();
void resource_changed(const RES &p_res);
- void _update_areas();
- void _update_area_instances();
-
- void _clear_internal(bool p_keep_areas = false);
+ void _clear_internal();
protected:
bool _set(const StringName &p_name, const Variant &p_value);
@@ -229,8 +200,8 @@ public:
void set_theme(const Ref<MeshLibrary> &p_theme);
Ref<MeshLibrary> get_theme() const;
- void set_cell_size(float p_size);
- float get_cell_size() const;
+ void set_cell_size(const Vector3 &p_size);
+ Vector3 get_cell_size() const;
void set_octant_size(int p_size);
int get_octant_size() const;
@@ -248,20 +219,6 @@ public:
void set_clip(bool p_enabled, bool p_clip_above = true, int p_floor = 0, Vector3::Axis p_axis = Vector3::AXIS_X);
- Error create_area(int p_id, const Rect3 &p_area);
- Rect3 area_get_bounds(int p_area) const;
- void area_set_exterior_portal(int p_area, bool p_enable);
- void area_set_name(int p_area, const String &p_name);
- String area_get_name(int p_area) const;
- bool area_is_exterior_portal(int p_area) const;
- void area_set_portal_disable_distance(int p_area, float p_distance);
- float area_get_portal_disable_distance(int p_area) const;
- void area_set_portal_disable_color(int p_area, Color p_color);
- Color area_get_portal_disable_color(int p_area) const;
- void get_area_list(List<int> *p_areas) const;
- void erase_area(int p_area);
- int get_unused_area_id() const;
-
void set_cell_scale(float p_scale);
float get_cell_scale() const;
@@ -273,4 +230,4 @@ public:
~GridMap();
};
-#endif // CUBE_GRID_MAP_H
+#endif // GRID_MAP_H
diff --git a/modules/gridmap/grid_map_editor_plugin.cpp b/modules/gridmap/grid_map_editor_plugin.cpp
index 38f58799df..6f0a13e07f 100644
--- a/modules/gridmap/grid_map_editor_plugin.cpp
+++ b/modules/gridmap/grid_map_editor_plugin.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -178,30 +178,6 @@ void GridMapEditor::_menu_option(int p_option) {
int idx = options->get_popup()->get_item_index(MENU_OPTION_DUPLICATE_SELECTS);
options->get_popup()->set_item_checked(idx, !options->get_popup()->is_item_checked(idx));
} break;
- case MENU_OPTION_SELECTION_MAKE_AREA:
- case MENU_OPTION_SELECTION_MAKE_EXTERIOR_CONNECTOR: {
-
- if (!selection.active)
- break;
- int area = node->get_unused_area_id();
- Error err = node->create_area(area, Rect3(selection.begin, selection.end - selection.begin + Vector3(1, 1, 1)));
- if (err != OK) {
- }
- if (p_option == MENU_OPTION_SELECTION_MAKE_EXTERIOR_CONNECTOR) {
-
- node->area_set_exterior_portal(area, true);
- }
- _update_areas_display();
- update_areas();
-
- } break;
- case MENU_OPTION_REMOVE_AREA: {
- if (selected_area < 1)
- return;
- node->erase_area(selected_area);
- _update_areas_display();
- update_areas();
- } break;
case MENU_OPTION_SELECTION_DUPLICATE:
if (!(selection.active && input_action == INPUT_NONE))
return;
@@ -241,12 +217,15 @@ void GridMapEditor::_update_cursor_transform() {
}
void GridMapEditor::_update_selection_transform() {
+ Transform xf_zero;
+ xf_zero.basis.set_zero();
if (!selection.active) {
- Transform xf;
- xf.basis.set_zero();
- VisualServer::get_singleton()->instance_set_transform(selection_instance, xf);
+ VisualServer::get_singleton()->instance_set_transform(selection_instance, xf_zero);
+ for (int i = 0; i < 3; i++) {
+ VisualServer::get_singleton()->instance_set_transform(selection_level_instance[i], xf_zero);
+ }
return;
}
@@ -255,6 +234,27 @@ void GridMapEditor::_update_selection_transform() {
xf.origin = selection.begin * node->get_cell_size();
VisualServer::get_singleton()->instance_set_transform(selection_instance, node->get_global_transform() * xf);
+
+ for (int i = 0; i < 3; i++) {
+ if (i != edit_axis || (edit_floor[edit_axis] < selection.begin[edit_axis]) || (edit_floor[edit_axis] > selection.end[edit_axis] + 1)) {
+ VisualServer::get_singleton()->instance_set_transform(selection_level_instance[i], xf_zero);
+ } else {
+
+ Vector3 scale = (selection.end - selection.begin + Vector3(1, 1, 1));
+ scale[edit_axis] = 1.0;
+ Vector3 pos = selection.begin;
+ pos[edit_axis] = edit_floor[edit_axis];
+
+ scale *= node->get_cell_size();
+ pos *= node->get_cell_size();
+
+ Transform xf;
+ xf.basis.scale(scale);
+ xf.origin = pos;
+
+ VisualServer::get_singleton()->instance_set_transform(selection_level_instance[i], xf);
+ }
+ }
}
void GridMapEditor::_validate_selection() {
@@ -297,7 +297,7 @@ bool GridMapEditor::do_input_action(Camera *p_camera, const Point2 &p_point, boo
Plane p;
p.normal[edit_axis] = 1.0;
- p.d = edit_floor[edit_axis] * node->get_cell_size();
+ p.d = edit_floor[edit_axis] * node->get_cell_size()[edit_axis];
Vector3 inters;
if (!p.intersects_segment(from, from + normal * settings_pick_distance->get_value(), &inters))
@@ -313,7 +313,7 @@ bool GridMapEditor::do_input_action(Camera *p_camera, const Point2 &p_point, boo
}
int cell[3];
- float cell_size[3] = { node->get_cell_size(), node->get_cell_size(), node->get_cell_size() };
+ float cell_size[3] = { node->get_cell_size().x, node->get_cell_size().y, node->get_cell_size().z };
last_mouseover = Vector3(-1, -1, -1);
@@ -323,7 +323,7 @@ bool GridMapEditor::do_input_action(Camera *p_camera, const Point2 &p_point, boo
cell[i] = edit_floor[i];
else {
- cell[i] = inters[i] / node->get_cell_size();
+ cell[i] = inters[i] / node->get_cell_size()[i];
if (inters[i] < 0)
cell[i] -= 1; //compensate negative
grid_ofs[i] = cell[i] * cell_size[i];
@@ -403,7 +403,7 @@ void GridMapEditor::_delete_selection() {
if (!selection.active)
return;
- undo_redo->create_action("GridMap Delete Selection");
+ undo_redo->create_action(TTR("GridMap Delete Selection"));
for (int i = selection.begin.x; i <= selection.end.x; i++) {
for (int j = selection.begin.y; j <= selection.end.y; j++) {
@@ -487,7 +487,7 @@ void GridMapEditor::_duplicate_paste() {
Vector3 ofs = selection.current - selection.click;
if (items.size()) {
- undo_redo->create_action("GridMap Duplicate Selection");
+ undo_redo->create_action(TTR("GridMap Duplicate Selection"));
for (List<__Item>::Element *E = items.front(); E; E = E->next()) {
__Item &it = E->get();
Vector3 pos = it.pos + ofs;
@@ -513,146 +513,96 @@ bool GridMapEditor::forward_spatial_input_event(Camera *p_camera, const Ref<Inpu
return false;
}
- if (edit_mode->get_selected() == 0) { // regular click
-
- Ref<InputEventMouseButton> mb = p_event;
-
- if (mb.is_valid()) {
-
- if (mb->get_button_index() == BUTTON_WHEEL_UP && (mb->get_command() || mb->get_shift())) {
- if (mb->is_pressed())
- floor->set_value(floor->get_value() + mb->get_factor());
-
- return true; //eaten
- } else if (mb->get_button_index() == BUTTON_WHEEL_DOWN && (mb->get_command() || mb->get_shift())) {
- if (mb->is_pressed())
- floor->set_value(floor->get_value() - mb->get_factor());
- return true;
- }
-
- if (mb->is_pressed()) {
-
- if (mb->get_button_index() == BUTTON_LEFT) {
+ Ref<InputEventMouseButton> mb = p_event;
- if (input_action == INPUT_DUPLICATE) {
+ if (mb.is_valid()) {
- //paste
- _duplicate_paste();
- input_action = INPUT_NONE;
- _update_duplicate_indicator();
- } else if (mb->get_shift()) {
- input_action = INPUT_SELECT;
- } else if (mb->get_command())
- input_action = INPUT_COPY;
- else {
- input_action = INPUT_PAINT;
- set_items.clear();
- }
- } else if (mb->get_button_index() == BUTTON_RIGHT)
- if (input_action == INPUT_DUPLICATE) {
-
- input_action = INPUT_NONE;
- _update_duplicate_indicator();
- } else {
- input_action = INPUT_ERASE;
- set_items.clear();
- }
- else
- return false;
+ if (mb->get_button_index() == BUTTON_WHEEL_UP && (mb->get_command() || mb->get_shift())) {
+ if (mb->is_pressed())
+ floor->set_value(floor->get_value() + mb->get_factor());
- return do_input_action(p_camera, Point2(mb->get_position().x, mb->get_position().y), true);
- } else {
-
- if (
- (mb->get_button_index() == BUTTON_RIGHT && input_action == INPUT_ERASE) ||
- (mb->get_button_index() == BUTTON_LEFT && input_action == INPUT_PAINT)) {
+ return true; //eaten
+ } else if (mb->get_button_index() == BUTTON_WHEEL_DOWN && (mb->get_command() || mb->get_shift())) {
+ if (mb->is_pressed())
+ floor->set_value(floor->get_value() - mb->get_factor());
+ return true;
+ }
- if (set_items.size()) {
- undo_redo->create_action("GridMap Paint");
- for (List<SetItem>::Element *E = set_items.front(); E; E = E->next()) {
+ if (mb->is_pressed()) {
- const SetItem &si = E->get();
- undo_redo->add_do_method(node, "set_cell_item", si.pos.x, si.pos.y, si.pos.z, si.new_value, si.new_orientation);
- }
- for (List<SetItem>::Element *E = set_items.back(); E; E = E->prev()) {
+ if (mb->get_button_index() == BUTTON_LEFT) {
- const SetItem &si = E->get();
- undo_redo->add_undo_method(node, "set_cell_item", si.pos.x, si.pos.y, si.pos.z, si.old_value, si.old_orientation);
- }
+ if (input_action == INPUT_DUPLICATE) {
- undo_redo->commit_action();
- }
- set_items.clear();
+ //paste
+ _duplicate_paste();
input_action = INPUT_NONE;
- return true;
- }
-
- if (mb->get_button_index() == BUTTON_LEFT && input_action != INPUT_NONE) {
-
+ _update_duplicate_indicator();
+ } else if (mb->get_shift()) {
+ input_action = INPUT_SELECT;
+ } else if (mb->get_command())
+ input_action = INPUT_COPY;
+ else {
+ input_action = INPUT_PAINT;
set_items.clear();
- input_action = INPUT_NONE;
- return true;
}
- if (mb->get_button_index() == BUTTON_RIGHT && (input_action == INPUT_ERASE || input_action == INPUT_DUPLICATE)) {
+ } else if (mb->get_button_index() == BUTTON_RIGHT)
+ if (input_action == INPUT_DUPLICATE) {
+
input_action = INPUT_NONE;
- return true;
+ _update_duplicate_indicator();
+ } else {
+ input_action = INPUT_ERASE;
+ set_items.clear();
}
- }
- }
-
- Ref<InputEventMouseMotion> mm = p_event;
+ else
+ return false;
- if (mm.is_valid()) {
+ return do_input_action(p_camera, Point2(mb->get_position().x, mb->get_position().y), true);
+ } else {
- return do_input_action(p_camera, mm->get_position(), false);
- }
-
- } else if (edit_mode->get_selected() == 1) {
- //area mode, select an area
-
- Ref<InputEventMouseButton> mb = p_event;
-
- if (mb.is_valid()) {
-
- if (mb->get_button_index() == BUTTON_LEFT && mb->is_pressed()) {
+ if (
+ (mb->get_button_index() == BUTTON_RIGHT && input_action == INPUT_ERASE) ||
+ (mb->get_button_index() == BUTTON_LEFT && input_action == INPUT_PAINT)) {
- Point2 point = mb->get_position();
+ if (set_items.size()) {
+ undo_redo->create_action("GridMap Paint");
+ for (List<SetItem>::Element *E = set_items.front(); E; E = E->next()) {
- Camera *camera = p_camera;
- Vector3 from = camera->project_ray_origin(point);
- Vector3 normal = camera->project_ray_normal(point);
- Transform local_xform = node->get_global_transform().affine_inverse();
- from = local_xform.xform(from);
- normal = local_xform.basis.xform(normal).normalized();
+ const SetItem &si = E->get();
+ undo_redo->add_do_method(node, "set_cell_item", si.pos.x, si.pos.y, si.pos.z, si.new_value, si.new_orientation);
+ }
+ for (List<SetItem>::Element *E = set_items.back(); E; E = E->prev()) {
- List<int> areas;
- node->get_area_list(&areas);
+ const SetItem &si = E->get();
+ undo_redo->add_undo_method(node, "set_cell_item", si.pos.x, si.pos.y, si.pos.z, si.old_value, si.old_orientation);
+ }
- float min_d = 1e10;
- int min_area = -1;
+ undo_redo->commit_action();
+ }
+ set_items.clear();
+ input_action = INPUT_NONE;
+ return true;
+ }
- for (List<int>::Element *E = areas.front(); E; E = E->next()) {
+ if (mb->get_button_index() == BUTTON_LEFT && input_action != INPUT_NONE) {
- int area = E->get();
- Rect3 aabb = node->area_get_bounds(area);
- aabb.position *= node->get_cell_size();
- aabb.size *= node->get_cell_size();
+ set_items.clear();
+ input_action = INPUT_NONE;
+ return true;
+ }
+ if (mb->get_button_index() == BUTTON_RIGHT && (input_action == INPUT_ERASE || input_action == INPUT_DUPLICATE)) {
+ input_action = INPUT_NONE;
+ return true;
+ }
+ }
+ }
- Vector3 rclip, rnormal;
- if (!aabb.intersects_segment(from, from + normal * 10000, &rclip, &rnormal))
- continue;
+ Ref<InputEventMouseMotion> mm = p_event;
- float d = normal.dot(rclip);
- if (d < min_d) {
- min_d = d;
- min_area = area;
- }
- }
+ if (mm.is_valid()) {
- selected_area = min_area;
- update_areas();
- }
- }
+ return do_input_action(p_camera, mm->get_position(), false);
}
return false;
@@ -749,52 +699,6 @@ void GridMapEditor::update_pallete() {
last_theme = theme.operator->();
}
-void GridMapEditor::_area_renamed() {
-
- TreeItem *it = area_list->get_selected();
- int area = it->get_metadata(0);
- if (area < 1)
- return;
- node->area_set_name(area, it->get_text(0));
-}
-
-void GridMapEditor::_area_selected() {
-
- TreeItem *it = area_list->get_selected();
- int area = it->get_metadata(0);
- if (area < 1)
- return;
- selected_area = area;
-}
-
-void GridMapEditor::update_areas() {
-
- area_list->clear();
-
- List<int> areas;
- node->get_area_list(&areas);
-
- TreeItem *root = area_list->create_item(NULL);
- area_list->set_hide_root(true);
- TreeItem *selected = NULL;
-
- for (List<int>::Element *E = areas.front(); E; E = E->next()) {
-
- int area = E->get();
- TreeItem *ti = area_list->create_item(root);
- String name = node->area_get_name(area);
-
- ti->set_metadata(0, area);
- ti->set_text(0, name);
- ti->set_editable(0, true);
- if (area == selected_area)
- selected = ti;
- }
-
- if (selected)
- selected->select(0);
-}
-
void GridMapEditor::edit(GridMap *p_gridmap) {
node = p_gridmap;
@@ -806,7 +710,7 @@ void GridMapEditor::edit(GridMap *p_gridmap) {
_update_selection_transform();
_update_duplicate_indicator();
- spatial_editor = editor->get_editor_plugin_screen()->cast_to<SpatialEditorPlugin>();
+ spatial_editor = Object::cast_to<SpatialEditorPlugin>(editor->get_editor_plugin_screen());
if (!node) {
set_process(false);
@@ -816,13 +720,10 @@ void GridMapEditor::edit(GridMap *p_gridmap) {
VisualServer::get_singleton()->instance_set_visible(cursor_instance, false);
- _clear_areas();
-
return;
}
update_pallete();
- update_areas();
set_process(true);
@@ -840,6 +741,7 @@ void GridMapEditor::edit(GridMap *p_gridmap) {
//update grids
indicator_mat.instance();
indicator_mat->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
+ indicator_mat->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true);
indicator_mat->set_flag(SpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true);
indicator_mat->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
indicator_mat->set_albedo(Color(0.8, 0.5, 0.1));
@@ -847,7 +749,7 @@ void GridMapEditor::edit(GridMap *p_gridmap) {
Vector<Vector3> grid_points[3];
Vector<Color> grid_colors[3];
- float cell_size[3] = { p_gridmap->get_cell_size(), p_gridmap->get_cell_size(), p_gridmap->get_cell_size() };
+ float cell_size[3] = { p_gridmap->get_cell_size().x, p_gridmap->get_cell_size().y, p_gridmap->get_cell_size().z };
for (int i = 0; i < 3; i++) {
@@ -894,7 +796,6 @@ void GridMapEditor::edit(GridMap *p_gridmap) {
update_grid();
_update_clip();
- _update_areas_display();
}
void GridMapEditor::_update_clip() {
@@ -912,7 +813,7 @@ void GridMapEditor::update_grid() {
//VS *vs = VS::get_singleton();
- grid_ofs[edit_axis] = edit_floor[edit_axis] * node->get_cell_size();
+ grid_ofs[edit_axis] = edit_floor[edit_axis] * node->get_cell_size()[edit_axis];
edit_grid_xform.origin = grid_ofs;
edit_grid_xform.basis = Basis();
@@ -931,13 +832,11 @@ void GridMapEditor::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE) {
theme_pallete->connect("item_selected", this, "_item_selected_cbk");
- edit_mode->connect("item_selected", this, "_edit_mode_changed");
- area_list->connect("item_edited", this, "_area_renamed");
- area_list->connect("item_selected", this, "_area_selected");
for (int i = 0; i < 3; i++) {
grid[i] = VS::get_singleton()->mesh_create();
grid_instance[i] = VS::get_singleton()->instance_create2(grid[i], get_tree()->get_root()->get_world()->get_scenario());
+ selection_level_instance[i] = VisualServer::get_singleton()->instance_create2(selection_level_mesh[i], get_tree()->get_root()->get_world()->get_scenario());
}
selection_instance = VisualServer::get_singleton()->instance_create2(selection_mesh, get_tree()->get_root()->get_world()->get_scenario());
@@ -954,6 +853,7 @@ void GridMapEditor::_notification(int p_what) {
VS::get_singleton()->free(grid[i]);
grid_instance[i] = RID();
grid[i] = RID();
+ VisualServer::get_singleton()->free(selection_level_instance[i]);
}
VisualServer::get_singleton()->free(selection_instance);
@@ -962,6 +862,9 @@ void GridMapEditor::_notification(int p_what) {
duplicate_instance = RID();
} else if (p_what == NOTIFICATION_PROCESS) {
+ if (!node) {
+ return;
+ }
Transform xf = node->get_global_transform();
@@ -978,14 +881,14 @@ void GridMapEditor::_notification(int p_what) {
if (lock_view) {
- EditorNode *editor = get_tree()->get_root()->get_child(0)->cast_to<EditorNode>();
+ EditorNode *editor = Object::cast_to<EditorNode>(get_tree()->get_root()->get_child(0));
Plane p;
p.normal[edit_axis] = 1.0;
- p.d = edit_floor[edit_axis] * node->get_cell_size();
+ p.d = edit_floor[edit_axis] * node->get_cell_size()[edit_axis];
p = node->get_transform().xform(p); // plane to snap
- SpatialEditorPlugin *sep = editor->get_editor_plugin_screen()->cast_to<SpatialEditorPlugin>();
+ SpatialEditorPlugin *sep = Object::cast_to<SpatialEditorPlugin>(editor->get_editor_plugin_screen());
if (sep)
sep->snap_cursor_to_plane(p);
//editor->get_editor_plugin_screen()->call("snap_cursor_to_plane",p);
@@ -1021,85 +924,6 @@ void GridMapEditor::_item_selected_cbk(int idx) {
_update_cursor_instance();
}
-void GridMapEditor::_clear_areas() {
-
- for (int i = 0; i < areas.size(); i++) {
-
- VisualServer::get_singleton()->free(areas[i].instance);
- VisualServer::get_singleton()->free(areas[i].mesh);
- }
-
- areas.clear();
-}
-
-void GridMapEditor::_update_areas_display() {
- if (!node) {
- return;
- }
-#if 0
- _clear_areas();
- List<int> areas;
- node->get_area_list(&areas);
-
- Transform global_xf = node->get_global_transform();
-
- for(List<int>::Element *E=areas.front();E;E=E->next()) {
-
- int area = E->get();
- Color color;
- if (node->area_is_exterior_portal(area))
- color=Color(1,1,1,0.2);
- else
- color.set_hsv(Math::fmod(area*0.37,1),Math::fmod(area*0.75,1),1.0,0.2);
-
-
- RID material = VisualServer::get_singleton()->fixed_material_create();
- VisualServer::get_singleton()->fixed_material_set_param( material, VS::FIXED_MATERIAL_PARAM_DIFFUSE,color );
- VisualServer::get_singleton()->fixed_material_set_param( material, VS::FIXED_MATERIAL_PARAM_EMISSION,0.5 );
- VisualServer::get_singleton()->fixed_material_set_flag( material, VisualServer::FIXED_MATERIAL_FLAG_USE_ALPHA, true );
-
-
- RID mesh = VisualServer::get_singleton()->mesh_create();
-
- PoolVector<Plane> planes;
- for(int i=0;i<3;i++) {
-
- Vector3 axis;
- axis[i]=1.0;
- planes.push_back(Plane(axis,1));
- planes.push_back(Plane(-axis,0));
- }
-
- VisualServer::get_singleton()->mesh_add_surface_from_planes(mesh,planes);
- VisualServer::get_singleton()->mesh_surface_set_material(mesh,0,material,true);
-
- AreaDisplay ad;
- ad.mesh=mesh;
- ad.instance = VisualServer::get_singleton()->instance_create2(mesh,node->get_world()->get_scenario());
- Transform xform;
- Rect3 aabb = node->area_get_bounds(area);
- xform.origin=aabb.pos * node->get_cell_size();
- xform.basis.scale(aabb.size * node->get_cell_size());
- VisualServer::get_singleton()->instance_set_transform(ad.instance,global_xf * xform);
- this->areas.push_back(ad);
-
- }
-#endif
-}
-
-void GridMapEditor::_edit_mode_changed(int p_what) {
-
- if (p_what == 0) {
-
- theme_pallete->show();
- area_list->hide();
- } else {
-
- theme_pallete->hide();
- area_list->show();
- }
-}
-
void GridMapEditor::_floor_changed(float p_value) {
if (updating)
@@ -1109,6 +933,7 @@ void GridMapEditor::_floor_changed(float p_value) {
node->set_meta("_editor_floor_", Vector3(edit_floor[0], edit_floor[1], edit_floor[2]));
update_grid();
_update_clip();
+ _update_selection_transform();
}
void GridMapEditor::_bind_methods() {
@@ -1116,9 +941,6 @@ void GridMapEditor::_bind_methods() {
ClassDB::bind_method("_menu_option", &GridMapEditor::_menu_option);
ClassDB::bind_method("_configure", &GridMapEditor::_configure);
ClassDB::bind_method("_item_selected_cbk", &GridMapEditor::_item_selected_cbk);
- ClassDB::bind_method("_edit_mode_changed", &GridMapEditor::_edit_mode_changed);
- ClassDB::bind_method("_area_renamed", &GridMapEditor::_area_renamed);
- ClassDB::bind_method("_area_selected", &GridMapEditor::_area_selected);
ClassDB::bind_method("_floor_changed", &GridMapEditor::_floor_changed);
ClassDB::bind_method(D_METHOD("_set_display_mode", "mode"), &GridMapEditor::_set_display_mode);
@@ -1142,45 +964,43 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) {
spatial_editor_hb->hide();
options->set_text("Grid");
- options->get_popup()->add_check_item("Snap View", MENU_OPTION_LOCK_VIEW);
+ options->get_popup()->add_check_item(TTR("Snap View"), MENU_OPTION_LOCK_VIEW);
options->get_popup()->add_separator();
- options->get_popup()->add_item("Prev Level (" + keycode_get_string(KEY_MASK_CMD) + "Down Wheel)", MENU_OPTION_PREV_LEVEL);
- options->get_popup()->add_item("Next Level (" + keycode_get_string(KEY_MASK_CMD) + "Up Wheel)", MENU_OPTION_NEXT_LEVEL);
+ options->get_popup()->add_item(vformat(TTR("Prev Level (%sDown Wheel)"), keycode_get_string(KEY_MASK_CMD)), MENU_OPTION_PREV_LEVEL);
+ options->get_popup()->add_item(vformat(TTR("Next Level (%sUp Wheel)"), keycode_get_string(KEY_MASK_CMD)), MENU_OPTION_NEXT_LEVEL);
options->get_popup()->add_separator();
- options->get_popup()->add_check_item("Clip Disabled", MENU_OPTION_CLIP_DISABLED);
+ options->get_popup()->add_check_item(TTR("Clip Disabled"), MENU_OPTION_CLIP_DISABLED);
options->get_popup()->set_item_checked(options->get_popup()->get_item_index(MENU_OPTION_CLIP_DISABLED), true);
- options->get_popup()->add_check_item("Clip Above", MENU_OPTION_CLIP_ABOVE);
- options->get_popup()->add_check_item("Clip Below", MENU_OPTION_CLIP_BELOW);
+ options->get_popup()->add_check_item(TTR("Clip Above"), MENU_OPTION_CLIP_ABOVE);
+ options->get_popup()->add_check_item(TTR("Clip Below"), MENU_OPTION_CLIP_BELOW);
options->get_popup()->add_separator();
- options->get_popup()->add_check_item("Edit X Axis", MENU_OPTION_X_AXIS, KEY_Z);
- options->get_popup()->add_check_item("Edit Y Axis", MENU_OPTION_Y_AXIS, KEY_X);
- options->get_popup()->add_check_item("Edit Z Axis", MENU_OPTION_Z_AXIS, KEY_C);
+ options->get_popup()->add_check_item(TTR("Edit X Axis"), MENU_OPTION_X_AXIS, KEY_Z);
+ options->get_popup()->add_check_item(TTR("Edit Y Axis"), MENU_OPTION_Y_AXIS, KEY_X);
+ options->get_popup()->add_check_item(TTR("Edit Z Axis"), MENU_OPTION_Z_AXIS, KEY_C);
options->get_popup()->set_item_checked(options->get_popup()->get_item_index(MENU_OPTION_Y_AXIS), true);
options->get_popup()->add_separator();
- options->get_popup()->add_item("Cursor Rotate X", MENU_OPTION_CURSOR_ROTATE_X, KEY_A);
- options->get_popup()->add_item("Cursor Rotate Y", MENU_OPTION_CURSOR_ROTATE_Y, KEY_S);
- options->get_popup()->add_item("Cursor Rotate Z", MENU_OPTION_CURSOR_ROTATE_Z, KEY_D);
- options->get_popup()->add_item("Cursor Back Rotate X", MENU_OPTION_CURSOR_BACK_ROTATE_X, KEY_MASK_SHIFT + KEY_A);
- options->get_popup()->add_item("Cursor Back Rotate Y", MENU_OPTION_CURSOR_BACK_ROTATE_Y, KEY_MASK_SHIFT + KEY_S);
- options->get_popup()->add_item("Cursor Back Rotate Z", MENU_OPTION_CURSOR_BACK_ROTATE_Z, KEY_MASK_SHIFT + KEY_D);
- options->get_popup()->add_item("Cursor Clear Rotation", MENU_OPTION_CURSOR_CLEAR_ROTATION, KEY_W);
+ options->get_popup()->add_item(TTR("Cursor Rotate X"), MENU_OPTION_CURSOR_ROTATE_X, KEY_A);
+ options->get_popup()->add_item(TTR("Cursor Rotate Y"), MENU_OPTION_CURSOR_ROTATE_Y, KEY_S);
+ options->get_popup()->add_item(TTR("Cursor Rotate Z"), MENU_OPTION_CURSOR_ROTATE_Z, KEY_D);
+ options->get_popup()->add_item(TTR("Cursor Back Rotate X"), MENU_OPTION_CURSOR_BACK_ROTATE_X, KEY_MASK_SHIFT + KEY_A);
+ options->get_popup()->add_item(TTR("Cursor Back Rotate Y"), MENU_OPTION_CURSOR_BACK_ROTATE_Y, KEY_MASK_SHIFT + KEY_S);
+ options->get_popup()->add_item(TTR("Cursor Back Rotate Z"), MENU_OPTION_CURSOR_BACK_ROTATE_Z, KEY_MASK_SHIFT + KEY_D);
+ options->get_popup()->add_item(TTR("Cursor Clear Rotation"), MENU_OPTION_CURSOR_CLEAR_ROTATION, KEY_W);
options->get_popup()->add_separator();
options->get_popup()->add_check_item("Duplicate Selects", MENU_OPTION_DUPLICATE_SELECTS);
options->get_popup()->add_separator();
- options->get_popup()->add_item("Create Area", MENU_OPTION_SELECTION_MAKE_AREA, KEY_CONTROL + KEY_C);
- options->get_popup()->add_item("Create Exterior Connector", MENU_OPTION_SELECTION_MAKE_EXTERIOR_CONNECTOR);
- options->get_popup()->add_item("Erase Area", MENU_OPTION_REMOVE_AREA);
+ options->get_popup()->add_item(TTR("Create Area"), MENU_OPTION_SELECTION_MAKE_AREA, KEY_CONTROL + KEY_C);
+ options->get_popup()->add_item(TTR("Create Exterior Connector"), MENU_OPTION_SELECTION_MAKE_EXTERIOR_CONNECTOR);
+ options->get_popup()->add_item(TTR("Erase Area"), MENU_OPTION_REMOVE_AREA);
options->get_popup()->add_separator();
- options->get_popup()->add_item("Selection -> Duplicate", MENU_OPTION_SELECTION_DUPLICATE, KEY_MASK_SHIFT + KEY_INSERT);
- options->get_popup()->add_item("Selection -> Clear", MENU_OPTION_SELECTION_CLEAR, KEY_MASK_SHIFT + KEY_DELETE);
- //options->get_popup()->add_separator();
- //options->get_popup()->add_item("Configure",MENU_OPTION_CONFIGURE);
+ options->get_popup()->add_item(TTR("Selection -> Duplicate"), MENU_OPTION_SELECTION_DUPLICATE, KEY_MASK_SHIFT + KEY_INSERT);
+ options->get_popup()->add_item(TTR("Selection -> Clear"), MENU_OPTION_SELECTION_CLEAR, KEY_MASK_SHIFT + KEY_DELETE);
options->get_popup()->add_separator();
- options->get_popup()->add_item("Settings", MENU_OPTION_GRIDMAP_SETTINGS);
+ options->get_popup()->add_item(TTR("Settings"), MENU_OPTION_GRIDMAP_SETTINGS);
settings_dialog = memnew(ConfirmationDialog);
- settings_dialog->set_title("GridMap Settings");
+ settings_dialog->set_title(TTR("GridMap Settings"));
add_child(settings_dialog);
settings_vbc = memnew(VBoxContainer);
settings_vbc->set_custom_minimum_size(Size2(200, 0));
@@ -1191,7 +1011,7 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) {
settings_pick_distance->set_min(500.0f);
settings_pick_distance->set_step(1.0f);
settings_pick_distance->set_value(EDITOR_DEF("editors/grid_map/pick_distance", 5000.0));
- settings_vbc->add_margin_child("Pick Distance:", settings_pick_distance);
+ settings_vbc->add_margin_child(TTR("Pick Distance:"), settings_pick_distance);
clip_mode = CLIP_DISABLED;
options->get_popup()->connect("id_pressed", this, "_menu_option");
@@ -1200,15 +1020,6 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) {
add_child(hb);
hb->set_h_size_flags(SIZE_EXPAND_FILL);
- edit_mode = memnew(OptionButton);
- edit_mode->set_area_as_parent_rect();
- edit_mode->set_anchor_and_margin(MARGIN_BOTTOM, ANCHOR_BEGIN, 24);
- edit_mode->set_anchor_and_margin(MARGIN_RIGHT, ANCHOR_END, -14);
- edit_mode->add_item("Tiles");
- edit_mode->add_item("Areas");
- hb->add_child(edit_mode);
- edit_mode->set_h_size_flags(SIZE_EXPAND_FILL);
-
mode_thumbnail = memnew(ToolButton);
mode_thumbnail->set_toggle_mode(true);
mode_thumbnail->set_pressed(true);
@@ -1226,17 +1037,11 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) {
EDITOR_DEF("editors/grid_map/preview_size", 64);
display_mode = DISPLAY_THUMBNAIL;
- selected_area = -1;
theme_pallete = memnew(ItemList);
add_child(theme_pallete);
theme_pallete->set_v_size_flags(SIZE_EXPAND_FILL);
- area_list = memnew(Tree);
- add_child(area_list);
- area_list->set_v_size_flags(SIZE_EXPAND_FILL);
- area_list->hide();
-
spatial_editor_hb->add_child(memnew(VSeparator));
Label *fl = memnew(Label);
fl->set_text(" Floor: ");
@@ -1270,6 +1075,7 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) {
PoolVector<Vector3> lines;
PoolVector<Vector3> triangles;
+ PoolVector<Vector3> square[3];
for (int i = 0; i < 6; i++) {
@@ -1309,12 +1115,41 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) {
lines.push_back(b);
}
+ for (int i = 0; i < 3; i++) {
+ Vector3 points[4];
+ for (int j = 0; j < 4; j++) {
+
+ static const bool orderx[4] = { 0, 1, 1, 0 };
+ static const bool ordery[4] = { 0, 0, 1, 1 };
+
+ Vector3 sp;
+ if (orderx[j]) {
+ sp[(i + 1) % 3] = 1.0;
+ }
+ if (ordery[j]) {
+ sp[(i + 2) % 3] = 1.0;
+ }
+
+ points[j] = sp;
+ }
+
+ for (int j = 0; j < 4; j++) {
+
+ Vector3 ofs;
+ ofs[i] += 0.01;
+ square[i].push_back(points[j] - ofs);
+ square[i].push_back(points[(j + 1) % 4] - ofs);
+ square[i].push_back(points[j] + ofs);
+ square[i].push_back(points[(j + 1) % 4] + ofs);
+ }
+ }
+
Array d;
d.resize(VS::ARRAY_MAX);
inner_mat.instance();
- inner_mat->set_albedo(Color(0.7, 0.7, 1.0, 0.3));
- inner_mat->set_flag(SpatialMaterial::FLAG_ONTOP, true);
+ inner_mat->set_albedo(Color(0.7, 0.7, 1.0, 0.2));
+ //inner_mat->set_flag(SpatialMaterial::FLAG_ONTOP, true);
inner_mat->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
inner_mat->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true);
@@ -1323,12 +1158,19 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) {
VisualServer::get_singleton()->mesh_surface_set_material(selection_mesh, 0, inner_mat->get_rid());
outer_mat.instance();
- outer_mat->set_albedo(Color(0.7, 0.7, 1.0, 0.3));
+ outer_mat->set_albedo(Color(0.7, 0.7, 1.0, 0.8));
outer_mat->set_flag(SpatialMaterial::FLAG_ONTOP, true);
outer_mat->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
outer_mat->set_line_width(3.0);
outer_mat->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true);
+ selection_floor_mat.instance();
+ selection_floor_mat->set_albedo(Color(0.80, 0.80, 1.0, 1));
+ selection_floor_mat->set_flag(SpatialMaterial::FLAG_ONTOP, true);
+ selection_floor_mat->set_flag(SpatialMaterial::FLAG_UNSHADED, true);
+ selection_floor_mat->set_line_width(3.0);
+ //selection_floor_mat->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true);
+
d[VS::ARRAY_VERTEX] = lines;
VisualServer::get_singleton()->mesh_add_surface_from_arrays(selection_mesh, VS::PRIMITIVE_LINES, d);
VisualServer::get_singleton()->mesh_surface_set_material(selection_mesh, 1, outer_mat->get_rid());
@@ -1340,6 +1182,13 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) {
d[VS::ARRAY_VERTEX] = lines;
VisualServer::get_singleton()->mesh_add_surface_from_arrays(duplicate_mesh, VS::PRIMITIVE_LINES, d);
VisualServer::get_singleton()->mesh_surface_set_material(duplicate_mesh, 1, outer_mat->get_rid());
+
+ for (int i = 0; i < 3; i++) {
+ d[VS::ARRAY_VERTEX] = square[i];
+ selection_level_mesh[i] = VS::get_singleton()->mesh_create();
+ VisualServer::get_singleton()->mesh_add_surface_from_arrays(selection_level_mesh[i], VS::PRIMITIVE_LINES, d);
+ VisualServer::get_singleton()->mesh_surface_set_material(selection_level_mesh[i], 0, selection_floor_mat->get_rid());
+ }
}
selection.active = false;
@@ -1356,6 +1205,9 @@ GridMapEditor::~GridMapEditor() {
VisualServer::get_singleton()->free(grid_instance[i]);
if (cursor_instance.is_valid())
VisualServer::get_singleton()->free(cursor_instance);
+ if (selection_level_instance[i].is_valid()) {
+ VisualServer::get_singleton()->free(selection_level_instance[i]);
+ }
}
VisualServer::get_singleton()->free(selection_mesh);
@@ -1365,13 +1217,11 @@ GridMapEditor::~GridMapEditor() {
VisualServer::get_singleton()->free(duplicate_mesh);
if (duplicate_instance.is_valid())
VisualServer::get_singleton()->free(duplicate_instance);
-
- _clear_areas();
}
void GridMapEditorPlugin::edit(Object *p_object) {
- gridmap_editor->edit(p_object ? p_object->cast_to<GridMap>() : NULL);
+ gridmap_editor->edit(Object::cast_to<GridMap>(p_object));
}
bool GridMapEditorPlugin::handles(Object *p_object) const {
diff --git a/modules/gridmap/grid_map_editor_plugin.h b/modules/gridmap/grid_map_editor_plugin.h
index a1b2c96ccd..ecbfbf2d65 100644
--- a/modules/gridmap/grid_map_editor_plugin.h
+++ b/modules/gridmap/grid_map_editor_plugin.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -75,7 +75,6 @@ class GridMapEditor : public VBoxContainer {
Panel *panel;
MenuButton *options;
SpinBox *floor;
- OptionButton *edit_mode;
ToolButton *mode_thumbnail;
ToolButton *mode_list;
HBoxContainer *spatial_editor_hb;
@@ -110,12 +109,15 @@ class GridMapEditor : public VBoxContainer {
RID cursor_instance;
RID selection_mesh;
RID selection_instance;
+ RID selection_level_mesh[3];
+ RID selection_level_instance[3];
RID duplicate_mesh;
RID duplicate_instance;
Ref<SpatialMaterial> indicator_mat;
Ref<SpatialMaterial> inner_mat;
Ref<SpatialMaterial> outer_mat;
+ Ref<SpatialMaterial> selection_floor_mat;
bool updating;
@@ -137,7 +139,6 @@ class GridMapEditor : public VBoxContainer {
int display_mode;
int selected_pallete;
- int selected_area;
int cursor_rot;
enum Menu {
@@ -177,18 +178,12 @@ class GridMapEditor : public VBoxContainer {
RID instance;
};
- Vector<AreaDisplay> areas;
-
- void _update_areas_display();
- void _clear_areas();
-
void update_grid();
void _configure();
void _menu_option(int);
void update_pallete();
void _set_display_mode(int p_mode);
ItemList *theme_pallete;
- Tree *area_list;
void _item_selected_cbk(int idx);
void _update_cursor_transform();
void _update_cursor_instance();
@@ -199,14 +194,9 @@ class GridMapEditor : public VBoxContainer {
void _update_selection_transform();
void _validate_selection();
- void _edit_mode_changed(int p_what);
- void _area_renamed();
- void _area_selected();
-
void _floor_changed(float p_value);
void _delete_selection();
- void update_areas();
EditorNode *editor;
bool do_input_action(Camera *p_camera, const Point2 &p_point, bool p_click);
@@ -236,7 +226,7 @@ class GridMapEditorPlugin : public EditorPlugin {
EditorNode *editor;
public:
- virtual bool forward_spatial_input_event(Camera *p_camera, const Ref<InputEvent> &p_event) { return gridmap_editor->forward_spatial_input_event(p_camera, p_event); }
+ virtual bool forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event) { return gridmap_editor->forward_spatial_input_event(p_camera, p_event); }
virtual String get_name() const { return "GridMap"; }
bool has_main_screen() const { return false; }
virtual void edit(Object *p_object);
diff --git a/modules/gridmap/register_types.cpp b/modules/gridmap/register_types.cpp
index e4def9378f..e2f6b57c04 100644
--- a/modules/gridmap/register_types.cpp
+++ b/modules/gridmap/register_types.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/gridmap/register_types.h b/modules/gridmap/register_types.h
index 1978353fc3..c50f89155f 100644
--- a/modules/gridmap/register_types.h
+++ b/modules/gridmap/register_types.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/hdr/image_loader_hdr.cpp b/modules/hdr/image_loader_hdr.cpp
index 19df27b962..d883b0f280 100644
--- a/modules/hdr/image_loader_hdr.cpp
+++ b/modules/hdr/image_loader_hdr.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -34,7 +34,7 @@
#include "thirdparty/tinyexr/tinyexr.h"
-Error ImageLoaderHDR::load_image(Ref<Image> p_image, FileAccess *f, bool p_force_linear) {
+Error ImageLoaderHDR::load_image(Ref<Image> p_image, FileAccess *f, bool p_force_linear, float p_scale) {
String header = f->get_token();
diff --git a/modules/hdr/image_loader_hdr.h b/modules/hdr/image_loader_hdr.h
index 127833ebd0..e6703dc142 100644
--- a/modules/hdr/image_loader_hdr.h
+++ b/modules/hdr/image_loader_hdr.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -38,7 +38,7 @@
class ImageLoaderHDR : public ImageFormatLoader {
public:
- virtual Error load_image(Ref<Image> p_image, FileAccess *f, bool p_force_linear);
+ virtual Error load_image(Ref<Image> p_image, FileAccess *f, bool p_force_linear, float p_scale);
virtual void get_recognized_extensions(List<String> *p_extensions) const;
ImageLoaderHDR();
};
diff --git a/modules/hdr/register_types.cpp b/modules/hdr/register_types.cpp
index e4f7c14aa7..808b168432 100644
--- a/modules/hdr/register_types.cpp
+++ b/modules/hdr/register_types.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/hdr/register_types.h b/modules/hdr/register_types.h
index 3d901ea003..e453192d9c 100644
--- a/modules/hdr/register_types.h
+++ b/modules/hdr/register_types.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/jpg/image_loader_jpegd.cpp b/modules/jpg/image_loader_jpegd.cpp
index 8c73b69f1b..57ec074bbb 100644
--- a/modules/jpg/image_loader_jpegd.cpp
+++ b/modules/jpg/image_loader_jpegd.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -89,7 +89,7 @@ Error jpeg_load_image_from_buffer(Image *p_image, const uint8_t *p_buffer, int p
return OK;
}
-Error ImageLoaderJPG::load_image(Ref<Image> p_image, FileAccess *f, bool p_force_linear) {
+Error ImageLoaderJPG::load_image(Ref<Image> p_image, FileAccess *f, bool p_force_linear, float p_scale) {
PoolVector<uint8_t> src_image;
int src_image_len = f->get_len();
diff --git a/modules/jpg/image_loader_jpegd.h b/modules/jpg/image_loader_jpegd.h
index aa073b493d..6a2f042412 100644
--- a/modules/jpg/image_loader_jpegd.h
+++ b/modules/jpg/image_loader_jpegd.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -38,7 +38,7 @@
class ImageLoaderJPG : public ImageFormatLoader {
public:
- virtual Error load_image(Ref<Image> p_image, FileAccess *f, bool p_force_linear);
+ virtual Error load_image(Ref<Image> p_image, FileAccess *f, bool p_force_linear, float p_scale);
virtual void get_recognized_extensions(List<String> *p_extensions) const;
ImageLoaderJPG();
};
diff --git a/modules/jpg/register_types.cpp b/modules/jpg/register_types.cpp
index 2379bee0df..85dee90eb0 100644
--- a/modules/jpg/register_types.cpp
+++ b/modules/jpg/register_types.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/jpg/register_types.h b/modules/jpg/register_types.h
index c14f860742..3d912a4398 100644
--- a/modules/jpg/register_types.h
+++ b/modules/jpg/register_types.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/nativescript/api_generator.cpp b/modules/nativescript/api_generator.cpp
index 47162bfc49..fdd5a2ea19 100644
--- a/modules/nativescript/api_generator.cpp
+++ b/modules/nativescript/api_generator.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -33,6 +33,7 @@
#include "class_db.h"
#include "core/global_constants.h"
+#include "core/pair.h"
#include "core/project_settings.h"
#include "os/file_access.h"
@@ -93,6 +94,11 @@ struct SignalAPI {
Map<int, Variant> default_arguments;
};
+struct EnumAPI {
+ String name;
+ List<Pair<int, String> > values;
+};
+
struct ClassAPI {
String class_name;
String super_class_name;
@@ -109,8 +115,28 @@ struct ClassAPI {
List<PropertyAPI> properties;
List<ConstantAPI> constants;
List<SignalAPI> signals_;
+ List<EnumAPI> enums;
};
+static String get_type_name(const PropertyInfo &info) {
+ if (info.type == Variant::INT && (info.usage & PROPERTY_USAGE_CLASS_IS_ENUM)) {
+ return String("enum.") + String(info.class_name).replace(".", "::");
+ }
+ if (info.class_name != StringName()) {
+ return info.class_name;
+ }
+ if (info.hint == PROPERTY_HINT_RESOURCE_TYPE) {
+ return info.hint_string;
+ }
+ if (info.type == Variant::NIL && (info.usage & PROPERTY_USAGE_NIL_IS_VARIANT)) {
+ return "Variant";
+ }
+ if (info.type == Variant::NIL) {
+ return "void";
+ }
+ return Variant::get_type_name(info.type);
+}
+
/*
* Reads the entire Godot API to a list
*/
@@ -155,10 +181,9 @@ List<ClassAPI> generate_c_api_classes() {
class_api.is_instanciable = !class_api.is_singleton && ClassDB::can_instance(class_name);
{
- bool is_reference = false;
List<StringName> inheriters;
ClassDB::get_inheriters_from_class("Reference", &inheriters);
- is_reference = !!inheriters.find(class_name);
+ bool is_reference = !!inheriters.find(class_name);
// @Unclear
class_api.is_reference = !class_api.is_singleton && is_reference;
}
@@ -195,12 +220,8 @@ List<ClassAPI> generate_c_api_classes() {
if (argument.name.find(":") != -1) {
type = argument.name.get_slice(":", 1);
name = argument.name.get_slice(":", 0);
- } else if (argument.hint == PROPERTY_HINT_RESOURCE_TYPE) {
- type = argument.hint_string;
- } else if (argument.type == Variant::NIL) {
- type = "Variant";
} else {
- type = Variant::get_type_name(argument.type);
+ type = get_type_name(argument);
}
signal.argument_names.push_back(name);
@@ -234,12 +255,8 @@ List<ClassAPI> generate_c_api_classes() {
if (p->get().name.find(":") != -1) {
property_api.type = p->get().name.get_slice(":", 1);
property_api.name = p->get().name.get_slice(":", 0);
- } else if (p->get().hint == PROPERTY_HINT_RESOURCE_TYPE) {
- property_api.type = p->get().hint_string;
- } else if (p->get().type == Variant::NIL) {
- property_api.type = "Variant";
} else {
- property_api.type = Variant::get_type_name(p->get().type);
+ property_api.type = get_type_name(p->get());
}
if (!property_api.setter.empty() || !property_api.getter.empty()) {
@@ -261,17 +278,11 @@ List<ClassAPI> generate_c_api_classes() {
//method name
method_api.method_name = m->get().name;
//method return type
- if (method_bind && method_bind->get_return_type() != StringName()) {
- method_api.return_type = method_bind->get_return_type();
- } else if (method_api.method_name.find(":") != -1) {
+ if (method_api.method_name.find(":") != -1) {
method_api.return_type = method_api.method_name.get_slice(":", 1);
method_api.method_name = method_api.method_name.get_slice(":", 0);
- } else if (m->get().return_val.type != Variant::NIL) {
- method_api.return_type = m->get().return_val.hint == PROPERTY_HINT_RESOURCE_TYPE ? m->get().return_val.hint_string : Variant::get_type_name(m->get().return_val.type);
- } else if (m->get().return_val.name != "") {
- method_api.return_type = m->get().return_val.name;
} else {
- method_api.return_type = "void";
+ method_api.return_type = get_type_name(m->get().return_val);
}
method_api.argument_count = method_info.arguments.size();
@@ -322,6 +333,25 @@ List<ClassAPI> generate_c_api_classes() {
}
}
+ // enums
+ {
+ List<EnumAPI> enums;
+ List<StringName> enum_names;
+ ClassDB::get_enum_list(class_name, &enum_names, true);
+ for (List<StringName>::Element *E = enum_names.front(); E; E = E->next()) {
+ List<StringName> value_names;
+ EnumAPI enum_api;
+ enum_api.name = E->get();
+ ClassDB::get_enum_constants(class_name, E->get(), &value_names, true);
+ for (List<StringName>::Element *val_e = value_names.front(); val_e; val_e = val_e->next()) {
+ int int_val = ClassDB::get_integer_constant(class_name, val_e->get(), NULL);
+ enum_api.values.push_back(Pair<int, String>(int_val, val_e->get()));
+ }
+ enum_api.values.sort_custom<PairSort<int, String> >();
+ class_api.enums.push_back(enum_api);
+ }
+ }
+
api.push_back(class_api);
}
@@ -411,11 +441,24 @@ static List<String> generate_c_api_json(const List<ClassAPI> &p_api) {
source.push_back("\t\t\t\t]\n");
source.push_back(String("\t\t\t}") + (e->next() ? "," : "") + "\n");
}
+ source.push_back("\t\t],\n");
+
+ source.push_back("\t\t\"enums\": [\n");
+ for (List<EnumAPI>::Element *e = api.enums.front(); e; e = e->next()) {
+ source.push_back("\t\t\t{\n");
+ source.push_back("\t\t\t\t\"name\": \"" + e->get().name + "\",\n");
+ source.push_back("\t\t\t\t\"values\": {\n");
+ for (List<Pair<int, String> >::Element *val_e = e->get().values.front(); val_e; val_e = val_e->next()) {
+ source.push_back("\t\t\t\t\t\"" + val_e->get().second + "\": " + itos(val_e->get().first));
+ source.push_back(String((val_e->next() ? "," : "")) + "\n");
+ }
+ source.push_back("\t\t\t\t}\n");
+ source.push_back(String("\t\t\t}") + (e->next() ? "," : "") + "\n");
+ }
source.push_back("\t\t]\n");
source.push_back(String("\t}") + (c->next() ? "," : "") + "\n");
}
-
source.push_back("]");
return source;
diff --git a/modules/nativescript/api_generator.h b/modules/nativescript/api_generator.h
index a108d7a7b6..56c2d786e6 100644
--- a/modules/nativescript/api_generator.h
+++ b/modules/nativescript/api_generator.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/nativescript/godot_nativescript.cpp b/modules/nativescript/godot_nativescript.cpp
index 453cee3a18..926b3261b2 100644
--- a/modules/nativescript/godot_nativescript.cpp
+++ b/modules/nativescript/godot_nativescript.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/nativescript/godot_nativescript.h b/modules/nativescript/godot_nativescript.h
index cfd445086b..1eaf459570 100644
--- a/modules/nativescript/godot_nativescript.h
+++ b/modules/nativescript/godot_nativescript.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/nativescript/nativescript.cpp b/modules/nativescript/nativescript.cpp
index d428834d59..3799ce31f8 100644
--- a/modules/nativescript/nativescript.cpp
+++ b/modules/nativescript/nativescript.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -399,7 +399,7 @@ Variant NativeScript::_new(const Variant **p_args, int p_argcount, Variant::Call
owner = memnew(Reference);
}
- Reference *r = owner->cast_to<Reference>();
+ Reference *r = Object::cast_to<Reference>(owner);
if (r) {
ref = REF(r);
}
@@ -1203,11 +1203,11 @@ Error ResourceFormatSaverNativeScript::save(const String &p_path, const RES &p_r
}
bool ResourceFormatSaverNativeScript::recognize(const RES &p_resource) const {
- return p_resource->cast_to<NativeScript>() != NULL;
+ return Object::cast_to<NativeScript>(*p_resource) != NULL;
}
void ResourceFormatSaverNativeScript::get_recognized_extensions(const RES &p_resource, List<String> *p_extensions) const {
- if (p_resource->cast_to<NativeScript>()) {
+ if (Object::cast_to<NativeScript>(*p_resource)) {
p_extensions->push_back("gdns");
}
}
diff --git a/modules/nativescript/nativescript.h b/modules/nativescript/nativescript.h
index b62fefec40..571a3c9cc7 100644
--- a/modules/nativescript/nativescript.h
+++ b/modules/nativescript/nativescript.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/nativescript/register_types.cpp b/modules/nativescript/register_types.cpp
index c28b982884..b846710ab8 100644
--- a/modules/nativescript/register_types.cpp
+++ b/modules/nativescript/register_types.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/nativescript/register_types.h b/modules/nativescript/register_types.h
index 319da9c42f..7ac558f68f 100644
--- a/modules/nativescript/register_types.h
+++ b/modules/nativescript/register_types.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/ogg/register_types.cpp b/modules/ogg/register_types.cpp
index 9837ae12d9..452e6e332a 100644
--- a/modules/ogg/register_types.cpp
+++ b/modules/ogg/register_types.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/ogg/register_types.h b/modules/ogg/register_types.h
index dc84227b80..a2a8b7cedc 100644
--- a/modules/ogg/register_types.h
+++ b/modules/ogg/register_types.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/openssl/register_types.cpp b/modules/openssl/register_types.cpp
index e1ae581caf..16563aabf7 100644
--- a/modules/openssl/register_types.cpp
+++ b/modules/openssl/register_types.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/openssl/register_types.h b/modules/openssl/register_types.h
index ff39ec8798..58f2d55c98 100644
--- a/modules/openssl/register_types.h
+++ b/modules/openssl/register_types.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/openssl/stream_peer_openssl.cpp b/modules/openssl/stream_peer_openssl.cpp
index 7a9d5195a9..d40bf73883 100644
--- a/modules/openssl/stream_peer_openssl.cpp
+++ b/modules/openssl/stream_peer_openssl.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -28,40 +28,32 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "stream_peer_openssl.h"
-//hostname matching code from curl
-//#include <openssl/applink.c> // To prevent crashing (see the OpenSSL FAQ)
+//hostname matching code from curl
bool StreamPeerOpenSSL::_match_host_name(const char *name, const char *hostname) {
return Tool_Curl_cert_hostcheck(name, hostname) == CURL_HOST_MATCH;
- //print_line("MATCH: "+String(name)+" vs "+String(hostname));
- //return true;
}
Error StreamPeerOpenSSL::_match_common_name(const char *hostname, const X509 *server_cert) {
- int common_name_loc = -1;
- X509_NAME_ENTRY *common_name_entry = NULL;
- ASN1_STRING *common_name_asn1 = NULL;
- char *common_name_str = NULL;
-
// Find the position of the CN field in the Subject field of the certificate
- common_name_loc = X509_NAME_get_index_by_NID(X509_get_subject_name((X509 *)server_cert), NID_commonName, -1);
+ int common_name_loc = X509_NAME_get_index_by_NID(X509_get_subject_name((X509 *)server_cert), NID_commonName, -1);
ERR_FAIL_COND_V(common_name_loc < 0, ERR_INVALID_PARAMETER);
// Extract the CN field
- common_name_entry = X509_NAME_get_entry(X509_get_subject_name((X509 *)server_cert), common_name_loc);
+ X509_NAME_ENTRY *common_name_entry = X509_NAME_get_entry(X509_get_subject_name((X509 *)server_cert), common_name_loc);
ERR_FAIL_COND_V(common_name_entry == NULL, ERR_INVALID_PARAMETER);
// Convert the CN field to a C string
- common_name_asn1 = X509_NAME_ENTRY_get_data(common_name_entry);
+ ASN1_STRING *common_name_asn1 = X509_NAME_ENTRY_get_data(common_name_entry);
ERR_FAIL_COND_V(common_name_asn1 == NULL, ERR_INVALID_PARAMETER);
- common_name_str = (char *)ASN1_STRING_data(common_name_asn1);
+ char *common_name_str = (char *)ASN1_STRING_data(common_name_asn1);
// Make sure there isn't an embedded NUL character in the CN
bool malformed_certificate = (size_t)ASN1_STRING_length(common_name_asn1) != strlen(common_name_str);
@@ -303,20 +295,6 @@ Error StreamPeerOpenSSL::connect_to_stream(Ref<StreamPeer> p_base, bool p_valida
X509_STORE_add_cert(store, certs[i]);
}
-#if 0
- const unsigned char *in=(const unsigned char *)certs.ptr();
- X509 *Cert = d2i_X509(NULL, &in, certs.size()-1);
- if (!Cert) {
- print_line(String(ERR_error_string(ERR_get_error(),NULL)));
- }
- ERR_FAIL_COND_V(!Cert,ERR_PARSE_ERROR);
-
- X509_STORE *store = SSL_CTX_get_cert_store(ctx);
- X509_STORE_add_cert(store,Cert);
-
- //char *str = X509_NAME_oneline(X509_get_subject_name(Cert),0,0);
- //printf ("subject: %s\n", str); /* [1] */
-#endif
}
//used for testing
diff --git a/modules/openssl/stream_peer_openssl.h b/modules/openssl/stream_peer_openssl.h
index b1da5e1d95..1e445ef681 100644
--- a/modules/openssl/stream_peer_openssl.h
+++ b/modules/openssl/stream_peer_openssl.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/opus/audio_stream_opus.cpp b/modules/opus/audio_stream_opus.cpp
index e361ebf019..1dac890eb8 100644
--- a/modules/opus/audio_stream_opus.cpp
+++ b/modules/opus/audio_stream_opus.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/opus/audio_stream_opus.h b/modules/opus/audio_stream_opus.h
index daf3958c2a..ccfe04e84e 100644
--- a/modules/opus/audio_stream_opus.h
+++ b/modules/opus/audio_stream_opus.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/opus/register_types.cpp b/modules/opus/register_types.cpp
index e8bff58cbb..a69c8bf9f3 100644
--- a/modules/opus/register_types.cpp
+++ b/modules/opus/register_types.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/opus/register_types.h b/modules/opus/register_types.h
index 4517dc5df7..1865b7966e 100644
--- a/modules/opus/register_types.h
+++ b/modules/opus/register_types.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/pbm/bitmap_loader_pbm.cpp b/modules/pbm/bitmap_loader_pbm.cpp
index c8f25ad68c..d222935970 100644
--- a/modules/pbm/bitmap_loader_pbm.cpp
+++ b/modules/pbm/bitmap_loader_pbm.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -95,6 +95,9 @@ static bool _get_token(FileAccessRef &f, uint8_t &saved, PoolVector<uint8_t> &r_
resized = true;
}
if (resized) {
+ // Note: Certain C++ static analyzers might point out that the following assigment is unnecessary.
+ // This is wrong since PoolVector<class T>::Write has an operator= method where the lhs gets updated under certain conditions.
+ // See core/dvector.h.
w = PoolVector<uint8_t>::Write();
r_token.resize(token_max);
w = r_token.write();
diff --git a/modules/pbm/bitmap_loader_pbm.h b/modules/pbm/bitmap_loader_pbm.h
index 7a72edaeee..85d3eadcb9 100644
--- a/modules/pbm/bitmap_loader_pbm.h
+++ b/modules/pbm/bitmap_loader_pbm.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/pbm/register_types.cpp b/modules/pbm/register_types.cpp
index c9531ba14f..60401b8cc9 100644
--- a/modules/pbm/register_types.cpp
+++ b/modules/pbm/register_types.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/pbm/register_types.h b/modules/pbm/register_types.h
index 3888fd6f77..b75eff55d3 100644
--- a/modules/pbm/register_types.h
+++ b/modules/pbm/register_types.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/pvr/register_types.cpp b/modules/pvr/register_types.cpp
index 04e20558ce..8fb78d7734 100644
--- a/modules/pvr/register_types.cpp
+++ b/modules/pvr/register_types.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/pvr/register_types.h b/modules/pvr/register_types.h
index 7ff5237c03..4db8219b21 100644
--- a/modules/pvr/register_types.h
+++ b/modules/pvr/register_types.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/pvr/texture_loader_pvr.cpp b/modules/pvr/texture_loader_pvr.cpp
index bdd4779e28..9989785c70 100644
--- a/modules/pvr/texture_loader_pvr.cpp
+++ b/modules/pvr/texture_loader_pvr.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/pvr/texture_loader_pvr.h b/modules/pvr/texture_loader_pvr.h
index 7d60831175..a51160d902 100644
--- a/modules/pvr/texture_loader_pvr.h
+++ b/modules/pvr/texture_loader_pvr.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/regex/SCsub b/modules/regex/SCsub
index 0882406761..0fbdf97620 100644
--- a/modules/regex/SCsub
+++ b/modules/regex/SCsub
@@ -1,7 +1,50 @@
#!/usr/bin/env python
Import('env')
+Import('env_modules')
-env.add_source_files(env.modules_sources, "*.cpp")
+env_regex = env_modules.Clone()
+env_regex.Append(CPPFLAGS=["-DPCRE2_CODE_UNIT_WIDTH=0"])
+env_regex.add_source_files(env.modules_sources, "*.cpp")
-Export('env')
+if (env['builtin_pcre2'] != 'no'):
+ thirdparty_dir = "#thirdparty/pcre2/src/"
+ thirdparty_flags = ["-DPCRE2_STATIC", "-DHAVE_CONFIG_H", "-DSUPPORT_JIT"]
+ thirdparty_sources = [
+ "pcre2_auto_possess.c",
+ "pcre2_chartables.c",
+ "pcre2_compile.c",
+ "pcre2_config.c",
+ "pcre2_context.c",
+ "pcre2_dfa_match.c",
+ "pcre2_error.c",
+ "pcre2_find_bracket.c",
+ "pcre2_jit_compile.c",
+ "pcre2_maketables.c",
+ "pcre2_match.c",
+ "pcre2_match_data.c",
+ "pcre2_newline.c",
+ "pcre2_ord2utf.c",
+ "pcre2_pattern_info.c",
+ "pcre2_serialize.c",
+ "pcre2_string_utils.c",
+ "pcre2_study.c",
+ "pcre2_substitute.c",
+ "pcre2_substring.c",
+ "pcre2_tables.c",
+ "pcre2_ucd.c",
+ "pcre2_valid_utf.c",
+ "pcre2_xclass.c",
+ ]
+ thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]
+ env_regex.Append(CPPPATH=[thirdparty_dir])
+ env_regex.Append(CPPFLAGS=thirdparty_flags)
+ def pcre2_builtin(width):
+ env_pcre2 = env_modules.Clone()
+ env_pcre2["OBJSUFFIX"] = "_" + width + env_pcre2["OBJSUFFIX"]
+ env_pcre2.Append(CPPPATH=[thirdparty_dir])
+ env_pcre2.add_source_files(env.modules_sources, thirdparty_sources)
+ env_pcre2.Append(CPPFLAGS=thirdparty_flags)
+ env_pcre2.Append(CPPFLAGS=["-DPCRE2_CODE_UNIT_WIDTH=" + width])
+ pcre2_builtin("16")
+ pcre2_builtin("32")
diff --git a/modules/regex/regex.cpp b/modules/regex/regex.cpp
index c728657d6b..8afd01e20b 100644
--- a/modules/regex/regex.cpp
+++ b/modules/regex/regex.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -29,1479 +29,469 @@
/*************************************************************************/
#include "regex.h"
-#include <wchar.h>
-#include <wctype.h>
-
-static int RegEx_hex2int(const CharType c) {
- if ('0' <= c && c <= '9')
- return int(c - '0');
- else if ('a' <= c && c <= 'f')
- return int(c - 'a') + 10;
- else if ('A' <= c && c <= 'F')
- return int(c - 'A') + 10;
- return -1;
-}
-
-struct RegExSearch {
-
- Ref<RegExMatch> match;
- const CharType *str;
- int end;
- int eof;
-
- // For standard quantifier behaviour, test_parent is used to check the
- // rest of the pattern. If the pattern matches, to prevent the parent
- // from testing again, the complete flag is used as a shortcut out.
- bool complete;
-
- // With lookahead, the position needs to rewind to its starting position
- // when test_parent is used. Due to functional programming, this state
- // has to be kept as a parameter.
- Vector<int> lookahead_pos;
-
- CharType at(int p_pos) {
- return str[p_pos];
- }
-
- RegExSearch(Ref<RegExMatch> &p_match, int p_end, int p_lookahead)
- : match(p_match) {
-
- str = p_match->string.c_str();
- end = p_end;
- eof = p_match->string.length();
- complete = false;
- lookahead_pos.resize(p_lookahead);
- }
-};
-
-struct RegExNode {
-
- RegExNode *next;
- RegExNode *previous;
- RegExNode *parent;
- bool quantifiable;
- int length;
-
- RegExNode() {
-
- next = NULL;
- previous = NULL;
- parent = NULL;
- quantifiable = false;
- length = -1;
- }
-
- virtual ~RegExNode() {
-
- if (next)
- memdelete(next);
- }
+#include "core/os/memory.h"
- // For avoiding RTTI
- virtual bool is_look_behind() { return false; }
-
- virtual int test(RegExSearch &s, int pos) const {
-
- return next ? next->test(s, pos) : -1;
- }
-
- virtual int test_parent(RegExSearch &s, int pos) const {
-
- if (next)
- pos = next->test(s, pos);
-
- if (pos >= 0) {
- s.complete = true;
- if (parent)
- pos = parent->test_parent(s, pos);
- }
-
- if (pos < 0)
- s.complete = false;
-
- return pos;
- }
-
- void increment_length(int amount, bool subtract = false) {
-
- if (amount >= 0 && length >= 0) {
- if (!subtract)
- length += amount;
- else
- length -= amount;
- } else {
- length = -1;
- }
+extern "C" {
+#include <pcre2.h>
+}
- if (parent)
- parent->increment_length(amount, subtract);
- }
-};
+static void *_regex_malloc(PCRE2_SIZE size, void *user) {
-struct RegExNodeChar : public RegExNode {
+ return memalloc(size);
+}
- CharType ch;
+static void _regex_free(void *ptr, void *user) {
- RegExNodeChar(CharType p_char) {
+ memfree(ptr);
+}
- length = 1;
- quantifiable = true;
- ch = p_char;
- }
+int RegExMatch::_find(const Variant &p_name) const {
- virtual int test(RegExSearch &s, int pos) const {
+ if (p_name.is_num()) {
- if (s.end <= pos || 0 > pos || s.at(pos) != ch)
+ int i = (int)p_name;
+ if (i >= data.size())
return -1;
+ return i;
- return next ? next->test(s, pos + 1) : pos + 1;
- }
+ } else if (p_name.get_type() == Variant::STRING) {
- static CharType parse_escape(const CharType *&c) {
-
- int point = 0;
- switch (c[1]) {
- case 'x':
- for (int i = 2; i <= 3; ++i) {
- int res = RegEx_hex2int(c[i]);
- if (res == -1)
- return '\0';
- point = (point << 4) + res;
- }
- c = &c[3];
- return CharType(point);
- case 'u':
- for (int i = 2; i <= 5; ++i) {
- int res = RegEx_hex2int(c[i]);
- if (res == -1)
- return '\0';
- point = (point << 4) + res;
- }
- c = &c[5];
- return CharType(point);
- case '0': ++c; return '\0';
- case 'a': ++c; return '\a';
- case 'e': ++c; return '\e';
- case 'f': ++c; return '\f';
- case 'n': ++c; return '\n';
- case 'r': ++c; return '\r';
- case 't': ++c; return '\t';
- case 'v': ++c; return '\v';
- case 'b': ++c; return '\b';
- default: break;
- }
- return (++c)[0];
+ const Map<String, int>::Element *found = names.find((String)p_name);
+ if (found)
+ return found->value();
}
-};
-struct RegExNodeRange : public RegExNode {
+ return -1;
+}
- CharType start;
- CharType end;
+String RegExMatch::get_subject() const {
- RegExNodeRange(CharType p_start, CharType p_end) {
+ return subject;
+}
- length = 1;
- quantifiable = true;
- start = p_start;
- end = p_end;
- }
+int RegExMatch::get_group_count() const {
- virtual int test(RegExSearch &s, int pos) const {
+ if (data.size() == 0)
+ return 0;
+ return data.size() - 1;
+}
- if (s.end <= pos || 0 > pos)
- return -1;
+Dictionary RegExMatch::get_names() const {
- CharType c = s.at(pos);
- if (c < start || end < c)
- return -1;
+ Dictionary result;
- return next ? next->test(s, pos + 1) : pos + 1;
+ for (const Map<String, int>::Element *i = names.front(); i != NULL; i = i->next()) {
+ result[i->key()] = i->value();
}
-};
-
-struct RegExNodeShorthand : public RegExNode {
- CharType repr;
+ return result;
+}
- RegExNodeShorthand(CharType p_repr) {
+Array RegExMatch::get_strings() const {
- length = 1;
- quantifiable = true;
- repr = p_repr;
- }
+ Array result;
- virtual int test(RegExSearch &s, int pos) const {
+ int size = data.size();
- if (s.end <= pos || 0 > pos)
- return -1;
+ for (int i = 0; i < size; i++) {
- bool found = false;
- bool invert = false;
- CharType c = s.at(pos);
- switch (repr) {
- case '.':
- found = true;
- break;
- case 'W':
- invert = true;
- case 'w':
- found = (c == '_' || iswalnum(c) != 0);
- break;
- case 'D':
- invert = true;
- case 'd':
- found = ('0' <= c && c <= '9');
- break;
- case 'S':
- invert = true;
- case 's':
- found = (iswspace(c) != 0);
- break;
- default:
- break;
- }
+ int start = data[i].start;
- if (found == invert)
- return -1;
-
- return next ? next->test(s, pos + 1) : pos + 1;
- }
-};
-
-struct RegExNodeClass : public RegExNode {
-
- enum Type {
- Type_none,
- Type_alnum,
- Type_alpha,
- Type_ascii,
- Type_blank,
- Type_cntrl,
- Type_digit,
- Type_graph,
- Type_lower,
- Type_print,
- Type_punct,
- Type_space,
- Type_upper,
- Type_xdigit,
- Type_word
- };
-
- Type type;
-
- bool test_class(CharType c) const {
-
- static Vector<CharType> REGEX_NODE_SPACE = String(" \t\r\n\f");
- static Vector<CharType> REGEX_NODE_PUNCT = String("!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~");
-
- switch (type) {
- case Type_alnum:
- if ('0' <= c && c <= '9') return true;
- if ('a' <= c && c <= 'z') return true;
- if ('A' <= c && c <= 'Z') return true;
- return false;
- case Type_alpha:
- if ('a' <= c && c <= 'z') return true;
- if ('A' <= c && c <= 'Z') return true;
- return false;
- case Type_ascii:
- return (0x00 <= c && c <= 0x7F);
- case Type_blank:
- return (c == ' ' || c == '\t');
- case Type_cntrl:
- return ((0x00 <= c && c <= 0x1F) || c == 0x7F);
- case Type_digit:
- return ('0' <= c && c <= '9');
- case Type_graph:
- return (0x20 < c && c < 0x7F);
- case Type_lower:
- return ('a' <= c && c <= 'z');
- case Type_print:
- return (0x20 < c && c < 0x7f);
- case Type_punct:
- return (REGEX_NODE_PUNCT.find(c) >= 0);
- case Type_space:
- return (REGEX_NODE_SPACE.find(c) >= 0);
- case Type_upper:
- return ('A' <= c && c <= 'Z');
- case Type_xdigit:
- if ('0' <= c && c <= '9') return true;
- if ('a' <= c && c <= 'f') return true;
- if ('A' <= c && c <= 'F') return true;
- return false;
- case Type_word:
- if ('0' <= c && c <= '9') return true;
- if ('a' <= c && c <= 'z') return true;
- if ('A' <= c && c <= 'Z') return true;
- return (c == '_');
- default:
- return false;
+ if (start == -1) {
+ result.append(String());
+ continue;
}
- return false;
- }
-
- RegExNodeClass(Type p_type) {
-
- length = 1;
- quantifiable = true;
- type = p_type;
- }
-
- virtual int test(RegExSearch &s, int pos) const {
-
- if (s.end <= pos || 0 > pos)
- return -1;
-
- if (!test_class(s.at(pos)))
- return -1;
-
- return next ? next->test(s, pos + 1) : pos + 1;
- }
-
-#define REGEX_CMP_CLASS(POS, NAME) \
- if (cmp_class(POS, #NAME)) return Type_##NAME
-
- static Type parse_type(const CharType *&p_pos) {
-
- REGEX_CMP_CLASS(p_pos, alnum);
- REGEX_CMP_CLASS(p_pos, alpha);
- REGEX_CMP_CLASS(p_pos, ascii);
- REGEX_CMP_CLASS(p_pos, blank);
- REGEX_CMP_CLASS(p_pos, cntrl);
- REGEX_CMP_CLASS(p_pos, digit);
- REGEX_CMP_CLASS(p_pos, graph);
- REGEX_CMP_CLASS(p_pos, lower);
- REGEX_CMP_CLASS(p_pos, print);
- REGEX_CMP_CLASS(p_pos, punct);
- REGEX_CMP_CLASS(p_pos, space);
- REGEX_CMP_CLASS(p_pos, upper);
- REGEX_CMP_CLASS(p_pos, xdigit);
- REGEX_CMP_CLASS(p_pos, word);
- return Type_none;
- }
-
- static bool cmp_class(const CharType *&p_pos, const char *p_text) {
-
- unsigned int i = 0;
- for (i = 0; p_text[i] != '\0'; ++i)
- if (p_pos[i] != p_text[i])
- return false;
-
- if (p_pos[i++] != ':' || p_pos[i] != ']')
- return false;
-
- p_pos = &p_pos[i];
- return true;
- }
-};
-
-struct RegExNodeAnchorStart : public RegExNode {
- RegExNodeAnchorStart() {
+ int length = data[i].end - start;
- length = 0;
+ result.append(subject.substr(start, length));
}
- virtual int test(RegExSearch &s, int pos) const {
+ return result;
+}
- if (pos != 0)
- return -1;
+String RegExMatch::get_string(const Variant &p_name) const {
- return next ? next->test(s, pos) : pos;
- }
-};
+ int id = _find(p_name);
-struct RegExNodeAnchorEnd : public RegExNode {
+ if (id < 0)
+ return String();
- RegExNodeAnchorEnd() {
+ int start = data[id].start;
- length = 0;
- }
+ if (start == -1)
+ return String();
- virtual int test(RegExSearch &s, int pos) const {
+ int length = data[id].end - start;
- if (pos != s.eof)
- return -1;
+ return subject.substr(start, length);
+}
- return next ? next->test(s, pos) : pos;
- }
-};
+int RegExMatch::get_start(const Variant &p_name) const {
-struct RegExNodeWordBoundary : public RegExNode {
+ int id = _find(p_name);
- bool inverse;
+ if (id < 0)
+ return -1;
- RegExNodeWordBoundary(bool p_inverse) {
+ return data[id].start;
+}
- length = 0;
- inverse = p_inverse;
- }
+int RegExMatch::get_end(const Variant &p_name) const {
- virtual int test(RegExSearch &s, int pos) const {
+ int id = _find(p_name);
- bool left = false;
- bool right = false;
+ if (id < 0)
+ return -1;
- if (pos != 0) {
- CharType c = s.at(pos - 1);
- if (c == '_' || iswalnum(c))
- left = true;
- }
+ return data[id].end;
+}
- if (pos != s.eof) {
- CharType c = s.at(pos);
- if (c == '_' || iswalnum(c))
- right = true;
- }
+void RegExMatch::_bind_methods() {
- if ((left == right) != inverse)
- return -1;
+ ClassDB::bind_method(D_METHOD("get_subject"), &RegExMatch::get_subject);
+ ClassDB::bind_method(D_METHOD("get_group_count"), &RegExMatch::get_group_count);
+ ClassDB::bind_method(D_METHOD("get_names"), &RegExMatch::get_names);
+ ClassDB::bind_method(D_METHOD("get_strings"), &RegExMatch::get_strings);
+ ClassDB::bind_method(D_METHOD("get_string", "name"), &RegExMatch::get_string, DEFVAL(0));
+ ClassDB::bind_method(D_METHOD("get_start", "name"), &RegExMatch::get_start, DEFVAL(0));
+ ClassDB::bind_method(D_METHOD("get_end", "name"), &RegExMatch::get_end, DEFVAL(0));
+}
- return next ? next->test(s, pos) : pos;
- }
-};
+void RegEx::_pattern_info(uint32_t what, void *where) const {
-struct RegExNodeQuantifier : public RegExNode {
+ if (sizeof(CharType) == 2) {
- int min;
- int max;
- bool greedy;
- RegExNode *child;
+ pcre2_pattern_info_16((pcre2_code_16 *)code, what, where);
- RegExNodeQuantifier(int p_min, int p_max) {
+ } else {
- min = p_min;
- max = p_max;
- greedy = true;
- child = NULL;
+ pcre2_pattern_info_32((pcre2_code_32 *)code, what, where);
}
+}
- ~RegExNodeQuantifier() {
-
- if (child)
- memdelete(child);
- }
+void RegEx::clear() {
- virtual int test(RegExSearch &s, int pos) const {
+ if (sizeof(CharType) == 2) {
- return test_step(s, pos, 0, pos);
- }
+ if (code)
+ pcre2_code_free_16((pcre2_code_16 *)code);
- virtual int test_parent(RegExSearch &s, int pos) const {
+ } else {
- s.complete = false;
- return pos;
+ if (code)
+ pcre2_code_free_32((pcre2_code_32 *)code);
}
+}
- int test_step(RegExSearch &s, int pos, int level, int start) const {
-
- if (pos > s.end)
- return -1;
-
- if (!greedy && level > min) {
- int res = next ? next->test(s, pos) : pos;
- if (s.complete)
- return res;
-
- if (res >= 0 && parent->test_parent(s, res) >= 0)
- return res;
- }
-
- if (max >= 0 && level > max)
- return -1;
+Error RegEx::compile(const String &p_pattern) {
- int res = pos;
- if (level >= 1) {
- if (level > min + 1 && pos == start)
- return -1;
+ pattern = p_pattern;
+ clear();
- res = child->test(s, pos);
- if (s.complete)
- return res;
- }
+ int err;
+ PCRE2_SIZE offset;
+ uint32_t flags = PCRE2_DUPNAMES;
- if (res >= 0) {
+ if (sizeof(CharType) == 2) {
- int res_step = test_step(s, res, level + 1, start);
- if (res_step >= 0)
- return res_step;
+ pcre2_general_context_16 *gctx = (pcre2_general_context_16 *)general_ctx;
+ pcre2_compile_context_16 *cctx = pcre2_compile_context_create_16(gctx);
+ PCRE2_SPTR16 p = (PCRE2_SPTR16)pattern.c_str();
- if (greedy && level >= min) {
- if (next)
- res = next->test(s, res);
- if (s.complete)
- return res;
+ code = pcre2_compile_16(p, pattern.length(), flags, &err, &offset, cctx);
- if (res >= 0 && parent->test_parent(s, res) >= 0)
- return res;
- }
+ if (!code) {
+ PCRE2_UCHAR16 buf[256];
+ pcre2_get_error_message_16(err, buf, 256);
+ String message = String::num(offset) + ": " + String((const CharType *)buf);
+ ERR_PRINT(message.utf8());
+ return FAILED;
}
- return -1;
- }
-};
-
-struct RegExNodeBackReference : public RegExNode {
- int id;
+ } else {
- RegExNodeBackReference(int p_id) {
-
- length = -1;
- quantifiable = true;
- id = p_id;
- }
+ pcre2_general_context_32 *gctx = (pcre2_general_context_32 *)general_ctx;
+ pcre2_compile_context_32 *cctx = pcre2_compile_context_create_32(gctx);
+ PCRE2_SPTR32 p = (PCRE2_SPTR32)pattern.c_str();
- virtual int test(RegExSearch &s, int pos) const {
+ code = pcre2_compile_32(p, pattern.length(), flags, &err, &offset, cctx);
- RegExMatch::Group &ref = s.match->captures[id];
- for (int i = 0; i < ref.length; ++i) {
-
- if (pos + i >= s.end)
- return -1;
-
- if (s.at(ref.start + i) != s.at(pos + i))
- return -1;
+ if (!code) {
+ PCRE2_UCHAR32 buf[256];
+ pcre2_get_error_message_32(err, buf, 256);
+ String message = String::num(offset) + ": " + String((const CharType *)buf);
+ ERR_PRINT(message.utf8());
+ return FAILED;
}
- return next ? next->test(s, pos + ref.length) : pos + ref.length;
}
-};
-
-struct RegExNodeGroup : public RegExNode {
-
- bool inverse;
- bool reset_pos;
- Vector<RegExNode *> childset;
- RegExNode *back;
-
- RegExNodeGroup() {
-
- length = 0;
- quantifiable = true;
- inverse = false;
- reset_pos = false;
- back = NULL;
- }
-
- virtual ~RegExNodeGroup() {
-
- for (int i = 0; i < childset.size(); ++i)
- memdelete(childset[i]);
- }
-
- virtual void test_success(RegExSearch &s, int pos) const {
+ return OK;
+}
- return;
- }
+Ref<RegExMatch> RegEx::search(const String &p_subject, int p_offset, int p_end) const {
- virtual int test(RegExSearch &s, int pos) const {
+ ERR_FAIL_COND_V(!is_valid(), NULL);
- for (int i = 0; i < childset.size(); ++i) {
+ Ref<RegExMatch> result = memnew(RegExMatch);
- s.complete = false;
+ int length = p_subject.length();
+ if (p_end >= 0 && p_end < length)
+ length = p_end;
- int res = childset[i]->test(s, pos);
+ if (sizeof(CharType) == 2) {
- if (inverse) {
- s.complete = false;
- if (res < 0)
- res = pos + 1;
- else
- return -1;
+ pcre2_code_16 *c = (pcre2_code_16 *)code;
+ pcre2_general_context_16 *gctx = (pcre2_general_context_16 *)general_ctx;
+ pcre2_match_context_16 *mctx = pcre2_match_context_create_16(gctx);
+ PCRE2_SPTR16 s = (PCRE2_SPTR16)p_subject.c_str();
- if (i + 1 < childset.size())
- continue;
- }
+ pcre2_match_data_16 *match = pcre2_match_data_create_from_pattern_16(c, gctx);
- if (s.complete)
- return res;
+ int res = pcre2_match_16(c, s, length, p_offset, 0, match, mctx);
- if (res >= 0) {
- if (reset_pos)
- res = pos;
- this->test_success(s, res);
- return next ? next->test(s, res) : res;
- }
+ if (res < 0) {
+ pcre2_match_data_free_16(match);
+ return NULL;
}
- return -1;
- }
-
- void add_child(RegExNode *node) {
- node->parent = this;
- node->previous = back;
+ uint32_t size = pcre2_get_ovector_count_16(match);
+ PCRE2_SIZE *ovector = pcre2_get_ovector_pointer_16(match);
- if (back)
- back->next = node;
- else
- childset.push_back(node);
+ result->data.resize(size);
- increment_length(node->length);
+ for (uint32_t i = 0; i < size; i++) {
- back = node;
- }
-
- void add_childset() {
-
- if (childset.size() > 0)
- length = -1;
- back = NULL;
- }
-
- RegExNode *swap_back(RegExNode *node) {
-
- RegExNode *old = back;
-
- if (old) {
- if (!old->previous)
- childset.remove(childset.size() - 1);
- back = old->previous;
- increment_length(old->length, true);
+ result->data[i].start = ovector[i * 2];
+ result->data[i].end = ovector[i * 2 + 1];
}
- add_child(node);
+ pcre2_match_data_free_16(match);
+ pcre2_match_context_free_16(mctx);
- return old;
- }
-};
+ } else {
-struct RegExNodeCapturing : public RegExNodeGroup {
+ pcre2_code_32 *c = (pcre2_code_32 *)code;
+ pcre2_general_context_32 *gctx = (pcre2_general_context_32 *)general_ctx;
+ pcre2_match_context_32 *mctx = pcre2_match_context_create_32(gctx);
+ PCRE2_SPTR32 s = (PCRE2_SPTR32)p_subject.c_str();
- int id;
+ pcre2_match_data_32 *match = pcre2_match_data_create_from_pattern_32(c, gctx);
- RegExNodeCapturing(int p_id = 0) {
+ int res = pcre2_match_32(c, s, length, p_offset, 0, match, mctx);
- id = p_id;
- }
-
- virtual void test_success(RegExSearch &s, int pos) const {
-
- RegExMatch::Group &ref = s.match->captures[id];
- ref.length = pos - ref.start;
- }
-
- virtual int test(RegExSearch &s, int pos) const {
-
- RegExMatch::Group &ref = s.match->captures[id];
- int old_start = ref.start;
- ref.start = pos;
-
- int res = RegExNodeGroup::test(s, pos);
-
- if (res < 0)
- ref.start = old_start;
- return res;
- }
-
- virtual int test_parent(RegExSearch &s, int pos) const {
-
- RegExMatch::Group &ref = s.match->captures[id];
- ref.length = pos - ref.start;
- return RegExNode::test_parent(s, pos);
- }
-
- static Variant parse_name(const CharType *&c, bool p_allow_numeric) {
-
- if (c[1] == '0') {
- return -1;
- } else if ('1' <= c[1] && c[1] <= '9') {
- if (!p_allow_numeric)
- return -1;
- int res = (++c)[0] - '0';
- while ('0' <= c[1] && c[1] <= '9')
- res = res * 10 + int((++c)[0] - '0');
- if ((++c)[0] != '>')
- return -1;
- return res;
- } else if (iswalnum(c[1])) {
- String res(++c, 1);
- while (iswalnum(c[1]))
- res += String(++c, 1);
- if ((++c)[0] != '>')
- return -1;
- return res;
+ if (res < 0) {
+ pcre2_match_data_free_32(match);
+ return NULL;
}
- return -1;
- }
-};
-
-struct RegExNodeLookAhead : public RegExNodeGroup {
-
- int id;
- RegExNodeLookAhead(bool p_inverse, int p_id = 0) {
+ uint32_t size = pcre2_get_ovector_count_32(match);
+ PCRE2_SIZE *ovector = pcre2_get_ovector_pointer_32(match);
- quantifiable = false;
- inverse = p_inverse;
- reset_pos = true;
- id = p_id;
- }
-
- virtual int test(RegExSearch &s, int pos) const {
+ result->data.resize(size);
- s.lookahead_pos[id] = pos;
- return RegExNodeGroup::test(s, pos);
- }
+ for (uint32_t i = 0; i < size; i++) {
- virtual int test_parent(RegExSearch &s, int pos) const {
+ result->data[i].start = ovector[i * 2];
+ result->data[i].end = ovector[i * 2 + 1];
+ }
- return RegExNode::test_parent(s, s.lookahead_pos[id]);
+ pcre2_match_data_free_32(match);
+ pcre2_match_context_free_32(mctx);
}
-};
-struct RegExNodeLookBehind : public RegExNodeGroup {
+ result->subject = p_subject;
- RegExNodeLookBehind(bool p_inverse, int p_id = 0) {
+ uint32_t count;
+ const CharType *table;
+ uint32_t entry_size;
- quantifiable = false;
- inverse = p_inverse;
- reset_pos = true;
- }
+ _pattern_info(PCRE2_INFO_NAMECOUNT, &count);
+ _pattern_info(PCRE2_INFO_NAMETABLE, &table);
+ _pattern_info(PCRE2_INFO_NAMEENTRYSIZE, &entry_size);
- virtual bool is_look_behind() { return true; }
+ for (int i = 0; i < count; i++) {
- virtual int test(RegExSearch &s, int pos) const {
+ CharType id = table[i * entry_size];
+ if (result->data[id].start == -1)
+ continue;
+ String name = &table[i * entry_size + 1];
+ if (result->names.has(name))
+ continue;
- if (pos < length)
- return -1;
- return RegExNodeGroup::test(s, pos - length);
+ result->names.insert(name, id);
}
-};
-struct RegExNodeBracket : public RegExNode {
+ return result;
+}
- bool inverse;
- Vector<RegExNode *> children;
+String RegEx::sub(const String &p_subject, const String &p_replacement, bool p_all, int p_offset, int p_end) const {
- RegExNodeBracket() {
+ ERR_FAIL_COND_V(!is_valid(), String());
- length = 1;
- quantifiable = true;
- inverse = false;
- }
+ String output;
+ output.resize(p_subject.length());
- virtual ~RegExNodeBracket() {
+ uint32_t flags = PCRE2_SUBSTITUTE_OVERFLOW_LENGTH;
+ if (p_all)
+ flags |= PCRE2_SUBSTITUTE_GLOBAL;
- for (int i = 0; i < children.size(); ++i)
- memdelete(children[i]);
- }
+ PCRE2_SIZE olength = output.length();
- virtual int test(RegExSearch &s, int pos) const {
+ PCRE2_SIZE length = p_subject.length();
+ if (p_end >= 0 && p_end < length)
+ length = p_end;
- for (int i = 0; i < children.size(); ++i) {
+ if (sizeof(CharType) == 2) {
- int res = children[i]->test(s, pos);
+ pcre2_code_16 *c = (pcre2_code_16 *)code;
+ pcre2_general_context_16 *gctx = (pcre2_general_context_16 *)general_ctx;
+ pcre2_match_context_16 *mctx = pcre2_match_context_create_16(gctx);
+ PCRE2_SPTR16 s = (PCRE2_SPTR16)p_subject.c_str();
+ PCRE2_SPTR16 r = (PCRE2_SPTR16)p_replacement.c_str();
+ PCRE2_UCHAR16 *o = (PCRE2_UCHAR16 *)output.c_str();
- if (inverse) {
- if (res < 0)
- res = pos + 1;
- else
- return -1;
+ pcre2_match_data_16 *match = pcre2_match_data_create_from_pattern_16(c, gctx);
- if (i + 1 < children.size())
- continue;
- }
+ int res = pcre2_substitute_16(c, s, length, p_offset, flags, match, mctx, r, p_replacement.length(), o, &olength);
- if (res >= 0)
- return next ? next->test(s, res) : res;
+ if (res == PCRE2_ERROR_NOMEMORY) {
+ output.resize(olength);
+ o = (PCRE2_UCHAR16 *)output.c_str();
+ res = pcre2_substitute_16(c, s, length, p_offset, flags, match, mctx, r, p_replacement.length(), o, &olength);
}
- return -1;
- }
- void add_child(RegExNode *node) {
-
- node->parent = this;
- children.push_back(node);
- }
+ pcre2_match_data_free_16(match);
+ pcre2_match_context_free_16(mctx);
- void pop_back() {
-
- memdelete(children[children.size() - 1]);
- children.remove(children.size() - 1);
- }
-};
-
-#define REGEX_EXPAND_FAIL(MSG) \
- { \
- ERR_PRINT(MSG); \
- return String(); \
- }
-
-String RegExMatch::expand(const String &p_template) const {
-
- String res;
- for (const CharType *c = p_template.c_str(); *c != '\0'; ++c) {
- if (c[0] == '\\') {
- if (('1' <= c[1] && c[1] <= '9') || (c[1] == 'g' && c[2] == '{')) {
-
- int ref = 0;
- bool unclosed = false;
-
- if (c[1] == 'g') {
- unclosed = true;
- c = &c[2];
- }
-
- while ('0' <= c[1] && c[1] <= '9') {
- ref = ref * 10 + int(c[1] - '0');
- ++c;
- }
-
- if (unclosed) {
- if (c[1] != '}')
- REGEX_EXPAND_FAIL("unclosed backreference '{'");
- ++c;
- }
-
- res += get_string(ref);
-
- } else if (c[1] == 'g' && c[2] == '<') {
-
- const CharType *d = &c[2];
+ if (res < 0)
+ return String();
- Variant name = RegExNodeCapturing::parse_name(d, true);
- if (name == Variant(-1))
- REGEX_EXPAND_FAIL("unrecognised character for group name");
+ } else {
- c = d;
+ pcre2_code_32 *c = (pcre2_code_32 *)code;
+ pcre2_general_context_32 *gctx = (pcre2_general_context_32 *)general_ctx;
+ pcre2_match_context_32 *mctx = pcre2_match_context_create_32(gctx);
+ PCRE2_SPTR32 s = (PCRE2_SPTR32)p_subject.c_str();
+ PCRE2_SPTR32 r = (PCRE2_SPTR32)p_replacement.c_str();
+ PCRE2_UCHAR32 *o = (PCRE2_UCHAR32 *)output.c_str();
- res += get_string(name);
+ pcre2_match_data_32 *match = pcre2_match_data_create_from_pattern_32(c, gctx);
- } else {
+ int res = pcre2_substitute_32(c, s, length, p_offset, flags, match, mctx, r, p_replacement.length(), o, &olength);
- const CharType *d = c;
- CharType ch = RegExNodeChar::parse_escape(d);
- if (c == d)
- REGEX_EXPAND_FAIL("invalid escape token");
- res += String(&ch, 1);
- c = d;
- }
- } else {
- res += String(c, 1);
+ if (res == PCRE2_ERROR_NOMEMORY) {
+ output.resize(olength);
+ o = (PCRE2_UCHAR32 *)output.c_str();
+ res = pcre2_substitute_32(c, s, length, p_offset, flags, match, mctx, r, p_replacement.length(), o, &olength);
}
- }
- return res;
-}
-int RegExMatch::get_group_count() const {
+ pcre2_match_data_free_32(match);
+ pcre2_match_context_free_32(mctx);
- int count = 0;
- for (int i = 1; i < captures.size(); ++i)
- if (captures[i].name.get_type() == Variant::INT)
- ++count;
- return count;
-}
-
-Array RegExMatch::get_group_array() const {
-
- Array res;
- for (int i = 1; i < captures.size(); ++i) {
- const RegExMatch::Group &capture = captures[i];
- if (capture.name.get_type() != Variant::INT)
- continue;
-
- if (capture.start >= 0)
- res.push_back(string.substr(capture.start, capture.length));
- else
- res.push_back(String());
- }
- return res;
-}
-
-Array RegExMatch::get_names() const {
-
- Array res;
- for (int i = 1; i < captures.size(); ++i)
- if (captures[i].name.get_type() == Variant::STRING)
- res.push_back(captures[i].name);
- return res;
-}
-
-Dictionary RegExMatch::get_name_dict() const {
-
- Dictionary res;
- for (int i = 1; i < captures.size(); ++i) {
- const RegExMatch::Group &capture = captures[i];
- if (capture.name.get_type() != Variant::STRING)
- continue;
-
- if (capture.start >= 0)
- res[capture.name] = string.substr(capture.start, capture.length);
- else
- res[capture.name] = String();
- }
- return res;
-}
-
-String RegExMatch::get_string(const Variant &p_name) const {
-
- for (int i = 0; i < captures.size(); ++i) {
-
- const RegExMatch::Group &capture = captures[i];
-
- if (capture.name != p_name)
- continue;
-
- if (capture.start == -1)
+ if (res < 0)
return String();
-
- return string.substr(capture.start, capture.length);
}
- return String();
-}
-
-int RegExMatch::get_start(const Variant &p_name) const {
- for (int i = 0; i < captures.size(); ++i)
- if (captures[i].name == p_name)
- return captures[i].start;
- return -1;
+ return output;
}
-int RegExMatch::get_end(const Variant &p_name) const {
+bool RegEx::is_valid() const {
- for (int i = 0; i < captures.size(); ++i)
- if (captures[i].name == p_name)
- return captures[i].start + captures[i].length;
- return -1;
+ return (code != NULL);
}
-RegExMatch::RegExMatch() {
-}
+String RegEx::get_pattern() const {
-static bool RegEx_is_shorthand(CharType ch) {
-
- switch (ch) {
- case 'w':
- case 'W':
- case 'd':
- case 'D':
- case 's':
- case 'S':
- return true;
- default:
- break;
- }
- return false;
+ return pattern;
}
-#define REGEX_COMPILE_FAIL(MSG) \
- { \
- ERR_PRINT(MSG); \
- clear(); \
- return FAILED; \
- }
+int RegEx::get_group_count() const {
-Error RegEx::compile(const String &p_pattern) {
+ ERR_FAIL_COND_V(!is_valid(), 0);
- ERR_FAIL_COND_V(p_pattern.length() == 0, FAILED);
+ uint32_t count;
- if (pattern == p_pattern && root)
- return OK;
+ _pattern_info(PCRE2_INFO_CAPTURECOUNT, &count);
- clear();
- pattern = p_pattern;
- group_names.push_back(0);
- RegExNodeGroup *root_group = memnew(RegExNodeCapturing(0));
- root = root_group;
- Vector<RegExNodeGroup *> stack;
- stack.push_back(root_group);
- int lookahead_level = 0;
- int numeric_groups = 0;
- const int numeric_max = 9;
-
- for (const CharType *c = p_pattern.c_str(); *c != '\0'; ++c) {
-
- switch (c[0]) {
- case '(':
- if (c[1] == '?') {
-
- RegExNodeGroup *group = NULL;
- switch (c[2]) {
- case ':':
- c = &c[2];
- group = memnew(RegExNodeGroup());
- break;
- case '!':
- case '=':
- group = memnew(RegExNodeLookAhead((c[2] == '!'), lookahead_level++));
- if (lookahead_depth < lookahead_level)
- lookahead_depth = lookahead_level;
- c = &c[2];
- break;
- case '<':
- if (c[3] == '!' || c[3] == '=') {
- group = memnew(RegExNodeLookBehind((c[3] == '!'), lookahead_level++));
- c = &c[3];
- }
- break;
- case 'P':
- if (c[3] == '<') {
- const CharType *d = &c[3];
- Variant name = RegExNodeCapturing::parse_name(d, false);
- if (name == Variant(-1))
- REGEX_COMPILE_FAIL("unrecognised character for group name");
- group = memnew(RegExNodeCapturing(group_names.size()));
- group_names.push_back(name);
- c = d;
- }
- default:
- break;
- }
- if (!group)
- REGEX_COMPILE_FAIL("unrecognised qualifier for group");
- stack[0]->add_child(group);
- stack.insert(0, group);
-
- } else if (numeric_groups < numeric_max) {
-
- RegExNodeCapturing *group = memnew(RegExNodeCapturing(group_names.size()));
- group_names.push_back(++numeric_groups);
- stack[0]->add_child(group);
- stack.insert(0, group);
-
- } else {
-
- RegExNodeGroup *group = memnew(RegExNodeGroup());
- stack[0]->add_child(group);
- stack.insert(0, group);
- }
- break;
- case ')':
- if (stack.size() == 1)
- REGEX_COMPILE_FAIL("unexpected ')'");
- stack.remove(0);
- break;
- case '\\':
- if (('1' <= c[1] && c[1] <= '9') || (c[1] == 'g' && c[2] == '{')) {
-
- int ref = 0;
- bool unclosed = false;
-
- if (c[1] == 'g') {
- unclosed = true;
- c = &c[2];
- }
-
- while ('0' <= c[1] && c[1] <= '9') {
- ref = ref * 10 + int(c[1] - '0');
- ++c;
- }
-
- if (unclosed) {
- if (c[1] != '}')
- REGEX_COMPILE_FAIL("unclosed backreference '{'");
- ++c;
- }
-
- if (ref > numeric_groups || ref <= 0)
- REGEX_COMPILE_FAIL("backreference not found");
-
- for (int i = 0; i < stack.size(); ++i)
- if (stack[i]->is_look_behind())
- REGEX_COMPILE_FAIL("backreferences inside lookbehind not supported");
-
- for (int i = 0; i < group_names.size(); ++i) {
- if (group_names[i].get_type() == Variant::INT && int(group_names[i]) == ref) {
- ref = group_names[i];
- break;
- }
- }
-
- stack[0]->add_child(memnew(RegExNodeBackReference(ref)));
- }
- if (c[1] == 'g' && c[2] == '<') {
-
- const CharType *d = &c[2];
-
- Variant name = RegExNodeCapturing::parse_name(d, true);
- if (name == Variant(-1))
- REGEX_COMPILE_FAIL("unrecognised character for group name");
-
- c = d;
-
- for (int i = 0; i < stack.size(); ++i)
- if (stack[i]->is_look_behind())
- REGEX_COMPILE_FAIL("backreferences inside lookbehind not supported");
-
- int ref = -1;
-
- for (int i = 0; i < group_names.size(); ++i) {
- if (group_names[i].get_type() == Variant::INT && int(group_names[i]) == ref) {
- ref = group_names[i];
- break;
- }
- }
-
- if (ref == -1)
- REGEX_COMPILE_FAIL("backreference not found");
-
- stack[0]->add_child(memnew(RegExNodeBackReference(ref)));
-
- } else if (c[1] == 'b' || c[1] == 'B') {
-
- stack[0]->add_child(memnew(RegExNodeWordBoundary(*(++c) == 'B')));
-
- } else if (RegEx_is_shorthand(c[1])) {
-
- stack[0]->add_child(memnew(RegExNodeShorthand(*(++c))));
-
- } else {
-
- const CharType *d = c;
- CharType ch = RegExNodeChar::parse_escape(d);
- if (c == d)
- REGEX_COMPILE_FAIL("invalid escape token");
- stack[0]->add_child(memnew(RegExNodeChar(ch)));
- c = d;
- }
- break;
- case '[': {
- RegExNodeBracket *bracket = memnew(RegExNodeBracket());
- stack[0]->add_child(bracket);
- if (c[1] == '^') {
- bracket->inverse = true;
- ++c;
- }
- bool first_child = true;
- CharType previous_child;
- bool previous_child_single = false;
- while (true) {
- ++c;
- if (!first_child && c[0] == ']') {
-
- break;
-
- } else if (c[0] == '\0') {
-
- REGEX_COMPILE_FAIL("unclosed bracket expression '['");
-
- } else if (c[0] == '\\') {
-
- if (RegEx_is_shorthand(c[1])) {
- bracket->add_child(memnew(RegExNodeShorthand(*(++c))));
- } else {
- const CharType *d = c;
- CharType ch = RegExNodeChar::parse_escape(d);
- if (c == d)
- REGEX_COMPILE_FAIL("invalid escape token");
- bracket->add_child(memnew(RegExNodeChar(ch)));
- c = d;
- previous_child = ch;
- previous_child_single = true;
- }
-
- } else if (c[0] == ']' && c[1] == ':') {
-
- const CharType *d = &c[2];
- RegExNodeClass::Type type = RegExNodeClass::parse_type(d);
- if (type != RegExNodeClass::Type_none) {
-
- c = d;
- previous_child_single = false;
-
- } else {
-
- bracket->add_child(memnew(RegExNodeChar('[')));
- previous_child = '[';
- previous_child_single = true;
- }
- } else if (previous_child_single && c[0] == '-') {
-
- if (c[1] != '\0' && c[1] != ']') {
-
- CharType next;
-
- if (c[1] == '\\') {
- const CharType *d = ++c;
- next = RegExNodeChar::parse_escape(d);
- if (c == d)
- REGEX_COMPILE_FAIL("invalid escape token");
- } else {
- next = *(++c);
- }
-
- if (next < previous_child)
- REGEX_COMPILE_FAIL("text range out of order");
-
- bracket->pop_back();
- bracket->add_child(memnew(RegExNodeRange(previous_child, next)));
- previous_child_single = false;
- } else {
-
- bracket->add_child(memnew(RegExNodeChar('-')));
- previous_child = '-';
- previous_child_single = true;
- }
- } else {
-
- bracket->add_child(memnew(RegExNodeChar(c[0])));
- previous_child = c[0];
- previous_child_single = true;
- }
- first_child = false;
- }
- } break;
- case '|':
- for (int i = 0; i < stack.size(); ++i)
- if (stack[i]->is_look_behind())
- REGEX_COMPILE_FAIL("alternations inside lookbehind not supported");
- stack[0]->add_childset();
- break;
- case '^':
- stack[0]->add_child(memnew(RegExNodeAnchorStart()));
- break;
- case '$':
- stack[0]->add_child(memnew(RegExNodeAnchorEnd()));
- break;
- case '.':
- stack[0]->add_child(memnew(RegExNodeShorthand('.')));
- break;
- case '?':
- case '*':
- case '+':
- case '{': {
- int min_val = 0;
- int max_val = -1;
- bool valid = true;
- const CharType *d = c;
- bool max_set = true;
- switch (c[0]) {
- case '?':
- min_val = 0;
- max_val = 1;
- break;
- case '*':
- min_val = 0;
- max_val = -1;
- break;
- case '+':
- min_val = 1;
- max_val = -1;
- break;
- case '{':
- max_set = false;
- while (valid) {
- ++d;
- if (d[0] == '}') {
- break;
- } else if (d[0] == ',') {
- max_set = true;
- } else if ('0' <= d[0] && d[0] <= '9') {
- if (max_set) {
- if (max_val < 0)
- max_val = int(d[0] - '0');
- else
- max_val = max_val * 10 + int(d[0] - '0');
- } else {
- min_val = min_val * 10 + int(d[0] - '0');
- }
- } else {
- valid = false;
- }
- }
- break;
- default:
- break;
- }
-
- if (!max_set)
- max_val = min_val;
-
- if (valid) {
-
- c = d;
-
- if (stack[0]->back == NULL || !stack[0]->back->quantifiable)
- REGEX_COMPILE_FAIL("element not quantifiable");
-
- if (min_val != max_val)
- for (int i = 0; i < stack.size(); ++i)
- if (stack[i]->is_look_behind())
- REGEX_COMPILE_FAIL("variable length quantifiers inside lookbehind not supported");
-
- RegExNodeQuantifier *quant = memnew(RegExNodeQuantifier(min_val, max_val));
- quant->child = stack[0]->swap_back(quant);
- quant->child->previous = NULL;
- quant->child->parent = quant;
-
- if (min_val == max_val && quant->child->length >= 0)
- quant->length = max_val * quant->child->length;
-
- if (c[1] == '?') {
- quant->greedy = false;
- ++c;
- }
- break;
- }
- }
- default:
- stack[0]->add_child(memnew(RegExNodeChar(c[0])));
- break;
- }
- }
- if (stack.size() > 1)
- REGEX_COMPILE_FAIL("unclosed group '('");
- return OK;
+ return count;
}
-Ref<RegExMatch> RegEx::search(const String &p_text, int p_start, int p_end) const {
-
- ERR_FAIL_COND_V(!is_valid(), NULL);
- ERR_FAIL_COND_V(p_start < 0, NULL);
- ERR_FAIL_COND_V(p_start >= p_text.length(), NULL);
- ERR_FAIL_COND_V(p_end > p_text.length(), NULL);
- ERR_FAIL_COND_V(p_end != -1 && p_end < p_start, NULL);
+Array RegEx::get_names() const {
- Ref<RegExMatch> res = memnew(RegExMatch());
+ Array result;
- for (int i = 0; i < group_names.size(); ++i) {
- RegExMatch::Group group;
- group.name = group_names[i];
- res->captures.push_back(group);
- }
+ ERR_FAIL_COND_V(!is_valid(), result);
- res->string = p_text;
+ uint32_t count;
+ const CharType *table;
+ uint32_t entry_size;
- if (p_end == -1)
- p_end = p_text.length();
+ _pattern_info(PCRE2_INFO_NAMECOUNT, &count);
+ _pattern_info(PCRE2_INFO_NAMETABLE, &table);
+ _pattern_info(PCRE2_INFO_NAMEENTRYSIZE, &entry_size);
- RegExSearch s(res, p_end, lookahead_depth);
+ for (int i = 0; i < count; i++) {
- for (int i = p_start; i <= s.end; ++i) {
- for (int c = 0; c < group_names.size(); ++c) {
- res->captures[c].start = -1;
- res->captures[c].length = 0;
+ String name = &table[i * entry_size + 1];
+ if (result.find(name) < 0) {
+ result.append(name);
}
- if (root->test(s, i) >= 0)
- break;
}
- if (res->captures[0].start >= 0)
- return res;
- return NULL;
+ return result;
}
-String RegEx::sub(const String &p_text, const String &p_replacement, bool p_all, int p_start, int p_end) const {
-
- ERR_FAIL_COND_V(!is_valid(), p_text);
- ERR_FAIL_COND_V(p_start < 0, p_text);
- ERR_FAIL_COND_V(p_start >= p_text.length(), p_text);
- ERR_FAIL_COND_V(p_end > p_text.length(), p_text);
- ERR_FAIL_COND_V(p_end != -1 && p_end < p_start, p_text);
-
- String text = p_text;
- int start = p_start;
-
- if (p_end == -1)
- p_end = p_text.length();
-
- while (start < text.length() && (p_all || start == p_start)) {
-
- Ref<RegExMatch> m = search(text, start, p_end);
-
- RegExMatch::Group &s = m->captures[0];
-
- if (s.start < 0)
- break;
-
- String res = text.substr(0, s.start) + m->expand(p_replacement);
-
- start = res.length();
+RegEx::RegEx() {
- if (s.length == 0)
- ++start;
+ if (sizeof(CharType) == 2) {
- int sub_end = s.start + s.length;
- if (sub_end < text.length())
- res += text.substr(sub_end, text.length() - sub_end);
+ general_ctx = pcre2_general_context_create_16(&_regex_malloc, &_regex_free, NULL);
- p_end += res.length() - text.length();
+ } else {
- text = res;
+ general_ctx = pcre2_general_context_create_32(&_regex_malloc, &_regex_free, NULL);
}
- return text;
+ code = NULL;
}
-void RegEx::clear() {
-
- if (root)
- memdelete(root);
-
- root = NULL;
- group_names.clear();
- lookahead_depth = 0;
-}
-
-bool RegEx::is_valid() const {
-
- return (root != NULL);
-}
-
-String RegEx::get_pattern() const {
-
- return pattern;
-}
-
-int RegEx::get_group_count() const {
-
- int count = 0;
- for (int i = 1; i < group_names.size(); ++i)
- if (group_names[i].get_type() == Variant::INT)
- ++count;
- return count;
-}
-
-Array RegEx::get_names() const {
+RegEx::RegEx(const String &p_pattern) {
- Array res;
- for (int i = 1; i < group_names.size(); ++i)
- if (group_names[i].get_type() == Variant::STRING)
- res.push_back(group_names[i]);
- return res;
-}
+ if (sizeof(CharType) == 2) {
-RegEx::RegEx() {
+ general_ctx = pcre2_general_context_create_16(&_regex_malloc, &_regex_free, NULL);
- root = NULL;
- lookahead_depth = 0;
-}
+ } else {
-RegEx::RegEx(const String &p_pattern) {
-
- root = NULL;
+ general_ctx = pcre2_general_context_create_32(&_regex_malloc, &_regex_free, NULL);
+ }
+ code = NULL;
compile(p_pattern);
}
RegEx::~RegEx() {
- if (root)
- memdelete(root);
-}
+ if (sizeof(CharType) == 2) {
-void RegExMatch::_bind_methods() {
+ if (code)
+ pcre2_code_free_16((pcre2_code_16 *)code);
+ pcre2_general_context_free_16((pcre2_general_context_16 *)general_ctx);
- ClassDB::bind_method(D_METHOD("expand", "template"), &RegExMatch::expand);
- ClassDB::bind_method(D_METHOD("get_group_count"), &RegExMatch::get_group_count);
- ClassDB::bind_method(D_METHOD("get_group_array"), &RegExMatch::get_group_array);
- ClassDB::bind_method(D_METHOD("get_names"), &RegExMatch::get_names);
- ClassDB::bind_method(D_METHOD("get_name_dict"), &RegExMatch::get_name_dict);
- ClassDB::bind_method(D_METHOD("get_string", "name"), &RegExMatch::get_string, DEFVAL(0));
- ClassDB::bind_method(D_METHOD("get_start", "name"), &RegExMatch::get_start, DEFVAL(0));
- ClassDB::bind_method(D_METHOD("get_end", "name"), &RegExMatch::get_end, DEFVAL(0));
+ } else {
+
+ if (code)
+ pcre2_code_free_32((pcre2_code_32 *)code);
+ pcre2_general_context_free_32((pcre2_general_context_32 *)general_ctx);
+ }
}
void RegEx::_bind_methods() {
ClassDB::bind_method(D_METHOD("clear"), &RegEx::clear);
ClassDB::bind_method(D_METHOD("compile", "pattern"), &RegEx::compile);
- ClassDB::bind_method(D_METHOD("search", "text", "start", "end"), &RegEx::search, DEFVAL(0), DEFVAL(-1));
- ClassDB::bind_method(D_METHOD("sub", "text", "replacement", "all", "start", "end"), &RegEx::sub, DEFVAL(false), DEFVAL(0), DEFVAL(-1));
+ ClassDB::bind_method(D_METHOD("search", "subject", "offset", "end"), &RegEx::search, DEFVAL(0), DEFVAL(-1));
+ ClassDB::bind_method(D_METHOD("sub", "subject", "replacement", "all", "offset", "end"), &RegEx::sub, DEFVAL(false), DEFVAL(0), DEFVAL(-1));
ClassDB::bind_method(D_METHOD("is_valid"), &RegEx::is_valid);
ClassDB::bind_method(D_METHOD("get_pattern"), &RegEx::get_pattern);
ClassDB::bind_method(D_METHOD("get_group_count"), &RegEx::get_group_count);
ClassDB::bind_method(D_METHOD("get_names"), &RegEx::get_names);
-
- ADD_PROPERTY(PropertyInfo(Variant::STRING, "pattern"), "compile", "get_pattern");
}
diff --git a/modules/regex/regex.h b/modules/regex/regex.h
index 106d2649a5..0d97bcce54 100644
--- a/modules/regex/regex.h
+++ b/modules/regex/regex.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -31,59 +31,53 @@
#ifndef REGEX_H
#define REGEX_H
+#include "core/array.h"
#include "core/dictionary.h"
+#include "core/map.h"
#include "core/reference.h"
-#include "core/resource.h"
#include "core/ustring.h"
#include "core/vector.h"
-class RegExNode;
-
class RegExMatch : public Reference {
GDCLASS(RegExMatch, Reference);
- struct Group {
- Variant name;
+ struct Range {
int start;
- int length;
+ int end;
};
- Vector<Group> captures;
- String string;
+ String subject;
+ Vector<Range> data;
+ Map<String, int> names;
friend class RegEx;
- friend class RegExSearch;
- friend class RegExNodeCapturing;
- friend class RegExNodeBackReference;
protected:
static void _bind_methods();
-public:
- String expand(const String &p_template) const;
+ int _find(const Variant &p_name) const;
+public:
+ String get_subject() const;
int get_group_count() const;
- Array get_group_array() const;
-
- Array get_names() const;
- Dictionary get_name_dict() const;
+ Dictionary get_names() const;
+ Array get_strings() const;
String get_string(const Variant &p_name) const;
int get_start(const Variant &p_name) const;
int get_end(const Variant &p_name) const;
-
- RegExMatch();
};
-class RegEx : public Resource {
+class RegEx : public Reference {
- GDCLASS(RegEx, Resource);
+ GDCLASS(RegEx, Reference);
- RegExNode *root;
- Vector<Variant> group_names;
+ void *general_ctx;
+ void *code;
String pattern;
- int lookahead_depth;
+
+ void _pattern_info(uint32_t what, void *where) const;
protected:
static void _bind_methods();
@@ -91,9 +85,10 @@ protected:
public:
void clear();
Error compile(const String &p_pattern);
+ void _init(const String &p_pattern = "");
- Ref<RegExMatch> search(const String &p_text, int p_start = 0, int p_end = -1) const;
- String sub(const String &p_text, const String &p_replacement, bool p_all = false, int p_start = 0, int p_end = -1) const;
+ Ref<RegExMatch> search(const String &p_subject, int offset = 0, int end = -1) const;
+ String sub(const String &p_subject, const String &p_replacement, bool p_all = false, int p_start = 0, int p_end = -1) const;
bool is_valid() const;
String get_pattern() const;
diff --git a/modules/regex/register_types.cpp b/modules/regex/register_types.cpp
index eaa8f41e33..7b042aaa52 100644
--- a/modules/regex/register_types.cpp
+++ b/modules/regex/register_types.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/regex/register_types.h b/modules/regex/register_types.h
index 3b977edd32..1624fe18c8 100644
--- a/modules/regex/register_types.h
+++ b/modules/regex/register_types.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/register_module_types.h b/modules/register_module_types.h
index e30dab2819..089055ffa0 100644
--- a/modules/register_module_types.h
+++ b/modules/register_module_types.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/squish/image_compress_squish.cpp b/modules/squish/image_compress_squish.cpp
index efce76c805..29073a8499 100644
--- a/modules/squish/image_compress_squish.cpp
+++ b/modules/squish/image_compress_squish.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/squish/image_compress_squish.h b/modules/squish/image_compress_squish.h
index 68aaeefc30..0dff5a7ce3 100644
--- a/modules/squish/image_compress_squish.h
+++ b/modules/squish/image_compress_squish.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/squish/register_types.cpp b/modules/squish/register_types.cpp
index 2eeea59836..d5aa1d4b71 100644
--- a/modules/squish/register_types.cpp
+++ b/modules/squish/register_types.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/squish/register_types.h b/modules/squish/register_types.h
index 3bf1b19dec..0afeeeff3b 100644
--- a/modules/squish/register_types.h
+++ b/modules/squish/register_types.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp b/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp
index 7b8b2abebb..49d959203c 100644
--- a/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp
+++ b/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -49,7 +49,7 @@ void AudioStreamPlaybackOGGVorbis::_mix_internal(AudioFrame *p_buffer, int p_fra
//end of file!
if (vorbis_stream->loop) {
//loop
- seek_pos(0);
+ seek_pos(vorbis_stream->loop_offset);
loops++;
} else {
for (int i = mixed; i < p_frames; i++) {
@@ -227,6 +227,14 @@ bool AudioStreamOGGVorbis::has_loop() const {
return loop;
}
+void AudioStreamOGGVorbis::set_loop_offset(float p_seconds) {
+ loop_offset = p_seconds;
+}
+
+float AudioStreamOGGVorbis::get_loop_offset() const {
+ return loop_offset;
+}
+
void AudioStreamOGGVorbis::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_data", "data"), &AudioStreamOGGVorbis::set_data);
@@ -235,8 +243,12 @@ void AudioStreamOGGVorbis::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_loop", "enable"), &AudioStreamOGGVorbis::set_loop);
ClassDB::bind_method(D_METHOD("has_loop"), &AudioStreamOGGVorbis::has_loop);
+ ClassDB::bind_method(D_METHOD("set_loop_offset", "seconds"), &AudioStreamOGGVorbis::set_loop_offset);
+ ClassDB::bind_method(D_METHOD("get_loop_offset"), &AudioStreamOGGVorbis::get_loop_offset);
+
ADD_PROPERTY(PropertyInfo(Variant::POOL_BYTE_ARRAY, "data", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_data", "get_data");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "loop", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_loop", "has_loop");
+ ADD_PROPERTY(PropertyInfo(Variant::REAL, "loop_offset", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_loop_offset", "get_loop_offset");
}
AudioStreamOGGVorbis::AudioStreamOGGVorbis() {
@@ -245,6 +257,7 @@ AudioStreamOGGVorbis::AudioStreamOGGVorbis() {
length = 0;
sample_rate = 1;
channels = 1;
+ loop_offset = 0;
decode_mem_size = 0;
loop = false;
}
diff --git a/modules/stb_vorbis/audio_stream_ogg_vorbis.h b/modules/stb_vorbis/audio_stream_ogg_vorbis.h
index 46cdfd3f2d..a459e6f31d 100644
--- a/modules/stb_vorbis/audio_stream_ogg_vorbis.h
+++ b/modules/stb_vorbis/audio_stream_ogg_vorbis.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -89,6 +89,7 @@ class AudioStreamOGGVorbis : public AudioStream {
int channels;
float length;
bool loop;
+ float loop_offset;
protected:
static void _bind_methods();
@@ -97,6 +98,9 @@ public:
void set_loop(bool p_enable);
bool has_loop() const;
+ void set_loop_offset(float p_seconds);
+ float get_loop_offset() const;
+
virtual Ref<AudioStreamPlayback> instance_playback();
virtual String get_stream_name() const;
diff --git a/modules/stb_vorbis/register_types.cpp b/modules/stb_vorbis/register_types.cpp
index 726260b45c..abd01e9a14 100644
--- a/modules/stb_vorbis/register_types.cpp
+++ b/modules/stb_vorbis/register_types.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/stb_vorbis/register_types.h b/modules/stb_vorbis/register_types.h
index c17e1eafe9..8e2d5e78f8 100644
--- a/modules/stb_vorbis/register_types.h
+++ b/modules/stb_vorbis/register_types.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/stb_vorbis/resource_importer_ogg_vorbis.cpp b/modules/stb_vorbis/resource_importer_ogg_vorbis.cpp
index f0a7ee1ec6..4d28dc027b 100644
--- a/modules/stb_vorbis/resource_importer_ogg_vorbis.cpp
+++ b/modules/stb_vorbis/resource_importer_ogg_vorbis.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -72,11 +72,13 @@ String ResourceImporterOGGVorbis::get_preset_name(int p_idx) const {
void ResourceImporterOGGVorbis::get_import_options(List<ImportOption> *r_options, int p_preset) const {
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "loop"), true));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::REAL, "loop_offset"), 0));
}
Error ResourceImporterOGGVorbis::import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files) {
bool loop = p_options["loop"];
+ float loop_offset = p_options["loop_offset"];
FileAccess *f = FileAccess::open(p_source_file, FileAccess::READ);
if (!f) {
@@ -98,6 +100,7 @@ Error ResourceImporterOGGVorbis::import(const String &p_source_file, const Strin
ogg_stream->set_data(data);
ogg_stream->set_loop(loop);
+ ogg_stream->set_loop_offset(loop_offset);
return ResourceSaver::save(p_save_path + ".oggstr", ogg_stream);
}
diff --git a/modules/stb_vorbis/resource_importer_ogg_vorbis.h b/modules/stb_vorbis/resource_importer_ogg_vorbis.h
index c588b58fb2..8134009704 100644
--- a/modules/stb_vorbis/resource_importer_ogg_vorbis.h
+++ b/modules/stb_vorbis/resource_importer_ogg_vorbis.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/svg/SCsub b/modules/svg/SCsub
new file mode 100644
index 0000000000..5be9367808
--- /dev/null
+++ b/modules/svg/SCsub
@@ -0,0 +1,35 @@
+#!/usr/bin/env python
+
+Import('env')
+from compat import isbasestring
+
+# Thirdparty source files
+thirdparty_dir = "#thirdparty/nanosvg/"
+thirdparty_sources = [
+ "nanosvg.cc"
+]
+thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]
+
+# env.add_source_files(env.modules_sources, thirdparty_sources)
+
+lib = env.Library("svg_builtin", thirdparty_sources)
+# Needs to be appended to arrive after libscene in the linker call,
+# but we don't want it to arrive *after* system libs, so manual hack
+# LIBS contains first SCons Library objects ("SCons.Node.FS.File object")
+# and then plain strings for system library. We insert between the two.
+inserted = False
+for idx, linklib in enumerate(env["LIBS"]):
+ if isbasestring(linklib): # first system lib such as "X11", otherwise SCons lib object
+ env["LIBS"].insert(idx, lib)
+ inserted = True
+ break
+if not inserted:
+ env.Append(LIBS=[lib])
+
+env.Append(CPPPATH=[thirdparty_dir])
+env.Append(CCFLAGS=["-DSVG_ENABLED"])
+
+# Godot's own source files
+env.add_source_files(env.modules_sources, "*.cpp")
+
+Export('env')
diff --git a/modules/svg/config.py b/modules/svg/config.py
new file mode 100644
index 0000000000..fb920482f5
--- /dev/null
+++ b/modules/svg/config.py
@@ -0,0 +1,7 @@
+
+def can_build(platform):
+ return True
+
+
+def configure(env):
+ pass
diff --git a/modules/svg/image_loader_svg.cpp b/modules/svg/image_loader_svg.cpp
new file mode 100644
index 0000000000..f5c379d32e
--- /dev/null
+++ b/modules/svg/image_loader_svg.cpp
@@ -0,0 +1,156 @@
+/*************************************************************************/
+/* image_loader_svg.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+#include "image_loader_svg.h"
+
+#include "os/os.h"
+#include "print_string.h"
+
+#include <ustring.h>
+
+void SVGRasterizer::rasterize(NSVGimage *p_image, float p_tx, float p_ty, float p_scale, unsigned char *p_dst, int p_w, int p_h, int p_stride) {
+ nsvgRasterize(rasterizer, p_image, p_tx, p_ty, p_scale, p_dst, p_w, p_h, p_stride);
+}
+
+SVGRasterizer::SVGRasterizer() {
+ rasterizer = nsvgCreateRasterizer();
+}
+SVGRasterizer::~SVGRasterizer() {
+ nsvgDeleteRasterizer(rasterizer);
+}
+
+SVGRasterizer ImageLoaderSVG::rasterizer;
+
+inline void change_nsvg_paint_color(NSVGpaint *p_paint, const uint32_t p_old, const uint32_t p_new) {
+
+ if (p_paint->type == NSVG_PAINT_COLOR) {
+ if (p_paint->color << 8 == p_old << 8) {
+ p_paint->color = p_new;
+ }
+ }
+
+ if (p_paint->type == NSVG_PAINT_LINEAR_GRADIENT || p_paint->type == NSVG_PAINT_RADIAL_GRADIENT) {
+ for (int stop_index = 0; stop_index < p_paint->gradient->nstops; stop_index++) {
+ if (p_paint->gradient->stops[stop_index].color << 8 == p_old << 8) {
+ p_paint->gradient->stops[stop_index].color = p_new;
+ }
+ }
+ }
+}
+void ImageLoaderSVG::_convert_colors(NSVGimage *p_svg_image, const Dictionary p_colors) {
+ List<uint32_t> replace_colors_i;
+ List<uint32_t> new_colors_i;
+ List<Color> replace_colors;
+ List<Color> new_colors;
+
+ for (int i = 0; i < p_colors.keys().size(); i++) {
+ Variant r_c = p_colors.keys()[i];
+ Variant n_c = p_colors[p_colors.keys()[i]];
+ if (r_c.get_type() == Variant::COLOR && n_c.get_type() == Variant::COLOR) {
+ Color replace_color = r_c;
+ Color new_color = n_c;
+ replace_colors_i.push_back(replace_color.to_ABGR32());
+ new_colors_i.push_back(new_color.to_ABGR32());
+ }
+ }
+
+ for (NSVGshape *shape = p_svg_image->shapes; shape != NULL; shape = shape->next) {
+
+ for (int i = 0; i < replace_colors_i.size(); i++) {
+ change_nsvg_paint_color(&(shape->stroke), replace_colors_i[i], new_colors_i[i]);
+ change_nsvg_paint_color(&(shape->fill), replace_colors_i[i], new_colors_i[i]);
+ }
+ }
+}
+
+Error ImageLoaderSVG::_create_image(Ref<Image> p_image, const PoolVector<uint8_t> *p_data, float p_scale, bool upsample, const Dictionary *p_replace_colors) {
+ NSVGimage *svg_image;
+ PoolVector<uint8_t>::Read src_r = p_data->read();
+ svg_image = nsvgParse((char *)src_r.ptr(), "px", 96);
+ if (svg_image == NULL) {
+ ERR_PRINT("SVG Corrupted");
+ return ERR_FILE_CORRUPT;
+ }
+
+ if (p_replace_colors != NULL) {
+ _convert_colors(svg_image, *p_replace_colors);
+ }
+ float upscale = upsample ? 2.0 : 1.0;
+
+ int w = (int)(svg_image->width * p_scale * upscale);
+ int h = (int)(svg_image->height * p_scale * upscale);
+
+ PoolVector<uint8_t> dst_image;
+ dst_image.resize(w * h * 4);
+
+ PoolVector<uint8_t>::Write dw = dst_image.write();
+
+ rasterizer.rasterize(svg_image, 0, 0, p_scale * upscale, (unsigned char *)dw.ptr(), w, h, w * 4);
+
+ dw = PoolVector<uint8_t>::Write();
+ p_image->create(w, h, false, Image::FORMAT_RGBA8, dst_image);
+ if (upsample)
+ p_image->shrink_x2();
+
+ nsvgDelete(svg_image);
+
+ return OK;
+}
+
+Error ImageLoaderSVG::create_image_from_string(Ref<Image> p_image, const char *svg_str, float p_scale, bool upsample, const Dictionary *p_replace_colors) {
+
+ size_t str_len = strlen(svg_str);
+ PoolVector<uint8_t> src_data;
+ src_data.resize(str_len + 1);
+ PoolVector<uint8_t>::Write src_w = src_data.write();
+ memcpy(src_w.ptr(), svg_str, str_len + 1);
+
+ return _create_image(p_image, &src_data, p_scale, upsample, p_replace_colors);
+}
+
+Error ImageLoaderSVG::load_image(Ref<Image> p_image, FileAccess *f, bool p_force_linear, float p_scale) {
+
+ uint32_t size = f->get_len();
+ PoolVector<uint8_t> src_image;
+ src_image.resize(size + 1);
+ PoolVector<uint8_t>::Write src_w = src_image.write();
+ f->get_buffer(src_w.ptr(), size);
+ src_w.ptr()[size] = '\0';
+
+ return _create_image(p_image, &src_image, p_scale, 1.0);
+}
+
+void ImageLoaderSVG::get_recognized_extensions(List<String> *p_extensions) const {
+
+ p_extensions->push_back("svg");
+ p_extensions->push_back("svgz");
+}
+
+ImageLoaderSVG::ImageLoaderSVG() {
+}
diff --git a/modules/svg/image_loader_svg.h b/modules/svg/image_loader_svg.h
new file mode 100644
index 0000000000..f692b1b28c
--- /dev/null
+++ b/modules/svg/image_loader_svg.h
@@ -0,0 +1,68 @@
+/*************************************************************************/
+/* image_loader_svg.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+#ifndef IMAGE_LOADER_SVG_H
+#define IMAGE_LOADER_SVG_H
+
+#include "io/image_loader.h"
+#include "ustring.h"
+
+#include <nanosvg.h>
+#include <nanosvgrast.h>
+
+/**
+ @author Daniel Ramirez <djrmuv@gmail.com>
+*/
+
+class SVGRasterizer {
+
+ NSVGrasterizer *rasterizer;
+
+public:
+ void rasterize(NSVGimage *p_image, float p_tx, float p_ty, float p_scale, unsigned char *p_dst, int p_w, int p_h, int p_stride);
+
+ SVGRasterizer();
+ ~SVGRasterizer();
+};
+
+class ImageLoaderSVG : public ImageFormatLoader {
+
+ static SVGRasterizer rasterizer;
+ static void _convert_colors(NSVGimage *p_svg_imge, const Dictionary p_colors);
+ static Error _create_image(Ref<Image> p_image, const PoolVector<uint8_t> *p_data, float p_scale, bool upsample, const Dictionary *p_replace_color = NULL);
+
+public:
+ static Error create_image_from_string(Ref<Image> p_image, const char *p_svg_str, float p_scale, bool upsample, const Dictionary *p_replace_color = NULL);
+
+ virtual Error load_image(Ref<Image> p_image, FileAccess *f, bool p_force_linear, float p_scale);
+ virtual void get_recognized_extensions(List<String> *p_extensions) const;
+ ImageLoaderSVG();
+};
+
+#endif
diff --git a/modules/svg/register_types.cpp b/modules/svg/register_types.cpp
new file mode 100644
index 0000000000..e37239f27a
--- /dev/null
+++ b/modules/svg/register_types.cpp
@@ -0,0 +1,45 @@
+/*************************************************************************/
+/* register_types.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+#include "register_types.h"
+
+#include "image_loader_svg.h"
+
+static ImageLoaderSVG *image_loader_svg = NULL;
+
+void register_svg_types() {
+
+ image_loader_svg = memnew(ImageLoaderSVG);
+ ImageLoader::add_image_format_loader(image_loader_svg);
+}
+
+void unregister_svg_types() {
+
+ memdelete(image_loader_svg);
+}
diff --git a/modules/svg/register_types.h b/modules/svg/register_types.h
new file mode 100644
index 0000000000..49d550e7c9
--- /dev/null
+++ b/modules/svg/register_types.h
@@ -0,0 +1,31 @@
+/*************************************************************************/
+/* register_types.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+void register_svg_types();
+void unregister_svg_types();
diff --git a/modules/tga/image_loader_tga.cpp b/modules/tga/image_loader_tga.cpp
index 5b8610b975..379c894550 100644
--- a/modules/tga/image_loader_tga.cpp
+++ b/modules/tga/image_loader_tga.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -203,7 +203,7 @@ Error ImageLoaderTGA::convert_to_image(Ref<Image> p_image, const uint8_t *p_buff
return OK;
}
-Error ImageLoaderTGA::load_image(Ref<Image> p_image, FileAccess *f, bool p_force_linear) {
+Error ImageLoaderTGA::load_image(Ref<Image> p_image, FileAccess *f, bool p_force_linear, float p_scale) {
PoolVector<uint8_t> src_image;
int src_image_len = f->get_len();
diff --git a/modules/tga/image_loader_tga.h b/modules/tga/image_loader_tga.h
index 11329ec68a..8689a1773b 100644
--- a/modules/tga/image_loader_tga.h
+++ b/modules/tga/image_loader_tga.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -75,7 +75,7 @@ class ImageLoaderTGA : public ImageFormatLoader {
static Error convert_to_image(Ref<Image> p_image, const uint8_t *p_buffer, const tga_header_s &p_header, const uint8_t *p_palette, const bool p_is_monochrome);
public:
- virtual Error load_image(Ref<Image> p_image, FileAccess *f, bool p_force_linear);
+ virtual Error load_image(Ref<Image> p_image, FileAccess *f, bool p_force_linear, float p_scale);
virtual void get_recognized_extensions(List<String> *p_extensions) const;
ImageLoaderTGA();
};
diff --git a/modules/tga/register_types.cpp b/modules/tga/register_types.cpp
index 6e120fa3bf..814b21d368 100644
--- a/modules/tga/register_types.cpp
+++ b/modules/tga/register_types.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/tga/register_types.h b/modules/tga/register_types.h
index 079b7bf291..10812981f8 100644
--- a/modules/tga/register_types.h
+++ b/modules/tga/register_types.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/theora/register_types.cpp b/modules/theora/register_types.cpp
index 1bea5439a3..ae6961b3da 100644
--- a/modules/theora/register_types.cpp
+++ b/modules/theora/register_types.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/theora/register_types.h b/modules/theora/register_types.h
index cb9f9d1848..7011ee44d0 100644
--- a/modules/theora/register_types.h
+++ b/modules/theora/register_types.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/theora/video_stream_theora.cpp b/modules/theora/video_stream_theora.cpp
index 977062dd14..2a24f8d4d1 100644
--- a/modules/theora/video_stream_theora.cpp
+++ b/modules/theora/video_stream_theora.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -83,37 +83,6 @@ void VideoStreamPlaybackTheora::video_write(void) {
th_ycbcr_buffer yuv;
th_decode_ycbcr_out(td, yuv);
- // FIXME: The way stuff is commented out with `//*/` closing comments
- // sounds very fishy...
-
- /*
- int y_offset, uv_offset;
- y_offset=(ti.pic_x&~1)+yuv[0].stride*(ti.pic_y&~1);
-
- {
- int pixels = size.x * size.y;
- frame_data.resize(pixels * 4);
- PoolVector<uint8_t>::Write w = frame_data.write();
- char* dst = (char*)w.ptr();
- int p = 0;
- for (int i=0; i<size.y; i++) {
-
- char *in_y = (char *)yuv[0].data+y_offset+yuv[0].stride*i;
- char *out = dst + (int)size.x * 4 * i;
- for (int j=0;j<size.x;j++) {
-
- dst[p++] = in_y[j];
- dst[p++] = in_y[j];
- dst[p++] = in_y[j];
- dst[p++] = 255;
- };
- }
- format = Image::FORMAT_RGBA8;
- }
- //*/
-
- //*
-
int pitch = 4;
frame_data.resize(size.x * size.y * pitch);
{
@@ -142,99 +111,6 @@ void VideoStreamPlaybackTheora::video_write(void) {
texture->set_data(img); //zero copy send to visual server
- /*
-
- if (px_fmt == TH_PF_444) {
-
- int pitch = 3;
- frame_data.resize(size.x * size.y * pitch);
- PoolVector<uint8_t>::Write w = frame_data.write();
- char* dst = (char*)w.ptr();
-
- for(int i=0;i<size.y;i++) {
-
- char *in_y = (char *)yuv[0].data+y_offset+yuv[0].stride*i;
- char *out = dst + (int)size.x * pitch * i;
- char *in_u = (char *)yuv[1].data+uv_offset+yuv[1].stride*i;
- char *in_v = (char *)yuv[2].data+uv_offset+yuv[2].stride*i;
- for (int j=0;j<size.x;j++) {
-
- out[j*3+0] = in_y[j];
- out[j*3+1] = in_u[j];
- out[j*3+2] = in_v[j];
- };
- }
-
- format = Image::FORMAT_YUV_444;
-
- } else {
-
- int div;
- if (px_fmt!=TH_PF_422) {
- div = 2;
- }
-
- bool rgba = true;
- if (rgba) {
-
- int pitch = 4;
- frame_data.resize(size.x * size.y * pitch);
- PoolVector<uint8_t>::Write w = frame_data.write();
- char* dst = (char*)w.ptr();
-
- uv_offset=(ti.pic_x/2)+(yuv[1].stride)*(ti.pic_y / div);
- for(int i=0;i<size.y;i++) {
- char *in_y = (char *)yuv[0].data+y_offset+yuv[0].stride*i;
- char *in_u = (char *)yuv[1].data+uv_offset+yuv[1].stride*(i/div);
- char *in_v = (char *)yuv[2].data+uv_offset+yuv[2].stride*(i/div);
- uint8_t *out = (uint8_t*)dst + (int)size.x * pitch * i;
- int ofs = 0;
- for (int j=0;j<size.x;j++) {
-
- uint8_t y, u, v;
- y = in_y[j];
- u = in_u[j/2];
- v = in_v[j/2];
-
- int32_t r = Math::fast_ftoi(1.164 * (y - 16) + 1.596 * (v - 128));
- int32_t g = Math::fast_ftoi(1.164 * (y - 16) - 0.813 * (v - 128) - 0.391 * (u - 128));
- int32_t b = Math::fast_ftoi(1.164 * (y - 16) + 2.018 * (u - 128));
-
- out[ofs++] = CLAMP(r, 0, 255);
- out[ofs++] = CLAMP(g, 0, 255);
- out[ofs++] = CLAMP(b, 0, 255);
- out[ofs++] = 255;
- }
- }
-
- format = Image::FORMAT_RGBA8;
-
- } else {
-
- int pitch = 2;
- frame_data.resize(size.x * size.y * pitch);
- PoolVector<uint8_t>::Write w = frame_data.write();
- char* dst = (char*)w.ptr();
-
- uv_offset=(ti.pic_x/2)+(yuv[1].stride)*(ti.pic_y / div);
- for(int i=0;i<size.y;i++) {
- char *in_y = (char *)yuv[0].data+y_offset+yuv[0].stride*i;
- char *out = dst + (int)size.x * pitch * i;
- for (int j=0;j<size.x;j++)
- out[j*2] = in_y[j];
- char *in_u = (char *)yuv[1].data+uv_offset+yuv[1].stride*(i/div);
- char *in_v = (char *)yuv[2].data+uv_offset+yuv[2].stride*(i/div);
- for (int j=0;j<(int)size.x>>1;j++) {
- out[j*4+1] = in_u[j];
- out[j*4+3] = in_v[j];
- }
- }
-
- format = Image::FORMAT_YUV_422;
- };
- };
- //*/
-
frames_pending = 1;
}
@@ -451,20 +327,10 @@ void VideoStreamPlaybackTheora::set_file(const String &p_file) {
ti.frame_width, ti.frame_height, ti.pic_x, ti.pic_y);
th_decode_ctl(td, TH_DECCTL_GET_PPLEVEL_MAX, &pp_level_max,
sizeof(pp_level_max));
- pp_level = pp_level_max;
pp_level = 0;
th_decode_ctl(td, TH_DECCTL_SET_PPLEVEL, &pp_level, sizeof(pp_level));
pp_inc = 0;
- /*{
- int arg = 0xffff;
- th_decode_ctl(td,TH_DECCTL_SET_TELEMETRY_MBMODE,&arg,sizeof(arg));
- th_decode_ctl(td,TH_DECCTL_SET_TELEMETRY_MV,&arg,sizeof(arg));
- th_decode_ctl(td,TH_DECCTL_SET_TELEMETRY_QI,&arg,sizeof(arg));
- arg=10;
- th_decode_ctl(td,TH_DECCTL_SET_TELEMETRY_BITS,&arg,sizeof(arg));
- }*/
-
int w;
int h;
w = (ti.pic_x + ti.frame_width + 1 & ~1) - (ti.pic_x & ~1);
@@ -503,8 +369,6 @@ void VideoStreamPlaybackTheora::set_file(const String &p_file) {
float VideoStreamPlaybackTheora::get_time() const {
- //print_line("total: "+itos(get_total())+" todo: "+itos(get_todo()));
- //return MAX(0,time-((get_total())/(float)vi.rate));
return time - AudioServer::get_singleton()->get_output_delay() - delay_compensation; //-((get_total())/(float)vi.rate);
};
@@ -527,8 +391,6 @@ void VideoStreamPlaybackTheora::update(float p_delta) {
thread_sem->post();
#endif
- //double ctime =AudioServer::get_singleton()->get_mix_time();
-
//print_line("play "+rtos(p_delta));
time += p_delta;
@@ -664,8 +526,6 @@ void VideoStreamPlaybackTheora::update(float p_delta) {
}
}
-//print_line("no theora: "+itos(no_theora)+" theora eos: "+itos(theora_eos)+" frame done "+itos(frame_done));
-
#ifdef THEORA_USE_THREAD_STREAMING
if (file && thread_eof && no_theora && theora_eos && ring_buffer.data_left() == 0) {
#else
@@ -675,16 +535,6 @@ void VideoStreamPlaybackTheora::update(float p_delta) {
stop();
return;
};
-#if 0
- if (!videobuf_ready || audio_todo > 0){
- /* no data yet for somebody. Grab another page */
-
- buffer_data();
- while(ogg_sync_pageout(&oy,&og)>0){
- queue_page(&og);
- }
- }
-#else
if (!frame_done || !audio_done) {
//what's the point of waiting for audio to grab a page?
@@ -694,7 +544,7 @@ void VideoStreamPlaybackTheora::update(float p_delta) {
queue_page(&og);
}
}
-#endif
+
/* If playback has begun, top audio buffer off immediately. */
//if(stateflag) audio_write_nonblocking();
diff --git a/modules/theora/video_stream_theora.h b/modules/theora/video_stream_theora.h
index 84b665382b..f04e49c662 100644
--- a/modules/theora/video_stream_theora.h
+++ b/modules/theora/video_stream_theora.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/tinyexr/image_loader_tinyexr.cpp b/modules/tinyexr/image_loader_tinyexr.cpp
index 4eb91da10b..57826d69fb 100644
--- a/modules/tinyexr/image_loader_tinyexr.cpp
+++ b/modules/tinyexr/image_loader_tinyexr.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -34,7 +34,7 @@
#include "thirdparty/tinyexr/tinyexr.h"
-Error ImageLoaderTinyEXR::load_image(Ref<Image> p_image, FileAccess *f, bool p_force_linear) {
+Error ImageLoaderTinyEXR::load_image(Ref<Image> p_image, FileAccess *f, bool p_force_linear, float p_scale) {
PoolVector<uint8_t> src_image;
int src_image_len = f->get_len();
diff --git a/modules/tinyexr/image_loader_tinyexr.h b/modules/tinyexr/image_loader_tinyexr.h
index a52894b12b..adecba5d9d 100644
--- a/modules/tinyexr/image_loader_tinyexr.h
+++ b/modules/tinyexr/image_loader_tinyexr.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -38,7 +38,7 @@
class ImageLoaderTinyEXR : public ImageFormatLoader {
public:
- virtual Error load_image(Ref<Image> p_image, FileAccess *f, bool p_force_linear);
+ virtual Error load_image(Ref<Image> p_image, FileAccess *f, bool p_force_linear, float p_scale);
virtual void get_recognized_extensions(List<String> *p_extensions) const;
ImageLoaderTinyEXR();
};
diff --git a/modules/tinyexr/register_types.cpp b/modules/tinyexr/register_types.cpp
index 73f3131276..4bbafbc90a 100644
--- a/modules/tinyexr/register_types.cpp
+++ b/modules/tinyexr/register_types.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/tinyexr/register_types.h b/modules/tinyexr/register_types.h
index f3c7372359..e866bb7624 100644
--- a/modules/tinyexr/register_types.h
+++ b/modules/tinyexr/register_types.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/visual_script/register_types.cpp b/modules/visual_script/register_types.cpp
index a54d306aff..c50ba17c35 100644
--- a/modules/visual_script/register_types.cpp
+++ b/modules/visual_script/register_types.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/visual_script/register_types.h b/modules/visual_script/register_types.h
index 2c0ee56268..4fb03bc227 100644
--- a/modules/visual_script/register_types.h
+++ b/modules/visual_script/register_types.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/visual_script/visual_script.cpp b/modules/visual_script/visual_script.cpp
index d1cf0f1dce..88012d2031 100644
--- a/modules/visual_script/visual_script.cpp
+++ b/modules/visual_script/visual_script.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -273,7 +273,9 @@ void VisualScript::_node_ports_changed(int p_id) {
Function &func = functions[function];
Ref<VisualScriptNode> vsn = func.nodes[p_id].node;
- if (OS::get_singleton()->get_main_loop() && OS::get_singleton()->get_main_loop()->cast_to<SceneTree>() && OS::get_singleton()->get_main_loop()->cast_to<SceneTree>()->is_editor_hint()) {
+ if (OS::get_singleton()->get_main_loop() &&
+ Object::cast_to<SceneTree>(OS::get_singleton()->get_main_loop()) &&
+ Engine::get_singleton()->is_editor_hint()) {
vsn->validate_input_default_values(); //force validate default values when editing on editor
}
@@ -336,7 +338,7 @@ void VisualScript::add_node(const StringName &p_func, int p_id, const Ref<Visual
Function &func = functions[p_func];
- if (p_node->cast_to<VisualScriptFunction>()) {
+ if (Object::cast_to<VisualScriptFunction>(*p_node)) {
//the function indeed
ERR_EXPLAIN("A function node already has been set here.");
ERR_FAIL_COND(func.function_id >= 0);
@@ -393,7 +395,7 @@ void VisualScript::remove_node(const StringName &p_func, int p_id) {
}
}
- if (func.nodes[p_id].node->cast_to<VisualScriptFunction>()) {
+ if (Object::cast_to<VisualScriptFunction>(func.nodes[p_id].node.ptr())) {
func.function_id = -1; //revert to invalid
}
@@ -1086,7 +1088,7 @@ int VisualScript::get_member_line(const StringName &p_member) const {
#ifdef TOOLS_ENABLED
if (has_function(p_member)) {
for (Map<int, Function::NodeData>::Element *E = functions[p_member].nodes.front(); E; E = E->next()) {
- if (E->get().node->cast_to<VisualScriptFunction>())
+ if (Object::cast_to<VisualScriptFunction>(E->get().node.ptr()))
return E->key();
}
}
@@ -1578,12 +1580,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));
@@ -1998,9 +2003,9 @@ void VisualScriptInstance::create(const Ref<VisualScript> &p_script, Object *p_o
max_input_args = 0;
max_output_args = 0;
- if (p_owner->cast_to<Node>()) {
+ if (Object::cast_to<Node>(p_owner)) {
//turn on these if they exist and base is a node
- Node *node = p_owner->cast_to<Node>();
+ Node *node = Object::cast_to<Node>(p_owner);
if (p_script->functions.has("_process"))
node->set_process(true);
if (p_script->functions.has("_fixed_process"))
@@ -2091,16 +2096,16 @@ void VisualScriptInstance::create(const Ref<VisualScript> &p_script, Object *p_o
}
}
- if (node->cast_to<VisualScriptLocalVar>() || node->cast_to<VisualScriptLocalVarSet>()) {
+ if (Object::cast_to<VisualScriptLocalVar>(node.ptr()) || Object::cast_to<VisualScriptLocalVarSet>(*node)) {
//working memory is shared only for this node, for the same variables
Ref<VisualScriptLocalVar> vslv = node;
StringName var_name;
- if (node->cast_to<VisualScriptLocalVar>())
- var_name = String(node->cast_to<VisualScriptLocalVar>()->get_var_name()).strip_edges();
+ if (Object::cast_to<VisualScriptLocalVar>(*node))
+ var_name = String(Object::cast_to<VisualScriptLocalVar>(*node)->get_var_name()).strip_edges();
else
- var_name = String(node->cast_to<VisualScriptLocalVarSet>()->get_var_name()).strip_edges();
+ var_name = String(Object::cast_to<VisualScriptLocalVarSet>(*node)->get_var_name()).strip_edges();
if (!local_var_indices.has(var_name)) {
local_var_indices[var_name] = function.max_stack;
diff --git a/modules/visual_script/visual_script.h b/modules/visual_script/visual_script.h
index b61b67a890..b2e7a6aa27 100644
--- a/modules/visual_script/visual_script.h
+++ b/modules/visual_script/visual_script.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/visual_script/visual_script_builtin_funcs.cpp b/modules/visual_script/visual_script_builtin_funcs.cpp
index 203e0bb483..2c8796820e 100644
--- a/modules/visual_script/visual_script_builtin_funcs.cpp
+++ b/modules/visual_script/visual_script_builtin_funcs.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -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_builtin_funcs.h b/modules/visual_script/visual_script_builtin_funcs.h
index 8e9c0eca76..97ab307039 100644
--- a/modules/visual_script/visual_script_builtin_funcs.h
+++ b/modules/visual_script/visual_script_builtin_funcs.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/visual_script/visual_script_editor.cpp b/modules/visual_script/visual_script_editor.cpp
index 0f6b47c56d..05ceb7a38f 100644
--- a/modules/visual_script/visual_script_editor.cpp
+++ b/modules/visual_script/visual_script_editor.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -73,7 +73,7 @@ protected:
if (argc == new_argc)
return true;
- undo_redo->create_action("Change Signal Arguments");
+ undo_redo->create_action(TTR("Change Signal Arguments"));
if (new_argc < argc) {
for (int i = new_argc; i < argc; i++) {
@@ -104,7 +104,7 @@ protected:
int old_type = script->custom_signal_get_argument_type(sig, idx);
int new_type = p_value;
- undo_redo->create_action("Change Argument Type");
+ undo_redo->create_action(TTR("Change Argument Type"));
undo_redo->add_do_method(script.ptr(), "custom_signal_set_argument_type", sig, idx, new_type);
undo_redo->add_undo_method(script.ptr(), "custom_signal_set_argument_type", sig, idx, old_type);
undo_redo->commit_action();
@@ -116,7 +116,7 @@ protected:
String old_name = script->custom_signal_get_argument_name(sig, idx);
String new_name = p_value;
- undo_redo->create_action("Change Argument name");
+ undo_redo->create_action(TTR("Change Argument name"));
undo_redo->add_do_method(script.ptr(), "custom_signal_set_argument_name", sig, idx, new_name);
undo_redo->add_undo_method(script.ptr(), "custom_signal_set_argument_name", sig, idx, old_name);
undo_redo->commit_action();
@@ -213,7 +213,7 @@ protected:
return false;
if (String(p_name) == "value") {
- undo_redo->create_action("Set Variable Default Value");
+ undo_redo->create_action(TTR("Set Variable Default Value"));
Variant current = script->get_variable_default_value(var);
undo_redo->add_do_method(script.ptr(), "set_variable_default_value", var, p_value);
undo_redo->add_undo_method(script.ptr(), "set_variable_default_value", var, current);
@@ -229,7 +229,7 @@ protected:
Dictionary dc = d.copy();
dc["type"] = p_value;
- undo_redo->create_action("Set Variable Type");
+ undo_redo->create_action(TTR("Set Variable Type"));
undo_redo->add_do_method(script.ptr(), "set_variable_info", var, dc);
undo_redo->add_undo_method(script.ptr(), "set_variable_info", var, d);
undo_redo->add_do_method(this, "_var_changed");
@@ -242,7 +242,7 @@ protected:
Dictionary dc = d.copy();
dc["hint"] = p_value;
- undo_redo->create_action("Set Variable Type");
+ undo_redo->create_action(TTR("Set Variable Type"));
undo_redo->add_do_method(script.ptr(), "set_variable_info", var, dc);
undo_redo->add_undo_method(script.ptr(), "set_variable_info", var, d);
undo_redo->add_do_method(this, "_var_changed");
@@ -255,7 +255,7 @@ protected:
Dictionary dc = d.copy();
dc["hint_string"] = p_value;
- undo_redo->create_action("Set Variable Type");
+ undo_redo->create_action(TTR("Set Variable Type"));
undo_redo->add_do_method(script.ptr(), "set_variable_info", var, dc);
undo_redo->add_undo_method(script.ptr(), "set_variable_info", var, d);
undo_redo->add_do_method(this, "_var_changed");
@@ -422,7 +422,7 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
for (int i = 0; i < graph->get_child_count(); i++) {
- if (graph->get_child(i)->cast_to<GraphNode>()) {
+ if (Object::cast_to<GraphNode>(graph->get_child(i))) {
memdelete(graph->get_child(i));
i--;
}
@@ -506,7 +506,7 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
gnode->set_show_close_button(true);
}
- if (node->cast_to<VisualScriptExpression>()) {
+ if (Object::cast_to<VisualScriptExpression>(*node)) {
LineEdit *line_edit = memnew(LineEdit);
line_edit->set_text(node->get_text());
@@ -520,7 +520,7 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
gnode->add_child(text);
}
- if (node->cast_to<VisualScriptComment>()) {
+ if (Object::cast_to<VisualScriptExpression>(*node)) {
Ref<VisualScriptComment> vsc = node;
gnode->set_comment(true);
gnode->set_resizeable(true);
@@ -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", "edited_script_changed");
+ undo_redo->add_undo_method(this, "emit_signal", "edited_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", "edited_script_changed");
+ undo_redo->add_undo_method(this, "emit_signal", "edited_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", "edited_script_changed");
+ undo_redo->add_undo_method(this, "emit_signal", "edited_script_changed");
undo_redo->commit_action();
return; //or crash because it will become invalid
@@ -964,7 +970,7 @@ void VisualScriptEditor::_override_pressed(int p_id) {
void VisualScriptEditor::_member_button(Object *p_item, int p_column, int p_button) {
- TreeItem *ti = p_item->cast_to<TreeItem>();
+ TreeItem *ti = Object::cast_to<TreeItem>(p_item);
TreeItem *root = members->get_root();
@@ -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", "edited_script_changed");
+ undo_redo->add_undo_method(this, "emit_signal", "edited_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", "edited_script_changed");
+ undo_redo->add_undo_method(this, "emit_signal", "edited_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", "edited_script_changed");
+ undo_redo->add_undo_method(this, "emit_signal", "edited_script_changed");
undo_redo->commit_action();
return; //or crash because it will become invalid
}
@@ -1106,8 +1117,8 @@ void VisualScriptEditor::_expression_text_changed(const String &p_text, int p_id
undo_redo->commit_action();
Node *node = graph->get_node(itos(p_id));
- if (node->cast_to<Control>())
- node->cast_to<Control>()->set_size(Vector2(1, 1)); //shrink if text is smaller
+ if (Object::cast_to<Control>(node))
+ Object::cast_to<Control>(node)->set_size(Vector2(1, 1)); //shrink if text is smaller
updating_graph = false;
}
@@ -1242,7 +1253,7 @@ void VisualScriptEditor::_on_nodes_delete() {
List<int> to_erase;
for (int i = 0; i < graph->get_child_count(); i++) {
- GraphNode *gn = graph->get_child(i)->cast_to<GraphNode>();
+ GraphNode *gn = Object::cast_to<GraphNode>(graph->get_child(i));
if (gn) {
if (gn->is_selected() && gn->is_close_button_visible()) {
to_erase.push_back(gn->get_name().operator String().to_int());
@@ -1253,7 +1264,7 @@ void VisualScriptEditor::_on_nodes_delete() {
if (to_erase.empty())
return;
- undo_redo->create_action("Remove VisualScript Nodes");
+ undo_redo->create_action(TTR("Remove VisualScript Nodes"));
for (List<int>::Element *F = to_erase.front(); F; F = F->next()) {
@@ -1291,7 +1302,7 @@ void VisualScriptEditor::_on_nodes_duplicate() {
List<int> to_duplicate;
for (int i = 0; i < graph->get_child_count(); i++) {
- GraphNode *gn = graph->get_child(i)->cast_to<GraphNode>();
+ GraphNode *gn = Object::cast_to<GraphNode>(graph->get_child(i));
if (gn) {
if (gn->is_selected() && gn->is_close_button_visible()) {
to_duplicate.push_back(gn->get_name().operator String().to_int());
@@ -1302,7 +1313,7 @@ void VisualScriptEditor::_on_nodes_duplicate() {
if (to_duplicate.empty())
return;
- undo_redo->create_action("Duplicate VisualScript Nodes");
+ undo_redo->create_action(TTR("Duplicate VisualScript Nodes"));
int idc = script->get_available_id() + 1;
Set<int> to_select;
@@ -1324,7 +1335,7 @@ void VisualScriptEditor::_on_nodes_duplicate() {
undo_redo->commit_action();
for (int i = 0; i < graph->get_child_count(); i++) {
- GraphNode *gn = graph->get_child(i)->cast_to<GraphNode>();
+ GraphNode *gn = Object::cast_to<GraphNode>(graph->get_child(i));
if (gn) {
int id = gn->get_name().operator String().to_int();
gn->set_selected(to_select.has(id));
@@ -1788,7 +1799,7 @@ void VisualScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da
if (!obj)
return;
- Node *node = obj->cast_to<Node>();
+ Node *node = Object::cast_to<Node>(obj);
Vector2 ofs = graph->get_scroll_ofs() + p_point;
if (graph->is_using_snap()) {
@@ -1907,7 +1918,7 @@ void VisualScriptEditor::_selected_method(const String &p_method) {
void VisualScriptEditor::_draw_color_over_button(Object *obj, Color p_color) {
- Button *button = obj->cast_to<Button>();
+ Button *button = Object::cast_to<Button>(obj);
if (!button)
return;
@@ -1926,7 +1937,7 @@ void VisualScriptEditor::_button_resource_previewed(const String &p_path, const
if (!obj)
return;
- Button *b = obj->cast_to<Button>();
+ Button *b = Object::cast_to<Button>(obj);
ERR_FAIL_COND(!b);
if (p_preview.is_null()) {
@@ -2039,9 +2050,7 @@ void VisualScriptEditor::set_edit_state(const Variant &p_state) {
void VisualScriptEditor::_center_on_node(int p_id) {
Node *n = graph->get_node(itos(p_id));
- if (!n)
- return;
- GraphNode *gn = n->cast_to<GraphNode>();
+ GraphNode *gn = Object::cast_to<GraphNode>(n);
if (gn) {
gn->set_selected(true);
Vector2 new_scroll = gn->get_offset() - graph->get_size() * 0.5 + gn->get_size() * 0.5;
@@ -2199,7 +2208,7 @@ void VisualScriptEditor::_change_base_type_callback() {
String bt = select_base_type->get_selected_type();
ERR_FAIL_COND(bt == String());
- undo_redo->create_action("Change Base Type");
+ undo_redo->create_action(TTR("Change Base Type"));
undo_redo->add_do_method(script.ptr(), "set_instance_base_type", bt);
undo_redo->add_undo_method(script.ptr(), "set_instance_base_type", script->get_instance_base_type());
undo_redo->add_do_method(this, "_update_members");
@@ -2247,7 +2256,7 @@ static bool _get_in_slot(const Ref<VisualScriptNode> &p_node, int p_slot, int &r
void VisualScriptEditor::_begin_node_move() {
- undo_redo->create_action("Move Node(s)");
+ undo_redo->create_action(TTR("Move Node(s)"));
}
void VisualScriptEditor::_end_node_move() {
@@ -2259,8 +2268,8 @@ void VisualScriptEditor::_move_node(String func, int p_id, const Vector2 &p_to)
if (func == String(edited_func)) {
Node *node = graph->get_node(itos(p_id));
- if (node && node->cast_to<GraphNode>())
- node->cast_to<GraphNode>()->set_offset(p_to);
+ if (Object::cast_to<GraphNode>(node))
+ Object::cast_to<GraphNode>(node)->set_offset(p_to);
}
script->set_node_pos(edited_func, p_id, p_to / EDSCALE);
}
@@ -2273,7 +2282,7 @@ void VisualScriptEditor::_node_moved(Vector2 p_from, Vector2 p_to, int p_id) {
void VisualScriptEditor::_remove_node(int p_id) {
- undo_redo->create_action("Remove VisualScript Node");
+ undo_redo->create_action(TTR("Remove VisualScript Node"));
undo_redo->add_do_method(script.ptr(), "remove_node", edited_func, p_id);
undo_redo->add_undo_method(script.ptr(), "add_node", edited_func, p_id, script->get_node(edited_func, p_id), script->get_node_pos(edited_func, p_id));
@@ -2334,7 +2343,7 @@ void VisualScriptEditor::_graph_connected(const String &p_from, int p_from_slot,
ERR_FAIL_COND(from_seq != to_seq);
- undo_redo->create_action("Connect Nodes");
+ undo_redo->create_action(TTR("Connect Nodes"));
if (from_seq) {
undo_redo->add_do_method(script.ptr(), "sequence_connect", edited_func, p_from.to_int(), from_port, p_to.to_int());
@@ -2387,7 +2396,7 @@ void VisualScriptEditor::_graph_disconnected(const String &p_from, int p_from_sl
ERR_FAIL_COND(from_seq != to_seq);
- undo_redo->create_action("Connect Nodes");
+ undo_redo->create_action(TTR("Connect Nodes"));
if (from_seq) {
undo_redo->add_do_method(script.ptr(), "sequence_disconnect", edited_func, p_from.to_int(), from_port, p_to.to_int());
@@ -2410,10 +2419,7 @@ void VisualScriptEditor::_graph_disconnected(const String &p_from, int p_from_sl
void VisualScriptEditor::_graph_connect_to_empty(const String &p_from, int p_from_slot, const Vector2 &p_release_pos) {
Node *node = graph->get_node(p_from);
- if (!node)
- return;
-
- GraphNode *gn = node->cast_to<GraphNode>();
+ GraphNode *gn = Object::cast_to<GraphNode>(node);
if (!gn)
return;
@@ -2680,21 +2686,21 @@ void VisualScriptEditor::_selected_connect_node_method_or_setget(const String &p
Ref<VisualScriptNode> vsn = script->get_node(edited_func, port_action_new_node);
- if (vsn->cast_to<VisualScriptFunctionCall>()) {
+ if (Object::cast_to<VisualScriptFunctionCall>(*vsn)) {
Ref<VisualScriptFunctionCall> vsfc = vsn;
vsfc->set_function(p_text);
script->data_connect(edited_func, port_action_node, port_action_output, port_action_new_node, 0);
}
- if (vsn->cast_to<VisualScriptPropertySet>()) {
+ if (Object::cast_to<VisualScriptPropertySet>(*vsn)) {
Ref<VisualScriptPropertySet> vsp = vsn;
vsp->set_property(p_text);
script->data_connect(edited_func, port_action_node, port_action_output, port_action_new_node, 0);
}
- if (vsn->cast_to<VisualScriptPropertyGet>()) {
+ if (Object::cast_to<VisualScriptPropertyGet>(*vsn)) {
Ref<VisualScriptPropertyGet> vsp = vsn;
vsp->set_property(p_text);
@@ -2705,13 +2711,19 @@ void VisualScriptEditor::_selected_connect_node_method_or_setget(const String &p
_update_graph_connections();
}
+void VisualScriptEditor::_cancel_connect_node_method_or_setget() {
+
+ script->remove_node(edited_func, port_action_new_node);
+ _update_graph();
+}
+
void VisualScriptEditor::_default_value_changed() {
Ref<VisualScriptNode> vsn = script->get_node(edited_func, editing_id);
if (vsn.is_null())
return;
- undo_redo->create_action("Change Input Value");
+ undo_redo->create_action(TTR("Change Input Value"));
undo_redo->add_do_method(vsn.ptr(), "set_default_input_value", editing_input, default_value_edit->get_variant());
undo_redo->add_undo_method(vsn.ptr(), "set_default_input_value", editing_input, vsn->get_default_input_value(editing_input));
@@ -2735,7 +2747,7 @@ void VisualScriptEditor::_default_value_edited(Node *p_button, int p_id, int p_i
existing = Variant::construct(pinfo.type, &existingp, 1, ce, false);
}
- default_value_edit->set_position(p_button->cast_to<Control>()->get_global_position() + Vector2(0, p_button->cast_to<Control>()->get_size().y));
+ default_value_edit->set_position(Object::cast_to<Control>(p_button)->get_global_position() + Vector2(0, Object::cast_to<Control>(p_button)->get_size().y));
default_value_edit->set_size(Size2(1, 1));
if (default_value_edit->edit(NULL, pinfo.name, pinfo.type, existing, pinfo.hint, pinfo.hint_string)) {
if (pinfo.hint == PROPERTY_HINT_MULTILINE_TEXT)
@@ -2801,9 +2813,7 @@ void VisualScriptEditor::_comment_node_resized(const Vector2 &p_new_size, int p_
return;
Node *node = graph->get_node(itos(p_node));
- if (!node)
- return;
- GraphNode *gn = node->cast_to<GraphNode>();
+ GraphNode *gn = Object::cast_to<GraphNode>(node);
if (!gn)
return;
@@ -2832,7 +2842,7 @@ void VisualScriptEditor::_menu_option(int p_what) {
List<String> reselect;
for (int i = 0; i < graph->get_child_count(); i++) {
- GraphNode *gn = graph->get_child(i)->cast_to<GraphNode>();
+ GraphNode *gn = Object::cast_to<GraphNode>(graph->get_child(i));
if (gn) {
if (gn->is_selected()) {
int id = String(gn->get_name()).to_int();
@@ -2848,7 +2858,7 @@ void VisualScriptEditor::_menu_option(int p_what) {
_update_graph();
for (List<String>::Element *E = reselect.front(); E; E = E->next()) {
- GraphNode *gn = graph->get_node(E->get())->cast_to<GraphNode>();
+ GraphNode *gn = Object::cast_to<GraphNode>(graph->get_node(E->get()));
gn->set_selected(true);
}
@@ -2869,14 +2879,14 @@ void VisualScriptEditor::_menu_option(int p_what) {
clipboard->sequence_connections.clear();
for (int i = 0; i < graph->get_child_count(); i++) {
- GraphNode *gn = graph->get_child(i)->cast_to<GraphNode>();
+ GraphNode *gn = Object::cast_to<GraphNode>(graph->get_child(i));
if (gn) {
if (gn->is_selected()) {
int id = String(gn->get_name()).to_int();
Ref<VisualScriptNode> node = script->get_node(edited_func, id);
- if (node->cast_to<VisualScriptFunction>()) {
- EditorNode::get_singleton()->show_warning("Can't copy the function node.");
+ if (Object::cast_to<VisualScriptFunction>(*node)) {
+ EditorNode::get_singleton()->show_warning(TTR("Can't copy the function node."));
return;
}
if (node.is_valid()) {
@@ -2924,13 +2934,13 @@ void VisualScriptEditor::_menu_option(int p_what) {
break;
if (clipboard->nodes.empty()) {
- EditorNode::get_singleton()->show_warning("Clipboard is empty!");
+ EditorNode::get_singleton()->show_warning(TTR("Clipboard is empty!"));
break;
}
Map<int, int> remap;
- undo_redo->create_action("Paste VisualScript Nodes");
+ undo_redo->create_action(TTR("Paste VisualScript Nodes"));
int idc = script->get_available_id() + 1;
Set<int> to_select;
@@ -2983,7 +2993,7 @@ void VisualScriptEditor::_menu_option(int p_what) {
undo_redo->commit_action();
for (int i = 0; i < graph->get_child_count(); i++) {
- GraphNode *gn = graph->get_child(i)->cast_to<GraphNode>();
+ GraphNode *gn = Object::cast_to<GraphNode>(graph->get_child(i));
if (gn) {
int id = gn->get_name().operator String().to_int();
gn->set_selected(to_select.has(id));
@@ -3156,6 +3166,7 @@ void VisualScriptEditor::_bind_methods() {
ClassDB::bind_method("_button_resource_previewed", &VisualScriptEditor::_button_resource_previewed);
ClassDB::bind_method("_port_action_menu", &VisualScriptEditor::_port_action_menu);
ClassDB::bind_method("_selected_connect_node_method_or_setget", &VisualScriptEditor::_selected_connect_node_method_or_setget);
+ ClassDB::bind_method("_cancel_connect_node_method_or_setget", &VisualScriptEditor::_cancel_connect_node_method_or_setget);
ClassDB::bind_method("_expression_text_changed", &VisualScriptEditor::_expression_text_changed);
ClassDB::bind_method("get_drag_data_fw", &VisualScriptEditor::get_drag_data_fw);
@@ -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);
@@ -3268,7 +3279,6 @@ VisualScriptEditor::VisualScriptEditor() {
select_func_text->set_valign(Label::VALIGN_CENTER);
select_func_text->set_h_size_flags(SIZE_EXPAND_FILL);
add_child(select_func_text);
- graph->set_area_as_parent_rect();
hint_text = memnew(Label);
hint_text->set_anchor_and_margin(MARGIN_TOP, ANCHOR_END, -100);
@@ -3354,6 +3364,7 @@ VisualScriptEditor::VisualScriptEditor() {
new_connect_node_select = memnew(PropertySelector);
add_child(new_connect_node_select);
new_connect_node_select->connect("selected", this, "_selected_connect_node_method_or_setget");
+ new_connect_node_select->get_cancel()->connect("pressed", this, "_cancel_connect_node_method_or_setget");
port_action_popup = memnew(PopupMenu);
add_child(port_action_popup);
@@ -3375,7 +3386,7 @@ VisualScriptEditor::~VisualScriptEditor() {
static ScriptEditorBase *create_editor(const Ref<Script> &p_script) {
- if (p_script->cast_to<VisualScript>()) {
+ if (Object::cast_to<VisualScript>(*p_script)) {
return memnew(VisualScriptEditor);
}
diff --git a/modules/visual_script/visual_script_editor.h b/modules/visual_script/visual_script_editor.h
index fee4e27bd5..dd051ef8e4 100644
--- a/modules/visual_script/visual_script_editor.h
+++ b/modules/visual_script/visual_script_editor.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -176,6 +176,7 @@ class VisualScriptEditor : public ScriptEditorBase {
int port_action_new_node;
void _port_action_menu(int p_option);
void _selected_connect_node_method_or_setget(const String &p_text);
+ void _cancel_connect_node_method_or_setget();
int error_line;
diff --git a/modules/visual_script/visual_script_expression.cpp b/modules/visual_script/visual_script_expression.cpp
index 78b70934c0..6bd052fe26 100644
--- a/modules/visual_script/visual_script_expression.cpp
+++ b/modules/visual_script/visual_script_expression.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -585,7 +585,6 @@ Error VisualScriptExpression::_get_token(Token &r_token) {
r_token.type = TK_BASIC_TYPE;
r_token.value = i;
return OK;
- break;
}
}
diff --git a/modules/visual_script/visual_script_expression.h b/modules/visual_script/visual_script_expression.h
index 4a9f59ebc3..2636e79842 100644
--- a/modules/visual_script/visual_script_expression.h
+++ b/modules/visual_script/visual_script_expression.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/visual_script/visual_script_flow_control.cpp b/modules/visual_script/visual_script_flow_control.cpp
index 77f3111d94..59d9540239 100644
--- a/modules/visual_script/visual_script_flow_control.cpp
+++ b/modules/visual_script/visual_script_flow_control.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/visual_script/visual_script_flow_control.h b/modules/visual_script/visual_script_flow_control.h
index d27fd47f84..380eb76c45 100644
--- a/modules/visual_script/visual_script_flow_control.h
+++ b/modules/visual_script/visual_script_flow_control.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/visual_script/visual_script_func_nodes.cpp b/modules/visual_script/visual_script_func_nodes.cpp
index afdf50027e..5fcc5b0ad9 100644
--- a/modules/visual_script/visual_script_func_nodes.cpp
+++ b/modules/visual_script/visual_script_func_nodes.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -85,10 +85,7 @@ Node *VisualScriptFunctionCall::_get_base_node() const {
return NULL;
MainLoop *main_loop = OS::get_singleton()->get_main_loop();
- if (!main_loop)
- return NULL;
-
- SceneTree *scene_tree = main_loop->cast_to<SceneTree>();
+ SceneTree *scene_tree = Object::cast_to<SceneTree>(main_loop);
if (!scene_tree)
return NULL;
@@ -747,10 +744,10 @@ void VisualScriptFunctionCall::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "validate"), "set_validate", "get_validate");
ADD_PROPERTY(PropertyInfo(Variant::INT, "rpc_call_mode", PROPERTY_HINT_ENUM, "Disabled,Reliable,Unreliable,ReliableToID,UnreliableToID"), "set_rpc_call_mode", "get_rpc_call_mode"); //when set, if loaded properly, will override argument count.
- BIND_CONSTANT(CALL_MODE_SELF);
- BIND_CONSTANT(CALL_MODE_NODE_PATH);
- BIND_CONSTANT(CALL_MODE_INSTANCE);
- BIND_CONSTANT(CALL_MODE_BASIC_TYPE);
+ BIND_ENUM_CONSTANT(CALL_MODE_SELF);
+ BIND_ENUM_CONSTANT(CALL_MODE_NODE_PATH);
+ BIND_ENUM_CONSTANT(CALL_MODE_INSTANCE);
+ BIND_ENUM_CONSTANT(CALL_MODE_BASIC_TYPE);
}
class VisualScriptNodeInstanceFunctionCall : public VisualScriptNodeInstance {
@@ -776,7 +773,7 @@ public:
if (!p_base)
return false;
- Node *node = p_base->cast_to<Node>();
+ Node *node = Object::cast_to<Node>(p_base);
if (!node)
return false;
@@ -817,7 +814,7 @@ public:
} break;
case VisualScriptFunctionCall::CALL_MODE_NODE_PATH: {
- Node *node = instance->get_owner_ptr()->cast_to<Node>();
+ Node *node = Object::cast_to<Node>(instance->get_owner_ptr());
if (!node) {
r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
r_error_str = "Base object is not a Node!";
@@ -825,7 +822,7 @@ public:
}
Node *another = node->get_node(node_path);
- if (!node) {
+ if (!another) {
r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
r_error_str = "Path does not lead Node!";
return 0;
@@ -961,10 +958,8 @@ Node *VisualScriptPropertySet::_get_base_node() const {
return NULL;
MainLoop *main_loop = OS::get_singleton()->get_main_loop();
- if (!main_loop)
- return NULL;
- SceneTree *scene_tree = main_loop->cast_to<SceneTree>();
+ SceneTree *scene_tree = Object::cast_to<SceneTree>(main_loop);
if (!scene_tree)
return NULL;
@@ -1159,12 +1154,10 @@ String VisualScriptPropertySet::get_base_script() const {
void VisualScriptPropertySet::_update_cache() {
- if (!OS::get_singleton()->get_main_loop())
- return;
- if (!OS::get_singleton()->get_main_loop()->cast_to<SceneTree>())
+ if (!Object::cast_to<SceneTree>(OS::get_singleton()->get_main_loop()))
return;
- if (!OS::get_singleton()->get_main_loop()->cast_to<SceneTree>()->is_editor_hint()) //only update cache if editor exists, it's pointless otherwise
+ if (!Engine::get_singleton()->is_editor_hint()) //only update cache if editor exists, it's pointless otherwise
return;
if (call_mode == CALL_MODE_BASIC_TYPE) {
@@ -1490,9 +1483,10 @@ void VisualScriptPropertySet::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::STRING, "property"), "set_property", "get_property");
ADD_PROPERTY(PropertyInfo(Variant::STRING, "index"), "set_index", "get_index");
ADD_PROPERTY(PropertyInfo(Variant::INT, "assign_op", PROPERTY_HINT_ENUM, "Assign,Add,Sub,Mul,Div,Mod,ShiftLeft,ShiftRight,BitAnd,BitOr,Bitxor"), "set_assign_op", "get_assign_op");
- BIND_CONSTANT(CALL_MODE_SELF);
- BIND_CONSTANT(CALL_MODE_NODE_PATH);
- BIND_CONSTANT(CALL_MODE_INSTANCE);
+
+ BIND_ENUM_CONSTANT(CALL_MODE_SELF);
+ BIND_ENUM_CONSTANT(CALL_MODE_NODE_PATH);
+ BIND_ENUM_CONSTANT(CALL_MODE_INSTANCE);
}
class VisualScriptNodeInstancePropertySet : public VisualScriptNodeInstance {
@@ -1594,7 +1588,7 @@ public:
} break;
case VisualScriptPropertySet::CALL_MODE_NODE_PATH: {
- Node *node = instance->get_owner_ptr()->cast_to<Node>();
+ Node *node = Object::cast_to<Node>(instance->get_owner_ptr());
if (!node) {
r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
r_error_str = "Base object is not a Node!";
@@ -1602,7 +1596,7 @@ public:
}
Node *another = node->get_node(node_path);
- if (!node) {
+ if (!another) {
r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
r_error_str = "Path does not lead Node!";
return 0;
@@ -1729,10 +1723,8 @@ Node *VisualScriptPropertyGet::_get_base_node() const {
return NULL;
MainLoop *main_loop = OS::get_singleton()->get_main_loop();
- if (!main_loop)
- return NULL;
- SceneTree *scene_tree = main_loop->cast_to<SceneTree>();
+ SceneTree *scene_tree = Object::cast_to<SceneTree>(main_loop);
if (!scene_tree)
return NULL;
@@ -2202,9 +2194,9 @@ void VisualScriptPropertyGet::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::STRING, "property"), "set_property", "get_property");
ADD_PROPERTY(PropertyInfo(Variant::STRING, "index", PROPERTY_HINT_ENUM), "set_index", "get_index");
- BIND_CONSTANT(CALL_MODE_SELF);
- BIND_CONSTANT(CALL_MODE_NODE_PATH);
- BIND_CONSTANT(CALL_MODE_INSTANCE);
+ BIND_ENUM_CONSTANT(CALL_MODE_SELF);
+ BIND_ENUM_CONSTANT(CALL_MODE_NODE_PATH);
+ BIND_ENUM_CONSTANT(CALL_MODE_INSTANCE);
}
class VisualScriptNodeInstancePropertyGet : public VisualScriptNodeInstance {
@@ -2241,7 +2233,7 @@ public:
} break;
case VisualScriptPropertyGet::CALL_MODE_NODE_PATH: {
- Node *node = instance->get_owner_ptr()->cast_to<Node>();
+ Node *node = Object::cast_to<Node>(instance->get_owner_ptr());
if (!node) {
r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
r_error_str = RTR("Base object is not a Node!");
@@ -2249,7 +2241,7 @@ public:
}
Node *another = node->get_node(node_path);
- if (!node) {
+ if (!another) {
r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
r_error_str = RTR("Path does not lead Node!");
return 0;
diff --git a/modules/visual_script/visual_script_func_nodes.h b/modules/visual_script/visual_script_func_nodes.h
index 3b38d0d08f..a9a0bd083f 100644
--- a/modules/visual_script/visual_script_func_nodes.h
+++ b/modules/visual_script/visual_script_func_nodes.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/visual_script/visual_script_nodes.cpp b/modules/visual_script/visual_script_nodes.cpp
index 4f9cd4a33b..1decc004ab 100644
--- a/modules/visual_script/visual_script_nodes.cpp
+++ b/modules/visual_script/visual_script_nodes.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -2079,7 +2079,7 @@ public:
virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Variant::CallError &r_error, String &r_error_str) {
- Node *node = instance->get_owner_ptr()->cast_to<Node>();
+ Node *node = Object::cast_to<Node>(instance->get_owner_ptr());
if (!node) {
r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
r_error_str = "Base object is not a Node!";
@@ -2087,7 +2087,7 @@ public:
}
Node *another = node->get_node(path);
- if (!node) {
+ if (!another) {
r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
r_error_str = "Path does not lead Node!";
return 0;
@@ -2143,10 +2143,7 @@ VisualScriptSceneNode::TypeGuess VisualScriptSceneNode::guess_output_type(TypeGu
return tg;
MainLoop *main_loop = OS::get_singleton()->get_main_loop();
- if (!main_loop)
- return tg;
-
- SceneTree *scene_tree = main_loop->cast_to<SceneTree>();
+ SceneTree *scene_tree = Object::cast_to<SceneTree>(main_loop);
if (!scene_tree)
return tg;
@@ -2181,10 +2178,7 @@ void VisualScriptSceneNode::_validate_property(PropertyInfo &property) const {
return;
MainLoop *main_loop = OS::get_singleton()->get_main_loop();
- if (!main_loop)
- return;
-
- SceneTree *scene_tree = main_loop->cast_to<SceneTree>();
+ SceneTree *scene_tree = Object::cast_to<SceneTree>(main_loop);
if (!scene_tree)
return;
@@ -2274,7 +2268,7 @@ public:
virtual int step(const Variant **p_inputs, Variant **p_outputs, StartMode p_start_mode, Variant *p_working_mem, Variant::CallError &r_error, String &r_error_str) {
- Node *node = instance->get_owner_ptr()->cast_to<Node>();
+ Node *node = Object::cast_to<Node>(instance->get_owner_ptr());
if (!node) {
r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
r_error_str = "Base object is not a Node!";
@@ -2708,13 +2702,16 @@ void VisualScriptCustomNode::_bind_methods() {
BIND_VMETHOD(MethodInfo(Variant::STRING, "_get_category"));
BIND_VMETHOD(MethodInfo(Variant::INT, "_get_working_memory_size"));
- BIND_VMETHOD(MethodInfo(Variant::NIL, "_step:Variant", PropertyInfo(Variant::ARRAY, "inputs"), PropertyInfo(Variant::ARRAY, "outputs"), PropertyInfo(Variant::INT, "start_mode"), PropertyInfo(Variant::ARRAY, "working_mem")));
+
+ MethodInfo stepmi(Variant::NIL, "_step", PropertyInfo(Variant::ARRAY, "inputs"), PropertyInfo(Variant::ARRAY, "outputs"), PropertyInfo(Variant::INT, "start_mode"), PropertyInfo(Variant::ARRAY, "working_mem"));
+ stepmi.return_val.usage |= PROPERTY_USAGE_NIL_IS_VARIANT;
+ BIND_VMETHOD(stepmi);
ClassDB::bind_method(D_METHOD("_script_changed"), &VisualScriptCustomNode::_script_changed);
- BIND_CONSTANT(START_MODE_BEGIN_SEQUENCE);
- BIND_CONSTANT(START_MODE_CONTINUE_SEQUENCE);
- BIND_CONSTANT(START_MODE_RESUME_YIELD);
+ BIND_ENUM_CONSTANT(START_MODE_BEGIN_SEQUENCE);
+ BIND_ENUM_CONSTANT(START_MODE_CONTINUE_SEQUENCE);
+ BIND_ENUM_CONSTANT(START_MODE_RESUME_YIELD);
BIND_CONSTANT(STEP_PUSH_STACK_BIT);
BIND_CONSTANT(STEP_GO_BACK_BIT);
@@ -2845,7 +2842,9 @@ VisualScriptNodeInstance *VisualScriptSubCall::instance(VisualScriptInstance *p_
void VisualScriptSubCall::_bind_methods() {
- BIND_VMETHOD(MethodInfo(Variant::NIL, "_subcall:Variant", PropertyInfo(Variant::NIL, "arguments:Variant")));
+ MethodInfo scmi(Variant::NIL, "_subcall", PropertyInfo(Variant::NIL, "arguments"));
+ scmi.return_val.usage |= PROPERTY_USAGE_NIL_IS_VARIANT;
+ BIND_VMETHOD(scmi);
}
VisualScriptSubCall::VisualScriptSubCall() {
diff --git a/modules/visual_script/visual_script_nodes.h b/modules/visual_script/visual_script_nodes.h
index 6ce906efe0..694fb96cfa 100644
--- a/modules/visual_script/visual_script_nodes.h
+++ b/modules/visual_script/visual_script_nodes.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -727,6 +727,8 @@ public:
VisualScriptCustomNode();
};
+VARIANT_ENUM_CAST(VisualScriptCustomNode::StartMode);
+
class VisualScriptSubCall : public VisualScriptNode {
GDCLASS(VisualScriptSubCall, VisualScriptNode)
diff --git a/modules/visual_script/visual_script_yield_nodes.cpp b/modules/visual_script/visual_script_yield_nodes.cpp
index 2e111511b7..4b8e17421b 100644
--- a/modules/visual_script/visual_script_yield_nodes.cpp
+++ b/modules/visual_script/visual_script_yield_nodes.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -105,7 +105,7 @@ public:
} else {
//yield
- SceneTree *tree = OS::get_singleton()->get_main_loop()->cast_to<SceneTree>();
+ SceneTree *tree = Object::cast_to<SceneTree>(OS::get_singleton()->get_main_loop());
if (!tree) {
r_error_str = "Main Loop is not SceneTree";
r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
@@ -189,9 +189,9 @@ void VisualScriptYield::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::INT, "mode", PROPERTY_HINT_ENUM, "Frame,FixedFrame,Time", PROPERTY_USAGE_NOEDITOR), "set_yield_mode", "get_yield_mode");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "wait_time"), "set_wait_time", "get_wait_time");
- BIND_CONSTANT(YIELD_FRAME);
- BIND_CONSTANT(YIELD_FIXED_FRAME);
- BIND_CONSTANT(YIELD_WAIT);
+ BIND_ENUM_CONSTANT(YIELD_FRAME);
+ BIND_ENUM_CONSTANT(YIELD_FIXED_FRAME);
+ BIND_ENUM_CONSTANT(YIELD_WAIT);
}
VisualScriptYield::VisualScriptYield() {
@@ -252,10 +252,7 @@ Node *VisualScriptYieldSignal::_get_base_node() const {
return NULL;
MainLoop *main_loop = OS::get_singleton()->get_main_loop();
- if (!main_loop)
- return NULL;
-
- SceneTree *scene_tree = main_loop->cast_to<SceneTree>();
+ SceneTree *scene_tree = Object::cast_to<SceneTree>(main_loop);
if (!scene_tree)
return NULL;
@@ -493,9 +490,9 @@ void VisualScriptYieldSignal::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "node_path", PROPERTY_HINT_NODE_PATH_TO_EDITED_NODE), "set_base_path", "get_base_path");
ADD_PROPERTY(PropertyInfo(Variant::STRING, "signal"), "set_signal", "get_signal");
- BIND_CONSTANT(CALL_MODE_SELF);
- BIND_CONSTANT(CALL_MODE_NODE_PATH);
- BIND_CONSTANT(CALL_MODE_INSTANCE);
+ BIND_ENUM_CONSTANT(CALL_MODE_SELF);
+ BIND_ENUM_CONSTANT(CALL_MODE_NODE_PATH);
+ BIND_ENUM_CONSTANT(CALL_MODE_INSTANCE);
}
class VisualScriptNodeInstanceYieldSignal : public VisualScriptNodeInstance {
@@ -530,7 +527,7 @@ public:
} break;
case VisualScriptYieldSignal::CALL_MODE_NODE_PATH: {
- Node *node = instance->get_owner_ptr()->cast_to<Node>();
+ Node *node = Object::cast_to<Node>(instance->get_owner_ptr());
if (!node) {
r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
r_error_str = "Base object is not a Node!";
@@ -538,7 +535,7 @@ public:
}
Node *another = node->get_node(node_path);
- if (!node) {
+ if (!another) {
r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
r_error_str = "Path does not lead Node!";
return 0;
diff --git a/modules/visual_script/visual_script_yield_nodes.h b/modules/visual_script/visual_script_yield_nodes.h
index 638b7b5b41..d074962471 100644
--- a/modules/visual_script/visual_script_yield_nodes.h
+++ b/modules/visual_script/visual_script_yield_nodes.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/vorbis/audio_stream_ogg_vorbis.cpp b/modules/vorbis/audio_stream_ogg_vorbis.cpp
index 1b10637fdc..6389c286c2 100644
--- a/modules/vorbis/audio_stream_ogg_vorbis.cpp
+++ b/modules/vorbis/audio_stream_ogg_vorbis.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/vorbis/audio_stream_ogg_vorbis.h b/modules/vorbis/audio_stream_ogg_vorbis.h
index 519ceaaea1..03b3726b52 100644
--- a/modules/vorbis/audio_stream_ogg_vorbis.h
+++ b/modules/vorbis/audio_stream_ogg_vorbis.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/vorbis/register_types.cpp b/modules/vorbis/register_types.cpp
index d9865072b9..270a58e7fe 100644
--- a/modules/vorbis/register_types.cpp
+++ b/modules/vorbis/register_types.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/vorbis/register_types.h b/modules/vorbis/register_types.h
index e7cde7a66c..db317e9f6a 100644
--- a/modules/vorbis/register_types.h
+++ b/modules/vorbis/register_types.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/webm/register_types.cpp b/modules/webm/register_types.cpp
index c234f81097..892d1b8420 100644
--- a/modules/webm/register_types.cpp
+++ b/modules/webm/register_types.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/webm/register_types.h b/modules/webm/register_types.h
index cf412e601e..94ff7de739 100644
--- a/modules/webm/register_types.h
+++ b/modules/webm/register_types.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/webm/video_stream_webm.cpp b/modules/webm/video_stream_webm.cpp
index 72f10b4f45..26344877de 100644
--- a/modules/webm/video_stream_webm.cpp
+++ b/modules/webm/video_stream_webm.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/webm/video_stream_webm.h b/modules/webm/video_stream_webm.h
index b2e88347aa..a48a6c6b9a 100644
--- a/modules/webm/video_stream_webm.h
+++ b/modules/webm/video_stream_webm.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/webp/image_loader_webp.cpp b/modules/webp/image_loader_webp.cpp
index 87c2e811b3..8fe2db9e27 100644
--- a/modules/webp/image_loader_webp.cpp
+++ b/modules/webp/image_loader_webp.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -115,7 +115,7 @@ static Ref<Image> _webp_lossy_unpack(const PoolVector<uint8_t> &p_buffer) {
return img;
}
-Error ImageLoaderWEBP::load_image(Ref<Image> p_image, FileAccess *f, bool p_force_linear) {
+Error ImageLoaderWEBP::load_image(Ref<Image> p_image, FileAccess *f, bool p_force_linear, float p_scale) {
uint32_t size = f->get_len();
PoolVector<uint8_t> src_image;
diff --git a/modules/webp/image_loader_webp.h b/modules/webp/image_loader_webp.h
index 1ac2196a71..f7ef210458 100644
--- a/modules/webp/image_loader_webp.h
+++ b/modules/webp/image_loader_webp.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
@@ -38,7 +38,7 @@
class ImageLoaderWEBP : public ImageFormatLoader {
public:
- virtual Error load_image(Ref<Image> p_image, FileAccess *f, bool p_force_linear);
+ virtual Error load_image(Ref<Image> p_image, FileAccess *f, bool p_force_linear, float p_scale);
virtual void get_recognized_extensions(List<String> *p_extensions) const;
ImageLoaderWEBP();
};
diff --git a/modules/webp/register_types.cpp b/modules/webp/register_types.cpp
index 6e29986740..95e5cd105d 100644
--- a/modules/webp/register_types.cpp
+++ b/modules/webp/register_types.cpp
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
diff --git a/modules/webp/register_types.h b/modules/webp/register_types.h
index d0aa148079..7ec926c572 100644
--- a/modules/webp/register_types.h
+++ b/modules/webp/register_types.h
@@ -3,7 +3,7 @@
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
-/* http://www.godotengine.org */
+/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */