Skip to content

Commit 2e850c7

Browse files
authored
Update Cinematic
1 parent 23de7bd commit 2e850c7

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

jme3-core/src/main/java/com/jme3/cinematic/Cinematic.java

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2009-2025 jMonkeyEngine
2+
* Copyright (c) 2009-2026 jMonkeyEngine
33
* All rights reserved.
44
*
55
* Redistribution and use in source and binary forms, with or without
@@ -48,6 +48,7 @@
4848
import java.io.IOException;
4949
import java.util.ArrayList;
5050
import java.util.HashMap;
51+
import java.util.List;
5152
import java.util.Map;
5253
import java.util.logging.Level;
5354
import java.util.logging.Logger;
@@ -96,7 +97,7 @@ public class Cinematic extends AbstractCinematicEvent implements AppState {
9697
private Node scene;
9798
protected TimeLine timeLine = new TimeLine();
9899
private int lastFetchedKeyFrame = -1;
99-
private ArrayList<CinematicEvent> cinematicEvents = new ArrayList<>();
100+
private final List<CinematicEvent> cinematicEvents = new ArrayList<>();
100101
private Map<String, CameraNode> cameras = new HashMap<>();
101102
private CameraNode currentCam;
102103
private boolean initialized = false;
@@ -240,7 +241,7 @@ public void onPause() {
240241
public void write(JmeExporter ex) throws IOException {
241242
super.write(ex);
242243
OutputCapsule oc = ex.getCapsule(this);
243-
oc.writeSavableArrayList(cinematicEvents, "cinematicEvents", null);
244+
oc.write(cinematicEvents.toArray(new CinematicEvent[cinematicEvents.size()]), "cinematicEvents", null);
244245
oc.writeStringSavableMap(cameras, "cameras", null);
245246
oc.write(timeLine, "timeLine", null);
246247
}
@@ -256,7 +257,12 @@ public void write(JmeExporter ex) throws IOException {
256257
public void read(JmeImporter im) throws IOException {
257258
super.read(im);
258259
InputCapsule ic = im.getCapsule(this);
259-
cinematicEvents = ic.readSavableArrayList("cinematicEvents", null);
260+
261+
Savable[] events = ic.readSavableArray("cinematicEvents", null);
262+
for (Savable c : events) {
263+
// addCinematicEvent(((CinematicEvent) c).getTime(), (CinematicEvent) c)
264+
cinematicEvents.add((CinematicEvent) c);
265+
}
260266
cameras = (Map<String, CameraNode>) ic.readStringSavableMap("cameras", null);
261267
timeLine = (TimeLine) ic.readSavable("timeLine", null);
262268
}
@@ -551,7 +557,6 @@ public void postRender() {
551557
public void cleanup() {
552558
initialized = false;
553559
clear();
554-
clearCameras();
555560
}
556561

557562
/**
@@ -774,3 +779,4 @@ public void dispose() {
774779
}
775780
}
776781

782+

0 commit comments

Comments
 (0)