summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--SConstruct9
-rw-r--r--core/global_constants.cpp2
-rw-r--r--core/helper/math_fieldwise.cpp8
-rw-r--r--core/io/marshalls.cpp12
-rw-r--r--core/io/resource_format_binary.cpp12
-rw-r--r--core/math/aabb.cpp (renamed from core/math/rect3.cpp)52
-rw-r--r--core/math/aabb.h (renamed from core/math/rect3.h)54
-rw-r--r--core/math/bsp_tree.cpp6
-rw-r--r--core/math/bsp_tree.h10
-rw-r--r--core/math/camera_matrix.cpp2
-rw-r--r--core/math/camera_matrix.h2
-rw-r--r--core/math/face3.cpp4
-rw-r--r--core/math/face3.h14
-rw-r--r--core/math/geometry.cpp4
-rw-r--r--core/math/octree.h38
-rw-r--r--core/math/quick_hull.cpp2
-rw-r--r--core/math/quick_hull.h2
-rw-r--r--core/math/transform.h14
-rw-r--r--core/math/triangle_mesh.cpp4
-rw-r--r--core/math/triangle_mesh.h4
-rw-r--r--core/method_ptrcall.h2
-rw-r--r--core/packed_data_container.cpp2
-rw-r--r--core/print_string.cpp20
-rw-r--r--core/print_string.h3
-rw-r--r--core/script_debugger_remote.cpp2
-rw-r--r--core/script_debugger_remote.h2
-rw-r--r--core/type_info.h2
-rw-r--r--core/ustring.cpp2
-rw-r--r--core/variant.cpp58
-rw-r--r--core/variant.h10
-rw-r--r--core/variant_call.cpp98
-rw-r--r--core/variant_op.cpp60
-rw-r--r--core/variant_parser.cpp10
-rw-r--r--doc/classes/@GDScript.xml4
-rw-r--r--doc/classes/@GlobalScope.xml4
-rw-r--r--doc/classes/AABB.xml (renamed from doc/classes/Rect3.xml)62
-rw-r--r--doc/classes/ArrayMesh.xml4
-rw-r--r--doc/classes/Control.xml36
-rw-r--r--doc/classes/EditorSpatialGizmo.xml2
-rw-r--r--doc/classes/GIProbeData.xml6
-rw-r--r--doc/classes/MultiMesh.xml6
-rw-r--r--doc/classes/Nil.xml2
-rw-r--r--doc/classes/Particles.xml8
-rw-r--r--doc/classes/RichTextLabel.xml51
-rw-r--r--doc/classes/String.xml4
-rw-r--r--doc/classes/VisibilityNotifier.xml6
-rw-r--r--doc/classes/VisualInstance.xml4
-rw-r--r--doc/classes/VisualServer.xml6
-rw-r--r--doc/tools/makerst.py10
-rw-r--r--drivers/gles3/rasterizer_canvas_gles3.cpp1
-rw-r--r--drivers/gles3/rasterizer_storage_gles3.cpp118
-rw-r--r--drivers/gles3/rasterizer_storage_gles3.h46
-rw-r--r--drivers/gles3/shader_compiler_gles3.cpp4
-rw-r--r--editor/SCsub14
-rw-r--r--editor/animation_editor.cpp13
-rw-r--r--editor/connections_dialog.cpp4
-rw-r--r--editor/create_dialog.cpp9
-rw-r--r--editor/doc/doc_dump.cpp2
-rw-r--r--editor/editor_node.cpp29
-rw-r--r--editor/editor_node.h4
-rw-r--r--editor/editor_plugin.cpp10
-rw-r--r--editor/editor_settings.cpp3
-rw-r--r--editor/filesystem_dock.cpp16
-rw-r--r--editor/filesystem_dock.h2
-rw-r--r--editor/icons/icon_texture_button.svg4
-rw-r--r--editor/icons/icon_texture_rect.svg3
-rw-r--r--editor/import/resource_importer_scene.cpp89
-rw-r--r--editor/plugins/collision_polygon_editor_plugin.cpp2
-rw-r--r--editor/plugins/editor_preview_plugins.cpp4
-rw-r--r--editor/plugins/mesh_editor_plugin.cpp2
-rw-r--r--editor/plugins/particles_editor_plugin.cpp8
-rw-r--r--editor/plugins/script_text_editor.cpp2
-rw-r--r--editor/plugins/spatial_editor_plugin.cpp23
-rw-r--r--editor/plugins/spatial_editor_plugin.h10
-rw-r--r--editor/property_editor.cpp24
-rw-r--r--editor/scene_tree_dock.cpp61
-rw-r--r--editor/scene_tree_dock.h10
-rw-r--r--editor/spatial_editor_gizmos.cpp30
-rw-r--r--editor/spatial_editor_gizmos.h4
-rw-r--r--main/main.cpp3
-rw-r--r--main/tests/test_gdscript.cpp298
-rw-r--r--misc/dist/html/default.html2
-rw-r--r--modules/gdnative/SCsub43
-rw-r--r--modules/gdnative/gdnative/aabb.cpp217
-rw-r--r--modules/gdnative/gdnative/rect3.cpp217
-rw-r--r--modules/gdnative/gdnative/transform.cpp16
-rw-r--r--modules/gdnative/gdnative/variant.cpp12
-rw-r--r--modules/gdnative/gdnative_api.json146
-rw-r--r--modules/gdnative/include/gdnative/aabb.h117
-rw-r--r--modules/gdnative/include/gdnative/gdnative.h4
-rw-r--r--modules/gdnative/include/gdnative/rect3.h117
-rw-r--r--modules/gdnative/include/gdnative/string.h1
-rw-r--r--modules/gdnative/include/gdnative/transform.h4
-rw-r--r--modules/gdnative/include/gdnative/variant.h8
-rw-r--r--modules/gdnative/register_types.cpp2
-rw-r--r--modules/gdscript/config.py4
-rw-r--r--modules/gdscript/doc_classes/GDScriptFunctionState.xml (renamed from modules/gdscript/doc_classes/GDFunctionState.xml)4
-rw-r--r--modules/gdscript/doc_classes/GDScriptNativeClass.xml (renamed from modules/gdscript/doc_classes/GDNativeClass.xml)2
-rw-r--r--modules/gdscript/gdscript.cpp (renamed from modules/gdscript/gd_script.cpp)128
-rw-r--r--modules/gdscript/gdscript.h (renamed from modules/gdscript/gd_script.h)63
-rw-r--r--modules/gdscript/gdscript_compiler.cpp (renamed from modules/gdscript/gd_compiler.cpp)557
-rw-r--r--modules/gdscript/gdscript_compiler.h (renamed from modules/gdscript/gd_compiler.h)46
-rw-r--r--modules/gdscript/gdscript_editor.cpp (renamed from modules/gdscript/gd_editor.cpp)460
-rw-r--r--modules/gdscript/gdscript_function.cpp (renamed from modules/gdscript/gd_function.cpp)78
-rw-r--r--modules/gdscript/gdscript_function.h (renamed from modules/gdscript/gd_function.h)40
-rw-r--r--modules/gdscript/gdscript_functions.cpp (renamed from modules/gdscript/gd_functions.cpp)21
-rw-r--r--modules/gdscript/gdscript_functions.h (renamed from modules/gdscript/gd_functions.h)10
-rw-r--r--modules/gdscript/gdscript_parser.cpp (renamed from modules/gdscript/gd_parser.cpp)695
-rw-r--r--modules/gdscript/gdscript_parser.h (renamed from modules/gdscript/gd_parser.h)22
-rw-r--r--modules/gdscript/gdscript_tokenizer.cpp (renamed from modules/gdscript/gd_tokenizer.cpp)207
-rw-r--r--modules/gdscript/gdscript_tokenizer.h (renamed from modules/gdscript/gd_tokenizer.h)30
-rw-r--r--modules/gdscript/register_types.cpp5
-rw-r--r--modules/gridmap/grid_map.cpp1
-rw-r--r--modules/gridmap/grid_map_editor_plugin.cpp183
-rw-r--r--modules/mono/csharp_script.cpp2
-rw-r--r--modules/mono/editor/bindings_generator.cpp4
-rw-r--r--modules/mono/glue/cs_files/AABB.cs (renamed from modules/mono/glue/cs_files/Rect3.cs)44
-rw-r--r--modules/mono/mono_gd/gd_mono_field.cpp6
-rw-r--r--modules/mono/mono_gd/gd_mono_marshal.cpp16
-rw-r--r--modules/mono/mono_gd/gd_mono_marshal.h8
-rw-r--r--modules/mono/mono_gd/gd_mono_utils.cpp6
-rw-r--r--modules/mono/mono_gd/gd_mono_utils.h4
-rw-r--r--modules/regex/doc_classes/RegExMatch.xml2
-rw-r--r--modules/visual_script/visual_script_builtin_funcs.cpp2
-rw-r--r--modules/visual_script/visual_script_editor.cpp4
-rw-r--r--platform/javascript/SCsub28
-rw-r--r--platform/javascript/detect.py17
-rw-r--r--platform/javascript/engine.js59
-rw-r--r--platform/javascript/export/export.cpp63
-rw-r--r--platform/javascript/pre.js (renamed from platform/javascript/pre_wasm.js)1
-rw-r--r--platform/javascript/pre_asmjs.js3
-rw-r--r--platform/osx/os_osx.h6
-rw-r--r--platform/osx/os_osx.mm92
-rw-r--r--scene/2d/particles_2d.cpp6
-rw-r--r--scene/2d/tile_map.cpp4
-rw-r--r--scene/3d/collision_polygon.cpp4
-rw-r--r--scene/3d/collision_polygon.h4
-rw-r--r--scene/3d/gi_probe.cpp70
-rw-r--r--scene/3d/gi_probe.h14
-rw-r--r--scene/3d/immediate_geometry.cpp2
-rw-r--r--scene/3d/immediate_geometry.h4
-rw-r--r--scene/3d/light.cpp10
-rw-r--r--scene/3d/light.h2
-rw-r--r--scene/3d/mesh_instance.cpp4
-rw-r--r--scene/3d/mesh_instance.h2
-rw-r--r--scene/3d/multimesh_instance.cpp4
-rw-r--r--scene/3d/multimesh_instance.h2
-rw-r--r--scene/3d/particles.cpp14
-rw-r--r--scene/3d/particles.h10
-rw-r--r--scene/3d/portal.cpp2
-rw-r--r--scene/3d/portal.h4
-rw-r--r--scene/3d/reflection_probe.cpp4
-rw-r--r--scene/3d/reflection_probe.h2
-rw-r--r--scene/3d/room_instance.cpp6
-rw-r--r--scene/3d/room_instance.h2
-rw-r--r--scene/3d/sprite_3d.cpp6
-rw-r--r--scene/3d/sprite_3d.h6
-rw-r--r--scene/3d/visibility_notifier.cpp8
-rw-r--r--scene/3d/visibility_notifier.h6
-rw-r--r--scene/3d/visual_instance.cpp2
-rw-r--r--scene/3d/visual_instance.h4
-rw-r--r--scene/animation/tween.cpp16
-rw-r--r--scene/gui/control.cpp68
-rw-r--r--scene/gui/control.h7
-rw-r--r--scene/gui/line_edit.cpp3
-rw-r--r--scene/gui/text_edit.cpp8
-rw-r--r--scene/resources/animation.cpp12
-rw-r--r--scene/resources/box_shape.cpp2
-rw-r--r--scene/resources/mesh.cpp24
-rw-r--r--scene/resources/mesh.h18
-rw-r--r--scene/resources/multimesh.cpp2
-rw-r--r--scene/resources/multimesh.h2
-rw-r--r--scene/resources/primitive_meshes.cpp4
-rw-r--r--scene/resources/primitive_meshes.h4
-rw-r--r--scene/resources/scene_format_text.cpp2
-rw-r--r--scene/resources/tile_set.cpp20
-rw-r--r--scene/resources/tile_set.h3
-rw-r--r--scene/resources/world.cpp10
-rw-r--r--scene/resources/world.h4
-rw-r--r--servers/physics/broad_phase_basic.cpp10
-rw-r--r--servers/physics/broad_phase_basic.h6
-rw-r--r--servers/physics/broad_phase_octree.cpp6
-rw-r--r--servers/physics/broad_phase_octree.h4
-rw-r--r--servers/physics/broad_phase_sw.h6
-rw-r--r--servers/physics/collision_object_sw.cpp6
-rw-r--r--servers/physics/collision_object_sw.h4
-rw-r--r--servers/physics/collision_solver_sw.cpp10
-rw-r--r--servers/physics/collision_solver_sw.h2
-rw-r--r--servers/physics/shape_sw.cpp36
-rw-r--r--servers/physics/shape_sw.h18
-rw-r--r--servers/physics/space_sw.cpp16
-rw-r--r--servers/physics/space_sw.h2
-rw-r--r--servers/visual/rasterizer.h36
-rw-r--r--servers/visual/visual_server_raster.h32
-rw-r--r--servers/visual/visual_server_scene.cpp12
-rw-r--r--servers/visual/visual_server_scene.h6
-rw-r--r--servers/visual/visual_server_wrap_mt.h24
-rw-r--r--servers/visual_server.cpp22
-rw-r--r--servers/visual_server.h24
199 files changed, 3253 insertions, 2868 deletions
diff --git a/SConstruct b/SConstruct
index 99533ecc24..c3ecdafd45 100644
--- a/SConstruct
+++ b/SConstruct
@@ -274,9 +274,12 @@ if selected_platform in platform_list:
if len(pieces) > 0:
basename = pieces[0]
basename = basename.replace('\\\\', '/')
- env.vs_srcs = env.vs_srcs + [basename + ".cpp"]
- env.vs_incs = env.vs_incs + [basename + ".h"]
- # print basename
+ if os.path.isfile(basename + ".h"):
+ env.vs_incs = env.vs_incs + [basename + ".h"]
+ if os.path.isfile(basename + ".c"):
+ env.vs_srcs = env.vs_srcs + [basename + ".c"]
+ elif os.path.isfile(basename + ".cpp"):
+ env.vs_srcs = env.vs_srcs + [basename + ".cpp"]
env.AddToVSProject = AddToVSProject
env.extra_suffix = ""
diff --git a/core/global_constants.cpp b/core/global_constants.cpp
index 7854f342b0..48101c8cf1 100644
--- a/core/global_constants.cpp
+++ b/core/global_constants.cpp
@@ -557,7 +557,7 @@ void register_global_constants() {
BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_TRANSFORM2D", Variant::TRANSFORM2D);
BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_PLANE", Variant::PLANE);
BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_QUAT", Variant::QUAT); // 10
- BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_RECT3", Variant::RECT3);
+ BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_AABB", Variant::AABB);
BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_BASIS", Variant::BASIS);
BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_TRANSFORM", Variant::TRANSFORM);
BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_COLOR", Variant::COLOR);
diff --git a/core/helper/math_fieldwise.cpp b/core/helper/math_fieldwise.cpp
index 228611f8b3..2cd8a4f392 100644
--- a/core/helper/math_fieldwise.cpp
+++ b/core/helper/math_fieldwise.cpp
@@ -46,8 +46,8 @@ Variant fieldwise_assign(const Variant &p_target, const Variant &p_source, const
switch (p_source.get_type()) {
- /* clang-format makes a mess of this macro usage */
- /* clang-format off */
+ /* clang-format makes a mess of this macro usage */
+ /* clang-format off */
case Variant::VECTOR2: {
@@ -106,9 +106,9 @@ Variant fieldwise_assign(const Variant &p_target, const Variant &p_source, const
return target;
}
- case Variant::RECT3: {
+ case Variant::AABB: {
- SETUP_TYPE(Rect3)
+ SETUP_TYPE(AABB)
/**/ TRY_TRANSFER_FIELD("px", position.x)
else TRY_TRANSFER_FIELD("py", position.y)
diff --git a/core/io/marshalls.cpp b/core/io/marshalls.cpp
index d388a622de..1d9d2dd959 100644
--- a/core/io/marshalls.cpp
+++ b/core/io/marshalls.cpp
@@ -159,7 +159,7 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
r_variant = str;
} break;
- // math types
+ // math types
case Variant::VECTOR2: {
@@ -245,10 +245,10 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
(*r_len) += 4 * 4;
} break;
- case Variant::RECT3: {
+ case Variant::AABB: {
ERR_FAIL_COND_V(len < (int)4 * 6, ERR_INVALID_DATA);
- Rect3 val;
+ AABB val;
val.position.x = decode_float(&buf[0]);
val.position.y = decode_float(&buf[4]);
val.position.z = decode_float(&buf[8]);
@@ -967,7 +967,7 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
_encode_string(p_variant, buf, r_len);
} break;
- // math types
+ // math types
case Variant::VECTOR2: {
@@ -1045,10 +1045,10 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
r_len += 4 * 4;
} break;
- case Variant::RECT3: {
+ case Variant::AABB: {
if (buf) {
- Rect3 aabb = p_variant;
+ AABB aabb = p_variant;
encode_float(aabb.position.x, &buf[0]);
encode_float(aabb.position.y, &buf[4]);
encode_float(aabb.position.z, &buf[8]);
diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp
index 03c3c5f615..8dc396c362 100644
--- a/core/io/resource_format_binary.cpp
+++ b/core/io/resource_format_binary.cpp
@@ -52,7 +52,7 @@ enum {
VARIANT_VECTOR3 = 12,
VARIANT_PLANE = 13,
VARIANT_QUAT = 14,
- VARIANT_RECT3 = 15,
+ VARIANT_AABB = 15,
VARIANT_MATRIX3 = 16,
VARIANT_TRANSFORM = 17,
VARIANT_MATRIX32 = 18,
@@ -196,9 +196,9 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) {
r_v = v;
} break;
- case VARIANT_RECT3: {
+ case VARIANT_AABB: {
- Rect3 v;
+ AABB v;
v.position.x = f->get_real();
v.position.y = f->get_real();
v.position.z = f->get_real();
@@ -1374,10 +1374,10 @@ void ResourceFormatSaverBinaryInstance::write_variant(const Variant &p_property,
f->store_real(val.w);
} break;
- case Variant::RECT3: {
+ case Variant::AABB: {
- f->store_32(VARIANT_RECT3);
- Rect3 val = p_property;
+ f->store_32(VARIANT_AABB);
+ AABB val = p_property;
f->store_real(val.position.x);
f->store_real(val.position.y);
f->store_real(val.position.z);
diff --git a/core/math/rect3.cpp b/core/math/aabb.cpp
index 6f01000f61..737a42b337 100644
--- a/core/math/rect3.cpp
+++ b/core/math/aabb.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* rect3.cpp */
+/* aabb.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -27,25 +27,25 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "rect3.h"
+#include "aabb.h"
#include "print_string.h"
-real_t Rect3::get_area() const {
+real_t AABB::get_area() const {
return size.x * size.y * size.z;
}
-bool Rect3::operator==(const Rect3 &p_rval) const {
+bool AABB::operator==(const AABB &p_rval) const {
return ((position == p_rval.position) && (size == p_rval.size));
}
-bool Rect3::operator!=(const Rect3 &p_rval) const {
+bool AABB::operator!=(const AABB &p_rval) const {
return ((position != p_rval.position) || (size != p_rval.size));
}
-void Rect3::merge_with(const Rect3 &p_aabb) {
+void AABB::merge_with(const AABB &p_aabb) {
Vector3 beg_1, beg_2;
Vector3 end_1, end_2;
@@ -68,7 +68,7 @@ void Rect3::merge_with(const Rect3 &p_aabb) {
size = max - min;
}
-Rect3 Rect3::intersection(const Rect3 &p_aabb) const {
+AABB AABB::intersection(const AABB &p_aabb) const {
Vector3 src_min = position;
Vector3 src_max = position + size;
@@ -78,7 +78,7 @@ Rect3 Rect3::intersection(const Rect3 &p_aabb) const {
Vector3 min, max;
if (src_min.x > dst_max.x || src_max.x < dst_min.x)
- return Rect3();
+ return AABB();
else {
min.x = (src_min.x > dst_min.x) ? src_min.x : dst_min.x;
@@ -86,7 +86,7 @@ Rect3 Rect3::intersection(const Rect3 &p_aabb) const {
}
if (src_min.y > dst_max.y || src_max.y < dst_min.y)
- return Rect3();
+ return AABB();
else {
min.y = (src_min.y > dst_min.y) ? src_min.y : dst_min.y;
@@ -94,17 +94,17 @@ Rect3 Rect3::intersection(const Rect3 &p_aabb) const {
}
if (src_min.z > dst_max.z || src_max.z < dst_min.z)
- return Rect3();
+ return AABB();
else {
min.z = (src_min.z > dst_min.z) ? src_min.z : dst_min.z;
max.z = (src_max.z < dst_max.z) ? src_max.z : dst_max.z;
}
- return Rect3(min, max - min);
+ return AABB(min, max - min);
}
-bool Rect3::intersects_ray(const Vector3 &p_from, const Vector3 &p_dir, Vector3 *r_clip, Vector3 *r_normal) const {
+bool AABB::intersects_ray(const Vector3 &p_from, const Vector3 &p_dir, Vector3 *r_clip, Vector3 *r_normal) const {
Vector3 c1, c2;
Vector3 end = position + size;
@@ -147,7 +147,7 @@ bool Rect3::intersects_ray(const Vector3 &p_from, const Vector3 &p_dir, Vector3
return true;
}
-bool Rect3::intersects_segment(const Vector3 &p_from, const Vector3 &p_to, Vector3 *r_clip, Vector3 *r_normal) const {
+bool AABB::intersects_segment(const Vector3 &p_from, const Vector3 &p_to, Vector3 *r_clip, Vector3 *r_normal) const {
real_t min = 0, max = 1;
int axis = 0;
@@ -205,7 +205,7 @@ bool Rect3::intersects_segment(const Vector3 &p_from, const Vector3 &p_to, Vecto
return true;
}
-bool Rect3::intersects_plane(const Plane &p_plane) const {
+bool AABB::intersects_plane(const Plane &p_plane) const {
Vector3 points[8] = {
Vector3(position.x, position.y, position.z),
@@ -232,7 +232,7 @@ bool Rect3::intersects_plane(const Plane &p_plane) const {
return under && over;
}
-Vector3 Rect3::get_longest_axis() const {
+Vector3 AABB::get_longest_axis() const {
Vector3 axis(1, 0, 0);
real_t max_size = size.x;
@@ -249,7 +249,7 @@ Vector3 Rect3::get_longest_axis() const {
return axis;
}
-int Rect3::get_longest_axis_index() const {
+int AABB::get_longest_axis_index() const {
int axis = 0;
real_t max_size = size.x;
@@ -267,7 +267,7 @@ int Rect3::get_longest_axis_index() const {
return axis;
}
-Vector3 Rect3::get_shortest_axis() const {
+Vector3 AABB::get_shortest_axis() const {
Vector3 axis(1, 0, 0);
real_t max_size = size.x;
@@ -284,7 +284,7 @@ Vector3 Rect3::get_shortest_axis() const {
return axis;
}
-int Rect3::get_shortest_axis_index() const {
+int AABB::get_shortest_axis_index() const {
int axis = 0;
real_t max_size = size.x;
@@ -302,25 +302,25 @@ int Rect3::get_shortest_axis_index() const {
return axis;
}
-Rect3 Rect3::merge(const Rect3 &p_with) const {
+AABB AABB::merge(const AABB &p_with) const {
- Rect3 aabb = *this;
+ AABB aabb = *this;
aabb.merge_with(p_with);
return aabb;
}
-Rect3 Rect3::expand(const Vector3 &p_vector) const {
- Rect3 aabb = *this;
+AABB AABB::expand(const Vector3 &p_vector) const {
+ AABB aabb = *this;
aabb.expand_to(p_vector);
return aabb;
}
-Rect3 Rect3::grow(real_t p_by) const {
+AABB AABB::grow(real_t p_by) const {
- Rect3 aabb = *this;
+ AABB aabb = *this;
aabb.grow_by(p_by);
return aabb;
}
-void Rect3::get_edge(int p_edge, Vector3 &r_from, Vector3 &r_to) const {
+void AABB::get_edge(int p_edge, Vector3 &r_from, Vector3 &r_to) const {
ERR_FAIL_INDEX(p_edge, 12);
switch (p_edge) {
@@ -394,7 +394,7 @@ void Rect3::get_edge(int p_edge, Vector3 &r_from, Vector3 &r_to) const {
}
}
-Rect3::operator String() const {
+AABB::operator String() const {
return String() + position + " - " + size;
}
diff --git a/core/math/rect3.h b/core/math/aabb.h
index c3a2f5fbfb..c60213496a 100644
--- a/core/math/rect3.h
+++ b/core/math/aabb.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* rect3.h */
+/* aabb.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -39,7 +39,7 @@
* This is implemented by a point (position) and the box size
*/
-class Rect3 {
+class AABB {
public:
Vector3 position;
Vector3 size;
@@ -60,16 +60,16 @@ public:
const Vector3 &get_size() const { return size; }
void set_size(const Vector3 &p_size) { size = p_size; }
- bool operator==(const Rect3 &p_rval) const;
- bool operator!=(const Rect3 &p_rval) const;
+ bool operator==(const AABB &p_rval) const;
+ bool operator!=(const AABB &p_rval) const;
- _FORCE_INLINE_ bool intersects(const Rect3 &p_aabb) const; /// Both AABBs overlap
- _FORCE_INLINE_ bool intersects_inclusive(const Rect3 &p_aabb) const; /// Both AABBs (or their faces) overlap
- _FORCE_INLINE_ bool encloses(const Rect3 &p_aabb) const; /// p_aabb is completely inside this
+ _FORCE_INLINE_ bool intersects(const AABB &p_aabb) const; /// Both AABBs overlap
+ _FORCE_INLINE_ bool intersects_inclusive(const AABB &p_aabb) const; /// Both AABBs (or their faces) overlap
+ _FORCE_INLINE_ bool encloses(const AABB &p_aabb) const; /// p_aabb is completely inside this
- Rect3 merge(const Rect3 &p_with) const;
- void merge_with(const Rect3 &p_aabb); ///merge with another AABB
- Rect3 intersection(const Rect3 &p_aabb) const; ///get box where two intersect, empty if no intersection occurs
+ AABB merge(const AABB &p_with) const;
+ void merge_with(const AABB &p_aabb); ///merge with another AABB
+ AABB intersection(const AABB &p_aabb) const; ///get box where two intersect, empty if no intersection occurs
bool intersects_segment(const Vector3 &p_from, const Vector3 &p_to, Vector3 *r_clip = NULL, Vector3 *r_normal = NULL) const;
bool intersects_ray(const Vector3 &p_from, const Vector3 &p_dir, Vector3 *r_clip = NULL, Vector3 *r_normal = NULL) const;
_FORCE_INLINE_ bool smits_intersect_ray(const Vector3 &p_from, const Vector3 &p_dir, real_t t0, real_t t1) const;
@@ -88,26 +88,26 @@ public:
int get_shortest_axis_index() const;
_FORCE_INLINE_ real_t get_shortest_axis_size() const;
- Rect3 grow(real_t p_by) const;
+ AABB grow(real_t p_by) const;
_FORCE_INLINE_ void grow_by(real_t p_amount);
void get_edge(int p_edge, Vector3 &r_from, Vector3 &r_to) const;
_FORCE_INLINE_ Vector3 get_endpoint(int p_point) const;
- Rect3 expand(const Vector3 &p_vector) const;
+ AABB expand(const Vector3 &p_vector) const;
_FORCE_INLINE_ void project_range_in_plane(const Plane &p_plane, real_t &r_min, real_t &r_max) const;
_FORCE_INLINE_ void expand_to(const Vector3 &p_vector); /** expand to contain a point if necessary */
operator String() const;
- _FORCE_INLINE_ Rect3() {}
- inline Rect3(const Vector3 &p_pos, const Vector3 &p_size)
+ _FORCE_INLINE_ AABB() {}
+ inline AABB(const Vector3 &p_pos, const Vector3 &p_size)
: position(p_pos),
size(p_size) {
}
};
-inline bool Rect3::intersects(const Rect3 &p_aabb) const {
+inline bool AABB::intersects(const AABB &p_aabb) const {
if (position.x >= (p_aabb.position.x + p_aabb.size.x))
return false;
@@ -125,7 +125,7 @@ inline bool Rect3::intersects(const Rect3 &p_aabb) const {
return true;
}
-inline bool Rect3::intersects_inclusive(const Rect3 &p_aabb) const {
+inline bool AABB::intersects_inclusive(const AABB &p_aabb) const {
if (position.x > (p_aabb.position.x + p_aabb.size.x))
return false;
@@ -143,7 +143,7 @@ inline bool Rect3::intersects_inclusive(const Rect3 &p_aabb) const {
return true;
}
-inline bool Rect3::encloses(const Rect3 &p_aabb) const {
+inline bool AABB::encloses(const AABB &p_aabb) const {
Vector3 src_min = position;
Vector3 src_max = position + size;
@@ -159,7 +159,7 @@ inline bool Rect3::encloses(const Rect3 &p_aabb) const {
(src_max.z > dst_max.z));
}
-Vector3 Rect3::get_support(const Vector3 &p_normal) const {
+Vector3 AABB::get_support(const Vector3 &p_normal) const {
Vector3 half_extents = size * 0.5;
Vector3 ofs = position + half_extents;
@@ -171,7 +171,7 @@ Vector3 Rect3::get_support(const Vector3 &p_normal) const {
ofs;
}
-Vector3 Rect3::get_endpoint(int p_point) const {
+Vector3 AABB::get_endpoint(int p_point) const {
switch (p_point) {
case 0: return Vector3(position.x, position.y, position.z);
@@ -187,7 +187,7 @@ Vector3 Rect3::get_endpoint(int p_point) const {
ERR_FAIL_V(Vector3());
}
-bool Rect3::intersects_convex_shape(const Plane *p_planes, int p_plane_count) const {
+bool AABB::intersects_convex_shape(const Plane *p_planes, int p_plane_count) const {
Vector3 half_extents = size * 0.5;
Vector3 ofs = position + half_extents;
@@ -206,7 +206,7 @@ bool Rect3::intersects_convex_shape(const Plane *p_planes, int p_plane_count) co
return true;
}
-bool Rect3::has_point(const Vector3 &p_point) const {
+bool AABB::has_point(const Vector3 &p_point) const {
if (p_point.x < position.x)
return false;
@@ -224,7 +224,7 @@ bool Rect3::has_point(const Vector3 &p_point) const {
return true;
}
-inline void Rect3::expand_to(const Vector3 &p_vector) {
+inline void AABB::expand_to(const Vector3 &p_vector) {
Vector3 begin = position;
Vector3 end = position + size;
@@ -247,7 +247,7 @@ inline void Rect3::expand_to(const Vector3 &p_vector) {
size = end - begin;
}
-void Rect3::project_range_in_plane(const Plane &p_plane, real_t &r_min, real_t &r_max) const {
+void AABB::project_range_in_plane(const Plane &p_plane, real_t &r_min, real_t &r_max) const {
Vector3 half_extents(size.x * 0.5, size.y * 0.5, size.z * 0.5);
Vector3 center(position.x + half_extents.x, position.y + half_extents.y, position.z + half_extents.z);
@@ -258,7 +258,7 @@ void Rect3::project_range_in_plane(const Plane &p_plane, real_t &r_min, real_t &
r_max = distance + length;
}
-inline real_t Rect3::get_longest_axis_size() const {
+inline real_t AABB::get_longest_axis_size() const {
real_t max_size = size.x;
@@ -273,7 +273,7 @@ inline real_t Rect3::get_longest_axis_size() const {
return max_size;
}
-inline real_t Rect3::get_shortest_axis_size() const {
+inline real_t AABB::get_shortest_axis_size() const {
real_t max_size = size.x;
@@ -288,7 +288,7 @@ inline real_t Rect3::get_shortest_axis_size() const {
return max_size;
}
-bool Rect3::smits_intersect_ray(const Vector3 &p_from, const Vector3 &p_dir, real_t t0, real_t t1) const {
+bool AABB::smits_intersect_ray(const Vector3 &p_from, const Vector3 &p_dir, real_t t0, real_t t1) const {
real_t divx = 1.0 / p_dir.x;
real_t divy = 1.0 / p_dir.y;
@@ -332,7 +332,7 @@ bool Rect3::smits_intersect_ray(const Vector3 &p_from, const Vector3 &p_dir, rea
return ((tmin < t1) && (tmax > t0));
}
-void Rect3::grow_by(real_t p_amount) {
+void AABB::grow_by(real_t p_amount) {
position.x -= p_amount;
position.y -= p_amount;
diff --git a/core/math/bsp_tree.cpp b/core/math/bsp_tree.cpp
index be950568cf..bdc040160f 100644
--- a/core/math/bsp_tree.cpp
+++ b/core/math/bsp_tree.cpp
@@ -31,7 +31,7 @@
#include "error_macros.h"
#include "print_string.h"
-void BSP_Tree::from_aabb(const Rect3 &p_aabb) {
+void BSP_Tree::from_aabb(const AABB &p_aabb) {
planes.clear();
@@ -67,7 +67,7 @@ Vector<Plane> BSP_Tree::get_planes() const {
return planes;
}
-Rect3 BSP_Tree::get_aabb() const {
+AABB BSP_Tree::get_aabb() const {
return aabb;
}
@@ -577,7 +577,7 @@ BSP_Tree::BSP_Tree(const PoolVector<Face3> &p_faces, real_t p_error_radius) {
error_radius = p_error_radius;
}
-BSP_Tree::BSP_Tree(const Vector<Node> &p_nodes, const Vector<Plane> &p_planes, const Rect3 &p_aabb, real_t p_error_radius)
+BSP_Tree::BSP_Tree(const Vector<Node> &p_nodes, const Vector<Plane> &p_planes, const AABB &p_aabb, real_t p_error_radius)
: nodes(p_nodes),
planes(p_planes),
aabb(p_aabb),
diff --git a/core/math/bsp_tree.h b/core/math/bsp_tree.h
index 2e762ba4de..f64a13ce39 100644
--- a/core/math/bsp_tree.h
+++ b/core/math/bsp_tree.h
@@ -30,11 +30,11 @@
#ifndef BSP_TREE_H
#define BSP_TREE_H
+#include "aabb.h"
#include "dvector.h"
#include "face3.h"
#include "method_ptrcall.h"
#include "plane.h"
-#include "rect3.h"
#include "variant.h"
#include "vector.h"
/**
@@ -64,7 +64,7 @@ private:
Vector<Node> nodes;
Vector<Plane> planes;
- Rect3 aabb;
+ AABB aabb;
real_t error_radius;
int _get_points_inside(int p_node, const Vector3 *p_points, int *p_indices, const Vector3 &p_center, const Vector3 &p_half_extents, int p_indices_count) const;
@@ -76,7 +76,7 @@ public:
bool is_empty() const { return nodes.size() == 0; }
Vector<Node> get_nodes() const;
Vector<Plane> get_planes() const;
- Rect3 get_aabb() const;
+ AABB get_aabb() const;
bool point_is_inside(const Vector3 &p_point) const;
int get_points_inside(const Vector3 *p_points, int p_point_count) const;
@@ -85,12 +85,12 @@ public:
operator Variant() const;
- void from_aabb(const Rect3 &p_aabb);
+ void from_aabb(const AABB &p_aabb);
BSP_Tree();
BSP_Tree(const Variant &p_variant);
BSP_Tree(const PoolVector<Face3> &p_faces, real_t p_error_radius = 0);
- BSP_Tree(const Vector<Node> &p_nodes, const Vector<Plane> &p_planes, const Rect3 &p_aabb, real_t p_error_radius = 0);
+ BSP_Tree(const Vector<Node> &p_nodes, const Vector<Plane> &p_planes, const AABB &p_aabb, real_t p_error_radius = 0);
~BSP_Tree();
};
diff --git a/core/math/camera_matrix.cpp b/core/math/camera_matrix.cpp
index 2c587762e8..c5f1d57441 100644
--- a/core/math/camera_matrix.cpp
+++ b/core/math/camera_matrix.cpp
@@ -596,7 +596,7 @@ void CameraMatrix::make_scale(const Vector3 &p_scale) {
matrix[2][2] = p_scale.z;
}
-void CameraMatrix::scale_translate_to_fit(const Rect3 &p_aabb) {
+void CameraMatrix::scale_translate_to_fit(const AABB &p_aabb) {
Vector3 min = p_aabb.position;
Vector3 max = p_aabb.position + p_aabb.size;
diff --git a/core/math/camera_matrix.h b/core/math/camera_matrix.h
index 3145d73356..15d6b8128e 100644
--- a/core/math/camera_matrix.h
+++ b/core/math/camera_matrix.h
@@ -86,7 +86,7 @@ struct CameraMatrix {
operator String() const;
- void scale_translate_to_fit(const Rect3 &p_aabb);
+ void scale_translate_to_fit(const AABB &p_aabb);
void make_scale(const Vector3 &p_scale);
int get_pixels_per_meter(int p_for_pixel_width) const;
operator Transform() const;
diff --git a/core/math/face3.cpp b/core/math/face3.cpp
index e1b172e491..070ce77db4 100644
--- a/core/math/face3.cpp
+++ b/core/math/face3.cpp
@@ -189,13 +189,13 @@ ClockDirection Face3::get_clock_dir() const {
return (normal.dot(vertex[0]) >= 0) ? CLOCKWISE : COUNTERCLOCKWISE;
}
-bool Face3::intersects_aabb(const Rect3 &p_aabb) const {
+bool Face3::intersects_aabb(const AABB &p_aabb) const {
/** TEST PLANE **/
if (!p_aabb.intersects_plane(get_plane()))
return false;
-/** TEST FACE AXIS */
+ /** TEST FACE AXIS */
#define TEST_AXIS(m_ax) \
{ \
diff --git a/core/math/face3.h b/core/math/face3.h
index 8e4a25fb7a..561fa31238 100644
--- a/core/math/face3.h
+++ b/core/math/face3.h
@@ -30,8 +30,8 @@
#ifndef FACE3_H
#define FACE3_H
+#include "aabb.h"
#include "plane.h"
-#include "rect3.h"
#include "transform.h"
#include "vector3.h"
@@ -76,16 +76,16 @@ public:
void get_support(const Vector3 &p_normal, const Transform &p_transform, Vector3 *p_vertices, int *p_count, int p_max) const;
void project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const;
- Rect3 get_aabb() const {
+ AABB get_aabb() const {
- Rect3 aabb(vertex[0], Vector3());
+ AABB aabb(vertex[0], Vector3());
aabb.expand_to(vertex[1]);
aabb.expand_to(vertex[2]);
return aabb;
}
- bool intersects_aabb(const Rect3 &p_aabb) const;
- _FORCE_INLINE_ bool intersects_aabb2(const Rect3 &p_aabb) const;
+ bool intersects_aabb(const AABB &p_aabb) const;
+ _FORCE_INLINE_ bool intersects_aabb2(const AABB &p_aabb) const;
operator String() const;
inline Face3() {}
@@ -96,7 +96,7 @@ public:
}
};
-bool Face3::intersects_aabb2(const Rect3 &p_aabb) const {
+bool Face3::intersects_aabb2(const AABB &p_aabb) const {
Vector3 perp = (vertex[0] - vertex[2]).cross(vertex[0] - vertex[1]);
@@ -256,6 +256,6 @@ bool Face3::intersects_aabb2(const Rect3 &p_aabb) const {
return true;
}
-//this sucks...
+ //this sucks...
#endif // FACE3_H
diff --git a/core/math/geometry.cpp b/core/math/geometry.cpp
index 7c8fb6f17d..39bd34f03c 100644
--- a/core/math/geometry.cpp
+++ b/core/math/geometry.cpp
@@ -300,7 +300,7 @@ enum _CellFlags {
static inline void _plot_face(uint8_t ***p_cell_status, int x, int y, int z, int len_x, int len_y, int len_z, const Vector3 &voxelsize, const Face3 &p_face) {
- Rect3 aabb(Vector3(x, y, z), Vector3(len_x, len_y, len_z));
+ AABB aabb(Vector3(x, y, z), Vector3(len_x, len_y, len_z));
aabb.position = aabb.position * voxelsize;
aabb.size = aabb.size * voxelsize;
@@ -575,7 +575,7 @@ PoolVector<Face3> Geometry::wrap_geometry(PoolVector<Face3> p_array, real_t *p_e
PoolVector<Face3>::Read facesr = p_array.read();
const Face3 *faces = facesr.ptr();
- Rect3 global_aabb;
+ AABB global_aabb;
for (int i = 0; i < face_count; i++) {
diff --git a/core/math/octree.h b/core/math/octree.h
index 95a67943fd..6acd4c5f75 100644
--- a/core/math/octree.h
+++ b/core/math/octree.h
@@ -30,10 +30,10 @@
#ifndef OCTREE_H
#define OCTREE_H
+#include "aabb.h"
#include "list.h"
#include "map.h"
#include "print_string.h"
-#include "rect3.h"
#include "variant.h"
#include "vector3.h"
@@ -106,7 +106,7 @@ private:
struct Octant {
// cached for FAST plane check
- Rect3 aabb;
+ AABB aabb;
uint64_t last_pass;
Octant *parent;
@@ -152,8 +152,8 @@ private:
OctreeElementID _id;
Octant *common_parent;
- Rect3 aabb;
- Rect3 container_aabb;
+ AABB aabb;
+ AABB container_aabb;
List<PairData *, AL> pair_list;
@@ -334,7 +334,7 @@ private:
}
void _insert_element(Element *p_element, Octant *p_octant);
- void _ensure_valid_root(const Rect3 &p_aabb);
+ void _ensure_valid_root(const AABB &p_aabb);
bool _remove_element_from_octant(Element *p_element, Octant *p_octant, Octant *p_limit = NULL);
void _remove_element(Element *p_element);
void _pair_element(Element *p_element, Octant *p_octant);
@@ -351,7 +351,7 @@ private:
};
void _cull_convex(Octant *p_octant, _CullConvexData *p_cull);
- void _cull_aabb(Octant *p_octant, const Rect3 &p_aabb, T **p_result_array, int *p_result_idx, int p_result_max, int *p_subindex_array, uint32_t p_mask);
+ void _cull_aabb(Octant *p_octant, const AABB &p_aabb, T **p_result_array, int *p_result_idx, int p_result_max, int *p_subindex_array, uint32_t p_mask);
void _cull_segment(Octant *p_octant, const Vector3 &p_from, const Vector3 &p_to, T **p_result_array, int *p_result_idx, int p_result_max, int *p_subindex_array, uint32_t p_mask);
void _cull_point(Octant *p_octant, const Vector3 &p_point, T **p_result_array, int *p_result_idx, int p_result_max, int *p_subindex_array, uint32_t p_mask);
@@ -370,8 +370,8 @@ private:
}
public:
- OctreeElementID create(T *p_userdata, const Rect3 &p_aabb = Rect3(), int p_subindex = 0, bool p_pairable = false, uint32_t p_pairable_type = 0, uint32_t pairable_mask = 1);
- void move(OctreeElementID p_id, const Rect3 &p_aabb);
+ OctreeElementID create(T *p_userdata, const AABB &p_aabb = AABB(), int p_subindex = 0, bool p_pairable = false, uint32_t p_pairable_type = 0, uint32_t pairable_mask = 1);
+ void move(OctreeElementID p_id, const AABB &p_aabb);
void set_pairable(OctreeElementID p_id, bool p_pairable = false, uint32_t p_pairable_type = 0, uint32_t pairable_mask = 1);
void erase(OctreeElementID p_id);
@@ -380,7 +380,7 @@ public:
int get_subindex(OctreeElementID p_id) const;
int cull_convex(const Vector<Plane> &p_convex, T **p_result_array, int p_result_max, uint32_t p_mask = 0xFFFFFFFF);
- int cull_aabb(const Rect3 &p_aabb, T **p_result_array, int p_result_max, int *p_subindex_array = NULL, uint32_t p_mask = 0xFFFFFFFF);
+ int cull_aabb(const AABB &p_aabb, T **p_result_array, int p_result_max, int *p_subindex_array = NULL, uint32_t p_mask = 0xFFFFFFFF);
int cull_segment(const Vector3 &p_from, const Vector3 &p_to, T **p_result_array, int p_result_max, int *p_subindex_array = NULL, uint32_t p_mask = 0xFFFFFFFF);
int cull_point(const Vector3 &p_point, T **p_result_array, int p_result_max, int *p_subindex_array = NULL, uint32_t p_mask = 0xFFFFFFFF);
@@ -479,7 +479,7 @@ void Octree<T, use_pairs, AL>::_insert_element(Element *p_element, Octant *p_oct
} else {
/* check againt AABB where child should be */
- Rect3 aabb = p_octant->aabb;
+ AABB aabb = p_octant->aabb;
aabb.size *= 0.5;
if (i & 1)
@@ -535,12 +535,12 @@ void Octree<T, use_pairs, AL>::_insert_element(Element *p_element, Octant *p_oct
}
template <class T, bool use_pairs, class AL>
-void Octree<T, use_pairs, AL>::_ensure_valid_root(const Rect3 &p_aabb) {
+void Octree<T, use_pairs, AL>::_ensure_valid_root(const AABB &p_aabb) {
if (!root) {
// octre is empty
- Rect3 base(Vector3(), Vector3(1.0, 1.0, 1.0) * unit_size);
+ AABB base(Vector3(), Vector3(1.0, 1.0, 1.0) * unit_size);
while (!base.encloses(p_aabb)) {
@@ -563,7 +563,7 @@ void Octree<T, use_pairs, AL>::_ensure_valid_root(const Rect3 &p_aabb) {
} else {
- Rect3 base = root->aabb;
+ AABB base = root->aabb;
while (!base.encloses(p_aabb)) {
@@ -793,7 +793,7 @@ void Octree<T, use_pairs, AL>::_remove_element(Element *p_element) {
}
template <class T, bool use_pairs, class AL>
-OctreeElementID Octree<T, use_pairs, AL>::create(T *p_userdata, const Rect3 &p_aabb, int p_subindex, bool p_pairable, uint32_t p_pairable_type, uint32_t p_pairable_mask) {
+OctreeElementID Octree<T, use_pairs, AL>::create(T *p_userdata, const AABB &p_aabb, int p_subindex, bool p_pairable, uint32_t p_pairable_type, uint32_t p_pairable_mask) {
// check for AABB validity
#ifdef DEBUG_ENABLED
@@ -833,7 +833,7 @@ OctreeElementID Octree<T, use_pairs, AL>::create(T *p_userdata, const Rect3 &p_a
}
template <class T, bool use_pairs, class AL>
-void Octree<T, use_pairs, AL>::move(OctreeElementID p_id, const Rect3 &p_aabb) {
+void Octree<T, use_pairs, AL>::move(OctreeElementID p_id, const AABB &p_aabb) {
#ifdef DEBUG_ENABLED
// check for AABB validity
@@ -859,7 +859,7 @@ void Octree<T, use_pairs, AL>::move(OctreeElementID p_id, const Rect3 &p_aabb) {
if (old_has_surf) {
_remove_element(&e); // removing
e.common_parent = NULL;
- e.aabb = Rect3();
+ e.aabb = AABB();
_optimize();
} else {
_ensure_valid_root(p_aabb); // inserting
@@ -886,7 +886,7 @@ void Octree<T, use_pairs, AL>::move(OctreeElementID p_id, const Rect3 &p_aabb) {
return;
}
- Rect3 combined = e.aabb;
+ AABB combined = e.aabb;
combined.merge_with(p_aabb);
_ensure_valid_root(combined);
@@ -1072,7 +1072,7 @@ void Octree<T, use_pairs, AL>::_cull_convex(Octant *p_octant, _CullConvexData *p
}
template <class T, bool use_pairs, class AL>
-void Octree<T, use_pairs, AL>::_cull_aabb(Octant *p_octant, const Rect3 &p_aabb, T **p_result_array, int *p_result_idx, int p_result_max, int *p_subindex_array, uint32_t p_mask) {
+void Octree<T, use_pairs, AL>::_cull_aabb(Octant *p_octant, const AABB &p_aabb, T **p_result_array, int *p_result_idx, int p_result_max, int *p_subindex_array, uint32_t p_mask) {
if (*p_result_idx == p_result_max)
return; //pointless
@@ -1313,7 +1313,7 @@ int Octree<T, use_pairs, AL>::cull_convex(const Vector<Plane> &p_convex, T **p_r
}
template <class T, bool use_pairs, class AL>
-int Octree<T, use_pairs, AL>::cull_aabb(const Rect3 &p_aabb, T **p_result_array, int p_result_max, int *p_subindex_array, uint32_t p_mask) {
+int Octree<T, use_pairs, AL>::cull_aabb(const AABB &p_aabb, T **p_result_array, int p_result_max, int *p_subindex_array, uint32_t p_mask) {
if (!root)
return 0;
diff --git a/core/math/quick_hull.cpp b/core/math/quick_hull.cpp
index e0137b6921..946d9f6b79 100644
--- a/core/math/quick_hull.cpp
+++ b/core/math/quick_hull.cpp
@@ -38,7 +38,7 @@ Error QuickHull::build(const Vector<Vector3> &p_points, Geometry::MeshData &r_me
/* CREATE AABB VOLUME */
- Rect3 aabb;
+ AABB aabb;
for (int i = 0; i < p_points.size(); i++) {
if (i == 0) {
diff --git a/core/math/quick_hull.h b/core/math/quick_hull.h
index 47ed22615b..f014d0decc 100644
--- a/core/math/quick_hull.h
+++ b/core/math/quick_hull.h
@@ -30,9 +30,9 @@
#ifndef QUICK_HULL_H
#define QUICK_HULL_H
+#include "aabb.h"
#include "geometry.h"
#include "list.h"
-#include "rect3.h"
#include "set.h"
class QuickHull {
diff --git a/core/math/transform.h b/core/math/transform.h
index 566bf482a9..4d91869121 100644
--- a/core/math/transform.h
+++ b/core/math/transform.h
@@ -30,9 +30,9 @@
#ifndef TRANSFORM_H
#define TRANSFORM_H
+#include "aabb.h"
#include "matrix3.h"
#include "plane.h"
-#include "rect3.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
@@ -80,8 +80,8 @@ public:
_FORCE_INLINE_ Plane xform(const Plane &p_plane) const;
_FORCE_INLINE_ Plane xform_inv(const Plane &p_plane) const;
- _FORCE_INLINE_ Rect3 xform(const Rect3 &p_aabb) const;
- _FORCE_INLINE_ Rect3 xform_inv(const Rect3 &p_aabb) const;
+ _FORCE_INLINE_ AABB xform(const AABB &p_aabb) const;
+ _FORCE_INLINE_ AABB xform_inv(const AABB &p_aabb) const;
void operator*=(const Transform &p_transform);
Transform operator*(const Transform &p_transform) const;
@@ -153,14 +153,14 @@ _FORCE_INLINE_ Plane Transform::xform_inv(const Plane &p_plane) const {
return Plane(normal, d);
}
-_FORCE_INLINE_ Rect3 Transform::xform(const Rect3 &p_aabb) const {
+_FORCE_INLINE_ AABB Transform::xform(const AABB &p_aabb) const {
/* define vertices */
Vector3 x = basis.get_axis(0) * p_aabb.size.x;
Vector3 y = basis.get_axis(1) * p_aabb.size.y;
Vector3 z = basis.get_axis(2) * p_aabb.size.z;
Vector3 pos = xform(p_aabb.position);
//could be even further optimized
- Rect3 new_aabb;
+ AABB new_aabb;
new_aabb.position = pos;
new_aabb.expand_to(pos + x);
new_aabb.expand_to(pos + y);
@@ -172,7 +172,7 @@ _FORCE_INLINE_ Rect3 Transform::xform(const Rect3 &p_aabb) const {
return new_aabb;
}
-_FORCE_INLINE_ Rect3 Transform::xform_inv(const Rect3 &p_aabb) const {
+_FORCE_INLINE_ AABB Transform::xform_inv(const AABB &p_aabb) const {
/* define vertices */
Vector3 vertices[8] = {
@@ -186,7 +186,7 @@ _FORCE_INLINE_ Rect3 Transform::xform_inv(const Rect3 &p_aabb) const {
Vector3(p_aabb.position.x, p_aabb.position.y, p_aabb.position.z)
};
- Rect3 ret;
+ AABB ret;
ret.position = xform_inv(vertices[0]);
diff --git a/core/math/triangle_mesh.cpp b/core/math/triangle_mesh.cpp
index 3b246cb183..5f57c7c26a 100644
--- a/core/math/triangle_mesh.cpp
+++ b/core/math/triangle_mesh.cpp
@@ -44,7 +44,7 @@ int TriangleMesh::_create_bvh(BVH *p_bvh, BVH **p_bb, int p_from, int p_size, in
return -1;
}
- Rect3 aabb;
+ AABB aabb;
aabb = p_bb[p_from]->aabb;
for (int i = 1; i < p_size; i++) {
@@ -166,7 +166,7 @@ void TriangleMesh::create(const PoolVector<Vector3> &p_faces) {
valid = true;
}
-Vector3 TriangleMesh::get_area_normal(const Rect3 &p_aabb) const {
+Vector3 TriangleMesh::get_area_normal(const AABB &p_aabb) const {
uint32_t *stack = (uint32_t *)alloca(sizeof(int) * max_depth);
diff --git a/core/math/triangle_mesh.h b/core/math/triangle_mesh.h
index 2bf67fffcb..4bd9fecf37 100644
--- a/core/math/triangle_mesh.h
+++ b/core/math/triangle_mesh.h
@@ -47,7 +47,7 @@ class TriangleMesh : public Reference {
struct BVH {
- Rect3 aabb;
+ AABB aabb;
Vector3 center; //used for sorting
int left;
int right;
@@ -88,7 +88,7 @@ public:
bool is_valid() const;
bool intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_point, Vector3 &r_normal) const;
bool intersect_ray(const Vector3 &p_begin, const Vector3 &p_dir, Vector3 &r_point, Vector3 &r_normal) const;
- Vector3 get_area_normal(const Rect3 &p_aabb) const;
+ Vector3 get_area_normal(const AABB &p_aabb) const;
PoolVector<Face3> get_faces() const;
void create(const PoolVector<Vector3> &p_faces);
diff --git a/core/method_ptrcall.h b/core/method_ptrcall.h
index 2875eb912f..d819dfbc27 100644
--- a/core/method_ptrcall.h
+++ b/core/method_ptrcall.h
@@ -119,7 +119,7 @@ MAKE_PTRARG_BY_REFERENCE(Vector3);
MAKE_PTRARG(Transform2D);
MAKE_PTRARG_BY_REFERENCE(Plane);
MAKE_PTRARG(Quat);
-MAKE_PTRARG_BY_REFERENCE(Rect3);
+MAKE_PTRARG_BY_REFERENCE(AABB);
MAKE_PTRARG_BY_REFERENCE(Basis);
MAKE_PTRARG_BY_REFERENCE(Transform);
MAKE_PTRARG_BY_REFERENCE(Color);
diff --git a/core/packed_data_container.cpp b/core/packed_data_container.cpp
index ad8438e416..3748df12f7 100644
--- a/core/packed_data_container.cpp
+++ b/core/packed_data_container.cpp
@@ -234,7 +234,7 @@ uint32_t PackedDataContainer::_pack(const Variant &p_data, Vector<uint8_t> &tmpd
case Variant::TRANSFORM2D:
case Variant::PLANE:
case Variant::QUAT:
- case Variant::RECT3:
+ case Variant::AABB:
case Variant::BASIS:
case Variant::TRANSFORM:
case Variant::POOL_BYTE_ARRAY:
diff --git a/core/print_string.cpp b/core/print_string.cpp
index 92a04cbf0b..520fb3daec 100644
--- a/core/print_string.cpp
+++ b/core/print_string.cpp
@@ -82,7 +82,25 @@ void print_line(String p_string) {
PrintHandlerList *l = print_handler_list;
while (l) {
- l->printfunc(l->userdata, p_string);
+ l->printfunc(l->userdata, p_string, false);
+ l = l->next;
+ }
+
+ _global_unlock();
+}
+
+void print_error(String p_string) {
+
+ if (!_print_error_enabled)
+ return;
+
+ OS::get_singleton()->printerr("%s\n", p_string.utf8().get_data());
+
+ _global_lock();
+ PrintHandlerList *l = print_handler_list;
+ while (l) {
+
+ l->printfunc(l->userdata, p_string, true);
l = l->next;
}
diff --git a/core/print_string.h b/core/print_string.h
index 9f8420c31a..6b68380b9d 100644
--- a/core/print_string.h
+++ b/core/print_string.h
@@ -34,7 +34,7 @@
extern void (*_print_func)(String);
-typedef void (*PrintHandlerFunc)(void *, const String &p_string);
+typedef void (*PrintHandlerFunc)(void *, const String &p_string, bool p_error);
struct PrintHandlerList {
@@ -56,5 +56,6 @@ void remove_print_handler(PrintHandlerList *p_handler);
extern bool _print_line_enabled;
extern bool _print_error_enabled;
extern void print_line(String p_string);
+extern void print_error(String p_string);
#endif
diff --git a/core/script_debugger_remote.cpp b/core/script_debugger_remote.cpp
index f77fb116c7..5655a4d5e4 100644
--- a/core/script_debugger_remote.cpp
+++ b/core/script_debugger_remote.cpp
@@ -832,7 +832,7 @@ void ScriptDebuggerRemote::send_message(const String &p_message, const Array &p_
mutex->unlock();
}
-void ScriptDebuggerRemote::_print_handler(void *p_this, const String &p_string) {
+void ScriptDebuggerRemote::_print_handler(void *p_this, const String &p_string, bool p_error) {
ScriptDebuggerRemote *sdr = (ScriptDebuggerRemote *)p_this;
diff --git a/core/script_debugger_remote.h b/core/script_debugger_remote.h
index 22137d1350..90d2daf1f8 100644
--- a/core/script_debugger_remote.h
+++ b/core/script_debugger_remote.h
@@ -94,7 +94,7 @@ class ScriptDebuggerRemote : public ScriptDebugger {
uint64_t msec_count;
bool locking; //hack to avoid a deadloop
- static void _print_handler(void *p_this, const String &p_string);
+ static void _print_handler(void *p_this, const String &p_string, bool p_error);
PrintHandlerList phl;
diff --git a/core/type_info.h b/core/type_info.h
index 9fb80af0eb..24d96c51e8 100644
--- a/core/type_info.h
+++ b/core/type_info.h
@@ -82,7 +82,7 @@ MAKE_TYPE_INFO(Vector3, Variant::VECTOR3)
MAKE_TYPE_INFO(Transform2D, Variant::TRANSFORM2D)
MAKE_TYPE_INFO(Plane, Variant::PLANE)
MAKE_TYPE_INFO(Quat, Variant::QUAT)
-MAKE_TYPE_INFO(Rect3, Variant::RECT3)
+MAKE_TYPE_INFO(AABB, Variant::AABB)
MAKE_TYPE_INFO(Basis, Variant::BASIS)
MAKE_TYPE_INFO(Transform, Variant::TRANSFORM)
MAKE_TYPE_INFO(Color, Variant::COLOR)
diff --git a/core/ustring.cpp b/core/ustring.cpp
index 415494ddc8..7c3a784c5b 100644
--- a/core/ustring.cpp
+++ b/core/ustring.cpp
@@ -564,7 +564,7 @@ void String::erase(int p_pos, int p_chars) {
String String::capitalize() const {
- String aux = this->replace("_", " ").to_lower();
+ String aux = this->camelcase_to_underscore(true).replace("_", " ").strip_edges();
String cap;
for (int i = 0; i < aux.get_slice_count(" "); i++) {
diff --git a/core/variant.cpp b/core/variant.cpp
index f70e4a5218..1dca494492 100644
--- a/core/variant.cpp
+++ b/core/variant.cpp
@@ -66,7 +66,7 @@ String Variant::get_type_name(Variant::Type p_type) {
return "String";
} break;
- // math types
+ // math types
case VECTOR2: {
@@ -94,9 +94,9 @@ String Variant::get_type_name(Variant::Type p_type) {
} break;*/
- case RECT3: {
+ case AABB: {
- return "Rect3";
+ return "AABB";
} break;
case QUAT: {
@@ -722,7 +722,7 @@ bool Variant::is_zero() const {
} break;
- // math types
+ // math types
case VECTOR2: {
@@ -754,9 +754,9 @@ bool Variant::is_zero() const {
} break;*/
- case RECT3: {
+ case AABB: {
- return *_data._rect3 == Rect3();
+ return *_data._aabb == ::AABB();
} break;
case QUAT: {
@@ -931,7 +931,7 @@ void Variant::reference(const Variant &p_variant) {
memnew_placement(_data._mem, String(*reinterpret_cast<const String *>(p_variant._data._mem)));
} break;
- // math types
+ // math types
case VECTOR2: {
@@ -954,9 +954,9 @@ void Variant::reference(const Variant &p_variant) {
memnew_placement(_data._mem, Plane(*reinterpret_cast<const Plane *>(p_variant._data._mem)));
} break;
- case RECT3: {
+ case AABB: {
- _data._rect3 = memnew(Rect3(*p_variant._data._rect3));
+ _data._aabb = memnew(::AABB(*p_variant._data._aabb));
} break;
case QUAT: {
@@ -1079,9 +1079,9 @@ void Variant::clear() {
memdelete(_data._transform2d);
} break;
- case RECT3: {
+ case AABB: {
- memdelete(_data._rect3);
+ memdelete(_data._aabb);
} break;
case BASIS: {
@@ -1426,7 +1426,7 @@ Variant::operator String() const {
case PLANE:
return operator Plane();
//case QUAT:
- case RECT3: return operator Rect3();
+ case AABB: return operator ::AABB();
case QUAT: return "(" + operator Quat() + ")";
case BASIS: {
@@ -1617,12 +1617,12 @@ Variant::operator Plane() const {
else
return Plane();
}
-Variant::operator Rect3() const {
+Variant::operator ::AABB() const {
- if (type == RECT3)
- return *_data._rect3;
+ if (type == AABB)
+ return *_data._aabb;
else
- return Rect3();
+ return ::AABB();
}
Variant::operator Basis() const {
@@ -2188,10 +2188,10 @@ Variant::Variant(const Plane &p_plane) {
type = PLANE;
memnew_placement(_data._mem, Plane(p_plane));
}
-Variant::Variant(const Rect3 &p_aabb) {
+Variant::Variant(const ::AABB &p_aabb) {
- type = RECT3;
- _data._rect3 = memnew(Rect3(p_aabb));
+ type = AABB;
+ _data._aabb = memnew(::AABB(p_aabb));
}
Variant::Variant(const Basis &p_matrix) {
@@ -2501,7 +2501,7 @@ void Variant::operator=(const Variant &p_variant) {
*reinterpret_cast<String *>(_data._mem) = *reinterpret_cast<const String *>(p_variant._data._mem);
} break;
- // math types
+ // math types
case VECTOR2: {
@@ -2524,9 +2524,9 @@ void Variant::operator=(const Variant &p_variant) {
*reinterpret_cast<Plane *>(_data._mem) = *reinterpret_cast<const Plane *>(p_variant._data._mem);
} break;
- case RECT3: {
+ case AABB: {
- *_data._rect3 = *(p_variant._data._rect3);
+ *_data._aabb = *(p_variant._data._aabb);
} break;
case QUAT: {
@@ -2641,7 +2641,7 @@ uint32_t Variant::hash() const {
return reinterpret_cast<const String *>(_data._mem)->hash();
} break;
- // math types
+ // math types
case VECTOR2: {
@@ -2686,13 +2686,13 @@ uint32_t Variant::hash() const {
} break;*/
- case RECT3: {
+ case AABB: {
uint32_t hash = 5831;
for (int i = 0; i < 3; i++) {
- hash = hash_djb2_one_float(_data._rect3->position[i], hash);
- hash = hash_djb2_one_float(_data._rect3->size[i], hash);
+ hash = hash_djb2_one_float(_data._aabb->position[i], hash);
+ hash = hash_djb2_one_float(_data._aabb->size[i], hash);
}
return hash;
@@ -2952,9 +2952,9 @@ bool Variant::hash_compare(const Variant &p_variant) const {
(hash_compare_scalar(l->d, r->d));
} break;
- case RECT3: {
- const Rect3 *l = _data._rect3;
- const Rect3 *r = p_variant._data._rect3;
+ case AABB: {
+ const ::AABB *l = _data._aabb;
+ const ::AABB *r = p_variant._data._aabb;
return (hash_compare_vector3(l->position, r->position) &&
(hash_compare_vector3(l->size, r->size)));
diff --git a/core/variant.h b/core/variant.h
index 45066af401..8ba4d576cf 100644
--- a/core/variant.h
+++ b/core/variant.h
@@ -34,6 +34,7 @@
@author Juan Linietsky <reduzio@gmail.com>
*/
+#include "aabb.h"
#include "array.h"
#include "color.h"
#include "dictionary.h"
@@ -45,7 +46,6 @@
#include "node_path.h"
#include "plane.h"
#include "quat.h"
-#include "rect3.h"
#include "ref_ptr.h"
#include "rid.h"
#include "transform.h"
@@ -89,7 +89,7 @@ public:
TRANSFORM2D,
PLANE,
QUAT, // 10
- RECT3,
+ AABB,
BASIS,
TRANSFORM,
@@ -136,7 +136,7 @@ private:
int64_t _int;
double _real;
Transform2D *_transform2d;
- Rect3 *_rect3;
+ ::AABB *_aabb;
Basis *_basis;
Transform *_transform;
RefPtr *_resource;
@@ -184,7 +184,7 @@ public:
operator Rect2() const;
operator Vector3() const;
operator Plane() const;
- operator Rect3() const;
+ operator ::AABB() const;
operator Quat() const;
operator Basis() const;
operator Transform() const;
@@ -253,7 +253,7 @@ public:
Variant(const Rect2 &p_rect2);
Variant(const Vector3 &p_vector3);
Variant(const Plane &p_plane);
- Variant(const Rect3 &p_aabb);
+ Variant(const ::AABB &p_aabb);
Variant(const Quat &p_quat);
Variant(const Basis &p_transform);
Variant(const Transform2D &p_transform);
diff --git a/core/variant_call.cpp b/core/variant_call.cpp
index 05f0478003..9e6aaeb911 100644
--- a/core/variant_call.cpp
+++ b/core/variant_call.cpp
@@ -655,26 +655,26 @@ struct _VariantCall {
#define VCALL_PTR5R(m_type, m_method) \
static void _call_##m_type##_##m_method(Variant &r_ret, Variant &p_self, const Variant **p_args) { r_ret = reinterpret_cast<m_type *>(p_self._data._ptr)->m_method(*p_args[0], *p_args[1], *p_args[2], *p_args[3], *p_args[4]); }
- VCALL_PTR0R(Rect3, get_area);
- VCALL_PTR0R(Rect3, has_no_area);
- VCALL_PTR0R(Rect3, has_no_surface);
- VCALL_PTR1R(Rect3, intersects);
- VCALL_PTR1R(Rect3, encloses);
- VCALL_PTR1R(Rect3, merge);
- VCALL_PTR1R(Rect3, intersection);
- VCALL_PTR1R(Rect3, intersects_plane);
- VCALL_PTR2R(Rect3, intersects_segment);
- VCALL_PTR1R(Rect3, has_point);
- VCALL_PTR1R(Rect3, get_support);
- VCALL_PTR0R(Rect3, get_longest_axis);
- VCALL_PTR0R(Rect3, get_longest_axis_index);
- VCALL_PTR0R(Rect3, get_longest_axis_size);
- VCALL_PTR0R(Rect3, get_shortest_axis);
- VCALL_PTR0R(Rect3, get_shortest_axis_index);
- VCALL_PTR0R(Rect3, get_shortest_axis_size);
- VCALL_PTR1R(Rect3, expand);
- VCALL_PTR1R(Rect3, grow);
- VCALL_PTR1R(Rect3, get_endpoint);
+ VCALL_PTR0R(AABB, get_area);
+ VCALL_PTR0R(AABB, has_no_area);
+ VCALL_PTR0R(AABB, has_no_surface);
+ VCALL_PTR1R(AABB, intersects);
+ VCALL_PTR1R(AABB, encloses);
+ VCALL_PTR1R(AABB, merge);
+ VCALL_PTR1R(AABB, intersection);
+ VCALL_PTR1R(AABB, intersects_plane);
+ VCALL_PTR2R(AABB, intersects_segment);
+ VCALL_PTR1R(AABB, has_point);
+ VCALL_PTR1R(AABB, get_support);
+ VCALL_PTR0R(AABB, get_longest_axis);
+ VCALL_PTR0R(AABB, get_longest_axis_index);
+ VCALL_PTR0R(AABB, get_longest_axis_size);
+ VCALL_PTR0R(AABB, get_shortest_axis);
+ VCALL_PTR0R(AABB, get_shortest_axis_index);
+ VCALL_PTR0R(AABB, get_shortest_axis_size);
+ VCALL_PTR1R(AABB, expand);
+ VCALL_PTR1R(AABB, grow);
+ VCALL_PTR1R(AABB, get_endpoint);
VCALL_PTR0R(Transform2D, inverse);
VCALL_PTR0R(Transform2D, affine_inverse);
@@ -755,7 +755,7 @@ struct _VariantCall {
case Variant::VECTOR3: r_ret = reinterpret_cast<Transform *>(p_self._data._ptr)->xform(p_args[0]->operator Vector3()); return;
case Variant::PLANE: r_ret = reinterpret_cast<Transform *>(p_self._data._ptr)->xform(p_args[0]->operator Plane()); return;
- case Variant::RECT3: r_ret = reinterpret_cast<Transform *>(p_self._data._ptr)->xform(p_args[0]->operator Rect3()); return;
+ case Variant::AABB: r_ret = reinterpret_cast<Transform *>(p_self._data._ptr)->xform(p_args[0]->operator ::AABB()); return;
default: r_ret = Variant();
}
}
@@ -766,7 +766,7 @@ struct _VariantCall {
case Variant::VECTOR3: r_ret = reinterpret_cast<Transform *>(p_self._data._ptr)->xform_inv(p_args[0]->operator Vector3()); return;
case Variant::PLANE: r_ret = reinterpret_cast<Transform *>(p_self._data._ptr)->xform_inv(p_args[0]->operator Plane()); return;
- case Variant::RECT3: r_ret = reinterpret_cast<Transform *>(p_self._data._ptr)->xform_inv(p_args[0]->operator Rect3()); return;
+ case Variant::AABB: r_ret = reinterpret_cast<Transform *>(p_self._data._ptr)->xform_inv(p_args[0]->operator ::AABB()); return;
default: r_ret = Variant();
}
}
@@ -878,9 +878,9 @@ struct _VariantCall {
r_ret = Color::hex(*p_args[0]);
}
- static void Rect3_init1(Variant &r_ret, const Variant **p_args) {
+ static void AABB_init1(Variant &r_ret, const Variant **p_args) {
- r_ret = Rect3(*p_args[0], *p_args[1]);
+ r_ret = ::AABB(*p_args[0], *p_args[1]);
}
static void Basis_init1(Variant &r_ret, const Variant **p_args) {
@@ -1058,8 +1058,8 @@ Variant Variant::construct(const Variant::Type p_type, const Variant **p_args, i
case TRANSFORM2D: return Transform2D();
case PLANE: return Plane();
case QUAT: return Quat();
- case RECT3:
- return Rect3(); // 10
+ case AABB:
+ return ::AABB(); // 10
case BASIS: return Basis();
case TRANSFORM:
return Transform();
@@ -1138,8 +1138,8 @@ Variant Variant::construct(const Variant::Type p_type, const Variant **p_args, i
case VECTOR3: return (Vector3(*p_args[0]));
case PLANE: return (Plane(*p_args[0]));
case QUAT: return (Quat(*p_args[0]));
- case RECT3:
- return (Rect3(*p_args[0])); // 10
+ case AABB:
+ return (::AABB(*p_args[0])); // 10
case BASIS: return (Basis(p_args[0]->operator Basis()));
case TRANSFORM:
return (Transform(p_args[0]->operator Transform()));
@@ -1707,26 +1707,26 @@ void register_variant_methods() {
//pointerbased
- ADDFUNC0R(RECT3, REAL, Rect3, get_area, varray());
- ADDFUNC0R(RECT3, BOOL, Rect3, has_no_area, varray());
- ADDFUNC0R(RECT3, BOOL, Rect3, has_no_surface, varray());
- ADDFUNC1R(RECT3, BOOL, Rect3, intersects, RECT3, "with", varray());
- ADDFUNC1R(RECT3, BOOL, Rect3, encloses, RECT3, "with", varray());
- ADDFUNC1R(RECT3, RECT3, Rect3, merge, RECT3, "with", varray());
- ADDFUNC1R(RECT3, RECT3, Rect3, intersection, RECT3, "with", varray());
- ADDFUNC1R(RECT3, BOOL, Rect3, intersects_plane, PLANE, "plane", varray());
- ADDFUNC2R(RECT3, BOOL, Rect3, intersects_segment, VECTOR3, "from", VECTOR3, "to", varray());
- ADDFUNC1R(RECT3, BOOL, Rect3, has_point, VECTOR3, "point", varray());
- ADDFUNC1R(RECT3, VECTOR3, Rect3, get_support, VECTOR3, "dir", varray());
- ADDFUNC0R(RECT3, VECTOR3, Rect3, get_longest_axis, varray());
- ADDFUNC0R(RECT3, INT, Rect3, get_longest_axis_index, varray());
- ADDFUNC0R(RECT3, REAL, Rect3, get_longest_axis_size, varray());
- ADDFUNC0R(RECT3, VECTOR3, Rect3, get_shortest_axis, varray());
- ADDFUNC0R(RECT3, INT, Rect3, get_shortest_axis_index, varray());
- ADDFUNC0R(RECT3, REAL, Rect3, get_shortest_axis_size, varray());
- ADDFUNC1R(RECT3, RECT3, Rect3, expand, VECTOR3, "to_point", varray());
- ADDFUNC1R(RECT3, RECT3, Rect3, grow, REAL, "by", varray());
- ADDFUNC1R(RECT3, VECTOR3, Rect3, get_endpoint, INT, "idx", varray());
+ ADDFUNC0R(AABB, REAL, AABB, get_area, varray());
+ ADDFUNC0R(AABB, BOOL, AABB, has_no_area, varray());
+ ADDFUNC0R(AABB, BOOL, AABB, has_no_surface, varray());
+ ADDFUNC1R(AABB, BOOL, AABB, intersects, AABB, "with", varray());
+ ADDFUNC1R(AABB, BOOL, AABB, encloses, AABB, "with", varray());
+ ADDFUNC1R(AABB, AABB, AABB, merge, AABB, "with", varray());
+ ADDFUNC1R(AABB, AABB, AABB, intersection, AABB, "with", varray());
+ ADDFUNC1R(AABB, BOOL, AABB, intersects_plane, PLANE, "plane", varray());
+ ADDFUNC2R(AABB, BOOL, AABB, intersects_segment, VECTOR3, "from", VECTOR3, "to", varray());
+ ADDFUNC1R(AABB, BOOL, AABB, has_point, VECTOR3, "point", varray());
+ ADDFUNC1R(AABB, VECTOR3, AABB, get_support, VECTOR3, "dir", varray());
+ ADDFUNC0R(AABB, VECTOR3, AABB, get_longest_axis, varray());
+ ADDFUNC0R(AABB, INT, AABB, get_longest_axis_index, varray());
+ ADDFUNC0R(AABB, REAL, AABB, get_longest_axis_size, varray());
+ ADDFUNC0R(AABB, VECTOR3, AABB, get_shortest_axis, varray());
+ ADDFUNC0R(AABB, INT, AABB, get_shortest_axis_index, varray());
+ ADDFUNC0R(AABB, REAL, AABB, get_shortest_axis_size, varray());
+ ADDFUNC1R(AABB, AABB, AABB, expand, VECTOR3, "to_point", varray());
+ ADDFUNC1R(AABB, AABB, AABB, grow, REAL, "by", varray());
+ ADDFUNC1R(AABB, VECTOR3, AABB, get_endpoint, INT, "idx", varray());
ADDFUNC0R(TRANSFORM2D, TRANSFORM2D, Transform2D, inverse, varray());
ADDFUNC0R(TRANSFORM2D, TRANSFORM2D, Transform2D, affine_inverse, varray());
@@ -1791,7 +1791,7 @@ void register_variant_methods() {
_VariantCall::add_constructor(_VariantCall::Color_init1, Variant::COLOR, "r", Variant::REAL, "g", Variant::REAL, "b", Variant::REAL, "a", Variant::REAL);
_VariantCall::add_constructor(_VariantCall::Color_init2, Variant::COLOR, "r", Variant::REAL, "g", Variant::REAL, "b", Variant::REAL);
- _VariantCall::add_constructor(_VariantCall::Rect3_init1, Variant::RECT3, "position", Variant::VECTOR3, "size", Variant::VECTOR3);
+ _VariantCall::add_constructor(_VariantCall::AABB_init1, Variant::AABB, "position", Variant::VECTOR3, "size", Variant::VECTOR3);
_VariantCall::add_constructor(_VariantCall::Basis_init1, Variant::BASIS, "x_axis", Variant::VECTOR3, "y_axis", Variant::VECTOR3, "z_axis", Variant::VECTOR3);
_VariantCall::add_constructor(_VariantCall::Basis_init2, Variant::BASIS, "axis", Variant::VECTOR3, "phi", Variant::REAL);
diff --git a/core/variant_op.cpp b/core/variant_op.cpp
index 6362090902..c793d70ed8 100644
--- a/core/variant_op.cpp
+++ b/core/variant_op.cpp
@@ -48,7 +48,7 @@
CASE_TYPE(PREFIX, OP, TRANSFORM2D) \
CASE_TYPE(PREFIX, OP, PLANE) \
CASE_TYPE(PREFIX, OP, QUAT) \
- CASE_TYPE(PREFIX, OP, RECT3) \
+ CASE_TYPE(PREFIX, OP, AABB) \
CASE_TYPE(PREFIX, OP, BASIS) \
CASE_TYPE(PREFIX, OP, TRANSFORM) \
CASE_TYPE(PREFIX, OP, COLOR) \
@@ -81,7 +81,7 @@
TYPE(PREFIX, OP, TRANSFORM2D), \
TYPE(PREFIX, OP, PLANE), \
TYPE(PREFIX, OP, QUAT), \
- TYPE(PREFIX, OP, RECT3), \
+ TYPE(PREFIX, OP, AABB), \
TYPE(PREFIX, OP, BASIS), \
TYPE(PREFIX, OP, TRANSFORM), \
TYPE(PREFIX, OP, COLOR), \
@@ -465,7 +465,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a,
DEFAULT_OP_LOCALMEM_NULL(math, OP_EQUAL, VECTOR3, ==, Vector3);
DEFAULT_OP_LOCALMEM_NULL(math, OP_EQUAL, PLANE, ==, Plane);
DEFAULT_OP_LOCALMEM_NULL(math, OP_EQUAL, QUAT, ==, Quat);
- DEFAULT_OP_PTRREF_NULL(math, OP_EQUAL, RECT3, ==, _rect3);
+ DEFAULT_OP_PTRREF_NULL(math, OP_EQUAL, AABB, ==, _aabb);
DEFAULT_OP_PTRREF_NULL(math, OP_EQUAL, BASIS, ==, _basis);
DEFAULT_OP_PTRREF_NULL(math, OP_EQUAL, TRANSFORM, ==, _transform);
DEFAULT_OP_LOCALMEM_NULL(math, OP_EQUAL, COLOR, ==, Color);
@@ -555,7 +555,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a,
DEFAULT_OP_LOCALMEM_NULL(math, OP_NOT_EQUAL, VECTOR3, !=, Vector3);
DEFAULT_OP_LOCALMEM_NULL(math, OP_NOT_EQUAL, PLANE, !=, Plane);
DEFAULT_OP_LOCALMEM_NULL(math, OP_NOT_EQUAL, QUAT, !=, Quat);
- DEFAULT_OP_PTRREF_NULL(math, OP_NOT_EQUAL, RECT3, !=, _rect3);
+ DEFAULT_OP_PTRREF_NULL(math, OP_NOT_EQUAL, AABB, !=, _aabb);
DEFAULT_OP_PTRREF_NULL(math, OP_NOT_EQUAL, BASIS, !=, _basis);
DEFAULT_OP_PTRREF_NULL(math, OP_NOT_EQUAL, TRANSFORM, !=, _transform);
DEFAULT_OP_LOCALMEM_NULL(math, OP_NOT_EQUAL, COLOR, !=, Color);
@@ -629,7 +629,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a,
CASE_TYPE(math, OP_LESS, TRANSFORM2D)
CASE_TYPE(math, OP_LESS, PLANE)
CASE_TYPE(math, OP_LESS, QUAT)
- CASE_TYPE(math, OP_LESS, RECT3)
+ CASE_TYPE(math, OP_LESS, AABB)
CASE_TYPE(math, OP_LESS, BASIS)
CASE_TYPE(math, OP_LESS, TRANSFORM)
CASE_TYPE(math, OP_LESS, COLOR)
@@ -658,7 +658,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a,
CASE_TYPE(math, OP_LESS_EQUAL, TRANSFORM2D)
CASE_TYPE(math, OP_LESS_EQUAL, PLANE)
CASE_TYPE(math, OP_LESS_EQUAL, QUAT)
- CASE_TYPE(math, OP_LESS_EQUAL, RECT3)
+ CASE_TYPE(math, OP_LESS_EQUAL, AABB)
CASE_TYPE(math, OP_LESS_EQUAL, BASIS)
CASE_TYPE(math, OP_LESS_EQUAL, TRANSFORM)
CASE_TYPE(math, OP_LESS_EQUAL, COLOR)
@@ -733,7 +733,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a,
CASE_TYPE(math, OP_GREATER, TRANSFORM2D)
CASE_TYPE(math, OP_GREATER, PLANE)
CASE_TYPE(math, OP_GREATER, QUAT)
- CASE_TYPE(math, OP_GREATER, RECT3)
+ CASE_TYPE(math, OP_GREATER, AABB)
CASE_TYPE(math, OP_GREATER, BASIS)
CASE_TYPE(math, OP_GREATER, TRANSFORM)
CASE_TYPE(math, OP_GREATER, COLOR)
@@ -762,7 +762,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a,
CASE_TYPE(math, OP_GREATER_EQUAL, TRANSFORM2D)
CASE_TYPE(math, OP_GREATER_EQUAL, PLANE)
CASE_TYPE(math, OP_GREATER_EQUAL, QUAT)
- CASE_TYPE(math, OP_GREATER_EQUAL, RECT3)
+ CASE_TYPE(math, OP_GREATER_EQUAL, AABB)
CASE_TYPE(math, OP_GREATER_EQUAL, BASIS)
CASE_TYPE(math, OP_GREATER_EQUAL, TRANSFORM)
CASE_TYPE(math, OP_GREATER_EQUAL, COLOR)
@@ -818,7 +818,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a,
CASE_TYPE(math, OP_ADD, RECT2)
CASE_TYPE(math, OP_ADD, TRANSFORM2D)
CASE_TYPE(math, OP_ADD, PLANE)
- CASE_TYPE(math, OP_ADD, RECT3)
+ CASE_TYPE(math, OP_ADD, AABB)
CASE_TYPE(math, OP_ADD, BASIS)
CASE_TYPE(math, OP_ADD, TRANSFORM)
CASE_TYPE(math, OP_ADD, NODE_PATH)
@@ -842,7 +842,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a,
CASE_TYPE(math, OP_SUBTRACT, RECT2)
CASE_TYPE(math, OP_SUBTRACT, TRANSFORM2D)
CASE_TYPE(math, OP_SUBTRACT, PLANE)
- CASE_TYPE(math, OP_SUBTRACT, RECT3)
+ CASE_TYPE(math, OP_SUBTRACT, AABB)
CASE_TYPE(math, OP_SUBTRACT, BASIS)
CASE_TYPE(math, OP_SUBTRACT, TRANSFORM)
CASE_TYPE(math, OP_SUBTRACT, NODE_PATH)
@@ -923,7 +923,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a,
CASE_TYPE(math, OP_MULTIPLY, STRING)
CASE_TYPE(math, OP_MULTIPLY, RECT2)
CASE_TYPE(math, OP_MULTIPLY, PLANE)
- CASE_TYPE(math, OP_MULTIPLY, RECT3)
+ CASE_TYPE(math, OP_MULTIPLY, AABB)
CASE_TYPE(math, OP_MULTIPLY, NODE_PATH)
CASE_TYPE(math, OP_MULTIPLY, _RID)
CASE_TYPE(math, OP_MULTIPLY, OBJECT)
@@ -964,7 +964,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a,
CASE_TYPE(math, OP_DIVIDE, RECT2)
CASE_TYPE(math, OP_DIVIDE, TRANSFORM2D)
CASE_TYPE(math, OP_DIVIDE, PLANE)
- CASE_TYPE(math, OP_DIVIDE, RECT3)
+ CASE_TYPE(math, OP_DIVIDE, AABB)
CASE_TYPE(math, OP_DIVIDE, BASIS)
CASE_TYPE(math, OP_DIVIDE, TRANSFORM)
CASE_TYPE(math, OP_DIVIDE, NODE_PATH)
@@ -995,7 +995,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a,
CASE_TYPE(math, OP_POSITIVE, STRING)
CASE_TYPE(math, OP_POSITIVE, RECT2)
CASE_TYPE(math, OP_POSITIVE, TRANSFORM2D)
- CASE_TYPE(math, OP_POSITIVE, RECT3)
+ CASE_TYPE(math, OP_POSITIVE, AABB)
CASE_TYPE(math, OP_POSITIVE, BASIS)
CASE_TYPE(math, OP_POSITIVE, TRANSFORM)
CASE_TYPE(math, OP_POSITIVE, COLOR)
@@ -1029,7 +1029,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a,
CASE_TYPE(math, OP_NEGATE, STRING)
CASE_TYPE(math, OP_NEGATE, RECT2)
CASE_TYPE(math, OP_NEGATE, TRANSFORM2D)
- CASE_TYPE(math, OP_NEGATE, RECT3)
+ CASE_TYPE(math, OP_NEGATE, AABB)
CASE_TYPE(math, OP_NEGATE, BASIS)
CASE_TYPE(math, OP_NEGATE, TRANSFORM)
CASE_TYPE(math, OP_NEGATE, NODE_PATH)
@@ -1088,7 +1088,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a,
CASE_TYPE(math, OP_MODULE, TRANSFORM2D)
CASE_TYPE(math, OP_MODULE, PLANE)
CASE_TYPE(math, OP_MODULE, QUAT)
- CASE_TYPE(math, OP_MODULE, RECT3)
+ CASE_TYPE(math, OP_MODULE, AABB)
CASE_TYPE(math, OP_MODULE, BASIS)
CASE_TYPE(math, OP_MODULE, TRANSFORM)
CASE_TYPE(math, OP_MODULE, COLOR)
@@ -1384,10 +1384,10 @@ void Variant::set_named(const StringName &p_index, const Variant &p_value, bool
}
} break; // 10
- case RECT3: {
+ case AABB: {
if (p_value.type == Variant::VECTOR3) {
- Rect3 *v = _data._rect3;
+ ::AABB *v = _data._aabb;
//scalar name
if (p_index == CoreStringNames::singleton->position) {
v->position = *reinterpret_cast<const Vector3 *>(p_value._data._mem);
@@ -1609,9 +1609,9 @@ Variant Variant::get_named(const StringName &p_index, bool *r_valid) const {
}
} break; // 10
- case RECT3: {
+ case AABB: {
- const Rect3 *v = _data._rect3;
+ const ::AABB *v = _data._aabb;
//scalar name
if (p_index == CoreStringNames::singleton->position) {
return v->position;
@@ -1982,7 +1982,7 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid)
}
} break; // 10
- case RECT3: {
+ case AABB: {
if (p_value.type != Variant::VECTOR3)
return;
@@ -1991,7 +1991,7 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid)
//scalar name
const String *str = reinterpret_cast<const String *>(p_index._data._mem);
- Rect3 *v = _data._rect3;
+ ::AABB *v = _data._aabb;
if (*str == "position") {
valid = true;
v->position = p_value;
@@ -2400,13 +2400,13 @@ Variant Variant::get(const Variant &p_index, bool *r_valid) const {
}
} break; // 10
- case RECT3: {
+ case AABB: {
if (p_index.get_type() == Variant::STRING) {
//scalar name
const String *str = reinterpret_cast<const String *>(p_index._data._mem);
- const Rect3 *v = _data._rect3;
+ const ::AABB *v = _data._aabb;
if (*str == "position") {
valid = true;
return v->position;
@@ -2835,7 +2835,7 @@ void Variant::get_property_list(List<PropertyInfo> *p_list) const {
p_list->push_back(PropertyInfo(Variant::REAL, "w"));
} break; // 10
- case RECT3: {
+ case AABB: {
p_list->push_back(PropertyInfo(Variant::VECTOR3, "position"));
p_list->push_back(PropertyInfo(Variant::VECTOR3, "size"));
p_list->push_back(PropertyInfo(Variant::VECTOR3, "end"));
@@ -3457,10 +3457,10 @@ void Variant::blend(const Variant &a, const Variant &b, float c, Variant &r_dst)
r_dst = *reinterpret_cast<const Vector3 *>(a._data._mem) + *reinterpret_cast<const Vector3 *>(b._data._mem) * c;
}
return;
- case RECT3: {
- const Rect3 *ra = reinterpret_cast<const Rect3 *>(a._data._mem);
- const Rect3 *rb = reinterpret_cast<const Rect3 *>(b._data._mem);
- r_dst = Rect3(ra->position + rb->position * c, ra->size + rb->size * c);
+ case AABB: {
+ const ::AABB *ra = reinterpret_cast<const ::AABB *>(a._data._mem);
+ const ::AABB *rb = reinterpret_cast<const ::AABB *>(b._data._mem);
+ r_dst = ::AABB(ra->position + rb->position * c, ra->size + rb->size * c);
}
return;
case QUAT: {
@@ -3591,8 +3591,8 @@ void Variant::interpolate(const Variant &a, const Variant &b, float c, Variant &
r_dst = reinterpret_cast<const Quat *>(a._data._mem)->slerp(*reinterpret_cast<const Quat *>(b._data._mem), c);
}
return;
- case RECT3: {
- r_dst = Rect3(a._data._rect3->position.linear_interpolate(b._data._rect3->position, c), a._data._rect3->size.linear_interpolate(b._data._rect3->size, c));
+ case AABB: {
+ r_dst = ::AABB(a._data._aabb->position.linear_interpolate(b._data._aabb->position, c), a._data._aabb->size.linear_interpolate(b._data._aabb->size, c));
}
return;
case BASIS: {
diff --git a/core/variant_parser.cpp b/core/variant_parser.cpp
index d60d10cd3a..1552b62c64 100644
--- a/core/variant_parser.cpp
+++ b/core/variant_parser.cpp
@@ -595,7 +595,7 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
value = Quat(args[0], args[1], args[2], args[3]);
return OK;
- } else if (id == "Rect3" || id == "AABB") {
+ } else if (id == "AABB") {
Vector<float> args;
Error err = _parse_construct<float>(p_stream, args, line, r_err_str);
@@ -606,7 +606,7 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream,
r_err_str = "Expected 6 arguments for constructor";
}
- value = Rect3(Vector3(args[0], args[1], args[2]), Vector3(args[3], args[4], args[5]));
+ value = AABB(Vector3(args[0], args[1], args[2]), Vector3(args[3], args[4], args[5]));
return OK;
} else if (id == "Basis" || id == "Matrix3") { //compatibility
@@ -1634,10 +1634,10 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str
p_store_string_func(p_store_string_ud, "Plane( " + rtosfix(p.normal.x) + ", " + rtosfix(p.normal.y) + ", " + rtosfix(p.normal.z) + ", " + rtosfix(p.d) + " )");
} break;
- case Variant::RECT3: {
+ case Variant::AABB: {
- Rect3 aabb = p_variant;
- p_store_string_func(p_store_string_ud, "Rect3( " + rtosfix(aabb.position.x) + ", " + rtosfix(aabb.position.y) + ", " + rtosfix(aabb.position.z) + ", " + rtosfix(aabb.size.x) + ", " + rtosfix(aabb.size.y) + ", " + rtosfix(aabb.size.z) + " )");
+ AABB aabb = p_variant;
+ p_store_string_func(p_store_string_ud, "AABB( " + rtosfix(aabb.position.x) + ", " + rtosfix(aabb.position.y) + ", " + rtosfix(aabb.position.z) + ", " + rtosfix(aabb.size.x) + ", " + rtosfix(aabb.size.y) + ", " + rtosfix(aabb.size.z) + " )");
} break;
case Variant::QUAT: {
diff --git a/doc/classes/@GDScript.xml b/doc/classes/@GDScript.xml
index 3f2d0c71e7..49ec412ba0 100644
--- a/doc/classes/@GDScript.xml
+++ b/doc/classes/@GDScript.xml
@@ -1103,14 +1103,14 @@
</description>
</method>
<method name="yield">
- <return type="GDFunctionState">
+ <return type="GDScriptFunctionState">
</return>
<argument index="0" name="object" type="Object">
</argument>
<argument index="1" name="signal" type="String">
</argument>
<description>
- Stops the function execution and returns the current state. Call [method GDFunctionState.resume] on the state to resume execution. This invalidates the state.
+ Stops the function execution and returns the current state. Call [method GDScriptFunctionState.resume] on the state to resume execution. This invalidates the state.
Returns anything that was passed to the resume function call. If passed an object and a signal, the execution is resumed when the object's signal is emitted.
</description>
</method>
diff --git a/doc/classes/@GlobalScope.xml b/doc/classes/@GlobalScope.xml
index 98f2cf1896..d9bdf0e3cf 100644
--- a/doc/classes/@GlobalScope.xml
+++ b/doc/classes/@GlobalScope.xml
@@ -1334,8 +1334,8 @@
<constant name="TYPE_QUAT" value="10">
Variable is of type [Quat].
</constant>
- <constant name="TYPE_RECT3" value="11">
- Variable is of type [Rect3].
+ <constant name="TYPE_AABB" value="11">
+ Variable is of type [AABB].
</constant>
<constant name="TYPE_BASIS" value="12">
Variable is of type [Basis].
diff --git a/doc/classes/Rect3.xml b/doc/classes/AABB.xml
index 88be5fa419..494dcb8fce 100644
--- a/doc/classes/Rect3.xml
+++ b/doc/classes/AABB.xml
@@ -1,18 +1,18 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="Rect3" category="Built-In Types" version="3.0-alpha">
+<class name="AABB" category="Built-In Types" version="3.0-alpha">
<brief_description>
Axis-Aligned Bounding Box.
</brief_description>
<description>
- Rect3 consists of a position, a size, and several utility functions. It is typically used for fast overlap tests.
+ AABB consists of a position, a size, and several utility functions. It is typically used for fast overlap tests.
</description>
<tutorials>
</tutorials>
<demos>
</demos>
<methods>
- <method name="Rect3">
- <return type="Rect3">
+ <method name="AABB">
+ <return type="AABB">
</return>
<argument index="0" name="position" type="Vector3">
</argument>
@@ -25,26 +25,26 @@
<method name="encloses">
<return type="bool">
</return>
- <argument index="0" name="with" type="Rect3">
+ <argument index="0" name="with" type="AABB">
</argument>
<description>
- Returns [code]true[/code] if this [code]Rect3[/code] completely encloses another one.
+ Returns [code]true[/code] if this [code]AABB[/code] completely encloses another one.
</description>
</method>
<method name="expand">
- <return type="Rect3">
+ <return type="AABB">
</return>
<argument index="0" name="to_point" type="Vector3">
</argument>
<description>
- Returns this [code]Rect3[/code] expanded to include a given point.
+ Returns this [code]AABB[/code] expanded to include a given point.
</description>
</method>
<method name="get_area">
<return type="float">
</return>
<description>
- Gets the area of the [code]Rect3[/code].
+ Gets the area of the [code]AABB[/code].
</description>
</method>
<method name="get_endpoint">
@@ -53,49 +53,49 @@
<argument index="0" name="idx" type="int">
</argument>
<description>
- Gets the position of the 8 endpoints of the [code]Rect3[/code] in space.
+ Gets the position of the 8 endpoints of the [code]AABB[/code] in space.
</description>
</method>
<method name="get_longest_axis">
<return type="Vector3">
</return>
<description>
- Returns the normalized longest axis of the [code]Rect3[/code].
+ Returns the normalized longest axis of the [code]AABB[/code].
</description>
</method>
<method name="get_longest_axis_index">
<return type="int">
</return>
<description>
- Returns the index of the longest axis of the [code]Rect3[/code] (according to [Vector3]::AXIS* enum).
+ Returns the index of the longest axis of the [code]AABB[/code] (according to [Vector3]::AXIS* enum).
</description>
</method>
<method name="get_longest_axis_size">
<return type="float">
</return>
<description>
- Returns the scalar length of the longest axis of the [code]Rect3[/code].
+ Returns the scalar length of the longest axis of the [code]AABB[/code].
</description>
</method>
<method name="get_shortest_axis">
<return type="Vector3">
</return>
<description>
- Returns the normalized shortest axis of the [code]Rect3[/code].
+ Returns the normalized shortest axis of the [code]AABB[/code].
</description>
</method>
<method name="get_shortest_axis_index">
<return type="int">
</return>
<description>
- Returns the index of the shortest axis of the [code]Rect3[/code] (according to [Vector3]::AXIS* enum).
+ Returns the index of the shortest axis of the [code]AABB[/code] (according to [Vector3]::AXIS* enum).
</description>
</method>
<method name="get_shortest_axis_size">
<return type="float">
</return>
<description>
- Returns the scalar length of the shortest axis of the [code]Rect3[/code].
+ Returns the scalar length of the shortest axis of the [code]AABB[/code].
</description>
</method>
<method name="get_support">
@@ -108,26 +108,26 @@
</description>
</method>
<method name="grow">
- <return type="Rect3">
+ <return type="AABB">
</return>
<argument index="0" name="by" type="float">
</argument>
<description>
- Returns a copy of the [code]Rect3[/code] grown a given amount of units towards all the sides.
+ Returns a copy of the [code]AABB[/code] grown a given amount of units towards all the sides.
</description>
</method>
<method name="has_no_area">
<return type="bool">
</return>
<description>
- Returns [code]true[/code] if the [code]Rect3[/code] is flat or empty.
+ Returns [code]true[/code] if the [code]AABB[/code] is flat or empty.
</description>
</method>
<method name="has_no_surface">
<return type="bool">
</return>
<description>
- Returns [code]true[/code] if the [code]Rect3[/code] is empty.
+ Returns [code]true[/code] if the [code]AABB[/code] is empty.
</description>
</method>
<method name="has_point">
@@ -136,25 +136,25 @@
<argument index="0" name="point" type="Vector3">
</argument>
<description>
- Returns [code]true[/code] if the [code]Rect3[/code] contains a point.
+ Returns [code]true[/code] if the [code]AABB[/code] contains a point.
</description>
</method>
<method name="intersection">
- <return type="Rect3">
+ <return type="AABB">
</return>
- <argument index="0" name="with" type="Rect3">
+ <argument index="0" name="with" type="AABB">
</argument>
<description>
- Returns the intersection between two [code]Rect3[/code]. An empty Rect3 (size 0,0,0) is returned on failure.
+ Returns the intersection between two [code]AABB[/code]. An empty AABB (size 0,0,0) is returned on failure.
</description>
</method>
<method name="intersects">
<return type="bool">
</return>
- <argument index="0" name="with" type="Rect3">
+ <argument index="0" name="with" type="AABB">
</argument>
<description>
- Returns [code]true[/code] if the [code]Rect3[/code] overlaps with another.
+ Returns [code]true[/code] if the [code]AABB[/code] overlaps with another.
</description>
</method>
<method name="intersects_plane">
@@ -163,7 +163,7 @@
<argument index="0" name="plane" type="Plane">
</argument>
<description>
- Returns [code]true[/code] if the [code]Rect3[/code] is on both sides of a plane.
+ Returns [code]true[/code] if the [code]AABB[/code] is on both sides of a plane.
</description>
</method>
<method name="intersects_segment">
@@ -174,16 +174,16 @@
<argument index="1" name="to" type="Vector3">
</argument>
<description>
- Returns [code]true[/code] if the [code]Rect3[/code] intersects the line segment between [code]from[/code] and [code]to[/code].
+ Returns [code]true[/code] if the [code]AABB[/code] intersects the line segment between [code]from[/code] and [code]to[/code].
</description>
</method>
<method name="merge">
- <return type="Rect3">
+ <return type="AABB">
</return>
- <argument index="0" name="with" type="Rect3">
+ <argument index="0" name="with" type="AABB">
</argument>
<description>
- Returns a larger Rect3 that contains this Rect3 and [code]with[/code].
+ Returns a larger AABB that contains this AABB and [code]with[/code].
</description>
</method>
</methods>
diff --git a/doc/classes/ArrayMesh.xml b/doc/classes/ArrayMesh.xml
index 10456f805d..6c9b191371 100644
--- a/doc/classes/ArrayMesh.xml
+++ b/doc/classes/ArrayMesh.xml
@@ -66,7 +66,7 @@
</description>
</method>
<method name="get_custom_aabb" qualifiers="const">
- <return type="Rect3">
+ <return type="AABB">
</return>
<description>
</description>
@@ -95,7 +95,7 @@
<method name="set_custom_aabb">
<return type="void">
</return>
- <argument index="0" name="aabb" type="Rect3">
+ <argument index="0" name="aabb" type="AABB">
</argument>
<description>
</description>
diff --git a/doc/classes/Control.xml b/doc/classes/Control.xml
index 79870dd411..03871802b7 100644
--- a/doc/classes/Control.xml
+++ b/doc/classes/Control.xml
@@ -228,7 +228,14 @@
<argument index="0" name="margin" type="int" enum="Margin">
</argument>
<description>
- Return the forced neighbour for moving the input focus to. When pressing TAB or directional/joypad directions focus is moved to the next control in that direction. However, the neighbour to move to can be forced with this function.
+ Return the forced neighbour for moving the input focus to. When pressing directional/joypad directions, focus is moved to the next control in that direction. However, the neighbour to move to can be forced with this function.
+ </description>
+ </method>
+ <method name="get_focus_next" qualifiers="const">
+ <return type="NodePath">
+ </return>
+ <description>
+ Return the 'focus_next' for moving input focus to. When pressing TAB, focus is moved to the next control in the tree. However, the control to move to can be forced with this function.
</description>
</method>
<method name="get_focus_owner" qualifiers="const">
@@ -238,6 +245,13 @@
Return which control is owning the keyboard focus, or null if no one.
</description>
</method>
+ <method name="get_focus_previous" qualifiers="const">
+ <return type="NodePath">
+ </return>
+ <description>
+ Return the 'focus_previous' for moving input focus to. When pressing Shift+TAB focus is moved to the previous control in the tree. However, the control to move to can be forced with this function.
+ </description>
+ </method>
<method name="get_font" qualifiers="const">
<return type="Font">
</return>
@@ -676,7 +690,25 @@
<argument index="1" name="neighbour" type="NodePath">
</argument>
<description>
- Force a neighbour for moving the input focus to. When pressing TAB or directional/joypad directions focus is moved to the next control in that direction. However, the neighbour to move to can be forced with this function.
+ Force a neighbour for moving the input focus to. When pressing directional/joypad directions, focus is moved to the next control in that direction. However, the neighbour to move to can be forced with this function.
+ </description>
+ </method>
+ <method name="set_focus_next">
+ <return type="void">
+ </return>
+ <argument index="0" name="next" type="NodePath">
+ </argument>
+ <description>
+ Force the 'focus_next' for moving input focus to. When pressing TAB, focus is moved to the next control in the tree. However, the control to move to can be forced with this function.
+ </description>
+ </method>
+ <method name="set_focus_previous">
+ <return type="void">
+ </return>
+ <argument index="0" name="previous" type="NodePath">
+ </argument>
+ <description>
+ Force the 'focus_previous' for moving input focus to. When pressing Shift+TAB, focus is moved to the previous control in the tree. However, the control to move to can be forced with this function.
</description>
</method>
<method name="set_global_position">
diff --git a/doc/classes/EditorSpatialGizmo.xml b/doc/classes/EditorSpatialGizmo.xml
index e111eec3b9..758024c99b 100644
--- a/doc/classes/EditorSpatialGizmo.xml
+++ b/doc/classes/EditorSpatialGizmo.xml
@@ -24,7 +24,7 @@
</return>
<argument index="0" name="triangles" type="TriangleMesh">
</argument>
- <argument index="1" name="bounds" type="Rect3">
+ <argument index="1" name="bounds" type="AABB">
</argument>
<description>
Add collision triangles to the gizmo for picking. A [TriangleMesh] can be generated from a regular [Mesh] too. Call this function during [method redraw].
diff --git a/doc/classes/GIProbeData.xml b/doc/classes/GIProbeData.xml
index 3777eba6af..5d118be776 100644
--- a/doc/classes/GIProbeData.xml
+++ b/doc/classes/GIProbeData.xml
@@ -16,7 +16,7 @@
</description>
</method>
<method name="get_bounds" qualifiers="const">
- <return type="Rect3">
+ <return type="AABB">
</return>
<description>
</description>
@@ -86,7 +86,7 @@
<method name="set_bounds">
<return type="void">
</return>
- <argument index="0" name="bounds" type="Rect3">
+ <argument index="0" name="bounds" type="AABB">
</argument>
<description>
</description>
@@ -167,7 +167,7 @@
<members>
<member name="bias" type="float" setter="set_bias" getter="get_bias">
</member>
- <member name="bounds" type="Rect3" setter="set_bounds" getter="get_bounds">
+ <member name="bounds" type="AABB" setter="set_bounds" getter="get_bounds">
</member>
<member name="cell_size" type="float" setter="set_cell_size" getter="get_cell_size">
</member>
diff --git a/doc/classes/MultiMesh.xml b/doc/classes/MultiMesh.xml
index 73384c27e4..b6a89d09f4 100644
--- a/doc/classes/MultiMesh.xml
+++ b/doc/classes/MultiMesh.xml
@@ -7,7 +7,7 @@
MultiMesh provides low level mesh instancing. If the amount of [Mesh] instances needed goes from hundreds to thousands (and most need to be visible at close proximity) creating such a large amount of [MeshInstance] nodes may affect performance by using too much CPU or video memory.
For this case a MultiMesh becomes very useful, as it can draw thousands of instances with little API overhead.
As a drawback, if the instances are too far away of each other, performance may be reduced as every single instance will always rendered (they are spatially indexed as one, for the whole object).
- Since instances may have any behavior, the Rect3 used for visibility must be provided by the user.
+ Since instances may have any behavior, the AABB used for visibility must be provided by the user.
</description>
<tutorials>
</tutorials>
@@ -15,10 +15,10 @@
</demos>
<methods>
<method name="get_aabb" qualifiers="const">
- <return type="Rect3">
+ <return type="AABB">
</return>
<description>
- Return the visibility Rect3.
+ Return the visibility AABB.
</description>
</method>
<method name="get_color_format" qualifiers="const">
diff --git a/doc/classes/Nil.xml b/doc/classes/Nil.xml
index 1fccdc0148..a4bd60d53e 100644
--- a/doc/classes/Nil.xml
+++ b/doc/classes/Nil.xml
@@ -100,7 +100,7 @@
</description>
</method>
<method name="Nil">
- <argument index="0" name="from" type="Rect3">
+ <argument index="0" name="from" type="AABB">
</argument>
<description>
</description>
diff --git a/doc/classes/Particles.xml b/doc/classes/Particles.xml
index 4e070f67fd..9a9279b0a7 100644
--- a/doc/classes/Particles.xml
+++ b/doc/classes/Particles.xml
@@ -13,7 +13,7 @@
</demos>
<methods>
<method name="capture_aabb" qualifiers="const">
- <return type="Rect3">
+ <return type="AABB">
</return>
<description>
</description>
@@ -105,7 +105,7 @@
</description>
</method>
<method name="get_visibility_aabb" qualifiers="const">
- <return type="Rect3">
+ <return type="AABB">
</return>
<description>
</description>
@@ -247,7 +247,7 @@
<method name="set_visibility_aabb">
<return type="void">
</return>
- <argument index="0" name="aabb" type="Rect3">
+ <argument index="0" name="aabb" type="AABB">
</argument>
<description>
</description>
@@ -300,7 +300,7 @@
<member name="speed_scale" type="float" setter="set_speed_scale" getter="get_speed_scale">
Speed scaling ratio. Default value: [code]1[/code].
</member>
- <member name="visibility_aabb" type="Rect3" setter="set_visibility_aabb" getter="get_visibility_aabb">
+ <member name="visibility_aabb" type="AABB" setter="set_visibility_aabb" getter="get_visibility_aabb">
</member>
</members>
<constants>
diff --git a/doc/classes/RichTextLabel.xml b/doc/classes/RichTextLabel.xml
index a907e0aa0a..693bd5cf2f 100644
--- a/doc/classes/RichTextLabel.xml
+++ b/doc/classes/RichTextLabel.xml
@@ -4,7 +4,8 @@
Label that displays rich text.
</brief_description>
<description>
- Label that displays rich text. Rich text can contain custom text, fonts, images and some basic formatting. It also adapts itself to given width/heights.
+ Rich text can contain custom text, fonts, images and some basic formatting. The label manages these as an internal tag stack. It also adapts itself to given width/heights.
+ Note that assignments to [member bbcode_text] clear the tag stack and reconstruct it from the property's contents. Any edits made to [member bbcode_text] will erase previous edits made from other manual sources such as [method append_bbcode] and the [code]push_*[/code] / [method pop] methods.
</description>
<tutorials>
</tutorials>
@@ -17,6 +18,7 @@
<argument index="0" name="image" type="Texture">
</argument>
<description>
+ Adds an image's opening and closing tags to the tag stack.
</description>
</method>
<method name="add_text">
@@ -25,6 +27,7 @@
<argument index="0" name="text" type="String">
</argument>
<description>
+ Adds raw non-bbcode-parsed text to the tag stack.
</description>
</method>
<method name="append_bbcode">
@@ -33,27 +36,28 @@
<argument index="0" name="bbcode" type="String">
</argument>
<description>
+ Parses [code]bbcode[/code] and adds tags to the tag stack as needed. Returns the result of the parsing, [code]OK[/code] if successful.
</description>
</method>
<method name="clear">
<return type="void">
</return>
<description>
- Clears the label's text.
+ Clears the tag stack and sets [member bbcode_text] to an empty string.
</description>
</method>
<method name="get_bbcode" qualifiers="const">
<return type="String">
</return>
<description>
- Returns label's BBCode.
+ Returns the bbcode-parsed [member bbcode_text].
</description>
</method>
<method name="get_line_count" qualifiers="const">
<return type="int">
</return>
<description>
- Returns the number of lines in the text.
+ Returns the total number of newlines in the tag stack's text tags. Considers wrapped text as one line.
</description>
</method>
<method name="get_percent_visible" qualifiers="const">
@@ -67,26 +71,28 @@
<return type="int">
</return>
<description>
+ Returns the number of spaces associated with a single tab length. Does not affect "\t" in text tags, only indent tags.
</description>
</method>
<method name="get_text">
<return type="String">
</return>
<description>
- Returns the label's text with the formatting removed.
+ Returns the raw content of [member bbcode_text].
</description>
</method>
<method name="get_total_character_count" qualifiers="const">
<return type="int">
</return>
<description>
- Returns the total number of characters.
+ Returns the total number of characters from text tags. Does not include bbcodes.
</description>
</method>
<method name="get_v_scroll">
<return type="VScrollBar">
</return>
<description>
+ Returns the vertical scrollbar.
</description>
</method>
<method name="get_visible_characters" qualifiers="const">
@@ -106,6 +112,7 @@
<return type="bool">
</return>
<description>
+ Returns [code]true[/code] if the label underlines meta tags such as [url]{text}[/url].
</description>
</method>
<method name="is_overriding_selected_font_color" qualifiers="const">
@@ -118,34 +125,34 @@
<return type="bool">
</return>
<description>
- Returns [code]true[/code] if active scrolling is enabled.
+ Returns [code]true[/code] if the scrollbar is visible. Does not block scrolling completely. See [method scroll_to_line].
</description>
</method>
<method name="is_scroll_following" qualifiers="const">
<return type="bool">
</return>
<description>
+ Returns [code]true[/code] if the window scrolls down to display new content automatically.
</description>
</method>
<method name="is_selection_enabled" qualifiers="const">
<return type="bool">
</return>
<description>
- Returns [code]true[/code] if the label's text can be selected.
+ Returns [code]true[/code] if the label allows text selection.
</description>
</method>
<method name="is_using_bbcode" qualifiers="const">
<return type="bool">
</return>
<description>
- Returns [code]true[/code] if the label has BBCode.
</description>
</method>
<method name="newline">
<return type="void">
</return>
<description>
- Adds a newline to the end of the rich text.
+ Adds a newline tag to the tag stack.
</description>
</method>
<method name="parse_bbcode">
@@ -154,12 +161,14 @@
<argument index="0" name="bbcode" type="String">
</argument>
<description>
+ The assignment version of [method append_bbcode]. Clears the tag stack and inserts the new content. Returns [code]OK[/code] if parses [code]bbcode[/code] successfully.
</description>
</method>
<method name="pop">
<return type="void">
</return>
<description>
+ Terminates the current tag. Use after [code]push_*[/code] methods to close bbcodes manually. Does not need to follow [code]add_*[/code] methods.
</description>
</method>
<method name="push_align">
@@ -168,12 +177,14 @@
<argument index="0" name="align" type="int" enum="RichTextLabel.Align">
</argument>
<description>
+ Adds a [code][right][/code] tag to the tag stack.
</description>
</method>
<method name="push_cell">
<return type="void">
</return>
<description>
+ Adds a [code][cell][/code] tag to the tag stack. Must be inside a [table] tag. See [method push_table] for details.
</description>
</method>
<method name="push_color">
@@ -182,6 +193,7 @@
<argument index="0" name="color" type="Color">
</argument>
<description>
+ Adds a [code][color][/code] tag to the tag stack.
</description>
</method>
<method name="push_font">
@@ -190,6 +202,7 @@
<argument index="0" name="font" type="Font">
</argument>
<description>
+ Adds a [code][font][/code] tag to the tag stack. Overrides default fonts for its duration.
</description>
</method>
<method name="push_indent">
@@ -198,6 +211,7 @@
<argument index="0" name="level" type="int">
</argument>
<description>
+ Adds an [code][indent][/code] tag to the tag stack. Multiplies "level" by current tab_size to determine new margin length.
</description>
</method>
<method name="push_list">
@@ -206,6 +220,7 @@
<argument index="0" name="type" type="int" enum="RichTextLabel.ListType">
</argument>
<description>
+ Adds a list tag to the tag stack. Similar to the bbcodes [code][ol][/code] or [code][ul][/code], but supports more list types. Not fully implemented!
</description>
</method>
<method name="push_meta">
@@ -214,6 +229,7 @@
<argument index="0" name="data" type="Variant">
</argument>
<description>
+ Adds a meta tag to the tag stack. Similar to the bbcode [code][url=something]{text}[/url][/code], but supports non-[String] metadata types.
</description>
</method>
<method name="push_table">
@@ -222,12 +238,14 @@
<argument index="0" name="columns" type="int">
</argument>
<description>
+ Adds a [code][table=columns][/code] tag to the tag stack.
</description>
</method>
<method name="push_underline">
<return type="void">
</return>
<description>
+ Adds a [code][u][/code] tag to the tag stack.
</description>
</method>
<method name="remove_line">
@@ -236,6 +254,7 @@
<argument index="0" name="line" type="int">
</argument>
<description>
+ Removes a line of content from the label. Returns [code]true[/code] if the line exists.
</description>
</method>
<method name="scroll_to_line">
@@ -244,6 +263,7 @@
<argument index="0" name="line" type="int">
</argument>
<description>
+ Scrolls the window's top line to match [code]line[/code].
</description>
</method>
<method name="set_bbcode">
@@ -261,6 +281,7 @@
<argument index="0" name="enable" type="bool">
</argument>
<description>
+ If [code]true[/code] will underline meta tags such as the [url] bbcode. Default value: [code]true[/code].
</description>
</method>
<method name="set_override_selected_font_color">
@@ -286,6 +307,7 @@
<argument index="0" name="active" type="bool">
</argument>
<description>
+ If [code]false[/code] the vertical scrollbar is hidden. Default value: [code]true[/code].
</description>
</method>
<method name="set_scroll_follow">
@@ -294,6 +316,7 @@
<argument index="0" name="follow" type="bool">
</argument>
<description>
+ If [code]true[/code] the window scrolls to reveal new content. Default value: [code]false[/code].
</description>
</method>
<method name="set_selection_enabled">
@@ -311,6 +334,7 @@
<argument index="0" name="spaces" type="int">
</argument>
<description>
+ Sets the current tab length in spaces. Use with [method push_indent] to redefine indent length.
</description>
</method>
<method name="set_table_column_expand">
@@ -323,6 +347,9 @@
<argument index="2" name="ratio" type="int">
</argument>
<description>
+ Edits the selected columns expansion options. If [code]expand[/code] is [code]true[/code], the column expands in proportion to its expansion ratio versus the other columns' ratios.
+ For example, 2 columns with ratios 3 and 4 plus 70 pixels in available width would expand 30 and 40 pixels, respectively.
+ Columns with a [code]false[/code] expand will not contribute to the total ratio.
</description>
</method>
<method name="set_text">
@@ -331,6 +358,7 @@
<argument index="0" name="text" type="String">
</argument>
<description>
+ Clears the tag stack and adds a raw text tag to the top of it. Does not parse bbcodes. Does not modify [member bbcode_text].
</description>
</method>
<method name="set_use_bbcode">
@@ -355,7 +383,7 @@
If [code]true[/code] the label uses BBCode formatting. Default value: [code]false[/code].
</member>
<member name="bbcode_text" type="String" setter="set_bbcode" getter="get_bbcode">
- The label's text in BBCode format.
+ The label's text in BBCode format. Is not representative of manual modifications to the internal tag stack. Erases changes made by other methods when edited.
</member>
<member name="override_selected_font_color" type="bool" setter="set_override_selected_font_color" getter="is_overriding_selected_font_color">
If [code]true[/code] the label uses the custom font color. Default value: [code]false[/code].
@@ -372,6 +400,7 @@
<argument index="0" name="meta" type="Nil">
</argument>
<description>
+ Triggered when the user clicks on content between [url] tags. If the meta is defined in text, e.g. [code][url={"data"="hi"}]hi[/url][/code], then the parameter for this signal will be a [String] type. If a particular type or an object is desired, the [method push_meta] method must be used to manually insert the data into the tag stack.
</description>
</signal>
</signals>
diff --git a/doc/classes/String.xml b/doc/classes/String.xml
index ecf9e54ee7..60c5e75dec 100644
--- a/doc/classes/String.xml
+++ b/doc/classes/String.xml
@@ -95,10 +95,10 @@
<method name="String">
<return type="String">
</return>
- <argument index="0" name="from" type="Rect3">
+ <argument index="0" name="from" type="AABB">
</argument>
<description>
- Constructs a new String from the given [Rect3].
+ Constructs a new String from the given [AABB].
</description>
</method>
<method name="String">
diff --git a/doc/classes/VisibilityNotifier.xml b/doc/classes/VisibilityNotifier.xml
index 1dfa60a5ac..90f1974697 100644
--- a/doc/classes/VisibilityNotifier.xml
+++ b/doc/classes/VisibilityNotifier.xml
@@ -12,7 +12,7 @@
</demos>
<methods>
<method name="get_aabb" qualifiers="const">
- <return type="Rect3">
+ <return type="AABB">
</return>
<description>
Returns the bounding box of the VisibilityNotifier.
@@ -28,7 +28,7 @@
<method name="set_aabb">
<return type="void">
</return>
- <argument index="0" name="rect" type="Rect3">
+ <argument index="0" name="rect" type="AABB">
</argument>
<description>
Set the visibility bounding box of the VisibilityNotifier.
@@ -36,7 +36,7 @@
</method>
</methods>
<members>
- <member name="aabb" type="Rect3" setter="set_aabb" getter="get_aabb">
+ <member name="aabb" type="AABB" setter="set_aabb" getter="get_aabb">
The VisibilityNotifier's bounding box.
</member>
</members>
diff --git a/doc/classes/VisualInstance.xml b/doc/classes/VisualInstance.xml
index be2d38bf9f..7108eb13c5 100644
--- a/doc/classes/VisualInstance.xml
+++ b/doc/classes/VisualInstance.xml
@@ -10,7 +10,7 @@
</demos>
<methods>
<method name="get_aabb" qualifiers="const">
- <return type="Rect3">
+ <return type="AABB">
</return>
<description>
</description>
@@ -22,7 +22,7 @@
</description>
</method>
<method name="get_transformed_aabb" qualifiers="const">
- <return type="Rect3">
+ <return type="AABB">
</return>
<description>
</description>
diff --git a/doc/classes/VisualServer.xml b/doc/classes/VisualServer.xml
index 1030e4ecc0..d716d99e5d 100644
--- a/doc/classes/VisualServer.xml
+++ b/doc/classes/VisualServer.xml
@@ -1035,7 +1035,7 @@
</description>
</method>
<method name="mesh_get_custom_aabb" qualifiers="const">
- <return type="Rect3">
+ <return type="AABB">
</return>
<argument index="0" name="mesh" type="RID">
</argument>
@@ -1085,13 +1085,13 @@
</return>
<argument index="0" name="mesh" type="RID">
</argument>
- <argument index="1" name="aabb" type="Rect3">
+ <argument index="1" name="aabb" type="AABB">
</argument>
<description>
</description>
</method>
<method name="mesh_surface_get_aabb" qualifiers="const">
- <return type="Rect3">
+ <return type="AABB">
</return>
<argument index="0" name="mesh" type="RID">
</argument>
diff --git a/doc/tools/makerst.py b/doc/tools/makerst.py
index dc015d781b..d3ddbaddca 100644
--- a/doc/tools/makerst.py
+++ b/doc/tools/makerst.py
@@ -7,6 +7,7 @@ import os
import xml.etree.ElementTree as ET
input_list = []
+cur_file = ""
for arg in sys.argv[1:]:
if arg.endswith(os.sep):
@@ -217,7 +218,10 @@ def rstize_text(text, cclass):
param = tag_text[space_pos + 1:]
if param.find('.') != -1:
- (class_param, method_param) = param.split('.')
+ ss = param.split('.')
+ if len(ss) > 2:
+ sys.exit("Bad reference: '" + param + "' in file: " + cur_file)
+ (class_param, method_param) = ss
tag_text = ':ref:`' + class_param + '.' + method_param + '<class_' + class_param + '_' + method_param + '>`'
else:
tag_text = ':ref:`' + param + '<class_' + cclass + "_" + param + '>`'
@@ -519,8 +523,8 @@ for path in input_list:
elif os.path.isfile(path) and path.endswith('.xml'):
file_list.append(path)
-for file in file_list:
- tree = ET.parse(file)
+for cur_file in file_list:
+ tree = ET.parse(cur_file)
doc = tree.getroot()
if 'version' not in doc.attrib:
diff --git a/drivers/gles3/rasterizer_canvas_gles3.cpp b/drivers/gles3/rasterizer_canvas_gles3.cpp
index 5d62d2f5a0..42a253bc2d 100644
--- a/drivers/gles3/rasterizer_canvas_gles3.cpp
+++ b/drivers/gles3/rasterizer_canvas_gles3.cpp
@@ -1570,6 +1570,7 @@ void RasterizerCanvasGLES3::reset_canvas() {
glDisable(GL_CULL_FACE);
glDisable(GL_DEPTH_TEST);
glDisable(GL_SCISSOR_TEST);
+ glDisable(GL_DITHER);
glEnable(GL_BLEND);
glBlendEquation(GL_FUNC_ADD);
if (storage->frame.current_rt && storage->frame.current_rt->flags[RasterizerStorage::RENDER_TARGET_TRANSPARENT]) {
diff --git a/drivers/gles3/rasterizer_storage_gles3.cpp b/drivers/gles3/rasterizer_storage_gles3.cpp
index 5071fbba01..004c628252 100644
--- a/drivers/gles3/rasterizer_storage_gles3.cpp
+++ b/drivers/gles3/rasterizer_storage_gles3.cpp
@@ -2600,7 +2600,7 @@ RID RasterizerStorageGLES3::mesh_create() {
return mesh_owner.make_rid(mesh);
}
-void RasterizerStorageGLES3::mesh_add_surface(RID p_mesh, uint32_t p_format, VS::PrimitiveType p_primitive, const PoolVector<uint8_t> &p_array, int p_vertex_count, const PoolVector<uint8_t> &p_index_array, int p_index_count, const Rect3 &p_aabb, const Vector<PoolVector<uint8_t> > &p_blend_shapes, const Vector<Rect3> &p_bone_aabbs) {
+void RasterizerStorageGLES3::mesh_add_surface(RID p_mesh, uint32_t p_format, VS::PrimitiveType p_primitive, const PoolVector<uint8_t> &p_array, int p_vertex_count, const PoolVector<uint8_t> &p_index_array, int p_index_count, const AABB &p_aabb, const Vector<PoolVector<uint8_t> > &p_blend_shapes, const Vector<AABB> &p_bone_aabbs) {
PoolVector<uint8_t> array = p_array;
@@ -3240,11 +3240,11 @@ VS::PrimitiveType RasterizerStorageGLES3::mesh_surface_get_primitive_type(RID p_
return mesh->surfaces[p_surface]->primitive;
}
-Rect3 RasterizerStorageGLES3::mesh_surface_get_aabb(RID p_mesh, int p_surface) const {
+AABB RasterizerStorageGLES3::mesh_surface_get_aabb(RID p_mesh, int p_surface) const {
const Mesh *mesh = mesh_owner.getornull(p_mesh);
- ERR_FAIL_COND_V(!mesh, Rect3());
- ERR_FAIL_INDEX_V(p_surface, mesh->surfaces.size(), Rect3());
+ ERR_FAIL_COND_V(!mesh, AABB());
+ ERR_FAIL_INDEX_V(p_surface, mesh->surfaces.size(), AABB());
return mesh->surfaces[p_surface]->aabb;
}
@@ -3279,11 +3279,11 @@ Vector<PoolVector<uint8_t> > RasterizerStorageGLES3::mesh_surface_get_blend_shap
return bsarr;
}
-Vector<Rect3> RasterizerStorageGLES3::mesh_surface_get_skeleton_aabb(RID p_mesh, int p_surface) const {
+Vector<AABB> RasterizerStorageGLES3::mesh_surface_get_skeleton_aabb(RID p_mesh, int p_surface) const {
const Mesh *mesh = mesh_owner.getornull(p_mesh);
- ERR_FAIL_COND_V(!mesh, Vector<Rect3>());
- ERR_FAIL_INDEX_V(p_surface, mesh->surfaces.size(), Vector<Rect3>());
+ ERR_FAIL_COND_V(!mesh, Vector<AABB>());
+ ERR_FAIL_INDEX_V(p_surface, mesh->surfaces.size(), Vector<AABB>());
return mesh->surfaces[p_surface]->skeleton_bone_aabb;
}
@@ -3337,7 +3337,7 @@ int RasterizerStorageGLES3::mesh_get_surface_count(RID p_mesh) const {
return mesh->surfaces.size();
}
-void RasterizerStorageGLES3::mesh_set_custom_aabb(RID p_mesh, const Rect3 &p_aabb) {
+void RasterizerStorageGLES3::mesh_set_custom_aabb(RID p_mesh, const AABB &p_aabb) {
Mesh *mesh = mesh_owner.getornull(p_mesh);
ERR_FAIL_COND(!mesh);
@@ -3345,37 +3345,37 @@ void RasterizerStorageGLES3::mesh_set_custom_aabb(RID p_mesh, const Rect3 &p_aab
mesh->custom_aabb = p_aabb;
}
-Rect3 RasterizerStorageGLES3::mesh_get_custom_aabb(RID p_mesh) const {
+AABB RasterizerStorageGLES3::mesh_get_custom_aabb(RID p_mesh) const {
const Mesh *mesh = mesh_owner.getornull(p_mesh);
- ERR_FAIL_COND_V(!mesh, Rect3());
+ ERR_FAIL_COND_V(!mesh, AABB());
return mesh->custom_aabb;
}
-Rect3 RasterizerStorageGLES3::mesh_get_aabb(RID p_mesh, RID p_skeleton) const {
+AABB RasterizerStorageGLES3::mesh_get_aabb(RID p_mesh, RID p_skeleton) const {
Mesh *mesh = mesh_owner.get(p_mesh);
- ERR_FAIL_COND_V(!mesh, Rect3());
+ ERR_FAIL_COND_V(!mesh, AABB());
- if (mesh->custom_aabb != Rect3())
+ if (mesh->custom_aabb != AABB())
return mesh->custom_aabb;
Skeleton *sk = NULL;
if (p_skeleton.is_valid())
sk = skeleton_owner.get(p_skeleton);
- Rect3 aabb;
+ AABB aabb;
if (sk && sk->size != 0) {
for (int i = 0; i < mesh->surfaces.size(); i++) {
- Rect3 laabb;
+ AABB laabb;
if ((mesh->surfaces[i]->format & VS::ARRAY_FORMAT_BONES) && mesh->surfaces[i]->skeleton_bone_aabb.size()) {
int bs = mesh->surfaces[i]->skeleton_bone_aabb.size();
- const Rect3 *skbones = mesh->surfaces[i]->skeleton_bone_aabb.ptr();
+ const AABB *skbones = mesh->surfaces[i]->skeleton_bone_aabb.ptr();
const bool *skused = mesh->surfaces[i]->skeleton_bone_used.ptr();
int sbs = sk->size;
@@ -3401,7 +3401,7 @@ Rect3 RasterizerStorageGLES3::mesh_get_aabb(RID p_mesh, RID p_skeleton) const {
mtx.basis[1].y = texture[base_ofs + 1];
mtx.origin.y = texture[base_ofs + 3];
- Rect3 baabb = mtx.xform(skbones[j]);
+ AABB baabb = mtx.xform(skbones[j]);
if (first) {
laabb = baabb;
first = false;
@@ -3434,7 +3434,7 @@ Rect3 RasterizerStorageGLES3::mesh_get_aabb(RID p_mesh, RID p_skeleton) const {
mtx.basis[2].z = texture[base_ofs + 2];
mtx.origin.z = texture[base_ofs + 3];
- Rect3 baabb = mtx.xform(skbones[j]);
+ AABB baabb = mtx.xform(skbones[j]);
if (first) {
laabb = baabb;
first = false;
@@ -4028,10 +4028,10 @@ int RasterizerStorageGLES3::multimesh_get_visible_instances(RID p_multimesh) con
return multimesh->visible_instances;
}
-Rect3 RasterizerStorageGLES3::multimesh_get_aabb(RID p_multimesh) const {
+AABB RasterizerStorageGLES3::multimesh_get_aabb(RID p_multimesh) const {
MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh);
- ERR_FAIL_COND_V(!multimesh, Rect3());
+ ERR_FAIL_COND_V(!multimesh, AABB());
const_cast<RasterizerStorageGLES3 *>(this)->update_dirty_multimeshes(); //update pending AABBs
@@ -4053,7 +4053,7 @@ void RasterizerStorageGLES3::update_dirty_multimeshes() {
if (multimesh->size && multimesh->dirty_aabb) {
- Rect3 mesh_aabb;
+ AABB mesh_aabb;
if (multimesh->mesh.is_valid()) {
mesh_aabb = mesh_get_aabb(multimesh->mesh, RID());
@@ -4065,7 +4065,7 @@ void RasterizerStorageGLES3::update_dirty_multimeshes() {
int count = multimesh->data.size();
float *data = multimesh->data.ptr();
- Rect3 aabb;
+ AABB aabb;
if (multimesh->transform_format == VS::MULTIMESH_TRANSFORM_2D) {
@@ -4080,7 +4080,7 @@ void RasterizerStorageGLES3::update_dirty_multimeshes() {
xform.basis[1][1] = dataptr[5];
xform.origin[1] = dataptr[7];
- Rect3 laabb = xform.xform(mesh_aabb);
+ AABB laabb = xform.xform(mesh_aabb);
if (i == 0)
aabb = laabb;
else
@@ -4106,7 +4106,7 @@ void RasterizerStorageGLES3::update_dirty_multimeshes() {
xform.basis.elements[2][2] = dataptr[10];
xform.origin.z = dataptr[11];
- Rect3 laabb = xform.xform(mesh_aabb);
+ AABB laabb = xform.xform(mesh_aabb);
if (i == 0)
aabb = laabb;
else
@@ -4242,10 +4242,10 @@ void RasterizerStorageGLES3::immediate_clear(RID p_immediate) {
im->instance_change_notify();
}
-Rect3 RasterizerStorageGLES3::immediate_get_aabb(RID p_immediate) const {
+AABB RasterizerStorageGLES3::immediate_get_aabb(RID p_immediate) const {
Immediate *im = immediate_owner.get(p_immediate);
- ERR_FAIL_COND_V(!im, Rect3());
+ ERR_FAIL_COND_V(!im, AABB());
return im->aabb;
}
@@ -4694,10 +4694,10 @@ uint64_t RasterizerStorageGLES3::light_get_version(RID p_light) const {
return light->version;
}
-Rect3 RasterizerStorageGLES3::light_get_aabb(RID p_light) const {
+AABB RasterizerStorageGLES3::light_get_aabb(RID p_light) const {
const Light *light = light_owner.getornull(p_light);
- ERR_FAIL_COND_V(!light, Rect3());
+ ERR_FAIL_COND_V(!light, AABB());
switch (light->type) {
@@ -4705,22 +4705,22 @@ Rect3 RasterizerStorageGLES3::light_get_aabb(RID p_light) const {
float len = light->param[VS::LIGHT_PARAM_RANGE];
float size = Math::tan(Math::deg2rad(light->param[VS::LIGHT_PARAM_SPOT_ANGLE])) * len;
- return Rect3(Vector3(-size, -size, -len), Vector3(size * 2, size * 2, len));
+ return AABB(Vector3(-size, -size, -len), Vector3(size * 2, size * 2, len));
} break;
case VS::LIGHT_OMNI: {
float r = light->param[VS::LIGHT_PARAM_RANGE];
- return Rect3(-Vector3(r, r, r), Vector3(r, r, r) * 2);
+ return AABB(-Vector3(r, r, r), Vector3(r, r, r) * 2);
} break;
case VS::LIGHT_DIRECTIONAL: {
- return Rect3();
+ return AABB();
} break;
default: {}
}
- ERR_FAIL_V(Rect3());
- return Rect3();
+ ERR_FAIL_V(AABB());
+ return AABB();
}
/* PROBE API */
@@ -4842,11 +4842,11 @@ void RasterizerStorageGLES3::reflection_probe_set_cull_mask(RID p_probe, uint32_
reflection_probe->instance_change_notify();
}
-Rect3 RasterizerStorageGLES3::reflection_probe_get_aabb(RID p_probe) const {
+AABB RasterizerStorageGLES3::reflection_probe_get_aabb(RID p_probe) const {
const ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe);
- ERR_FAIL_COND_V(!reflection_probe, Rect3());
+ ERR_FAIL_COND_V(!reflection_probe, AABB());
- Rect3 aabb;
+ AABB aabb;
aabb.position = -reflection_probe->extents;
aabb.size = reflection_probe->extents * 2.0;
@@ -4903,7 +4903,7 @@ RID RasterizerStorageGLES3::gi_probe_create() {
GIProbe *gip = memnew(GIProbe);
- gip->bounds = Rect3(Vector3(), Vector3(1, 1, 1));
+ gip->bounds = AABB(Vector3(), Vector3(1, 1, 1));
gip->dynamic_range = 1.0;
gip->energy = 1.0;
gip->propagation = 1.0;
@@ -4917,7 +4917,7 @@ RID RasterizerStorageGLES3::gi_probe_create() {
return gi_probe_owner.make_rid(gip);
}
-void RasterizerStorageGLES3::gi_probe_set_bounds(RID p_probe, const Rect3 &p_bounds) {
+void RasterizerStorageGLES3::gi_probe_set_bounds(RID p_probe, const AABB &p_bounds) {
GIProbe *gip = gi_probe_owner.getornull(p_probe);
ERR_FAIL_COND(!gip);
@@ -4926,10 +4926,10 @@ void RasterizerStorageGLES3::gi_probe_set_bounds(RID p_probe, const Rect3 &p_bou
gip->version++;
gip->instance_change_notify();
}
-Rect3 RasterizerStorageGLES3::gi_probe_get_bounds(RID p_probe) const {
+AABB RasterizerStorageGLES3::gi_probe_get_bounds(RID p_probe) const {
const GIProbe *gip = gi_probe_owner.getornull(p_probe);
- ERR_FAIL_COND_V(!gip, Rect3());
+ ERR_FAIL_COND_V(!gip, AABB());
return gip->bounds;
}
@@ -5338,7 +5338,7 @@ void RasterizerStorageGLES3::_particles_update_histories(Particles *particles) {
particles->clear = true;
}
-void RasterizerStorageGLES3::particles_set_custom_aabb(RID p_particles, const Rect3 &p_aabb) {
+void RasterizerStorageGLES3::particles_set_custom_aabb(RID p_particles, const AABB &p_aabb) {
Particles *particles = particles_owner.getornull(p_particles);
ERR_FAIL_COND(!particles);
@@ -5429,15 +5429,15 @@ void RasterizerStorageGLES3::particles_request_process(RID p_particles) {
}
}
-Rect3 RasterizerStorageGLES3::particles_get_current_aabb(RID p_particles) {
+AABB RasterizerStorageGLES3::particles_get_current_aabb(RID p_particles) {
const Particles *particles = particles_owner.getornull(p_particles);
- ERR_FAIL_COND_V(!particles, Rect3());
+ ERR_FAIL_COND_V(!particles, AABB());
glBindBuffer(GL_ARRAY_BUFFER, particles->particle_buffers[0]);
float *data = (float *)glMapBufferRange(GL_ARRAY_BUFFER, 0, particles->amount * 16 * 6, GL_MAP_READ_BIT);
- Rect3 aabb;
+ AABB aabb;
Transform inv = particles->emission_transform.affine_inverse();
@@ -5459,7 +5459,7 @@ Rect3 RasterizerStorageGLES3::particles_get_current_aabb(RID p_particles) {
float longest_axis = 0;
for (int i = 0; i < particles->draw_passes.size(); i++) {
if (particles->draw_passes[i].is_valid()) {
- Rect3 maabb = mesh_get_aabb(particles->draw_passes[i], RID());
+ AABB maabb = mesh_get_aabb(particles->draw_passes[i], RID());
longest_axis = MAX(maabb.get_longest_axis_size(), longest_axis);
}
}
@@ -5469,10 +5469,10 @@ Rect3 RasterizerStorageGLES3::particles_get_current_aabb(RID p_particles) {
return aabb;
}
-Rect3 RasterizerStorageGLES3::particles_get_aabb(RID p_particles) const {
+AABB RasterizerStorageGLES3::particles_get_aabb(RID p_particles) const {
const Particles *particles = particles_owner.getornull(p_particles);
- ERR_FAIL_COND_V(!particles, Rect3());
+ ERR_FAIL_COND_V(!particles, AABB());
return particles->custom_aabb;
}
@@ -7027,14 +7027,22 @@ void RasterizerStorageGLES3::initialize() {
glBindBuffer(GL_ARRAY_BUFFER, resources.quadie);
{
const float qv[16] = {
- -1, -1,
- 0, 0,
- -1, 1,
- 0, 1,
- 1, 1,
- 1, 1,
- 1, -1,
- 1, 0,
+ -1,
+ -1,
+ 0,
+ 0,
+ -1,
+ 1,
+ 0,
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ -1,
+ 1,
+ 0,
};
glBufferData(GL_ARRAY_BUFFER, sizeof(float) * 16, qv, GL_STATIC_DRAW);
diff --git a/drivers/gles3/rasterizer_storage_gles3.h b/drivers/gles3/rasterizer_storage_gles3.h
index bd5aad29c9..8aa8235b42 100644
--- a/drivers/gles3/rasterizer_storage_gles3.h
+++ b/drivers/gles3/rasterizer_storage_gles3.h
@@ -592,7 +592,7 @@ public:
GLuint instancing_array_wireframe_id;
int index_wireframe_len;
- Vector<Rect3> skeleton_bone_aabb;
+ Vector<AABB> skeleton_bone_aabb;
Vector<bool> skeleton_bone_used;
//bool packed;
@@ -604,7 +604,7 @@ public:
Vector<BlendShape> blend_shapes;
- Rect3 aabb;
+ AABB aabb;
int array_len;
int index_array_len;
@@ -659,7 +659,7 @@ public:
Vector<Surface *> surfaces;
int blend_shape_count;
VS::BlendShapeMode blend_shape_mode;
- Rect3 custom_aabb;
+ AABB custom_aabb;
mutable uint64_t last_pass;
SelfList<MultiMesh>::List multimeshes;
@@ -684,7 +684,7 @@ public:
virtual RID mesh_create();
- virtual void mesh_add_surface(RID p_mesh, uint32_t p_format, VS::PrimitiveType p_primitive, const PoolVector<uint8_t> &p_array, int p_vertex_count, const PoolVector<uint8_t> &p_index_array, int p_index_count, const Rect3 &p_aabb, const Vector<PoolVector<uint8_t> > &p_blend_shapes = Vector<PoolVector<uint8_t> >(), const Vector<Rect3> &p_bone_aabbs = Vector<Rect3>());
+ virtual void mesh_add_surface(RID p_mesh, uint32_t p_format, VS::PrimitiveType p_primitive, const PoolVector<uint8_t> &p_array, int p_vertex_count, const PoolVector<uint8_t> &p_index_array, int p_index_count, const AABB &p_aabb, const Vector<PoolVector<uint8_t> > &p_blend_shapes = Vector<PoolVector<uint8_t> >(), const Vector<AABB> &p_bone_aabbs = Vector<AABB>());
virtual void mesh_set_blend_shape_count(RID p_mesh, int p_amount);
virtual int mesh_get_blend_shape_count(RID p_mesh) const;
@@ -706,17 +706,17 @@ public:
virtual uint32_t mesh_surface_get_format(RID p_mesh, int p_surface) const;
virtual VS::PrimitiveType mesh_surface_get_primitive_type(RID p_mesh, int p_surface) const;
- virtual Rect3 mesh_surface_get_aabb(RID p_mesh, int p_surface) const;
+ virtual AABB mesh_surface_get_aabb(RID p_mesh, int p_surface) const;
virtual Vector<PoolVector<uint8_t> > mesh_surface_get_blend_shapes(RID p_mesh, int p_surface) const;
- virtual Vector<Rect3> mesh_surface_get_skeleton_aabb(RID p_mesh, int p_surface) const;
+ virtual Vector<AABB> mesh_surface_get_skeleton_aabb(RID p_mesh, int p_surface) const;
virtual void mesh_remove_surface(RID p_mesh, int p_surface);
virtual int mesh_get_surface_count(RID p_mesh) const;
- virtual void mesh_set_custom_aabb(RID p_mesh, const Rect3 &p_aabb);
- virtual Rect3 mesh_get_custom_aabb(RID p_mesh) const;
+ virtual void mesh_set_custom_aabb(RID p_mesh, const AABB &p_aabb);
+ virtual AABB mesh_get_custom_aabb(RID p_mesh) const;
- virtual Rect3 mesh_get_aabb(RID p_mesh, RID p_skeleton) const;
+ virtual AABB mesh_get_aabb(RID p_mesh, RID p_skeleton) const;
virtual void mesh_clear(RID p_mesh);
void mesh_render_blend_shapes(Surface *s, float *p_weights);
@@ -729,7 +729,7 @@ public:
VS::MultimeshTransformFormat transform_format;
VS::MultimeshColorFormat color_format;
Vector<float> data;
- Rect3 aabb;
+ AABB aabb;
SelfList<MultiMesh> update_list;
SelfList<MultiMesh> mesh_list;
GLuint buffer;
@@ -780,7 +780,7 @@ public:
virtual void multimesh_set_visible_instances(RID p_multimesh, int p_visible);
virtual int multimesh_get_visible_instances(RID p_multimesh) const;
- virtual Rect3 multimesh_get_aabb(RID p_multimesh) const;
+ virtual AABB multimesh_get_aabb(RID p_multimesh) const;
/* IMMEDIATE API */
@@ -801,7 +801,7 @@ public:
List<Chunk> chunks;
bool building;
int mask;
- Rect3 aabb;
+ AABB aabb;
Immediate() {
type = GEOMETRY_IMMEDIATE;
@@ -830,7 +830,7 @@ public:
virtual void immediate_clear(RID p_immediate);
virtual void immediate_set_material(RID p_immediate, RID p_material);
virtual RID immediate_get_material(RID p_immediate) const;
- virtual Rect3 immediate_get_aabb(RID p_immediate) const;
+ virtual AABB immediate_get_aabb(RID p_immediate) const;
/* SKELETON API */
@@ -918,7 +918,7 @@ public:
virtual float light_get_param(RID p_light, VS::LightParam p_param);
virtual Color light_get_color(RID p_light);
- virtual Rect3 light_get_aabb(RID p_light) const;
+ virtual AABB light_get_aabb(RID p_light) const;
virtual uint64_t light_get_version(RID p_light) const;
/* PROBE API */
@@ -956,7 +956,7 @@ public:
virtual void reflection_probe_set_enable_shadows(RID p_probe, bool p_enable);
virtual void reflection_probe_set_cull_mask(RID p_probe, uint32_t p_layers);
- virtual Rect3 reflection_probe_get_aabb(RID p_probe) const;
+ virtual AABB reflection_probe_get_aabb(RID p_probe) const;
virtual VS::ReflectionProbeUpdateMode reflection_probe_get_update_mode(RID p_probe) const;
virtual uint32_t reflection_probe_get_cull_mask(RID p_probe) const;
@@ -969,7 +969,7 @@ public:
struct GIProbe : public Instantiable {
- Rect3 bounds;
+ AABB bounds;
Transform to_cell;
float cell_size;
@@ -990,8 +990,8 @@ public:
virtual RID gi_probe_create();
- virtual void gi_probe_set_bounds(RID p_probe, const Rect3 &p_bounds);
- virtual Rect3 gi_probe_get_bounds(RID p_probe) const;
+ virtual void gi_probe_set_bounds(RID p_probe, const AABB &p_bounds);
+ virtual AABB gi_probe_get_bounds(RID p_probe) const;
virtual void gi_probe_set_cell_size(RID p_probe, float p_size);
virtual float gi_probe_get_cell_size(RID p_probe) const;
@@ -1058,7 +1058,7 @@ public:
float explosiveness;
float randomness;
bool restart_request;
- Rect3 custom_aabb;
+ AABB custom_aabb;
bool use_local_coords;
RID process_material;
@@ -1113,7 +1113,7 @@ public:
restart_request = false;
- custom_aabb = Rect3(Vector3(-4, -4, -4), Vector3(8, 8, 8));
+ custom_aabb = AABB(Vector3(-4, -4, -4), Vector3(8, 8, 8));
draw_order = VS::PARTICLES_DRAW_ORDER_INDEX;
particle_buffers[0] = 0;
@@ -1155,7 +1155,7 @@ public:
virtual void particles_set_pre_process_time(RID p_particles, float p_time);
virtual void particles_set_explosiveness_ratio(RID p_particles, float p_ratio);
virtual void particles_set_randomness_ratio(RID p_particles, float p_ratio);
- virtual void particles_set_custom_aabb(RID p_particles, const Rect3 &p_aabb);
+ virtual void particles_set_custom_aabb(RID p_particles, const AABB &p_aabb);
virtual void particles_set_speed_scale(RID p_particles, float p_scale);
virtual void particles_set_use_local_coordinates(RID p_particles, bool p_enable);
virtual void particles_set_process_material(RID p_particles, RID p_material);
@@ -1169,8 +1169,8 @@ public:
virtual void particles_set_draw_pass_mesh(RID p_particles, int p_pass, RID p_mesh);
virtual void particles_request_process(RID p_particles);
- virtual Rect3 particles_get_current_aabb(RID p_particles);
- virtual Rect3 particles_get_aabb(RID p_particles) const;
+ virtual AABB particles_get_current_aabb(RID p_particles);
+ virtual AABB particles_get_aabb(RID p_particles) const;
virtual void _particles_update_histories(Particles *particles);
diff --git a/drivers/gles3/shader_compiler_gles3.cpp b/drivers/gles3/shader_compiler_gles3.cpp
index ad08c59de8..325df8e4f1 100644
--- a/drivers/gles3/shader_compiler_gles3.cpp
+++ b/drivers/gles3/shader_compiler_gles3.cpp
@@ -741,6 +741,7 @@ ShaderCompilerGLES3::ShaderCompilerGLES3() {
actions[VS::SHADER_CANVAS_ITEM].usage_defines["NORMAL"] = "#define NORMAL_USED\n";
actions[VS::SHADER_CANVAS_ITEM].usage_defines["NORMALMAP"] = "#define NORMALMAP_USED\n";
actions[VS::SHADER_CANVAS_ITEM].usage_defines["SHADOW_COLOR"] = "#define SHADOW_COLOR_USED\n";
+ actions[VS::SHADER_CANVAS_ITEM].usage_defines["LIGHT"] = "#define USE_LIGHT_SHADER_CODE\n";
actions[VS::SHADER_CANVAS_ITEM].render_mode_defines["skip_vertex_transform"] = "#define SKIP_TRANSFORM_USED\n";
@@ -828,6 +829,9 @@ ShaderCompilerGLES3::ShaderCompilerGLES3() {
actions[VS::SHADER_SPATIAL].usage_defines["SCREEN_TEXTURE"] = "#define SCREEN_TEXTURE_USED\n";
actions[VS::SHADER_SPATIAL].usage_defines["SCREEN_UV"] = "#define SCREEN_UV_USED\n";
+ actions[VS::SHADER_SPATIAL].usage_defines["DIFFUSE_LIGHT"] = "#define USE_LIGHT_SHADER_CODE\n";
+ actions[VS::SHADER_SPATIAL].usage_defines["SPECULAR_LIGHT"] = "#define USE_LIGHT_SHADER_CODE\n";
+
actions[VS::SHADER_SPATIAL].renames["SSS_STRENGTH"] = "sss_strength";
actions[VS::SHADER_SPATIAL].render_mode_defines["skip_vertex_transform"] = "#define SKIP_TRANSFORM_USED\n";
diff --git a/editor/SCsub b/editor/SCsub
index ff351cbc5d..75ec422bd5 100644
--- a/editor/SCsub
+++ b/editor/SCsub
@@ -416,8 +416,18 @@ if env['tools']:
# API documentation
docs = []
- for f in os.listdir(os.path.join(env.Dir('#').abspath, "doc/classes")):
- docs.append("#doc/classes/" + f)
+ doc_dirs = ["doc/classes"]
+
+ for p in env.doc_class_path.values():
+ if p not in doc_dirs:
+ doc_dirs.append(p)
+
+ for d in doc_dirs:
+ try:
+ for f in os.listdir(os.path.join(env.Dir('#').abspath, d)):
+ docs.append("#" + os.path.join(d, f))
+ except OSError:
+ pass
_make_doc_data_class_path(os.path.join(env.Dir('#').abspath, "editor/doc"))
diff --git a/editor/animation_editor.cpp b/editor/animation_editor.cpp
index 54eb695178..1afa1e708a 100644
--- a/editor/animation_editor.cpp
+++ b/editor/animation_editor.cpp
@@ -1368,7 +1368,7 @@ void AnimationKeyEditor::_track_editor_draw() {
icon_ofs.x-=hsep;
*/
- track_ofs[0] = size.width - icon_ofs.x;
+ track_ofs[0] = size.width - icon_ofs.x + ofs.x;
icon_ofs.x -= down_icon->get_width();
te->draw_texture(down_icon, icon_ofs - Size2(0, 4 * EDSCALE));
@@ -1380,7 +1380,7 @@ void AnimationKeyEditor::_track_editor_draw() {
icon_ofs.x -= hsep;
te->draw_line(Point2(icon_ofs.x, ofs.y + y), Point2(icon_ofs.x, ofs.y + y + h), sepcolor);
- track_ofs[1] = size.width - icon_ofs.x;
+ track_ofs[1] = size.width - icon_ofs.x + ofs.x;
icon_ofs.x -= down_icon->get_width();
te->draw_texture(down_icon, icon_ofs - Size2(0, 4 * EDSCALE));
@@ -1394,7 +1394,7 @@ void AnimationKeyEditor::_track_editor_draw() {
icon_ofs.x -= hsep;
te->draw_line(Point2(icon_ofs.x, ofs.y + y), Point2(icon_ofs.x, ofs.y + y + h), sepcolor);
- track_ofs[2] = size.width - icon_ofs.x;
+ track_ofs[2] = size.width - icon_ofs.x + ofs.x;
if (animation->track_get_type(idx) == Animation::TYPE_VALUE) {
@@ -1415,13 +1415,12 @@ void AnimationKeyEditor::_track_editor_draw() {
icon_ofs.x -= hsep;
te->draw_line(Point2(icon_ofs.x, ofs.y + y), Point2(icon_ofs.x, ofs.y + y + h), sepcolor);
- track_ofs[3] = size.width - icon_ofs.x;
+ track_ofs[3] = size.width - icon_ofs.x + ofs.x;
icon_ofs.x -= hsep;
icon_ofs.x -= add_key_icon->get_width();
te->draw_texture((mouse_over.over == MouseOver::OVER_ADD_KEY && mouse_over.track == idx) ? add_key_icon_hl : add_key_icon, icon_ofs);
-
- track_ofs[4] = size.width - icon_ofs.x;
+ track_ofs[4] = size.width - icon_ofs.x + ofs.x;
//draw the keys;
int tt = animation->track_get_type(idx);
@@ -3330,7 +3329,7 @@ int AnimationKeyEditor::_confirm_insert(InsertData p_id, int p_last_track) {
h.type == Variant::VECTOR2 ||
h.type == Variant::RECT2 ||
h.type == Variant::VECTOR3 ||
- h.type == Variant::RECT3 ||
+ h.type == Variant::AABB ||
h.type == Variant::QUAT ||
h.type == Variant::COLOR ||
h.type == Variant::TRANSFORM) {
diff --git a/editor/connections_dialog.cpp b/editor/connections_dialog.cpp
index b4c2ac95cc..cd60455f4f 100644
--- a/editor/connections_dialog.cpp
+++ b/editor/connections_dialog.cpp
@@ -209,7 +209,7 @@ void ConnectDialog::_add_bind() {
case Variant::VECTOR3: value = Vector3(); break;
case Variant::PLANE: value = Plane(); break;
case Variant::QUAT: value = Quat(); break;
- case Variant::RECT3: value = Rect3(); break;
+ case Variant::AABB: value = AABB(); break;
case Variant::BASIS: value = Basis(); break;
case Variant::TRANSFORM: value = Transform(); break;
case Variant::COLOR: value = Color(); break;
@@ -295,7 +295,7 @@ ConnectDialog::ConnectDialog() {
type_list->add_item("Vector3", Variant::VECTOR3);
type_list->add_item("Plane", Variant::PLANE);
type_list->add_item("Quat", Variant::QUAT);
- type_list->add_item("Rect3", Variant::RECT3);
+ type_list->add_item("AABB", Variant::AABB);
type_list->add_item("Basis", Variant::BASIS);
type_list->add_item("Transform", Variant::TRANSFORM);
//type_list->add_separator();
diff --git a/editor/create_dialog.cpp b/editor/create_dialog.cpp
index 95b4f7e982..02af304dc6 100644
--- a/editor/create_dialog.cpp
+++ b/editor/create_dialog.cpp
@@ -97,6 +97,15 @@ void CreateDialog::popup_create(bool p_dontclear) {
search_box->grab_focus();
_update_search();
+
+ bool enable_rl = EditorSettings::get_singleton()->get("docks/scene_tree/draw_relationship_lines");
+ Color rl_color = EditorSettings::get_singleton()->get("docks/scene_tree/relationship_line_color");
+
+ if (enable_rl) {
+ search_options->add_constant_override("draw_relationship_lines", 1);
+ search_options->add_color_override("relationship_line_color", rl_color);
+ } else
+ search_options->add_constant_override("draw_relationship_lines", 0);
}
void CreateDialog::_text_changed(const String &p_newtext) {
diff --git a/editor/doc/doc_dump.cpp b/editor/doc/doc_dump.cpp
index 13dbb149d5..45b7613659 100644
--- a/editor/doc/doc_dump.cpp
+++ b/editor/doc/doc_dump.cpp
@@ -182,7 +182,7 @@ void DocDump::dump(const String &p_file) {
case Variant::VECTOR3:
case Variant::PLANE:
case Variant::QUAT:
- case Variant::RECT3:
+ case Variant::AABB:
case Variant::BASIS:
case Variant::COLOR:
case Variant::POOL_BYTE_ARRAY:
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index 6a4e879340..27f967cce7 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -1109,7 +1109,7 @@ void EditorNode::_dialog_action(String p_file) {
_save_default_environment();
_save_scene_with_preview(p_file);
- _run(true);
+ _run(false);
}
} break;
@@ -4276,12 +4276,19 @@ Variant EditorNode::drag_files_and_dirs(const Vector<String> &p_paths, Control *
void EditorNode::_dropped_files(const Vector<String> &p_files, int p_screen) {
- /*
- String cur_path = filesystem_dock->get_current_path();
- for(int i=0;i<EditorImportExport::get_singleton()->get_import_plugin_count();i++) {
- EditorImportExport::get_singleton()->get_import_plugin(i)->import_from_drop(p_files,cur_path);
+ String to_path = ProjectSettings::get_singleton()->globalize_path(get_filesystem_dock()->get_current_path());
+ DirAccessRef dir = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
+
+ for (int i = 0; i < p_files.size(); i++) {
+
+ String from = p_files[i];
+ if (!ResourceFormatImporter::get_singleton()->can_be_imported(from)) {
+ continue;
+ }
+ String to = to_path.plus_file(from.get_file());
+ dir->copy(from, to);
}
- */
+ EditorFileSystem::get_singleton()->scan_changes();
}
void EditorNode::_file_access_close_error_notify(const String &p_str) {
@@ -4552,6 +4559,11 @@ static Node *_resource_get_edited_scene() {
return EditorNode::get_singleton()->get_edited_scene();
}
+void EditorNode::_print_handler(void *p_this, const String &p_string, bool p_error) {
+ EditorNode *en = (EditorNode *)p_this;
+ en->log->add_message(p_string, p_error);
+}
+
EditorNode::EditorNode() {
Resource::_get_local_scene_func = _resource_get_edited_scene;
@@ -5652,6 +5664,10 @@ EditorNode::EditorNode() {
_dim_timer->connect("timeout", this, "_dim_timeout");
add_child(_dim_timer);
+ print_handler.printfunc = _print_handler;
+ print_handler.userdata = this;
+ add_print_handler(&print_handler);
+
ED_SHORTCUT("editor/editor_2d", TTR("Open 2D Editor"), KEY_F1);
ED_SHORTCUT("editor/editor_3d", TTR("Open 3D Editor"), KEY_F2);
ED_SHORTCUT("editor/editor_script", TTR("Open Script Editor"), KEY_F3); //hack neded for script editor F3 search to work :) Assign like this or don't use F3
@@ -5663,6 +5679,7 @@ EditorNode::EditorNode() {
EditorNode::~EditorNode() {
+ remove_print_handler(&print_handler);
memdelete(EditorHelp::get_doc_data());
memdelete(editor_selection);
memdelete(editor_plugins_over);
diff --git a/editor/editor_node.h b/editor/editor_node.h
index 81ff886228..54cb414835 100644
--- a/editor/editor_node.h
+++ b/editor/editor_node.h
@@ -30,6 +30,7 @@
#ifndef EDITOR_NODE_H
#define EDITOR_NODE_H
+#include "core/print_string.h"
#include "editor/connections_dialog.h"
#include "editor/create_dialog.h"
#include "editor/editor_about.h"
@@ -610,6 +611,9 @@ private:
Vector<Ref<EditorResourceConversionPlugin> > resource_conversion_plugins;
+ PrintHandlerList print_handler;
+ static void _print_handler(void *p_this, const String &p_string, bool p_error);
+
protected:
void _notification(int p_what);
static void _bind_methods();
diff --git a/editor/editor_plugin.cpp b/editor/editor_plugin.cpp
index 0bd677ca1b..38e8b301b7 100644
--- a/editor/editor_plugin.cpp
+++ b/editor/editor_plugin.cpp
@@ -102,14 +102,14 @@ Vector<Ref<Texture> > EditorInterface::make_mesh_previews(const Vector<Ref<Mesh>
textures.push_back(Ref<Texture>());
continue;
}
- Rect3 aabb = mesh->get_aabb();
+ AABB aabb = mesh->get_aabb();
print_line("aabb: " + aabb);
Vector3 ofs = aabb.position + aabb.size * 0.5;
aabb.position -= ofs;
Transform xform;
xform.basis = Basis().rotated(Vector3(0, 1, 0), -Math_PI * 0.25);
xform.basis = Basis().rotated(Vector3(1, 0, 0), Math_PI * 0.25) * xform.basis;
- Rect3 rot_aabb = xform.xform(aabb);
+ AABB rot_aabb = xform.xform(aabb);
print_line("rot_aabb: " + rot_aabb);
float m = MAX(rot_aabb.size.x, rot_aabb.size.y) * 0.5;
if (m == 0) {
@@ -455,7 +455,11 @@ void EditorPlugin::make_visible(bool p_visible) {
void EditorPlugin::edit(Object *p_object) {
if (get_script_instance() && get_script_instance()->has_method("edit")) {
- get_script_instance()->call("edit", p_object);
+ if (p_object->is_class("Resource")) {
+ get_script_instance()->call("edit", Ref<Resource>(Object::cast_to<Resource>(p_object)));
+ } else {
+ get_script_instance()->call("edit", p_object);
+ }
}
}
diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp
index bf4ef3ae39..165c0691fb 100644
--- a/editor/editor_settings.cpp
+++ b/editor/editor_settings.cpp
@@ -922,7 +922,8 @@ void EditorSettings::raise_order(const String &p_setting) {
void EditorSettings::set_initial_value(const StringName &p_setting, const Variant &p_value) {
- ERR_FAIL_COND(!props.has(p_setting));
+ if (!props.has(p_setting))
+ return;
props[p_setting].initial = p_value;
props[p_setting].initial_set = true;
}
diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp
index 7abddb9f67..533401b317 100644
--- a/editor/filesystem_dock.cpp
+++ b/editor/filesystem_dock.cpp
@@ -1454,11 +1454,21 @@ void FileSystemDock::select_file(const String &p_file) {
void FileSystemDock::_file_multi_selected(int p_index, bool p_selected) {
- _file_selected();
+ import_dock_needs_update = true;
+ call_deferred("_update_import_dock");
}
void FileSystemDock::_file_selected() {
+ import_dock_needs_update = true;
+ _update_import_dock();
+}
+
+void FileSystemDock::_update_import_dock() {
+
+ if (!import_dock_needs_update)
+ return;
+
//check import
Vector<String> imports;
String import_type;
@@ -1498,6 +1508,8 @@ void FileSystemDock::_file_selected() {
} else {
EditorNode::get_singleton()->get_import_dock()->set_edit_multiple_paths(imports);
}
+
+ import_dock_needs_update = false;
}
void FileSystemDock::_bind_methods() {
@@ -1534,6 +1546,7 @@ void FileSystemDock::_bind_methods() {
ClassDB::bind_method(D_METHOD("_preview_invalidated"), &FileSystemDock::_preview_invalidated);
ClassDB::bind_method(D_METHOD("_file_selected"), &FileSystemDock::_file_selected);
ClassDB::bind_method(D_METHOD("_file_multi_selected"), &FileSystemDock::_file_multi_selected);
+ ClassDB::bind_method(D_METHOD("_update_import_dock"), &FileSystemDock::_update_import_dock);
ADD_SIGNAL(MethodInfo("instance", PropertyInfo(Variant::POOL_STRING_ARRAY, "files")));
ADD_SIGNAL(MethodInfo("open"));
@@ -1705,6 +1718,7 @@ FileSystemDock::FileSystemDock(EditorNode *p_editor) {
updating_tree = false;
initialized = false;
+ import_dock_needs_update = false;
history_pos = 0;
history_max_size = 20;
diff --git a/editor/filesystem_dock.h b/editor/filesystem_dock.h
index 249621564d..d100de8b72 100644
--- a/editor/filesystem_dock.h
+++ b/editor/filesystem_dock.h
@@ -147,6 +147,7 @@ private:
bool updating_tree;
Tree *tree; //directories
ItemList *files;
+ bool import_dock_needs_update;
bool _create_tree(TreeItem *p_parent, EditorFileSystemDirectory *p_dir, Vector<String> &uncollapsed_paths);
void _update_tree(bool keep_collapse_state);
@@ -161,6 +162,7 @@ private:
void _select_file(int p_idx);
void _file_multi_selected(int p_index, bool p_selected);
+ void _update_import_dock();
void _file_selected();
void _dir_selected();
diff --git a/editor/icons/icon_texture_button.svg b/editor/icons/icon_texture_button.svg
index 17f87ab861..19f5e8d5c9 100644
--- a/editor/icons/icon_texture_button.svg
+++ b/editor/icons/icon_texture_button.svg
@@ -1,7 +1,5 @@
<svg width="16" height="16" version="1.1" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
<g transform="translate(0 -1036.4)">
-<path transform="translate(0 1036.4)" d="m1 3v8h14v-8h-1-12-1zm8 2h1v1h1v2h1v2h-2-2-2-2v-1h1v-1h1v-1h2v-1h1v-1z" fill="#a5efac"/>
-<rect transform="scale(1,-1)" x="1" y="-1049.4" width="14" height="2.0001" fill="#a5efac"/>
-<rect transform="scale(1,-1)" x="1" y="-1049.4" width="14" height="2.0001" fill-opacity=".078431"/>
+<path transform="translate(0 1036.4)" d="m8 1v2h6v10h-4v2h6v-14h-8zm-5 1v3.1328l-1.4453-0.96484-1.1094 1.6641 3 2c0.3359 0.2239 0.77347 0.2239 1.1094 0l3-2-1.1094-1.6641-1.4453 0.96484v-3.1328h-2zm7 4v1h-1v1h-1v1h1v2h2 2v-2h-1v-2h-1v-1h-1zm-7.5 4c-0.831 0-1.5 0.669-1.5 1.5v0.5 1h-1v2h8v-2h-1v-1-0.5c0-0.831-0.669-1.5-1.5-1.5h-3z" fill="#a5efac"/>
</g>
</svg>
diff --git a/editor/icons/icon_texture_rect.svg b/editor/icons/icon_texture_rect.svg
index 86d24ac223..2dbbe7f247 100644
--- a/editor/icons/icon_texture_rect.svg
+++ b/editor/icons/icon_texture_rect.svg
@@ -1,6 +1,5 @@
<svg width="16" height="16" version="1.1" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
<g transform="translate(0 -1036.4)">
-<rect x="2" y="1038.4" width="12" height="12" fill="none" stroke="#a5efac" stroke-linecap="round" stroke-width="2"/>
-<path d="m9 1042.4v1h-1v1h-2v1h-1v1h-1v1h2 2 2 2v-2h-1v-2h-1v-1h-1z" fill="#a5efac"/>
+<path transform="translate(0 1036.4)" d="m1 1v14h14v-14h-14zm2 2h10v10h-10v-10zm6 3v1h-1v1h-2v1h-1v1h-1v1h2 2 2 2v-2h-1v-2h-1v-1h-1z" color="#000000" color-rendering="auto" dominant-baseline="auto" fill="#a5efac" image-rendering="auto" shape-rendering="auto" solid-color="#000000" style="font-feature-settings:normal;font-variant-alternates:normal;font-variant-caps:normal;font-variant-ligatures:normal;font-variant-numeric:normal;font-variant-position:normal;isolation:auto;mix-blend-mode:normal;shape-padding:0;text-decoration-color:#000000;text-decoration-line:none;text-decoration-style:solid;text-indent:0;text-orientation:mixed;text-transform:none;white-space:normal"/>
</g>
</svg>
diff --git a/editor/import/resource_importer_scene.cpp b/editor/import/resource_importer_scene.cpp
index 660db9ac27..cbc21c9536 100644
--- a/editor/import/resource_importer_scene.cpp
+++ b/editor/import/resource_importer_scene.cpp
@@ -232,16 +232,26 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Array
}
}
- if (_teststr(name, "colonly")) {
+ if (_teststr(name, "colonly") || _teststr(name, "convcolonly")) {
if (isroot)
return p_node;
MeshInstance *mi = Object::cast_to<MeshInstance>(p_node);
if (mi) {
- Node *col = mi->create_trimesh_collision_node();
- ERR_FAIL_COND_V(!col, NULL);
+ Node *col;
+
+ if (_teststr(name, "colonly")) {
+ col = mi->create_trimesh_collision_node();
+ ERR_FAIL_COND_V(!col, NULL);
+
+ col->set_name(_fixstr(name, "colonly"));
+ } else {
+ col = mi->create_convex_collision_node();
+ ERR_FAIL_COND_V(!col, NULL);
+
+ col->set_name(_fixstr(name, "convcolonly"));
+ }
- col->set_name(_fixstr(name, "colonly"));
Object::cast_to<Spatial>(col)->set_transform(mi->get_transform());
p_node->replace_by(col);
memdelete(p_node);
@@ -292,7 +302,7 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Array
// get mesh instance and bounding box
MeshInstance *mi = Object::cast_to<MeshInstance>(p_node);
- Rect3 aabb = mi->get_aabb();
+ AABB aabb = mi->get_aabb();
// create a new rigid body collision node
RigidBody *rigid_body = memnew(RigidBody);
@@ -328,15 +338,25 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Array
rb->add_child(colshape);
colshape->set_owner(p_node->get_owner());
- } else if (_teststr(name, "col") && Object::cast_to<MeshInstance>(p_node)) {
+ } else if ((_teststr(name, "col") || (_teststr(name, "convcol"))) && Object::cast_to<MeshInstance>(p_node)) {
MeshInstance *mi = Object::cast_to<MeshInstance>(p_node);
+ Node *col;
- mi->set_name(_fixstr(name, "col"));
- Node *col = mi->create_trimesh_collision_node();
- ERR_FAIL_COND_V(!col, NULL);
+ if (_teststr(name, "col")) {
+ mi->set_name(_fixstr(name, "col"));
+ col = mi->create_trimesh_collision_node();
+ ERR_FAIL_COND_V(!col, NULL);
+
+ col->set_name("col");
+ } else {
+ mi->set_name(_fixstr(name, "convcol"));
+ col = mi->create_convex_collision_node();
+ ERR_FAIL_COND_V(!col, NULL);
+
+ col->set_name("convcol");
+ }
- col->set_name("col");
p_node->add_child(col);
StaticBody *sb = Object::cast_to<StaticBody>(col);
@@ -527,26 +547,55 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Array
#endif
} else if (Object::cast_to<MeshInstance>(p_node)) {
- //last attempt, maybe collision insde the mesh data
+ //last attempt, maybe collision inside the mesh data
MeshInstance *mi = Object::cast_to<MeshInstance>(p_node);
Ref<ArrayMesh> mesh = mi->get_mesh();
if (!mesh.is_null()) {
- if (_teststr(mesh->get_name(), "col")) {
-
- mesh->set_name(_fixstr(mesh->get_name(), "col"));
+ if (_teststr(mesh->get_name(), "col") || _teststr(mesh->get_name(), "convcol")) {
Ref<Shape> shape;
+ if (_teststr(mesh->get_name(), "col")) {
+ mesh->set_name(_fixstr(mesh->get_name(), "col"));
+
+ if (collision_map.has(mesh)) {
+ shape = collision_map[mesh];
+
+ } else {
+
+ shape = mesh->create_trimesh_shape();
+ if (!shape.is_null())
+ collision_map[mesh] = shape;
+ }
+ } else if (_teststr(mesh->get_name(), "convcol")) {
+ mesh->set_name(_fixstr(mesh->get_name(), "convcol"));
+
+ if (collision_map.has(mesh)) {
+ shape = collision_map[mesh];
+
+ } else {
+
+ shape = mesh->create_convex_shape();
+ if (!shape.is_null())
+ collision_map[mesh] = shape;
+ }
+ }
- if (collision_map.has(mesh)) {
- shape = collision_map[mesh];
+ if (!shape.is_null()) {
+ StaticBody *col = memnew(StaticBody);
+ CollisionShape *cshape = memnew(CollisionShape);
+ cshape->set_shape(shape);
+ col->add_child(cshape);
- } else {
+ col->set_transform(mi->get_transform());
+ col->set_name(mi->get_name());
+ p_node->replace_by(col);
+ memdelete(p_node);
+ p_node = col;
- shape = mesh->create_trimesh_shape();
- if (!shape.is_null())
- collision_map[mesh] = shape;
+ cshape->set_name("shape");
+ cshape->set_owner(p_node->get_owner());
}
}
}
diff --git a/editor/plugins/collision_polygon_editor_plugin.cpp b/editor/plugins/collision_polygon_editor_plugin.cpp
index 24c4813771..0818c8975e 100644
--- a/editor/plugins/collision_polygon_editor_plugin.cpp
+++ b/editor/plugins/collision_polygon_editor_plugin.cpp
@@ -389,7 +389,7 @@ void CollisionPolygonEditor::_polygon_draw() {
rect = rect.grow(1);
- Rect3 r;
+ AABB r;
r.position.x = rect.position.x;
r.position.y = rect.position.y;
r.position.z = depth;
diff --git a/editor/plugins/editor_preview_plugins.cpp b/editor/plugins/editor_preview_plugins.cpp
index 5f73d0b465..dd49bae51d 100644
--- a/editor/plugins/editor_preview_plugins.cpp
+++ b/editor/plugins/editor_preview_plugins.cpp
@@ -790,13 +790,13 @@ Ref<Texture> EditorMeshPreviewPlugin::generate(const RES &p_from) {
VS::get_singleton()->instance_set_base(mesh_instance, mesh->get_rid());
- Rect3 aabb = mesh->get_aabb();
+ AABB aabb = mesh->get_aabb();
Vector3 ofs = aabb.position + aabb.size * 0.5;
aabb.position -= ofs;
Transform xform;
xform.basis = Basis().rotated(Vector3(0, 1, 0), -Math_PI * 0.125);
xform.basis = Basis().rotated(Vector3(1, 0, 0), Math_PI * 0.125) * xform.basis;
- Rect3 rot_aabb = xform.xform(aabb);
+ AABB rot_aabb = xform.xform(aabb);
float m = MAX(rot_aabb.size.x, rot_aabb.size.y) * 0.5;
if (m == 0)
return Ref<Texture>();
diff --git a/editor/plugins/mesh_editor_plugin.cpp b/editor/plugins/mesh_editor_plugin.cpp
index 74618aecc2..60e8858b2d 100644
--- a/editor/plugins/mesh_editor_plugin.cpp
+++ b/editor/plugins/mesh_editor_plugin.cpp
@@ -95,7 +95,7 @@ void MeshEditor::edit(Ref<Mesh> p_mesh) {
rot_y = 0;
_update_rotation();
- Rect3 aabb = mesh->get_aabb();
+ AABB aabb = mesh->get_aabb();
print_line("aabb: " + aabb);
Vector3 ofs = aabb.position + aabb.size * 0.5;
float m = aabb.get_longest_axis_size();
diff --git a/editor/plugins/particles_editor_plugin.cpp b/editor/plugins/particles_editor_plugin.cpp
index 10834b74ff..f4a9960087 100644
--- a/editor/plugins/particles_editor_plugin.cpp
+++ b/editor/plugins/particles_editor_plugin.cpp
@@ -153,15 +153,15 @@ void ParticlesEditor::_generate_aabb() {
EditorProgress ep("gen_aabb", TTR("Generating AABB"), int(time));
- Rect3 rect;
+ AABB rect;
while (running < time) {
uint64_t ticks = OS::get_singleton()->get_ticks_usec();
ep.step("Generating..", int(running), true);
OS::get_singleton()->delay_usec(1000);
- Rect3 capture = node->capture_aabb();
- if (rect == Rect3())
+ AABB capture = node->capture_aabb();
+ if (rect == AABB())
rect = capture;
else
rect.merge_with(capture);
@@ -247,7 +247,7 @@ void ParticlesEditor::_generate_emission_points() {
PoolVector<Face3>::Read r = geometry.read();
- Rect3 aabb;
+ AABB aabb;
for (int i = 0; i < gcount; i++) {
diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp
index 6b945157e8..f670724f47 100644
--- a/editor/plugins/script_text_editor.cpp
+++ b/editor/plugins/script_text_editor.cpp
@@ -201,7 +201,7 @@ void ScriptTextEditor::_set_theme_for_script() {
text_edit->add_keyword_color("Rect2", basetype_color);
text_edit->add_keyword_color("Transform2D", basetype_color);
text_edit->add_keyword_color("Vector3", basetype_color);
- text_edit->add_keyword_color("Rect3", basetype_color);
+ text_edit->add_keyword_color("AABB", basetype_color);
text_edit->add_keyword_color("Basis", basetype_color);
text_edit->add_keyword_color("Plane", basetype_color);
text_edit->add_keyword_color("Transform", basetype_color);
diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp
index b87084e392..2c16157b6a 100644
--- a/editor/plugins/spatial_editor_plugin.cpp
+++ b/editor/plugins/spatial_editor_plugin.cpp
@@ -1808,6 +1808,11 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) {
if (!k->is_pressed()) emit_signal("toggle_maximize_view", this);
}
}
+
+ // freelook uses most of the useful shortcuts, like save, so its ok
+ // to consider freelook active as end of the line for future events.
+ if (freelook_active)
+ accept_event();
}
void SpatialEditorViewport::set_freelook_active(bool active_now) {
@@ -2006,7 +2011,7 @@ void SpatialEditorViewport::_notification(int p_what) {
if (se->aabb.has_no_surface()) {
- se->aabb = vi ? vi->get_aabb() : Rect3(Vector3(-0.2, -0.2, -0.2), Vector3(0.4, 0.4, 0.4));
+ se->aabb = vi ? vi->get_aabb() : AABB(Vector3(-0.2, -0.2, -0.2), Vector3(0.4, 0.4, 0.4));
}
Transform t = sp->get_global_transform();
@@ -2751,7 +2756,7 @@ void SpatialEditorViewport::focus_selection() {
cursor.pos = center;
}
-void SpatialEditorViewport::assign_pending_data_pointers(Spatial *p_preview_node, Rect3 *p_preview_bounds, AcceptDialog *p_accept) {
+void SpatialEditorViewport::assign_pending_data_pointers(Spatial *p_preview_node, AABB *p_preview_bounds, AcceptDialog *p_accept) {
preview_node = p_preview_node;
preview_bounds = p_preview_bounds;
accept = p_accept;
@@ -2814,14 +2819,14 @@ Vector3 SpatialEditorViewport::_get_instance_position(const Point2 &p_pos) const
return point + offset;
}
-Rect3 SpatialEditorViewport::_calculate_spatial_bounds(const Spatial *p_parent, const Rect3 p_bounds) {
- Rect3 bounds = p_bounds;
+AABB SpatialEditorViewport::_calculate_spatial_bounds(const Spatial *p_parent, const AABB p_bounds) {
+ AABB bounds = p_bounds;
for (int i = 0; i < p_parent->get_child_count(); i++) {
Spatial *child = Object::cast_to<Spatial>(p_parent->get_child(i));
if (child) {
MeshInstance *mesh_instance = Object::cast_to<MeshInstance>(child);
if (mesh_instance) {
- Rect3 mesh_instance_bounds = mesh_instance->get_aabb();
+ AABB mesh_instance_bounds = mesh_instance->get_aabb();
mesh_instance_bounds.position += mesh_instance->get_global_transform().origin - p_parent->get_global_transform().origin;
bounds.merge_with(mesh_instance_bounds);
}
@@ -2853,7 +2858,7 @@ void SpatialEditorViewport::_create_preview(const Vector<String> &files) const {
editor->get_scene_root()->add_child(preview_node);
}
}
- *preview_bounds = _calculate_spatial_bounds(preview_node, Rect3());
+ *preview_bounds = _calculate_spatial_bounds(preview_node, AABB());
}
void SpatialEditorViewport::_remove_preview() {
@@ -3529,7 +3534,7 @@ void SpatialEditor::select_gizmo_highlight_axis(int p_axis) {
void SpatialEditor::update_transform_gizmo() {
List<Node *> &selection = editor_selection->get_selected_node_list();
- Rect3 center;
+ AABB center;
bool first = true;
Basis gizmo_basis;
@@ -3590,7 +3595,7 @@ Object *SpatialEditor::_get_editor_data(Object *p_what) {
void SpatialEditor::_generate_selection_box() {
- Rect3 aabb(Vector3(), Vector3(1, 1, 1));
+ AABB aabb(Vector3(), Vector3(1, 1, 1));
aabb.grow_by(aabb.get_longest_axis_size() / 20.0);
Ref<SurfaceTool> st = memnew(SurfaceTool);
@@ -4617,7 +4622,7 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) {
// Drag and drop support;
preview_node = memnew(Spatial);
- preview_bounds = Rect3();
+ preview_bounds = AABB();
ED_SHORTCUT("spatial_editor/bottom_view", TTR("Bottom View"), KEY_MASK_ALT + KEY_KP_7);
ED_SHORTCUT("spatial_editor/top_view", TTR("Top View"), KEY_KP_7);
diff --git a/editor/plugins/spatial_editor_plugin.h b/editor/plugins/spatial_editor_plugin.h
index c2b698068f..0ef85b72d9 100644
--- a/editor/plugins/spatial_editor_plugin.h
+++ b/editor/plugins/spatial_editor_plugin.h
@@ -108,7 +108,7 @@ private:
Size2 prev_size;
Spatial *preview_node;
- Rect3 *preview_bounds;
+ AABB *preview_bounds;
Vector<String> selected_files;
AcceptDialog *accept;
@@ -287,7 +287,7 @@ private:
Point2i _get_warped_mouse_motion(const Ref<InputEventMouseMotion> &p_ev_mouse_motion) const;
Vector3 _get_instance_position(const Point2 &p_pos) const;
- static Rect3 _calculate_spatial_bounds(const Spatial *p_parent, const Rect3 p_bounds);
+ static AABB _calculate_spatial_bounds(const Spatial *p_parent, const AABB p_bounds);
void _create_preview(const Vector<String> &files) const;
void _remove_preview();
bool _cyclical_dependency_exists(const String &p_target_scene_path, Node *p_desired_node);
@@ -314,7 +314,7 @@ public:
void assign_pending_data_pointers(
Spatial *p_preview_node,
- Rect3 *p_preview_bounds,
+ AABB *p_preview_bounds,
AcceptDialog *p_accept);
Viewport *get_viewport_node() { return viewport; }
@@ -327,7 +327,7 @@ class SpatialEditorSelectedItem : public Object {
GDCLASS(SpatialEditorSelectedItem, Object);
public:
- Rect3 aabb;
+ AABB aabb;
Transform original; // original location when moving
Transform original_local;
Transform last_xform; // last transform
@@ -435,7 +435,7 @@ private:
// Scene drag and drop support
Spatial *preview_node;
- Rect3 preview_bounds;
+ AABB preview_bounds;
/*
struct Selected {
diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp
index 002ae568ff..5136c96cbf 100644
--- a/editor/property_editor.cpp
+++ b/editor/property_editor.cpp
@@ -755,7 +755,7 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
value_editor[3]->set_text(String::num(q.w));
} break;
- case Variant::RECT3: {
+ case Variant::AABB: {
field_names.push_back("px");
field_names.push_back("py");
@@ -765,7 +765,7 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant::
field_names.push_back("sz");
config_value_editors(6, 3, 16, field_names);
- Rect3 aabb = v;
+ AABB aabb = v;
value_editor[0]->set_text(String::num(aabb.position.x));
value_editor[1]->set_text(String::num(aabb.position.y));
value_editor[2]->set_text(String::num(aabb.position.z));
@@ -1585,7 +1585,7 @@ void CustomPropertyEditor::_modified(String p_string) {
_emit_changed_whole_or_field();
} break;
- case Variant::RECT3: {
+ case Variant::AABB: {
Vector3 pos;
Vector3 size;
@@ -1605,7 +1605,7 @@ void CustomPropertyEditor::_modified(String p_string) {
size.y = value_editor[4]->get_text().to_double();
size.z = value_editor[5]->get_text().to_double();
}
- v = Rect3(pos, size);
+ v = AABB(pos, size);
_emit_changed_whole_or_field();
} break;
@@ -1727,7 +1727,7 @@ void CustomPropertyEditor::_focus_enter() {
case Variant::VECTOR3:
case Variant::PLANE:
case Variant::QUAT:
- case Variant::RECT3:
+ case Variant::AABB:
case Variant::TRANSFORM2D:
case Variant::BASIS:
case Variant::TRANSFORM: {
@@ -1752,7 +1752,7 @@ void CustomPropertyEditor::_focus_exit() {
case Variant::VECTOR3:
case Variant::PLANE:
case Variant::QUAT:
- case Variant::RECT3:
+ case Variant::AABB:
case Variant::TRANSFORM2D:
case Variant::BASIS:
case Variant::TRANSFORM: {
@@ -2238,7 +2238,7 @@ void PropertyEditor::set_item_text(TreeItem *p_item, int p_type, const String &p
case Variant::VECTOR3:
case Variant::QUAT:
case Variant::VECTOR2:
- case Variant::RECT3:
+ case Variant::AABB:
case Variant::RECT2:
case Variant::TRANSFORM2D:
case Variant::BASIS:
@@ -3367,13 +3367,13 @@ void PropertyEditor::update_tree() {
item->set_icon(0, get_icon("Plane", "EditorIcons"));
} break;
- case Variant::RECT3: {
+ case Variant::AABB: {
item->set_cell_mode(1, TreeItem::CELL_MODE_CUSTOM);
item->set_editable(1, true);
- item->set_text(1, "Rect3");
+ item->set_text(1, "AABB");
if (show_type_icons)
- item->set_icon(0, get_icon("Rect3", "EditorIcons"));
+ item->set_icon(0, get_icon("AABB", "EditorIcons"));
} break;
case Variant::QUAT: {
@@ -3714,7 +3714,7 @@ void PropertyEditor::_item_edited() {
_edit_set(name, item->get_text(1), refresh_all);
}
} break;
- // math types
+ // math types
case Variant::VECTOR3: {
@@ -3725,7 +3725,7 @@ void PropertyEditor::_item_edited() {
case Variant::QUAT: {
} break;
- case Variant::RECT3: {
+ case Variant::AABB: {
} break;
case Variant::BASIS: {
diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp
index 7ada335007..816156ef00 100644
--- a/editor/scene_tree_dock.cpp
+++ b/editor/scene_tree_dock.cpp
@@ -1423,6 +1423,7 @@ void SceneTreeDock::_create() {
} else {
editor_data->get_undo_redo().add_do_method(editor, "set_edited_scene", child);
+ editor_data->get_undo_redo().add_do_method(scene_tree, "update_tree");
editor_data->get_undo_redo().add_do_reference(child);
editor_data->get_undo_redo().add_undo_method(editor, "set_edited_scene", (Object *)NULL);
}
@@ -1887,6 +1888,43 @@ void SceneTreeDock::open_script_dialog(Node *p_for_node) {
_tool_selected(TOOL_ATTACH_SCRIPT);
}
+void SceneTreeDock::add_remote_tree_editor(Control *p_remote) {
+ ERR_FAIL_COND(remote_tree != NULL);
+ add_child(p_remote);
+ remote_tree = p_remote;
+ remote_tree->hide();
+}
+
+void SceneTreeDock::show_remote_tree() {
+
+ button_hb->show();
+ _remote_tree_selected();
+}
+
+void SceneTreeDock::hide_remote_tree() {
+
+ button_hb->hide();
+ _local_tree_selected();
+}
+
+void SceneTreeDock::_remote_tree_selected() {
+
+ scene_tree->hide();
+ if (remote_tree)
+ remote_tree->show();
+ edit_remote->set_pressed(true);
+ edit_local->set_pressed(false);
+}
+
+void SceneTreeDock::_local_tree_selected() {
+
+ scene_tree->show();
+ if (remote_tree)
+ remote_tree->hide();
+ edit_remote->set_pressed(false);
+ edit_local->set_pressed(true);
+}
+
void SceneTreeDock::_bind_methods() {
ClassDB::bind_method(D_METHOD("_tool_selected"), &SceneTreeDock::_tool_selected, DEFVAL(false));
@@ -1912,6 +1950,8 @@ void SceneTreeDock::_bind_methods() {
ClassDB::bind_method(D_METHOD("_tree_rmb"), &SceneTreeDock::_tree_rmb);
ClassDB::bind_method(D_METHOD("_filter_changed"), &SceneTreeDock::_filter_changed);
ClassDB::bind_method(D_METHOD("_focus_node"), &SceneTreeDock::_focus_node);
+ ClassDB::bind_method(D_METHOD("_remote_tree_selected"), &SceneTreeDock::_remote_tree_selected);
+ ClassDB::bind_method(D_METHOD("_local_tree_selected"), &SceneTreeDock::_local_tree_selected);
ClassDB::bind_method(D_METHOD("instance"), &SceneTreeDock::instance);
}
@@ -1982,7 +2022,28 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor, Node *p_scene_root, EditorSel
button_clear_script = tb;
tb->hide();
+ button_hb = memnew(HBoxContainer);
+ vbc->add_child(button_hb);
+
+ edit_remote = memnew(ToolButton);
+ button_hb->add_child(edit_remote);
+ edit_remote->set_h_size_flags(SIZE_EXPAND_FILL);
+ edit_remote->set_text(TTR("Remote"));
+ edit_remote->set_toggle_mode(true);
+ edit_remote->connect("pressed", this, "_remote_tree_selected");
+
+ edit_local = memnew(ToolButton);
+ button_hb->add_child(edit_local);
+ edit_local->set_h_size_flags(SIZE_EXPAND_FILL);
+ edit_local->set_text(TTR("Local"));
+ edit_local->set_toggle_mode(true);
+ edit_local->connect("pressed", this, "_local_tree_selected");
+
+ remote_tree = NULL;
+ button_hb->hide();
+
scene_tree = memnew(SceneTreeEditor(false, true, true));
+
vbc->add_child(scene_tree);
scene_tree->set_v_size_flags(SIZE_EXPAND | SIZE_FILL);
scene_tree->connect("rmb_pressed", this, "_tree_rmb");
diff --git a/editor/scene_tree_dock.h b/editor/scene_tree_dock.h
index f61c67bb13..97d3c4748a 100644
--- a/editor/scene_tree_dock.h
+++ b/editor/scene_tree_dock.h
@@ -95,7 +95,10 @@ class SceneTreeDock : public VBoxContainer {
ToolButton *button_create_script;
ToolButton *button_clear_script;
+ HBoxContainer *button_hb;
+ ToolButton *edit_local, *edit_remote;
SceneTreeEditor *scene_tree;
+ Control *remote_tree;
HBoxContainer *tool_hbc;
void _tool_selected(int p_tool, bool p_confirm_override = false);
@@ -174,6 +177,9 @@ class SceneTreeDock : public VBoxContainer {
void _file_selected(String p_file);
+ void _remote_tree_selected();
+ void _local_tree_selected();
+
protected:
void _notification(int p_what);
static void _bind_methods();
@@ -194,6 +200,10 @@ public:
SceneTreeEditor *get_tree_editor() { return scene_tree; }
EditorData *get_editor_data() { return editor_data; }
+ void add_remote_tree_editor(Control *p_remote);
+ void show_remote_tree();
+ void hide_remote_tree();
+
void open_script_dialog(Node *p_for_node);
SceneTreeDock(EditorNode *p_editor, Node *p_scene_root, EditorSelection *p_editor_selection, EditorData &p_editor_data);
};
diff --git a/editor/spatial_editor_gizmos.cpp b/editor/spatial_editor_gizmos.cpp
index 3f8d93d976..3ffc61cb45 100644
--- a/editor/spatial_editor_gizmos.cpp
+++ b/editor/spatial_editor_gizmos.cpp
@@ -149,7 +149,7 @@ void EditorSpatialGizmo::add_lines(const Vector<Vector3> &p_lines, const Ref<Mat
md = MAX(0, p_lines[i].length());
}
if (md) {
- mesh->set_custom_aabb(Rect3(Vector3(-md, -md, -md), Vector3(md, md, md) * 2.0));
+ mesh->set_custom_aabb(AABB(Vector3(-md, -md, -md), Vector3(md, md, md) * 2.0));
}
}
@@ -196,7 +196,7 @@ void EditorSpatialGizmo::add_unscaled_billboard(const Ref<Material> &p_material,
md = MAX(0, vs[i].length());
}
if (md) {
- mesh->set_custom_aabb(Rect3(Vector3(-md, -md, -md), Vector3(md, md, md) * 2.0));
+ mesh->set_custom_aabb(AABB(Vector3(-md, -md, -md), Vector3(md, md, md) * 2.0));
}
}
@@ -211,7 +211,7 @@ void EditorSpatialGizmo::add_unscaled_billboard(const Ref<Material> &p_material,
instances.push_back(ins);
}
-void EditorSpatialGizmo::add_collision_triangles(const Ref<TriangleMesh> &p_tmesh, const Rect3 &p_bounds) {
+void EditorSpatialGizmo::add_collision_triangles(const Ref<TriangleMesh> &p_tmesh, const AABB &p_bounds) {
collision_mesh = p_tmesh;
collision_mesh_bounds = p_bounds;
@@ -270,7 +270,7 @@ void EditorSpatialGizmo::add_handles(const Vector<Vector3> &p_handles, bool p_bi
md = MAX(0, p_handles[i].length());
}
if (md) {
- mesh->set_custom_aabb(Rect3(Vector3(-md, -md, -md), Vector3(md, md, md) * 2.0));
+ mesh->set_custom_aabb(AABB(Vector3(-md, -md, -md), Vector3(md, md, md) * 2.0));
}
}
@@ -1274,7 +1274,7 @@ void MeshInstanceSpatialGizmo::redraw() {
Ref<TriangleMesh> tm = m->generate_triangle_mesh();
if (tm.is_valid()) {
- Rect3 aabb;
+ AABB aabb;
add_collision_triangles(tm, aabb);
}
}
@@ -1336,7 +1336,7 @@ void SkeletonSpatialGizmo::redraw() {
weights[0] = 1;
- Rect3 aabb;
+ AABB aabb;
Color bonecolor = Color(1.0, 0.4, 0.4, 0.3);
Color rootcolor = Color(0.4, 1.0, 0.4, 0.1);
@@ -1961,7 +1961,7 @@ void CollisionShapeSpatialGizmo::redraw() {
Ref<BoxShape> bs = s;
Vector<Vector3> lines;
- Rect3 aabb;
+ AABB aabb;
aabb.position = -bs->get_extents();
aabb.size = aabb.position * -2;
@@ -2191,7 +2191,7 @@ void VisibilityNotifierGizmo::set_handle(int p_idx, Camera *p_camera, const Poin
//gt.orthonormalize();
Transform gi = gt.affine_inverse();
- Rect3 aabb = notifier->get_aabb();
+ AABB aabb = notifier->get_aabb();
Vector3 ray_from = p_camera->project_ray_origin(p_point);
Vector3 ray_dir = p_camera->project_ray_normal(p_point);
@@ -2234,7 +2234,7 @@ void VisibilityNotifierGizmo::redraw() {
clear();
Vector<Vector3> lines;
- Rect3 aabb = notifier->get_aabb();
+ AABB aabb = notifier->get_aabb();
for (int i = 0; i < 12; i++) {
Vector3 a, b;
@@ -2293,7 +2293,7 @@ void ParticlesGizmo::set_handle(int p_idx, Camera *p_camera, const Point2 &p_poi
bool move = p_idx >= 3;
p_idx = p_idx % 3;
- Rect3 aabb = particles->get_visibility_aabb();
+ AABB aabb = particles->get_visibility_aabb();
Vector3 ray_from = p_camera->project_ray_origin(p_point);
Vector3 ray_dir = p_camera->project_ray_normal(p_point);
@@ -2347,7 +2347,7 @@ void ParticlesGizmo::redraw() {
clear();
Vector<Vector3> lines;
- Rect3 aabb = particles->get_visibility_aabb();
+ AABB aabb = particles->get_visibility_aabb();
for (int i = 0; i < 12; i++) {
Vector3 a, b;
@@ -2420,7 +2420,7 @@ String ReflectionProbeGizmo::get_handle_name(int p_idx) const {
}
Variant ReflectionProbeGizmo::get_handle_value(int p_idx) const {
- return Rect3(probe->get_extents(), probe->get_origin_offset());
+ return AABB(probe->get_extents(), probe->get_origin_offset());
}
void ReflectionProbeGizmo::set_handle(int p_idx, Camera *p_camera, const Point2 &p_point) {
@@ -2474,7 +2474,7 @@ void ReflectionProbeGizmo::set_handle(int p_idx, Camera *p_camera, const Point2
void ReflectionProbeGizmo::commit_handle(int p_idx, const Variant &p_restore, bool p_cancel) {
- Rect3 restore = p_restore;
+ AABB restore = p_restore;
if (p_cancel) {
probe->set_extents(restore.position);
@@ -2499,7 +2499,7 @@ void ReflectionProbeGizmo::redraw() {
Vector<Vector3> internal_lines;
Vector3 extents = probe->get_extents();
- Rect3 aabb;
+ AABB aabb;
aabb.position = -extents;
aabb.size = extents * 2;
@@ -2641,7 +2641,7 @@ void GIProbeGizmo::redraw() {
static const int subdivs[GIProbe::SUBDIV_MAX] = { 64, 128, 256, 512 };
- Rect3 aabb = Rect3(-extents, extents * 2);
+ AABB aabb = AABB(-extents, extents * 2);
int subdiv = subdivs[probe->get_subdiv()];
float cell_size = aabb.get_longest_axis_size() / subdiv;
diff --git a/editor/spatial_editor_gizmos.h b/editor/spatial_editor_gizmos.h
index afe64c723c..751bad2b13 100644
--- a/editor/spatial_editor_gizmos.h
+++ b/editor/spatial_editor_gizmos.h
@@ -78,7 +78,7 @@ class EditorSpatialGizmo : public SpatialEditorGizmo {
Vector<Vector3> collision_segments;
Ref<TriangleMesh> collision_mesh;
- Rect3 collision_mesh_bounds;
+ AABB collision_mesh_bounds;
struct Handle {
Vector3 pos;
@@ -100,7 +100,7 @@ protected:
void add_lines(const Vector<Vector3> &p_lines, const Ref<Material> &p_material, bool p_billboard = false);
void add_mesh(const Ref<ArrayMesh> &p_mesh, bool p_billboard = false, const RID &p_skeleton = RID());
void add_collision_segments(const Vector<Vector3> &p_lines);
- void add_collision_triangles(const Ref<TriangleMesh> &p_tmesh, const Rect3 &p_bounds = Rect3());
+ void add_collision_triangles(const Ref<TriangleMesh> &p_tmesh, const AABB &p_bounds = AABB());
void add_unscaled_billboard(const Ref<Material> &p_material, float p_scale = 1);
void add_handles(const Vector<Vector3> &p_handles, bool p_billboard = false, bool p_secondary = false);
void add_solid_box(Ref<Material> &p_material, Vector3 size);
diff --git a/main/main.cpp b/main/main.cpp
index f6b11bc3ca..023520017b 100644
--- a/main/main.cpp
+++ b/main/main.cpp
@@ -1766,7 +1766,8 @@ bool Main::iteration() {
return exit;
if (OS::get_singleton()->is_in_low_processor_usage_mode() || !OS::get_singleton()->can_draw())
- OS::get_singleton()->delay_usec(16600); //apply some delay to force idle time (results in about 60 FPS max)
+ //OS::get_singleton()->delay_usec(16600); //apply some delay to force idle time (results in about 60 FPS max)
+ OS::get_singleton()->delay_usec(1000); //apply some delay to force idle time (results in about 60 FPS max)
else {
uint32_t frame_delay = Engine::get_singleton()->get_frame_delay();
if (frame_delay)
diff --git a/main/tests/test_gdscript.cpp b/main/tests/test_gdscript.cpp
index bcf4278bde..b41b5f6452 100644
--- a/main/tests/test_gdscript.cpp
+++ b/main/tests/test_gdscript.cpp
@@ -35,10 +35,10 @@
#ifdef GDSCRIPT_ENABLED
-#include "modules/gdscript/gd_compiler.h"
-#include "modules/gdscript/gd_parser.h"
-#include "modules/gdscript/gd_script.h"
-#include "modules/gdscript/gd_tokenizer.h"
+#include "modules/gdscript/gdscript.h"
+#include "modules/gdscript/gdscript_compiler.h"
+#include "modules/gdscript/gdscript_parser.h"
+#include "modules/gdscript/gdscript_tokenizer.h"
namespace TestGDScript {
@@ -52,7 +52,7 @@ static void _print_indent(int p_ident, const String &p_text) {
print_line(txt + p_text);
}
-static String _parser_extends(const GDParser::ClassNode *p_class) {
+static String _parser_extends(const GDScriptParser::ClassNode *p_class) {
String txt = "extends ";
if (String(p_class->extends_file) != "") {
@@ -72,29 +72,29 @@ static String _parser_extends(const GDParser::ClassNode *p_class) {
return txt;
}
-static String _parser_expr(const GDParser::Node *p_expr) {
+static String _parser_expr(const GDScriptParser::Node *p_expr) {
String txt;
switch (p_expr->type) {
- case GDParser::Node::TYPE_IDENTIFIER: {
+ case GDScriptParser::Node::TYPE_IDENTIFIER: {
- const GDParser::IdentifierNode *id_node = static_cast<const GDParser::IdentifierNode *>(p_expr);
+ const GDScriptParser::IdentifierNode *id_node = static_cast<const GDScriptParser::IdentifierNode *>(p_expr);
txt = id_node->name;
} break;
- case GDParser::Node::TYPE_CONSTANT: {
- const GDParser::ConstantNode *c_node = static_cast<const GDParser::ConstantNode *>(p_expr);
+ case GDScriptParser::Node::TYPE_CONSTANT: {
+ const GDScriptParser::ConstantNode *c_node = static_cast<const GDScriptParser::ConstantNode *>(p_expr);
if (c_node->value.get_type() == Variant::STRING)
txt = "\"" + String(c_node->value) + "\"";
else
txt = c_node->value;
} break;
- case GDParser::Node::TYPE_SELF: {
+ case GDScriptParser::Node::TYPE_SELF: {
txt = "self";
} break;
- case GDParser::Node::TYPE_ARRAY: {
- const GDParser::ArrayNode *arr_node = static_cast<const GDParser::ArrayNode *>(p_expr);
+ case GDScriptParser::Node::TYPE_ARRAY: {
+ const GDScriptParser::ArrayNode *arr_node = static_cast<const GDScriptParser::ArrayNode *>(p_expr);
txt += "[";
for (int i = 0; i < arr_node->elements.size(); i++) {
@@ -104,51 +104,51 @@ static String _parser_expr(const GDParser::Node *p_expr) {
}
txt += "]";
} break;
- case GDParser::Node::TYPE_DICTIONARY: {
- const GDParser::DictionaryNode *dict_node = static_cast<const GDParser::DictionaryNode *>(p_expr);
+ case GDScriptParser::Node::TYPE_DICTIONARY: {
+ const GDScriptParser::DictionaryNode *dict_node = static_cast<const GDScriptParser::DictionaryNode *>(p_expr);
txt += "{";
for (int i = 0; i < dict_node->elements.size(); i++) {
if (i > 0)
txt += ", ";
- const GDParser::DictionaryNode::Pair &p = dict_node->elements[i];
+ const GDScriptParser::DictionaryNode::Pair &p = dict_node->elements[i];
txt += _parser_expr(p.key);
txt += ":";
txt += _parser_expr(p.value);
}
txt += "}";
} break;
- case GDParser::Node::TYPE_OPERATOR: {
+ case GDScriptParser::Node::TYPE_OPERATOR: {
- const GDParser::OperatorNode *c_node = static_cast<const GDParser::OperatorNode *>(p_expr);
+ const GDScriptParser::OperatorNode *c_node = static_cast<const GDScriptParser::OperatorNode *>(p_expr);
switch (c_node->op) {
- case GDParser::OperatorNode::OP_PARENT_CALL:
+ case GDScriptParser::OperatorNode::OP_PARENT_CALL:
txt += ".";
- case GDParser::OperatorNode::OP_CALL: {
+ case GDScriptParser::OperatorNode::OP_CALL: {
ERR_FAIL_COND_V(c_node->arguments.size() < 1, "");
String func_name;
- const GDParser::Node *nfunc = c_node->arguments[0];
+ const GDScriptParser::Node *nfunc = c_node->arguments[0];
int arg_ofs = 0;
- if (nfunc->type == GDParser::Node::TYPE_BUILT_IN_FUNCTION) {
+ if (nfunc->type == GDScriptParser::Node::TYPE_BUILT_IN_FUNCTION) {
- const GDParser::BuiltInFunctionNode *bif_node = static_cast<const GDParser::BuiltInFunctionNode *>(nfunc);
- func_name = GDFunctions::get_func_name(bif_node->function);
+ const GDScriptParser::BuiltInFunctionNode *bif_node = static_cast<const GDScriptParser::BuiltInFunctionNode *>(nfunc);
+ func_name = GDScriptFunctions::get_func_name(bif_node->function);
arg_ofs = 1;
- } else if (nfunc->type == GDParser::Node::TYPE_TYPE) {
+ } else if (nfunc->type == GDScriptParser::Node::TYPE_TYPE) {
- const GDParser::TypeNode *t_node = static_cast<const GDParser::TypeNode *>(nfunc);
+ const GDScriptParser::TypeNode *t_node = static_cast<const GDScriptParser::TypeNode *>(nfunc);
func_name = Variant::get_type_name(t_node->vtype);
arg_ofs = 1;
} else {
ERR_FAIL_COND_V(c_node->arguments.size() < 2, "");
nfunc = c_node->arguments[1];
- ERR_FAIL_COND_V(nfunc->type != GDParser::Node::TYPE_IDENTIFIER, "");
+ ERR_FAIL_COND_V(nfunc->type != GDScriptParser::Node::TYPE_IDENTIFIER, "");
- if (c_node->arguments[0]->type != GDParser::Node::TYPE_SELF)
+ if (c_node->arguments[0]->type != GDScriptParser::Node::TYPE_SELF)
func_name = _parser_expr(c_node->arguments[0]) + ".";
func_name += _parser_expr(nfunc);
@@ -159,7 +159,7 @@ static String _parser_expr(const GDParser::Node *p_expr) {
for (int i = arg_ofs; i < c_node->arguments.size(); i++) {
- const GDParser::Node *arg = c_node->arguments[i];
+ const GDScriptParser::Node *arg = c_node->arguments[i];
if (i > arg_ofs)
txt += ", ";
txt += _parser_expr(arg);
@@ -168,7 +168,7 @@ static String _parser_expr(const GDParser::Node *p_expr) {
txt += ")";
} break;
- case GDParser::OperatorNode::OP_INDEX: {
+ case GDScriptParser::OperatorNode::OP_INDEX: {
ERR_FAIL_COND_V(c_node->arguments.size() != 2, "");
@@ -176,125 +176,125 @@ static String _parser_expr(const GDParser::Node *p_expr) {
txt = _parser_expr(c_node->arguments[0]) + "[" + _parser_expr(c_node->arguments[1]) + "]";
} break;
- case GDParser::OperatorNode::OP_INDEX_NAMED: {
+ case GDScriptParser::OperatorNode::OP_INDEX_NAMED: {
ERR_FAIL_COND_V(c_node->arguments.size() != 2, "");
txt = _parser_expr(c_node->arguments[0]) + "." + _parser_expr(c_node->arguments[1]);
} break;
- case GDParser::OperatorNode::OP_NEG: {
+ case GDScriptParser::OperatorNode::OP_NEG: {
txt = "-" + _parser_expr(c_node->arguments[0]);
} break;
- case GDParser::OperatorNode::OP_NOT: {
+ case GDScriptParser::OperatorNode::OP_NOT: {
txt = "not " + _parser_expr(c_node->arguments[0]);
} break;
- case GDParser::OperatorNode::OP_BIT_INVERT: {
+ case GDScriptParser::OperatorNode::OP_BIT_INVERT: {
txt = "~" + _parser_expr(c_node->arguments[0]);
} break;
- case GDParser::OperatorNode::OP_PREINC: {
+ case GDScriptParser::OperatorNode::OP_PREINC: {
} break;
- case GDParser::OperatorNode::OP_PREDEC: {
+ case GDScriptParser::OperatorNode::OP_PREDEC: {
} break;
- case GDParser::OperatorNode::OP_INC: {
+ case GDScriptParser::OperatorNode::OP_INC: {
} break;
- case GDParser::OperatorNode::OP_DEC: {
+ case GDScriptParser::OperatorNode::OP_DEC: {
} break;
- case GDParser::OperatorNode::OP_IN: {
+ case GDScriptParser::OperatorNode::OP_IN: {
txt = _parser_expr(c_node->arguments[0]) + " in " + _parser_expr(c_node->arguments[1]);
} break;
- case GDParser::OperatorNode::OP_EQUAL: {
+ case GDScriptParser::OperatorNode::OP_EQUAL: {
txt = _parser_expr(c_node->arguments[0]) + "==" + _parser_expr(c_node->arguments[1]);
} break;
- case GDParser::OperatorNode::OP_NOT_EQUAL: {
+ case GDScriptParser::OperatorNode::OP_NOT_EQUAL: {
txt = _parser_expr(c_node->arguments[0]) + "!=" + _parser_expr(c_node->arguments[1]);
} break;
- case GDParser::OperatorNode::OP_LESS: {
+ case GDScriptParser::OperatorNode::OP_LESS: {
txt = _parser_expr(c_node->arguments[0]) + "<" + _parser_expr(c_node->arguments[1]);
} break;
- case GDParser::OperatorNode::OP_LESS_EQUAL: {
+ case GDScriptParser::OperatorNode::OP_LESS_EQUAL: {
txt = _parser_expr(c_node->arguments[0]) + "<=" + _parser_expr(c_node->arguments[1]);
} break;
- case GDParser::OperatorNode::OP_GREATER: {
+ case GDScriptParser::OperatorNode::OP_GREATER: {
txt = _parser_expr(c_node->arguments[0]) + ">" + _parser_expr(c_node->arguments[1]);
} break;
- case GDParser::OperatorNode::OP_GREATER_EQUAL: {
+ case GDScriptParser::OperatorNode::OP_GREATER_EQUAL: {
txt = _parser_expr(c_node->arguments[0]) + ">=" + _parser_expr(c_node->arguments[1]);
} break;
- case GDParser::OperatorNode::OP_AND: {
+ case GDScriptParser::OperatorNode::OP_AND: {
txt = _parser_expr(c_node->arguments[0]) + " and " + _parser_expr(c_node->arguments[1]);
} break;
- case GDParser::OperatorNode::OP_OR: {
+ case GDScriptParser::OperatorNode::OP_OR: {
txt = _parser_expr(c_node->arguments[0]) + " or " + _parser_expr(c_node->arguments[1]);
} break;
- case GDParser::OperatorNode::OP_ADD: {
+ case GDScriptParser::OperatorNode::OP_ADD: {
txt = _parser_expr(c_node->arguments[0]) + "+" + _parser_expr(c_node->arguments[1]);
} break;
- case GDParser::OperatorNode::OP_SUB: {
+ case GDScriptParser::OperatorNode::OP_SUB: {
txt = _parser_expr(c_node->arguments[0]) + "-" + _parser_expr(c_node->arguments[1]);
} break;
- case GDParser::OperatorNode::OP_MUL: {
+ case GDScriptParser::OperatorNode::OP_MUL: {
txt = _parser_expr(c_node->arguments[0]) + "*" + _parser_expr(c_node->arguments[1]);
} break;
- case GDParser::OperatorNode::OP_DIV: {
+ case GDScriptParser::OperatorNode::OP_DIV: {
txt = _parser_expr(c_node->arguments[0]) + "/" + _parser_expr(c_node->arguments[1]);
} break;
- case GDParser::OperatorNode::OP_MOD: {
+ case GDScriptParser::OperatorNode::OP_MOD: {
txt = _parser_expr(c_node->arguments[0]) + "%" + _parser_expr(c_node->arguments[1]);
} break;
- case GDParser::OperatorNode::OP_SHIFT_LEFT: {
+ case GDScriptParser::OperatorNode::OP_SHIFT_LEFT: {
txt = _parser_expr(c_node->arguments[0]) + "<<" + _parser_expr(c_node->arguments[1]);
} break;
- case GDParser::OperatorNode::OP_SHIFT_RIGHT: {
+ case GDScriptParser::OperatorNode::OP_SHIFT_RIGHT: {
txt = _parser_expr(c_node->arguments[0]) + ">>" + _parser_expr(c_node->arguments[1]);
} break;
- case GDParser::OperatorNode::OP_ASSIGN: {
+ case GDScriptParser::OperatorNode::OP_ASSIGN: {
txt = _parser_expr(c_node->arguments[0]) + "=" + _parser_expr(c_node->arguments[1]);
} break;
- case GDParser::OperatorNode::OP_ASSIGN_ADD: {
+ case GDScriptParser::OperatorNode::OP_ASSIGN_ADD: {
txt = _parser_expr(c_node->arguments[0]) + "+=" + _parser_expr(c_node->arguments[1]);
} break;
- case GDParser::OperatorNode::OP_ASSIGN_SUB: {
+ case GDScriptParser::OperatorNode::OP_ASSIGN_SUB: {
txt = _parser_expr(c_node->arguments[0]) + "-=" + _parser_expr(c_node->arguments[1]);
} break;
- case GDParser::OperatorNode::OP_ASSIGN_MUL: {
+ case GDScriptParser::OperatorNode::OP_ASSIGN_MUL: {
txt = _parser_expr(c_node->arguments[0]) + "*=" + _parser_expr(c_node->arguments[1]);
} break;
- case GDParser::OperatorNode::OP_ASSIGN_DIV: {
+ case GDScriptParser::OperatorNode::OP_ASSIGN_DIV: {
txt = _parser_expr(c_node->arguments[0]) + "/=" + _parser_expr(c_node->arguments[1]);
} break;
- case GDParser::OperatorNode::OP_ASSIGN_MOD: {
+ case GDScriptParser::OperatorNode::OP_ASSIGN_MOD: {
txt = _parser_expr(c_node->arguments[0]) + "%=" + _parser_expr(c_node->arguments[1]);
} break;
- case GDParser::OperatorNode::OP_ASSIGN_SHIFT_LEFT: {
+ case GDScriptParser::OperatorNode::OP_ASSIGN_SHIFT_LEFT: {
txt = _parser_expr(c_node->arguments[0]) + "<<=" + _parser_expr(c_node->arguments[1]);
} break;
- case GDParser::OperatorNode::OP_ASSIGN_SHIFT_RIGHT: {
+ case GDScriptParser::OperatorNode::OP_ASSIGN_SHIFT_RIGHT: {
txt = _parser_expr(c_node->arguments[0]) + ">>=" + _parser_expr(c_node->arguments[1]);
} break;
- case GDParser::OperatorNode::OP_ASSIGN_BIT_AND: {
+ case GDScriptParser::OperatorNode::OP_ASSIGN_BIT_AND: {
txt = _parser_expr(c_node->arguments[0]) + "&=" + _parser_expr(c_node->arguments[1]);
} break;
- case GDParser::OperatorNode::OP_ASSIGN_BIT_OR: {
+ case GDScriptParser::OperatorNode::OP_ASSIGN_BIT_OR: {
txt = _parser_expr(c_node->arguments[0]) + "|=" + _parser_expr(c_node->arguments[1]);
} break;
- case GDParser::OperatorNode::OP_ASSIGN_BIT_XOR: {
+ case GDScriptParser::OperatorNode::OP_ASSIGN_BIT_XOR: {
txt = _parser_expr(c_node->arguments[0]) + "^=" + _parser_expr(c_node->arguments[1]);
} break;
- case GDParser::OperatorNode::OP_BIT_AND: {
+ case GDScriptParser::OperatorNode::OP_BIT_AND: {
txt = _parser_expr(c_node->arguments[0]) + "&" + _parser_expr(c_node->arguments[1]);
} break;
- case GDParser::OperatorNode::OP_BIT_OR: {
+ case GDScriptParser::OperatorNode::OP_BIT_OR: {
txt = _parser_expr(c_node->arguments[0]) + "|" + _parser_expr(c_node->arguments[1]);
} break;
- case GDParser::OperatorNode::OP_BIT_XOR: {
+ case GDScriptParser::OperatorNode::OP_BIT_XOR: {
txt = _parser_expr(c_node->arguments[0]) + "^" + _parser_expr(c_node->arguments[1]);
} break;
default: {}
}
} break;
- case GDParser::Node::TYPE_NEWLINE: {
+ case GDScriptParser::Node::TYPE_NEWLINE: {
//skippie
} break;
@@ -310,20 +310,20 @@ static String _parser_expr(const GDParser::Node *p_expr) {
//return "("+txt+")";
}
-static void _parser_show_block(const GDParser::BlockNode *p_block, int p_indent) {
+static void _parser_show_block(const GDScriptParser::BlockNode *p_block, int p_indent) {
for (int i = 0; i < p_block->statements.size(); i++) {
- const GDParser::Node *statement = p_block->statements[i];
+ const GDScriptParser::Node *statement = p_block->statements[i];
switch (statement->type) {
- case GDParser::Node::TYPE_CONTROL_FLOW: {
+ case GDScriptParser::Node::TYPE_CONTROL_FLOW: {
- const GDParser::ControlFlowNode *cf_node = static_cast<const GDParser::ControlFlowNode *>(statement);
+ const GDScriptParser::ControlFlowNode *cf_node = static_cast<const GDScriptParser::ControlFlowNode *>(statement);
switch (cf_node->cf_type) {
- case GDParser::ControlFlowNode::CF_IF: {
+ case GDScriptParser::ControlFlowNode::CF_IF: {
ERR_FAIL_COND(cf_node->arguments.size() != 1);
String txt;
@@ -339,7 +339,7 @@ static void _parser_show_block(const GDParser::BlockNode *p_block, int p_indent)
}
} break;
- case GDParser::ControlFlowNode::CF_FOR: {
+ case GDScriptParser::ControlFlowNode::CF_FOR: {
ERR_FAIL_COND(cf_node->arguments.size() != 2);
String txt;
txt += "for ";
@@ -352,7 +352,7 @@ static void _parser_show_block(const GDParser::BlockNode *p_block, int p_indent)
_parser_show_block(cf_node->body, p_indent + 1);
} break;
- case GDParser::ControlFlowNode::CF_WHILE: {
+ case GDScriptParser::ControlFlowNode::CF_WHILE: {
ERR_FAIL_COND(cf_node->arguments.size() != 1);
String txt;
@@ -364,18 +364,18 @@ static void _parser_show_block(const GDParser::BlockNode *p_block, int p_indent)
_parser_show_block(cf_node->body, p_indent + 1);
} break;
- case GDParser::ControlFlowNode::CF_SWITCH: {
+ case GDScriptParser::ControlFlowNode::CF_SWITCH: {
} break;
- case GDParser::ControlFlowNode::CF_CONTINUE: {
+ case GDScriptParser::ControlFlowNode::CF_CONTINUE: {
_print_indent(p_indent, "continue");
} break;
- case GDParser::ControlFlowNode::CF_BREAK: {
+ case GDScriptParser::ControlFlowNode::CF_BREAK: {
_print_indent(p_indent, "break");
} break;
- case GDParser::ControlFlowNode::CF_RETURN: {
+ case GDScriptParser::ControlFlowNode::CF_RETURN: {
if (cf_node->arguments.size())
_print_indent(p_indent, "return " + _parser_expr(cf_node->arguments[0]));
@@ -385,9 +385,9 @@ static void _parser_show_block(const GDParser::BlockNode *p_block, int p_indent)
}
} break;
- case GDParser::Node::TYPE_LOCAL_VAR: {
+ case GDScriptParser::Node::TYPE_LOCAL_VAR: {
- const GDParser::LocalVarNode *lv_node = static_cast<const GDParser::LocalVarNode *>(statement);
+ const GDScriptParser::LocalVarNode *lv_node = static_cast<const GDScriptParser::LocalVarNode *>(statement);
_print_indent(p_indent, "var " + String(lv_node->name));
} break;
default: {
@@ -398,7 +398,7 @@ static void _parser_show_block(const GDParser::BlockNode *p_block, int p_indent)
}
}
-static void _parser_show_function(const GDParser::FunctionNode *p_func, int p_indent, GDParser::BlockNode *p_initializer = NULL) {
+static void _parser_show_function(const GDScriptParser::FunctionNode *p_func, int p_indent, GDScriptParser::BlockNode *p_initializer = NULL) {
String txt;
if (p_func->_static)
@@ -434,7 +434,7 @@ static void _parser_show_function(const GDParser::FunctionNode *p_func, int p_in
_parser_show_block(p_func->body, p_indent + 1);
}
-static void _parser_show_class(const GDParser::ClassNode *p_class, int p_indent, const Vector<String> &p_code) {
+static void _parser_show_class(const GDScriptParser::ClassNode *p_class, int p_indent, const Vector<String> &p_code) {
if (p_indent == 0 && (String(p_class->extends_file) != "" || p_class->extends_class.size())) {
@@ -444,7 +444,7 @@ static void _parser_show_class(const GDParser::ClassNode *p_class, int p_indent,
for (int i = 0; i < p_class->subclasses.size(); i++) {
- const GDParser::ClassNode *subclass = p_class->subclasses[i];
+ const GDScriptParser::ClassNode *subclass = p_class->subclasses[i];
String line = "class " + subclass->name;
if (String(subclass->extends_file) != "" || subclass->extends_class.size())
line += " " + _parser_extends(subclass);
@@ -456,13 +456,13 @@ static void _parser_show_class(const GDParser::ClassNode *p_class, int p_indent,
for (int i = 0; i < p_class->constant_expressions.size(); i++) {
- const GDParser::ClassNode::Constant &constant = p_class->constant_expressions[i];
+ const GDScriptParser::ClassNode::Constant &constant = p_class->constant_expressions[i];
_print_indent(p_indent, "const " + String(constant.identifier) + "=" + _parser_expr(constant.expression));
}
for (int i = 0; i < p_class->variables.size(); i++) {
- const GDParser::ClassNode::Member &m = p_class->variables[i];
+ const GDScriptParser::ClassNode::Member &m = p_class->variables[i];
_print_indent(p_indent, "var " + String(m.identifier));
}
@@ -487,27 +487,27 @@ static void _parser_show_class(const GDParser::ClassNode *p_class, int p_indent,
print_line("\n");
}
-static String _disassemble_addr(const Ref<GDScript> &p_script, const GDFunction &func, int p_addr) {
+static String _disassemble_addr(const Ref<GDScript> &p_script, const GDScriptFunction &func, int p_addr) {
- int addr = p_addr & GDFunction::ADDR_MASK;
+ int addr = p_addr & GDScriptFunction::ADDR_MASK;
- switch (p_addr >> GDFunction::ADDR_BITS) {
+ switch (p_addr >> GDScriptFunction::ADDR_BITS) {
- case GDFunction::ADDR_TYPE_SELF: {
+ case GDScriptFunction::ADDR_TYPE_SELF: {
return "self";
} break;
- case GDFunction::ADDR_TYPE_CLASS: {
+ case GDScriptFunction::ADDR_TYPE_CLASS: {
return "class";
} break;
- case GDFunction::ADDR_TYPE_MEMBER: {
+ case GDScriptFunction::ADDR_TYPE_MEMBER: {
return "member(" + p_script->debug_get_member_by_index(addr) + ")";
} break;
- case GDFunction::ADDR_TYPE_CLASS_CONSTANT: {
+ case GDScriptFunction::ADDR_TYPE_CLASS_CONSTANT: {
return "class_const(" + func.get_global_name(addr) + ")";
} break;
- case GDFunction::ADDR_TYPE_LOCAL_CONSTANT: {
+ case GDScriptFunction::ADDR_TYPE_LOCAL_CONSTANT: {
Variant v = func.get_constant(addr);
String txt;
@@ -517,19 +517,19 @@ static String _disassemble_addr(const Ref<GDScript> &p_script, const GDFunction
txt = v;
return "const(" + txt + ")";
} break;
- case GDFunction::ADDR_TYPE_STACK: {
+ case GDScriptFunction::ADDR_TYPE_STACK: {
return "stack(" + itos(addr) + ")";
} break;
- case GDFunction::ADDR_TYPE_STACK_VARIABLE: {
+ case GDScriptFunction::ADDR_TYPE_STACK_VARIABLE: {
return "var_stack(" + itos(addr) + ")";
} break;
- case GDFunction::ADDR_TYPE_GLOBAL: {
+ case GDScriptFunction::ADDR_TYPE_GLOBAL: {
return "global(" + func.get_global_name(addr) + ")";
} break;
- case GDFunction::ADDR_TYPE_NIL: {
+ case GDScriptFunction::ADDR_TYPE_NIL: {
return "nil";
} break;
}
@@ -539,11 +539,11 @@ static String _disassemble_addr(const Ref<GDScript> &p_script, const GDFunction
static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String> &p_code) {
- const Map<StringName, GDFunction *> &mf = p_class->debug_get_member_functions();
+ const Map<StringName, GDScriptFunction *> &mf = p_class->debug_get_member_functions();
- for (const Map<StringName, GDFunction *>::Element *E = mf.front(); E; E = E->next()) {
+ for (const Map<StringName, GDScriptFunction *>::Element *E = mf.front(); E; E = E->next()) {
- const GDFunction &func = *E->get();
+ const GDScriptFunction &func = *E->get();
const int *code = func.get_code();
int codelen = func.get_code_size();
String defargs;
@@ -568,7 +568,7 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String
switch (code[ip]) {
- case GDFunction::OPCODE_OPERATOR: {
+ case GDScriptFunction::OPCODE_OPERATOR: {
int op = code[ip + 1];
txt += "op ";
@@ -583,7 +583,7 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String
incr += 5;
} break;
- case GDFunction::OPCODE_SET: {
+ case GDScriptFunction::OPCODE_SET: {
txt += "set ";
txt += DADDR(1);
@@ -594,7 +594,7 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String
incr += 4;
} break;
- case GDFunction::OPCODE_GET: {
+ case GDScriptFunction::OPCODE_GET: {
txt += " get ";
txt += DADDR(3);
@@ -606,7 +606,7 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String
incr += 4;
} break;
- case GDFunction::OPCODE_SET_NAMED: {
+ case GDScriptFunction::OPCODE_SET_NAMED: {
txt += " set_named ";
txt += DADDR(1);
@@ -617,7 +617,7 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String
incr += 4;
} break;
- case GDFunction::OPCODE_GET_NAMED: {
+ case GDScriptFunction::OPCODE_GET_NAMED: {
txt += " get_named ";
txt += DADDR(3);
@@ -629,7 +629,7 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String
incr += 4;
} break;
- case GDFunction::OPCODE_SET_MEMBER: {
+ case GDScriptFunction::OPCODE_SET_MEMBER: {
txt += " set_member ";
txt += "[\"";
@@ -639,7 +639,7 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String
incr += 3;
} break;
- case GDFunction::OPCODE_GET_MEMBER: {
+ case GDScriptFunction::OPCODE_GET_MEMBER: {
txt += " get_member ";
txt += DADDR(2);
@@ -650,7 +650,7 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String
incr += 3;
} break;
- case GDFunction::OPCODE_ASSIGN: {
+ case GDScriptFunction::OPCODE_ASSIGN: {
txt += " assign ";
txt += DADDR(1);
@@ -659,7 +659,7 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String
incr += 3;
} break;
- case GDFunction::OPCODE_ASSIGN_TRUE: {
+ case GDScriptFunction::OPCODE_ASSIGN_TRUE: {
txt += " assign ";
txt += DADDR(1);
@@ -667,7 +667,7 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String
incr += 2;
} break;
- case GDFunction::OPCODE_ASSIGN_FALSE: {
+ case GDScriptFunction::OPCODE_ASSIGN_FALSE: {
txt += " assign ";
txt += DADDR(1);
@@ -675,7 +675,7 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String
incr += 2;
} break;
- case GDFunction::OPCODE_CONSTRUCT: {
+ case GDScriptFunction::OPCODE_CONSTRUCT: {
Variant::Type t = Variant::Type(code[ip + 1]);
int argc = code[ip + 2];
@@ -696,7 +696,7 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String
incr = 4 + argc;
} break;
- case GDFunction::OPCODE_CONSTRUCT_ARRAY: {
+ case GDScriptFunction::OPCODE_CONSTRUCT_ARRAY: {
int argc = code[ip + 1];
txt += " make_array ";
@@ -714,7 +714,7 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String
incr += 3 + argc;
} break;
- case GDFunction::OPCODE_CONSTRUCT_DICTIONARY: {
+ case GDScriptFunction::OPCODE_CONSTRUCT_DICTIONARY: {
int argc = code[ip + 1];
txt += " make_dict ";
@@ -735,10 +735,10 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String
} break;
- case GDFunction::OPCODE_CALL:
- case GDFunction::OPCODE_CALL_RETURN: {
+ case GDScriptFunction::OPCODE_CALL:
+ case GDScriptFunction::OPCODE_CALL_RETURN: {
- bool ret = code[ip] == GDFunction::OPCODE_CALL_RETURN;
+ bool ret = code[ip] == GDScriptFunction::OPCODE_CALL_RETURN;
if (ret)
txt += " call-ret ";
@@ -764,14 +764,14 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String
incr = 5 + argc;
} break;
- case GDFunction::OPCODE_CALL_BUILT_IN: {
+ case GDScriptFunction::OPCODE_CALL_BUILT_IN: {
txt += " call-built-in ";
int argc = code[ip + 2];
txt += DADDR(3 + argc) + "=";
- txt += GDFunctions::get_func_name(GDFunctions::Function(code[ip + 1]));
+ txt += GDScriptFunctions::get_func_name(GDScriptFunctions::Function(code[ip + 1]));
txt += "(";
for (int i = 0; i < argc; i++) {
@@ -784,7 +784,7 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String
incr = 4 + argc;
} break;
- case GDFunction::OPCODE_CALL_SELF_BASE: {
+ case GDScriptFunction::OPCODE_CALL_SELF_BASE: {
txt += " call-self-base ";
@@ -804,13 +804,13 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String
incr = 4 + argc;
} break;
- case GDFunction::OPCODE_YIELD: {
+ case GDScriptFunction::OPCODE_YIELD: {
txt += " yield ";
incr = 1;
} break;
- case GDFunction::OPCODE_YIELD_SIGNAL: {
+ case GDScriptFunction::OPCODE_YIELD_SIGNAL: {
txt += " yield_signal ";
txt += DADDR(1);
@@ -818,13 +818,13 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String
txt += DADDR(2);
incr = 3;
} break;
- case GDFunction::OPCODE_YIELD_RESUME: {
+ case GDScriptFunction::OPCODE_YIELD_RESUME: {
txt += " yield resume: ";
txt += DADDR(1);
incr = 2;
} break;
- case GDFunction::OPCODE_JUMP: {
+ case GDScriptFunction::OPCODE_JUMP: {
txt += " jump ";
txt += itos(code[ip + 1]);
@@ -832,7 +832,7 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String
incr = 2;
} break;
- case GDFunction::OPCODE_JUMP_IF: {
+ case GDScriptFunction::OPCODE_JUMP_IF: {
txt += " jump-if ";
txt += DADDR(1);
@@ -841,7 +841,7 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String
incr = 3;
} break;
- case GDFunction::OPCODE_JUMP_IF_NOT: {
+ case GDScriptFunction::OPCODE_JUMP_IF_NOT: {
txt += " jump-if-not ";
txt += DADDR(1);
@@ -850,12 +850,12 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String
incr = 3;
} break;
- case GDFunction::OPCODE_JUMP_TO_DEF_ARGUMENT: {
+ case GDScriptFunction::OPCODE_JUMP_TO_DEF_ARGUMENT: {
txt += " jump-to-default-argument ";
incr = 1;
} break;
- case GDFunction::OPCODE_RETURN: {
+ case GDScriptFunction::OPCODE_RETURN: {
txt += " return ";
txt += DADDR(1);
@@ -863,19 +863,19 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String
incr = 2;
} break;
- case GDFunction::OPCODE_ITERATE_BEGIN: {
+ case GDScriptFunction::OPCODE_ITERATE_BEGIN: {
txt += " for-init " + DADDR(4) + " in " + DADDR(2) + " counter " + DADDR(1) + " end " + itos(code[ip + 3]);
incr += 5;
} break;
- case GDFunction::OPCODE_ITERATE: {
+ case GDScriptFunction::OPCODE_ITERATE: {
txt += " for-loop " + DADDR(4) + " in " + DADDR(2) + " counter " + DADDR(1) + " end " + itos(code[ip + 3]);
incr += 5;
} break;
- case GDFunction::OPCODE_LINE: {
+ case GDScriptFunction::OPCODE_LINE: {
int line = code[ip + 1] - 1;
if (line >= 0 && line < p_code.size())
@@ -884,12 +884,12 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String
txt = "";
incr += 2;
} break;
- case GDFunction::OPCODE_END: {
+ case GDScriptFunction::OPCODE_END: {
txt += " end";
incr += 1;
} break;
- case GDFunction::OPCODE_ASSERT: {
+ case GDScriptFunction::OPCODE_ASSERT: {
txt += " assert ";
txt += DADDR(1);
@@ -952,15 +952,15 @@ MainLoop *test(TestType p_type) {
if (p_type == TEST_TOKENIZER) {
- GDTokenizerText tk;
+ GDScriptTokenizerText tk;
tk.set_code(code);
int line = -1;
- while (tk.get_token() != GDTokenizer::TK_EOF) {
+ while (tk.get_token() != GDScriptTokenizer::TK_EOF) {
String text;
- if (tk.get_token() == GDTokenizer::TK_IDENTIFIER)
+ if (tk.get_token() == GDScriptTokenizer::TK_IDENTIFIER)
text = "'" + tk.get_token_identifier() + "' (identifier)";
- else if (tk.get_token() == GDTokenizer::TK_CONSTANT) {
+ else if (tk.get_token() == GDScriptTokenizer::TK_CONSTANT) {
Variant c = tk.get_token_constant();
if (c.get_type() == Variant::STRING)
text = "\"" + String(c) + "\"";
@@ -968,12 +968,12 @@ MainLoop *test(TestType p_type) {
text = c;
text = text + " (" + Variant::get_type_name(c.get_type()) + " constant)";
- } else if (tk.get_token() == GDTokenizer::TK_ERROR)
+ } else if (tk.get_token() == GDScriptTokenizer::TK_ERROR)
text = "ERROR: " + tk.get_token_error();
- else if (tk.get_token() == GDTokenizer::TK_NEWLINE)
+ else if (tk.get_token() == GDScriptTokenizer::TK_NEWLINE)
text = "newline (" + itos(tk.get_token_line()) + ") + indent: " + itos(tk.get_token_line_indent());
- else if (tk.get_token() == GDTokenizer::TK_BUILT_IN_FUNC)
- text = "'" + String(GDFunctions::get_func_name(tk.get_token_built_in_func())) + "' (built-in function)";
+ else if (tk.get_token() == GDScriptTokenizer::TK_BUILT_IN_FUNC)
+ text = "'" + String(GDScriptFunctions::get_func_name(tk.get_token_built_in_func())) + "' (built-in function)";
else
text = tk.get_token_name(tk.get_token());
@@ -995,7 +995,7 @@ MainLoop *test(TestType p_type) {
if (p_type == TEST_PARSER) {
- GDParser parser;
+ GDScriptParser parser;
Error err = parser.parse(code);
if (err) {
print_line("Parse Error:\n" + itos(parser.get_error_line()) + ":" + itos(parser.get_error_column()) + ":" + parser.get_error());
@@ -1003,16 +1003,16 @@ MainLoop *test(TestType p_type) {
return NULL;
}
- const GDParser::Node *root = parser.get_parse_tree();
- ERR_FAIL_COND_V(root->type != GDParser::Node::TYPE_CLASS, NULL);
- const GDParser::ClassNode *cnode = static_cast<const GDParser::ClassNode *>(root);
+ const GDScriptParser::Node *root = parser.get_parse_tree();
+ ERR_FAIL_COND_V(root->type != GDScriptParser::Node::TYPE_CLASS, NULL);
+ const GDScriptParser::ClassNode *cnode = static_cast<const GDScriptParser::ClassNode *>(root);
_parser_show_class(cnode, 0, lines);
}
if (p_type == TEST_COMPILER) {
- GDParser parser;
+ GDScriptParser parser;
Error err = parser.parse(code);
if (err) {
@@ -1023,7 +1023,7 @@ MainLoop *test(TestType p_type) {
GDScript *script = memnew(GDScript);
- GDCompiler gdc;
+ GDScriptCompiler gdc;
err = gdc.compile(&parser, script);
if (err) {
@@ -1046,7 +1046,7 @@ MainLoop *test(TestType p_type) {
} else if (p_type == TEST_BYTECODE) {
- Vector<uint8_t> buf = GDTokenizerBuffer::parse_code_string(code);
+ Vector<uint8_t> buf = GDScriptTokenizerBuffer::parse_code_string(code);
String dst = test.get_basename() + ".gdc";
FileAccess *fw = FileAccess::open(dst, FileAccess::WRITE);
fw->store_buffer(buf.ptr(), buf.size());
diff --git a/misc/dist/html/default.html b/misc/dist/html/default.html
index 9fae34f97e..91193eea47 100644
--- a/misc/dist/html/default.html
+++ b/misc/dist/html/default.html
@@ -230,7 +230,6 @@ $GODOT_HEAD_INCLUDE
(function() {
const BASENAME = '$GODOT_BASENAME';
- const MEMORY_SIZE = $GODOT_TOTAL_MEMORY;
const DEBUG_ENABLED = $GODOT_DEBUG_ENABLED;
const INDETERMINATE_STATUS_STEP_MS = 100;
@@ -247,7 +246,6 @@ $GODOT_HEAD_INCLUDE
setStatusMode('indeterminate');
game.setCanvas(canvas);
- game.setAsmjsMemorySize(MEMORY_SIZE);
function setStatusMode(mode) {
diff --git a/modules/gdnative/SCsub b/modules/gdnative/SCsub
index 2755930a55..66b8d5cbdd 100644
--- a/modules/gdnative/SCsub
+++ b/modules/gdnative/SCsub
@@ -19,6 +19,20 @@ def _spaced(e):
return e if e[-1] == '*' else e + ' '
def _build_gdnative_api_struct_header(api):
+ ext_wrappers = ''
+
+ for name in api['extensions']:
+ ext_wrappers += ' extern const godot_gdnative_ext_' + name + '_api_struct *_gdnative_wrapper_' + name + '_api_struct;'
+
+ ext_init = 'for (int i = 0; i < _gdnative_wrapper_api_struct->num_extensions; i++) { '
+ ext_init += 'switch (_gdnative_wrapper_api_struct->extensions[i]->type) {'
+
+ for name in api['extensions']:
+ ext_init += 'case GDNATIVE_EXT_' + api['extensions'][name]['type'] + ': '
+ ext_init += '_gdnative_wrapper_' + name + '_api_struct = (' + 'godot_gdnative_ext_' + name + '_api_struct *) _gdnative_wrapper_api_struct->extensions[i]; break;'
+
+ ext_init += '}'
+
out = [
'/* THIS FILE IS GENERATED DO NOT EDIT */',
'#ifndef GODOT_GDNATIVE_API_STRUCT_H',
@@ -29,7 +43,7 @@ def _build_gdnative_api_struct_header(api):
'#include <nativescript/godot_nativescript.h>',
'#include <pluginscript/godot_pluginscript.h>',
'',
- '#define GDNATIVE_API_INIT(options) do { extern const godot_gdnative_api_struct *_gdnative_wrapper_api_struct; _gdnative_wrapper_api_struct = options->api_struct; } while (0)',
+ '#define GDNATIVE_API_INIT(options) do { extern const godot_gdnative_api_struct *_gdnative_wrapper_api_struct;' + ext_wrappers + ' _gdnative_wrapper_api_struct = options->api_struct; ' + ext_init + ' } while (0)',
'',
'#ifdef __cplusplus',
'extern "C" {',
@@ -166,18 +180,23 @@ def _build_gdnative_wrapper_code(api):
'#include <gdnative/gdnative.h>',
'#include <nativescript/godot_nativescript.h>',
'#include <pluginscript/godot_pluginscript.h>',
+ '#include <arvr/godot_arvr.h>',
'',
'#include <gdnative_api_struct.gen.h>',
'',
- 'godot_gdnative_api_struct *_gdnative_wrapper_api_struct = 0;',
- '',
'#ifdef __cplusplus',
'extern "C" {',
'#endif',
- ''
+ '',
+ 'godot_gdnative_core_api_struct *_gdnative_wrapper_api_struct = 0;',
]
- for funcdef in api['api']:
+ for name in api['extensions']:
+ out.append('godot_gdnative_ext_' + name + '_api_struct *_gdnative_wrapper_' + name + '_api_struct;')
+
+ out += ['']
+
+ for funcdef in api['core']['api']:
args = ', '.join(['%s%s' % (_spaced(t), n) for t, n in funcdef['arguments']])
out.append('%s%s(%s) {' % (_spaced(funcdef['return_type']), funcdef['name'], args))
@@ -190,6 +209,20 @@ def _build_gdnative_wrapper_code(api):
out.append('}')
out.append('')
+ for name in api['extensions']:
+ for funcdef in api['extensions'][name]['api']:
+ args = ', '.join(['%s%s' % (_spaced(t), n) for t, n in funcdef['arguments']])
+ out.append('%s%s(%s) {' % (_spaced(funcdef['return_type']), funcdef['name'], args))
+
+ args = ', '.join(['%s' % n for t, n in funcdef['arguments']])
+
+ return_line = '\treturn ' if funcdef['return_type'] != 'void' else '\t'
+ return_line += '_gdnative_wrapper_' + name + '_api_struct->' + funcdef['name'] + '(' + args + ');'
+
+ out.append(return_line)
+ out.append('}')
+ out.append('')
+
out += [
'#ifdef __cplusplus',
'}',
diff --git a/modules/gdnative/gdnative/aabb.cpp b/modules/gdnative/gdnative/aabb.cpp
new file mode 100644
index 0000000000..6c89bcdceb
--- /dev/null
+++ b/modules/gdnative/gdnative/aabb.cpp
@@ -0,0 +1,217 @@
+/*************************************************************************/
+/* aabb.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 "gdnative/aabb.h"
+
+#include "core/math/aabb.h"
+#include "core/variant.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void GDAPI godot_aabb_new(godot_aabb *r_dest, const godot_vector3 *p_pos, const godot_vector3 *p_size) {
+ const Vector3 *pos = (const Vector3 *)p_pos;
+ const Vector3 *size = (const Vector3 *)p_size;
+ AABB *dest = (AABB *)r_dest;
+ *dest = AABB(*pos, *size);
+}
+
+godot_vector3 GDAPI godot_aabb_get_position(const godot_aabb *p_self) {
+ godot_vector3 raw_ret;
+ const AABB *self = (const AABB *)p_self;
+ Vector3 *ret = (Vector3 *)&raw_ret;
+ *ret = self->position;
+ return raw_ret;
+}
+
+void GDAPI godot_aabb_set_position(const godot_aabb *p_self, const godot_vector3 *p_v) {
+ AABB *self = (AABB *)p_self;
+ const Vector3 *v = (const Vector3 *)p_v;
+ self->position = *v;
+}
+
+godot_vector3 GDAPI godot_aabb_get_size(const godot_aabb *p_self) {
+ godot_vector3 raw_ret;
+ const AABB *self = (const AABB *)p_self;
+ Vector3 *ret = (Vector3 *)&raw_ret;
+ *ret = self->size;
+ return raw_ret;
+}
+
+void GDAPI godot_aabb_set_size(const godot_aabb *p_self, const godot_vector3 *p_v) {
+ AABB *self = (AABB *)p_self;
+ const Vector3 *v = (const Vector3 *)p_v;
+ self->size = *v;
+}
+
+godot_string GDAPI godot_aabb_as_string(const godot_aabb *p_self) {
+ godot_string ret;
+ const AABB *self = (const AABB *)p_self;
+ memnew_placement(&ret, String(*self));
+ return ret;
+}
+
+godot_real GDAPI godot_aabb_get_area(const godot_aabb *p_self) {
+ const AABB *self = (const AABB *)p_self;
+ return self->get_area();
+}
+
+godot_bool GDAPI godot_aabb_has_no_area(const godot_aabb *p_self) {
+ const AABB *self = (const AABB *)p_self;
+ return self->has_no_area();
+}
+
+godot_bool GDAPI godot_aabb_has_no_surface(const godot_aabb *p_self) {
+ const AABB *self = (const AABB *)p_self;
+ return self->has_no_surface();
+}
+
+godot_bool GDAPI godot_aabb_intersects(const godot_aabb *p_self, const godot_aabb *p_with) {
+ const AABB *self = (const AABB *)p_self;
+ const AABB *with = (const AABB *)p_with;
+ return self->intersects(*with);
+}
+
+godot_bool GDAPI godot_aabb_encloses(const godot_aabb *p_self, const godot_aabb *p_with) {
+ const AABB *self = (const AABB *)p_self;
+ const AABB *with = (const AABB *)p_with;
+ return self->encloses(*with);
+}
+
+godot_aabb GDAPI godot_aabb_merge(const godot_aabb *p_self, const godot_aabb *p_with) {
+ godot_aabb dest;
+ const AABB *self = (const AABB *)p_self;
+ const AABB *with = (const AABB *)p_with;
+ *((AABB *)&dest) = self->merge(*with);
+ return dest;
+}
+
+godot_aabb GDAPI godot_aabb_intersection(const godot_aabb *p_self, const godot_aabb *p_with) {
+ godot_aabb dest;
+ const AABB *self = (const AABB *)p_self;
+ const AABB *with = (const AABB *)p_with;
+ *((AABB *)&dest) = self->intersection(*with);
+ return dest;
+}
+
+godot_bool GDAPI godot_aabb_intersects_plane(const godot_aabb *p_self, const godot_plane *p_plane) {
+ const AABB *self = (const AABB *)p_self;
+ const Plane *plane = (const Plane *)p_plane;
+ return self->intersects_plane(*plane);
+}
+
+godot_bool GDAPI godot_aabb_intersects_segment(const godot_aabb *p_self, const godot_vector3 *p_from, const godot_vector3 *p_to) {
+ const AABB *self = (const AABB *)p_self;
+ const Vector3 *from = (const Vector3 *)p_from;
+ const Vector3 *to = (const Vector3 *)p_to;
+ return self->intersects_segment(*from, *to);
+}
+
+godot_bool GDAPI godot_aabb_has_point(const godot_aabb *p_self, const godot_vector3 *p_point) {
+ const AABB *self = (const AABB *)p_self;
+ const Vector3 *point = (const Vector3 *)p_point;
+ return self->has_point(*point);
+}
+
+godot_vector3 GDAPI godot_aabb_get_support(const godot_aabb *p_self, const godot_vector3 *p_dir) {
+ godot_vector3 dest;
+ const AABB *self = (const AABB *)p_self;
+ const Vector3 *dir = (const Vector3 *)p_dir;
+ *((Vector3 *)&dest) = self->get_support(*dir);
+ return dest;
+}
+
+godot_vector3 GDAPI godot_aabb_get_longest_axis(const godot_aabb *p_self) {
+ godot_vector3 dest;
+ const AABB *self = (const AABB *)p_self;
+ *((Vector3 *)&dest) = self->get_longest_axis();
+ return dest;
+}
+
+godot_int GDAPI godot_aabb_get_longest_axis_index(const godot_aabb *p_self) {
+ const AABB *self = (const AABB *)p_self;
+ return self->get_longest_axis_index();
+}
+
+godot_real GDAPI godot_aabb_get_longest_axis_size(const godot_aabb *p_self) {
+ const AABB *self = (const AABB *)p_self;
+ return self->get_longest_axis_size();
+}
+
+godot_vector3 GDAPI godot_aabb_get_shortest_axis(const godot_aabb *p_self) {
+ godot_vector3 dest;
+ const AABB *self = (const AABB *)p_self;
+ *((Vector3 *)&dest) = self->get_shortest_axis();
+ return dest;
+}
+
+godot_int GDAPI godot_aabb_get_shortest_axis_index(const godot_aabb *p_self) {
+ const AABB *self = (const AABB *)p_self;
+ return self->get_shortest_axis_index();
+}
+
+godot_real GDAPI godot_aabb_get_shortest_axis_size(const godot_aabb *p_self) {
+ const AABB *self = (const AABB *)p_self;
+ return self->get_shortest_axis_size();
+}
+
+godot_aabb GDAPI godot_aabb_expand(const godot_aabb *p_self, const godot_vector3 *p_to_point) {
+ godot_aabb dest;
+ const AABB *self = (const AABB *)p_self;
+ const Vector3 *to_point = (const Vector3 *)p_to_point;
+ *((AABB *)&dest) = self->expand(*to_point);
+ return dest;
+}
+
+godot_aabb GDAPI godot_aabb_grow(const godot_aabb *p_self, const godot_real p_by) {
+ godot_aabb dest;
+ const AABB *self = (const AABB *)p_self;
+
+ *((AABB *)&dest) = self->grow(p_by);
+ return dest;
+}
+
+godot_vector3 GDAPI godot_aabb_get_endpoint(const godot_aabb *p_self, const godot_int p_idx) {
+ godot_vector3 dest;
+ const AABB *self = (const AABB *)p_self;
+
+ *((Vector3 *)&dest) = self->get_endpoint(p_idx);
+ return dest;
+}
+
+godot_bool GDAPI godot_aabb_operator_equal(const godot_aabb *p_self, const godot_aabb *p_b) {
+ const AABB *self = (const AABB *)p_self;
+ const AABB *b = (const AABB *)p_b;
+ return *self == *b;
+}
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/modules/gdnative/gdnative/rect3.cpp b/modules/gdnative/gdnative/rect3.cpp
deleted file mode 100644
index 8e088743b4..0000000000
--- a/modules/gdnative/gdnative/rect3.cpp
+++ /dev/null
@@ -1,217 +0,0 @@
-/*************************************************************************/
-/* rect3.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 "gdnative/rect3.h"
-
-#include "core/math/rect3.h"
-#include "core/variant.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-void GDAPI godot_rect3_new(godot_rect3 *r_dest, const godot_vector3 *p_pos, const godot_vector3 *p_size) {
- const Vector3 *pos = (const Vector3 *)p_pos;
- const Vector3 *size = (const Vector3 *)p_size;
- Rect3 *dest = (Rect3 *)r_dest;
- *dest = Rect3(*pos, *size);
-}
-
-godot_vector3 GDAPI godot_rect3_get_position(const godot_rect3 *p_self) {
- godot_vector3 raw_ret;
- const Rect3 *self = (const Rect3 *)p_self;
- Vector3 *ret = (Vector3 *)&raw_ret;
- *ret = self->position;
- return raw_ret;
-}
-
-void GDAPI godot_rect3_set_position(const godot_rect3 *p_self, const godot_vector3 *p_v) {
- Rect3 *self = (Rect3 *)p_self;
- const Vector3 *v = (const Vector3 *)p_v;
- self->position = *v;
-}
-
-godot_vector3 GDAPI godot_rect3_get_size(const godot_rect3 *p_self) {
- godot_vector3 raw_ret;
- const Rect3 *self = (const Rect3 *)p_self;
- Vector3 *ret = (Vector3 *)&raw_ret;
- *ret = self->size;
- return raw_ret;
-}
-
-void GDAPI godot_rect3_set_size(const godot_rect3 *p_self, const godot_vector3 *p_v) {
- Rect3 *self = (Rect3 *)p_self;
- const Vector3 *v = (const Vector3 *)p_v;
- self->size = *v;
-}
-
-godot_string GDAPI godot_rect3_as_string(const godot_rect3 *p_self) {
- godot_string ret;
- const Rect3 *self = (const Rect3 *)p_self;
- memnew_placement(&ret, String(*self));
- return ret;
-}
-
-godot_real GDAPI godot_rect3_get_area(const godot_rect3 *p_self) {
- const Rect3 *self = (const Rect3 *)p_self;
- return self->get_area();
-}
-
-godot_bool GDAPI godot_rect3_has_no_area(const godot_rect3 *p_self) {
- const Rect3 *self = (const Rect3 *)p_self;
- return self->has_no_area();
-}
-
-godot_bool GDAPI godot_rect3_has_no_surface(const godot_rect3 *p_self) {
- const Rect3 *self = (const Rect3 *)p_self;
- return self->has_no_surface();
-}
-
-godot_bool GDAPI godot_rect3_intersects(const godot_rect3 *p_self, const godot_rect3 *p_with) {
- const Rect3 *self = (const Rect3 *)p_self;
- const Rect3 *with = (const Rect3 *)p_with;
- return self->intersects(*with);
-}
-
-godot_bool GDAPI godot_rect3_encloses(const godot_rect3 *p_self, const godot_rect3 *p_with) {
- const Rect3 *self = (const Rect3 *)p_self;
- const Rect3 *with = (const Rect3 *)p_with;
- return self->encloses(*with);
-}
-
-godot_rect3 GDAPI godot_rect3_merge(const godot_rect3 *p_self, const godot_rect3 *p_with) {
- godot_rect3 dest;
- const Rect3 *self = (const Rect3 *)p_self;
- const Rect3 *with = (const Rect3 *)p_with;
- *((Rect3 *)&dest) = self->merge(*with);
- return dest;
-}
-
-godot_rect3 GDAPI godot_rect3_intersection(const godot_rect3 *p_self, const godot_rect3 *p_with) {
- godot_rect3 dest;
- const Rect3 *self = (const Rect3 *)p_self;
- const Rect3 *with = (const Rect3 *)p_with;
- *((Rect3 *)&dest) = self->intersection(*with);
- return dest;
-}
-
-godot_bool GDAPI godot_rect3_intersects_plane(const godot_rect3 *p_self, const godot_plane *p_plane) {
- const Rect3 *self = (const Rect3 *)p_self;
- const Plane *plane = (const Plane *)p_plane;
- return self->intersects_plane(*plane);
-}
-
-godot_bool GDAPI godot_rect3_intersects_segment(const godot_rect3 *p_self, const godot_vector3 *p_from, const godot_vector3 *p_to) {
- const Rect3 *self = (const Rect3 *)p_self;
- const Vector3 *from = (const Vector3 *)p_from;
- const Vector3 *to = (const Vector3 *)p_to;
- return self->intersects_segment(*from, *to);
-}
-
-godot_bool GDAPI godot_rect3_has_point(const godot_rect3 *p_self, const godot_vector3 *p_point) {
- const Rect3 *self = (const Rect3 *)p_self;
- const Vector3 *point = (const Vector3 *)p_point;
- return self->has_point(*point);
-}
-
-godot_vector3 GDAPI godot_rect3_get_support(const godot_rect3 *p_self, const godot_vector3 *p_dir) {
- godot_vector3 dest;
- const Rect3 *self = (const Rect3 *)p_self;
- const Vector3 *dir = (const Vector3 *)p_dir;
- *((Vector3 *)&dest) = self->get_support(*dir);
- return dest;
-}
-
-godot_vector3 GDAPI godot_rect3_get_longest_axis(const godot_rect3 *p_self) {
- godot_vector3 dest;
- const Rect3 *self = (const Rect3 *)p_self;
- *((Vector3 *)&dest) = self->get_longest_axis();
- return dest;
-}
-
-godot_int GDAPI godot_rect3_get_longest_axis_index(const godot_rect3 *p_self) {
- const Rect3 *self = (const Rect3 *)p_self;
- return self->get_longest_axis_index();
-}
-
-godot_real GDAPI godot_rect3_get_longest_axis_size(const godot_rect3 *p_self) {
- const Rect3 *self = (const Rect3 *)p_self;
- return self->get_longest_axis_size();
-}
-
-godot_vector3 GDAPI godot_rect3_get_shortest_axis(const godot_rect3 *p_self) {
- godot_vector3 dest;
- const Rect3 *self = (const Rect3 *)p_self;
- *((Vector3 *)&dest) = self->get_shortest_axis();
- return dest;
-}
-
-godot_int GDAPI godot_rect3_get_shortest_axis_index(const godot_rect3 *p_self) {
- const Rect3 *self = (const Rect3 *)p_self;
- return self->get_shortest_axis_index();
-}
-
-godot_real GDAPI godot_rect3_get_shortest_axis_size(const godot_rect3 *p_self) {
- const Rect3 *self = (const Rect3 *)p_self;
- return self->get_shortest_axis_size();
-}
-
-godot_rect3 GDAPI godot_rect3_expand(const godot_rect3 *p_self, const godot_vector3 *p_to_point) {
- godot_rect3 dest;
- const Rect3 *self = (const Rect3 *)p_self;
- const Vector3 *to_point = (const Vector3 *)p_to_point;
- *((Rect3 *)&dest) = self->expand(*to_point);
- return dest;
-}
-
-godot_rect3 GDAPI godot_rect3_grow(const godot_rect3 *p_self, const godot_real p_by) {
- godot_rect3 dest;
- const Rect3 *self = (const Rect3 *)p_self;
-
- *((Rect3 *)&dest) = self->grow(p_by);
- return dest;
-}
-
-godot_vector3 GDAPI godot_rect3_get_endpoint(const godot_rect3 *p_self, const godot_int p_idx) {
- godot_vector3 dest;
- const Rect3 *self = (const Rect3 *)p_self;
-
- *((Vector3 *)&dest) = self->get_endpoint(p_idx);
- return dest;
-}
-
-godot_bool GDAPI godot_rect3_operator_equal(const godot_rect3 *p_self, const godot_rect3 *p_b) {
- const Rect3 *self = (const Rect3 *)p_self;
- const Rect3 *b = (const Rect3 *)p_b;
- return *self == *b;
-}
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/modules/gdnative/gdnative/transform.cpp b/modules/gdnative/gdnative/transform.cpp
index 96b2ec8a7a..b07fcffcb6 100644
--- a/modules/gdnative/gdnative/transform.cpp
+++ b/modules/gdnative/gdnative/transform.cpp
@@ -198,20 +198,20 @@ godot_vector3 GDAPI godot_transform_xform_inv_vector3(const godot_transform *p_s
return raw_dest;
}
-godot_rect3 GDAPI godot_transform_xform_rect3(const godot_transform *p_self, const godot_rect3 *p_v) {
- godot_rect3 raw_dest;
- Rect3 *dest = (Rect3 *)&raw_dest;
+godot_aabb GDAPI godot_transform_xform_aabb(const godot_transform *p_self, const godot_aabb *p_v) {
+ godot_aabb raw_dest;
+ AABB *dest = (AABB *)&raw_dest;
const Transform *self = (const Transform *)p_self;
- const Rect3 *v = (const Rect3 *)p_v;
+ const AABB *v = (const AABB *)p_v;
*dest = self->xform(*v);
return raw_dest;
}
-godot_rect3 GDAPI godot_transform_xform_inv_rect3(const godot_transform *p_self, const godot_rect3 *p_v) {
- godot_rect3 raw_dest;
- Rect3 *dest = (Rect3 *)&raw_dest;
+godot_aabb GDAPI godot_transform_xform_inv_aabb(const godot_transform *p_self, const godot_aabb *p_v) {
+ godot_aabb raw_dest;
+ AABB *dest = (AABB *)&raw_dest;
const Transform *self = (const Transform *)p_self;
- const Rect3 *v = (const Rect3 *)p_v;
+ const AABB *v = (const AABB *)p_v;
*dest = self->xform_inv(*v);
return raw_dest;
}
diff --git a/modules/gdnative/gdnative/variant.cpp b/modules/gdnative/gdnative/variant.cpp
index 0c31bc643c..6483d19d74 100644
--- a/modules/gdnative/gdnative/variant.cpp
+++ b/modules/gdnative/gdnative/variant.cpp
@@ -118,10 +118,10 @@ void GDAPI godot_variant_new_quat(godot_variant *r_dest, const godot_quat *p_qua
memnew_placement_custom(dest, Variant, Variant(*quat));
}
-void GDAPI godot_variant_new_rect3(godot_variant *r_dest, const godot_rect3 *p_rect3) {
+void GDAPI godot_variant_new_aabb(godot_variant *r_dest, const godot_aabb *p_aabb) {
Variant *dest = (Variant *)r_dest;
- Rect3 *rect3 = (Rect3 *)p_rect3;
- memnew_placement_custom(dest, Variant, Variant(*rect3));
+ AABB *aabb = (AABB *)p_aabb;
+ memnew_placement_custom(dest, Variant, Variant(*aabb));
}
void GDAPI godot_variant_new_basis(godot_variant *r_dest, const godot_basis *p_basis) {
@@ -304,10 +304,10 @@ godot_quat GDAPI godot_variant_as_quat(const godot_variant *p_self) {
return raw_dest;
}
-godot_rect3 GDAPI godot_variant_as_rect3(const godot_variant *p_self) {
- godot_rect3 raw_dest;
+godot_aabb GDAPI godot_variant_as_aabb(const godot_variant *p_self) {
+ godot_aabb raw_dest;
const Variant *self = (const Variant *)p_self;
- Rect3 *dest = (Rect3 *)&raw_dest;
+ AABB *dest = (AABB *)&raw_dest;
*dest = *self;
return raw_dest;
}
diff --git a/modules/gdnative/gdnative_api.json b/modules/gdnative/gdnative_api.json
index 770fb429c7..877c65dfb9 100644
--- a/modules/gdnative/gdnative_api.json
+++ b/modules/gdnative/gdnative_api.json
@@ -3221,209 +3221,209 @@
]
},
{
- "name": "godot_rect3_new",
+ "name": "godot_aabb_new",
"return_type": "void",
"arguments": [
- ["godot_rect3 *", "r_dest"],
+ ["godot_aabb *", "r_dest"],
["const godot_vector3 *", "p_pos"],
["const godot_vector3 *", "p_size"]
]
},
{
- "name": "godot_rect3_get_position",
+ "name": "godot_aabb_get_position",
"return_type": "godot_vector3",
"arguments": [
- ["const godot_rect3 *", "p_self"]
+ ["const godot_aabb *", "p_self"]
]
},
{
- "name": "godot_rect3_set_position",
+ "name": "godot_aabb_set_position",
"return_type": "void",
"arguments": [
- ["const godot_rect3 *", "p_self"],
+ ["const godot_aabb *", "p_self"],
["const godot_vector3 *", "p_v"]
]
},
{
- "name": "godot_rect3_get_size",
+ "name": "godot_aabb_get_size",
"return_type": "godot_vector3",
"arguments": [
- ["const godot_rect3 *", "p_self"]
+ ["const godot_aabb *", "p_self"]
]
},
{
- "name": "godot_rect3_set_size",
+ "name": "godot_aabb_set_size",
"return_type": "void",
"arguments": [
- ["const godot_rect3 *", "p_self"],
+ ["const godot_aabb *", "p_self"],
["const godot_vector3 *", "p_v"]
]
},
{
- "name": "godot_rect3_as_string",
+ "name": "godot_aabb_as_string",
"return_type": "godot_string",
"arguments": [
- ["const godot_rect3 *", "p_self"]
+ ["const godot_aabb *", "p_self"]
]
},
{
- "name": "godot_rect3_get_area",
+ "name": "godot_aabb_get_area",
"return_type": "godot_real",
"arguments": [
- ["const godot_rect3 *", "p_self"]
+ ["const godot_aabb *", "p_self"]
]
},
{
- "name": "godot_rect3_has_no_area",
+ "name": "godot_aabb_has_no_area",
"return_type": "godot_bool",
"arguments": [
- ["const godot_rect3 *", "p_self"]
+ ["const godot_aabb *", "p_self"]
]
},
{
- "name": "godot_rect3_has_no_surface",
+ "name": "godot_aabb_has_no_surface",
"return_type": "godot_bool",
"arguments": [
- ["const godot_rect3 *", "p_self"]
+ ["const godot_aabb *", "p_self"]
]
},
{
- "name": "godot_rect3_intersects",
+ "name": "godot_aabb_intersects",
"return_type": "godot_bool",
"arguments": [
- ["const godot_rect3 *", "p_self"],
- ["const godot_rect3 *", "p_with"]
+ ["const godot_aabb *", "p_self"],
+ ["const godot_aabb *", "p_with"]
]
},
{
- "name": "godot_rect3_encloses",
+ "name": "godot_aabb_encloses",
"return_type": "godot_bool",
"arguments": [
- ["const godot_rect3 *", "p_self"],
- ["const godot_rect3 *", "p_with"]
+ ["const godot_aabb *", "p_self"],
+ ["const godot_aabb *", "p_with"]
]
},
{
- "name": "godot_rect3_merge",
- "return_type": "godot_rect3",
+ "name": "godot_aabb_merge",
+ "return_type": "godot_aabb",
"arguments": [
- ["const godot_rect3 *", "p_self"],
- ["const godot_rect3 *", "p_with"]
+ ["const godot_aabb *", "p_self"],
+ ["const godot_aabb *", "p_with"]
]
},
{
- "name": "godot_rect3_intersection",
- "return_type": "godot_rect3",
+ "name": "godot_aabb_intersection",
+ "return_type": "godot_aabb",
"arguments": [
- ["const godot_rect3 *", "p_self"],
- ["const godot_rect3 *", "p_with"]
+ ["const godot_aabb *", "p_self"],
+ ["const godot_aabb *", "p_with"]
]
},
{
- "name": "godot_rect3_intersects_plane",
+ "name": "godot_aabb_intersects_plane",
"return_type": "godot_bool",
"arguments": [
- ["const godot_rect3 *", "p_self"],
+ ["const godot_aabb *", "p_self"],
["const godot_plane *", "p_plane"]
]
},
{
- "name": "godot_rect3_intersects_segment",
+ "name": "godot_aabb_intersects_segment",
"return_type": "godot_bool",
"arguments": [
- ["const godot_rect3 *", "p_self"],
+ ["const godot_aabb *", "p_self"],
["const godot_vector3 *", "p_from"],
["const godot_vector3 *", "p_to"]
]
},
{
- "name": "godot_rect3_has_point",
+ "name": "godot_aabb_has_point",
"return_type": "godot_bool",
"arguments": [
- ["const godot_rect3 *", "p_self"],
+ ["const godot_aabb *", "p_self"],
["const godot_vector3 *", "p_point"]
]
},
{
- "name": "godot_rect3_get_support",
+ "name": "godot_aabb_get_support",
"return_type": "godot_vector3",
"arguments": [
- ["const godot_rect3 *", "p_self"],
+ ["const godot_aabb *", "p_self"],
["const godot_vector3 *", "p_dir"]
]
},
{
- "name": "godot_rect3_get_longest_axis",
+ "name": "godot_aabb_get_longest_axis",
"return_type": "godot_vector3",
"arguments": [
- ["const godot_rect3 *", "p_self"]
+ ["const godot_aabb *", "p_self"]
]
},
{
- "name": "godot_rect3_get_longest_axis_index",
+ "name": "godot_aabb_get_longest_axis_index",
"return_type": "godot_int",
"arguments": [
- ["const godot_rect3 *", "p_self"]
+ ["const godot_aabb *", "p_self"]
]
},
{
- "name": "godot_rect3_get_longest_axis_size",
+ "name": "godot_aabb_get_longest_axis_size",
"return_type": "godot_real",
"arguments": [
- ["const godot_rect3 *", "p_self"]
+ ["const godot_aabb *", "p_self"]
]
},
{
- "name": "godot_rect3_get_shortest_axis",
+ "name": "godot_aabb_get_shortest_axis",
"return_type": "godot_vector3",
"arguments": [
- ["const godot_rect3 *", "p_self"]
+ ["const godot_aabb *", "p_self"]
]
},
{
- "name": "godot_rect3_get_shortest_axis_index",
+ "name": "godot_aabb_get_shortest_axis_index",
"return_type": "godot_int",
"arguments": [
- ["const godot_rect3 *", "p_self"]
+ ["const godot_aabb *", "p_self"]
]
},
{
- "name": "godot_rect3_get_shortest_axis_size",
+ "name": "godot_aabb_get_shortest_axis_size",
"return_type": "godot_real",
"arguments": [
- ["const godot_rect3 *", "p_self"]
+ ["const godot_aabb *", "p_self"]
]
},
{
- "name": "godot_rect3_expand",
- "return_type": "godot_rect3",
+ "name": "godot_aabb_expand",
+ "return_type": "godot_aabb",
"arguments": [
- ["const godot_rect3 *", "p_self"],
+ ["const godot_aabb *", "p_self"],
["const godot_vector3 *", "p_to_point"]
]
},
{
- "name": "godot_rect3_grow",
- "return_type": "godot_rect3",
+ "name": "godot_aabb_grow",
+ "return_type": "godot_aabb",
"arguments": [
- ["const godot_rect3 *", "p_self"],
+ ["const godot_aabb *", "p_self"],
["const godot_real", "p_by"]
]
},
{
- "name": "godot_rect3_get_endpoint",
+ "name": "godot_aabb_get_endpoint",
"return_type": "godot_vector3",
"arguments": [
- ["const godot_rect3 *", "p_self"],
+ ["const godot_aabb *", "p_self"],
["const godot_int", "p_idx"]
]
},
{
- "name": "godot_rect3_operator_equal",
+ "name": "godot_aabb_operator_equal",
"return_type": "godot_bool",
"arguments": [
- ["const godot_rect3 *", "p_self"],
- ["const godot_rect3 *", "p_b"]
+ ["const godot_aabb *", "p_self"],
+ ["const godot_aabb *", "p_b"]
]
},
{
@@ -3632,19 +3632,19 @@
]
},
{
- "name": "godot_transform_xform_rect3",
- "return_type": "godot_rect3",
+ "name": "godot_transform_xform_aabb",
+ "return_type": "godot_aabb",
"arguments": [
["const godot_transform *", "p_self"],
- ["const godot_rect3 *", "p_v"]
+ ["const godot_aabb *", "p_v"]
]
},
{
- "name": "godot_transform_xform_inv_rect3",
- "return_type": "godot_rect3",
+ "name": "godot_transform_xform_inv_aabb",
+ "return_type": "godot_aabb",
"arguments": [
["const godot_transform *", "p_self"],
- ["const godot_rect3 *", "p_v"]
+ ["const godot_aabb *", "p_v"]
]
},
{
@@ -3930,11 +3930,11 @@
]
},
{
- "name": "godot_variant_new_rect3",
+ "name": "godot_variant_new_aabb",
"return_type": "void",
"arguments": [
["godot_variant *", "r_dest"],
- ["const godot_rect3 *", "p_rect3"]
+ ["const godot_aabb *", "p_aabb"]
]
},
{
@@ -4135,8 +4135,8 @@
]
},
{
- "name": "godot_variant_as_rect3",
- "return_type": "godot_rect3",
+ "name": "godot_variant_as_aabb",
+ "return_type": "godot_aabb",
"arguments": [
["const godot_variant *", "p_self"]
]
diff --git a/modules/gdnative/include/gdnative/aabb.h b/modules/gdnative/include/gdnative/aabb.h
new file mode 100644
index 0000000000..34339fa242
--- /dev/null
+++ b/modules/gdnative/include/gdnative/aabb.h
@@ -0,0 +1,117 @@
+/*************************************************************************/
+/* aabb.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 GODOT_AABB_H
+#define GODOT_AABB_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stdint.h>
+
+#define GODOT_AABB_SIZE 24
+
+#ifndef GODOT_CORE_API_GODOT_AABB_TYPE_DEFINED
+#define GODOT_CORE_API_GODOT_AABB_TYPE_DEFINED
+typedef struct {
+ uint8_t _dont_touch_that[GODOT_AABB_SIZE];
+} godot_aabb;
+#endif
+
+// reduce extern "C" nesting for VS2013
+#ifdef __cplusplus
+}
+#endif
+
+#include <gdnative/gdnative.h>
+#include <gdnative/plane.h>
+#include <gdnative/vector3.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void GDAPI godot_aabb_new(godot_aabb *r_dest, const godot_vector3 *p_pos, const godot_vector3 *p_size);
+
+godot_vector3 GDAPI godot_aabb_get_position(const godot_aabb *p_self);
+void GDAPI godot_aabb_set_position(const godot_aabb *p_self, const godot_vector3 *p_v);
+
+godot_vector3 GDAPI godot_aabb_get_size(const godot_aabb *p_self);
+void GDAPI godot_aabb_set_size(const godot_aabb *p_self, const godot_vector3 *p_v);
+
+godot_string GDAPI godot_aabb_as_string(const godot_aabb *p_self);
+
+godot_real GDAPI godot_aabb_get_area(const godot_aabb *p_self);
+
+godot_bool GDAPI godot_aabb_has_no_area(const godot_aabb *p_self);
+
+godot_bool GDAPI godot_aabb_has_no_surface(const godot_aabb *p_self);
+
+godot_bool GDAPI godot_aabb_intersects(const godot_aabb *p_self, const godot_aabb *p_with);
+
+godot_bool GDAPI godot_aabb_encloses(const godot_aabb *p_self, const godot_aabb *p_with);
+
+godot_aabb GDAPI godot_aabb_merge(const godot_aabb *p_self, const godot_aabb *p_with);
+
+godot_aabb GDAPI godot_aabb_intersection(const godot_aabb *p_self, const godot_aabb *p_with);
+
+godot_bool GDAPI godot_aabb_intersects_plane(const godot_aabb *p_self, const godot_plane *p_plane);
+
+godot_bool GDAPI godot_aabb_intersects_segment(const godot_aabb *p_self, const godot_vector3 *p_from, const godot_vector3 *p_to);
+
+godot_bool GDAPI godot_aabb_has_point(const godot_aabb *p_self, const godot_vector3 *p_point);
+
+godot_vector3 GDAPI godot_aabb_get_support(const godot_aabb *p_self, const godot_vector3 *p_dir);
+
+godot_vector3 GDAPI godot_aabb_get_longest_axis(const godot_aabb *p_self);
+
+godot_int GDAPI godot_aabb_get_longest_axis_index(const godot_aabb *p_self);
+
+godot_real GDAPI godot_aabb_get_longest_axis_size(const godot_aabb *p_self);
+
+godot_vector3 GDAPI godot_aabb_get_shortest_axis(const godot_aabb *p_self);
+
+godot_int GDAPI godot_aabb_get_shortest_axis_index(const godot_aabb *p_self);
+
+godot_real GDAPI godot_aabb_get_shortest_axis_size(const godot_aabb *p_self);
+
+godot_aabb GDAPI godot_aabb_expand(const godot_aabb *p_self, const godot_vector3 *p_to_point);
+
+godot_aabb GDAPI godot_aabb_grow(const godot_aabb *p_self, const godot_real p_by);
+
+godot_vector3 GDAPI godot_aabb_get_endpoint(const godot_aabb *p_self, const godot_int p_idx);
+
+godot_bool GDAPI godot_aabb_operator_equal(const godot_aabb *p_self, const godot_aabb *p_b);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // GODOT_AABB_H
diff --git a/modules/gdnative/include/gdnative/gdnative.h b/modules/gdnative/include/gdnative/gdnative.h
index a479eced16..38a42ab658 100644
--- a/modules/gdnative/include/gdnative/gdnative.h
+++ b/modules/gdnative/include/gdnative/gdnative.h
@@ -169,9 +169,9 @@ typedef void godot_object;
#include <gdnative/quat.h>
-/////// Rect3
+/////// AABB
-#include <gdnative/rect3.h>
+#include <gdnative/aabb.h>
/////// Basis
diff --git a/modules/gdnative/include/gdnative/rect3.h b/modules/gdnative/include/gdnative/rect3.h
deleted file mode 100644
index f603a9268a..0000000000
--- a/modules/gdnative/include/gdnative/rect3.h
+++ /dev/null
@@ -1,117 +0,0 @@
-/*************************************************************************/
-/* rect3.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 GODOT_RECT3_H
-#define GODOT_RECT3_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <stdint.h>
-
-#define GODOT_RECT3_SIZE 24
-
-#ifndef GODOT_CORE_API_GODOT_RECT3_TYPE_DEFINED
-#define GODOT_CORE_API_GODOT_RECT3_TYPE_DEFINED
-typedef struct {
- uint8_t _dont_touch_that[GODOT_RECT3_SIZE];
-} godot_rect3;
-#endif
-
-// reduce extern "C" nesting for VS2013
-#ifdef __cplusplus
-}
-#endif
-
-#include <gdnative/gdnative.h>
-#include <gdnative/plane.h>
-#include <gdnative/vector3.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-void GDAPI godot_rect3_new(godot_rect3 *r_dest, const godot_vector3 *p_pos, const godot_vector3 *p_size);
-
-godot_vector3 GDAPI godot_rect3_get_position(const godot_rect3 *p_self);
-void GDAPI godot_rect3_set_position(const godot_rect3 *p_self, const godot_vector3 *p_v);
-
-godot_vector3 GDAPI godot_rect3_get_size(const godot_rect3 *p_self);
-void GDAPI godot_rect3_set_size(const godot_rect3 *p_self, const godot_vector3 *p_v);
-
-godot_string GDAPI godot_rect3_as_string(const godot_rect3 *p_self);
-
-godot_real GDAPI godot_rect3_get_area(const godot_rect3 *p_self);
-
-godot_bool GDAPI godot_rect3_has_no_area(const godot_rect3 *p_self);
-
-godot_bool GDAPI godot_rect3_has_no_surface(const godot_rect3 *p_self);
-
-godot_bool GDAPI godot_rect3_intersects(const godot_rect3 *p_self, const godot_rect3 *p_with);
-
-godot_bool GDAPI godot_rect3_encloses(const godot_rect3 *p_self, const godot_rect3 *p_with);
-
-godot_rect3 GDAPI godot_rect3_merge(const godot_rect3 *p_self, const godot_rect3 *p_with);
-
-godot_rect3 GDAPI godot_rect3_intersection(const godot_rect3 *p_self, const godot_rect3 *p_with);
-
-godot_bool GDAPI godot_rect3_intersects_plane(const godot_rect3 *p_self, const godot_plane *p_plane);
-
-godot_bool GDAPI godot_rect3_intersects_segment(const godot_rect3 *p_self, const godot_vector3 *p_from, const godot_vector3 *p_to);
-
-godot_bool GDAPI godot_rect3_has_point(const godot_rect3 *p_self, const godot_vector3 *p_point);
-
-godot_vector3 GDAPI godot_rect3_get_support(const godot_rect3 *p_self, const godot_vector3 *p_dir);
-
-godot_vector3 GDAPI godot_rect3_get_longest_axis(const godot_rect3 *p_self);
-
-godot_int GDAPI godot_rect3_get_longest_axis_index(const godot_rect3 *p_self);
-
-godot_real GDAPI godot_rect3_get_longest_axis_size(const godot_rect3 *p_self);
-
-godot_vector3 GDAPI godot_rect3_get_shortest_axis(const godot_rect3 *p_self);
-
-godot_int GDAPI godot_rect3_get_shortest_axis_index(const godot_rect3 *p_self);
-
-godot_real GDAPI godot_rect3_get_shortest_axis_size(const godot_rect3 *p_self);
-
-godot_rect3 GDAPI godot_rect3_expand(const godot_rect3 *p_self, const godot_vector3 *p_to_point);
-
-godot_rect3 GDAPI godot_rect3_grow(const godot_rect3 *p_self, const godot_real p_by);
-
-godot_vector3 GDAPI godot_rect3_get_endpoint(const godot_rect3 *p_self, const godot_int p_idx);
-
-godot_bool GDAPI godot_rect3_operator_equal(const godot_rect3 *p_self, const godot_rect3 *p_b);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // GODOT_RECT3_H
diff --git a/modules/gdnative/include/gdnative/string.h b/modules/gdnative/include/gdnative/string.h
index 29510313c9..cca3eb2672 100644
--- a/modules/gdnative/include/gdnative/string.h
+++ b/modules/gdnative/include/gdnative/string.h
@@ -51,6 +51,7 @@ typedef struct {
}
#endif
+#include <gdnative/array.h>
#include <gdnative/gdnative.h>
#include <gdnative/variant.h>
diff --git a/modules/gdnative/include/gdnative/transform.h b/modules/gdnative/include/gdnative/transform.h
index 8f50b01fb5..3b5c189bdf 100644
--- a/modules/gdnative/include/gdnative/transform.h
+++ b/modules/gdnative/include/gdnative/transform.h
@@ -98,9 +98,9 @@ godot_vector3 GDAPI godot_transform_xform_vector3(const godot_transform *p_self,
godot_vector3 GDAPI godot_transform_xform_inv_vector3(const godot_transform *p_self, const godot_vector3 *p_v);
-godot_rect3 GDAPI godot_transform_xform_rect3(const godot_transform *p_self, const godot_rect3 *p_v);
+godot_aabb GDAPI godot_transform_xform_aabb(const godot_transform *p_self, const godot_aabb *p_v);
-godot_rect3 GDAPI godot_transform_xform_inv_rect3(const godot_transform *p_self, const godot_rect3 *p_v);
+godot_aabb GDAPI godot_transform_xform_inv_aabb(const godot_transform *p_self, const godot_aabb *p_v);
#ifdef __cplusplus
}
diff --git a/modules/gdnative/include/gdnative/variant.h b/modules/gdnative/include/gdnative/variant.h
index 3d744ef1f2..06cafcfa63 100644
--- a/modules/gdnative/include/gdnative/variant.h
+++ b/modules/gdnative/include/gdnative/variant.h
@@ -62,7 +62,7 @@ typedef enum godot_variant_type {
GODOT_VARIANT_TYPE_TRANSFORM2D,
GODOT_VARIANT_TYPE_PLANE,
GODOT_VARIANT_TYPE_QUAT, // 10
- GODOT_VARIANT_TYPE_RECT3,
+ GODOT_VARIANT_TYPE_AABB,
GODOT_VARIANT_TYPE_BASIS,
GODOT_VARIANT_TYPE_TRANSFORM,
@@ -104,6 +104,7 @@ typedef struct godot_variant_call_error {
}
#endif
+#include <gdnative/aabb.h>
#include <gdnative/array.h>
#include <gdnative/basis.h>
#include <gdnative/color.h>
@@ -113,7 +114,6 @@ typedef struct godot_variant_call_error {
#include <gdnative/pool_arrays.h>
#include <gdnative/quat.h>
#include <gdnative/rect2.h>
-#include <gdnative/rect3.h>
#include <gdnative/rid.h>
#include <gdnative/string.h>
#include <gdnative/transform.h>
@@ -145,7 +145,7 @@ void GDAPI godot_variant_new_vector3(godot_variant *r_dest, const godot_vector3
void GDAPI godot_variant_new_transform2d(godot_variant *r_dest, const godot_transform2d *p_t2d);
void GDAPI godot_variant_new_plane(godot_variant *r_dest, const godot_plane *p_plane);
void GDAPI godot_variant_new_quat(godot_variant *r_dest, const godot_quat *p_quat);
-void GDAPI godot_variant_new_rect3(godot_variant *r_dest, const godot_rect3 *p_rect3);
+void GDAPI godot_variant_new_aabb(godot_variant *r_dest, const godot_aabb *p_aabb);
void GDAPI godot_variant_new_basis(godot_variant *r_dest, const godot_basis *p_basis);
void GDAPI godot_variant_new_transform(godot_variant *r_dest, const godot_transform *p_trans);
void GDAPI godot_variant_new_color(godot_variant *r_dest, const godot_color *p_color);
@@ -173,7 +173,7 @@ godot_vector3 GDAPI godot_variant_as_vector3(const godot_variant *p_self);
godot_transform2d GDAPI godot_variant_as_transform2d(const godot_variant *p_self);
godot_plane GDAPI godot_variant_as_plane(const godot_variant *p_self);
godot_quat GDAPI godot_variant_as_quat(const godot_variant *p_self);
-godot_rect3 GDAPI godot_variant_as_rect3(const godot_variant *p_self);
+godot_aabb GDAPI godot_variant_as_aabb(const godot_variant *p_self);
godot_basis GDAPI godot_variant_as_basis(const godot_variant *p_self);
godot_transform GDAPI godot_variant_as_transform(const godot_variant *p_self);
godot_color GDAPI godot_variant_as_color(const godot_variant *p_self);
diff --git a/modules/gdnative/register_types.cpp b/modules/gdnative/register_types.cpp
index 29b0a6719c..8af643df50 100644
--- a/modules/gdnative/register_types.cpp
+++ b/modules/gdnative/register_types.cpp
@@ -371,7 +371,7 @@ void unregister_gdnative_types() {
print_line(String("poolarray:\t") + itos(sizeof(PoolByteArray)));
print_line(String("quat:\t") + itos(sizeof(Quat)));
print_line(String("rect2:\t") + itos(sizeof(Rect2)));
- print_line(String("rect3:\t") + itos(sizeof(Rect3)));
+ print_line(String("aabb:\t") + itos(sizeof(AABB)));
print_line(String("rid:\t") + itos(sizeof(RID)));
print_line(String("string:\t") + itos(sizeof(String)));
print_line(String("transform:\t") + itos(sizeof(Transform)));
diff --git a/modules/gdscript/config.py b/modules/gdscript/config.py
index 6e8994d643..6496b59d75 100644
--- a/modules/gdscript/config.py
+++ b/modules/gdscript/config.py
@@ -6,9 +6,9 @@ def configure(env):
def get_doc_classes():
return [
- "GDFunctionState",
- "GDNativeClass",
"GDScript",
+ "GDScriptFunctionState",
+ "GDScriptNativeClass",
]
def get_doc_path():
diff --git a/modules/gdscript/doc_classes/GDFunctionState.xml b/modules/gdscript/doc_classes/GDScriptFunctionState.xml
index e1aafa8a5b..2df4e7c217 100644
--- a/modules/gdscript/doc_classes/GDFunctionState.xml
+++ b/modules/gdscript/doc_classes/GDScriptFunctionState.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="GDFunctionState" inherits="Reference" category="Core" version="3.0-alpha">
+<class name="GDScriptFunctionState" inherits="Reference" category="Core" version="3.0-alpha">
<brief_description>
State of a function call after yielding.
</brief_description>
@@ -18,7 +18,7 @@
</argument>
<description>
Check whether the function call may be resumed. This is not the case if the function state was already resumed.
- If [code]extended_check[/code] is enabled, it also checks if the associated script and object still exist. The extended check is done in debug mode as part of [method GDFunctionState.resume], but you can use this if you know you may be trying to resume without knowing for sure the object and/or script have survived up to that point.
+ If [code]extended_check[/code] is enabled, it also checks if the associated script and object still exist. The extended check is done in debug mode as part of [method GDScriptFunctionState.resume], but you can use this if you know you may be trying to resume without knowing for sure the object and/or script have survived up to that point.
</description>
</method>
<method name="resume">
diff --git a/modules/gdscript/doc_classes/GDNativeClass.xml b/modules/gdscript/doc_classes/GDScriptNativeClass.xml
index 95789e1b63..4514a78469 100644
--- a/modules/gdscript/doc_classes/GDNativeClass.xml
+++ b/modules/gdscript/doc_classes/GDScriptNativeClass.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<class name="GDNativeClass" inherits="Reference" category="Core" version="3.0-alpha">
+<class name="GDScriptNativeClass" inherits="Reference" category="Core" version="3.0-alpha">
<brief_description>
</brief_description>
<description>
diff --git a/modules/gdscript/gd_script.cpp b/modules/gdscript/gdscript.cpp
index e5d834c9e7..55ea8a5f24 100644
--- a/modules/gdscript/gd_script.cpp
+++ b/modules/gdscript/gdscript.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* gd_script.cpp */
+/* gdscript.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -27,10 +27,10 @@
/* 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 "gdscript.h"
#include "engine.h"
-#include "gd_compiler.h"
+#include "gdscript_compiler.h"
#include "global_constants.h"
#include "io/file_access_encrypted.h"
#include "os/file_access.h"
@@ -39,12 +39,12 @@
///////////////////////////
-GDNativeClass::GDNativeClass(const StringName &p_name) {
+GDScriptNativeClass::GDScriptNativeClass(const StringName &p_name) {
name = p_name;
}
-bool GDNativeClass::_get(const StringName &p_name, Variant &r_ret) const {
+bool GDScriptNativeClass::_get(const StringName &p_name, Variant &r_ret) const {
bool ok;
int v = ClassDB::get_integer_constant(name, p_name, &ok);
@@ -57,12 +57,12 @@ bool GDNativeClass::_get(const StringName &p_name, Variant &r_ret) const {
}
}
-void GDNativeClass::_bind_methods() {
+void GDScriptNativeClass::_bind_methods() {
- ClassDB::bind_method(D_METHOD("new"), &GDNativeClass::_new);
+ ClassDB::bind_method(D_METHOD("new"), &GDScriptNativeClass::_new);
}
-Variant GDNativeClass::_new() {
+Variant GDScriptNativeClass::_new() {
Object *o = instance();
if (!o) {
@@ -78,16 +78,16 @@ Variant GDNativeClass::_new() {
}
}
-Object *GDNativeClass::instance() {
+Object *GDScriptNativeClass::instance() {
return ClassDB::instance(name);
}
-GDInstance *GDScript::_create_instance(const Variant **p_args, int p_argcount, Object *p_owner, bool p_isref, Variant::CallError &r_error) {
+GDScriptInstance *GDScript::_create_instance(const Variant **p_args, int p_argcount, Object *p_owner, bool p_isref, Variant::CallError &r_error) {
/* STEP 1, CREATE */
- GDInstance *instance = memnew(GDInstance);
+ GDScriptInstance *instance = memnew(GDScriptInstance);
instance->base_ref = p_isref;
instance->members.resize(member_indices.size());
instance->script = Ref<GDScript>(this);
@@ -163,7 +163,7 @@ Variant GDScript::_new(const Variant **p_args, int p_argcount, Variant::CallErro
ref = REF(r);
}
- GDInstance *instance = _create_instance(p_args, p_argcount, owner, r != NULL, r_error);
+ GDScriptInstance *instance = _create_instance(p_args, p_argcount, owner, r != NULL, r_error);
if (!instance) {
if (ref.is_null()) {
memdelete(owner); //no owner, sorry
@@ -218,7 +218,7 @@ void GDScript::_placeholder_erased(PlaceHolderScriptInstance *p_placeholder) {
void GDScript::get_script_method_list(List<MethodInfo> *p_list) const {
- for (const Map<StringName, GDFunction *>::Element *E = member_functions.front(); E; E = E->next()) {
+ for (const Map<StringName, GDScriptFunction *>::Element *E = member_functions.front(); E; E = E->next()) {
MethodInfo mi;
mi.name = E->key();
for (int i = 0; i < E->get()->get_argument_count(); i++) {
@@ -272,7 +272,7 @@ bool GDScript::has_method(const StringName &p_method) const {
MethodInfo GDScript::get_method_info(const StringName &p_method) const {
- const Map<StringName, GDFunction *>::Element *E = member_functions.find(p_method);
+ const Map<StringName, GDScriptFunction *>::Element *E = member_functions.find(p_method);
if (!E)
return MethodInfo();
@@ -420,15 +420,15 @@ bool GDScript::_update_exports() {
if (basedir != "")
basedir = basedir.get_base_dir();
- GDParser parser;
+ GDScriptParser parser;
Error err = parser.parse(source, basedir, true, path);
if (err == OK) {
- const GDParser::Node *root = parser.get_parse_tree();
- ERR_FAIL_COND_V(root->type != GDParser::Node::TYPE_CLASS, false);
+ const GDScriptParser::Node *root = parser.get_parse_tree();
+ ERR_FAIL_COND_V(root->type != GDScriptParser::Node::TYPE_CLASS, false);
- const GDParser::ClassNode *c = static_cast<const GDParser::ClassNode *>(root);
+ const GDScriptParser::ClassNode *c = static_cast<const GDScriptParser::ClassNode *>(root);
if (base_cache.is_valid()) {
base_cache->inheriters_cache.erase(get_instance_id());
@@ -572,7 +572,7 @@ Error GDScript::reload(bool p_keep_state) {
}
valid = false;
- GDParser parser;
+ GDScriptParser parser;
Error err = parser.parse(source, basedir, false, path);
if (err) {
if (ScriptDebugger::get_singleton()) {
@@ -584,7 +584,7 @@ Error GDScript::reload(bool p_keep_state) {
bool can_run = ScriptServer::is_scripting_enabled() || parser.is_tool_script();
- GDCompiler compiler;
+ GDScriptCompiler compiler;
err = compiler.compile(&parser, this, p_keep_state);
if (err) {
@@ -620,7 +620,7 @@ Variant GDScript::call(const StringName &p_method, const Variant **p_args, int p
GDScript *top = this;
while (top) {
- Map<StringName, GDFunction *>::Element *E = top->member_functions.find(p_method);
+ Map<StringName, GDScriptFunction *>::Element *E = top->member_functions.find(p_method);
if (E) {
if (!E->get()->is_static()) {
@@ -699,7 +699,7 @@ void GDScript::_bind_methods() {
Vector<uint8_t> GDScript::get_as_byte_code() const {
- GDTokenizerBuffer tokenizer;
+ GDScriptTokenizerBuffer tokenizer;
return tokenizer.parse_code_string(source);
};
@@ -739,14 +739,14 @@ Error GDScript::load_byte_code(const String &p_path) {
basedir = basedir.get_base_dir();
valid = false;
- GDParser parser;
+ GDScriptParser parser;
Error err = parser.parse_bytecode(bytecode, basedir, get_path());
if (err) {
_err_print_error("GDScript::load_byte_code", path.empty() ? "built-in" : (const char *)path.utf8().get_data(), parser.get_error_line(), ("Parse Error: " + parser.get_error()).utf8().get_data(), ERR_HANDLER_SCRIPT);
ERR_FAIL_V(ERR_PARSE_ERROR);
}
- GDCompiler compiler;
+ GDScriptCompiler compiler;
err = compiler.compile(&parser, this);
if (err) {
@@ -799,7 +799,7 @@ Error GDScript::load_source_code(const String &p_path) {
return OK;
}
-const Map<StringName, GDFunction *> &GDScript::debug_get_member_functions() const {
+const Map<StringName, GDScriptFunction *> &GDScript::debug_get_member_functions() const {
return member_functions;
}
@@ -886,7 +886,7 @@ GDScript::GDScript()
}
GDScript::~GDScript() {
- for (Map<StringName, GDFunction *>::Element *E = member_functions.front(); E; E = E->next()) {
+ for (Map<StringName, GDScriptFunction *>::Element *E = member_functions.front(); E; E = E->next()) {
memdelete(E->get());
}
@@ -910,7 +910,7 @@ GDScript::~GDScript() {
// INSTANCE //
//////////////////////////////
-bool GDInstance::set(const StringName &p_name, const Variant &p_value) {
+bool GDScriptInstance::set(const StringName &p_name, const Variant &p_value) {
//member
{
@@ -932,7 +932,7 @@ bool GDInstance::set(const StringName &p_name, const Variant &p_value) {
GDScript *sptr = script.ptr();
while (sptr) {
- Map<StringName, GDFunction *>::Element *E = sptr->member_functions.find(GDScriptLanguage::get_singleton()->strings._set);
+ Map<StringName, GDScriptFunction *>::Element *E = sptr->member_functions.find(GDScriptLanguage::get_singleton()->strings._set);
if (E) {
Variant name = p_name;
@@ -949,7 +949,7 @@ bool GDInstance::set(const StringName &p_name, const Variant &p_value) {
return false;
}
-bool GDInstance::get(const StringName &p_name, Variant &r_ret) const {
+bool GDScriptInstance::get(const StringName &p_name, Variant &r_ret) const {
const GDScript *sptr = script.ptr();
while (sptr) {
@@ -959,7 +959,7 @@ bool GDInstance::get(const StringName &p_name, Variant &r_ret) const {
if (E) {
if (E->get().getter) {
Variant::CallError err;
- r_ret = const_cast<GDInstance *>(this)->call(E->get().getter, NULL, 0, err);
+ r_ret = const_cast<GDScriptInstance *>(this)->call(E->get().getter, NULL, 0, err);
if (err.error == Variant::CallError::CALL_OK) {
return true;
}
@@ -983,14 +983,14 @@ bool GDInstance::get(const StringName &p_name, Variant &r_ret) const {
}
{
- const Map<StringName, GDFunction *>::Element *E = sptr->member_functions.find(GDScriptLanguage::get_singleton()->strings._get);
+ const Map<StringName, GDScriptFunction *>::Element *E = sptr->member_functions.find(GDScriptLanguage::get_singleton()->strings._get);
if (E) {
Variant name = p_name;
const Variant *args[1] = { &name };
Variant::CallError err;
- Variant ret = const_cast<GDFunction *>(E->get())->call(const_cast<GDInstance *>(this), (const Variant **)args, 1, err);
+ Variant ret = const_cast<GDScriptFunction *>(E->get())->call(const_cast<GDScriptInstance *>(this), (const Variant **)args, 1, err);
if (err.error == Variant::CallError::CALL_OK && ret.get_type() != Variant::NIL) {
r_ret = ret;
return true;
@@ -1003,7 +1003,7 @@ bool GDInstance::get(const StringName &p_name, Variant &r_ret) const {
return false;
}
-Variant::Type GDInstance::get_property_type(const StringName &p_name, bool *r_is_valid) const {
+Variant::Type GDScriptInstance::get_property_type(const StringName &p_name, bool *r_is_valid) const {
const GDScript *sptr = script.ptr();
while (sptr) {
@@ -1021,7 +1021,7 @@ Variant::Type GDInstance::get_property_type(const StringName &p_name, bool *r_is
return Variant::NIL;
}
-void GDInstance::get_property_list(List<PropertyInfo> *p_properties) const {
+void GDScriptInstance::get_property_list(List<PropertyInfo> *p_properties) const {
// exported members, not doen yet!
const GDScript *sptr = script.ptr();
@@ -1029,11 +1029,11 @@ void GDInstance::get_property_list(List<PropertyInfo> *p_properties) const {
while (sptr) {
- const Map<StringName, GDFunction *>::Element *E = sptr->member_functions.find(GDScriptLanguage::get_singleton()->strings._get_property_list);
+ const Map<StringName, GDScriptFunction *>::Element *E = sptr->member_functions.find(GDScriptLanguage::get_singleton()->strings._get_property_list);
if (E) {
Variant::CallError err;
- Variant ret = const_cast<GDFunction *>(E->get())->call(const_cast<GDInstance *>(this), NULL, 0, err);
+ Variant ret = const_cast<GDScriptFunction *>(E->get())->call(const_cast<GDScriptInstance *>(this), NULL, 0, err);
if (err.error == Variant::CallError::CALL_OK) {
if (ret.get_type() != Variant::ARRAY) {
@@ -1092,12 +1092,12 @@ void GDInstance::get_property_list(List<PropertyInfo> *p_properties) const {
}
}
-void GDInstance::get_method_list(List<MethodInfo> *p_list) const {
+void GDScriptInstance::get_method_list(List<MethodInfo> *p_list) const {
const GDScript *sptr = script.ptr();
while (sptr) {
- for (Map<StringName, GDFunction *>::Element *E = sptr->member_functions.front(); E; E = E->next()) {
+ for (Map<StringName, GDScriptFunction *>::Element *E = sptr->member_functions.front(); E; E = E->next()) {
MethodInfo mi;
mi.name = E->key();
@@ -1110,11 +1110,11 @@ void GDInstance::get_method_list(List<MethodInfo> *p_list) const {
}
}
-bool GDInstance::has_method(const StringName &p_method) const {
+bool GDScriptInstance::has_method(const StringName &p_method) const {
const GDScript *sptr = script.ptr();
while (sptr) {
- const Map<StringName, GDFunction *>::Element *E = sptr->member_functions.find(p_method);
+ const Map<StringName, GDScriptFunction *>::Element *E = sptr->member_functions.find(p_method);
if (E)
return true;
sptr = sptr->_base;
@@ -1122,13 +1122,13 @@ bool GDInstance::has_method(const StringName &p_method) const {
return false;
}
-Variant GDInstance::call(const StringName &p_method, const Variant **p_args, int p_argcount, Variant::CallError &r_error) {
+Variant GDScriptInstance::call(const StringName &p_method, const Variant **p_args, int p_argcount, Variant::CallError &r_error) {
//printf("calling %ls:%i method %ls\n", script->get_path().c_str(), -1, String(p_method).c_str());
GDScript *sptr = script.ptr();
while (sptr) {
- Map<StringName, GDFunction *>::Element *E = sptr->member_functions.find(p_method);
+ Map<StringName, GDScriptFunction *>::Element *E = sptr->member_functions.find(p_method);
if (E) {
return E->get()->call(this, p_args, p_argcount, r_error);
}
@@ -1138,13 +1138,13 @@ Variant GDInstance::call(const StringName &p_method, const Variant **p_args, int
return Variant();
}
-void GDInstance::call_multilevel(const StringName &p_method, const Variant **p_args, int p_argcount) {
+void GDScriptInstance::call_multilevel(const StringName &p_method, const Variant **p_args, int p_argcount) {
GDScript *sptr = script.ptr();
Variant::CallError ce;
while (sptr) {
- Map<StringName, GDFunction *>::Element *E = sptr->member_functions.find(p_method);
+ Map<StringName, GDScriptFunction *>::Element *E = sptr->member_functions.find(p_method);
if (E) {
E->get()->call(this, p_args, p_argcount, ce);
}
@@ -1152,27 +1152,27 @@ void GDInstance::call_multilevel(const StringName &p_method, const Variant **p_a
}
}
-void GDInstance::_ml_call_reversed(GDScript *sptr, const StringName &p_method, const Variant **p_args, int p_argcount) {
+void GDScriptInstance::_ml_call_reversed(GDScript *sptr, const StringName &p_method, const Variant **p_args, int p_argcount) {
if (sptr->_base)
_ml_call_reversed(sptr->_base, p_method, p_args, p_argcount);
Variant::CallError ce;
- Map<StringName, GDFunction *>::Element *E = sptr->member_functions.find(p_method);
+ Map<StringName, GDScriptFunction *>::Element *E = sptr->member_functions.find(p_method);
if (E) {
E->get()->call(this, p_args, p_argcount, ce);
}
}
-void GDInstance::call_multilevel_reversed(const StringName &p_method, const Variant **p_args, int p_argcount) {
+void GDScriptInstance::call_multilevel_reversed(const StringName &p_method, const Variant **p_args, int p_argcount) {
if (script.ptr()) {
_ml_call_reversed(script.ptr(), p_method, p_args, p_argcount);
}
}
-void GDInstance::notification(int p_notification) {
+void GDScriptInstance::notification(int p_notification) {
//notification is not virtual, it gets called at ALL levels just like in C.
Variant value = p_notification;
@@ -1180,7 +1180,7 @@ void GDInstance::notification(int p_notification) {
GDScript *sptr = script.ptr();
while (sptr) {
- Map<StringName, GDFunction *>::Element *E = sptr->member_functions.find(GDScriptLanguage::get_singleton()->strings._notification);
+ Map<StringName, GDScriptFunction *>::Element *E = sptr->member_functions.find(GDScriptLanguage::get_singleton()->strings._notification);
if (E) {
Variant::CallError err;
E->get()->call(this, args, 1, err);
@@ -1192,22 +1192,22 @@ void GDInstance::notification(int p_notification) {
}
}
-Ref<Script> GDInstance::get_script() const {
+Ref<Script> GDScriptInstance::get_script() const {
return script;
}
-ScriptLanguage *GDInstance::get_language() {
+ScriptLanguage *GDScriptInstance::get_language() {
return GDScriptLanguage::get_singleton();
}
-GDInstance::RPCMode GDInstance::get_rpc_mode(const StringName &p_method) const {
+GDScriptInstance::RPCMode GDScriptInstance::get_rpc_mode(const StringName &p_method) const {
const GDScript *cscript = script.ptr();
while (cscript) {
- const Map<StringName, GDFunction *>::Element *E = cscript->member_functions.find(p_method);
+ const Map<StringName, GDScriptFunction *>::Element *E = cscript->member_functions.find(p_method);
if (E) {
if (E->get()->get_rpc_mode() != RPC_MODE_DISABLED) {
@@ -1220,7 +1220,7 @@ GDInstance::RPCMode GDInstance::get_rpc_mode(const StringName &p_method) const {
return RPC_MODE_DISABLED;
}
-GDInstance::RPCMode GDInstance::get_rset_mode(const StringName &p_variable) const {
+GDScriptInstance::RPCMode GDScriptInstance::get_rset_mode(const StringName &p_variable) const {
const GDScript *cscript = script.ptr();
@@ -1238,7 +1238,7 @@ GDInstance::RPCMode GDInstance::get_rset_mode(const StringName &p_variable) cons
return RPC_MODE_DISABLED;
}
-void GDInstance::reload_members() {
+void GDScriptInstance::reload_members() {
#ifdef DEBUG_ENABLED
@@ -1269,12 +1269,12 @@ void GDInstance::reload_members() {
#endif
}
-GDInstance::GDInstance() {
+GDScriptInstance::GDScriptInstance() {
owner = NULL;
base_ref = false;
}
-GDInstance::~GDInstance() {
+GDScriptInstance::~GDScriptInstance() {
if (script.is_valid() && owner) {
#ifndef NO_THREADS
GDScriptLanguage::singleton->lock->lock();
@@ -1342,7 +1342,7 @@ void GDScriptLanguage::init() {
if (globals.has(n))
continue;
- Ref<GDNativeClass> nc = memnew(GDNativeClass(E->get()));
+ Ref<GDScriptNativeClass> nc = memnew(GDScriptNativeClass(E->get()));
_add_global(n, nc);
}
@@ -1379,7 +1379,7 @@ void GDScriptLanguage::profiling_start() {
lock->lock();
}
- SelfList<GDFunction> *elem = function_list.first();
+ SelfList<GDScriptFunction> *elem = function_list.first();
while (elem) {
elem->self()->profile.call_count = 0;
elem->self()->profile.self_time = 0;
@@ -1424,7 +1424,7 @@ int GDScriptLanguage::profiling_get_accumulated_data(ProfilingInfo *p_info_arr,
lock->lock();
}
- SelfList<GDFunction> *elem = function_list.first();
+ SelfList<GDScriptFunction> *elem = function_list.first();
while (elem) {
if (current >= p_info_max)
break;
@@ -1454,7 +1454,7 @@ int GDScriptLanguage::profiling_get_frame_data(ProfilingInfo *p_info_arr, int p_
lock->lock();
}
- SelfList<GDFunction> *elem = function_list.first();
+ SelfList<GDScriptFunction> *elem = function_list.first();
while (elem) {
if (current >= p_info_max)
break;
@@ -1668,7 +1668,7 @@ void GDScriptLanguage::frame() {
lock->lock();
}
- SelfList<GDFunction> *elem = function_list.first();
+ SelfList<GDScriptFunction> *elem = function_list.first();
while (elem) {
elem->self()->profile.last_frame_call_count = elem->self()->profile.frame_call_count;
elem->self()->profile.last_frame_self_time = elem->self()->profile.frame_self_time;
@@ -1753,8 +1753,8 @@ void GDScriptLanguage::get_reserved_words(List<String> *p_words) const {
w++;
}
- for (int i = 0; i < GDFunctions::FUNC_MAX; i++) {
- p_words->push_back(GDFunctions::get_func_name(GDFunctions::Function(i)));
+ for (int i = 0; i < GDScriptFunctions::FUNC_MAX; i++) {
+ p_words->push_back(GDScriptFunctions::get_func_name(GDScriptFunctions::Function(i)));
}
}
diff --git a/modules/gdscript/gd_script.h b/modules/gdscript/gdscript.h
index e0d142014a..3f6f431938 100644
--- a/modules/gdscript/gd_script.h
+++ b/modules/gdscript/gdscript.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* gd_script.h */
+/* gdscript.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -27,16 +27,17 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef GD_SCRIPT_H
-#define GD_SCRIPT_H
+#ifndef GDSCRIPT_H
+#define GDSCRIPT_H
-#include "gd_function.h"
+#include "gdscript_function.h"
#include "io/resource_loader.h"
#include "io/resource_saver.h"
#include "script_language.h"
-class GDNativeClass : public Reference {
- GDCLASS(GDNativeClass, Reference);
+class GDScriptNativeClass : public Reference {
+
+ GDCLASS(GDScriptNativeClass, Reference);
StringName name;
@@ -48,7 +49,7 @@ public:
_FORCE_INLINE_ const StringName &get_name() const { return name; }
Variant _new();
Object *instance();
- GDNativeClass(const StringName &p_name);
+ GDScriptNativeClass(const StringName &p_name);
};
class GDScript : public Script {
@@ -64,21 +65,21 @@ class GDScript : public Script {
ScriptInstance::RPCMode rpc_mode;
};
- friend class GDInstance;
- friend class GDFunction;
- friend class GDCompiler;
- friend class GDFunctions;
+ friend class GDScriptInstance;
+ friend class GDScriptFunction;
+ friend class GDScriptCompiler;
+ friend class GDScriptFunctions;
friend class GDScriptLanguage;
Variant _static_ref; //used for static call
- Ref<GDNativeClass> native;
+ Ref<GDScriptNativeClass> native;
Ref<GDScript> base;
GDScript *_base; //fast pointer access
GDScript *_owner; //for subclasses
Set<StringName> members; //members are just indices to the instanced script.
Map<StringName, Variant> constants;
- Map<StringName, GDFunction *> member_functions;
+ Map<StringName, GDScriptFunction *> member_functions;
Map<StringName, MemberInfo> member_indices; //members are just indices to the instanced script.
Map<StringName, Ref<GDScript> > subclasses;
Map<StringName, Vector<StringName> > _signals;
@@ -99,7 +100,7 @@ class GDScript : public Script {
#endif
Map<StringName, PropertyInfo> member_info;
- GDFunction *initializer; //direct pointer to _init , faster to locate
+ GDScriptFunction *initializer; //direct pointer to _init , faster to locate
int subclass_count;
Set<Object *> instances;
@@ -109,7 +110,7 @@ class GDScript : public Script {
String name;
SelfList<GDScript> script_list;
- GDInstance *_create_instance(const Variant **p_args, int p_argcount, Object *p_owner, bool p_isref, Variant::CallError &r_error);
+ GDScriptInstance *_create_instance(const Variant **p_args, int p_argcount, Object *p_owner, bool p_isref, Variant::CallError &r_error);
void _set_subclass_path(Ref<GDScript> &p_sc, const String &p_path);
@@ -143,8 +144,8 @@ public:
const Map<StringName, Ref<GDScript> > &get_subclasses() const { return subclasses; }
const Map<StringName, Variant> &get_constants() const { return constants; }
const Set<StringName> &get_members() const { return members; }
- const Map<StringName, GDFunction *> &get_member_functions() const { return member_functions; }
- const Ref<GDNativeClass> &get_native() const { return native; }
+ const Map<StringName, GDScriptFunction *> &get_member_functions() const { return member_functions; }
+ const Ref<GDScriptNativeClass> &get_native() const { return native; }
virtual bool has_script_signal(const StringName &p_signal) const;
virtual void get_script_signal_list(List<MethodInfo> *r_signals) const;
@@ -153,7 +154,7 @@ public:
Ref<GDScript> get_base() const;
const Map<StringName, MemberInfo> &debug_get_member_indices() const { return member_indices; }
- const Map<StringName, GDFunction *> &debug_get_member_functions() const; //this is debug only
+ const Map<StringName, GDScriptFunction *> &debug_get_member_functions() const; //this is debug only
StringName debug_get_member_by_index(int p_idx) const;
Variant _new(const Variant **p_args, int p_argcount, Variant::CallError &r_error);
@@ -201,11 +202,11 @@ public:
~GDScript();
};
-class GDInstance : public ScriptInstance {
+class GDScriptInstance : public ScriptInstance {
friend class GDScript;
- friend class GDFunction;
- friend class GDFunctions;
- friend class GDCompiler;
+ friend class GDScriptFunction;
+ friend class GDScriptFunctions;
+ friend class GDScriptCompiler;
Object *owner;
Ref<GDScript> script;
@@ -246,8 +247,8 @@ public:
virtual RPCMode get_rpc_mode(const StringName &p_method) const;
virtual RPCMode get_rset_mode(const StringName &p_variable) const;
- GDInstance();
- ~GDInstance();
+ GDScriptInstance();
+ ~GDScriptInstance();
};
class GDScriptLanguage : public ScriptLanguage {
@@ -261,8 +262,8 @@ class GDScriptLanguage : public ScriptLanguage {
struct CallLevel {
Variant *stack;
- GDFunction *function;
- GDInstance *instance;
+ GDScriptFunction *function;
+ GDScriptInstance *instance;
int *ip;
int *line;
};
@@ -276,16 +277,16 @@ class GDScriptLanguage : public ScriptLanguage {
void _add_global(const StringName &p_name, const Variant &p_value);
- friend class GDInstance;
+ friend class GDScriptInstance;
Mutex *lock;
friend class GDScript;
SelfList<GDScript>::List script_list;
- friend class GDFunction;
+ friend class GDScriptFunction;
- SelfList<GDFunction>::List function_list;
+ SelfList<GDScriptFunction>::List function_list;
bool profiling;
uint64_t script_frame_time;
@@ -295,7 +296,7 @@ public:
bool debug_break(const String &p_error, bool p_allow_continue = true);
bool debug_break_parse(const String &p_file, int p_line, const String &p_error);
- _FORCE_INLINE_ void enter_function(GDInstance *p_instance, GDFunction *p_function, Variant *p_stack, int *p_ip, int *p_line) {
+ _FORCE_INLINE_ void enter_function(GDScriptInstance *p_instance, GDScriptFunction *p_function, Variant *p_stack, int *p_ip, int *p_line) {
if (Thread::get_main_id() != Thread::get_caller_id())
return; //no support for other threads than main for now
@@ -446,4 +447,4 @@ public:
virtual bool recognize(const RES &p_resource) const;
};
-#endif // GD_SCRIPT_H
+#endif // GDSCRIPT_H
diff --git a/modules/gdscript/gd_compiler.cpp b/modules/gdscript/gdscript_compiler.cpp
index 7036a708e5..3121a61436 100644
--- a/modules/gdscript/gd_compiler.cpp
+++ b/modules/gdscript/gdscript_compiler.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* gd_compiler.cpp */
+/* gdscript_compiler.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -27,10 +27,11 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "gd_compiler.h"
-#include "gd_script.h"
+#include "gdscript_compiler.h"
-bool GDCompiler::_is_class_member_property(CodeGen &codegen, const StringName &p_name) {
+#include "gdscript.h"
+
+bool GDScriptCompiler::_is_class_member_property(CodeGen &codegen, const StringName &p_name) {
if (!codegen.function_node || codegen.function_node->_static)
return false;
@@ -38,10 +39,10 @@ bool GDCompiler::_is_class_member_property(CodeGen &codegen, const StringName &p
return _is_class_member_property(codegen.script, p_name);
}
-bool GDCompiler::_is_class_member_property(GDScript *owner, const StringName &p_name) {
+bool GDScriptCompiler::_is_class_member_property(GDScript *owner, const StringName &p_name) {
GDScript *scr = owner;
- GDNativeClass *nc = NULL;
+ GDScriptNativeClass *nc = NULL;
while (scr) {
if (scr->native.is_valid())
@@ -54,7 +55,7 @@ bool GDCompiler::_is_class_member_property(GDScript *owner, const StringName &p_
return ClassDB::has_property(nc->get_name(), p_name);
}
-void GDCompiler::_set_error(const String &p_error, const GDParser::Node *p_node) {
+void GDScriptCompiler::_set_error(const String &p_error, const GDScriptParser::Node *p_node) {
if (error != "")
return;
@@ -69,7 +70,7 @@ void GDCompiler::_set_error(const String &p_error, const GDParser::Node *p_node)
}
}
-bool GDCompiler::_create_unary_operator(CodeGen &codegen, const GDParser::OperatorNode *on, Variant::Operator op, int p_stack_level) {
+bool GDScriptCompiler::_create_unary_operator(CodeGen &codegen, const GDScriptParser::OperatorNode *on, Variant::Operator op, int p_stack_level) {
ERR_FAIL_COND_V(on->arguments.size() != 1, false);
@@ -77,29 +78,29 @@ bool GDCompiler::_create_unary_operator(CodeGen &codegen, const GDParser::Operat
if (src_address_a < 0)
return false;
- codegen.opcodes.push_back(GDFunction::OPCODE_OPERATOR); // perform operator
+ codegen.opcodes.push_back(GDScriptFunction::OPCODE_OPERATOR); // perform operator
codegen.opcodes.push_back(op); //which operator
codegen.opcodes.push_back(src_address_a); // argument 1
codegen.opcodes.push_back(src_address_a); // argument 2 (repeated)
- //codegen.opcodes.push_back(GDFunction::ADDR_TYPE_NIL); // argument 2 (unary only takes one parameter)
+ //codegen.opcodes.push_back(GDScriptFunction::ADDR_TYPE_NIL); // argument 2 (unary only takes one parameter)
return true;
}
-bool GDCompiler::_create_binary_operator(CodeGen &codegen, const GDParser::OperatorNode *on, Variant::Operator op, int p_stack_level, bool p_initializer) {
+bool GDScriptCompiler::_create_binary_operator(CodeGen &codegen, const GDScriptParser::OperatorNode *on, Variant::Operator op, int p_stack_level, bool p_initializer) {
ERR_FAIL_COND_V(on->arguments.size() != 2, false);
int src_address_a = _parse_expression(codegen, on->arguments[0], p_stack_level, false, p_initializer);
if (src_address_a < 0)
return false;
- if (src_address_a & GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS)
+ if (src_address_a & GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS)
p_stack_level++; //uses stack for return, increase stack
int src_address_b = _parse_expression(codegen, on->arguments[1], p_stack_level, false, p_initializer);
if (src_address_b < 0)
return false;
- codegen.opcodes.push_back(GDFunction::OPCODE_OPERATOR); // perform operator
+ codegen.opcodes.push_back(GDScriptFunction::OPCODE_OPERATOR); // perform operator
codegen.opcodes.push_back(op); //which operator
codegen.opcodes.push_back(src_address_a); // argument 1
codegen.opcodes.push_back(src_address_b); // argument 2 (unary only takes one parameter)
@@ -107,14 +108,14 @@ bool GDCompiler::_create_binary_operator(CodeGen &codegen, const GDParser::Opera
}
/*
-int GDCompiler::_parse_subexpression(CodeGen& codegen,const GDParser::Node *p_expression) {
+int GDScriptCompiler::_parse_subexpression(CodeGen& codegen,const GDScriptParser::Node *p_expression) {
int ret = _parse_expression(codegen,p_expression);
if (ret<0)
return ret;
- if (ret&(GDFunction::ADDR_TYPE_STACK<<GDFunction::ADDR_BITS)) {
+ if (ret&(GDScriptFunction::ADDR_TYPE_STACK<<GDScriptFunction::ADDR_BITS)) {
codegen.stack_level++;
codegen.check_max_stack_level();
//stack was used, keep value
@@ -124,24 +125,24 @@ int GDCompiler::_parse_subexpression(CodeGen& codegen,const GDParser::Node *p_ex
}
*/
-int GDCompiler::_parse_assign_right_expression(CodeGen &codegen, const GDParser::OperatorNode *p_expression, int p_stack_level) {
+int GDScriptCompiler::_parse_assign_right_expression(CodeGen &codegen, const GDScriptParser::OperatorNode *p_expression, int p_stack_level) {
Variant::Operator var_op = Variant::OP_MAX;
switch (p_expression->op) {
- case GDParser::OperatorNode::OP_ASSIGN_ADD: var_op = Variant::OP_ADD; break;
- case GDParser::OperatorNode::OP_ASSIGN_SUB: var_op = Variant::OP_SUBTRACT; break;
- case GDParser::OperatorNode::OP_ASSIGN_MUL: var_op = Variant::OP_MULTIPLY; break;
- case GDParser::OperatorNode::OP_ASSIGN_DIV: var_op = Variant::OP_DIVIDE; break;
- case GDParser::OperatorNode::OP_ASSIGN_MOD: var_op = Variant::OP_MODULE; break;
- case GDParser::OperatorNode::OP_ASSIGN_SHIFT_LEFT: var_op = Variant::OP_SHIFT_LEFT; break;
- case GDParser::OperatorNode::OP_ASSIGN_SHIFT_RIGHT: var_op = Variant::OP_SHIFT_RIGHT; break;
- case GDParser::OperatorNode::OP_ASSIGN_BIT_AND: var_op = Variant::OP_BIT_AND; break;
- case GDParser::OperatorNode::OP_ASSIGN_BIT_OR: var_op = Variant::OP_BIT_OR; break;
- case GDParser::OperatorNode::OP_ASSIGN_BIT_XOR: var_op = Variant::OP_BIT_XOR; break;
- case GDParser::OperatorNode::OP_INIT_ASSIGN:
- case GDParser::OperatorNode::OP_ASSIGN: {
+ case GDScriptParser::OperatorNode::OP_ASSIGN_ADD: var_op = Variant::OP_ADD; break;
+ case GDScriptParser::OperatorNode::OP_ASSIGN_SUB: var_op = Variant::OP_SUBTRACT; break;
+ case GDScriptParser::OperatorNode::OP_ASSIGN_MUL: var_op = Variant::OP_MULTIPLY; break;
+ case GDScriptParser::OperatorNode::OP_ASSIGN_DIV: var_op = Variant::OP_DIVIDE; break;
+ case GDScriptParser::OperatorNode::OP_ASSIGN_MOD: var_op = Variant::OP_MODULE; break;
+ case GDScriptParser::OperatorNode::OP_ASSIGN_SHIFT_LEFT: var_op = Variant::OP_SHIFT_LEFT; break;
+ case GDScriptParser::OperatorNode::OP_ASSIGN_SHIFT_RIGHT: var_op = Variant::OP_SHIFT_RIGHT; break;
+ case GDScriptParser::OperatorNode::OP_ASSIGN_BIT_AND: var_op = Variant::OP_BIT_AND; break;
+ case GDScriptParser::OperatorNode::OP_ASSIGN_BIT_OR: var_op = Variant::OP_BIT_OR; break;
+ case GDScriptParser::OperatorNode::OP_ASSIGN_BIT_XOR: var_op = Variant::OP_BIT_XOR; break;
+ case GDScriptParser::OperatorNode::OP_INIT_ASSIGN:
+ case GDScriptParser::OperatorNode::OP_ASSIGN: {
//none
} break;
@@ -151,7 +152,7 @@ int GDCompiler::_parse_assign_right_expression(CodeGen &codegen, const GDParser:
}
}
- bool initializer = p_expression->op == GDParser::OperatorNode::OP_INIT_ASSIGN;
+ bool initializer = p_expression->op == GDScriptParser::OperatorNode::OP_INIT_ASSIGN;
if (var_op == Variant::OP_MAX) {
@@ -161,32 +162,32 @@ int GDCompiler::_parse_assign_right_expression(CodeGen &codegen, const GDParser:
if (!_create_binary_operator(codegen, p_expression, var_op, p_stack_level, initializer))
return -1;
- int dst_addr = (p_stack_level) | (GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS);
+ int dst_addr = (p_stack_level) | (GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS);
codegen.opcodes.push_back(dst_addr); // append the stack level as destination address of the opcode
codegen.alloc_stack(p_stack_level);
return dst_addr;
}
-int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expression, int p_stack_level, bool p_root, bool p_initializer) {
+int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser::Node *p_expression, int p_stack_level, bool p_root, bool p_initializer) {
switch (p_expression->type) {
//should parse variable declaration and adjust stack accordingly...
- case GDParser::Node::TYPE_IDENTIFIER: {
+ case GDScriptParser::Node::TYPE_IDENTIFIER: {
//return identifier
//wait, identifier could be a local variable or something else... careful here, must reference properly
//as stack may be more interesting to work with
//This could be made much simpler by just indexing "self", but done this way (with custom self-addressing modes) increases peformance a lot.
- const GDParser::IdentifierNode *in = static_cast<const GDParser::IdentifierNode *>(p_expression);
+ const GDScriptParser::IdentifierNode *in = static_cast<const GDScriptParser::IdentifierNode *>(p_expression);
StringName identifier = in->name;
if (_is_class_member_property(codegen, identifier)) {
//get property
- codegen.opcodes.push_back(GDFunction::OPCODE_GET_MEMBER); // perform operator
+ codegen.opcodes.push_back(GDScriptFunction::OPCODE_GET_MEMBER); // perform operator
codegen.opcodes.push_back(codegen.get_name_map_pos(identifier)); // argument 2 (unary only takes one parameter)
- int dst_addr = (p_stack_level) | (GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS);
+ int dst_addr = (p_stack_level) | (GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS);
codegen.opcodes.push_back(dst_addr); // append the stack level as destination address of the opcode
codegen.alloc_stack(p_stack_level);
return dst_addr;
@@ -196,7 +197,7 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
if (!p_initializer && codegen.stack_identifiers.has(identifier)) {
int pos = codegen.stack_identifiers[identifier];
- return pos | (GDFunction::ADDR_TYPE_STACK_VARIABLE << GDFunction::ADDR_BITS);
+ return pos | (GDScriptFunction::ADDR_TYPE_STACK_VARIABLE << GDScriptFunction::ADDR_BITS);
}
//TRY MEMBERS!
if (!codegen.function_node || !codegen.function_node->_static) {
@@ -206,7 +207,7 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
if (codegen.script->member_indices.has(identifier)) {
int idx = codegen.script->member_indices[identifier].index;
- return idx | (GDFunction::ADDR_TYPE_MEMBER << GDFunction::ADDR_BITS); //argument (stack root)
+ return idx | (GDScriptFunction::ADDR_TYPE_MEMBER << GDScriptFunction::ADDR_BITS); //argument (stack root)
}
}
@@ -216,14 +217,14 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
while (owner) {
GDScript *scr = owner;
- GDNativeClass *nc = NULL;
+ GDScriptNativeClass *nc = NULL;
while (scr) {
if (scr->constants.has(identifier)) {
//int idx=scr->constants[identifier];
int idx = codegen.get_name_map_pos(identifier);
- return idx | (GDFunction::ADDR_TYPE_CLASS_CONSTANT << GDFunction::ADDR_BITS); //argument (stack root)
+ return idx | (GDScriptFunction::ADDR_TYPE_CLASS_CONSTANT << GDScriptFunction::ADDR_BITS); //argument (stack root)
}
if (scr->native.is_valid())
nc = scr->native.ptr();
@@ -249,7 +250,7 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
idx = codegen.constant_map[key];
}
- return idx | (GDFunction::ADDR_TYPE_LOCAL_CONSTANT << GDFunction::ADDR_BITS); //make it a local constant (faster access)
+ return idx | (GDScriptFunction::ADDR_TYPE_LOCAL_CONSTANT << GDScriptFunction::ADDR_BITS); //make it a local constant (faster access)
}
}
@@ -261,14 +262,14 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
if (codegen.script->subclasses.has(identifier)) {
//same with a subclass, make it a local constant.
int idx = codegen.get_constant_pos(codegen.script->subclasses[identifier]);
- return idx|(GDFunction::ADDR_TYPE_LOCAL_CONSTANT<<GDFunction::ADDR_BITS); //make it a local constant (faster access)
+ return idx|(GDScriptFunction::ADDR_TYPE_LOCAL_CONSTANT<<GDScriptFunction::ADDR_BITS); //make it a local constant (faster access)
}*/
if (GDScriptLanguage::get_singleton()->get_global_map().has(identifier)) {
int idx = GDScriptLanguage::get_singleton()->get_global_map()[identifier];
- return idx | (GDFunction::ADDR_TYPE_GLOBAL << GDFunction::ADDR_BITS); //argument (stack root)
+ return idx | (GDScriptFunction::ADDR_TYPE_GLOBAL << GDScriptFunction::ADDR_BITS); //argument (stack root)
}
//not found, error
@@ -278,9 +279,9 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
return -1;
} break;
- case GDParser::Node::TYPE_CONSTANT: {
+ case GDScriptParser::Node::TYPE_CONSTANT: {
//return constant
- const GDParser::ConstantNode *cn = static_cast<const GDParser::ConstantNode *>(p_expression);
+ const GDScriptParser::ConstantNode *cn = static_cast<const GDScriptParser::ConstantNode *>(p_expression);
int idx;
@@ -293,20 +294,20 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
idx = codegen.constant_map[cn->value];
}
- return idx | (GDFunction::ADDR_TYPE_LOCAL_CONSTANT << GDFunction::ADDR_BITS); //argument (stack root)
+ return idx | (GDScriptFunction::ADDR_TYPE_LOCAL_CONSTANT << GDScriptFunction::ADDR_BITS); //argument (stack root)
} break;
- case GDParser::Node::TYPE_SELF: {
+ case GDScriptParser::Node::TYPE_SELF: {
//return constant
if (codegen.function_node && codegen.function_node->_static) {
_set_error("'self' not present in static function!", p_expression);
return -1;
}
- return (GDFunction::ADDR_TYPE_SELF << GDFunction::ADDR_BITS);
+ return (GDScriptFunction::ADDR_TYPE_SELF << GDScriptFunction::ADDR_BITS);
} break;
- case GDParser::Node::TYPE_ARRAY: {
+ case GDScriptParser::Node::TYPE_ARRAY: {
- const GDParser::ArrayNode *an = static_cast<const GDParser::ArrayNode *>(p_expression);
+ const GDScriptParser::ArrayNode *an = static_cast<const GDScriptParser::ArrayNode *>(p_expression);
Vector<int> values;
int slevel = p_stack_level;
@@ -316,7 +317,7 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
int ret = _parse_expression(codegen, an->elements[i], slevel);
if (ret < 0)
return ret;
- if (ret & GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS) {
+ if (ret & GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS) {
slevel++;
codegen.alloc_stack(slevel);
}
@@ -324,20 +325,20 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
values.push_back(ret);
}
- codegen.opcodes.push_back(GDFunction::OPCODE_CONSTRUCT_ARRAY);
+ codegen.opcodes.push_back(GDScriptFunction::OPCODE_CONSTRUCT_ARRAY);
codegen.opcodes.push_back(values.size());
for (int i = 0; i < values.size(); i++)
codegen.opcodes.push_back(values[i]);
- int dst_addr = (p_stack_level) | (GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS);
+ int dst_addr = (p_stack_level) | (GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS);
codegen.opcodes.push_back(dst_addr); // append the stack level as destination address of the opcode
codegen.alloc_stack(p_stack_level);
return dst_addr;
} break;
- case GDParser::Node::TYPE_DICTIONARY: {
+ case GDScriptParser::Node::TYPE_DICTIONARY: {
- const GDParser::DictionaryNode *dn = static_cast<const GDParser::DictionaryNode *>(p_expression);
+ const GDScriptParser::DictionaryNode *dn = static_cast<const GDScriptParser::DictionaryNode *>(p_expression);
Vector<int> values;
int slevel = p_stack_level;
@@ -347,7 +348,7 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
int ret = _parse_expression(codegen, dn->elements[i].key, slevel);
if (ret < 0)
return ret;
- if (ret & GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS) {
+ if (ret & GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS) {
slevel++;
codegen.alloc_stack(slevel);
}
@@ -357,7 +358,7 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
ret = _parse_expression(codegen, dn->elements[i].value, slevel);
if (ret < 0)
return ret;
- if (ret & GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS) {
+ if (ret & GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS) {
slevel++;
codegen.alloc_stack(slevel);
}
@@ -365,29 +366,29 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
values.push_back(ret);
}
- codegen.opcodes.push_back(GDFunction::OPCODE_CONSTRUCT_DICTIONARY);
+ codegen.opcodes.push_back(GDScriptFunction::OPCODE_CONSTRUCT_DICTIONARY);
codegen.opcodes.push_back(dn->elements.size());
for (int i = 0; i < values.size(); i++)
codegen.opcodes.push_back(values[i]);
- int dst_addr = (p_stack_level) | (GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS);
+ int dst_addr = (p_stack_level) | (GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS);
codegen.opcodes.push_back(dst_addr); // append the stack level as destination address of the opcode
codegen.alloc_stack(p_stack_level);
return dst_addr;
} break;
- case GDParser::Node::TYPE_OPERATOR: {
+ case GDScriptParser::Node::TYPE_OPERATOR: {
//hell breaks loose
- const GDParser::OperatorNode *on = static_cast<const GDParser::OperatorNode *>(p_expression);
+ const GDScriptParser::OperatorNode *on = static_cast<const GDScriptParser::OperatorNode *>(p_expression);
switch (on->op) {
//call/constructor operator
- case GDParser::OperatorNode::OP_PARENT_CALL: {
+ case GDScriptParser::OperatorNode::OP_PARENT_CALL: {
ERR_FAIL_COND_V(on->arguments.size() < 1, -1);
- const GDParser::IdentifierNode *in = (const GDParser::IdentifierNode *)on->arguments[0];
+ const GDScriptParser::IdentifierNode *in = (const GDScriptParser::IdentifierNode *)on->arguments[0];
Vector<int> arguments;
int slevel = p_stack_level;
@@ -396,7 +397,7 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
int ret = _parse_expression(codegen, on->arguments[i], slevel);
if (ret < 0)
return ret;
- if (ret & GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS) {
+ if (ret & GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS) {
slevel++;
codegen.alloc_stack(slevel);
}
@@ -404,7 +405,7 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
}
//push call bytecode
- codegen.opcodes.push_back(GDFunction::OPCODE_CALL_SELF_BASE); // basic type constructor
+ codegen.opcodes.push_back(GDScriptFunction::OPCODE_CALL_SELF_BASE); // basic type constructor
codegen.opcodes.push_back(codegen.get_name_map_pos(in->name)); //instance
codegen.opcodes.push_back(arguments.size()); //argument count
@@ -413,13 +414,13 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
codegen.opcodes.push_back(arguments[i]); //arguments
} break;
- case GDParser::OperatorNode::OP_CALL: {
+ case GDScriptParser::OperatorNode::OP_CALL: {
- if (on->arguments[0]->type == GDParser::Node::TYPE_TYPE) {
+ if (on->arguments[0]->type == GDScriptParser::Node::TYPE_TYPE) {
//construct a basic type
ERR_FAIL_COND_V(on->arguments.size() < 1, -1);
- const GDParser::TypeNode *tn = (const GDParser::TypeNode *)on->arguments[0];
+ const GDScriptParser::TypeNode *tn = (const GDScriptParser::TypeNode *)on->arguments[0];
int vtype = tn->vtype;
Vector<int> arguments;
@@ -429,7 +430,7 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
int ret = _parse_expression(codegen, on->arguments[i], slevel);
if (ret < 0)
return ret;
- if (ret & GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS) {
+ if (ret & GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS) {
slevel++;
codegen.alloc_stack(slevel);
}
@@ -437,14 +438,14 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
}
//push call bytecode
- codegen.opcodes.push_back(GDFunction::OPCODE_CONSTRUCT); // basic type constructor
+ codegen.opcodes.push_back(GDScriptFunction::OPCODE_CONSTRUCT); // basic type constructor
codegen.opcodes.push_back(vtype); //instance
codegen.opcodes.push_back(arguments.size()); //argument count
codegen.alloc_call(arguments.size());
for (int i = 0; i < arguments.size(); i++)
codegen.opcodes.push_back(arguments[i]); //arguments
- } else if (on->arguments[0]->type == GDParser::Node::TYPE_BUILT_IN_FUNCTION) {
+ } else if (on->arguments[0]->type == GDScriptParser::Node::TYPE_BUILT_IN_FUNCTION) {
//built in function
ERR_FAIL_COND_V(on->arguments.size() < 1, -1);
@@ -457,7 +458,7 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
if (ret < 0)
return ret;
- if (ret & GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS) {
+ if (ret & GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS) {
slevel++;
codegen.alloc_stack(slevel);
}
@@ -465,8 +466,8 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
arguments.push_back(ret);
}
- codegen.opcodes.push_back(GDFunction::OPCODE_CALL_BUILT_IN);
- codegen.opcodes.push_back(static_cast<const GDParser::BuiltInFunctionNode *>(on->arguments[0])->function);
+ codegen.opcodes.push_back(GDScriptFunction::OPCODE_CALL_BUILT_IN);
+ codegen.opcodes.push_back(static_cast<const GDScriptParser::BuiltInFunctionNode *>(on->arguments[0])->function);
codegen.opcodes.push_back(on->arguments.size() - 1);
codegen.alloc_call(on->arguments.size() - 1);
for (int i = 0; i < arguments.size(); i++)
@@ -476,9 +477,9 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
//regular function
ERR_FAIL_COND_V(on->arguments.size() < 2, -1);
- const GDParser::Node *instance = on->arguments[0];
+ const GDScriptParser::Node *instance = on->arguments[0];
- if (instance->type == GDParser::Node::TYPE_SELF) {
+ if (instance->type == GDScriptParser::Node::TYPE_SELF) {
//room for optimization
}
@@ -489,16 +490,16 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
int ret;
- if (i == 0 && on->arguments[i]->type == GDParser::Node::TYPE_SELF && codegen.function_node && codegen.function_node->_static) {
+ if (i == 0 && on->arguments[i]->type == GDScriptParser::Node::TYPE_SELF && codegen.function_node && codegen.function_node->_static) {
//static call to self
- ret = (GDFunction::ADDR_TYPE_CLASS << GDFunction::ADDR_BITS);
+ ret = (GDScriptFunction::ADDR_TYPE_CLASS << GDScriptFunction::ADDR_BITS);
} else if (i == 1) {
- if (on->arguments[i]->type != GDParser::Node::TYPE_IDENTIFIER) {
+ if (on->arguments[i]->type != GDScriptParser::Node::TYPE_IDENTIFIER) {
_set_error("Attempt to call a non-identifier.", on);
return -1;
}
- GDParser::IdentifierNode *id = static_cast<GDParser::IdentifierNode *>(on->arguments[i]);
+ GDScriptParser::IdentifierNode *id = static_cast<GDScriptParser::IdentifierNode *>(on->arguments[i]);
ret = codegen.get_name_map_pos(id->name);
} else {
@@ -506,7 +507,7 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
ret = _parse_expression(codegen, on->arguments[i], slevel);
if (ret < 0)
return ret;
- if (ret & GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS) {
+ if (ret & GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS) {
slevel++;
codegen.alloc_stack(slevel);
}
@@ -514,14 +515,14 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
arguments.push_back(ret);
}
- codegen.opcodes.push_back(p_root ? GDFunction::OPCODE_CALL : GDFunction::OPCODE_CALL_RETURN); // perform operator
+ codegen.opcodes.push_back(p_root ? GDScriptFunction::OPCODE_CALL : GDScriptFunction::OPCODE_CALL_RETURN); // perform operator
codegen.opcodes.push_back(on->arguments.size() - 2);
codegen.alloc_call(on->arguments.size() - 2);
for (int i = 0; i < arguments.size(); i++)
codegen.opcodes.push_back(arguments[i]);
}
} break;
- case GDParser::OperatorNode::OP_YIELD: {
+ case GDScriptParser::OperatorNode::OP_YIELD: {
ERR_FAIL_COND_V(on->arguments.size() && on->arguments.size() != 2, -1);
@@ -532,7 +533,7 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
int ret = _parse_expression(codegen, on->arguments[i], slevel);
if (ret < 0)
return ret;
- if (ret & (GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS)) {
+ if (ret & (GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS)) {
slevel++;
codegen.alloc_stack(slevel);
}
@@ -540,22 +541,22 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
}
//push call bytecode
- codegen.opcodes.push_back(arguments.size() == 0 ? GDFunction::OPCODE_YIELD : GDFunction::OPCODE_YIELD_SIGNAL); // basic type constructor
+ codegen.opcodes.push_back(arguments.size() == 0 ? GDScriptFunction::OPCODE_YIELD : GDScriptFunction::OPCODE_YIELD_SIGNAL); // basic type constructor
for (int i = 0; i < arguments.size(); i++)
codegen.opcodes.push_back(arguments[i]); //arguments
- codegen.opcodes.push_back(GDFunction::OPCODE_YIELD_RESUME);
+ codegen.opcodes.push_back(GDScriptFunction::OPCODE_YIELD_RESUME);
//next will be where to place the result :)
} break;
//indexing operator
- case GDParser::OperatorNode::OP_INDEX:
- case GDParser::OperatorNode::OP_INDEX_NAMED: {
+ case GDScriptParser::OperatorNode::OP_INDEX:
+ case GDScriptParser::OperatorNode::OP_INDEX_NAMED: {
ERR_FAIL_COND_V(on->arguments.size() != 2, -1);
int slevel = p_stack_level;
- bool named = (on->op == GDParser::OperatorNode::OP_INDEX_NAMED);
+ bool named = (on->op == GDScriptParser::OperatorNode::OP_INDEX_NAMED);
int from = _parse_expression(codegen, on->arguments[0], slevel);
if (from < 0)
@@ -563,14 +564,14 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
int index;
if (named) {
- if (on->arguments[0]->type == GDParser::Node::TYPE_SELF && codegen.script && codegen.function_node && !codegen.function_node->_static) {
+ if (on->arguments[0]->type == GDScriptParser::Node::TYPE_SELF && codegen.script && codegen.function_node && !codegen.function_node->_static) {
- GDParser::IdentifierNode *identifier = static_cast<GDParser::IdentifierNode *>(on->arguments[1]);
+ GDScriptParser::IdentifierNode *identifier = static_cast<GDScriptParser::IdentifierNode *>(on->arguments[1]);
const Map<StringName, GDScript::MemberInfo>::Element *MI = codegen.script->member_indices.find(identifier->name);
#ifdef DEBUG_ENABLED
if (MI && MI->get().getter == codegen.function_node->name) {
- String n = static_cast<GDParser::IdentifierNode *>(on->arguments[1])->name;
+ String n = static_cast<GDScriptParser::IdentifierNode *>(on->arguments[1])->name;
_set_error("Must use '" + n + "' instead of 'self." + n + "' in getter.", on);
return -1;
}
@@ -578,23 +579,23 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
if (MI && MI->get().getter == "") {
// Faster than indexing self (as if no self. had been used)
- return (MI->get().index) | (GDFunction::ADDR_TYPE_MEMBER << GDFunction::ADDR_BITS);
+ return (MI->get().index) | (GDScriptFunction::ADDR_TYPE_MEMBER << GDScriptFunction::ADDR_BITS);
}
}
- index = codegen.get_name_map_pos(static_cast<GDParser::IdentifierNode *>(on->arguments[1])->name);
+ index = codegen.get_name_map_pos(static_cast<GDScriptParser::IdentifierNode *>(on->arguments[1])->name);
} else {
- if (on->arguments[1]->type == GDParser::Node::TYPE_CONSTANT && static_cast<const GDParser::ConstantNode *>(on->arguments[1])->value.get_type() == Variant::STRING) {
+ if (on->arguments[1]->type == GDScriptParser::Node::TYPE_CONSTANT && static_cast<const GDScriptParser::ConstantNode *>(on->arguments[1])->value.get_type() == Variant::STRING) {
//also, somehow, named (speed up anyway)
- StringName name = static_cast<const GDParser::ConstantNode *>(on->arguments[1])->value;
+ StringName name = static_cast<const GDScriptParser::ConstantNode *>(on->arguments[1])->value;
index = codegen.get_name_map_pos(name);
named = true;
} else {
//regular indexing
- if (from & GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS) {
+ if (from & GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS) {
slevel++;
codegen.alloc_stack(slevel);
}
@@ -605,19 +606,19 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
}
}
- codegen.opcodes.push_back(named ? GDFunction::OPCODE_GET_NAMED : GDFunction::OPCODE_GET); // perform operator
+ codegen.opcodes.push_back(named ? GDScriptFunction::OPCODE_GET_NAMED : GDScriptFunction::OPCODE_GET); // perform operator
codegen.opcodes.push_back(from); // argument 1
codegen.opcodes.push_back(index); // argument 2 (unary only takes one parameter)
} break;
- case GDParser::OperatorNode::OP_AND: {
+ case GDScriptParser::OperatorNode::OP_AND: {
// AND operator with early out on failure
int res = _parse_expression(codegen, on->arguments[0], p_stack_level);
if (res < 0)
return res;
- codegen.opcodes.push_back(GDFunction::OPCODE_JUMP_IF_NOT);
+ codegen.opcodes.push_back(GDScriptFunction::OPCODE_JUMP_IF_NOT);
codegen.opcodes.push_back(res);
int jump_fail_pos = codegen.opcodes.size();
codegen.opcodes.push_back(0);
@@ -626,31 +627,31 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
if (res < 0)
return res;
- codegen.opcodes.push_back(GDFunction::OPCODE_JUMP_IF_NOT);
+ codegen.opcodes.push_back(GDScriptFunction::OPCODE_JUMP_IF_NOT);
codegen.opcodes.push_back(res);
int jump_fail_pos2 = codegen.opcodes.size();
codegen.opcodes.push_back(0);
codegen.alloc_stack(p_stack_level); //it will be used..
- codegen.opcodes.push_back(GDFunction::OPCODE_ASSIGN_TRUE);
- codegen.opcodes.push_back(p_stack_level | GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS);
- codegen.opcodes.push_back(GDFunction::OPCODE_JUMP);
+ codegen.opcodes.push_back(GDScriptFunction::OPCODE_ASSIGN_TRUE);
+ codegen.opcodes.push_back(p_stack_level | GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS);
+ codegen.opcodes.push_back(GDScriptFunction::OPCODE_JUMP);
codegen.opcodes.push_back(codegen.opcodes.size() + 3);
codegen.opcodes[jump_fail_pos] = codegen.opcodes.size();
codegen.opcodes[jump_fail_pos2] = codegen.opcodes.size();
- codegen.opcodes.push_back(GDFunction::OPCODE_ASSIGN_FALSE);
- codegen.opcodes.push_back(p_stack_level | GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS);
- return p_stack_level | GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS;
+ codegen.opcodes.push_back(GDScriptFunction::OPCODE_ASSIGN_FALSE);
+ codegen.opcodes.push_back(p_stack_level | GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS);
+ return p_stack_level | GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS;
} break;
- case GDParser::OperatorNode::OP_OR: {
+ case GDScriptParser::OperatorNode::OP_OR: {
// OR operator with early out on success
int res = _parse_expression(codegen, on->arguments[0], p_stack_level);
if (res < 0)
return res;
- codegen.opcodes.push_back(GDFunction::OPCODE_JUMP_IF);
+ codegen.opcodes.push_back(GDScriptFunction::OPCODE_JUMP_IF);
codegen.opcodes.push_back(res);
int jump_success_pos = codegen.opcodes.size();
codegen.opcodes.push_back(0);
@@ -659,32 +660,32 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
if (res < 0)
return res;
- codegen.opcodes.push_back(GDFunction::OPCODE_JUMP_IF);
+ codegen.opcodes.push_back(GDScriptFunction::OPCODE_JUMP_IF);
codegen.opcodes.push_back(res);
int jump_success_pos2 = codegen.opcodes.size();
codegen.opcodes.push_back(0);
codegen.alloc_stack(p_stack_level); //it will be used..
- codegen.opcodes.push_back(GDFunction::OPCODE_ASSIGN_FALSE);
- codegen.opcodes.push_back(p_stack_level | GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS);
- codegen.opcodes.push_back(GDFunction::OPCODE_JUMP);
+ codegen.opcodes.push_back(GDScriptFunction::OPCODE_ASSIGN_FALSE);
+ codegen.opcodes.push_back(p_stack_level | GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS);
+ codegen.opcodes.push_back(GDScriptFunction::OPCODE_JUMP);
codegen.opcodes.push_back(codegen.opcodes.size() + 3);
codegen.opcodes[jump_success_pos] = codegen.opcodes.size();
codegen.opcodes[jump_success_pos2] = codegen.opcodes.size();
- codegen.opcodes.push_back(GDFunction::OPCODE_ASSIGN_TRUE);
- codegen.opcodes.push_back(p_stack_level | GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS);
- return p_stack_level | GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS;
+ codegen.opcodes.push_back(GDScriptFunction::OPCODE_ASSIGN_TRUE);
+ codegen.opcodes.push_back(p_stack_level | GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS);
+ return p_stack_level | GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS;
} break;
// ternary operators
- case GDParser::OperatorNode::OP_TERNARY_IF: {
+ case GDScriptParser::OperatorNode::OP_TERNARY_IF: {
// x IF a ELSE y operator with early out on failure
int res = _parse_expression(codegen, on->arguments[0], p_stack_level);
if (res < 0)
return res;
- codegen.opcodes.push_back(GDFunction::OPCODE_JUMP_IF_NOT);
+ codegen.opcodes.push_back(GDScriptFunction::OPCODE_JUMP_IF_NOT);
codegen.opcodes.push_back(res);
int jump_fail_pos = codegen.opcodes.size();
codegen.opcodes.push_back(0);
@@ -694,10 +695,10 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
return res;
codegen.alloc_stack(p_stack_level); //it will be used..
- codegen.opcodes.push_back(GDFunction::OPCODE_ASSIGN);
- codegen.opcodes.push_back(p_stack_level | GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS);
+ codegen.opcodes.push_back(GDScriptFunction::OPCODE_ASSIGN);
+ codegen.opcodes.push_back(p_stack_level | GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS);
codegen.opcodes.push_back(res);
- codegen.opcodes.push_back(GDFunction::OPCODE_JUMP);
+ codegen.opcodes.push_back(GDScriptFunction::OPCODE_JUMP);
int jump_past_pos = codegen.opcodes.size();
codegen.opcodes.push_back(0);
@@ -706,116 +707,116 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
if (res < 0)
return res;
- codegen.opcodes.push_back(GDFunction::OPCODE_ASSIGN);
- codegen.opcodes.push_back(p_stack_level | GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS);
+ codegen.opcodes.push_back(GDScriptFunction::OPCODE_ASSIGN);
+ codegen.opcodes.push_back(p_stack_level | GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS);
codegen.opcodes.push_back(res);
codegen.opcodes[jump_past_pos] = codegen.opcodes.size();
- return p_stack_level | GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS;
+ return p_stack_level | GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS;
} break;
//unary operators
- case GDParser::OperatorNode::OP_NEG: {
+ case GDScriptParser::OperatorNode::OP_NEG: {
if (!_create_unary_operator(codegen, on, Variant::OP_NEGATE, p_stack_level)) return -1;
} break;
- case GDParser::OperatorNode::OP_NOT: {
+ case GDScriptParser::OperatorNode::OP_NOT: {
if (!_create_unary_operator(codegen, on, Variant::OP_NOT, p_stack_level)) return -1;
} break;
- case GDParser::OperatorNode::OP_BIT_INVERT: {
+ case GDScriptParser::OperatorNode::OP_BIT_INVERT: {
if (!_create_unary_operator(codegen, on, Variant::OP_BIT_NEGATE, p_stack_level)) return -1;
} break;
- case GDParser::OperatorNode::OP_PREINC: {
+ case GDScriptParser::OperatorNode::OP_PREINC: {
} break; //?
- case GDParser::OperatorNode::OP_PREDEC: {
+ case GDScriptParser::OperatorNode::OP_PREDEC: {
} break;
- case GDParser::OperatorNode::OP_INC: {
+ case GDScriptParser::OperatorNode::OP_INC: {
} break;
- case GDParser::OperatorNode::OP_DEC: {
+ case GDScriptParser::OperatorNode::OP_DEC: {
} break;
//binary operators (in precedence order)
- case GDParser::OperatorNode::OP_IN: {
+ case GDScriptParser::OperatorNode::OP_IN: {
if (!_create_binary_operator(codegen, on, Variant::OP_IN, p_stack_level)) return -1;
} break;
- case GDParser::OperatorNode::OP_EQUAL: {
+ case GDScriptParser::OperatorNode::OP_EQUAL: {
if (!_create_binary_operator(codegen, on, Variant::OP_EQUAL, p_stack_level)) return -1;
} break;
- case GDParser::OperatorNode::OP_NOT_EQUAL: {
+ case GDScriptParser::OperatorNode::OP_NOT_EQUAL: {
if (!_create_binary_operator(codegen, on, Variant::OP_NOT_EQUAL, p_stack_level)) return -1;
} break;
- case GDParser::OperatorNode::OP_LESS: {
+ case GDScriptParser::OperatorNode::OP_LESS: {
if (!_create_binary_operator(codegen, on, Variant::OP_LESS, p_stack_level)) return -1;
} break;
- case GDParser::OperatorNode::OP_LESS_EQUAL: {
+ case GDScriptParser::OperatorNode::OP_LESS_EQUAL: {
if (!_create_binary_operator(codegen, on, Variant::OP_LESS_EQUAL, p_stack_level)) return -1;
} break;
- case GDParser::OperatorNode::OP_GREATER: {
+ case GDScriptParser::OperatorNode::OP_GREATER: {
if (!_create_binary_operator(codegen, on, Variant::OP_GREATER, p_stack_level)) return -1;
} break;
- case GDParser::OperatorNode::OP_GREATER_EQUAL: {
+ case GDScriptParser::OperatorNode::OP_GREATER_EQUAL: {
if (!_create_binary_operator(codegen, on, Variant::OP_GREATER_EQUAL, p_stack_level)) return -1;
} break;
- case GDParser::OperatorNode::OP_ADD: {
+ case GDScriptParser::OperatorNode::OP_ADD: {
if (!_create_binary_operator(codegen, on, Variant::OP_ADD, p_stack_level)) return -1;
} break;
- case GDParser::OperatorNode::OP_SUB: {
+ case GDScriptParser::OperatorNode::OP_SUB: {
if (!_create_binary_operator(codegen, on, Variant::OP_SUBTRACT, p_stack_level)) return -1;
} break;
- case GDParser::OperatorNode::OP_MUL: {
+ case GDScriptParser::OperatorNode::OP_MUL: {
if (!_create_binary_operator(codegen, on, Variant::OP_MULTIPLY, p_stack_level)) return -1;
} break;
- case GDParser::OperatorNode::OP_DIV: {
+ case GDScriptParser::OperatorNode::OP_DIV: {
if (!_create_binary_operator(codegen, on, Variant::OP_DIVIDE, p_stack_level)) return -1;
} break;
- case GDParser::OperatorNode::OP_MOD: {
+ case GDScriptParser::OperatorNode::OP_MOD: {
if (!_create_binary_operator(codegen, on, Variant::OP_MODULE, p_stack_level)) return -1;
} break;
- //case GDParser::OperatorNode::OP_SHIFT_LEFT: { if (!_create_binary_operator(codegen,on,Variant::OP_SHIFT_LEFT,p_stack_level)) return -1;} break;
- //case GDParser::OperatorNode::OP_SHIFT_RIGHT: { if (!_create_binary_operator(codegen,on,Variant::OP_SHIFT_RIGHT,p_stack_level)) return -1;} break;
- case GDParser::OperatorNode::OP_BIT_AND: {
+ //case GDScriptParser::OperatorNode::OP_SHIFT_LEFT: { if (!_create_binary_operator(codegen,on,Variant::OP_SHIFT_LEFT,p_stack_level)) return -1;} break;
+ //case GDScriptParser::OperatorNode::OP_SHIFT_RIGHT: { if (!_create_binary_operator(codegen,on,Variant::OP_SHIFT_RIGHT,p_stack_level)) return -1;} break;
+ case GDScriptParser::OperatorNode::OP_BIT_AND: {
if (!_create_binary_operator(codegen, on, Variant::OP_BIT_AND, p_stack_level)) return -1;
} break;
- case GDParser::OperatorNode::OP_BIT_OR: {
+ case GDScriptParser::OperatorNode::OP_BIT_OR: {
if (!_create_binary_operator(codegen, on, Variant::OP_BIT_OR, p_stack_level)) return -1;
} break;
- case GDParser::OperatorNode::OP_BIT_XOR: {
+ case GDScriptParser::OperatorNode::OP_BIT_XOR: {
if (!_create_binary_operator(codegen, on, Variant::OP_BIT_XOR, p_stack_level)) return -1;
} break;
//shift
- case GDParser::OperatorNode::OP_SHIFT_LEFT: {
+ case GDScriptParser::OperatorNode::OP_SHIFT_LEFT: {
if (!_create_binary_operator(codegen, on, Variant::OP_SHIFT_LEFT, p_stack_level)) return -1;
} break;
- case GDParser::OperatorNode::OP_SHIFT_RIGHT: {
+ case GDScriptParser::OperatorNode::OP_SHIFT_RIGHT: {
if (!_create_binary_operator(codegen, on, Variant::OP_SHIFT_RIGHT, p_stack_level)) return -1;
} break;
//assignment operators
- case GDParser::OperatorNode::OP_ASSIGN_ADD:
- case GDParser::OperatorNode::OP_ASSIGN_SUB:
- case GDParser::OperatorNode::OP_ASSIGN_MUL:
- case GDParser::OperatorNode::OP_ASSIGN_DIV:
- case GDParser::OperatorNode::OP_ASSIGN_MOD:
- case GDParser::OperatorNode::OP_ASSIGN_SHIFT_LEFT:
- case GDParser::OperatorNode::OP_ASSIGN_SHIFT_RIGHT:
- case GDParser::OperatorNode::OP_ASSIGN_BIT_AND:
- case GDParser::OperatorNode::OP_ASSIGN_BIT_OR:
- case GDParser::OperatorNode::OP_ASSIGN_BIT_XOR:
- case GDParser::OperatorNode::OP_INIT_ASSIGN:
- case GDParser::OperatorNode::OP_ASSIGN: {
+ case GDScriptParser::OperatorNode::OP_ASSIGN_ADD:
+ case GDScriptParser::OperatorNode::OP_ASSIGN_SUB:
+ case GDScriptParser::OperatorNode::OP_ASSIGN_MUL:
+ case GDScriptParser::OperatorNode::OP_ASSIGN_DIV:
+ case GDScriptParser::OperatorNode::OP_ASSIGN_MOD:
+ case GDScriptParser::OperatorNode::OP_ASSIGN_SHIFT_LEFT:
+ case GDScriptParser::OperatorNode::OP_ASSIGN_SHIFT_RIGHT:
+ case GDScriptParser::OperatorNode::OP_ASSIGN_BIT_AND:
+ case GDScriptParser::OperatorNode::OP_ASSIGN_BIT_OR:
+ case GDScriptParser::OperatorNode::OP_ASSIGN_BIT_XOR:
+ case GDScriptParser::OperatorNode::OP_INIT_ASSIGN:
+ case GDScriptParser::OperatorNode::OP_ASSIGN: {
ERR_FAIL_COND_V(on->arguments.size() != 2, -1);
- if (on->arguments[0]->type == GDParser::Node::TYPE_OPERATOR && (static_cast<GDParser::OperatorNode *>(on->arguments[0])->op == GDParser::OperatorNode::OP_INDEX || static_cast<GDParser::OperatorNode *>(on->arguments[0])->op == GDParser::OperatorNode::OP_INDEX_NAMED)) {
+ if (on->arguments[0]->type == GDScriptParser::Node::TYPE_OPERATOR && (static_cast<GDScriptParser::OperatorNode *>(on->arguments[0])->op == GDScriptParser::OperatorNode::OP_INDEX || static_cast<GDScriptParser::OperatorNode *>(on->arguments[0])->op == GDScriptParser::OperatorNode::OP_INDEX_NAMED)) {
//SET (chained) MODE!!
#ifdef DEBUG_ENABLED
- if (static_cast<GDParser::OperatorNode *>(on->arguments[0])->op == GDParser::OperatorNode::OP_INDEX_NAMED) {
- const GDParser::OperatorNode *inon = static_cast<GDParser::OperatorNode *>(on->arguments[0]);
+ if (static_cast<GDScriptParser::OperatorNode *>(on->arguments[0])->op == GDScriptParser::OperatorNode::OP_INDEX_NAMED) {
+ const GDScriptParser::OperatorNode *inon = static_cast<GDScriptParser::OperatorNode *>(on->arguments[0]);
- if (inon->arguments[0]->type == GDParser::Node::TYPE_SELF && codegen.script && codegen.function_node && !codegen.function_node->_static) {
+ if (inon->arguments[0]->type == GDScriptParser::Node::TYPE_SELF && codegen.script && codegen.function_node && !codegen.function_node->_static) {
- const Map<StringName, GDScript::MemberInfo>::Element *MI = codegen.script->member_indices.find(static_cast<GDParser::IdentifierNode *>(inon->arguments[1])->name);
+ const Map<StringName, GDScript::MemberInfo>::Element *MI = codegen.script->member_indices.find(static_cast<GDScriptParser::IdentifierNode *>(inon->arguments[1])->name);
if (MI && MI->get().setter == codegen.function_node->name) {
- String n = static_cast<GDParser::IdentifierNode *>(inon->arguments[1])->name;
+ String n = static_cast<GDScriptParser::IdentifierNode *>(inon->arguments[1])->name;
_set_error("Must use '" + n + "' instead of 'self." + n + "' in setter.", inon);
return -1;
}
@@ -825,34 +826,34 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
int slevel = p_stack_level;
- GDParser::OperatorNode *op = static_cast<GDParser::OperatorNode *>(on->arguments[0]);
+ GDScriptParser::OperatorNode *op = static_cast<GDScriptParser::OperatorNode *>(on->arguments[0]);
/* Find chain of sets */
StringName assign_property;
- List<GDParser::OperatorNode *> chain;
+ List<GDScriptParser::OperatorNode *> chain;
{
//create get/set chain
- GDParser::OperatorNode *n = op;
+ GDScriptParser::OperatorNode *n = op;
while (true) {
chain.push_back(n);
- if (n->arguments[0]->type != GDParser::Node::TYPE_OPERATOR) {
+ if (n->arguments[0]->type != GDScriptParser::Node::TYPE_OPERATOR) {
//check for a built-in property
- if (n->arguments[0]->type == GDParser::Node::TYPE_IDENTIFIER) {
+ if (n->arguments[0]->type == GDScriptParser::Node::TYPE_IDENTIFIER) {
- GDParser::IdentifierNode *identifier = static_cast<GDParser::IdentifierNode *>(n->arguments[0]);
+ GDScriptParser::IdentifierNode *identifier = static_cast<GDScriptParser::IdentifierNode *>(n->arguments[0]);
if (_is_class_member_property(codegen, identifier->name)) {
assign_property = identifier->name;
}
}
break;
}
- n = static_cast<GDParser::OperatorNode *>(n->arguments[0]);
- if (n->op != GDParser::OperatorNode::OP_INDEX && n->op != GDParser::OperatorNode::OP_INDEX_NAMED)
+ n = static_cast<GDScriptParser::OperatorNode *>(n->arguments[0]);
+ if (n->op != GDScriptParser::OperatorNode::OP_INDEX && n->op != GDScriptParser::OperatorNode::OP_INDEX_NAMED)
break;
}
}
@@ -867,7 +868,7 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
//print_line("retval: "+itos(retval));
- if (retval & GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS) {
+ if (retval & GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS) {
slevel++;
codegen.alloc_stack(slevel);
}
@@ -881,30 +882,30 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
// in Node2D
setchain.push_back(prev_pos);
setchain.push_back(codegen.get_name_map_pos(assign_property));
- setchain.push_back(GDFunction::OPCODE_SET_MEMBER);
+ setchain.push_back(GDScriptFunction::OPCODE_SET_MEMBER);
}
- for (List<GDParser::OperatorNode *>::Element *E = chain.back(); E; E = E->prev()) {
+ for (List<GDScriptParser::OperatorNode *>::Element *E = chain.back(); E; E = E->prev()) {
if (E == chain.front()) //ignore first
break;
- bool named = E->get()->op == GDParser::OperatorNode::OP_INDEX_NAMED;
+ bool named = E->get()->op == GDScriptParser::OperatorNode::OP_INDEX_NAMED;
int key_idx;
if (named) {
- key_idx = codegen.get_name_map_pos(static_cast<const GDParser::IdentifierNode *>(E->get()->arguments[1])->name);
+ key_idx = codegen.get_name_map_pos(static_cast<const GDScriptParser::IdentifierNode *>(E->get()->arguments[1])->name);
//printf("named key %x\n",key_idx);
} else {
- if (prev_pos & (GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS)) {
+ if (prev_pos & (GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS)) {
slevel++;
codegen.alloc_stack(slevel);
}
- GDParser::Node *key = E->get()->arguments[1];
+ GDScriptParser::Node *key = E->get()->arguments[1];
key_idx = _parse_expression(codegen, key, slevel);
//printf("expr key %x\n",key_idx);
@@ -914,12 +915,12 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
if (key_idx < 0) //error
return key_idx;
- codegen.opcodes.push_back(named ? GDFunction::OPCODE_GET_NAMED : GDFunction::OPCODE_GET);
+ codegen.opcodes.push_back(named ? GDScriptFunction::OPCODE_GET_NAMED : GDScriptFunction::OPCODE_GET);
codegen.opcodes.push_back(prev_pos);
codegen.opcodes.push_back(key_idx);
slevel++;
codegen.alloc_stack(slevel);
- int dst_pos = (GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS) | slevel;
+ int dst_pos = (GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS) | slevel;
codegen.opcodes.push_back(dst_pos);
@@ -928,7 +929,7 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
setchain.push_back(dst_pos);
setchain.push_back(key_idx);
setchain.push_back(prev_pos);
- setchain.push_back(named ? GDFunction::OPCODE_SET_NAMED : GDFunction::OPCODE_SET);
+ setchain.push_back(named ? GDScriptFunction::OPCODE_SET_NAMED : GDScriptFunction::OPCODE_SET);
prev_pos = dst_pos;
}
@@ -938,9 +939,9 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
int set_index;
bool named = false;
- if (static_cast<const GDParser::OperatorNode *>(op)->op == GDParser::OperatorNode::OP_INDEX_NAMED) {
+ if (static_cast<const GDScriptParser::OperatorNode *>(op)->op == GDScriptParser::OperatorNode::OP_INDEX_NAMED) {
- set_index = codegen.get_name_map_pos(static_cast<const GDParser::IdentifierNode *>(op->arguments[1])->name);
+ set_index = codegen.get_name_map_pos(static_cast<const GDScriptParser::IdentifierNode *>(op->arguments[1])->name);
named = true;
} else {
@@ -951,7 +952,7 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
if (set_index < 0) //error
return set_index;
- if (set_index & GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS) {
+ if (set_index & GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS) {
slevel++;
codegen.alloc_stack(slevel);
}
@@ -960,7 +961,7 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
if (set_value < 0) //error
return set_value;
- codegen.opcodes.push_back(named ? GDFunction::OPCODE_SET_NAMED : GDFunction::OPCODE_SET);
+ codegen.opcodes.push_back(named ? GDScriptFunction::OPCODE_SET_NAMED : GDScriptFunction::OPCODE_SET);
codegen.opcodes.push_back(prev_pos);
codegen.opcodes.push_back(set_index);
codegen.opcodes.push_back(set_value);
@@ -972,7 +973,7 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
return retval;
- } else if (on->arguments[0]->type == GDParser::Node::TYPE_IDENTIFIER && _is_class_member_property(codegen, static_cast<GDParser::IdentifierNode *>(on->arguments[0])->name)) {
+ } else if (on->arguments[0]->type == GDScriptParser::Node::TYPE_IDENTIFIER && _is_class_member_property(codegen, static_cast<GDScriptParser::IdentifierNode *>(on->arguments[0])->name)) {
//assignment to member property
int slevel = p_stack_level;
@@ -981,24 +982,24 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
if (src_address < 0)
return -1;
- StringName name = static_cast<GDParser::IdentifierNode *>(on->arguments[0])->name;
+ StringName name = static_cast<GDScriptParser::IdentifierNode *>(on->arguments[0])->name;
- codegen.opcodes.push_back(GDFunction::OPCODE_SET_MEMBER);
+ codegen.opcodes.push_back(GDScriptFunction::OPCODE_SET_MEMBER);
codegen.opcodes.push_back(codegen.get_name_map_pos(name));
codegen.opcodes.push_back(src_address);
- return GDFunction::ADDR_TYPE_NIL << GDFunction::ADDR_BITS;
+ return GDScriptFunction::ADDR_TYPE_NIL << GDScriptFunction::ADDR_BITS;
} else {
//REGULAR ASSIGNMENT MODE!!
int slevel = p_stack_level;
- int dst_address_a = _parse_expression(codegen, on->arguments[0], slevel, false, on->op == GDParser::OperatorNode::OP_INIT_ASSIGN);
+ int dst_address_a = _parse_expression(codegen, on->arguments[0], slevel, false, on->op == GDScriptParser::OperatorNode::OP_INIT_ASSIGN);
if (dst_address_a < 0)
return -1;
- if (dst_address_a & GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS) {
+ if (dst_address_a & GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS) {
slevel++;
codegen.alloc_stack(slevel);
}
@@ -1007,14 +1008,14 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
if (src_address_b < 0)
return -1;
- codegen.opcodes.push_back(GDFunction::OPCODE_ASSIGN); // perform operator
+ codegen.opcodes.push_back(GDScriptFunction::OPCODE_ASSIGN); // perform operator
codegen.opcodes.push_back(dst_address_a); // argument 1
codegen.opcodes.push_back(src_address_b); // argument 2 (unary only takes one parameter)
return dst_address_a; //if anything, returns wathever was assigned or correct stack position
}
} break;
- case GDParser::OperatorNode::OP_IS: {
+ case GDScriptParser::OperatorNode::OP_IS: {
ERR_FAIL_COND_V(on->arguments.size() != 2, false);
@@ -1024,14 +1025,14 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
if (src_address_a < 0)
return -1;
- if (src_address_a & GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS)
+ if (src_address_a & GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS)
slevel++; //uses stack for return, increase stack
int src_address_b = _parse_expression(codegen, on->arguments[1], slevel);
if (src_address_b < 0)
return -1;
- codegen.opcodes.push_back(GDFunction::OPCODE_EXTENDS_TEST); // perform operator
+ codegen.opcodes.push_back(GDScriptFunction::OPCODE_EXTENDS_TEST); // perform operator
codegen.opcodes.push_back(src_address_a); // argument 1
codegen.opcodes.push_back(src_address_b); // argument 2 (unary only takes one parameter)
@@ -1044,7 +1045,7 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
} break;
}
- int dst_addr = (p_stack_level) | (GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS);
+ int dst_addr = (p_stack_level) | (GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS);
codegen.opcodes.push_back(dst_addr); // append the stack level as destination address of the opcode
codegen.alloc_stack(p_stack_level);
return dst_addr;
@@ -1060,7 +1061,7 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr
ERR_FAIL_V(-1); //unreachable code
}
-Error GDCompiler::_parse_block(CodeGen &codegen, const GDParser::BlockNode *p_block, int p_stack_level, int p_break_addr, int p_continue_addr) {
+Error GDScriptCompiler::_parse_block(CodeGen &codegen, const GDScriptParser::BlockNode *p_block, int p_stack_level, int p_break_addr, int p_continue_addr) {
codegen.push_stack_identifiers();
int new_identifiers = 0;
@@ -1068,28 +1069,28 @@ Error GDCompiler::_parse_block(CodeGen &codegen, const GDParser::BlockNode *p_bl
for (int i = 0; i < p_block->statements.size(); i++) {
- const GDParser::Node *s = p_block->statements[i];
+ const GDScriptParser::Node *s = p_block->statements[i];
switch (s->type) {
- case GDParser::Node::TYPE_NEWLINE: {
+ case GDScriptParser::Node::TYPE_NEWLINE: {
#ifdef DEBUG_ENABLED
- const GDParser::NewLineNode *nl = static_cast<const GDParser::NewLineNode *>(s);
- codegen.opcodes.push_back(GDFunction::OPCODE_LINE);
+ const GDScriptParser::NewLineNode *nl = static_cast<const GDScriptParser::NewLineNode *>(s);
+ codegen.opcodes.push_back(GDScriptFunction::OPCODE_LINE);
codegen.opcodes.push_back(nl->line);
codegen.current_line = nl->line;
#endif
} break;
- case GDParser::Node::TYPE_CONTROL_FLOW: {
+ case GDScriptParser::Node::TYPE_CONTROL_FLOW: {
// try subblocks
- const GDParser::ControlFlowNode *cf = static_cast<const GDParser::ControlFlowNode *>(s);
+ const GDScriptParser::ControlFlowNode *cf = static_cast<const GDScriptParser::ControlFlowNode *>(s);
switch (cf->cf_type) {
- case GDParser::ControlFlowNode::CF_MATCH: {
- GDParser::MatchNode *match = cf->match;
+ case GDScriptParser::ControlFlowNode::CF_MATCH: {
+ GDScriptParser::MatchNode *match = cf->match;
- GDParser::IdentifierNode *id = memnew(GDParser::IdentifierNode);
+ GDScriptParser::IdentifierNode *id = memnew(GDScriptParser::IdentifierNode);
id->name = "#match_value";
// var #match_value
@@ -1098,8 +1099,8 @@ Error GDCompiler::_parse_block(CodeGen &codegen, const GDParser::BlockNode *p_bl
codegen.alloc_stack(p_stack_level);
new_identifiers++;
- GDParser::OperatorNode *op = memnew(GDParser::OperatorNode);
- op->op = GDParser::OperatorNode::OP_ASSIGN;
+ GDScriptParser::OperatorNode *op = memnew(GDScriptParser::OperatorNode);
+ op->op = GDScriptParser::OperatorNode::OP_ASSIGN;
op->arguments.push_back(id);
op->arguments.push_back(match->val_to_match);
@@ -1109,14 +1110,14 @@ Error GDCompiler::_parse_block(CodeGen &codegen, const GDParser::BlockNode *p_bl
}
// break address
- codegen.opcodes.push_back(GDFunction::OPCODE_JUMP);
+ codegen.opcodes.push_back(GDScriptFunction::OPCODE_JUMP);
codegen.opcodes.push_back(codegen.opcodes.size() + 3);
int break_addr = codegen.opcodes.size();
- codegen.opcodes.push_back(GDFunction::OPCODE_JUMP);
+ codegen.opcodes.push_back(GDScriptFunction::OPCODE_JUMP);
codegen.opcodes.push_back(0); // break addr
for (int j = 0; j < match->compiled_pattern_branches.size(); j++) {
- GDParser::MatchNode::CompiledPatternBranch branch = match->compiled_pattern_branches[j];
+ GDScriptParser::MatchNode::CompiledPatternBranch branch = match->compiled_pattern_branches[j];
// jump over continue
// jump unconditionally
@@ -1127,11 +1128,11 @@ Error GDCompiler::_parse_block(CodeGen &codegen, const GDParser::BlockNode *p_bl
return ERR_PARSE_ERROR;
}
- codegen.opcodes.push_back(GDFunction::OPCODE_JUMP_IF);
+ codegen.opcodes.push_back(GDScriptFunction::OPCODE_JUMP_IF);
codegen.opcodes.push_back(ret);
codegen.opcodes.push_back(codegen.opcodes.size() + 3);
int continue_addr = codegen.opcodes.size();
- codegen.opcodes.push_back(GDFunction::OPCODE_JUMP);
+ codegen.opcodes.push_back(GDScriptFunction::OPCODE_JUMP);
codegen.opcodes.push_back(0);
Error err = _parse_block(codegen, branch.body, p_stack_level, p_break_addr, continue_addr);
@@ -1139,7 +1140,7 @@ Error GDCompiler::_parse_block(CodeGen &codegen, const GDParser::BlockNode *p_bl
return ERR_PARSE_ERROR;
}
- codegen.opcodes.push_back(GDFunction::OPCODE_JUMP);
+ codegen.opcodes.push_back(GDScriptFunction::OPCODE_JUMP);
codegen.opcodes.push_back(break_addr);
codegen.opcodes[continue_addr + 1] = codegen.opcodes.size();
@@ -1149,10 +1150,10 @@ Error GDCompiler::_parse_block(CodeGen &codegen, const GDParser::BlockNode *p_bl
} break;
- case GDParser::ControlFlowNode::CF_IF: {
+ case GDScriptParser::ControlFlowNode::CF_IF: {
#ifdef DEBUG_ENABLED
- codegen.opcodes.push_back(GDFunction::OPCODE_LINE);
+ codegen.opcodes.push_back(GDScriptFunction::OPCODE_LINE);
codegen.opcodes.push_back(cf->line);
codegen.current_line = cf->line;
#endif
@@ -1160,7 +1161,7 @@ Error GDCompiler::_parse_block(CodeGen &codegen, const GDParser::BlockNode *p_bl
if (ret < 0)
return ERR_PARSE_ERROR;
- codegen.opcodes.push_back(GDFunction::OPCODE_JUMP_IF_NOT);
+ codegen.opcodes.push_back(GDScriptFunction::OPCODE_JUMP_IF_NOT);
codegen.opcodes.push_back(ret);
int else_addr = codegen.opcodes.size();
codegen.opcodes.push_back(0); //temporary
@@ -1171,7 +1172,7 @@ Error GDCompiler::_parse_block(CodeGen &codegen, const GDParser::BlockNode *p_bl
if (cf->body_else) {
- codegen.opcodes.push_back(GDFunction::OPCODE_JUMP);
+ codegen.opcodes.push_back(GDScriptFunction::OPCODE_JUMP);
int end_addr = codegen.opcodes.size();
codegen.opcodes.push_back(0);
codegen.opcodes[else_addr] = codegen.opcodes.size();
@@ -1187,42 +1188,42 @@ Error GDCompiler::_parse_block(CodeGen &codegen, const GDParser::BlockNode *p_bl
}
} break;
- case GDParser::ControlFlowNode::CF_FOR: {
+ case GDScriptParser::ControlFlowNode::CF_FOR: {
int slevel = p_stack_level;
int iter_stack_pos = slevel;
- int iterator_pos = (slevel++) | (GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS);
- int counter_pos = (slevel++) | (GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS);
- int container_pos = (slevel++) | (GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS);
+ int iterator_pos = (slevel++) | (GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS);
+ int counter_pos = (slevel++) | (GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS);
+ int container_pos = (slevel++) | (GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS);
codegen.alloc_stack(slevel);
codegen.push_stack_identifiers();
- codegen.add_stack_identifier(static_cast<const GDParser::IdentifierNode *>(cf->arguments[0])->name, iter_stack_pos);
+ codegen.add_stack_identifier(static_cast<const GDScriptParser::IdentifierNode *>(cf->arguments[0])->name, iter_stack_pos);
int ret = _parse_expression(codegen, cf->arguments[1], slevel, false);
if (ret < 0)
return ERR_COMPILATION_FAILED;
//assign container
- codegen.opcodes.push_back(GDFunction::OPCODE_ASSIGN);
+ codegen.opcodes.push_back(GDScriptFunction::OPCODE_ASSIGN);
codegen.opcodes.push_back(container_pos);
codegen.opcodes.push_back(ret);
//begin loop
- codegen.opcodes.push_back(GDFunction::OPCODE_ITERATE_BEGIN);
+ codegen.opcodes.push_back(GDScriptFunction::OPCODE_ITERATE_BEGIN);
codegen.opcodes.push_back(counter_pos);
codegen.opcodes.push_back(container_pos);
codegen.opcodes.push_back(codegen.opcodes.size() + 4);
codegen.opcodes.push_back(iterator_pos);
- codegen.opcodes.push_back(GDFunction::OPCODE_JUMP); //skip code for next
+ codegen.opcodes.push_back(GDScriptFunction::OPCODE_JUMP); //skip code for next
codegen.opcodes.push_back(codegen.opcodes.size() + 8);
//break loop
int break_pos = codegen.opcodes.size();
- codegen.opcodes.push_back(GDFunction::OPCODE_JUMP); //skip code for next
+ codegen.opcodes.push_back(GDScriptFunction::OPCODE_JUMP); //skip code for next
codegen.opcodes.push_back(0); //skip code for next
//next loop
int continue_pos = codegen.opcodes.size();
- codegen.opcodes.push_back(GDFunction::OPCODE_ITERATE);
+ codegen.opcodes.push_back(GDScriptFunction::OPCODE_ITERATE);
codegen.opcodes.push_back(counter_pos);
codegen.opcodes.push_back(container_pos);
codegen.opcodes.push_back(break_pos);
@@ -1232,52 +1233,52 @@ Error GDCompiler::_parse_block(CodeGen &codegen, const GDParser::BlockNode *p_bl
if (err)
return err;
- codegen.opcodes.push_back(GDFunction::OPCODE_JUMP);
+ codegen.opcodes.push_back(GDScriptFunction::OPCODE_JUMP);
codegen.opcodes.push_back(continue_pos);
codegen.opcodes[break_pos + 1] = codegen.opcodes.size();
codegen.pop_stack_identifiers();
} break;
- case GDParser::ControlFlowNode::CF_WHILE: {
+ case GDScriptParser::ControlFlowNode::CF_WHILE: {
- codegen.opcodes.push_back(GDFunction::OPCODE_JUMP);
+ codegen.opcodes.push_back(GDScriptFunction::OPCODE_JUMP);
codegen.opcodes.push_back(codegen.opcodes.size() + 3);
int break_addr = codegen.opcodes.size();
- codegen.opcodes.push_back(GDFunction::OPCODE_JUMP);
+ codegen.opcodes.push_back(GDScriptFunction::OPCODE_JUMP);
codegen.opcodes.push_back(0);
int continue_addr = codegen.opcodes.size();
int ret = _parse_expression(codegen, cf->arguments[0], p_stack_level, false);
if (ret < 0)
return ERR_PARSE_ERROR;
- codegen.opcodes.push_back(GDFunction::OPCODE_JUMP_IF_NOT);
+ codegen.opcodes.push_back(GDScriptFunction::OPCODE_JUMP_IF_NOT);
codegen.opcodes.push_back(ret);
codegen.opcodes.push_back(break_addr);
Error err = _parse_block(codegen, cf->body, p_stack_level, break_addr, continue_addr);
if (err)
return err;
- codegen.opcodes.push_back(GDFunction::OPCODE_JUMP);
+ codegen.opcodes.push_back(GDScriptFunction::OPCODE_JUMP);
codegen.opcodes.push_back(continue_addr);
codegen.opcodes[break_addr + 1] = codegen.opcodes.size();
} break;
- case GDParser::ControlFlowNode::CF_SWITCH: {
+ case GDScriptParser::ControlFlowNode::CF_SWITCH: {
} break;
- case GDParser::ControlFlowNode::CF_BREAK: {
+ case GDScriptParser::ControlFlowNode::CF_BREAK: {
if (p_break_addr < 0) {
_set_error("'break'' not within loop", cf);
return ERR_COMPILATION_FAILED;
}
- codegen.opcodes.push_back(GDFunction::OPCODE_JUMP);
+ codegen.opcodes.push_back(GDScriptFunction::OPCODE_JUMP);
codegen.opcodes.push_back(p_break_addr);
} break;
- case GDParser::ControlFlowNode::CF_CONTINUE: {
+ case GDScriptParser::ControlFlowNode::CF_CONTINUE: {
if (p_continue_addr < 0) {
@@ -1285,11 +1286,11 @@ Error GDCompiler::_parse_block(CodeGen &codegen, const GDParser::BlockNode *p_bl
return ERR_COMPILATION_FAILED;
}
- codegen.opcodes.push_back(GDFunction::OPCODE_JUMP);
+ codegen.opcodes.push_back(GDScriptFunction::OPCODE_JUMP);
codegen.opcodes.push_back(p_continue_addr);
} break;
- case GDParser::ControlFlowNode::CF_RETURN: {
+ case GDScriptParser::ControlFlowNode::CF_RETURN: {
int ret;
@@ -1301,38 +1302,38 @@ Error GDCompiler::_parse_block(CodeGen &codegen, const GDParser::BlockNode *p_bl
} else {
- ret = GDFunction::ADDR_TYPE_NIL << GDFunction::ADDR_BITS;
+ ret = GDScriptFunction::ADDR_TYPE_NIL << GDScriptFunction::ADDR_BITS;
}
- codegen.opcodes.push_back(GDFunction::OPCODE_RETURN);
+ codegen.opcodes.push_back(GDScriptFunction::OPCODE_RETURN);
codegen.opcodes.push_back(ret);
} break;
}
} break;
- case GDParser::Node::TYPE_ASSERT: {
+ case GDScriptParser::Node::TYPE_ASSERT: {
#ifdef DEBUG_ENABLED
// try subblocks
- const GDParser::AssertNode *as = static_cast<const GDParser::AssertNode *>(s);
+ const GDScriptParser::AssertNode *as = static_cast<const GDScriptParser::AssertNode *>(s);
int ret = _parse_expression(codegen, as->condition, p_stack_level, false);
if (ret < 0)
return ERR_PARSE_ERROR;
- codegen.opcodes.push_back(GDFunction::OPCODE_ASSERT);
+ codegen.opcodes.push_back(GDScriptFunction::OPCODE_ASSERT);
codegen.opcodes.push_back(ret);
#endif
} break;
- case GDParser::Node::TYPE_BREAKPOINT: {
+ case GDScriptParser::Node::TYPE_BREAKPOINT: {
#ifdef DEBUG_ENABLED
// try subblocks
- codegen.opcodes.push_back(GDFunction::OPCODE_BREAKPOINT);
+ codegen.opcodes.push_back(GDScriptFunction::OPCODE_BREAKPOINT);
#endif
} break;
- case GDParser::Node::TYPE_LOCAL_VAR: {
+ case GDScriptParser::Node::TYPE_LOCAL_VAR: {
- const GDParser::LocalVarNode *lv = static_cast<const GDParser::LocalVarNode *>(s);
+ const GDScriptParser::LocalVarNode *lv = static_cast<const GDScriptParser::LocalVarNode *>(s);
if (_is_class_member_property(codegen, lv->name)) {
_set_error("Name for local variable '" + String(lv->name) + "' can't shadow class property of the same name.", lv);
@@ -1356,7 +1357,7 @@ Error GDCompiler::_parse_block(CodeGen &codegen, const GDParser::BlockNode *p_bl
return OK;
}
-Error GDCompiler::_parse_function(GDScript *p_script, const GDParser::ClassNode *p_class, const GDParser::FunctionNode *p_func, bool p_for_ready) {
+Error GDScriptCompiler::_parse_function(GDScript *p_script, const GDScriptParser::ClassNode *p_class, const GDScriptParser::FunctionNode *p_func, bool p_for_ready) {
Vector<int> bytecode;
CodeGen codegen;
@@ -1397,10 +1398,10 @@ Error GDCompiler::_parse_function(GDScript *p_script, const GDParser::ClassNode
if (!p_func && p_class->extends_used && p_script->native.is_null()) {
//call implicit parent constructor
- codegen.opcodes.push_back(GDFunction::OPCODE_CALL_SELF_BASE);
+ codegen.opcodes.push_back(GDScriptFunction::OPCODE_CALL_SELF_BASE);
codegen.opcodes.push_back(codegen.get_name_map_pos("_init"));
codegen.opcodes.push_back(0);
- codegen.opcodes.push_back((GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS) | 0);
+ codegen.opcodes.push_back((GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS) | 0);
}
Error err = _parse_block(codegen, p_class->initializer, stack_level);
if (err)
@@ -1426,7 +1427,7 @@ Error GDCompiler::_parse_function(GDScript *p_script, const GDParser::ClassNode
if (p_func->default_values.size()) {
- codegen.opcodes.push_back(GDFunction::OPCODE_JUMP_TO_DEF_ARGUMENT);
+ codegen.opcodes.push_back(GDScriptFunction::OPCODE_JUMP_TO_DEF_ARGUMENT);
defarg_addr.push_back(codegen.opcodes.size());
for (int i = 0; i < p_func->default_values.size(); i++) {
@@ -1449,15 +1450,15 @@ Error GDCompiler::_parse_function(GDScript *p_script, const GDParser::ClassNode
func_name = "_init";
}
- codegen.opcodes.push_back(GDFunction::OPCODE_END);
+ codegen.opcodes.push_back(GDScriptFunction::OPCODE_END);
/*
if (String(p_func->name)=="") { //initializer func
gdfunc = &p_script->initializer;
*/
//} else { //regular func
- p_script->member_functions[func_name] = memnew(GDFunction);
- GDFunction *gdfunc = p_script->member_functions[func_name];
+ p_script->member_functions[func_name] = memnew(GDScriptFunction);
+ GDScriptFunction *gdfunc = p_script->member_functions[func_name];
//}
if (p_func) {
@@ -1579,7 +1580,7 @@ Error GDCompiler::_parse_function(GDScript *p_script, const GDParser::ClassNode
return OK;
}
-Error GDCompiler::_parse_class(GDScript *p_script, GDScript *p_owner, const GDParser::ClassNode *p_class, bool p_keep_state) {
+Error GDScriptCompiler::_parse_class(GDScript *p_script, GDScript *p_owner, const GDScriptParser::ClassNode *p_class, bool p_keep_state) {
Map<StringName, Ref<GDScript> > old_subclasses;
@@ -1587,12 +1588,12 @@ Error GDCompiler::_parse_class(GDScript *p_script, GDScript *p_owner, const GDPa
old_subclasses = p_script->subclasses;
}
- p_script->native = Ref<GDNativeClass>();
+ p_script->native = Ref<GDScriptNativeClass>();
p_script->base = Ref<GDScript>();
p_script->_base = NULL;
p_script->members.clear();
p_script->constants.clear();
- for (Map<StringName, GDFunction *>::Element *E = p_script->member_functions.front(); E; E = E->next()) {
+ for (Map<StringName, GDScriptFunction *>::Element *E = p_script->member_functions.front(); E; E = E->next()) {
memdelete(E->get());
}
p_script->member_functions.clear();
@@ -1606,7 +1607,7 @@ Error GDCompiler::_parse_class(GDScript *p_script, GDScript *p_owner, const GDPa
p_script->tool = p_class->tool;
p_script->name = p_class->name;
- Ref<GDNativeClass> native;
+ Ref<GDScriptNativeClass> native;
if (p_class->extends_used) {
//do inheritance
@@ -1801,14 +1802,14 @@ Error GDCompiler::_parse_class(GDScript *p_script, GDScript *p_owner, const GDPa
for (int i = 0; i < p_class->constant_expressions.size(); i++) {
StringName name = p_class->constant_expressions[i].identifier;
- ERR_CONTINUE(p_class->constant_expressions[i].expression->type != GDParser::Node::TYPE_CONSTANT);
+ ERR_CONTINUE(p_class->constant_expressions[i].expression->type != GDScriptParser::Node::TYPE_CONSTANT);
if (_is_class_member_property(p_script, name)) {
_set_error("Member '" + name + "' already exists as a class property.", p_class);
return ERR_ALREADY_EXISTS;
}
- GDParser::ConstantNode *constant = static_cast<GDParser::ConstantNode *>(p_class->constant_expressions[i].expression);
+ GDScriptParser::ConstantNode *constant = static_cast<GDScriptParser::ConstantNode *>(p_class->constant_expressions[i].expression);
p_script->constants.insert(name, constant->value);
//p_script->constants[constant->value].make_const();
@@ -1917,7 +1918,7 @@ Error GDCompiler::_parse_class(GDScript *p_script, GDScript *p_owner, const GDPa
for (int i = 0; i < p_class->variables.size(); i++) {
if (p_class->variables[i].setter) {
- const Map<StringName, GDFunction *>::Element *E = p_script->get_member_functions().find(p_class->variables[i].setter);
+ const Map<StringName, GDScriptFunction *>::Element *E = p_script->get_member_functions().find(p_class->variables[i].setter);
if (!E) {
_set_error("Setter function '" + String(p_class->variables[i].setter) + "' not found in class.", NULL);
err_line = p_class->variables[i].line;
@@ -1934,7 +1935,7 @@ Error GDCompiler::_parse_class(GDScript *p_script, GDScript *p_owner, const GDPa
}
}
if (p_class->variables[i].getter) {
- const Map<StringName, GDFunction *>::Element *E = p_script->get_member_functions().find(p_class->variables[i].getter);
+ const Map<StringName, GDScriptFunction *>::Element *E = p_script->get_member_functions().find(p_class->variables[i].getter);
if (!E) {
_set_error("Getter function '" + String(p_class->variables[i].getter) + "' not found in class.", NULL);
err_line = p_class->variables[i].line;
@@ -1970,7 +1971,7 @@ Error GDCompiler::_parse_class(GDScript *p_script, GDScript *p_owner, const GDPa
//re-create as an instance
p_script->placeholders.erase(psi); //remove placeholder
- GDInstance *instance = memnew(GDInstance);
+ GDScriptInstance *instance = memnew(GDScriptInstance);
instance->base_ref = Object::cast_to<Reference>(E->get());
instance->members.resize(p_script->member_indices.size());
instance->script = Ref<GDScript>(p_script);
@@ -1994,7 +1995,7 @@ Error GDCompiler::_parse_class(GDScript *p_script, GDScript *p_owner, const GDPa
#endif
} else {
- GDInstance *gi = static_cast<GDInstance *>(si);
+ GDScriptInstance *gi = static_cast<GDScriptInstance *>(si);
gi->reload_members();
}
@@ -2007,18 +2008,18 @@ Error GDCompiler::_parse_class(GDScript *p_script, GDScript *p_owner, const GDPa
return OK;
}
-Error GDCompiler::compile(const GDParser *p_parser, GDScript *p_script, bool p_keep_state) {
+Error GDScriptCompiler::compile(const GDScriptParser *p_parser, GDScript *p_script, bool p_keep_state) {
err_line = -1;
err_column = -1;
error = "";
parser = p_parser;
- const GDParser::Node *root = parser->get_parse_tree();
- ERR_FAIL_COND_V(root->type != GDParser::Node::TYPE_CLASS, ERR_INVALID_DATA);
+ const GDScriptParser::Node *root = parser->get_parse_tree();
+ ERR_FAIL_COND_V(root->type != GDScriptParser::Node::TYPE_CLASS, ERR_INVALID_DATA);
source = p_script->get_path();
- Error err = _parse_class(p_script, NULL, static_cast<const GDParser::ClassNode *>(root), p_keep_state);
+ Error err = _parse_class(p_script, NULL, static_cast<const GDScriptParser::ClassNode *>(root), p_keep_state);
if (err)
return err;
@@ -2026,18 +2027,18 @@ Error GDCompiler::compile(const GDParser *p_parser, GDScript *p_script, bool p_k
return OK;
}
-String GDCompiler::get_error() const {
+String GDScriptCompiler::get_error() const {
return error;
}
-int GDCompiler::get_error_line() const {
+int GDScriptCompiler::get_error_line() const {
return err_line;
}
-int GDCompiler::get_error_column() const {
+int GDScriptCompiler::get_error_column() const {
return err_column;
}
-GDCompiler::GDCompiler() {
+GDScriptCompiler::GDScriptCompiler() {
}
diff --git a/modules/gdscript/gd_compiler.h b/modules/gdscript/gdscript_compiler.h
index ac713ae75b..6e0457ba30 100644
--- a/modules/gdscript/gd_compiler.h
+++ b/modules/gdscript/gdscript_compiler.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* gd_compiler.h */
+/* gdscript_compiler.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -27,26 +27,26 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef GD_COMPILER_H
-#define GD_COMPILER_H
+#ifndef GDSCRIPT_COMPILER_H
+#define GDSCRIPT_COMPILER_H
-#include "gd_parser.h"
-#include "gd_script.h"
+#include "gdscript.h"
+#include "gdscript_parser.h"
-class GDCompiler {
+class GDScriptCompiler {
- const GDParser *parser;
+ const GDScriptParser *parser;
struct CodeGen {
GDScript *script;
- const GDParser::ClassNode *class_node;
- const GDParser::FunctionNode *function_node;
+ const GDScriptParser::ClassNode *class_node;
+ const GDScriptParser::FunctionNode *function_node;
bool debug_stack;
List<Map<StringName, int> > stack_id_stack;
Map<StringName, int> stack_identifiers;
- List<GDFunction::StackDebug> stack_debug;
+ List<GDScriptFunction::StackDebug> stack_debug;
List<Map<StringName, int> > block_identifier_stack;
Map<StringName, int> block_identifiers;
@@ -54,7 +54,7 @@ class GDCompiler {
stack_identifiers[p_id] = p_stackpos;
if (debug_stack) {
block_identifiers[p_id] = p_stackpos;
- GDFunction::StackDebug sd;
+ GDScriptFunction::StackDebug sd;
sd.added = true;
sd.line = current_line;
sd.identifier = p_id;
@@ -79,7 +79,7 @@ class GDCompiler {
if (debug_stack) {
for (Map<StringName, int>::Element *E = block_identifiers.front(); E; E = E->next()) {
- GDFunction::StackDebug sd;
+ GDScriptFunction::StackDebug sd;
sd.added = false;
sd.identifier = E->key();
sd.line = current_line;
@@ -129,29 +129,29 @@ class GDCompiler {
bool _is_class_member_property(CodeGen &codegen, const StringName &p_name);
bool _is_class_member_property(GDScript *owner, const StringName &p_name);
- void _set_error(const String &p_error, const GDParser::Node *p_node);
+ void _set_error(const String &p_error, const GDScriptParser::Node *p_node);
- 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);
+ bool _create_unary_operator(CodeGen &codegen, const GDScriptParser::OperatorNode *on, Variant::Operator op, int p_stack_level);
+ bool _create_binary_operator(CodeGen &codegen, const GDScriptParser::OperatorNode *on, Variant::Operator op, int p_stack_level, bool p_initializer = false);
- 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);
- Error _parse_function(GDScript *p_script, const GDParser::ClassNode *p_class, const GDParser::FunctionNode *p_func, bool p_for_ready = false);
- Error _parse_class(GDScript *p_script, GDScript *p_owner, const GDParser::ClassNode *p_class, bool p_keep_state);
+ int _parse_assign_right_expression(CodeGen &codegen, const GDScriptParser::OperatorNode *p_expression, int p_stack_level);
+ int _parse_expression(CodeGen &codegen, const GDScriptParser::Node *p_expression, int p_stack_level, bool p_root = false, bool p_initializer = false);
+ Error _parse_block(CodeGen &codegen, const GDScriptParser::BlockNode *p_block, int p_stack_level = 0, int p_break_addr = -1, int p_continue_addr = -1);
+ Error _parse_function(GDScript *p_script, const GDScriptParser::ClassNode *p_class, const GDScriptParser::FunctionNode *p_func, bool p_for_ready = false);
+ Error _parse_class(GDScript *p_script, GDScript *p_owner, const GDScriptParser::ClassNode *p_class, bool p_keep_state);
int err_line;
int err_column;
StringName source;
String error;
public:
- Error compile(const GDParser *p_parser, GDScript *p_script, bool p_keep_state = false);
+ Error compile(const GDScriptParser *p_parser, GDScript *p_script, bool p_keep_state = false);
String get_error() const;
int get_error_line() const;
int get_error_column() const;
- GDCompiler();
+ GDScriptCompiler();
};
-#endif // COMPILER_H
+#endif // GDSCRIPT_COMPILER_H
diff --git a/modules/gdscript/gd_editor.cpp b/modules/gdscript/gdscript_editor.cpp
index 9b7201f5f7..a74b8a8483 100644
--- a/modules/gdscript/gd_editor.cpp
+++ b/modules/gdscript/gdscript_editor.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* gd_editor.cpp */
+/* gdscript_editor.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -27,10 +27,10 @@
/* 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 "gdscript.h"
#include "editor/editor_settings.h"
-#include "gd_compiler.h"
+#include "gdscript_compiler.h"
#include "global_constants.h"
#include "os/file_access.h"
#include "project_settings.h"
@@ -92,7 +92,7 @@ void GDScriptLanguage::make_template(const String &p_class_name, const String &p
bool GDScriptLanguage::validate(const String &p_script, int &r_line_error, int &r_col_error, String &r_test_error, const String &p_path, List<String> *r_functions) const {
- GDParser parser;
+ GDScriptParser parser;
Error err = parser.parse(p_script, p_path.get_base_dir(), true, p_path);
if (err) {
@@ -102,10 +102,10 @@ bool GDScriptLanguage::validate(const String &p_script, int &r_line_error, int &
return false;
} else {
- const GDParser::Node *root = parser.get_parse_tree();
- ERR_FAIL_COND_V(root->type != GDParser::Node::TYPE_CLASS, false);
+ const GDScriptParser::Node *root = parser.get_parse_tree();
+ ERR_FAIL_COND_V(root->type != GDScriptParser::Node::TYPE_CLASS, false);
- const GDParser::ClassNode *cl = static_cast<const GDParser::ClassNode *>(root);
+ const GDScriptParser::ClassNode *cl = static_cast<const GDScriptParser::ClassNode *>(root);
Map<int, String> funcs;
for (int i = 0; i < cl->functions.size(); i++) {
@@ -138,16 +138,16 @@ bool GDScriptLanguage::supports_builtin_mode() const {
int GDScriptLanguage::find_function(const String &p_function, const String &p_code) const {
- GDTokenizerText tokenizer;
+ GDScriptTokenizerText tokenizer;
tokenizer.set_code(p_code);
int indent = 0;
- while (tokenizer.get_token() != GDTokenizer::TK_EOF && tokenizer.get_token() != GDTokenizer::TK_ERROR) {
+ while (tokenizer.get_token() != GDScriptTokenizer::TK_EOF && tokenizer.get_token() != GDScriptTokenizer::TK_ERROR) {
- if (tokenizer.get_token() == GDTokenizer::TK_NEWLINE) {
+ if (tokenizer.get_token() == GDScriptTokenizer::TK_NEWLINE) {
indent = tokenizer.get_token_line_indent();
}
- //print_line("TOKEN: "+String(GDTokenizer::get_token_name(tokenizer.get_token())));
- if (indent == 0 && tokenizer.get_token() == GDTokenizer::TK_PR_FUNCTION && tokenizer.get_token(1) == GDTokenizer::TK_IDENTIFIER) {
+ //print_line("TOKEN: "+String(GDScriptTokenizer::get_token_name(tokenizer.get_token())));
+ if (indent == 0 && tokenizer.get_token() == GDScriptTokenizer::TK_PR_FUNCTION && tokenizer.get_token(1) == GDScriptTokenizer::TK_IDENTIFIER) {
String identifier = tokenizer.get_token_identifier(1);
if (identifier == p_function) {
@@ -155,7 +155,7 @@ int GDScriptLanguage::find_function(const String &p_function, const String &p_co
}
}
tokenizer.advance();
- //print_line("NEXT: "+String(GDTokenizer::get_token_name(tokenizer.get_token())));
+ //print_line("NEXT: "+String(GDScriptTokenizer::get_token_name(tokenizer.get_token())));
}
return -1;
}
@@ -245,7 +245,7 @@ void GDScriptLanguage::debug_get_stack_level_locals(int p_level, List<String> *p
ERR_FAIL_INDEX(p_level, _debug_call_stack_pos);
int l = _debug_call_stack_pos - p_level - 1;
- GDFunction *f = _call_stack[l].function;
+ GDScriptFunction *f = _call_stack[l].function;
List<Pair<StringName, int> > locals;
@@ -264,7 +264,7 @@ void GDScriptLanguage::debug_get_stack_level_members(int p_level, List<String> *
ERR_FAIL_INDEX(p_level, _debug_call_stack_pos);
int l = _debug_call_stack_pos - p_level - 1;
- GDInstance *instance = _call_stack[l].instance;
+ GDScriptInstance *instance = _call_stack[l].instance;
if (!instance)
return;
@@ -298,9 +298,9 @@ void GDScriptLanguage::get_recognized_extensions(List<String> *p_extensions) con
void GDScriptLanguage::get_public_functions(List<MethodInfo> *p_functions) const {
- for (int i = 0; i < GDFunctions::FUNC_MAX; i++) {
+ for (int i = 0; i < GDScriptFunctions::FUNC_MAX; i++) {
- p_functions->push_back(GDFunctions::get_info(GDFunctions::Function(i)));
+ p_functions->push_back(GDScriptFunctions::get_info(GDScriptFunctions::Function(i)));
}
//not really "functions", but..
@@ -318,7 +318,7 @@ void GDScriptLanguage::get_public_functions(List<MethodInfo> *p_functions) const
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");
+ mi.return_val = PropertyInfo(Variant::OBJECT, "", PROPERTY_HINT_RESOURCE_TYPE, "GDScriptFunctionState");
p_functions->push_back(mi);
}
{
@@ -372,7 +372,7 @@ String GDScriptLanguage::make_function(const String &p_class, const String &p_na
#if defined(DEBUG_METHODS_ENABLED) && defined(TOOLS_ENABLED)
-struct GDCompletionIdentifier {
+struct GDScriptCompletionIdentifier {
String enumeration;
StringName obj_type;
@@ -381,17 +381,17 @@ struct GDCompletionIdentifier {
Variant value; //im case there is a value, also return it
};
-static GDCompletionIdentifier _get_type_from_variant(const Variant &p_variant, bool p_allow_gdnative_class = false) {
+static GDScriptCompletionIdentifier _get_type_from_variant(const Variant &p_variant, bool p_allow_gdnative_class = false) {
- GDCompletionIdentifier t;
+ GDScriptCompletionIdentifier t;
t.type = p_variant.get_type();
t.value = p_variant;
if (p_variant.get_type() == Variant::OBJECT) {
Object *obj = p_variant;
if (obj) {
- if (p_allow_gdnative_class && Object::cast_to<GDNativeClass>(obj)) {
- t.obj_type = Object::cast_to<GDNativeClass>(obj)->get_name();
+ if (p_allow_gdnative_class && Object::cast_to<GDScriptNativeClass>(obj)) {
+ t.obj_type = Object::cast_to<GDScriptNativeClass>(obj)->get_name();
t.value = Variant();
} else {
@@ -402,9 +402,9 @@ static GDCompletionIdentifier _get_type_from_variant(const Variant &p_variant, b
return t;
}
-static GDCompletionIdentifier _get_type_from_pinfo(const PropertyInfo &p_info) {
+static GDScriptCompletionIdentifier _get_type_from_pinfo(const PropertyInfo &p_info) {
- GDCompletionIdentifier t;
+ GDScriptCompletionIdentifier t;
t.type = p_info.type;
if (p_info.hint == PROPERTY_HINT_RESOURCE_TYPE) {
t.obj_type = p_info.hint_string;
@@ -412,23 +412,23 @@ static GDCompletionIdentifier _get_type_from_pinfo(const PropertyInfo &p_info) {
return t;
}
-struct GDCompletionContext {
+struct GDScriptCompletionContext {
- const GDParser::ClassNode *_class;
- const GDParser::FunctionNode *function;
- const GDParser::BlockNode *block;
+ const GDScriptParser::ClassNode *_class;
+ const GDScriptParser::FunctionNode *function;
+ const GDScriptParser::BlockNode *block;
Object *base;
String base_path;
};
-static Ref<Reference> _get_parent_class(GDCompletionContext &context) {
+static Ref<Reference> _get_parent_class(GDScriptCompletionContext &context) {
if (context._class->extends_used) {
//do inheritance
String path = context._class->extends_file;
Ref<GDScript> script;
- Ref<GDNativeClass> native;
+ Ref<GDScriptNativeClass> native;
if (path != "") {
//path (and optionally subclasses)
@@ -498,17 +498,17 @@ static Ref<Reference> _get_parent_class(GDCompletionContext &context) {
return Ref<Reference>();
}
-static GDCompletionIdentifier _get_native_class(GDCompletionContext &context) {
+static GDScriptCompletionIdentifier _get_native_class(GDScriptCompletionContext &context) {
//eeh...
- GDCompletionIdentifier id;
+ GDScriptCompletionIdentifier id;
id.type = Variant::NIL;
REF pc = _get_parent_class(context);
if (!pc.is_valid()) {
return id;
}
- Ref<GDNativeClass> nc = pc;
+ Ref<GDScriptNativeClass> nc = pc;
Ref<GDScript> s = pc;
if (s.is_null() && nc.is_null()) {
@@ -529,28 +529,28 @@ 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, bool p_for_indexing);
+static bool _guess_identifier_type(GDScriptCompletionContext &context, int p_line, const StringName &p_identifier, GDScriptCompletionIdentifier &r_type, bool p_for_indexing);
-static bool _guess_expression_type(GDCompletionContext &context, const GDParser::Node *p_node, int p_line, GDCompletionIdentifier &r_type, bool p_for_indexing = false) {
+static bool _guess_expression_type(GDScriptCompletionContext &context, const GDScriptParser::Node *p_node, int p_line, GDScriptCompletionIdentifier &r_type, bool p_for_indexing = false) {
- if (p_node->type == GDParser::Node::TYPE_CONSTANT) {
+ if (p_node->type == GDScriptParser::Node::TYPE_CONSTANT) {
- const GDParser::ConstantNode *cn = static_cast<const GDParser::ConstantNode *>(p_node);
+ const GDScriptParser::ConstantNode *cn = static_cast<const GDScriptParser::ConstantNode *>(p_node);
r_type = _get_type_from_variant(cn->value);
return true;
- } else if (p_node->type == GDParser::Node::TYPE_DICTIONARY) {
+ } else if (p_node->type == GDScriptParser::Node::TYPE_DICTIONARY) {
r_type.type = Variant::DICTIONARY;
//what the heck, fill it anyway
- const GDParser::DictionaryNode *an = static_cast<const GDParser::DictionaryNode *>(p_node);
+ const GDScriptParser::DictionaryNode *an = static_cast<const GDScriptParser::DictionaryNode *>(p_node);
Dictionary d;
for (int i = 0; i < an->elements.size(); i++) {
- GDCompletionIdentifier k;
+ GDScriptCompletionIdentifier k;
if (_guess_expression_type(context, an->elements[i].key, p_line, k) && k.value.get_type() != Variant::NIL) {
- GDCompletionIdentifier v;
+ GDScriptCompletionIdentifier v;
if (_guess_expression_type(context, an->elements[i].value, p_line, v)) {
d[k.value] = v.value;
}
@@ -558,15 +558,15 @@ static bool _guess_expression_type(GDCompletionContext &context, const GDParser:
}
r_type.value = d;
return true;
- } else if (p_node->type == GDParser::Node::TYPE_ARRAY) {
+ } else if (p_node->type == GDScriptParser::Node::TYPE_ARRAY) {
r_type.type = Variant::ARRAY;
//what the heck, fill it anyway
- const GDParser::ArrayNode *an = static_cast<const GDParser::ArrayNode *>(p_node);
+ const GDScriptParser::ArrayNode *an = static_cast<const GDScriptParser::ArrayNode *>(p_node);
Array arr;
arr.resize(an->elements.size());
for (int i = 0; i < an->elements.size(); i++) {
- GDCompletionIdentifier ci;
+ GDScriptCompletionIdentifier ci;
if (_guess_expression_type(context, an->elements[i], p_line, ci)) {
arr[i] = ci.value;
}
@@ -574,44 +574,44 @@ static bool _guess_expression_type(GDCompletionContext &context, const GDParser:
r_type.value = arr;
return true;
- } else if (p_node->type == GDParser::Node::TYPE_BUILT_IN_FUNCTION) {
+ } else if (p_node->type == GDScriptParser::Node::TYPE_BUILT_IN_FUNCTION) {
- MethodInfo mi = GDFunctions::get_info(static_cast<const GDParser::BuiltInFunctionNode *>(p_node)->function);
+ MethodInfo mi = GDScriptFunctions::get_info(static_cast<const GDScriptParser::BuiltInFunctionNode *>(p_node)->function);
r_type = _get_type_from_pinfo(mi.return_val);
return true;
- } else if (p_node->type == GDParser::Node::TYPE_IDENTIFIER) {
+ } else if (p_node->type == GDScriptParser::Node::TYPE_IDENTIFIER) {
- 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) {
+ return _guess_identifier_type(context, p_line - 1, static_cast<const GDScriptParser::IdentifierNode *>(p_node)->name, r_type, p_for_indexing);
+ } else if (p_node->type == GDScriptParser::Node::TYPE_SELF) {
//eeh...
r_type = _get_native_class(context);
return r_type.type != Variant::NIL;
- } else if (p_node->type == GDParser::Node::TYPE_OPERATOR) {
+ } else if (p_node->type == GDScriptParser::Node::TYPE_OPERATOR) {
- const GDParser::OperatorNode *op = static_cast<const GDParser::OperatorNode *>(p_node);
- if (op->op == GDParser::OperatorNode::OP_CALL) {
+ const GDScriptParser::OperatorNode *op = static_cast<const GDScriptParser::OperatorNode *>(p_node);
+ if (op->op == GDScriptParser::OperatorNode::OP_CALL) {
- if (op->arguments[0]->type == GDParser::Node::TYPE_TYPE) {
+ if (op->arguments[0]->type == GDScriptParser::Node::TYPE_TYPE) {
- const GDParser::TypeNode *tn = static_cast<const GDParser::TypeNode *>(op->arguments[0]);
+ const GDScriptParser::TypeNode *tn = static_cast<const GDScriptParser::TypeNode *>(op->arguments[0]);
r_type.type = tn->vtype;
return true;
- } else if (op->arguments[0]->type == GDParser::Node::TYPE_BUILT_IN_FUNCTION) {
+ } else if (op->arguments[0]->type == GDScriptParser::Node::TYPE_BUILT_IN_FUNCTION) {
- const GDParser::BuiltInFunctionNode *bin = static_cast<const GDParser::BuiltInFunctionNode *>(op->arguments[0]);
+ const GDScriptParser::BuiltInFunctionNode *bin = static_cast<const GDScriptParser::BuiltInFunctionNode *>(op->arguments[0]);
return _guess_expression_type(context, bin, p_line, r_type);
- } else if (op->arguments.size() > 1 && op->arguments[1]->type == GDParser::Node::TYPE_IDENTIFIER) {
+ } else if (op->arguments.size() > 1 && op->arguments[1]->type == GDScriptParser::Node::TYPE_IDENTIFIER) {
- StringName id = static_cast<const GDParser::IdentifierNode *>(op->arguments[1])->name;
+ StringName id = static_cast<const GDScriptParser::IdentifierNode *>(op->arguments[1])->name;
- if (op->arguments[0]->type == GDParser::Node::TYPE_IDENTIFIER && String(id) == "new") {
+ if (op->arguments[0]->type == GDScriptParser::Node::TYPE_IDENTIFIER && String(id) == "new") {
//shortcut
- StringName identifier = static_cast<const GDParser::IdentifierNode *>(op->arguments[0])->name;
+ StringName identifier = static_cast<const GDScriptParser::IdentifierNode *>(op->arguments[0])->name;
if (ClassDB::class_exists(identifier)) {
r_type.type = Variant::OBJECT;
@@ -621,7 +621,7 @@ static bool _guess_expression_type(GDCompletionContext &context, const GDParser:
}
}
- GDCompletionIdentifier base;
+ GDScriptCompletionIdentifier base;
if (!_guess_expression_type(context, op->arguments[0], p_line, base))
return false;
@@ -630,8 +630,8 @@ static bool _guess_expression_type(GDCompletionContext &context, const GDParser:
if (id.operator String() == "new" && base.value.get_type() == Variant::OBJECT) {
Object *obj = base.value;
- if (obj && Object::cast_to<GDNativeClass>(obj)) {
- GDNativeClass *gdnc = Object::cast_to<GDNativeClass>(obj);
+ if (obj && Object::cast_to<GDScriptNativeClass>(obj)) {
+ GDScriptNativeClass *gdnc = Object::cast_to<GDScriptNativeClass>(obj);
r_type.type = Variant::OBJECT;
r_type.value = Variant();
r_type.obj_type = gdnc->get_name();
@@ -662,7 +662,7 @@ static bool _guess_expression_type(GDCompletionContext &context, const GDParser:
bool all_valid = true;
Vector<Variant> args;
for (int i = 2; i < op->arguments.size(); i++) {
- GDCompletionIdentifier arg;
+ GDScriptCompletionIdentifier arg;
if (_guess_expression_type(context, op->arguments[i], p_line, arg)) {
if (arg.value.get_type() != Variant::NIL && arg.value.get_type() != Variant::OBJECT) { // calling with object seems dangerous, i don' t know
@@ -785,15 +785,15 @@ static bool _guess_expression_type(GDCompletionContext &context, const GDParser:
}
}
}
- } else if (op->op == GDParser::OperatorNode::OP_INDEX || op->op == GDParser::OperatorNode::OP_INDEX_NAMED) {
+ } else if (op->op == GDScriptParser::OperatorNode::OP_INDEX || op->op == GDScriptParser::OperatorNode::OP_INDEX_NAMED) {
- GDCompletionIdentifier p1;
- GDCompletionIdentifier p2;
+ GDScriptCompletionIdentifier p1;
+ GDScriptCompletionIdentifier p2;
- if (op->op == GDParser::OperatorNode::OP_INDEX_NAMED) {
+ if (op->op == GDScriptParser::OperatorNode::OP_INDEX_NAMED) {
- if (op->arguments[1]->type == GDParser::Node::TYPE_IDENTIFIER) {
- String id = static_cast<const GDParser::IdentifierNode *>(op->arguments[1])->name;
+ if (op->arguments[1]->type == GDScriptParser::Node::TYPE_IDENTIFIER) {
+ String id = static_cast<const GDScriptParser::IdentifierNode *>(op->arguments[1])->name;
p2.type = Variant::STRING;
p2.value = id;
}
@@ -807,9 +807,9 @@ static bool _guess_expression_type(GDCompletionContext &context, const GDParser:
}
}
- if (op->arguments[0]->type == GDParser::Node::TYPE_ARRAY) {
+ if (op->arguments[0]->type == GDScriptParser::Node::TYPE_ARRAY) {
- const GDParser::ArrayNode *an = static_cast<const GDParser::ArrayNode *>(op->arguments[0]);
+ const GDScriptParser::ArrayNode *an = static_cast<const GDScriptParser::ArrayNode *>(op->arguments[0]);
if (p2.value.is_num()) {
int index = p2.value;
if (index < 0 || index >= an->elements.size())
@@ -817,16 +817,16 @@ static bool _guess_expression_type(GDCompletionContext &context, const GDParser:
return _guess_expression_type(context, an->elements[index], p_line, r_type);
}
- } else if (op->arguments[0]->type == GDParser::Node::TYPE_DICTIONARY) {
+ } else if (op->arguments[0]->type == GDScriptParser::Node::TYPE_DICTIONARY) {
- const GDParser::DictionaryNode *dn = static_cast<const GDParser::DictionaryNode *>(op->arguments[0]);
+ const GDScriptParser::DictionaryNode *dn = static_cast<const GDScriptParser::DictionaryNode *>(op->arguments[0]);
if (p2.value.get_type() == Variant::NIL)
return false;
for (int i = 0; i < dn->elements.size(); i++) {
- GDCompletionIdentifier k;
+ GDScriptCompletionIdentifier k;
if (!_guess_expression_type(context, dn->elements[i].key, p_line, k)) {
@@ -858,9 +858,9 @@ static bool _guess_expression_type(GDCompletionContext &context, const GDParser:
StringName base_type = p1.obj_type;
- if (p1.obj_type == "GDNativeClass") {
+ if (p1.obj_type == "GDScriptNativeClass") {
//native enum
- Ref<GDNativeClass> gdn = p1.value;
+ Ref<GDScriptNativeClass> gdn = p1.value;
if (gdn.is_valid()) {
base_type = gdn->get_name();
@@ -921,24 +921,24 @@ static bool _guess_expression_type(GDCompletionContext &context, const GDParser:
Variant::Operator vop = Variant::OP_MAX;
switch (op->op) {
- case GDParser::OperatorNode::OP_ADD: vop = Variant::OP_ADD; break;
- case GDParser::OperatorNode::OP_SUB: vop = Variant::OP_SUBTRACT; break;
- case GDParser::OperatorNode::OP_MUL: vop = Variant::OP_MULTIPLY; break;
- case GDParser::OperatorNode::OP_DIV: vop = Variant::OP_DIVIDE; break;
- case GDParser::OperatorNode::OP_MOD: vop = Variant::OP_MODULE; break;
- case GDParser::OperatorNode::OP_SHIFT_LEFT: vop = Variant::OP_SHIFT_LEFT; break;
- case GDParser::OperatorNode::OP_SHIFT_RIGHT: vop = Variant::OP_SHIFT_RIGHT; break;
- case GDParser::OperatorNode::OP_BIT_AND: vop = Variant::OP_BIT_AND; break;
- case GDParser::OperatorNode::OP_BIT_OR: vop = Variant::OP_BIT_OR; break;
- case GDParser::OperatorNode::OP_BIT_XOR: vop = Variant::OP_BIT_XOR; break;
+ case GDScriptParser::OperatorNode::OP_ADD: vop = Variant::OP_ADD; break;
+ case GDScriptParser::OperatorNode::OP_SUB: vop = Variant::OP_SUBTRACT; break;
+ case GDScriptParser::OperatorNode::OP_MUL: vop = Variant::OP_MULTIPLY; break;
+ case GDScriptParser::OperatorNode::OP_DIV: vop = Variant::OP_DIVIDE; break;
+ case GDScriptParser::OperatorNode::OP_MOD: vop = Variant::OP_MODULE; break;
+ case GDScriptParser::OperatorNode::OP_SHIFT_LEFT: vop = Variant::OP_SHIFT_LEFT; break;
+ case GDScriptParser::OperatorNode::OP_SHIFT_RIGHT: vop = Variant::OP_SHIFT_RIGHT; break;
+ case GDScriptParser::OperatorNode::OP_BIT_AND: vop = Variant::OP_BIT_AND; break;
+ case GDScriptParser::OperatorNode::OP_BIT_OR: vop = Variant::OP_BIT_OR; break;
+ case GDScriptParser::OperatorNode::OP_BIT_XOR: vop = Variant::OP_BIT_XOR; break;
default: {}
}
if (vop == Variant::OP_MAX)
return false;
- GDCompletionIdentifier p1;
- GDCompletionIdentifier p2;
+ GDScriptCompletionIdentifier p1;
+ GDScriptCompletionIdentifier p2;
if (op->arguments[0]) {
if (!_guess_expression_type(context, op->arguments[0], p_line, p1)) {
@@ -985,15 +985,15 @@ static bool _guess_expression_type(GDCompletionContext &context, const GDParser:
return false;
}
-static bool _guess_identifier_type_in_block(GDCompletionContext &context, int p_line, const StringName &p_identifier, GDCompletionIdentifier &r_type) {
+static bool _guess_identifier_type_in_block(GDScriptCompletionContext &context, int p_line, const StringName &p_identifier, GDScriptCompletionIdentifier &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) {
+ if (context.block->if_condition && context.block->if_condition->type == GDScriptParser::Node::TYPE_OPERATOR && static_cast<const GDScriptParser::OperatorNode *>(context.block->if_condition)->op == GDScriptParser::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) {
+ const GDScriptParser::OperatorNode *op = static_cast<const GDScriptParser::OperatorNode *>(context.block->if_condition);
+ if (op->arguments[0]->type == GDScriptParser::Node::TYPE_IDENTIFIER && static_cast<const GDScriptParser::IdentifierNode *>(op->arguments[0])->name == p_identifier) {
//bingo
if (_guess_expression_type(context, op->arguments[1], op->line, r_type)) {
return true;
@@ -1001,7 +1001,7 @@ static bool _guess_identifier_type_in_block(GDCompletionContext &context, int p_
}
}
- GDCompletionIdentifier gdi = _get_native_class(context);
+ GDScriptCompletionIdentifier 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);
@@ -1027,7 +1027,7 @@ static bool _guess_identifier_type_in_block(GDCompletionContext &context, int p_
}
}
- const GDParser::Node *last_assign = NULL;
+ const GDScriptParser::Node *last_assign = NULL;
int last_assign_line = -1;
for (int i = 0; i < context.block->statements.size(); i++) {
@@ -1035,9 +1035,9 @@ static bool _guess_identifier_type_in_block(GDCompletionContext &context, int p_
if (context.block->statements[i]->line > p_line)
continue;
- if (context.block->statements[i]->type == GDParser::BlockNode::TYPE_LOCAL_VAR) {
+ if (context.block->statements[i]->type == GDScriptParser::BlockNode::TYPE_LOCAL_VAR) {
- const GDParser::LocalVarNode *lv = static_cast<const GDParser::LocalVarNode *>(context.block->statements[i]);
+ const GDScriptParser::LocalVarNode *lv = static_cast<const GDScriptParser::LocalVarNode *>(context.block->statements[i]);
if (lv->assign && lv->name == p_identifier) {
@@ -1046,13 +1046,13 @@ static bool _guess_identifier_type_in_block(GDCompletionContext &context, int p_
}
}
- if (context.block->statements[i]->type == GDParser::BlockNode::TYPE_OPERATOR) {
- const GDParser::OperatorNode *op = static_cast<const GDParser::OperatorNode *>(context.block->statements[i]);
- if (op->op == GDParser::OperatorNode::OP_ASSIGN) {
+ if (context.block->statements[i]->type == GDScriptParser::BlockNode::TYPE_OPERATOR) {
+ const GDScriptParser::OperatorNode *op = static_cast<const GDScriptParser::OperatorNode *>(context.block->statements[i]);
+ if (op->op == GDScriptParser::OperatorNode::OP_ASSIGN) {
- if (op->arguments.size() && op->arguments[0]->type == GDParser::Node::TYPE_IDENTIFIER) {
+ if (op->arguments.size() && op->arguments[0]->type == GDScriptParser::Node::TYPE_IDENTIFIER) {
- const GDParser::IdentifierNode *id = static_cast<const GDParser::IdentifierNode *>(op->arguments[0]);
+ const GDScriptParser::IdentifierNode *id = static_cast<const GDScriptParser::IdentifierNode *>(op->arguments[0]);
if (id->name == p_identifier) {
@@ -1073,9 +1073,9 @@ static bool _guess_identifier_type_in_block(GDCompletionContext &context, int p_
return false;
}
-static bool _guess_identifier_from_assignment_in_function(GDCompletionContext &context, int p_src_line, const StringName &p_identifier, const StringName &p_function, GDCompletionIdentifier &r_type) {
+static bool _guess_identifier_from_assignment_in_function(GDScriptCompletionContext &context, int p_src_line, const StringName &p_identifier, const StringName &p_function, GDScriptCompletionIdentifier &r_type) {
- const GDParser::FunctionNode *func = NULL;
+ const GDScriptParser::FunctionNode *func = NULL;
for (int i = 0; i < context._class->functions.size(); i++) {
if (context._class->functions[i]->name == p_function) {
func = context._class->functions[i];
@@ -1092,13 +1092,13 @@ static bool _guess_identifier_from_assignment_in_function(GDCompletionContext &c
break;
}
- if (func->body->statements[i]->type == GDParser::BlockNode::TYPE_OPERATOR) {
- const GDParser::OperatorNode *op = static_cast<const GDParser::OperatorNode *>(func->body->statements[i]);
- if (op->op == GDParser::OperatorNode::OP_ASSIGN) {
+ if (func->body->statements[i]->type == GDScriptParser::BlockNode::TYPE_OPERATOR) {
+ const GDScriptParser::OperatorNode *op = static_cast<const GDScriptParser::OperatorNode *>(func->body->statements[i]);
+ if (op->op == GDScriptParser::OperatorNode::OP_ASSIGN) {
- if (op->arguments.size() && op->arguments[0]->type == GDParser::Node::TYPE_IDENTIFIER) {
+ if (op->arguments.size() && op->arguments[0]->type == GDScriptParser::Node::TYPE_IDENTIFIER) {
- const GDParser::IdentifierNode *id = static_cast<const GDParser::IdentifierNode *>(op->arguments[0]);
+ const GDScriptParser::IdentifierNode *id = static_cast<const GDScriptParser::IdentifierNode *>(op->arguments[0]);
if (id->name == p_identifier) {
@@ -1112,15 +1112,15 @@ 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, bool p_for_indexing) {
+static bool _guess_identifier_type(GDScriptCompletionContext &context, int p_line, const StringName &p_identifier, GDScriptCompletionIdentifier &r_type, bool p_for_indexing) {
//go to block first
- const GDParser::BlockNode *block = context.block;
+ const GDScriptParser::BlockNode *block = context.block;
while (block) {
- GDCompletionContext c = context;
+ GDScriptCompletionContext c = context;
c.block = block;
if (_guess_identifier_type_in_block(c, p_line, p_identifier, r_type)) {
@@ -1144,7 +1144,7 @@ static bool _guess_identifier_type(GDCompletionContext &context, int p_line, con
}
if (argindex != -1) {
- GDCompletionIdentifier id = _get_native_class(context);
+ GDScriptCompletionIdentifier id = _get_native_class(context);
if (id.type == Variant::OBJECT && id.obj_type != StringName()) {
//this kinda sucks but meh
@@ -1182,8 +1182,8 @@ static bool _guess_identifier_type(GDCompletionContext &context, int p_line, con
if (context._class->constant_expressions[i].identifier == p_identifier) {
- ERR_FAIL_COND_V(context._class->constant_expressions[i].expression->type != GDParser::Node::TYPE_CONSTANT, false);
- r_type = _get_type_from_variant(static_cast<const GDParser::ConstantNode *>(context._class->constant_expressions[i].expression)->value);
+ ERR_FAIL_COND_V(context._class->constant_expressions[i].expression->type != GDScriptParser::Node::TYPE_CONSTANT, false);
+ r_type = _get_type_from_variant(static_cast<const GDScriptParser::ConstantNode *>(context._class->constant_expressions[i].expression)->value);
return true;
}
}
@@ -1275,7 +1275,7 @@ static bool _guess_identifier_type(GDCompletionContext &context, int p_line, con
return false;
}
-static void _find_identifiers_in_block(GDCompletionContext &context, int p_line, bool p_only_functions, Set<String> &result) {
+static void _find_identifiers_in_block(GDScriptCompletionContext &context, int p_line, bool p_only_functions, Set<String> &result) {
if (p_only_functions)
return;
@@ -1285,15 +1285,15 @@ static void _find_identifiers_in_block(GDCompletionContext &context, int p_line,
if (context.block->statements[i]->line > p_line)
continue;
- if (context.block->statements[i]->type == GDParser::BlockNode::TYPE_LOCAL_VAR) {
+ if (context.block->statements[i]->type == GDScriptParser::BlockNode::TYPE_LOCAL_VAR) {
- const GDParser::LocalVarNode *lv = static_cast<const GDParser::LocalVarNode *>(context.block->statements[i]);
+ const GDScriptParser::LocalVarNode *lv = static_cast<const GDScriptParser::LocalVarNode *>(context.block->statements[i]);
result.insert(lv->name.operator String());
}
}
}
-static void _find_identifiers_in_class(GDCompletionContext &context, bool p_static, bool p_only_functions, Set<String> &result) {
+static void _find_identifiers_in_class(GDScriptCompletionContext &context, bool p_static, bool p_only_functions, Set<String> &result) {
if (!p_static && !p_only_functions) {
@@ -1336,7 +1336,7 @@ static void _find_identifiers_in_class(GDCompletionContext &context, bool p_stat
while (true) {
Ref<GDScript> script = base;
- Ref<GDNativeClass> nc = base;
+ Ref<GDScriptNativeClass> nc = base;
if (script.is_valid()) {
if (!p_static && !p_only_functions) {
@@ -1351,7 +1351,7 @@ static void _find_identifiers_in_class(GDCompletionContext &context, bool p_stat
}
}
- for (const Map<StringName, GDFunction *>::Element *E = script->get_member_functions().front(); E; E = E->next()) {
+ for (const Map<StringName, GDScriptFunction *>::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() + "(");
@@ -1410,13 +1410,13 @@ static void _find_identifiers_in_class(GDCompletionContext &context, bool p_stat
}
}
-static void _find_identifiers(GDCompletionContext &context, int p_line, bool p_only_functions, Set<String> &result) {
+static void _find_identifiers(GDScriptCompletionContext &context, int p_line, bool p_only_functions, Set<String> &result) {
- const GDParser::BlockNode *block = context.block;
+ const GDScriptParser::BlockNode *block = context.block;
if (context.function) {
- const GDParser::FunctionNode *f = context.function;
+ const GDScriptParser::FunctionNode *f = context.function;
for (int i = 0; i < f->arguments.size(); i++) {
result.insert(f->arguments[i].operator String());
@@ -1425,19 +1425,19 @@ static void _find_identifiers(GDCompletionContext &context, int p_line, bool p_o
while (block) {
- GDCompletionContext c = context;
+ GDScriptCompletionContext c = context;
c.block = block;
_find_identifiers_in_block(c, p_line, p_only_functions, result);
block = block->parent_block;
}
- const GDParser::ClassNode *clss = context._class;
+ const GDScriptParser::ClassNode *clss = context._class;
bool _static = context.function && context.function->_static;
while (clss) {
- GDCompletionContext c = context;
+ GDScriptCompletionContext c = context;
c._class = clss;
c.block = NULL;
c.function = NULL;
@@ -1445,9 +1445,9 @@ static void _find_identifiers(GDCompletionContext &context, int p_line, bool p_o
clss = clss->owner;
}
- for (int i = 0; i < GDFunctions::FUNC_MAX; i++) {
+ for (int i = 0; i < GDScriptFunctions::FUNC_MAX; i++) {
- result.insert(GDFunctions::get_func_name(GDFunctions::Function(i)));
+ result.insert(GDScriptFunctions::get_func_name(GDScriptFunctions::Function(i)));
}
static const char *_type_names[Variant::VARIANT_MAX] = {
@@ -1501,7 +1501,7 @@ static String _get_visual_datatype(const PropertyInfo &p_info, bool p_isarg = tr
return Variant::get_type_name(p_info.type);
}
-static void _make_function_hint(const GDParser::FunctionNode *p_func, int p_argidx, String &arghint) {
+static void _make_function_hint(const GDScriptParser::FunctionNode *p_func, int p_argidx, String &arghint) {
arghint = "func " + p_func->name + "(";
for (int i = 0; i < p_func->arguments.size(); i++) {
@@ -1521,11 +1521,11 @@ static void _make_function_hint(const GDParser::FunctionNode *p_func, int p_argi
if (defidx >= 0 && defidx < p_func->default_values.size()) {
- if (p_func->default_values[defidx]->type == GDParser::Node::TYPE_OPERATOR) {
+ if (p_func->default_values[defidx]->type == GDScriptParser::Node::TYPE_OPERATOR) {
- const GDParser::OperatorNode *op = static_cast<const GDParser::OperatorNode *>(p_func->default_values[defidx]);
- if (op->op == GDParser::OperatorNode::OP_ASSIGN) {
- const GDParser::ConstantNode *cn = static_cast<const GDParser::ConstantNode *>(op->arguments[1]);
+ const GDScriptParser::OperatorNode *op = static_cast<const GDScriptParser::OperatorNode *>(p_func->default_values[defidx]);
+ if (op->op == GDScriptParser::OperatorNode::OP_ASSIGN) {
+ const GDScriptParser::ConstantNode *cn = static_cast<const GDScriptParser::ConstantNode *>(op->arguments[1]);
arghint += "=" + cn->value.get_construct_string();
}
} else {
@@ -1553,7 +1553,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, bool &r_forced, String &arghint) {
+static void _find_type_arguments(GDScriptCompletionContext &context, const GDScriptParser::Node *p_node, int p_line, const StringName &p_method, const GDScriptCompletionIdentifier &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()) {
@@ -1572,7 +1572,7 @@ static void _find_type_arguments(GDCompletionContext &context, const GDParser::N
if (scr) {
while (scr) {
- for (const Map<StringName, GDFunction *>::Element *E = scr->get_member_functions().front(); E; E = E->next()) {
+ for (const Map<StringName, GDScriptFunction *>::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++) {
@@ -1629,7 +1629,7 @@ static void _find_type_arguments(GDCompletionContext &context, const GDParser::N
if (code != "") {
//if there is code, parse it. This way is slower but updates in real-time
- GDParser p;
+ GDScriptParser p;
//Error parse(const String& p_code, const String& p_base_path="", bool p_just_validate=false,const String& p_self_path="",bool p_for_completion=false);
Error err = p.parse(scr->get_source_code(), scr->get_path().get_base_dir(), true, "", false);
@@ -1637,13 +1637,13 @@ static void _find_type_arguments(GDCompletionContext &context, const GDParser::N
if (err == OK) {
//print_line("checking the functions...");
//only if ok, otherwise use what is cached on the script
- //GDParser::ClassNode *base = p.
- const GDParser::Node *root = p.get_parse_tree();
- ERR_FAIL_COND(root->type != GDParser::Node::TYPE_CLASS);
+ //GDScriptParser::ClassNode *base = p.
+ const GDScriptParser::Node *root = p.get_parse_tree();
+ ERR_FAIL_COND(root->type != GDScriptParser::Node::TYPE_CLASS);
- const GDParser::ClassNode *cl = static_cast<const GDParser::ClassNode *>(root);
+ const GDScriptParser::ClassNode *cl = static_cast<const GDScriptParser::ClassNode *>(root);
- const GDParser::FunctionNode *func = NULL;
+ const GDScriptParser::FunctionNode *func = NULL;
bool st = false;
for (int i = 0; i < cl->functions.size(); i++) {
@@ -1681,10 +1681,10 @@ static void _find_type_arguments(GDCompletionContext &context, const GDParser::N
int defidx = deffrom - i;
- if (defidx >= 0 && defidx < func->default_values.size() && func->default_values[defidx]->type == GDParser::Node::TYPE_OPERATOR) {
- const GDParser::OperatorNode *op = static_cast<const GDParser::OperatorNode *>(func->default_values[defidx]);
- if (op->op == GDParser::OperatorNode::OP_ASSIGN) {
- const GDParser::ConstantNode *cn = static_cast<const GDParser::ConstantNode *>(op->arguments[1]);
+ if (defidx >= 0 && defidx < func->default_values.size() && func->default_values[defidx]->type == GDScriptParser::Node::TYPE_OPERATOR) {
+ const GDScriptParser::OperatorNode *op = static_cast<const GDScriptParser::OperatorNode *>(func->default_values[defidx]);
+ if (op->op == GDScriptParser::OperatorNode::OP_ASSIGN) {
+ const GDScriptParser::ConstantNode *cn = static_cast<const GDScriptParser::ConstantNode *>(op->arguments[1]);
arghint += "=" + cn->value.get_construct_string();
}
}
@@ -1705,7 +1705,7 @@ static void _find_type_arguments(GDCompletionContext &context, const GDParser::N
if (code == "") {
- for (const Map<StringName, GDFunction *>::Element *E = scr->get_member_functions().front(); E; E = E->next()) {
+ for (const Map<StringName, GDScriptFunction *>::Element *E = scr->get_member_functions().front(); E; E = E->next()) {
if (p_method == E->get()->get_name()) {
arghint = "func " + String(p_method) + "(";
for (int i = 0; i < E->get()->get_argument_count(); i++) {
@@ -1814,8 +1814,8 @@ static void _find_type_arguments(GDCompletionContext &context, const GDParser::N
}
/*if (p_argidx==2) {
- ERR_FAIL_COND(p_node->type!=GDParser::Node::TYPE_OPERATOR);
- const GDParser::OperatorNode *op=static_cast<const GDParser::OperatorNode *>(p_node);
+ ERR_FAIL_COND(p_node->type!=GDScriptParser::Node::TYPE_OPERATOR);
+ const GDScriptParser::OperatorNode *op=static_cast<const GDScriptParser::OperatorNode *>(p_node);
if (op->arguments.size()>)
}*/
@@ -1890,30 +1890,30 @@ 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, bool &r_forced, String &arghint) {
+static void _find_call_arguments(GDScriptCompletionContext &context, const GDScriptParser::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) {
+ if (!p_node || p_node->type != GDScriptParser::Node::TYPE_OPERATOR) {
return;
}
- const GDParser::OperatorNode *op = static_cast<const GDParser::OperatorNode *>(p_node);
+ const GDScriptParser::OperatorNode *op = static_cast<const GDScriptParser::OperatorNode *>(p_node);
- if (op->op != GDParser::OperatorNode::OP_CALL) {
+ if (op->op != GDScriptParser::OperatorNode::OP_CALL) {
return;
}
- if (op->arguments[0]->type == GDParser::Node::TYPE_BUILT_IN_FUNCTION) {
+ if (op->arguments[0]->type == GDScriptParser::Node::TYPE_BUILT_IN_FUNCTION) {
//complete built-in function
- const GDParser::BuiltInFunctionNode *fn = static_cast<const GDParser::BuiltInFunctionNode *>(op->arguments[0]);
- MethodInfo mi = GDFunctions::get_info(fn->function);
+ const GDScriptParser::BuiltInFunctionNode *fn = static_cast<const GDScriptParser::BuiltInFunctionNode *>(op->arguments[0]);
+ MethodInfo mi = GDScriptFunctions::get_info(fn->function);
if (mi.name == "load" && bool(EditorSettings::get_singleton()->get("text_editor/completion/complete_file_paths"))) {
get_directory_contents(EditorFileSystem::get_singleton()->get_filesystem(), result);
}
- arghint = _get_visual_datatype(mi.return_val, false) + " " + GDFunctions::get_func_name(fn->function) + String("(");
+ arghint = _get_visual_datatype(mi.return_val, false) + " " + GDScriptFunctions::get_func_name(fn->function) + String("(");
for (int i = 0; i < mi.arguments.size(); i++) {
if (i > 0)
arghint += ", ";
@@ -1931,9 +1931,9 @@ static void _find_call_arguments(GDCompletionContext &context, const GDParser::N
arghint += " ";
arghint += ")";
- } else if (op->arguments[0]->type == GDParser::Node::TYPE_TYPE) {
+ } else if (op->arguments[0]->type == GDScriptParser::Node::TYPE_TYPE) {
//complete constructor
- const GDParser::TypeNode *tn = static_cast<const GDParser::TypeNode *>(op->arguments[0]);
+ const GDScriptParser::TypeNode *tn = static_cast<const GDScriptParser::TypeNode *>(op->arguments[0]);
List<MethodInfo> mil;
Variant::get_constructor_list(tn->vtype, &mil);
@@ -1964,11 +1964,11 @@ static void _find_call_arguments(GDCompletionContext &context, const GDParser::N
arghint += ")";
}
- } else if (op->arguments.size() >= 2 && op->arguments[1]->type == GDParser::Node::TYPE_IDENTIFIER) {
+ } else if (op->arguments.size() >= 2 && op->arguments[1]->type == GDScriptParser::Node::TYPE_IDENTIFIER) {
//make sure identifier exists...
- const GDParser::IdentifierNode *id = static_cast<const GDParser::IdentifierNode *>(op->arguments[1]);
- if (op->arguments[0]->type == GDParser::Node::TYPE_SELF) {
+ const GDScriptParser::IdentifierNode *id = static_cast<const GDScriptParser::IdentifierNode *>(op->arguments[1]);
+ if (op->arguments[0]->type == GDScriptParser::Node::TYPE_SELF) {
//self, look up
for (int i = 0; i < context._class->static_functions.size(); i++) {
@@ -1993,10 +1993,10 @@ static void _find_call_arguments(GDCompletionContext &context, const GDParser::N
while (true) {
Ref<GDScript> script = base;
- Ref<GDNativeClass> nc = base;
+ Ref<GDScriptNativeClass> nc = base;
if (script.is_valid()) {
- for (const Map<StringName, GDFunction *>::Element *E = script->get_member_functions().front(); E; E = E->next()) {
+ for (const Map<StringName, GDScriptFunction *>::Element *E = script->get_member_functions().front(); E; E = E->next()) {
if (E->key() == id->name) {
@@ -2038,7 +2038,7 @@ static void _find_call_arguments(GDCompletionContext &context, const GDParser::N
if (!(context.function && context.function->_static)) {
- GDCompletionIdentifier ci;
+ GDScriptCompletionIdentifier ci;
ci.type = Variant::OBJECT;
ci.obj_type = nc->get_name();
if (!context._class->owner)
@@ -2063,7 +2063,7 @@ static void _find_call_arguments(GDCompletionContext &context, const GDParser::N
} else {
//indexed lookup
- GDCompletionIdentifier ci;
+ GDScriptCompletionIdentifier 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, r_forced, arghint);
@@ -2075,13 +2075,13 @@ static void _find_call_arguments(GDCompletionContext &context, const GDParser::N
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;
+ GDScriptParser p;
p.parse(p_code, p_base_path, false, "", true);
bool isfunction = false;
Set<String> options;
r_forced = false;
- GDCompletionContext context;
+ GDScriptCompletionContext context;
context._class = p.get_completion_class();
context.block = p.get_completion_block();
context.function = p.get_completion_function();
@@ -2090,9 +2090,9 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_base
switch (p.get_completion_type()) {
- case GDParser::COMPLETION_NONE: {
+ case GDScriptParser::COMPLETION_NONE: {
} break;
- case GDParser::COMPLETION_BUILT_IN_TYPE_CONSTANT: {
+ case GDScriptParser::COMPLETION_BUILT_IN_TYPE_CONSTANT: {
List<StringName> constants;
Variant::get_numeric_constants_for_type(p.get_completion_built_in_constant(), &constants);
for (List<StringName>::Element *E = constants.front(); E; E = E->next()) {
@@ -2100,16 +2100,16 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_base
}
} break;
- case GDParser::COMPLETION_FUNCTION:
+ case GDScriptParser::COMPLETION_FUNCTION:
isfunction = true;
- case GDParser::COMPLETION_IDENTIFIER: {
+ case GDScriptParser::COMPLETION_IDENTIFIER: {
_find_identifiers(context, p.get_completion_line(), isfunction, options);
} break;
- case GDParser::COMPLETION_PARENT_FUNCTION: {
+ case GDScriptParser::COMPLETION_PARENT_FUNCTION: {
} break;
- case GDParser::COMPLETION_GET_NODE: {
+ case GDScriptParser::COMPLETION_GET_NODE: {
if (p_owner) {
List<String> opts;
@@ -2130,20 +2130,20 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_base
}
}
} break;
- case GDParser::COMPLETION_METHOD:
+ case GDScriptParser::COMPLETION_METHOD:
isfunction = true;
- case GDParser::COMPLETION_INDEX: {
+ case GDScriptParser::COMPLETION_INDEX: {
- const GDParser::Node *node = p.get_completion_node();
- if (node->type != GDParser::Node::TYPE_OPERATOR)
+ const GDScriptParser::Node *node = p.get_completion_node();
+ if (node->type != GDScriptParser::Node::TYPE_OPERATOR)
break;
- GDCompletionIdentifier t;
- if (_guess_expression_type(context, static_cast<const GDParser::OperatorNode *>(node)->arguments[0], p.get_completion_line(), t, true)) {
+ GDScriptCompletionIdentifier t;
+ if (_guess_expression_type(context, static_cast<const GDScriptParser::OperatorNode *>(node)->arguments[0], p.get_completion_line(), t, true)) {
- if (t.type == Variant::OBJECT && t.obj_type == "GDNativeClass") {
+ if (t.type == Variant::OBJECT && t.obj_type == "GDScriptNativeClass") {
//native enum
- Ref<GDNativeClass> gdn = t.value;
+ Ref<GDScriptNativeClass> gdn = t.value;
if (gdn.is_valid()) {
StringName cn = gdn->get_name();
List<String> cnames;
@@ -2179,7 +2179,7 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_base
options.insert(E->key());
}
}
- for (const Map<StringName, GDFunction *>::Element *E = scr->get_member_functions().front(); E; E = E->next()) {
+ for (const Map<StringName, GDScriptFunction *>::Element *E = scr->get_member_functions().front(); E; E = E->next()) {
if (E->get()->is_static())
options.insert(E->key());
}
@@ -2210,17 +2210,17 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_base
if (code != "") {
//if there is code, parse it. This way is slower but updates in real-time
- GDParser p;
+ GDScriptParser p;
Error err = p.parse(scr->get_source_code(), scr->get_path().get_base_dir(), true, "", false);
if (err == OK) {
//only if ok, otherwise use what is cached on the script
- //GDParser::ClassNode *base = p.
- const GDParser::Node *root = p.get_parse_tree();
- ERR_FAIL_COND_V(root->type != GDParser::Node::TYPE_CLASS, ERR_PARSE_ERROR);
+ //GDScriptParser::ClassNode *base = p.
+ const GDScriptParser::Node *root = p.get_parse_tree();
+ ERR_FAIL_COND_V(root->type != GDScriptParser::Node::TYPE_CLASS, ERR_PARSE_ERROR);
- const GDParser::ClassNode *cl = static_cast<const GDParser::ClassNode *>(root);
+ const GDScriptParser::ClassNode *cl = static_cast<const GDScriptParser::ClassNode *>(root);
for (int i = 0; i < cl->functions.size(); i++) {
@@ -2262,7 +2262,7 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_base
options.insert(E->key());
}
}
- for (const Map<StringName, GDFunction *>::Element *E = scr->get_member_functions().front(); E; E = E->next()) {
+ for (const Map<StringName, GDScriptFunction *>::Element *E = scr->get_member_functions().front(); E; E = E->next()) {
if (E->get()->get_argument_count())
options.insert(String(E->key()) + "()");
else
@@ -2341,13 +2341,13 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_base
}
} break;
- case GDParser::COMPLETION_CALL_ARGUMENTS: {
+ case GDScriptParser::COMPLETION_CALL_ARGUMENTS: {
_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: {
+ case GDScriptParser::COMPLETION_VIRTUAL_FUNC: {
- GDCompletionIdentifier cid = _get_native_class(context);
+ GDScriptCompletionIdentifier cid = _get_native_class(context);
if (cid.obj_type != StringName()) {
List<MethodInfo> vm;
@@ -2376,11 +2376,11 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_base
}
}
} break;
- case GDParser::COMPLETION_YIELD: {
+ case GDScriptParser::COMPLETION_YIELD: {
- const GDParser::Node *node = p.get_completion_node();
+ const GDScriptParser::Node *node = p.get_completion_node();
- GDCompletionIdentifier t;
+ GDScriptCompletionIdentifier t;
if (!_guess_expression_type(context, node, p.get_completion_line(), t))
break;
@@ -2395,15 +2395,15 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_base
}
} break;
- case GDParser::COMPLETION_RESOURCE_PATH: {
+ case GDScriptParser::COMPLETION_RESOURCE_PATH: {
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: {
+ case GDScriptParser::COMPLETION_ASSIGN: {
#if defined(DEBUG_METHODS_ENABLED) && defined(TOOLS_ENABLED)
- GDCompletionIdentifier ci;
+ GDScriptCompletionIdentifier ci;
if (_guess_expression_type(context, p.get_completion_node(), p.get_completion_line(), ci)) {
String enumeration = ci.enumeration;
@@ -2556,8 +2556,8 @@ Error GDScriptLanguage::lookup_code(const String &p_code, const String &p_symbol
}
}
- for (int i = 0; i < GDFunctions::FUNC_MAX; i++) {
- if (GDFunctions::get_func_name(GDFunctions::Function(i)) == p_symbol) {
+ for (int i = 0; i < GDScriptFunctions::FUNC_MAX; i++) {
+ if (GDScriptFunctions::get_func_name(GDScriptFunctions::Function(i)) == p_symbol) {
r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS_METHOD;
r_result.class_name = "@GDScript";
r_result.class_member = p_symbol;
@@ -2565,13 +2565,13 @@ Error GDScriptLanguage::lookup_code(const String &p_code, const String &p_symbol
}
}
- GDParser p;
+ GDScriptParser p;
p.parse(p_code, p_base_path, false, "", true);
- if (p.get_completion_type() == GDParser::COMPLETION_NONE)
+ if (p.get_completion_type() == GDScriptParser::COMPLETION_NONE)
return ERR_CANT_RESOLVE;
- GDCompletionContext context;
+ GDScriptCompletionContext context;
context._class = p.get_completion_class();
context.block = p.get_completion_block();
@@ -2582,10 +2582,10 @@ Error GDScriptLanguage::lookup_code(const String &p_code, const String &p_symbol
switch (p.get_completion_type()) {
- case GDParser::COMPLETION_GET_NODE:
- case GDParser::COMPLETION_NONE: {
+ case GDScriptParser::COMPLETION_GET_NODE:
+ case GDScriptParser::COMPLETION_NONE: {
} break;
- case GDParser::COMPLETION_BUILT_IN_TYPE_CONSTANT: {
+ case GDScriptParser::COMPLETION_BUILT_IN_TYPE_CONSTANT: {
r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS_CONSTANT;
r_result.class_name = Variant::get_type_name(p.get_completion_built_in_constant());
@@ -2593,7 +2593,7 @@ Error GDScriptLanguage::lookup_code(const String &p_code, const String &p_symbol
return OK;
} break;
- case GDParser::COMPLETION_FUNCTION: {
+ case GDScriptParser::COMPLETION_FUNCTION: {
if (context._class && context._class->functions.size()) {
for (int i = 0; i < context._class->functions.size(); i++) {
@@ -2618,7 +2618,7 @@ Error GDScriptLanguage::lookup_code(const String &p_code, const String &p_symbol
parent = parent->get_base();
}
- GDCompletionIdentifier identifier = _get_native_class(context);
+ GDScriptCompletionIdentifier identifier = _get_native_class(context);
print_line("identifier: " + String(identifier.obj_type));
if (ClassDB::has_method(identifier.obj_type, p_symbol)) {
@@ -2630,7 +2630,7 @@ Error GDScriptLanguage::lookup_code(const String &p_code, const String &p_symbol
}
} break;
- case GDParser::COMPLETION_IDENTIFIER: {
+ case GDScriptParser::COMPLETION_IDENTIFIER: {
//check if a function
if (p.get_completion_identifier_is_function()) {
@@ -2657,7 +2657,7 @@ Error GDScriptLanguage::lookup_code(const String &p_code, const String &p_symbol
parent = parent->get_base();
}
- GDCompletionIdentifier identifier = _get_native_class(context);
+ GDScriptCompletionIdentifier identifier = _get_native_class(context);
if (ClassDB::has_method(identifier.obj_type, p_symbol)) {
@@ -2668,7 +2668,7 @@ Error GDScriptLanguage::lookup_code(const String &p_code, const String &p_symbol
}
} else {
- GDCompletionIdentifier gdi = _get_native_class(context);
+ GDScriptCompletionIdentifier gdi = _get_native_class(context);
if (gdi.obj_type != StringName()) {
bool valid;
Variant::Type t = ClassDB::get_property_type(gdi.obj_type, p_symbol, &valid);
@@ -2680,7 +2680,7 @@ Error GDScriptLanguage::lookup_code(const String &p_code, const String &p_symbol
}
}
- const GDParser::BlockNode *block = context.block;
+ const GDScriptParser::BlockNode *block = context.block;
//search in blocks going up (local var?)
while (block) {
@@ -2689,9 +2689,9 @@ Error GDScriptLanguage::lookup_code(const String &p_code, const String &p_symbol
if (block->statements[i]->line > p.get_completion_line())
continue;
- if (block->statements[i]->type == GDParser::BlockNode::TYPE_LOCAL_VAR) {
+ if (block->statements[i]->type == GDScriptParser::BlockNode::TYPE_LOCAL_VAR) {
- const GDParser::LocalVarNode *lv = static_cast<const GDParser::LocalVarNode *>(block->statements[i]);
+ const GDScriptParser::LocalVarNode *lv = static_cast<const GDScriptParser::LocalVarNode *>(block->statements[i]);
if (lv->assign && lv->name == p_symbol) {
@@ -2782,9 +2782,9 @@ Error GDScriptLanguage::lookup_code(const String &p_code, const String &p_symbol
if (value.get_type() == Variant::OBJECT) {
Object *obj = value;
if (obj) {
- if (Object::cast_to<GDNativeClass>(obj)) {
+ if (Object::cast_to<GDScriptNativeClass>(obj)) {
r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS;
- r_result.class_name = Object::cast_to<GDNativeClass>(obj)->get_name();
+ r_result.class_name = Object::cast_to<GDScriptNativeClass>(obj)->get_name();
} else {
r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS;
r_result.class_name = obj->get_class();
@@ -2806,23 +2806,23 @@ Error GDScriptLanguage::lookup_code(const String &p_code, const String &p_symbol
}
} break;
- case GDParser::COMPLETION_PARENT_FUNCTION: {
+ case GDScriptParser::COMPLETION_PARENT_FUNCTION: {
} break;
- case GDParser::COMPLETION_METHOD:
+ case GDScriptParser::COMPLETION_METHOD:
isfunction = true;
- case GDParser::COMPLETION_INDEX: {
+ case GDScriptParser::COMPLETION_INDEX: {
- const GDParser::Node *node = p.get_completion_node();
- if (node->type != GDParser::Node::TYPE_OPERATOR)
+ const GDScriptParser::Node *node = p.get_completion_node();
+ if (node->type != GDScriptParser::Node::TYPE_OPERATOR)
break;
- GDCompletionIdentifier t;
- if (_guess_expression_type(context, static_cast<const GDParser::OperatorNode *>(node)->arguments[0], p.get_completion_line(), t)) {
+ GDScriptCompletionIdentifier t;
+ if (_guess_expression_type(context, static_cast<const GDScriptParser::OperatorNode *>(node)->arguments[0], p.get_completion_line(), t)) {
- if (t.type == Variant::OBJECT && t.obj_type == "GDNativeClass") {
+ if (t.type == Variant::OBJECT && t.obj_type == "GDScriptNativeClass") {
//native enum
- Ref<GDNativeClass> gdn = t.value;
+ Ref<GDScriptNativeClass> gdn = t.value;
if (gdn.is_valid()) {
r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS_CONSTANT;
r_result.class_name = gdn->get_name();
@@ -2914,13 +2914,13 @@ Error GDScriptLanguage::lookup_code(const String &p_code, const String &p_symbol
}
} break;
- case GDParser::COMPLETION_CALL_ARGUMENTS: {
+ case GDScriptParser::COMPLETION_CALL_ARGUMENTS: {
return ERR_CANT_RESOLVE;
} break;
- case GDParser::COMPLETION_VIRTUAL_FUNC: {
+ case GDScriptParser::COMPLETION_VIRTUAL_FUNC: {
- GDCompletionIdentifier cid = _get_native_class(context);
+ GDScriptCompletionIdentifier cid = _get_native_class(context);
if (cid.obj_type != StringName()) {
List<MethodInfo> vm;
@@ -2937,7 +2937,7 @@ Error GDScriptLanguage::lookup_code(const String &p_code, const String &p_symbol
}
}
} break;
- case GDParser::COMPLETION_YIELD: {
+ case GDScriptParser::COMPLETION_YIELD: {
return ERR_CANT_RESOLVE;
diff --git a/modules/gdscript/gd_function.cpp b/modules/gdscript/gdscript_function.cpp
index 1a46ad324a..765a76fec4 100644
--- a/modules/gdscript/gd_function.cpp
+++ b/modules/gdscript/gdscript_function.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* gd_function.cpp */
+/* gdscript_function.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -27,13 +27,13 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "gd_function.h"
+#include "gdscript_function.h"
-#include "gd_functions.h"
-#include "gd_script.h"
+#include "gdscript.h"
+#include "gdscript_functions.h"
#include "os/os.h"
-Variant *GDFunction::_get_variant(int p_address, GDInstance *p_instance, GDScript *p_script, Variant &self, Variant *p_stack, String &r_error) const {
+Variant *GDScriptFunction::_get_variant(int p_address, GDScriptInstance *p_instance, GDScript *p_script, Variant &self, Variant *p_stack, String &r_error) const {
int address = p_address & ADDR_MASK;
@@ -85,7 +85,7 @@ Variant *GDFunction::_get_variant(int p_address, GDInstance *p_instance, GDScrip
o = o->_owner;
}
- ERR_EXPLAIN("GDCompiler bug..");
+ ERR_EXPLAIN("GDScriptCompiler bug..");
ERR_FAIL_V(NULL);
} break;
case ADDR_TYPE_LOCAL_CONSTANT: {
@@ -117,7 +117,7 @@ Variant *GDFunction::_get_variant(int p_address, GDInstance *p_instance, GDScrip
return NULL;
}
-String GDFunction::_get_call_error(const Variant::CallError &p_err, const String &p_where, const Variant **argptrs) const {
+String GDScriptFunction::_get_call_error(const Variant::CallError &p_err, const String &p_where, const Variant **argptrs) const {
String err_text;
@@ -231,7 +231,7 @@ static String _get_var_type(const Variant *p_type) {
#define OPCODE_OUT break
#endif
-Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_argcount, Variant::CallError &r_err, CallState *p_state) {
+Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_args, int p_argcount, Variant::CallError &r_err, CallState *p_state) {
OPCODES_TABLE;
@@ -479,7 +479,7 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a
} else {
- GDNativeClass *nc = Object::cast_to<GDNativeClass>(obj_B);
+ GDScriptNativeClass *nc = Object::cast_to<GDScriptNativeClass>(obj_B);
#ifdef DEBUG_ENABLED
if (!nc) {
@@ -851,7 +851,7 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a
CHECK_SPACE(4);
- GDFunctions::Function func = GDFunctions::Function(_code_ptr[ip + 1]);
+ GDScriptFunctions::Function func = GDScriptFunctions::Function(_code_ptr[ip + 1]);
int argc = _code_ptr[ip + 2];
GD_ERR_BREAK(argc < 0);
@@ -868,12 +868,12 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a
Variant::CallError err;
- GDFunctions::call(func, (const Variant **)argptrs, argc, *dst, err);
+ GDScriptFunctions::call(func, (const Variant **)argptrs, argc, *dst, err);
#ifdef DEBUG_ENABLED
if (err.error != Variant::CallError::CALL_OK) {
- String methodstr = GDFunctions::get_func_name(func);
+ String methodstr = GDScriptFunctions::get_func_name(func);
if (dst->get_type() == Variant::STRING) {
//call provided error string
err_text = "Error calling built-in function '" + methodstr + "': " + String(*dst);
@@ -921,7 +921,7 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a
const GDScript *gds = _script;
- const Map<StringName, GDFunction *>::Element *E = NULL;
+ const Map<StringName, GDScriptFunction *>::Element *E = NULL;
while (gds->base.ptr()) {
gds = gds->base.ptr();
E = gds->member_functions.find(*methodname);
@@ -979,7 +979,7 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a
CHECK_SPACE(2);
}
- Ref<GDFunctionState> gdfs = memnew(GDFunctionState);
+ Ref<GDScriptFunctionState> gdfs = memnew(GDScriptFunctionState);
gdfs->function = this;
gdfs->state.stack.resize(alloca_size);
@@ -1321,43 +1321,43 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a
return retvalue;
}
-const int *GDFunction::get_code() const {
+const int *GDScriptFunction::get_code() const {
return _code_ptr;
}
-int GDFunction::get_code_size() const {
+int GDScriptFunction::get_code_size() const {
return _code_size;
}
-Variant GDFunction::get_constant(int p_idx) const {
+Variant GDScriptFunction::get_constant(int p_idx) const {
ERR_FAIL_INDEX_V(p_idx, constants.size(), "<errconst>");
return constants[p_idx];
}
-StringName GDFunction::get_global_name(int p_idx) const {
+StringName GDScriptFunction::get_global_name(int p_idx) const {
ERR_FAIL_INDEX_V(p_idx, global_names.size(), "<errgname>");
return global_names[p_idx];
}
-int GDFunction::get_default_argument_count() const {
+int GDScriptFunction::get_default_argument_count() const {
return default_arguments.size();
}
-int GDFunction::get_default_argument_addr(int p_idx) const {
+int GDScriptFunction::get_default_argument_addr(int p_idx) const {
ERR_FAIL_INDEX_V(p_idx, default_arguments.size(), -1);
return default_arguments[p_idx];
}
-StringName GDFunction::get_name() const {
+StringName GDScriptFunction::get_name() const {
return name;
}
-int GDFunction::get_max_stack_size() const {
+int GDScriptFunction::get_max_stack_size() const {
return _stack_size;
}
@@ -1380,7 +1380,7 @@ struct _GDFKCS {
}
};
-void GDFunction::debug_get_stack_member_state(int p_line, List<Pair<StringName, int> > *r_stackvars) const {
+void GDScriptFunction::debug_get_stack_member_state(int p_line, List<Pair<StringName, int> > *r_stackvars) const {
int oc = 0;
Map<StringName, _GDFKC> sdmap;
@@ -1432,7 +1432,7 @@ void GDFunction::debug_get_stack_member_state(int p_line, List<Pair<StringName,
}
}
-GDFunction::GDFunction()
+GDScriptFunction::GDScriptFunction()
: function_list(this) {
_stack_size = 0;
@@ -1464,7 +1464,7 @@ GDFunction::GDFunction()
#endif
}
-GDFunction::~GDFunction() {
+GDScriptFunction::~GDScriptFunction() {
#ifdef DEBUG_ENABLED
if (GDScriptLanguage::get_singleton()->lock) {
GDScriptLanguage::get_singleton()->lock->lock();
@@ -1479,7 +1479,7 @@ GDFunction::~GDFunction() {
/////////////////////
-Variant GDFunctionState::_signal_callback(const Variant **p_args, int p_argcount, Variant::CallError &r_error) {
+Variant GDScriptFunctionState::_signal_callback(const Variant **p_args, int p_argcount, Variant::CallError &r_error) {
#ifdef DEBUG_ENABLED
if (state.instance_id && !ObjectDB::get_instance(state.instance_id)) {
@@ -1514,7 +1514,7 @@ Variant GDFunctionState::_signal_callback(const Variant **p_args, int p_argcount
arg = extra_args;
}
- Ref<GDFunctionState> self = *p_args[p_argcount - 1];
+ Ref<GDScriptFunctionState> self = *p_args[p_argcount - 1];
if (self.is_null()) {
r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT;
@@ -1528,10 +1528,10 @@ Variant GDFunctionState::_signal_callback(const Variant **p_args, int p_argcount
bool completed = true;
- // If the return value is a GDFunctionState reference,
+ // If the return value is a GDScriptFunctionState reference,
// then the function did yield again after resuming.
if (ret.is_ref()) {
- GDFunctionState *gdfs = Object::cast_to<GDFunctionState>(ret);
+ GDScriptFunctionState *gdfs = Object::cast_to<GDScriptFunctionState>(ret);
if (gdfs && gdfs->function == function)
completed = false;
}
@@ -1546,7 +1546,7 @@ Variant GDFunctionState::_signal_callback(const Variant **p_args, int p_argcount
return ret;
}
-bool GDFunctionState::is_valid(bool p_extended_check) const {
+bool GDScriptFunctionState::is_valid(bool p_extended_check) const {
if (function == NULL)
return false;
@@ -1563,7 +1563,7 @@ bool GDFunctionState::is_valid(bool p_extended_check) const {
return true;
}
-Variant GDFunctionState::resume(const Variant &p_arg) {
+Variant GDScriptFunctionState::resume(const Variant &p_arg) {
ERR_FAIL_COND_V(!function, Variant());
#ifdef DEBUG_ENABLED
@@ -1584,10 +1584,10 @@ Variant GDFunctionState::resume(const Variant &p_arg) {
bool completed = true;
- // If the return value is a GDFunctionState reference,
+ // If the return value is a GDScriptFunctionState reference,
// then the function did yield again after resuming.
if (ret.is_ref()) {
- GDFunctionState *gdfs = Object::cast_to<GDFunctionState>(ret);
+ GDScriptFunctionState *gdfs = Object::cast_to<GDScriptFunctionState>(ret);
if (gdfs && gdfs->function == function)
completed = false;
}
@@ -1602,21 +1602,21 @@ Variant GDFunctionState::resume(const Variant &p_arg) {
return ret;
}
-void GDFunctionState::_bind_methods() {
+void GDScriptFunctionState::_bind_methods() {
- ClassDB::bind_method(D_METHOD("resume", "arg"), &GDFunctionState::resume, DEFVAL(Variant()));
- ClassDB::bind_method(D_METHOD("is_valid", "extended_check"), &GDFunctionState::is_valid, DEFVAL(false));
- ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT, "_signal_callback", &GDFunctionState::_signal_callback, MethodInfo("_signal_callback"));
+ ClassDB::bind_method(D_METHOD("resume", "arg"), &GDScriptFunctionState::resume, DEFVAL(Variant()));
+ ClassDB::bind_method(D_METHOD("is_valid", "extended_check"), &GDScriptFunctionState::is_valid, DEFVAL(false));
+ ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT, "_signal_callback", &GDScriptFunctionState::_signal_callback, MethodInfo("_signal_callback"));
ADD_SIGNAL(MethodInfo("completed", PropertyInfo(Variant::NIL, "result", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NIL_IS_VARIANT)));
}
-GDFunctionState::GDFunctionState() {
+GDScriptFunctionState::GDScriptFunctionState() {
function = NULL;
}
-GDFunctionState::~GDFunctionState() {
+GDScriptFunctionState::~GDScriptFunctionState() {
if (function != NULL) {
//never called, deinitialize stack
diff --git a/modules/gdscript/gd_function.h b/modules/gdscript/gdscript_function.h
index bf5ff5f8da..03fd5d52dc 100644
--- a/modules/gdscript/gd_function.h
+++ b/modules/gdscript/gdscript_function.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* gd_function.h */
+/* gdscript_function.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -27,8 +27,8 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef GD_FUNCTION_H
-#define GD_FUNCTION_H
+#ifndef GDSCRIPT_FUNCTION_H
+#define GDSCRIPT_FUNCTION_H
#include "os/thread.h"
#include "pair.h"
@@ -38,10 +38,10 @@
#include "string_db.h"
#include "variant.h"
-class GDInstance;
+class GDScriptInstance;
class GDScript;
-class GDFunction {
+class GDScriptFunction {
public:
enum Opcode {
OPCODE_OPERATOR,
@@ -111,7 +111,7 @@ public:
};
private:
- friend class GDCompiler;
+ friend class GDScriptCompiler;
StringName source;
@@ -145,12 +145,12 @@ private:
List<StackDebug> stack_debug;
- _FORCE_INLINE_ Variant *_get_variant(int p_address, GDInstance *p_instance, GDScript *p_script, Variant &self, Variant *p_stack, String &r_error) const;
+ _FORCE_INLINE_ Variant *_get_variant(int p_address, GDScriptInstance *p_instance, GDScript *p_script, Variant &self, Variant *p_stack, String &r_error) const;
_FORCE_INLINE_ String _get_call_error(const Variant::CallError &p_err, const String &p_where, const Variant **argptrs) const;
friend class GDScriptLanguage;
- SelfList<GDFunction> function_list;
+ SelfList<GDScriptFunction> function_list;
#ifdef DEBUG_ENABLED
CharString func_cname;
const char *_func_cname;
@@ -176,7 +176,7 @@ public:
ObjectID instance_id; //by debug only
ObjectID script_id;
- GDInstance *instance;
+ GDScriptInstance *instance;
Vector<uint8_t> stack;
int stack_size;
Variant self;
@@ -219,19 +219,19 @@ public:
return default_arguments[p_idx];
}
- Variant call(GDInstance *p_instance, const Variant **p_args, int p_argcount, Variant::CallError &r_err, CallState *p_state = NULL);
+ Variant call(GDScriptInstance *p_instance, const Variant **p_args, int p_argcount, Variant::CallError &r_err, CallState *p_state = NULL);
_FORCE_INLINE_ ScriptInstance::RPCMode get_rpc_mode() const { return rpc_mode; }
- GDFunction();
- ~GDFunction();
+ GDScriptFunction();
+ ~GDScriptFunction();
};
-class GDFunctionState : public Reference {
+class GDScriptFunctionState : public Reference {
- GDCLASS(GDFunctionState, Reference);
- friend class GDFunction;
- GDFunction *function;
- GDFunction::CallState state;
+ GDCLASS(GDScriptFunctionState, Reference);
+ friend class GDScriptFunction;
+ GDScriptFunction *function;
+ GDScriptFunction::CallState state;
Variant _signal_callback(const Variant **p_args, int p_argcount, Variant::CallError &r_error);
protected:
@@ -240,8 +240,8 @@ protected:
public:
bool is_valid(bool p_extended_check = false) const;
Variant resume(const Variant &p_arg = Variant());
- GDFunctionState();
- ~GDFunctionState();
+ GDScriptFunctionState();
+ ~GDScriptFunctionState();
};
-#endif // GD_FUNCTION_H
+#endif // GDSCRIPT_FUNCTION_H
diff --git a/modules/gdscript/gd_functions.cpp b/modules/gdscript/gdscript_functions.cpp
index b43ec409a1..c6066ceefb 100644
--- a/modules/gdscript/gd_functions.cpp
+++ b/modules/gdscript/gdscript_functions.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* gd_functions.cpp */
+/* gdscript_functions.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -27,10 +27,11 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "gd_functions.h"
+#include "gdscript_functions.h"
+
#include "class_db.h"
#include "func_ref.h"
-#include "gd_script.h"
+#include "gdscript.h"
#include "io/json.h"
#include "io/marshalls.h"
#include "math_funcs.h"
@@ -38,7 +39,7 @@
#include "reference.h"
#include "variant_parser.h"
-const char *GDFunctions::get_func_name(Function p_func) {
+const char *GDScriptFunctions::get_func_name(Function p_func) {
ERR_FAIL_INDEX_V(p_func, FUNC_MAX, "");
@@ -123,7 +124,7 @@ const char *GDFunctions::get_func_name(Function p_func) {
return _names[p_func];
}
-void GDFunctions::call(Function p_func, const Variant **p_args, int p_arg_count, Variant &r_ret, Variant::CallError &r_error) {
+void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_count, Variant &r_ret, Variant::CallError &r_error) {
r_error.error = Variant::CallError::CALL_OK;
#ifdef DEBUG_ENABLED
@@ -641,7 +642,7 @@ void GDFunctions::call(Function p_func, const Variant **p_args, int p_arg_count,
}
//str+="\n";
- OS::get_singleton()->printerr("%s\n", str.utf8().get_data());
+ print_error(str);
r_ret = Variant();
} break;
@@ -899,7 +900,7 @@ void GDFunctions::call(Function p_func, const Variant **p_args, int p_arg_count,
return;
} else {
- GDInstance *ins = static_cast<GDInstance *>(obj->get_script_instance());
+ GDScriptInstance *ins = static_cast<GDScriptInstance *>(obj->get_script_instance());
Ref<GDScript> base = ins->get_script();
if (base.is_null()) {
@@ -1030,7 +1031,7 @@ void GDFunctions::call(Function p_func, const Variant **p_args, int p_arg_count,
r_ret = gdscr->_new(NULL, 0, r_error);
- GDInstance *ins = static_cast<GDInstance *>(static_cast<Object *>(r_ret)->get_script_instance());
+ GDScriptInstance *ins = static_cast<GDScriptInstance *>(static_cast<Object *>(r_ret)->get_script_instance());
Ref<GDScript> gd_ref = ins->get_script();
for (Map<StringName, GDScript::MemberInfo>::Element *E = gd_ref->member_indices.front(); E; E = E->next()) {
@@ -1254,7 +1255,7 @@ void GDFunctions::call(Function p_func, const Variant **p_args, int p_arg_count,
}
}
-bool GDFunctions::is_deterministic(Function p_func) {
+bool GDScriptFunctions::is_deterministic(Function p_func) {
//man i couldn't have chosen a worse function name,
//way too controversial..
@@ -1317,7 +1318,7 @@ bool GDFunctions::is_deterministic(Function p_func) {
return false;
}
-MethodInfo GDFunctions::get_info(Function p_func) {
+MethodInfo GDScriptFunctions::get_info(Function p_func) {
#ifdef TOOLS_ENABLED
//using a switch, so the compiler generates a jumptable
diff --git a/modules/gdscript/gd_functions.h b/modules/gdscript/gdscript_functions.h
index 0de09f2e71..ecbede83a8 100644
--- a/modules/gdscript/gd_functions.h
+++ b/modules/gdscript/gdscript_functions.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* gd_functions.h */
+/* gdscript_functions.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -27,12 +27,12 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef GD_FUNCTIONS_H
-#define GD_FUNCTIONS_H
+#ifndef GDSCRIPT_FUNCTIONS_H
+#define GDSCRIPT_FUNCTIONS_H
#include "variant.h"
-class GDFunctions {
+class GDScriptFunctions {
public:
enum Function {
MATH_SIN,
@@ -120,4 +120,4 @@ public:
static MethodInfo get_info(Function p_func);
};
-#endif // GD_FUNCTIONS_H
+#endif // GDSCRIPT_FUNCTIONS_H
diff --git a/modules/gdscript/gd_parser.cpp b/modules/gdscript/gdscript_parser.cpp
index d7e83c3a33..29b9865b1d 100644
--- a/modules/gdscript/gd_parser.cpp
+++ b/modules/gdscript/gdscript_parser.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* gd_parser.cpp */
+/* gdscript_parser.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -27,15 +27,16 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "gd_parser.h"
-#include "gd_script.h"
+#include "gdscript_parser.h"
+
+#include "gdscript.h"
#include "io/resource_loader.h"
#include "os/file_access.h"
#include "print_string.h"
#include "script_language.h"
template <class T>
-T *GDParser::alloc_node() {
+T *GDScriptParser::alloc_node() {
T *t = memnew(T);
@@ -50,21 +51,21 @@ T *GDParser::alloc_node() {
return t;
}
-bool GDParser::_end_statement() {
+bool GDScriptParser::_end_statement() {
- if (tokenizer->get_token() == GDTokenizer::TK_SEMICOLON) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_SEMICOLON) {
tokenizer->advance();
return true; //handle next
- } else if (tokenizer->get_token() == GDTokenizer::TK_NEWLINE || tokenizer->get_token() == GDTokenizer::TK_EOF) {
+ } else if (tokenizer->get_token() == GDScriptTokenizer::TK_NEWLINE || tokenizer->get_token() == GDScriptTokenizer::TK_EOF) {
return true; //will be handled properly
}
return false;
}
-bool GDParser::_enter_indent_block(BlockNode *p_block) {
+bool GDScriptParser::_enter_indent_block(BlockNode *p_block) {
- if (tokenizer->get_token() != GDTokenizer::TK_COLON) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_COLON) {
// report location at the previous token (on the previous line)
int error_line = tokenizer->get_token_line(-1);
int error_column = tokenizer->get_token_column(-1);
@@ -73,7 +74,7 @@ bool GDParser::_enter_indent_block(BlockNode *p_block) {
}
tokenizer->advance();
- if (tokenizer->get_token() != GDTokenizer::TK_NEWLINE) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_NEWLINE) {
// be more python-like
int current = tab_level.back()->get();
@@ -85,10 +86,10 @@ bool GDParser::_enter_indent_block(BlockNode *p_block) {
while (true) {
- if (tokenizer->get_token() != GDTokenizer::TK_NEWLINE) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_NEWLINE) {
return false; //wtf
- } else if (tokenizer->get_token(1) != GDTokenizer::TK_NEWLINE) {
+ } else if (tokenizer->get_token(1) != GDScriptTokenizer::TK_NEWLINE) {
int indent = tokenizer->get_token_line_indent();
int current = tab_level.back()->get();
@@ -113,9 +114,9 @@ bool GDParser::_enter_indent_block(BlockNode *p_block) {
}
}
-bool GDParser::_parse_arguments(Node *p_parent, Vector<Node *> &p_args, bool p_static, bool p_can_codecomplete) {
+bool GDScriptParser::_parse_arguments(Node *p_parent, Vector<Node *> &p_args, bool p_static, bool p_can_codecomplete) {
- if (tokenizer->get_token() == GDTokenizer::TK_PARENTHESIS_CLOSE) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_PARENTHESIS_CLOSE) {
tokenizer->advance();
} else {
@@ -124,10 +125,10 @@ bool GDParser::_parse_arguments(Node *p_parent, Vector<Node *> &p_args, bool p_s
while (true) {
- if (tokenizer->get_token() == GDTokenizer::TK_CURSOR) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_CURSOR) {
_make_completable_call(argidx);
completion_node = p_parent;
- } else if (tokenizer->get_token() == GDTokenizer::TK_CONSTANT && tokenizer->get_token_constant().get_type() == Variant::STRING && tokenizer->get_token(1) == GDTokenizer::TK_CURSOR) {
+ } else if (tokenizer->get_token() == GDScriptTokenizer::TK_CONSTANT && tokenizer->get_token_constant().get_type() == Variant::STRING && tokenizer->get_token(1) == GDScriptTokenizer::TK_CURSOR) {
//completing a string argument..
completion_cursor = tokenizer->get_token_constant();
@@ -143,13 +144,13 @@ bool GDParser::_parse_arguments(Node *p_parent, Vector<Node *> &p_args, bool p_s
p_args.push_back(arg);
- if (tokenizer->get_token() == GDTokenizer::TK_PARENTHESIS_CLOSE) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_PARENTHESIS_CLOSE) {
tokenizer->advance();
break;
- } else if (tokenizer->get_token() == GDTokenizer::TK_COMMA) {
+ } else if (tokenizer->get_token() == GDScriptTokenizer::TK_COMMA) {
- if (tokenizer->get_token(1) == GDTokenizer::TK_PARENTHESIS_CLOSE) {
+ if (tokenizer->get_token(1) == GDScriptTokenizer::TK_PARENTHESIS_CLOSE) {
_set_error("Expression expected");
return false;
@@ -169,7 +170,7 @@ bool GDParser::_parse_arguments(Node *p_parent, Vector<Node *> &p_args, bool p_s
return true;
}
-void GDParser::_make_completable_call(int p_arg) {
+void GDScriptParser::_make_completable_call(int p_arg) {
completion_cursor = StringName();
completion_type = COMPLETION_CALL_ARGUMENTS;
@@ -182,14 +183,14 @@ void GDParser::_make_completable_call(int p_arg) {
tokenizer->advance();
}
-bool GDParser::_get_completable_identifier(CompletionType p_type, StringName &identifier) {
+bool GDScriptParser::_get_completable_identifier(CompletionType p_type, StringName &identifier) {
identifier = StringName();
if (tokenizer->is_token_literal()) {
identifier = tokenizer->get_token_literal();
tokenizer->advance();
}
- if (tokenizer->get_token() == GDTokenizer::TK_CURSOR) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_CURSOR) {
completion_cursor = identifier;
completion_type = p_type;
@@ -206,7 +207,7 @@ bool GDParser::_get_completable_identifier(CompletionType p_type, StringName &id
tokenizer->advance();
}
- if (tokenizer->get_token() == GDTokenizer::TK_PARENTHESIS_OPEN) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_PARENTHESIS_OPEN) {
completion_ident_is_call = true;
}
return true;
@@ -215,7 +216,7 @@ bool GDParser::_get_completable_identifier(CompletionType p_type, StringName &id
return false;
}
-GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool p_allow_assign, bool p_parsing_constant) {
+GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_static, bool p_allow_assign, bool p_parsing_constant) {
//Vector<Node*> expressions;
//Vector<OperatorNode::Operator> operators;
@@ -234,12 +235,12 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool
if (parenthesis > 0) {
//remove empty space (only allowed if inside parenthesis
- while (tokenizer->get_token() == GDTokenizer::TK_NEWLINE) {
+ while (tokenizer->get_token() == GDScriptTokenizer::TK_NEWLINE) {
tokenizer->advance();
}
}
- if (tokenizer->get_token() == GDTokenizer::TK_PARENTHESIS_OPEN) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_PARENTHESIS_OPEN) {
//subexpression ()
tokenizer->advance();
parenthesis++;
@@ -248,7 +249,7 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool
if (!subexpr)
return NULL;
- if (tokenizer->get_token() != GDTokenizer::TK_PARENTHESIS_CLOSE) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_PARENTHESIS_CLOSE) {
_set_error("Expected ')' in expression");
return NULL;
@@ -256,7 +257,7 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool
tokenizer->advance();
expr = subexpr;
- } else if (tokenizer->get_token() == GDTokenizer::TK_DOLLAR) {
+ } else if (tokenizer->get_token() == GDScriptTokenizer::TK_DOLLAR) {
tokenizer->advance();
String path;
@@ -267,7 +268,7 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool
while (!done) {
switch (tokenizer->get_token()) {
- case GDTokenizer::TK_CURSOR: {
+ case GDScriptTokenizer::TK_CURSOR: {
completion_cursor = StringName();
completion_type = COMPLETION_GET_NODE;
completion_class = current_class;
@@ -279,7 +280,7 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool
completion_found = true;
tokenizer->advance();
} break;
- case GDTokenizer::TK_CONSTANT: {
+ case GDScriptTokenizer::TK_CONSTANT: {
if (!need_identifier) {
done = true;
@@ -296,7 +297,7 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool
need_identifier = false;
} break;
- case GDTokenizer::TK_OP_DIV: {
+ case GDScriptTokenizer::TK_OP_DIV: {
if (need_identifier) {
done = true;
@@ -344,56 +345,56 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool
expr = op;
- } else if (tokenizer->get_token() == GDTokenizer::TK_CURSOR) {
+ } else if (tokenizer->get_token() == GDScriptTokenizer::TK_CURSOR) {
tokenizer->advance();
continue; //no point in cursor in the middle of expression
- } else if (tokenizer->get_token() == GDTokenizer::TK_CONSTANT) {
+ } else if (tokenizer->get_token() == GDScriptTokenizer::TK_CONSTANT) {
//constant defined by tokenizer
ConstantNode *constant = alloc_node<ConstantNode>();
constant->value = tokenizer->get_token_constant();
tokenizer->advance();
expr = constant;
- } else if (tokenizer->get_token() == GDTokenizer::TK_CONST_PI) {
+ } else if (tokenizer->get_token() == GDScriptTokenizer::TK_CONST_PI) {
//constant defined by tokenizer
ConstantNode *constant = alloc_node<ConstantNode>();
constant->value = Math_PI;
tokenizer->advance();
expr = constant;
- } else if (tokenizer->get_token() == GDTokenizer::TK_CONST_TAU) {
+ } else if (tokenizer->get_token() == GDScriptTokenizer::TK_CONST_TAU) {
//constant defined by tokenizer
ConstantNode *constant = alloc_node<ConstantNode>();
constant->value = Math_TAU;
tokenizer->advance();
expr = constant;
- } else if (tokenizer->get_token() == GDTokenizer::TK_CONST_INF) {
+ } else if (tokenizer->get_token() == GDScriptTokenizer::TK_CONST_INF) {
//constant defined by tokenizer
ConstantNode *constant = alloc_node<ConstantNode>();
constant->value = Math_INF;
tokenizer->advance();
expr = constant;
- } else if (tokenizer->get_token() == GDTokenizer::TK_CONST_NAN) {
+ } else if (tokenizer->get_token() == GDScriptTokenizer::TK_CONST_NAN) {
//constant defined by tokenizer
ConstantNode *constant = alloc_node<ConstantNode>();
constant->value = Math_NAN;
tokenizer->advance();
expr = constant;
- } else if (tokenizer->get_token() == GDTokenizer::TK_PR_PRELOAD) {
+ } else if (tokenizer->get_token() == GDScriptTokenizer::TK_PR_PRELOAD) {
//constant defined by tokenizer
tokenizer->advance();
- if (tokenizer->get_token() != GDTokenizer::TK_PARENTHESIS_OPEN) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_PARENTHESIS_OPEN) {
_set_error("Expected '(' after 'preload'");
return NULL;
}
tokenizer->advance();
- if (tokenizer->get_token() == GDTokenizer::TK_CURSOR) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_CURSOR) {
completion_cursor = StringName();
completion_node = p_parent;
completion_type = COMPLETION_RESOURCE_PATH;
@@ -473,7 +474,7 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool
}
}
- if (tokenizer->get_token() != GDTokenizer::TK_PARENTHESIS_CLOSE) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_PARENTHESIS_CLOSE) {
_set_error("Expected ')' after 'preload' path");
return NULL;
}
@@ -483,12 +484,12 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool
constant->value = res;
expr = constant;
- } else if (tokenizer->get_token() == GDTokenizer::TK_PR_YIELD) {
+ } else if (tokenizer->get_token() == GDScriptTokenizer::TK_PR_YIELD) {
//constant defined by tokenizer
tokenizer->advance();
- if (tokenizer->get_token() != GDTokenizer::TK_PARENTHESIS_OPEN) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_PARENTHESIS_OPEN) {
_set_error("Expected '(' after 'yield'");
return NULL;
}
@@ -498,11 +499,11 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool
OperatorNode *yield = alloc_node<OperatorNode>();
yield->op = OperatorNode::OP_YIELD;
- while (tokenizer->get_token() == GDTokenizer::TK_NEWLINE) {
+ while (tokenizer->get_token() == GDScriptTokenizer::TK_NEWLINE) {
tokenizer->advance();
}
- if (tokenizer->get_token() == GDTokenizer::TK_PARENTHESIS_CLOSE) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_PARENTHESIS_CLOSE) {
expr = yield;
tokenizer->advance();
} else {
@@ -514,14 +515,14 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool
return NULL;
yield->arguments.push_back(object);
- if (tokenizer->get_token() != GDTokenizer::TK_COMMA) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_COMMA) {
_set_error("Expected ',' after first argument of 'yield'");
return NULL;
}
tokenizer->advance();
- if (tokenizer->get_token() == GDTokenizer::TK_CURSOR) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_CURSOR) {
completion_cursor = StringName();
completion_node = object;
@@ -540,7 +541,7 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool
return NULL;
yield->arguments.push_back(signal);
- if (tokenizer->get_token() != GDTokenizer::TK_PARENTHESIS_CLOSE) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_PARENTHESIS_CLOSE) {
_set_error("Expected ')' after second argument of 'yield'");
return NULL;
}
@@ -552,7 +553,7 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool
expr = yield;
}
- } else if (tokenizer->get_token() == GDTokenizer::TK_SELF) {
+ } else if (tokenizer->get_token() == GDScriptTokenizer::TK_SELF) {
if (p_static) {
_set_error("'self'' not allowed in static function or constant expression");
@@ -562,7 +563,7 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool
SelfNode *self = alloc_node<SelfNode>();
tokenizer->advance();
expr = self;
- } else if (tokenizer->get_token() == GDTokenizer::TK_BUILT_IN_TYPE && tokenizer->get_token(1) == GDTokenizer::TK_PERIOD) {
+ } else if (tokenizer->get_token() == GDScriptTokenizer::TK_BUILT_IN_TYPE && tokenizer->get_token(1) == GDScriptTokenizer::TK_PERIOD) {
Variant::Type bi_type = tokenizer->get_token_type();
tokenizer->advance(2);
@@ -589,20 +590,20 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool
cn->value = Variant::get_numeric_constant_value(bi_type, identifier);
expr = cn;
- } else if (tokenizer->get_token(1) == GDTokenizer::TK_PARENTHESIS_OPEN && tokenizer->is_token_literal()) {
+ } else if (tokenizer->get_token(1) == GDScriptTokenizer::TK_PARENTHESIS_OPEN && tokenizer->is_token_literal()) {
// We check with is_token_literal, as this allows us to use match/sync/etc. as a name
//function or constructor
OperatorNode *op = alloc_node<OperatorNode>();
op->op = OperatorNode::OP_CALL;
- if (tokenizer->get_token() == GDTokenizer::TK_BUILT_IN_TYPE) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_BUILT_IN_TYPE) {
TypeNode *tn = alloc_node<TypeNode>();
tn->vtype = tokenizer->get_token_type();
op->arguments.push_back(tn);
tokenizer->advance(2);
- } else if (tokenizer->get_token() == GDTokenizer::TK_BUILT_IN_FUNC) {
+ } else if (tokenizer->get_token() == GDScriptTokenizer::TK_BUILT_IN_FUNC) {
BuiltInFunctionNode *bn = alloc_node<BuiltInFunctionNode>();
bn->function = tokenizer->get_token_built_in_func();
@@ -623,7 +624,7 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool
tokenizer->advance(1);
}
- if (tokenizer->get_token() == GDTokenizer::TK_CURSOR) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_CURSOR) {
_make_completable_call(0);
completion_node = op;
}
@@ -668,7 +669,7 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool
expr = id;
}
- } else if (tokenizer->get_token() == GDTokenizer::TK_OP_ADD || tokenizer->get_token() == GDTokenizer::TK_OP_SUB || tokenizer->get_token() == GDTokenizer::TK_OP_NOT || tokenizer->get_token() == GDTokenizer::TK_OP_BIT_INVERT) {
+ } else if (tokenizer->get_token() == GDScriptTokenizer::TK_OP_ADD || tokenizer->get_token() == GDScriptTokenizer::TK_OP_SUB || tokenizer->get_token() == GDScriptTokenizer::TK_OP_NOT || tokenizer->get_token() == GDScriptTokenizer::TK_OP_BIT_INVERT) {
//single prefix operators like !expr +expr -expr ++expr --expr
alloc_node<OperatorNode>();
@@ -676,16 +677,16 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool
e.is_op = true;
switch (tokenizer->get_token()) {
- case GDTokenizer::TK_OP_ADD: e.op = OperatorNode::OP_POS; break;
- case GDTokenizer::TK_OP_SUB: e.op = OperatorNode::OP_NEG; break;
- case GDTokenizer::TK_OP_NOT: e.op = OperatorNode::OP_NOT; break;
- case GDTokenizer::TK_OP_BIT_INVERT: e.op = OperatorNode::OP_BIT_INVERT; break;
+ case GDScriptTokenizer::TK_OP_ADD: e.op = OperatorNode::OP_POS; break;
+ case GDScriptTokenizer::TK_OP_SUB: e.op = OperatorNode::OP_NEG; break;
+ case GDScriptTokenizer::TK_OP_NOT: e.op = OperatorNode::OP_NOT; break;
+ case GDScriptTokenizer::TK_OP_BIT_INVERT: e.op = OperatorNode::OP_BIT_INVERT; break;
default: {}
}
tokenizer->advance();
- if (e.op != OperatorNode::OP_NOT && tokenizer->get_token() == GDTokenizer::TK_OP_NOT) {
+ if (e.op != OperatorNode::OP_NOT && tokenizer->get_token() == GDScriptTokenizer::TK_OP_NOT) {
_set_error("Misplaced 'not'.");
return NULL;
}
@@ -700,7 +701,7 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool
op->arguments.push_back(subexpr);
expr=op;*/
- } else if (tokenizer->get_token() == GDTokenizer::TK_BRACKET_OPEN) {
+ } else if (tokenizer->get_token() == GDScriptTokenizer::TK_BRACKET_OPEN) {
// array
tokenizer->advance();
@@ -709,18 +710,18 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool
while (true) {
- if (tokenizer->get_token() == GDTokenizer::TK_EOF) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_EOF) {
_set_error("Unterminated array");
return NULL;
- } else if (tokenizer->get_token() == GDTokenizer::TK_BRACKET_CLOSE) {
+ } else if (tokenizer->get_token() == GDScriptTokenizer::TK_BRACKET_CLOSE) {
tokenizer->advance();
break;
- } else if (tokenizer->get_token() == GDTokenizer::TK_NEWLINE) {
+ } else if (tokenizer->get_token() == GDScriptTokenizer::TK_NEWLINE) {
tokenizer->advance(); //ignore newline
- } else if (tokenizer->get_token() == GDTokenizer::TK_COMMA) {
+ } else if (tokenizer->get_token() == GDScriptTokenizer::TK_COMMA) {
if (!expecting_comma) {
_set_error("expression or ']' expected");
return NULL;
@@ -743,7 +744,7 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool
}
expr = arr;
- } else if (tokenizer->get_token() == GDTokenizer::TK_CURLY_BRACKET_OPEN) {
+ } else if (tokenizer->get_token() == GDScriptTokenizer::TK_CURLY_BRACKET_OPEN) {
// array
tokenizer->advance();
@@ -765,12 +766,12 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool
while (true) {
- if (tokenizer->get_token() == GDTokenizer::TK_EOF) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_EOF) {
_set_error("Unterminated dictionary");
return NULL;
- } else if (tokenizer->get_token() == GDTokenizer::TK_CURLY_BRACKET_CLOSE) {
+ } else if (tokenizer->get_token() == GDScriptTokenizer::TK_CURLY_BRACKET_CLOSE) {
if (expecting == DICT_EXPECT_COLON) {
_set_error("':' expected");
@@ -782,10 +783,10 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool
}
tokenizer->advance();
break;
- } else if (tokenizer->get_token() == GDTokenizer::TK_NEWLINE) {
+ } else if (tokenizer->get_token() == GDScriptTokenizer::TK_NEWLINE) {
tokenizer->advance(); //ignore newline
- } else if (tokenizer->get_token() == GDTokenizer::TK_COMMA) {
+ } else if (tokenizer->get_token() == GDScriptTokenizer::TK_COMMA) {
if (expecting == DICT_EXPECT_KEY) {
_set_error("key or '}' expected");
@@ -803,7 +804,7 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool
expecting = DICT_EXPECT_KEY;
tokenizer->advance(); //ignore newline
- } else if (tokenizer->get_token() == GDTokenizer::TK_COLON) {
+ } else if (tokenizer->get_token() == GDScriptTokenizer::TK_COLON) {
if (expecting == DICT_EXPECT_KEY) {
_set_error("key or '}' expected");
@@ -833,7 +834,7 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool
if (expecting == DICT_EXPECT_KEY) {
- if (tokenizer->is_token_literal() && tokenizer->get_token(1) == GDTokenizer::TK_OP_ASSIGN) {
+ if (tokenizer->is_token_literal() && tokenizer->get_token(1) == GDScriptTokenizer::TK_OP_ASSIGN) {
// We check with is_token_literal, as this allows us to use match/sync/etc. as a name
//lua style identifier, easier to write
ConstantNode *cn = alloc_node<ConstantNode>();
@@ -856,8 +857,8 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool
return NULL;
expecting = DICT_EXPECT_COMMA;
- if (key->type == GDParser::Node::TYPE_CONSTANT) {
- Variant const &keyName = static_cast<const GDParser::ConstantNode *>(key)->value;
+ if (key->type == GDScriptParser::Node::TYPE_CONSTANT) {
+ Variant const &keyName = static_cast<const GDScriptParser::ConstantNode *>(key)->value;
if (keys.has(keyName)) {
_set_error("Duplicate key found in Dictionary literal");
@@ -877,7 +878,7 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool
expr = dict;
- } else if (tokenizer->get_token() == GDTokenizer::TK_PERIOD && (tokenizer->is_token_literal(1) || tokenizer->get_token(1) == GDTokenizer::TK_CURSOR) && tokenizer->get_token(2) == GDTokenizer::TK_PARENTHESIS_OPEN) {
+ } else if (tokenizer->get_token() == GDScriptTokenizer::TK_PERIOD && (tokenizer->is_token_literal(1) || tokenizer->get_token(1) == GDScriptTokenizer::TK_CURSOR) && tokenizer->get_token(2) == GDScriptTokenizer::TK_PARENTHESIS_OPEN) {
// We check with is_token_literal, as this allows us to use match/sync/etc. as a name
// parent call
@@ -914,7 +915,7 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool
}
if (!expr) {
- ERR_EXPLAIN("GDParser bug, couldn't figure out what expression is..");
+ ERR_EXPLAIN("GDScriptParser bug, couldn't figure out what expression is..");
ERR_FAIL_COND_V(!expr, NULL);
}
@@ -926,15 +927,15 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool
//expressions can be indexed any number of times
- if (tokenizer->get_token() == GDTokenizer::TK_PERIOD) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_PERIOD) {
//indexing using "."
- if (tokenizer->get_token(1) != GDTokenizer::TK_CURSOR && !tokenizer->is_token_literal(1)) {
+ if (tokenizer->get_token(1) != GDScriptTokenizer::TK_CURSOR && !tokenizer->is_token_literal(1)) {
// We check with is_token_literal, as this allows us to use match/sync/etc. as a name
_set_error("Expected identifier as member");
return NULL;
- } else if (tokenizer->get_token(2) == GDTokenizer::TK_PARENTHESIS_OPEN) {
+ } else if (tokenizer->get_token(2) == GDScriptTokenizer::TK_PARENTHESIS_OPEN) {
//call!!
OperatorNode *op = alloc_node<OperatorNode>();
op->op = OperatorNode::OP_CALL;
@@ -942,10 +943,10 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool
tokenizer->advance();
IdentifierNode *id = alloc_node<IdentifierNode>();
- if (tokenizer->get_token() == GDTokenizer::TK_BUILT_IN_FUNC) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_BUILT_IN_FUNC) {
//small hack so built in funcs don't obfuscate methods
- id->name = GDFunctions::get_func_name(tokenizer->get_token_built_in_func());
+ id->name = GDScriptFunctions::get_func_name(tokenizer->get_token_built_in_func());
tokenizer->advance();
} else {
@@ -962,7 +963,7 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool
op->arguments.push_back(id); // call func
//get arguments
tokenizer->advance(1);
- if (tokenizer->get_token() == GDTokenizer::TK_CURSOR) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_CURSOR) {
_make_completable_call(0);
completion_node = op;
}
@@ -997,7 +998,7 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool
expr = op;
}
- } else if (tokenizer->get_token() == GDTokenizer::TK_BRACKET_OPEN) {
+ } else if (tokenizer->get_token() == GDScriptTokenizer::TK_BRACKET_OPEN) {
//indexing using "[]"
OperatorNode *op = alloc_node<OperatorNode>();
op->op = OperatorNode::OP_INDEX;
@@ -1009,7 +1010,7 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool
return NULL;
}
- if (tokenizer->get_token() != GDTokenizer::TK_BRACKET_CLOSE) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_BRACKET_CLOSE) {
_set_error("Expected ']'");
return NULL;
}
@@ -1029,7 +1030,7 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool
if (parenthesis > 0) {
//remove empty space (only allowed if inside parenthesis
- while (tokenizer->get_token() == GDTokenizer::TK_NEWLINE) {
+ while (tokenizer->get_token() == GDScriptTokenizer::TK_NEWLINE) {
tokenizer->advance();
}
}
@@ -1054,29 +1055,29 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool
switch (tokenizer->get_token()) { //see operator
- case GDTokenizer::TK_OP_IN: op = OperatorNode::OP_IN; break;
- case GDTokenizer::TK_OP_EQUAL: op = OperatorNode::OP_EQUAL; break;
- case GDTokenizer::TK_OP_NOT_EQUAL: op = OperatorNode::OP_NOT_EQUAL; break;
- case GDTokenizer::TK_OP_LESS: op = OperatorNode::OP_LESS; break;
- case GDTokenizer::TK_OP_LESS_EQUAL: op = OperatorNode::OP_LESS_EQUAL; break;
- case GDTokenizer::TK_OP_GREATER: op = OperatorNode::OP_GREATER; break;
- case GDTokenizer::TK_OP_GREATER_EQUAL: op = OperatorNode::OP_GREATER_EQUAL; break;
- case GDTokenizer::TK_OP_AND: op = OperatorNode::OP_AND; break;
- case GDTokenizer::TK_OP_OR: op = OperatorNode::OP_OR; break;
- case GDTokenizer::TK_OP_ADD: op = OperatorNode::OP_ADD; break;
- case GDTokenizer::TK_OP_SUB: op = OperatorNode::OP_SUB; break;
- case GDTokenizer::TK_OP_MUL: op = OperatorNode::OP_MUL; break;
- case GDTokenizer::TK_OP_DIV: op = OperatorNode::OP_DIV; break;
- case GDTokenizer::TK_OP_MOD:
+ case GDScriptTokenizer::TK_OP_IN: op = OperatorNode::OP_IN; break;
+ case GDScriptTokenizer::TK_OP_EQUAL: op = OperatorNode::OP_EQUAL; break;
+ case GDScriptTokenizer::TK_OP_NOT_EQUAL: op = OperatorNode::OP_NOT_EQUAL; break;
+ case GDScriptTokenizer::TK_OP_LESS: op = OperatorNode::OP_LESS; break;
+ case GDScriptTokenizer::TK_OP_LESS_EQUAL: op = OperatorNode::OP_LESS_EQUAL; break;
+ case GDScriptTokenizer::TK_OP_GREATER: op = OperatorNode::OP_GREATER; break;
+ case GDScriptTokenizer::TK_OP_GREATER_EQUAL: op = OperatorNode::OP_GREATER_EQUAL; break;
+ case GDScriptTokenizer::TK_OP_AND: op = OperatorNode::OP_AND; break;
+ case GDScriptTokenizer::TK_OP_OR: op = OperatorNode::OP_OR; break;
+ case GDScriptTokenizer::TK_OP_ADD: op = OperatorNode::OP_ADD; break;
+ case GDScriptTokenizer::TK_OP_SUB: op = OperatorNode::OP_SUB; break;
+ case GDScriptTokenizer::TK_OP_MUL: op = OperatorNode::OP_MUL; break;
+ case GDScriptTokenizer::TK_OP_DIV: op = OperatorNode::OP_DIV; break;
+ case GDScriptTokenizer::TK_OP_MOD:
op = OperatorNode::OP_MOD;
break;
- //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: {
+ //case GDScriptTokenizer::TK_OP_NEG: op=OperatorNode::OP_NEG ; break;
+ case GDScriptTokenizer::TK_OP_SHIFT_LEFT: op = OperatorNode::OP_SHIFT_LEFT; break;
+ case GDScriptTokenizer::TK_OP_SHIFT_RIGHT: op = OperatorNode::OP_SHIFT_RIGHT; break;
+ case GDScriptTokenizer::TK_OP_ASSIGN: {
_VALIDATE_ASSIGN op = OperatorNode::OP_ASSIGN;
- if (tokenizer->get_token(1) == GDTokenizer::TK_CURSOR) {
+ if (tokenizer->get_token(1) == GDScriptTokenizer::TK_CURSOR) {
//code complete assignment
completion_type = COMPLETION_ASSIGN;
completion_node = expr;
@@ -1089,22 +1090,22 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool
}
} 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;
- case GDTokenizer::TK_OP_ASSIGN_DIV: _VALIDATE_ASSIGN op = OperatorNode::OP_ASSIGN_DIV; break;
- case GDTokenizer::TK_OP_ASSIGN_MOD: _VALIDATE_ASSIGN op = OperatorNode::OP_ASSIGN_MOD; break;
- case GDTokenizer::TK_OP_ASSIGN_SHIFT_LEFT: _VALIDATE_ASSIGN op = OperatorNode::OP_ASSIGN_SHIFT_LEFT; break;
- case GDTokenizer::TK_OP_ASSIGN_SHIFT_RIGHT: _VALIDATE_ASSIGN op = OperatorNode::OP_ASSIGN_SHIFT_RIGHT; break;
- case GDTokenizer::TK_OP_ASSIGN_BIT_AND: _VALIDATE_ASSIGN op = OperatorNode::OP_ASSIGN_BIT_AND; break;
- case GDTokenizer::TK_OP_ASSIGN_BIT_OR: _VALIDATE_ASSIGN op = OperatorNode::OP_ASSIGN_BIT_OR; break;
- case GDTokenizer::TK_OP_ASSIGN_BIT_XOR: _VALIDATE_ASSIGN op = OperatorNode::OP_ASSIGN_BIT_XOR; break;
- case GDTokenizer::TK_OP_BIT_AND: op = OperatorNode::OP_BIT_AND; break;
- case GDTokenizer::TK_OP_BIT_OR: op = OperatorNode::OP_BIT_OR; break;
- case GDTokenizer::TK_OP_BIT_XOR: op = OperatorNode::OP_BIT_XOR; break;
- case GDTokenizer::TK_PR_IS: op = OperatorNode::OP_IS; break;
- case GDTokenizer::TK_CF_IF: op = OperatorNode::OP_TERNARY_IF; break;
- case GDTokenizer::TK_CF_ELSE: op = OperatorNode::OP_TERNARY_ELSE; break;
+ case GDScriptTokenizer::TK_OP_ASSIGN_ADD: _VALIDATE_ASSIGN op = OperatorNode::OP_ASSIGN_ADD; break;
+ case GDScriptTokenizer::TK_OP_ASSIGN_SUB: _VALIDATE_ASSIGN op = OperatorNode::OP_ASSIGN_SUB; break;
+ case GDScriptTokenizer::TK_OP_ASSIGN_MUL: _VALIDATE_ASSIGN op = OperatorNode::OP_ASSIGN_MUL; break;
+ case GDScriptTokenizer::TK_OP_ASSIGN_DIV: _VALIDATE_ASSIGN op = OperatorNode::OP_ASSIGN_DIV; break;
+ case GDScriptTokenizer::TK_OP_ASSIGN_MOD: _VALIDATE_ASSIGN op = OperatorNode::OP_ASSIGN_MOD; break;
+ case GDScriptTokenizer::TK_OP_ASSIGN_SHIFT_LEFT: _VALIDATE_ASSIGN op = OperatorNode::OP_ASSIGN_SHIFT_LEFT; break;
+ case GDScriptTokenizer::TK_OP_ASSIGN_SHIFT_RIGHT: _VALIDATE_ASSIGN op = OperatorNode::OP_ASSIGN_SHIFT_RIGHT; break;
+ case GDScriptTokenizer::TK_OP_ASSIGN_BIT_AND: _VALIDATE_ASSIGN op = OperatorNode::OP_ASSIGN_BIT_AND; break;
+ case GDScriptTokenizer::TK_OP_ASSIGN_BIT_OR: _VALIDATE_ASSIGN op = OperatorNode::OP_ASSIGN_BIT_OR; break;
+ case GDScriptTokenizer::TK_OP_ASSIGN_BIT_XOR: _VALIDATE_ASSIGN op = OperatorNode::OP_ASSIGN_BIT_XOR; break;
+ case GDScriptTokenizer::TK_OP_BIT_AND: op = OperatorNode::OP_BIT_AND; break;
+ case GDScriptTokenizer::TK_OP_BIT_OR: op = OperatorNode::OP_BIT_OR; break;
+ case GDScriptTokenizer::TK_OP_BIT_XOR: op = OperatorNode::OP_BIT_XOR; break;
+ case GDScriptTokenizer::TK_PR_IS: op = OperatorNode::OP_IS; break;
+ case GDScriptTokenizer::TK_CF_IF: op = OperatorNode::OP_TERNARY_IF; break;
+ case GDScriptTokenizer::TK_CF_ELSE: op = OperatorNode::OP_TERNARY_ELSE; break;
default: valid = false; break;
}
@@ -1212,7 +1213,7 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool
case OperatorNode::OP_ASSIGN_BIT_XOR: priority = 15; break;
default: {
- _set_error("GDParser bug, invalid operator in expression: " + itos(expression[i].op));
+ _set_error("GDScriptParser bug, invalid operator in expression: " + itos(expression[i].op));
return NULL;
}
}
@@ -1358,7 +1359,7 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool
return expression[0].node;
}
-GDParser::Node *GDParser::_reduce_expression(Node *p_node, bool p_to_const) {
+GDScriptParser::Node *GDScriptParser::_reduce_expression(Node *p_node, bool p_to_const) {
switch (p_node->type) {
@@ -1455,7 +1456,7 @@ GDParser::Node *GDParser::_reduce_expression(Node *p_node, bool p_to_const) {
} else if (op->op == OperatorNode::OP_CALL) {
//can reduce base type constructors
- if ((op->arguments[0]->type == Node::TYPE_TYPE || (op->arguments[0]->type == Node::TYPE_BUILT_IN_FUNCTION && GDFunctions::is_deterministic(static_cast<BuiltInFunctionNode *>(op->arguments[0])->function))) && last_not_constant == 0) {
+ if ((op->arguments[0]->type == Node::TYPE_TYPE || (op->arguments[0]->type == Node::TYPE_BUILT_IN_FUNCTION && GDScriptFunctions::is_deterministic(static_cast<BuiltInFunctionNode *>(op->arguments[0])->function))) && last_not_constant == 0) {
//native type constructor or intrinsic function
const Variant **vptr = NULL;
@@ -1480,8 +1481,8 @@ GDParser::Node *GDParser::_reduce_expression(Node *p_node, bool p_to_const) {
v = Variant::construct(tn->vtype, vptr, ptrs.size(), ce);
} else {
- GDFunctions::Function func = static_cast<BuiltInFunctionNode *>(op->arguments[0])->function;
- GDFunctions::call(func, vptr, ptrs.size(), v, ce);
+ GDScriptFunctions::Function func = static_cast<BuiltInFunctionNode *>(op->arguments[0])->function;
+ GDScriptFunctions::call(func, vptr, ptrs.size(), v, ce);
}
if (ce.error != Variant::CallError::CALL_OK) {
@@ -1492,8 +1493,8 @@ GDParser::Node *GDParser::_reduce_expression(Node *p_node, bool p_to_const) {
errwhere = "'" + Variant::get_type_name(tn->vtype) + "'' constructor";
} else {
- GDFunctions::Function func = static_cast<BuiltInFunctionNode *>(op->arguments[0])->function;
- errwhere = String("'") + GDFunctions::get_func_name(func) + "'' intrinsic function";
+ GDScriptFunctions::Function func = static_cast<BuiltInFunctionNode *>(op->arguments[0])->function;
+ errwhere = String("'") + GDScriptFunctions::get_func_name(func) + "'' intrinsic function";
}
switch (ce.error) {
@@ -1743,7 +1744,7 @@ GDParser::Node *GDParser::_reduce_expression(Node *p_node, bool p_to_const) {
}
}
-GDParser::Node *GDParser::_parse_and_reduce_expression(Node *p_parent, bool p_static, bool p_reduce_const, bool p_allow_assign) {
+GDScriptParser::Node *GDScriptParser::_parse_and_reduce_expression(Node *p_parent, bool p_static, bool p_reduce_const, bool p_allow_assign) {
Node *expr = _parse_expression(p_parent, p_static, p_allow_assign, p_reduce_const);
if (!expr || error_set)
@@ -1754,58 +1755,58 @@ GDParser::Node *GDParser::_parse_and_reduce_expression(Node *p_parent, bool p_st
return expr;
}
-bool GDParser::_recover_from_completion() {
+bool GDScriptParser::_recover_from_completion() {
if (!completion_found) {
return false; //can't recover if no completion
}
//skip stuff until newline
- while (tokenizer->get_token() != GDTokenizer::TK_NEWLINE && tokenizer->get_token() != GDTokenizer::TK_EOF && tokenizer->get_token() != GDTokenizer::TK_ERROR) {
+ while (tokenizer->get_token() != GDScriptTokenizer::TK_NEWLINE && tokenizer->get_token() != GDScriptTokenizer::TK_EOF && tokenizer->get_token() != GDScriptTokenizer::TK_ERROR) {
tokenizer->advance();
}
completion_found = false;
error_set = false;
- if (tokenizer->get_token() == GDTokenizer::TK_ERROR) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_ERROR) {
error_set = true;
}
return true;
}
-GDParser::PatternNode *GDParser::_parse_pattern(bool p_static) {
+GDScriptParser::PatternNode *GDScriptParser::_parse_pattern(bool p_static) {
PatternNode *pattern = alloc_node<PatternNode>();
- GDTokenizer::Token token = tokenizer->get_token();
+ GDScriptTokenizer::Token token = tokenizer->get_token();
if (error_set)
return NULL;
- if (token == GDTokenizer::TK_EOF) {
+ if (token == GDScriptTokenizer::TK_EOF) {
return NULL;
}
switch (token) {
// array
- case GDTokenizer::TK_BRACKET_OPEN: {
+ case GDScriptTokenizer::TK_BRACKET_OPEN: {
tokenizer->advance();
- pattern->pt_type = GDParser::PatternNode::PT_ARRAY;
+ pattern->pt_type = GDScriptParser::PatternNode::PT_ARRAY;
while (true) {
- if (tokenizer->get_token() == GDTokenizer::TK_BRACKET_CLOSE) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_BRACKET_CLOSE) {
tokenizer->advance();
break;
}
- if (tokenizer->get_token() == GDTokenizer::TK_PERIOD && tokenizer->get_token(1) == GDTokenizer::TK_PERIOD) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_PERIOD && tokenizer->get_token(1) == GDScriptTokenizer::TK_PERIOD) {
// match everything
tokenizer->advance(2);
PatternNode *sub_pattern = alloc_node<PatternNode>();
- sub_pattern->pt_type = GDParser::PatternNode::PT_IGNORE_REST;
+ sub_pattern->pt_type = GDScriptParser::PatternNode::PT_IGNORE_REST;
pattern->array.push_back(sub_pattern);
- if (tokenizer->get_token() == GDTokenizer::TK_COMMA && tokenizer->get_token(1) == GDTokenizer::TK_BRACKET_CLOSE) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_COMMA && tokenizer->get_token(1) == GDScriptTokenizer::TK_BRACKET_CLOSE) {
tokenizer->advance(2);
break;
- } else if (tokenizer->get_token() == GDTokenizer::TK_BRACKET_CLOSE) {
+ } else if (tokenizer->get_token() == GDScriptTokenizer::TK_BRACKET_CLOSE) {
tokenizer->advance(1);
break;
} else {
@@ -1821,10 +1822,10 @@ GDParser::PatternNode *GDParser::_parse_pattern(bool p_static) {
pattern->array.push_back(sub_pattern);
- if (tokenizer->get_token() == GDTokenizer::TK_COMMA) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_COMMA) {
tokenizer->advance();
continue;
- } else if (tokenizer->get_token() == GDTokenizer::TK_BRACKET_CLOSE) {
+ } else if (tokenizer->get_token() == GDScriptTokenizer::TK_BRACKET_CLOSE) {
tokenizer->advance();
break;
} else {
@@ -1834,33 +1835,33 @@ GDParser::PatternNode *GDParser::_parse_pattern(bool p_static) {
}
} break;
// bind
- case GDTokenizer::TK_PR_VAR: {
+ case GDScriptTokenizer::TK_PR_VAR: {
tokenizer->advance();
- pattern->pt_type = GDParser::PatternNode::PT_BIND;
+ pattern->pt_type = GDScriptParser::PatternNode::PT_BIND;
pattern->bind = tokenizer->get_token_identifier();
tokenizer->advance();
} break;
// dictionary
- case GDTokenizer::TK_CURLY_BRACKET_OPEN: {
+ case GDScriptTokenizer::TK_CURLY_BRACKET_OPEN: {
tokenizer->advance();
- pattern->pt_type = GDParser::PatternNode::PT_DICTIONARY;
+ pattern->pt_type = GDScriptParser::PatternNode::PT_DICTIONARY;
while (true) {
- if (tokenizer->get_token() == GDTokenizer::TK_CURLY_BRACKET_CLOSE) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_CURLY_BRACKET_CLOSE) {
tokenizer->advance();
break;
}
- if (tokenizer->get_token() == GDTokenizer::TK_PERIOD && tokenizer->get_token(1) == GDTokenizer::TK_PERIOD) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_PERIOD && tokenizer->get_token(1) == GDScriptTokenizer::TK_PERIOD) {
// match everything
tokenizer->advance(2);
PatternNode *sub_pattern = alloc_node<PatternNode>();
sub_pattern->pt_type = PatternNode::PT_IGNORE_REST;
pattern->array.push_back(sub_pattern);
- if (tokenizer->get_token() == GDTokenizer::TK_COMMA && tokenizer->get_token(1) == GDTokenizer::TK_CURLY_BRACKET_CLOSE) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_COMMA && tokenizer->get_token(1) == GDScriptTokenizer::TK_CURLY_BRACKET_CLOSE) {
tokenizer->advance(2);
break;
- } else if (tokenizer->get_token() == GDTokenizer::TK_CURLY_BRACKET_CLOSE) {
+ } else if (tokenizer->get_token() == GDScriptTokenizer::TK_CURLY_BRACKET_CLOSE) {
tokenizer->advance(1);
break;
} else {
@@ -1875,12 +1876,12 @@ GDParser::PatternNode *GDParser::_parse_pattern(bool p_static) {
return NULL;
}
- if (key->type != GDParser::Node::TYPE_CONSTANT) {
+ if (key->type != GDScriptParser::Node::TYPE_CONSTANT) {
_set_error("Not a constant expression as key");
return NULL;
}
- if (tokenizer->get_token() == GDTokenizer::TK_COLON) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_COLON) {
tokenizer->advance();
PatternNode *value = _parse_pattern(p_static);
@@ -1894,10 +1895,10 @@ GDParser::PatternNode *GDParser::_parse_pattern(bool p_static) {
pattern->dictionary.insert(static_cast<ConstantNode *>(key), NULL);
}
- if (tokenizer->get_token() == GDTokenizer::TK_COMMA) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_COMMA) {
tokenizer->advance();
continue;
- } else if (tokenizer->get_token() == GDTokenizer::TK_CURLY_BRACKET_CLOSE) {
+ } else if (tokenizer->get_token() == GDScriptTokenizer::TK_CURLY_BRACKET_CLOSE) {
tokenizer->advance();
break;
} else {
@@ -1906,7 +1907,7 @@ GDParser::PatternNode *GDParser::_parse_pattern(bool p_static) {
}
}
} break;
- case GDTokenizer::TK_WILDCARD: {
+ case GDScriptTokenizer::TK_WILDCARD: {
tokenizer->advance();
pattern->pt_type = PatternNode::PT_WILDCARD;
} break;
@@ -1950,15 +1951,15 @@ GDParser::PatternNode *GDParser::_parse_pattern(bool p_static) {
return pattern;
}
-void GDParser::_parse_pattern_block(BlockNode *p_block, Vector<PatternBranchNode *> &p_branches, bool p_static) {
+void GDScriptParser::_parse_pattern_block(BlockNode *p_block, Vector<PatternBranchNode *> &p_branches, bool p_static) {
int indent_level = tab_level.back()->get();
while (true) {
- while (tokenizer->get_token() == GDTokenizer::TK_NEWLINE && _parse_newline())
+ while (tokenizer->get_token() == GDScriptTokenizer::TK_NEWLINE && _parse_newline())
;
- // GDTokenizer::Token token = tokenizer->get_token();
+ // GDScriptTokenizer::Token token = tokenizer->get_token();
if (error_set)
return;
@@ -1977,7 +1978,7 @@ void GDParser::_parse_pattern_block(BlockNode *p_block, Vector<PatternBranchNode
return;
}
- while (tokenizer->get_token() == GDTokenizer::TK_COMMA) {
+ while (tokenizer->get_token() == GDScriptTokenizer::TK_COMMA) {
tokenizer->advance();
branch->patterns.push_back(_parse_pattern(p_static));
if (!branch->patterns[branch->patterns.size() - 1]) {
@@ -2003,13 +2004,13 @@ void GDParser::_parse_pattern_block(BlockNode *p_block, Vector<PatternBranchNode
}
}
-void GDParser::_generate_pattern(PatternNode *p_pattern, Node *p_node_to_match, Node *&p_resulting_node, Map<StringName, Node *> &p_bindings) {
+void GDScriptParser::_generate_pattern(PatternNode *p_pattern, Node *p_node_to_match, Node *&p_resulting_node, Map<StringName, Node *> &p_bindings) {
switch (p_pattern->pt_type) {
case PatternNode::PT_CONSTANT: {
// typecheck
BuiltInFunctionNode *typeof_node = alloc_node<BuiltInFunctionNode>();
- typeof_node->function = GDFunctions::TYPE_OF;
+ typeof_node->function = GDScriptFunctions::TYPE_OF;
OperatorNode *typeof_match_value = alloc_node<OperatorNode>();
typeof_match_value->op = OperatorNode::OP_CALL;
@@ -2064,7 +2065,7 @@ void GDParser::_generate_pattern(PatternNode *p_pattern, Node *p_node_to_match,
{
// typecheck
BuiltInFunctionNode *typeof_node = alloc_node<BuiltInFunctionNode>();
- typeof_node->function = GDFunctions::TYPE_OF;
+ typeof_node->function = GDScriptFunctions::TYPE_OF;
OperatorNode *typeof_match_value = alloc_node<OperatorNode>();
typeof_match_value->op = OperatorNode::OP_CALL;
@@ -2143,7 +2144,7 @@ void GDParser::_generate_pattern(PatternNode *p_pattern, Node *p_node_to_match,
{
// typecheck
BuiltInFunctionNode *typeof_node = alloc_node<BuiltInFunctionNode>();
- typeof_node->function = GDFunctions::TYPE_OF;
+ typeof_node->function = GDScriptFunctions::TYPE_OF;
OperatorNode *typeof_match_value = alloc_node<OperatorNode>();
typeof_match_value->op = OperatorNode::OP_CALL;
@@ -2241,7 +2242,7 @@ void GDParser::_generate_pattern(PatternNode *p_pattern, Node *p_node_to_match,
}
}
-void GDParser::_transform_match_statment(BlockNode *p_block, MatchNode *p_match_statement) {
+void GDScriptParser::_transform_match_statment(BlockNode *p_block, MatchNode *p_match_statement) {
IdentifierNode *id = alloc_node<IdentifierNode>();
id->name = "#match_value";
@@ -2305,7 +2306,7 @@ void GDParser::_transform_match_statment(BlockNode *p_block, MatchNode *p_match_
}
}
-void GDParser::_parse_block(BlockNode *p_block, bool p_static) {
+void GDScriptParser::_parse_block(BlockNode *p_block, bool p_static) {
int indent_level = tab_level.back()->get();
@@ -2328,7 +2329,7 @@ void GDParser::_parse_block(BlockNode *p_block, bool p_static) {
}
is_first_line = false;
- GDTokenizer::Token token = tokenizer->get_token();
+ GDScriptTokenizer::Token token = tokenizer->get_token();
if (error_set)
return;
@@ -2347,15 +2348,15 @@ void GDParser::_parse_block(BlockNode *p_block, bool p_static) {
switch (token) {
- case GDTokenizer::TK_EOF:
+ case GDScriptTokenizer::TK_EOF:
p_block->end_line = tokenizer->get_token_line();
- case GDTokenizer::TK_ERROR: {
+ case GDScriptTokenizer::TK_ERROR: {
return; //go back
//end of file!
} break;
- case GDTokenizer::TK_NEWLINE: {
+ case GDScriptTokenizer::TK_NEWLINE: {
if (!_parse_newline()) {
if (!error_set) {
@@ -2370,19 +2371,19 @@ void GDParser::_parse_block(BlockNode *p_block, bool p_static) {
p_block->statements.push_back(nl);
} break;
- case GDTokenizer::TK_CF_PASS: {
- if (tokenizer->get_token(1) != GDTokenizer::TK_SEMICOLON && tokenizer->get_token(1) != GDTokenizer::TK_NEWLINE && tokenizer->get_token(1) != GDTokenizer::TK_EOF) {
+ case GDScriptTokenizer::TK_CF_PASS: {
+ if (tokenizer->get_token(1) != GDScriptTokenizer::TK_SEMICOLON && tokenizer->get_token(1) != GDScriptTokenizer::TK_NEWLINE && tokenizer->get_token(1) != GDScriptTokenizer::TK_EOF) {
_set_error("Expected ';' or <NewLine>.");
return;
}
tokenizer->advance();
- if (tokenizer->get_token() == GDTokenizer::TK_SEMICOLON) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_SEMICOLON) {
// Ignore semicolon after 'pass'
tokenizer->advance();
}
} break;
- case GDTokenizer::TK_PR_VAR: {
+ case GDScriptTokenizer::TK_PR_VAR: {
//variale declaration and (eventual) initialization
tokenizer->advance();
@@ -2421,7 +2422,7 @@ void GDParser::_parse_block(BlockNode *p_block, bool p_static) {
Node *assigned = NULL;
- if (tokenizer->get_token() == GDTokenizer::TK_OP_ASSIGN) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_OP_ASSIGN) {
tokenizer->advance();
Node *subexpr = _parse_and_reduce_expression(p_block, p_static);
@@ -2459,7 +2460,7 @@ void GDParser::_parse_block(BlockNode *p_block, bool p_static) {
}
} break;
- case GDTokenizer::TK_CF_IF: {
+ case GDScriptTokenizer::TK_CF_IF: {
tokenizer->advance();
@@ -2498,7 +2499,7 @@ void GDParser::_parse_block(BlockNode *p_block, bool p_static) {
while (true) {
- while (tokenizer->get_token() == GDTokenizer::TK_NEWLINE && _parse_newline())
+ while (tokenizer->get_token() == GDScriptTokenizer::TK_NEWLINE && _parse_newline())
;
if (tab_level.back()->get() < indent_level) { //not at current indent level
@@ -2506,7 +2507,7 @@ void GDParser::_parse_block(BlockNode *p_block, bool p_static) {
return;
}
- if (tokenizer->get_token() == GDTokenizer::TK_CF_ELIF) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_CF_ELIF) {
if (tab_level.back()->get() > indent_level) {
@@ -2552,7 +2553,7 @@ void GDParser::_parse_block(BlockNode *p_block, bool p_static) {
if (error_set)
return;
- } else if (tokenizer->get_token() == GDTokenizer::TK_CF_ELSE) {
+ } else if (tokenizer->get_token() == GDScriptTokenizer::TK_CF_ELSE) {
if (tab_level.back()->get() > indent_level) {
_set_error("Invalid indent");
@@ -2582,7 +2583,7 @@ void GDParser::_parse_block(BlockNode *p_block, bool p_static) {
}
} break;
- case GDTokenizer::TK_CF_WHILE: {
+ case GDScriptTokenizer::TK_CF_WHILE: {
tokenizer->advance();
Node *condition = _parse_and_reduce_expression(p_block, p_static);
@@ -2615,7 +2616,7 @@ void GDParser::_parse_block(BlockNode *p_block, bool p_static) {
return;
p_block->statements.push_back(cf_while);
} break;
- case GDTokenizer::TK_CF_FOR: {
+ case GDScriptTokenizer::TK_CF_FOR: {
tokenizer->advance();
@@ -2629,7 +2630,7 @@ void GDParser::_parse_block(BlockNode *p_block, bool p_static) {
tokenizer->advance();
- if (tokenizer->get_token() != GDTokenizer::TK_OP_IN) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_OP_IN) {
_set_error("'in' expected after identifier");
return;
}
@@ -2647,7 +2648,7 @@ void GDParser::_parse_block(BlockNode *p_block, bool p_static) {
if (container->type == Node::TYPE_OPERATOR) {
OperatorNode *op = static_cast<OperatorNode *>(container);
- if (op->op == OperatorNode::OP_CALL && op->arguments[0]->type == Node::TYPE_BUILT_IN_FUNCTION && static_cast<BuiltInFunctionNode *>(op->arguments[0])->function == GDFunctions::GEN_RANGE) {
+ if (op->op == OperatorNode::OP_CALL && op->arguments[0]->type == Node::TYPE_BUILT_IN_FUNCTION && static_cast<BuiltInFunctionNode *>(op->arguments[0])->function == GDScriptFunctions::GEN_RANGE) {
//iterating a range, so see if range() can be optimized without allocating memory, by replacing it by vectors (which can work as iterable too!)
Vector<Node *> args;
@@ -2733,7 +2734,7 @@ void GDParser::_parse_block(BlockNode *p_block, bool p_static) {
return;
p_block->statements.push_back(cf_for);
} break;
- case GDTokenizer::TK_CF_CONTINUE: {
+ case GDScriptTokenizer::TK_CF_CONTINUE: {
tokenizer->advance();
ControlFlowNode *cf_continue = alloc_node<ControlFlowNode>();
@@ -2744,7 +2745,7 @@ void GDParser::_parse_block(BlockNode *p_block, bool p_static) {
return;
}
} break;
- case GDTokenizer::TK_CF_BREAK: {
+ case GDScriptTokenizer::TK_CF_BREAK: {
tokenizer->advance();
ControlFlowNode *cf_break = alloc_node<ControlFlowNode>();
@@ -2755,13 +2756,13 @@ void GDParser::_parse_block(BlockNode *p_block, bool p_static) {
return;
}
} break;
- case GDTokenizer::TK_CF_RETURN: {
+ case GDScriptTokenizer::TK_CF_RETURN: {
tokenizer->advance();
ControlFlowNode *cf_return = alloc_node<ControlFlowNode>();
cf_return->cf_type = ControlFlowNode::CF_RETURN;
- if (tokenizer->get_token() == GDTokenizer::TK_SEMICOLON || tokenizer->get_token() == GDTokenizer::TK_NEWLINE || tokenizer->get_token() == GDTokenizer::TK_EOF) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_SEMICOLON || tokenizer->get_token() == GDScriptTokenizer::TK_NEWLINE || tokenizer->get_token() == GDScriptTokenizer::TK_EOF) {
//expect end of statement
p_block->statements.push_back(cf_return);
if (!_end_statement()) {
@@ -2785,7 +2786,7 @@ void GDParser::_parse_block(BlockNode *p_block, bool p_static) {
}
} break;
- case GDTokenizer::TK_CF_MATCH: {
+ case GDScriptTokenizer::TK_CF_MATCH: {
tokenizer->advance();
@@ -2825,7 +2826,7 @@ void GDParser::_parse_block(BlockNode *p_block, bool p_static) {
_end_statement();
} break;
- case GDTokenizer::TK_PR_ASSERT: {
+ case GDScriptTokenizer::TK_PR_ASSERT: {
tokenizer->advance();
Node *condition = _parse_and_reduce_expression(p_block, p_static);
@@ -2844,7 +2845,7 @@ void GDParser::_parse_block(BlockNode *p_block, bool p_static) {
return;
}
} break;
- case GDTokenizer::TK_PR_BREAKPOINT: {
+ case GDScriptTokenizer::TK_PR_BREAKPOINT: {
tokenizer->advance();
BreakpointNode *bn = alloc_node<BreakpointNode>();
@@ -2872,9 +2873,9 @@ void GDParser::_parse_block(BlockNode *p_block, bool p_static) {
} break;
/*
- case GDTokenizer::TK_CF_LOCAL: {
+ case GDScriptTokenizer::TK_CF_LOCAL: {
- if (tokenizer->get_token(1)!=GDTokenizer::TK_SEMICOLON && tokenizer->get_token(1)!=GDTokenizer::TK_NEWLINE ) {
+ if (tokenizer->get_token(1)!=GDScriptTokenizer::TK_SEMICOLON && tokenizer->get_token(1)!=GDScriptTokenizer::TK_NEWLINE ) {
_set_error("Expected ';' or <NewLine>.");
}
@@ -2885,9 +2886,9 @@ void GDParser::_parse_block(BlockNode *p_block, bool p_static) {
}
}
-bool GDParser::_parse_newline() {
+bool GDScriptParser::_parse_newline() {
- if (tokenizer->get_token(1) != GDTokenizer::TK_EOF && tokenizer->get_token(1) != GDTokenizer::TK_NEWLINE) {
+ if (tokenizer->get_token(1) != GDScriptTokenizer::TK_EOF && tokenizer->get_token(1) != GDScriptTokenizer::TK_NEWLINE) {
int indent = tokenizer->get_token_line_indent();
int current_indent = tab_level.back()->get();
@@ -2926,7 +2927,7 @@ bool GDParser::_parse_newline() {
return true;
}
-void GDParser::_parse_extends(ClassNode *p_class) {
+void GDScriptParser::_parse_extends(ClassNode *p_class) {
if (p_class->extends_used) {
@@ -2944,14 +2945,14 @@ void GDParser::_parse_extends(ClassNode *p_class) {
tokenizer->advance();
- if (tokenizer->get_token() == GDTokenizer::TK_BUILT_IN_TYPE && tokenizer->get_token_type() == Variant::OBJECT) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_BUILT_IN_TYPE && tokenizer->get_token_type() == Variant::OBJECT) {
p_class->extends_class.push_back(Variant::get_type_name(Variant::OBJECT));
tokenizer->advance();
return;
}
// see if inheritance happens from a file
- if (tokenizer->get_token() == GDTokenizer::TK_CONSTANT) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_CONSTANT) {
Variant constant = tokenizer->get_token_constant();
if (constant.get_type() != Variant::STRING) {
@@ -2963,14 +2964,14 @@ void GDParser::_parse_extends(ClassNode *p_class) {
p_class->extends_file = constant;
tokenizer->advance();
- if (tokenizer->get_token() != GDTokenizer::TK_PERIOD) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_PERIOD) {
return;
} else
tokenizer->advance();
}
while (true) {
- if (tokenizer->get_token() != GDTokenizer::TK_IDENTIFIER) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_IDENTIFIER) {
_set_error("Invalid 'extends' syntax, expected string constant (path) and/or identifier (parent class).");
return;
@@ -2980,18 +2981,18 @@ void GDParser::_parse_extends(ClassNode *p_class) {
p_class->extends_class.push_back(identifier);
tokenizer->advance(1);
- if (tokenizer->get_token() != GDTokenizer::TK_PERIOD)
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_PERIOD)
return;
}
}
-void GDParser::_parse_class(ClassNode *p_class) {
+void GDScriptParser::_parse_class(ClassNode *p_class) {
int indent_level = tab_level.back()->get();
while (true) {
- GDTokenizer::Token token = tokenizer->get_token();
+ GDScriptTokenizer::Token token = tokenizer->get_token();
if (error_set)
return;
@@ -3002,13 +3003,13 @@ void GDParser::_parse_class(ClassNode *p_class) {
switch (token) {
- case GDTokenizer::TK_EOF:
+ case GDScriptTokenizer::TK_EOF:
p_class->end_line = tokenizer->get_token_line();
- case GDTokenizer::TK_ERROR: {
+ case GDScriptTokenizer::TK_ERROR: {
return; //go back
//end of file!
} break;
- case GDTokenizer::TK_NEWLINE: {
+ case GDScriptTokenizer::TK_NEWLINE: {
if (!_parse_newline()) {
if (!error_set) {
p_class->end_line = tokenizer->get_token_line();
@@ -3016,7 +3017,7 @@ void GDParser::_parse_class(ClassNode *p_class) {
return;
}
} break;
- case GDTokenizer::TK_PR_EXTENDS: {
+ case GDScriptTokenizer::TK_PR_EXTENDS: {
_parse_extends(p_class);
if (error_set)
@@ -3027,7 +3028,7 @@ void GDParser::_parse_class(ClassNode *p_class) {
}
} break;
- case GDTokenizer::TK_PR_TOOL: {
+ case GDScriptTokenizer::TK_PR_TOOL: {
if (p_class->tool) {
@@ -3039,13 +3040,13 @@ void GDParser::_parse_class(ClassNode *p_class) {
tokenizer->advance();
} break;
- case GDTokenizer::TK_PR_CLASS: {
+ case GDScriptTokenizer::TK_PR_CLASS: {
//class inside class :D
StringName name;
StringName extends;
- if (tokenizer->get_token(1) != GDTokenizer::TK_IDENTIFIER) {
+ if (tokenizer->get_token(1) != GDScriptTokenizer::TK_IDENTIFIER) {
_set_error("'class' syntax: 'class <Name>:' or 'class <Name> extends <BaseClass>:'");
return;
@@ -3063,7 +3064,7 @@ void GDParser::_parse_class(ClassNode *p_class) {
p_class->subclasses.push_back(newclass);
- if (tokenizer->get_token() == GDTokenizer::TK_PR_EXTENDS) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_PR_EXTENDS) {
_parse_extends(newclass);
if (error_set)
@@ -3081,26 +3082,26 @@ void GDParser::_parse_class(ClassNode *p_class) {
} break;
/* this is for functions....
- case GDTokenizer::TK_CF_PASS: {
+ case GDScriptTokenizer::TK_CF_PASS: {
tokenizer->advance(1);
} break;
*/
- case GDTokenizer::TK_PR_STATIC: {
+ case GDScriptTokenizer::TK_PR_STATIC: {
tokenizer->advance();
- if (tokenizer->get_token() != GDTokenizer::TK_PR_FUNCTION) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_PR_FUNCTION) {
_set_error("Expected 'func'.");
return;
}
}; //fallthrough to function
- case GDTokenizer::TK_PR_FUNCTION: {
+ case GDScriptTokenizer::TK_PR_FUNCTION: {
bool _static = false;
pending_newline = -1;
- if (tokenizer->get_token(-1) == GDTokenizer::TK_PR_STATIC) {
+ if (tokenizer->get_token(-1) == GDScriptTokenizer::TK_PR_STATIC) {
_static = true;
}
@@ -3128,7 +3129,7 @@ void GDParser::_parse_class(ClassNode *p_class) {
}
}
- if (tokenizer->get_token() != GDTokenizer::TK_PARENTHESIS_OPEN) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_PARENTHESIS_OPEN) {
_set_error("Expected '(' after identifier (syntax: 'func <identifier>([arguments]):' ).");
return;
@@ -3141,17 +3142,17 @@ void GDParser::_parse_class(ClassNode *p_class) {
int fnline = tokenizer->get_token_line();
- if (tokenizer->get_token() != GDTokenizer::TK_PARENTHESIS_CLOSE) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_PARENTHESIS_CLOSE) {
//has arguments
bool defaulting = false;
while (true) {
- if (tokenizer->get_token() == GDTokenizer::TK_NEWLINE) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_NEWLINE) {
tokenizer->advance();
continue;
}
- if (tokenizer->get_token() == GDTokenizer::TK_PR_VAR) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_PR_VAR) {
tokenizer->advance(); //var before the identifier is allowed
}
@@ -3167,7 +3168,7 @@ void GDParser::_parse_class(ClassNode *p_class) {
tokenizer->advance();
- if (defaulting && tokenizer->get_token() != GDTokenizer::TK_OP_ASSIGN) {
+ if (defaulting && tokenizer->get_token() != GDScriptTokenizer::TK_OP_ASSIGN) {
_set_error("Default parameter expected.");
return;
@@ -3175,7 +3176,7 @@ void GDParser::_parse_class(ClassNode *p_class) {
//tokenizer->advance();
- if (tokenizer->get_token() == GDTokenizer::TK_OP_ASSIGN) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_OP_ASSIGN) {
defaulting = true;
tokenizer->advance(1);
Node *defval = _parse_and_reduce_expression(p_class, _static);
@@ -3199,14 +3200,14 @@ void GDParser::_parse_class(ClassNode *p_class) {
default_values.push_back(on);
}
- while (tokenizer->get_token() == GDTokenizer::TK_NEWLINE) {
+ while (tokenizer->get_token() == GDScriptTokenizer::TK_NEWLINE) {
tokenizer->advance();
}
- if (tokenizer->get_token() == GDTokenizer::TK_COMMA) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_COMMA) {
tokenizer->advance();
continue;
- } else if (tokenizer->get_token() != GDTokenizer::TK_PARENTHESIS_CLOSE) {
+ } else if (tokenizer->get_token() != GDScriptTokenizer::TK_PARENTHESIS_CLOSE) {
_set_error("Expected ',' or ')'.");
return;
@@ -3233,14 +3234,14 @@ void GDParser::_parse_class(ClassNode *p_class) {
id->name = "_init";
cparent->arguments.push_back(id);
- if (tokenizer->get_token() == GDTokenizer::TK_PERIOD) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_PERIOD) {
tokenizer->advance();
- if (tokenizer->get_token() != GDTokenizer::TK_PARENTHESIS_OPEN) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_PARENTHESIS_OPEN) {
_set_error("expected '(' for parent constructor arguments.");
}
tokenizer->advance();
- if (tokenizer->get_token() != GDTokenizer::TK_PARENTHESIS_CLOSE) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_PARENTHESIS_CLOSE) {
//has arguments
parenthesis++;
while (true) {
@@ -3248,10 +3249,10 @@ void GDParser::_parse_class(ClassNode *p_class) {
Node *arg = _parse_and_reduce_expression(p_class, _static);
cparent->arguments.push_back(arg);
- if (tokenizer->get_token() == GDTokenizer::TK_COMMA) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_COMMA) {
tokenizer->advance();
continue;
- } else if (tokenizer->get_token() != GDTokenizer::TK_PARENTHESIS_CLOSE) {
+ } else if (tokenizer->get_token() != GDScriptTokenizer::TK_PARENTHESIS_CLOSE) {
_set_error("Expected ',' or ')'.");
return;
@@ -3266,7 +3267,7 @@ void GDParser::_parse_class(ClassNode *p_class) {
}
} else {
- if (tokenizer->get_token() == GDTokenizer::TK_PERIOD) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_PERIOD) {
_set_error("Parent constructor call found for a class without inheritance.");
return;
@@ -3303,7 +3304,7 @@ void GDParser::_parse_class(ClassNode *p_class) {
//arguments
} break;
- case GDTokenizer::TK_PR_SIGNAL: {
+ case GDScriptTokenizer::TK_PR_SIGNAL: {
tokenizer->advance();
if (!tokenizer->is_token_literal()) {
@@ -3315,15 +3316,15 @@ void GDParser::_parse_class(ClassNode *p_class) {
sig.name = tokenizer->get_token_identifier();
tokenizer->advance();
- if (tokenizer->get_token() == GDTokenizer::TK_PARENTHESIS_OPEN) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_PARENTHESIS_OPEN) {
tokenizer->advance();
while (true) {
- if (tokenizer->get_token() == GDTokenizer::TK_NEWLINE) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_NEWLINE) {
tokenizer->advance();
continue;
}
- if (tokenizer->get_token() == GDTokenizer::TK_PARENTHESIS_CLOSE) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_PARENTHESIS_CLOSE) {
tokenizer->advance();
break;
}
@@ -3336,13 +3337,13 @@ void GDParser::_parse_class(ClassNode *p_class) {
sig.arguments.push_back(tokenizer->get_token_identifier());
tokenizer->advance();
- while (tokenizer->get_token() == GDTokenizer::TK_NEWLINE) {
+ while (tokenizer->get_token() == GDScriptTokenizer::TK_NEWLINE) {
tokenizer->advance();
}
- if (tokenizer->get_token() == GDTokenizer::TK_COMMA) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_COMMA) {
tokenizer->advance();
- } else if (tokenizer->get_token() != GDTokenizer::TK_PARENTHESIS_CLOSE) {
+ } else if (tokenizer->get_token() != GDScriptTokenizer::TK_PARENTHESIS_CLOSE) {
_set_error("Expected ',' or ')' after signal parameter identifier.");
return;
}
@@ -3356,14 +3357,14 @@ void GDParser::_parse_class(ClassNode *p_class) {
return;
}
} break;
- case GDTokenizer::TK_PR_EXPORT: {
+ case GDScriptTokenizer::TK_PR_EXPORT: {
tokenizer->advance();
- if (tokenizer->get_token() == GDTokenizer::TK_PARENTHESIS_OPEN) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_PARENTHESIS_OPEN) {
tokenizer->advance();
- if (tokenizer->get_token() == GDTokenizer::TK_BUILT_IN_TYPE) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_BUILT_IN_TYPE) {
Variant::Type type = tokenizer->get_token_type();
if (type == Variant::NIL) {
@@ -3376,17 +3377,17 @@ void GDParser::_parse_class(ClassNode *p_class) {
String hint_prefix = "";
- if (type == Variant::ARRAY && tokenizer->get_token() == GDTokenizer::TK_COMMA) {
+ if (type == Variant::ARRAY && tokenizer->get_token() == GDScriptTokenizer::TK_COMMA) {
tokenizer->advance();
- while (tokenizer->get_token() == GDTokenizer::TK_BUILT_IN_TYPE) {
+ while (tokenizer->get_token() == GDScriptTokenizer::TK_BUILT_IN_TYPE) {
type = tokenizer->get_token_type();
tokenizer->advance();
if (type == Variant::ARRAY) {
hint_prefix += itos(Variant::ARRAY) + ":";
- if (tokenizer->get_token() == GDTokenizer::TK_COMMA) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_COMMA) {
tokenizer->advance();
}
} else {
@@ -3396,7 +3397,7 @@ void GDParser::_parse_class(ClassNode *p_class) {
}
}
- if (tokenizer->get_token() == GDTokenizer::TK_COMMA) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_COMMA) {
// hint expected next!
tokenizer->advance();
@@ -3404,15 +3405,15 @@ void GDParser::_parse_class(ClassNode *p_class) {
case Variant::INT: {
- if (tokenizer->get_token() == GDTokenizer::TK_IDENTIFIER && tokenizer->get_token_identifier() == "FLAGS") {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_IDENTIFIER && tokenizer->get_token_identifier() == "FLAGS") {
//current_export.hint=PROPERTY_HINT_ALL_FLAGS;
tokenizer->advance();
- if (tokenizer->get_token() == GDTokenizer::TK_PARENTHESIS_CLOSE) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_PARENTHESIS_CLOSE) {
break;
}
- if (tokenizer->get_token() != GDTokenizer::TK_COMMA) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_COMMA) {
_set_error("Expected ')' or ',' in bit flags hint.");
return;
}
@@ -3423,7 +3424,7 @@ void GDParser::_parse_class(ClassNode *p_class) {
bool first = true;
while (true) {
- if (tokenizer->get_token() != GDTokenizer::TK_CONSTANT || tokenizer->get_token_constant().get_type() != Variant::STRING) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_CONSTANT || tokenizer->get_token_constant().get_type() != Variant::STRING) {
current_export = PropertyInfo();
_set_error("Expected a string constant in named bit flags hint.");
return;
@@ -3438,10 +3439,10 @@ void GDParser::_parse_class(ClassNode *p_class) {
current_export.hint_string += c.xml_escape();
tokenizer->advance();
- if (tokenizer->get_token() == GDTokenizer::TK_PARENTHESIS_CLOSE)
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_PARENTHESIS_CLOSE)
break;
- if (tokenizer->get_token() != GDTokenizer::TK_COMMA) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_COMMA) {
current_export = PropertyInfo();
_set_error("Expected ')' or ',' in named bit flags hint.");
return;
@@ -3452,13 +3453,13 @@ void GDParser::_parse_class(ClassNode *p_class) {
break;
}
- if (tokenizer->get_token() == GDTokenizer::TK_CONSTANT && tokenizer->get_token_constant().get_type() == Variant::STRING) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_CONSTANT && tokenizer->get_token_constant().get_type() == Variant::STRING) {
//enumeration
current_export.hint = PROPERTY_HINT_ENUM;
bool first = true;
while (true) {
- if (tokenizer->get_token() != GDTokenizer::TK_CONSTANT || tokenizer->get_token_constant().get_type() != Variant::STRING) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_CONSTANT || tokenizer->get_token_constant().get_type() != Variant::STRING) {
current_export = PropertyInfo();
_set_error("Expected a string constant in enumeration hint.");
@@ -3474,10 +3475,10 @@ void GDParser::_parse_class(ClassNode *p_class) {
current_export.hint_string += c.xml_escape();
tokenizer->advance();
- if (tokenizer->get_token() == GDTokenizer::TK_PARENTHESIS_CLOSE)
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_PARENTHESIS_CLOSE)
break;
- if (tokenizer->get_token() != GDTokenizer::TK_COMMA) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_COMMA) {
current_export = PropertyInfo();
_set_error("Expected ')' or ',' in enumeration hint.");
return;
@@ -3492,10 +3493,10 @@ void GDParser::_parse_class(ClassNode *p_class) {
}; //fallthrough to use the same
case Variant::REAL: {
- if (tokenizer->get_token() == GDTokenizer::TK_IDENTIFIER && tokenizer->get_token_identifier() == "EASE") {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_IDENTIFIER && tokenizer->get_token_identifier() == "EASE") {
current_export.hint = PROPERTY_HINT_EXP_EASING;
tokenizer->advance();
- if (tokenizer->get_token() != GDTokenizer::TK_PARENTHESIS_CLOSE) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_PARENTHESIS_CLOSE) {
_set_error("Expected ')' in hint.");
return;
}
@@ -3503,14 +3504,14 @@ void GDParser::_parse_class(ClassNode *p_class) {
}
// range
- if (tokenizer->get_token() == GDTokenizer::TK_IDENTIFIER && tokenizer->get_token_identifier() == "EXP") {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_IDENTIFIER && tokenizer->get_token_identifier() == "EXP") {
current_export.hint = PROPERTY_HINT_EXP_RANGE;
tokenizer->advance();
- if (tokenizer->get_token() == GDTokenizer::TK_PARENTHESIS_CLOSE)
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_PARENTHESIS_CLOSE)
break;
- else if (tokenizer->get_token() != GDTokenizer::TK_COMMA) {
+ else if (tokenizer->get_token() != GDScriptTokenizer::TK_COMMA) {
_set_error("Expected ')' or ',' in exponential range hint.");
return;
}
@@ -3520,11 +3521,11 @@ void GDParser::_parse_class(ClassNode *p_class) {
float sign = 1.0;
- if (tokenizer->get_token() == GDTokenizer::TK_OP_SUB) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_OP_SUB) {
sign = -1;
tokenizer->advance();
}
- if (tokenizer->get_token() != GDTokenizer::TK_CONSTANT || !tokenizer->get_token_constant().is_num()) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_CONSTANT || !tokenizer->get_token_constant().is_num()) {
current_export = PropertyInfo();
_set_error("Expected a range in numeric hint.");
@@ -3534,12 +3535,12 @@ void GDParser::_parse_class(ClassNode *p_class) {
current_export.hint_string = rtos(sign * double(tokenizer->get_token_constant()));
tokenizer->advance();
- if (tokenizer->get_token() == GDTokenizer::TK_PARENTHESIS_CLOSE) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_PARENTHESIS_CLOSE) {
current_export.hint_string = "0," + current_export.hint_string;
break;
}
- if (tokenizer->get_token() != GDTokenizer::TK_COMMA) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_COMMA) {
current_export = PropertyInfo();
_set_error("Expected ',' or ')' in numeric range hint.");
@@ -3549,12 +3550,12 @@ void GDParser::_parse_class(ClassNode *p_class) {
tokenizer->advance();
sign = 1.0;
- if (tokenizer->get_token() == GDTokenizer::TK_OP_SUB) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_OP_SUB) {
sign = -1;
tokenizer->advance();
}
- if (tokenizer->get_token() != GDTokenizer::TK_CONSTANT || !tokenizer->get_token_constant().is_num()) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_CONSTANT || !tokenizer->get_token_constant().is_num()) {
current_export = PropertyInfo();
_set_error("Expected a number as upper bound in numeric range hint.");
@@ -3564,10 +3565,10 @@ void GDParser::_parse_class(ClassNode *p_class) {
current_export.hint_string += "," + rtos(sign * double(tokenizer->get_token_constant()));
tokenizer->advance();
- if (tokenizer->get_token() == GDTokenizer::TK_PARENTHESIS_CLOSE)
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_PARENTHESIS_CLOSE)
break;
- if (tokenizer->get_token() != GDTokenizer::TK_COMMA) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_COMMA) {
current_export = PropertyInfo();
_set_error("Expected ',' or ')' in numeric range hint.");
@@ -3576,12 +3577,12 @@ void GDParser::_parse_class(ClassNode *p_class) {
tokenizer->advance();
sign = 1.0;
- if (tokenizer->get_token() == GDTokenizer::TK_OP_SUB) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_OP_SUB) {
sign = -1;
tokenizer->advance();
}
- if (tokenizer->get_token() != GDTokenizer::TK_CONSTANT || !tokenizer->get_token_constant().is_num()) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_CONSTANT || !tokenizer->get_token_constant().is_num()) {
current_export = PropertyInfo();
_set_error("Expected a number as step in numeric range hint.");
@@ -3594,13 +3595,13 @@ void GDParser::_parse_class(ClassNode *p_class) {
} break;
case Variant::STRING: {
- if (tokenizer->get_token() == GDTokenizer::TK_CONSTANT && tokenizer->get_token_constant().get_type() == Variant::STRING) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_CONSTANT && tokenizer->get_token_constant().get_type() == Variant::STRING) {
//enumeration
current_export.hint = PROPERTY_HINT_ENUM;
bool first = true;
while (true) {
- if (tokenizer->get_token() != GDTokenizer::TK_CONSTANT || tokenizer->get_token_constant().get_type() != Variant::STRING) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_CONSTANT || tokenizer->get_token_constant().get_type() != Variant::STRING) {
current_export = PropertyInfo();
_set_error("Expected a string constant in enumeration hint.");
@@ -3615,10 +3616,10 @@ void GDParser::_parse_class(ClassNode *p_class) {
current_export.hint_string += c.xml_escape();
tokenizer->advance();
- if (tokenizer->get_token() == GDTokenizer::TK_PARENTHESIS_CLOSE)
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_PARENTHESIS_CLOSE)
break;
- if (tokenizer->get_token() != GDTokenizer::TK_COMMA) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_COMMA) {
current_export = PropertyInfo();
_set_error("Expected ')' or ',' in enumeration hint.");
return;
@@ -3629,17 +3630,17 @@ void GDParser::_parse_class(ClassNode *p_class) {
break;
}
- if (tokenizer->get_token() == GDTokenizer::TK_IDENTIFIER && tokenizer->get_token_identifier() == "DIR") {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_IDENTIFIER && tokenizer->get_token_identifier() == "DIR") {
tokenizer->advance();
- if (tokenizer->get_token() == GDTokenizer::TK_PARENTHESIS_CLOSE)
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_PARENTHESIS_CLOSE)
current_export.hint = PROPERTY_HINT_DIR;
- else if (tokenizer->get_token() == GDTokenizer::TK_COMMA) {
+ else if (tokenizer->get_token() == GDScriptTokenizer::TK_COMMA) {
tokenizer->advance();
- if (tokenizer->get_token() != GDTokenizer::TK_IDENTIFIER || !(tokenizer->get_token_identifier() == "GLOBAL")) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_IDENTIFIER || !(tokenizer->get_token_identifier() == "GLOBAL")) {
_set_error("Expected 'GLOBAL' after comma in directory hint.");
return;
}
@@ -3650,7 +3651,7 @@ void GDParser::_parse_class(ClassNode *p_class) {
current_export.hint = PROPERTY_HINT_GLOBAL_DIR;
tokenizer->advance();
- if (tokenizer->get_token() != GDTokenizer::TK_PARENTHESIS_CLOSE) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_PARENTHESIS_CLOSE) {
_set_error("Expected ')' in hint.");
return;
}
@@ -3661,16 +3662,16 @@ void GDParser::_parse_class(ClassNode *p_class) {
break;
}
- if (tokenizer->get_token() == GDTokenizer::TK_IDENTIFIER && tokenizer->get_token_identifier() == "FILE") {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_IDENTIFIER && tokenizer->get_token_identifier() == "FILE") {
current_export.hint = PROPERTY_HINT_FILE;
tokenizer->advance();
- if (tokenizer->get_token() == GDTokenizer::TK_COMMA) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_COMMA) {
tokenizer->advance();
- if (tokenizer->get_token() == GDTokenizer::TK_IDENTIFIER && tokenizer->get_token_identifier() == "GLOBAL") {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_IDENTIFIER && tokenizer->get_token_identifier() == "GLOBAL") {
if (!p_class->tool) {
_set_error("Global filesystem hints may only be used in tool scripts.");
@@ -3679,9 +3680,9 @@ void GDParser::_parse_class(ClassNode *p_class) {
current_export.hint = PROPERTY_HINT_GLOBAL_FILE;
tokenizer->advance();
- if (tokenizer->get_token() == GDTokenizer::TK_PARENTHESIS_CLOSE)
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_PARENTHESIS_CLOSE)
break;
- else if (tokenizer->get_token() == GDTokenizer::TK_COMMA)
+ else if (tokenizer->get_token() == GDScriptTokenizer::TK_COMMA)
tokenizer->advance();
else {
_set_error("Expected ')' or ',' in hint.");
@@ -3689,7 +3690,7 @@ void GDParser::_parse_class(ClassNode *p_class) {
}
}
- if (tokenizer->get_token() != GDTokenizer::TK_CONSTANT || tokenizer->get_token_constant().get_type() != Variant::STRING) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_CONSTANT || tokenizer->get_token_constant().get_type() != Variant::STRING) {
if (current_export.hint == PROPERTY_HINT_GLOBAL_FILE)
_set_error("Expected string constant with filter");
@@ -3701,18 +3702,18 @@ void GDParser::_parse_class(ClassNode *p_class) {
tokenizer->advance();
}
- if (tokenizer->get_token() != GDTokenizer::TK_PARENTHESIS_CLOSE) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_PARENTHESIS_CLOSE) {
_set_error("Expected ')' in hint.");
return;
}
break;
}
- if (tokenizer->get_token() == GDTokenizer::TK_IDENTIFIER && tokenizer->get_token_identifier() == "MULTILINE") {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_IDENTIFIER && tokenizer->get_token_identifier() == "MULTILINE") {
current_export.hint = PROPERTY_HINT_MULTILINE_TEXT;
tokenizer->advance();
- if (tokenizer->get_token() != GDTokenizer::TK_PARENTHESIS_CLOSE) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_PARENTHESIS_CLOSE) {
_set_error("Expected ')' in hint.");
return;
}
@@ -3721,7 +3722,7 @@ void GDParser::_parse_class(ClassNode *p_class) {
} break;
case Variant::COLOR: {
- if (tokenizer->get_token() != GDTokenizer::TK_IDENTIFIER) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_IDENTIFIER) {
current_export = PropertyInfo();
_set_error("Color type hint expects RGB or RGBA as hints");
@@ -3757,7 +3758,7 @@ void GDParser::_parse_class(ClassNode *p_class) {
current_export.hint = PROPERTY_HINT_NONE;
}
- } else if (tokenizer->get_token() == GDTokenizer::TK_IDENTIFIER) {
+ } else if (tokenizer->get_token() == GDScriptTokenizer::TK_IDENTIFIER) {
String identifier = tokenizer->get_token_identifier();
if (!ClassDB::is_parent_class(identifier, "Resource")) {
@@ -3775,7 +3776,7 @@ void GDParser::_parse_class(ClassNode *p_class) {
tokenizer->advance();
}
- if (tokenizer->get_token() != GDTokenizer::TK_PARENTHESIS_CLOSE) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_PARENTHESIS_CLOSE) {
current_export = PropertyInfo();
_set_error("Expected ')' or ',' after export hint.");
@@ -3785,7 +3786,7 @@ void GDParser::_parse_class(ClassNode *p_class) {
tokenizer->advance();
}
- if (tokenizer->get_token() != GDTokenizer::TK_PR_VAR && tokenizer->get_token() != GDTokenizer::TK_PR_ONREADY && tokenizer->get_token() != GDTokenizer::TK_PR_REMOTE && tokenizer->get_token() != GDTokenizer::TK_PR_MASTER && tokenizer->get_token() != GDTokenizer::TK_PR_SLAVE && tokenizer->get_token() != GDTokenizer::TK_PR_SYNC) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_PR_VAR && tokenizer->get_token() != GDScriptTokenizer::TK_PR_ONREADY && tokenizer->get_token() != GDScriptTokenizer::TK_PR_REMOTE && tokenizer->get_token() != GDScriptTokenizer::TK_PR_MASTER && tokenizer->get_token() != GDScriptTokenizer::TK_PR_SLAVE && tokenizer->get_token() != GDScriptTokenizer::TK_PR_SYNC) {
current_export = PropertyInfo();
_set_error("Expected 'var', 'onready', 'remote', 'master', 'slave' or 'sync'.");
@@ -3794,29 +3795,29 @@ void GDParser::_parse_class(ClassNode *p_class) {
continue;
} break;
- case GDTokenizer::TK_PR_ONREADY: {
+ case GDScriptTokenizer::TK_PR_ONREADY: {
//may be fallthrough from export, ignore if so
tokenizer->advance();
- if (tokenizer->get_token() != GDTokenizer::TK_PR_VAR) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_PR_VAR) {
_set_error("Expected 'var'.");
return;
}
continue;
} break;
- case GDTokenizer::TK_PR_REMOTE: {
+ case GDScriptTokenizer::TK_PR_REMOTE: {
//may be fallthrough from export, ignore if so
tokenizer->advance();
if (current_export.type) {
- if (tokenizer->get_token() != GDTokenizer::TK_PR_VAR) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_PR_VAR) {
_set_error("Expected 'var'.");
return;
}
} else {
- if (tokenizer->get_token() != GDTokenizer::TK_PR_VAR && tokenizer->get_token() != GDTokenizer::TK_PR_FUNCTION) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_PR_VAR && tokenizer->get_token() != GDScriptTokenizer::TK_PR_FUNCTION) {
_set_error("Expected 'var' or 'func'.");
return;
}
@@ -3825,18 +3826,18 @@ void GDParser::_parse_class(ClassNode *p_class) {
continue;
} break;
- case GDTokenizer::TK_PR_MASTER: {
+ case GDScriptTokenizer::TK_PR_MASTER: {
//may be fallthrough from export, ignore if so
tokenizer->advance();
if (current_export.type) {
- if (tokenizer->get_token() != GDTokenizer::TK_PR_VAR) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_PR_VAR) {
_set_error("Expected 'var'.");
return;
}
} else {
- if (tokenizer->get_token() != GDTokenizer::TK_PR_VAR && tokenizer->get_token() != GDTokenizer::TK_PR_FUNCTION) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_PR_VAR && tokenizer->get_token() != GDScriptTokenizer::TK_PR_FUNCTION) {
_set_error("Expected 'var' or 'func'.");
return;
}
@@ -3845,18 +3846,18 @@ void GDParser::_parse_class(ClassNode *p_class) {
rpc_mode = ScriptInstance::RPC_MODE_MASTER;
continue;
} break;
- case GDTokenizer::TK_PR_SLAVE: {
+ case GDScriptTokenizer::TK_PR_SLAVE: {
//may be fallthrough from export, ignore if so
tokenizer->advance();
if (current_export.type) {
- if (tokenizer->get_token() != GDTokenizer::TK_PR_VAR) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_PR_VAR) {
_set_error("Expected 'var'.");
return;
}
} else {
- if (tokenizer->get_token() != GDTokenizer::TK_PR_VAR && tokenizer->get_token() != GDTokenizer::TK_PR_FUNCTION) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_PR_VAR && tokenizer->get_token() != GDScriptTokenizer::TK_PR_FUNCTION) {
_set_error("Expected 'var' or 'func'.");
return;
}
@@ -3865,11 +3866,11 @@ void GDParser::_parse_class(ClassNode *p_class) {
rpc_mode = ScriptInstance::RPC_MODE_SLAVE;
continue;
} break;
- case GDTokenizer::TK_PR_SYNC: {
+ case GDScriptTokenizer::TK_PR_SYNC: {
//may be fallthrough from export, ignore if so
tokenizer->advance();
- if (tokenizer->get_token() != GDTokenizer::TK_PR_VAR && tokenizer->get_token() != GDTokenizer::TK_PR_FUNCTION) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_PR_VAR && tokenizer->get_token() != GDScriptTokenizer::TK_PR_FUNCTION) {
if (current_export.type)
_set_error("Expected 'var'.");
else
@@ -3880,17 +3881,17 @@ void GDParser::_parse_class(ClassNode *p_class) {
rpc_mode = ScriptInstance::RPC_MODE_SYNC;
continue;
} break;
- case GDTokenizer::TK_PR_VAR: {
+ case GDScriptTokenizer::TK_PR_VAR: {
//variale declaration and (eventual) initialization
ClassNode::Member member;
- bool autoexport = tokenizer->get_token(-1) == GDTokenizer::TK_PR_EXPORT;
+ bool autoexport = tokenizer->get_token(-1) == GDScriptTokenizer::TK_PR_EXPORT;
if (current_export.type != Variant::NIL) {
member._export = current_export;
current_export = PropertyInfo();
}
- bool onready = tokenizer->get_token(-1) == GDTokenizer::TK_PR_ONREADY;
+ bool onready = tokenizer->get_token(-1) == GDScriptTokenizer::TK_PR_ONREADY;
tokenizer->advance();
if (!tokenizer->is_token_literal(0, true)) {
@@ -3909,7 +3910,7 @@ void GDParser::_parse_class(ClassNode *p_class) {
rpc_mode = ScriptInstance::RPC_MODE_DISABLED;
- if (tokenizer->get_token() == GDTokenizer::TK_OP_ASSIGN) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_OP_ASSIGN) {
#ifdef DEBUG_ENABLED
int line = tokenizer->get_token_line();
@@ -4017,11 +4018,11 @@ void GDParser::_parse_class(ClassNode *p_class) {
}
}
- if (tokenizer->get_token() == GDTokenizer::TK_PR_SETGET) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_PR_SETGET) {
tokenizer->advance();
- if (tokenizer->get_token() != GDTokenizer::TK_COMMA) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_COMMA) {
//just comma means using only getter
if (!tokenizer->is_token_literal()) {
_set_error("Expected identifier for setter function after 'setget'.");
@@ -4032,7 +4033,7 @@ void GDParser::_parse_class(ClassNode *p_class) {
tokenizer->advance();
}
- if (tokenizer->get_token() == GDTokenizer::TK_COMMA) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_COMMA) {
//there is a getter
tokenizer->advance();
@@ -4052,7 +4053,7 @@ void GDParser::_parse_class(ClassNode *p_class) {
return;
}
} break;
- case GDTokenizer::TK_PR_CONST: {
+ case GDScriptTokenizer::TK_PR_CONST: {
//variale declaration and (eventual) initialization
ClassNode::Constant constant;
@@ -4067,7 +4068,7 @@ void GDParser::_parse_class(ClassNode *p_class) {
constant.identifier = tokenizer->get_token_literal();
tokenizer->advance();
- if (tokenizer->get_token() != GDTokenizer::TK_OP_ASSIGN) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_OP_ASSIGN) {
_set_error("Constant expects assignment.");
return;
}
@@ -4095,7 +4096,7 @@ void GDParser::_parse_class(ClassNode *p_class) {
}
} break;
- case GDTokenizer::TK_PR_ENUM: {
+ case GDScriptTokenizer::TK_PR_ENUM: {
//mutiple constant declarations..
int last_assign = -1; // Incremented by 1 right before the assingment.
@@ -4107,26 +4108,26 @@ void GDParser::_parse_class(ClassNode *p_class) {
enum_name = tokenizer->get_token_literal();
tokenizer->advance();
}
- if (tokenizer->get_token() != GDTokenizer::TK_CURLY_BRACKET_OPEN) {
+ if (tokenizer->get_token() != GDScriptTokenizer::TK_CURLY_BRACKET_OPEN) {
_set_error("Expected '{' in enum declaration");
return;
}
tokenizer->advance();
while (true) {
- if (tokenizer->get_token() == GDTokenizer::TK_NEWLINE) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_NEWLINE) {
tokenizer->advance(); // Ignore newlines
- } else if (tokenizer->get_token() == GDTokenizer::TK_CURLY_BRACKET_CLOSE) {
+ } else if (tokenizer->get_token() == GDScriptTokenizer::TK_CURLY_BRACKET_CLOSE) {
tokenizer->advance();
break; // End of enum
} else if (!tokenizer->is_token_literal(0, true)) {
- if (tokenizer->get_token() == GDTokenizer::TK_EOF) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_EOF) {
_set_error("Unexpected end of file.");
} else {
- _set_error(String("Unexpected ") + GDTokenizer::get_token_name(tokenizer->get_token()) + ", expected identifier");
+ _set_error(String("Unexpected ") + GDScriptTokenizer::get_token_name(tokenizer->get_token()) + ", expected identifier");
}
return;
@@ -4137,7 +4138,7 @@ void GDParser::_parse_class(ClassNode *p_class) {
tokenizer->advance();
- if (tokenizer->get_token() == GDTokenizer::TK_OP_ASSIGN) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_OP_ASSIGN) {
tokenizer->advance();
Node *subexpr = _parse_and_reduce_expression(p_class, true, true);
@@ -4169,7 +4170,7 @@ void GDParser::_parse_class(ClassNode *p_class) {
constant.expression = cn;
}
- if (tokenizer->get_token() == GDTokenizer::TK_COMMA) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_COMMA) {
tokenizer->advance();
}
@@ -4198,7 +4199,7 @@ void GDParser::_parse_class(ClassNode *p_class) {
} break;
- case GDTokenizer::TK_CONSTANT: {
+ case GDScriptTokenizer::TK_CONSTANT: {
if (tokenizer->get_token_constant().get_type() == Variant::STRING) {
tokenizer->advance();
// Ignore
@@ -4218,7 +4219,7 @@ void GDParser::_parse_class(ClassNode *p_class) {
}
}
-void GDParser::_set_error(const String &p_error, int p_line, int p_column) {
+void GDScriptParser::_set_error(const String &p_error, int p_line, int p_column) {
if (error_set)
return; //allow no further errors
@@ -4229,21 +4230,21 @@ void GDParser::_set_error(const String &p_error, int p_line, int p_column) {
error_set = true;
}
-String GDParser::get_error() const {
+String GDScriptParser::get_error() const {
return error;
}
-int GDParser::get_error_line() const {
+int GDScriptParser::get_error_line() const {
return error_line;
}
-int GDParser::get_error_column() const {
+int GDScriptParser::get_error_column() const {
return error_column;
}
-Error GDParser::_parse(const String &p_base_path) {
+Error GDScriptParser::_parse(const String &p_base_path) {
base_path = p_base_path;
@@ -4259,7 +4260,7 @@ Error GDParser::_parse(const String &p_base_path) {
_parse_class(main_class);
- if (tokenizer->get_token() == GDTokenizer::TK_ERROR) {
+ if (tokenizer->get_token() == GDScriptTokenizer::TK_ERROR) {
error_set = false;
_set_error("Parse Error: " + tokenizer->get_token_error());
}
@@ -4271,7 +4272,7 @@ Error GDParser::_parse(const String &p_base_path) {
return OK;
}
-Error GDParser::parse_bytecode(const Vector<uint8_t> &p_bytecode, const String &p_base_path, const String &p_self_path) {
+Error GDScriptParser::parse_bytecode(const Vector<uint8_t> &p_bytecode, const String &p_base_path, const String &p_self_path) {
for_completion = false;
validating = false;
@@ -4286,7 +4287,7 @@ Error GDParser::parse_bytecode(const Vector<uint8_t> &p_bytecode, const String &
current_function = NULL;
self_path = p_self_path;
- GDTokenizerBuffer *tb = memnew(GDTokenizerBuffer);
+ GDScriptTokenizerBuffer *tb = memnew(GDScriptTokenizerBuffer);
tb->set_code_buffer(p_bytecode);
tokenizer = tb;
Error ret = _parse(p_base_path);
@@ -4295,7 +4296,7 @@ Error GDParser::parse_bytecode(const Vector<uint8_t> &p_bytecode, const String &
return ret;
}
-Error GDParser::parse(const String &p_code, const String &p_base_path, bool p_just_validate, const String &p_self_path, bool p_for_completion) {
+Error GDScriptParser::parse(const String &p_code, const String &p_base_path, bool p_just_validate, const String &p_self_path, bool p_for_completion) {
completion_type = COMPLETION_NONE;
completion_node = NULL;
@@ -4309,7 +4310,7 @@ Error GDParser::parse(const String &p_code, const String &p_base_path, bool p_ju
current_function = NULL;
self_path = p_self_path;
- GDTokenizerText *tt = memnew(GDTokenizerText);
+ GDScriptTokenizerText *tt = memnew(GDScriptTokenizerText);
tt->set_code(p_code);
validating = p_just_validate;
@@ -4321,17 +4322,17 @@ Error GDParser::parse(const String &p_code, const String &p_base_path, bool p_ju
return ret;
}
-bool GDParser::is_tool_script() const {
+bool GDScriptParser::is_tool_script() const {
return (head && head->type == Node::TYPE_CLASS && static_cast<const ClassNode *>(head)->tool);
}
-const GDParser::Node *GDParser::get_parse_tree() const {
+const GDScriptParser::Node *GDScriptParser::get_parse_tree() const {
return head;
}
-void GDParser::clear() {
+void GDScriptParser::clear() {
while (list) {
@@ -4369,57 +4370,57 @@ void GDParser::clear() {
error = "";
}
-GDParser::CompletionType GDParser::get_completion_type() {
+GDScriptParser::CompletionType GDScriptParser::get_completion_type() {
return completion_type;
}
-StringName GDParser::get_completion_cursor() {
+StringName GDScriptParser::get_completion_cursor() {
return completion_cursor;
}
-int GDParser::get_completion_line() {
+int GDScriptParser::get_completion_line() {
return completion_line;
}
-Variant::Type GDParser::get_completion_built_in_constant() {
+Variant::Type GDScriptParser::get_completion_built_in_constant() {
return completion_built_in_constant;
}
-GDParser::Node *GDParser::get_completion_node() {
+GDScriptParser::Node *GDScriptParser::get_completion_node() {
return completion_node;
}
-GDParser::BlockNode *GDParser::get_completion_block() {
+GDScriptParser::BlockNode *GDScriptParser::get_completion_block() {
return completion_block;
}
-GDParser::ClassNode *GDParser::get_completion_class() {
+GDScriptParser::ClassNode *GDScriptParser::get_completion_class() {
return completion_class;
}
-GDParser::FunctionNode *GDParser::get_completion_function() {
+GDScriptParser::FunctionNode *GDScriptParser::get_completion_function() {
return completion_function;
}
-int GDParser::get_completion_argument_index() {
+int GDScriptParser::get_completion_argument_index() {
return completion_argument;
}
-int GDParser::get_completion_identifier_is_function() {
+int GDScriptParser::get_completion_identifier_is_function() {
return completion_ident_is_call;
}
-GDParser::GDParser() {
+GDScriptParser::GDScriptParser() {
head = NULL;
list = NULL;
@@ -4428,7 +4429,7 @@ GDParser::GDParser() {
clear();
}
-GDParser::~GDParser() {
+GDScriptParser::~GDScriptParser() {
clear();
}
diff --git a/modules/gdscript/gd_parser.h b/modules/gdscript/gdscript_parser.h
index 7e88fd9746..3c9c5ea02c 100644
--- a/modules/gdscript/gd_parser.h
+++ b/modules/gdscript/gdscript_parser.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* gd_parser.h */
+/* gdscript_parser.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -27,16 +27,16 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef GD_PARSER_H
-#define GD_PARSER_H
+#ifndef GDSCRIPT_PARSER_H
+#define GDSCRIPT_PARSER_H
-#include "gd_functions.h"
-#include "gd_tokenizer.h"
+#include "gdscript_functions.h"
+#include "gdscript_tokenizer.h"
#include "map.h"
#include "object.h"
#include "script_language.h"
-class GDParser {
+class GDScriptParser {
public:
struct Node {
@@ -166,7 +166,7 @@ public:
TypeNode() { type = TYPE_TYPE; }
};
struct BuiltInFunctionNode : public Node {
- GDFunctions::Function function;
+ GDScriptFunctions::Function function;
BuiltInFunctionNode() { type = TYPE_BUILT_IN_FUNCTION; }
};
@@ -448,7 +448,7 @@ public:
};
private:
- GDTokenizer *tokenizer;
+ GDScriptTokenizer *tokenizer;
Node *head;
Node *list;
@@ -540,8 +540,8 @@ public:
int get_completion_identifier_is_function();
void clear();
- GDParser();
- ~GDParser();
+ GDScriptParser();
+ ~GDScriptParser();
};
-#endif // PARSER_H
+#endif // GDSCRIPT_PARSER_H
diff --git a/modules/gdscript/gd_tokenizer.cpp b/modules/gdscript/gdscript_tokenizer.cpp
index 98ac0f473d..e3a0af8ee6 100644
--- a/modules/gdscript/gd_tokenizer.cpp
+++ b/modules/gdscript/gdscript_tokenizer.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* gd_tokenizer.cpp */
+/* gdscript_tokenizer.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -27,14 +27,14 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "gd_tokenizer.h"
+#include "gdscript_tokenizer.h"
-#include "gd_functions.h"
+#include "gdscript_functions.h"
#include "io/marshalls.h"
#include "map.h"
#include "print_string.h"
-const char *GDTokenizer::token_names[TK_MAX] = {
+const char *GDScriptTokenizer::token_names[TK_MAX] = {
"Empty",
"Identifier",
"Constant",
@@ -148,7 +148,7 @@ static const _bit _type_list[] = {
{ Variant::RECT2, "Rect2" },
{ Variant::TRANSFORM2D, "Transform2D" },
{ Variant::VECTOR3, "Vector3" },
- { Variant::RECT3, "Rect3" },
+ { Variant::AABB, "AABB" },
{ Variant::PLANE, "Plane" },
{ Variant::QUAT, "Quat" },
{ Variant::BASIS, "Basis" },
@@ -170,68 +170,68 @@ static const _bit _type_list[] = {
};
struct _kws {
- GDTokenizer::Token token;
+ GDScriptTokenizer::Token token;
const char *text;
};
static const _kws _keyword_list[] = {
//ops
- { GDTokenizer::TK_OP_IN, "in" },
- { GDTokenizer::TK_OP_NOT, "not" },
- { GDTokenizer::TK_OP_OR, "or" },
- { GDTokenizer::TK_OP_AND, "and" },
+ { GDScriptTokenizer::TK_OP_IN, "in" },
+ { GDScriptTokenizer::TK_OP_NOT, "not" },
+ { GDScriptTokenizer::TK_OP_OR, "or" },
+ { GDScriptTokenizer::TK_OP_AND, "and" },
//func
- { GDTokenizer::TK_PR_FUNCTION, "func" },
- { GDTokenizer::TK_PR_CLASS, "class" },
- { GDTokenizer::TK_PR_EXTENDS, "extends" },
- { GDTokenizer::TK_PR_IS, "is" },
- { GDTokenizer::TK_PR_ONREADY, "onready" },
- { GDTokenizer::TK_PR_TOOL, "tool" },
- { GDTokenizer::TK_PR_STATIC, "static" },
- { GDTokenizer::TK_PR_EXPORT, "export" },
- { GDTokenizer::TK_PR_SETGET, "setget" },
- { GDTokenizer::TK_PR_VAR, "var" },
- { GDTokenizer::TK_PR_PRELOAD, "preload" },
- { GDTokenizer::TK_PR_ASSERT, "assert" },
- { GDTokenizer::TK_PR_YIELD, "yield" },
- { GDTokenizer::TK_PR_SIGNAL, "signal" },
- { GDTokenizer::TK_PR_BREAKPOINT, "breakpoint" },
- { GDTokenizer::TK_PR_REMOTE, "remote" },
- { GDTokenizer::TK_PR_MASTER, "master" },
- { GDTokenizer::TK_PR_SLAVE, "slave" },
- { GDTokenizer::TK_PR_SYNC, "sync" },
- { GDTokenizer::TK_PR_CONST, "const" },
- { GDTokenizer::TK_PR_ENUM, "enum" },
+ { GDScriptTokenizer::TK_PR_FUNCTION, "func" },
+ { GDScriptTokenizer::TK_PR_CLASS, "class" },
+ { GDScriptTokenizer::TK_PR_EXTENDS, "extends" },
+ { GDScriptTokenizer::TK_PR_IS, "is" },
+ { GDScriptTokenizer::TK_PR_ONREADY, "onready" },
+ { GDScriptTokenizer::TK_PR_TOOL, "tool" },
+ { GDScriptTokenizer::TK_PR_STATIC, "static" },
+ { GDScriptTokenizer::TK_PR_EXPORT, "export" },
+ { GDScriptTokenizer::TK_PR_SETGET, "setget" },
+ { GDScriptTokenizer::TK_PR_VAR, "var" },
+ { GDScriptTokenizer::TK_PR_PRELOAD, "preload" },
+ { GDScriptTokenizer::TK_PR_ASSERT, "assert" },
+ { GDScriptTokenizer::TK_PR_YIELD, "yield" },
+ { GDScriptTokenizer::TK_PR_SIGNAL, "signal" },
+ { GDScriptTokenizer::TK_PR_BREAKPOINT, "breakpoint" },
+ { GDScriptTokenizer::TK_PR_REMOTE, "remote" },
+ { GDScriptTokenizer::TK_PR_MASTER, "master" },
+ { GDScriptTokenizer::TK_PR_SLAVE, "slave" },
+ { GDScriptTokenizer::TK_PR_SYNC, "sync" },
+ { GDScriptTokenizer::TK_PR_CONST, "const" },
+ { GDScriptTokenizer::TK_PR_ENUM, "enum" },
//controlflow
- { GDTokenizer::TK_CF_IF, "if" },
- { GDTokenizer::TK_CF_ELIF, "elif" },
- { GDTokenizer::TK_CF_ELSE, "else" },
- { GDTokenizer::TK_CF_FOR, "for" },
- { GDTokenizer::TK_CF_WHILE, "while" },
- { GDTokenizer::TK_CF_DO, "do" },
- { GDTokenizer::TK_CF_SWITCH, "switch" },
- { GDTokenizer::TK_CF_CASE, "case" },
- { GDTokenizer::TK_CF_BREAK, "break" },
- { GDTokenizer::TK_CF_CONTINUE, "continue" },
- { GDTokenizer::TK_CF_RETURN, "return" },
- { GDTokenizer::TK_CF_MATCH, "match" },
- { GDTokenizer::TK_CF_PASS, "pass" },
- { GDTokenizer::TK_SELF, "self" },
- { GDTokenizer::TK_CONST_PI, "PI" },
- { GDTokenizer::TK_CONST_TAU, "TAU" },
- { GDTokenizer::TK_WILDCARD, "_" },
- { GDTokenizer::TK_CONST_INF, "INF" },
- { GDTokenizer::TK_CONST_NAN, "NAN" },
- { GDTokenizer::TK_ERROR, NULL }
+ { GDScriptTokenizer::TK_CF_IF, "if" },
+ { GDScriptTokenizer::TK_CF_ELIF, "elif" },
+ { GDScriptTokenizer::TK_CF_ELSE, "else" },
+ { GDScriptTokenizer::TK_CF_FOR, "for" },
+ { GDScriptTokenizer::TK_CF_WHILE, "while" },
+ { GDScriptTokenizer::TK_CF_DO, "do" },
+ { GDScriptTokenizer::TK_CF_SWITCH, "switch" },
+ { GDScriptTokenizer::TK_CF_CASE, "case" },
+ { GDScriptTokenizer::TK_CF_BREAK, "break" },
+ { GDScriptTokenizer::TK_CF_CONTINUE, "continue" },
+ { GDScriptTokenizer::TK_CF_RETURN, "return" },
+ { GDScriptTokenizer::TK_CF_MATCH, "match" },
+ { GDScriptTokenizer::TK_CF_PASS, "pass" },
+ { GDScriptTokenizer::TK_SELF, "self" },
+ { GDScriptTokenizer::TK_CONST_PI, "PI" },
+ { GDScriptTokenizer::TK_CONST_TAU, "TAU" },
+ { GDScriptTokenizer::TK_WILDCARD, "_" },
+ { GDScriptTokenizer::TK_CONST_INF, "INF" },
+ { GDScriptTokenizer::TK_CONST_NAN, "NAN" },
+ { GDScriptTokenizer::TK_ERROR, NULL }
};
-const char *GDTokenizer::get_token_name(Token p_token) {
+const char *GDScriptTokenizer::get_token_name(Token p_token) {
ERR_FAIL_INDEX_V(p_token, TK_MAX, "<error>");
return token_names[p_token];
}
-bool GDTokenizer::is_token_literal(int p_offset, bool variable_safe) const {
+bool GDScriptTokenizer::is_token_literal(int p_offset, bool variable_safe) const {
switch (get_token(p_offset)) {
// Can always be literal:
case TK_IDENTIFIER:
@@ -253,9 +253,9 @@ bool GDTokenizer::is_token_literal(int p_offset, bool variable_safe) const {
case TK_BUILT_IN_FUNC:
case TK_OP_IN:
- //case TK_OP_NOT:
- //case TK_OP_OR:
- //case TK_OP_AND:
+ //case TK_OP_NOT:
+ //case TK_OP_OR:
+ //case TK_OP_AND:
case TK_PR_CLASS:
case TK_PR_CONST:
@@ -303,7 +303,7 @@ bool GDTokenizer::is_token_literal(int p_offset, bool variable_safe) const {
}
}
-StringName GDTokenizer::get_token_literal(int p_offset) const {
+StringName GDScriptTokenizer::get_token_literal(int p_offset) const {
Token token = get_token(p_offset);
switch (token) {
case TK_IDENTIFIER:
@@ -320,7 +320,7 @@ StringName GDTokenizer::get_token_literal(int p_offset) const {
}
} break; // Shouldn't get here, stuff happens
case TK_BUILT_IN_FUNC:
- return GDFunctions::get_func_name(get_token_built_in_func(p_offset));
+ return GDScriptFunctions::get_func_name(get_token_built_in_func(p_offset));
case TK_CONSTANT: {
const Variant value = get_token_constant(p_offset);
@@ -365,7 +365,7 @@ static bool _is_hex(CharType c) {
return (c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F');
}
-void GDTokenizerText::_make_token(Token p_type) {
+void GDScriptTokenizerText::_make_token(Token p_type) {
TokenData &tk = tk_rb[tk_rb_pos];
@@ -375,7 +375,7 @@ void GDTokenizerText::_make_token(Token p_type) {
tk_rb_pos = (tk_rb_pos + 1) % TK_RB_SIZE;
}
-void GDTokenizerText::_make_identifier(const StringName &p_identifier) {
+void GDScriptTokenizerText::_make_identifier(const StringName &p_identifier) {
TokenData &tk = tk_rb[tk_rb_pos];
@@ -387,7 +387,7 @@ void GDTokenizerText::_make_identifier(const StringName &p_identifier) {
tk_rb_pos = (tk_rb_pos + 1) % TK_RB_SIZE;
}
-void GDTokenizerText::_make_built_in_func(GDFunctions::Function p_func) {
+void GDScriptTokenizerText::_make_built_in_func(GDScriptFunctions::Function p_func) {
TokenData &tk = tk_rb[tk_rb_pos];
@@ -398,7 +398,7 @@ void GDTokenizerText::_make_built_in_func(GDFunctions::Function p_func) {
tk_rb_pos = (tk_rb_pos + 1) % TK_RB_SIZE;
}
-void GDTokenizerText::_make_constant(const Variant &p_constant) {
+void GDScriptTokenizerText::_make_constant(const Variant &p_constant) {
TokenData &tk = tk_rb[tk_rb_pos];
@@ -410,7 +410,7 @@ void GDTokenizerText::_make_constant(const Variant &p_constant) {
tk_rb_pos = (tk_rb_pos + 1) % TK_RB_SIZE;
}
-void GDTokenizerText::_make_type(const Variant::Type &p_type) {
+void GDScriptTokenizerText::_make_type(const Variant::Type &p_type) {
TokenData &tk = tk_rb[tk_rb_pos];
@@ -422,7 +422,7 @@ void GDTokenizerText::_make_type(const Variant::Type &p_type) {
tk_rb_pos = (tk_rb_pos + 1) % TK_RB_SIZE;
}
-void GDTokenizerText::_make_error(const String &p_error) {
+void GDScriptTokenizerText::_make_error(const String &p_error) {
error_flag = true;
last_error = p_error;
@@ -435,7 +435,7 @@ void GDTokenizerText::_make_error(const String &p_error) {
tk_rb_pos = (tk_rb_pos + 1) % TK_RB_SIZE;
}
-void GDTokenizerText::_make_newline(int p_spaces) {
+void GDScriptTokenizerText::_make_newline(int p_spaces) {
TokenData &tk = tk_rb[tk_rb_pos];
tk.type = TK_NEWLINE;
@@ -445,7 +445,7 @@ void GDTokenizerText::_make_newline(int p_spaces) {
tk_rb_pos = (tk_rb_pos + 1) % TK_RB_SIZE;
}
-void GDTokenizerText::_advance() {
+void GDScriptTokenizerText::_advance() {
if (error_flag) {
//parser broke
@@ -885,6 +885,9 @@ void GDTokenizerText::_advance() {
return;
}
sign_found = true;
+ } else if (GETCHAR(i) == '_') {
+ i++;
+ continue; // Included for readability, shouldn't be a part of the string
} else
break;
@@ -897,7 +900,7 @@ void GDTokenizerText::_advance() {
return;
}
- INCPOS(str.length());
+ INCPOS(i);
if (hexa_found) {
int64_t val = str.hex_to_int64();
_make_constant(val);
@@ -963,11 +966,11 @@ void GDTokenizerText::_advance() {
//built in func?
- for (int i = 0; i < GDFunctions::FUNC_MAX; i++) {
+ for (int i = 0; i < GDScriptFunctions::FUNC_MAX; i++) {
- if (str == GDFunctions::get_func_name(GDFunctions::Function(i))) {
+ if (str == GDScriptFunctions::get_func_name(GDScriptFunctions::Function(i))) {
- _make_built_in_func(GDFunctions::Function(i));
+ _make_built_in_func(GDScriptFunctions::Function(i));
found = true;
break;
}
@@ -1013,7 +1016,7 @@ void GDTokenizerText::_advance() {
}
}
-void GDTokenizerText::set_code(const String &p_code) {
+void GDScriptTokenizerText::set_code(const String &p_code) {
code = p_code;
len = p_code.length();
@@ -1032,7 +1035,7 @@ void GDTokenizerText::set_code(const String &p_code) {
_advance();
}
-GDTokenizerText::Token GDTokenizerText::get_token(int p_offset) const {
+GDScriptTokenizerText::Token GDScriptTokenizerText::get_token(int p_offset) const {
ERR_FAIL_COND_V(p_offset <= -MAX_LOOKAHEAD, TK_ERROR);
ERR_FAIL_COND_V(p_offset >= MAX_LOOKAHEAD, TK_ERROR);
@@ -1040,7 +1043,7 @@ GDTokenizerText::Token GDTokenizerText::get_token(int p_offset) const {
return tk_rb[ofs].type;
}
-int GDTokenizerText::get_token_line(int p_offset) const {
+int GDScriptTokenizerText::get_token_line(int p_offset) const {
ERR_FAIL_COND_V(p_offset <= -MAX_LOOKAHEAD, -1);
ERR_FAIL_COND_V(p_offset >= MAX_LOOKAHEAD, -1);
@@ -1048,7 +1051,7 @@ int GDTokenizerText::get_token_line(int p_offset) const {
return tk_rb[ofs].line;
}
-int GDTokenizerText::get_token_column(int p_offset) const {
+int GDScriptTokenizerText::get_token_column(int p_offset) const {
ERR_FAIL_COND_V(p_offset <= -MAX_LOOKAHEAD, -1);
ERR_FAIL_COND_V(p_offset >= MAX_LOOKAHEAD, -1);
@@ -1056,7 +1059,7 @@ int GDTokenizerText::get_token_column(int p_offset) const {
return tk_rb[ofs].col;
}
-const Variant &GDTokenizerText::get_token_constant(int p_offset) const {
+const Variant &GDScriptTokenizerText::get_token_constant(int p_offset) const {
ERR_FAIL_COND_V(p_offset <= -MAX_LOOKAHEAD, tk_rb[0].constant);
ERR_FAIL_COND_V(p_offset >= MAX_LOOKAHEAD, tk_rb[0].constant);
@@ -1065,7 +1068,7 @@ const Variant &GDTokenizerText::get_token_constant(int p_offset) const {
return tk_rb[ofs].constant;
}
-StringName GDTokenizerText::get_token_identifier(int p_offset) const {
+StringName GDScriptTokenizerText::get_token_identifier(int p_offset) const {
ERR_FAIL_COND_V(p_offset <= -MAX_LOOKAHEAD, StringName());
ERR_FAIL_COND_V(p_offset >= MAX_LOOKAHEAD, StringName());
@@ -1075,17 +1078,17 @@ StringName GDTokenizerText::get_token_identifier(int p_offset) const {
return tk_rb[ofs].identifier;
}
-GDFunctions::Function GDTokenizerText::get_token_built_in_func(int p_offset) const {
+GDScriptFunctions::Function GDScriptTokenizerText::get_token_built_in_func(int p_offset) const {
- ERR_FAIL_COND_V(p_offset <= -MAX_LOOKAHEAD, GDFunctions::FUNC_MAX);
- ERR_FAIL_COND_V(p_offset >= MAX_LOOKAHEAD, GDFunctions::FUNC_MAX);
+ ERR_FAIL_COND_V(p_offset <= -MAX_LOOKAHEAD, GDScriptFunctions::FUNC_MAX);
+ ERR_FAIL_COND_V(p_offset >= MAX_LOOKAHEAD, GDScriptFunctions::FUNC_MAX);
int ofs = (TK_RB_SIZE + tk_rb_pos + p_offset - MAX_LOOKAHEAD - 1) % TK_RB_SIZE;
- ERR_FAIL_COND_V(tk_rb[ofs].type != TK_BUILT_IN_FUNC, GDFunctions::FUNC_MAX);
+ ERR_FAIL_COND_V(tk_rb[ofs].type != TK_BUILT_IN_FUNC, GDScriptFunctions::FUNC_MAX);
return tk_rb[ofs].func;
}
-Variant::Type GDTokenizerText::get_token_type(int p_offset) const {
+Variant::Type GDScriptTokenizerText::get_token_type(int p_offset) const {
ERR_FAIL_COND_V(p_offset <= -MAX_LOOKAHEAD, Variant::NIL);
ERR_FAIL_COND_V(p_offset >= MAX_LOOKAHEAD, Variant::NIL);
@@ -1095,7 +1098,7 @@ Variant::Type GDTokenizerText::get_token_type(int p_offset) const {
return tk_rb[ofs].vtype;
}
-int GDTokenizerText::get_token_line_indent(int p_offset) const {
+int GDScriptTokenizerText::get_token_line_indent(int p_offset) const {
ERR_FAIL_COND_V(p_offset <= -MAX_LOOKAHEAD, 0);
ERR_FAIL_COND_V(p_offset >= MAX_LOOKAHEAD, 0);
@@ -1105,7 +1108,7 @@ int GDTokenizerText::get_token_line_indent(int p_offset) const {
return tk_rb[ofs].constant;
}
-String GDTokenizerText::get_token_error(int p_offset) const {
+String GDScriptTokenizerText::get_token_error(int p_offset) const {
ERR_FAIL_COND_V(p_offset <= -MAX_LOOKAHEAD, String());
ERR_FAIL_COND_V(p_offset >= MAX_LOOKAHEAD, String());
@@ -1115,18 +1118,18 @@ String GDTokenizerText::get_token_error(int p_offset) const {
return tk_rb[ofs].constant;
}
-void GDTokenizerText::advance(int p_amount) {
+void GDScriptTokenizerText::advance(int p_amount) {
ERR_FAIL_COND(p_amount <= 0);
for (int i = 0; i < p_amount; i++)
_advance();
}
-//////////////////////////////////////////////////////////////////////////////////////////////////////
+ //////////////////////////////////////////////////////////////////////////////////////////////////////
#define BYTECODE_VERSION 12
-Error GDTokenizerBuffer::set_code_buffer(const Vector<uint8_t> &p_buffer) {
+Error GDScriptTokenizerBuffer::set_code_buffer(const Vector<uint8_t> &p_buffer) {
const uint8_t *buf = p_buffer.ptr();
int total_len = p_buffer.size();
@@ -1214,7 +1217,7 @@ Error GDTokenizerBuffer::set_code_buffer(const Vector<uint8_t> &p_buffer) {
return OK;
}
-Vector<uint8_t> GDTokenizerBuffer::parse_code_string(const String &p_code) {
+Vector<uint8_t> GDScriptTokenizerBuffer::parse_code_string(const String &p_code) {
Vector<uint8_t> buf;
@@ -1223,7 +1226,7 @@ Vector<uint8_t> GDTokenizerBuffer::parse_code_string(const String &p_code) {
Map<uint32_t, int> line_map;
Vector<uint32_t> token_array;
- GDTokenizerText tt;
+ GDScriptTokenizerText tt;
tt.set_code(p_code);
int line = -1;
@@ -1372,17 +1375,17 @@ Vector<uint8_t> GDTokenizerBuffer::parse_code_string(const String &p_code) {
return buf;
}
-GDTokenizerBuffer::Token GDTokenizerBuffer::get_token(int p_offset) const {
+GDScriptTokenizerBuffer::Token GDScriptTokenizerBuffer::get_token(int p_offset) const {
int offset = token + p_offset;
if (offset < 0 || offset >= tokens.size())
return TK_EOF;
- return GDTokenizerBuffer::Token(tokens[offset] & TOKEN_MASK);
+ return GDScriptTokenizerBuffer::Token(tokens[offset] & TOKEN_MASK);
}
-StringName GDTokenizerBuffer::get_token_identifier(int p_offset) const {
+StringName GDScriptTokenizerBuffer::get_token_identifier(int p_offset) const {
int offset = token + p_offset;
@@ -1393,14 +1396,14 @@ StringName GDTokenizerBuffer::get_token_identifier(int p_offset) const {
return identifiers[identifier];
}
-GDFunctions::Function GDTokenizerBuffer::get_token_built_in_func(int p_offset) const {
+GDScriptFunctions::Function GDScriptTokenizerBuffer::get_token_built_in_func(int p_offset) const {
int offset = token + p_offset;
- ERR_FAIL_INDEX_V(offset, tokens.size(), GDFunctions::FUNC_MAX);
- return GDFunctions::Function(tokens[offset] >> TOKEN_BITS);
+ ERR_FAIL_INDEX_V(offset, tokens.size(), GDScriptFunctions::FUNC_MAX);
+ return GDScriptFunctions::Function(tokens[offset] >> TOKEN_BITS);
}
-Variant::Type GDTokenizerBuffer::get_token_type(int p_offset) const {
+Variant::Type GDScriptTokenizerBuffer::get_token_type(int p_offset) const {
int offset = token + p_offset;
ERR_FAIL_INDEX_V(offset, tokens.size(), Variant::NIL);
@@ -1408,7 +1411,7 @@ Variant::Type GDTokenizerBuffer::get_token_type(int p_offset) const {
return Variant::Type(tokens[offset] >> TOKEN_BITS);
}
-int GDTokenizerBuffer::get_token_line(int p_offset) const {
+int GDScriptTokenizerBuffer::get_token_line(int p_offset) const {
int offset = token + p_offset;
int pos = lines.find_nearest(offset);
@@ -1421,7 +1424,7 @@ int GDTokenizerBuffer::get_token_line(int p_offset) const {
uint32_t l = lines.getv(pos);
return l & TOKEN_LINE_MASK;
}
-int GDTokenizerBuffer::get_token_column(int p_offset) const {
+int GDScriptTokenizerBuffer::get_token_column(int p_offset) const {
int offset = token + p_offset;
int pos = lines.find_nearest(offset);
@@ -1433,13 +1436,13 @@ int GDTokenizerBuffer::get_token_column(int p_offset) const {
uint32_t l = lines.getv(pos);
return l >> TOKEN_LINE_BITS;
}
-int GDTokenizerBuffer::get_token_line_indent(int p_offset) const {
+int GDScriptTokenizerBuffer::get_token_line_indent(int p_offset) const {
int offset = token + p_offset;
ERR_FAIL_INDEX_V(offset, tokens.size(), 0);
return tokens[offset] >> TOKEN_BITS;
}
-const Variant &GDTokenizerBuffer::get_token_constant(int p_offset) const {
+const Variant &GDScriptTokenizerBuffer::get_token_constant(int p_offset) const {
int offset = token + p_offset;
ERR_FAIL_INDEX_V(offset, tokens.size(), nil);
@@ -1447,17 +1450,17 @@ const Variant &GDTokenizerBuffer::get_token_constant(int p_offset) const {
ERR_FAIL_INDEX_V(constant, (uint32_t)constants.size(), nil);
return constants[constant];
}
-String GDTokenizerBuffer::get_token_error(int p_offset) const {
+String GDScriptTokenizerBuffer::get_token_error(int p_offset) const {
ERR_FAIL_V(String());
}
-void GDTokenizerBuffer::advance(int p_amount) {
+void GDScriptTokenizerBuffer::advance(int p_amount) {
ERR_FAIL_INDEX(p_amount + token, tokens.size());
token += p_amount;
}
-GDTokenizerBuffer::GDTokenizerBuffer() {
+GDScriptTokenizerBuffer::GDScriptTokenizerBuffer() {
token = 0;
}
diff --git a/modules/gdscript/gd_tokenizer.h b/modules/gdscript/gdscript_tokenizer.h
index f4b579def4..d19367177b 100644
--- a/modules/gdscript/gd_tokenizer.h
+++ b/modules/gdscript/gdscript_tokenizer.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* gd_tokenizer.h */
+/* gdscript_tokenizer.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -27,16 +27,16 @@
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef GD_TOKENIZER_H
-#define GD_TOKENIZER_H
+#ifndef GDSCRIPT_TOKENIZER_H
+#define GDSCRIPT_TOKENIZER_H
-#include "gd_functions.h"
+#include "gdscript_functions.h"
#include "string_db.h"
#include "ustring.h"
#include "variant.h"
#include "vmap.h"
-class GDTokenizer {
+class GDScriptTokenizer {
public:
enum Token {
@@ -156,7 +156,7 @@ public:
virtual const Variant &get_token_constant(int p_offset = 0) const = 0;
virtual Token get_token(int p_offset = 0) const = 0;
virtual StringName get_token_identifier(int p_offset = 0) const = 0;
- virtual GDFunctions::Function get_token_built_in_func(int p_offset = 0) const = 0;
+ virtual GDScriptFunctions::Function get_token_built_in_func(int p_offset = 0) const = 0;
virtual Variant::Type get_token_type(int p_offset = 0) const = 0;
virtual int get_token_line(int p_offset = 0) const = 0;
virtual int get_token_column(int p_offset = 0) const = 0;
@@ -164,10 +164,10 @@ public:
virtual String get_token_error(int p_offset = 0) const = 0;
virtual void advance(int p_amount = 1) = 0;
- virtual ~GDTokenizer(){};
+ virtual ~GDScriptTokenizer(){};
};
-class GDTokenizerText : public GDTokenizer {
+class GDScriptTokenizerText : public GDScriptTokenizer {
enum {
MAX_LOOKAHEAD = 4,
@@ -181,7 +181,7 @@ class GDTokenizerText : public GDTokenizer {
Variant constant; //for constant types
union {
Variant::Type vtype; //for type types
- GDFunctions::Function func; //function for built in functions
+ GDScriptFunctions::Function func; //function for built in functions
};
int line, col;
TokenData() {
@@ -194,7 +194,7 @@ class GDTokenizerText : public GDTokenizer {
void _make_token(Token p_type);
void _make_newline(int p_spaces = 0);
void _make_identifier(const StringName &p_identifier);
- void _make_built_in_func(GDFunctions::Function p_func);
+ void _make_built_in_func(GDScriptFunctions::Function p_func);
void _make_constant(const Variant &p_constant);
void _make_type(const Variant::Type &p_type);
void _make_error(const String &p_error);
@@ -216,7 +216,7 @@ public:
void set_code(const String &p_code);
virtual Token get_token(int p_offset = 0) const;
virtual StringName get_token_identifier(int p_offset = 0) const;
- virtual GDFunctions::Function get_token_built_in_func(int p_offset = 0) const;
+ virtual GDScriptFunctions::Function get_token_built_in_func(int p_offset = 0) const;
virtual Variant::Type get_token_type(int p_offset = 0) const;
virtual int get_token_line(int p_offset = 0) const;
virtual int get_token_column(int p_offset = 0) const;
@@ -226,7 +226,7 @@ public:
virtual void advance(int p_amount = 1);
};
-class GDTokenizerBuffer : public GDTokenizer {
+class GDScriptTokenizerBuffer : public GDScriptTokenizer {
enum {
@@ -249,7 +249,7 @@ public:
static Vector<uint8_t> parse_code_string(const String &p_code);
virtual Token get_token(int p_offset = 0) const;
virtual StringName get_token_identifier(int p_offset = 0) const;
- virtual GDFunctions::Function get_token_built_in_func(int p_offset = 0) const;
+ virtual GDScriptFunctions::Function get_token_built_in_func(int p_offset = 0) const;
virtual Variant::Type get_token_type(int p_offset = 0) const;
virtual int get_token_line(int p_offset = 0) const;
virtual int get_token_column(int p_offset = 0) const;
@@ -257,7 +257,7 @@ public:
virtual const Variant &get_token_constant(int p_offset = 0) const;
virtual String get_token_error(int p_offset = 0) const;
virtual void advance(int p_amount = 1);
- GDTokenizerBuffer();
+ GDScriptTokenizerBuffer();
};
-#endif // TOKENIZER_H
+#endif // GDSCRIPT_TOKENIZER_H
diff --git a/modules/gdscript/register_types.cpp b/modules/gdscript/register_types.cpp
index 036274c8f2..1e007ddb0f 100644
--- a/modules/gdscript/register_types.cpp
+++ b/modules/gdscript/register_types.cpp
@@ -29,7 +29,7 @@
/*************************************************************************/
#include "register_types.h"
-#include "gd_script.h"
+#include "gdscript.h"
#include "io/file_access_encrypted.h"
#include "io/resource_loader.h"
#include "os/file_access.h"
@@ -41,10 +41,9 @@ ResourceFormatSaverGDScript *resource_saver_gd = NULL;
void register_gdscript_types() {
ClassDB::register_class<GDScript>();
- ClassDB::register_virtual_class<GDFunctionState>();
+ ClassDB::register_virtual_class<GDScriptFunctionState>();
script_language_gd = memnew(GDScriptLanguage);
- //script_language_gd->init();
ScriptServer::register_language(script_language_gd);
resource_loader_gd = memnew(ResourceFormatLoaderGDScript);
ResourceLoader::add_resource_format_loader(resource_loader_gd);
diff --git a/modules/gridmap/grid_map.cpp b/modules/gridmap/grid_map.cpp
index cb14a5ee9c..b3a1947647 100644
--- a/modules/gridmap/grid_map.cpp
+++ b/modules/gridmap/grid_map.cpp
@@ -747,7 +747,6 @@ void GridMap::_update_octants_callback() {
}
while (to_delete.front()) {
- memdelete(octant_map[to_delete.front()->get()]);
octant_map.erase(to_delete.front()->get());
to_delete.pop_back();
}
diff --git a/modules/gridmap/grid_map_editor_plugin.cpp b/modules/gridmap/grid_map_editor_plugin.cpp
index f6a76ad2a1..491adb31ee 100644
--- a/modules/gridmap/grid_map_editor_plugin.cpp
+++ b/modules/gridmap/grid_map_editor_plugin.cpp
@@ -28,8 +28,10 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "grid_map_editor_plugin.h"
+#include "editor/editor_scale.h"
#include "editor/editor_settings.h"
#include "editor/plugins/spatial_editor_plugin.h"
+#include "os/input.h"
#include "scene/3d/camera.h"
#include "geometry.h"
@@ -56,6 +58,14 @@ void GridMapEditor::_menu_option(int p_option) {
switch (p_option) {
+ case MENU_OPTION_PREV_LEVEL: {
+ floor->set_value(floor->get_value() - 1);
+ } break;
+
+ case MENU_OPTION_NEXT_LEVEL: {
+ floor->set_value(floor->get_value() + 1);
+ } break;
+
case MENU_OPTION_CONFIGURE: {
} break;
@@ -94,6 +104,7 @@ void GridMapEditor::_menu_option(int p_option) {
} break;
case MENU_OPTION_CURSOR_ROTATE_Y: {
+
Basis r;
if (input_action == INPUT_DUPLICATE) {
@@ -109,6 +120,7 @@ void GridMapEditor::_menu_option(int p_option) {
_update_cursor_transform();
} break;
case MENU_OPTION_CURSOR_ROTATE_X: {
+
Basis r;
if (input_action == INPUT_DUPLICATE) {
@@ -125,6 +137,7 @@ void GridMapEditor::_menu_option(int p_option) {
_update_cursor_transform();
} break;
case MENU_OPTION_CURSOR_ROTATE_Z: {
+
Basis r;
if (input_action == INPUT_DUPLICATE) {
@@ -141,6 +154,7 @@ void GridMapEditor::_menu_option(int p_option) {
_update_cursor_transform();
} break;
case MENU_OPTION_CURSOR_BACK_ROTATE_Y: {
+
Basis r;
r.set_orthogonal_index(cursor_rot);
r.rotate(Vector3(0, 1, 0), Math_PI / 2.0);
@@ -148,6 +162,7 @@ void GridMapEditor::_menu_option(int p_option) {
_update_cursor_transform();
} break;
case MENU_OPTION_CURSOR_BACK_ROTATE_X: {
+
Basis r;
r.set_orthogonal_index(cursor_rot);
r.rotate(Vector3(1, 0, 0), Math_PI / 2.0);
@@ -155,6 +170,7 @@ void GridMapEditor::_menu_option(int p_option) {
_update_cursor_transform();
} break;
case MENU_OPTION_CURSOR_BACK_ROTATE_Z: {
+
Basis r;
r.set_orthogonal_index(cursor_rot);
r.rotate(Vector3(0, 0, 1), Math_PI / 2.0);
@@ -184,6 +200,9 @@ void GridMapEditor::_menu_option(int p_option) {
if (last_mouseover == Vector3(-1, -1, -1)) //nono mouseovering anythin
break;
+ last_mouseover = selection.begin;
+ VS::get_singleton()->instance_set_transform(grid_instance[edit_axis], Transform(Basis(), grid_ofs));
+
input_action = INPUT_DUPLICATE;
selection.click = last_mouseover;
selection.current = last_mouseover;
@@ -198,7 +217,7 @@ void GridMapEditor::_menu_option(int p_option) {
} break;
case MENU_OPTION_GRIDMAP_SETTINGS: {
- settings_dialog->popup_centered(settings_vbc->get_combined_minimum_size() + Size2(50, 50));
+ settings_dialog->popup_centered(settings_vbc->get_combined_minimum_size() + Size2(50, 50) * EDSCALE);
} break;
}
}
@@ -551,12 +570,11 @@ bool GridMapEditor::forward_spatial_input_event(Camera *p_camera, const Ref<Inpu
input_action = INPUT_NONE;
_update_duplicate_indicator();
- } else {
+ } else if (mb->get_shift()) {
input_action = INPUT_ERASE;
set_items.clear();
- }
- else
- return false;
+ } else
+ return false;
return do_input_action(p_camera, Point2(mb->get_position().x, mb->get_position().y), true);
} else {
@@ -829,70 +847,77 @@ void GridMapEditor::update_grid() {
void GridMapEditor::_notification(int p_what) {
- if (p_what == NOTIFICATION_ENTER_TREE) {
+ switch (p_what) {
- theme_pallete->connect("item_selected", this, "_item_selected_cbk");
- for (int i = 0; i < 3; i++) {
+ case NOTIFICATION_ENTER_TREE: {
+ theme_pallete->connect("item_selected", this, "_item_selected_cbk");
+ 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());
- }
+ 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());
- duplicate_instance = VisualServer::get_singleton()->instance_create2(duplicate_mesh, 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());
+ duplicate_instance = VisualServer::get_singleton()->instance_create2(duplicate_mesh, get_tree()->get_root()->get_world()->get_scenario());
- _update_selection_transform();
- _update_duplicate_indicator();
-
- } else if (p_what == NOTIFICATION_EXIT_TREE) {
+ _update_selection_transform();
+ _update_duplicate_indicator();
+ } break;
- for (int i = 0; i < 3; i++) {
+ case NOTIFICATION_EXIT_TREE: {
+ for (int i = 0; i < 3; i++) {
- VS::get_singleton()->free(grid_instance[i]);
- VS::get_singleton()->free(grid[i]);
- grid_instance[i] = RID();
- grid[i] = RID();
- VisualServer::get_singleton()->free(selection_level_instance[i]);
- }
+ VS::get_singleton()->free(grid_instance[i]);
+ 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);
- VisualServer::get_singleton()->free(duplicate_instance);
- selection_instance = RID();
- duplicate_instance = RID();
+ VisualServer::get_singleton()->free(selection_instance);
+ VisualServer::get_singleton()->free(duplicate_instance);
+ selection_instance = RID();
+ duplicate_instance = RID();
+ } break;
- } else if (p_what == NOTIFICATION_PROCESS) {
- if (!node) {
- return;
- }
+ case NOTIFICATION_PROCESS: {
+ if (!node) {
+ return;
+ }
- Transform xf = node->get_global_transform();
+ Transform xf = node->get_global_transform();
- if (xf != grid_xform) {
- for (int i = 0; i < 3; i++) {
+ if (xf != grid_xform) {
+ for (int i = 0; i < 3; i++) {
- VS::get_singleton()->instance_set_transform(grid_instance[i], xf * edit_grid_xform);
+ VS::get_singleton()->instance_set_transform(grid_instance[i], xf * edit_grid_xform);
+ }
+ grid_xform = xf;
}
- grid_xform = xf;
- }
- Ref<MeshLibrary> cgmt = node->get_theme();
- if (cgmt.operator->() != last_theme)
- update_pallete();
+ Ref<MeshLibrary> cgmt = node->get_theme();
+ if (cgmt.operator->() != last_theme)
+ update_pallete();
- if (lock_view) {
+ if (lock_view) {
- EditorNode *editor = Object::cast_to<EditorNode>(get_tree()->get_root()->get_child(0));
+ 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()[edit_axis];
- p = node->get_transform().xform(p); // plane to snap
+ Plane p;
+ p.normal[edit_axis] = 1.0;
+ p.d = edit_floor[edit_axis] * node->get_cell_size()[edit_axis];
+ p = node->get_transform().xform(p); // plane to snap
- 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);
- }
+ 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);
+ }
+ } break;
+
+ case NOTIFICATION_THEME_CHANGED: {
+ options->set_icon(get_icon("GridMap", "EditorIcons"));
+ } break;
}
}
@@ -954,20 +979,38 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) {
int mw = EDITOR_DEF("editors/grid_map/palette_min_width", 230);
Control *ec = memnew(Control);
- ec->set_custom_minimum_size(Size2(mw, 0));
+ ec->set_custom_minimum_size(Size2(mw, 0) * EDSCALE);
add_child(ec);
spatial_editor_hb = memnew(HBoxContainer);
+ spatial_editor_hb->set_h_size_flags(SIZE_EXPAND_FILL);
+ spatial_editor_hb->set_alignment(BoxContainer::ALIGN_END);
SpatialEditor::get_singleton()->add_control_to_menu_panel(spatial_editor_hb);
+
+ Label *fl = memnew(Label);
+ fl->set_text(TTR("Floor:"));
+ spatial_editor_hb->add_child(fl);
+
+ floor = memnew(SpinBox);
+ floor->set_min(-32767);
+ floor->set_max(32767);
+ floor->set_step(1);
+ floor->get_line_edit()->add_constant_override("minimum_spaces", 16);
+
+ spatial_editor_hb->add_child(floor);
+ floor->connect("value_changed", this, "_floor_changed");
+
+ spatial_editor_hb->add_child(memnew(VSeparator));
+
options = memnew(MenuButton);
spatial_editor_hb->add_child(options);
spatial_editor_hb->hide();
- options->set_text("Grid");
+ options->set_text(TTR("Grid Map"));
options->get_popup()->add_check_item(TTR("Snap View"), MENU_OPTION_LOCK_VIEW);
options->get_popup()->add_separator();
- 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_item(TTR("Previous Floor"), MENU_OPTION_PREV_LEVEL, KEY_Q);
+ options->get_popup()->add_item(TTR("Next Floor"), MENU_OPTION_NEXT_LEVEL, KEY_E);
options->get_popup()->add_separator();
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);
@@ -993,8 +1036,8 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) {
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(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_item(TTR("Duplicate Selection"), MENU_OPTION_SELECTION_DUPLICATE, KEY_MASK_SHIFT + KEY_C);
+ options->get_popup()->add_item(TTR("Clear Selection"), MENU_OPTION_SELECTION_CLEAR, KEY_MASK_SHIFT + KEY_X);
options->get_popup()->add_separator();
options->get_popup()->add_item(TTR("Settings"), MENU_OPTION_GRIDMAP_SETTINGS);
@@ -1003,7 +1046,7 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) {
settings_dialog->set_title(TTR("GridMap Settings"));
add_child(settings_dialog);
settings_vbc = memnew(VBoxContainer);
- settings_vbc->set_custom_minimum_size(Size2(200, 0));
+ settings_vbc->set_custom_minimum_size(Size2(200, 0) * EDSCALE);
settings_dialog->add_child(settings_vbc);
settings_pick_distance = memnew(SpinBox);
@@ -1042,20 +1085,6 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) {
add_child(theme_pallete);
theme_pallete->set_v_size_flags(SIZE_EXPAND_FILL);
- spatial_editor_hb->add_child(memnew(VSeparator));
- Label *fl = memnew(Label);
- fl->set_text(" Floor: ");
- spatial_editor_hb->add_child(fl);
-
- floor = memnew(SpinBox);
- floor->set_min(-32767);
- floor->set_max(32767);
- floor->set_step(1);
- floor->get_line_edit()->add_constant_override("minimum_spaces", 16);
-
- spatial_editor_hb->add_child(floor);
- floor->connect("value_changed", this, "_floor_changed");
-
edit_axis = Vector3::AXIS_Y;
edit_floor[0] = -1;
edit_floor[1] = -1;
@@ -1108,7 +1137,7 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) {
for (int i = 0; i < 12; i++) {
- Rect3 base(Vector3(0, 0, 0), Vector3(1, 1, 1));
+ AABB base(Vector3(0, 0, 0), Vector3(1, 1, 1));
Vector3 a, b;
base.get_edge(i, a, b);
lines.push_back(a);
@@ -1250,7 +1279,9 @@ GridMapEditorPlugin::GridMapEditorPlugin(EditorNode *p_node) {
gridmap_editor = memnew(GridMapEditor(editor));
SpatialEditor::get_singleton()->get_palette_split()->add_child(gridmap_editor);
- SpatialEditor::get_singleton()->get_palette_split()->move_child(gridmap_editor, 0);
+ // TODO: make this configurable, so the user can choose were to put this, it makes more sense
+ // on the right, but some people might find it strange.
+ SpatialEditor::get_singleton()->get_palette_split()->move_child(gridmap_editor, 1);
gridmap_editor->hide();
}
diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp
index 161e130a07..dfa5e720ae 100644
--- a/modules/mono/csharp_script.cpp
+++ b/modules/mono/csharp_script.cpp
@@ -346,7 +346,7 @@ static String variant_type_to_managed_name(const String &p_var_type_name) {
Variant::TRANSFORM2D,
Variant::PLANE,
Variant::QUAT,
- Variant::RECT3,
+ Variant::AABB,
Variant::BASIS,
Variant::TRANSFORM,
Variant::COLOR,
diff --git a/modules/mono/editor/bindings_generator.cpp b/modules/mono/editor/bindings_generator.cpp
index a293cc2c50..59a2b73dbc 100644
--- a/modules/mono/editor/bindings_generator.cpp
+++ b/modules/mono/editor/bindings_generator.cpp
@@ -1721,7 +1721,7 @@ void BindingsGenerator::_default_argument_from_variant(const Variant &p_val, Arg
r_iarg.def_param_mode = ArgumentInterface::NULLABLE_VAL;
break;
case Variant::PLANE:
- case Variant::RECT3:
+ case Variant::AABB:
case Variant::COLOR:
r_iarg.default_argument = "new Color(1, 1, 1, 1)";
r_iarg.def_param_mode = ArgumentInterface::NULLABLE_VAL;
@@ -1793,7 +1793,7 @@ void BindingsGenerator::_populate_builtin_type_interfaces() {
INSERT_STRUCT_TYPE(Basis, "real_t*")
INSERT_STRUCT_TYPE(Quat, "real_t*")
INSERT_STRUCT_TYPE(Transform, "real_t*")
- INSERT_STRUCT_TYPE(Rect3, "real_t*")
+ INSERT_STRUCT_TYPE(AABB, "real_t*")
INSERT_STRUCT_TYPE(Color, "real_t*")
INSERT_STRUCT_TYPE(Plane, "real_t*")
diff --git a/modules/mono/glue/cs_files/Rect3.cs b/modules/mono/glue/cs_files/AABB.cs
index 617d33e7fd..6ee3bbe53a 100644
--- a/modules/mono/glue/cs_files/Rect3.cs
+++ b/modules/mono/glue/cs_files/AABB.cs
@@ -1,15 +1,15 @@
using System;
-// file: core/math/rect3.h
+// file: core/math/aabb.h
// commit: 7ad14e7a3e6f87ddc450f7e34621eb5200808451
-// file: core/math/rect3.cpp
+// file: core/math/aabb.cpp
// commit: bd282ff43f23fe845f29a3e25c8efc01bd65ffb0
// file: core/variant_call.cpp
// commit: 5ad9be4c24e9d7dc5672fdc42cea896622fe5685
namespace Godot
{
- public struct Rect3 : IEquatable<Rect3>
+ public struct AABB : IEquatable<AABB>
{
private Vector3 position;
private Vector3 size;
@@ -38,7 +38,7 @@ namespace Godot
}
}
- public bool encloses(Rect3 with)
+ public bool encloses(AABB with)
{
Vector3 src_min = position;
Vector3 src_max = position + size;
@@ -53,7 +53,7 @@ namespace Godot
(src_max.z > dst_max.z));
}
- public Rect3 expand(Vector3 to_point)
+ public AABB expand(Vector3 to_point)
{
Vector3 begin = position;
Vector3 end = position + size;
@@ -72,7 +72,7 @@ namespace Godot
if (to_point.z > end.z)
end.z = to_point.z;
- return new Rect3(begin, end - begin);
+ return new AABB(begin, end - begin);
}
public float get_area()
@@ -222,9 +222,9 @@ namespace Godot
(dir.z > 0f) ? -half_extents.z : half_extents.z);
}
- public Rect3 grow(float by)
+ public AABB grow(float by)
{
- Rect3 res = this;
+ AABB res = this;
res.position.x -= by;
res.position.y -= by;
@@ -264,7 +264,7 @@ namespace Godot
return true;
}
- public Rect3 intersection(Rect3 with)
+ public AABB intersection(AABB with)
{
Vector3 src_min = position;
Vector3 src_max = position + size;
@@ -275,7 +275,7 @@ namespace Godot
if (src_min.x > dst_max.x || src_max.x < dst_min.x)
{
- return new Rect3();
+ return new AABB();
}
else
{
@@ -285,7 +285,7 @@ namespace Godot
if (src_min.y > dst_max.y || src_max.y < dst_min.y)
{
- return new Rect3();
+ return new AABB();
}
else
{
@@ -295,7 +295,7 @@ namespace Godot
if (src_min.z > dst_max.z || src_max.z < dst_min.z)
{
- return new Rect3();
+ return new AABB();
}
else
{
@@ -303,10 +303,10 @@ namespace Godot
max.z = (src_max.z < dst_max.z) ? src_max.z : dst_max.z;
}
- return new Rect3(min, max - min);
+ return new AABB(min, max - min);
}
- public bool intersects(Rect3 with)
+ public bool intersects(AABB with)
{
if (position.x >= (with.position.x + with.size.x))
return false;
@@ -398,7 +398,7 @@ namespace Godot
return true;
}
- public Rect3 merge(Rect3 with)
+ public AABB merge(AABB with)
{
Vector3 beg_1 = position;
Vector3 beg_2 = with.position;
@@ -417,36 +417,36 @@ namespace Godot
(end_1.z > end_2.z) ? end_1.z : end_2.z
);
- return new Rect3(min, max - min);
+ return new AABB(min, max - min);
}
- public Rect3(Vector3 position, Vector3 size)
+ public AABB(Vector3 position, Vector3 size)
{
this.position = position;
this.size = size;
}
- public static bool operator ==(Rect3 left, Rect3 right)
+ public static bool operator ==(AABB left, AABB right)
{
return left.Equals(right);
}
- public static bool operator !=(Rect3 left, Rect3 right)
+ public static bool operator !=(AABB left, AABB right)
{
return !left.Equals(right);
}
public override bool Equals(object obj)
{
- if (obj is Rect3)
+ if (obj is AABB)
{
- return Equals((Rect3)obj);
+ return Equals((AABB)obj);
}
return false;
}
- public bool Equals(Rect3 other)
+ public bool Equals(AABB other)
{
return position == other.position && size == other.size;
}
diff --git a/modules/mono/mono_gd/gd_mono_field.cpp b/modules/mono/mono_gd/gd_mono_field.cpp
index 1643f8cfc5..1bee1115a6 100644
--- a/modules/mono/mono_gd/gd_mono_field.cpp
+++ b/modules/mono/mono_gd/gd_mono_field.cpp
@@ -129,8 +129,8 @@ void GDMonoField::set_value(MonoObject *p_object, const Variant &p_value) {
if (tclass == CACHED_CLASS(Transform))
SET_FROM_STRUCT_AND_BREAK(Transform);
- if (tclass == CACHED_CLASS(Rect3))
- SET_FROM_STRUCT_AND_BREAK(Rect3);
+ if (tclass == CACHED_CLASS(AABB))
+ SET_FROM_STRUCT_AND_BREAK(AABB);
if (tclass == CACHED_CLASS(Color))
SET_FROM_STRUCT_AND_BREAK(Color);
@@ -229,7 +229,7 @@ void GDMonoField::set_value(MonoObject *p_object, const Variant &p_value) {
case Variant::TRANSFORM2D: SET_FROM_STRUCT_AND_BREAK(Transform2D);
case Variant::PLANE: SET_FROM_STRUCT_AND_BREAK(Plane);
case Variant::QUAT: SET_FROM_STRUCT_AND_BREAK(Quat);
- case Variant::RECT3: SET_FROM_STRUCT_AND_BREAK(Rect3);
+ case Variant::AABB: SET_FROM_STRUCT_AND_BREAK(AABB);
case Variant::BASIS: SET_FROM_STRUCT_AND_BREAK(Basis);
case Variant::TRANSFORM: SET_FROM_STRUCT_AND_BREAK(Transform);
case Variant::COLOR: SET_FROM_STRUCT_AND_BREAK(Color);
diff --git a/modules/mono/mono_gd/gd_mono_marshal.cpp b/modules/mono/mono_gd/gd_mono_marshal.cpp
index 01392447f3..9c415951bb 100644
--- a/modules/mono/mono_gd/gd_mono_marshal.cpp
+++ b/modules/mono/mono_gd/gd_mono_marshal.cpp
@@ -104,8 +104,8 @@ Variant::Type managed_to_variant_type(const ManagedType &p_type) {
if (tclass == CACHED_CLASS(Transform))
return Variant::TRANSFORM;
- if (tclass == CACHED_CLASS(Rect3))
- return Variant::RECT3;
+ if (tclass == CACHED_CLASS(AABB))
+ return Variant::AABB;
if (tclass == CACHED_CLASS(Color))
return Variant::COLOR;
@@ -297,8 +297,8 @@ MonoObject *variant_to_mono_object(const Variant *p_var, const ManagedType &p_ty
if (tclass == CACHED_CLASS(Transform))
RETURN_BOXED_STRUCT(Transform, p_var);
- if (tclass == CACHED_CLASS(Rect3))
- RETURN_BOXED_STRUCT(Rect3, p_var);
+ if (tclass == CACHED_CLASS(AABB))
+ RETURN_BOXED_STRUCT(AABB, p_var);
if (tclass == CACHED_CLASS(Color))
RETURN_BOXED_STRUCT(Color, p_var);
@@ -394,8 +394,8 @@ MonoObject *variant_to_mono_object(const Variant *p_var, const ManagedType &p_ty
RETURN_BOXED_STRUCT(Plane, p_var);
case Variant::QUAT:
RETURN_BOXED_STRUCT(Quat, p_var);
- case Variant::RECT3:
- RETURN_BOXED_STRUCT(Rect3, p_var);
+ case Variant::AABB:
+ RETURN_BOXED_STRUCT(AABB, p_var);
case Variant::BASIS:
RETURN_BOXED_STRUCT(Basis, p_var);
case Variant::TRANSFORM:
@@ -518,8 +518,8 @@ Variant mono_object_to_variant(MonoObject *p_obj, const ManagedType &p_type) {
if (tclass == CACHED_CLASS(Transform))
RETURN_UNBOXED_STRUCT(Transform, p_obj);
- if (tclass == CACHED_CLASS(Rect3))
- RETURN_UNBOXED_STRUCT(Rect3, p_obj);
+ if (tclass == CACHED_CLASS(AABB))
+ RETURN_UNBOXED_STRUCT(AABB, p_obj);
if (tclass == CACHED_CLASS(Color))
RETURN_UNBOXED_STRUCT(Color, p_obj);
diff --git a/modules/mono/mono_gd/gd_mono_marshal.h b/modules/mono/mono_gd/gd_mono_marshal.h
index 9f403b787f..443e947fb5 100644
--- a/modules/mono/mono_gd/gd_mono_marshal.h
+++ b/modules/mono/mono_gd/gd_mono_marshal.h
@@ -197,10 +197,10 @@ Dictionary mono_object_to_Dictionary(MonoObject *p_dict);
Basis(m_in[0], m_in[1], m_in[2], m_in[3], m_in[4], m_in[5], m_in[6], m_in[7], m_in[8]), \
Vector3(m_in[9], m_in[10], m_in[11]));
-// Rect3
+// AABB
-#define MARSHALLED_OUT_Rect3(m_in, m_out) real_t m_out[6] = { m_in.position.x, m_in.position.y, m_in.position.z, m_in.size.x, m_in.size.y, m_in.size.z };
-#define MARSHALLED_IN_Rect3(m_in, m_out) Rect3 m_out(Vector3(m_in[0], m_in[1], m_in[2]), Vector3(m_in[3], m_in[4], m_in[5]));
+#define MARSHALLED_OUT_AABB(m_in, m_out) real_t m_out[6] = { m_in.position.x, m_in.position.y, m_in.position.z, m_in.size.x, m_in.size.y, m_in.size.z };
+#define MARSHALLED_IN_AABB(m_in, m_out) AABB m_out(Vector3(m_in[0], m_in[1], m_in[2]), Vector3(m_in[3], m_in[4], m_in[5]));
// Color
@@ -214,6 +214,6 @@ Dictionary mono_object_to_Dictionary(MonoObject *p_dict);
#endif
-} // GDMonoMarshal
+} // namespace GDMonoMarshal
#endif // GDMONOMARSHAL_H
diff --git a/modules/mono/mono_gd/gd_mono_utils.cpp b/modules/mono/mono_gd/gd_mono_utils.cpp
index 53e45002c4..1cccd0ad9d 100644
--- a/modules/mono/mono_gd/gd_mono_utils.cpp
+++ b/modules/mono/mono_gd/gd_mono_utils.cpp
@@ -80,7 +80,7 @@ void MonoCache::clear_members() {
class_Basis = NULL;
class_Quat = NULL;
class_Transform = NULL;
- class_Rect3 = NULL;
+ class_AABB = NULL;
class_Color = NULL;
class_Plane = NULL;
class_NodePath = NULL;
@@ -147,7 +147,7 @@ void update_godot_api_cache() {
CACHE_CLASS_AND_CHECK(Basis, GODOT_API_CLASS(Basis));
CACHE_CLASS_AND_CHECK(Quat, GODOT_API_CLASS(Quat));
CACHE_CLASS_AND_CHECK(Transform, GODOT_API_CLASS(Transform));
- CACHE_CLASS_AND_CHECK(Rect3, GODOT_API_CLASS(Rect3));
+ CACHE_CLASS_AND_CHECK(AABB, GODOT_API_CLASS(AABB));
CACHE_CLASS_AND_CHECK(Color, GODOT_API_CLASS(Color));
CACHE_CLASS_AND_CHECK(Plane, GODOT_API_CLASS(Plane));
CACHE_CLASS_AND_CHECK(NodePath, GODOT_API_CLASS(NodePath));
@@ -364,4 +364,4 @@ String get_exception_name_and_message(MonoObject *p_ex) {
return res;
}
-}
+} // namespace GDMonoUtils
diff --git a/modules/mono/mono_gd/gd_mono_utils.h b/modules/mono/mono_gd/gd_mono_utils.h
index ebb5d28e4d..c38f8c5af5 100644
--- a/modules/mono/mono_gd/gd_mono_utils.h
+++ b/modules/mono/mono_gd/gd_mono_utils.h
@@ -82,7 +82,7 @@ struct MonoCache {
GDMonoClass *class_Basis;
GDMonoClass *class_Quat;
GDMonoClass *class_Transform;
- GDMonoClass *class_Rect3;
+ GDMonoClass *class_AABB;
GDMonoClass *class_Color;
GDMonoClass *class_Plane;
GDMonoClass *class_NodePath;
@@ -166,7 +166,7 @@ MonoDomain *create_domain(const String &p_friendly_name);
String get_exception_name_and_message(MonoObject *p_ex);
-} // GDMonoUtils
+} // namespace GDMonoUtils
#define NATIVE_GDMONOCLASS_NAME(m_class) (GDMonoMarshal::mono_string_to_godot((MonoString *)m_class->get_field(BINDINGS_NATIVE_NAME_FIELD)->get_value(NULL)))
diff --git a/modules/regex/doc_classes/RegExMatch.xml b/modules/regex/doc_classes/RegExMatch.xml
index 354febf89a..8c6951fea2 100644
--- a/modules/regex/doc_classes/RegExMatch.xml
+++ b/modules/regex/doc_classes/RegExMatch.xml
@@ -4,7 +4,7 @@
Contains the results of a regex search.
</brief_description>
<description>
- Contains the results of a single regex match returned by [method RegEx.search] and [method.RegEx.search_all]. It can be used to find the position and range of the match and its capturing groups, and it can extract its sub-string for you.
+ Contains the results of a single regex match returned by [method RegEx.search] and [method RegEx.search_all]. It can be used to find the position and range of the match and its capturing groups, and it can extract its sub-string for you.
</description>
<tutorials>
</tutorials>
diff --git a/modules/visual_script/visual_script_builtin_funcs.cpp b/modules/visual_script/visual_script_builtin_funcs.cpp
index 7c9d306831..8f7fe58bee 100644
--- a/modules/visual_script/visual_script_builtin_funcs.cpp
+++ b/modules/visual_script/visual_script_builtin_funcs.cpp
@@ -1109,7 +1109,7 @@ void VisualScriptBuiltinFunc::exec_func(BuiltinFunc p_func, const Variant **p_in
String str = *p_inputs[0];
//str+="\n";
- OS::get_singleton()->printerr("%s\n", str.utf8().get_data());
+ print_error(str);
} break;
case VisualScriptBuiltinFunc::TEXT_PRINTRAW: {
diff --git a/modules/visual_script/visual_script_editor.cpp b/modules/visual_script/visual_script_editor.cpp
index 86cf5b27e6..83b8d8da2d 100644
--- a/modules/visual_script/visual_script_editor.cpp
+++ b/modules/visual_script/visual_script_editor.cpp
@@ -349,7 +349,7 @@ static Color _color_from_type(Variant::Type p_type, bool dark_theme = true) {
case Variant::TRANSFORM2D: color = Color::html("#c4ec69"); break;
case Variant::PLANE: color = Color::html("#f77070"); break;
case Variant::QUAT: color = Color::html("#ec69a3"); break;
- case Variant::RECT3: color = Color::html("#ee7991"); break;
+ case Variant::AABB: color = Color::html("#ee7991"); break;
case Variant::BASIS: color = Color::html("#e3ec69"); break;
case Variant::TRANSFORM: color = Color::html("#f6a86e"); break;
@@ -386,7 +386,7 @@ static Color _color_from_type(Variant::Type p_type, bool dark_theme = true) {
case Variant::TRANSFORM2D: color = Color::html("#96ce1a"); break;
case Variant::PLANE: color = Color::html("#f77070"); break;
case Variant::QUAT: color = Color::html("#ec69a3"); break;
- case Variant::RECT3: color = Color::html("#ee7991"); break;
+ case Variant::AABB: color = Color::html("#ee7991"); break;
case Variant::BASIS: color = Color::html("#b2bb19"); break;
case Variant::TRANSFORM: color = Color::html("#f49047"); break;
diff --git a/platform/javascript/SCsub b/platform/javascript/SCsub
index e3015d87b9..8d505a5829 100644
--- a/platform/javascript/SCsub
+++ b/platform/javascript/SCsub
@@ -21,37 +21,21 @@ for x in javascript_files:
env.Append(LINKFLAGS=["-s", "EXPORTED_FUNCTIONS=\"['_main','_main_after_fs_sync','_send_notification']\""])
-# output file name without file extension
-basename = "godot" + env["PROGSUFFIX"]
target_dir = env.Dir("#bin")
-
-zip_dir = target_dir.Dir('.javascript_zip')
-zip_files = env.InstallAs(zip_dir.File('godot.html'), '#misc/dist/html/default.html')
-
-implicit_targets = []
-if env['wasm']:
- wasm = target_dir.File(basename + '.wasm')
- implicit_targets.append(wasm)
- zip_files.append(InstallAs(zip_dir.File('godot.wasm'), wasm))
- prejs = env.File('pre_wasm.js')
-else:
- asmjs_files = [target_dir.File(basename + '.asm.js'), target_dir.File(basename + '.js.mem')]
- implicit_targets.extend(asmjs_files)
- zip_files.append(InstallAs([zip_dir.File('godot.asm.js'), zip_dir.File('godot.mem')], asmjs_files))
- prejs = env.File('pre_asmjs.js')
-
-js = env.Program(['#bin/godot'] + implicit_targets, javascript_objects, PROGSUFFIX=env['PROGSUFFIX'] + '.js')[0];
-zip_files.append(InstallAs(zip_dir.File('godot.js'), js))
+build = env.Program(['#bin/godot', target_dir.File('godot' + env['PROGSUFFIX'] + '.wasm')], javascript_objects, PROGSUFFIX=env['PROGSUFFIX'] + '.js');
js_libraries = []
js_libraries.append(env.File('http_request.js'))
for lib in js_libraries:
env.Append(LINKFLAGS=['--js-library', lib.path])
-env.Depends(js, js_libraries)
+env.Depends(build, js_libraries)
+prejs = env.File('pre.js')
postjs = env.File('engine.js')
-env.Depends(js, [prejs, postjs])
env.Append(LINKFLAGS=['--pre-js', prejs.path])
env.Append(LINKFLAGS=['--post-js', postjs.path])
+env.Depends(build, [prejs, postjs])
+zip_dir = target_dir.Dir('.javascript_zip')
+zip_files = env.InstallAs([zip_dir.File('godot.js'), zip_dir.File('godot.wasm'), zip_dir.File('godot.html')], build + ['#misc/dist/html/default.html'])
Zip('#bin/godot', zip_files, ZIPSUFFIX=env['PROGSUFFIX'] + env['ZIPSUFFIX'], ZIPROOT=zip_dir, ZIPCOMSTR="Archving $SOURCES as $TARGET")
diff --git a/platform/javascript/detect.py b/platform/javascript/detect.py
index a2988d9c60..ba0b63a375 100644
--- a/platform/javascript/detect.py
+++ b/platform/javascript/detect.py
@@ -19,7 +19,6 @@ def can_build():
def get_opts():
from SCons.Variables import BoolVariable
return [
- BoolVariable('wasm', 'Compile to WebAssembly', False),
BoolVariable('javascript_eval', 'Enable JavaScript eval interface', True),
]
@@ -106,17 +105,11 @@ def configure(env):
env.Append(LINKFLAGS=['-s', 'EXTRA_EXPORTED_RUNTIME_METHODS="[\'FS\']"'])
env.Append(LINKFLAGS=['-s', 'USE_WEBGL2=1'])
- if env['wasm']:
- env.Append(LINKFLAGS=['-s', 'BINARYEN=1'])
- # In contrast to asm.js, enabling memory growth on WebAssembly has no
- # major performance impact, and causes only a negligible increase in
- # memory size.
- env.Append(LINKFLAGS=['-s', 'ALLOW_MEMORY_GROWTH=1'])
- env.extra_suffix = '.webassembly' + env.extra_suffix
- else:
- env.Append(LINKFLAGS=['-s', 'ASM_JS=1'])
- env.Append(LINKFLAGS=['--separate-asm'])
- env.Append(LINKFLAGS=['--memory-init-file', '1'])
+ env.Append(LINKFLAGS=['-s', 'BINARYEN=1'])
+ # In contrast to asm.js, enabling memory growth on WebAssembly has no
+ # major performance impact, and causes only a negligible increase in
+ # memory size.
+ env.Append(LINKFLAGS=['-s', 'ALLOW_MEMORY_GROWTH=1'])
# TODO: Move that to opus module's config
if 'module_opus_enabled' in env and env['module_opus_enabled']:
diff --git a/platform/javascript/engine.js b/platform/javascript/engine.js
index 99d1c20bbd..f3a7c49a95 100644
--- a/platform/javascript/engine.js
+++ b/platform/javascript/engine.js
@@ -5,7 +5,6 @@
(function() {
var engine = Engine;
- var USING_WASM = engine.USING_WASM;
var DOWNLOAD_ATTEMPTS_MAX = 4;
var basePath = null;
@@ -34,7 +33,6 @@
var gameInitPromise = null;
var unloadAfterInit = true;
- var memorySize = 268435456;
var progressFunc = null;
var pckProgressTracker = {};
@@ -91,10 +89,6 @@
});
return {};
};
- } else if (initializer.asm && initializer.mem) {
- rtenvOpts.asm = initializer.asm;
- rtenvOpts.memoryInitializerRequest = initializer.mem;
- rtenvOpts.TOTAL_MEMORY = memorySize;
} else {
throw new Error("Invalid initializer");
}
@@ -190,10 +184,6 @@
canvas = elem;
};
- this.setAsmjsMemorySize = function(size) {
- memorySize = size;
- };
-
this.setUnloadAfterInit = function(enabled) {
if (enabled && !unloadAfterInit && gameInitPromise) {
@@ -236,22 +226,12 @@
if (newBasePath !== undefined) basePath = getBasePath(newBasePath);
if (engineLoadPromise === null) {
- if (USING_WASM) {
- if (typeof WebAssembly !== 'object')
- return Promise.reject(new Error("Browser doesn't support WebAssembly"));
- // TODO cache/retrieve module to/from idb
- engineLoadPromise = loadPromise(basePath + '.wasm').then(function(xhr) {
- return xhr.response;
- });
- } else {
- var asmjsPromise = loadPromise(basePath + '.asm.js').then(function(xhr) {
- return asmjsModulePromise(xhr.response);
- });
- var memPromise = loadPromise(basePath + '.mem');
- engineLoadPromise = Promise.all([asmjsPromise, memPromise]).then(function(values) {
- return { asm: values[0], mem: values[1] };
- });
- }
+ if (typeof WebAssembly !== 'object')
+ return Promise.reject(new Error("Browser doesn't support WebAssembly"));
+ // TODO cache/retrieve module to/from idb
+ engineLoadPromise = loadPromise(basePath + '.wasm').then(function(xhr) {
+ return xhr.response;
+ });
engineLoadPromise = engineLoadPromise.catch(function(err) {
engineLoadPromise = null;
throw err;
@@ -260,33 +240,6 @@
return engineLoadPromise;
};
- function asmjsModulePromise(module) {
- var elem = document.createElement('script');
- var script = new Blob([
- 'Engine.asm = (function() { var Module = {};',
- module,
- 'return Module.asm; })();'
- ]);
- var url = URL.createObjectURL(script);
- elem.src = url;
- return new Promise(function(resolve, reject) {
- elem.addEventListener('load', function() {
- URL.revokeObjectURL(url);
- var asm = Engine.asm;
- Engine.asm = undefined;
- setTimeout(function() {
- // delay to reclaim compilation memory
- resolve(asm);
- }, 1);
- });
- elem.addEventListener('error', function() {
- URL.revokeObjectURL(url);
- reject("asm.js faiilure");
- });
- document.body.appendChild(elem);
- });
- }
-
Engine.unloadEngine = function() {
engineLoadPromise = null;
};
diff --git a/platform/javascript/export/export.cpp b/platform/javascript/export/export.cpp
index 4a97bf4c32..d0d4b17874 100644
--- a/platform/javascript/export/export.cpp
+++ b/platform/javascript/export/export.cpp
@@ -35,8 +35,6 @@
#define EXPORT_TEMPLATE_WEBASSEMBLY_RELEASE "webassembly_release.zip"
#define EXPORT_TEMPLATE_WEBASSEMBLY_DEBUG "webassembly_debug.zip"
-#define EXPORT_TEMPLATE_ASMJS_RELEASE "javascript_release.zip"
-#define EXPORT_TEMPLATE_ASMJS_DEBUG "javascript_debug.zip"
class EditorExportPlatformJavaScript : public EditorExportPlatform {
@@ -47,18 +45,11 @@ class EditorExportPlatformJavaScript : public EditorExportPlatform {
bool runnable_when_last_polled;
void _fix_html(Vector<uint8_t> &p_html, const Ref<EditorExportPreset> &p_preset, const String &p_name, bool p_debug);
- void _fix_fsloader_js(Vector<uint8_t> &p_js, const String &p_pack_name, uint64_t p_pack_size);
public:
- enum Target {
- TARGET_WEBASSEMBLY,
- TARGET_ASMJS
- };
-
virtual void get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features);
virtual void get_export_options(List<ExportOption> *r_options);
- virtual bool get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const;
virtual String get_name() const;
virtual String get_os_name() const;
@@ -90,17 +81,9 @@ void EditorExportPlatformJavaScript::_fix_html(Vector<uint8_t> &p_html, const Re
String str_export;
Vector<String> lines = str_template.split("\n");
- int memory_mb;
- if (p_preset->get("options/target").operator int() != TARGET_ASMJS)
- // WebAssembly allows memory growth, so start with a reasonable default
- memory_mb = 1 << 4;
- else
- memory_mb = 1 << (p_preset->get("options/memory_size").operator int() + 5);
-
for (int i = 0; i < lines.size(); i++) {
String current_line = lines[i];
- current_line = current_line.replace("$GODOT_TOTAL_MEMORY", itos(memory_mb * 1024 * 1024));
current_line = current_line.replace("$GODOT_BASENAME", p_name);
current_line = current_line.replace("$GODOT_HEAD_INCLUDE", p_preset->get("html/head_include"));
current_line = current_line.replace("$GODOT_DEBUG_ENABLED", p_debug ? "true" : "false");
@@ -129,8 +112,6 @@ void EditorExportPlatformJavaScript::get_preset_features(const Ref<EditorExportP
void EditorExportPlatformJavaScript::get_export_options(List<ExportOption> *r_options) {
- r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "options/target", PROPERTY_HINT_ENUM, "WebAssembly,asm.js"), TARGET_WEBASSEMBLY));
- r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "options/memory_size", PROPERTY_HINT_ENUM, "32 MB,64 MB,128 MB,256 MB,512 MB,1 GB"), 3));
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "texture_format/s3tc"), false));
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "texture_format/etc"), true));
r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "texture_format/etc2"), false));
@@ -139,14 +120,6 @@ void EditorExportPlatformJavaScript::get_export_options(List<ExportOption> *r_op
r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_template/debug", PROPERTY_HINT_GLOBAL_FILE, "zip"), ""));
}
-bool EditorExportPlatformJavaScript::get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const {
-
- if (p_option == "options/memory_size") {
- return p_options["options/target"].operator int() == TARGET_ASMJS;
- }
- return true;
-}
-
String EditorExportPlatformJavaScript::get_name() const {
return "HTML5";
@@ -166,17 +139,10 @@ bool EditorExportPlatformJavaScript::can_export(const Ref<EditorExportPreset> &p
r_missing_templates = false;
- if (p_preset->get("options/target").operator int() == TARGET_WEBASSEMBLY) {
- if (find_export_template(EXPORT_TEMPLATE_WEBASSEMBLY_RELEASE) == String())
- r_missing_templates = true;
- else if (find_export_template(EXPORT_TEMPLATE_WEBASSEMBLY_DEBUG) == String())
- r_missing_templates = true;
- } else {
- if (find_export_template(EXPORT_TEMPLATE_ASMJS_RELEASE) == String())
- r_missing_templates = true;
- else if (find_export_template(EXPORT_TEMPLATE_ASMJS_DEBUG) == String())
- r_missing_templates = true;
- }
+ if (find_export_template(EXPORT_TEMPLATE_WEBASSEMBLY_RELEASE) == String())
+ r_missing_templates = true;
+ else if (find_export_template(EXPORT_TEMPLATE_WEBASSEMBLY_DEBUG) == String())
+ r_missing_templates = true;
return !r_missing_templates;
}
@@ -197,17 +163,10 @@ Error EditorExportPlatformJavaScript::export_project(const Ref<EditorExportPrese
if (template_path == String()) {
- if (p_preset->get("options/target").operator int() == TARGET_WEBASSEMBLY) {
- if (p_debug)
- template_path = find_export_template(EXPORT_TEMPLATE_WEBASSEMBLY_DEBUG);
- else
- template_path = find_export_template(EXPORT_TEMPLATE_WEBASSEMBLY_RELEASE);
- } else {
- if (p_debug)
- template_path = find_export_template(EXPORT_TEMPLATE_ASMJS_DEBUG);
- else
- template_path = find_export_template(EXPORT_TEMPLATE_ASMJS_RELEASE);
- }
+ if (p_debug)
+ template_path = find_export_template(EXPORT_TEMPLATE_WEBASSEMBLY_DEBUG);
+ else
+ template_path = find_export_template(EXPORT_TEMPLATE_WEBASSEMBLY_RELEASE);
}
if (template_path != String() && !FileAccess::exists(template_path)) {
@@ -270,12 +229,6 @@ Error EditorExportPlatformJavaScript::export_project(const Ref<EditorExportPrese
} else if (file == "godot.wasm") {
file = p_path.get_file().get_basename() + ".wasm";
- } else if (file == "godot.asm.js") {
-
- file = p_path.get_file().get_basename() + ".asm.js";
- } else if (file == "godot.mem") {
-
- file = p_path.get_file().get_basename() + ".mem";
}
String dst = p_path.get_base_dir().plus_file(file);
diff --git a/platform/javascript/pre_wasm.js b/platform/javascript/pre.js
index be4383c8c9..311aa44fda 100644
--- a/platform/javascript/pre_wasm.js
+++ b/platform/javascript/pre.js
@@ -1,3 +1,2 @@
var Engine = {
- USING_WASM: true,
RuntimeEnvironment: function(Module) {
diff --git a/platform/javascript/pre_asmjs.js b/platform/javascript/pre_asmjs.js
deleted file mode 100644
index 3c497721b6..0000000000
--- a/platform/javascript/pre_asmjs.js
+++ /dev/null
@@ -1,3 +0,0 @@
-var Engine = {
- USING_WASM: false,
- RuntimeEnvironment: function(Module) {
diff --git a/platform/osx/os_osx.h b/platform/osx/os_osx.h
index 53f45511f9..1df847eb79 100644
--- a/platform/osx/os_osx.h
+++ b/platform/osx/os_osx.h
@@ -226,6 +226,12 @@ public:
virtual Error move_to_trash(const String &p_path);
OS_OSX();
+
+private:
+ Point2 get_native_screen_position(int p_screen) const;
+ Point2 get_native_window_position() const;
+ void set_native_window_position(const Point2 &p_position);
+ Point2 get_screens_origin() const;
};
#endif
diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm
index 6faa8e12ed..2e0e2620be 100644
--- a/platform/osx/os_osx.mm
+++ b/platform/osx/os_osx.mm
@@ -913,10 +913,15 @@ void OS_OSX::initialize_core() {
}
static bool keyboard_layout_dirty = true;
-static void keyboardLayoutChanged(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) {
+static void keyboard_layout_changed(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef user_info) {
keyboard_layout_dirty = true;
}
+static bool displays_arrangement_dirty = true;
+static void displays_arrangement_changed(CGDirectDisplayID display_id, CGDisplayChangeSummaryFlags flags, void *user_info) {
+ displays_arrangement_dirty = true;
+}
+
void OS_OSX::initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver) {
/*** OSX INITIALIZATION ***/
@@ -924,13 +929,17 @@ void OS_OSX::initialize(const VideoMode &p_desired, int p_video_driver, int p_au
/*** OSX INITIALIZATION ***/
keyboard_layout_dirty = true;
+ displays_arrangement_dirty = true;
// Register to be notified on keyboard layout changes
CFNotificationCenterAddObserver(CFNotificationCenterGetDistributedCenter(),
- NULL, keyboardLayoutChanged,
+ NULL, keyboard_layout_changed,
kTISNotifySelectedKeyboardInputSourceChanged, NULL,
CFNotificationSuspensionBehaviorDeliverImmediately);
+ // Register to be notified on displays arrangement changes
+ CGDisplayRegisterReconfigurationCallback(displays_arrangement_changed, NULL);
+
window_delegate = [[GodotWindowDelegate alloc] init];
// Don't use accumulation buffer support; it's not accelerated
@@ -1094,6 +1103,8 @@ void OS_OSX::initialize(const VideoMode &p_desired, int p_video_driver, int p_au
void OS_OSX::finalize() {
CFNotificationCenterRemoveObserver(CFNotificationCenterGetDistributedCenter(), NULL, kTISNotifySelectedKeyboardInputSourceChanged, NULL);
+ CGDisplayRemoveReconfigurationCallback(displays_arrangement_changed, NULL);
+
delete_main_loop();
memdelete(joypad_osx);
@@ -1456,6 +1467,32 @@ int OS_OSX::get_screen_count() const {
return [screenArray count];
};
+// Returns the native top-left screen coordinate of the smallest rectangle
+// that encompasses all screens. Needed in get_screen_position(),
+// get_window_position, and set_window_position()
+// to convert between OS X native screen coordinates and the ones expected by Godot
+Point2 OS_OSX::get_screens_origin() const {
+ static Point2 origin;
+
+ if (displays_arrangement_dirty) {
+ origin = Point2();
+
+ for (int i = 0; i < get_screen_count(); i++) {
+ Point2 position = get_native_screen_position(i);
+ if (position.x < origin.x) {
+ origin.x = position.x;
+ }
+ if (position.y > origin.y) {
+ origin.y = position.y;
+ }
+ }
+
+ displays_arrangement_dirty = false;
+ }
+
+ return origin;
+}
+
static int get_screen_index(NSScreen *screen) {
const NSUInteger index = [[NSScreen screens] indexOfObject:screen];
return index == NSNotFound ? 0 : index;
@@ -1474,21 +1511,30 @@ void OS_OSX::set_current_screen(int p_screen) {
set_window_position(wpos + get_screen_position(p_screen));
};
-Point2 OS_OSX::get_screen_position(int p_screen) const {
+Point2 OS_OSX::get_native_screen_position(int p_screen) const {
if (p_screen == -1) {
p_screen = get_current_screen();
}
NSArray *screenArray = [NSScreen screens];
if (p_screen < [screenArray count]) {
- float displayScale = _display_scale([screenArray objectAtIndex:p_screen]);
+ float display_scale = _display_scale([screenArray objectAtIndex:p_screen]);
NSRect nsrect = [[screenArray objectAtIndex:p_screen] frame];
- return Point2(nsrect.origin.x, nsrect.origin.y) * displayScale;
+ // Return the top-left corner of the screen, for OS X the y starts at the bottom
+ return Point2(nsrect.origin.x, nsrect.origin.y + nsrect.size.height) * display_scale;
}
return Point2();
}
+Point2 OS_OSX::get_screen_position(int p_screen) const {
+ Point2 position = get_native_screen_position(p_screen) - get_screens_origin();
+ // OS X native y-coordinate relative to get_screens_origin() is negative,
+ // Godot expects a positive value
+ position.y *= -1;
+ return position;
+}
+
int OS_OSX::get_screen_dpi(int p_screen) const {
if (p_screen == -1) {
p_screen = get_current_screen();
@@ -1567,28 +1613,48 @@ float OS_OSX::_display_scale(id screen) const {
}
}
-Point2 OS_OSX::get_window_position() const {
+Point2 OS_OSX::get_native_window_position() const {
- Size2 wp([window_object frame].origin.x, [window_object frame].origin.y);
- wp *= _display_scale();
- return wp;
+ NSRect nsrect = [window_object frame];
+ Point2 pos;
+ float display_scale = _display_scale();
+
+ // Return the position of the top-left corner, for OS X the y starts at the bottom
+ pos.x = nsrect.origin.x * display_scale;
+ pos.y = (nsrect.origin.y + nsrect.size.height) * display_scale;
+
+ return pos;
};
-void OS_OSX::set_window_position(const Point2 &p_position) {
+Point2 OS_OSX::get_window_position() const {
+ Point2 position = get_native_window_position() - get_screens_origin();
+ // OS X native y-coordinate relative to get_screens_origin() is negative,
+ // Godot expects a positive value
+ position.y *= -1;
+ return position;
+}
+
+void OS_OSX::set_native_window_position(const Point2 &p_position) {
- Size2 scr = get_screen_size();
NSPoint pos;
float displayScale = _display_scale();
pos.x = p_position.x / displayScale;
- // For OS X the y starts at the bottom
- pos.y = (scr.height - p_position.y) / displayScale;
+ pos.y = p_position.y / displayScale;
[window_object setFrameTopLeftPoint:pos];
_update_window();
};
+void OS_OSX::set_window_position(const Point2 &p_position) {
+ Point2 position = p_position;
+ // OS X native y-coordinate relative to get_screens_origin() is negative,
+ // Godot passes a positive value
+ position.y *= -1;
+ set_native_window_position(get_screens_origin() + position);
+};
+
Size2 OS_OSX::get_window_size() const {
return window_size;
diff --git a/scene/2d/particles_2d.cpp b/scene/2d/particles_2d.cpp
index c146ac08c2..aee5d89150 100644
--- a/scene/2d/particles_2d.cpp
+++ b/scene/2d/particles_2d.cpp
@@ -77,7 +77,7 @@ void Particles2D::set_randomness_ratio(float p_ratio) {
void Particles2D::set_visibility_rect(const Rect2 &p_aabb) {
visibility_rect = p_aabb;
- Rect3 aabb;
+ AABB aabb;
aabb.position.x = p_aabb.position.x;
aabb.position.y = p_aabb.position.y;
aabb.size.x = p_aabb.size.x;
@@ -223,7 +223,7 @@ String Particles2D::get_configuration_warning() const {
Rect2 Particles2D::capture_rect() const {
- Rect3 aabb = VS::get_singleton()->particles_get_current_aabb(particles);
+ AABB aabb = VS::get_singleton()->particles_get_current_aabb(particles);
Rect2 r;
r.position.x = aabb.position.x;
r.position.y = aabb.position.y;
@@ -378,7 +378,7 @@ void Particles2D::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::INT, "fixed_fps", PROPERTY_HINT_RANGE, "0,1000,1"), "set_fixed_fps", "get_fixed_fps");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "fract_delta"), "set_fractional_delta", "get_fractional_delta");
ADD_GROUP("Drawing", "");
- ADD_PROPERTY(PropertyInfo(Variant::RECT3, "visibility_rect"), "set_visibility_rect", "get_visibility_rect");
+ ADD_PROPERTY(PropertyInfo(Variant::AABB, "visibility_rect"), "set_visibility_rect", "get_visibility_rect");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "local_coords"), "set_use_local_coordinates", "get_use_local_coordinates");
ADD_PROPERTY(PropertyInfo(Variant::INT, "draw_order", PROPERTY_HINT_ENUM, "Index,Lifetime"), "set_draw_order", "get_draw_order");
ADD_GROUP("Process Material", "process_");
diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp
index 5fb9e3f527..dd4270ab26 100644
--- a/scene/2d/tile_map.cpp
+++ b/scene/2d/tile_map.cpp
@@ -459,9 +459,9 @@ void TileMap::_update_dirty_quadrants() {
Transform2D xform;
xform.set_origin(offset.floor());
- _fix_cell_transform(xform, c, center_ofs, s);
+ Vector2 shape_ofs = tile_set->tile_get_shape_offset(c.id, i);
- xform *= shapes[i].shape_transform;
+ _fix_cell_transform(xform, c, shape_ofs + center_ofs, s);
if (debug_canvas_item.is_valid()) {
vs->canvas_item_add_set_transform(debug_canvas_item, xform);
diff --git a/scene/3d/collision_polygon.cpp b/scene/3d/collision_polygon.cpp
index 382cbb8f38..a6d812efec 100644
--- a/scene/3d/collision_polygon.cpp
+++ b/scene/3d/collision_polygon.cpp
@@ -117,7 +117,7 @@ Vector<Point2> CollisionPolygon::get_polygon() const {
return polygon;
}
-Rect3 CollisionPolygon::get_item_rect() const {
+AABB CollisionPolygon::get_item_rect() const {
return aabb;
}
@@ -176,7 +176,7 @@ void CollisionPolygon::_bind_methods() {
CollisionPolygon::CollisionPolygon() {
- aabb = Rect3(Vector3(-1, -1, -1), Vector3(2, 2, 2));
+ aabb = AABB(Vector3(-1, -1, -1), Vector3(2, 2, 2));
depth = 1.0;
set_notify_local_transform(true);
parent = NULL;
diff --git a/scene/3d/collision_polygon.h b/scene/3d/collision_polygon.h
index dbed1d7154..14d8c3aba6 100644
--- a/scene/3d/collision_polygon.h
+++ b/scene/3d/collision_polygon.h
@@ -40,7 +40,7 @@ class CollisionPolygon : public Spatial {
protected:
float depth;
- Rect3 aabb;
+ AABB aabb;
Vector<Point2> polygon;
uint32_t owner_id;
@@ -64,7 +64,7 @@ public:
void set_disabled(bool p_disabled);
bool is_disabled() const;
- virtual Rect3 get_item_rect() const;
+ virtual AABB get_item_rect() const;
String get_configuration_warning() const;
diff --git a/scene/3d/gi_probe.cpp b/scene/3d/gi_probe.cpp
index 002ce1793b..05d5d52d28 100644
--- a/scene/3d/gi_probe.cpp
+++ b/scene/3d/gi_probe.cpp
@@ -31,12 +31,12 @@
#include "mesh_instance.h"
-void GIProbeData::set_bounds(const Rect3 &p_bounds) {
+void GIProbeData::set_bounds(const AABB &p_bounds) {
VS::get_singleton()->gi_probe_set_bounds(probe, p_bounds);
}
-Rect3 GIProbeData::get_bounds() const {
+AABB GIProbeData::get_bounds() const {
return VS::get_singleton()->gi_probe_get_bounds(probe);
}
@@ -180,7 +180,7 @@ void GIProbeData::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_compress", "compress"), &GIProbeData::set_compress);
ClassDB::bind_method(D_METHOD("is_compressed"), &GIProbeData::is_compressed);
- ADD_PROPERTY(PropertyInfo(Variant::RECT3, "bounds", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_bounds", "get_bounds");
+ ADD_PROPERTY(PropertyInfo(Variant::AABB, "bounds", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_bounds", "get_bounds");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "cell_size", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_cell_size", "get_cell_size");
ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM, "to_cell_xform", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_to_cell_xform", "get_to_cell_xform");
@@ -410,7 +410,7 @@ static bool planeBoxOverlap(Vector3 normal, float d, Vector3 maxbox) {
rad = fa * boxhalfsize.x + fb * boxhalfsize.z; \
if (min > rad || max < -rad) return false;
-/*======================== Z-tests ========================*/
+ /*======================== Z-tests ========================*/
#define AXISTEST_Z12(a, b, fa, fb) \
p1 = a * v1.x - b * v1.y; \
@@ -542,7 +542,7 @@ static _FORCE_INLINE_ Vector2 get_uv(const Vector3 &p_pos, const Vector3 *p_vtx,
return p_uv[0] * u + p_uv[1] * v + p_uv[2] * w;
}
-void GIProbe::_plot_face(int p_idx, int p_level, int p_x, int p_y, int p_z, const Vector3 *p_vtx, const Vector2 *p_uv, const Baker::MaterialCache &p_material, const Rect3 &p_aabb, Baker *p_baker) {
+void GIProbe::_plot_face(int p_idx, int p_level, int p_x, int p_y, int p_z, const Vector3 *p_vtx, const Vector2 *p_uv, const Baker::MaterialCache &p_material, const AABB &p_aabb, Baker *p_baker) {
if (p_level == p_baker->cell_subdiv - 1) {
//plot the face by guessing it's albedo and emission value
@@ -702,7 +702,7 @@ void GIProbe::_plot_face(int p_idx, int p_level, int p_x, int p_y, int p_z, cons
int half = (1 << (p_baker->cell_subdiv - 1)) >> (p_level + 1);
for (int i = 0; i < 8; i++) {
- Rect3 aabb = p_aabb;
+ AABB aabb = p_aabb;
aabb.size *= 0.5;
int nx = p_x;
@@ -726,7 +726,7 @@ void GIProbe::_plot_face(int p_idx, int p_level, int p_x, int p_y, int p_z, cons
continue;
{
- Rect3 test_aabb = aabb;
+ AABB test_aabb = aabb;
//test_aabb.grow_by(test_aabb.get_longest_axis_size()*0.05); //grow a bit to avoid numerical error in real-time
Vector3 qsize = test_aabb.size * 0.5; //quarter size, for fast aabb test
@@ -891,7 +891,7 @@ void GIProbe::_fixup_plot(int p_idx, int p_level, int p_x, int p_y, int p_z, Bak
}
}
-Vector<Color> GIProbe::_get_bake_texture(Ref<Image> p_image, const Color &p_color, bool p_color_add) {
+Vector<Color> GIProbe::_get_bake_texture(Ref<Image> p_image, const Color &p_color_mul, const Color &p_color_add) {
Vector<Color> ret;
@@ -899,7 +899,7 @@ Vector<Color> GIProbe::_get_bake_texture(Ref<Image> p_image, const Color &p_colo
ret.resize(bake_texture_size * bake_texture_size);
for (int i = 0; i < bake_texture_size * bake_texture_size; i++) {
- ret[i] = p_color;
+ ret[i] = p_color_add;
}
return ret;
@@ -919,15 +919,9 @@ Vector<Color> GIProbe::_get_bake_texture(Ref<Image> p_image, const Color &p_colo
for (int i = 0; i < bake_texture_size * bake_texture_size; i++) {
Color c;
- if (p_color_add) {
- c.r = (r[i * 4 + 0] / 255.0) + p_color.r;
- c.g = (r[i * 4 + 1] / 255.0) + p_color.g;
- c.b = (r[i * 4 + 2] / 255.0) + p_color.b;
- } else {
- c.r = (r[i * 4 + 0] / 255.0) * p_color.r;
- c.g = (r[i * 4 + 1] / 255.0) * p_color.g;
- c.b = (r[i * 4 + 2] / 255.0) * p_color.b;
- }
+ c.r = (r[i * 4 + 0] / 255.0) * p_color_mul.r + p_color_add.r;
+ c.g = (r[i * 4 + 1] / 255.0) * p_color_mul.g + p_color_add.g;
+ c.b = (r[i * 4 + 2] / 255.0) * p_color_mul.b + p_color_add.b;
c.a = r[i * 4 + 3] / 255.0;
@@ -958,17 +952,15 @@ GIProbe::Baker::MaterialCache GIProbe::_get_material_cache(Ref<Material> p_mater
if (albedo_tex.is_valid()) {
img_albedo = albedo_tex->get_data();
+ mc.albedo = _get_bake_texture(img_albedo, mat->get_albedo(), Color(0, 0, 0)); // albedo texture, color is multiplicative
} else {
+ mc.albedo = _get_bake_texture(img_albedo, Color(1, 1, 1), mat->get_albedo()); // no albedo texture, color is additive
}
- mc.albedo = _get_bake_texture(img_albedo, mat->get_albedo(), false);
-
- Ref<ImageTexture> emission_tex = mat->get_texture(SpatialMaterial::TEXTURE_EMISSION);
+ Ref<Texture> emission_tex = mat->get_texture(SpatialMaterial::TEXTURE_EMISSION);
Color emission_col = mat->get_emission();
- emission_col.r *= mat->get_emission_energy();
- emission_col.g *= mat->get_emission_energy();
- emission_col.b *= mat->get_emission_energy();
+ float emission_energy = mat->get_emission_energy();
Ref<Image> img_emission;
@@ -977,13 +969,17 @@ GIProbe::Baker::MaterialCache GIProbe::_get_material_cache(Ref<Material> p_mater
img_emission = emission_tex->get_data();
}
- mc.emission = _get_bake_texture(img_emission, emission_col, mat->get_emission_operator() == SpatialMaterial::EMISSION_OP_ADD);
+ if (mat->get_emission_operator() == SpatialMaterial::EMISSION_OP_ADD) {
+ mc.emission = _get_bake_texture(img_emission, Color(1, 1, 1) * emission_energy, emission_col * emission_energy);
+ } else {
+ mc.emission = _get_bake_texture(img_emission, emission_col * emission_energy, Color(0, 0, 0));
+ }
} else {
Ref<Image> empty;
- mc.albedo = _get_bake_texture(empty, Color(0.7, 0.7, 0.7));
- mc.emission = _get_bake_texture(empty, Color(0, 0, 0));
+ mc.albedo = _get_bake_texture(empty, Color(0, 0, 0), Color(1, 1, 1));
+ mc.emission = _get_bake_texture(empty, Color(0, 0, 0), Color(0, 0, 0));
}
p_baker->material_cache[p_material] = mc;
@@ -1087,11 +1083,11 @@ void GIProbe::_find_meshes(Node *p_at_node, Baker *p_baker) {
Ref<Mesh> mesh = mi->get_mesh();
if (mesh.is_valid()) {
- Rect3 aabb = mesh->get_aabb();
+ AABB aabb = mesh->get_aabb();
Transform xf = get_global_transform().affine_inverse() * mi->get_global_transform();
- if (Rect3(-extents, extents * 2).intersects(xf.xform(aabb))) {
+ if (AABB(-extents, extents * 2).intersects(xf.xform(aabb))) {
Baker::PlotMesh pm;
pm.local_xform = xf;
pm.mesh = mesh;
@@ -1117,11 +1113,11 @@ void GIProbe::_find_meshes(Node *p_at_node, Baker *p_baker) {
if (!mesh.is_valid())
continue;
- Rect3 aabb = mesh->get_aabb();
+ AABB aabb = mesh->get_aabb();
Transform xf = get_global_transform().affine_inverse() * (s->get_global_transform() * mxf);
- if (Rect3(-extents, extents * 2).intersects(xf.xform(aabb))) {
+ if (AABB(-extents, extents * 2).intersects(xf.xform(aabb))) {
Baker::PlotMesh pm;
pm.local_xform = xf;
pm.mesh = mesh;
@@ -1155,7 +1151,7 @@ void GIProbe::bake(Node *p_from_node, bool p_create_visual_debug) {
baker.bake_cells.resize(1);
//find out the actual real bounds, power of 2, which gets the highest subdivision
- baker.po2_bounds = Rect3(-extents, extents * 2.0);
+ baker.po2_bounds = AABB(-extents, extents * 2.0);
int longest_axis = baker.po2_bounds.get_longest_axis_index();
baker.axis_cell_size[longest_axis] = (1 << (baker.cell_subdiv - 1));
baker.leaf_voxel_count = 0;
@@ -1290,7 +1286,7 @@ void GIProbe::bake(Node *p_from_node, bool p_create_visual_debug) {
Ref<GIProbeData> probe_data;
probe_data.instance();
- probe_data->set_bounds(Rect3(-extents, extents * 2.0));
+ probe_data->set_bounds(AABB(-extents, extents * 2.0));
probe_data->set_cell_size(baker.po2_bounds.size[longest_axis] / baker.axis_cell_size[longest_axis]);
probe_data->set_dynamic_data(data);
probe_data->set_dynamic_range(dynamic_range);
@@ -1310,7 +1306,7 @@ void GIProbe::bake(Node *p_from_node, bool p_create_visual_debug) {
}
}
-void GIProbe::_debug_mesh(int p_idx, int p_level, const Rect3 &p_aabb, Ref<MultiMesh> &p_multimesh, int &idx, Baker *p_baker) {
+void GIProbe::_debug_mesh(int p_idx, int p_level, const AABB &p_aabb, Ref<MultiMesh> &p_multimesh, int &idx, Baker *p_baker) {
if (p_level == p_baker->cell_subdiv - 1) {
@@ -1332,7 +1328,7 @@ void GIProbe::_debug_mesh(int p_idx, int p_level, const Rect3 &p_aabb, Ref<Multi
if (p_baker->bake_cells[p_idx].childs[i] == Baker::CHILD_EMPTY)
continue;
- Rect3 aabb = p_aabb;
+ AABB aabb = p_aabb;
aabb.size *= 0.5;
if (i & 1)
@@ -1444,9 +1440,9 @@ void GIProbe::_debug_bake() {
bake(NULL, true);
}
-Rect3 GIProbe::get_aabb() const {
+AABB GIProbe::get_aabb() const {
- return Rect3(-extents, extents * 2);
+ return AABB(-extents, extents * 2);
}
PoolVector<Face3> GIProbe::get_faces(uint32_t p_usage_flags) const {
diff --git a/scene/3d/gi_probe.h b/scene/3d/gi_probe.h
index 8aca2c549b..324ff8e917 100644
--- a/scene/3d/gi_probe.h
+++ b/scene/3d/gi_probe.h
@@ -43,8 +43,8 @@ protected:
static void _bind_methods();
public:
- void set_bounds(const Rect3 &p_bounds);
- Rect3 get_bounds() const;
+ void set_bounds(const AABB &p_bounds);
+ AABB get_bounds() const;
void set_cell_size(float p_size);
float get_cell_size() const;
@@ -146,7 +146,7 @@ private:
MaterialCache _get_material_cache(Ref<Material> p_material);
int leaf_voxel_count;
- Rect3 po2_bounds;
+ AABB po2_bounds;
int axis_cell_size[3];
struct PlotMesh {
@@ -178,14 +178,14 @@ private:
int color_scan_cell_width;
int bake_texture_size;
- Vector<Color> _get_bake_texture(Ref<Image> p_image, const Color &p_color, bool p_color_add = false);
+ Vector<Color> _get_bake_texture(Ref<Image> p_image, const Color &p_color_mul, const Color &p_color_add);
Baker::MaterialCache _get_material_cache(Ref<Material> p_material, Baker *p_baker);
- void _plot_face(int p_idx, int p_level, int p_x, int p_y, int p_z, const Vector3 *p_vtx, const Vector2 *p_uv, const Baker::MaterialCache &p_material, const Rect3 &p_aabb, Baker *p_baker);
+ void _plot_face(int p_idx, int p_level, int p_x, int p_y, int p_z, const Vector3 *p_vtx, const Vector2 *p_uv, const Baker::MaterialCache &p_material, const AABB &p_aabb, Baker *p_baker);
void _plot_mesh(const Transform &p_xform, Ref<Mesh> &p_mesh, Baker *p_baker, const Vector<Ref<Material> > &p_materials, const Ref<Material> &p_override_material);
void _find_meshes(Node *p_at_node, Baker *p_baker);
void _fixup_plot(int p_idx, int p_level, int p_x, int p_y, int p_z, Baker *p_baker);
- void _debug_mesh(int p_idx, int p_level, const Rect3 &p_aabb, Ref<MultiMesh> &p_multimesh, int &idx, Baker *p_baker);
+ void _debug_mesh(int p_idx, int p_level, const AABB &p_aabb, Ref<MultiMesh> &p_multimesh, int &idx, Baker *p_baker);
void _create_debug_mesh(Baker *p_baker);
void _debug_bake();
@@ -230,7 +230,7 @@ public:
void bake(Node *p_from_node = NULL, bool p_create_visual_debug = false);
- virtual Rect3 get_aabb() const;
+ virtual AABB get_aabb() const;
virtual PoolVector<Face3> get_faces(uint32_t p_usage_flags) const;
GIProbe();
diff --git a/scene/3d/immediate_geometry.cpp b/scene/3d/immediate_geometry.cpp
index 11f7efe066..092ed8f0b2 100644
--- a/scene/3d/immediate_geometry.cpp
+++ b/scene/3d/immediate_geometry.cpp
@@ -85,7 +85,7 @@ void ImmediateGeometry::clear() {
cached_textures.clear();
}
-Rect3 ImmediateGeometry::get_aabb() const {
+AABB ImmediateGeometry::get_aabb() const {
return aabb;
}
diff --git a/scene/3d/immediate_geometry.h b/scene/3d/immediate_geometry.h
index 93ef726c6d..1ff4e05e82 100644
--- a/scene/3d/immediate_geometry.h
+++ b/scene/3d/immediate_geometry.h
@@ -42,7 +42,7 @@ class ImmediateGeometry : public GeometryInstance {
// in VisualServer from becoming invalid if the texture is no longer used
List<Ref<Texture> > cached_textures;
bool empty;
- Rect3 aabb;
+ AABB aabb;
protected:
static void _bind_methods();
@@ -62,7 +62,7 @@ public:
void add_sphere(int p_lats, int p_lons, float p_radius, bool p_add_uv = true);
- virtual Rect3 get_aabb() const;
+ virtual AABB get_aabb() const;
virtual PoolVector<Face3> get_faces(uint32_t p_usage_flags) const;
ImmediateGeometry();
diff --git a/scene/3d/light.cpp b/scene/3d/light.cpp
index 389d87cd90..324411c5cc 100644
--- a/scene/3d/light.cpp
+++ b/scene/3d/light.cpp
@@ -117,24 +117,24 @@ bool Light::get_shadow_reverse_cull_face() const {
return reverse_cull;
}
-Rect3 Light::get_aabb() const {
+AABB Light::get_aabb() const {
if (type == VisualServer::LIGHT_DIRECTIONAL) {
- return Rect3(Vector3(-1, -1, -1), Vector3(2, 2, 2));
+ return AABB(Vector3(-1, -1, -1), Vector3(2, 2, 2));
} else if (type == VisualServer::LIGHT_OMNI) {
- return Rect3(Vector3(-1, -1, -1) * param[PARAM_RANGE], Vector3(2, 2, 2) * param[PARAM_RANGE]);
+ return AABB(Vector3(-1, -1, -1) * param[PARAM_RANGE], Vector3(2, 2, 2) * param[PARAM_RANGE]);
} else if (type == VisualServer::LIGHT_SPOT) {
float len = param[PARAM_RANGE];
float size = Math::tan(Math::deg2rad(param[PARAM_SPOT_ANGLE])) * len;
- return Rect3(Vector3(-size, -size, -len), Vector3(size * 2, size * 2, len));
+ return AABB(Vector3(-size, -size, -len), Vector3(size * 2, size * 2, len));
}
- return Rect3();
+ return AABB();
}
PoolVector<Face3> Light::get_faces(uint32_t p_usage_flags) const {
diff --git a/scene/3d/light.h b/scene/3d/light.h
index 2f3ac8a5e7..37c17cbbe3 100644
--- a/scene/3d/light.h
+++ b/scene/3d/light.h
@@ -113,7 +113,7 @@ public:
void set_shadow_reverse_cull_face(bool p_enable);
bool get_shadow_reverse_cull_face() const;
- virtual Rect3 get_aabb() const;
+ virtual AABB get_aabb() const;
virtual PoolVector<Face3> get_faces(uint32_t p_usage_flags) const;
Light();
diff --git a/scene/3d/mesh_instance.cpp b/scene/3d/mesh_instance.cpp
index c8215971c4..1e52ccc6e0 100644
--- a/scene/3d/mesh_instance.cpp
+++ b/scene/3d/mesh_instance.cpp
@@ -165,12 +165,12 @@ NodePath MeshInstance::get_skeleton_path() {
return skeleton_path;
}
-Rect3 MeshInstance::get_aabb() const {
+AABB MeshInstance::get_aabb() const {
if (!mesh.is_null())
return mesh->get_aabb();
- return Rect3();
+ return AABB();
}
PoolVector<Face3> MeshInstance::get_faces(uint32_t p_usage_flags) const {
diff --git a/scene/3d/mesh_instance.h b/scene/3d/mesh_instance.h
index 8e8c12a592..970a10aaf3 100644
--- a/scene/3d/mesh_instance.h
+++ b/scene/3d/mesh_instance.h
@@ -85,7 +85,7 @@ public:
void create_debug_tangents();
- virtual Rect3 get_aabb() const;
+ virtual AABB get_aabb() const;
virtual PoolVector<Face3> get_faces(uint32_t p_usage_flags) const;
MeshInstance();
diff --git a/scene/3d/multimesh_instance.cpp b/scene/3d/multimesh_instance.cpp
index f90489f1f0..ce7b97be7f 100644
--- a/scene/3d/multimesh_instance.cpp
+++ b/scene/3d/multimesh_instance.cpp
@@ -55,10 +55,10 @@ PoolVector<Face3> MultiMeshInstance::get_faces(uint32_t p_usage_flags) const {
return PoolVector<Face3>();
}
-Rect3 MultiMeshInstance::get_aabb() const {
+AABB MultiMeshInstance::get_aabb() const {
if (multimesh.is_null())
- return Rect3();
+ return AABB();
else
return multimesh->get_aabb();
}
diff --git a/scene/3d/multimesh_instance.h b/scene/3d/multimesh_instance.h
index cd0e7b463c..9b2b1ff9a7 100644
--- a/scene/3d/multimesh_instance.h
+++ b/scene/3d/multimesh_instance.h
@@ -52,7 +52,7 @@ public:
void set_multimesh(const Ref<MultiMesh> &p_multimesh);
Ref<MultiMesh> get_multimesh() const;
- virtual Rect3 get_aabb() const;
+ virtual AABB get_aabb() const;
MultiMeshInstance();
~MultiMeshInstance();
diff --git a/scene/3d/particles.cpp b/scene/3d/particles.cpp
index 6ac6e52367..915a10328b 100644
--- a/scene/3d/particles.cpp
+++ b/scene/3d/particles.cpp
@@ -31,9 +31,9 @@
#include "scene/resources/surface_tool.h"
#include "servers/visual_server.h"
-Rect3 Particles::get_aabb() const {
+AABB Particles::get_aabb() const {
- return Rect3();
+ return AABB();
}
PoolVector<Face3> Particles::get_faces(uint32_t p_usage_flags) const {
@@ -82,7 +82,7 @@ void Particles::set_randomness_ratio(float p_ratio) {
randomness_ratio = p_ratio;
VS::get_singleton()->particles_set_randomness_ratio(particles, randomness_ratio);
}
-void Particles::set_visibility_aabb(const Rect3 &p_aabb) {
+void Particles::set_visibility_aabb(const AABB &p_aabb) {
visibility_aabb = p_aabb;
VS::get_singleton()->particles_set_custom_aabb(particles, visibility_aabb);
@@ -140,7 +140,7 @@ float Particles::get_randomness_ratio() const {
return randomness_ratio;
}
-Rect3 Particles::get_visibility_aabb() const {
+AABB Particles::get_visibility_aabb() const {
return visibility_aabb;
}
@@ -252,7 +252,7 @@ void Particles::restart() {
VisualServer::get_singleton()->particles_restart(particles);
}
-Rect3 Particles::capture_aabb() const {
+AABB Particles::capture_aabb() const {
return VS::get_singleton()->particles_get_current_aabb(particles);
}
@@ -335,7 +335,7 @@ void Particles::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::INT, "fixed_fps", PROPERTY_HINT_RANGE, "0,1000,1"), "set_fixed_fps", "get_fixed_fps");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "fract_delta"), "set_fractional_delta", "get_fractional_delta");
ADD_GROUP("Drawing", "");
- ADD_PROPERTY(PropertyInfo(Variant::RECT3, "visibility_aabb"), "set_visibility_aabb", "get_visibility_aabb");
+ ADD_PROPERTY(PropertyInfo(Variant::AABB, "visibility_aabb"), "set_visibility_aabb", "get_visibility_aabb");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "local_coords"), "set_use_local_coordinates", "get_use_local_coordinates");
ADD_PROPERTY(PropertyInfo(Variant::INT, "draw_order", PROPERTY_HINT_ENUM, "Index,Lifetime,View Depth"), "set_draw_order", "get_draw_order");
ADD_GROUP("Process Material", "");
@@ -367,7 +367,7 @@ Particles::Particles() {
set_pre_process_time(0);
set_explosiveness_ratio(0);
set_randomness_ratio(0);
- set_visibility_aabb(Rect3(Vector3(-4, -4, -4), Vector3(8, 8, 8)));
+ set_visibility_aabb(AABB(Vector3(-4, -4, -4), Vector3(8, 8, 8)));
set_use_local_coordinates(true);
set_draw_passes(1);
set_draw_order(DRAW_ORDER_INDEX);
diff --git a/scene/3d/particles.h b/scene/3d/particles.h
index e3109f470f..30080360bb 100644
--- a/scene/3d/particles.h
+++ b/scene/3d/particles.h
@@ -65,7 +65,7 @@ private:
float explosiveness_ratio;
float randomness_ratio;
float speed_scale;
- Rect3 visibility_aabb;
+ AABB visibility_aabb;
bool local_coords;
int fixed_fps;
bool fractional_delta;
@@ -82,7 +82,7 @@ protected:
virtual void _validate_property(PropertyInfo &property) const;
public:
- Rect3 get_aabb() const;
+ AABB get_aabb() const;
PoolVector<Face3> get_faces(uint32_t p_usage_flags) const;
void set_emitting(bool p_emitting);
@@ -92,7 +92,7 @@ public:
void set_pre_process_time(float p_time);
void set_explosiveness_ratio(float p_ratio);
void set_randomness_ratio(float p_ratio);
- void set_visibility_aabb(const Rect3 &p_aabb);
+ void set_visibility_aabb(const AABB &p_aabb);
void set_use_local_coordinates(bool p_enable);
void set_process_material(const Ref<Material> &p_material);
void set_speed_scale(float p_scale);
@@ -104,7 +104,7 @@ public:
float get_pre_process_time() const;
float get_explosiveness_ratio() const;
float get_randomness_ratio() const;
- Rect3 get_visibility_aabb() const;
+ AABB get_visibility_aabb() const;
bool get_use_local_coordinates() const;
Ref<Material> get_process_material() const;
float get_speed_scale() const;
@@ -128,7 +128,7 @@ public:
void restart();
- Rect3 capture_aabb() const;
+ AABB capture_aabb() const;
Particles();
~Particles();
};
diff --git a/scene/3d/portal.cpp b/scene/3d/portal.cpp
index 6c14f7dbc9..4fde29aab9 100644
--- a/scene/3d/portal.cpp
+++ b/scene/3d/portal.cpp
@@ -98,7 +98,7 @@ void Portal::_get_property_list(List<PropertyInfo> *p_list) const {
p_list->push_back(PropertyInfo(Variant::REAL, "connect_range", PROPERTY_HINT_RANGE, "0.1,4096,0.01"));
}
-Rect3 Portal::get_aabb() const {
+AABB Portal::get_aabb() const {
return aabb;
}
diff --git a/scene/3d/portal.h b/scene/3d/portal.h
index 6de3df8553..4ea208a718 100644
--- a/scene/3d/portal.h
+++ b/scene/3d/portal.h
@@ -53,7 +53,7 @@ class Portal : public VisualInstance {
Color disabled_color;
float connect_range;
- Rect3 aabb;
+ AABB aabb;
protected:
bool _set(const StringName &p_name, const Variant &p_value);
@@ -63,7 +63,7 @@ protected:
static void _bind_methods();
public:
- virtual Rect3 get_aabb() const;
+ virtual AABB get_aabb() const;
virtual PoolVector<Face3> get_faces(uint32_t p_usage_flags) const;
void set_enabled(bool p_enabled);
diff --git a/scene/3d/reflection_probe.cpp b/scene/3d/reflection_probe.cpp
index 46b105cd21..0e575ec152 100644
--- a/scene/3d/reflection_probe.cpp
+++ b/scene/3d/reflection_probe.cpp
@@ -178,9 +178,9 @@ ReflectionProbe::UpdateMode ReflectionProbe::get_update_mode() const {
return update_mode;
}
-Rect3 ReflectionProbe::get_aabb() const {
+AABB ReflectionProbe::get_aabb() const {
- Rect3 aabb;
+ AABB aabb;
aabb.position = -origin_offset;
aabb.size = origin_offset + extents;
return aabb;
diff --git a/scene/3d/reflection_probe.h b/scene/3d/reflection_probe.h
index 7c328a8f16..26f17fdcf9 100644
--- a/scene/3d/reflection_probe.h
+++ b/scene/3d/reflection_probe.h
@@ -101,7 +101,7 @@ public:
void set_update_mode(UpdateMode p_mode);
UpdateMode get_update_mode() const;
- virtual Rect3 get_aabb() const;
+ virtual AABB get_aabb() const;
virtual PoolVector<Face3> get_faces(uint32_t p_usage_flags) const;
ReflectionProbe();
diff --git a/scene/3d/room_instance.cpp b/scene/3d/room_instance.cpp
index 439b6bfdf8..47a7b8bfb9 100644
--- a/scene/3d/room_instance.cpp
+++ b/scene/3d/room_instance.cpp
@@ -66,12 +66,12 @@ void Room::_notification(int p_what) {
}
}
-Rect3 Room::get_aabb() const {
+AABB Room::get_aabb() const {
if (room.is_null())
- return Rect3();
+ return AABB();
- return Rect3();
+ return AABB();
}
PoolVector<Face3> Room::get_faces(uint32_t p_usage_flags) const {
diff --git a/scene/3d/room_instance.h b/scene/3d/room_instance.h
index b9a64b6670..3069ea2eba 100644
--- a/scene/3d/room_instance.h
+++ b/scene/3d/room_instance.h
@@ -71,7 +71,7 @@ public:
NOTIFICATION_AREA_CHANGED = 60
};
- virtual Rect3 get_aabb() const;
+ virtual AABB get_aabb() const;
virtual PoolVector<Face3> get_faces(uint32_t p_usage_flags) const;
void set_room(const Ref<RoomBounds> &p_room);
diff --git a/scene/3d/sprite_3d.cpp b/scene/3d/sprite_3d.cpp
index 49a3205f21..18ebc22c8b 100644
--- a/scene/3d/sprite_3d.cpp
+++ b/scene/3d/sprite_3d.cpp
@@ -188,7 +188,7 @@ void SpriteBase3D::_queue_update() {
call_deferred(SceneStringNames::get_singleton()->_im_update);
}
-Rect3 SpriteBase3D::get_aabb() const {
+AABB SpriteBase3D::get_aabb() const {
return aabb;
}
@@ -407,7 +407,7 @@ void Sprite3D::_draw() {
}
}
- Rect3 aabb;
+ AABB aabb;
for (int i = 0; i < 4; i++) {
VS::get_singleton()->immediate_normal(immediate, normal);
@@ -698,7 +698,7 @@ void AnimatedSprite3D::_draw() {
}
}
- Rect3 aabb;
+ AABB aabb;
for (int i = 0; i < 4; i++) {
VS::get_singleton()->immediate_normal(immediate, normal);
diff --git a/scene/3d/sprite_3d.h b/scene/3d/sprite_3d.h
index 1165392cb2..d18553a504 100644
--- a/scene/3d/sprite_3d.h
+++ b/scene/3d/sprite_3d.h
@@ -71,7 +71,7 @@ private:
Vector3::Axis axis;
float pixel_size;
- Rect3 aabb;
+ AABB aabb;
RID immediate;
@@ -87,7 +87,7 @@ protected:
void _notification(int p_what);
static void _bind_methods();
virtual void _draw() = 0;
- _FORCE_INLINE_ void set_aabb(const Rect3 &p_aabb) { aabb = p_aabb; }
+ _FORCE_INLINE_ void set_aabb(const AABB &p_aabb) { aabb = p_aabb; }
_FORCE_INLINE_ RID &get_immediate() { return immediate; }
void _queue_update();
@@ -130,7 +130,7 @@ public:
virtual Rect2 get_item_rect() const = 0;
- virtual Rect3 get_aabb() const;
+ virtual AABB get_aabb() const;
virtual PoolVector<Face3> get_faces(uint32_t p_usage_flags) const;
SpriteBase3D();
diff --git a/scene/3d/visibility_notifier.cpp b/scene/3d/visibility_notifier.cpp
index e60b32a92a..47144c4b78 100644
--- a/scene/3d/visibility_notifier.cpp
+++ b/scene/3d/visibility_notifier.cpp
@@ -60,7 +60,7 @@ void VisibilityNotifier::_exit_camera(Camera *p_camera) {
}
}
-void VisibilityNotifier::set_aabb(const Rect3 &p_aabb) {
+void VisibilityNotifier::set_aabb(const AABB &p_aabb) {
if (aabb == p_aabb)
return;
@@ -74,7 +74,7 @@ void VisibilityNotifier::set_aabb(const Rect3 &p_aabb) {
update_gizmo();
}
-Rect3 VisibilityNotifier::get_aabb() const {
+AABB VisibilityNotifier::get_aabb() const {
return aabb;
}
@@ -108,7 +108,7 @@ void VisibilityNotifier::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_aabb"), &VisibilityNotifier::get_aabb);
ClassDB::bind_method(D_METHOD("is_on_screen"), &VisibilityNotifier::is_on_screen);
- ADD_PROPERTY(PropertyInfo(Variant::RECT3, "aabb"), "set_aabb", "get_aabb");
+ ADD_PROPERTY(PropertyInfo(Variant::AABB, "aabb"), "set_aabb", "get_aabb");
ADD_SIGNAL(MethodInfo("camera_entered", PropertyInfo(Variant::OBJECT, "camera", PROPERTY_HINT_RESOURCE_TYPE, "Camera")));
ADD_SIGNAL(MethodInfo("camera_exited", PropertyInfo(Variant::OBJECT, "camera", PROPERTY_HINT_RESOURCE_TYPE, "Camera")));
@@ -118,7 +118,7 @@ void VisibilityNotifier::_bind_methods() {
VisibilityNotifier::VisibilityNotifier() {
- aabb = Rect3(Vector3(-1, -1, -1), Vector3(2, 2, 2));
+ aabb = AABB(Vector3(-1, -1, -1), Vector3(2, 2, 2));
set_notify_transform(true);
}
diff --git a/scene/3d/visibility_notifier.h b/scene/3d/visibility_notifier.h
index 0b83e0534e..fc06cf5aec 100644
--- a/scene/3d/visibility_notifier.h
+++ b/scene/3d/visibility_notifier.h
@@ -39,7 +39,7 @@ class VisibilityNotifier : public Spatial {
Set<Camera *> cameras;
- Rect3 aabb;
+ AABB aabb;
protected:
virtual void _screen_enter() {}
@@ -53,8 +53,8 @@ protected:
void _exit_camera(Camera *p_camera);
public:
- void set_aabb(const Rect3 &p_aabb);
- Rect3 get_aabb() const;
+ void set_aabb(const AABB &p_aabb);
+ AABB get_aabb() const;
bool is_on_screen() const;
VisibilityNotifier();
diff --git a/scene/3d/visual_instance.cpp b/scene/3d/visual_instance.cpp
index fa35d982eb..b92e7ead04 100644
--- a/scene/3d/visual_instance.cpp
+++ b/scene/3d/visual_instance.cpp
@@ -33,7 +33,7 @@
#include "servers/visual_server.h"
#include "skeleton.h"
-Rect3 VisualInstance::get_transformed_aabb() const {
+AABB VisualInstance::get_transformed_aabb() const {
return get_global_transform().xform(get_aabb());
}
diff --git a/scene/3d/visual_instance.h b/scene/3d/visual_instance.h
index c405236d2c..5827f1e1fb 100644
--- a/scene/3d/visual_instance.h
+++ b/scene/3d/visual_instance.h
@@ -62,10 +62,10 @@ public:
};
RID get_instance() const;
- virtual Rect3 get_aabb() const = 0;
+ virtual AABB get_aabb() const = 0;
virtual PoolVector<Face3> get_faces(uint32_t p_usage_flags) const = 0;
- virtual Rect3 get_transformed_aabb() const; // helper
+ virtual AABB get_transformed_aabb() const; // helper
void set_base(const RID &p_base);
diff --git a/scene/animation/tween.cpp b/scene/animation/tween.cpp
index e0508cf147..40d06dc756 100644
--- a/scene/animation/tween.cpp
+++ b/scene/animation/tween.cpp
@@ -416,10 +416,10 @@ Variant Tween::_run_equation(InterpolateData &p_data) {
result = r;
} break;
- case Variant::RECT3: {
- Rect3 i = initial_val;
- Rect3 d = delta_val;
- Rect3 r;
+ case Variant::AABB: {
+ AABB i = initial_val;
+ AABB d = delta_val;
+ AABB r;
APPLY_EQUATION(position.x);
APPLY_EQUATION(position.y);
@@ -956,10 +956,10 @@ bool Tween::_calc_delta_val(const Variant &p_initial_val, const Variant &p_final
case Variant::QUAT:
delta_val = final_val.operator Quat() - initial_val.operator Quat();
break;
- case Variant::RECT3: {
- Rect3 i = initial_val;
- Rect3 f = final_val;
- delta_val = Rect3(f.position - i.position, f.size - i.size);
+ case Variant::AABB: {
+ AABB i = initial_val;
+ AABB f = final_val;
+ delta_val = AABB(f.position - i.position, f.size - i.size);
} break;
case Variant::TRANSFORM: {
Transform i = initial_val;
diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp
index e73ada9f31..3976a2ad48 100644
--- a/scene/gui/control.cpp
+++ b/scene/gui/control.cpp
@@ -1847,6 +1847,25 @@ Control *Control::find_next_valid_focus() const {
while (true) {
+ // If the focus property is manually overwritten, attempt to use it.
+
+ if (!data.focus_next.is_empty()) {
+ Node *n = get_node(data.focus_next);
+ if (n) {
+ from = Object::cast_to<Control>(n);
+
+ if (!from) {
+
+ ERR_EXPLAIN("Next focus node is not a control: " + n->get_name());
+ ERR_FAIL_V(NULL);
+ }
+ } else {
+ return NULL;
+ }
+ if (from->is_visible() && from->get_focus_mode() != FOCUS_NONE)
+ return from;
+ }
+
// find next child
Control *next_child = NULL;
@@ -1926,6 +1945,25 @@ Control *Control::find_prev_valid_focus() const {
while (true) {
+ // If the focus property is manually overwritten, attempt to use it.
+
+ if (!data.focus_prev.is_empty()) {
+ Node *n = get_node(data.focus_prev);
+ if (n) {
+ from = Object::cast_to<Control>(n);
+
+ if (!from) {
+
+ ERR_EXPLAIN("Prev focus node is not a control: " + n->get_name());
+ ERR_FAIL_V(NULL);
+ }
+ } else {
+ return NULL;
+ }
+ if (from->is_visible() && from->get_focus_mode() != FOCUS_NONE)
+ return from;
+ }
+
// find prev child
Control *prev_child = NULL;
@@ -2157,6 +2195,26 @@ NodePath Control::get_focus_neighbour(Margin p_margin) const {
return data.focus_neighbour[p_margin];
}
+void Control::set_focus_next(const NodePath &p_next) {
+
+ data.focus_next = p_next;
+}
+
+NodePath Control::get_focus_next() const {
+
+ return data.focus_next;
+}
+
+void Control::set_focus_previous(const NodePath &p_prev) {
+
+ data.focus_prev = p_prev;
+}
+
+NodePath Control::get_focus_previous() const {
+
+ return data.focus_prev;
+}
+
#define MAX_NEIGHBOUR_SEARCH_COUNT 512
Control *Control::_get_focus_neighbour(Margin p_margin, int p_count) {
@@ -2172,7 +2230,7 @@ Control *Control::_get_focus_neighbour(Margin p_margin, int p_count) {
if (!c) {
- ERR_EXPLAIN("Next focus node is not a control: " + n->get_name());
+ ERR_EXPLAIN("Neighbour focus node is not a control: " + n->get_name());
ERR_FAIL_V(NULL);
}
} else {
@@ -2677,6 +2735,12 @@ void Control::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_focus_neighbour", "margin", "neighbour"), &Control::set_focus_neighbour);
ClassDB::bind_method(D_METHOD("get_focus_neighbour", "margin"), &Control::get_focus_neighbour);
+ ClassDB::bind_method(D_METHOD("set_focus_next", "next"), &Control::set_focus_next);
+ ClassDB::bind_method(D_METHOD("get_focus_next"), &Control::get_focus_next);
+
+ ClassDB::bind_method(D_METHOD("set_focus_previous", "previous"), &Control::set_focus_previous);
+ ClassDB::bind_method(D_METHOD("get_focus_previous"), &Control::get_focus_previous);
+
ClassDB::bind_method(D_METHOD("force_drag", "data", "preview"), &Control::force_drag);
ClassDB::bind_method(D_METHOD("set_mouse_filter", "filter"), &Control::set_mouse_filter);
@@ -2737,6 +2801,8 @@ void Control::_bind_methods() {
ADD_PROPERTYINZ(PropertyInfo(Variant::NODE_PATH, "focus_neighbour_top"), "set_focus_neighbour", "get_focus_neighbour", MARGIN_TOP);
ADD_PROPERTYINZ(PropertyInfo(Variant::NODE_PATH, "focus_neighbour_right"), "set_focus_neighbour", "get_focus_neighbour", MARGIN_RIGHT);
ADD_PROPERTYINZ(PropertyInfo(Variant::NODE_PATH, "focus_neighbour_bottom"), "set_focus_neighbour", "get_focus_neighbour", MARGIN_BOTTOM);
+ ADD_PROPERTYNZ(PropertyInfo(Variant::NODE_PATH, "focus_next"), "set_focus_next", "get_focus_next");
+ ADD_PROPERTYNZ(PropertyInfo(Variant::NODE_PATH, "focus_previous"), "set_focus_previous", "get_focus_previous");
ADD_GROUP("Mouse", "mouse_");
ADD_PROPERTY(PropertyInfo(Variant::INT, "mouse_filter", PROPERTY_HINT_ENUM, "Stop,Pass,Ignore"), "set_mouse_filter", "get_mouse_filter");
diff --git a/scene/gui/control.h b/scene/gui/control.h
index 4d0e3934ad..94c484ca50 100644
--- a/scene/gui/control.h
+++ b/scene/gui/control.h
@@ -191,6 +191,8 @@ private:
ObjectID modal_prev_focus_owner;
NodePath focus_neighbour[4];
+ NodePath focus_next;
+ NodePath focus_prev;
HashMap<StringName, Ref<Texture>, StringNameHasher> icon_override;
HashMap<StringName, Ref<Shader>, StringNameHasher> shader_override;
@@ -374,6 +376,11 @@ public:
void set_focus_neighbour(Margin p_margin, const NodePath &p_neighbour);
NodePath get_focus_neighbour(Margin p_margin) const;
+ void set_focus_next(const NodePath &p_next);
+ NodePath get_focus_next() const;
+ void set_focus_previous(const NodePath &p_prev);
+ NodePath get_focus_previous() const;
+
Control *get_focus_owner() const;
void set_mouse_filter(MouseFilter p_filter);
diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp
index 5d3e5ec0e8..f7bf1cd9ea 100644
--- a/scene/gui/line_edit.cpp
+++ b/scene/gui/line_edit.cpp
@@ -1309,6 +1309,7 @@ void LineEdit::set_expand_to_text_length(bool p_enabled) {
expand_to_text_length = p_enabled;
minimum_size_changed();
+ set_window_pos(0);
}
bool LineEdit::get_expand_to_text_length() const {
@@ -1428,7 +1429,7 @@ void LineEdit::_bind_methods() {
ADD_PROPERTYNZ(PropertyInfo(Variant::INT, "max_length"), "set_max_length", "get_max_length");
ADD_PROPERTYNO(PropertyInfo(Variant::BOOL, "editable"), "set_editable", "is_editable");
ADD_PROPERTYNZ(PropertyInfo(Variant::BOOL, "secret"), "set_secret", "is_secret");
- ADD_PROPERTYNO(PropertyInfo(Variant::BOOL, "expand_to_len"), "set_expand_to_text_length", "get_expand_to_text_length");
+ ADD_PROPERTYNZ(PropertyInfo(Variant::BOOL, "expand_to_text_length"), "set_expand_to_text_length", "get_expand_to_text_length");
ADD_PROPERTY(PropertyInfo(Variant::INT, "focus_mode", PROPERTY_HINT_ENUM, "None,Click,All"), "set_focus_mode", "get_focus_mode");
ADD_GROUP("Placeholder", "placeholder_");
ADD_PROPERTYNZ(PropertyInfo(Variant::STRING, "placeholder_text"), "set_placeholder", "get_placeholder");
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index 5d429f9f91..1b87771fd4 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -894,17 +894,18 @@ void TextEdit::_notification(int p_what) {
is_hex_notation = false;
}
- // check for dot or 'x' for hex notation in floating point number
- if ((str[j] == '.' || str[j] == 'x') && !in_word && prev_is_number && !is_number) {
+ // check for dot or underscore or 'x' for hex notation in floating point number
+ if ((str[j] == '.' || str[j] == 'x' || str[j] == '_') && !in_word && prev_is_number && !is_number) {
is_number = true;
is_symbol = false;
+ is_char = false;
if (str[j] == 'x' && str[j - 1] == '0') {
is_hex_notation = true;
}
}
- if (!in_word && _is_char(str[j])) {
+ if (!in_word && _is_char(str[j]) && !is_number) {
in_word = true;
}
@@ -2040,6 +2041,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
_confirm_completion();
accept_event();
+ emit_signal("request_completion");
return;
}
diff --git a/scene/resources/animation.cpp b/scene/resources/animation.cpp
index 21e4a85cd1..8192074c17 100644
--- a/scene/resources/animation.cpp
+++ b/scene/resources/animation.cpp
@@ -1125,14 +1125,14 @@ Variant Animation::_cubic_interpolate(const Variant &p_pre_a, const Variant &p_a
return a.cubic_slerp(b, pa, pb, p_c);
} break;
- case Variant::RECT3: {
+ case Variant::AABB: {
- Rect3 a = p_a;
- Rect3 b = p_b;
- Rect3 pa = p_pre_a;
- Rect3 pb = p_post_b;
+ AABB a = p_a;
+ AABB b = p_b;
+ AABB pa = p_pre_a;
+ AABB pb = p_post_b;
- return Rect3(
+ return AABB(
a.position.cubic_interpolate(b.position, pa.position, pb.position, p_c),
a.size.cubic_interpolate(b.size, pa.size, pb.size, p_c));
} break;
diff --git a/scene/resources/box_shape.cpp b/scene/resources/box_shape.cpp
index bbc85ce0f6..4b9843f3f5 100644
--- a/scene/resources/box_shape.cpp
+++ b/scene/resources/box_shape.cpp
@@ -33,7 +33,7 @@
Vector<Vector3> BoxShape::_gen_debug_mesh_lines() {
Vector<Vector3> lines;
- Rect3 aabb;
+ AABB aabb;
aabb.position = -get_extents();
aabb.size = aabb.position * -2;
diff --git a/scene/resources/mesh.cpp b/scene/resources/mesh.cpp
index 3e86daf3a7..06b147ba41 100644
--- a/scene/resources/mesh.cpp
+++ b/scene/resources/mesh.cpp
@@ -594,9 +594,9 @@ bool ArrayMesh::_set(const StringName &p_name, const Variant &p_value) {
}
ERR_FAIL_COND_V(!d.has("aabb"), false);
- Rect3 aabb = d["aabb"];
+ AABB aabb = d["aabb"];
- Vector<Rect3> bone_aabb;
+ Vector<AABB> bone_aabb;
if (d.has("skeleton_aabb")) {
Array baabb = d["skeleton_aabb"];
bone_aabb.resize(baabb.size());
@@ -676,7 +676,7 @@ bool ArrayMesh::_get(const StringName &p_name, Variant &r_ret) const {
d["format"] = VS::get_singleton()->mesh_surface_get_format(mesh, idx);
d["aabb"] = VS::get_singleton()->mesh_surface_get_aabb(mesh, idx);
- Vector<Rect3> skel_aabb = VS::get_singleton()->mesh_surface_get_skeleton_aabb(mesh, idx);
+ Vector<AABB> skel_aabb = VS::get_singleton()->mesh_surface_get_skeleton_aabb(mesh, idx);
Array arr;
for (int i = 0; i < skel_aabb.size(); i++) {
arr[i] = skel_aabb[i];
@@ -725,13 +725,13 @@ void ArrayMesh::_get_property_list(List<PropertyInfo> *p_list) const {
}
}
- p_list->push_back(PropertyInfo(Variant::RECT3, "custom_aabb/custom_aabb"));
+ p_list->push_back(PropertyInfo(Variant::AABB, "custom_aabb/custom_aabb"));
}
void ArrayMesh::_recompute_aabb() {
// regenerate AABB
- aabb = Rect3();
+ aabb = AABB();
for (int i = 0; i < surfaces.size(); i++) {
@@ -742,7 +742,7 @@ void ArrayMesh::_recompute_aabb() {
}
}
-void ArrayMesh::add_surface(uint32_t p_format, PrimitiveType p_primitive, const PoolVector<uint8_t> &p_array, int p_vertex_count, const PoolVector<uint8_t> &p_index_array, int p_index_count, const Rect3 &p_aabb, const Vector<PoolVector<uint8_t> > &p_blend_shapes, const Vector<Rect3> &p_bone_aabbs) {
+void ArrayMesh::add_surface(uint32_t p_format, PrimitiveType p_primitive, const PoolVector<uint8_t> &p_array, int p_vertex_count, const PoolVector<uint8_t> &p_index_array, int p_index_count, const AABB &p_aabb, const Vector<PoolVector<uint8_t> > &p_blend_shapes, const Vector<AABB> &p_bone_aabbs) {
Surface s;
s.aabb = p_aabb;
@@ -772,7 +772,7 @@ void ArrayMesh::add_surface_from_arrays(PrimitiveType p_primitive, const Array &
const Vector3 *vtx = r.ptr();
// check AABB
- Rect3 aabb;
+ AABB aabb;
for (int i = 0; i < len; i++) {
if (i == 0)
@@ -926,7 +926,7 @@ void ArrayMesh::surface_update_region(int p_surface, int p_offset, const PoolVec
VS::get_singleton()->mesh_surface_update_region(mesh, p_surface, p_offset, p_data);
}
-void ArrayMesh::surface_set_custom_aabb(int p_idx, const Rect3 &p_aabb) {
+void ArrayMesh::surface_set_custom_aabb(int p_idx, const AABB &p_aabb) {
ERR_FAIL_INDEX(p_idx, surfaces.size());
surfaces[p_idx].aabb = p_aabb;
@@ -942,7 +942,7 @@ Ref<Material> ArrayMesh::surface_get_material(int p_idx) const {
void ArrayMesh::add_surface_from_mesh_data(const Geometry::MeshData &p_mesh_data) {
VisualServer::get_singleton()->mesh_add_surface_from_mesh_data(mesh, p_mesh_data);
- Rect3 aabb;
+ AABB aabb;
for (int i = 0; i < p_mesh_data.vertices.size(); i++) {
if (i == 0)
@@ -970,18 +970,18 @@ RID ArrayMesh::get_rid() const {
return mesh;
}
-Rect3 ArrayMesh::get_aabb() const {
+AABB ArrayMesh::get_aabb() const {
return aabb;
}
-void ArrayMesh::set_custom_aabb(const Rect3 &p_custom) {
+void ArrayMesh::set_custom_aabb(const AABB &p_custom) {
custom_aabb = p_custom;
VS::get_singleton()->mesh_set_custom_aabb(mesh, custom_aabb);
}
-Rect3 ArrayMesh::get_custom_aabb() const {
+AABB ArrayMesh::get_custom_aabb() const {
return custom_aabb;
}
diff --git a/scene/resources/mesh.h b/scene/resources/mesh.h
index 75927079c7..b85a6a84af 100644
--- a/scene/resources/mesh.h
+++ b/scene/resources/mesh.h
@@ -136,7 +136,7 @@ public:
Ref<Mesh> create_outline(float p_margin) const;
- virtual Rect3 get_aabb() const = 0;
+ virtual AABB get_aabb() const = 0;
Mesh();
};
@@ -149,16 +149,16 @@ class ArrayMesh : public Mesh {
private:
struct Surface {
String name;
- Rect3 aabb;
+ AABB aabb;
Ref<Material> material;
bool is_2d;
};
Vector<Surface> surfaces;
RID mesh;
- Rect3 aabb;
+ AABB aabb;
BlendShapeMode blend_shape_mode;
Vector<StringName> blend_shapes;
- Rect3 custom_aabb;
+ AABB custom_aabb;
void _recompute_aabb();
@@ -173,7 +173,7 @@ protected:
public:
void add_surface_from_arrays(PrimitiveType p_primitive, const Array &p_arrays, const Array &p_blend_shapes = Array(), uint32_t p_flags = ARRAY_COMPRESS_DEFAULT);
- void add_surface(uint32_t p_format, PrimitiveType p_primitive, const PoolVector<uint8_t> &p_array, int p_vertex_count, const PoolVector<uint8_t> &p_index_array, int p_index_count, const Rect3 &p_aabb, const Vector<PoolVector<uint8_t> > &p_blend_shapes = Vector<PoolVector<uint8_t> >(), const Vector<Rect3> &p_bone_aabbs = Vector<Rect3>());
+ void add_surface(uint32_t p_format, PrimitiveType p_primitive, const PoolVector<uint8_t> &p_array, int p_vertex_count, const PoolVector<uint8_t> &p_index_array, int p_index_count, const AABB &p_aabb, const Vector<PoolVector<uint8_t> > &p_blend_shapes = Vector<PoolVector<uint8_t> >(), const Vector<AABB> &p_bone_aabbs = Vector<AABB>());
Array surface_get_arrays(int p_surface) const;
Array surface_get_blend_shape_arrays(int p_surface) const;
@@ -191,7 +191,7 @@ public:
int get_surface_count() const;
void surface_remove(int p_idx);
- void surface_set_custom_aabb(int p_idx, const Rect3 &p_aabb); //only recognized by driver
+ void surface_set_custom_aabb(int p_idx, const AABB &p_aabb); //only recognized by driver
int surface_get_array_len(int p_idx) const;
int surface_get_array_index_len(int p_idx) const;
@@ -207,10 +207,10 @@ public:
void add_surface_from_mesh_data(const Geometry::MeshData &p_mesh_data);
- void set_custom_aabb(const Rect3 &p_custom);
- Rect3 get_custom_aabb() const;
+ void set_custom_aabb(const AABB &p_custom);
+ AABB get_custom_aabb() const;
- Rect3 get_aabb() const;
+ AABB get_aabb() const;
virtual RID get_rid() const;
void center_geometry();
diff --git a/scene/resources/multimesh.cpp b/scene/resources/multimesh.cpp
index 15f1e15542..ee6efa6e85 100644
--- a/scene/resources/multimesh.cpp
+++ b/scene/resources/multimesh.cpp
@@ -155,7 +155,7 @@ Color MultiMesh::get_instance_color(int p_instance) const {
return VisualServer::get_singleton()->multimesh_instance_get_color(multimesh, p_instance);
}
-Rect3 MultiMesh::get_aabb() const {
+AABB MultiMesh::get_aabb() const {
return VisualServer::get_singleton()->multimesh_get_aabb(multimesh);
}
diff --git a/scene/resources/multimesh.h b/scene/resources/multimesh.h
index 7ca66b0b46..0a5310f641 100644
--- a/scene/resources/multimesh.h
+++ b/scene/resources/multimesh.h
@@ -84,7 +84,7 @@ public:
void set_instance_color(int p_instance, const Color &p_color);
Color get_instance_color(int p_instance) const;
- virtual Rect3 get_aabb() const;
+ virtual AABB get_aabb() const;
virtual RID get_rid() const;
diff --git a/scene/resources/primitive_meshes.cpp b/scene/resources/primitive_meshes.cpp
index 8e3899315c..3b80db291c 100644
--- a/scene/resources/primitive_meshes.cpp
+++ b/scene/resources/primitive_meshes.cpp
@@ -42,7 +42,7 @@ void PrimitiveMesh::_update() const {
PoolVector<Vector3> points = arr[VS::ARRAY_VERTEX];
- aabb = Rect3();
+ aabb = AABB();
int pc = points.size();
ERR_FAIL_COND(pc == 0);
@@ -141,7 +141,7 @@ StringName PrimitiveMesh::get_blend_shape_name(int p_index) const {
return StringName();
}
-Rect3 PrimitiveMesh::get_aabb() const {
+AABB PrimitiveMesh::get_aabb() const {
if (pending_request) {
_update();
}
diff --git a/scene/resources/primitive_meshes.h b/scene/resources/primitive_meshes.h
index f0c8935261..b38c247827 100644
--- a/scene/resources/primitive_meshes.h
+++ b/scene/resources/primitive_meshes.h
@@ -47,7 +47,7 @@ class PrimitiveMesh : public Mesh {
private:
RID mesh;
- mutable Rect3 aabb;
+ mutable AABB aabb;
Ref<Material> material;
@@ -73,7 +73,7 @@ public:
virtual Ref<Material> surface_get_material(int p_idx) const;
virtual int get_blend_shape_count() const;
virtual StringName get_blend_shape_name(int p_index) const;
- virtual Rect3 get_aabb() const;
+ virtual AABB get_aabb() const;
virtual RID get_rid() const;
void set_material(const Ref<Material> &p_material);
diff --git a/scene/resources/scene_format_text.cpp b/scene/resources/scene_format_text.cpp
index f0304bfaa5..fe23fbf6b3 100644
--- a/scene/resources/scene_format_text.cpp
+++ b/scene/resources/scene_format_text.cpp
@@ -33,7 +33,7 @@
#include "project_settings.h"
#include "version.h"
-//version 2: changed names for basis, rect3, poolvectors, etc.
+//version 2: changed names for basis, aabb, poolvectors, etc.
#define FORMAT_VERSION 2
#include "os/dir_access.h"
diff --git a/scene/resources/tile_set.cpp b/scene/resources/tile_set.cpp
index 50e8c28c22..29ac7852bf 100644
--- a/scene/resources/tile_set.cpp
+++ b/scene/resources/tile_set.cpp
@@ -57,11 +57,9 @@ bool TileSet::_set(const StringName &p_name, const Variant &p_value) {
tile_set_region(id, p_value);
else if (what == "shape")
tile_set_shape(id, 0, p_value);
- else if (what == "shape_offset") {
- Transform2D xform = tile_get_shape_transform(id, 0);
- xform.set_origin(p_value);
- tile_set_shape_transform(id, 0, xform);
- } else if (what == "shape_transform")
+ else if (what == "shape_offset")
+ tile_set_shape_offset(id, 0, p_value);
+ else if (what == "shape_transform")
tile_set_shape_transform(id, 0, p_value);
else if (what == "shape_one_way")
tile_set_shape_one_way(id, 0, p_value);
@@ -110,7 +108,7 @@ bool TileSet::_get(const StringName &p_name, Variant &r_ret) const {
else if (what == "shape")
r_ret = tile_get_shape(id, 0);
else if (what == "shape_offset")
- r_ret = tile_get_shape_transform(id, 0).get_origin();
+ r_ret = tile_get_shape_offset(id, 0);
else if (what == "shape_transform")
r_ret = tile_get_shape_transform(id, 0);
else if (what == "shape_one_way")
@@ -313,6 +311,16 @@ Transform2D TileSet::tile_get_shape_transform(int p_id, int p_shape_id) const {
return Transform2D();
}
+void TileSet::tile_set_shape_offset(int p_id, int p_shape_id, const Vector2 &p_offset) {
+ Transform2D transform = tile_get_shape_transform(p_id, p_shape_id);
+ transform.set_origin(p_offset);
+ tile_set_shape_transform(p_id, p_shape_id, transform);
+}
+
+Vector2 TileSet::tile_get_shape_offset(int p_id, int p_shape_id) const {
+ return tile_get_shape_transform(p_id, p_shape_id).get_origin();
+}
+
void TileSet::tile_set_shape_one_way(int p_id, int p_shape_id, const bool p_one_way) {
ERR_FAIL_COND(!tile_map.has(p_id));
diff --git a/scene/resources/tile_set.h b/scene/resources/tile_set.h
index fe782ff987..3ef3f00cef 100644
--- a/scene/resources/tile_set.h
+++ b/scene/resources/tile_set.h
@@ -108,6 +108,9 @@ public:
void tile_set_shape_transform(int p_id, int p_shape_id, const Transform2D &p_offset);
Transform2D tile_get_shape_transform(int p_id, int p_shape_id) const;
+ void tile_set_shape_offset(int p_id, int p_shape_id, const Vector2 &p_offset);
+ Vector2 tile_get_shape_offset(int p_id, int p_shape_id) const;
+
void tile_set_shape_one_way(int p_id, int p_shape_id, bool p_one_way);
bool tile_get_shape_one_way(int p_id, int p_shape_id) const;
diff --git a/scene/resources/world.cpp b/scene/resources/world.cpp
index af159975ca..86b32a5cdd 100644
--- a/scene/resources/world.cpp
+++ b/scene/resources/world.cpp
@@ -41,7 +41,7 @@ struct SpatialIndexer {
struct NotifierData {
- Rect3 aabb;
+ AABB aabb;
OctreeElementID id;
};
@@ -63,7 +63,7 @@ struct SpatialIndexer {
uint64_t pass;
uint64_t last_frame;
- void _notifier_add(VisibilityNotifier *p_notifier, const Rect3 &p_rect) {
+ void _notifier_add(VisibilityNotifier *p_notifier, const AABB &p_rect) {
ERR_FAIL_COND(notifiers.has(p_notifier));
notifiers[p_notifier].aabb = p_rect;
@@ -71,7 +71,7 @@ struct SpatialIndexer {
changed = true;
}
- void _notifier_update(VisibilityNotifier *p_notifier, const Rect3 &p_rect) {
+ void _notifier_update(VisibilityNotifier *p_notifier, const AABB &p_rect) {
Map<VisibilityNotifier *, NotifierData>::Element *E = notifiers.find(p_notifier);
ERR_FAIL_COND(!E);
@@ -229,14 +229,14 @@ void World::_remove_camera(Camera *p_camera) {
#endif
}
-void World::_register_notifier(VisibilityNotifier *p_notifier, const Rect3 &p_rect) {
+void World::_register_notifier(VisibilityNotifier *p_notifier, const AABB &p_rect) {
#ifndef _3D_DISABLED
indexer->_notifier_add(p_notifier, p_rect);
#endif
}
-void World::_update_notifier(VisibilityNotifier *p_notifier, const Rect3 &p_rect) {
+void World::_update_notifier(VisibilityNotifier *p_notifier, const AABB &p_rect) {
#ifndef _3D_DISABLED
indexer->_notifier_update(p_notifier, p_rect);
diff --git a/scene/resources/world.h b/scene/resources/world.h
index 767d1b5b6e..e0f1de1fd0 100644
--- a/scene/resources/world.h
+++ b/scene/resources/world.h
@@ -60,8 +60,8 @@ protected:
void _update_camera(Camera *p_camera);
void _remove_camera(Camera *p_camera);
- void _register_notifier(VisibilityNotifier *p_notifier, const Rect3 &p_rect);
- void _update_notifier(VisibilityNotifier *p_notifier, const Rect3 &p_rect);
+ void _register_notifier(VisibilityNotifier *p_notifier, const AABB &p_rect);
+ void _update_notifier(VisibilityNotifier *p_notifier, const AABB &p_rect);
void _remove_notifier(VisibilityNotifier *p_notifier);
friend class Viewport;
void _update(uint64_t p_frame);
diff --git a/servers/physics/broad_phase_basic.cpp b/servers/physics/broad_phase_basic.cpp
index c6565ac2e9..e4eae09c61 100644
--- a/servers/physics/broad_phase_basic.cpp
+++ b/servers/physics/broad_phase_basic.cpp
@@ -46,7 +46,7 @@ BroadPhaseSW::ID BroadPhaseBasic::create(CollisionObjectSW *p_object, int p_subi
return current;
}
-void BroadPhaseBasic::move(ID p_id, const Rect3 &p_aabb) {
+void BroadPhaseBasic::move(ID p_id, const AABB &p_aabb) {
Map<ID, Element>::Element *E = element_map.find(p_id);
ERR_FAIL_COND(!E);
@@ -109,7 +109,7 @@ int BroadPhaseBasic::cull_point(const Vector3 &p_point, CollisionObjectSW **p_re
for (Map<ID, Element>::Element *E = element_map.front(); E; E = E->next()) {
- const Rect3 aabb = E->get().aabb;
+ const AABB aabb = E->get().aabb;
if (aabb.has_point(p_point)) {
p_results[rc] = E->get().owner;
@@ -129,7 +129,7 @@ int BroadPhaseBasic::cull_segment(const Vector3 &p_from, const Vector3 &p_to, Co
for (Map<ID, Element>::Element *E = element_map.front(); E; E = E->next()) {
- const Rect3 aabb = E->get().aabb;
+ const AABB aabb = E->get().aabb;
if (aabb.intersects_segment(p_from, p_to)) {
p_results[rc] = E->get().owner;
@@ -142,13 +142,13 @@ int BroadPhaseBasic::cull_segment(const Vector3 &p_from, const Vector3 &p_to, Co
return rc;
}
-int BroadPhaseBasic::cull_aabb(const Rect3 &p_aabb, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices) {
+int BroadPhaseBasic::cull_aabb(const AABB &p_aabb, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices) {
int rc = 0;
for (Map<ID, Element>::Element *E = element_map.front(); E; E = E->next()) {
- const Rect3 aabb = E->get().aabb;
+ const AABB aabb = E->get().aabb;
if (aabb.intersects(p_aabb)) {
p_results[rc] = E->get().owner;
diff --git a/servers/physics/broad_phase_basic.h b/servers/physics/broad_phase_basic.h
index 5c124c1792..ee683ed840 100644
--- a/servers/physics/broad_phase_basic.h
+++ b/servers/physics/broad_phase_basic.h
@@ -39,7 +39,7 @@ class BroadPhaseBasic : public BroadPhaseSW {
CollisionObjectSW *owner;
bool _static;
- Rect3 aabb;
+ AABB aabb;
int subindex;
};
@@ -83,7 +83,7 @@ class BroadPhaseBasic : public BroadPhaseSW {
public:
// 0 is an invalid ID
virtual ID create(CollisionObjectSW *p_object, int p_subindex = 0);
- virtual void move(ID p_id, const Rect3 &p_aabb);
+ virtual void move(ID p_id, const AABB &p_aabb);
virtual void set_static(ID p_id, bool p_static);
virtual void remove(ID p_id);
@@ -93,7 +93,7 @@ public:
virtual int cull_point(const Vector3 &p_point, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices = NULL);
virtual int cull_segment(const Vector3 &p_from, const Vector3 &p_to, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices = NULL);
- virtual int cull_aabb(const Rect3 &p_aabb, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices = NULL);
+ virtual int cull_aabb(const AABB &p_aabb, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices = NULL);
virtual void set_pair_callback(PairCallback p_pair_callback, void *p_userdata);
virtual void set_unpair_callback(UnpairCallback p_unpair_callback, void *p_userdata);
diff --git a/servers/physics/broad_phase_octree.cpp b/servers/physics/broad_phase_octree.cpp
index e7111d9580..3b18a270f0 100644
--- a/servers/physics/broad_phase_octree.cpp
+++ b/servers/physics/broad_phase_octree.cpp
@@ -32,11 +32,11 @@
BroadPhaseSW::ID BroadPhaseOctree::create(CollisionObjectSW *p_object, int p_subindex) {
- ID oid = octree.create(p_object, Rect3(), p_subindex, false, 1 << p_object->get_type(), 0);
+ ID oid = octree.create(p_object, AABB(), p_subindex, false, 1 << p_object->get_type(), 0);
return oid;
}
-void BroadPhaseOctree::move(ID p_id, const Rect3 &p_aabb) {
+void BroadPhaseOctree::move(ID p_id, const AABB &p_aabb) {
octree.move(p_id, p_aabb);
}
@@ -76,7 +76,7 @@ int BroadPhaseOctree::cull_segment(const Vector3 &p_from, const Vector3 &p_to, C
return octree.cull_segment(p_from, p_to, p_results, p_max_results, p_result_indices);
}
-int BroadPhaseOctree::cull_aabb(const Rect3 &p_aabb, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices) {
+int BroadPhaseOctree::cull_aabb(const AABB &p_aabb, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices) {
return octree.cull_aabb(p_aabb, p_results, p_max_results, p_result_indices);
}
diff --git a/servers/physics/broad_phase_octree.h b/servers/physics/broad_phase_octree.h
index d28f2da13f..f894d6ca5a 100644
--- a/servers/physics/broad_phase_octree.h
+++ b/servers/physics/broad_phase_octree.h
@@ -48,7 +48,7 @@ class BroadPhaseOctree : public BroadPhaseSW {
public:
// 0 is an invalid ID
virtual ID create(CollisionObjectSW *p_object, int p_subindex = 0);
- virtual void move(ID p_id, const Rect3 &p_aabb);
+ virtual void move(ID p_id, const AABB &p_aabb);
virtual void set_static(ID p_id, bool p_static);
virtual void remove(ID p_id);
@@ -58,7 +58,7 @@ public:
virtual int cull_point(const Vector3 &p_point, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices = NULL);
virtual int cull_segment(const Vector3 &p_from, const Vector3 &p_to, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices = NULL);
- virtual int cull_aabb(const Rect3 &p_aabb, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices = NULL);
+ virtual int cull_aabb(const AABB &p_aabb, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices = NULL);
virtual void set_pair_callback(PairCallback p_pair_callback, void *p_userdata);
virtual void set_unpair_callback(UnpairCallback p_unpair_callback, void *p_userdata);
diff --git a/servers/physics/broad_phase_sw.h b/servers/physics/broad_phase_sw.h
index 2b5ed629fe..5ad3f9a261 100644
--- a/servers/physics/broad_phase_sw.h
+++ b/servers/physics/broad_phase_sw.h
@@ -30,8 +30,8 @@
#ifndef BROAD_PHASE_SW_H
#define BROAD_PHASE_SW_H
+#include "aabb.h"
#include "math_funcs.h"
-#include "rect3.h"
class CollisionObjectSW;
@@ -49,7 +49,7 @@ public:
// 0 is an invalid ID
virtual ID create(CollisionObjectSW *p_object_, int p_subindex = 0) = 0;
- virtual void move(ID p_id, const Rect3 &p_aabb) = 0;
+ virtual void move(ID p_id, const AABB &p_aabb) = 0;
virtual void set_static(ID p_id, bool p_static) = 0;
virtual void remove(ID p_id) = 0;
@@ -59,7 +59,7 @@ public:
virtual int cull_point(const Vector3 &p_point, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices = NULL) = 0;
virtual int cull_segment(const Vector3 &p_from, const Vector3 &p_to, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices = NULL) = 0;
- virtual int cull_aabb(const Rect3 &p_aabb, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices = NULL) = 0;
+ virtual int cull_aabb(const AABB &p_aabb, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices = NULL) = 0;
virtual void set_pair_callback(PairCallback p_pair_callback, void *p_userdata) = 0;
virtual void set_unpair_callback(UnpairCallback p_unpair_callback, void *p_userdata) = 0;
diff --git a/servers/physics/collision_object_sw.cpp b/servers/physics/collision_object_sw.cpp
index 3af8b542fa..126f8141ff 100644
--- a/servers/physics/collision_object_sw.cpp
+++ b/servers/physics/collision_object_sw.cpp
@@ -149,7 +149,7 @@ void CollisionObjectSW::_update_shapes() {
}
//not quite correct, should compute the next matrix..
- Rect3 shape_aabb = s.shape->get_aabb();
+ AABB shape_aabb = s.shape->get_aabb();
Transform xform = transform * s.xform;
shape_aabb = xform.xform(shape_aabb);
s.aabb_cache = shape_aabb;
@@ -176,10 +176,10 @@ void CollisionObjectSW::_update_shapes_with_motion(const Vector3 &p_motion) {
}
//not quite correct, should compute the next matrix..
- Rect3 shape_aabb = s.shape->get_aabb();
+ AABB shape_aabb = s.shape->get_aabb();
Transform xform = transform * s.xform;
shape_aabb = xform.xform(shape_aabb);
- shape_aabb = shape_aabb.merge(Rect3(shape_aabb.position + p_motion, shape_aabb.size)); //use motion
+ shape_aabb = shape_aabb.merge(AABB(shape_aabb.position + p_motion, shape_aabb.size)); //use motion
s.aabb_cache = shape_aabb;
space->get_broadphase()->move(s.bpid, shape_aabb);
diff --git a/servers/physics/collision_object_sw.h b/servers/physics/collision_object_sw.h
index 67a8a44944..254947060b 100644
--- a/servers/physics/collision_object_sw.h
+++ b/servers/physics/collision_object_sw.h
@@ -61,7 +61,7 @@ private:
Transform xform;
Transform xform_inv;
BroadPhaseSW::ID bpid;
- Rect3 aabb_cache; //for rayqueries
+ AABB aabb_cache; //for rayqueries
real_t area_cache;
ShapeSW *shape;
bool disabled;
@@ -123,7 +123,7 @@ public:
_FORCE_INLINE_ ShapeSW *get_shape(int p_index) const { return shapes[p_index].shape; }
_FORCE_INLINE_ const Transform &get_shape_transform(int p_index) const { return shapes[p_index].xform; }
_FORCE_INLINE_ const Transform &get_shape_inv_transform(int p_index) const { return shapes[p_index].xform_inv; }
- _FORCE_INLINE_ const Rect3 &get_shape_aabb(int p_index) const { return shapes[p_index].aabb_cache; }
+ _FORCE_INLINE_ const AABB &get_shape_aabb(int p_index) const { return shapes[p_index].aabb_cache; }
_FORCE_INLINE_ const real_t get_shape_area(int p_index) const { return shapes[p_index].area_cache; }
_FORCE_INLINE_ Transform get_transform() const { return transform; }
diff --git a/servers/physics/collision_solver_sw.cpp b/servers/physics/collision_solver_sw.cpp
index 7bef208237..a9431dc6d8 100644
--- a/servers/physics/collision_solver_sw.cpp
+++ b/servers/physics/collision_solver_sw.cpp
@@ -152,7 +152,7 @@ bool CollisionSolverSW::solve_concave(const ShapeSW *p_shape_A, const Transform
//quickly compute a local AABB
- Rect3 local_aabb;
+ AABB local_aabb;
for (int i = 0; i < 3; i++) {
Vector3 axis(p_transform_B.basis.get_axis(i));
@@ -291,7 +291,7 @@ bool CollisionSolverSW::solve_distance_plane(const ShapeSW *p_shape_A, const Tra
return collided;
}
-bool CollisionSolverSW::solve_distance(const ShapeSW *p_shape_A, const Transform &p_transform_A, const ShapeSW *p_shape_B, const Transform &p_transform_B, Vector3 &r_point_A, Vector3 &r_point_B, const Rect3 &p_concave_hint, Vector3 *r_sep_axis) {
+bool CollisionSolverSW::solve_distance(const ShapeSW *p_shape_A, const Transform &p_transform_A, const ShapeSW *p_shape_B, const Transform &p_transform_B, Vector3 &r_point_A, Vector3 &r_point_B, const AABB &p_concave_hint, Vector3 *r_sep_axis) {
if (p_shape_A->is_concave())
return false;
@@ -328,14 +328,14 @@ bool CollisionSolverSW::solve_distance(const ShapeSW *p_shape_A, const Transform
//quickly compute a local AABB
- bool use_cc_hint = p_concave_hint != Rect3();
- Rect3 cc_hint_aabb;
+ bool use_cc_hint = p_concave_hint != AABB();
+ AABB cc_hint_aabb;
if (use_cc_hint) {
cc_hint_aabb = p_concave_hint;
cc_hint_aabb.position -= p_transform_B.origin;
}
- Rect3 local_aabb;
+ AABB local_aabb;
for (int i = 0; i < 3; i++) {
Vector3 axis(p_transform_B.basis.get_axis(i));
diff --git a/servers/physics/collision_solver_sw.h b/servers/physics/collision_solver_sw.h
index 1e38b1b54e..a40b665ff0 100644
--- a/servers/physics/collision_solver_sw.h
+++ b/servers/physics/collision_solver_sw.h
@@ -46,7 +46,7 @@ private:
public:
static bool solve_static(const ShapeSW *p_shape_A, const Transform &p_transform_A, const ShapeSW *p_shape_B, const Transform &p_transform_B, CallbackResult p_result_callback, void *p_userdata, Vector3 *r_sep_axis = NULL, real_t p_margin_A = 0, real_t p_margin_B = 0);
- static bool solve_distance(const ShapeSW *p_shape_A, const Transform &p_transform_A, const ShapeSW *p_shape_B, const Transform &p_transform_B, Vector3 &r_point_A, Vector3 &r_point_B, const Rect3 &p_concave_hint, Vector3 *r_sep_axis = NULL);
+ static bool solve_distance(const ShapeSW *p_shape_A, const Transform &p_transform_A, const ShapeSW *p_shape_B, const Transform &p_transform_B, Vector3 &r_point_A, Vector3 &r_point_B, const AABB &p_concave_hint, Vector3 *r_sep_axis = NULL);
};
#endif // COLLISION_SOLVER__SW_H
diff --git a/servers/physics/shape_sw.cpp b/servers/physics/shape_sw.cpp
index 6dafaac115..b204ff7a33 100644
--- a/servers/physics/shape_sw.cpp
+++ b/servers/physics/shape_sw.cpp
@@ -37,7 +37,7 @@
#define _EDGE_IS_VALID_SUPPORT_THRESHOLD 0.0002
#define _FACE_IS_VALID_SUPPORT_THRESHOLD 0.9998
-void ShapeSW::configure(const Rect3 &p_aabb) {
+void ShapeSW::configure(const AABB &p_aabb) {
aabb = p_aabb;
configured = true;
for (Map<ShapeOwnerSW *, int>::Element *E = owners.front(); E; E = E->next()) {
@@ -141,7 +141,7 @@ Vector3 PlaneShapeSW::get_moment_of_inertia(real_t p_mass) const {
void PlaneShapeSW::_setup(const Plane &p_plane) {
plane = p_plane;
- configure(Rect3(Vector3(-1e4, -1e4, -1e4), Vector3(1e4 * 2, 1e4 * 2, 1e4 * 2)));
+ configure(AABB(Vector3(-1e4, -1e4, -1e4), Vector3(1e4 * 2, 1e4 * 2, 1e4 * 2)));
}
void PlaneShapeSW::set_data(const Variant &p_data) {
@@ -223,7 +223,7 @@ Vector3 RayShapeSW::get_moment_of_inertia(real_t p_mass) const {
void RayShapeSW::_setup(real_t p_length) {
length = p_length;
- configure(Rect3(Vector3(0, 0, 0), Vector3(0.1, 0.1, length)));
+ configure(AABB(Vector3(0, 0, 0), Vector3(0.1, 0.1, length)));
}
void RayShapeSW::set_data(const Variant &p_data) {
@@ -299,7 +299,7 @@ Vector3 SphereShapeSW::get_moment_of_inertia(real_t p_mass) const {
void SphereShapeSW::_setup(real_t p_radius) {
radius = p_radius;
- configure(Rect3(Vector3(-radius, -radius, -radius), Vector3(radius * 2.0, radius * 2.0, radius * 2.0)));
+ configure(AABB(Vector3(-radius, -radius, -radius), Vector3(radius * 2.0, radius * 2.0, radius * 2.0)));
}
void SphereShapeSW::set_data(const Variant &p_data) {
@@ -430,7 +430,7 @@ void BoxShapeSW::get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_sup
bool BoxShapeSW::intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const {
- Rect3 aabb(-half_extents, half_extents * 2.0);
+ AABB aabb(-half_extents, half_extents * 2.0);
return aabb.intersects_segment(p_begin, p_end, &r_result, &r_normal);
}
@@ -504,7 +504,7 @@ void BoxShapeSW::_setup(const Vector3 &p_half_extents) {
half_extents = p_half_extents.abs();
- configure(Rect3(-half_extents, half_extents * 2));
+ configure(AABB(-half_extents, half_extents * 2));
}
void BoxShapeSW::set_data(const Variant &p_data) {
@@ -684,7 +684,7 @@ void CapsuleShapeSW::_setup(real_t p_height, real_t p_radius) {
height = p_height;
radius = p_radius;
- configure(Rect3(Vector3(-radius, -radius, -height * 0.5 - radius), Vector3(radius * 2, radius * 2, height + radius * 2.0)));
+ configure(AABB(Vector3(-radius, -radius, -height * 0.5 - radius), Vector3(radius * 2, radius * 2, height + radius * 2.0)));
}
void CapsuleShapeSW::set_data(const Variant &p_data) {
@@ -957,7 +957,7 @@ void ConvexPolygonShapeSW::_setup(const Vector<Vector3> &p_vertices) {
if (err != OK)
ERR_PRINT("Failed to build QuickHull");
- Rect3 _aabb;
+ AABB _aabb;
for (int i = 0; i < mesh.vertices.size(); i++) {
@@ -1102,7 +1102,7 @@ Vector3 FaceShapeSW::get_moment_of_inertia(real_t p_mass) const {
FaceShapeSW::FaceShapeSW() {
- configure(Rect3());
+ configure(AABB());
}
PoolVector<Vector3> ConcavePolygonShapeSW::get_faces() const {
@@ -1300,13 +1300,13 @@ void ConcavePolygonShapeSW::_cull(int p_idx, _CullParams *p_params) const {
}
}
-void ConcavePolygonShapeSW::cull(const Rect3 &p_local_aabb, Callback p_callback, void *p_userdata) const {
+void ConcavePolygonShapeSW::cull(const AABB &p_local_aabb, Callback p_callback, void *p_userdata) const {
// make matrix local to concave
if (faces.size() == 0)
return;
- Rect3 local_aabb = p_local_aabb;
+ AABB local_aabb = p_local_aabb;
// unlock data
PoolVector<Face>::Read fr = faces.read();
@@ -1341,7 +1341,7 @@ Vector3 ConcavePolygonShapeSW::get_moment_of_inertia(real_t p_mass) const {
struct _VolumeSW_BVH_Element {
- Rect3 aabb;
+ AABB aabb;
Vector3 center;
int face_index;
};
@@ -1372,7 +1372,7 @@ struct _VolumeSW_BVH_CompareZ {
struct _VolumeSW_BVH {
- Rect3 aabb;
+ AABB aabb;
_VolumeSW_BVH *left;
_VolumeSW_BVH *right;
@@ -1396,7 +1396,7 @@ _VolumeSW_BVH *_volume_sw_build_bvh(_VolumeSW_BVH_Element *p_elements, int p_siz
bvh->face_index = -1;
}
- Rect3 aabb;
+ AABB aabb;
for (int i = 0; i < p_size; i++) {
if (i == 0)
@@ -1467,7 +1467,7 @@ void ConcavePolygonShapeSW::_setup(PoolVector<Vector3> p_faces) {
int src_face_count = p_faces.size();
if (src_face_count == 0) {
- configure(Rect3());
+ configure(AABB());
return;
}
ERR_FAIL_COND(src_face_count % 3);
@@ -1491,7 +1491,7 @@ void ConcavePolygonShapeSW::_setup(PoolVector<Vector3> p_faces) {
PoolVector<Vector3>::Write vw = vertices.write();
Vector3 *verticesw = vw.ptr();
- Rect3 _aabb;
+ AABB _aabb;
for (int i = 0; i < src_face_count; i++) {
@@ -1588,7 +1588,7 @@ Vector3 HeightMapShapeSW::get_closest_point_to(const Vector3 &p_point) const {
return Vector3();
}
-void HeightMapShapeSW::cull(const Rect3 &p_local_aabb, Callback p_callback, void *p_userdata) const {
+void HeightMapShapeSW::cull(const AABB &p_local_aabb, Callback p_callback, void *p_userdata) const {
}
Vector3 HeightMapShapeSW::get_moment_of_inertia(real_t p_mass) const {
@@ -1611,7 +1611,7 @@ void HeightMapShapeSW::_setup(PoolVector<real_t> p_heights, int p_width, int p_d
PoolVector<real_t>::Read r = heights.read();
- Rect3 aabb;
+ AABB aabb;
for (int i = 0; i < depth; i++) {
diff --git a/servers/physics/shape_sw.h b/servers/physics/shape_sw.h
index 151b84c054..48832affc9 100644
--- a/servers/physics/shape_sw.h
+++ b/servers/physics/shape_sw.h
@@ -58,14 +58,14 @@ public:
class ShapeSW : public RID_Data {
RID self;
- Rect3 aabb;
+ AABB aabb;
bool configured;
real_t custom_bias;
Map<ShapeOwnerSW *, int> owners;
protected:
- void configure(const Rect3 &p_aabb);
+ void configure(const AABB &p_aabb);
public:
enum {
@@ -79,7 +79,7 @@ public:
virtual PhysicsServer::ShapeType get_type() const = 0;
- _FORCE_INLINE_ Rect3 get_aabb() const { return aabb; }
+ _FORCE_INLINE_ AABB get_aabb() const { return aabb; }
_FORCE_INLINE_ bool is_configured() const { return configured; }
virtual bool is_concave() const { return false; }
@@ -114,7 +114,7 @@ public:
typedef void (*Callback)(void *p_userdata, ShapeSW *p_convex);
virtual void get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount) const { r_amount = 0; }
- virtual void cull(const Rect3 &p_local_aabb, Callback p_callback, void *p_userdata) const = 0;
+ virtual void cull(const AABB &p_local_aabb, Callback p_callback, void *p_userdata) const = 0;
ConcaveShapeSW() {}
};
@@ -299,7 +299,7 @@ struct ConcavePolygonShapeSW : public ConcaveShapeSW {
struct BVH {
- Rect3 aabb;
+ AABB aabb;
int left;
int right;
@@ -310,7 +310,7 @@ struct ConcavePolygonShapeSW : public ConcaveShapeSW {
struct _CullParams {
- Rect3 aabb;
+ AABB aabb;
Callback callback;
void *userdata;
const Face *faces;
@@ -353,7 +353,7 @@ public:
virtual bool intersect_point(const Vector3 &p_point) const;
virtual Vector3 get_closest_point_to(const Vector3 &p_point) const;
- virtual void cull(const Rect3 &p_local_aabb, Callback p_callback, void *p_userdata) const;
+ virtual void cull(const AABB &p_local_aabb, Callback p_callback, void *p_userdata) const;
virtual Vector3 get_moment_of_inertia(real_t p_mass) const;
@@ -389,7 +389,7 @@ public:
virtual bool intersect_point(const Vector3 &p_point) const;
virtual Vector3 get_closest_point_to(const Vector3 &p_point) const;
- virtual void cull(const Rect3 &p_local_aabb, Callback p_callback, void *p_userdata) const;
+ virtual void cull(const AABB &p_local_aabb, Callback p_callback, void *p_userdata) const;
virtual Vector3 get_moment_of_inertia(real_t p_mass) const;
@@ -462,7 +462,7 @@ struct MotionShapeSW : public ShapeSW {
virtual void set_data(const Variant &p_data) {}
virtual Variant get_data() const { return Variant(); }
- MotionShapeSW() { configure(Rect3()); }
+ MotionShapeSW() { configure(AABB()); }
};
struct _ShapeTestConvexBSPSW {
diff --git a/servers/physics/space_sw.cpp b/servers/physics/space_sw.cpp
index 7fac56f3d7..a6426b7ee0 100644
--- a/servers/physics/space_sw.cpp
+++ b/servers/physics/space_sw.cpp
@@ -176,7 +176,7 @@ int PhysicsDirectSpaceStateSW::intersect_shape(const RID &p_shape, const Transfo
ShapeSW *shape = static_cast<PhysicsServerSW *>(PhysicsServer::get_singleton())->shape_owner.get(p_shape);
ERR_FAIL_COND_V(!shape, 0);
- Rect3 aabb = p_xform.xform(shape->get_aabb());
+ AABB aabb = p_xform.xform(shape->get_aabb());
int amount = space->broadphase->cull_aabb(aabb, space->intersection_query_results, SpaceSW::INTERSECTION_QUERY_MAX, space->intersection_query_subindex_results);
@@ -224,8 +224,8 @@ bool PhysicsDirectSpaceStateSW::cast_motion(const RID &p_shape, const Transform
ShapeSW *shape = static_cast<PhysicsServerSW *>(PhysicsServer::get_singleton())->shape_owner.get(p_shape);
ERR_FAIL_COND_V(!shape, false);
- Rect3 aabb = p_xform.xform(shape->get_aabb());
- aabb = aabb.merge(Rect3(aabb.position + p_motion, aabb.size)); //motion
+ AABB aabb = p_xform.xform(shape->get_aabb());
+ aabb = aabb.merge(AABB(aabb.position + p_motion, aabb.size)); //motion
aabb = aabb.grow(p_margin);
/*
@@ -341,7 +341,7 @@ bool PhysicsDirectSpaceStateSW::collide_shape(RID p_shape, const Transform &p_sh
ShapeSW *shape = static_cast<PhysicsServerSW *>(PhysicsServer::get_singleton())->shape_owner.get(p_shape);
ERR_FAIL_COND_V(!shape, 0);
- Rect3 aabb = p_shape_xform.xform(shape->get_aabb());
+ AABB aabb = p_shape_xform.xform(shape->get_aabb());
aabb = aabb.grow(p_margin);
int amount = space->broadphase->cull_aabb(aabb, space->intersection_query_results, SpaceSW::INTERSECTION_QUERY_MAX, space->intersection_query_subindex_results);
@@ -417,7 +417,7 @@ bool PhysicsDirectSpaceStateSW::rest_info(RID p_shape, const Transform &p_shape_
ShapeSW *shape = static_cast<PhysicsServerSW *>(PhysicsServer::get_singleton())->shape_owner.get(p_shape);
ERR_FAIL_COND_V(!shape, 0);
- Rect3 aabb = p_shape_xform.xform(shape->get_aabb());
+ AABB aabb = p_shape_xform.xform(shape->get_aabb());
aabb = aabb.grow(p_margin);
int amount = space->broadphase->cull_aabb(aabb, space->intersection_query_results, SpaceSW::INTERSECTION_QUERY_MAX, space->intersection_query_subindex_results);
@@ -514,7 +514,7 @@ PhysicsDirectSpaceStateSW::PhysicsDirectSpaceStateSW() {
////////////////////////////////////////////////////////////////////////////////////////////////////////////
-int SpaceSW::_cull_aabb_for_body(BodySW *p_body, const Rect3 &p_aabb) {
+int SpaceSW::_cull_aabb_for_body(BodySW *p_body, const AABB &p_aabb) {
int amount = broadphase->cull_aabb(p_aabb, intersection_query_results, INTERSECTION_QUERY_MAX, intersection_query_subindex_results);
@@ -561,7 +561,7 @@ bool SpaceSW::test_body_motion(BodySW *p_body, const Transform &p_from, const Ve
r_result->collider_id = 0;
r_result->collider_shape = 0;
}
- Rect3 body_aabb;
+ AABB body_aabb;
for (int i = 0; i < p_body->get_shape_count(); i++) {
@@ -648,7 +648,7 @@ bool SpaceSW::test_body_motion(BodySW *p_body, const Transform &p_from, const Ve
{
// STEP 2 ATTEMPT MOTION
- Rect3 motion_aabb = body_aabb;
+ AABB motion_aabb = body_aabb;
motion_aabb.position += p_motion;
motion_aabb = motion_aabb.merge(body_aabb);
diff --git a/servers/physics/space_sw.h b/servers/physics/space_sw.h
index 270e4ef1bd..fd7e6d16a9 100644
--- a/servers/physics/space_sw.h
+++ b/servers/physics/space_sw.h
@@ -122,7 +122,7 @@ private:
friend class PhysicsDirectSpaceStateSW;
- int _cull_aabb_for_body(BodySW *p_body, const Rect3 &p_aabb);
+ int _cull_aabb_for_body(BodySW *p_body, const AABB &p_aabb);
public:
_FORCE_INLINE_ void set_self(const RID &p_self) { self = p_self; }
diff --git a/servers/visual/rasterizer.h b/servers/visual/rasterizer.h
index 333fe1e72a..21d059c48e 100644
--- a/servers/visual/rasterizer.h
+++ b/servers/visual/rasterizer.h
@@ -234,7 +234,7 @@ public:
virtual RID mesh_create() = 0;
- virtual void mesh_add_surface(RID p_mesh, uint32_t p_format, VS::PrimitiveType p_primitive, const PoolVector<uint8_t> &p_array, int p_vertex_count, const PoolVector<uint8_t> &p_index_array, int p_index_count, const Rect3 &p_aabb, const Vector<PoolVector<uint8_t> > &p_blend_shapes = Vector<PoolVector<uint8_t> >(), const Vector<Rect3> &p_bone_aabbs = Vector<Rect3>()) = 0;
+ virtual void mesh_add_surface(RID p_mesh, uint32_t p_format, VS::PrimitiveType p_primitive, const PoolVector<uint8_t> &p_array, int p_vertex_count, const PoolVector<uint8_t> &p_index_array, int p_index_count, const AABB &p_aabb, const Vector<PoolVector<uint8_t> > &p_blend_shapes = Vector<PoolVector<uint8_t> >(), const Vector<AABB> &p_bone_aabbs = Vector<AABB>()) = 0;
virtual void mesh_set_blend_shape_count(RID p_mesh, int p_amount) = 0;
virtual int mesh_get_blend_shape_count(RID p_mesh) const = 0;
@@ -256,17 +256,17 @@ public:
virtual uint32_t mesh_surface_get_format(RID p_mesh, int p_surface) const = 0;
virtual VS::PrimitiveType mesh_surface_get_primitive_type(RID p_mesh, int p_surface) const = 0;
- virtual Rect3 mesh_surface_get_aabb(RID p_mesh, int p_surface) const = 0;
+ virtual AABB mesh_surface_get_aabb(RID p_mesh, int p_surface) const = 0;
virtual Vector<PoolVector<uint8_t> > mesh_surface_get_blend_shapes(RID p_mesh, int p_surface) const = 0;
- virtual Vector<Rect3> mesh_surface_get_skeleton_aabb(RID p_mesh, int p_surface) const = 0;
+ virtual Vector<AABB> mesh_surface_get_skeleton_aabb(RID p_mesh, int p_surface) const = 0;
virtual void mesh_remove_surface(RID p_mesh, int p_index) = 0;
virtual int mesh_get_surface_count(RID p_mesh) const = 0;
- virtual void mesh_set_custom_aabb(RID p_mesh, const Rect3 &p_aabb) = 0;
- virtual Rect3 mesh_get_custom_aabb(RID p_mesh) const = 0;
+ virtual void mesh_set_custom_aabb(RID p_mesh, const AABB &p_aabb) = 0;
+ virtual AABB mesh_get_custom_aabb(RID p_mesh) const = 0;
- virtual Rect3 mesh_get_aabb(RID p_mesh, RID p_skeleton) const = 0;
+ virtual AABB mesh_get_aabb(RID p_mesh, RID p_skeleton) const = 0;
virtual void mesh_clear(RID p_mesh) = 0;
/* MULTIMESH API */
@@ -290,7 +290,7 @@ public:
virtual void multimesh_set_visible_instances(RID p_multimesh, int p_visible) = 0;
virtual int multimesh_get_visible_instances(RID p_multimesh) const = 0;
- virtual Rect3 multimesh_get_aabb(RID p_multimesh) const = 0;
+ virtual AABB multimesh_get_aabb(RID p_multimesh) const = 0;
/* IMMEDIATE API */
@@ -306,7 +306,7 @@ public:
virtual void immediate_clear(RID p_immediate) = 0;
virtual void immediate_set_material(RID p_immediate, RID p_material) = 0;
virtual RID immediate_get_material(RID p_immediate) const = 0;
- virtual Rect3 immediate_get_aabb(RID p_immediate) const = 0;
+ virtual AABB immediate_get_aabb(RID p_immediate) const = 0;
/* SKELETON API */
@@ -350,7 +350,7 @@ public:
virtual bool light_has_shadow(RID p_light) const = 0;
virtual VS::LightType light_get_type(RID p_light) const = 0;
- virtual Rect3 light_get_aabb(RID p_light) const = 0;
+ virtual AABB light_get_aabb(RID p_light) const = 0;
virtual float light_get_param(RID p_light, VS::LightParam p_param) = 0;
virtual Color light_get_color(RID p_light) = 0;
virtual uint64_t light_get_version(RID p_light) const = 0;
@@ -372,7 +372,7 @@ public:
virtual void reflection_probe_set_enable_shadows(RID p_probe, bool p_enable) = 0;
virtual void reflection_probe_set_cull_mask(RID p_probe, uint32_t p_layers) = 0;
- virtual Rect3 reflection_probe_get_aabb(RID p_probe) const = 0;
+ virtual AABB reflection_probe_get_aabb(RID p_probe) const = 0;
virtual VS::ReflectionProbeUpdateMode reflection_probe_get_update_mode(RID p_probe) const = 0;
virtual uint32_t reflection_probe_get_cull_mask(RID p_probe) const = 0;
virtual Vector3 reflection_probe_get_extents(RID p_probe) const = 0;
@@ -390,8 +390,8 @@ public:
virtual RID gi_probe_create() = 0;
- virtual void gi_probe_set_bounds(RID p_probe, const Rect3 &p_bounds) = 0;
- virtual Rect3 gi_probe_get_bounds(RID p_probe) const = 0;
+ virtual void gi_probe_set_bounds(RID p_probe, const AABB &p_bounds) = 0;
+ virtual AABB gi_probe_get_bounds(RID p_probe) const = 0;
virtual void gi_probe_set_cell_size(RID p_probe, float p_range) = 0;
virtual float gi_probe_get_cell_size(RID p_probe) const = 0;
@@ -446,7 +446,7 @@ public:
virtual void particles_set_pre_process_time(RID p_particles, float p_time) = 0;
virtual void particles_set_explosiveness_ratio(RID p_particles, float p_ratio) = 0;
virtual void particles_set_randomness_ratio(RID p_particles, float p_ratio) = 0;
- virtual void particles_set_custom_aabb(RID p_particles, const Rect3 &p_aabb) = 0;
+ virtual void particles_set_custom_aabb(RID p_particles, const AABB &p_aabb) = 0;
virtual void particles_set_speed_scale(RID p_particles, float p_scale) = 0;
virtual void particles_set_use_local_coordinates(RID p_particles, bool p_enable) = 0;
virtual void particles_set_process_material(RID p_particles, RID p_material) = 0;
@@ -460,8 +460,8 @@ public:
virtual void particles_set_draw_pass_mesh(RID p_particles, int p_pass, RID p_mesh) = 0;
virtual void particles_request_process(RID p_particles) = 0;
- virtual Rect3 particles_get_current_aabb(RID p_particles) = 0;
- virtual Rect3 particles_get_aabb(RID p_particles) const = 0;
+ virtual AABB particles_get_current_aabb(RID p_particles) = 0;
+ virtual AABB particles_get_aabb(RID p_particles) const = 0;
virtual void particles_set_emission_transform(RID p_particles, const Transform &p_transform) = 0;
@@ -882,7 +882,7 @@ public:
case Item::Command::TYPE_MESH: {
const Item::CommandMesh *mesh = static_cast<const Item::CommandMesh *>(c);
- Rect3 aabb = RasterizerStorage::base_singleton->mesh_get_aabb(mesh->mesh, mesh->skeleton);
+ AABB aabb = RasterizerStorage::base_singleton->mesh_get_aabb(mesh->mesh, mesh->skeleton);
r = Rect2(aabb.position.x, aabb.position.y, aabb.size.x, aabb.size.y);
@@ -890,7 +890,7 @@ public:
case Item::Command::TYPE_MULTIMESH: {
const Item::CommandMultiMesh *multimesh = static_cast<const Item::CommandMultiMesh *>(c);
- Rect3 aabb = RasterizerStorage::base_singleton->multimesh_get_aabb(multimesh->multimesh);
+ AABB aabb = RasterizerStorage::base_singleton->multimesh_get_aabb(multimesh->multimesh);
r = Rect2(aabb.position.x, aabb.position.y, aabb.size.x, aabb.size.y);
@@ -899,7 +899,7 @@ public:
const Item::CommandParticles *particles_cmd = static_cast<const Item::CommandParticles *>(c);
if (particles_cmd->particles.is_valid()) {
- Rect3 aabb = RasterizerStorage::base_singleton->particles_get_aabb(particles_cmd->particles);
+ AABB aabb = RasterizerStorage::base_singleton->particles_get_aabb(particles_cmd->particles);
r = Rect2(aabb.position.x, aabb.position.y, aabb.size.x, aabb.size.y);
}
diff --git a/servers/visual/visual_server_raster.h b/servers/visual/visual_server_raster.h
index 67375e81b6..08a0cfa269 100644
--- a/servers/visual/visual_server_raster.h
+++ b/servers/visual/visual_server_raster.h
@@ -77,8 +77,8 @@ class VisualServerRaster : public VisualServer {
static void _changes_changed() {}
public:
-//if editor is redrawing when it shouldn't, enable this and put a breakpoint in _changes_changed()
-//#define DEBUG_CHANGES
+ //if editor is redrawing when it shouldn't, enable this and put a breakpoint in _changes_changed()
+ //#define DEBUG_CHANGES
#ifdef DEBUG_CHANGES
_FORCE_INLINE_ static void redraw_request() {
@@ -96,7 +96,7 @@ public:
#define DISPLAY_CHANGED \
changes++;
#endif
-// print_line(String("CHANGED: ") + __FUNCTION__);
+ // print_line(String("CHANGED: ") + __FUNCTION__);
#define BIND0R(m_r, m_name) \
m_r m_name() { return BINDBASE->m_name(); }
@@ -203,7 +203,7 @@ public:
BIND0R(RID, mesh_create)
- BIND10(mesh_add_surface, RID, uint32_t, PrimitiveType, const PoolVector<uint8_t> &, int, const PoolVector<uint8_t> &, int, const Rect3 &, const Vector<PoolVector<uint8_t> > &, const Vector<Rect3> &)
+ BIND10(mesh_add_surface, RID, uint32_t, PrimitiveType, const PoolVector<uint8_t> &, int, const PoolVector<uint8_t> &, int, const AABB &, const Vector<PoolVector<uint8_t> > &, const Vector<AABB> &)
BIND2(mesh_set_blend_shape_count, RID, int)
BIND1RC(int, mesh_get_blend_shape_count, RID)
@@ -225,15 +225,15 @@ public:
BIND2RC(uint32_t, mesh_surface_get_format, RID, int)
BIND2RC(PrimitiveType, mesh_surface_get_primitive_type, RID, int)
- BIND2RC(Rect3, mesh_surface_get_aabb, RID, int)
+ BIND2RC(AABB, mesh_surface_get_aabb, RID, int)
BIND2RC(Vector<PoolVector<uint8_t> >, mesh_surface_get_blend_shapes, RID, int)
- BIND2RC(Vector<Rect3>, mesh_surface_get_skeleton_aabb, RID, int)
+ BIND2RC(Vector<AABB>, mesh_surface_get_skeleton_aabb, RID, int)
BIND2(mesh_remove_surface, RID, int)
BIND1RC(int, mesh_get_surface_count, RID)
- BIND2(mesh_set_custom_aabb, RID, const Rect3 &)
- BIND1RC(Rect3, mesh_get_custom_aabb, RID)
+ BIND2(mesh_set_custom_aabb, RID, const AABB &)
+ BIND1RC(AABB, mesh_get_custom_aabb, RID)
BIND1(mesh_clear, RID)
@@ -250,7 +250,7 @@ public:
BIND3(multimesh_instance_set_color, RID, int, const Color &)
BIND1RC(RID, multimesh_get_mesh, RID)
- BIND1RC(Rect3, multimesh_get_aabb, RID)
+ BIND1RC(AABB, multimesh_get_aabb, RID)
BIND2RC(Transform, multimesh_instance_get_transform, RID, int)
BIND2RC(Transform2D, multimesh_instance_get_transform_2d, RID, int)
@@ -327,8 +327,8 @@ public:
BIND0R(RID, gi_probe_create)
- BIND2(gi_probe_set_bounds, RID, const Rect3 &)
- BIND1RC(Rect3, gi_probe_get_bounds, RID)
+ BIND2(gi_probe_set_bounds, RID, const AABB &)
+ BIND1RC(AABB, gi_probe_get_bounds, RID)
BIND2(gi_probe_set_cell_size, RID, float)
BIND1RC(float, gi_probe_get_cell_size, RID)
@@ -371,7 +371,7 @@ public:
BIND2(particles_set_pre_process_time, RID, float)
BIND2(particles_set_explosiveness_ratio, RID, float)
BIND2(particles_set_randomness_ratio, RID, float)
- BIND2(particles_set_custom_aabb, RID, const Rect3 &)
+ BIND2(particles_set_custom_aabb, RID, const AABB &)
BIND2(particles_set_speed_scale, RID, float)
BIND2(particles_set_use_local_coordinates, RID, bool)
BIND2(particles_set_process_material, RID, RID)
@@ -384,7 +384,7 @@ public:
BIND2(particles_set_draw_passes, RID, int)
BIND3(particles_set_draw_pass_mesh, RID, int, RID)
- BIND1R(Rect3, particles_get_current_aabb, RID)
+ BIND1R(AABB, particles_get_current_aabb, RID)
BIND2(particles_set_emission_transform, RID, const Transform &)
#undef BINDBASE
@@ -449,7 +449,7 @@ public:
BIND2R(int, viewport_get_render_info, RID, ViewportRenderInfo)
BIND2(viewport_set_debug_draw, RID, ViewportDebugDraw)
-/* ENVIRONMENT API */
+ /* ENVIRONMENT API */
#undef BINDBASE
//from now on, calls forwarded to this singleton
@@ -479,7 +479,7 @@ public:
BIND6(environment_set_fog_depth, RID, bool, float, float, bool, float)
BIND5(environment_set_fog_height, RID, bool, float, float, float)
-/* SCENARIO API */
+ /* SCENARIO API */
#undef BINDBASE
#define BINDBASE VSG::scene
@@ -510,7 +510,7 @@ public:
BIND2(instance_set_extra_visibility_margin, RID, real_t)
// don't use these in a game!
- BIND2RC(Vector<ObjectID>, instances_cull_aabb, const Rect3 &, RID)
+ BIND2RC(Vector<ObjectID>, instances_cull_aabb, const AABB &, RID)
BIND3RC(Vector<ObjectID>, instances_cull_ray, const Vector3 &, const Vector3 &, RID)
BIND2RC(Vector<ObjectID>, instances_cull_convex, const Vector<Plane> &, RID)
diff --git a/servers/visual/visual_server_scene.cpp b/servers/visual/visual_server_scene.cpp
index e49baf0763..3e46705ff8 100644
--- a/servers/visual/visual_server_scene.cpp
+++ b/servers/visual/visual_server_scene.cpp
@@ -614,7 +614,7 @@ void VisualServerScene::instance_set_exterior(RID p_instance, bool p_enabled) {
void VisualServerScene::instance_set_extra_visibility_margin(RID p_instance, real_t p_margin) {
}
-Vector<ObjectID> VisualServerScene::instances_cull_aabb(const Rect3 &p_aabb, RID p_scenario) const {
+Vector<ObjectID> VisualServerScene::instances_cull_aabb(const AABB &p_aabb, RID p_scenario) const {
Vector<ObjectID> instances;
Scenario *scenario = scenario_owner.get(p_scenario);
@@ -772,7 +772,7 @@ void VisualServerScene::_update_instance(Instance *p_instance) {
p_instance->mirror = p_instance->transform.basis.determinant() < 0.0;
- Rect3 new_aabb;
+ AABB new_aabb;
new_aabb = p_instance->transform.xform(p_instance->aabb);
@@ -817,7 +817,7 @@ void VisualServerScene::_update_instance(Instance *p_instance) {
void VisualServerScene::_update_instance_aabb(Instance *p_instance) {
- Rect3 new_aabb;
+ AABB new_aabb;
ERR_FAIL_COND(p_instance->base_type != VS::INSTANCE_NONE && !p_instance->base.is_valid());
@@ -1279,7 +1279,7 @@ void VisualServerScene::render_camera(RID p_camera, RID p_scenario, Size2 p_view
camera->zfar,
camera->vaspect
- );
+ );
ortho = true;
} break;
case Camera::PERSPECTIVE: {
@@ -1291,7 +1291,7 @@ void VisualServerScene::render_camera(RID p_camera, RID p_scenario, Size2 p_view
camera->zfar,
camera->vaspect
- );
+ );
ortho = false;
} break;
@@ -1863,7 +1863,7 @@ void VisualServerScene::_setup_gi_probe(Instance *p_instance) {
probe->dynamic.enabled = true;
Transform cell_to_xform = VSG::storage->gi_probe_get_to_cell_xform(p_instance->base);
- Rect3 bounds = VSG::storage->gi_probe_get_bounds(p_instance->base);
+ AABB bounds = VSG::storage->gi_probe_get_bounds(p_instance->base);
float cell_size = VSG::storage->gi_probe_get_cell_size(p_instance->base);
probe->dynamic.light_to_cell_xform = cell_to_xform * p_instance->transform.affine_inverse();
diff --git a/servers/visual/visual_server_scene.h b/servers/visual/visual_server_scene.h
index d30a2108a5..2738fa058d 100644
--- a/servers/visual/visual_server_scene.h
+++ b/servers/visual/visual_server_scene.h
@@ -195,8 +195,8 @@ public:
SelfList<Instance> update_item;
- Rect3 aabb;
- Rect3 transformed_aabb;
+ AABB aabb;
+ AABB transformed_aabb;
float extra_margin;
uint32_t object_ID;
@@ -466,7 +466,7 @@ public:
virtual void instance_set_extra_visibility_margin(RID p_instance, real_t p_margin);
// don't use these in a game!
- virtual Vector<ObjectID> instances_cull_aabb(const Rect3 &p_aabb, RID p_scenario = RID()) const;
+ virtual Vector<ObjectID> instances_cull_aabb(const AABB &p_aabb, RID p_scenario = RID()) const;
virtual Vector<ObjectID> instances_cull_ray(const Vector3 &p_from, const Vector3 &p_to, RID p_scenario = RID()) const;
virtual Vector<ObjectID> instances_cull_convex(const Vector<Plane> &p_convex, RID p_scenario = RID()) const;
diff --git a/servers/visual/visual_server_wrap_mt.h b/servers/visual/visual_server_wrap_mt.h
index 1dddef7bd4..509b77cf9c 100644
--- a/servers/visual/visual_server_wrap_mt.h
+++ b/servers/visual/visual_server_wrap_mt.h
@@ -63,7 +63,7 @@ class VisualServerWrapMT : public VisualServer {
int pool_max_size;
-//#define DEBUG_SYNC
+ //#define DEBUG_SYNC
#ifdef DEBUG_SYNC
#define SYNC_DEBUG print_line("sync on: " + String(__FUNCTION__));
@@ -136,7 +136,7 @@ public:
FUNCRID(mesh)
- FUNC10(mesh_add_surface, RID, uint32_t, PrimitiveType, const PoolVector<uint8_t> &, int, const PoolVector<uint8_t> &, int, const Rect3 &, const Vector<PoolVector<uint8_t> > &, const Vector<Rect3> &)
+ FUNC10(mesh_add_surface, RID, uint32_t, PrimitiveType, const PoolVector<uint8_t> &, int, const PoolVector<uint8_t> &, int, const AABB &, const Vector<PoolVector<uint8_t> > &, const Vector<AABB> &)
FUNC2(mesh_set_blend_shape_count, RID, int)
FUNC1RC(int, mesh_get_blend_shape_count, RID)
@@ -158,15 +158,15 @@ public:
FUNC2RC(uint32_t, mesh_surface_get_format, RID, int)
FUNC2RC(PrimitiveType, mesh_surface_get_primitive_type, RID, int)
- FUNC2RC(Rect3, mesh_surface_get_aabb, RID, int)
+ FUNC2RC(AABB, mesh_surface_get_aabb, RID, int)
FUNC2RC(Vector<PoolVector<uint8_t> >, mesh_surface_get_blend_shapes, RID, int)
- FUNC2RC(Vector<Rect3>, mesh_surface_get_skeleton_aabb, RID, int)
+ FUNC2RC(Vector<AABB>, mesh_surface_get_skeleton_aabb, RID, int)
FUNC2(mesh_remove_surface, RID, int)
FUNC1RC(int, mesh_get_surface_count, RID)
- FUNC2(mesh_set_custom_aabb, RID, const Rect3 &)
- FUNC1RC(Rect3, mesh_get_custom_aabb, RID)
+ FUNC2(mesh_set_custom_aabb, RID, const AABB &)
+ FUNC1RC(AABB, mesh_get_custom_aabb, RID)
FUNC1(mesh_clear, RID)
@@ -183,7 +183,7 @@ public:
FUNC3(multimesh_instance_set_color, RID, int, const Color &)
FUNC1RC(RID, multimesh_get_mesh, RID)
- FUNC1RC(Rect3, multimesh_get_aabb, RID)
+ FUNC1RC(AABB, multimesh_get_aabb, RID)
FUNC2RC(Transform, multimesh_instance_get_transform, RID, int)
FUNC2RC(Transform2D, multimesh_instance_get_transform_2d, RID, int)
@@ -260,8 +260,8 @@ public:
FUNCRID(gi_probe)
- FUNC2(gi_probe_set_bounds, RID, const Rect3 &)
- FUNC1RC(Rect3, gi_probe_get_bounds, RID)
+ FUNC2(gi_probe_set_bounds, RID, const AABB &)
+ FUNC1RC(AABB, gi_probe_get_bounds, RID)
FUNC2(gi_probe_set_cell_size, RID, float)
FUNC1RC(float, gi_probe_get_cell_size, RID)
@@ -304,7 +304,7 @@ public:
FUNC2(particles_set_pre_process_time, RID, float)
FUNC2(particles_set_explosiveness_ratio, RID, float)
FUNC2(particles_set_randomness_ratio, RID, float)
- FUNC2(particles_set_custom_aabb, RID, const Rect3 &)
+ FUNC2(particles_set_custom_aabb, RID, const AABB &)
FUNC2(particles_set_speed_scale, RID, float)
FUNC2(particles_set_use_local_coordinates, RID, bool)
FUNC2(particles_set_process_material, RID, RID)
@@ -318,7 +318,7 @@ public:
FUNC3(particles_set_draw_pass_mesh, RID, int, RID)
FUNC2(particles_set_emission_transform, RID, const Transform &)
- FUNC1R(Rect3, particles_get_current_aabb, RID)
+ FUNC1R(AABB, particles_get_current_aabb, RID)
/* CAMERA API */
@@ -431,7 +431,7 @@ public:
FUNC2(instance_set_extra_visibility_margin, RID, real_t)
// don't use these in a game!
- FUNC2RC(Vector<ObjectID>, instances_cull_aabb, const Rect3 &, RID)
+ FUNC2RC(Vector<ObjectID>, instances_cull_aabb, const AABB &, RID)
FUNC3RC(Vector<ObjectID>, instances_cull_ray, const Vector3 &, const Vector3 &, RID)
FUNC2RC(Vector<ObjectID>, instances_cull_convex, const Vector<Plane> &, RID)
diff --git a/servers/visual_server.cpp b/servers/visual_server.cpp
index 039bbedbcc..10f350d667 100644
--- a/servers/visual_server.cpp
+++ b/servers/visual_server.cpp
@@ -308,7 +308,7 @@ RID VisualServer::get_white_texture() {
#define SMALL_VEC2 Vector2(0.00001, 0.00001)
#define SMALL_VEC3 Vector3(0.00001, 0.00001, 0.00001)
-Error VisualServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint32_t *p_offsets, uint32_t p_stride, PoolVector<uint8_t> &r_vertex_array, int p_vertex_array_len, PoolVector<uint8_t> &r_index_array, int p_index_array_len, Rect3 &r_aabb, Vector<Rect3> r_bone_aabb) {
+Error VisualServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint32_t *p_offsets, uint32_t p_stride, PoolVector<uint8_t> &r_vertex_array, int p_vertex_array_len, PoolVector<uint8_t> &r_index_array, int p_index_array_len, AABB &r_aabb, Vector<AABB> r_bone_aabb) {
PoolVector<uint8_t>::Write vw = r_vertex_array.write();
@@ -373,7 +373,7 @@ Error VisualServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint32_
}
}
- r_aabb = Rect3(Vector3(aabb.position.x, aabb.position.y, 0), Vector3(aabb.size.x, aabb.size.y, 0));
+ r_aabb = AABB(Vector3(aabb.position.x, aabb.position.y, 0), Vector3(aabb.size.x, aabb.size.y, 0));
} else {
PoolVector<Vector3> array = p_arrays[ai];
@@ -383,7 +383,7 @@ Error VisualServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint32_
const Vector3 *src = read.ptr();
// setting vertices means regenerating the AABB
- Rect3 aabb;
+ AABB aabb;
if (p_format & ARRAY_COMPRESS_VERTEX) {
@@ -395,7 +395,7 @@ Error VisualServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint32_
if (i == 0) {
- aabb = Rect3(src[i], SMALL_VEC3);
+ aabb = AABB(src[i], SMALL_VEC3);
} else {
aabb.expand_to(src[i]);
@@ -411,7 +411,7 @@ Error VisualServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint32_
if (i == 0) {
- aabb = Rect3(src[i], SMALL_VEC3);
+ aabb = AABB(src[i], SMALL_VEC3);
} else {
aabb.expand_to(src[i]);
@@ -728,7 +728,7 @@ Error VisualServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint32_
PoolVector<int>::Read rb = bones.read();
PoolVector<float>::Read rw = weights.read();
- Rect3 *bptr = r_bone_aabb.ptr();
+ AABB *bptr = r_bone_aabb.ptr();
for (int i = 0; i < vs; i++) {
@@ -743,7 +743,7 @@ Error VisualServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint32_
if (bptr->size.x < 0) {
//first
- bptr[idx] = Rect3(v, SMALL_VEC3);
+ bptr[idx] = AABB(v, SMALL_VEC3);
any_valid = true;
} else {
bptr[idx].expand_to(v);
@@ -975,8 +975,8 @@ void VisualServer::mesh_add_surface_from_arrays(RID p_mesh, PrimitiveType p_prim
PoolVector<uint8_t> index_array;
index_array.resize(index_array_size);
- Rect3 aabb;
- Vector<Rect3> bone_aabb;
+ AABB aabb;
+ Vector<AABB> bone_aabb;
Error err = _surface_set_data(p_arrays, format, offsets, total_elem_size, vertex_array, array_len, index_array, index_array_len, aabb, bone_aabb);
@@ -993,7 +993,7 @@ void VisualServer::mesh_add_surface_from_arrays(RID p_mesh, PrimitiveType p_prim
vertex_array_shape.resize(array_size);
PoolVector<uint8_t> noindex;
- Rect3 laabb;
+ AABB laabb;
Error err = _surface_set_data(p_blend_shapes[i], format & ~ARRAY_FORMAT_INDEX, offsets, total_elem_size, vertex_array_shape, array_len, noindex, 0, laabb, bone_aabb);
aabb.merge_with(laabb);
if (err) {
@@ -1470,7 +1470,7 @@ Array VisualServer::mesh_surface_get_blend_shape_arrays(RID p_mesh, int p_surfac
Array VisualServer::_mesh_surface_get_skeleton_aabb_bind(RID p_mesh, int p_surface) const {
- Vector<Rect3> vec = VS::get_singleton()->mesh_surface_get_skeleton_aabb(p_mesh, p_surface);
+ Vector<AABB> vec = VS::get_singleton()->mesh_surface_get_skeleton_aabb(p_mesh, p_surface);
Array arr;
for (int i = 0; i < vec.size(); i++) {
arr[i] = vec[i];
diff --git a/servers/visual_server.h b/servers/visual_server.h
index a36ba4a50a..4e43d0bd17 100644
--- a/servers/visual_server.h
+++ b/servers/visual_server.h
@@ -60,7 +60,7 @@ protected:
RID white_texture;
RID test_material;
- Error _surface_set_data(Array p_arrays, uint32_t p_format, uint32_t *p_offsets, uint32_t p_stride, PoolVector<uint8_t> &r_vertex_array, int p_vertex_array_len, PoolVector<uint8_t> &r_index_array, int p_index_array_len, Rect3 &r_aabb, Vector<Rect3> r_bone_aabb);
+ Error _surface_set_data(Array p_arrays, uint32_t p_format, uint32_t *p_offsets, uint32_t p_stride, PoolVector<uint8_t> &r_vertex_array, int p_vertex_array_len, PoolVector<uint8_t> &r_index_array, int p_index_array_len, AABB &r_aabb, Vector<AABB> r_bone_aabb);
static VisualServer *(*create_func)();
static void _bind_methods();
@@ -247,7 +247,7 @@ public:
virtual RID mesh_create() = 0;
virtual void mesh_add_surface_from_arrays(RID p_mesh, PrimitiveType p_primitive, const Array &p_arrays, const Array &p_blend_shapes = Array(), uint32_t p_compress_format = ARRAY_COMPRESS_DEFAULT);
- virtual void mesh_add_surface(RID p_mesh, uint32_t p_format, PrimitiveType p_primitive, const PoolVector<uint8_t> &p_array, int p_vertex_count, const PoolVector<uint8_t> &p_index_array, int p_index_count, const Rect3 &p_aabb, const Vector<PoolVector<uint8_t> > &p_blend_shapes = Vector<PoolVector<uint8_t> >(), const Vector<Rect3> &p_bone_aabbs = Vector<Rect3>()) = 0;
+ virtual void mesh_add_surface(RID p_mesh, uint32_t p_format, PrimitiveType p_primitive, const PoolVector<uint8_t> &p_array, int p_vertex_count, const PoolVector<uint8_t> &p_index_array, int p_index_count, const AABB &p_aabb, const Vector<PoolVector<uint8_t> > &p_blend_shapes = Vector<PoolVector<uint8_t> >(), const Vector<AABB> &p_bone_aabbs = Vector<AABB>()) = 0;
virtual void mesh_set_blend_shape_count(RID p_mesh, int p_amount) = 0;
virtual int mesh_get_blend_shape_count(RID p_mesh) const = 0;
@@ -277,16 +277,16 @@ public:
virtual uint32_t mesh_surface_get_format(RID p_mesh, int p_surface) const = 0;
virtual PrimitiveType mesh_surface_get_primitive_type(RID p_mesh, int p_surface) const = 0;
- virtual Rect3 mesh_surface_get_aabb(RID p_mesh, int p_surface) const = 0;
+ virtual AABB mesh_surface_get_aabb(RID p_mesh, int p_surface) const = 0;
virtual Vector<PoolVector<uint8_t> > mesh_surface_get_blend_shapes(RID p_mesh, int p_surface) const = 0;
- virtual Vector<Rect3> mesh_surface_get_skeleton_aabb(RID p_mesh, int p_surface) const = 0;
+ virtual Vector<AABB> mesh_surface_get_skeleton_aabb(RID p_mesh, int p_surface) const = 0;
Array _mesh_surface_get_skeleton_aabb_bind(RID p_mesh, int p_surface) const;
virtual void mesh_remove_surface(RID p_mesh, int p_index) = 0;
virtual int mesh_get_surface_count(RID p_mesh) const = 0;
- virtual void mesh_set_custom_aabb(RID p_mesh, const Rect3 &p_aabb) = 0;
- virtual Rect3 mesh_get_custom_aabb(RID p_mesh) const = 0;
+ virtual void mesh_set_custom_aabb(RID p_mesh, const AABB &p_aabb) = 0;
+ virtual AABB mesh_get_custom_aabb(RID p_mesh) const = 0;
virtual void mesh_clear(RID p_mesh) = 0;
@@ -314,7 +314,7 @@ public:
virtual void multimesh_instance_set_color(RID p_multimesh, int p_index, const Color &p_color) = 0;
virtual RID multimesh_get_mesh(RID p_multimesh) const = 0;
- virtual Rect3 multimesh_get_aabb(RID p_multimesh) const = 0;
+ virtual AABB multimesh_get_aabb(RID p_multimesh) const = 0;
virtual Transform multimesh_instance_get_transform(RID p_multimesh, int p_index) const = 0;
virtual Transform2D multimesh_instance_get_transform_2d(RID p_multimesh, int p_index) const = 0;
@@ -449,8 +449,8 @@ public:
virtual RID gi_probe_create() = 0;
- virtual void gi_probe_set_bounds(RID p_probe, const Rect3 &p_bounds) = 0;
- virtual Rect3 gi_probe_get_bounds(RID p_probe) const = 0;
+ virtual void gi_probe_set_bounds(RID p_probe, const AABB &p_bounds) = 0;
+ virtual AABB gi_probe_get_bounds(RID p_probe) const = 0;
virtual void gi_probe_set_cell_size(RID p_probe, float p_range) = 0;
virtual float gi_probe_get_cell_size(RID p_probe) const = 0;
@@ -493,7 +493,7 @@ public:
virtual void particles_set_pre_process_time(RID p_particles, float p_time) = 0;
virtual void particles_set_explosiveness_ratio(RID p_particles, float p_ratio) = 0;
virtual void particles_set_randomness_ratio(RID p_particles, float p_ratio) = 0;
- virtual void particles_set_custom_aabb(RID p_particles, const Rect3 &p_aabb) = 0;
+ virtual void particles_set_custom_aabb(RID p_particles, const AABB &p_aabb) = 0;
virtual void particles_set_speed_scale(RID p_particles, float p_scale) = 0;
virtual void particles_set_use_local_coordinates(RID p_particles, bool p_enable) = 0;
virtual void particles_set_process_material(RID p_particles, RID p_material) = 0;
@@ -512,7 +512,7 @@ public:
virtual void particles_set_draw_passes(RID p_particles, int p_count) = 0;
virtual void particles_set_draw_pass_mesh(RID p_particles, int p_pass, RID p_mesh) = 0;
- virtual Rect3 particles_get_current_aabb(RID p_particles) = 0;
+ virtual AABB particles_get_current_aabb(RID p_particles) = 0;
virtual void particles_set_emission_transform(RID p_particles, const Transform &p_transform) = 0; //this is only used for 2D, in 3D it's automatic
@@ -758,7 +758,7 @@ public:
virtual void instance_set_extra_visibility_margin(RID p_instance, real_t p_margin) = 0;
// don't use these in a game!
- virtual Vector<ObjectID> instances_cull_aabb(const Rect3 &p_aabb, RID p_scenario = RID()) const = 0;
+ virtual Vector<ObjectID> instances_cull_aabb(const AABB &p_aabb, RID p_scenario = RID()) const = 0;
virtual Vector<ObjectID> instances_cull_ray(const Vector3 &p_from, const Vector3 &p_to, RID p_scenario = RID()) const = 0;
virtual Vector<ObjectID> instances_cull_convex(const Vector<Plane> &p_convex, RID p_scenario = RID()) const = 0;