Fix Cinematic initialization and serialization bugs #2560
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
Refactors and Improves the Cinematic class
This pull request enhances the
Cinematic
class, focusing on better documentation, serialization improvements, and memory management. Key updates include:SavableArrayList
serialization/deserialization.Application
field to the class, initialized duringinitialize()
and passed to event initialization for consistency.clearCameras()
method to properly detach and clear all camera nodes from the scene, now called fromcleanup()
to avoid memory leaks.initialized
flag, clearing events, and removing camera nodes.cinematicEvents
list non-final for deserialization.These changes improve maintainability, clarity, and the robustness of cinematic lifecycle management in the engine.
Enhance AnimEvent Serialization and Model Handling
This PR introduces improvements to the
AnimEvent
class in thecom.jme3.cinematic.events
package by enhancing how animation events are associated with their models and how they are serialized/deserialized. The changes ensure more robust handling ofAnimComposer
and the associatedSpatial
model, especially when saving and loading animation events.Key Changes
Introduced a
private Spatial model
field toAnimEvent
to keep track of the model associated with the animation event.model
field from theAnimComposer
.In
initEvent
, if thecomposer
is not set but themodel
is, the code attempts to retrieve the correctAnimComposer
from the model, ensuring reliable initialization even after deserialization.model
field is now written to and read from the JME capsules, replacing the direct serialization ofcinematic
andcomposer
fields (which are no longer serialized).Added a custom
dispose()
method to clean up references tocinematic
andcomposer
when the event is disposed, aiding memory management.Updated the copyright year.
Motivation
These changes address issues related to the persistence and restoration of animation events across sessions, improving the reliability of cinematic workflows in jMonkeyEngine. By serializing the model reference and reconstructing the composer as needed, the risk of null references or mismatched state is reduced.
Impact