Files
Cog/Source/CogSample/CogSampleAnimNotifyState.cpp
T
Arnaud Jamin 2f1361a412 CogEngine: Fix and improve Plot window
CogEngine: Fix and improve the Plot window
- Fix ImPlot assert
- Improve UI

CogSample:
-  Add Inputs and AnimNotify plot events
- Fix ability system warning
2025-01-11 00:31:53 -05:00

87 lines
4.1 KiB
C++

#include "CogSampleAnimNotifyState.h"
#include "CogCommon.h"
#include "Animation/AnimNotifies/AnimNotify.h"
#include "Animation/AnimNotifyEndDataContext.h"
#include "Animation/AnimSequenceBase.h"
#include "Components/SkeletalMeshComponent.h"
#if ENABLE_COG
#include "CogDebugPlot.h"
#endif
//--------------------------------------------------------------------------------------------------------------------------
UCogSampleAnimNotifyState::UCogSampleAnimNotifyState(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
{
bIsNativeBranchingPoint = false;
}
//--------------------------------------------------------------------------------------------------------------------------
void UCogSampleAnimNotifyState::NotifyBegin(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation, float TotalDuration, const FAnimNotifyEventReference& EventReference)
{
#if ENABLE_COG
FCogDebugPlot::PlotEventStart(MeshComp->GetOwner(), "Anim Notify", GetFName())
.AddParam("Name", GetNameSafe(this))
.AddParam("Animation", GetNameSafe(Animation))
.AddParam("Debug Info", GetDebugInfo());
#endif
Super::NotifyBegin(MeshComp, Animation, TotalDuration, EventReference);
}
//--------------------------------------------------------------------------------------------------------------------------
void UCogSampleAnimNotifyState::NotifyEnd(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation, const FAnimNotifyEventReference& EventReference)
{
#if ENABLE_COG
FCogDebugPlot::PlotEventStop(MeshComp->GetOwner(), "Anim Notify", GetFName());
#endif
Super::NotifyEnd(MeshComp, Animation, EventReference);
}
//--------------------------------------------------------------------------------------------------------------------------
void UCogSampleAnimNotifyState::BranchingPointNotifyBegin(FBranchingPointNotifyPayload& BranchingPointPayload)
{
//--------------------------------------------------------------------------------------------------------
// Replace UAnimNotifyState::BranchingPointNotifyBegin to fill the EventReference with the NotifyEvent for
// UGPCoreAnimMotifyFunctionLibrary::AnimNotifyEventReferenceGetMontage to work properly
//--------------------------------------------------------------------------------------------------------
// Super::BranchingPointNotifyBegin(BranchingPointPayload);
const FAnimNotifyEventReference EventReference(BranchingPointPayload.NotifyEvent,
BranchingPointPayload.SequenceAsset);
NotifyBegin(BranchingPointPayload.SkelMeshComponent,
BranchingPointPayload.SequenceAsset,
BranchingPointPayload.NotifyEvent
? BranchingPointPayload.NotifyEvent->GetDuration()
: 0.f,
EventReference);
}
//--------------------------------------------------------------------------------------------------------------------------
void UCogSampleAnimNotifyState::BranchingPointNotifyEnd(FBranchingPointNotifyPayload& BranchingPointPayload)
{
//--------------------------------------------------------------------------------------------------------
// Replace UAnimNotifyState::BranchingPointNotifyEnd to fill the EventReference with the NotifyEvent for
// UGPCoreAnimMotifyFunctionLibrary::AnimNotifyEventReferenceGetMontage to work properly
//--------------------------------------------------------------------------------------------------------
// Super::BranchingPointNotifyEnd(BranchingPointPayload);
FAnimNotifyEventReference EventReference(BranchingPointPayload.NotifyEvent, BranchingPointPayload.SequenceAsset);
if (BranchingPointPayload.bReachedEnd)
{
EventReference.AddContextData<UE::Anim::FAnimNotifyEndDataContext>(true);
}
NotifyEnd(BranchingPointPayload.SkelMeshComponent, BranchingPointPayload.SequenceAsset, EventReference);
}
//--------------------------------------------------------------------------------------------------------------------------
FString UCogSampleAnimNotifyState::GetDebugInfo_Implementation() const
{
FString DebugInfo;
return DebugInfo;
}