Add MapTrack to SceneAnimationPlayer
This commit is contained in:
@@ -220,6 +220,41 @@ void SceneAnimationPlayer::MapObject(const Guid& from, const Guid& to)
|
||||
_objectsMapping[from] = to;
|
||||
}
|
||||
|
||||
void SceneAnimationPlayer::MapTrack(const StringView& from, const Guid& to)
|
||||
{
|
||||
SceneAnimation* anim = Animation.Get();
|
||||
if (!anim || !anim->IsLoaded())
|
||||
return;
|
||||
for (int32 j = 0; j < anim->Tracks.Count(); j++)
|
||||
{
|
||||
const auto& track = anim->Tracks[j];
|
||||
if (track.Name != from)
|
||||
continue;
|
||||
switch (track.Type)
|
||||
{
|
||||
case SceneAnimation::Track::Types::Actor:
|
||||
{
|
||||
const auto trackData = track.GetData<SceneAnimation::ActorTrack::Data>();
|
||||
_objectsMapping[trackData->ID] = to;
|
||||
break;
|
||||
}
|
||||
case SceneAnimation::Track::Types::Script:
|
||||
{
|
||||
const auto trackData = track.GetData<SceneAnimation::ScriptTrack::Data>();
|
||||
_objectsMapping[trackData->ID] = to;
|
||||
break;
|
||||
}
|
||||
case SceneAnimation::Track::Types::CameraCut:
|
||||
{
|
||||
const auto trackData = track.GetData<SceneAnimation::CameraCutTrack::Data>();
|
||||
_objectsMapping[trackData->ID] = to;
|
||||
break;
|
||||
}
|
||||
default: ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SceneAnimationPlayer::Restore(SceneAnimation* anim, int32 stateIndexOffset)
|
||||
{
|
||||
// Restore all tracks
|
||||
|
||||
@@ -198,6 +198,13 @@ public:
|
||||
/// <param name="to">The destination object to animate.</param>
|
||||
API_FUNCTION() void MapObject(const Guid& from, const Guid& to);
|
||||
|
||||
/// <summary>
|
||||
/// Adds an object mapping for the object track. The track name `from` will be redirected to the specified object `to`. Can be used to reuse the same animation for different objects.
|
||||
/// </summary>
|
||||
/// <param name="from">The source track name from the scene animation asset to replace.</param>
|
||||
/// <param name="to">The destination object to animate.</param>
|
||||
API_FUNCTION() void MapTrack(const StringView& from, const Guid& to);
|
||||
|
||||
private:
|
||||
|
||||
void Restore(SceneAnimation* anim, int32 stateIndexOffset);
|
||||
|
||||
Reference in New Issue
Block a user