Checking in what I found on my hard drive
This commit is contained in:
@@ -5,46 +5,6 @@
|
||||
#include "Containers/Deque.h"
|
||||
#include "AnimQueue.generated.h"
|
||||
|
||||
////////////////////////////////////////////////
|
||||
//
|
||||
// This is copied over from Luprex source. Not ideal.
|
||||
//
|
||||
////////////////////////////////////////////////
|
||||
|
||||
enum class ElxAnimValueType {
|
||||
STRING,
|
||||
NUMBER,
|
||||
BOOLEAN,
|
||||
XYZ,
|
||||
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 +21,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
|
||||
@@ -78,6 +44,14 @@ public:
|
||||
// routine tries to find a string property "color" in the
|
||||
// UObject, and then it sets that property to "blue."
|
||||
//
|
||||
// The prefix is prepended to the key names. For example,
|
||||
// if one of the key-value pairs is "color=blue", and the
|
||||
// prefix is "aq", then the property "aqColor=blue" will be
|
||||
// stored in the UObject.
|
||||
//
|
||||
// All properties of the UObject starting with the specified
|
||||
// prefix are cleared before unpacking the animation step.
|
||||
//
|
||||
// Returns true if all of the key-value pairs in the
|
||||
// animation step could be unpacked into fields of the UObject.
|
||||
// This could fail, for instance, if the UObject just doesn't
|
||||
@@ -85,16 +59,23 @@ public:
|
||||
// fail if there's a type mismatch. For example, "color=blue"
|
||||
// cannot be stored in a property "color" of type int.
|
||||
//
|
||||
// The prefix is prepended to the key names. For example,
|
||||
// if one of the key-value pairs is "color=blue", and the
|
||||
// prefix is "aq", then the property "aqColor=blue" will be
|
||||
// stored in the UObject.
|
||||
// Automatically injects a boolean property "idle" representing
|
||||
// whether the property's finished flag is set.
|
||||
//
|
||||
// If pre-clear is true, then all properties of the UObject
|
||||
// starting with the specified prefix are cleared before
|
||||
// unpacking the animation step.
|
||||
bool Unpack(const FString& prefix, UObject* into) const;
|
||||
|
||||
// Auto-Execute
|
||||
//
|
||||
bool Unpack(const FString& prefix, UObject* into, bool preclear = true) const;
|
||||
// These functions automatically update certain actor
|
||||
// properties:
|
||||
//
|
||||
// AutoUpdateXYZ(AActor *actor); // uses 'xyz' keyword
|
||||
// AutoUpdateFacing(AActor *actor); // uses 'facing' keyword.
|
||||
// AutoUpdatePlane(FName *plane); // uses 'plane' keyword
|
||||
//
|
||||
void AutoUpdateXYZ(AActor *actor) const;
|
||||
void AutoUpdateFacing(AActor *actor) const;
|
||||
void AutoUpdatePlane(FName *plane) const;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////
|
||||
@@ -114,10 +95,15 @@ 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 = TEXT("aq"));
|
||||
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Luprex")
|
||||
static bool AnimationStepEqual(const FlxAnimationStep &StepA, const FlxAnimationStep &StepB);
|
||||
|
||||
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);
|
||||
|
||||
@@ -129,18 +115,13 @@ public:
|
||||
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Luprex")
|
||||
static bool AnimationStepGetBool(const FlxAnimationStep& step, const FString& name);
|
||||
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////
|
||||
//
|
||||
// Exposing functions to blueprints.
|
||||
//
|
||||
////////////////////////////////////////////////
|
||||
|
||||
//UFUNCTION(BlueprintCallable)
|
||||
//void Unpack(const FString& prefix, UObject* into, bool preclear = true);
|
||||
|
||||
struct FlxAnimationStepView {
|
||||
uint64 Hash;
|
||||
std::string_view Body;
|
||||
@@ -166,7 +147,7 @@ struct FlxAnimationStepView {
|
||||
struct FlxAnimationField {
|
||||
std::string_view Name;
|
||||
bool Persistent;
|
||||
ElxAnimValueType Type;
|
||||
SimpleDynamicTag Type;
|
||||
double X, Y, Z;
|
||||
std::string_view S;
|
||||
};
|
||||
@@ -184,21 +165,38 @@ struct FlxAnimationField {
|
||||
|
||||
class FlxAnimQueueDecoder {
|
||||
private:
|
||||
FlxStringDecoder Decoder;
|
||||
FlxStreamBuffer 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.
|
||||
//
|
||||
bool AtEOF() { return Decoder.at_eof(); }
|
||||
bool AtEOF() { return Decoder.empty(); }
|
||||
|
||||
// Read one animation step.
|
||||
//
|
||||
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);
|
||||
@@ -217,7 +215,7 @@ public:
|
||||
|
||||
class FlxAnimationStepDecoder {
|
||||
private:
|
||||
FlxStringDecoder Decoder;
|
||||
FlxStreamBuffer Decoder;
|
||||
|
||||
public:
|
||||
// Initialize the FlxAnimationStepDecoder from the FlxAnimationStepView.
|
||||
@@ -226,7 +224,7 @@ public:
|
||||
|
||||
// Return true if the parser has reached the end of the string.
|
||||
//
|
||||
bool AtEOF() { return Decoder.at_eof(); }
|
||||
bool AtEOF() { return Decoder.empty(); }
|
||||
|
||||
// Read one field.
|
||||
//
|
||||
@@ -234,7 +232,7 @@ public:
|
||||
|
||||
// Convert an AnimStep to an FString.
|
||||
//
|
||||
static FString DebugString(uint64 hash, std::string_view body);
|
||||
static FString DebugString(bool injectidle, bool persistentonly, uint64 hash, std::string_view body);
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////
|
||||
@@ -257,26 +255,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.
|
||||
//
|
||||
@@ -284,6 +267,10 @@ public:
|
||||
//
|
||||
FlxAnimTracker();
|
||||
|
||||
// Clear everything, reset to the initial state.
|
||||
//
|
||||
void Clear();
|
||||
|
||||
// Update from the specified animation queue.
|
||||
//
|
||||
// After the update is done, AQ will be a copy
|
||||
@@ -291,24 +278,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; }
|
||||
};
|
||||
Reference in New Issue
Block a user