Skip to content

Commit 1964918

Browse files
committed
Use LocalVector in Animation
1 parent 46c495c commit 1964918

File tree

5 files changed

+285
-285
lines changed

5 files changed

+285
-285
lines changed

scene/3d/physics/physical_bone_simulator_3d.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ void PhysicalBoneSimulator3D::_pose_updated() {
7474
return;
7575
}
7676
// If this triggers that means that we likely haven't rebuilt the bone list yet.
77-
if (skeleton->get_bone_count() != bones.size()) {
77+
if (skeleton->get_bone_count() != (int)bones.size()) {
7878
// NOTE: this is re-entrant and will call _pose_updated again.
7979
_bone_list_changed();
8080
} else {
@@ -85,8 +85,8 @@ void PhysicalBoneSimulator3D::_pose_updated() {
8585
}
8686

8787
void PhysicalBoneSimulator3D::_bone_pose_updated(Skeleton3D *p_skeleton, int p_bone_id) {
88-
ERR_FAIL_INDEX(p_bone_id, bones.size());
89-
bones.write[p_bone_id].global_pose = p_skeleton->get_bone_global_pose(p_bone_id);
88+
ERR_FAIL_UNSIGNED_INDEX((uint32_t)p_bone_id, bones.size());
89+
bones[p_bone_id].global_pose = p_skeleton->get_bone_global_pose(p_bone_id);
9090
}
9191

9292
void PhysicalBoneSimulator3D::_set_active(bool p_active) {
@@ -96,7 +96,7 @@ void PhysicalBoneSimulator3D::_set_active(bool p_active) {
9696
}
9797

9898
void PhysicalBoneSimulator3D::_reset_physical_bones_state() {
99-
for (int i = 0; i < bones.size(); i += 1) {
99+
for (uint32_t i = 0; i < bones.size(); i += 1) {
100100
if (bones[i].physical_bone) {
101101
bones[i].physical_bone->reset_physics_simulation_state();
102102
}
@@ -140,15 +140,15 @@ void PhysicalBoneSimulator3D::bind_physical_bone_to_bone(int p_bone, PhysicalBon
140140
ERR_FAIL_INDEX(p_bone, bone_size);
141141
ERR_FAIL_COND(bones[p_bone].physical_bone);
142142
ERR_FAIL_NULL(p_physical_bone);
143-
bones.write[p_bone].physical_bone = p_physical_bone;
143+
bones[p_bone].physical_bone = p_physical_bone;
144144

145145
_rebuild_physical_bones_cache();
146146
}
147147

148148
void PhysicalBoneSimulator3D::unbind_physical_bone_from_bone(int p_bone) {
149149
const int bone_size = bones.size();
150150
ERR_FAIL_INDEX(p_bone, bone_size);
151-
bones.write[p_bone].physical_bone = nullptr;
151+
bones[p_bone].physical_bone = nullptr;
152152

153153
_rebuild_physical_bones_cache();
154154
}
@@ -193,7 +193,7 @@ void PhysicalBoneSimulator3D::_rebuild_physical_bones_cache() {
193193
for (int i = 0; i < b_size; ++i) {
194194
PhysicalBone3D *parent_pb = _get_physical_bone_parent(i);
195195
if (parent_pb != bones[i].cache_parent_physical_bone) {
196-
bones.write[i].cache_parent_physical_bone = parent_pb;
196+
bones[i].cache_parent_physical_bone = parent_pb;
197197
if (bones[i].physical_bone) {
198198
bones[i].physical_bone->_on_bone_parent_changed();
199199
}
@@ -361,15 +361,15 @@ Transform3D PhysicalBoneSimulator3D::get_bone_global_pose(int p_bone) const {
361361
void PhysicalBoneSimulator3D::set_bone_global_pose(int p_bone, const Transform3D &p_pose) {
362362
const int bone_size = bones.size();
363363
ERR_FAIL_INDEX(p_bone, bone_size);
364-
bones.write[p_bone].global_pose = p_pose;
364+
bones[p_bone].global_pose = p_pose;
365365
}
366366

367367
void PhysicalBoneSimulator3D::_process_modification(double p_delta) {
368368
Skeleton3D *skeleton = get_skeleton();
369369
if (!skeleton) {
370370
return;
371371
}
372-
ERR_FAIL_COND(skeleton->get_bone_count() != bones.size());
372+
ERR_FAIL_COND(skeleton->get_bone_count() != (int)bones.size());
373373
for (int i = 0; i < skeleton->get_bone_count(); i++) {
374374
if (!bones[i].physical_bone) {
375375
continue;

scene/3d/physics/physical_bone_simulator_3d.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class PhysicalBoneSimulator3D : public SkeletonModifier3D {
5656
}
5757
};
5858

59-
Vector<SimulatedBone> bones;
59+
LocalVector<SimulatedBone> bones;
6060

6161
/// This is a slow API, so it's cached
6262
PhysicalBone3D *_get_physical_bone_parent(int p_bone);

scene/animation/animation_mixer.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -609,10 +609,10 @@ void AnimationMixer::_create_track_num_to_track_cache_for_animation(Ref<Animatio
609609
return;
610610
}
611611
LocalVector<TrackCache *> &track_num_to_track_cache = animation_track_num_to_track_cache.insert_new(p_animation, LocalVector<TrackCache *>())->value;
612-
const Vector<Animation::Track *> &tracks = p_animation->get_tracks();
612+
const LocalVector<Animation::Track *> &tracks = p_animation->get_tracks();
613613

614614
track_num_to_track_cache.resize(tracks.size());
615-
for (int i = 0; i < tracks.size(); i++) {
615+
for (uint32_t i = 0; i < tracks.size(); i++) {
616616
TrackCache **track_ptr = track_cache.getptr(tracks[i]->thash);
617617
if (track_ptr == nullptr) {
618618
track_num_to_track_cache[i] = nullptr;
@@ -1133,7 +1133,7 @@ void AnimationMixer::_blend_calc_total_weight() {
11331133
LocalVector<TrackCache *> &track_num_to_track_cache = animation_track_num_to_track_cache[a];
11341134
thread_local HashSet<Animation::TypeHash, HashHasher> processed_hashes;
11351135
processed_hashes.clear();
1136-
const Vector<Animation::Track *> tracks = a->get_tracks();
1136+
const LocalVector<Animation::Track *> &tracks = a->get_tracks();
11371137
Animation::Track *const *tracks_ptr = tracks.ptr();
11381138
int count = tracks.size();
11391139
for (int i = 0; i < count; i++) {
@@ -1181,7 +1181,7 @@ void AnimationMixer::_blend_process(double p_delta, bool p_update_only) {
11811181
#endif // _3D_DISABLED
11821182
ERR_CONTINUE_EDMSG(!animation_track_num_to_track_cache.has(a), "No animation in cache.");
11831183
LocalVector<TrackCache *> &track_num_to_track_cache = animation_track_num_to_track_cache[a];
1184-
const Vector<Animation::Track *> tracks = a->get_tracks();
1184+
const LocalVector<Animation::Track *> &tracks = a->get_tracks();
11851185
Animation::Track *const *tracks_ptr = tracks.ptr();
11861186
real_t a_length = a->get_length();
11871187
int count = tracks.size();

0 commit comments

Comments
 (0)