Overhaul of tangible/blueprint animation interface

This commit is contained in:
2023-10-02 15:48:42 -04:00
parent 642b444d13
commit a2e49338cf
7 changed files with 197 additions and 186 deletions

View File

@@ -19,32 +19,6 @@ enum class ElxAnimValueType {
INVALID
};
////////////////////////////////////////////////
//
// Playback Modes
//
// There are three different ways to play an animation:
//
// 1. Start Animation. This is the normal way to play an animation.
//
// 2. Warp to Final. Skip the actual animation, and jump
// instantaneously to the final state of the animation.
//
// 3. Blend to Final. Skip the actual animation, and blend
// smoothly to the final state of the animation. If the current
// state is very far from the final state, then maybe
// jump instantaneously instead.
//
////////////////////////////////////////////////
UENUM(BlueprintType)
enum class ElxAnimationMode : uint8 {
StartAnimation,
WarpToFinal,
BlendToFinal,
INVALID,
};
////////////////////////////////////////////////
//
// An single animation step.
@@ -61,13 +35,19 @@ struct INTEGRATION_API FlxAnimationStep {
GENERATED_BODY()
public:
UPROPERTY()
bool Finished;
UPROPERTY()
uint64 Hash;
UPROPERTY()
TArray<uint8> Body;
FlxAnimationStep() : Hash(0), Body() {}
UPROPERTY()
FString Blueprint;
FlxAnimationStep() : Finished(false), Hash(0), Body(), Blueprint() {}
FlxAnimationStep(uint64 h, std::string_view b);
// Unpack an AnimStep into a UObject
@@ -114,10 +94,12 @@ public:
UFUNCTION(BlueprintCallable, BlueprintPure, Category = Luprex)
static FString AnimationStepDebugString(const FlxAnimationStep& step);
UFUNCTION(BlueprintCallable, Category = Luprex)
static void UnpackAnimationStep(const FlxAnimationStep& step,
const FString& VariableNamePrefix, UObject* into);
UFUNCTION(BlueprintCallable, Meta = (DefaultToSelf = "into"), Category = Luprex)
static void UnpackAnimationStep(UObject* into, const FlxAnimationStep& step, const FString& VariableNamePrefix);
UFUNCTION(BlueprintCallable, BlueprintPure, Category = Luprex)
static bool AnimationStepIsIdle(const FlxAnimationStep &step);
UFUNCTION(BlueprintCallable, BlueprintPure, Category = Luprex)
static FVector AnimationStepGetVector(const FlxAnimationStep& step, const FString& name);
@@ -180,11 +162,24 @@ struct FlxAnimationField {
class FlxAnimQueueDecoder {
private:
FlxStringDecoder Decoder;
// These values are immediately read from the header.
//
int SizeLimit;
int ActualSize;
public:
// Initialize the FlxAnimQueueDecoder with the encoded animation queue.
//
FlxAnimQueueDecoder(std::string_view s) : Decoder(s) {}
FlxAnimQueueDecoder(std::string_view s);
// Get the size limit of the animation queue.
//
int GetSizeLimit() const { return SizeLimit; }
// Get the Actual Size of the animation queue.
//
int GetActualSize() const { return ActualSize; }
// Return true if the parser has reached the end of the string.
//
@@ -194,6 +189,10 @@ public:
//
FlxAnimationStepView ReadStep();
// Peek at the hash of the next animation step.
//
uint64 PeekHash();
// Convert an AnimQueue to an FString.
//
static FString DebugString(std::string_view s);
@@ -252,26 +251,11 @@ public:
//
TDeque<FlxAnimationStep> AQ;
// The sequence number of the first item in AQ.
// True if something has recently changed.
//
int32 FirstSeqno;
// Map from hash to sequence number.
//
TMap<uint64, int32> HashToSeqno;
// The sequence number of the first unstarted animation.
//
int32 UnstartedSeqno;
// Indicates whether the unstarted animation should be played or otherwise.
//
ElxAnimationMode PlaybackMode;
// Array of recently-aborted hash values.
//
TArray<uint64> AbortedHashes;
bool Changed;
private:
public:
// Construct a tracker.
//
@@ -290,24 +274,39 @@ public:
//
void Update(std::string_view encqueue);
// Fetch the aborted hash values.
// Get the current animation step.
//
// This gets the array of aborted hashes and clears
// the stored array.
//
TArray<uint64> GetAborted();
// Get the current animation step. This is the step that the
// blueprint should currently be playing.
//
FlxAnimationStep GetCurrentAnimation();
// Get the next unstarted animation step.
// Declare that an animation is finished.
//
// Get the next animation step. Returns the next step and the
// playback mode. If the playback mode is INVALID then there is
// no next step to play
//
ElxAnimationMode GetNextStep(FlxAnimationStep& step);
// The blueprint uses this function call to indicate that it
// is done playing the specified animation. This will cause the
// animation to be marked as finished, which in turn causes
// 'GetCurrentStep' to advance to the next animation.
//
void FinishedAnimation(uint64 Hash);
// Declare that an animation has been started.
// Skip to the end of the animation queue.
//
// This is equivalent to calling 'FinishedHash' on every
// animation in the entire queue.
//
// After starting an animation, you should call this.
void SkipToEnd();
// Clear the 'Changed' flag.
//
void StartedStep(uint64 Hash);
void ClearChanged() { Changed = false; }
// Get the 'Changed' flag.
//
// The changed flag is set to true whenever the Luprex animation
// queue changes from its previous state. The changed flag is also
// set to true whenever 'SetFinished' marks an animation as finished.
// The changed flag can only be set to false by 'ClearChanged,' above.
//
bool IsChanged() const { return Changed; }
};