Skip to content

Commit

Permalink
Massive rewrite to AnimationTree. Many APIs changed in order to:
Browse files Browse the repository at this point in the history
-Reuse resources
-Expose properties in AnimationTree
  • Loading branch information
reduz committed Aug 20, 2018
1 parent 1b66b08 commit c7e4527
Show file tree
Hide file tree
Showing 34 changed files with 3,830 additions and 2,911 deletions.
23 changes: 20 additions & 3 deletions core/object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1476,8 +1476,13 @@ Error Object::connect(const StringName &p_signal, Object *p_to_object, const Str

Signal::Target target(p_to_object->get_instance_id(), p_to_method);
if (s->slot_map.has(target)) {
ERR_EXPLAIN("Signal '" + p_signal + "' is already connected to given method '" + p_to_method + "' in that object.");
ERR_FAIL_COND_V(s->slot_map.has(target), ERR_INVALID_PARAMETER);
if (p_flags & CONNECT_REFERENCE_COUNTED) {
s->slot_map[target].reference_count++;
return OK;
} else {
ERR_EXPLAIN("Signal '" + p_signal + "' is already connected to given method '" + p_to_method + "' in that object.");
ERR_FAIL_COND_V(s->slot_map.has(target), ERR_INVALID_PARAMETER);
}
}

Signal::Slot slot;
Expand All @@ -1491,6 +1496,10 @@ Error Object::connect(const StringName &p_signal, Object *p_to_object, const Str
conn.binds = p_binds;
slot.conn = conn;
slot.cE = p_to_object->connections.push_back(conn);
if (p_flags & CONNECT_REFERENCE_COUNTED) {
slot.reference_count = 1;
}

s->slot_map[target] = slot;

return OK;
Expand Down Expand Up @@ -1539,7 +1548,14 @@ void Object::disconnect(const StringName &p_signal, Object *p_to_object, const S
ERR_FAIL();
}

p_to_object->connections.erase(s->slot_map[target].cE);
Signal::Slot *slot = &s->slot_map[target];

slot->reference_count--; // by default is zero, if it was not referenced it will go below it
if (slot->reference_count >= 0) {
return;
}

p_to_object->connections.erase(slot->cE);
s->slot_map.erase(target);

if (s->slot_map.empty() && ClassDB::has_signal(get_class_name(), p_signal)) {
Expand Down Expand Up @@ -1761,6 +1777,7 @@ void Object::_bind_methods() {
BIND_ENUM_CONSTANT(CONNECT_DEFERRED);
BIND_ENUM_CONSTANT(CONNECT_PERSIST);
BIND_ENUM_CONSTANT(CONNECT_ONESHOT);
BIND_ENUM_CONSTANT(CONNECT_REFERENCE_COUNTED);
}

void Object::call_deferred(const StringName &p_method, VARIANT_ARG_DECLARE) {
Expand Down
5 changes: 4 additions & 1 deletion core/object.h
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,8 @@ class Object {

CONNECT_DEFERRED = 1,
CONNECT_PERSIST = 2, // hint for scene to save this connection
CONNECT_ONESHOT = 4
CONNECT_ONESHOT = 4,
CONNECT_REFERENCE_COUNTED = 8,
};

struct Connection {
Expand Down Expand Up @@ -443,8 +444,10 @@ class Object {

struct Slot {

int reference_count;
Connection conn;
List<Connection>::Element *cE;
Slot() { reference_count = 0; }
};

MethodInfo user;
Expand Down
3 changes: 2 additions & 1 deletion editor/editor_inspector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1533,9 +1533,10 @@ void EditorInspector::update_tree() {

if (capitalize_paths)
path_name = path_name.capitalize();

Color c = sscolor;
c.a /= level;
section->setup(path_name, acc_path, object, c, use_folding);
section->setup(path_name, path_name, object, c, use_folding);

item_path[acc_path] = section->get_vbox();
}
Expand Down
6 changes: 2 additions & 4 deletions editor/editor_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
#include "editor/plugins/animation_player_editor_plugin.h"
#include "editor/plugins/animation_state_machine_editor.h"
#include "editor/plugins/animation_tree_editor_plugin.h"
#include "editor/plugins/animation_tree_player_editor_plugin.h"
#include "editor/plugins/asset_library_editor_plugin.h"
#include "editor/plugins/audio_stream_editor_plugin.h"
#include "editor/plugins/baked_lightmap_editor_plugin.h"
Expand Down Expand Up @@ -5589,16 +5590,13 @@ EditorNode::EditorNode() {

add_editor_plugin(memnew(ShaderEditorPlugin(this)));
add_editor_plugin(memnew(VisualShaderEditorPlugin(this)));
add_editor_plugin(memnew(AnimationNodeBlendTreeEditorPlugin(this)));
add_editor_plugin(memnew(AnimationNodeBlendSpace1DEditorPlugin(this)));
add_editor_plugin(memnew(AnimationNodeBlendSpace2DEditorPlugin(this)));
add_editor_plugin(memnew(AnimationNodeStateMachineEditorPlugin(this)));

add_editor_plugin(memnew(CameraEditorPlugin(this)));
add_editor_plugin(memnew(ThemeEditorPlugin(this)));
add_editor_plugin(memnew(MultiMeshEditorPlugin(this)));
add_editor_plugin(memnew(MeshInstanceEditorPlugin(this)));
add_editor_plugin(memnew(AnimationTreeEditorPlugin(this)));
add_editor_plugin(memnew(AnimationTreePlayerEditorPlugin(this)));
add_editor_plugin(memnew(MeshLibraryEditorPlugin(this)));
add_editor_plugin(memnew(StyleBoxEditorPlugin(this)));
add_editor_plugin(memnew(SpriteEditorPlugin(this)));
Expand Down
15 changes: 13 additions & 2 deletions editor/inspector_dock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@

void InspectorDock::_menu_option(int p_option) {
switch (p_option) {
case RESOURCE_MAKE_BUILT_IN: {
_unref_resource();
} break;
case RESOURCE_COPY: {
_copy_resource();
} break;
case RESOURCE_EDIT_CLIPBOARD: {
_paste_resource();
} break;

case RESOURCE_SAVE: {
_save_resource(false);
} break;
Expand Down Expand Up @@ -400,10 +410,11 @@ void InspectorDock::update(Object *p_object) {
p->add_shortcut(ED_SHORTCUT("property_editor/copy_params", TTR("Copy Params")), OBJECT_COPY_PARAMS);
p->add_shortcut(ED_SHORTCUT("property_editor/paste_params", TTR("Paste Params")), OBJECT_PASTE_PARAMS);
p->add_separator();
p->add_shortcut(ED_SHORTCUT("property_editor/paste_resource", TTR("Paste Resource")), RESOURCE_PASTE);

p->add_shortcut(ED_SHORTCUT("property_editor/paste_resource", TTR("Edit Resource Clipboard")), RESOURCE_EDIT_CLIPBOARD);
if (is_resource) {
p->add_shortcut(ED_SHORTCUT("property_editor/copy_resource", TTR("Copy Resource")), RESOURCE_COPY);
p->add_shortcut(ED_SHORTCUT("property_editor/unref_resource", TTR("Make Built-In")), RESOURCE_UNREF);
p->add_shortcut(ED_SHORTCUT("property_editor/unref_resource", TTR("Make Built-In")), RESOURCE_MAKE_BUILT_IN);
}

if (is_resource || is_node) {
Expand Down
5 changes: 2 additions & 3 deletions editor/inspector_dock.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,12 @@ class InspectorDock : public VBoxContainer {
GDCLASS(InspectorDock, VBoxContainer);

enum MenuOptions {
RESOURCE_NEW,
RESOURCE_LOAD,
RESOURCE_SAVE,
RESOURCE_SAVE_AS,
RESOURCE_UNREF,
RESOURCE_MAKE_BUILT_IN,
RESOURCE_COPY,
RESOURCE_PASTE,
RESOURCE_EDIT_CLIPBOARD,
OBJECT_COPY_PARAMS,
OBJECT_PASTE_PARAMS,
OBJECT_UNIQUE_RESOURCES,
Expand Down
Loading

0 comments on commit c7e4527

Please sign in to comment.