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

Conversation

lsemp3d
Copy link
Contributor

@lsemp3d lsemp3d commented Dec 8, 2024

What does this PR do?

The MovieSystem is still using the legacy paradigm of keeping global pointers in gEnv, this creates a tight coupling that is undesirable given O3DE's modular design. This is the first part of a refactor that aims to move the MovieSystem entirely proviedd by a gem and all the legacy code moved out of Legacy/CryCommon

Removed the global pointer to IMovieSystem and replaced it with an EBus call, this decouples the MovieSystem from the Editor itself and allows it to be provided by a gem, in this case the Maestro gem which creates the MovieSystem in its system component.

While this does not entirely decouple the movie system from the editor, it's a step in that direction. Next step will be for the MovieSystem to receive update events rather than having them called directly from the editor.

How was this PR tested?

Used TrackView to make a simple sequence that moved and rotated an entity.

@lsemp3d lsemp3d requested review from a team as code owners December 8, 2024 20:46
@lsemp3d lsemp3d added the feature/trackview This item is related to the Trackview and cinematic feature. label Dec 8, 2024
@@ -241,6 +241,9 @@ CSystem::CSystem()
#endif

m_ConfigPlatform = CONFIG_INVALID_PLATFORM;

m_movieSystem = nullptr;
Maestro::MovieSystemRequestBus::BroadcastResult(m_movieSystem, &Maestro::MovieSystemRequestBus::Events::GetMovieSystem);
Copy link
Contributor

Choose a reason for hiding this comment

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

I expect CrySystem/System to be init super early, we're sure that we won't end up in a case where m_movieSystem is always nullptr because Maestro hasn't been init ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It gets set during OnCrySystemInitialized which is also where gEnv->pMovieSystem was being populated before, the behavior/timing did not change

Signed-off-by: Luis Sempé <[email protected]>
Maestro::MovieSystemRequestBus::BroadcastResult(movieSystem, &Maestro::MovieSystemRequestBus::Events::GetMovieSystem);

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?

Signed-off-by: Luis Sempé <[email protected]>
Signed-off-by: Luis Sempé <[email protected]>
Copy link
Contributor

@spham-amzn spham-amzn left a comment

Choose a reason for hiding this comment

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

Great!

@lsemp3d lsemp3d merged commit b930f00 into o3de:development Dec 10, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature/trackview This item is related to the Trackview and cinematic feature.
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants