Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion core/object/object.h
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,7 @@ class Object {
// Store on each object a bitfield to quickly test whether it is derived from some "key" classes
// that are commonly tested in performance sensitive code.
// Ensure unsigned to bitpack.
// If you want to add more classes, please make sure to edit the Object::_ancestry field.
enum class AncestralClass : unsigned int {
REF_COUNTED = 1 << 0,
NODE = 1 << 1,
Expand All @@ -603,6 +604,8 @@ class Object {
COLLISION_OBJECT_3D = 1 << 12,
PHYSICS_BODY_3D = 1 << 13,
MESH_INSTANCE_3D = 1 << 14,
// Used a lot in AnimationMixer, SkeletonModifier3D and BoneAttachment3D.
SKELETON_3D = 1 << 15,
};

static constexpr AncestralClass static_ancestral_class = (AncestralClass)0;
Expand Down Expand Up @@ -653,7 +656,7 @@ class Object {
void _initialize();
void _postinitialize();

uint32_t _ancestry : 15;
uint32_t _ancestry : 16;

bool _block_signals : 1;
bool _can_translate : 1;
Expand Down
6 changes: 6 additions & 0 deletions core/string/node_path.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,12 @@ bool NodePath::operator==(const NodePath &p_path) const {
return false;
}

if (data->hash_cache_valid && p_path.data->hash_cache_valid) {
if (data->hash_cache != p_path.data->hash_cache) {
return false;
}
}

if (data->absolute != p_path.data->absolute) {
return false;
}
Expand Down
29 changes: 18 additions & 11 deletions core/templates/a_hash_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,22 @@ class AHashMap {
return nullptr;
}

TValue &get_value_ref_or_add_default(const TKey &p_key, bool &r_was_added) {
uint32_t element_idx = 0;
uint32_t meta_idx = 0;
uint32_t hash = _hash(p_key);
bool exists = _lookup_idx_with_hash(p_key, element_idx, meta_idx, hash);

if (exists) {
r_was_added = false;
return _elements[element_idx].value;
} else {
r_was_added = true;
element_idx = _insert_element(p_key, TValue(), hash);
return _elements[element_idx].value;
}
}

bool has(const TKey &p_key) const {
uint32_t _idx = 0;
uint32_t meta_idx = 0;
Expand Down Expand Up @@ -592,17 +608,8 @@ class AHashMap {
}

TValue &operator[](const TKey &p_key) {
uint32_t element_idx = 0;
uint32_t meta_idx = 0;
uint32_t hash = _hash(p_key);
bool exists = _lookup_idx_with_hash(p_key, element_idx, meta_idx, hash);

if (exists) {
return _elements[element_idx].value;
} else {
element_idx = _insert_element(p_key, TValue(), hash);
return _elements[element_idx].value;
}
bool dummy;
return get_value_ref_or_add_default(p_key, dummy);
}

/* Insert */
Expand Down
6 changes: 6 additions & 0 deletions doc/classes/AnimationNode.xml
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,12 @@
Emitted by nodes that inherit from this class and that have an internal tree when one of their animation node names changes. The animation nodes that emit this signal are [AnimationNodeBlendSpace1D], [AnimationNodeBlendSpace2D], [AnimationNodeStateMachine], and [AnimationNodeBlendTree].
</description>
</signal>
<signal name="node_updated" experimental="">
<param index="0" name="object_id" type="int" />
<description>
Emitted by [AnimationNodeAnimation] when its [member AnimationNodeAnimation.animation] resource is changed, or by [AnimationNodeBlendTree] when its connections change.
</description>
</signal>
<signal name="tree_changed">
<description>
Emitted by nodes that inherit from this class and that have an internal tree when one of their animation nodes changes. The animation nodes that emit this signal are [AnimationNodeBlendSpace1D], [AnimationNodeBlendSpace2D], [AnimationNodeStateMachine], [AnimationNodeBlendTree] and [AnimationNodeTransition].
Expand Down
26 changes: 6 additions & 20 deletions editor/animation/animation_blend_space_1d_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#include "scene/gui/line_edit.h"
#include "scene/gui/option_button.h"
#include "scene/gui/panel_container.h"
#include "scene/gui/rich_text_label.h"
#include "scene/gui/separator.h"
#include "scene/gui/spin_box.h"

Expand Down Expand Up @@ -77,15 +78,12 @@ void AnimationNodeBlendSpace1DEditor::_blend_space_gui_input(const Ref<InputEven
animations_to_add.clear();

LocalVector<StringName> classes;
ClassDB::get_inheriters_from_class("AnimationRootNode", classes);
ClassDB::get_inheriters_from_class(SNAME("AnimationRootNode"), classes);
classes.sort_custom<StringName::AlphCompare>();

menu->add_submenu_node_item(TTR("Add Animation"), animations_menu);

List<StringName> names;
tree->get_animation_list(&names);

for (const StringName &E : names) {
for (const StringName &E : tree->get_sorted_animation_list()) {
animations_menu->add_icon_item(get_editor_theme_icon(SNAME("Animation")), E);
animations_to_add.push_back(E);
}
Expand Down Expand Up @@ -588,7 +586,7 @@ void AnimationNodeBlendSpace1DEditor::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_THEME_CHANGED: {
error_panel->add_theme_style_override(SceneStringName(panel), get_theme_stylebox(SceneStringName(panel), SNAME("Tree")));
error_label->add_theme_color_override(SceneStringName(font_color), get_theme_color(SNAME("error_color"), EditorStringName(Editor)));
error_label->add_theme_color_override(SNAME("default_color"), get_theme_color(SNAME("error_color"), EditorStringName(Editor)));
panel->add_theme_style_override(SceneStringName(panel), get_theme_stylebox(SceneStringName(panel), SNAME("Tree")));
tool_blend->set_button_icon(get_editor_theme_icon(SNAME("EditPivot")));
tool_select->set_button_icon(get_editor_theme_icon(SNAME("ToolSelect")));
Expand All @@ -608,18 +606,7 @@ void AnimationNodeBlendSpace1DEditor::_notification(int p_what) {
return;
}

String error;

error = tree->get_editor_error_message();

if (error != error_label->get_text()) {
error_label->set_text(error);
if (!error.is_empty()) {
error_panel->show();
} else {
error_panel->hide();
}
}
update_error_message(tree, error_panel, error_label);
} break;

case NOTIFICATION_VISIBILITY_CHANGED: {
Expand Down Expand Up @@ -809,8 +796,7 @@ AnimationNodeBlendSpace1DEditor::AnimationNodeBlendSpace1DEditor() {
error_panel = memnew(PanelContainer);
add_child(error_panel);

error_label = memnew(Label);
error_label->set_focus_mode(FOCUS_ACCESSIBILITY);
error_label = create_error_label_node();
error_panel->add_child(error_label);
error_panel->hide();

Expand Down
4 changes: 2 additions & 2 deletions editor/animation/animation_blend_space_1d_editor.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class AnimationNodeBlendSpace1DEditor : public AnimationTreeNodeEditorPlugin {
Control *blend_space_draw = nullptr;

PanelContainer *error_panel = nullptr;
Label *error_label = nullptr;
RichTextLabel *error_label = nullptr;

bool updating = false;

Expand All @@ -94,7 +94,7 @@ class AnimationNodeBlendSpace1DEditor : public AnimationTreeNodeEditorPlugin {

PopupMenu *menu = nullptr;
PopupMenu *animations_menu = nullptr;
Vector<String> animations_to_add;
Vector<StringName> animations_to_add;
float add_point_pos = 0.0f;
Vector<real_t> points;

Expand Down
27 changes: 5 additions & 22 deletions editor/animation/animation_blend_space_2d_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
#include "scene/gui/option_button.h"
#include "scene/gui/panel.h"
#include "scene/gui/panel_container.h"
#include "scene/gui/rich_text_label.h"
#include "scene/gui/separator.h"
#include "scene/gui/spin_box.h"
#include "scene/main/window.h"
Expand Down Expand Up @@ -126,9 +127,7 @@ void AnimationNodeBlendSpace2DEditor::_blend_space_gui_input(const Ref<InputEven

menu->add_submenu_node_item(TTR("Add Animation"), animations_menu);

List<StringName> names;
tree->get_animation_list(&names);
for (const StringName &E : names) {
for (const StringName &E : tree->get_sorted_animation_list()) {
animations_menu->add_icon_item(get_editor_theme_icon(SNAME("Animation")), E);
animations_to_add.push_back(E);
}
Expand Down Expand Up @@ -813,7 +812,7 @@ void AnimationNodeBlendSpace2DEditor::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_THEME_CHANGED: {
error_panel->add_theme_style_override(SceneStringName(panel), get_theme_stylebox(SceneStringName(panel), SNAME("Tree")));
error_label->add_theme_color_override(SceneStringName(font_color), get_theme_color(SNAME("error_color"), EditorStringName(Editor)));
error_label->add_theme_color_override(SNAME("default_color"), get_theme_color(SNAME("error_color"), EditorStringName(Editor)));
panel->add_theme_style_override(SceneStringName(panel), get_theme_stylebox(SceneStringName(panel), SNAME("Tree")));
tool_blend->set_button_icon(get_editor_theme_icon(SNAME("EditPivot")));
tool_select->set_button_icon(get_editor_theme_icon(SNAME("ToolSelect")));
Expand All @@ -835,22 +834,7 @@ void AnimationNodeBlendSpace2DEditor::_notification(int p_what) {
return;
}

String error;

error = tree->get_editor_error_message();

if (error.is_empty() && blend_space->get_triangle_count() == 0) {
error = TTR("No triangles exist, so no blending can take place.");
}

if (error != error_label->get_text()) {
error_label->set_text(error);
if (!error.is_empty()) {
error_panel->show();
} else {
error_panel->hide();
}
}
update_error_message(tree, error_panel, error_label);
} break;

case NOTIFICATION_VISIBILITY_CHANGED: {
Expand Down Expand Up @@ -1096,8 +1080,7 @@ AnimationNodeBlendSpace2DEditor::AnimationNodeBlendSpace2DEditor() {

error_panel = memnew(PanelContainer);
add_child(error_panel);
error_label = memnew(Label);
error_label->set_focus_mode(FOCUS_ACCESSIBILITY);
error_label = create_error_label_node();
error_panel->add_child(error_label);
error_panel->hide();

Expand Down
4 changes: 2 additions & 2 deletions editor/animation/animation_blend_space_2d_editor.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class AnimationNodeBlendSpace2DEditor : public AnimationTreeNodeEditorPlugin {
Control *blend_space_draw = nullptr;

PanelContainer *error_panel = nullptr;
Label *error_label = nullptr;
RichTextLabel *error_label = nullptr;

bool updating;

Expand All @@ -99,7 +99,7 @@ class AnimationNodeBlendSpace2DEditor : public AnimationTreeNodeEditorPlugin {

PopupMenu *menu = nullptr;
PopupMenu *animations_menu = nullptr;
Vector<String> animations_to_add;
Vector<StringName> animations_to_add;
Vector2 add_point_pos;
Vector<Vector2> points;

Expand Down
Loading