Progress on Animation Queue Pipeline

This commit is contained in:
2023-09-15 00:01:41 -04:00
parent 7b58dea692
commit afa0cfbe6d
15 changed files with 342 additions and 30 deletions

View File

@@ -2,6 +2,7 @@
#include "CoreMinimal.h"
#include "StringDecoder.h"
#include "Containers/Deque.h"
////////////////////////////////////////////////
//
@@ -24,12 +25,25 @@ enum EAnimValueType {
// The body consists of a sequence of FAnimField
// records. The body is encoded, to read the
// FAnimField records you need an FAnimStepDecoder.
// This comes in two versions: the string version,
// and the string_view version.
//
////////////////////////////////////////////////
struct FAnimStep {
uint32 Hash;
std::string_view Body;
FAnimStep() : Hash(0), Body("") {}
FAnimStep(uint32 h, std::string_view b) : Hash(h), Body(b) {}
};
struct FAnimStoredStep {
uint64 Hash;
std::string Body;
FAnimStoredStep() : Hash(0), Body("") {}
FAnimStoredStep(uint32 h, std::string_view b) : Hash(h), Body(b) {}
};
////////////////////////////////////////////////
@@ -106,6 +120,7 @@ public:
// Initialize the FAnimStepDecoder from the FAnimStep.
//
FAnimStepDecoder(const FAnimStep &step) : Decoder(step.Body) {}
FAnimStepDecoder(const FAnimStoredStep& step) : Decoder(step.Body) {}
// Return true if the parser has reached the end of the string.
//
@@ -119,3 +134,76 @@ public:
//
static FString DebugString(const FAnimStep &step);
};
////////////////////////////////////////////////
//
// FAnimTracker
//
// This class monitors the animation queue for a single
// tangible. It can identify when a new animation has
// appeared on the animation queue, and when animations have
// been removed from the animation queue. It also
// keeps track of which animations have been started.
//
////////////////////////////////////////////////
class FAnimTracker {
public:
// Our own copy of the animation queue. We only
// store the hashes, not the steps. The First element
// of the queue is the oldest item.
//
TDeque<FAnimStoredStep> AQ;
// The sequence number of the first item in AQ.
//
int32 FirstSeqno;
// Map from hash to sequence number.
//
TMap<uint64, int32> HashToSeqno;
// The sequence number of the first unstarted animation.
//
int32 UnstartedSeqno;
// Array of recently-aborted hash values.
TArray<uint64> AbortedHashes;
public:
// Construct a tracker.
//
// Initially, the tracker is in the empty (Clear) state.
//
FAnimTracker();
// Update from the specified animation queue.
//
// After the update is done, AQ will be a copy
// of the animation queue that is passed in.
//
void Update(std::string_view encqueue);
// Fetch the aborted hash values.
//
// This gets the array of aborted hashes and clears
// the stored array.
//
TArray<uint64> GetAborted();
// Return true if there are any unstarted animation steps.
//
bool AnyUnstarted();
// Get the next unstarted animation step.
//
// You may only call this if AnyUnstarted returns true.
//
FAnimStoredStep GetUnstarted();
// Declare that an animation has been started.
//
// After starting an animation, you should call this.
//
void Started(uint64 Hash);
};