Missing Animation Curves in Cooked Builds

We are noticing our animation curves in 4.17.2 is being dropped in cooked builds. I came across this piece of code in AnimSequence which clears the animation curves before serializing and then put back the curves. We basically disabled this portion of the code and now our animation curves came back in cooked builds. Is there another way to put in animation curves? Are we missing a step for cooking animation curves? Or is this the plan to not use animation curves?

thanks
–bill

void UAnimSequence::Serialize(FArchive& Ar)
{
	Ar.UsingCustomVersion(FFrameworkObjectVersion::GUID);

	FRawCurveTracks RawCurveCache;

	if (Ar.IsCooking())
	{
		RawCurveCache.FloatCurves = MoveTemp(RawCurveData.FloatCurves);
		RawCurveData.FloatCurves.Reset();

#if WITH_EDITORONLY_DATA
		RawCurveCache.VectorCurves = MoveTemp(RawCurveData.VectorCurves);
		RawCurveData.VectorCurves.Reset();

		RawCurveCache.TransformCurves = MoveTemp(RawCurveData.TransformCurves);
		RawCurveData.TransformCurves.Reset();
#endif
	}

	Super::Serialize(Ar);

	if (Ar.IsCooking())
	{
		RawCurveData.FloatCurves = MoveTemp(RawCurveCache.FloatCurves);
#if WITH_EDITORONLY_DATA
		RawCurveData.VectorCurves = MoveTemp(RawCurveCache.VectorCurves);
		RawCurveData.TransformCurves = MoveTemp(RawCurveCache.TransformCurves);
#endif
	}

Nevermind. I found out that there was an accessor function (UAnimSequence::GetCurveData) that we have to go through to get the curves which decides if it gets the raw curve or the compressed curve.

Thanks!

Thanks, this helped me out.

I ran into this Issue recently when i was testing various Animations in a Cooked Build:

Turns out i was getting the Data using Animation->RawCurveData which directly uses the Raw Curve, though this won’t work in Cooked Builds anymore so you have to use Animation->GetCurveData() which takes care of choosing between CompressedCurveData or RawCurveData, as example to access the Curve it could look like this:

(Animation->GetCurveData().GetCurveData(Uid));

for me GetCurveData() returns an empty array in cooked builds UE4.22

i’m trying to get curve keys from an UAnimSequence with following code

Sequence->GetCurveData().GetCurveData(Uid)

did i miss something?

AnimSequenceBase.h line107 looks like this it just returns RawCurveData:

virtual const FRawCurveTracks& GetCurveData() const { return RawCurveData; }

In 4.22, they removed CompressedCurveData. Seems like it might be related to your issue, but I’m not sure.

Yes looked through the commits, its now a byte Stream.

 TArray<uint8> CompressedCurveByteStream;

Hello, is anybody managed to get curve in packaged build? (GetCurveData doesn’t work for me)

For finding a curve value at a specific time i use something like this, maybe this helps you out. (Works in a Shipping build).

void yourfunction (UAnimSequence* Sequence, FName CurveName){
    
    		USkeleton* Skeleton = Sequence->GetSkeleton();
    
    		const FSmartNameMapping* NameMapping = Skeleton->GetSmartNameContainer(USkeleton::AnimCurveMappingName);
    
    		USkeleton::AnimCurveUID Uid;
    		Uid = NameMapping->FindUID(CurveName);
    
                   float value = Sequence->EvaluateCurveData(Uid, <TIME>);
    
    }