summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/basis_universal/SCsub1
-rw-r--r--modules/csg/SCsub3
-rw-r--r--modules/csg/editor/csg_gizmos.cpp (renamed from modules/csg/csg_gizmos.cpp)4
-rw-r--r--modules/csg/editor/csg_gizmos.h (renamed from modules/csg/csg_gizmos.h)6
-rw-r--r--modules/csg/register_types.cpp12
-rw-r--r--modules/fbx/editor_scene_importer_fbx.cpp34
-rw-r--r--modules/fbx/editor_scene_importer_fbx.h3
-rw-r--r--modules/gdscript/SCsub5
-rw-r--r--modules/gdscript/editor/script_templates/CharacterBody2D/basic_movement.gd (renamed from modules/gdscript/editor_templates/CharacterBody2D/basic_movement.gd)0
-rw-r--r--modules/gdscript/editor/script_templates/CharacterBody3D/basic_movement.gd (renamed from modules/gdscript/editor_templates/CharacterBody3D/basic_movement.gd)0
-rw-r--r--modules/gdscript/editor/script_templates/EditorPlugin/plugin.gd (renamed from modules/gdscript/editor_templates/EditorPlugin/plugin.gd)0
-rw-r--r--modules/gdscript/editor/script_templates/EditorScript/basic_editor_script.gd (renamed from modules/gdscript/editor_templates/EditorScript/basic_editor_script.gd)0
-rw-r--r--modules/gdscript/editor/script_templates/Node/default.gd (renamed from modules/gdscript/editor_templates/Node/default.gd)0
-rw-r--r--modules/gdscript/editor/script_templates/Object/empty.gd (renamed from modules/gdscript/editor_templates/Object/empty.gd)0
-rw-r--r--modules/gdscript/editor/script_templates/SCsub (renamed from modules/gdscript/editor_templates/SCsub)0
-rw-r--r--modules/gdscript/editor/script_templates/VisualShaderNodeCustom/basic.gd (renamed from modules/gdscript/editor_templates/VisualShaderNodeCustom/basic.gd)0
-rw-r--r--modules/gdscript/gdscript.h4
-rw-r--r--modules/gdscript/gdscript_editor.cpp320
-rw-r--r--modules/gdscript/language_server/gdscript_text_document.cpp26
-rw-r--r--modules/gdscript/language_server/gdscript_workspace.cpp4
-rw-r--r--modules/gdscript/language_server/gdscript_workspace.h2
-rw-r--r--modules/gltf/SCsub3
-rw-r--r--modules/gltf/config.py7
-rw-r--r--modules/gltf/doc_classes/EditorSceneFormatImporterBlend.xml15
-rw-r--r--modules/gltf/doc_classes/EditorSceneFormatImporterGLTF.xml9
-rw-r--r--modules/gltf/doc_classes/GLTFDocument.xml1
-rw-r--r--modules/gltf/editor/editor_scene_exporter_gltf_plugin.cpp (renamed from modules/gltf/editor_scene_exporter_gltf_plugin.cpp)11
-rw-r--r--modules/gltf/editor/editor_scene_exporter_gltf_plugin.h (renamed from modules/gltf/editor_scene_exporter_gltf_plugin.h)5
-rw-r--r--modules/gltf/editor/editor_scene_importer_blend.cpp268
-rw-r--r--modules/gltf/editor/editor_scene_importer_blend.h75
-rw-r--r--modules/gltf/editor/editor_scene_importer_gltf.cpp (renamed from modules/gltf/editor_scene_importer_gltf.cpp)27
-rw-r--r--modules/gltf/editor/editor_scene_importer_gltf.h (renamed from modules/gltf/editor_scene_importer_gltf.h)17
-rw-r--r--modules/gltf/gltf_document.cpp30
-rw-r--r--modules/gltf/gltf_document.h2
-rw-r--r--modules/gltf/gltf_mesh.h1
-rw-r--r--modules/gltf/register_types.cpp80
-rw-r--r--modules/gridmap/SCsub3
-rw-r--r--modules/gridmap/editor/grid_map_editor_plugin.cpp (renamed from modules/gridmap/grid_map_editor_plugin.cpp)8
-rw-r--r--modules/gridmap/editor/grid_map_editor_plugin.h (renamed from modules/gridmap/grid_map_editor_plugin.h)8
-rw-r--r--modules/gridmap/register_types.cpp12
-rw-r--r--modules/lightmapper_rd/lightmapper_rd.cpp29
-rw-r--r--modules/mono/SCsub3
-rw-r--r--modules/mono/csharp_script.cpp8
-rw-r--r--modules/mono/csharp_script.h4
-rw-r--r--modules/mono/editor/script_templates/CharacterBody2D/basic_movement.cs (renamed from modules/mono/editor_templates/CharacterBody2D/basic_movement.cs)0
-rw-r--r--modules/mono/editor/script_templates/CharacterBody3D/basic_movement.cs (renamed from modules/mono/editor_templates/CharacterBody3D/basic_movement.cs)0
-rw-r--r--modules/mono/editor/script_templates/EditorPlugin/plugin.cs (renamed from modules/mono/editor_templates/EditorPlugin/plugin.cs)0
-rw-r--r--modules/mono/editor/script_templates/EditorScript/basic_editor_script.cs (renamed from modules/mono/editor_templates/EditorScript/basic_editor_script.cs)0
-rw-r--r--modules/mono/editor/script_templates/Node/default.cs (renamed from modules/mono/editor_templates/Node/default.cs)0
-rw-r--r--modules/mono/editor/script_templates/Object/empty.cs (renamed from modules/mono/editor_templates/Object/empty.cs)0
-rw-r--r--modules/mono/editor/script_templates/SCsub (renamed from modules/mono/editor_templates/SCsub)0
-rw-r--r--modules/mono/editor/script_templates/VisualShaderNodeCustom/basic.cs (renamed from modules/mono/editor_templates/VisualShaderNodeCustom/basic.cs)0
-rw-r--r--modules/navigation/SCsub2
-rw-r--r--modules/navigation/editor/navigation_mesh_editor_plugin.cpp (renamed from modules/navigation/navigation_mesh_editor_plugin.cpp)7
-rw-r--r--modules/navigation/editor/navigation_mesh_editor_plugin.h (renamed from modules/navigation/navigation_mesh_editor_plugin.h)4
-rw-r--r--modules/navigation/register_types.cpp2
-rw-r--r--modules/noise/SCsub (renamed from modules/opensimplex/SCsub)12
-rw-r--r--modules/noise/config.py (renamed from modules/opensimplex/config.py)3
-rw-r--r--modules/noise/doc_classes/FastNoiseLite.xml169
-rw-r--r--modules/noise/doc_classes/Noise.xml72
-rw-r--r--modules/noise/doc_classes/NoiseTexture.xml (renamed from modules/opensimplex/doc_classes/NoiseTexture.xml)23
-rw-r--r--modules/noise/fastnoise_lite.cpp577
-rw-r--r--modules/noise/fastnoise_lite.h237
-rw-r--r--modules/noise/icons/NoiseTexture.svg (renamed from modules/opensimplex/icons/NoiseTexture.svg)0
-rw-r--r--modules/noise/noise.cpp68
-rw-r--r--modules/noise/noise.h239
-rw-r--r--modules/noise/noise_texture.cpp (renamed from modules/opensimplex/noise_texture.cpp)57
-rw-r--r--modules/noise/noise_texture.h (renamed from modules/opensimplex/noise_texture.h)19
-rw-r--r--modules/noise/register_types.cpp (renamed from modules/opensimplex/register_types.cpp)11
-rw-r--r--modules/noise/register_types.h (renamed from modules/opensimplex/register_types.h)10
-rw-r--r--modules/opensimplex/doc_classes/OpenSimplexNoise.xml112
-rw-r--r--modules/opensimplex/open_simplex_noise.cpp250
-rw-r--r--modules/opensimplex/open_simplex_noise.h99
-rw-r--r--modules/openxr/openxr_api.cpp26
-rw-r--r--modules/openxr/openxr_api.h1
-rw-r--r--modules/openxr/register_types.cpp1
-rw-r--r--modules/svg/register_types.cpp2
-rw-r--r--modules/text_server_adv/SCsub78
-rw-r--r--modules/text_server_fb/SCsub18
-rw-r--r--modules/visual_script/visual_script.h4
-rw-r--r--modules/websocket/SCsub2
-rw-r--r--modules/websocket/editor/editor_debugger_server_websocket.cpp (renamed from modules/websocket/editor_debugger_server_websocket.cpp)6
-rw-r--r--modules/websocket/editor/editor_debugger_server_websocket.h (renamed from modules/websocket/editor_debugger_server_websocket.h)6
-rw-r--r--modules/websocket/register_types.cpp5
-rw-r--r--modules/websocket/remote_debugger_peer_websocket.h7
85 files changed, 2205 insertions, 974 deletions
diff --git a/modules/basis_universal/SCsub b/modules/basis_universal/SCsub
index a3bd85089d..a44a7f0db3 100644
--- a/modules/basis_universal/SCsub
+++ b/modules/basis_universal/SCsub
@@ -13,7 +13,6 @@ thirdparty_obj = []
thirdparty_dir = "#thirdparty/basis_universal/"
# Sync list with upstream CMakeLists.txt
encoder_sources = [
- "basisu_uastc_enc.cpp",
"basisu_backend.cpp",
"basisu_basis_file.cpp",
"basisu_bc7enc.cpp",
diff --git a/modules/csg/SCsub b/modules/csg/SCsub
index 641a42c187..c7307ddefd 100644
--- a/modules/csg/SCsub
+++ b/modules/csg/SCsub
@@ -3,7 +3,10 @@
Import("env")
Import("env_modules")
+# Godot's own source files
env_csg = env_modules.Clone()
# Godot's own source files
env_csg.add_source_files(env.modules_sources, "*.cpp")
+if env["tools"]:
+ env_csg.add_source_files(env.modules_sources, "editor/*.cpp")
diff --git a/modules/csg/csg_gizmos.cpp b/modules/csg/editor/csg_gizmos.cpp
index 95a0fc7ada..be29810252 100644
--- a/modules/csg/csg_gizmos.cpp
+++ b/modules/csg/editor/csg_gizmos.cpp
@@ -30,6 +30,8 @@
#include "csg_gizmos.h"
+#ifdef TOOLS_ENABLED
+
#include "editor/editor_settings.h"
#include "editor/plugins/node_3d_editor_plugin.h"
#include "scene/3d/camera_3d.h"
@@ -425,3 +427,5 @@ EditorPluginCSG::EditorPluginCSG() {
Ref<CSGShape3DGizmoPlugin> gizmo_plugin = Ref<CSGShape3DGizmoPlugin>(memnew(CSGShape3DGizmoPlugin));
Node3DEditor::get_singleton()->add_gizmo_plugin(gizmo_plugin);
}
+
+#endif // TOOLS_ENABLED
diff --git a/modules/csg/csg_gizmos.h b/modules/csg/editor/csg_gizmos.h
index 43efe57e64..fa51010f98 100644
--- a/modules/csg/csg_gizmos.h
+++ b/modules/csg/editor/csg_gizmos.h
@@ -31,7 +31,9 @@
#ifndef CSG_GIZMOS_H
#define CSG_GIZMOS_H
-#include "csg_shape.h"
+#ifdef TOOLS_ENABLED
+
+#include "../csg_shape.h"
#include "editor/editor_plugin.h"
#include "editor/plugins/node_3d_editor_gizmos.h"
@@ -60,4 +62,6 @@ public:
EditorPluginCSG();
};
+#endif // TOOLS_ENABLED
+
#endif // CSG_GIZMOS_H
diff --git a/modules/csg/register_types.cpp b/modules/csg/register_types.cpp
index f8db42b1a9..72ed027dc9 100644
--- a/modules/csg/register_types.cpp
+++ b/modules/csg/register_types.cpp
@@ -30,12 +30,15 @@
#include "register_types.h"
-#include "csg_gizmos.h"
+#ifndef _3D_DISABLED
+
#include "csg_shape.h"
-void register_csg_types() {
-#ifndef _3D_DISABLED
+#ifdef TOOLS_ENABLED
+#include "editor/csg_gizmos.h"
+#endif
+void register_csg_types() {
GDREGISTER_ABSTRACT_CLASS(CSGShape3D);
GDREGISTER_ABSTRACT_CLASS(CSGPrimitive3D);
GDREGISTER_CLASS(CSGMesh3D);
@@ -49,8 +52,9 @@ void register_csg_types() {
#ifdef TOOLS_ENABLED
EditorPlugins::add_by_type<EditorPluginCSG>();
#endif
-#endif
}
void unregister_csg_types() {
}
+
+#endif // _3D_DISABLED
diff --git a/modules/fbx/editor_scene_importer_fbx.cpp b/modules/fbx/editor_scene_importer_fbx.cpp
index 758c47eecc..afaeb15708 100644
--- a/modules/fbx/editor_scene_importer_fbx.cpp
+++ b/modules/fbx/editor_scene_importer_fbx.cpp
@@ -58,24 +58,8 @@
void EditorSceneFormatImporterFBX::get_extensions(List<String> *r_extensions) const {
// register FBX as the one and only format for FBX importing
- const String import_setting_string = "filesystem/import/fbx/";
- const String fbx_str = "fbx";
- Vector<String> exts;
- exts.push_back(fbx_str);
- _register_project_setting_import(fbx_str, import_setting_string, exts, r_extensions, true);
-}
-
-void EditorSceneFormatImporterFBX::_register_project_setting_import(const String generic,
- const String import_setting_string,
- const Vector<String> &exts,
- List<String> *r_extensions,
- const bool p_enabled) const {
- const String use_generic = "use_" + generic;
- _GLOBAL_DEF(import_setting_string + use_generic, p_enabled, true);
- if (ProjectSettings::get_singleton()->get(import_setting_string + use_generic)) {
- for (int32_t i = 0; i < exts.size(); i++) {
- r_extensions->push_back(exts[i]);
- }
+ if (GLOBAL_GET("filesystem/import/fbx/use_fbx")) {
+ r_extensions->push_back("fbx");
}
}
@@ -964,7 +948,7 @@ Node3D *EditorSceneFormatImporterFBX::_generate_scene(
// extra const required by C++11 colon/Range operator
// note: do not use C++17 syntax here for dicts.
// this is banned in Godot.
- for (std::pair<const std::string, const FBXDocParser::AnimationCurve *> &kvp : curves) {
+ for (const std::pair<const std::string, const FBXDocParser::AnimationCurve *> &kvp : curves) {
const String curve_element = ImportUtils::FBXNodeToName(kvp.first);
const FBXDocParser::AnimationCurve *curve = kvp.second;
String curve_name = ImportUtils::FBXNodeToName(curve->Name());
@@ -980,7 +964,7 @@ Node3D *EditorSceneFormatImporterFBX::_generate_scene(
const std::map<int64_t, float> &track_time = curve->GetValueTimeTrack();
if (track_time.size() > 0) {
- for (std::pair<int64_t, float> keyframe : track_time) {
+ for (const std::pair<const int64_t, float> &keyframe : track_time) {
if (curve_element == "d|X") {
keyframe_map.keyframes[keyframe.first].x = keyframe.second;
} else if (curve_element == "d|Y") {
@@ -1089,7 +1073,7 @@ Node3D *EditorSceneFormatImporterFBX::_generate_scene(
double max_duration = 0;
double anim_length = animation->get_length();
- for (std::pair<int64_t, Vector3> position_key : translation_keys.keyframes) {
+ for (const std::pair<const int64_t, Vector3> &position_key : translation_keys.keyframes) {
pos_values.push_back(position_key.second * state.scale);
double animation_track_time = CONVERT_FBX_TIME(position_key.first);
@@ -1101,7 +1085,7 @@ Node3D *EditorSceneFormatImporterFBX::_generate_scene(
pos_times.push_back(animation_track_time);
}
- for (std::pair<int64_t, Vector3> scale_key : scale_keys.keyframes) {
+ for (const std::pair<const int64_t, Vector3> &scale_key : scale_keys.keyframes) {
scale_values.push_back(scale_key.second);
double animation_track_time = CONVERT_FBX_TIME(scale_key.first);
@@ -1136,7 +1120,7 @@ Node3D *EditorSceneFormatImporterFBX::_generate_scene(
Quaternion lastQuaternion = Quaternion();
- for (std::pair<int64_t, Vector3> rotation_key : rotation_keys.keyframes) {
+ for (const std::pair<const int64_t, Vector3> &rotation_key : rotation_keys.keyframes) {
double animation_track_time = CONVERT_FBX_TIME(rotation_key.first);
//print_verbose("euler rotation key: " + rotation_key.second);
@@ -1473,3 +1457,7 @@ Ref<Animation> EditorSceneFormatImporterFBX::import_animation(const String &p_pa
int p_bake_fps) {
return Ref<Animation>();
}
+
+EditorSceneFormatImporterFBX::EditorSceneFormatImporterFBX() {
+ _GLOBAL_DEF("filesystem/import/fbx/use_fbx", true, true);
+}
diff --git a/modules/fbx/editor_scene_importer_fbx.h b/modules/fbx/editor_scene_importer_fbx.h
index eebcb86409..fb72f93feb 100644
--- a/modules/fbx/editor_scene_importer_fbx.h
+++ b/modules/fbx/editor_scene_importer_fbx.h
@@ -119,10 +119,9 @@ private:
template <class T>
T _interpolate_track(const Vector<float> &p_times, const Vector<T> &p_values, float p_time, AssetImportAnimation::Interpolation p_interp);
- void _register_project_setting_import(const String generic, const String import_setting_string, const Vector<String> &exts, List<String> *r_extensions, const bool p_enabled) const;
public:
- EditorSceneFormatImporterFBX() {}
+ EditorSceneFormatImporterFBX();
~EditorSceneFormatImporterFBX() {}
virtual void get_extensions(List<String> *r_extensions) const override;
diff --git a/modules/gdscript/SCsub b/modules/gdscript/SCsub
index c6121ec7fe..2f507db548 100644
--- a/modules/gdscript/SCsub
+++ b/modules/gdscript/SCsub
@@ -10,6 +10,8 @@ env_gdscript.add_source_files(env.modules_sources, "*.cpp")
if env["tools"]:
env_gdscript.add_source_files(env.modules_sources, "./editor/*.cpp")
+ SConscript("editor/script_templates/SCsub")
+
# Those two modules are required for the language server protocol
if env["module_jsonrpc_enabled"] and env["module_websocket_enabled"]:
env_gdscript.add_source_files(env.modules_sources, "./language_server/*.cpp")
@@ -18,8 +20,7 @@ if env["tools"]:
# in regular builds where all modules are enabled.
env_gdscript.Append(CPPDEFINES=["GDSCRIPT_NO_LSP"])
+
if env["tests"]:
env_gdscript.Append(CPPDEFINES=["TESTS_ENABLED"])
env_gdscript.add_source_files(env.modules_sources, "./tests/*.cpp")
-
-SConscript("editor_templates/SCsub")
diff --git a/modules/gdscript/editor_templates/CharacterBody2D/basic_movement.gd b/modules/gdscript/editor/script_templates/CharacterBody2D/basic_movement.gd
index a379d915a9..a379d915a9 100644
--- a/modules/gdscript/editor_templates/CharacterBody2D/basic_movement.gd
+++ b/modules/gdscript/editor/script_templates/CharacterBody2D/basic_movement.gd
diff --git a/modules/gdscript/editor_templates/CharacterBody3D/basic_movement.gd b/modules/gdscript/editor/script_templates/CharacterBody3D/basic_movement.gd
index 360b199e56..360b199e56 100644
--- a/modules/gdscript/editor_templates/CharacterBody3D/basic_movement.gd
+++ b/modules/gdscript/editor/script_templates/CharacterBody3D/basic_movement.gd
diff --git a/modules/gdscript/editor_templates/EditorPlugin/plugin.gd b/modules/gdscript/editor/script_templates/EditorPlugin/plugin.gd
index b27b3e5655..b27b3e5655 100644
--- a/modules/gdscript/editor_templates/EditorPlugin/plugin.gd
+++ b/modules/gdscript/editor/script_templates/EditorPlugin/plugin.gd
diff --git a/modules/gdscript/editor_templates/EditorScript/basic_editor_script.gd b/modules/gdscript/editor/script_templates/EditorScript/basic_editor_script.gd
index fdb8550d43..fdb8550d43 100644
--- a/modules/gdscript/editor_templates/EditorScript/basic_editor_script.gd
+++ b/modules/gdscript/editor/script_templates/EditorScript/basic_editor_script.gd
diff --git a/modules/gdscript/editor_templates/Node/default.gd b/modules/gdscript/editor/script_templates/Node/default.gd
index cb96a21537..cb96a21537 100644
--- a/modules/gdscript/editor_templates/Node/default.gd
+++ b/modules/gdscript/editor/script_templates/Node/default.gd
diff --git a/modules/gdscript/editor_templates/Object/empty.gd b/modules/gdscript/editor/script_templates/Object/empty.gd
index 387786b0a4..387786b0a4 100644
--- a/modules/gdscript/editor_templates/Object/empty.gd
+++ b/modules/gdscript/editor/script_templates/Object/empty.gd
diff --git a/modules/gdscript/editor_templates/SCsub b/modules/gdscript/editor/script_templates/SCsub
index 2266ef2d01..2266ef2d01 100644
--- a/modules/gdscript/editor_templates/SCsub
+++ b/modules/gdscript/editor/script_templates/SCsub
diff --git a/modules/gdscript/editor_templates/VisualShaderNodeCustom/basic.gd b/modules/gdscript/editor/script_templates/VisualShaderNodeCustom/basic.gd
index 283a95d3b4..283a95d3b4 100644
--- a/modules/gdscript/editor_templates/VisualShaderNodeCustom/basic.gd
+++ b/modules/gdscript/editor/script_templates/VisualShaderNodeCustom/basic.gd
diff --git a/modules/gdscript/gdscript.h b/modules/gdscript/gdscript.h
index 30e60e2b91..f7fa967883 100644
--- a/modules/gdscript/gdscript.h
+++ b/modules/gdscript/gdscript.h
@@ -212,7 +212,7 @@ public:
virtual void update_exports() override;
#ifdef TOOLS_ENABLED
- virtual const Vector<DocData::ClassDoc> &get_documentation() const override {
+ virtual Vector<DocData::ClassDoc> get_documentation() const override {
return docs;
}
#endif // TOOLS_ENABLED
@@ -455,7 +455,7 @@ public:
virtual bool can_inherit_from_file() const override { return true; }
virtual int find_function(const String &p_function, const String &p_code) const override;
virtual String make_function(const String &p_class, const String &p_name, const PackedStringArray &p_args) const override;
- virtual Error complete_code(const String &p_code, const String &p_path, Object *p_owner, List<ScriptCodeCompletionOption> *r_options, bool &r_forced, String &r_call_hint) override;
+ virtual Error complete_code(const String &p_code, const String &p_path, Object *p_owner, List<ScriptLanguage::CodeCompletionOption> *r_options, bool &r_forced, String &r_call_hint) override;
#ifdef TOOLS_ENABLED
virtual Error lookup_code(const String &p_code, const String &p_symbol, const String &p_path, Object *p_owner, LookupResult &r_result) override;
#endif
diff --git a/modules/gdscript/gdscript_editor.cpp b/modules/gdscript/gdscript_editor.cpp
index 2cc178edc8..fd8fcea7b3 100644
--- a/modules/gdscript/gdscript_editor.cpp
+++ b/modules/gdscript/gdscript_editor.cpp
@@ -33,7 +33,6 @@
#include "core/config/engine.h"
#include "core/core_constants.h"
#include "core/io/file_access.h"
-#include "editor_templates/templates.gen.h"
#include "gdscript_analyzer.h"
#include "gdscript_compiler.h"
#include "gdscript_parser.h"
@@ -44,6 +43,7 @@
#include "core/config/project_settings.h"
#include "editor/editor_file_system.h"
#include "editor/editor_settings.h"
+#include "editor/script_templates/templates.gen.h"
#endif
void GDScriptLanguage::get_comment_delimiters(List<String> *p_delimiters) const {
@@ -64,8 +64,11 @@ Ref<Script> GDScriptLanguage::make_template(const String &p_template, const Stri
Ref<GDScript> script;
script.instantiate();
String processed_template = p_template;
+ bool type_hints = false;
#ifdef TOOLS_ENABLED
- if (!EDITOR_GET("text_editor/completion/add_type_hints")) {
+ type_hints = EDITOR_GET("text_editor/completion/add_type_hints");
+#endif
+ if (!type_hints) {
processed_template = processed_template.replace(": int", "")
.replace(": String", "")
.replace(": Array[String]", "")
@@ -75,16 +78,6 @@ Ref<Script> GDScriptLanguage::make_template(const String &p_template, const Stri
.replace(" -> int", "")
.replace(" -> void", "");
}
-#else
- processed_template = processed_template.replace(": int", "")
- .replace(": String", "")
- .replace(": Array[String]", "")
- .replace(": float", "")
- .replace(":=", "=")
- .replace(" -> String", "")
- .replace(" -> int", "")
- .replace(" -> void", "");
-#endif
processed_template = processed_template.replace("_BASE_", p_base_class_name)
.replace("_CLASS_", p_class_name)
@@ -95,11 +88,13 @@ Ref<Script> GDScriptLanguage::make_template(const String &p_template, const Stri
Vector<ScriptLanguage::ScriptTemplate> GDScriptLanguage::get_built_in_templates(StringName p_object) {
Vector<ScriptLanguage::ScriptTemplate> templates;
+#ifdef TOOLS_ENABLED
for (int i = 0; i < TEMPLATES_ARRAY_SIZE; i++) {
if (TEMPLATES[i].inherit == p_object) {
templates.append(TEMPLATES[i]);
}
}
+#endif
return templates;
}
@@ -490,89 +485,6 @@ struct GDScriptCompletionIdentifier {
const GDScriptParser::ExpressionNode *assigned_expression = nullptr;
};
-// LOCATION METHODS
-// These methods are used to populate the `ScriptCodeCompletionOption::location` integer.
-// For these methods, the location is based on the depth in the inheritance chain that the property
-// appears. For example, if you are completing code in a class that inherits Node2D, a property found on Node2D
-// will have a "better" (lower) location "score" than a property that is found on CanvasItem.
-
-static int _get_property_location(StringName p_class, StringName p_property) {
- if (!ClassDB::has_property(p_class, p_property)) {
- return ScriptCodeCompletionOption::LOCATION_OTHER;
- }
-
- int depth = 0;
- StringName class_test = p_class;
- while (class_test && !ClassDB::has_property(class_test, p_property, true)) {
- class_test = ClassDB::get_parent_class(class_test);
- depth++;
- }
-
- return depth | ScriptCodeCompletionOption::LOCATION_PARENT_MASK;
-}
-
-static int _get_constant_location(StringName p_class, StringName p_constant) {
- if (!ClassDB::has_integer_constant(p_class, p_constant)) {
- return ScriptCodeCompletionOption::LOCATION_OTHER;
- }
-
- int depth = 0;
- StringName class_test = p_class;
- while (class_test && !ClassDB::has_integer_constant(class_test, p_constant, true)) {
- class_test = ClassDB::get_parent_class(class_test);
- depth++;
- }
-
- return depth | ScriptCodeCompletionOption::LOCATION_PARENT_MASK;
-}
-
-static int _get_signal_location(StringName p_class, StringName p_signal) {
- if (!ClassDB::has_signal(p_class, p_signal)) {
- return ScriptCodeCompletionOption::LOCATION_OTHER;
- }
-
- int depth = 0;
- StringName class_test = p_class;
- while (class_test && !ClassDB::has_signal(class_test, p_signal, true)) {
- class_test = ClassDB::get_parent_class(class_test);
- depth++;
- }
-
- return depth | ScriptCodeCompletionOption::LOCATION_PARENT_MASK;
-}
-
-static int _get_method_location(StringName p_class, StringName p_method) {
- if (!ClassDB::has_method(p_class, p_method)) {
- return ScriptCodeCompletionOption::LOCATION_OTHER;
- }
-
- int depth = 0;
- StringName class_test = p_class;
- while (class_test && !ClassDB::has_method(class_test, p_method, true)) {
- class_test = ClassDB::get_parent_class(class_test);
- depth++;
- }
-
- return depth | ScriptCodeCompletionOption::LOCATION_PARENT_MASK;
-}
-
-static int _get_enum_constant_location(StringName p_class, StringName p_enum_constant) {
- if (!ClassDB::get_integer_constant_enum(p_class, p_enum_constant)) {
- return ScriptCodeCompletionOption::LOCATION_OTHER;
- }
-
- int depth = 0;
- StringName class_test = p_class;
- while (class_test && !ClassDB::get_integer_constant_enum(class_test, p_enum_constant, true)) {
- class_test = ClassDB::get_parent_class(class_test);
- depth++;
- }
-
- return depth | ScriptCodeCompletionOption::LOCATION_PARENT_MASK;
-}
-
-// END LOCATION METHODS
-
static String _get_visual_datatype(const PropertyInfo &p_info, bool p_is_arg = true) {
if (p_info.usage & PROPERTY_USAGE_CLASS_IS_ENUM) {
String enum_name = p_info.class_name;
@@ -727,11 +639,11 @@ static String _make_arguments_hint(const GDScriptParser::FunctionNode *p_functio
return arghint;
}
-static void _get_directory_contents(EditorFileSystemDirectory *p_dir, Map<String, ScriptCodeCompletionOption> &r_list) {
+static void _get_directory_contents(EditorFileSystemDirectory *p_dir, Map<String, ScriptLanguage::CodeCompletionOption> &r_list) {
const String quote_style = EDITOR_GET("text_editor/completion/use_single_quotes") ? "'" : "\"";
for (int i = 0; i < p_dir->get_file_count(); i++) {
- ScriptCodeCompletionOption option(p_dir->get_file_path(i), ScriptCodeCompletionOption::KIND_FILE_PATH);
+ ScriptLanguage::CodeCompletionOption option(p_dir->get_file_path(i), ScriptLanguage::CODE_COMPLETION_KIND_FILE_PATH);
option.insert_text = option.display.quote(quote_style);
r_list.insert(option.display, option);
}
@@ -741,29 +653,29 @@ static void _get_directory_contents(EditorFileSystemDirectory *p_dir, Map<String
}
}
-static void _find_annotation_arguments(const GDScriptParser::AnnotationNode *p_annotation, int p_argument, const String p_quote_style, Map<String, ScriptCodeCompletionOption> &r_result) {
+static void _find_annotation_arguments(const GDScriptParser::AnnotationNode *p_annotation, int p_argument, const String p_quote_style, Map<String, ScriptLanguage::CodeCompletionOption> &r_result) {
if (p_annotation->name == SNAME("@export_range")) {
if (p_argument == 3 || p_argument == 4) {
// Slider hint.
- ScriptCodeCompletionOption slider1("or_greater", ScriptCodeCompletionOption::KIND_PLAIN_TEXT);
+ ScriptLanguage::CodeCompletionOption slider1("or_greater", ScriptLanguage::CODE_COMPLETION_KIND_PLAIN_TEXT);
slider1.insert_text = slider1.display.quote(p_quote_style);
r_result.insert(slider1.display, slider1);
- ScriptCodeCompletionOption slider2("or_lesser", ScriptCodeCompletionOption::KIND_PLAIN_TEXT);
+ ScriptLanguage::CodeCompletionOption slider2("or_lesser", ScriptLanguage::CODE_COMPLETION_KIND_PLAIN_TEXT);
slider2.insert_text = slider2.display.quote(p_quote_style);
r_result.insert(slider2.display, slider2);
}
} else if (p_annotation->name == SNAME("@export_exp_easing")) {
if (p_argument == 0 || p_argument == 1) {
// Easing hint.
- ScriptCodeCompletionOption hint1("attenuation", ScriptCodeCompletionOption::KIND_PLAIN_TEXT);
+ ScriptLanguage::CodeCompletionOption hint1("attenuation", ScriptLanguage::CODE_COMPLETION_KIND_PLAIN_TEXT);
hint1.insert_text = hint1.display.quote(p_quote_style);
r_result.insert(hint1.display, hint1);
- ScriptCodeCompletionOption hint2("inout", ScriptCodeCompletionOption::KIND_PLAIN_TEXT);
+ ScriptLanguage::CodeCompletionOption hint2("inout", ScriptLanguage::CODE_COMPLETION_KIND_PLAIN_TEXT);
hint2.insert_text = hint2.display.quote(p_quote_style);
r_result.insert(hint2.display, hint2);
}
} else if (p_annotation->name == SNAME("@export_node_path")) {
- ScriptCodeCompletionOption node("Node", ScriptCodeCompletionOption::KIND_CLASS);
+ ScriptLanguage::CodeCompletionOption node("Node", ScriptLanguage::CODE_COMPLETION_KIND_CLASS);
r_result.insert(node.display, node);
List<StringName> node_types;
ClassDB::get_inheriters_from_class("Node", &node_types);
@@ -771,23 +683,23 @@ static void _find_annotation_arguments(const GDScriptParser::AnnotationNode *p_a
if (!ClassDB::is_class_exposed(E)) {
continue;
}
- ScriptCodeCompletionOption option(E, ScriptCodeCompletionOption::KIND_CLASS);
+ ScriptLanguage::CodeCompletionOption option(E, ScriptLanguage::CODE_COMPLETION_KIND_CLASS);
r_result.insert(option.display, option);
}
} else if (p_annotation->name == SNAME("@warning_ignore")) {
for (int warning_code = 0; warning_code < GDScriptWarning::WARNING_MAX; warning_code++) {
- ScriptCodeCompletionOption warning(GDScriptWarning::get_name_from_code((GDScriptWarning::Code)warning_code).to_lower(), ScriptCodeCompletionOption::KIND_PLAIN_TEXT);
+ ScriptLanguage::CodeCompletionOption warning(GDScriptWarning::get_name_from_code((GDScriptWarning::Code)warning_code).to_lower(), ScriptLanguage::CODE_COMPLETION_KIND_PLAIN_TEXT);
r_result.insert(warning.display, warning);
}
}
}
-static void _list_available_types(bool p_inherit_only, GDScriptParser::CompletionContext &p_context, Map<String, ScriptCodeCompletionOption> &r_result) {
+static void _list_available_types(bool p_inherit_only, GDScriptParser::CompletionContext &p_context, Map<String, ScriptLanguage::CodeCompletionOption> &r_result) {
List<StringName> native_types;
ClassDB::get_class_list(&native_types);
for (const StringName &E : native_types) {
if (ClassDB::is_class_exposed(E) && !Engine::get_singleton()->has_singleton(E)) {
- ScriptCodeCompletionOption option(E, ScriptCodeCompletionOption::KIND_CLASS);
+ ScriptLanguage::CodeCompletionOption option(E, ScriptLanguage::CODE_COMPLETION_KIND_CLASS);
r_result.insert(option.display, option);
}
}
@@ -798,7 +710,7 @@ static void _list_available_types(bool p_inherit_only, GDScriptParser::Completio
List<StringName> enums;
ClassDB::get_enum_list(p_context.current_class->base_type.native_type, &enums);
for (const StringName &E : enums) {
- ScriptCodeCompletionOption option(E, ScriptCodeCompletionOption::KIND_ENUM);
+ ScriptLanguage::CodeCompletionOption option(E, ScriptLanguage::CODE_COMPLETION_KIND_ENUM);
r_result.insert(option.display, option);
}
}
@@ -809,18 +721,18 @@ static void _list_available_types(bool p_inherit_only, GDScriptParser::Completio
const GDScriptParser::ClassNode::Member &member = current->members[i];
switch (member.type) {
case GDScriptParser::ClassNode::Member::CLASS: {
- ScriptCodeCompletionOption option(member.m_class->identifier->name, ScriptCodeCompletionOption::KIND_CLASS, ScriptCodeCompletionOption::LOCATION_LOCAL);
+ ScriptLanguage::CodeCompletionOption option(member.m_class->identifier->name, ScriptLanguage::CODE_COMPLETION_KIND_CLASS);
r_result.insert(option.display, option);
} break;
case GDScriptParser::ClassNode::Member::ENUM: {
if (!p_inherit_only) {
- ScriptCodeCompletionOption option(member.m_enum->identifier->name, ScriptCodeCompletionOption::KIND_ENUM, ScriptCodeCompletionOption::LOCATION_LOCAL);
+ ScriptLanguage::CodeCompletionOption option(member.m_enum->identifier->name, ScriptLanguage::CODE_COMPLETION_KIND_ENUM);
r_result.insert(option.display, option);
}
} break;
case GDScriptParser::ClassNode::Member::CONSTANT: {
if (member.constant->get_datatype().is_meta_type && p_context.current_class->outer != nullptr) {
- ScriptCodeCompletionOption option(member.constant->identifier->name, ScriptCodeCompletionOption::KIND_CLASS, ScriptCodeCompletionOption::LOCATION_LOCAL);
+ ScriptLanguage::CodeCompletionOption option(member.constant->identifier->name, ScriptLanguage::CODE_COMPLETION_KIND_CLASS);
r_result.insert(option.display, option);
}
} break;
@@ -836,7 +748,7 @@ static void _list_available_types(bool p_inherit_only, GDScriptParser::Completio
List<StringName> global_classes;
ScriptServer::get_global_class_list(&global_classes);
for (const StringName &E : global_classes) {
- ScriptCodeCompletionOption option(E, ScriptCodeCompletionOption::KIND_CLASS, ScriptCodeCompletionOption::LOCATION_OTHER_USER_CODE);
+ ScriptLanguage::CodeCompletionOption option(E, ScriptLanguage::CODE_COMPLETION_KIND_CLASS);
r_result.insert(option.display, option);
}
@@ -847,19 +759,19 @@ static void _list_available_types(bool p_inherit_only, GDScriptParser::Completio
if (!info.is_singleton || info.path.get_extension().to_lower() != "gd") {
continue;
}
- ScriptCodeCompletionOption option(info.name, ScriptCodeCompletionOption::KIND_CLASS, ScriptCodeCompletionOption::LOCATION_OTHER_USER_CODE);
+ ScriptLanguage::CodeCompletionOption option(info.name, ScriptLanguage::CODE_COMPLETION_KIND_CLASS);
r_result.insert(option.display, option);
}
}
-static void _find_identifiers_in_suite(const GDScriptParser::SuiteNode *p_suite, Map<String, ScriptCodeCompletionOption> &r_result) {
+static void _find_identifiers_in_suite(const GDScriptParser::SuiteNode *p_suite, Map<String, ScriptLanguage::CodeCompletionOption> &r_result) {
for (int i = 0; i < p_suite->locals.size(); i++) {
- ScriptCodeCompletionOption option;
+ ScriptLanguage::CodeCompletionOption option;
if (p_suite->locals[i].type == GDScriptParser::SuiteNode::Local::CONSTANT) {
- option = ScriptCodeCompletionOption(p_suite->locals[i].name, ScriptCodeCompletionOption::KIND_CONSTANT, ScriptCodeCompletionOption::LOCATION_LOCAL);
+ option = ScriptLanguage::CodeCompletionOption(p_suite->locals[i].name, ScriptLanguage::CODE_COMPLETION_KIND_CONSTANT);
option.default_value = p_suite->locals[i].constant->initializer->reduced_value;
} else {
- option = ScriptCodeCompletionOption(p_suite->locals[i].name, ScriptCodeCompletionOption::KIND_VARIABLE, ScriptCodeCompletionOption::LOCATION_LOCAL);
+ option = ScriptLanguage::CodeCompletionOption(p_suite->locals[i].name, ScriptLanguage::CODE_COMPLETION_KIND_VARIABLE);
}
r_result.insert(option.display, option);
}
@@ -868,26 +780,24 @@ static void _find_identifiers_in_suite(const GDScriptParser::SuiteNode *p_suite,
}
}
-static void _find_identifiers_in_base(const GDScriptCompletionIdentifier &p_base, bool p_only_functions, Map<String, ScriptCodeCompletionOption> &r_result, int p_recursion_depth);
+static void _find_identifiers_in_base(const GDScriptCompletionIdentifier &p_base, bool p_only_functions, Map<String, ScriptLanguage::CodeCompletionOption> &r_result, int p_recursion_depth);
-static void _find_identifiers_in_class(const GDScriptParser::ClassNode *p_class, bool p_only_functions, bool p_static, bool p_parent_only, Map<String, ScriptCodeCompletionOption> &r_result, int p_recursion_depth) {
+static void _find_identifiers_in_class(const GDScriptParser::ClassNode *p_class, bool p_only_functions, bool p_static, bool p_parent_only, Map<String, ScriptLanguage::CodeCompletionOption> &r_result, int p_recursion_depth) {
ERR_FAIL_COND(p_recursion_depth > COMPLETION_RECURSION_LIMIT);
if (!p_parent_only) {
bool outer = false;
const GDScriptParser::ClassNode *clss = p_class;
- int classes_processed = 0;
while (clss) {
for (int i = 0; i < clss->members.size(); i++) {
- const int location = (classes_processed + p_recursion_depth) | ScriptCodeCompletionOption::LOCATION_PARENT_MASK;
const GDScriptParser::ClassNode::Member &member = clss->members[i];
- ScriptCodeCompletionOption option;
+ ScriptLanguage::CodeCompletionOption option;
switch (member.type) {
case GDScriptParser::ClassNode::Member::VARIABLE:
if (p_only_functions || outer || (p_static)) {
continue;
}
- option = ScriptCodeCompletionOption(member.variable->identifier->name, ScriptCodeCompletionOption::KIND_MEMBER, location);
+ option = ScriptLanguage::CodeCompletionOption(member.variable->identifier->name, ScriptLanguage::CODE_COMPLETION_KIND_MEMBER);
break;
case GDScriptParser::ClassNode::Member::CONSTANT:
if (p_only_functions) {
@@ -896,7 +806,7 @@ static void _find_identifiers_in_class(const GDScriptParser::ClassNode *p_class,
if (r_result.has(member.constant->identifier->name)) {
continue;
}
- option = ScriptCodeCompletionOption(member.constant->identifier->name, ScriptCodeCompletionOption::KIND_CONSTANT, location);
+ option = ScriptLanguage::CodeCompletionOption(member.constant->identifier->name, ScriptLanguage::CODE_COMPLETION_KIND_CONSTANT);
if (member.constant->initializer) {
option.default_value = member.constant->initializer->reduced_value;
}
@@ -905,25 +815,25 @@ static void _find_identifiers_in_class(const GDScriptParser::ClassNode *p_class,
if (p_only_functions) {
continue;
}
- option = ScriptCodeCompletionOption(member.m_class->identifier->name, ScriptCodeCompletionOption::KIND_CLASS, location);
+ option = ScriptLanguage::CodeCompletionOption(member.m_class->identifier->name, ScriptLanguage::CODE_COMPLETION_KIND_CLASS);
break;
case GDScriptParser::ClassNode::Member::ENUM_VALUE:
if (p_only_functions) {
continue;
}
- option = ScriptCodeCompletionOption(member.enum_value.identifier->name, ScriptCodeCompletionOption::KIND_CONSTANT, location);
+ option = ScriptLanguage::CodeCompletionOption(member.enum_value.identifier->name, ScriptLanguage::CODE_COMPLETION_KIND_CONSTANT);
break;
case GDScriptParser::ClassNode::Member::ENUM:
if (p_only_functions) {
continue;
}
- option = ScriptCodeCompletionOption(member.m_enum->identifier->name, ScriptCodeCompletionOption::KIND_ENUM, location);
+ option = ScriptLanguage::CodeCompletionOption(member.m_enum->identifier->name, ScriptLanguage::CODE_COMPLETION_KIND_ENUM);
break;
case GDScriptParser::ClassNode::Member::FUNCTION:
if (outer || (p_static && !member.function->is_static) || member.function->identifier->name.operator String().begins_with("@")) {
continue;
}
- option = ScriptCodeCompletionOption(member.function->identifier->name, ScriptCodeCompletionOption::KIND_FUNCTION, location);
+ option = ScriptLanguage::CodeCompletionOption(member.function->identifier->name, ScriptLanguage::CODE_COMPLETION_KIND_FUNCTION);
if (member.function->parameters.size() > 0) {
option.insert_text += "(";
} else {
@@ -934,7 +844,7 @@ static void _find_identifiers_in_class(const GDScriptParser::ClassNode *p_class,
if (p_only_functions || outer) {
continue;
}
- option = ScriptCodeCompletionOption(member.signal->identifier->name, ScriptCodeCompletionOption::KIND_SIGNAL, location);
+ option = ScriptLanguage::CodeCompletionOption(member.signal->identifier->name, ScriptLanguage::CODE_COMPLETION_KIND_SIGNAL);
break;
case GDScriptParser::ClassNode::Member::UNDEFINED:
break;
@@ -943,7 +853,6 @@ static void _find_identifiers_in_class(const GDScriptParser::ClassNode *p_class,
}
outer = true;
clss = clss->outer;
- classes_processed++;
}
}
@@ -955,14 +864,14 @@ static void _find_identifiers_in_class(const GDScriptParser::ClassNode *p_class,
_find_identifiers_in_base(base_type, p_only_functions, r_result, p_recursion_depth + 1);
}
-static void _find_identifiers_in_base(const GDScriptCompletionIdentifier &p_base, bool p_only_functions, Map<String, ScriptCodeCompletionOption> &r_result, int p_recursion_depth) {
+static void _find_identifiers_in_base(const GDScriptCompletionIdentifier &p_base, bool p_only_functions, Map<String, ScriptLanguage::CodeCompletionOption> &r_result, int p_recursion_depth) {
ERR_FAIL_COND(p_recursion_depth > COMPLETION_RECURSION_LIMIT);
GDScriptParser::DataType base_type = p_base.type;
bool _static = base_type.is_meta_type;
if (_static && base_type.kind != GDScriptParser::DataType::BUILTIN) {
- ScriptCodeCompletionOption option("new", ScriptCodeCompletionOption::KIND_FUNCTION);
+ ScriptLanguage::CodeCompletionOption option("new", ScriptLanguage::CODE_COMPLETION_KIND_FUNCTION);
option.insert_text += "(";
r_result.insert(option.display, option);
}
@@ -982,24 +891,21 @@ static void _find_identifiers_in_base(const GDScriptCompletionIdentifier &p_base
List<PropertyInfo> members;
scr->get_script_property_list(&members);
for (const PropertyInfo &E : members) {
- int location = p_recursion_depth + _get_property_location(scr->get_class_name(), E.class_name);
- ScriptCodeCompletionOption option(E.name, ScriptCodeCompletionOption::KIND_MEMBER, location);
+ ScriptLanguage::CodeCompletionOption option(E.name, ScriptLanguage::CODE_COMPLETION_KIND_MEMBER);
r_result.insert(option.display, option);
}
}
Map<StringName, Variant> constants;
scr->get_constants(&constants);
for (const KeyValue<StringName, Variant> &E : constants) {
- int location = p_recursion_depth + _get_constant_location(scr->get_class_name(), E.key);
- ScriptCodeCompletionOption option(E.key.operator String(), ScriptCodeCompletionOption::KIND_CONSTANT, location);
+ ScriptLanguage::CodeCompletionOption option(E.key.operator String(), ScriptLanguage::CODE_COMPLETION_KIND_CONSTANT);
r_result.insert(option.display, option);
}
List<MethodInfo> signals;
scr->get_script_signal_list(&signals);
for (const MethodInfo &E : signals) {
- int location = p_recursion_depth + _get_signal_location(scr->get_class_name(), E.name);
- ScriptCodeCompletionOption option(E.name, ScriptCodeCompletionOption::KIND_SIGNAL, location);
+ ScriptLanguage::CodeCompletionOption option(E.name, ScriptLanguage::CODE_COMPLETION_KIND_SIGNAL);
r_result.insert(option.display, option);
}
}
@@ -1010,8 +916,7 @@ static void _find_identifiers_in_base(const GDScriptCompletionIdentifier &p_base
if (E.name.begins_with("@")) {
continue;
}
- int location = p_recursion_depth + _get_method_location(scr->get_class_name(), E.name);
- ScriptCodeCompletionOption option(E.name, ScriptCodeCompletionOption::KIND_FUNCTION, location);
+ ScriptLanguage::CodeCompletionOption option(E.name, ScriptLanguage::CODE_COMPLETION_KIND_FUNCTION);
if (E.arguments.size()) {
option.insert_text += "(";
} else {
@@ -1041,8 +946,7 @@ static void _find_identifiers_in_base(const GDScriptCompletionIdentifier &p_base
List<String> constants;
ClassDB::get_integer_constant_list(type, &constants);
for (const String &E : constants) {
- int location = p_recursion_depth + _get_constant_location(type, StringName(E));
- ScriptCodeCompletionOption option(E, ScriptCodeCompletionOption::KIND_CONSTANT, location);
+ ScriptLanguage::CodeCompletionOption option(E, ScriptLanguage::CODE_COMPLETION_KIND_CONSTANT);
r_result.insert(option.display, option);
}
@@ -1056,8 +960,7 @@ static void _find_identifiers_in_base(const GDScriptCompletionIdentifier &p_base
if (E.name.contains("/")) {
continue;
}
- int location = p_recursion_depth + _get_property_location(type, E.class_name);
- ScriptCodeCompletionOption option(E.name, ScriptCodeCompletionOption::KIND_MEMBER, location);
+ ScriptLanguage::CodeCompletionOption option(E.name, ScriptLanguage::CODE_COMPLETION_KIND_MEMBER);
r_result.insert(option.display, option);
}
}
@@ -1070,8 +973,7 @@ static void _find_identifiers_in_base(const GDScriptCompletionIdentifier &p_base
if (E.name.begins_with("_")) {
continue;
}
- int location = p_recursion_depth + _get_method_location(type, E.name);
- ScriptCodeCompletionOption option(E.name, ScriptCodeCompletionOption::KIND_FUNCTION, location);
+ ScriptLanguage::CodeCompletionOption option(E.name, ScriptLanguage::CODE_COMPLETION_KIND_FUNCTION);
if (E.arguments.size()) {
option.insert_text += "(";
} else {
@@ -1080,6 +982,7 @@ static void _find_identifiers_in_base(const GDScriptCompletionIdentifier &p_base
r_result.insert(option.display, option);
}
}
+
return;
} break;
case GDScriptParser::DataType::BUILTIN: {
@@ -1100,7 +1003,7 @@ static void _find_identifiers_in_base(const GDScriptCompletionIdentifier &p_base
for (const PropertyInfo &E : members) {
if (!String(E.name).contains("/")) {
- ScriptCodeCompletionOption option(E.name, ScriptCodeCompletionOption::KIND_MEMBER);
+ ScriptLanguage::CodeCompletionOption option(E.name, ScriptLanguage::CODE_COMPLETION_KIND_MEMBER);
r_result.insert(option.display, option);
}
}
@@ -1109,7 +1012,7 @@ static void _find_identifiers_in_base(const GDScriptCompletionIdentifier &p_base
List<MethodInfo> methods;
tmp.get_method_list(&methods);
for (const MethodInfo &E : methods) {
- ScriptCodeCompletionOption option(E.name, ScriptCodeCompletionOption::KIND_FUNCTION);
+ ScriptLanguage::CodeCompletionOption option(E.name, ScriptLanguage::CODE_COMPLETION_KIND_FUNCTION);
if (E.arguments.size()) {
option.insert_text += "(";
} else {
@@ -1127,7 +1030,7 @@ static void _find_identifiers_in_base(const GDScriptCompletionIdentifier &p_base
}
}
-static void _find_identifiers(GDScriptParser::CompletionContext &p_context, bool p_only_functions, Map<String, ScriptCodeCompletionOption> &r_result, int p_recursion_depth) {
+static void _find_identifiers(GDScriptParser::CompletionContext &p_context, bool p_only_functions, Map<String, ScriptLanguage::CodeCompletionOption> &r_result, int p_recursion_depth) {
if (!p_only_functions && p_context.current_suite) {
// This includes function parameters, since they are also locals.
_find_identifiers_in_suite(p_context.current_suite, r_result);
@@ -1142,7 +1045,7 @@ static void _find_identifiers(GDScriptParser::CompletionContext &p_context, bool
for (const StringName &E : functions) {
MethodInfo function = GDScriptUtilityFunctions::get_function_info(E);
- ScriptCodeCompletionOption option(String(E), ScriptCodeCompletionOption::KIND_FUNCTION);
+ ScriptLanguage::CodeCompletionOption option(String(E), ScriptLanguage::CODE_COMPLETION_KIND_FUNCTION);
if (function.arguments.size() || (function.flags & METHOD_FLAG_VARARG)) {
option.insert_text += "(";
} else {
@@ -1163,7 +1066,7 @@ static void _find_identifiers(GDScriptParser::CompletionContext &p_context, bool
static_assert((sizeof(_type_names) / sizeof(*_type_names)) == Variant::VARIANT_MAX, "Completion for builtin types is incomplete");
for (int i = 0; i < Variant::VARIANT_MAX; i++) {
- ScriptCodeCompletionOption option(_type_names[i], ScriptCodeCompletionOption::KIND_CLASS);
+ ScriptLanguage::CodeCompletionOption option(_type_names[i], ScriptLanguage::CODE_COMPLETION_KIND_CLASS);
r_result.insert(option.display, option);
}
@@ -1175,7 +1078,7 @@ static void _find_identifiers(GDScriptParser::CompletionContext &p_context, bool
const char **kw = _keywords;
while (*kw) {
- ScriptCodeCompletionOption option(*kw, ScriptCodeCompletionOption::KIND_PLAIN_TEXT);
+ ScriptLanguage::CodeCompletionOption option(*kw, ScriptLanguage::CODE_COMPLETION_KIND_PLAIN_TEXT);
r_result.insert(option.display, option);
kw++;
}
@@ -1188,7 +1091,7 @@ static void _find_identifiers(GDScriptParser::CompletionContext &p_context, bool
const char **kws = _keywords_with_space;
while (*kws) {
- ScriptCodeCompletionOption option(*kws, ScriptCodeCompletionOption::KIND_PLAIN_TEXT);
+ ScriptLanguage::CodeCompletionOption option(*kws, ScriptLanguage::CODE_COMPLETION_KIND_PLAIN_TEXT);
option.insert_text += " ";
r_result.insert(option.display, option);
kws++;
@@ -1201,7 +1104,7 @@ static void _find_identifiers(GDScriptParser::CompletionContext &p_context, bool
const char **kwa = _keywords_with_args;
while (*kwa) {
- ScriptCodeCompletionOption option(*kwa, ScriptCodeCompletionOption::KIND_FUNCTION);
+ ScriptLanguage::CodeCompletionOption option(*kwa, ScriptLanguage::CODE_COMPLETION_KIND_FUNCTION);
option.insert_text += "(";
r_result.insert(option.display, option);
kwa++;
@@ -1211,7 +1114,7 @@ static void _find_identifiers(GDScriptParser::CompletionContext &p_context, bool
Variant::get_utility_function_list(&utility_func_names);
for (List<StringName>::Element *E = utility_func_names.front(); E; E = E->next()) {
- ScriptCodeCompletionOption option(E->get(), ScriptCodeCompletionOption::KIND_FUNCTION);
+ ScriptLanguage::CodeCompletionOption option(E->get(), ScriptLanguage::CODE_COMPLETION_KIND_FUNCTION);
option.insert_text += "(";
r_result.insert(option.display, option);
}
@@ -1221,17 +1124,17 @@ static void _find_identifiers(GDScriptParser::CompletionContext &p_context, bool
if (!E.value().is_singleton) {
continue;
}
- ScriptCodeCompletionOption option(E.key(), ScriptCodeCompletionOption::KIND_CONSTANT);
+ ScriptLanguage::CodeCompletionOption option(E.key(), ScriptLanguage::CODE_COMPLETION_KIND_CONSTANT);
r_result.insert(option.display, option);
}
// Native classes and global constants.
for (const KeyValue<StringName, int> &E : GDScriptLanguage::get_singleton()->get_global_map()) {
- ScriptCodeCompletionOption option;
+ ScriptLanguage::CodeCompletionOption option;
if (ClassDB::class_exists(E.key) || Engine::get_singleton()->has_singleton(E.key)) {
- option = ScriptCodeCompletionOption(E.key.operator String(), ScriptCodeCompletionOption::KIND_CLASS);
+ option = ScriptLanguage::CodeCompletionOption(E.key.operator String(), ScriptLanguage::CODE_COMPLETION_KIND_CLASS);
} else {
- option = ScriptCodeCompletionOption(E.key.operator String(), ScriptCodeCompletionOption::KIND_CONSTANT);
+ option = ScriptLanguage::CodeCompletionOption(E.key.operator String(), ScriptLanguage::CODE_COMPLETION_KIND_CONSTANT);
}
r_result.insert(option.display, option);
}
@@ -2309,20 +2212,20 @@ static bool _guess_method_return_type_from_base(GDScriptParser::CompletionContex
return false;
}
-static void _find_enumeration_candidates(GDScriptParser::CompletionContext &p_context, const String &p_enum_hint, Map<String, ScriptCodeCompletionOption> &r_result) {
+static void _find_enumeration_candidates(GDScriptParser::CompletionContext &p_context, const String &p_enum_hint, Map<String, ScriptLanguage::CodeCompletionOption> &r_result) {
if (!p_enum_hint.contains(".")) {
// Global constant or in the current class.
StringName current_enum = p_enum_hint;
if (p_context.current_class && p_context.current_class->has_member(current_enum) && p_context.current_class->get_member(current_enum).type == GDScriptParser::ClassNode::Member::ENUM) {
const GDScriptParser::EnumNode *_enum = p_context.current_class->get_member(current_enum).m_enum;
for (int i = 0; i < _enum->values.size(); i++) {
- ScriptCodeCompletionOption option(_enum->values[i].identifier->name, ScriptCodeCompletionOption::KIND_ENUM);
+ ScriptLanguage::CodeCompletionOption option(_enum->values[i].identifier->name, ScriptLanguage::CODE_COMPLETION_KIND_ENUM);
r_result.insert(option.display, option);
}
} else {
for (int i = 0; i < CoreConstants::get_global_constant_count(); i++) {
if (CoreConstants::get_global_constant_enum(i) == current_enum) {
- ScriptCodeCompletionOption option(CoreConstants::get_global_constant_name(i), ScriptCodeCompletionOption::KIND_ENUM);
+ ScriptLanguage::CodeCompletionOption option(CoreConstants::get_global_constant_name(i), ScriptLanguage::CODE_COMPLETION_KIND_ENUM);
r_result.insert(option.display, option);
}
}
@@ -2339,14 +2242,13 @@ static void _find_enumeration_candidates(GDScriptParser::CompletionContext &p_co
ClassDB::get_enum_constants(class_name, enum_name, &enum_constants);
for (const StringName &E : enum_constants) {
String candidate = class_name + "." + E;
- int location = _get_enum_constant_location(class_name, E);
- ScriptCodeCompletionOption option(candidate, ScriptCodeCompletionOption::KIND_ENUM, location);
+ ScriptLanguage::CodeCompletionOption option(candidate, ScriptLanguage::CODE_COMPLETION_KIND_ENUM);
r_result.insert(option.display, option);
}
}
}
-static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, const GDScriptCompletionIdentifier &p_base, const StringName &p_method, int p_argidx, bool p_static, Map<String, ScriptCodeCompletionOption> &r_result, String &r_arghint) {
+static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, const GDScriptCompletionIdentifier &p_base, const StringName &p_method, int p_argidx, bool p_static, Map<String, ScriptLanguage::CodeCompletionOption> &r_result, String &r_arghint) {
Variant base = p_base.value;
GDScriptParser::DataType base_type = p_base.type;
@@ -2387,7 +2289,7 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c
if (opt.is_quoted()) {
opt = opt.unquote().quote(quote_style); // Handle user preference.
}
- ScriptCodeCompletionOption option(opt, ScriptCodeCompletionOption::KIND_FUNCTION);
+ ScriptLanguage::CodeCompletionOption option(opt, ScriptLanguage::CODE_COMPLETION_KIND_FUNCTION);
r_result.insert(option.display, option);
}
}
@@ -2414,7 +2316,7 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c
continue;
}
String name = s.get_slice("/", 1);
- ScriptCodeCompletionOption option("/root/" + name, ScriptCodeCompletionOption::KIND_NODE_PATH);
+ ScriptLanguage::CodeCompletionOption option("/root/" + name, ScriptLanguage::CODE_COMPLETION_KIND_NODE_PATH);
option.insert_text = option.display.quote(quote_style);
r_result.insert(option.display, option);
}
@@ -2430,7 +2332,7 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c
continue;
}
String name = s.get_slice("/", 1);
- ScriptCodeCompletionOption option(name, ScriptCodeCompletionOption::KIND_CONSTANT);
+ ScriptLanguage::CodeCompletionOption option(name, ScriptLanguage::CODE_COMPLETION_KIND_CONSTANT);
option.insert_text = option.display.quote(quote_style);
r_result.insert(option.display, option);
}
@@ -2465,7 +2367,7 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c
}
}
-static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, const GDScriptParser::Node *p_call, int p_argidx, Map<String, ScriptCodeCompletionOption> &r_result, bool &r_forced, String &r_arghint) {
+static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, const GDScriptParser::Node *p_call, int p_argidx, Map<String, ScriptLanguage::CodeCompletionOption> &r_result, bool &r_forced, String &r_arghint) {
if (p_call->type == GDScriptParser::Node::PRELOAD) {
if (p_argidx == 0 && bool(EditorSettings::get_singleton()->get("text_editor/completion/complete_file_paths"))) {
_get_directory_contents(EditorFileSystem::get_singleton()->get_filesystem(), r_result);
@@ -2544,7 +2446,7 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c
r_forced = r_result.size() > 0;
}
-::Error GDScriptLanguage::complete_code(const String &p_code, const String &p_path, Object *p_owner, List<ScriptCodeCompletionOption> *r_options, bool &r_forced, String &r_call_hint) {
+::Error GDScriptLanguage::complete_code(const String &p_code, const String &p_path, Object *p_owner, List<ScriptLanguage::CodeCompletionOption> *r_options, bool &r_forced, String &r_call_hint) {
const String quote_style = EDITOR_GET("text_editor/completion/use_single_quotes") ? "'" : "\"";
GDScriptParser parser;
@@ -2554,7 +2456,7 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c
analyzer.analyze();
r_forced = false;
- Map<String, ScriptCodeCompletionOption> options;
+ Map<String, ScriptLanguage::CodeCompletionOption> options;
GDScriptParser::CompletionContext completion_context = parser.get_completion_context();
completion_context.base = p_owner;
@@ -2567,7 +2469,7 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c
List<MethodInfo> annotations;
parser.get_annotation_list(&annotations);
for (const MethodInfo &E : annotations) {
- ScriptCodeCompletionOption option(E.name.substr(1), ScriptCodeCompletionOption::KIND_PLAIN_TEXT);
+ ScriptLanguage::CodeCompletionOption option(E.name.substr(1), ScriptLanguage::CODE_COMPLETION_KIND_PLAIN_TEXT);
if (E.arguments.size() > 0) {
option.insert_text += "(";
}
@@ -2587,7 +2489,7 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c
List<StringName> constants;
Variant::get_constants_for_type(completion_context.builtin_type, &constants);
for (const StringName &E : constants) {
- ScriptCodeCompletionOption option(E, ScriptCodeCompletionOption::KIND_CONSTANT);
+ ScriptLanguage::CodeCompletionOption option(E, ScriptLanguage::CODE_COMPLETION_KIND_CONSTANT);
bool valid = false;
Variant default_value = Variant::get_constant_value(completion_context.builtin_type, E, &valid);
if (valid) {
@@ -2601,7 +2503,7 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c
r_forced = true;
} break;
case GDScriptParser::COMPLETION_TYPE_NAME_OR_VOID: {
- ScriptCodeCompletionOption option("void", ScriptCodeCompletionOption::KIND_PLAIN_TEXT);
+ ScriptLanguage::CodeCompletionOption option("void", ScriptLanguage::CODE_COMPLETION_KIND_PLAIN_TEXT);
options.insert(option.display, option);
}
[[fallthrough]];
@@ -2611,16 +2513,16 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c
} break;
case GDScriptParser::COMPLETION_PROPERTY_DECLARATION_OR_TYPE: {
_list_available_types(false, completion_context, options);
- ScriptCodeCompletionOption get("get", ScriptCodeCompletionOption::KIND_PLAIN_TEXT);
+ ScriptLanguage::CodeCompletionOption get("get", ScriptLanguage::CODE_COMPLETION_KIND_PLAIN_TEXT);
options.insert(get.display, get);
- ScriptCodeCompletionOption set("set", ScriptCodeCompletionOption::KIND_PLAIN_TEXT);
+ ScriptLanguage::CodeCompletionOption set("set", ScriptLanguage::CODE_COMPLETION_KIND_PLAIN_TEXT);
options.insert(set.display, set);
r_forced = true;
} break;
case GDScriptParser::COMPLETION_PROPERTY_DECLARATION: {
- ScriptCodeCompletionOption get("get", ScriptCodeCompletionOption::KIND_PLAIN_TEXT);
+ ScriptLanguage::CodeCompletionOption get("get", ScriptLanguage::CODE_COMPLETION_KIND_PLAIN_TEXT);
options.insert(get.display, get);
- ScriptCodeCompletionOption set("set", ScriptCodeCompletionOption::KIND_PLAIN_TEXT);
+ ScriptLanguage::CodeCompletionOption set("set", ScriptLanguage::CODE_COMPLETION_KIND_PLAIN_TEXT);
options.insert(set.display, set);
r_forced = true;
} break;
@@ -2636,7 +2538,7 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c
if (member.function->is_static) {
continue;
}
- ScriptCodeCompletionOption option(member.function->identifier->name, ScriptCodeCompletionOption::KIND_FUNCTION);
+ ScriptLanguage::CodeCompletionOption option(member.function->identifier->name, ScriptLanguage::CODE_COMPLETION_KIND_FUNCTION);
options.insert(option.display, option);
}
r_forced = true;
@@ -2806,7 +2708,7 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c
}
method_hint += ":";
- ScriptCodeCompletionOption option(method_hint, ScriptCodeCompletionOption::KIND_FUNCTION);
+ ScriptLanguage::CodeCompletionOption option(method_hint, ScriptLanguage::CODE_COMPLETION_KIND_FUNCTION);
options.insert(option.display, option);
}
} break;
@@ -2829,7 +2731,7 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c
if (!opt.replace("/", "_").is_valid_identifier()) {
opt = opt.quote(quote_style); // Handle user preference.
}
- ScriptCodeCompletionOption option(opt, ScriptCodeCompletionOption::KIND_NODE_PATH);
+ ScriptLanguage::CodeCompletionOption option(opt, ScriptLanguage::CODE_COMPLETION_KIND_NODE_PATH);
options.insert(option.display, option);
}
@@ -2838,7 +2740,7 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c
for (OrderedHashMap<StringName, ProjectSettings::AutoloadInfo>::Element E = autoloads.front(); E; E = E.next()) {
String path = "/root/" + E.key();
- ScriptCodeCompletionOption option(path.quote(quote_style), ScriptCodeCompletionOption::KIND_NODE_PATH);
+ ScriptLanguage::CodeCompletionOption option(path.quote(quote_style), ScriptLanguage::CODE_COMPLETION_KIND_NODE_PATH);
options.insert(option.display, option);
}
}
@@ -2851,18 +2753,16 @@ static void _find_call_arguments(GDScriptParser::CompletionContext &p_context, c
} break;
}
- for (const KeyValue<String, ScriptCodeCompletionOption> &E : options) {
+ for (const KeyValue<String, ScriptLanguage::CodeCompletionOption> &E : options) {
r_options->push_back(E.value);
}
- r_options->sort_custom_inplace<ScriptCodeCompletionOptionCompare>();
-
return OK;
}
#else
-Error GDScriptLanguage::complete_code(const String &p_code, const String &p_path, Object *p_owner, List<ScriptCodeCompletionOption> *r_options, bool &r_forced, String &r_call_hint) {
+Error GDScriptLanguage::complete_code(const String &p_code, const String &p_path, Object *p_owner, List<ScriptLanguage::CodeCompletionOption> *r_options, bool &r_forced, String &r_call_hint) {
return OK;
}
@@ -2961,7 +2861,7 @@ static Error _lookup_symbol_from_base(const GDScriptParser::DataType &p_base, co
case GDScriptParser::DataType::CLASS: {
if (base_type.class_type) {
if (base_type.class_type->has_member(p_symbol)) {
- r_result.type = ScriptLanguage::LookupResult::RESULT_SCRIPT_LOCATION;
+ r_result.type = ScriptLanguage::LOOKUP_RESULT_SCRIPT_LOCATION;
r_result.location = base_type.class_type->get_member(p_symbol).get_line();
r_result.class_path = base_type.script_path;
r_result.script = GDScriptCache::get_shallow_script(r_result.class_path);
@@ -2975,7 +2875,7 @@ static Error _lookup_symbol_from_base(const GDScriptParser::DataType &p_base, co
if (scr.is_valid()) {
int line = scr->get_member_line(p_symbol);
if (line >= 0) {
- r_result.type = ScriptLanguage::LookupResult::RESULT_SCRIPT_LOCATION;
+ r_result.type = ScriptLanguage::LOOKUP_RESULT_SCRIPT_LOCATION;
r_result.location = line;
r_result.script = scr;
return OK;
@@ -2999,7 +2899,7 @@ static Error _lookup_symbol_from_base(const GDScriptParser::DataType &p_base, co
}
if (ClassDB::has_method(class_name, p_symbol, true)) {
- r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS_METHOD;
+ r_result.type = ScriptLanguage::LOOKUP_RESULT_CLASS_METHOD;
r_result.class_name = base_type.native_type;
r_result.class_member = p_symbol;
return OK;
@@ -3009,7 +2909,7 @@ static Error _lookup_symbol_from_base(const GDScriptParser::DataType &p_base, co
ClassDB::get_virtual_methods(class_name, &virtual_methods, true);
for (const MethodInfo &E : virtual_methods) {
if (E.name == p_symbol) {
- r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS_METHOD;
+ r_result.type = ScriptLanguage::LOOKUP_RESULT_CLASS_METHOD;
r_result.class_name = base_type.native_type;
r_result.class_member = p_symbol;
return OK;
@@ -3018,7 +2918,7 @@ static Error _lookup_symbol_from_base(const GDScriptParser::DataType &p_base, co
StringName enum_name = ClassDB::get_integer_constant_enum(class_name, p_symbol, true);
if (enum_name != StringName()) {
- r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS_ENUM;
+ r_result.type = ScriptLanguage::LOOKUP_RESULT_CLASS_ENUM;
r_result.class_name = base_type.native_type;
r_result.class_member = enum_name;
return OK;
@@ -3028,7 +2928,7 @@ static Error _lookup_symbol_from_base(const GDScriptParser::DataType &p_base, co
ClassDB::get_integer_constant_list(class_name, &constants, true);
for (const String &E : constants) {
if (E == p_symbol) {
- r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS_CONSTANT;
+ r_result.type = ScriptLanguage::LOOKUP_RESULT_CLASS_CONSTANT;
r_result.class_name = base_type.native_type;
r_result.class_member = p_symbol;
return OK;
@@ -3036,7 +2936,7 @@ static Error _lookup_symbol_from_base(const GDScriptParser::DataType &p_base, co
}
if (ClassDB::has_property(class_name, p_symbol, true)) {
- r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS_PROPERTY;
+ r_result.type = ScriptLanguage::LOOKUP_RESULT_CLASS_PROPERTY;
r_result.class_name = base_type.native_type;
r_result.class_member = p_symbol;
return OK;
@@ -3053,7 +2953,7 @@ static Error _lookup_symbol_from_base(const GDScriptParser::DataType &p_base, co
base_type.kind = GDScriptParser::DataType::UNRESOLVED;
if (Variant::has_constant(base_type.builtin_type, p_symbol)) {
- r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS_CONSTANT;
+ r_result.type = ScriptLanguage::LOOKUP_RESULT_CLASS_CONSTANT;
r_result.class_name = Variant::get_type_name(base_type.builtin_type);
r_result.class_member = p_symbol;
return OK;
@@ -3073,7 +2973,7 @@ static Error _lookup_symbol_from_base(const GDScriptParser::DataType &p_base, co
}
if (v.has_method(p_symbol)) {
- r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS_METHOD;
+ r_result.type = ScriptLanguage::LOOKUP_RESULT_CLASS_METHOD;
r_result.class_name = Variant::get_type_name(base_type.builtin_type);
r_result.class_member = p_symbol;
return OK;
@@ -3082,7 +2982,7 @@ static Error _lookup_symbol_from_base(const GDScriptParser::DataType &p_base, co
bool valid = false;
v.get(p_symbol, &valid);
if (valid) {
- r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS_PROPERTY;
+ r_result.type = ScriptLanguage::LOOKUP_RESULT_CLASS_PROPERTY;
r_result.class_name = Variant::get_type_name(base_type.builtin_type);
r_result.class_member = p_symbol;
return OK;
@@ -3100,7 +3000,7 @@ static Error _lookup_symbol_from_base(const GDScriptParser::DataType &p_base, co
::Error GDScriptLanguage::lookup_code(const String &p_code, const String &p_symbol, const String &p_path, Object *p_owner, LookupResult &r_result) {
// Before parsing, try the usual stuff
if (ClassDB::class_exists(p_symbol)) {
- r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS;
+ r_result.type = ScriptLanguage::LOOKUP_RESULT_CLASS;
r_result.class_name = p_symbol;
return OK;
}
@@ -3108,21 +3008,21 @@ static Error _lookup_symbol_from_base(const GDScriptParser::DataType &p_base, co
for (int i = 0; i < Variant::VARIANT_MAX; i++) {
Variant::Type t = Variant::Type(i);
if (Variant::get_type_name(t) == p_symbol) {
- r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS;
+ r_result.type = ScriptLanguage::LOOKUP_RESULT_CLASS;
r_result.class_name = Variant::get_type_name(t);
return OK;
}
}
if (GDScriptUtilityFunctions::function_exists(p_symbol)) {
- r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS_METHOD;
+ r_result.type = ScriptLanguage::LOOKUP_RESULT_CLASS_METHOD;
r_result.class_name = "@GDScript";
r_result.class_member = p_symbol;
return OK;
}
if ("PI" == p_symbol || "TAU" == p_symbol || "INF" == p_symbol || "NAN" == p_symbol) {
- r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS_CONSTANT;
+ r_result.type = ScriptLanguage::LOOKUP_RESULT_CLASS_CONSTANT;
r_result.class_name = "@GDScript";
r_result.class_member = p_symbol;
return OK;
@@ -3139,7 +3039,7 @@ static Error _lookup_symbol_from_base(const GDScriptParser::DataType &p_base, co
bool success = false;
ClassDB::get_integer_constant(context.current_class->extends[0], p_symbol, &success);
if (success) {
- r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS_CONSTANT;
+ r_result.type = ScriptLanguage::LOOKUP_RESULT_CLASS_CONSTANT;
r_result.class_name = context.current_class->extends[0];
r_result.class_member = p_symbol;
return OK;
@@ -3150,7 +3050,7 @@ static Error _lookup_symbol_from_base(const GDScriptParser::DataType &p_base, co
switch (context.type) {
case GDScriptParser::COMPLETION_BUILT_IN_TYPE_CONSTANT: {
- r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS_CONSTANT;
+ r_result.type = ScriptLanguage::LOOKUP_RESULT_CLASS_CONSTANT;
r_result.class_name = Variant::get_type_name(context.builtin_type);
r_result.class_member = p_symbol;
return OK;
@@ -3178,7 +3078,7 @@ static Error _lookup_symbol_from_base(const GDScriptParser::DataType &p_base, co
const GDScriptParser::SuiteNode *suite = context.current_suite;
while (suite) {
if (suite->has_local(p_symbol)) {
- r_result.type = ScriptLanguage::LookupResult::RESULT_SCRIPT_LOCATION;
+ r_result.type = ScriptLanguage::LOOKUP_RESULT_SCRIPT_LOCATION;
r_result.location = suite->get_local(p_symbol).start_line;
return OK;
}
@@ -3203,7 +3103,7 @@ static Error _lookup_symbol_from_base(const GDScriptParser::DataType &p_base, co
}
if (FileAccess::exists(script)) {
- r_result.type = ScriptLanguage::LookupResult::RESULT_SCRIPT_LOCATION;
+ r_result.type = ScriptLanguage::LOOKUP_RESULT_SCRIPT_LOCATION;
r_result.location = 0;
r_result.script = ResourceLoader::load(script);
return OK;
@@ -3219,10 +3119,10 @@ static Error _lookup_symbol_from_base(const GDScriptParser::DataType &p_base, co
Object *obj = value;
if (obj) {
if (Object::cast_to<GDScriptNativeClass>(obj)) {
- r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS;
+ r_result.type = ScriptLanguage::LOOKUP_RESULT_CLASS;
r_result.class_name = Object::cast_to<GDScriptNativeClass>(obj)->get_name();
} else {
- r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS;
+ r_result.type = ScriptLanguage::LOOKUP_RESULT_CLASS;
r_result.class_name = obj->get_class();
}
@@ -3239,18 +3139,18 @@ static Error _lookup_symbol_from_base(const GDScriptParser::DataType &p_base, co
// Otherwise these codes would work
StringName enumName = ClassDB::get_integer_constant_enum("@GlobalScope", p_symbol, true);
if (enumName != nullptr) {
- r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS_ENUM;
+ r_result.type = ScriptLanguage::LOOKUP_RESULT_CLASS_ENUM;
r_result.class_name = "@GlobalScope";
r_result.class_member = enumName;
return OK;
}
else {
- r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS_CONSTANT;
+ r_result.type = ScriptLanguage::LOOKUP_RESULT_CLASS_CONSTANT;
r_result.class_name = "@GlobalScope";
r_result.class_member = p_symbol;
return OK;
}*/
- r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS_TBD_GLOBALSCOPE;
+ r_result.type = ScriptLanguage::LOOKUP_RESULT_CLASS_TBD_GLOBALSCOPE;
r_result.class_name = "@GlobalScope";
r_result.class_member = p_symbol;
return OK;
@@ -3259,7 +3159,7 @@ static Error _lookup_symbol_from_base(const GDScriptParser::DataType &p_base, co
List<StringName> utility_functions;
Variant::get_utility_function_list(&utility_functions);
if (utility_functions.find(p_symbol) != nullptr) {
- r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS_TBD_GLOBALSCOPE;
+ r_result.type = ScriptLanguage::LOOKUP_RESULT_CLASS_TBD_GLOBALSCOPE;
r_result.class_name = "@GlobalScope";
r_result.class_member = p_symbol;
return OK;
diff --git a/modules/gdscript/language_server/gdscript_text_document.cpp b/modules/gdscript/language_server/gdscript_text_document.cpp
index 961295b076..d5ef8fed74 100644
--- a/modules/gdscript/language_server/gdscript_text_document.cpp
+++ b/modules/gdscript/language_server/gdscript_text_document.cpp
@@ -166,49 +166,51 @@ Array GDScriptTextDocument::completion(const Dictionary &p_params) {
params.load(p_params);
Dictionary request_data = params.to_json();
- List<ScriptCodeCompletionOption> options;
+ List<ScriptLanguage::CodeCompletionOption> options;
GDScriptLanguageProtocol::get_singleton()->get_workspace()->completion(params, &options);
if (!options.is_empty()) {
int i = 0;
arr.resize(options.size());
- for (const ScriptCodeCompletionOption &option : options) {
+ for (const ScriptLanguage::CodeCompletionOption &option : options) {
lsp::CompletionItem item;
item.label = option.display;
item.data = request_data;
switch (option.kind) {
- case ScriptCodeCompletionOption::KIND_ENUM:
+ case ScriptLanguage::CODE_COMPLETION_KIND_ENUM:
item.kind = lsp::CompletionItemKind::Enum;
break;
- case ScriptCodeCompletionOption::KIND_CLASS:
+ case ScriptLanguage::CODE_COMPLETION_KIND_CLASS:
item.kind = lsp::CompletionItemKind::Class;
break;
- case ScriptCodeCompletionOption::KIND_MEMBER:
+ case ScriptLanguage::CODE_COMPLETION_KIND_MEMBER:
item.kind = lsp::CompletionItemKind::Property;
break;
- case ScriptCodeCompletionOption::KIND_FUNCTION:
+ case ScriptLanguage::CODE_COMPLETION_KIND_FUNCTION:
item.kind = lsp::CompletionItemKind::Method;
break;
- case ScriptCodeCompletionOption::KIND_SIGNAL:
+ case ScriptLanguage::CODE_COMPLETION_KIND_SIGNAL:
item.kind = lsp::CompletionItemKind::Event;
break;
- case ScriptCodeCompletionOption::KIND_CONSTANT:
+ case ScriptLanguage::CODE_COMPLETION_KIND_CONSTANT:
item.kind = lsp::CompletionItemKind::Constant;
break;
- case ScriptCodeCompletionOption::KIND_VARIABLE:
+ case ScriptLanguage::CODE_COMPLETION_KIND_VARIABLE:
item.kind = lsp::CompletionItemKind::Variable;
break;
- case ScriptCodeCompletionOption::KIND_FILE_PATH:
+ case ScriptLanguage::CODE_COMPLETION_KIND_FILE_PATH:
item.kind = lsp::CompletionItemKind::File;
break;
- case ScriptCodeCompletionOption::KIND_NODE_PATH:
+ case ScriptLanguage::CODE_COMPLETION_KIND_NODE_PATH:
item.kind = lsp::CompletionItemKind::Snippet;
break;
- case ScriptCodeCompletionOption::KIND_PLAIN_TEXT:
+ case ScriptLanguage::CODE_COMPLETION_KIND_PLAIN_TEXT:
item.kind = lsp::CompletionItemKind::Text;
break;
+ default: {
+ }
}
arr[i] = item.to_json();
diff --git a/modules/gdscript/language_server/gdscript_workspace.cpp b/modules/gdscript/language_server/gdscript_workspace.cpp
index d20b243616..1bf0b40842 100644
--- a/modules/gdscript/language_server/gdscript_workspace.cpp
+++ b/modules/gdscript/language_server/gdscript_workspace.cpp
@@ -571,7 +571,7 @@ Node *GDScriptWorkspace::_get_owner_scene_node(String p_path) {
return owner_scene_node;
}
-void GDScriptWorkspace::completion(const lsp::CompletionParams &p_params, List<ScriptCodeCompletionOption> *r_options) {
+void GDScriptWorkspace::completion(const lsp::CompletionParams &p_params, List<ScriptLanguage::CodeCompletionOption> *r_options) {
String path = get_file_path(p_params.textDocument.uri);
String call_hint;
bool forced = false;
@@ -638,7 +638,7 @@ const lsp::DocumentSymbol *GDScriptWorkspace::resolve_symbol(const lsp::TextDocu
symbol_identifier = "_init";
}
if (OK == GDScriptLanguage::get_singleton()->lookup_code(parser->get_text_for_lookup_symbol(pos, symbol_identifier, p_func_required), symbol_identifier, path, nullptr, ret)) {
- if (ret.type == ScriptLanguage::LookupResult::RESULT_SCRIPT_LOCATION) {
+ if (ret.type == ScriptLanguage::LOOKUP_RESULT_SCRIPT_LOCATION) {
String target_script_path = path;
if (!ret.script.is_null()) {
target_script_path = ret.script->get_path();
diff --git a/modules/gdscript/language_server/gdscript_workspace.h b/modules/gdscript/language_server/gdscript_workspace.h
index ce5bba5f00..92e78f8992 100644
--- a/modules/gdscript/language_server/gdscript_workspace.h
+++ b/modules/gdscript/language_server/gdscript_workspace.h
@@ -85,7 +85,7 @@ public:
String get_file_uri(const String &p_path) const;
void publish_diagnostics(const String &p_path);
- void completion(const lsp::CompletionParams &p_params, List<ScriptCodeCompletionOption> *r_options);
+ void completion(const lsp::CompletionParams &p_params, List<ScriptLanguage::CodeCompletionOption> *r_options);
const lsp::DocumentSymbol *resolve_symbol(const lsp::TextDocumentPositionParams &p_doc_pos, const String &p_symbol_name = "", bool p_func_required = false);
void resolve_related_symbols(const lsp::TextDocumentPositionParams &p_doc_pos, List<const lsp::DocumentSymbol *> &r_list);
diff --git a/modules/gltf/SCsub b/modules/gltf/SCsub
index 5d03ee8361..3379404a00 100644
--- a/modules/gltf/SCsub
+++ b/modules/gltf/SCsub
@@ -4,7 +4,8 @@ Import("env")
Import("env_modules")
env_gltf = env_modules.Clone()
-env_gltf.Prepend(CPPPATH=["."])
# Godot's own source files
env_gltf.add_source_files(env.modules_sources, "*.cpp")
+if env["tools"]:
+ env_gltf.add_source_files(env.modules_sources, "editor/*.cpp")
diff --git a/modules/gltf/config.py b/modules/gltf/config.py
index a4736321fa..4ff2a6db38 100644
--- a/modules/gltf/config.py
+++ b/modules/gltf/config.py
@@ -8,12 +8,15 @@ def configure(env):
def get_doc_classes():
return [
- "EditorSceneImporterGLTF",
+ "EditorSceneFormatImporterBlend",
+ "EditorSceneFormatImporterGLTF",
"GLTFAccessor",
"GLTFAnimation",
"GLTFBufferView",
"GLTFCamera",
"GLTFDocument",
+ "GLTFDocumentExtension",
+ "GLTFDocumentExtensionConvertImporterMesh",
"GLTFLight",
"GLTFMesh",
"GLTFNode",
@@ -22,8 +25,6 @@ def get_doc_classes():
"GLTFSpecGloss",
"GLTFState",
"GLTFTexture",
- "GLTFDocumentExtension",
- "GLTFDocumentExtensionConvertImporterMesh",
]
diff --git a/modules/gltf/doc_classes/EditorSceneFormatImporterBlend.xml b/modules/gltf/doc_classes/EditorSceneFormatImporterBlend.xml
new file mode 100644
index 0000000000..b3a0381efc
--- /dev/null
+++ b/modules/gltf/doc_classes/EditorSceneFormatImporterBlend.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<class name="EditorSceneFormatImporterBlend" inherits="EditorSceneFormatImporter" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
+ <brief_description>
+ Importer for Blender's [code].blend[/code] scene file format.
+ </brief_description>
+ <description>
+ Imports Blender scenes in the [code].blend[/code] file format through the glTF 2.0 3D import pipeline. This importer requires Blender to be installed by the user, so that it can be used to export the scene as glTF 2.0.
+ The location of the Blender binary is set via the [code]filesystem/import/blend/blender_path[/code] editor setting.
+ This importer is only used if [member ProjectSettings.filesystem/import/blend/enabled] is enabled, otherwise [code].blend[/code] present in the project folder are not imported.
+ Blend import requires Blender 3.0.
+ Internally, the EditorSceneFormatImporterBlend uses the Blender glTF "Use Original" mode to reference external textures.
+ </description>
+ <tutorials>
+ </tutorials>
+</class>
diff --git a/modules/gltf/doc_classes/EditorSceneFormatImporterGLTF.xml b/modules/gltf/doc_classes/EditorSceneFormatImporterGLTF.xml
new file mode 100644
index 0000000000..5a6a2f52d9
--- /dev/null
+++ b/modules/gltf/doc_classes/EditorSceneFormatImporterGLTF.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<class name="EditorSceneFormatImporterGLTF" inherits="EditorSceneFormatImporter" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
+ <brief_description>
+ </brief_description>
+ <description>
+ </description>
+ <tutorials>
+ </tutorials>
+</class>
diff --git a/modules/gltf/doc_classes/GLTFDocument.xml b/modules/gltf/doc_classes/GLTFDocument.xml
index 7adabdc605..cb0e3b6754 100644
--- a/modules/gltf/doc_classes/GLTFDocument.xml
+++ b/modules/gltf/doc_classes/GLTFDocument.xml
@@ -24,6 +24,7 @@
<argument index="1" name="state" type="GLTFState" />
<argument index="2" name="flags" type="int" default="0" />
<argument index="3" name="bake_fps" type="int" default="30" />
+ <argument index="4" name="base_path" type="String" default="&quot;&quot;" />
<description>
</description>
</method>
diff --git a/modules/gltf/editor_scene_exporter_gltf_plugin.cpp b/modules/gltf/editor/editor_scene_exporter_gltf_plugin.cpp
index 601c70791c..23a7b7fed6 100644
--- a/modules/gltf/editor_scene_exporter_gltf_plugin.cpp
+++ b/modules/gltf/editor/editor_scene_exporter_gltf_plugin.cpp
@@ -28,23 +28,24 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#if TOOLS_ENABLED
+#ifdef TOOLS_ENABLED
+
#include "editor_scene_exporter_gltf_plugin.h"
+#include "../gltf_document.h"
+#include "../gltf_state.h"
+
#include "core/config/project_settings.h"
#include "core/error/error_list.h"
#include "core/object/object.h"
#include "core/templates/vector.h"
#include "editor/editor_file_dialog.h"
#include "editor/editor_file_system.h"
-#include "gltf_document.h"
-#include "gltf_state.h"
+#include "editor/editor_node.h"
#include "scene/3d/mesh_instance_3d.h"
#include "scene/gui/check_box.h"
#include "scene/main/node.h"
-#include "editor/editor_node.h"
-
String SceneExporterGLTFPlugin::get_name() const {
return "ConvertGLTF2";
}
diff --git a/modules/gltf/editor_scene_exporter_gltf_plugin.h b/modules/gltf/editor/editor_scene_exporter_gltf_plugin.h
index c2c3f5710c..5af46bc752 100644
--- a/modules/gltf/editor_scene_exporter_gltf_plugin.h
+++ b/modules/gltf/editor/editor_scene_exporter_gltf_plugin.h
@@ -31,7 +31,8 @@
#ifndef EDITOR_SCENE_EXPORTER_GLTF_PLUGIN_H
#define EDITOR_SCENE_EXPORTER_GLTF_PLUGIN_H
-#if TOOLS_ENABLED
+#ifdef TOOLS_ENABLED
+
#include "editor/editor_plugin.h"
#include "editor_scene_importer_gltf.h"
@@ -47,5 +48,7 @@ public:
bool has_main_screen() const override;
SceneExporterGLTFPlugin();
};
+
#endif // TOOLS_ENABLED
+
#endif // EDITOR_SCENE_EXPORTER_GLTF_PLUGIN_H
diff --git a/modules/gltf/editor/editor_scene_importer_blend.cpp b/modules/gltf/editor/editor_scene_importer_blend.cpp
new file mode 100644
index 0000000000..931b2bc73b
--- /dev/null
+++ b/modules/gltf/editor/editor_scene_importer_blend.cpp
@@ -0,0 +1,268 @@
+/*************************************************************************/
+/* editor_scene_importer_blend.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2022 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 "editor_scene_importer_blend.h"
+
+#if TOOLS_ENABLED
+
+#include "../gltf_document.h"
+#include "../gltf_state.h"
+
+#include "core/config/project_settings.h"
+#include "core/io/json.h"
+#include "editor/editor_settings.h"
+#include "scene/main/node.h"
+#include "scene/resources/animation.h"
+
+uint32_t EditorSceneFormatImporterBlend::get_import_flags() const {
+ return ImportFlags::IMPORT_SCENE | ImportFlags::IMPORT_ANIMATION;
+}
+
+void EditorSceneFormatImporterBlend::get_extensions(List<String> *r_extensions) const {
+ r_extensions->push_back("blend");
+}
+
+Node *EditorSceneFormatImporterBlend::import_scene(const String &p_path, uint32_t p_flags,
+ const Map<StringName, Variant> &p_options, int p_bake_fps,
+ List<String> *r_missing_deps, Error *r_err) {
+ // Parse JSON config.
+
+ const String source_global = ProjectSettings::get_singleton()->globalize_path(p_path).c_escape();
+ const String sink = ProjectSettings::get_singleton()->get_imported_files_path().plus_file(
+ vformat("%s-%s.gltf", p_path.get_file().get_basename(), p_path.md5_text()));
+ const String sink_global = ProjectSettings::get_singleton()->globalize_path(sink).c_escape();
+ const String json_parameters = vformat("{\"source\": \"%s\", \"sink\": \"%s\"}", source_global, sink_global);
+
+ Ref<JSON> json;
+ json.instantiate();
+ Error err = json->parse(json_parameters);
+ if (err != OK) {
+ if (r_err) {
+ *r_err = err;
+ }
+ ERR_PRINT(vformat("Blend config can't be read at line %s with error: %s",
+ json->get_error_line(), json->get_error_message()));
+ return nullptr;
+ }
+ Dictionary parameters = json->get_data();
+
+ // Handle configuration options.
+
+ String parameters_arg;
+
+ if (p_options.has(SNAME("blender/nodes/custom_properties")) && p_options[SNAME("blender/nodes/custom_properties")]) {
+ parameters_arg += "export_extras=True,";
+ } else {
+ parameters_arg += "export_extras=False,";
+ }
+ if (p_options.has(SNAME("blender/meshes/skins")) && p_options[SNAME("blender/meshes/skins")]) {
+ int32_t skins = p_options["blender/meshes/skins"];
+ if (skins == BLEND_BONE_INFLUENCES_NONE) {
+ parameters_arg += "export_all_influences=False,";
+ } else if (skins == BLEND_BONE_INFLUENCES_COMPATIBLE) {
+ parameters_arg += "export_all_influences=False,";
+ } else if (skins == BLEND_BONE_INFLUENCES_ALL) {
+ parameters_arg += "export_all_influences=True,";
+ }
+ parameters_arg += "export_skins=True,";
+ } else {
+ parameters_arg += "export_skins=False,";
+ }
+ if (p_options.has(SNAME("blender/nodes/cameras")) && p_options[SNAME("blender/nodes/cameras")]) {
+ parameters_arg += "export_cameras=True,";
+ } else {
+ parameters_arg += "export_cameras=False,";
+ }
+ if (p_options.has(SNAME("blender/nodes/lights")) && p_options[SNAME("blender/nodes/lights")]) {
+ parameters_arg += "export_lights=True,";
+ } else {
+ parameters_arg += "export_lights=False,";
+ }
+ if (p_options.has(SNAME("blender/meshes/colors")) && p_options[SNAME("blender/meshes/colors")]) {
+ parameters_arg += "export_colors=True,";
+ } else {
+ parameters_arg += "export_colors=False,";
+ }
+ if (p_options.has(SNAME("blender/nodes/visible")) && p_options[SNAME("blender/nodes/visible")]) {
+ int32_t visible = p_options["blender/nodes/visible"];
+ if (visible == BLEND_VISIBLE_VISIBLE_ONLY) {
+ parameters_arg += "use_visible=True,";
+ } else if (visible == BLEND_VISIBLE_RENDERABLE) {
+ parameters_arg += "use_renderable=True,";
+ } else if (visible == BLEND_VISIBLE_ALL) {
+ parameters_arg += "use_visible=False,use_renderable=False,";
+ }
+ } else {
+ parameters_arg += "use_visible=False,use_renderable=False,";
+ }
+ if (p_options.has(SNAME("blender/meshes/uvs")) && p_options[SNAME("blender/meshes/uvs")]) {
+ parameters_arg += "export_texcoords=True,";
+ } else {
+ parameters_arg += "export_texcoords=False,";
+ }
+ if (p_options.has(SNAME("blender/meshes/normals")) && p_options[SNAME("blender/meshes/normals")]) {
+ parameters_arg += "export_normals=True,";
+ } else {
+ parameters_arg += "export_normals=False,";
+ }
+ if (p_options.has(SNAME("blender/meshes/tangents")) && p_options[SNAME("blender/meshes/tangents")]) {
+ parameters_arg += "export_tangents=True,";
+ } else {
+ parameters_arg += "export_tangents=False,";
+ }
+ if (p_options.has(SNAME("blender/animation/group_tracks")) && p_options[SNAME("blender/animation/group_tracks")]) {
+ parameters_arg += "export_nla_strips=True,";
+ } else {
+ parameters_arg += "export_nla_strips=False,";
+ }
+ if (p_options.has(SNAME("blender/animation/limit_playback")) && p_options[SNAME("blender/animation/limit_playback")]) {
+ parameters_arg += "export_frame_range=True,";
+ } else {
+ parameters_arg += "export_frame_range=False,";
+ }
+ if (p_options.has(SNAME("blender/animation/always_sample")) && p_options[SNAME("blender/animation/always_sample")]) {
+ parameters_arg += "export_force_sampling=True,";
+ } else {
+ parameters_arg += "export_force_sampling=False,";
+ }
+ if (p_options.has(SNAME("blender/meshes/export_bones_deforming_mesh_only")) && p_options[SNAME("blender/meshes/export_bones_deforming_mesh_only")]) {
+ parameters_arg += "export_def_bones=True,";
+ } else {
+ parameters_arg += "export_def_bones=False,";
+ }
+ if (p_options.has(SNAME("blender/nodes/modifiers")) && p_options[SNAME("blender/nodes/modifiers")]) {
+ parameters_arg += "export_apply=True";
+ } else {
+ parameters_arg += "export_apply=False";
+ }
+
+ String unpack_all;
+ if (p_options.has(SNAME("blender/materials/unpack_enabled")) && p_options[SNAME("blender/materials/unpack_enabled")]) {
+ unpack_all = "bpy.ops.file.unpack_all(method='USE_LOCAL');";
+ }
+
+ // Prepare Blender export script.
+
+ String common_args = vformat("filepath='%s',", parameters["sink"]) +
+ "export_format='GLTF_SEPARATE',"
+ "export_yup=True," +
+ parameters_arg;
+ String script =
+ String("import bpy, sys;") +
+ "print('Blender 3.0 or higher is required.', file=sys.stderr) if bpy.app.version < (3, 0, 0) else None;" +
+ vformat("bpy.ops.wm.open_mainfile(filepath='%s');", parameters["source"]) +
+ unpack_all +
+ vformat("bpy.ops.export_scene.gltf(export_keep_originals=True,%s);", common_args);
+ print_verbose(script);
+
+ // Run script with configured Blender binary.
+
+ String blender_path = EDITOR_GET("filesystem/import/blend/blender_path");
+
+ List<String> args;
+ args.push_back("--background");
+ args.push_back("--python-expr");
+ args.push_back(script);
+
+ String standard_out;
+ int32_t ret = OS::get_singleton()->execute(blender_path, args, &standard_out, &ret, true);
+ print_verbose(standard_out);
+
+ if (ret != OK) {
+ if (r_err) {
+ *r_err = ERR_SCRIPT_FAILED;
+ }
+ ERR_PRINT(vformat("Blend import failed with error: %d.", ret));
+ return nullptr;
+ }
+
+ // Import the generated glTF.
+
+ // Use GLTFDocument instead of gltf importer to keep image references.
+ Ref<GLTFDocument> gltf;
+ gltf.instantiate();
+ Ref<GLTFState> state;
+ state.instantiate();
+ String base_dir;
+ if (p_options.has(SNAME("blender/materials/unpack_enabled")) && p_options[SNAME("blender/materials/unpack_enabled")]) {
+ base_dir = sink.get_base_dir();
+ }
+ err = gltf->append_from_file(sink.get_basename() + ".gltf", state, p_flags, p_bake_fps, base_dir);
+ if (err != OK) {
+ if (r_err) {
+ *r_err = FAILED;
+ }
+ return nullptr;
+ }
+ return gltf->generate_scene(state, p_bake_fps);
+}
+
+Ref<Animation> EditorSceneFormatImporterBlend::import_animation(const String &p_path, uint32_t p_flags,
+ const Map<StringName, Variant> &p_options, int p_bake_fps) {
+ return Ref<Animation>();
+}
+
+Variant EditorSceneFormatImporterBlend::get_option_visibility(const String &p_path, const String &p_option,
+ const Map<StringName, Variant> &p_options) {
+ if (p_option.begins_with("animation/")) {
+ if (p_option != "animation/import" && !bool(p_options["animation/import"])) {
+ return false;
+ }
+ }
+ return true;
+}
+
+void EditorSceneFormatImporterBlend::get_import_options(const String &p_path, List<ResourceImporter::ImportOption> *r_options) {
+#define ADD_OPTION_BOOL(PATH, VALUE) \
+ r_options->push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::BOOL, SNAME(PATH)), VALUE));
+#define ADD_OPTION_ENUM(PATH, ENUM_HINT, VALUE) \
+ r_options->push_back(ResourceImporter::ImportOption(PropertyInfo(Variant::INT, SNAME(PATH), PROPERTY_HINT_ENUM, ENUM_HINT), VALUE));
+
+ ADD_OPTION_ENUM("blender/nodes/visible", "Visible Only,Renderable,All", BLEND_VISIBLE_ALL);
+ ADD_OPTION_BOOL("blender/nodes/punctual_lights", true);
+ ADD_OPTION_BOOL("blender/nodes/cameras", true);
+ ADD_OPTION_BOOL("blender/nodes/custom_properties", true);
+ ADD_OPTION_ENUM("blender/nodes/modifiers", "No Modifiers,All Modifiers", BLEND_MODIFIERS_ALL);
+ ADD_OPTION_BOOL("blender/meshes/colors", false);
+ ADD_OPTION_BOOL("blender/meshes/uvs", true);
+ ADD_OPTION_BOOL("blender/meshes/normals", true);
+ ADD_OPTION_BOOL("blender/meshes/tangents", true);
+ ADD_OPTION_ENUM("blender/meshes/skins", "None,4 Influences (Compatible),All Influences", BLEND_BONE_INFLUENCES_ALL);
+ ADD_OPTION_BOOL("blender/meshes/export_bones_deforming_mesh_only", false);
+ ADD_OPTION_BOOL("blender/materials/unpack_enabled", true);
+ ADD_OPTION_BOOL("blender/animation/limit_playback", true);
+ ADD_OPTION_BOOL("blender/animation/always_sample", true);
+ ADD_OPTION_BOOL("blender/animation/group_tracks", true);
+
+#undef ADD_OPTION_BOOL
+#undef ADD_OPTION_ENUM
+}
+
+#endif // TOOLS_ENABLED
diff --git a/modules/gltf/editor/editor_scene_importer_blend.h b/modules/gltf/editor/editor_scene_importer_blend.h
new file mode 100644
index 0000000000..4bdf4c93a2
--- /dev/null
+++ b/modules/gltf/editor/editor_scene_importer_blend.h
@@ -0,0 +1,75 @@
+/*************************************************************************/
+/* editor_scene_importer_blend.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2022 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 EDITOR_SCENE_IMPORTER_BLEND_H
+#define EDITOR_SCENE_IMPORTER_BLEND_H
+
+#ifdef TOOLS_ENABLED
+
+#include "editor/import/resource_importer_scene.h"
+
+class Animation;
+class Node;
+
+class EditorSceneFormatImporterBlend : public EditorSceneFormatImporter {
+ GDCLASS(EditorSceneFormatImporterBlend, EditorSceneFormatImporter);
+
+public:
+ enum {
+ BLEND_VISIBLE_VISIBLE_ONLY,
+ BLEND_VISIBLE_RENDERABLE,
+ BLEND_VISIBLE_ALL
+ };
+ enum {
+ BLEND_BONE_INFLUENCES_NONE,
+ BLEND_BONE_INFLUENCES_COMPATIBLE,
+ BLEND_BONE_INFLUENCES_ALL
+ };
+ enum {
+ BLEND_MODIFIERS_NONE,
+ BLEND_MODIFIERS_ALL
+ };
+
+ virtual uint32_t get_import_flags() const override;
+ virtual void get_extensions(List<String> *r_extensions) const override;
+ virtual Node *import_scene(const String &p_path, uint32_t p_flags,
+ const Map<StringName, Variant> &p_options, int p_bake_fps,
+ List<String> *r_missing_deps, Error *r_err = nullptr) override;
+ virtual Ref<Animation> import_animation(const String &p_path, uint32_t p_flags,
+ const Map<StringName, Variant> &p_options, int p_bake_fps) override;
+ virtual void get_import_options(const String &p_path,
+ List<ResourceImporter::ImportOption> *r_options) override;
+ virtual Variant get_option_visibility(const String &p_path, const String &p_option,
+ const Map<StringName, Variant> &p_options) override;
+};
+
+#endif // TOOLS_ENABLED
+
+#endif // EDITOR_SCENE_IMPORTER_BLEND_H
diff --git a/modules/gltf/editor_scene_importer_gltf.cpp b/modules/gltf/editor/editor_scene_importer_gltf.cpp
index f063cc1e2b..1d6a82e58a 100644
--- a/modules/gltf/editor_scene_importer_gltf.cpp
+++ b/modules/gltf/editor/editor_scene_importer_gltf.cpp
@@ -28,14 +28,14 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#if TOOLS_ENABLED
+#ifdef TOOLS_ENABLED
+
#include "editor_scene_importer_gltf.h"
-#include "gltf_document.h"
-#include "gltf_state.h"
+#include "../gltf_document.h"
+#include "../gltf_state.h"
-#include "scene/3d/node_3d.h"
-#include "scene/animation/animation_player.h"
+#include "scene/main/node.h"
#include "scene/resources/animation.h"
uint32_t EditorSceneFormatImporterGLTF::get_import_flags() const {
@@ -47,26 +47,25 @@ void EditorSceneFormatImporterGLTF::get_extensions(List<String> *r_extensions) c
r_extensions->push_back("glb");
}
-Node *EditorSceneFormatImporterGLTF::import_scene(const String &p_path,
- uint32_t p_flags, const Map<StringName, Variant> &p_options, int p_bake_fps,
- List<String> *r_missing_deps,
- Error *r_err) {
+Node *EditorSceneFormatImporterGLTF::import_scene(const String &p_path, uint32_t p_flags,
+ const Map<StringName, Variant> &p_options, int p_bake_fps,
+ List<String> *r_missing_deps, Error *r_err) {
Ref<GLTFDocument> doc;
doc.instantiate();
Ref<GLTFState> state;
state.instantiate();
Error err = doc->append_from_file(p_path, state, p_flags, p_bake_fps);
if (err != OK) {
- *r_err = err;
+ if (r_err) {
+ *r_err = err;
+ }
return nullptr;
}
- Node *root = doc->generate_scene(state, p_bake_fps);
- return root;
+ return doc->generate_scene(state, p_bake_fps);
}
Ref<Animation> EditorSceneFormatImporterGLTF::import_animation(const String &p_path,
- uint32_t p_flags, const Map<StringName, Variant> &p_options,
- int p_bake_fps) {
+ uint32_t p_flags, const Map<StringName, Variant> &p_options, int p_bake_fps) {
return Ref<Animation>();
}
diff --git a/modules/gltf/editor_scene_importer_gltf.h b/modules/gltf/editor/editor_scene_importer_gltf.h
index 4410559b3d..1f62ca9537 100644
--- a/modules/gltf/editor_scene_importer_gltf.h
+++ b/modules/gltf/editor/editor_scene_importer_gltf.h
@@ -30,16 +30,13 @@
#ifndef EDITOR_SCENE_IMPORTER_GLTF_H
#define EDITOR_SCENE_IMPORTER_GLTF_H
-#ifdef TOOLS_ENABLED
-#include "gltf_state.h"
-#include "gltf_document_extension.h"
+#ifdef TOOLS_ENABLED
#include "editor/import/resource_importer_scene.h"
-#include "scene/main/node.h"
-#include "scene/resources/packed_scene.h"
class Animation;
+class Node;
class EditorSceneFormatImporterGLTF : public EditorSceneFormatImporter {
GDCLASS(EditorSceneFormatImporterGLTF, EditorSceneFormatImporter);
@@ -47,9 +44,13 @@ class EditorSceneFormatImporterGLTF : public EditorSceneFormatImporter {
public:
virtual uint32_t get_import_flags() const override;
virtual void get_extensions(List<String> *r_extensions) const override;
- virtual Node *import_scene(const String &p_path, uint32_t p_flags, const Map<StringName, Variant> &p_options, int p_bake_fps, List<String> *r_missing_deps, Error *r_err = nullptr) override;
- virtual Ref<Animation> import_animation(const String &p_path,
- uint32_t p_flags, const Map<StringName, Variant> &p_options, int p_bake_fps) override;
+ virtual Node *import_scene(const String &p_path, uint32_t p_flags,
+ const Map<StringName, Variant> &p_options, int p_bake_fps,
+ List<String> *r_missing_deps, Error *r_err = nullptr) override;
+ virtual Ref<Animation> import_animation(const String &p_path, uint32_t p_flags,
+ const Map<StringName, Variant> &p_options, int p_bake_fps) override;
};
+
#endif // TOOLS_ENABLED
+
#endif // EDITOR_SCENE_IMPORTER_GLTF_H
diff --git a/modules/gltf/gltf_document.cpp b/modules/gltf/gltf_document.cpp
index a8211569eb..ee756c6d2e 100644
--- a/modules/gltf/gltf_document.cpp
+++ b/modules/gltf/gltf_document.cpp
@@ -58,7 +58,6 @@
#include "core/variant/variant.h"
#include "core/version.h"
#include "drivers/png/png_driver_common.h"
-#include "editor/import/resource_importer_scene.h"
#include "scene/2d/node_2d.h"
#include "scene/3d/camera_3d.h"
#include "scene/3d/mesh_instance_3d.h"
@@ -79,6 +78,9 @@
#include "modules/gridmap/grid_map.h"
#endif // MODULE_GRIDMAP_ENABLED
+// FIXME: Hardcoded to avoid editor dependency.
+#define GLTF_IMPORT_USE_NAMED_SKIN_BINDS 16
+
#include <stdio.h>
#include <stdlib.h>
#include <cstdint>
@@ -5748,7 +5750,7 @@ void GLTFDocument::_generate_skeleton_bone_node(Ref<GLTFState> state, Node *scen
}
template <class T>
-struct EditorSceneFormatImporterGLTFInterpolate {
+struct SceneFormatImporterGLTFInterpolate {
T lerp(const T &a, const T &b, float c) const {
return a + (b - a) * c;
}
@@ -5774,7 +5776,7 @@ struct EditorSceneFormatImporterGLTFInterpolate {
// thank you for existing, partial specialization
template <>
-struct EditorSceneFormatImporterGLTFInterpolate<Quaternion> {
+struct SceneFormatImporterGLTFInterpolate<Quaternion> {
Quaternion lerp(const Quaternion &a, const Quaternion &b, const float c) const {
ERR_FAIL_COND_V_MSG(!a.is_normalized(), Quaternion(), "The quaternion \"a\" must be normalized.");
ERR_FAIL_COND_V_MSG(!b.is_normalized(), Quaternion(), "The quaternion \"b\" must be normalized.");
@@ -5813,7 +5815,7 @@ T GLTFDocument::_interpolate_track(const Vector<real_t> &p_times, const Vector<T
idx++;
}
- EditorSceneFormatImporterGLTFInterpolate<T> interp;
+ SceneFormatImporterGLTFInterpolate<T> interp;
switch (p_interp) {
case GLTFAnimation::INTERP_LINEAR: {
@@ -6756,8 +6758,8 @@ Error GLTFDocument::_serialize_file(Ref<GLTFState> state, const String p_path) {
}
void GLTFDocument::_bind_methods() {
- ClassDB::bind_method(D_METHOD("append_from_file", "path", "state", "flags", "bake_fps"),
- &GLTFDocument::append_from_file, DEFVAL(0), DEFVAL(30));
+ ClassDB::bind_method(D_METHOD("append_from_file", "path", "state", "flags", "bake_fps", "base_path"),
+ &GLTFDocument::append_from_file, DEFVAL(0), DEFVAL(30), DEFVAL(String()));
ClassDB::bind_method(D_METHOD("append_from_buffer", "bytes", "base_path", "state", "flags", "bake_fps"),
&GLTFDocument::append_from_buffer, DEFVAL(0), DEFVAL(30));
ClassDB::bind_method(D_METHOD("append_from_scene", "node", "state", "flags", "bake_fps"),
@@ -6906,7 +6908,7 @@ Node *GLTFDocument::generate_scene(Ref<GLTFState> state, int32_t p_bake_fps) {
Error GLTFDocument::append_from_scene(Node *p_node, Ref<GLTFState> state, uint32_t p_flags, int32_t p_bake_fps) {
ERR_FAIL_COND_V(state.is_null(), FAILED);
state->use_named_skin_binds =
- p_flags & EditorSceneFormatImporter::IMPORT_USE_NAMED_SKIN_BINDS;
+ p_flags & GLTF_IMPORT_USE_NAMED_SKIN_BINDS;
_convert_scene_node(state, p_node, -1, -1);
if (!state->buffers.size()) {
@@ -6926,7 +6928,7 @@ Error GLTFDocument::append_from_buffer(PackedByteArray p_bytes, String p_base_pa
// TODO Add missing texture and missing .bin file paths to r_missing_deps 2021-09-10 fire
Error err = FAILED;
state->use_named_skin_binds =
- p_flags & EditorSceneFormatImporter::IMPORT_USE_NAMED_SKIN_BINDS;
+ p_flags & GLTF_IMPORT_USE_NAMED_SKIN_BINDS;
FileAccessMemory *file_access = memnew(FileAccessMemory);
file_access->open_custom(p_bytes.ptr(), p_bytes.size());
err = _parse(state, p_base_path.get_base_dir(), file_access, p_bake_fps);
@@ -7022,20 +7024,22 @@ Error GLTFDocument::_parse_gltf_state(Ref<GLTFState> state, const String &p_sear
return OK;
}
-Error GLTFDocument::append_from_file(String p_path, Ref<GLTFState> r_state, uint32_t p_flags, int32_t p_bake_fps) {
+Error GLTFDocument::append_from_file(String p_path, Ref<GLTFState> r_state, uint32_t p_flags, int32_t p_bake_fps, String p_base_path) {
// TODO Add missing texture and missing .bin file paths to r_missing_deps 2021-09-10 fire
if (r_state == Ref<GLTFState>()) {
r_state.instantiate();
}
r_state->filename = p_path.get_file().get_basename();
- r_state->use_named_skin_binds =
- p_flags & EditorSceneFormatImporter::IMPORT_USE_NAMED_SKIN_BINDS;
+ r_state->use_named_skin_binds = p_flags & GLTF_IMPORT_USE_NAMED_SKIN_BINDS;
Error err;
FileAccess *f = FileAccess::open(p_path, FileAccess::READ, &err);
ERR_FAIL_COND_V(err != OK, ERR_FILE_CANT_OPEN);
ERR_FAIL_NULL_V(f, ERR_FILE_CANT_OPEN);
-
- err = _parse(r_state, p_path.get_base_dir(), f, p_bake_fps);
+ String base_path = p_base_path;
+ if (base_path.is_empty()) {
+ base_path = p_path.get_base_dir();
+ }
+ err = _parse(r_state, base_path, f, p_bake_fps);
ERR_FAIL_COND_V(err != OK, ERR_PARSE_ERROR);
return err;
}
diff --git a/modules/gltf/gltf_document.h b/modules/gltf/gltf_document.h
index c0649e0129..0b7664a616 100644
--- a/modules/gltf/gltf_document.h
+++ b/modules/gltf/gltf_document.h
@@ -381,7 +381,7 @@ private:
static float get_max_component(const Color &p_color);
public:
- Error append_from_file(String p_path, Ref<GLTFState> r_state, uint32_t p_flags = 0, int32_t p_bake_fps = 30);
+ Error append_from_file(String p_path, Ref<GLTFState> r_state, uint32_t p_flags = 0, int32_t p_bake_fps = 30, String p_base_path = String());
Error append_from_buffer(PackedByteArray p_bytes, String p_base_path, Ref<GLTFState> r_state, uint32_t p_flags = 0, int32_t p_bake_fps = 30);
Error append_from_scene(Node *p_node, Ref<GLTFState> r_state, uint32_t p_flags = 0, int32_t p_bake_fps = 30);
diff --git a/modules/gltf/gltf_mesh.h b/modules/gltf/gltf_mesh.h
index aeab1ad68f..4a0533933a 100644
--- a/modules/gltf/gltf_mesh.h
+++ b/modules/gltf/gltf_mesh.h
@@ -32,7 +32,6 @@
#define GLTF_MESH_H
#include "core/io/resource.h"
-#include "editor/import/resource_importer_scene.h"
#include "scene/3d/importer_mesh_instance_3d.h"
#include "scene/resources/importer_mesh.h"
#include "scene/resources/mesh.h"
diff --git a/modules/gltf/register_types.cpp b/modules/gltf/register_types.cpp
index 6ab202096d..1669d40269 100644
--- a/modules/gltf/register_types.cpp
+++ b/modules/gltf/register_types.cpp
@@ -30,9 +30,8 @@
#include "register_types.h"
-#include "editor/editor_node.h"
-#include "editor_scene_exporter_gltf_plugin.h"
-#include "editor_scene_importer_gltf.h"
+#ifndef _3D_DISABLED
+
#include "gltf_accessor.h"
#include "gltf_animation.h"
#include "gltf_buffer_view.h"
@@ -49,43 +48,76 @@
#include "gltf_state.h"
#include "gltf_texture.h"
-#ifndef _3D_DISABLED
#ifdef TOOLS_ENABLED
+#include "core/config/project_settings.h"
+#include "editor/editor_node.h"
+#include "editor/editor_scene_exporter_gltf_plugin.h"
+#include "editor/editor_scene_importer_blend.h"
+#include "editor/editor_scene_importer_gltf.h"
+#include "editor/editor_settings.h"
+
static void _editor_init() {
Ref<EditorSceneFormatImporterGLTF> import_gltf;
import_gltf.instantiate();
ResourceImporterScene::get_singleton()->add_importer(import_gltf);
+
+ // Blend to glTF importer.
+ bool blend_enabled = GLOBAL_GET("filesystem/import/blend/enabled");
+ // Defined here because EditorSettings doesn't exist in `register_gltf_types` yet.
+ String blender_path = EDITOR_DEF_RST("filesystem/import/blend/blender_path", "");
+ EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING,
+ "filesystem/import/blend/blender_path", PROPERTY_HINT_GLOBAL_FILE));
+ if (blend_enabled) {
+ DirAccessRef da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
+ if (blender_path.is_empty()) {
+ WARN_PRINT("Blend file import is enabled, but no Blender path is configured. Blend files will not be imported.");
+ } else if (!da->file_exists(blender_path)) {
+ WARN_PRINT("Blend file import is enabled, but the Blender path doesn't point to a valid Blender executable. Blend files will not be imported.");
+ } else {
+ Ref<EditorSceneFormatImporterBlend> importer;
+ importer.instantiate();
+ ResourceImporterScene::get_singleton()->add_importer(importer);
+ }
+ }
}
-#endif
-#endif
+#endif // TOOLS_ENABLED
void register_gltf_types() {
-#ifndef _3D_DISABLED
+ // glTF API available at runtime.
+ GDREGISTER_CLASS(GLTFAccessor);
+ GDREGISTER_CLASS(GLTFAnimation);
+ GDREGISTER_CLASS(GLTFBufferView);
+ GDREGISTER_CLASS(GLTFCamera);
+ GDREGISTER_CLASS(GLTFDocument);
+ GDREGISTER_CLASS(GLTFDocumentExtension);
+ GDREGISTER_CLASS(GLTFDocumentExtensionConvertImporterMesh);
+ GDREGISTER_CLASS(GLTFLight);
+ GDREGISTER_CLASS(GLTFNode);
+ GDREGISTER_CLASS(GLTFSkeleton);
+ GDREGISTER_CLASS(GLTFSkin);
+ GDREGISTER_CLASS(GLTFSpecGloss);
+ GDREGISTER_CLASS(GLTFState);
+ GDREGISTER_CLASS(GLTFTexture);
+
#ifdef TOOLS_ENABLED
+ // Editor-specific API.
ClassDB::APIType prev_api = ClassDB::get_current_api();
ClassDB::set_current_api(ClassDB::API_EDITOR);
- GDREGISTER_CLASS(EditorSceneFormatImporterGLTF);
+
GDREGISTER_CLASS(GLTFMesh);
+ GDREGISTER_CLASS(EditorSceneFormatImporterGLTF);
EditorPlugins::add_by_type<SceneExporterGLTFPlugin>();
+
+ // Blend to glTF importer.
+ GLOBAL_DEF_RST("filesystem/import/blend/enabled", false); // Defined here to catch in docs.
+ GDREGISTER_CLASS(EditorSceneFormatImporterBlend);
+
ClassDB::set_current_api(prev_api);
EditorNode::add_init_callback(_editor_init);
-#endif
- GDREGISTER_CLASS(GLTFSpecGloss);
- GDREGISTER_CLASS(GLTFNode);
- GDREGISTER_CLASS(GLTFAnimation);
- GDREGISTER_CLASS(GLTFBufferView);
- GDREGISTER_CLASS(GLTFAccessor);
- GDREGISTER_CLASS(GLTFTexture);
- GDREGISTER_CLASS(GLTFSkeleton);
- GDREGISTER_CLASS(GLTFSkin);
- GDREGISTER_CLASS(GLTFCamera);
- GDREGISTER_CLASS(GLTFLight);
- GDREGISTER_CLASS(GLTFState);
- GDREGISTER_CLASS(GLTFDocumentExtensionConvertImporterMesh);
- GDREGISTER_CLASS(GLTFDocumentExtension);
- GDREGISTER_CLASS(GLTFDocument);
-#endif
+#endif // TOOLS_ENABLED
}
void unregister_gltf_types() {
}
+
+#endif // _3D_DISABLED
diff --git a/modules/gridmap/SCsub b/modules/gridmap/SCsub
index 970ce534f0..52777235b8 100644
--- a/modules/gridmap/SCsub
+++ b/modules/gridmap/SCsub
@@ -5,4 +5,7 @@ Import("env_modules")
env_gridmap = env_modules.Clone()
+# Godot's own source files
env_gridmap.add_source_files(env.modules_sources, "*.cpp")
+if env["tools"]:
+ env_gridmap.add_source_files(env.modules_sources, "editor/*.cpp")
diff --git a/modules/gridmap/grid_map_editor_plugin.cpp b/modules/gridmap/editor/grid_map_editor_plugin.cpp
index e8e096d52b..68968325dd 100644
--- a/modules/gridmap/grid_map_editor_plugin.cpp
+++ b/modules/gridmap/editor/grid_map_editor_plugin.cpp
@@ -29,14 +29,16 @@
/*************************************************************************/
#include "grid_map_editor_plugin.h"
+
+#ifdef TOOLS_ENABLED
+
#include "core/input/input.h"
+#include "core/os/keyboard.h"
#include "editor/editor_node.h"
#include "editor/editor_scale.h"
#include "editor/editor_settings.h"
#include "editor/plugins/node_3d_editor_plugin.h"
#include "scene/3d/camera_3d.h"
-
-#include "core/os/keyboard.h"
#include "scene/main/window.h"
void GridMapEditor::_node_removed(Node *p_node) {
@@ -1479,3 +1481,5 @@ GridMapEditorPlugin::GridMapEditorPlugin() {
GridMapEditorPlugin::~GridMapEditorPlugin() {
}
+
+#endif // TOOLS_ENABLED
diff --git a/modules/gridmap/grid_map_editor_plugin.h b/modules/gridmap/editor/grid_map_editor_plugin.h
index c44c4ca7e0..adb0da6e2c 100644
--- a/modules/gridmap/grid_map_editor_plugin.h
+++ b/modules/gridmap/editor/grid_map_editor_plugin.h
@@ -31,8 +31,10 @@
#ifndef GRID_MAP_EDITOR_PLUGIN_H
#define GRID_MAP_EDITOR_PLUGIN_H
+#ifdef TOOLS_ENABLED
+
+#include "../grid_map.h"
#include "editor/editor_plugin.h"
-#include "grid_map.h"
#include "scene/gui/item_list.h"
#include "scene/gui/slider.h"
#include "scene/gui/spin_box.h"
@@ -249,4 +251,6 @@ public:
~GridMapEditorPlugin();
};
-#endif // CUBE_GRID_MAP_EDITOR_PLUGIN_H
+#endif // TOOLS_ENABLED
+
+#endif // GRID_MAP_EDITOR_PLUGIN_H
diff --git a/modules/gridmap/register_types.cpp b/modules/gridmap/register_types.cpp
index f05c5de18b..d7c9f5c92e 100644
--- a/modules/gridmap/register_types.cpp
+++ b/modules/gridmap/register_types.cpp
@@ -28,21 +28,25 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "register_types.h"
#ifndef _3D_DISABLED
+
+#include "register_types.h"
+
#include "core/object/class_db.h"
#include "grid_map.h"
-#include "grid_map_editor_plugin.h"
+
+#ifdef TOOLS_ENABLED
+#include "editor/grid_map_editor_plugin.h"
#endif
void register_gridmap_types() {
-#ifndef _3D_DISABLED
GDREGISTER_CLASS(GridMap);
#ifdef TOOLS_ENABLED
EditorPlugins::add_by_type<GridMapEditorPlugin>();
#endif
-#endif
}
void unregister_gridmap_types() {
}
+
+#endif // _3D_DISABLED
diff --git a/modules/lightmapper_rd/lightmapper_rd.cpp b/modules/lightmapper_rd/lightmapper_rd.cpp
index 68b3a41b9a..faa1d21490 100644
--- a/modules/lightmapper_rd/lightmapper_rd.cpp
+++ b/modules/lightmapper_rd/lightmapper_rd.cpp
@@ -29,6 +29,7 @@
/*************************************************************************/
#include "lightmapper_rd.h"
+
#include "core/config/project_settings.h"
#include "core/math/geometry_2d.h"
#include "lm_blendseams.glsl.gen.h"
@@ -174,7 +175,7 @@ Lightmapper::BakeError LightmapperRD::_blit_meshes_into_atlas(int p_max_texture_
}
if (p_step_function) {
- p_step_function(0.1, TTR("Determining optimal atlas size"), p_bake_userdata, true);
+ p_step_function(0.1, RTR("Determining optimal atlas size"), p_bake_userdata, true);
}
atlas_size = Size2i(max, max);
@@ -243,7 +244,7 @@ Lightmapper::BakeError LightmapperRD::_blit_meshes_into_atlas(int p_max_texture_
emission_images.resize(atlas_slices);
if (p_step_function) {
- p_step_function(0.2, TTR("Blitting albedo and emission"), p_bake_userdata, true);
+ p_step_function(0.2, RTR("Blitting albedo and emission"), p_bake_userdata, true);
}
for (int i = 0; i < atlas_slices; i++) {
@@ -295,7 +296,7 @@ void LightmapperRD::_create_acceleration_structures(RenderingDevice *rd, Size2i
for (int m_i = 0; m_i < mesh_instances.size(); m_i++) {
if (p_step_function) {
float p = float(m_i + 1) / mesh_instances.size() * 0.1;
- p_step_function(0.3 + p, vformat(TTR("Plotting mesh into acceleration structure %d/%d"), m_i + 1, mesh_instances.size()), p_bake_userdata, false);
+ p_step_function(0.3 + p, vformat(RTR("Plotting mesh into acceleration structure %d/%d"), m_i + 1, mesh_instances.size()), p_bake_userdata, false);
}
HashMap<Edge, EdgeUV2, EdgeHash> edges;
@@ -409,7 +410,7 @@ void LightmapperRD::_create_acceleration_structures(RenderingDevice *rd, Size2i
seams.sort();
if (p_step_function) {
- p_step_function(0.4, TTR("Optimizing acceleration structure"), p_bake_userdata, true);
+ p_step_function(0.4, RTR("Optimizing acceleration structure"), p_bake_userdata, true);
}
//fill list of triangles in grid
@@ -668,7 +669,7 @@ LightmapperRD::BakeError LightmapperRD::_dilate(RenderingDevice *rd, Ref<RDShade
LightmapperRD::BakeError LightmapperRD::bake(BakeQuality p_quality, bool p_use_denoiser, int p_bounces, float p_bias, int p_max_texture_size, bool p_bake_sh, GenerateProbes p_generate_probes, const Ref<Image> &p_environment_panorama, const Basis &p_environment_transform, BakeStepFunc p_step_function, void *p_bake_userdata) {
if (p_step_function) {
- p_step_function(0.0, TTR("Begin Bake"), p_bake_userdata, true);
+ p_step_function(0.0, RTR("Begin Bake"), p_bake_userdata, true);
}
bake_textures.clear();
int grid_size = 128;
@@ -819,7 +820,7 @@ LightmapperRD::BakeError LightmapperRD::bake(BakeQuality p_quality, bool p_use_d
_create_acceleration_structures(rd, atlas_size, atlas_slices, bounds, grid_size, probe_positions, p_generate_probes, slice_triangle_count, slice_seam_count, vertex_buffer, triangle_buffer, lights_buffer, triangle_cell_indices_buffer, probe_positions_buffer, grid_texture, seams_buffer, p_step_function, p_bake_userdata);
if (p_step_function) {
- p_step_function(0.47, TTR("Preparing shaders"), p_bake_userdata, true);
+ p_step_function(0.47, RTR("Preparing shaders"), p_bake_userdata, true);
}
//shaders
@@ -1046,7 +1047,7 @@ LightmapperRD::BakeError LightmapperRD::bake(BakeQuality p_quality, bool p_use_d
rd->sync();
if (p_step_function) {
- p_step_function(0.49, TTR("Un-occluding geometry"), p_bake_userdata, true);
+ p_step_function(0.49, RTR("Un-occluding geometry"), p_bake_userdata, true);
}
/* UNOCCLUDE */
@@ -1086,7 +1087,7 @@ LightmapperRD::BakeError LightmapperRD::bake(BakeQuality p_quality, bool p_use_d
}
if (p_step_function) {
- p_step_function(0.5, TTR("Plot direct lighting"), p_bake_userdata, true);
+ p_step_function(0.5, RTR("Plot direct lighting"), p_bake_userdata, true);
}
/* PRIMARY (direct) LIGHT PASS */
@@ -1166,7 +1167,7 @@ LightmapperRD::BakeError LightmapperRD::bake(BakeQuality p_quality, bool p_use_d
/* SECONDARY (indirect) LIGHT PASS(ES) */
if (p_step_function) {
- p_step_function(0.6, TTR("Integrate indirect lighting"), p_bake_userdata, true);
+ p_step_function(0.6, RTR("Integrate indirect lighting"), p_bake_userdata, true);
}
if (p_bounces > 0) {
@@ -1298,7 +1299,7 @@ LightmapperRD::BakeError LightmapperRD::bake(BakeQuality p_quality, bool p_use_d
int total = (atlas_slices * x_regions * y_regions * ray_iterations);
int percent = count * 100 / total;
float p = float(count) / total * 0.1;
- p_step_function(0.6 + p, vformat(TTR("Bounce %d/%d: Integrate indirect lighting %d%%"), b + 1, p_bounces, percent), p_bake_userdata, false);
+ p_step_function(0.6 + p, vformat(RTR("Bounce %d/%d: Integrate indirect lighting %d%%"), b + 1, p_bounces, percent), p_bake_userdata, false);
}
}
}
@@ -1323,7 +1324,7 @@ LightmapperRD::BakeError LightmapperRD::bake(BakeQuality p_quality, bool p_use_d
light_probe_buffer = rd->storage_buffer_create(sizeof(float) * 4 * 9 * probe_positions.size());
if (p_step_function) {
- p_step_function(0.7, TTR("Baking lightprobes"), p_bake_userdata, true);
+ p_step_function(0.7, RTR("Baking lightprobes"), p_bake_userdata, true);
}
Vector<RD::Uniform> uniforms;
@@ -1398,7 +1399,7 @@ LightmapperRD::BakeError LightmapperRD::bake(BakeQuality p_quality, bool p_use_d
if (p_step_function) {
int percent = i * 100 / ray_iterations;
float p = float(i) / ray_iterations * 0.1;
- p_step_function(0.7 + p, vformat(TTR("Integrating light probes %d%%"), percent), p_bake_userdata, false);
+ p_step_function(0.7 + p, vformat(RTR("Integrating light probes %d%%"), percent), p_bake_userdata, false);
}
}
@@ -1434,7 +1435,7 @@ LightmapperRD::BakeError LightmapperRD::bake(BakeQuality p_quality, bool p_use_d
if (p_use_denoiser) {
if (p_step_function) {
- p_step_function(0.8, TTR("Denoising"), p_bake_userdata, true);
+ p_step_function(0.8, RTR("Denoising"), p_bake_userdata, true);
}
Ref<LightmapDenoiser> denoiser = LightmapDenoiser::create();
@@ -1639,7 +1640,7 @@ LightmapperRD::BakeError LightmapperRD::bake(BakeQuality p_quality, bool p_use_d
}
#endif
if (p_step_function) {
- p_step_function(0.9, TTR("Retrieving textures"), p_bake_userdata, true);
+ p_step_function(0.9, RTR("Retrieving textures"), p_bake_userdata, true);
}
for (int i = 0; i < atlas_slices * (p_bake_sh ? 4 : 1); i++) {
diff --git a/modules/mono/SCsub b/modules/mono/SCsub
index db35e804aa..3bafa351a9 100644
--- a/modules/mono/SCsub
+++ b/modules/mono/SCsub
@@ -63,5 +63,4 @@ elif env["platform"] == "android":
if env["tools"]:
env_mono.add_source_files(env.modules_sources, "editor/*.cpp")
-
-SConscript("editor_templates/SCsub")
+ SConscript("editor/script_templates/SCsub")
diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp
index 7ed0422236..8acd119880 100644
--- a/modules/mono/csharp_script.cpp
+++ b/modules/mono/csharp_script.cpp
@@ -45,17 +45,17 @@
#ifdef TOOLS_ENABLED
#include "core/os/keyboard.h"
#include "editor/bindings_generator.h"
+#include "editor/editor_internal_calls.h"
#include "editor/editor_node.h"
#include "editor/editor_settings.h"
#include "editor/node_dock.h"
+#include "editor/script_templates/templates.gen.h"
#endif
#ifdef DEBUG_METHODS_ENABLED
#include "class_db_api_json.h"
#endif
-#include "editor/editor_internal_calls.h"
-#include "editor_templates/templates.gen.h"
#include "godotsharp_dirs.h"
#include "mono_gd/gd_mono_cache.h"
#include "mono_gd/gd_mono_class.h"
@@ -373,11 +373,13 @@ Ref<Script> CSharpLanguage::make_template(const String &p_template, const String
Vector<ScriptLanguage::ScriptTemplate> CSharpLanguage::get_built_in_templates(StringName p_object) {
Vector<ScriptLanguage::ScriptTemplate> templates;
+#ifdef TOOLS_ENABLED
for (int i = 0; i < TEMPLATES_ARRAY_SIZE; i++) {
if (TEMPLATES[i].inherit == p_object) {
templates.append(TEMPLATES[i]);
}
}
+#endif
return templates;
}
@@ -386,7 +388,7 @@ String CSharpLanguage::validate_path(const String &p_path) const {
List<String> keywords;
get_reserved_words(&keywords);
if (keywords.find(class_name)) {
- return TTR("Class name can't be a reserved keyword");
+ return RTR("Class name can't be a reserved keyword");
}
return "";
}
diff --git a/modules/mono/csharp_script.h b/modules/mono/csharp_script.h
index 3b97d2acc4..1e5f218c95 100644
--- a/modules/mono/csharp_script.h
+++ b/modules/mono/csharp_script.h
@@ -202,9 +202,9 @@ public:
void set_source_code(const String &p_code) override;
#ifdef TOOLS_ENABLED
- virtual const Vector<DocData::ClassDoc> &get_documentation() const override {
+ virtual Vector<DocData::ClassDoc> get_documentation() const override {
// TODO
- static Vector<DocData::ClassDoc> docs;
+ Vector<DocData::ClassDoc> docs;
return docs;
}
#endif // TOOLS_ENABLED
diff --git a/modules/mono/editor_templates/CharacterBody2D/basic_movement.cs b/modules/mono/editor/script_templates/CharacterBody2D/basic_movement.cs
index 2ca81ab7cd..2ca81ab7cd 100644
--- a/modules/mono/editor_templates/CharacterBody2D/basic_movement.cs
+++ b/modules/mono/editor/script_templates/CharacterBody2D/basic_movement.cs
diff --git a/modules/mono/editor_templates/CharacterBody3D/basic_movement.cs b/modules/mono/editor/script_templates/CharacterBody3D/basic_movement.cs
index a6935fe497..a6935fe497 100644
--- a/modules/mono/editor_templates/CharacterBody3D/basic_movement.cs
+++ b/modules/mono/editor/script_templates/CharacterBody3D/basic_movement.cs
diff --git a/modules/mono/editor_templates/EditorPlugin/plugin.cs b/modules/mono/editor/script_templates/EditorPlugin/plugin.cs
index eba5fd12a4..eba5fd12a4 100644
--- a/modules/mono/editor_templates/EditorPlugin/plugin.cs
+++ b/modules/mono/editor/script_templates/EditorPlugin/plugin.cs
diff --git a/modules/mono/editor_templates/EditorScript/basic_editor_script.cs b/modules/mono/editor/script_templates/EditorScript/basic_editor_script.cs
index 1b347edc1c..1b347edc1c 100644
--- a/modules/mono/editor_templates/EditorScript/basic_editor_script.cs
+++ b/modules/mono/editor/script_templates/EditorScript/basic_editor_script.cs
diff --git a/modules/mono/editor_templates/Node/default.cs b/modules/mono/editor/script_templates/Node/default.cs
index 4c86d1666f..4c86d1666f 100644
--- a/modules/mono/editor_templates/Node/default.cs
+++ b/modules/mono/editor/script_templates/Node/default.cs
diff --git a/modules/mono/editor_templates/Object/empty.cs b/modules/mono/editor/script_templates/Object/empty.cs
index 34526d514f..34526d514f 100644
--- a/modules/mono/editor_templates/Object/empty.cs
+++ b/modules/mono/editor/script_templates/Object/empty.cs
diff --git a/modules/mono/editor_templates/SCsub b/modules/mono/editor/script_templates/SCsub
index 39f6cb5c01..39f6cb5c01 100644
--- a/modules/mono/editor_templates/SCsub
+++ b/modules/mono/editor/script_templates/SCsub
diff --git a/modules/mono/editor_templates/VisualShaderNodeCustom/basic.cs b/modules/mono/editor/script_templates/VisualShaderNodeCustom/basic.cs
index a1b93e7daa..a1b93e7daa 100644
--- a/modules/mono/editor_templates/VisualShaderNodeCustom/basic.cs
+++ b/modules/mono/editor/script_templates/VisualShaderNodeCustom/basic.cs
diff --git a/modules/navigation/SCsub b/modules/navigation/SCsub
index 22b5509b32..24a6b12639 100644
--- a/modules/navigation/SCsub
+++ b/modules/navigation/SCsub
@@ -57,6 +57,8 @@ env.modules_sources += thirdparty_obj
module_obj = []
env_navigation.add_source_files(module_obj, "*.cpp")
+if env["tools"]:
+ env_navigation.add_source_files(module_obj, "editor/*.cpp")
env.modules_sources += module_obj
# Needed to force rebuilding the module files when the thirdparty library is updated.
diff --git a/modules/navigation/navigation_mesh_editor_plugin.cpp b/modules/navigation/editor/navigation_mesh_editor_plugin.cpp
index 511490ba07..c243e3e6e3 100644
--- a/modules/navigation/navigation_mesh_editor_plugin.cpp
+++ b/modules/navigation/editor/navigation_mesh_editor_plugin.cpp
@@ -28,13 +28,14 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifdef TOOLS_ENABLED
#include "navigation_mesh_editor_plugin.h"
+#ifdef TOOLS_ENABLED
+
+#include "../navigation_mesh_generator.h"
#include "core/io/marshalls.h"
#include "core/io/resource_saver.h"
#include "editor/editor_node.h"
-#include "navigation_mesh_generator.h"
#include "scene/3d/mesh_instance_3d.h"
#include "scene/gui/box_container.h"
@@ -153,4 +154,4 @@ NavigationMeshEditorPlugin::NavigationMeshEditorPlugin() {
NavigationMeshEditorPlugin::~NavigationMeshEditorPlugin() {
}
-#endif
+#endif // TOOLS_ENABLED
diff --git a/modules/navigation/navigation_mesh_editor_plugin.h b/modules/navigation/editor/navigation_mesh_editor_plugin.h
index d581b453b3..3c3e804fd2 100644
--- a/modules/navigation/navigation_mesh_editor_plugin.h
+++ b/modules/navigation/editor/navigation_mesh_editor_plugin.h
@@ -81,6 +81,6 @@ public:
~NavigationMeshEditorPlugin();
};
-#endif
+#endif // TOOLS_ENABLED
-#endif
+#endif // NAVIGATION_MESH_EDITOR_PLUGIN_H
diff --git a/modules/navigation/register_types.cpp b/modules/navigation/register_types.cpp
index e2264e843c..218f2c2937 100644
--- a/modules/navigation/register_types.cpp
+++ b/modules/navigation/register_types.cpp
@@ -40,7 +40,7 @@
#endif
#ifdef TOOLS_ENABLED
-#include "navigation_mesh_editor_plugin.h"
+#include "editor/navigation_mesh_editor_plugin.h"
#endif
#ifndef _3D_DISABLED
diff --git a/modules/opensimplex/SCsub b/modules/noise/SCsub
index 86d77c3dfb..3e8395b9b1 100644
--- a/modules/opensimplex/SCsub
+++ b/modules/noise/SCsub
@@ -3,21 +3,21 @@
Import("env")
Import("env_modules")
-env_opensimplex = env_modules.Clone()
+env_noise = env_modules.Clone()
# Thirdparty source files
thirdparty_obj = []
-thirdparty_dir = "#thirdparty/misc/"
+thirdparty_dir = "#thirdparty/noise/"
thirdparty_sources = [
- "open-simplex-noise.c",
+ # Add C++ source files for noise modules here
]
thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]
-env_opensimplex.Prepend(CPPPATH=[thirdparty_dir])
+env_noise.Prepend(CPPPATH=[thirdparty_dir])
-env_thirdparty = env_opensimplex.Clone()
+env_thirdparty = env_noise.Clone()
env_thirdparty.disable_warnings()
env_thirdparty.add_source_files(thirdparty_obj, thirdparty_sources)
env.modules_sources += thirdparty_obj
@@ -26,7 +26,7 @@ env.modules_sources += thirdparty_obj
module_obj = []
-env_opensimplex.add_source_files(module_obj, "*.cpp")
+env_noise.add_source_files(module_obj, "*.cpp")
env.modules_sources += module_obj
# Needed to force rebuilding the module files when the thirdparty library is updated.
diff --git a/modules/opensimplex/config.py b/modules/noise/config.py
index 90b85dbd70..74db20f2a4 100644
--- a/modules/opensimplex/config.py
+++ b/modules/noise/config.py
@@ -8,8 +8,9 @@ def configure(env):
def get_doc_classes():
return [
+ "FastNoiseLite",
+ "Noise",
"NoiseTexture",
- "OpenSimplexNoise",
]
diff --git a/modules/noise/doc_classes/FastNoiseLite.xml b/modules/noise/doc_classes/FastNoiseLite.xml
new file mode 100644
index 0000000000..b6d91850c4
--- /dev/null
+++ b/modules/noise/doc_classes/FastNoiseLite.xml
@@ -0,0 +1,169 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<class name="FastNoiseLite" inherits="Noise" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
+ <brief_description>
+ Generates noise using the FastNoiseLite library.
+ </brief_description>
+ <description>
+ This class generates noise using the FastNoiseLite library, which is a collection of several noise algorithms including Cellular, Perlin, Value, and more.
+ Most generated noise values are in the range of [code][-1,1][/code], however not always. Some of the cellular noise algorithms return results above [code]1[/code].
+ </description>
+ <tutorials>
+ </tutorials>
+ <members>
+ <member name="cellular_distance_function" type="int" setter="set_cellular_distance_function" getter="get_cellular_distance_function" enum="FastNoiseLite.CellularDistanceFunction" default="0">
+ Determines how the distance to the nearest/second-nearest point is computed. See [enum CellularDistanceFunction] for options.
+ </member>
+ <member name="cellular_jitter" type="float" setter="set_cellular_jitter" getter="get_cellular_jitter" default="0.45">
+ Maximum distance a point can move off of its grid position. Set to [code]0[/code] for an even grid.
+ </member>
+ <member name="cellular_return_type" type="int" setter="set_cellular_return_type" getter="get_cellular_return_type" enum="FastNoiseLite.CellularReturnType" default="0">
+ Return type from cellular noise calculations. See [enum CellularReturnType].
+ </member>
+ <member name="color_ramp" type="Gradient" setter="set_color_ramp" getter="get_color_ramp">
+ A [Gradient] which is used to map the luminance of each pixel to a color value.
+ </member>
+ <member name="domain_warp_amplitude" type="float" setter="set_domain_warp_amplitude" getter="get_domain_warp_amplitude" default="30.0">
+ Sets the maximum warp distance from the origin.
+ </member>
+ <member name="domain_warp_enabled" type="bool" setter="set_domain_warp_enabled" getter="is_domain_warp_enabled" default="false">
+ If enabled, another FastNoiseLite instance is used to warp the space, resulting in a distortion of the noise.
+ </member>
+ <member name="domain_warp_fractal_gain" type="float" setter="set_domain_warp_fractal_gain" getter="get_domain_warp_fractal_gain" default="0.5">
+ Determines the strength of each subsequent layer of the noise which is used to warp the space.
+ A low value places more emphasis on the lower frequency base layers, while a high value puts more emphasis on the higher frequency layers.
+ </member>
+ <member name="domain_warp_fractal_lacunarity" type="float" setter="set_domain_warp_fractal_lacunarity" getter="get_domain_warp_fractal_lacunarity" default="6.0">
+ Octave lacunarity of the fractal noise which warps the space. Increasing this value results in higher octaves producing noise with finer details and a rougher appearance.
+ </member>
+ <member name="domain_warp_fractal_octaves" type="int" setter="set_domain_warp_fractal_octaves" getter="get_domain_warp_fractal_octaves" default="5">
+ The number of noise layers that are sampled to get the final value for the fractal noise which warps the space.
+ </member>
+ <member name="domain_warp_fractal_type" type="int" setter="set_domain_warp_fractal_type" getter="get_domain_warp_fractal_type" enum="FastNoiseLite.DomainWarpFractalType" default="1">
+ The method for combining octaves into a fractal which is used to warp the space. See [enum DomainWarpFractalType].
+ </member>
+ <member name="domain_warp_frequency" type="float" setter="set_domain_warp_frequency" getter="get_domain_warp_frequency" default="0.05">
+ Frequency of the noise which warps the space. Low frequency results in smooth noise while high frequency results in rougher, more granular noise.
+ </member>
+ <member name="domain_warp_type" type="int" setter="set_domain_warp_type" getter="get_domain_warp_type" enum="FastNoiseLite.DomainWarpType" default="0">
+ Sets the warp algorithm. See [enum DomainWarpType].
+ </member>
+ <member name="fractal_gain" type="float" setter="set_fractal_gain" getter="get_fractal_gain" default="0.5">
+ Determines the strength of each subsequent layer of noise in fractal noise.
+ A low value places more emphasis on the lower frequency base layers, while a high value puts more emphasis on the higher frequency layers.
+ </member>
+ <member name="fractal_lacunarity" type="float" setter="set_fractal_lacunarity" getter="get_fractal_lacunarity" default="2.0">
+ Frequency multiplier between subsequent octaves. Increasing this value results in higher octaves producing noise with finer details and a rougher appearance.
+ </member>
+ <member name="fractal_octaves" type="int" setter="set_fractal_octaves" getter="get_fractal_octaves" default="5">
+ The number of noise layers that are sampled to get the final value for fractal noise types.
+ </member>
+ <member name="fractal_ping_pong_strength" type="float" setter="set_fractal_ping_pong_strength" getter="get_fractal_ping_pong_strength" default="2.0">
+ Sets the strength of the fractal ping pong type.
+ </member>
+ <member name="fractal_type" type="int" setter="set_fractal_type" getter="get_fractal_type" enum="FastNoiseLite.FractalType" default="1">
+ The method for combining octaves into a fractal. See [enum FractalType].
+ </member>
+ <member name="fractal_weighted_strength" type="float" setter="set_fractal_weighted_strength" getter="get_fractal_weighted_strength" default="0.0">
+ Higher weighting means higher octaves have less impact if lower octaves have a large impact.
+ </member>
+ <member name="frequency" type="float" setter="set_frequency" getter="get_frequency" default="0.01">
+ The frequency for all noise types. Low frequency results in smooth noise while high frequency results in rougher, more granular noise.
+ </member>
+ <member name="in_3d_space" type="bool" setter="set_in_3d_space" getter="is_in_3d_space" default="false">
+ Determines whether the noise image returned by [method Noise.get_image] is calculated in 3d space. May result in reduced contrast.
+ </member>
+ <member name="noise_type" type="int" setter="set_noise_type" getter="get_noise_type" enum="FastNoiseLite.NoiseType" default="1">
+ The noise algorithm used. See [enum NoiseType].
+ </member>
+ <member name="offset" type="Vector3" setter="set_offset" getter="get_offset" default="Vector3(0, 0, 0)">
+ Translate the noise input coordinates by the given [Vector3].
+ </member>
+ <member name="seed" type="int" setter="set_seed" getter="get_seed" default="0">
+ The random number seed for all noise types.
+ </member>
+ </members>
+ <constants>
+ <constant name="TYPE_VALUE" value="5" enum="NoiseType">
+ A lattice of points are assigned random values then interpolated based on neighboring values.
+ </constant>
+ <constant name="TYPE_VALUE_CUBIC" value="4" enum="NoiseType">
+ Similar to Value noise, but slower. Has more variance in peaks and valleys.
+ Cubic noise can be used to avoid certain artifacts when using value noise to create a bumpmap. In general, you should always use this mode if the value noise is being used for a heightmap or bumpmap.
+ </constant>
+ <constant name="TYPE_PERLIN" value="3" enum="NoiseType">
+ A lattice of random gradients. Their dot products are interpolated to obtain values in between the lattices.
+ </constant>
+ <constant name="TYPE_CELLULAR" value="2" enum="NoiseType">
+ Cellular includes both Worley noise and Voronoi diagrams which creates various regions of the same value.
+ </constant>
+ <constant name="TYPE_SIMPLEX" value="0" enum="NoiseType">
+ As opposed to [constant TYPE_PERLIN], gradients exist in a simplex lattice rather than a grid lattice, avoiding directional artifacts.
+ </constant>
+ <constant name="TYPE_SIMPLEX_SMOOTH" value="1" enum="NoiseType">
+ Modified, higher quality version of [constant TYPE_SIMPLEX], but slower.
+ </constant>
+ <constant name="FRACTAL_NONE" value="0" enum="FractalType">
+ No fractal noise.
+ </constant>
+ <constant name="FRACTAL_FBM" value="1" enum="FractalType">
+ Method using Fractional Brownian Motion to combine octaves into a fractal.
+ </constant>
+ <constant name="FRACTAL_RIDGED" value="2" enum="FractalType">
+ Method of combining octaves into a fractal resulting in a "ridged" look.
+ </constant>
+ <constant name="FRACTAL_PING_PONG" value="3" enum="FractalType">
+ Method of combining octaves into a fractal with a ping pong effect.
+ </constant>
+ <constant name="DISTANCE_EUCLIDEAN" value="0" enum="CellularDistanceFunction">
+ Euclidean distance to the nearest point.
+ </constant>
+ <constant name="DISTANCE_EUCLIDEAN_SQUARED" value="1" enum="CellularDistanceFunction">
+ Squared Euclidean distance to the nearest point.
+ </constant>
+ <constant name="DISTANCE_MANHATTAN" value="2" enum="CellularDistanceFunction">
+ Manhattan distance (taxicab metric) to the nearest point.
+ </constant>
+ <constant name="DISTANCE_HYBRID" value="3" enum="CellularDistanceFunction">
+ Blend of [constant DISTANCE_EUCLIDEAN] and [constant DISTANCE_MANHATTAN] to give curved cell boundaries
+ </constant>
+ <constant name="RETURN_CELL_VALUE" value="0" enum="CellularReturnType">
+ The cellular distance function will return the same value for all points within a cell.
+ </constant>
+ <constant name="RETURN_DISTANCE" value="1" enum="CellularReturnType">
+ The cellular distance function will return a value determined by the distance to the nearest point.
+ </constant>
+ <constant name="RETURN_DISTANCE2" value="2" enum="CellularReturnType">
+ The cellular distance function returns the distance to the second-nearest point.
+ </constant>
+ <constant name="RETURN_DISTANCE2_ADD" value="3" enum="CellularReturnType">
+ The distance to the nearest point is added to the distance to the second-nearest point.
+ </constant>
+ <constant name="RETURN_DISTANCE2_SUB" value="4" enum="CellularReturnType">
+ The distance to the nearest point is subtracted from the distance to the second-nearest point.
+ </constant>
+ <constant name="RETURN_DISTANCE2_MUL" value="5" enum="CellularReturnType">
+ The distance to the nearest point is multiplied with the distance to the second-nearest point.
+ </constant>
+ <constant name="RETURN_DISTANCE2_DIV" value="6" enum="CellularReturnType">
+ The distance to the nearest point is divided by the distance to the second-nearest point.
+ </constant>
+ <constant name="DOMAIN_WARP_SIMPLEX" value="0" enum="DomainWarpType">
+ The domain is warped using the simplex noise algorithm.
+ </constant>
+ <constant name="DOMAIN_WARP_SIMPLEX_REDUCED" value="1" enum="DomainWarpType">
+ The domain is warped using a simplified version of the simplex noise algorithm.
+ </constant>
+ <constant name="DOMAIN_WARP_BASIC_GRID" value="2" enum="DomainWarpType">
+ The domain is warped using a simple noise grid (not as smooth as the other methods, but more performant).
+ </constant>
+ <constant name="DOMAIN_WARP_FRACTAL_NONE" value="0" enum="DomainWarpFractalType">
+ No fractal noise for warping the space.
+ </constant>
+ <constant name="DOMAIN_WARP_FRACTAL_PROGRESSIVE" value="1" enum="DomainWarpFractalType">
+ Warping the space progressively, octave for octave, resulting in a more "liquified" distortion.
+ </constant>
+ <constant name="DOMAIN_WARP_FRACTAL_INDEPENDENT" value="2" enum="DomainWarpFractalType">
+ Warping the space independently for each octave, resulting in a more chaotic distortion.
+ </constant>
+ </constants>
+</class>
diff --git a/modules/noise/doc_classes/Noise.xml b/modules/noise/doc_classes/Noise.xml
new file mode 100644
index 0000000000..db0dec18d2
--- /dev/null
+++ b/modules/noise/doc_classes/Noise.xml
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<class name="Noise" inherits="Resource" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
+ <brief_description>
+ Abstract base class for noise generators.
+ </brief_description>
+ <description>
+ This class defines the interface for noise generation libraries to inherit from.
+ A default get_seamless_noise() implementation is provided for libraries that do not provide seamless noise. This function requests a larger image from get_image(), reverses the quadrants of the image, then uses the strips of extra width to blend over the seams.
+ Inheriting noise classes can optionally override this function to provide a more optimal algorithm.
+ </description>
+ <tutorials>
+ </tutorials>
+ <methods>
+ <method name="get_image">
+ <return type="Image" />
+ <argument index="0" name="width" type="int" />
+ <argument index="1" name="height" type="int" />
+ <argument index="2" name="invert" type="bool" default="false" />
+ <description>
+ Returns a 2D [Image] noise image.
+ </description>
+ </method>
+ <method name="get_noise_1d">
+ <return type="float" />
+ <argument index="0" name="x" type="float" />
+ <description>
+ Returns the 1D noise value at the given (x) coordinate.
+ </description>
+ </method>
+ <method name="get_noise_2d">
+ <return type="float" />
+ <argument index="0" name="x" type="float" />
+ <argument index="1" name="y" type="float" />
+ <description>
+ Returns the 2D noise value at the given position.
+ </description>
+ </method>
+ <method name="get_noise_2dv">
+ <return type="float" />
+ <argument index="0" name="v" type="Vector2" />
+ <description>
+ Returns the 2D noise value at the given position.
+ </description>
+ </method>
+ <method name="get_noise_3d">
+ <return type="float" />
+ <argument index="0" name="x" type="float" />
+ <argument index="1" name="y" type="float" />
+ <argument index="2" name="z" type="float" />
+ <description>
+ Returns the 3D noise value at the given position.
+ </description>
+ </method>
+ <method name="get_noise_3dv">
+ <return type="float" />
+ <argument index="0" name="v" type="Vector3" />
+ <description>
+ Returns the 3D noise value at the given position.
+ </description>
+ </method>
+ <method name="get_seamless_image">
+ <return type="Image" />
+ <argument index="0" name="width" type="int" />
+ <argument index="1" name="height" type="int" />
+ <argument index="2" name="invert" type="bool" default="false" />
+ <argument index="3" name="skirt" type="float" default="0.1" />
+ <description>
+ Returns a seamless 2D [Image] noise image.
+ </description>
+ </method>
+ </methods>
+</class>
diff --git a/modules/opensimplex/doc_classes/NoiseTexture.xml b/modules/noise/doc_classes/NoiseTexture.xml
index 497735ccf3..63630eccde 100644
--- a/modules/opensimplex/doc_classes/NoiseTexture.xml
+++ b/modules/noise/doc_classes/NoiseTexture.xml
@@ -1,15 +1,15 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="NoiseTexture" inherits="Texture2D" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<brief_description>
- [OpenSimplexNoise] filled texture.
+ A texture filled with noise generated by a [Noise] object.
</brief_description>
<description>
- Uses an [OpenSimplexNoise] to fill the texture data. You can specify the texture size but keep in mind that larger textures will take longer to generate and seamless noise only works with square sized textures.
- NoiseTexture can also generate normal map textures.
+ Uses [FastNoiseLite] or other libraries to fill the texture data of your desired size.
+ NoiseTexture can also generate normalmap textures.
The class uses [Thread]s to generate the texture data internally, so [method Texture2D.get_image] may return [code]null[/code] if the generation process has not completed yet. In that case, you need to wait for the texture to be generated before accessing the image and the generated byte data:
[codeblock]
var texture = NoiseTexture.new()
- texture.noise = OpenSimplexNoise.new()
+ texture.noise = FastNoiseLite.new()
await texture.changed
var image = texture.get_image()
var data = image.get_data()
@@ -27,15 +27,18 @@
<member name="height" type="int" setter="set_height" getter="get_height" default="512">
Height of the generated texture.
</member>
- <member name="noise" type="OpenSimplexNoise" setter="set_noise" getter="get_noise">
- The [OpenSimplexNoise] instance used to generate the noise.
+ <member name="invert" type="bool" setter="set_invert" getter="get_invert" default="false">
+ If [code]true[/code], inverts the noise texture. White becomes black, black becomes white.
</member>
- <member name="noise_offset" type="Vector2" setter="set_noise_offset" getter="get_noise_offset" default="Vector2(0, 0)">
- An offset used to specify the noise space coordinate of the top left corner of the generated noise. This value is ignored if [member seamless] is enabled.
+ <member name="noise" type="Noise" setter="set_noise" getter="get_noise">
+ The instance of the [Noise] object.
</member>
<member name="seamless" type="bool" setter="set_seamless" getter="get_seamless" default="false">
- Whether the texture can be tiled without visible seams or not. Seamless textures take longer to generate.
- [b]Note:[/b] Seamless noise has a lower contrast compared to non-seamless noise. This is due to the way noise uses higher dimensions for generating seamless noise.
+ If [code]true[/code], a seamless texture is requested from the [Noise] resource.
+ [b]Note:[/b] Seamless noise textures may take longer to generate and/or can have a lower contrast compared to non-seamless noise depending on the used [Noise] resource. This is because some implementations use higher dimensions for generating seamless noise.
+ </member>
+ <member name="seamless_blend_skirt" type="float" setter="set_seamless_blend_skirt" getter="get_seamless_blend_skirt" default="0.1">
+ Used for the default/fallback implementation of the seamless texture generation. It determines the distance over which the seams are blended. High values may result in less details and contrast. See [Noise] for further details.
</member>
<member name="width" type="int" setter="set_width" getter="get_width" default="512">
Width of the generated texture.
diff --git a/modules/noise/fastnoise_lite.cpp b/modules/noise/fastnoise_lite.cpp
new file mode 100644
index 0000000000..98a4f817e3
--- /dev/null
+++ b/modules/noise/fastnoise_lite.cpp
@@ -0,0 +1,577 @@
+/*************************************************************************/
+/* fastnoise_lite.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2022 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 "fastnoise_lite.h"
+
+FastNoiseLite::FastNoiseLite() {
+ // Most defaults copied from the library.
+ set_noise_type(TYPE_SIMPLEX_SMOOTH);
+ set_seed(0);
+ set_frequency(0.01);
+ set_in_3d_space(false);
+
+ set_fractal_type(FRACTAL_FBM);
+ set_fractal_octaves(5);
+ set_fractal_lacunarity(2.0);
+ set_fractal_gain(0.5);
+ set_fractal_weighted_strength(0.0);
+ set_fractal_ping_pong_strength(2.0);
+
+ set_cellular_distance_function(DISTANCE_EUCLIDEAN);
+ set_cellular_return_type(RETURN_CELL_VALUE);
+ set_cellular_jitter(0.45);
+
+ set_domain_warp_enabled(false);
+ set_domain_warp_type(DOMAIN_WARP_SIMPLEX);
+ set_domain_warp_amplitude(30.0);
+ set_domain_warp_frequency(0.05);
+ set_domain_warp_fractal_type(DOMAIN_WARP_FRACTAL_PROGRESSIVE);
+ set_domain_warp_fractal_octaves(5);
+ set_domain_warp_fractal_lacunarity(6);
+ set_domain_warp_fractal_gain(0.5);
+}
+
+FastNoiseLite::~FastNoiseLite() {
+}
+
+// General settings.
+
+void FastNoiseLite::set_noise_type(NoiseType p_noise_type) {
+ noise_type = p_noise_type;
+ _noise.SetNoiseType((_FastNoiseLite::NoiseType)p_noise_type);
+ emit_changed();
+ notify_property_list_changed();
+}
+
+FastNoiseLite::NoiseType FastNoiseLite::get_noise_type() const {
+ return noise_type;
+}
+
+void FastNoiseLite::set_seed(int p_seed) {
+ seed = p_seed;
+ _noise.SetSeed(p_seed);
+ emit_changed();
+}
+
+int FastNoiseLite::get_seed() const {
+ return seed;
+}
+
+void FastNoiseLite::set_frequency(real_t p_freq) {
+ frequency = p_freq;
+ _noise.SetFrequency(p_freq);
+ emit_changed();
+}
+
+real_t FastNoiseLite::get_frequency() const {
+ return frequency;
+}
+
+void FastNoiseLite::set_in_3d_space(bool p_enable) {
+ in_3d_space = p_enable;
+ emit_changed();
+}
+bool FastNoiseLite::is_in_3d_space() const {
+ return in_3d_space;
+}
+
+void FastNoiseLite::set_offset(Vector3 p_offset) {
+ offset = p_offset;
+ emit_changed();
+}
+
+Vector3 FastNoiseLite::get_offset() const {
+ return offset;
+}
+
+void FastNoiseLite::set_color_ramp(const Ref<Gradient> &p_gradient) {
+ color_ramp = p_gradient;
+ if (color_ramp.is_valid()) {
+ color_ramp->connect(SNAME("changed"), callable_mp(this, &FastNoiseLite::_changed));
+ emit_changed();
+ }
+}
+
+Ref<Gradient> FastNoiseLite::get_color_ramp() const {
+ return color_ramp;
+}
+
+// Noise functions.
+
+real_t FastNoiseLite::get_noise_1d(real_t p_x) {
+ return get_noise_2d(p_x, 0.0);
+}
+
+real_t FastNoiseLite::get_noise_2dv(Vector2 p_v) {
+ return get_noise_2d(p_v.x, p_v.y);
+}
+
+real_t FastNoiseLite::get_noise_2d(real_t p_x, real_t p_y) {
+ if (domain_warp_enabled) {
+ _domain_warp_noise.DomainWarp(p_x, p_y);
+ }
+ return _noise.GetNoise(p_x + offset.x, p_y + offset.y);
+}
+
+real_t FastNoiseLite::get_noise_3dv(Vector3 p_v) {
+ return get_noise_3d(p_v.x, p_v.y, p_v.z);
+}
+
+real_t FastNoiseLite::get_noise_3d(real_t p_x, real_t p_y, real_t p_z) {
+ if (domain_warp_enabled) {
+ _domain_warp_noise.DomainWarp(p_x, p_y, p_z);
+ }
+ return _noise.GetNoise(p_x + offset.x, p_y + offset.y, p_z + offset.z);
+}
+
+// Fractal.
+
+void FastNoiseLite::set_fractal_type(FractalType p_type) {
+ fractal_type = p_type;
+ _noise.SetFractalType((_FastNoiseLite::FractalType)p_type);
+ emit_changed();
+ notify_property_list_changed();
+}
+
+FastNoiseLite::FractalType FastNoiseLite::get_fractal_type() const {
+ return fractal_type;
+}
+
+void FastNoiseLite::set_fractal_octaves(int p_octaves) {
+ fractal_octaves = p_octaves;
+ _noise.SetFractalOctaves(p_octaves);
+ emit_changed();
+}
+
+int FastNoiseLite::get_fractal_octaves() const {
+ return fractal_octaves;
+}
+
+void FastNoiseLite::set_fractal_lacunarity(real_t p_lacunarity) {
+ fractal_lacunarity = p_lacunarity;
+ _noise.SetFractalLacunarity(p_lacunarity);
+ emit_changed();
+}
+
+real_t FastNoiseLite::get_fractal_lacunarity() const {
+ return fractal_lacunarity;
+}
+
+void FastNoiseLite::set_fractal_gain(real_t p_gain) {
+ fractal_gain = p_gain;
+ _noise.SetFractalGain(p_gain);
+ emit_changed();
+}
+
+real_t FastNoiseLite::get_fractal_gain() const {
+ return fractal_gain;
+}
+
+void FastNoiseLite::set_fractal_weighted_strength(real_t p_weighted_strength) {
+ fractal_weighted_strength = p_weighted_strength;
+ _noise.SetFractalWeightedStrength(p_weighted_strength);
+ emit_changed();
+}
+real_t FastNoiseLite::get_fractal_weighted_strength() const {
+ return fractal_weighted_strength;
+}
+
+void FastNoiseLite::set_fractal_ping_pong_strength(real_t p_ping_pong_strength) {
+ fractal_pinp_pong_strength = p_ping_pong_strength;
+ _noise.SetFractalPingPongStrength(p_ping_pong_strength);
+ emit_changed();
+}
+real_t FastNoiseLite::get_fractal_ping_pong_strength() const {
+ return fractal_pinp_pong_strength;
+}
+
+// Cellular.
+
+void FastNoiseLite::set_cellular_distance_function(CellularDistanceFunction p_func) {
+ cellular_distance_function = p_func;
+ _noise.SetCellularDistanceFunction((_FastNoiseLite::CellularDistanceFunction)p_func);
+ emit_changed();
+}
+
+FastNoiseLite::CellularDistanceFunction FastNoiseLite::get_cellular_distance_function() const {
+ return cellular_distance_function;
+}
+
+void FastNoiseLite::set_cellular_jitter(real_t p_jitter) {
+ cellular_jitter = p_jitter;
+ _noise.SetCellularJitter(p_jitter);
+ emit_changed();
+}
+
+real_t FastNoiseLite::get_cellular_jitter() const {
+ return cellular_jitter;
+}
+
+void FastNoiseLite::set_cellular_return_type(CellularReturnType p_ret) {
+ cellular_return_type = p_ret;
+ _noise.SetCellularReturnType((_FastNoiseLite::CellularReturnType)p_ret);
+
+ emit_changed();
+}
+
+FastNoiseLite::CellularReturnType FastNoiseLite::get_cellular_return_type() const {
+ return cellular_return_type;
+}
+
+// Domain warp specific.
+
+void FastNoiseLite::set_domain_warp_enabled(bool p_enabled) {
+ if (domain_warp_enabled != p_enabled) {
+ domain_warp_enabled = p_enabled;
+ emit_changed();
+ notify_property_list_changed();
+ }
+}
+
+bool FastNoiseLite::is_domain_warp_enabled() const {
+ return domain_warp_enabled;
+}
+
+void FastNoiseLite::set_domain_warp_type(DomainWarpType p_domain_warp_type) {
+ domain_warp_type = p_domain_warp_type;
+ _domain_warp_noise.SetDomainWarpType((_FastNoiseLite::DomainWarpType)p_domain_warp_type);
+ emit_changed();
+}
+
+FastNoiseLite::DomainWarpType FastNoiseLite::get_domain_warp_type() const {
+ return domain_warp_type;
+}
+
+void FastNoiseLite::set_domain_warp_amplitude(real_t p_amplitude) {
+ domain_warp_amplitude = p_amplitude;
+ _domain_warp_noise.SetDomainWarpAmp(p_amplitude);
+ emit_changed();
+}
+real_t FastNoiseLite::get_domain_warp_amplitude() const {
+ return domain_warp_amplitude;
+}
+
+void FastNoiseLite::set_domain_warp_frequency(real_t p_frequency) {
+ domain_warp_frequency = p_frequency;
+ _domain_warp_noise.SetFrequency(p_frequency);
+ emit_changed();
+}
+
+real_t FastNoiseLite::get_domain_warp_frequency() const {
+ return domain_warp_frequency;
+}
+
+void FastNoiseLite::set_domain_warp_fractal_type(DomainWarpFractalType p_domain_warp_fractal_type) {
+ domain_warp_fractal_type = p_domain_warp_fractal_type;
+
+ // This needs manual conversion because Godots Inspector property API does not support discontiguous enum indices.
+ _FastNoiseLite::FractalType type;
+ switch (p_domain_warp_fractal_type) {
+ case DOMAIN_WARP_FRACTAL_NONE:
+ type = _FastNoiseLite::FractalType_None;
+ break;
+ case DOMAIN_WARP_FRACTAL_PROGRESSIVE:
+ type = _FastNoiseLite::FractalType_DomainWarpProgressive;
+ break;
+ case DOMAIN_WARP_FRACTAL_INDEPENDENT:
+ type = _FastNoiseLite::FractalType_DomainWarpIndependent;
+ break;
+ default:
+ type = _FastNoiseLite::FractalType_None;
+ }
+
+ _domain_warp_noise.SetFractalType(type);
+ emit_changed();
+}
+
+FastNoiseLite::DomainWarpFractalType FastNoiseLite::get_domain_warp_fractal_type() const {
+ return domain_warp_fractal_type;
+}
+
+void FastNoiseLite::set_domain_warp_fractal_octaves(int p_octaves) {
+ domain_warp_fractal_octaves = p_octaves;
+ _domain_warp_noise.SetFractalOctaves(p_octaves);
+ emit_changed();
+}
+
+int FastNoiseLite::get_domain_warp_fractal_octaves() const {
+ return domain_warp_fractal_octaves;
+}
+
+void FastNoiseLite::set_domain_warp_fractal_lacunarity(real_t p_lacunarity) {
+ domain_warp_fractal_lacunarity = p_lacunarity;
+ _domain_warp_noise.SetFractalLacunarity(p_lacunarity);
+ emit_changed();
+}
+
+real_t FastNoiseLite::get_domain_warp_fractal_lacunarity() const {
+ return domain_warp_fractal_lacunarity;
+}
+
+void FastNoiseLite::set_domain_warp_fractal_gain(real_t p_gain) {
+ domain_warp_fractal_gain = p_gain;
+ _domain_warp_noise.SetFractalGain(p_gain);
+ emit_changed();
+}
+
+real_t FastNoiseLite::get_domain_warp_fractal_gain() const {
+ return domain_warp_fractal_gain;
+}
+
+// Textures.
+
+Ref<Image> FastNoiseLite::get_image(int p_width, int p_height, bool p_invert) {
+ bool grayscale = color_ramp.is_null();
+
+ Vector<uint8_t> data;
+ data.resize(p_width * p_height * (grayscale ? 1 : 4));
+
+ uint8_t *wd8 = data.ptrw();
+
+ // Get all values and identify min/max values.
+ Vector<real_t> values;
+ values.resize(p_width * p_height);
+ real_t min_val = 100;
+ real_t max_val = -100;
+
+ for (int y = 0, i = 0; y < p_height; y++) {
+ for (int x = 0; x < p_width; x++, i++) {
+ values.set(i, is_in_3d_space() ? get_noise_3d(x, y, 0.0) : get_noise_2d(x, y));
+ if (values[i] > max_val) {
+ max_val = values[i];
+ }
+ if (values[i] < min_val) {
+ min_val = values[i];
+ }
+ }
+ }
+
+ // Normalize values and write to texture.
+ uint8_t value;
+ for (int i = 0, x = 0; i < p_height; i++) {
+ for (int j = 0; j < p_width; j++, x++) {
+ if (max_val == min_val) {
+ value = 0;
+ } else {
+ value = uint8_t(CLAMP((values[x] - min_val) / (max_val - min_val) * 255.f, 0, 255));
+ }
+ if (p_invert) {
+ value = 255 - value;
+ }
+ if (grayscale) {
+ wd8[x] = value;
+ } else {
+ float luminance = value / 255.0;
+ Color ramp_color = color_ramp->get_color_at_offset(luminance);
+ wd8[x * 4 + 0] = uint8_t(CLAMP(ramp_color.r * 255, 0, 255));
+ wd8[x * 4 + 1] = uint8_t(CLAMP(ramp_color.g * 255, 0, 255));
+ wd8[x * 4 + 2] = uint8_t(CLAMP(ramp_color.b * 255, 0, 255));
+ wd8[x * 4 + 3] = uint8_t(CLAMP(ramp_color.a * 255, 0, 255));
+ }
+ }
+ }
+ if (grayscale) {
+ return memnew(Image(p_width, p_height, false, Image::FORMAT_L8, data));
+ } else {
+ return memnew(Image(p_width, p_height, false, Image::FORMAT_RGBA8, data));
+ }
+}
+
+Ref<Image> FastNoiseLite::get_seamless_image(int p_width, int p_height, bool p_invert, real_t p_blend_skirt) {
+ // Just return parent function. This is here only so Godot will properly document this function.
+ return Noise::get_seamless_image(p_width, p_height, p_invert, p_blend_skirt);
+}
+
+void FastNoiseLite::_changed() {
+ emit_changed();
+}
+
+void FastNoiseLite::_bind_methods() {
+ // General settings.
+
+ ClassDB::bind_method(D_METHOD("set_noise_type", "type"), &FastNoiseLite::set_noise_type);
+ ClassDB::bind_method(D_METHOD("get_noise_type"), &FastNoiseLite::get_noise_type);
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "noise_type", PROPERTY_HINT_ENUM, "Simplex,Simplex Smooth,Cellular,Perlin,Value Cubic,Value"), "set_noise_type", "get_noise_type");
+
+ ClassDB::bind_method(D_METHOD("set_seed", "seed"), &FastNoiseLite::set_seed);
+ ClassDB::bind_method(D_METHOD("get_seed"), &FastNoiseLite::get_seed);
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "seed"), "set_seed", "get_seed");
+
+ ClassDB::bind_method(D_METHOD("set_frequency", "freq"), &FastNoiseLite::set_frequency);
+ ClassDB::bind_method(D_METHOD("get_frequency"), &FastNoiseLite::get_frequency);
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "frequency", PROPERTY_HINT_RANGE, ".001,1"), "set_frequency", "get_frequency");
+
+ ClassDB::bind_method(D_METHOD("set_in_3d_space", "enable"), &FastNoiseLite::set_in_3d_space);
+ ClassDB::bind_method(D_METHOD("is_in_3d_space"), &FastNoiseLite::is_in_3d_space);
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "in_3d_space"), "set_in_3d_space", "is_in_3d_space");
+
+ ClassDB::bind_method(D_METHOD("set_offset", "offset"), &FastNoiseLite::set_offset);
+ ClassDB::bind_method(D_METHOD("get_offset"), &FastNoiseLite::get_offset);
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "offset", PROPERTY_HINT_RANGE, "-999999999,999999999,1"), "set_offset", "get_offset");
+
+ ClassDB::bind_method(D_METHOD("set_color_ramp", "gradient"), &FastNoiseLite::set_color_ramp);
+ ClassDB::bind_method(D_METHOD("get_color_ramp"), &FastNoiseLite::get_color_ramp);
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "color_ramp", PROPERTY_HINT_RESOURCE_TYPE, "Gradient"), "set_color_ramp", "get_color_ramp");
+
+ // Fractal.
+
+ ADD_GROUP("Fractal", "fractal_");
+ ClassDB::bind_method(D_METHOD("set_fractal_type", "type"), &FastNoiseLite::set_fractal_type);
+ ClassDB::bind_method(D_METHOD("get_fractal_type"), &FastNoiseLite::get_fractal_type);
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "fractal_type", PROPERTY_HINT_ENUM, "None,FBM,Ridged,PingPong"), "set_fractal_type", "get_fractal_type");
+
+ ClassDB::bind_method(D_METHOD("set_fractal_octaves", "octave_count"), &FastNoiseLite::set_fractal_octaves);
+ ClassDB::bind_method(D_METHOD("get_fractal_octaves"), &FastNoiseLite::get_fractal_octaves);
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "fractal_octaves", PROPERTY_HINT_RANGE, "1,10,1"), "set_fractal_octaves", "get_fractal_octaves");
+
+ ClassDB::bind_method(D_METHOD("set_fractal_lacunarity", "lacunarity"), &FastNoiseLite::set_fractal_lacunarity);
+ ClassDB::bind_method(D_METHOD("get_fractal_lacunarity"), &FastNoiseLite::get_fractal_lacunarity);
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "fractal_lacunarity"), "set_fractal_lacunarity", "get_fractal_lacunarity");
+
+ ClassDB::bind_method(D_METHOD("set_fractal_gain", "gain"), &FastNoiseLite::set_fractal_gain);
+ ClassDB::bind_method(D_METHOD("get_fractal_gain"), &FastNoiseLite::get_fractal_gain);
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "fractal_gain"), "set_fractal_gain", "get_fractal_gain");
+
+ ClassDB::bind_method(D_METHOD("set_fractal_weighted_strength", "weighted_strength"), &FastNoiseLite::set_fractal_weighted_strength);
+ ClassDB::bind_method(D_METHOD("get_fractal_weighted_strength"), &FastNoiseLite::get_fractal_weighted_strength);
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "fractal_weighted_strength", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_fractal_weighted_strength", "get_fractal_weighted_strength");
+
+ ClassDB::bind_method(D_METHOD("set_fractal_ping_pong_strength", "ping_pong_strength"), &FastNoiseLite::set_fractal_ping_pong_strength);
+ ClassDB::bind_method(D_METHOD("get_fractal_ping_pong_strength"), &FastNoiseLite::get_fractal_ping_pong_strength);
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "fractal_ping_pong_strength"), "set_fractal_ping_pong_strength", "get_fractal_ping_pong_strength");
+
+ // Cellular.
+
+ ADD_GROUP("Cellular", "cellular_");
+ ClassDB::bind_method(D_METHOD("set_cellular_distance_function", "func"), &FastNoiseLite::set_cellular_distance_function);
+ ClassDB::bind_method(D_METHOD("get_cellular_distance_function"), &FastNoiseLite::get_cellular_distance_function);
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "cellular_distance_function", PROPERTY_HINT_ENUM, "Euclidean,EuclideanSquared,Manhattan,Hybrid"), "set_cellular_distance_function", "get_cellular_distance_function");
+
+ ClassDB::bind_method(D_METHOD("set_cellular_jitter", "jitter"), &FastNoiseLite::set_cellular_jitter);
+ ClassDB::bind_method(D_METHOD("get_cellular_jitter"), &FastNoiseLite::get_cellular_jitter);
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "cellular_jitter"), "set_cellular_jitter", "get_cellular_jitter");
+
+ ClassDB::bind_method(D_METHOD("set_cellular_return_type", "ret"), &FastNoiseLite::set_cellular_return_type);
+ ClassDB::bind_method(D_METHOD("get_cellular_return_type"), &FastNoiseLite::get_cellular_return_type);
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "cellular_return_type", PROPERTY_HINT_ENUM, "CellValue,Distance,Distance2,Distance2Add,Distance2Sub,Distance2Mul,Distance2Div"), "set_cellular_return_type", "get_cellular_return_type");
+
+ // Domain warp.
+
+ ADD_GROUP("Domain warp", "domain_warp_");
+
+ ClassDB::bind_method(D_METHOD("set_domain_warp_enabled", "domain_warp_enabled"), &FastNoiseLite::set_domain_warp_enabled);
+ ClassDB::bind_method(D_METHOD("is_domain_warp_enabled"), &FastNoiseLite::is_domain_warp_enabled);
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "domain_warp_enabled"), "set_domain_warp_enabled", "is_domain_warp_enabled");
+
+ ClassDB::bind_method(D_METHOD("set_domain_warp_type", "domain_warp_type"), &FastNoiseLite::set_domain_warp_type);
+ ClassDB::bind_method(D_METHOD("get_domain_warp_type"), &FastNoiseLite::get_domain_warp_type);
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "domain_warp_type", PROPERTY_HINT_ENUM, "Simplex,SimplexReduced,BasicGrid"), "set_domain_warp_type", "get_domain_warp_type");
+
+ ClassDB::bind_method(D_METHOD("set_domain_warp_amplitude", "domain_warp_amplitude"), &FastNoiseLite::set_domain_warp_amplitude);
+ ClassDB::bind_method(D_METHOD("get_domain_warp_amplitude"), &FastNoiseLite::get_domain_warp_amplitude);
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "domain_warp_amplitude"), "set_domain_warp_amplitude", "get_domain_warp_amplitude");
+
+ ClassDB::bind_method(D_METHOD("set_domain_warp_frequency", "domain_warp_frequency"), &FastNoiseLite::set_domain_warp_frequency);
+ ClassDB::bind_method(D_METHOD("get_domain_warp_frequency"), &FastNoiseLite::get_domain_warp_frequency);
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "domain_warp_frequency"), "set_domain_warp_frequency", "get_domain_warp_frequency");
+
+ ClassDB::bind_method(D_METHOD("set_domain_warp_fractal_type", "domain_warp_fractal_type"), &FastNoiseLite::set_domain_warp_fractal_type);
+ ClassDB::bind_method(D_METHOD("get_domain_warp_fractal_type"), &FastNoiseLite::get_domain_warp_fractal_type);
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "domain_warp_fractal_type", PROPERTY_HINT_ENUM, "None,Progressive,Independent"), "set_domain_warp_fractal_type", "get_domain_warp_fractal_type");
+
+ ClassDB::bind_method(D_METHOD("set_domain_warp_fractal_octaves", "domain_warp_octave_count"), &FastNoiseLite::set_domain_warp_fractal_octaves);
+ ClassDB::bind_method(D_METHOD("get_domain_warp_fractal_octaves"), &FastNoiseLite::get_domain_warp_fractal_octaves);
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "domain_warp_fractal_octaves", PROPERTY_HINT_RANGE, "1,10,1"), "set_domain_warp_fractal_octaves", "get_domain_warp_fractal_octaves");
+
+ ClassDB::bind_method(D_METHOD("set_domain_warp_fractal_lacunarity", "domain_warp_lacunarity"), &FastNoiseLite::set_domain_warp_fractal_lacunarity);
+ ClassDB::bind_method(D_METHOD("get_domain_warp_fractal_lacunarity"), &FastNoiseLite::get_domain_warp_fractal_lacunarity);
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "domain_warp_fractal_lacunarity"), "set_domain_warp_fractal_lacunarity", "get_domain_warp_fractal_lacunarity");
+
+ ClassDB::bind_method(D_METHOD("set_domain_warp_fractal_gain", "domain_warp_gain"), &FastNoiseLite::set_domain_warp_fractal_gain);
+ ClassDB::bind_method(D_METHOD("get_domain_warp_fractal_gain"), &FastNoiseLite::get_domain_warp_fractal_gain);
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "domain_warp_fractal_gain"), "set_domain_warp_fractal_gain", "get_domain_warp_fractal_gain");
+
+ ClassDB::bind_method(D_METHOD("_changed"), &FastNoiseLite::_changed);
+
+ BIND_ENUM_CONSTANT(TYPE_VALUE);
+ BIND_ENUM_CONSTANT(TYPE_VALUE_CUBIC);
+ BIND_ENUM_CONSTANT(TYPE_PERLIN);
+ BIND_ENUM_CONSTANT(TYPE_CELLULAR);
+ BIND_ENUM_CONSTANT(TYPE_SIMPLEX);
+ BIND_ENUM_CONSTANT(TYPE_SIMPLEX_SMOOTH);
+
+ BIND_ENUM_CONSTANT(FRACTAL_NONE);
+ BIND_ENUM_CONSTANT(FRACTAL_FBM);
+ BIND_ENUM_CONSTANT(FRACTAL_RIDGED);
+ BIND_ENUM_CONSTANT(FRACTAL_PING_PONG);
+
+ BIND_ENUM_CONSTANT(DISTANCE_EUCLIDEAN);
+ BIND_ENUM_CONSTANT(DISTANCE_EUCLIDEAN_SQUARED);
+ BIND_ENUM_CONSTANT(DISTANCE_MANHATTAN);
+ BIND_ENUM_CONSTANT(DISTANCE_HYBRID);
+
+ BIND_ENUM_CONSTANT(RETURN_CELL_VALUE);
+ BIND_ENUM_CONSTANT(RETURN_DISTANCE);
+ BIND_ENUM_CONSTANT(RETURN_DISTANCE2);
+ BIND_ENUM_CONSTANT(RETURN_DISTANCE2_ADD);
+ BIND_ENUM_CONSTANT(RETURN_DISTANCE2_SUB);
+ BIND_ENUM_CONSTANT(RETURN_DISTANCE2_MUL);
+ BIND_ENUM_CONSTANT(RETURN_DISTANCE2_DIV);
+
+ BIND_ENUM_CONSTANT(DOMAIN_WARP_SIMPLEX);
+ BIND_ENUM_CONSTANT(DOMAIN_WARP_SIMPLEX_REDUCED);
+ BIND_ENUM_CONSTANT(DOMAIN_WARP_BASIC_GRID);
+
+ BIND_ENUM_CONSTANT(DOMAIN_WARP_FRACTAL_NONE);
+ BIND_ENUM_CONSTANT(DOMAIN_WARP_FRACTAL_PROGRESSIVE);
+ BIND_ENUM_CONSTANT(DOMAIN_WARP_FRACTAL_INDEPENDENT);
+}
+
+void FastNoiseLite::_validate_property(PropertyInfo &property) const {
+ if (property.name.begins_with("cellular") && get_noise_type() != TYPE_CELLULAR) {
+ property.usage = PROPERTY_USAGE_NO_EDITOR;
+ return;
+ }
+
+ if (property.name != "fractal_type" && property.name.begins_with("fractal") && get_fractal_type() == FRACTAL_NONE) {
+ property.usage = PROPERTY_USAGE_NO_EDITOR;
+ return;
+ }
+
+ if (property.name == "fractal_ping_pong_strength" && get_fractal_type() != FRACTAL_PING_PONG) {
+ property.usage = PROPERTY_USAGE_NO_EDITOR;
+ return;
+ }
+
+ if (property.name != "domain_warp_enabled" && property.name.begins_with("domain_warp") && !domain_warp_enabled) {
+ property.usage = PROPERTY_USAGE_NO_EDITOR;
+ return;
+ }
+}
diff --git a/modules/noise/fastnoise_lite.h b/modules/noise/fastnoise_lite.h
new file mode 100644
index 0000000000..4635e26d28
--- /dev/null
+++ b/modules/noise/fastnoise_lite.h
@@ -0,0 +1,237 @@
+/*************************************************************************/
+/* fastnoise_lite.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2022 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 FASTNOISE_LITE_H
+#define FASTNOISE_LITE_H
+
+#include "core/io/image.h"
+#include "core/object/ref_counted.h"
+#include "noise.h"
+#include "scene/resources/gradient.h"
+
+#include <thirdparty/noise/FastNoiseLite.h>
+
+typedef fastnoiselite::FastNoiseLite _FastNoiseLite;
+
+class FastNoiseLite : public Noise {
+ GDCLASS(FastNoiseLite, Noise);
+ OBJ_SAVE_TYPE(FastNoiseLite);
+
+public:
+ enum NoiseType {
+ TYPE_SIMPLEX = _FastNoiseLite::NoiseType_OpenSimplex2,
+ TYPE_SIMPLEX_SMOOTH = _FastNoiseLite::NoiseType_OpenSimplex2S,
+ TYPE_CELLULAR = _FastNoiseLite::NoiseType_Cellular,
+ TYPE_PERLIN = _FastNoiseLite::NoiseType_Perlin,
+ TYPE_VALUE_CUBIC = _FastNoiseLite::NoiseType_ValueCubic,
+ TYPE_VALUE = _FastNoiseLite::NoiseType_Value,
+ };
+
+ enum FractalType {
+ FRACTAL_NONE = _FastNoiseLite::FractalType_None,
+ FRACTAL_FBM = _FastNoiseLite::FractalType_FBm,
+ FRACTAL_RIDGED = _FastNoiseLite::FractalType_Ridged,
+ FRACTAL_PING_PONG = _FastNoiseLite::FractalType_PingPong,
+ };
+
+ enum CellularDistanceFunction {
+ DISTANCE_EUCLIDEAN = _FastNoiseLite::CellularDistanceFunction_Euclidean,
+ DISTANCE_EUCLIDEAN_SQUARED = _FastNoiseLite::CellularDistanceFunction_EuclideanSq,
+ DISTANCE_MANHATTAN = _FastNoiseLite::CellularDistanceFunction_Manhattan,
+ DISTANCE_HYBRID = _FastNoiseLite::CellularDistanceFunction_Hybrid
+ };
+
+ enum CellularReturnType {
+ RETURN_CELL_VALUE = _FastNoiseLite::CellularReturnType_CellValue,
+ RETURN_DISTANCE = _FastNoiseLite::CellularReturnType_Distance,
+ RETURN_DISTANCE2 = _FastNoiseLite::CellularReturnType_Distance2,
+ RETURN_DISTANCE2_ADD = _FastNoiseLite::CellularReturnType_Distance2Add,
+ RETURN_DISTANCE2_SUB = _FastNoiseLite::CellularReturnType_Distance2Sub,
+ RETURN_DISTANCE2_MUL = _FastNoiseLite::CellularReturnType_Distance2Mul,
+ RETURN_DISTANCE2_DIV = _FastNoiseLite::CellularReturnType_Distance2Div
+ };
+
+ enum DomainWarpType {
+ DOMAIN_WARP_SIMPLEX = _FastNoiseLite::DomainWarpType_OpenSimplex2,
+ DOMAIN_WARP_SIMPLEX_REDUCED = _FastNoiseLite::DomainWarpType_OpenSimplex2Reduced,
+ DOMAIN_WARP_BASIC_GRID = _FastNoiseLite::DomainWarpType_BasicGrid
+ };
+
+ enum DomainWarpFractalType {
+ DOMAIN_WARP_FRACTAL_NONE,
+ DOMAIN_WARP_FRACTAL_PROGRESSIVE,
+ DOMAIN_WARP_FRACTAL_INDEPENDENT
+ };
+
+protected:
+ static void _bind_methods();
+ virtual void _validate_property(PropertyInfo &property) const override;
+
+private:
+ _FastNoiseLite _noise;
+ _FastNoiseLite _domain_warp_noise;
+
+ Vector3 offset;
+ NoiseType noise_type;
+ Ref<Gradient> color_ramp;
+
+ int seed;
+ real_t frequency;
+ bool in_3d_space;
+
+ // Fractal specific.
+ FractalType fractal_type;
+ int fractal_octaves;
+ real_t fractal_lacunarity;
+ real_t fractal_gain;
+ real_t fractal_weighted_strength;
+ real_t fractal_pinp_pong_strength;
+
+ // Cellular specific.
+ CellularDistanceFunction cellular_distance_function;
+ CellularReturnType cellular_return_type;
+ real_t cellular_jitter;
+
+ // Domain warp specific.
+ bool domain_warp_enabled;
+ DomainWarpType domain_warp_type;
+ real_t domain_warp_frequency;
+ real_t domain_warp_amplitude;
+
+ DomainWarpFractalType domain_warp_fractal_type;
+ int domain_warp_fractal_octaves;
+ real_t domain_warp_fractal_lacunarity;
+ real_t domain_warp_fractal_gain;
+
+public:
+ FastNoiseLite();
+ ~FastNoiseLite();
+
+ // General noise settings.
+
+ void set_noise_type(NoiseType p_noise_type);
+ NoiseType get_noise_type() const;
+
+ void set_seed(int p_seed);
+ int get_seed() const;
+
+ void set_frequency(real_t p_freq);
+ real_t get_frequency() const;
+
+ void set_in_3d_space(bool p_enable);
+ bool is_in_3d_space() const;
+
+ void set_offset(Vector3 p_offset);
+ Vector3 get_offset() const;
+
+ void set_color_ramp(const Ref<Gradient> &p_gradient);
+ Ref<Gradient> get_color_ramp() const;
+
+ // Fractal specific.
+
+ void set_fractal_type(FractalType p_type);
+ FractalType get_fractal_type() const;
+
+ void set_fractal_octaves(int p_octaves);
+ int get_fractal_octaves() const;
+
+ void set_fractal_lacunarity(real_t p_lacunarity);
+ real_t get_fractal_lacunarity() const;
+
+ void set_fractal_gain(real_t p_gain);
+ real_t get_fractal_gain() const;
+
+ void set_fractal_weighted_strength(real_t p_weighted_strength);
+ real_t get_fractal_weighted_strength() const;
+
+ void set_fractal_ping_pong_strength(real_t p_ping_pong_strength);
+ real_t get_fractal_ping_pong_strength() const;
+
+ // Cellular specific.
+
+ void set_cellular_distance_function(CellularDistanceFunction p_func);
+ CellularDistanceFunction get_cellular_distance_function() const;
+
+ void set_cellular_return_type(CellularReturnType p_ret);
+ CellularReturnType get_cellular_return_type() const;
+
+ void set_cellular_jitter(real_t p_jitter);
+ real_t get_cellular_jitter() const;
+
+ // Domain warp specific.
+
+ void set_domain_warp_enabled(bool p_enabled);
+ bool is_domain_warp_enabled() const;
+
+ void set_domain_warp_type(DomainWarpType p_domain_warp_type);
+ DomainWarpType get_domain_warp_type() const;
+
+ void set_domain_warp_amplitude(real_t p_amplitude);
+ real_t get_domain_warp_amplitude() const;
+
+ void set_domain_warp_frequency(real_t p_frequency);
+ real_t get_domain_warp_frequency() const;
+
+ void set_domain_warp_fractal_type(DomainWarpFractalType p_domain_warp_fractal_type);
+ DomainWarpFractalType get_domain_warp_fractal_type() const;
+
+ void set_domain_warp_fractal_octaves(int p_octaves);
+ int get_domain_warp_fractal_octaves() const;
+
+ void set_domain_warp_fractal_lacunarity(real_t p_lacunarity);
+ real_t get_domain_warp_fractal_lacunarity() const;
+
+ void set_domain_warp_fractal_gain(real_t p_gain);
+ real_t get_domain_warp_fractal_gain() const;
+
+ // Interface methods.
+
+ Ref<Image> get_image(int p_width, int p_height, bool p_invert = false) override;
+ Ref<Image> get_seamless_image(int p_width, int p_height, bool p_invert = false, real_t p_blend_skirt = 0.1) override;
+
+ real_t get_noise_1d(real_t p_x) override;
+
+ real_t get_noise_2dv(Vector2 p_v) override;
+ real_t get_noise_2d(real_t p_x, real_t p_y) override;
+
+ real_t get_noise_3dv(Vector3 p_v) override;
+ real_t get_noise_3d(real_t p_x, real_t p_y, real_t p_z) override;
+
+ void _changed();
+};
+
+VARIANT_ENUM_CAST(FastNoiseLite::NoiseType);
+VARIANT_ENUM_CAST(FastNoiseLite::FractalType);
+VARIANT_ENUM_CAST(FastNoiseLite::CellularDistanceFunction);
+VARIANT_ENUM_CAST(FastNoiseLite::CellularReturnType);
+VARIANT_ENUM_CAST(FastNoiseLite::DomainWarpType);
+VARIANT_ENUM_CAST(FastNoiseLite::DomainWarpFractalType);
+
+#endif // FASTNOISE_LITE_H
diff --git a/modules/opensimplex/icons/NoiseTexture.svg b/modules/noise/icons/NoiseTexture.svg
index 479684cde2..479684cde2 100644
--- a/modules/opensimplex/icons/NoiseTexture.svg
+++ b/modules/noise/icons/NoiseTexture.svg
diff --git a/modules/noise/noise.cpp b/modules/noise/noise.cpp
new file mode 100644
index 0000000000..430e8c87cf
--- /dev/null
+++ b/modules/noise/noise.cpp
@@ -0,0 +1,68 @@
+/*************************************************************************/
+/* noise.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2022 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 "noise.h"
+
+Ref<Image> Noise::get_seamless_image(int p_width, int p_height, bool p_invert, real_t p_blend_skirt) {
+ int skirt_width = p_width * p_blend_skirt;
+ int skirt_height = p_height * p_blend_skirt;
+ int src_width = p_width + skirt_width;
+ int src_height = p_height + skirt_height;
+
+ Ref<Image> src = get_image(src_width, src_height, p_invert);
+ bool grayscale = (src->get_format() == Image::FORMAT_L8);
+ if (grayscale) {
+ return _generate_seamless_image<uint8_t>(src, p_width, p_height, p_invert, p_blend_skirt);
+ } else {
+ return _generate_seamless_image<uint32_t>(src, p_width, p_height, p_invert, p_blend_skirt);
+ }
+}
+
+// Template specialization for faster grayscale blending.
+template <>
+uint8_t Noise::_alpha_blend<uint8_t>(uint8_t p_bg, uint8_t p_fg, int p_alpha) const {
+ uint16_t alpha = p_alpha + 1;
+ uint16_t inv_alpha = 256 - p_alpha;
+
+ return (uint8_t)((alpha * p_fg + inv_alpha * p_bg) >> 8);
+}
+
+void Noise::_bind_methods() {
+ // Noise functions.
+ ClassDB::bind_method(D_METHOD("get_noise_1d", "x"), &Noise::get_noise_1d);
+ ClassDB::bind_method(D_METHOD("get_noise_2d", "x", "y"), &Noise::get_noise_2d);
+ ClassDB::bind_method(D_METHOD("get_noise_2dv", "v"), &Noise::get_noise_2dv);
+ ClassDB::bind_method(D_METHOD("get_noise_3d", "x", "y", "z"), &Noise::get_noise_3d);
+ ClassDB::bind_method(D_METHOD("get_noise_3dv", "v"), &Noise::get_noise_3dv);
+
+ // Textures.
+ ClassDB::bind_method(D_METHOD("get_image", "width", "height", "invert"), &Noise::get_image, DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("get_seamless_image", "width", "height", "invert", "skirt"), &Noise::get_seamless_image, DEFVAL(false), DEFVAL(0.1));
+}
diff --git a/modules/noise/noise.h b/modules/noise/noise.h
new file mode 100644
index 0000000000..c05bc057da
--- /dev/null
+++ b/modules/noise/noise.h
@@ -0,0 +1,239 @@
+/*************************************************************************/
+/* noise.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2022 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 NOISE_H
+#define NOISE_H
+
+#include "core/io/image.h"
+
+class Noise : public Resource {
+ GDCLASS(Noise, Resource);
+
+ // Helper struct for get_seamless_image(). See comments in .cpp for usage.
+ template <typename T>
+ struct img_buff {
+ T *img;
+ int width; // Array dimensions & default modulo for image.
+ int height;
+ int offset_x; // Offset index location on image (wrapped by specified modulo).
+ int offset_y;
+ int alt_width; // Alternate module for image.
+ int alt_height;
+
+ enum ALT_MODULO {
+ DEFAULT = 0,
+ ALT_X,
+ ALT_Y,
+ ALT_XY
+ };
+
+ // Multi-dimensional array indexer (e.g. img[x][y]) that supports multiple modulos.
+ T &operator()(int x, int y, ALT_MODULO mode = DEFAULT) {
+ switch (mode) {
+ case ALT_XY:
+ return img[(x + offset_x) % alt_width + ((y + offset_y) % alt_height) * width];
+ case ALT_X:
+ return img[(x + offset_x) % alt_width + ((y + offset_y) % height) * width];
+ case ALT_Y:
+ return img[(x + offset_x) % width + ((y + offset_y) % alt_height) * width];
+ default:
+ return img[(x + offset_x) % width + ((y + offset_y) % height) * width];
+ }
+ }
+ };
+
+ union l2c {
+ uint32_t l;
+ uint8_t c[4];
+ struct {
+ uint8_t r;
+ uint8_t g;
+ uint8_t b;
+ uint8_t a;
+ };
+ };
+
+ template <typename T>
+ Ref<Image> _generate_seamless_image(Ref<Image> p_src, int p_width, int p_height, bool p_invert, real_t p_blend_skirt) {
+ /*
+ To make a seamless image, we swap the quadrants so the edges are perfect matches.
+ We initially get a 10% larger image so we have an overlap we can use to blend over the seams.
+
+ Noise::img_buff::operator() acts as a multi-dimensional array indexer.
+ It does the array math, translates between the flipped and non-flipped quadrants, and manages offsets and modulos.
+
+ Here is how the larger source image and final output image map to each other:
+
+ Output size = p_width*p_height Source w/ extra 10% skirt `s` size = src_width*src_height
+ Q1 Q2 Q4 Q3 s1
+ Q3 Q4 Q2 Q1 s2
+ s5 s4 s3
+
+ All of the loops use output coordinates, so Output:Q1 == Source:Q1
+ Ex: Output(half_width, half_height) [the midpoint, corner of Q1/Q4] =>
+ on Source it's translated to
+ corner of Q1/s3 unless the ALT_XY modulo moves it to Q4
+ */
+
+ int skirt_width = MAX(1, p_width * p_blend_skirt);
+ int skirt_height = MAX(1, p_height * p_blend_skirt);
+ int src_width = p_width + skirt_width;
+ int src_height = p_height + skirt_height;
+ int half_width = p_width * .5;
+ int half_height = p_height * .5;
+ int skirt_edge_x = half_width + skirt_width;
+ int skirt_edge_y = half_height + skirt_height;
+
+ Vector<uint8_t> dest;
+ dest.resize(p_width * p_height * Image::get_format_pixel_size(p_src->get_format()));
+
+ img_buff<T> rd_src = {
+ (T *)p_src->get_data().ptr(),
+ src_width, src_height,
+ half_width, half_height,
+ p_width, p_height
+ };
+
+ // `wr` is setup for straight x/y coordinate array access.
+ img_buff<T> wr = {
+ (T *)dest.ptrw(),
+ p_width, p_height,
+ 0, 0, 0, 0
+ };
+ // `rd_dest` is a readable pointer to `wr`, i.e. what has already been written to the output buffer.
+ img_buff<T> rd_dest = {
+ (T *)dest.ptr(),
+ p_width, p_height,
+ 0, 0, 0, 0
+ };
+
+ // Swap the quadrants to make edges seamless.
+ for (int y = 0; y < p_height; y++) {
+ for (int x = 0; x < p_width; x++) {
+ // rd_src has a half offset and the shorter modulo ignores the skirt.
+ // It reads and writes in Q1-4 order (see map above), skipping the skirt.
+ wr(x, y) = rd_src(x, y, img_buff<T>::ALT_XY);
+ }
+ }
+
+ // Blend the vertical skirt over the middle seam.
+ for (int x = half_width; x < skirt_edge_x; x++) {
+ int alpha = 255 * (1 - Math::smoothstep(.1f, .9f, float(x - half_width) / float(skirt_width)));
+ for (int y = 0; y < p_height; y++) {
+ // Skip the center square
+ if (y == half_height) {
+ y = skirt_edge_y - 1;
+ } else {
+ // Starts reading at s2, ALT_Y skips s3, and continues with s1.
+ wr(x, y) = _alpha_blend<T>(rd_dest(x, y), rd_src(x, y, img_buff<T>::ALT_Y), alpha);
+ }
+ }
+ }
+
+ // Blend the horizontal skirt over the middle seam.
+ for (int y = half_height; y < skirt_edge_y; y++) {
+ int alpha = 255 * (1 - Math::smoothstep(.1f, .9f, float(y - half_height) / float(skirt_height)));
+ for (int x = 0; x < p_width; x++) {
+ // Skip the center square
+ if (x == half_width) {
+ x = skirt_edge_x - 1;
+ } else {
+ // Starts reading at s4, skips s3, continues with s5.
+ wr(x, y) = _alpha_blend<T>(rd_dest(x, y), rd_src(x, y, img_buff<T>::ALT_X), alpha);
+ }
+ }
+ }
+
+ // Fill in the center square. Wr starts at the top left of Q4, which is the equivalent of the top left of s3, unless a modulo is used.
+ for (int y = half_height; y < skirt_edge_y; y++) {
+ for (int x = half_width; x < skirt_edge_x; x++) {
+ int xpos = 255 * (1 - Math::smoothstep(.1f, .9f, float(x - half_width) / float(skirt_width)));
+ int ypos = 255 * (1 - Math::smoothstep(.1f, .9f, float(y - half_height) / float(skirt_height)));
+
+ // Blend s3(Q1) onto s5(Q2) for the top half.
+ T top_blend = _alpha_blend<T>(rd_src(x, y, img_buff<T>::ALT_X), rd_src(x, y, img_buff<T>::DEFAULT), xpos);
+ // Blend s1(Q3) onto Q4 for the bottom half.
+ T bottom_blend = _alpha_blend<T>(rd_src(x, y, img_buff<T>::ALT_XY), rd_src(x, y, img_buff<T>::ALT_Y), xpos);
+ // Blend the top half onto the bottom half.
+ wr(x, y) = _alpha_blend<T>(bottom_blend, top_blend, ypos);
+ }
+ }
+ Ref<Image> image = memnew(Image(p_width, p_height, false, p_src->get_format(), dest));
+ p_src.unref();
+ return image;
+ }
+
+ template <typename T>
+ T _alpha_blend(T p_bg, T p_fg, int p_alpha) const {
+ l2c fg, bg, out;
+
+ fg.l = p_fg;
+ bg.l = p_bg;
+
+ uint16_t alpha;
+ uint16_t inv_alpha;
+
+ // If no alpha argument specified, use the alpha channel in the color
+ if (p_alpha == -1) {
+ alpha = fg.c[3] + 1;
+ inv_alpha = 256 - fg.c[3];
+ } else {
+ alpha = p_alpha + 1;
+ inv_alpha = 256 - p_alpha;
+ }
+
+ out.c[0] = (uint8_t)((alpha * fg.c[0] + inv_alpha * bg.c[0]) >> 8);
+ out.c[1] = (uint8_t)((alpha * fg.c[1] + inv_alpha * bg.c[1]) >> 8);
+ out.c[2] = (uint8_t)((alpha * fg.c[2] + inv_alpha * bg.c[2]) >> 8);
+ out.c[3] = 0xFF;
+
+ return out.l;
+ }
+
+protected:
+ static void _bind_methods();
+
+public:
+ // Virtual destructor so we can delete any Noise derived object when referenced as a Noise*.
+ virtual ~Noise() {}
+
+ virtual real_t get_noise_1d(real_t p_x) = 0;
+
+ virtual real_t get_noise_2dv(Vector2 p_v) = 0;
+ virtual real_t get_noise_2d(real_t p_x, real_t p_y) = 0;
+
+ virtual real_t get_noise_3dv(Vector3 p_v) = 0;
+ virtual real_t get_noise_3d(real_t p_x, real_t p_y, real_t p_z) = 0;
+
+ virtual Ref<Image> get_image(int p_width, int p_height, bool p_invert = false) = 0;
+ virtual Ref<Image> get_seamless_image(int p_width, int p_height, bool p_invert = false, real_t p_blend_skirt = 0.1);
+};
+
+#endif // NOISE_H
diff --git a/modules/opensimplex/noise_texture.cpp b/modules/noise/noise_texture.cpp
index f3342dfd84..3721043a09 100644
--- a/modules/opensimplex/noise_texture.cpp
+++ b/modules/noise/noise_texture.cpp
@@ -31,9 +31,10 @@
#include "noise_texture.h"
#include "core/core_string_names.h"
+#include "noise.h"
NoiseTexture::NoiseTexture() {
- noise = Ref<OpenSimplexNoise>();
+ noise = Ref<Noise>();
_queue_update();
}
@@ -52,12 +53,15 @@ void NoiseTexture::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_noise", "noise"), &NoiseTexture::set_noise);
ClassDB::bind_method(D_METHOD("get_noise"), &NoiseTexture::get_noise);
- ClassDB::bind_method(D_METHOD("set_noise_offset", "noise_offset"), &NoiseTexture::set_noise_offset);
- ClassDB::bind_method(D_METHOD("get_noise_offset"), &NoiseTexture::get_noise_offset);
+ ClassDB::bind_method(D_METHOD("set_invert", "invert"), &NoiseTexture::set_invert);
+ ClassDB::bind_method(D_METHOD("get_invert"), &NoiseTexture::get_invert);
ClassDB::bind_method(D_METHOD("set_seamless", "seamless"), &NoiseTexture::set_seamless);
ClassDB::bind_method(D_METHOD("get_seamless"), &NoiseTexture::get_seamless);
+ ClassDB::bind_method(D_METHOD("set_seamless_blend_skirt", "seamless_blend_skirt"), &NoiseTexture::set_seamless_blend_skirt);
+ ClassDB::bind_method(D_METHOD("get_seamless_blend_skirt"), &NoiseTexture::get_seamless_blend_skirt);
+
ClassDB::bind_method(D_METHOD("set_as_normal_map", "as_normal_map"), &NoiseTexture::set_as_normal_map);
ClassDB::bind_method(D_METHOD("is_normal_map"), &NoiseTexture::is_normal_map);
@@ -70,11 +74,12 @@ void NoiseTexture::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::INT, "width", PROPERTY_HINT_RANGE, "1,2048,1,or_greater"), "set_width", "get_width");
ADD_PROPERTY(PropertyInfo(Variant::INT, "height", PROPERTY_HINT_RANGE, "1,2048,1,or_greater"), "set_height", "get_height");
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "invert"), "set_invert", "get_invert");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "seamless"), "set_seamless", "get_seamless");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "seamless_blend_skirt", PROPERTY_HINT_RANGE, "0.05,1,0.001"), "set_seamless_blend_skirt", "get_seamless_blend_skirt");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "as_normal_map"), "set_as_normal_map", "is_normal_map");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "bump_strength", PROPERTY_HINT_RANGE, "0,32,0.1,or_greater"), "set_bump_strength", "get_bump_strength");
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "noise", PROPERTY_HINT_RESOURCE_TYPE, "OpenSimplexNoise"), "set_noise", "get_noise");
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "noise_offset"), "set_noise_offset", "get_noise_offset");
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "noise", PROPERTY_HINT_RESOURCE_TYPE, "Noise"), "set_noise", "get_noise");
}
void NoiseTexture::_validate_property(PropertyInfo &property) const {
@@ -83,6 +88,12 @@ void NoiseTexture::_validate_property(PropertyInfo &property) const {
property.usage = PROPERTY_USAGE_NO_EDITOR | PROPERTY_USAGE_INTERNAL;
}
}
+
+ if (property.name == "seamless_blend_skirt") {
+ if (!seamless) {
+ property.usage = PROPERTY_USAGE_NO_EDITOR;
+ }
+ }
}
void NoiseTexture::_set_texture_image(const Ref<Image> &p_image) {
@@ -123,7 +134,7 @@ void NoiseTexture::_queue_update() {
Ref<Image> NoiseTexture::_generate_texture() {
// Prevent memdelete due to unref() on other thread.
- Ref<OpenSimplexNoise> ref_noise = noise;
+ Ref<Noise> ref_noise = noise;
if (ref_noise.is_null()) {
return Ref<Image>();
@@ -132,9 +143,9 @@ Ref<Image> NoiseTexture::_generate_texture() {
Ref<Image> image;
if (seamless) {
- image = ref_noise->get_seamless_image(size.x);
+ image = ref_noise->get_seamless_image(size.x, size.y, invert, seamless_blend_skirt);
} else {
- image = ref_noise->get_image(size.x, size.y, noise_offset);
+ image = ref_noise->get_image(size.x, size.y, invert);
}
if (as_normal_map) {
@@ -168,7 +179,7 @@ void NoiseTexture::_update_texture() {
update_queued = false;
}
-void NoiseTexture::set_noise(Ref<OpenSimplexNoise> p_noise) {
+void NoiseTexture::set_noise(Ref<Noise> p_noise) {
if (p_noise == noise) {
return;
}
@@ -182,7 +193,7 @@ void NoiseTexture::set_noise(Ref<OpenSimplexNoise> p_noise) {
_queue_update();
}
-Ref<OpenSimplexNoise> NoiseTexture::get_noise() {
+Ref<Noise> NoiseTexture::get_noise() {
return noise;
}
@@ -204,26 +215,42 @@ void NoiseTexture::set_height(int p_height) {
_queue_update();
}
-void NoiseTexture::set_noise_offset(Vector2 p_noise_offset) {
- if (noise_offset == p_noise_offset) {
+void NoiseTexture::set_invert(bool p_invert) {
+ if (p_invert == invert) {
return;
}
- noise_offset = p_noise_offset;
+ invert = p_invert;
_queue_update();
}
+bool NoiseTexture::get_invert() const {
+ return invert;
+}
+
void NoiseTexture::set_seamless(bool p_seamless) {
if (p_seamless == seamless) {
return;
}
seamless = p_seamless;
_queue_update();
+ notify_property_list_changed();
}
bool NoiseTexture::get_seamless() {
return seamless;
}
+void NoiseTexture::set_seamless_blend_skirt(real_t p_blend_skirt) {
+ if (p_blend_skirt == seamless_blend_skirt) {
+ return;
+ }
+ seamless_blend_skirt = p_blend_skirt;
+ _queue_update();
+}
+real_t NoiseTexture::get_seamless_blend_skirt() {
+ return seamless_blend_skirt;
+}
+
void NoiseTexture::set_as_normal_map(bool p_as_normal_map) {
if (p_as_normal_map == as_normal_map) {
return;
@@ -259,10 +286,6 @@ int NoiseTexture::get_height() const {
return size.y;
}
-Vector2 NoiseTexture::get_noise_offset() const {
- return noise_offset;
-}
-
RID NoiseTexture::get_rid() const {
if (!texture.is_valid()) {
texture = RS::get_singleton()->texture_2d_placeholder_create();
diff --git a/modules/opensimplex/noise_texture.h b/modules/noise/noise_texture.h
index ee8f88aaca..2a94df39d4 100644
--- a/modules/opensimplex/noise_texture.h
+++ b/modules/noise/noise_texture.h
@@ -31,10 +31,10 @@
#ifndef NOISE_TEXTURE_H
#define NOISE_TEXTURE_H
-#include "open_simplex_noise.h"
+#include "noise.h"
-#include "core/io/image.h"
#include "core/object/ref_counted.h"
+#include "scene/resources/texture.h"
class NoiseTexture : public Texture2D {
GDCLASS(NoiseTexture, Texture2D);
@@ -51,10 +51,12 @@ private:
mutable RID texture;
uint32_t flags = 0;
- Ref<OpenSimplexNoise> noise;
+ Ref<Noise> noise;
+ bool invert = false;
Vector2i size = Vector2i(512, 512);
Vector2 noise_offset;
bool seamless = false;
+ real_t seamless_blend_skirt = 0.1;
bool as_normal_map = false;
float bump_strength = 8.0;
@@ -71,18 +73,21 @@ protected:
virtual void _validate_property(PropertyInfo &property) const override;
public:
- void set_noise(Ref<OpenSimplexNoise> p_noise);
- Ref<OpenSimplexNoise> get_noise();
+ void set_noise(Ref<Noise> p_noise);
+ Ref<Noise> get_noise();
void set_width(int p_width);
void set_height(int p_height);
- void set_noise_offset(Vector2 p_noise_offset);
- Vector2 get_noise_offset() const;
+ void set_invert(bool p_invert);
+ bool get_invert() const;
void set_seamless(bool p_seamless);
bool get_seamless();
+ void set_seamless_blend_skirt(real_t p_blend_skirt);
+ real_t get_seamless_blend_skirt();
+
void set_as_normal_map(bool p_as_normal_map);
bool is_normal_map();
diff --git a/modules/opensimplex/register_types.cpp b/modules/noise/register_types.cpp
index 30dfdc3764..81bb0317c1 100644
--- a/modules/opensimplex/register_types.cpp
+++ b/modules/noise/register_types.cpp
@@ -29,13 +29,16 @@
/*************************************************************************/
#include "register_types.h"
+
+#include "fastnoise_lite.h"
+#include "noise.h"
#include "noise_texture.h"
-#include "open_simplex_noise.h"
-void register_opensimplex_types() {
- GDREGISTER_CLASS(OpenSimplexNoise);
+void register_noise_types() {
GDREGISTER_CLASS(NoiseTexture);
+ GDREGISTER_ABSTRACT_CLASS(Noise);
+ GDREGISTER_CLASS(FastNoiseLite);
}
-void unregister_opensimplex_types() {
+void unregister_noise_types() {
}
diff --git a/modules/opensimplex/register_types.h b/modules/noise/register_types.h
index 2262ab2f5e..e441a48518 100644
--- a/modules/opensimplex/register_types.h
+++ b/modules/noise/register_types.h
@@ -28,10 +28,10 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef OPENSIMPLEX_REGISTER_TYPES_H
-#define OPENSIMPLEX_REGISTER_TYPES_H
+#ifndef NOISE_REGISTER_TYPES_H
+#define NOISE_REGISTER_TYPES_H
-void register_opensimplex_types();
-void unregister_opensimplex_types();
+void register_noise_types();
+void unregister_noise_types();
-#endif // OPENSIMPLEX_REGISTER_TYPES_H
+#endif // NOISE_REGISTER_TYPES_H
diff --git a/modules/opensimplex/doc_classes/OpenSimplexNoise.xml b/modules/opensimplex/doc_classes/OpenSimplexNoise.xml
deleted file mode 100644
index 51dd83efc3..0000000000
--- a/modules/opensimplex/doc_classes/OpenSimplexNoise.xml
+++ /dev/null
@@ -1,112 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<class name="OpenSimplexNoise" inherits="Resource" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
- <brief_description>
- Noise generator based on Open Simplex.
- </brief_description>
- <description>
- This resource allows you to configure and sample a fractal noise space. Here is a brief usage example that configures an OpenSimplexNoise and gets samples at various positions and dimensions:
- [codeblock]
- var noise = OpenSimplexNoise.new()
-
- # Configure
- noise.seed = randi()
- noise.octaves = 4
- noise.period = 20.0
- noise.persistence = 0.8
-
- # Sample
- print("Values:")
- print(noise.get_noise_2d(1.0, 1.0))
- print(noise.get_noise_3d(0.5, 3.0, 15.0))
- print(noise.get_noise_4d(0.5, 1.9, 4.7, 0.0))
- [/codeblock]
- </description>
- <tutorials>
- </tutorials>
- <methods>
- <method name="get_image" qualifiers="const">
- <return type="Image" />
- <argument index="0" name="width" type="int" />
- <argument index="1" name="height" type="int" />
- <argument index="2" name="noise_offset" type="Vector2" default="Vector2(0, 0)" />
- <description>
- Generate a noise image in [constant Image.FORMAT_L8] format with the requested [code]width[/code] and [code]height[/code], based on the current noise parameters. If [code]noise_offset[/code] is specified, then the offset value is used as the coordinates of the top-left corner of the generated noise.
- </description>
- </method>
- <method name="get_noise_1d" qualifiers="const">
- <return type="float" />
- <argument index="0" name="x" type="float" />
- <description>
- Returns the 1D noise value [code][-1,1][/code] at the given x-coordinate.
- [b]Note:[/b] This method actually returns the 2D noise value [code][-1,1][/code] with fixed y-coordinate value 0.0.
- </description>
- </method>
- <method name="get_noise_2d" qualifiers="const">
- <return type="float" />
- <argument index="0" name="x" type="float" />
- <argument index="1" name="y" type="float" />
- <description>
- Returns the 2D noise value [code][-1,1][/code] at the given position.
- </description>
- </method>
- <method name="get_noise_2dv" qualifiers="const">
- <return type="float" />
- <argument index="0" name="pos" type="Vector2" />
- <description>
- Returns the 2D noise value [code][-1,1][/code] at the given position.
- </description>
- </method>
- <method name="get_noise_3d" qualifiers="const">
- <return type="float" />
- <argument index="0" name="x" type="float" />
- <argument index="1" name="y" type="float" />
- <argument index="2" name="z" type="float" />
- <description>
- Returns the 3D noise value [code][-1,1][/code] at the given position.
- </description>
- </method>
- <method name="get_noise_3dv" qualifiers="const">
- <return type="float" />
- <argument index="0" name="pos" type="Vector3" />
- <description>
- Returns the 3D noise value [code][-1,1][/code] at the given position.
- </description>
- </method>
- <method name="get_noise_4d" qualifiers="const">
- <return type="float" />
- <argument index="0" name="x" type="float" />
- <argument index="1" name="y" type="float" />
- <argument index="2" name="z" type="float" />
- <argument index="3" name="w" type="float" />
- <description>
- Returns the 4D noise value [code][-1,1][/code] at the given position.
- </description>
- </method>
- <method name="get_seamless_image" qualifiers="const">
- <return type="Image" />
- <argument index="0" name="size" type="int" />
- <description>
- Generate a tileable noise image in [constant Image.FORMAT_L8] format, based on the current noise parameters. Generated seamless images are always square ([code]size[/code] × [code]size[/code]).
- [b]Note:[/b] Seamless noise has a lower contrast compared to non-seamless noise. This is due to the way noise uses higher dimensions for generating seamless noise.
- </description>
- </method>
- </methods>
- <members>
- <member name="lacunarity" type="float" setter="set_lacunarity" getter="get_lacunarity" default="2.0">
- Difference in period between [member octaves].
- </member>
- <member name="octaves" type="int" setter="set_octaves" getter="get_octaves" default="3">
- Number of OpenSimplex noise layers that are sampled to get the fractal noise. Higher values result in more detailed noise but take more time to generate.
- [b]Note:[/b] The maximum allowed value is 9.
- </member>
- <member name="period" type="float" setter="set_period" getter="get_period" default="64.0">
- Period of the base octave. A lower period results in a higher-frequency noise (more value changes across the same distance).
- </member>
- <member name="persistence" type="float" setter="set_persistence" getter="get_persistence" default="0.5">
- Contribution factor of the different octaves. A [code]persistence[/code] value of 1 means all the octaves have the same contribution, a value of 0.5 means each octave contributes half as much as the previous one.
- </member>
- <member name="seed" type="int" setter="set_seed" getter="get_seed" default="0">
- Seed used to generate random values, different seeds will generate different noise maps.
- </member>
- </members>
-</class>
diff --git a/modules/opensimplex/open_simplex_noise.cpp b/modules/opensimplex/open_simplex_noise.cpp
deleted file mode 100644
index b7c901fd06..0000000000
--- a/modules/opensimplex/open_simplex_noise.cpp
+++ /dev/null
@@ -1,250 +0,0 @@
-/*************************************************************************/
-/* open_simplex_noise.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2022 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 "open_simplex_noise.h"
-
-#include "core/core_string_names.h"
-
-OpenSimplexNoise::OpenSimplexNoise() {
- _init_seeds();
-}
-
-OpenSimplexNoise::~OpenSimplexNoise() {
-}
-
-void OpenSimplexNoise::_init_seeds() {
- for (int i = 0; i < MAX_OCTAVES; ++i) {
- open_simplex_noise(seed + i * 2, &(contexts[i]));
- }
-}
-
-void OpenSimplexNoise::set_seed(int p_seed) {
- if (seed == p_seed) {
- return;
- }
-
- seed = p_seed;
-
- _init_seeds();
-
- emit_changed();
-}
-
-int OpenSimplexNoise::get_seed() const {
- return seed;
-}
-
-void OpenSimplexNoise::set_octaves(int p_octaves) {
- if (p_octaves == octaves) {
- return;
- }
-
- ERR_FAIL_COND_MSG(p_octaves > MAX_OCTAVES, vformat("The number of OpenSimplexNoise octaves is limited to %d; ignoring the new value.", MAX_OCTAVES));
-
- octaves = CLAMP(p_octaves, 1, MAX_OCTAVES);
- emit_changed();
-}
-
-void OpenSimplexNoise::set_period(float p_period) {
- if (p_period == period) {
- return;
- }
- period = p_period;
- emit_changed();
-}
-
-void OpenSimplexNoise::set_persistence(float p_persistence) {
- if (p_persistence == persistence) {
- return;
- }
- persistence = p_persistence;
- emit_changed();
-}
-
-void OpenSimplexNoise::set_lacunarity(float p_lacunarity) {
- if (p_lacunarity == lacunarity) {
- return;
- }
- lacunarity = p_lacunarity;
- emit_changed();
-}
-
-Ref<Image> OpenSimplexNoise::get_image(int p_width, int p_height, const Vector2 &p_noise_offset) const {
- Vector<uint8_t> data;
- data.resize(p_width * p_height);
-
- uint8_t *wd8 = data.ptrw();
-
- for (int i = 0; i < p_height; i++) {
- for (int j = 0; j < p_width; j++) {
- float v = get_noise_2d(float(j) + p_noise_offset.x, float(i) + p_noise_offset.y);
- v = v * 0.5 + 0.5; // Normalize [0..1]
- wd8[(i * p_width + j)] = uint8_t(CLAMP(v * 255.0, 0, 255));
- }
- }
-
- Ref<Image> image = memnew(Image(p_width, p_height, false, Image::FORMAT_L8, data));
- return image;
-}
-
-Ref<Image> OpenSimplexNoise::get_seamless_image(int p_size) const {
- Vector<uint8_t> data;
- data.resize(p_size * p_size);
-
- uint8_t *wd8 = data.ptrw();
-
- for (int i = 0; i < p_size; i++) {
- for (int j = 0; j < p_size; j++) {
- float ii = (float)i / (float)p_size;
- float jj = (float)j / (float)p_size;
-
- ii *= Math_TAU;
- jj *= Math_TAU;
-
- float radius = p_size / Math_TAU;
-
- float x = radius * Math::sin(jj);
- float y = radius * Math::cos(jj);
- float z = radius * Math::sin(ii);
- float w = radius * Math::cos(ii);
- float v = get_noise_4d(x, y, z, w);
-
- v = v * 0.5 + 0.5; // Normalize [0..1]
- wd8[(i * p_size + j)] = uint8_t(CLAMP(v * 255.0, 0, 255));
- }
- }
-
- Ref<Image> image = memnew(Image(p_size, p_size, false, Image::FORMAT_L8, data));
- return image;
-}
-
-void OpenSimplexNoise::_bind_methods() {
- ClassDB::bind_method(D_METHOD("get_seed"), &OpenSimplexNoise::get_seed);
- ClassDB::bind_method(D_METHOD("set_seed", "seed"), &OpenSimplexNoise::set_seed);
-
- ClassDB::bind_method(D_METHOD("set_octaves", "octave_count"), &OpenSimplexNoise::set_octaves);
- ClassDB::bind_method(D_METHOD("get_octaves"), &OpenSimplexNoise::get_octaves);
-
- ClassDB::bind_method(D_METHOD("set_period", "period"), &OpenSimplexNoise::set_period);
- ClassDB::bind_method(D_METHOD("get_period"), &OpenSimplexNoise::get_period);
-
- ClassDB::bind_method(D_METHOD("set_persistence", "persistence"), &OpenSimplexNoise::set_persistence);
- ClassDB::bind_method(D_METHOD("get_persistence"), &OpenSimplexNoise::get_persistence);
-
- ClassDB::bind_method(D_METHOD("set_lacunarity", "lacunarity"), &OpenSimplexNoise::set_lacunarity);
- ClassDB::bind_method(D_METHOD("get_lacunarity"), &OpenSimplexNoise::get_lacunarity);
-
- ClassDB::bind_method(D_METHOD("get_image", "width", "height", "noise_offset"), &OpenSimplexNoise::get_image, DEFVAL(Vector2()));
- ClassDB::bind_method(D_METHOD("get_seamless_image", "size"), &OpenSimplexNoise::get_seamless_image);
-
- ClassDB::bind_method(D_METHOD("get_noise_1d", "x"), &OpenSimplexNoise::get_noise_1d);
- ClassDB::bind_method(D_METHOD("get_noise_2d", "x", "y"), &OpenSimplexNoise::get_noise_2d);
- ClassDB::bind_method(D_METHOD("get_noise_3d", "x", "y", "z"), &OpenSimplexNoise::get_noise_3d);
- ClassDB::bind_method(D_METHOD("get_noise_4d", "x", "y", "z", "w"), &OpenSimplexNoise::get_noise_4d);
-
- ClassDB::bind_method(D_METHOD("get_noise_2dv", "pos"), &OpenSimplexNoise::get_noise_2dv);
- ClassDB::bind_method(D_METHOD("get_noise_3dv", "pos"), &OpenSimplexNoise::get_noise_3dv);
-
- ADD_PROPERTY(PropertyInfo(Variant::INT, "seed"), "set_seed", "get_seed");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "octaves", PROPERTY_HINT_RANGE, vformat("1,%d,1", MAX_OCTAVES)), "set_octaves", "get_octaves");
- ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "period", PROPERTY_HINT_RANGE, "0.1,256.0,0.1"), "set_period", "get_period");
- ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "persistence", PROPERTY_HINT_RANGE, "0.0,1.0,0.001"), "set_persistence", "get_persistence");
- ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "lacunarity", PROPERTY_HINT_RANGE, "0.1,4.0,0.01"), "set_lacunarity", "get_lacunarity");
-}
-
-float OpenSimplexNoise::get_noise_1d(float x) const {
- return get_noise_2d(x, 1.0);
-}
-
-float OpenSimplexNoise::get_noise_2d(float x, float y) const {
- x /= period;
- y /= period;
-
- float amp = 1.0;
- float max = 1.0;
- float sum = _get_octave_noise_2d(0, x, y);
-
- int i = 0;
- while (++i < octaves) {
- x *= lacunarity;
- y *= lacunarity;
- amp *= persistence;
- max += amp;
- sum += _get_octave_noise_2d(i, x, y) * amp;
- }
-
- return sum / max;
-}
-
-float OpenSimplexNoise::get_noise_3d(float x, float y, float z) const {
- x /= period;
- y /= period;
- z /= period;
-
- float amp = 1.0;
- float max = 1.0;
- float sum = _get_octave_noise_3d(0, x, y, z);
-
- int i = 0;
- while (++i < octaves) {
- x *= lacunarity;
- y *= lacunarity;
- z *= lacunarity;
- amp *= persistence;
- max += amp;
- sum += _get_octave_noise_3d(i, x, y, z) * amp;
- }
-
- return sum / max;
-}
-
-float OpenSimplexNoise::get_noise_4d(float x, float y, float z, float w) const {
- x /= period;
- y /= period;
- z /= period;
- w /= period;
-
- float amp = 1.0;
- float max = 1.0;
- float sum = _get_octave_noise_4d(0, x, y, z, w);
-
- int i = 0;
- while (++i < octaves) {
- x *= lacunarity;
- y *= lacunarity;
- z *= lacunarity;
- w *= lacunarity;
- amp *= persistence;
- max += amp;
- sum += _get_octave_noise_4d(i, x, y, z, w) * amp;
- }
-
- return sum / max;
-}
diff --git a/modules/opensimplex/open_simplex_noise.h b/modules/opensimplex/open_simplex_noise.h
deleted file mode 100644
index c34f998b78..0000000000
--- a/modules/opensimplex/open_simplex_noise.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/*************************************************************************/
-/* open_simplex_noise.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* https://godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2022 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 OPEN_SIMPLEX_NOISE_H
-#define OPEN_SIMPLEX_NOISE_H
-
-#include "core/io/image.h"
-#include "core/object/ref_counted.h"
-#include "scene/resources/texture.h"
-
-#include "thirdparty/misc/open-simplex-noise.h"
-
-class OpenSimplexNoise : public Resource {
- GDCLASS(OpenSimplexNoise, Resource);
- OBJ_SAVE_TYPE(OpenSimplexNoise);
-
- // The maximum number of octaves allowed. Note that these are statically allocated.
- // Higher values become exponentially slower, so this shouldn't be set too high
- // to avoid freezing the editor for long periods of time.
- static const int MAX_OCTAVES = 9;
-
- osn_context contexts[MAX_OCTAVES];
-
- int seed = 0;
- float persistence = 0.5; // Controls details, value in [0,1]. Higher increases grain, lower increases smoothness.
- int octaves = 3; // Number of noise layers
- float period = 64.0; // Distance above which we start to see similarities. The higher, the longer "hills" will be on a terrain.
- float lacunarity = 2.0; // Controls period change across octaves. 2 is usually a good value to address all detail levels.
-
-public:
- OpenSimplexNoise();
- ~OpenSimplexNoise();
-
- void _init_seeds();
-
- void set_seed(int seed);
- int get_seed() const;
-
- void set_octaves(int p_octaves);
- int get_octaves() const { return octaves; }
-
- void set_period(float p_period);
- float get_period() const { return period; }
-
- void set_persistence(float p_persistence);
- float get_persistence() const { return persistence; }
-
- void set_lacunarity(float p_lacunarity);
- float get_lacunarity() const { return lacunarity; }
-
- Ref<Image> get_image(int p_width, int p_height, const Vector2 &p_noise_offset = Vector2()) const;
- Ref<Image> get_seamless_image(int p_size) const;
-
- float get_noise_1d(float x) const;
- float get_noise_2d(float x, float y) const;
- float get_noise_3d(float x, float y, float z) const;
- float get_noise_4d(float x, float y, float z, float w) const;
-
- _FORCE_INLINE_ float _get_octave_noise_2d(int octave, float x, float y) const { return open_simplex_noise2(&(contexts[octave]), x, y); }
- _FORCE_INLINE_ float _get_octave_noise_3d(int octave, float x, float y, float z) const { return open_simplex_noise3(&(contexts[octave]), x, y, z); }
- _FORCE_INLINE_ float _get_octave_noise_4d(int octave, float x, float y, float z, float w) const { return open_simplex_noise4(&(contexts[octave]), x, y, z, w); }
-
- // Convenience
-
- _FORCE_INLINE_ float get_noise_2dv(const Vector2 &v) const { return get_noise_2d(v.x, v.y); }
- _FORCE_INLINE_ float get_noise_3dv(const Vector3 &v) const { return get_noise_3d(v.x, v.y, v.z); }
-
-protected:
- static void _bind_methods();
-};
-
-#endif // OPEN_SIMPLEX_NOISE_H
diff --git a/modules/openxr/openxr_api.cpp b/modules/openxr/openxr_api.cpp
index bf668bac27..f7ff6cc89d 100644
--- a/modules/openxr/openxr_api.cpp
+++ b/modules/openxr/openxr_api.cpp
@@ -52,32 +52,6 @@
OpenXRAPI *OpenXRAPI::singleton = nullptr;
-void OpenXRAPI::setup_global_defs() {
- // As OpenXRAPI is not constructed if OpenXR is not enabled, we register our project and editor settings here
-
- // Project settings
- GLOBAL_DEF_BASIC("xr/openxr/enabled", false);
- GLOBAL_DEF_BASIC("xr/openxr/default_action_map", "res://default_action_map.tres");
- ProjectSettings::get_singleton()->set_custom_property_info("xr/openxr/default_action_map", PropertyInfo(Variant::STRING, "xr/openxr/default_action_map", PROPERTY_HINT_FILE, "*.tres"));
-
- GLOBAL_DEF_BASIC("xr/openxr/form_factor", "0");
- ProjectSettings::get_singleton()->set_custom_property_info("xr/openxr/form_factor", PropertyInfo(Variant::INT, "xr/openxr/form_factor", PROPERTY_HINT_ENUM, "Head mounted,Handheld"));
-
- GLOBAL_DEF_BASIC("xr/openxr/view_configuration", "1");
- ProjectSettings::get_singleton()->set_custom_property_info("xr/openxr/view_configuration", PropertyInfo(Variant::INT, "xr/openxr/view_configuration", PROPERTY_HINT_ENUM, "Mono,Stereo")); // "Mono,Stereo,Quad,Observer"
-
- GLOBAL_DEF_BASIC("xr/openxr/reference_space", "1");
- ProjectSettings::get_singleton()->set_custom_property_info("xr/openxr/reference_space", PropertyInfo(Variant::INT, "xr/openxr/reference_space", PROPERTY_HINT_ENUM, "Local,Stage"));
-
-#ifdef TOOLS_ENABLED
- // Disabled for now, using XR inside of the editor we'll be working on during the coming months.
-
- // editor settings (it seems we're too early in the process when setting up rendering, to access editor settings...)
- // EDITOR_DEF_RST("xr/openxr/in_editor", false);
- // GLOBAL_DEF("xr/openxr/in_editor", false);
-#endif
-}
-
bool OpenXRAPI::openxr_is_enabled() {
// @TODO we need an overrule switch so we can force enable openxr, i.e run "godot --openxr_enabled"
diff --git a/modules/openxr/openxr_api.h b/modules/openxr/openxr_api.h
index 5d1cea1217..1a1508e993 100644
--- a/modules/openxr/openxr_api.h
+++ b/modules/openxr/openxr_api.h
@@ -222,7 +222,6 @@ protected:
void parse_velocities(const XrSpaceVelocity &p_velocity, Vector3 &r_linear_velocity, Vector3 r_angular_velocity);
public:
- static void setup_global_defs();
static bool openxr_is_enabled();
static OpenXRAPI *get_singleton();
diff --git a/modules/openxr/register_types.cpp b/modules/openxr/register_types.cpp
index bb550980cf..47ee1316e7 100644
--- a/modules/openxr/register_types.cpp
+++ b/modules/openxr/register_types.cpp
@@ -44,7 +44,6 @@ Ref<OpenXRInterface> openxr_interface;
void preregister_openxr_types() {
// For now we create our openxr device here. If we merge it with openxr_interface we'll create that here soon.
- OpenXRAPI::setup_global_defs();
if (OpenXRAPI::openxr_is_enabled()) {
openxr_api = memnew(OpenXRAPI);
ERR_FAIL_NULL(openxr_api);
diff --git a/modules/svg/register_types.cpp b/modules/svg/register_types.cpp
index a4341c6f1e..b59c815056 100644
--- a/modules/svg/register_types.cpp
+++ b/modules/svg/register_types.cpp
@@ -38,7 +38,7 @@ static ImageLoaderSVG *image_loader_svg = nullptr;
void register_svg_types() {
tvg::CanvasEngine tvgEngine = tvg::CanvasEngine::Sw;
- if (tvg::Initializer::init(tvgEngine, 0) != tvg::Result::Success) {
+ if (tvg::Initializer::init(tvgEngine, 1) != tvg::Result::Success) {
return;
}
image_loader_svg = memnew(ImageLoaderSVG);
diff --git a/modules/text_server_adv/SCsub b/modules/text_server_adv/SCsub
index e999700d55..525d4d3efb 100644
--- a/modules/text_server_adv/SCsub
+++ b/modules/text_server_adv/SCsub
@@ -37,7 +37,7 @@ def make_icu_data(target, source, env):
thirdparty_obj = []
freetype_enabled = env.module_check_dependencies("text_server_adv", ["freetype"], True)
-msdngen_enabled = env.module_check_dependencies("text_server_adv", ["msdfgen"], True)
+msdfgen_enabled = env.module_check_dependencies("text_server_adv", ["msdfgen"], True)
if env["builtin_harfbuzz"]:
env_harfbuzz = env_modules.Clone()
@@ -117,20 +117,25 @@ if env["builtin_harfbuzz"]:
]
thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]
- env_harfbuzz.Append(
- CPPPATH=[
- "#thirdparty/harfbuzz/src",
- "#thirdparty/icu4c/common/",
- ]
- )
+ env_harfbuzz.Append(CPPPATH=["#thirdparty/harfbuzz/src"])
+
+ env_harfbuzz.Append(CCFLAGS=["-DHAVE_ICU"])
+ if env["builtin_icu"]:
+ env_harfbuzz.Append(CPPPATH=["#thirdparty/icu4c/common/"])
+ env_harfbuzz.Append(CCFLAGS=["-DU_HAVE_LIB_SUFFIX=1", "-DU_LIB_SUFFIX_C_NAME=_godot", "-DHAVE_ICU_BUILTIN"])
if freetype_enabled:
env_harfbuzz.Append(
- CPPPATH=[
- "#thirdparty/freetype/include",
- "#thirdparty/graphite/include",
+ CCFLAGS=[
+ "-DHAVE_FREETYPE",
+ "-DHAVE_GRAPHITE2",
]
)
+ if env["builtin_freetype"]:
+ env_harfbuzz.Append(CPPPATH=["#thirdparty/freetype/include"])
+ if env["builtin_graphite"]:
+ env_harfbuzz.Append(CPPPATH=["#thirdparty/graphite/include"])
+ env_harfbuzz.Append(CCFLAGS=["-DGRAPHITE2_STATIC"])
if env["platform"] == "android" or env["platform"] == "linuxbsd":
env_harfbuzz.Append(CCFLAGS=["-DHAVE_PTHREAD"])
@@ -141,21 +146,7 @@ if env["builtin_harfbuzz"]:
else:
env_harfbuzz.Append(CCFLAGS=["-DHB_NO_MT"])
- env_harfbuzz.Append(
- CCFLAGS=[
- "-DHAVE_ICU_BUILTIN",
- "-DHAVE_ICU",
- ]
- )
-
- if freetype_enabled:
- env_harfbuzz.Append(
- CCFLAGS=[
- "-DHAVE_FREETYPE",
- "-DHAVE_GRAPHITE2",
- "-DGRAPHITE2_STATIC",
- ]
- )
+ env_text_server_adv.Append(CPPPATH=["#thirdparty/harfbuzz/src"])
lib = env_harfbuzz.add_library("harfbuzz_builtin", thirdparty_sources)
thirdparty_obj += lib
@@ -473,14 +464,23 @@ if env["builtin_icu"]:
"-DUCONFIG_NO_FILE_IO",
"-DUCONFIG_NO_TRANSLITERATION",
"-DPKGDATA_MODE=static",
+ "-DU_ENABLE_DYLOAD=0",
+ "-DU_HAVE_LIB_SUFFIX=1",
+ "-DU_LIB_SUFFIX_C_NAME=_godot",
"-DICU_DATA_NAME=" + icu_data_name,
]
)
env_text_server_adv.Append(
CXXFLAGS=[
+ "-DU_HAVE_LIB_SUFFIX=1",
+ "-DU_LIB_SUFFIX_C_NAME=_godot",
"-DICU_DATA_NAME=" + icu_data_name,
]
)
+ if env_text_server_adv["tools"]:
+ env_text_server_adv.Append(CXXFLAGS=["-DICU_STATIC_DATA"])
+
+ env_text_server_adv.Append(CPPPATH=["#thirdparty/icu4c/common/"])
lib = env_icu.add_library("icu_builtin", thirdparty_sources)
thirdparty_obj += lib
@@ -503,30 +503,14 @@ if env["builtin_icu"]:
module_obj = []
-if env_text_server_adv["tools"]:
- env_text_server_adv.Append(CXXFLAGS=["-DICU_STATIC_DATA"])
+if env["builtin_msdfgen"] and msdfgen_enabled:
+ env_text_server_adv.Append(CPPPATH=["#thirdparty/msdfgen"])
-env_text_server_adv.Append(
- CPPPATH=[
- "#thirdparty/harfbuzz/src",
- "#thirdparty/icu4c/common/",
- ]
-)
+if env["builtin_freetype"] and freetype_enabled:
+ env_text_server_adv.Append(CPPPATH=["#thirdparty/freetype/include"])
-if msdngen_enabled:
- env_text_server_adv.Append(
- CPPPATH=[
- "#thirdparty/msdfgen",
- ]
- )
-
-if freetype_enabled:
- env_text_server_adv.Append(
- CPPPATH=[
- "#thirdparty/freetype/include",
- "#thirdparty/graphite/include",
- ]
- )
+if env["builtin_graphite"] and freetype_enabled:
+ env_text_server_adv.Append(CPPPATH=["#thirdparty/graphite/include"])
env_text_server_adv.add_source_files(module_obj, "*.cpp")
env.modules_sources += module_obj
diff --git a/modules/text_server_fb/SCsub b/modules/text_server_fb/SCsub
index 31d1db6167..121f38fcd5 100644
--- a/modules/text_server_fb/SCsub
+++ b/modules/text_server_fb/SCsub
@@ -4,22 +4,14 @@ Import("env")
Import("env_modules")
freetype_enabled = env.module_check_dependencies("text_server_fb", ["freetype"], True)
-msdngen_enabled = env.module_check_dependencies("text_server_fb", ["msdfgen"], True)
+msdfgen_enabled = env.module_check_dependencies("text_server_fb", ["msdfgen"], True)
env_text_server_fb = env_modules.Clone()
-if msdngen_enabled:
- env_text_server_fb.Append(
- CPPPATH=[
- "#thirdparty/msdfgen",
- ]
- )
+if env["builtin_msdfgen"] and msdfgen_enabled:
+ env_text_server_fb.Append(CPPPATH=["#thirdparty/msdfgen"])
-if freetype_enabled:
- env_text_server_fb.Append(
- CPPPATH=[
- "#thirdparty/freetype/include",
- ]
- )
+if env["builtin_freetype"] and freetype_enabled:
+ env_text_server_fb.Append(CPPPATH=["#thirdparty/freetype/include"])
env_text_server_fb.add_source_files(env.modules_sources, "*.cpp")
diff --git a/modules/visual_script/visual_script.h b/modules/visual_script/visual_script.h
index d4dffdfc7a..d72bdf9128 100644
--- a/modules/visual_script/visual_script.h
+++ b/modules/visual_script/visual_script.h
@@ -338,8 +338,8 @@ public:
virtual Error reload(bool p_keep_state = false) override;
#ifdef TOOLS_ENABLED
- virtual const Vector<DocData::ClassDoc> &get_documentation() const override {
- static Vector<DocData::ClassDoc> docs;
+ virtual Vector<DocData::ClassDoc> get_documentation() const override {
+ Vector<DocData::ClassDoc> docs;
return docs;
}
#endif // TOOLS_ENABLED
diff --git a/modules/websocket/SCsub b/modules/websocket/SCsub
index 63c941c4a8..dc0661995f 100644
--- a/modules/websocket/SCsub
+++ b/modules/websocket/SCsub
@@ -41,6 +41,8 @@ elif env["builtin_wslay"]:
module_obj = []
env_ws.add_source_files(module_obj, "*.cpp")
+if env["tools"]:
+ env_ws.add_source_files(module_obj, "editor/*.cpp")
env.modules_sources += module_obj
# Needed to force rebuilding the module files when the thirdparty library is updated.
diff --git a/modules/websocket/editor_debugger_server_websocket.cpp b/modules/websocket/editor/editor_debugger_server_websocket.cpp
index 4f1a56f00b..0443147d98 100644
--- a/modules/websocket/editor_debugger_server_websocket.cpp
+++ b/modules/websocket/editor/editor_debugger_server_websocket.cpp
@@ -30,11 +30,13 @@
#include "editor_debugger_server_websocket.h"
+#ifdef TOOLS_ENABLED
+
+#include "../remote_debugger_peer_websocket.h"
#include "core/config/project_settings.h"
#include "editor/editor_log.h"
#include "editor/editor_node.h"
#include "editor/editor_settings.h"
-#include "modules/websocket/remote_debugger_peer_websocket.h"
void EditorDebuggerServerWebSocket::_peer_connected(int p_id, String _protocol) {
pending_peers.push_back(p_id);
@@ -129,3 +131,5 @@ EditorDebuggerServer *EditorDebuggerServerWebSocket::create(const String &p_prot
ERR_FAIL_COND_V(p_protocol != "ws://", nullptr);
return memnew(EditorDebuggerServerWebSocket);
}
+
+#endif // TOOLS_ENABLED
diff --git a/modules/websocket/editor_debugger_server_websocket.h b/modules/websocket/editor/editor_debugger_server_websocket.h
index cc14bf62ba..7c0705302d 100644
--- a/modules/websocket/editor_debugger_server_websocket.h
+++ b/modules/websocket/editor/editor_debugger_server_websocket.h
@@ -31,8 +31,10 @@
#ifndef EDITOR_DEBUGGER_SERVER_WEBSOCKET_H
#define EDITOR_DEBUGGER_SERVER_WEBSOCKET_H
+#ifdef TOOLS_ENABLED
+
+#include "../websocket_server.h"
#include "editor/debugger/editor_debugger_server.h"
-#include "modules/websocket/websocket_server.h"
class EditorDebuggerServerWebSocket : public EditorDebuggerServer {
GDCLASS(EditorDebuggerServerWebSocket, EditorDebuggerServer);
@@ -60,4 +62,6 @@ public:
~EditorDebuggerServerWebSocket();
};
+#endif // TOOLS_ENABLED
+
#endif // EDITOR_DEBUGGER_SERVER_WEBSOCKET_H
diff --git a/modules/websocket/register_types.cpp b/modules/websocket/register_types.cpp
index ff900f496f..6d63938d4f 100644
--- a/modules/websocket/register_types.cpp
+++ b/modules/websocket/register_types.cpp
@@ -29,8 +29,10 @@
/*************************************************************************/
#include "register_types.h"
+
#include "core/config/project_settings.h"
#include "core/error/error_macros.h"
+
#ifdef JAVASCRIPT_ENABLED
#include "emscripten.h"
#include "emws_client.h"
@@ -40,10 +42,11 @@
#include "wsl_client.h"
#include "wsl_server.h"
#endif
+
#ifdef TOOLS_ENABLED
#include "editor/debugger/editor_debugger_server.h"
+#include "editor/editor_debugger_server_websocket.h"
#include "editor/editor_node.h"
-#include "editor_debugger_server_websocket.h"
#endif
#ifdef TOOLS_ENABLED
diff --git a/modules/websocket/remote_debugger_peer_websocket.h b/modules/websocket/remote_debugger_peer_websocket.h
index ddf5425d81..84f9506625 100644
--- a/modules/websocket/remote_debugger_peer_websocket.h
+++ b/modules/websocket/remote_debugger_peer_websocket.h
@@ -31,12 +31,13 @@
#ifndef REMOTE_DEBUGGER_PEER_WEBSOCKET_H
#define REMOTE_DEBUGGER_PEER_WEBSOCKET_H
+#include "core/debugger/remote_debugger_peer.h"
+
#ifdef JAVASCRIPT_ENABLED
-#include "modules/websocket/emws_client.h"
+#include "emws_client.h"
#else
-#include "modules/websocket/wsl_client.h"
+#include "wsl_client.h"
#endif
-#include "core/debugger/remote_debugger_peer.h"
class RemoteDebuggerPeerWebSocket : public RemoteDebuggerPeer {
Ref<WebSocketClient> ws_client;