summaryrefslogtreecommitdiff
path: root/scene/resources/packed_scene.cpp
AgeCommit message (Collapse)Author
2022-06-25Add ability to export Node pointers as NodePathsreduz
This PR implements: * A new hint: PROPERTY_HINT_NODE_TYPE for variant type OBJECT, which can take specific node types as hint string. * The editor will show it as a node path, but will set it as a pointer to a node from the current scene if you select a path. * When scene is saved, the node path is saved, then restored as a pointer. NOTE: This is a proof of concept and this approach will most likely not work. The reason if that, if the node referenced is deleted, then when trying to edit this the node will become invalid. Potential workarounds: Since this uses the Variant API, it should obtain the pointer from the Variant object ID. Yet, this would either only really work in GDScript or it would need to be implemented with workarounds in every language. Alternative ways to make this work: Nodes could export an additional property with a node path (like for which_node, it could be which_node_path). Another alternative: Path editing could happen as a hidden metadata (ignoring the pointer).
2022-05-23Fix typos with codespellRémi Verschelde
Using codespell 2.2-dev from current git.
2022-05-20Add a new HashSet templatereduz
* Intended to replace RBSet in most cases. * Optimized for iteration speed
2022-05-16Replace most uses of Map by HashMapreduz
* Map is unnecessary and inefficient in almost every case. * Replaced by the new HashMap. * Renamed Map to RBMap and Set to RBSet for cases that still make sense (order matters) but use is discouraged. There were very few cases where replacing by HashMap was undesired because keeping the key order was intended. I tried to keep those (as RBMap) as much as possible, but might have missed some. Review appreciated!
2022-05-12Add a new HashMap implementationreduz
Adds a new, cleaned up, HashMap implementation. * Uses Robin Hood Hashing (https://en.wikipedia.org/wiki/Hash_table#Robin_Hood_hashing). * Keeps elements in a double linked list for simpler, ordered, iteration. * Allows keeping iterators for later use in removal (Unlike Map<>, it does not do much for performance vs keeping the key, but helps replace old code). * Uses a more modern C++ iterator API, deprecates the old one. * Supports custom allocator (in case there is a wish to use a paged one). This class aims to unify all the associative template usage and replace it by this one: * Map<> (whereas key order does not matter, which is 99% of cases) * HashMap<> * OrderedHashMap<> * OAHashMap<>
2022-05-09Rescue orphan nodes in inherited sceneskobewi
2022-05-06Cleanup metadata usagekobewi
2022-05-03Implement missing Node & Resource placeholdersreduz
Implemented by request of @neikeq to advance in the GDExtension version of Mono. * If a Resource type is missing upon load, it will be remembered together with its data (Unless manually overriden). * If a Node type is missing upon load, it will be also be remembered together with its data (unless deleted). This feature makes working with GDExtension much easier, as it ensures that missing types no longer cause data loss.
2022-04-25Implement Scene Unique Nodesreduz
Implements https://github.com/godotengine/godot-proposals/issues/4096 * Nodes can be marked unique to the scene in the editor (or via code). * Unique nodes can be accessed via the **%** prefix at any point in the path. From that point in the path (depending on whether the scene of the path is), the unique node will be fetched. * Implementation is very optimal, as these nodes are cached.
2022-03-29Fix Callable::bind usage in connections_dialog.h and packed_scene.cppC.Even
* Callable::bind takes an array of pointers to Variant * Fixes #57057
2022-03-28Remove last editor code dependencies in template buildRémi Verschelde
SConstruct change also makes it possible to outright delete the `editor` folder in a `tools=no` build, which we use in CI to ensure no invalid cross-dependencies are added.
2022-03-05Various code and documentation improvementskobewi
2022-02-16Style: Cleanup single-line blocks, semicolons, dead codeRémi Verschelde
Remove currently unused implementation of TextureBasisU, could be re-added later on if needed and ported.
2022-01-08Removed redundant ClassDB::is_class_enabled() and moved second dynamic_cast ↵Bartłomiej T. Listwon
inside worst case if
2022-01-04Merge pull request #53313 from KoBeWi/debinded_konnektRémi Verschelde
2022-01-03Update copyright statements to 2022Rémi Verschelde
Happy new year to the wonderful Godot community!
2021-12-11Stop asuming a default value of NIL means there's no defaultPedro J. Estébanez
2021-12-09Replace String comparisons with "", String() to is_empty()Nathan Franke
Also: - Adds two stress tests to test_string.h - Changes to .empty() on std::strings
2021-11-23Rename `remove()` to `remove_at()` when removing by indexLightning_A
2021-11-17Fix crash when loading scene instance after node vanished from parentPedro J. Estébanez
2021-11-08Add property value pinningPedro J. Estébanez
2021-11-07Unify determination of default property valuesPedro J. Estébanez
2021-11-04Add is_built_in() method to Resourcekobewi
2021-10-05Fix editable children errors when packing scene tree at runtimePouleyKetchoupp
When packing a scene node which is not the root, errors where caused by internal checks in is_editable_instance method. This check can be safely made outside instead.
2021-10-04Add support for unbinding in connection dialogkobewi
2021-09-30Use range iterators for `Map`Lightning_A
2021-09-30Rename Node's `filename` property to `scene_file_path` for clarityHugo Locurcio
2021-09-18Fail at instantiating if the root node is instantiatedgyroninja
2021-08-27Fix loading packed scene with editable children at runtimePouleyKetchoupp
At runtime, packed scenes with nodes marked as editable instance where saved with node type tags, which prevented the scene to be then loaded as an instance, causing duplicated nodes in the tree. This change ensures nodes marked as editable instances and their owned children are properly set as instances. That doesn't make a difference in the editor, since such nodes where already set as instances based on their instance state, but it helps at runtime where instance states are disabled. Co-authored-by: latorril <latorril@gmail.com>
2021-08-13Disable Node3D when compiling without 3D and fix disable_3d optionAaron Franke
2021-07-25Use const references where possible for List range iteratorsRémi Verschelde
2021-07-23Use C++ iterators for Lists in many situationsAaron Franke
2021-06-29Merge pull request #49713 from nekomatata/fix-export-var-override-runtimeRémi Verschelde
Fix export var override in PackedScene at runtime
2021-06-19Rename `instance()`->`instantiate()` when it's a verbLightning_A
2021-06-19Remove side effects of scene savePedro J. Estébanez
2021-06-18Fix export var override in PackedScene at runtimePouleyKetchoupp
Regression fix: update_exports is tool only and should be used only in the editor, otherwise it can cause export variable overrides from instances to be discarded in favor of the parent's value.
2021-02-25Fix crash when loading a scene containing an uncreatable typeDelf Neumärker
2021-02-21Merge pull request #38565 from nekomatata/export-default-valuesRémi Verschelde
Fixed export var default value in PackedScene when script is not loaded in editor
2021-02-11Improve resource load cachereduz
-Added a new method in Resource: reset_state , used for reloading the same resource from disk -Added a new cache mode "replace" in ResourceLoader, which reuses existing loaded sub-resources but resets their data from disk (or replaces them if they chaged type) -Because the correct sub-resource paths are always loaded now, this fixes bugs with subresource folding or subresource ordering when saving.
2021-02-09Initialize class variables with default values in scene/ [2/2]Rafał Mikrut
2021-01-01Update copyright statements to 2021Rémi Verschelde
Happy new year to the wonderful Godot community! 2020 has been a tough year for most of us personally, but a good year for Godot development nonetheless with a huge amount of work done towards Godot 4.0 and great improvements backported to the long-lived 3.2 branch. We've had close to 400 contributors to engine code this year, authoring near 7,000 commit! (And that's only for the `master` branch and for the engine code, there's a lot more when counting docs, demos and other first-party repos.) Here's to a great year 2021 for all Godot users 🎆
2020-12-28Rename empty() to is_empty()Marcel Admiraal
2020-12-09Cleanup unused engine codeTomasz Chabora
2020-11-07Reorganized core/ directory, it was too fatty alreadyreduz
-Removed FuncRef, since Callable makes it obsolete -Removed int_types.h as its obsolete in c++11+ -Changed color names code
2020-09-18Fix typos with codespellRémi Verschelde
Using codespell 1.17.1. Method: ``` $ cat > ../godot-word-whitelist.txt << EOF ang curvelinear dof doubleclick fave findn leapyear lod merchantibility nd numer ois ony que seeked synching te uint unselect webp EOF $ codespell -w -q 3 -I ../godot-word-whitelist.txt --skip="./thirdparty,*.po" $ git diff // undo unwanted changes ```
2020-06-08PackedScene: Prevent crash when root node has `parent` attributeRémi Verschelde
The crash happens further down when setting an invalid owner in `Node::_set_owner_nocheck` but I couldn't figure out how to fix it. But here the proper fix is to catch the invalid scene file early on and fail loading it. Part of #17372.
2020-05-14Style: Enforce braces around if blocks and loopsRémi Verschelde
Using clang-tidy's `readability-braces-around-statements`. https://clang.llvm.org/extra/clang-tidy/checks/readability-braces-around-statements.html
2020-05-14Style: Enforce separation line between function definitionsRémi Verschelde
I couldn't find a tool that enforces it, so I went the manual route: ``` find -name "thirdparty" -prune \ -o -name "*.cpp" -o -name "*.h" -o -name "*.m" -o -name "*.mm" \ -o -name "*.glsl" > files perl -0777 -pi -e 's/\n}\n([^#])/\n}\n\n\1/g' $(cat files) misc/scripts/fix_style.sh -c ``` This adds a newline after all `}` on the first column, unless they are followed by `#` (typically `#endif`). This leads to having lots of places with two lines between function/class definitions, but clang-format then fixes it as we enforce max one line of separation. This doesn't fix potential occurrences of function definitions which are indented (e.g. for a helper class defined in a .cpp), but it's better than nothing. Also can't be made to run easily on CI/hooks so we'll have to be careful with new code. Part of #33027.
2020-05-14Style: clang-format: Disable KeepEmptyLinesAtTheStartOfBlocksRémi Verschelde
Which means that reduz' beloved style which we all became used to will now be changed automatically to remove the first empty line. This makes us lean closer to 1TBS (the one true brace style) instead of hybridating it with some Allman-inspired spacing. There's still the case of braces around single-statement blocks that needs to be addressed (but clang-format can't help with that, but clang-tidy may if we agree about it). Part of #33027.
2020-05-08Fixed export var default value in PackedScene when script is not loaded in ↵PouleyKetchoupp
editor