Optimize StringName usage
* Added a new macro SNAME() that constructs and caches a local stringname. * Subsequent usages use the cached version. * Since these use a global static variable, a second refcounter of static usages need to be kept for cleanup time. * Replaced all theme usages by this new macro. * Replace all signal emission usages by this new macro. * Replace all call_deferred usages by this new macro. This is part of ongoing work to optimize GUI and the editor.
This commit is contained in:
parent
b76dfde329
commit
6631f66c2a
236 changed files with 3694 additions and 3670 deletions
|
|
@ -54,7 +54,7 @@ void AnimationNodeBlendSpace1D::_validate_property(PropertyInfo &property) const
|
|||
}
|
||||
|
||||
void AnimationNodeBlendSpace1D::_tree_changed() {
|
||||
emit_signal("tree_changed");
|
||||
emit_signal(SNAME("tree_changed"));
|
||||
}
|
||||
|
||||
void AnimationNodeBlendSpace1D::_bind_methods() {
|
||||
|
|
@ -120,7 +120,7 @@ void AnimationNodeBlendSpace1D::add_blend_point(const Ref<AnimationRootNode> &p_
|
|||
blend_points[p_at_index].node->connect("tree_changed", callable_mp(this, &AnimationNodeBlendSpace1D::_tree_changed), varray(), CONNECT_REFERENCE_COUNTED);
|
||||
|
||||
blend_points_used++;
|
||||
emit_signal("tree_changed");
|
||||
emit_signal(SNAME("tree_changed"));
|
||||
}
|
||||
|
||||
void AnimationNodeBlendSpace1D::set_blend_point_position(int p_point, float p_position) {
|
||||
|
|
@ -140,7 +140,7 @@ void AnimationNodeBlendSpace1D::set_blend_point_node(int p_point, const Ref<Anim
|
|||
blend_points[p_point].node = p_node;
|
||||
blend_points[p_point].node->connect("tree_changed", callable_mp(this, &AnimationNodeBlendSpace1D::_tree_changed), varray(), CONNECT_REFERENCE_COUNTED);
|
||||
|
||||
emit_signal("tree_changed");
|
||||
emit_signal(SNAME("tree_changed"));
|
||||
}
|
||||
|
||||
float AnimationNodeBlendSpace1D::get_blend_point_position(int p_point) const {
|
||||
|
|
@ -164,7 +164,7 @@ void AnimationNodeBlendSpace1D::remove_blend_point(int p_point) {
|
|||
}
|
||||
|
||||
blend_points_used--;
|
||||
emit_signal("tree_changed");
|
||||
emit_signal(SNAME("tree_changed"));
|
||||
}
|
||||
|
||||
int AnimationNodeBlendSpace1D::get_blend_point_count() const {
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ void AnimationNodeBlendSpace2D::add_blend_point(const Ref<AnimationRootNode> &p_
|
|||
|
||||
_queue_auto_triangles();
|
||||
|
||||
emit_signal("tree_changed");
|
||||
emit_signal(SNAME("tree_changed"));
|
||||
}
|
||||
|
||||
void AnimationNodeBlendSpace2D::set_blend_point_position(int p_point, const Vector2 &p_position) {
|
||||
|
|
@ -103,7 +103,7 @@ void AnimationNodeBlendSpace2D::set_blend_point_node(int p_point, const Ref<Anim
|
|||
blend_points[p_point].node = p_node;
|
||||
blend_points[p_point].node->connect("tree_changed", callable_mp(this, &AnimationNodeBlendSpace2D::_tree_changed), varray(), CONNECT_REFERENCE_COUNTED);
|
||||
|
||||
emit_signal("tree_changed");
|
||||
emit_signal(SNAME("tree_changed"));
|
||||
}
|
||||
|
||||
Vector2 AnimationNodeBlendSpace2D::get_blend_point_position(int p_point) const {
|
||||
|
|
@ -143,7 +143,7 @@ void AnimationNodeBlendSpace2D::remove_blend_point(int p_point) {
|
|||
blend_points[i] = blend_points[i + 1];
|
||||
}
|
||||
blend_points_used--;
|
||||
emit_signal("tree_changed");
|
||||
emit_signal(SNAME("tree_changed"));
|
||||
}
|
||||
|
||||
int AnimationNodeBlendSpace2D::get_blend_point_count() const {
|
||||
|
|
@ -321,7 +321,7 @@ void AnimationNodeBlendSpace2D::_queue_auto_triangles() {
|
|||
}
|
||||
|
||||
trianges_dirty = true;
|
||||
call_deferred("_update_triangles");
|
||||
call_deferred(SNAME("_update_triangles"));
|
||||
}
|
||||
|
||||
void AnimationNodeBlendSpace2D::_update_triangles() {
|
||||
|
|
@ -332,7 +332,7 @@ void AnimationNodeBlendSpace2D::_update_triangles() {
|
|||
trianges_dirty = false;
|
||||
triangles.clear();
|
||||
if (blend_points_used < 3) {
|
||||
emit_signal("triangles_updated");
|
||||
emit_signal(SNAME("triangles_updated"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -347,7 +347,7 @@ void AnimationNodeBlendSpace2D::_update_triangles() {
|
|||
for (int i = 0; i < triangles.size(); i++) {
|
||||
add_triangle(triangles[i].points[0], triangles[i].points[1], triangles[i].points[2]);
|
||||
}
|
||||
emit_signal("triangles_updated");
|
||||
emit_signal(SNAME("triangles_updated"));
|
||||
}
|
||||
|
||||
Vector2 AnimationNodeBlendSpace2D::get_closest_point(const Vector2 &p_point) {
|
||||
|
|
@ -586,7 +586,7 @@ Ref<AnimationNode> AnimationNodeBlendSpace2D::get_child_by_name(const StringName
|
|||
}
|
||||
|
||||
void AnimationNodeBlendSpace2D::_tree_changed() {
|
||||
emit_signal("tree_changed");
|
||||
emit_signal(SNAME("tree_changed"));
|
||||
}
|
||||
|
||||
void AnimationNodeBlendSpace2D::set_blend_mode(BlendMode p_blend_mode) {
|
||||
|
|
|
|||
|
|
@ -816,7 +816,7 @@ void AnimationNodeBlendTree::add_node(const StringName &p_name, Ref<AnimationNod
|
|||
nodes[p_name] = n;
|
||||
|
||||
emit_changed();
|
||||
emit_signal("tree_changed");
|
||||
emit_signal(SNAME("tree_changed"));
|
||||
|
||||
p_node->connect("tree_changed", callable_mp(this, &AnimationNodeBlendTree::_tree_changed), varray(), CONNECT_REFERENCE_COUNTED);
|
||||
p_node->connect("changed", callable_mp(this, &AnimationNodeBlendTree::_node_changed), varray(p_name), CONNECT_REFERENCE_COUNTED);
|
||||
|
|
@ -896,7 +896,7 @@ void AnimationNodeBlendTree::remove_node(const StringName &p_name) {
|
|||
}
|
||||
|
||||
emit_changed();
|
||||
emit_signal("tree_changed");
|
||||
emit_signal(SNAME("tree_changed"));
|
||||
}
|
||||
|
||||
void AnimationNodeBlendTree::rename_node(const StringName &p_name, const StringName &p_new_name) {
|
||||
|
|
@ -921,7 +921,7 @@ void AnimationNodeBlendTree::rename_node(const StringName &p_name, const StringN
|
|||
//connection must be done with new name
|
||||
nodes[p_new_name].node->connect("changed", callable_mp(this, &AnimationNodeBlendTree::_node_changed), varray(p_new_name), CONNECT_REFERENCE_COUNTED);
|
||||
|
||||
emit_signal("tree_changed");
|
||||
emit_signal(SNAME("tree_changed"));
|
||||
}
|
||||
|
||||
void AnimationNodeBlendTree::connect_node(const StringName &p_input_node, int p_input_index, const StringName &p_output_node) {
|
||||
|
|
@ -1125,11 +1125,11 @@ void AnimationNodeBlendTree::reset_state() {
|
|||
graph_offset = Vector2();
|
||||
nodes.clear();
|
||||
emit_changed();
|
||||
emit_signal("tree_changed");
|
||||
emit_signal(SNAME("tree_changed"));
|
||||
}
|
||||
|
||||
void AnimationNodeBlendTree::_tree_changed() {
|
||||
emit_signal("tree_changed");
|
||||
emit_signal(SNAME("tree_changed"));
|
||||
}
|
||||
|
||||
void AnimationNodeBlendTree::_node_changed(const StringName &p_node) {
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ void AnimationNodeStateMachineTransition::set_advance_condition(const StringName
|
|||
} else {
|
||||
advance_condition_name = StringName();
|
||||
}
|
||||
emit_signal("advance_condition_changed");
|
||||
emit_signal(SNAME("advance_condition_changed"));
|
||||
}
|
||||
|
||||
StringName AnimationNodeStateMachineTransition::get_advance_condition() const {
|
||||
|
|
@ -539,7 +539,7 @@ void AnimationNodeStateMachine::add_node(const StringName &p_name, Ref<Animation
|
|||
states[p_name] = state;
|
||||
|
||||
emit_changed();
|
||||
emit_signal("tree_changed");
|
||||
emit_signal(SNAME("tree_changed"));
|
||||
|
||||
p_node->connect("tree_changed", callable_mp(this, &AnimationNodeStateMachine::_tree_changed), varray(), CONNECT_REFERENCE_COUNTED);
|
||||
}
|
||||
|
|
@ -559,7 +559,7 @@ void AnimationNodeStateMachine::replace_node(const StringName &p_name, Ref<Anima
|
|||
states[p_name].node = p_node;
|
||||
|
||||
emit_changed();
|
||||
emit_signal("tree_changed");
|
||||
emit_signal(SNAME("tree_changed"));
|
||||
|
||||
p_node->connect("tree_changed", callable_mp(this, &AnimationNodeStateMachine::_tree_changed), varray(), CONNECT_REFERENCE_COUNTED);
|
||||
}
|
||||
|
|
@ -636,7 +636,7 @@ void AnimationNodeStateMachine::remove_node(const StringName &p_name) {
|
|||
}*/
|
||||
|
||||
emit_changed();
|
||||
emit_signal("tree_changed");
|
||||
emit_signal(SNAME("tree_changed"));
|
||||
}
|
||||
|
||||
void AnimationNodeStateMachine::rename_node(const StringName &p_name, const StringName &p_new_name) {
|
||||
|
|
@ -669,7 +669,7 @@ void AnimationNodeStateMachine::rename_node(const StringName &p_name, const Stri
|
|||
}*/
|
||||
|
||||
//path.clear(); //clear path
|
||||
emit_signal("tree_changed");
|
||||
emit_signal(SNAME("tree_changed"));
|
||||
}
|
||||
|
||||
void AnimationNodeStateMachine::get_node_list(List<StringName> *r_nodes) const {
|
||||
|
|
@ -923,7 +923,7 @@ void AnimationNodeStateMachine::reset_state() {
|
|||
graph_offset = Vector2();
|
||||
|
||||
emit_changed();
|
||||
emit_signal("tree_changed");
|
||||
emit_signal(SNAME("tree_changed"));
|
||||
}
|
||||
|
||||
void AnimationNodeStateMachine::set_node_position(const StringName &p_name, const Vector2 &p_position) {
|
||||
|
|
@ -937,7 +937,7 @@ Vector2 AnimationNodeStateMachine::get_node_position(const StringName &p_name) c
|
|||
}
|
||||
|
||||
void AnimationNodeStateMachine::_tree_changed() {
|
||||
emit_signal("tree_changed");
|
||||
emit_signal(SNAME("tree_changed"));
|
||||
}
|
||||
|
||||
void AnimationNodeStateMachine::_bind_methods() {
|
||||
|
|
|
|||
|
|
@ -1325,7 +1325,7 @@ float AnimationPlayer::get_current_animation_length() const {
|
|||
|
||||
void AnimationPlayer::_animation_changed() {
|
||||
clear_caches();
|
||||
emit_signal("caches_cleared");
|
||||
emit_signal(SNAME("caches_cleared"));
|
||||
if (is_playing()) {
|
||||
playback.seeked = true; //need to restart stuff, like audio
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1327,7 +1327,7 @@ void AnimationTree::_tree_changed() {
|
|||
return;
|
||||
}
|
||||
|
||||
call_deferred("_update_properties");
|
||||
call_deferred(SNAME("_update_properties"));
|
||||
properties_dirty = true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -264,7 +264,7 @@ bool Tween::step(float p_delta) {
|
|||
rem_delta = step_delta;
|
||||
|
||||
if (!step_active) {
|
||||
emit_signal("step_finished", current_step);
|
||||
emit_signal(SNAME("step_finished"), current_step);
|
||||
current_step++;
|
||||
|
||||
if (current_step == tweeners.size()) {
|
||||
|
|
@ -272,9 +272,9 @@ bool Tween::step(float p_delta) {
|
|||
if (loops_done == loops) {
|
||||
running = false;
|
||||
dead = true;
|
||||
emit_signal("finished");
|
||||
emit_signal(SNAME("finished"));
|
||||
} else {
|
||||
emit_signal("loop_finished", loops_done);
|
||||
emit_signal(SNAME("loop_finished"), loops_done);
|
||||
current_step = 0;
|
||||
start_tweeners();
|
||||
}
|
||||
|
|
@ -690,7 +690,7 @@ bool PropertyTweener::step(float &r_delta) {
|
|||
} else {
|
||||
finished = true;
|
||||
r_delta = elapsed_time - delay - duration;
|
||||
emit_signal("finished");
|
||||
emit_signal(SNAME("finished"));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -745,7 +745,7 @@ bool IntervalTweener::step(float &r_delta) {
|
|||
} else {
|
||||
finished = true;
|
||||
r_delta = elapsed_time - duration;
|
||||
emit_signal("finished");
|
||||
emit_signal(SNAME("finished"));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -784,7 +784,7 @@ bool CallbackTweener::step(float &r_delta) {
|
|||
|
||||
finished = true;
|
||||
r_delta = elapsed_time - delay;
|
||||
emit_signal("finished");
|
||||
emit_signal(SNAME("finished"));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -854,7 +854,7 @@ bool MethodTweener::step(float &r_delta) {
|
|||
} else {
|
||||
finished = true;
|
||||
r_delta = elapsed_time - delay - duration;
|
||||
emit_signal("finished");
|
||||
emit_signal(SNAME("finished"));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue