Files
Cog/Source/CogSample/CogSampleAnimNotifyState.cpp
Arnaud Jamin 6d9494b685 Major Change - Rework how Cog gets integrated
Cog integration has been reworked to make it easier,  to keep Cog available between level loadings, and to properly tick ImGui while the game is paused.
Cog 's WindowManager is now a GameInstanceSubsystem.
The WindowManager ticks ImGui and the windows during the OnWorldPostActorTick delegate.
(If this is not working for your project, don't hesitate to open an issue.)

Check the readme to see how to integrate Cog.

The Plot debug functions (displayed by the Engine/Plot window) have been reworked as they were not properly working in Multi PIE in Single Process.

API changes:
- use FCogDebug::Plot instead of FCogDebugPlot::PlotValue
- use FCogDebug::InstantEvent  instead of FCogDebugPlot::PlotEventInstant
- use FCogDebug::StartEvent instead of FCogDebugPlot::PlotEventStart
- use FCogDebug::StopEvent instead of FCogDebugPlot::PlotEventStop
2025-02-11 13:29:12 -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 "CogDebug.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
FCogDebug::StartEvent(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
FCogDebug::StopEvent(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;
}