mirror of
https://github.com/godotengine/godot.git
synced 2025-10-19 07:53:26 +00:00
Merge pull request #101285 from Nazarwadim/use_LocalVector_in_animation
Use `LocalVector` in `Animation`
This commit is contained in:
commit
2557b0da9f
5 changed files with 285 additions and 285 deletions
|
@ -74,7 +74,7 @@ void PhysicalBoneSimulator3D::_pose_updated() {
|
|||
return;
|
||||
}
|
||||
// If this triggers that means that we likely haven't rebuilt the bone list yet.
|
||||
if (skeleton->get_bone_count() != bones.size()) {
|
||||
if (skeleton->get_bone_count() != (int)bones.size()) {
|
||||
// NOTE: this is re-entrant and will call _pose_updated again.
|
||||
_bone_list_changed();
|
||||
} else {
|
||||
|
@ -85,8 +85,8 @@ void PhysicalBoneSimulator3D::_pose_updated() {
|
|||
}
|
||||
|
||||
void PhysicalBoneSimulator3D::_bone_pose_updated(Skeleton3D *p_skeleton, int p_bone_id) {
|
||||
ERR_FAIL_INDEX(p_bone_id, bones.size());
|
||||
bones.write[p_bone_id].global_pose = p_skeleton->get_bone_global_pose(p_bone_id);
|
||||
ERR_FAIL_UNSIGNED_INDEX((uint32_t)p_bone_id, bones.size());
|
||||
bones[p_bone_id].global_pose = p_skeleton->get_bone_global_pose(p_bone_id);
|
||||
}
|
||||
|
||||
void PhysicalBoneSimulator3D::_set_active(bool p_active) {
|
||||
|
@ -96,7 +96,7 @@ void PhysicalBoneSimulator3D::_set_active(bool p_active) {
|
|||
}
|
||||
|
||||
void PhysicalBoneSimulator3D::_reset_physical_bones_state() {
|
||||
for (int i = 0; i < bones.size(); i += 1) {
|
||||
for (uint32_t i = 0; i < bones.size(); i += 1) {
|
||||
if (bones[i].physical_bone) {
|
||||
bones[i].physical_bone->reset_physics_simulation_state();
|
||||
}
|
||||
|
@ -140,7 +140,7 @@ void PhysicalBoneSimulator3D::bind_physical_bone_to_bone(int p_bone, PhysicalBon
|
|||
ERR_FAIL_INDEX(p_bone, bone_size);
|
||||
ERR_FAIL_COND(bones[p_bone].physical_bone);
|
||||
ERR_FAIL_NULL(p_physical_bone);
|
||||
bones.write[p_bone].physical_bone = p_physical_bone;
|
||||
bones[p_bone].physical_bone = p_physical_bone;
|
||||
|
||||
_rebuild_physical_bones_cache();
|
||||
}
|
||||
|
@ -148,7 +148,7 @@ void PhysicalBoneSimulator3D::bind_physical_bone_to_bone(int p_bone, PhysicalBon
|
|||
void PhysicalBoneSimulator3D::unbind_physical_bone_from_bone(int p_bone) {
|
||||
const int bone_size = bones.size();
|
||||
ERR_FAIL_INDEX(p_bone, bone_size);
|
||||
bones.write[p_bone].physical_bone = nullptr;
|
||||
bones[p_bone].physical_bone = nullptr;
|
||||
|
||||
_rebuild_physical_bones_cache();
|
||||
}
|
||||
|
@ -193,7 +193,7 @@ void PhysicalBoneSimulator3D::_rebuild_physical_bones_cache() {
|
|||
for (int i = 0; i < b_size; ++i) {
|
||||
PhysicalBone3D *parent_pb = _get_physical_bone_parent(i);
|
||||
if (parent_pb != bones[i].cache_parent_physical_bone) {
|
||||
bones.write[i].cache_parent_physical_bone = parent_pb;
|
||||
bones[i].cache_parent_physical_bone = parent_pb;
|
||||
if (bones[i].physical_bone) {
|
||||
bones[i].physical_bone->_on_bone_parent_changed();
|
||||
}
|
||||
|
@ -361,7 +361,7 @@ Transform3D PhysicalBoneSimulator3D::get_bone_global_pose(int p_bone) const {
|
|||
void PhysicalBoneSimulator3D::set_bone_global_pose(int p_bone, const Transform3D &p_pose) {
|
||||
const int bone_size = bones.size();
|
||||
ERR_FAIL_INDEX(p_bone, bone_size);
|
||||
bones.write[p_bone].global_pose = p_pose;
|
||||
bones[p_bone].global_pose = p_pose;
|
||||
}
|
||||
|
||||
void PhysicalBoneSimulator3D::_process_modification(double p_delta) {
|
||||
|
@ -369,7 +369,7 @@ void PhysicalBoneSimulator3D::_process_modification(double p_delta) {
|
|||
if (!skeleton) {
|
||||
return;
|
||||
}
|
||||
ERR_FAIL_COND(skeleton->get_bone_count() != bones.size());
|
||||
ERR_FAIL_COND(skeleton->get_bone_count() != (int)bones.size());
|
||||
for (int i = 0; i < skeleton->get_bone_count(); i++) {
|
||||
if (!bones[i].physical_bone) {
|
||||
continue;
|
||||
|
|
|
@ -56,7 +56,7 @@ class PhysicalBoneSimulator3D : public SkeletonModifier3D {
|
|||
}
|
||||
};
|
||||
|
||||
Vector<SimulatedBone> bones;
|
||||
LocalVector<SimulatedBone> bones;
|
||||
|
||||
/// This is a slow API, so it's cached
|
||||
PhysicalBone3D *_get_physical_bone_parent(int p_bone);
|
||||
|
|
|
@ -613,10 +613,10 @@ void AnimationMixer::_create_track_num_to_track_cache_for_animation(Ref<Animatio
|
|||
return;
|
||||
}
|
||||
LocalVector<TrackCache *> &track_num_to_track_cache = animation_track_num_to_track_cache.insert_new(p_animation, LocalVector<TrackCache *>())->value;
|
||||
const Vector<Animation::Track *> &tracks = p_animation->get_tracks();
|
||||
const LocalVector<Animation::Track *> &tracks = p_animation->get_tracks();
|
||||
|
||||
track_num_to_track_cache.resize(tracks.size());
|
||||
for (int i = 0; i < tracks.size(); i++) {
|
||||
for (uint32_t i = 0; i < tracks.size(); i++) {
|
||||
TrackCache **track_ptr = track_cache.getptr(tracks[i]->thash);
|
||||
if (track_ptr == nullptr) {
|
||||
track_num_to_track_cache[i] = nullptr;
|
||||
|
@ -1137,7 +1137,7 @@ void AnimationMixer::_blend_calc_total_weight() {
|
|||
LocalVector<TrackCache *> &track_num_to_track_cache = animation_track_num_to_track_cache[a];
|
||||
thread_local HashSet<Animation::TypeHash, HashHasher> processed_hashes;
|
||||
processed_hashes.clear();
|
||||
const Vector<Animation::Track *> tracks = a->get_tracks();
|
||||
const LocalVector<Animation::Track *> &tracks = a->get_tracks();
|
||||
Animation::Track *const *tracks_ptr = tracks.ptr();
|
||||
int count = tracks.size();
|
||||
for (int i = 0; i < count; i++) {
|
||||
|
@ -1185,7 +1185,7 @@ void AnimationMixer::_blend_process(double p_delta, bool p_update_only) {
|
|||
#endif // _3D_DISABLED
|
||||
ERR_CONTINUE_EDMSG(!animation_track_num_to_track_cache.has(a), "No animation in cache.");
|
||||
LocalVector<TrackCache *> &track_num_to_track_cache = animation_track_num_to_track_cache[a];
|
||||
const Vector<Animation::Track *> tracks = a->get_tracks();
|
||||
const LocalVector<Animation::Track *> &tracks = a->get_tracks();
|
||||
Animation::Track *const *tracks_ptr = tracks.ptr();
|
||||
real_t a_length = a->get_length();
|
||||
int count = tracks.size();
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -135,7 +135,7 @@ private:
|
|||
/* POSITION TRACK */
|
||||
|
||||
struct PositionTrack : public Track {
|
||||
Vector<TKey<Vector3>> positions;
|
||||
LocalVector<TKey<Vector3>> positions;
|
||||
int32_t compressed_track = -1;
|
||||
PositionTrack() { type = TYPE_POSITION_3D; }
|
||||
};
|
||||
|
@ -143,7 +143,7 @@ private:
|
|||
/* ROTATION TRACK */
|
||||
|
||||
struct RotationTrack : public Track {
|
||||
Vector<TKey<Quaternion>> rotations;
|
||||
LocalVector<TKey<Quaternion>> rotations;
|
||||
int32_t compressed_track = -1;
|
||||
RotationTrack() { type = TYPE_ROTATION_3D; }
|
||||
};
|
||||
|
@ -151,7 +151,7 @@ private:
|
|||
/* SCALE TRACK */
|
||||
|
||||
struct ScaleTrack : public Track {
|
||||
Vector<TKey<Vector3>> scales;
|
||||
LocalVector<TKey<Vector3>> scales;
|
||||
int32_t compressed_track = -1;
|
||||
ScaleTrack() { type = TYPE_SCALE_3D; }
|
||||
};
|
||||
|
@ -159,7 +159,7 @@ private:
|
|||
/* BLEND SHAPE TRACK */
|
||||
|
||||
struct BlendShapeTrack : public Track {
|
||||
Vector<TKey<float>> blend_shapes;
|
||||
LocalVector<TKey<float>> blend_shapes;
|
||||
int32_t compressed_track = -1;
|
||||
BlendShapeTrack() { type = TYPE_BLEND_SHAPE; }
|
||||
};
|
||||
|
@ -169,7 +169,7 @@ private:
|
|||
struct ValueTrack : public Track {
|
||||
UpdateMode update_mode = UPDATE_CONTINUOUS;
|
||||
bool update_on_seek = false;
|
||||
Vector<TKey<Variant>> values;
|
||||
LocalVector<TKey<Variant>> values;
|
||||
|
||||
ValueTrack() {
|
||||
type = TYPE_VALUE;
|
||||
|
@ -184,7 +184,7 @@ private:
|
|||
};
|
||||
|
||||
struct MethodTrack : public Track {
|
||||
Vector<MethodKey> methods;
|
||||
LocalVector<MethodKey> methods;
|
||||
MethodTrack() { type = TYPE_METHOD; }
|
||||
};
|
||||
|
||||
|
@ -200,7 +200,7 @@ private:
|
|||
};
|
||||
|
||||
struct BezierTrack : public Track {
|
||||
Vector<TKey<BezierKey>> values;
|
||||
LocalVector<TKey<BezierKey>> values;
|
||||
|
||||
BezierTrack() {
|
||||
type = TYPE_BEZIER;
|
||||
|
@ -218,7 +218,7 @@ private:
|
|||
};
|
||||
|
||||
struct AudioTrack : public Track {
|
||||
Vector<TKey<AudioKey>> values;
|
||||
LocalVector<TKey<AudioKey>> values;
|
||||
bool use_blend = true;
|
||||
|
||||
AudioTrack() {
|
||||
|
@ -229,7 +229,7 @@ private:
|
|||
/* ANIMATION TRACK */
|
||||
|
||||
struct AnimationTrack : public Track {
|
||||
Vector<TKey<StringName>> values;
|
||||
LocalVector<TKey<StringName>> values;
|
||||
|
||||
AnimationTrack() {
|
||||
type = TYPE_ANIMATION;
|
||||
|
@ -246,20 +246,20 @@ private:
|
|||
MarkerKey() = default;
|
||||
};
|
||||
|
||||
Vector<MarkerKey> marker_names; // time -> name
|
||||
LocalVector<MarkerKey> marker_names; // time -> name
|
||||
HashMap<StringName, double> marker_times; // name -> time
|
||||
HashMap<StringName, Color> marker_colors; // name -> color
|
||||
|
||||
Vector<Track *> tracks;
|
||||
LocalVector<Track *> tracks;
|
||||
|
||||
template <typename T, typename V>
|
||||
int _insert(double p_time, T &p_keys, const V &p_value);
|
||||
|
||||
int _marker_insert(double p_time, Vector<MarkerKey> &p_keys, const MarkerKey &p_value);
|
||||
int _marker_insert(double p_time, LocalVector<MarkerKey> &p_keys, const MarkerKey &p_value);
|
||||
|
||||
template <typename K>
|
||||
|
||||
inline int _find(const Vector<K> &p_keys, double p_time, bool p_backward = false, bool p_limit = false) const;
|
||||
inline int _find(const LocalVector<K> &p_keys, double p_time, bool p_backward = false, bool p_limit = false) const;
|
||||
|
||||
_FORCE_INLINE_ Vector3 _interpolate(const Vector3 &p_a, const Vector3 &p_b, real_t p_c) const;
|
||||
_FORCE_INLINE_ Quaternion _interpolate(const Quaternion &p_a, const Quaternion &p_b, real_t p_c) const;
|
||||
|
@ -274,10 +274,10 @@ private:
|
|||
_FORCE_INLINE_ Variant _cubic_interpolate_angle_in_time(const Variant &p_pre_a, const Variant &p_a, const Variant &p_b, const Variant &p_post_b, real_t p_c, real_t p_pre_a_t, real_t p_b_t, real_t p_post_b_t) const;
|
||||
|
||||
template <typename T>
|
||||
_FORCE_INLINE_ T _interpolate(const Vector<TKey<T>> &p_keys, double p_time, InterpolationType p_interp, bool p_loop_wrap, bool *p_ok, bool p_backward = false) const;
|
||||
_FORCE_INLINE_ T _interpolate(const LocalVector<TKey<T>> &p_keys, double p_time, InterpolationType p_interp, bool p_loop_wrap, bool *p_ok, bool p_backward = false) const;
|
||||
|
||||
template <typename T>
|
||||
_FORCE_INLINE_ void _track_get_key_indices_in_range(const Vector<T> &p_array, double from_time, double to_time, List<int> *p_indices, bool p_is_backward) const;
|
||||
_FORCE_INLINE_ void _track_get_key_indices_in_range(const LocalVector<T> &p_array, double from_time, double to_time, List<int> *p_indices, bool p_is_backward) const;
|
||||
|
||||
double length = 1.0;
|
||||
real_t step = DEFAULT_STEP;
|
||||
|
@ -408,7 +408,7 @@ public:
|
|||
int add_track(TrackType p_type, int p_at_pos = -1);
|
||||
void remove_track(int p_track);
|
||||
|
||||
_FORCE_INLINE_ const Vector<Track *> get_tracks() {
|
||||
_FORCE_INLINE_ const LocalVector<Track *> &get_tracks() {
|
||||
return tracks;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue