diff options
Diffstat (limited to 'scene/resources')
-rw-r--r-- | scene/resources/audio_stream_sample.cpp | 3 | ||||
-rw-r--r-- | scene/resources/audio_stream_sample.h | 6 | ||||
-rw-r--r-- | scene/resources/dynamic_font.cpp | 15 | ||||
-rw-r--r-- | scene/resources/font.cpp | 4 | ||||
-rw-r--r-- | scene/resources/material.h | 4 | ||||
-rw-r--r-- | scene/resources/room.cpp | 70 | ||||
-rw-r--r-- | scene/resources/room.h | 62 | ||||
-rw-r--r-- | scene/resources/texture.h | 3 | ||||
-rw-r--r-- | scene/resources/tile_set.cpp | 2 | ||||
-rw-r--r-- | scene/resources/video_stream.cpp | 39 | ||||
-rw-r--r-- | scene/resources/video_stream.h | 11 | ||||
-rw-r--r-- | scene/resources/visual_shader.cpp | 54 | ||||
-rw-r--r-- | scene/resources/visual_shader.h | 10 | ||||
-rw-r--r-- | scene/resources/visual_shader_nodes.cpp | 34 | ||||
-rw-r--r-- | scene/resources/visual_shader_nodes.h | 10 |
15 files changed, 90 insertions, 237 deletions
diff --git a/scene/resources/audio_stream_sample.cpp b/scene/resources/audio_stream_sample.cpp index bfc7f407eb..e8cb40154e 100644 --- a/scene/resources/audio_stream_sample.cpp +++ b/scene/resources/audio_stream_sample.cpp @@ -29,6 +29,7 @@ /*************************************************************************/ #include "audio_stream_sample.h" + #include "core/io/marshalls.h" #include "core/os/file_access.h" @@ -656,8 +657,8 @@ AudioStreamSample::AudioStreamSample() { data = NULL; data_bytes = 0; } -AudioStreamSample::~AudioStreamSample() { +AudioStreamSample::~AudioStreamSample() { if (data) { AudioServer::get_singleton()->audio_data_free(data); data = NULL; diff --git a/scene/resources/audio_stream_sample.h b/scene/resources/audio_stream_sample.h index d5d8f073fb..adcac14ea8 100644 --- a/scene/resources/audio_stream_sample.h +++ b/scene/resources/audio_stream_sample.h @@ -28,8 +28,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef AUDIOSTREAMSAMPLE_H -#define AUDIOSTREAMSAMPLE_H +#ifndef AUDIO_STREAM_SAMPLE_H +#define AUDIO_STREAM_SAMPLE_H #include "servers/audio/audio_stream.h" @@ -153,4 +153,4 @@ public: VARIANT_ENUM_CAST(AudioStreamSample::Format) VARIANT_ENUM_CAST(AudioStreamSample::LoopMode) -#endif // AUDIOSTREAMSample_H +#endif // AUDIO_STREAM_SAMPLE_H diff --git a/scene/resources/dynamic_font.cpp b/scene/resources/dynamic_font.cpp index 8b619345d6..d19d82d252 100644 --- a/scene/resources/dynamic_font.cpp +++ b/scene/resources/dynamic_font.cpp @@ -130,7 +130,10 @@ Error DynamicFontAtSize::_load() { } else { FileAccess *f = FileAccess::open(font->font_path, FileAccess::READ); - ERR_FAIL_COND_V_MSG(!f, ERR_CANT_OPEN, "Cannot open font file '" + font->font_path + "'."); + if (!f) { + FT_Done_FreeType(library); + ERR_FAIL_V_MSG(ERR_CANT_OPEN, "Cannot open font file '" + font->font_path + "'."); + } size_t len = f->get_len(); _fontdata[font->font_path] = Vector<uint8_t>(); @@ -145,7 +148,10 @@ Error DynamicFontAtSize::_load() { if (font->font_mem == NULL && font->font_path != String()) { FileAccess *f = FileAccess::open(font->font_path, FileAccess::READ); - ERR_FAIL_COND_V_MSG(!f, ERR_CANT_OPEN, "Cannot open font file '" + font->font_path + "'."); + if (!f) { + FT_Done_FreeType(library); + ERR_FAIL_V_MSG(ERR_CANT_OPEN, "Cannot open font file '" + font->font_path + "'."); + } memset(&stream, 0, sizeof(FT_StreamRec)); stream.base = NULL; @@ -176,6 +182,7 @@ Error DynamicFontAtSize::_load() { error = FT_Open_Face(library, &fargs, 0, &face); } else { + FT_Done_FreeType(library); ERR_FAIL_V_MSG(ERR_UNCONFIGURED, "DynamicFont uninitialized."); } @@ -1011,8 +1018,8 @@ void DynamicFont::_bind_methods() { ClassDB::bind_method(D_METHOD("get_fallback_count"), &DynamicFont::get_fallback_count); ADD_GROUP("Settings", ""); - ADD_PROPERTY(PropertyInfo(Variant::INT, "size", PROPERTY_HINT_RANGE, "1,255,1"), "set_size", "get_size"); - ADD_PROPERTY(PropertyInfo(Variant::INT, "outline_size", PROPERTY_HINT_RANGE, "0,255,1"), "set_outline_size", "get_outline_size"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "size", PROPERTY_HINT_RANGE, "1,1024,1"), "set_size", "get_size"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "outline_size", PROPERTY_HINT_RANGE, "0,1024,1"), "set_outline_size", "get_outline_size"); ADD_PROPERTY(PropertyInfo(Variant::COLOR, "outline_color"), "set_outline_color", "get_outline_color"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_mipmaps"), "set_use_mipmaps", "get_use_mipmaps"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_filter"), "set_use_filter", "get_use_filter"); diff --git a/scene/resources/font.cpp b/scene/resources/font.cpp index 960919df47..19c59b3817 100644 --- a/scene/resources/font.cpp +++ b/scene/resources/font.cpp @@ -628,8 +628,8 @@ void BitmapFont::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::POOL_INT_ARRAY, "chars", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL), "_set_chars", "_get_chars"); ADD_PROPERTY(PropertyInfo(Variant::POOL_INT_ARRAY, "kernings", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL), "_set_kernings", "_get_kernings"); - ADD_PROPERTY(PropertyInfo(Variant::REAL, "height", PROPERTY_HINT_RANGE, "-1024,1024,1"), "set_height", "get_height"); - ADD_PROPERTY(PropertyInfo(Variant::REAL, "ascent", PROPERTY_HINT_RANGE, "-1024,1024,1"), "set_ascent", "get_ascent"); + ADD_PROPERTY(PropertyInfo(Variant::REAL, "height", PROPERTY_HINT_RANGE, "1,1024,1"), "set_height", "get_height"); + ADD_PROPERTY(PropertyInfo(Variant::REAL, "ascent", PROPERTY_HINT_RANGE, "0,1024,1"), "set_ascent", "get_ascent"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "distance_field"), "set_distance_field_hint", "is_distance_field_hint"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "fallback", PROPERTY_HINT_RESOURCE_TYPE, "BitmapFont"), "set_fallback", "get_fallback"); } diff --git a/scene/resources/material.h b/scene/resources/material.h index 3c2a7c928a..8e66011bec 100644 --- a/scene/resources/material.h +++ b/scene/resources/material.h @@ -42,7 +42,7 @@ class Material : public Resource { GDCLASS(Material, Resource); RES_BASE_EXTENSION("material") - OBJ_SAVE_TYPE(Material) + OBJ_SAVE_TYPE(Material); RID material; Ref<Material> next_pass; @@ -249,7 +249,7 @@ private: uint64_t blend_mode : 2; uint64_t depth_draw_mode : 2; uint64_t cull_mode : 2; - uint64_t flags : 18; + uint64_t flags : 19; uint64_t detail_blend_mode : 2; uint64_t diffuse_mode : 3; uint64_t specular_mode : 3; diff --git a/scene/resources/room.cpp b/scene/resources/room.cpp deleted file mode 100644 index 51c4489ec3..0000000000 --- a/scene/resources/room.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/*************************************************************************/ -/* room.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 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 "room.h" - -#include "servers/visual_server.h" - -// FIXME: Left for reference for reimplementation using Area -#if 0 -RID RoomBounds::get_rid() const { - - return area; -} - -void RoomBounds::set_geometry_hint(const PoolVector<Face3> &p_geometry_hint) { - - geometry_hint = p_geometry_hint; -} - -PoolVector<Face3> RoomBounds::get_geometry_hint() const { - - return geometry_hint; -} - -void RoomBounds::_bind_methods() { - - ClassDB::bind_method(D_METHOD("set_geometry_hint", "triangles"), &RoomBounds::set_geometry_hint); - ClassDB::bind_method(D_METHOD("get_geometry_hint"), &RoomBounds::get_geometry_hint); - - //ADD_PROPERTY( PropertyInfo( Variant::DICTIONARY, "bounds"), "set_bounds","get_bounds") ; - ADD_PROPERTY(PropertyInfo(Variant::POOL_VECTOR3_ARRAY, "geometry_hint"), "set_geometry_hint", "get_geometry_hint"); -} - -RoomBounds::RoomBounds() { - - area = VisualServer::get_singleton()->room_create(); -} - -RoomBounds::~RoomBounds() { - - VisualServer::get_singleton()->free(area); -} -#endif diff --git a/scene/resources/room.h b/scene/resources/room.h deleted file mode 100644 index 809a9c1de8..0000000000 --- a/scene/resources/room.h +++ /dev/null @@ -1,62 +0,0 @@ -/*************************************************************************/ -/* room.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 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 ROOM_BOUNDS_H -#define ROOM_BOUNDS_H - -#include "core/math/bsp_tree.h" -#include "core/resource.h" - -// FIXME: left for reference but will be removed when portals are reimplemented using Area -#if 0 - -class RoomBounds : public Resource { - - GDCLASS(RoomBounds, Resource); - RES_BASE_EXTENSION("room"); - - RID area; - PoolVector<Face3> geometry_hint; - -protected: - static void _bind_methods(); - -public: - virtual RID get_rid() const; - - void set_geometry_hint(const PoolVector<Face3> &p_geometry_hint); - PoolVector<Face3> get_geometry_hint() const; - - RoomBounds(); - ~RoomBounds(); -}; - -#endif -#endif // ROOM_H diff --git a/scene/resources/texture.h b/scene/resources/texture.h index fcd8547d07..fa698d387b 100644 --- a/scene/resources/texture.h +++ b/scene/resources/texture.h @@ -45,7 +45,8 @@ class Texture : public Resource { GDCLASS(Texture, Resource); - OBJ_SAVE_TYPE(Texture); //children are all saved as Texture, so they can be exchanged + OBJ_SAVE_TYPE(Texture); // Saves derived classes with common type so they can be interchanged. + protected: static void _bind_methods(); diff --git a/scene/resources/tile_set.cpp b/scene/resources/tile_set.cpp index d9caf1d657..555e90ed3c 100644 --- a/scene/resources/tile_set.cpp +++ b/scene/resources/tile_set.cpp @@ -1038,6 +1038,7 @@ void TileSet::_tile_set_shapes(int p_id, const Array &p_shapes) { } tile_map[p_id].shapes_data = shapes_data; + emit_changed(); } Array TileSet::_tile_get_shapes(int p_id) const { @@ -1232,6 +1233,7 @@ void TileSet::_bind_methods() { BIND_ENUM_CONSTANT(BIND_TOP); BIND_ENUM_CONSTANT(BIND_TOPRIGHT); BIND_ENUM_CONSTANT(BIND_LEFT); + BIND_ENUM_CONSTANT(BIND_CENTER); BIND_ENUM_CONSTANT(BIND_RIGHT); BIND_ENUM_CONSTANT(BIND_BOTTOMLEFT); BIND_ENUM_CONSTANT(BIND_BOTTOM); diff --git a/scene/resources/video_stream.cpp b/scene/resources/video_stream.cpp deleted file mode 100644 index 81b4477c9a..0000000000 --- a/scene/resources/video_stream.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/*************************************************************************/ -/* video_stream.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 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 "video_stream.h" - -void VideoStreamPlayback::_bind_methods(){ - -}; - -VideoStreamPlayback::VideoStreamPlayback(){ - -}; diff --git a/scene/resources/video_stream.h b/scene/resources/video_stream.h index d8aee2eac3..444bb698ae 100644 --- a/scene/resources/video_stream.h +++ b/scene/resources/video_stream.h @@ -37,9 +37,6 @@ class VideoStreamPlayback : public Resource { GDCLASS(VideoStreamPlayback, Resource); -protected: - static void _bind_methods(); - public: typedef int (*AudioMixCallback)(void *p_udata, const float *p_data, int p_frames); @@ -61,28 +58,22 @@ public: virtual void set_audio_track(int p_idx) = 0; - //virtual int mix(int16_t* p_buffer,int p_frames)=0; - virtual Ref<Texture> get_texture() const = 0; virtual void update(float p_delta) = 0; virtual void set_mix_callback(AudioMixCallback p_callback, void *p_userdata) = 0; virtual int get_channels() const = 0; virtual int get_mix_rate() const = 0; - - VideoStreamPlayback(); }; class VideoStream : public Resource { GDCLASS(VideoStream, Resource); - OBJ_SAVE_TYPE(VideoStream); //children are all saved as AudioStream, so they can be exchanged + OBJ_SAVE_TYPE(VideoStream); // Saves derived classes with common type so they can be interchanged. public: virtual void set_audio_track(int p_track) = 0; virtual Ref<VideoStreamPlayback> instance_playback() = 0; - - VideoStream() {} }; #endif diff --git a/scene/resources/visual_shader.cpp b/scene/resources/visual_shader.cpp index 37792eaaea..e350a0a99e 100644 --- a/scene/resources/visual_shader.cpp +++ b/scene/resources/visual_shader.cpp @@ -79,7 +79,7 @@ Vector<StringName> VisualShaderNode::get_editable_properties() const { return Vector<StringName>(); } -Array VisualShaderNode::_get_default_input_values() const { +Array VisualShaderNode::get_default_input_values() const { Array ret; for (Map<int, Variant>::Element *E = default_input_values.front(); E; E = E->next()) { @@ -88,7 +88,7 @@ Array VisualShaderNode::_get_default_input_values() const { } return ret; } -void VisualShaderNode::_set_default_input_values(const Array &p_values) { +void VisualShaderNode::set_default_input_values(const Array &p_values) { if (p_values.size() % 2 == 0) { for (int i = 0; i < p_values.size(); i += 2) { @@ -115,11 +115,11 @@ void VisualShaderNode::_bind_methods() { ClassDB::bind_method(D_METHOD("set_input_port_default_value", "port", "value"), &VisualShaderNode::set_input_port_default_value); ClassDB::bind_method(D_METHOD("get_input_port_default_value", "port"), &VisualShaderNode::get_input_port_default_value); - ClassDB::bind_method(D_METHOD("_set_default_input_values", "values"), &VisualShaderNode::_set_default_input_values); - ClassDB::bind_method(D_METHOD("_get_default_input_values"), &VisualShaderNode::_get_default_input_values); + ClassDB::bind_method(D_METHOD("set_default_input_values", "values"), &VisualShaderNode::set_default_input_values); + ClassDB::bind_method(D_METHOD("get_default_input_values"), &VisualShaderNode::get_default_input_values); ADD_PROPERTY(PropertyInfo(Variant::INT, "output_port_for_preview"), "set_output_port_for_preview", "get_output_port_for_preview"); - ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "default_input_values", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "_set_default_input_values", "_get_default_input_values"); + ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "default_input_values", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL), "set_default_input_values", "get_default_input_values"); ADD_SIGNAL(MethodInfo("editor_refresh_request")); BIND_ENUM_CONSTANT(PORT_TYPE_SCALAR); @@ -378,6 +378,9 @@ void VisualShader::remove_node(Type p_type, int p_id) { List<Connection>::Element *N = E->next(); if (E->get().from_node == p_id || E->get().to_node == p_id) { g->connections.erase(E); + if (E->get().from_node == p_id) { + g->nodes[E->get().to_node].prev_connected_nodes.erase(p_id); + } } E = N; } @@ -399,6 +402,25 @@ bool VisualShader::is_node_connection(Type p_type, int p_from_node, int p_from_p return false; } +bool VisualShader::is_nodes_connected_relatively(const Graph *p_graph, int p_node, int p_target) const { + bool result = false; + + const VisualShader::Node &node = p_graph->nodes[p_node]; + + for (const List<int>::Element *E = node.prev_connected_nodes.front(); E; E = E->next()) { + + if (E->get() == p_target) { + return true; + } + + result = is_nodes_connected_relatively(p_graph, E->get(), p_target); + if (result) { + break; + } + } + return result; +} + bool VisualShader::can_connect_nodes(Type p_type, int p_from_node, int p_from_port, int p_to_node, int p_to_port) const { ERR_FAIL_INDEX_V(p_type, TYPE_MAX, false); @@ -433,6 +455,9 @@ bool VisualShader::can_connect_nodes(Type p_type, int p_from_node, int p_from_po } } + if (is_nodes_connected_relatively(g, p_from_node, p_to_node)) + return false; + return true; } @@ -449,6 +474,8 @@ void VisualShader::connect_nodes_forced(Type p_type, int p_from_node, int p_from c.to_node = p_to_node; c.to_port = p_to_port; g->connections.push_back(c); + g->nodes[p_to_node].prev_connected_nodes.push_back(p_from_node); + _queue_update(); } @@ -479,6 +506,7 @@ Error VisualShader::connect_nodes(Type p_type, int p_from_node, int p_from_port, c.to_node = p_to_node; c.to_port = p_to_port; g->connections.push_back(c); + g->nodes[p_to_node].prev_connected_nodes.push_back(p_from_node); _queue_update(); return OK; @@ -492,6 +520,7 @@ void VisualShader::disconnect_nodes(Type p_type, int p_from_node, int p_from_por if (E->get().from_node == p_from_node && E->get().from_port == p_from_port && E->get().to_node == p_to_node && E->get().to_port == p_to_port) { g->connections.erase(E); + g->nodes[p_to_node].prev_connected_nodes.erase(p_from_node); _queue_update(); return; } @@ -1326,6 +1355,7 @@ void VisualShader::_input_type_changed(Type p_type, int p_id) { List<Connection>::Element *N = E->next(); if (E->get().from_node == p_id) { g->connections.erase(E); + g->nodes[E->get().to_node].prev_connected_nodes.erase(p_id); } E = N; } @@ -2472,13 +2502,7 @@ void VisualShaderNodeGroupBase::_bind_methods() { ClassDB::bind_method(D_METHOD("get_free_input_port_id"), &VisualShaderNodeGroupBase::get_free_input_port_id); ClassDB::bind_method(D_METHOD("get_free_output_port_id"), &VisualShaderNodeGroupBase::get_free_output_port_id); - ClassDB::bind_method(D_METHOD("set_control", "control", "index"), &VisualShaderNodeGroupBase::set_control); - ClassDB::bind_method(D_METHOD("get_control", "index"), &VisualShaderNodeGroupBase::get_control); - - ClassDB::bind_method(D_METHOD("set_editable", "enabled"), &VisualShaderNodeGroupBase::set_editable); - ClassDB::bind_method(D_METHOD("is_editable"), &VisualShaderNodeGroupBase::is_editable); - - ADD_PROPERTY(PropertyInfo(Variant::BOOL, "editable"), "set_editable", "is_editable"); + ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "size"), "set_size", "get_size"); } String VisualShaderNodeGroupBase::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const { @@ -2502,10 +2526,6 @@ void VisualShaderNodeExpression::set_expression(const String &p_expression) { expression = p_expression; } -void VisualShaderNodeExpression::build() { - emit_changed(); -} - String VisualShaderNodeExpression::get_expression() const { return expression; } @@ -2612,8 +2632,6 @@ void VisualShaderNodeExpression::_bind_methods() { ClassDB::bind_method(D_METHOD("set_expression", "expression"), &VisualShaderNodeExpression::set_expression); ClassDB::bind_method(D_METHOD("get_expression"), &VisualShaderNodeExpression::get_expression); - ClassDB::bind_method(D_METHOD("build"), &VisualShaderNodeExpression::build); - ADD_PROPERTY(PropertyInfo(Variant::STRING, "expression"), "set_expression", "get_expression"); } diff --git a/scene/resources/visual_shader.h b/scene/resources/visual_shader.h index 0a3d5f96bd..f81090d9cb 100644 --- a/scene/resources/visual_shader.h +++ b/scene/resources/visual_shader.h @@ -65,6 +65,7 @@ private: struct Node { Ref<VisualShaderNode> node; Vector2 position; + List<int> prev_connected_nodes; }; struct Graph { @@ -135,6 +136,8 @@ public: void remove_node(Type p_type, int p_id); bool is_node_connection(Type p_type, int p_from_node, int p_from_port, int p_to_node, int p_to_port) const; + + bool is_nodes_connected_relatively(const Graph *p_graph, int p_node, int p_target) const; bool can_connect_nodes(Type p_type, int p_from_node, int p_from_port, int p_to_node, int p_to_port) const; Error connect_nodes(Type p_type, int p_from_node, int p_from_port, int p_to_node, int p_to_port); void disconnect_nodes(Type p_type, int p_from_node, int p_from_port, int p_to_node, int p_to_port); @@ -172,9 +175,6 @@ class VisualShaderNode : public Resource { Map<int, Variant> default_input_values; - Array _get_default_input_values() const; - void _set_default_input_values(const Array &p_values); - protected: static void _bind_methods(); @@ -196,6 +196,8 @@ public: void set_input_port_default_value(int p_port, const Variant &p_value); Variant get_input_port_default_value(int p_port) const; // if NIL (default if node does not set anything) is returned, it means no default value is wanted if disconnected, thus no input var must be supplied (empty string will be supplied) + Array get_default_input_values() const; + void set_default_input_values(const Array &p_values); virtual int get_output_port_count() const = 0; virtual PortType get_output_port_type(int p_port) const = 0; @@ -455,8 +457,6 @@ public: void set_expression(const String &p_expression); String get_expression() const; - void build(); - virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const; VisualShaderNodeExpression(); diff --git a/scene/resources/visual_shader_nodes.cpp b/scene/resources/visual_shader_nodes.cpp index f46fba3b5b..7d8c396b7f 100644 --- a/scene/resources/visual_shader_nodes.cpp +++ b/scene/resources/visual_shader_nodes.cpp @@ -792,7 +792,7 @@ String VisualShaderNodeCubeMap::generate_global(Shader::Mode p_mode, VisualShade case TYPE_COLOR: u += " : hint_albedo"; break; case TYPE_NORMALMAP: u += " : hint_normal"; break; } - return u + ";"; + return u + ";\n"; } return String(); } @@ -809,29 +809,33 @@ String VisualShaderNodeCubeMap::generate_code(Shader::Mode p_mode, VisualShader: return String(); } + code += "\t{\n"; + if (id == String()) { - code += "\tvec4 " + id + "_read = vec4(0.0);\n"; - code += "\t" + p_output_vars[0] + " = " + id + "_read.rgb;\n"; - code += "\t" + p_output_vars[1] + " = " + id + "_read.a;\n"; + code += "\t\tvec4 " + id + "_read = vec4(0.0);\n"; + code += "\t\t" + p_output_vars[0] + " = " + id + "_read.rgb;\n"; + code += "\t\t" + p_output_vars[1] + " = " + id + "_read.a;\n"; + code += "\t}\n"; return code; } if (p_input_vars[0] == String()) { // Use UV by default. if (p_input_vars[1] == String()) { - code += "\tvec4 " + id + "_read = texture( " + id + " , vec3( UV, 0.0 ) );\n"; + code += "\t\tvec4 " + id + "_read = texture( " + id + " , vec3( UV, 0.0 ) );\n"; } else { - code += "\tvec4 " + id + "_read = textureLod( " + id + " , vec3( UV, 0.0 )" + " , " + p_input_vars[1] + " );\n"; + code += "\t\tvec4 " + id + "_read = textureLod( " + id + " , vec3( UV, 0.0 )" + " , " + p_input_vars[1] + " );\n"; } } else if (p_input_vars[1] == String()) { //no lod - code += "\tvec4 " + id + "_read = texture( " + id + " , " + p_input_vars[0] + " );\n"; + code += "\t\tvec4 " + id + "_read = texture( " + id + " , " + p_input_vars[0] + " );\n"; } else { - code += "\tvec4 " + id + "_read = textureLod( " + id + " , " + p_input_vars[0] + " , " + p_input_vars[1] + " );\n"; + code += "\t\tvec4 " + id + "_read = textureLod( " + id + " , " + p_input_vars[0] + " , " + p_input_vars[1] + " );\n"; } - code += "\t" + p_output_vars[0] + " = " + id + "_read.rgb;\n"; - code += "\t" + p_output_vars[1] + " = " + id + "_read.a;\n"; + code += "\t\t" + p_output_vars[0] + " = " + id + "_read.rgb;\n"; + code += "\t\t" + p_output_vars[1] + " = " + id + "_read.a;\n"; + code += "\t}\n"; return code; } @@ -3929,7 +3933,7 @@ String VisualShaderNodeCompare::generate_code(Shader::Mode p_mode, VisualShader: return code; } -void VisualShaderNodeCompare::set_comparsion_type(ComparsionType p_type) { +void VisualShaderNodeCompare::set_comparison_type(ComparisonType p_type) { ctype = p_type; @@ -3954,7 +3958,7 @@ void VisualShaderNodeCompare::set_comparsion_type(ComparsionType p_type) { emit_changed(); } -VisualShaderNodeCompare::ComparsionType VisualShaderNodeCompare::get_comparsion_type() const { +VisualShaderNodeCompare::ComparisonType VisualShaderNodeCompare::get_comparison_type() const { return ctype; } @@ -3992,8 +3996,8 @@ Vector<StringName> VisualShaderNodeCompare::get_editable_properties() const { void VisualShaderNodeCompare::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_comparsion_type", "type"), &VisualShaderNodeCompare::set_comparsion_type); - ClassDB::bind_method(D_METHOD("get_comparsion_type"), &VisualShaderNodeCompare::get_comparsion_type); + ClassDB::bind_method(D_METHOD("set_comparison_type", "type"), &VisualShaderNodeCompare::set_comparison_type); + ClassDB::bind_method(D_METHOD("get_comparison_type"), &VisualShaderNodeCompare::get_comparison_type); ClassDB::bind_method(D_METHOD("set_function", "func"), &VisualShaderNodeCompare::set_function); ClassDB::bind_method(D_METHOD("get_function"), &VisualShaderNodeCompare::get_function); @@ -4001,7 +4005,7 @@ void VisualShaderNodeCompare::_bind_methods() { ClassDB::bind_method(D_METHOD("set_condition", "condition"), &VisualShaderNodeCompare::set_condition); ClassDB::bind_method(D_METHOD("get_condition"), &VisualShaderNodeCompare::get_condition); - ADD_PROPERTY(PropertyInfo(Variant::INT, "type", PROPERTY_HINT_ENUM, "Scalar,Vector,Boolean,Transform"), "set_comparsion_type", "get_comparsion_type"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "type", PROPERTY_HINT_ENUM, "Scalar,Vector,Boolean,Transform"), "set_comparison_type", "get_comparison_type"); ADD_PROPERTY(PropertyInfo(Variant::INT, "function", PROPERTY_HINT_ENUM, "a == b,a != b,a > b,a >= b,a < b,a <= b"), "set_function", "get_function"); ADD_PROPERTY(PropertyInfo(Variant::INT, "condition", PROPERTY_HINT_ENUM, "All,Any"), "set_condition", "get_condition"); diff --git a/scene/resources/visual_shader_nodes.h b/scene/resources/visual_shader_nodes.h index 0f428088e0..cca37273d9 100644 --- a/scene/resources/visual_shader_nodes.h +++ b/scene/resources/visual_shader_nodes.h @@ -1635,7 +1635,7 @@ class VisualShaderNodeCompare : public VisualShaderNode { GDCLASS(VisualShaderNodeCompare, VisualShaderNode); public: - enum ComparsionType { + enum ComparisonType { CTYPE_SCALAR, CTYPE_VECTOR, CTYPE_BOOLEAN, @@ -1657,7 +1657,7 @@ public: }; protected: - ComparsionType ctype; + ComparisonType ctype; Function func; Condition condition; @@ -1677,8 +1677,8 @@ public: virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const; //if no output is connected, the output var passed will be empty. if no input is connected and input is NIL, the input var passed will be empty - void set_comparsion_type(ComparsionType p_type); - ComparsionType get_comparsion_type() const; + void set_comparison_type(ComparisonType p_type); + ComparisonType get_comparison_type() const; void set_function(Function p_func); Function get_function() const; @@ -1692,7 +1692,7 @@ public: VisualShaderNodeCompare(); }; -VARIANT_ENUM_CAST(VisualShaderNodeCompare::ComparsionType) +VARIANT_ENUM_CAST(VisualShaderNodeCompare::ComparisonType) VARIANT_ENUM_CAST(VisualShaderNodeCompare::Function) VARIANT_ENUM_CAST(VisualShaderNodeCompare::Condition) |