summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/classes/ClassDB.xml1
-rw-r--r--editor/create_dialog.cpp10
-rw-r--r--editor/create_dialog.h2
-rw-r--r--editor/editor_data.cpp23
-rw-r--r--editor/editor_data.h4
-rw-r--r--editor/editor_properties.cpp19
-rw-r--r--editor/filesystem_dock.cpp9
-rw-r--r--editor/inspector_dock.cpp5
-rw-r--r--editor/plugins/node_3d_editor_plugin.cpp22
-rw-r--r--editor/property_editor.cpp19
-rw-r--r--editor/scene_tree_dock.cpp4
-rw-r--r--misc/dist/html/editor.html26
-rw-r--r--modules/gltf/register_types.cpp4
-rw-r--r--modules/minimp3/audio_stream_mp3.cpp5
-rw-r--r--modules/opensimplex/doc_classes/OpenSimplexNoise.xml4
-rw-r--r--modules/opensimplex/open_simplex_noise.cpp20
-rw-r--r--modules/stb_vorbis/audio_stream_ogg_vorbis.cpp5
-rw-r--r--modules/visual_script/visual_script_editor.cpp13
-rw-r--r--servers/physics_2d/body_pair_2d_sw.cpp43
-rw-r--r--servers/physics_2d/physics_server_2d_sw.cpp32
-rw-r--r--servers/physics_2d/space_2d_sw.cpp31
-rw-r--r--servers/physics_3d/space_3d_sw.cpp4
22 files changed, 156 insertions, 149 deletions
diff --git a/doc/classes/ClassDB.xml b/doc/classes/ClassDB.xml
index 2a6a2ddd91..860bdc7c8f 100644
--- a/doc/classes/ClassDB.xml
+++ b/doc/classes/ClassDB.xml
@@ -67,6 +67,7 @@
</argument>
<description>
Returns an array with all the methods of [code]class[/code] or its ancestry if [code]no_inheritance[/code] is [code]false[/code]. Every element of the array is a [Dictionary] with the following keys: [code]args[/code], [code]default_args[/code], [code]flags[/code], [code]id[/code], [code]name[/code], [code]return: (class_name, hint, hint_string, name, type, usage)[/code].
+ [b]Note:[/code] In exported release builds the debug info is not available, so the returned dictionaries will contain only method names.
</description>
</method>
<method name="class_get_property" qualifiers="const">
diff --git a/editor/create_dialog.cpp b/editor/create_dialog.cpp
index dd5a87ff30..3a63100012 100644
--- a/editor/create_dialog.cpp
+++ b/editor/create_dialog.cpp
@@ -408,15 +408,15 @@ String CreateDialog::get_selected_type() {
return selected->get_text(0);
}
-Object *CreateDialog::instance_selected() {
+Variant CreateDialog::instance_selected() {
TreeItem *selected = search_options->get_selected();
if (!selected) {
- return nullptr;
+ return Variant();
}
Variant md = selected->get_metadata(0);
- Object *obj = nullptr;
+ Variant obj;
if (md.get_type() != Variant::NIL) {
String custom = md;
if (ScriptServer::is_global_class(custom)) {
@@ -434,13 +434,13 @@ Object *CreateDialog::instance_selected() {
// Check if any Object-type property should be instantiated.
List<PropertyInfo> pinfo;
- obj->get_property_list(&pinfo);
+ ((Object *)obj)->get_property_list(&pinfo);
for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) {
PropertyInfo pi = E->get();
if (pi.type == Variant::OBJECT && pi.usage & PROPERTY_USAGE_EDITOR_INSTANTIATE_OBJECT) {
Object *prop = ClassDB::instance(pi.class_name);
- obj->set(pi.name, prop);
+ ((Object *)obj)->set(pi.name, prop);
}
}
diff --git a/editor/create_dialog.h b/editor/create_dialog.h
index b76155365f..b08cb72f14 100644
--- a/editor/create_dialog.h
+++ b/editor/create_dialog.h
@@ -102,7 +102,7 @@ protected:
void _save_and_update_favorite_list();
public:
- Object *instance_selected();
+ Variant instance_selected();
String get_selected_type();
void set_base_type(const String &p_base) { base_type = p_base; }
diff --git a/editor/editor_data.cpp b/editor/editor_data.cpp
index 4c4dacbeb5..1d3bd55ed3 100644
--- a/editor/editor_data.cpp
+++ b/editor/editor_data.cpp
@@ -468,24 +468,25 @@ void EditorData::add_custom_type(const String &p_type, const String &p_inherits,
custom_types[p_inherits].push_back(ct);
}
-Object *EditorData::instance_custom_type(const String &p_type, const String &p_inherits) {
+Variant EditorData::instance_custom_type(const String &p_type, const String &p_inherits) {
if (get_custom_types().has(p_inherits)) {
for (int i = 0; i < get_custom_types()[p_inherits].size(); i++) {
if (get_custom_types()[p_inherits][i].name == p_type) {
Ref<Script> script = get_custom_types()[p_inherits][i].script;
- Object *ob = ClassDB::instance(p_inherits);
- ERR_FAIL_COND_V(!ob, nullptr);
- if (ob->is_class("Node")) {
- ob->call("set_name", p_type);
+ Variant ob = ClassDB::instance(p_inherits);
+ ERR_FAIL_COND_V(!ob, Variant());
+ Node *n = Object::cast_to<Node>(ob);
+ if (n) {
+ n->set_name(p_type);
}
- ob->set_script(script);
+ ((Object *)ob)->set_script(script);
return ob;
}
}
}
- return nullptr;
+ return Variant();
}
void EditorData::remove_custom_type(const String &p_type) {
@@ -867,18 +868,18 @@ StringName EditorData::script_class_get_base(const String &p_class) const {
return script->get_language()->get_global_class_name(base_script->get_path());
}
-Object *EditorData::script_class_instance(const String &p_class) {
+Variant EditorData::script_class_instance(const String &p_class) {
if (ScriptServer::is_global_class(p_class)) {
- Object *obj = ClassDB::instance(ScriptServer::get_global_class_native_base(p_class));
+ Variant obj = ClassDB::instance(ScriptServer::get_global_class_native_base(p_class));
if (obj) {
Ref<Script> script = script_class_load_script(p_class);
if (script.is_valid()) {
- obj->set_script(script);
+ ((Object *)obj)->set_script(script);
}
return obj;
}
}
- return nullptr;
+ return Variant();
}
Ref<Script> EditorData::script_class_load_script(const String &p_class) const {
diff --git a/editor/editor_data.h b/editor/editor_data.h
index 42afc9e079..d5c8c2a713 100644
--- a/editor/editor_data.h
+++ b/editor/editor_data.h
@@ -171,7 +171,7 @@ public:
void restore_editor_global_states();
void add_custom_type(const String &p_type, const String &p_inherits, const Ref<Script> &p_script, const Ref<Texture2D> &p_icon);
- Object *instance_custom_type(const String &p_type, const String &p_inherits);
+ Variant instance_custom_type(const String &p_type, const String &p_inherits);
void remove_custom_type(const String &p_type);
const Map<String, Vector<CustomType>> &get_custom_types() const { return custom_types; }
@@ -208,7 +208,7 @@ public:
bool script_class_is_parent(const String &p_class, const String &p_inherits);
StringName script_class_get_base(const String &p_class) const;
- Object *script_class_instance(const String &p_class);
+ Variant script_class_instance(const String &p_class);
Ref<Script> script_class_load_script(const String &p_class) const;
diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp
index 143eea88e1..3fa183e10c 100644
--- a/editor/editor_properties.cpp
+++ b/editor/editor_properties.cpp
@@ -68,9 +68,9 @@ void EditorPropertyText::_text_changed(const String &p_string) {
}
if (string_name) {
- emit_changed(get_edited_property(), StringName(p_string), "", false);
+ emit_changed(get_edited_property(), StringName(p_string), "", true);
} else {
- emit_changed(get_edited_property(), p_string, "", false);
+ emit_changed(get_edited_property(), p_string, "", true);
}
}
@@ -2544,35 +2544,32 @@ void EditorPropertyResource::_menu_option(int p_which) {
return;
}
- Object *obj = nullptr;
- RES res_temp;
+ Variant obj;
if (ScriptServer::is_global_class(intype)) {
obj = ClassDB::instance(ScriptServer::get_global_class_native_base(intype));
if (obj) {
- res_temp = obj;
Ref<Script> script = ResourceLoader::load(ScriptServer::get_global_class_path(intype));
if (script.is_valid()) {
- obj->set_script(Variant(script));
+ ((Object *)obj)->set_script(script);
}
}
} else {
obj = ClassDB::instance(intype);
- res_temp = obj;
}
if (!obj) {
obj = EditorNode::get_editor_data().instance_custom_type(intype, "Resource");
- res_temp = obj;
}
- ERR_BREAK(!res_temp.is_valid());
+ Resource *resp = Object::cast_to<Resource>(obj);
+ ERR_BREAK(!resp);
if (get_edited_object() && base_type != String() && base_type == "Script") {
//make visual script the right type
- res_temp->call("set_instance_base_type", get_edited_object()->get_class());
+ resp->call("set_instance_base_type", get_edited_object()->get_class());
}
- res = res_temp;
+ res = RES(resp);
emit_changed(get_edited_property(), res);
update_property();
diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp
index fcf3e49a91..e8cf081320 100644
--- a/editor/filesystem_dock.cpp
+++ b/editor/filesystem_dock.cpp
@@ -1898,7 +1898,7 @@ void FileSystemDock::_file_option(int p_option, const Vector<String> &p_selected
}
void FileSystemDock::_resource_created() {
- Object *c = new_resource_dialog->instance_selected();
+ Variant c = new_resource_dialog->instance_selected();
ERR_FAIL_COND(!c);
Resource *r = Object::cast_to<Resource>(c);
@@ -1912,17 +1912,14 @@ void FileSystemDock::_resource_created() {
memdelete(node);
}
- REF res(r);
- editor->push_item(c);
-
- RES current_res = RES(r);
+ editor->push_item(r);
String fpath = path;
if (!fpath.ends_with("/")) {
fpath = fpath.get_base_dir();
}
- editor->save_resource_as(current_res, fpath);
+ editor->save_resource_as(RES(r), fpath);
}
void FileSystemDock::_search_changed(const String &p_text, const Control *p_from) {
diff --git a/editor/inspector_dock.cpp b/editor/inspector_dock.cpp
index 311fa5206e..fbcd76a95f 100644
--- a/editor/inspector_dock.cpp
+++ b/editor/inspector_dock.cpp
@@ -270,14 +270,13 @@ void InspectorDock::_select_history(int p_idx) {
}
void InspectorDock::_resource_created() {
- Object *c = new_resource_dialog->instance_selected();
+ Variant c = new_resource_dialog->instance_selected();
ERR_FAIL_COND(!c);
Resource *r = Object::cast_to<Resource>(c);
ERR_FAIL_COND(!r);
- REF res(r);
- editor->push_item(c);
+ editor->push_item(r);
}
void InspectorDock::_resource_selected(const RES &p_res, const String &p_property) {
diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp
index 3e8547439f..6cc28ab225 100644
--- a/editor/plugins/node_3d_editor_plugin.cpp
+++ b/editor/plugins/node_3d_editor_plugin.cpp
@@ -5880,17 +5880,20 @@ void Node3DEditor::snap_selected_nodes_to_floor() {
// Priorities for snapping to floor are CollisionShapes, VisualInstances and then origin
Set<VisualInstance3D *> vi = _get_child_nodes<VisualInstance3D>(sp);
Set<CollisionShape3D *> cs = _get_child_nodes<CollisionShape3D>(sp);
+ bool found_valid_shape = false;
if (cs.size()) {
AABB aabb;
- bool found_valid_shape = false;
- if (cs.front()->get()->get_shape().is_valid()) {
- aabb = sp->get_global_transform().xform(cs.front()->get()->get_shape()->get_debug_mesh()->get_aabb());
+ Set<CollisionShape3D *>::Element *I = cs.front();
+ if (I->get()->get_shape().is_valid()) {
+ CollisionShape3D *collision_shape = cs.front()->get();
+ aabb = collision_shape->get_global_transform().xform(collision_shape->get_shape()->get_debug_mesh()->get_aabb());
found_valid_shape = true;
}
- for (Set<CollisionShape3D *>::Element *I = cs.front(); I; I = I->next()) {
- if (I->get()->get_shape().is_valid()) {
- aabb.merge_with(sp->get_global_transform().xform(I->get()->get_shape()->get_debug_mesh()->get_aabb()));
+ for (I = I->next(); I; I = I->next()) {
+ CollisionShape3D *col_shape = I->get();
+ if (col_shape->get_shape().is_valid()) {
+ aabb.merge_with(col_shape->get_global_transform().xform(col_shape->get_shape()->get_debug_mesh()->get_aabb()));
found_valid_shape = true;
}
}
@@ -5898,10 +5901,9 @@ void Node3DEditor::snap_selected_nodes_to_floor() {
Vector3 size = aabb.size * Vector3(0.5, 0.0, 0.5);
from = aabb.position + size;
position_offset.y = from.y - sp->get_global_transform().origin.y;
- } else {
- from = sp->get_global_transform().origin;
}
- } else if (vi.size()) {
+ }
+ if (!found_valid_shape && vi.size()) {
AABB aabb = vi.front()->get()->get_transformed_aabb();
for (Set<VisualInstance3D *>::Element *I = vi.front(); I; I = I->next()) {
aabb.merge_with(I->get()->get_transformed_aabb());
@@ -5909,7 +5911,7 @@ void Node3DEditor::snap_selected_nodes_to_floor() {
Vector3 size = aabb.size * Vector3(0.5, 0.0, 0.5);
from = aabb.position + size;
position_offset.y = from.y - sp->get_global_transform().origin.y;
- } else {
+ } else if (!found_valid_shape) {
from = sp->get_global_transform().origin;
}
diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp
index 93689dd4cd..07312e42b4 100644
--- a/editor/property_editor.cpp
+++ b/editor/property_editor.cpp
@@ -262,7 +262,7 @@ void CustomPropertyEditor::_menu_option(int p_which) {
return;
}
- Object *obj = ClassDB::instance(intype);
+ Variant obj = ClassDB::instance(intype);
if (!obj) {
if (ScriptServer::is_global_class(intype)) {
@@ -280,7 +280,7 @@ void CustomPropertyEditor::_menu_option(int p_which) {
res->call("set_instance_base_type", owner->get_class());
}
- v = res;
+ v = obj;
emit_signal("variant_changed");
} break;
@@ -1064,7 +1064,7 @@ void CustomPropertyEditor::_type_create_selected(int p_idx) {
String intype = inheritors_array[p_idx];
- Object *obj = ClassDB::instance(intype);
+ Variant obj = ClassDB::instance(intype);
if (!obj) {
if (ScriptServer::is_global_class(intype)) {
@@ -1075,11 +1075,9 @@ void CustomPropertyEditor::_type_create_selected(int p_idx) {
}
ERR_FAIL_COND(!obj);
+ ERR_FAIL_COND(!Object::cast_to<Resource>(obj));
- Resource *res = Object::cast_to<Resource>(obj);
- ERR_FAIL_COND(!res);
-
- v = res;
+ v = obj;
emit_signal("variant_changed");
hide();
}
@@ -1251,7 +1249,7 @@ void CustomPropertyEditor::_action_pressed(int p_which) {
String intype = inheritors_array[0];
if (hint == PROPERTY_HINT_RESOURCE_TYPE) {
- Object *obj = ClassDB::instance(intype);
+ Variant obj = ClassDB::instance(intype);
if (!obj) {
if (ScriptServer::is_global_class(intype)) {
@@ -1262,10 +1260,9 @@ void CustomPropertyEditor::_action_pressed(int p_which) {
}
ERR_BREAK(!obj);
- Resource *res = Object::cast_to<Resource>(obj);
- ERR_BREAK(!res);
+ ERR_BREAK(!Object::cast_to<Resource>(obj));
- v = res;
+ v = obj;
emit_signal("variant_changed");
hide();
}
diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp
index 17d3883689..bbedb4f033 100644
--- a/editor/scene_tree_dock.cpp
+++ b/editor/scene_tree_dock.cpp
@@ -1936,7 +1936,7 @@ void SceneTreeDock::_selection_changed() {
}
void SceneTreeDock::_do_create(Node *p_parent) {
- Object *c = create_dialog->instance_selected();
+ Variant c = create_dialog->instance_selected();
ERR_FAIL_COND(!c);
Node *child = Object::cast_to<Node>(c);
@@ -2016,7 +2016,7 @@ void SceneTreeDock::_create() {
Node *n = E->get();
ERR_FAIL_COND(!n);
- Object *c = create_dialog->instance_selected();
+ Variant c = create_dialog->instance_selected();
ERR_FAIL_COND(!c);
Node *newnode = Object::cast_to<Node>(c);
diff --git a/misc/dist/html/editor.html b/misc/dist/html/editor.html
index 18c759ace8..de3cd07a93 100644
--- a/misc/dist/html/editor.html
+++ b/misc/dist/html/editor.html
@@ -7,6 +7,14 @@
<title></title>
<style type='text/css'>
+ *:focus {
+ /* More visible outline for better keyboard navigation. */
+ outline: 0.125rem solid hsl(220, 100%, 62.5%);
+ /* Make the outline always appear above other elements. */
+ /* Otherwise, one of its sides can be hidden by tabs in the Download and More layouts. */
+ position: relative;
+ }
+
body {
touch-action: none;
font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
@@ -18,6 +26,20 @@
overflow: hidden;
}
+ a {
+ color: hsl(205, 100%, 75%);
+ text-decoration-color: hsla(205, 100%, 75%, 0.3);
+ text-decoration-thickness: 0.125rem;
+ }
+
+ a:hover {
+ filter: brightness(117.5%);
+ }
+
+ a:active {
+ filter: brightness(82.5%);
+ }
+
#canvas, #gameCanvas {
display: block;
margin: 0;
@@ -45,10 +67,6 @@
margin: 0 0.5rem;
}
- .btn:focus {
- outline: 1px solid #699ce8;
- }
-
.btn:not(:disabled):hover {
color: #e0e1e5;
border-color: #666c7b;
diff --git a/modules/gltf/register_types.cpp b/modules/gltf/register_types.cpp
index 85da4a0dd7..dc995c9249 100644
--- a/modules/gltf/register_types.cpp
+++ b/modules/gltf/register_types.cpp
@@ -60,9 +60,10 @@ static void _editor_init() {
void register_gltf_types() {
#ifndef _3D_DISABLED
#ifdef TOOLS_ENABLED
- ClassDB::register_class<EditorSceneImporterGLTF>();
ClassDB::APIType prev_api = ClassDB::get_current_api();
ClassDB::set_current_api(ClassDB::API_EDITOR);
+ ClassDB::register_class<EditorSceneImporterGLTF>();
+ ClassDB::register_class<GLTFMesh>();
EditorPlugins::add_by_type<SceneExporterGLTFPlugin>();
ClassDB::set_current_api(prev_api);
EditorNode::add_init_callback(_editor_init);
@@ -75,7 +76,6 @@ void register_gltf_types() {
ClassDB::register_class<GLTFTexture>();
ClassDB::register_class<GLTFSkeleton>();
ClassDB::register_class<GLTFSkin>();
- ClassDB::register_class<GLTFMesh>();
ClassDB::register_class<GLTFCamera>();
ClassDB::register_class<GLTFLight>();
ClassDB::register_class<GLTFState>();
diff --git a/modules/minimp3/audio_stream_mp3.cpp b/modules/minimp3/audio_stream_mp3.cpp
index 392a2fb565..8627f71987 100644
--- a/modules/minimp3/audio_stream_mp3.cpp
+++ b/modules/minimp3/audio_stream_mp3.cpp
@@ -120,7 +120,10 @@ AudioStreamPlaybackMP3::~AudioStreamPlaybackMP3() {
Ref<AudioStreamPlayback> AudioStreamMP3::instance_playback() {
Ref<AudioStreamPlaybackMP3> mp3s;
- ERR_FAIL_COND_V(data == nullptr, mp3s);
+ ERR_FAIL_COND_V_MSG(data == nullptr, mp3s,
+ "This AudioStreamMP3 does not have an audio file assigned "
+ "to it. AudioStreamMP3 should not be created from the "
+ "inspector or with `.new()`. Instead, load an audio file.");
mp3s.instance();
mp3s->mp3_stream = Ref<AudioStreamMP3>(this);
diff --git a/modules/opensimplex/doc_classes/OpenSimplexNoise.xml b/modules/opensimplex/doc_classes/OpenSimplexNoise.xml
index 9fe4c9c249..dcda5c2324 100644
--- a/modules/opensimplex/doc_classes/OpenSimplexNoise.xml
+++ b/modules/opensimplex/doc_classes/OpenSimplexNoise.xml
@@ -32,7 +32,7 @@
<argument index="1" name="height" type="int">
</argument>
<description>
- Generate a noise image with the requested [code]width[/code] and [code]height[/code], based on the current noise parameters.
+ 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.
</description>
</method>
<method name="get_noise_1d" qualifiers="const">
@@ -108,7 +108,7 @@
<argument index="0" name="size" type="int">
</argument>
<description>
- Generate a tileable noise image, based on the current noise parameters. Generated seamless images are always square ([code]size[/code] × [code]size[/code]).
+ 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]).
</description>
</method>
</methods>
diff --git a/modules/opensimplex/open_simplex_noise.cpp b/modules/opensimplex/open_simplex_noise.cpp
index 403340e39c..e4e2e0613a 100644
--- a/modules/opensimplex/open_simplex_noise.cpp
+++ b/modules/opensimplex/open_simplex_noise.cpp
@@ -104,7 +104,7 @@ void OpenSimplexNoise::set_lacunarity(float p_lacunarity) {
Ref<Image> OpenSimplexNoise::get_image(int p_width, int p_height) const {
Vector<uint8_t> data;
- data.resize(p_width * p_height * 4);
+ data.resize(p_width * p_height);
uint8_t *wd8 = data.ptrw();
@@ -112,21 +112,17 @@ Ref<Image> OpenSimplexNoise::get_image(int p_width, int p_height) const {
for (int j = 0; j < p_width; j++) {
float v = get_noise_2d(j, i);
v = v * 0.5 + 0.5; // Normalize [0..1]
- uint8_t value = uint8_t(CLAMP(v * 255.0, 0, 255));
- wd8[(i * p_width + j) * 4 + 0] = value;
- wd8[(i * p_width + j) * 4 + 1] = value;
- wd8[(i * p_width + j) * 4 + 2] = value;
- wd8[(i * p_width + j) * 4 + 3] = 255;
+ 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_RGBA8, data));
+ 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 * 4);
+ data.resize(p_size * p_size);
uint8_t *wd8 = data.ptrw();
@@ -147,15 +143,11 @@ Ref<Image> OpenSimplexNoise::get_seamless_image(int p_size) const {
float v = get_noise_4d(x, y, z, w);
v = v * 0.5 + 0.5; // Normalize [0..1]
- uint8_t value = uint8_t(CLAMP(v * 255.0, 0, 255));
- wd8[(i * p_size + j) * 4 + 0] = value;
- wd8[(i * p_size + j) * 4 + 1] = value;
- wd8[(i * p_size + j) * 4 + 2] = value;
- wd8[(i * p_size + j) * 4 + 3] = 255;
+ 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_RGBA8, data));
+ Ref<Image> image = memnew(Image(p_size, p_size, false, Image::FORMAT_L8, data));
return image;
}
diff --git a/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp b/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp
index 82d1206e93..4b2be47e74 100644
--- a/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp
+++ b/modules/stb_vorbis/audio_stream_ogg_vorbis.cpp
@@ -124,7 +124,10 @@ AudioStreamPlaybackOGGVorbis::~AudioStreamPlaybackOGGVorbis() {
Ref<AudioStreamPlayback> AudioStreamOGGVorbis::instance_playback() {
Ref<AudioStreamPlaybackOGGVorbis> ovs;
- ERR_FAIL_COND_V(data == nullptr, ovs);
+ ERR_FAIL_COND_V_MSG(data == nullptr, ovs,
+ "This AudioStreamOGGVorbis does not have an audio file assigned "
+ "to it. AudioStreamOGGVorbis should not be created from the "
+ "inspector or with `.new()`. Instead, load an audio file.");
ovs.instance();
ovs->vorbis_stream = Ref<AudioStreamOGGVorbis>(this);
diff --git a/modules/visual_script/visual_script_editor.cpp b/modules/visual_script/visual_script_editor.cpp
index 3fbf19a48d..1e82259e59 100644
--- a/modules/visual_script/visual_script_editor.cpp
+++ b/modules/visual_script/visual_script_editor.cpp
@@ -227,6 +227,19 @@ protected:
undo_redo->create_action(TTR("Set Variable Type"));
undo_redo->add_do_method(script.ptr(), "set_variable_info", var, dc);
undo_redo->add_undo_method(script.ptr(), "set_variable_info", var, d);
+
+ // Setting the default value.
+ Variant::Type type = (Variant::Type)(int)p_value;
+ if (type != Variant::NIL) {
+ Variant default_value;
+ Callable::CallError ce;
+ Variant::construct(type, default_value, nullptr, 0, ce);
+ if (ce.error == Callable::CallError::CALL_OK) {
+ undo_redo->add_do_method(script.ptr(), "set_variable_default_value", var, default_value);
+ undo_redo->add_undo_method(script.ptr(), "set_variable_default_value", var, dc["value"]);
+ }
+ }
+
undo_redo->add_do_method(this, "_var_changed");
undo_redo->add_undo_method(this, "_var_changed");
undo_redo->commit_action();
diff --git a/servers/physics_2d/body_pair_2d_sw.cpp b/servers/physics_2d/body_pair_2d_sw.cpp
index 6a13453f9f..feced36a2b 100644
--- a/servers/physics_2d/body_pair_2d_sw.cpp
+++ b/servers/physics_2d/body_pair_2d_sw.cpp
@@ -288,21 +288,17 @@ bool BodyPair2DSW::setup(real_t p_step) {
if (A->is_shape_set_as_one_way_collision(shape_A)) {
Vector2 direction = xform_A.get_axis(1).normalized();
bool valid = false;
- if (B->get_linear_velocity().dot(direction) >= 0) {
- for (int i = 0; i < contact_count; i++) {
- Contact &c = contacts[i];
- if (!c.reused) {
- continue;
- }
- if (c.normal.dot(direction) > 0) { //greater (normal inverted)
- continue;
- }
-
- valid = true;
- break;
+ for (int i = 0; i < contact_count; i++) {
+ Contact &c = contacts[i];
+ if (!c.reused) {
+ continue;
}
+ if (c.normal.dot(direction) > -CMP_EPSILON) { //greater (normal inverted)
+ continue;
+ }
+ valid = true;
+ break;
}
-
if (!valid) {
collided = false;
oneway_disabled = true;
@@ -313,19 +309,16 @@ bool BodyPair2DSW::setup(real_t p_step) {
if (B->is_shape_set_as_one_way_collision(shape_B)) {
Vector2 direction = xform_B.get_axis(1).normalized();
bool valid = false;
- if (A->get_linear_velocity().dot(direction) >= 0) {
- for (int i = 0; i < contact_count; i++) {
- Contact &c = contacts[i];
- if (!c.reused) {
- continue;
- }
- if (c.normal.dot(direction) < 0) { //less (normal ok)
- continue;
- }
-
- valid = true;
- break;
+ for (int i = 0; i < contact_count; i++) {
+ Contact &c = contacts[i];
+ if (!c.reused) {
+ continue;
+ }
+ if (c.normal.dot(direction) < CMP_EPSILON) { //less (normal ok)
+ continue;
}
+ valid = true;
+ break;
}
if (!valid) {
collided = false;
diff --git a/servers/physics_2d/physics_server_2d_sw.cpp b/servers/physics_2d/physics_server_2d_sw.cpp
index 85e24ca537..c4e2489bef 100644
--- a/servers/physics_2d/physics_server_2d_sw.cpp
+++ b/servers/physics_2d/physics_server_2d_sw.cpp
@@ -149,24 +149,19 @@ void PhysicsServer2DSW::_shape_col_cbk(const Vector2 &p_point_A, const Vector2 &
return;
}
+ Vector2 rel_dir = (p_point_A - p_point_B);
+ real_t rel_length2 = rel_dir.length_squared();
if (cbk->valid_dir != Vector2()) {
- if (p_point_A.distance_squared_to(p_point_B) > cbk->valid_depth * cbk->valid_depth) {
- cbk->invalid_by_dir++;
- return;
- }
- Vector2 rel_dir = (p_point_A - p_point_B).normalized();
-
- if (cbk->valid_dir.dot(rel_dir) < Math_SQRT12) { //sqrt(2)/2.0 - 45 degrees
- cbk->invalid_by_dir++;
-
- /*
- print_line("A: "+p_point_A);
- print_line("B: "+p_point_B);
- print_line("discard too angled "+rtos(cbk->valid_dir.dot((p_point_A-p_point_B))));
- print_line("resnorm: "+(p_point_A-p_point_B).normalized());
- print_line("distance: "+rtos(p_point_A.distance_to(p_point_B)));
- */
- return;
+ if (cbk->valid_depth < 10e20) {
+ if (rel_length2 > cbk->valid_depth * cbk->valid_depth ||
+ (rel_length2 > CMP_EPSILON && cbk->valid_dir.dot(rel_dir.normalized()) < CMP_EPSILON)) {
+ cbk->invalid_by_dir++;
+ return;
+ }
+ } else {
+ if (rel_length2 > 0 && cbk->valid_dir.dot(rel_dir.normalized()) < CMP_EPSILON) {
+ return;
+ }
}
}
@@ -182,8 +177,7 @@ void PhysicsServer2DSW::_shape_col_cbk(const Vector2 &p_point_A, const Vector2 &
}
}
- real_t d = p_point_A.distance_squared_to(p_point_B);
- if (d < min_depth) {
+ if (rel_length2 < min_depth) {
return;
}
cbk->ptr[min_depth_idx * 2 + 0] = p_point_A;
diff --git a/servers/physics_2d/space_2d_sw.cpp b/servers/physics_2d/space_2d_sw.cpp
index c2a6dc828e..ad5dca37e4 100644
--- a/servers/physics_2d/space_2d_sw.cpp
+++ b/servers/physics_2d/space_2d_sw.cpp
@@ -376,25 +376,25 @@ struct _RestCallbackData2D {
Vector2 best_normal;
real_t best_len;
Vector2 valid_dir;
- real_t valid_depth;
real_t min_allowed_depth;
};
static void _rest_cbk_result(const Vector2 &p_point_A, const Vector2 &p_point_B, void *p_userdata) {
_RestCallbackData2D *rd = (_RestCallbackData2D *)p_userdata;
- if (rd->valid_dir != Vector2()) {
- if (p_point_A.distance_squared_to(p_point_B) > rd->valid_depth * rd->valid_depth) {
- return;
- }
- if (rd->valid_dir.dot((p_point_A - p_point_B).normalized()) < Math_PI * 0.25) {
- return;
- }
- }
-
Vector2 contact_rel = p_point_B - p_point_A;
real_t len = contact_rel.length();
+ if (len == 0) {
+ return;
+ }
+
+ Vector2 normal = contact_rel / len;
+
+ if (rd->valid_dir != Vector2() && rd->valid_dir.dot(normal) > -CMP_EPSILON) {
+ return;
+ }
+
if (len < rd->min_allowed_depth) {
return;
}
@@ -405,7 +405,7 @@ static void _rest_cbk_result(const Vector2 &p_point_A, const Vector2 &p_point_B,
rd->best_len = len;
rd->best_contact = p_point_B;
- rd->best_normal = contact_rel / len;
+ rd->best_normal = normal;
rd->best_object = rd->object;
rd->best_shape = rd->shape;
rd->best_local_shape = rd->local_shape;
@@ -440,7 +440,6 @@ bool PhysicsDirectSpaceState2DSW::rest_info(RID p_shape, const Transform2D &p_sh
}
rcd.valid_dir = Vector2();
- rcd.valid_depth = 0;
rcd.object = col_obj;
rcd.shape = shape_idx;
rcd.local_shape = 0;
@@ -643,7 +642,7 @@ int Space2DSW::test_body_ray_separation(Body2DSW *p_body, const Transform2D &p_t
Vector2 a = sr[k * 2 + 0];
Vector2 b = sr[k * 2 + 1];
- recover_motion += (b - a) * 0.4;
+ recover_motion += (b - a) / cbk.amount;
float depth = a.distance_to(b);
if (depth > result.collision_depth) {
@@ -850,7 +849,7 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co
for (int i = 0; i < cbk.amount; i++) {
Vector2 a = sr[i * 2 + 0];
Vector2 b = sr[i * 2 + 1];
- recover_motion += (b - a) * 0.4;
+ recover_motion += (b - a) / cbk.amount;
}
if (recover_motion == Vector2()) {
@@ -1002,7 +1001,7 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co
best_shape = -1; //no best shape with cast, reset to -1
}
- {
+ if (safe < 1) {
//it collided, let's get the rest info in unsafe advance
Transform2D ugt = body_transform;
ugt.elements[2] += p_motion * unsafe;
@@ -1061,10 +1060,8 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co
if (col_obj->is_shape_set_as_one_way_collision(shape_idx)) {
rcd.valid_dir = col_obj_shape_xform.get_axis(1).normalized();
- rcd.valid_depth = 10e20;
} else {
rcd.valid_dir = Vector2();
- rcd.valid_depth = 0;
}
rcd.object = col_obj;
diff --git a/servers/physics_3d/space_3d_sw.cpp b/servers/physics_3d/space_3d_sw.cpp
index 2b2b5122da..0395a3339c 100644
--- a/servers/physics_3d/space_3d_sw.cpp
+++ b/servers/physics_3d/space_3d_sw.cpp
@@ -649,7 +649,7 @@ int Space3DSW::test_body_ray_separation(Body3DSW *p_body, const Transform &p_tra
Vector3 a = sr[k * 2 + 0];
Vector3 b = sr[k * 2 + 1];
- recover_motion += (b - a) * 0.4;
+ recover_motion += (b - a) / cbk.amount;
float depth = a.distance_to(b);
if (depth > result.collision_depth) {
@@ -791,7 +791,7 @@ bool Space3DSW::test_body_motion(Body3DSW *p_body, const Transform &p_from, cons
for (int i = 0; i < cbk.amount; i++) {
Vector3 a = sr[i * 2 + 0];
Vector3 b = sr[i * 2 + 1];
- recover_motion += (b - a) * 0.4;
+ recover_motion += (b - a) / cbk.amount;
}
if (recover_motion == Vector3()) {