Skip to content

Commit

Permalink
Use thread_local for bones_backup
Browse files Browse the repository at this point in the history
  • Loading branch information
Nazarwadim committed Dec 31, 2024
1 parent efa1443 commit 482531c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
7 changes: 4 additions & 3 deletions scene/3d/skeleton_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,6 @@ void Skeleton3D::_update_process_order() const {
}
}

bones_backup.resize(bones.size());

concatenated_bone_names = StringName();

_update_bones_nested_set();
Expand Down Expand Up @@ -339,11 +337,14 @@ void Skeleton3D::_notification(int p_what) {
thread_local LocalVector<bool> bone_global_pose_dirty_backup;

// Process modifiers.

thread_local LocalVector<BonePoseBackup> bones_backup;
_find_modifiers();
if (!modifiers.is_empty()) {
bones_backup.resize(bones.size());
// Store unmodified bone poses.
for (uint32_t i = 0; i < bones.size(); i++) {
bones_backup[i].save(bones[i]);
bones_backup[i].save(bonesptr[i]);
}
// Store dirty flags for global bone poses.
bone_global_pose_dirty_backup = bone_global_pose_dirty;
Expand Down
1 change: 0 additions & 1 deletion scene/3d/skeleton_3d.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ class Skeleton3D : public Node3D {
void _process_modifiers();
void _process_changed();
void _make_modifiers_dirty();
mutable LocalVector<BonePoseBackup> bones_backup;

// Global bone pose calculation.
mutable LocalVector<int> nested_set_offset_to_bone_index; // Map from Bone::nested_set_offset to bone index.
Expand Down

0 comments on commit 482531c

Please sign in to comment.