Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring the MovieSystem so that it may be moved into a gem #18541

Merged
merged 8 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Changed EBus into AZ::Interface
Signed-off-by: Luis Sempé <[email protected]>
  • Loading branch information
l-sempe committed Dec 10, 2024
commit 4ce596effb07f5ed229517a61bb440608aed6137
4 changes: 2 additions & 2 deletions Code/Editor/AnimationContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ class CAnimationContextPostRender
};

//////////////////////////////////////////////////////////////////////////
CAnimationContext::CAnimationContext(IMovieSystem* movieSystem)
: m_movieSystem(movieSystem)
CAnimationContext::CAnimationContext()
: m_movieSystem(AZ::Interface<IMovieSystem>::Get())
{
m_paused = 0;
m_playing = false;
Expand Down
2 changes: 1 addition & 1 deletion Code/Editor/AnimationContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class CAnimationContext
//////////////////////////////////////////////////////////////////////////
/** Constructor.
*/
CAnimationContext(IMovieSystem* movieSystem);
CAnimationContext();
~CAnimationContext();

//////////////////////////////////////////////////////////////////////////
Expand Down
4 changes: 1 addition & 3 deletions Code/Editor/CryEditDoc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
#include "MainWindow.h"
#include "LevelFileDialog.h"
#include "Undo/Undo.h"
#include "Maestro/Bus/MovieSystemBus.h"

#include <Atom/RPI.Public/ViewportContext.h>
#include <Atom/RPI.Public/ViewportContextBus.h>
Expand Down Expand Up @@ -280,8 +279,7 @@ void CCryEditDoc::Load(TDocMultiArchive& /* arrXmlAr */, const QString& szFilena

GetIEditor()->Notify(eNotify_OnBeginSceneOpen);

IMovieSystem* movieSystem = nullptr;
Maestro::MovieSystemRequestBus::BroadcastResult(movieSystem, &Maestro::MovieSystemRequestBus::Events::GetMovieSystem);
IMovieSystem* movieSystem = AZ::Interface<IMovieSystem>::Get();
if (movieSystem)
{
movieSystem->RemoveAllSequences();
Expand Down
16 changes: 5 additions & 11 deletions Code/Editor/GameEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@

// CryCommon
#include <CryCommon/MainThreadRenderRequestBus.h>
#include <Maestro/Bus/MovieSystemBus.h>

// Editor
#include "CryEdit.h"
Expand Down Expand Up @@ -244,8 +243,7 @@ CGameEngine::~CGameEngine()
AZ_POP_DISABLE_WARNING
GetIEditor()->UnregisterNotifyListener(this);

IMovieSystem* movieSystem = nullptr;
Maestro::MovieSystemRequestBus::BroadcastResult(movieSystem, &Maestro::MovieSystemRequestBus::Events::GetMovieSystem);
IMovieSystem* movieSystem = AZ::Interface<IMovieSystem>::Get();
if (movieSystem)
{
movieSystem->SetCallback(nullptr);
Expand Down Expand Up @@ -414,8 +412,7 @@ AZ::Outcome<void, AZStd::string> CGameEngine::Init(

SetEditorCoreEnvironment(gEnv);

IMovieSystem* movieSystem = nullptr;
Maestro::MovieSystemRequestBus::BroadcastResult(movieSystem, &Maestro::MovieSystemRequestBus::Events::GetMovieSystem);
IMovieSystem* movieSystem = AZ::Interface<IMovieSystem>::Get();
if (movieSystem)
{
movieSystem->EnablePhysicsEvents(m_bSimulationMode);
Expand Down Expand Up @@ -506,8 +503,7 @@ void CGameEngine::SwitchToInGame()

GetIEditor()->Notify(eNotify_OnBeginGameMode);

IMovieSystem* movieSystem = nullptr;
Maestro::MovieSystemRequestBus::BroadcastResult(movieSystem, &Maestro::MovieSystemRequestBus::Events::GetMovieSystem);
IMovieSystem* movieSystem = AZ::Interface<IMovieSystem>::Get();
if (movieSystem)
{
movieSystem->EnablePhysicsEvents(true);
Expand Down Expand Up @@ -542,8 +538,7 @@ void CGameEngine::SwitchToInEditor()
AzToolsFramework::EditorEntityContextRequestBus::Broadcast(&AzToolsFramework::EditorEntityContextRequestBus::Events::StopPlayInEditor);

// Reset movie system
IMovieSystem* movieSystem = nullptr;
Maestro::MovieSystemRequestBus::BroadcastResult(movieSystem, &Maestro::MovieSystemRequestBus::Events::GetMovieSystem);
IMovieSystem* movieSystem = AZ::Interface<IMovieSystem>::Get();
if (movieSystem)
{
for (int i = movieSystem->GetNumPlayingSequences(); --i >= 0;)
Expand Down Expand Up @@ -664,8 +659,7 @@ void CGameEngine::SetSimulationMode(bool enabled, bool bOnlyPhysics)
return;
}

IMovieSystem* movieSystem = nullptr;
Maestro::MovieSystemRequestBus::BroadcastResult(movieSystem, &Maestro::MovieSystemRequestBus::Events::GetMovieSystem);
IMovieSystem* movieSystem = AZ::Interface<IMovieSystem>::Get();
if (movieSystem)
{
movieSystem->EnablePhysicsEvents(enabled);
Expand Down
6 changes: 1 addition & 5 deletions Code/Editor/IEditorImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@

#include "Core/QtEditorApplication.h" // for Editor::EditorQtApplication

#include <CryCommon/Maestro/Bus/MovieSystemBus.h>

static CCryEditDoc * theDocument;
#include <QMimeData>
#include <QMessageBox>
Expand Down Expand Up @@ -127,9 +125,7 @@ CEditorImpl::CEditorImpl()
m_pToolBoxManager = new CToolBoxManager;
m_pSequenceManager = new CTrackViewSequenceManager;

IMovieSystem* movieSystem = nullptr;
Maestro::MovieSystemRequestBus::BroadcastResult(movieSystem, &Maestro::MovieSystemRequestBus::Events::GetMovieSystem);
m_pAnimationContext = new CAnimationContext(movieSystem);
m_pAnimationContext = new CAnimationContext;

DetectVersion();
RegisterTools();
Expand Down
4 changes: 1 addition & 3 deletions Code/Editor/SelectLightAnimationDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

// CryCommon
#include <CryCommon/Maestro/Types/AnimNodeType.h> // for AnimNodeType
#include <CryCommon/Maestro/Bus/MovieSystemBus.h>

//////////////////////////////////////////////////////////////////////////
CSelectLightAnimationDialog::CSelectLightAnimationDialog(QWidget* pParent)
Expand All @@ -35,8 +34,7 @@ void CSelectLightAnimationDialog::OnInitDialog()
//////////////////////////////////////////////////////////////////////////
void CSelectLightAnimationDialog::GetItems(std::vector<SItem>& outItems)
{
IMovieSystem* movieSystem = nullptr;
Maestro::MovieSystemRequestBus::BroadcastResult(movieSystem, &Maestro::MovieSystemRequestBus::Events::GetMovieSystem);
IMovieSystem* movieSystem = AZ::Interface<IMovieSystem>::Get();
if (!movieSystem)
{
return;
Expand Down
5 changes: 1 addition & 4 deletions Code/Editor/SelectSequenceDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include "EditorDefs.h"

#include "SelectSequenceDialog.h"
#include <Maestro/Bus/MovieSystemBus.h>

// CSelectSequence dialog

Expand All @@ -33,9 +32,7 @@ CSelectSequenceDialog::OnInitDialog()
/* virtual */ void
CSelectSequenceDialog::GetItems(std::vector<SItem>& outItems)
{
IMovieSystem* movieSystem = nullptr;
Maestro::MovieSystemRequestBus::BroadcastResult(movieSystem, &Maestro::MovieSystemRequestBus::Events::GetMovieSystem);

IMovieSystem* movieSystem = AZ::Interface<IMovieSystem>::Get();
if (movieSystem)
{
for (int i = 0; i < movieSystem->GetNumSequences(); ++i)
Expand Down
4 changes: 1 addition & 3 deletions Code/Editor/TrackView/SelectKeyUIControls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#include <AzCore/Component/EntityBus.h> // for AZ::EntitySystemBus
#include <AzFramework/Components/CameraBus.h> // for Camera::CameraNotificationBus
#include <CryCommon/Maestro/Types/AnimValueType.h> // for AnimValueType
#include <Maestro/Bus/MovieSystemBus.h>

CSelectKeyUIControls::~CSelectKeyUIControls()
{
Expand Down Expand Up @@ -116,8 +115,7 @@ void CSelectKeyUIControls::OnUIChange(IVariable* pVar, CTrackViewKeyBundle& sele

if (!selectKey.szSelection.empty())
{
IMovieSystem* movieSystem = nullptr;
Maestro::MovieSystemRequestBus::BroadcastResult(movieSystem, &Maestro::MovieSystemRequestBus::Events::GetMovieSystem);
IMovieSystem* movieSystem = AZ::Interface<IMovieSystem>::Get();
if (movieSystem)
{
IAnimSequence* pSequence = movieSystem->FindLegacySequenceByName(selectKey.szSelection.c_str());
Expand Down
43 changes: 13 additions & 30 deletions Code/Editor/TrackView/SequenceBatchRenderDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@

// CryCommon
#include <CryCommon/Maestro/Types/AnimNodeType.h>
#include <CryCommon/Maestro/Bus/MovieSystemBus.h>

// Editor
#include "MainWindow.h"
Expand Down Expand Up @@ -190,9 +189,8 @@ void CSequenceBatchRenderDialog::OnInitDialog()

// Fill the sequence combo box.
bool activeSequenceWasSet = false;
IMovieSystem* movieSystem = nullptr;
Maestro::MovieSystemRequestBus::BroadcastResult(movieSystem, &Maestro::MovieSystemRequestBus::Events::GetMovieSystem);

IMovieSystem* movieSystem = AZ::Interface<IMovieSystem>::Get();
if (movieSystem)
{
for (int k = 0; k < movieSystem->GetNumSequences(); ++k)
Expand Down Expand Up @@ -542,9 +540,7 @@ void CSequenceBatchRenderDialog::OnGo()
m_ui->m_pGoBtn->setIcon(QPixmap(":/Trackview/clapperboard_cancel.png"));
// Inform the movie system that it soon will be in a batch-rendering mode.

IMovieSystem* movieSystem = nullptr;
Maestro::MovieSystemRequestBus::BroadcastResult(movieSystem, &Maestro::MovieSystemRequestBus::Events::GetMovieSystem);

IMovieSystem* movieSystem = AZ::Interface<IMovieSystem>::Get();
if (movieSystem)
{
movieSystem->EnableBatchRenderMode(true);
Expand Down Expand Up @@ -606,8 +602,7 @@ void CSequenceBatchRenderDialog::OnSequenceSelected()
{
// Get the selected sequence.
const QString seqName = m_ui->m_sequenceCombo->currentText();
IMovieSystem* movieSystem = nullptr;
Maestro::MovieSystemRequestBus::BroadcastResult(movieSystem, &Maestro::MovieSystemRequestBus::Events::GetMovieSystem);
IMovieSystem* movieSystem = AZ::Interface<IMovieSystem>::Get();

IAnimSequence* pSequence = movieSystem ? movieSystem->FindLegacySequenceByName(seqName.toUtf8().data()) : nullptr;
if (pSequence)
Expand Down Expand Up @@ -1014,8 +1009,7 @@ void CSequenceBatchRenderDialog::CaptureItemStart()
*TrackView::SceneFromGameEntityContext(), "TrackViewSequencePipeline", renderItem.resW, renderItem.resH);
UpdateAtomOutputFrameCaptureView(m_atomOutputFrameCapture, renderItem.resW, renderItem.resH);

IMovieSystem* movieSystem = nullptr;
Maestro::MovieSystemRequestBus::BroadcastResult(movieSystem, &Maestro::MovieSystemRequestBus::Events::GetMovieSystem);
IMovieSystem* movieSystem = AZ::Interface<IMovieSystem>::Get();
if (movieSystem)
{
movieSystem->EnableFixedStepForCapture(m_renderContext.captureOptions.timeStep);
Expand Down Expand Up @@ -1054,8 +1048,7 @@ void CSequenceBatchRenderDialog::OnUpdateEnteringGameMode()
// Pause the movie player on the first frame
if (m_renderContext.framesSpentInCurrentPhase++ == 0)
{
IMovieSystem* movieSystem = nullptr;
Maestro::MovieSystemRequestBus::BroadcastResult(movieSystem, &Maestro::MovieSystemRequestBus::Events::GetMovieSystem);
IMovieSystem* movieSystem = AZ::Interface<IMovieSystem>::Get();
if (movieSystem)
{
movieSystem->Pause();
Expand All @@ -1074,8 +1067,7 @@ void CSequenceBatchRenderDialog::OnUpdateBeginPlayingSequence()

SRenderItem renderItem = m_renderItems[m_renderContext.currentItemIndex];

IMovieSystem* movieSystem = nullptr;
Maestro::MovieSystemRequestBus::BroadcastResult(movieSystem, &Maestro::MovieSystemRequestBus::Events::GetMovieSystem);
IMovieSystem* movieSystem = AZ::Interface<IMovieSystem>::Get();
if (movieSystem)
{
movieSystem->AddMovieListener(renderItem.pSequence, this);
Expand Down Expand Up @@ -1114,8 +1106,7 @@ void CSequenceBatchRenderDialog::OnUpdateCapturing()
IAnimSequence* pCurSeq = m_renderItems[m_renderContext.currentItemIndex].pSequence;
Range rng = pCurSeq->GetTimeRange();

IMovieSystem* movieSystem = nullptr;
Maestro::MovieSystemRequestBus::BroadcastResult(movieSystem, &Maestro::MovieSystemRequestBus::Events::GetMovieSystem);
IMovieSystem* movieSystem = AZ::Interface<IMovieSystem>::Get();

float elapsedTime = movieSystem ? movieSystem->GetPlayingTime(pCurSeq) - rng.start : 0.f;
int percentage = int(100.0f * (m_renderContext.spentTime + elapsedTime) / m_renderContext.expectedTotalTime);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we protect against a divide by zero here?

Expand All @@ -1131,9 +1122,7 @@ void CSequenceBatchRenderDialog::OnUpdateCapturing()

void CSequenceBatchRenderDialog::OnUpdateEnd(IAnimSequence* sequence)
{
IMovieSystem* movieSystem = nullptr;
Maestro::MovieSystemRequestBus::BroadcastResult(movieSystem, &Maestro::MovieSystemRequestBus::Events::GetMovieSystem);

IMovieSystem* movieSystem = AZ::Interface<IMovieSystem>::Get();
if (movieSystem)
{
movieSystem->DisableFixedStepForCapture();
Expand Down Expand Up @@ -1367,9 +1356,7 @@ void CSequenceBatchRenderDialog::OnKickIdle()

if (canBeginFrameCapture())
{
IMovieSystem* movieSystem = nullptr;
Maestro::MovieSystemRequestBus::BroadcastResult(movieSystem, &Maestro::MovieSystemRequestBus::Events::GetMovieSystem);

IMovieSystem* movieSystem = AZ::Interface<IMovieSystem>::Get();
if (movieSystem)
{
// update the time so the frame number can be calculated in StartCapture()
Expand Down Expand Up @@ -1400,8 +1387,7 @@ void CSequenceBatchRenderDialog::OnKickIdle()
m_renderContext.captureOptions.folder.c_str(), fileName.c_str(), filePath, /*caseInsensitive=*/true,
/*normalize=*/false);

IMovieSystem* movieSystem = nullptr;
Maestro::MovieSystemRequestBus::BroadcastResult(movieSystem, &Maestro::MovieSystemRequestBus::Events::GetMovieSystem);
IMovieSystem* movieSystem = AZ::Interface<IMovieSystem>::Get();

// track view callback after each frame is captured
const auto captureFinishedCallback = [this, movieSystem]()
Expand Down Expand Up @@ -1461,8 +1447,7 @@ void CSequenceBatchRenderDialog::OnCancelRender()
{
// In the capturing state, abort the sequence, OnMovieEvent with an abort will fire and cause
// the transition to CaptureState::End.
IMovieSystem* movieSystem = nullptr;
Maestro::MovieSystemRequestBus::BroadcastResult(movieSystem, &Maestro::MovieSystemRequestBus::Events::GetMovieSystem);
IMovieSystem* movieSystem = AZ::Interface<IMovieSystem>::Get();
if (movieSystem)
{
movieSystem->AbortSequence(m_renderItems[m_renderContext.currentItemIndex].pSequence);
Expand Down Expand Up @@ -1519,8 +1504,7 @@ void CSequenceBatchRenderDialog::OnLoadBatch()

OnClearRenderItems();

IMovieSystem* movieSystem = nullptr;
Maestro::MovieSystemRequestBus::BroadcastResult(movieSystem, &Maestro::MovieSystemRequestBus::Events::GetMovieSystem);
IMovieSystem* movieSystem = AZ::Interface<IMovieSystem>::Get();

for (int i = 0; i < batchRenderListNode->getChildCount(); ++i)
{
Expand Down Expand Up @@ -1657,8 +1641,7 @@ bool CSequenceBatchRenderDialog::SetUpNewRenderItem(SRenderItem& item)
return false;
}
// sequence
IMovieSystem* movieSystem = nullptr;
Maestro::MovieSystemRequestBus::BroadcastResult(movieSystem, &Maestro::MovieSystemRequestBus::Events::GetMovieSystem);
IMovieSystem* movieSystem = AZ::Interface<IMovieSystem>::Get();

item.pSequence = movieSystem ? movieSystem->FindLegacySequenceByName(seqName.toUtf8().data()) : nullptr;
assert(item.pSequence);
Expand Down
7 changes: 2 additions & 5 deletions Code/Editor/TrackView/SequenceKeyUIControls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

// CryCommon
#include <CryCommon/Maestro/Types/AnimParamType.h>
#include <Maestro/Bus/MovieSystemBus.h>

// Editor
#include "KeyUIControls.h"
Expand Down Expand Up @@ -68,8 +67,7 @@ bool CSequenceKeyUIControls::OnKeySelectionChange(const CTrackViewKeyBundle& sel
mv_overrideTimes = sequenceKey.bOverrideTimes;
if (!sequenceKey.bOverrideTimes)
{
IMovieSystem* movieSystem = nullptr;
Maestro::MovieSystemRequestBus::BroadcastResult(movieSystem, &Maestro::MovieSystemRequestBus::Events::GetMovieSystem);
IMovieSystem* movieSystem = AZ::Interface<IMovieSystem>::Get();
if (movieSystem)
{
IAnimSequence* pSequence2 = movieSystem->FindSequence(sequenceKey.sequenceEntityId);
Expand Down Expand Up @@ -110,8 +108,7 @@ void CSequenceKeyUIControls::OnUIChange(IVariable* pVar, CTrackViewKeyBundle& se
return;
}

IMovieSystem* movieSystem = nullptr;
Maestro::MovieSystemRequestBus::BroadcastResult(movieSystem, &Maestro::MovieSystemRequestBus::Events::GetMovieSystem);
IMovieSystem* movieSystem = AZ::Interface<IMovieSystem>::Get();

for (unsigned int keyIndex = 0; keyIndex < selectedKeys.GetKeyCount(); ++keyIndex)
{
Expand Down
16 changes: 5 additions & 11 deletions Code/Editor/TrackView/TrackViewAnimNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

// CryCommon
#include <CryCommon/Maestro/Bus/EditorSequenceComponentBus.h>
#include <CryCommon/Maestro/Bus/MovieSystemBus.h>
#include <CryCommon/Maestro/Types/AnimNodeType.h>
#include <CryCommon/Maestro/Types/AnimValueType.h>
#include <CryCommon/Maestro/Types/AnimParamType.h>
Expand Down Expand Up @@ -411,8 +410,7 @@ CTrackViewAnimNode* CTrackViewAnimNode::CreateSubNode(
{
if (!owner.IsValid())
{
IMovieSystem* movieSystem = nullptr;
Maestro::MovieSystemRequestBus::BroadcastResult(movieSystem, &Maestro::MovieSystemRequestBus::Events::GetMovieSystem);
IMovieSystem* movieSystem = AZ::Interface<IMovieSystem>::Get();
if (movieSystem)
{
movieSystem->LogUserNotificationMsg(
Expand Down Expand Up @@ -467,8 +465,7 @@ CTrackViewAnimNode* CTrackViewAnimNode::CreateSubNode(
// Show an error if this node is a duplicate
if (alreadyExists)
{
IMovieSystem* movieSystem = nullptr;
Maestro::MovieSystemRequestBus::BroadcastResult(movieSystem, &Maestro::MovieSystemRequestBus::Events::GetMovieSystem);
IMovieSystem* movieSystem = AZ::Interface<IMovieSystem>::Get();
if (movieSystem)
{
movieSystem->LogUserNotificationMsg(
Expand All @@ -489,8 +486,7 @@ CTrackViewAnimNode* CTrackViewAnimNode::CreateSubNode(
IAnimNode* newAnimNode = m_animSequence->CreateNode(animNodeType);
if (!newAnimNode)
{
IMovieSystem* movieSystem = nullptr;
Maestro::MovieSystemRequestBus::BroadcastResult(movieSystem, &Maestro::MovieSystemRequestBus::Events::GetMovieSystem);
IMovieSystem* movieSystem = AZ::Interface<IMovieSystem>::Get();
if (movieSystem)
{
movieSystem->LogUserNotificationMsg(
Expand Down Expand Up @@ -1277,8 +1273,7 @@ CTrackViewAnimNodeBundle CTrackViewAnimNode::AddSelectedEntities(const AZStd::ve
// If it has the same director than the current node, reject it
if (existingNode->GetDirector() == GetDirector())
{
IMovieSystem* movieSystem = nullptr;
Maestro::MovieSystemRequestBus::BroadcastResult(movieSystem, &Maestro::MovieSystemRequestBus::Events::GetMovieSystem);
IMovieSystem* movieSystem = AZ::Interface<IMovieSystem>::Get();
if (movieSystem)
{
movieSystem->LogUserNotificationMsg(AZStd::string::format(
Expand Down Expand Up @@ -1511,8 +1506,7 @@ void CTrackViewAnimNode::PasteNodeFromClipboard(AZStd::map<int, IAnimNode*>& cop
}

AnimNodeType nodeType = AnimNodeType::Invalid;
IMovieSystem* movieSystem = nullptr;
Maestro::MovieSystemRequestBus::BroadcastResult(movieSystem, &Maestro::MovieSystemRequestBus::Events::GetMovieSystem);
IMovieSystem* movieSystem = AZ::Interface<IMovieSystem>::Get();
if (movieSystem)
{
movieSystem->SerializeNodeType(nodeType, xmlNode, /*bLoading=*/ true, IAnimSequence::kSequenceVersion, m_animSequence->GetFlags());
Expand Down
Loading
Loading