Skip to content

Commit

Permalink
Fixes for rendering TrackView sequences
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeykostin committed Dec 9, 2024
1 parent 6933b66 commit 8330691
Show file tree
Hide file tree
Showing 17 changed files with 384 additions and 176 deletions.
6 changes: 5 additions & 1 deletion Code/Editor/TrackView/AtomOutputFrameCapture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ namespace TrackView
pipelineDesc.m_mainViewTagName = "MainCamera"; // must be "MainCamera"
pipelineDesc.m_name = pipelineName;
pipelineDesc.m_rootPassTemplate = "MainPipelineRenderToTexture";
pipelineDesc.m_renderSettings.m_multisampleState.m_samples = 4;
pipelineDesc.m_renderSettings.m_multisampleState.m_samples = 2;
m_renderPipeline = AZ::RPI::RenderPipeline::CreateRenderPipeline(pipelineDesc);

if (auto renderToTexturePass = azrtti_cast<AZ::RPI::RenderToTexturePass*>(m_renderPipeline->GetRootPass().get()))
Expand All @@ -54,6 +54,8 @@ namespace TrackView
// This will be set again to mimic the active camera in UpdateView
fp->SetViewAlias(m_view, m_targetView);
}

m_pipelineCreated = true;
}

void AtomOutputFrameCapture::DestroyPipeline(AZ::RPI::Scene& scene)
Expand All @@ -68,6 +70,8 @@ namespace TrackView
m_renderPipeline.reset();
m_view.reset();
m_targetView.reset();

m_pipelineCreated = false;
}

void AtomOutputFrameCapture::UpdateView(const AZ::Matrix3x4& cameraTransform, const AZ::Matrix4x4& cameraProjection, const AZ::RPI::ViewPtr targetView)
Expand Down
4 changes: 4 additions & 0 deletions Code/Editor/TrackView/AtomOutputFrameCapture.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ namespace TrackView
//! @note scene must be the same scene used to create the pipeline.
void DestroyPipeline(AZ::RPI::Scene& scene);

bool IsCreated() const { return m_pipelineCreated; }

//! Request a capture to start.
//! @param attachmentReadbackCallback Handles the returned attachment (image data returned by the renderer).
//! @param captureFinishedCallback Logic to run once the capture has completed fully.
Expand All @@ -48,6 +50,8 @@ namespace TrackView
AZStd::vector<AZStd::string> m_passHierarchy; //!< Pass hierarchy (includes pipelineName and CopyToSwapChain).
CaptureFinishedCallback m_captureFinishedCallback; //!< Stored callback called from OnCaptureFinished.

bool m_pipelineCreated = false;

// FrameCaptureNotificationBus overrides ...
void OnFrameCaptureFinished(AZ::Render::FrameCaptureResult result, const AZStd::string& info) override;
};
Expand Down
244 changes: 127 additions & 117 deletions Code/Editor/TrackView/SequenceBatchRenderDialog.cpp

Large diffs are not rendered by default.

68 changes: 27 additions & 41 deletions Code/Editor/TrackView/SequenceBatchRenderDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ class CSequenceBatchRenderDialog
Range frameRange;
int resW, resH;
int fps;
QString seqName;
QString folder;
QString imageFormat;
QString prefix;
Expand All @@ -98,8 +99,10 @@ class CSequenceBatchRenderDialog
if (pSequence == item.pSequence
&& pDirectorNode == item.pDirectorNode
&& frameRange == item.frameRange
&& resW == item.resW && resH == item.resH
&& resW == item.resW
&& resH == item.resH
&& fps == item.fps
&& seqName == item.seqName
&& folder == item.folder
&& prefix == item.prefix
&& cvars == item.cvars
Expand All @@ -109,10 +112,7 @@ class CSequenceBatchRenderDialog
{
return true;
}
else
{
return false;
}
return false;
}
};
std::vector<SRenderItem> m_renderItems;
Expand All @@ -132,49 +132,32 @@ class CSequenceBatchRenderDialog

struct SRenderContext
{
int currentItemIndex;
float expectedTotalTime;
float spentTime;
int flagBU;
int currentItemIndex = -1;
float expectedTotalTime{};
float spentTime{};
int flagBU{};
Range rangeBU;
int cvarCustomResWidthBU, cvarCustomResHeightBU;
int cvarDisplayInfoBU;
int framesSpentInCurrentPhase;
IAnimNode* pActiveDirectorBU;
ICaptureKey captureOptions;
bool processingFFMPEG;
int cvarDisplayInfoBU{};
int framesSpentInCurrentPhase{};
IAnimNode* pActiveDirectorBU{};
ICaptureKey captureOptions{};
bool processingFFMPEG{};
// Signals when an mpeg is finished being processed.
QFutureWatcher<void> processingFFMPEGWatcher;
// True if the user canceled a render.
bool canceled;
bool canceled{};
// The sequence that triggered the CaptureState::Ending.
IAnimSequence* endingSequence;
IAnimSequence* endingSequence{};
// Current capture state.
CaptureState captureState;
CaptureState captureState = CaptureState::Idle;
// Is an individual frame currently being captured.
bool capturingFrame;
bool capturingFrame{};
// Current frame being captured
int frameNumber;

bool IsInRendering() const
{ return currentItemIndex >= 0; }

SRenderContext()
: currentItemIndex(-1)
, expectedTotalTime(0)
, spentTime(0)
, flagBU(0)
, pActiveDirectorBU(nullptr)
, cvarCustomResWidthBU(0)
, cvarCustomResHeightBU(0)
, cvarDisplayInfoBU(0)
, framesSpentInCurrentPhase(0)
, processingFFMPEG(false)
, canceled(false)
, endingSequence(nullptr)
, captureState(CaptureState::Idle)
, capturingFrame(false)
, frameNumber(0) {}
int frameNumber{};

bool IsInRendering() const { return currentItemIndex >= 0; }

SRenderContext() {}
};
SRenderContext m_renderContext;

Expand Down Expand Up @@ -220,14 +203,17 @@ protected slots:

private:
void CheckForEnableUpdateButton();
void stashActiveViewportResolution();
void StashActiveViewportResolution();
void UpdateSpinnerProgressMessage(const char* description);
void EnterCaptureState(CaptureState captureState);
void SetEnableEditorIdleProcessing(bool enabled);

void UpdateAtomOutputFrameCaptureView(const int width, const int height);

QScopedPointer<Ui::SequenceBatchRenderDialog> m_ui;
QStringListModel* m_renderListModel;
QTimer m_renderTimer;
ICVar* m_skipFramesCount;
bool m_editorIdleProcessingEnabled;
int32 CV_TrackViewRenderOutputCapturing;
QScopedPointer<CPrefixValidator> m_prefixValidator;
Expand Down
9 changes: 8 additions & 1 deletion Code/Editor/TrackView/TrackViewAnimNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1031,9 +1031,16 @@ void CTrackViewAnimNode::SetNodeEntityId(const AZ::EntityId entityId)
AZ::EntityId sequenceComponentEntityId(m_animSequence->GetSequenceEntityId());

// Notify the SequenceComponent that we're binding an entity to the sequence
Maestro::EditorSequenceComponentRequestBus::Event(
bool wasInvoked = false;
Maestro::EditorSequenceComponentRequestBus::EventResult(
wasInvoked,
sequenceComponentEntityId, &Maestro::EditorSequenceComponentRequestBus::Events::AddEntityToAnimate, entityId);

AZ_Info(
"CTrackViewAnimNode::SetNodeEntityId", "AddEntityToAnimate %s sequenceComponentEntityId %s was invoked %s", entityId.ToString().c_str(),
sequenceComponentEntityId.ToString().c_str(),
wasInvoked ? "true" : "false");

if (entityId != m_animNode->GetAzEntityId())
{
if (m_animNode->GetAzEntityId().IsValid())
Expand Down
10 changes: 9 additions & 1 deletion Code/Legacy/CryCommon/IMovieSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,15 @@ struct IAnimSequence
eSeqFlags_DisplayAsFramesOrSeconds = BIT(18), //!< Display Start/End time as frames or seconds
};

virtual ~IAnimSequence() {};
IAnimSequence()
{
AZ_Info("IAnimSequence", "IAnimSequence");
}

virtual ~IAnimSequence()
{
AZ_Info("IAnimSequence", "~IAnimSequence");
}

// for intrusive_ptr support
virtual void add_ref() = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ namespace Maestro
//////////////////////////////////////////////////////////////////////////

//! Adds an entity to be animated
virtual void AddEntityToAnimate(AZ::EntityId entityToAnimate) = 0;
virtual bool AddEntityToAnimate(AZ::EntityId entityToAnimate) = 0;

//! Remove EntityToAnimate
virtual void RemoveEntityToAnimate(AZ::EntityId removedEntityId) = 0;
Expand Down
2 changes: 1 addition & 1 deletion Code/Legacy/CryCommon/Maestro/Bus/SequenceComponentBus.h
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,7 @@ namespace Maestro
* @param animatedEntityId the entity Id of the entity containing the animatedAddress
* @param animatedAddress identifies the component and property to be set
*/
virtual void GetAnimatedPropertyValue(AnimatedValue& returnValue, const AZ::EntityId& animatedEntityId, const AnimatablePropertyAddress& animatableAddress) = 0;
virtual bool GetAnimatedPropertyValue(AnimatedValue& returnValue, const AZ::EntityId& animatedEntityId, const AnimatablePropertyAddress& animatableAddress) = 0;

/** Returns the Uuid of the type for the property at the animatableAddress on the given entityId
*/
Expand Down
10 changes: 9 additions & 1 deletion Gems/Maestro/Code/Source/Cinematics/AnimComponentNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -914,7 +914,15 @@ void CAnimComponentNode::Animate(SAnimContext& ac)

Maestro::SequenceComponentRequests::AnimatedVector3Value value(vec);
Maestro::SequenceComponentRequests::AnimatedVector3Value prevValue(vec);
Maestro::SequenceComponentRequestBus::Event(m_pSequence->GetSequenceEntityId(), &Maestro::SequenceComponentRequestBus::Events::GetAnimatedPropertyValue, prevValue, GetParentAzEntityId(), animatableAddress);
bool wasInvoked = false;
const AZ::EntityId& sequenceEntityId = m_pSequence->GetSequenceEntityId();
Maestro::SequenceComponentRequestBus::EventResult(wasInvoked, sequenceEntityId, &Maestro::SequenceComponentRequestBus::Events::GetAnimatedPropertyValue, prevValue, GetParentAzEntityId(), animatableAddress);

if (!wasInvoked)
{
AZ_Info("CAnimComponentNode::Animate", "GetAnimatedPropertyValue failed for %s", sequenceEntityId.ToString().c_str());
}

AZ::Vector3 vector3PrevValue;
prevValue.GetValue(vector3PrevValue);

Expand Down
3 changes: 3 additions & 0 deletions Gems/Maestro/Code/Source/Cinematics/AnimNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -901,6 +901,9 @@ void CAnimNode::Serialize(XmlNodeRef& xmlNode, bool bLoading, bool bLoadEmptyTra
//////////////////////////////////////////////////////////////////////////
void CAnimNode::InitPostLoad(IAnimSequence* sequence)
{
[[maybe_unused]]const AZ::EntityId& sequenceEntityId = sequence->GetSequenceEntityId();
AZ_Info("CAnimNode::InitPostLoad", "IAnimSequence is %s", sequenceEntityId.ToString().c_str());

m_pSequence = sequence;
m_pParentNode = ((CAnimSequence*)m_pSequence)->FindNodeById(m_parentNodeId);

Expand Down
Loading

0 comments on commit 8330691

Please sign in to comment.