Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
47 changes: 47 additions & 0 deletions Engine/apps/editor/src/play_session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ impl EditorPlaySession {
}
}
collect_snapshot_assets(document.project().root(), &mut programming)?;
collect_snapshot_scenes(
document.project().root(),
document.scene_path(),
&mut programming,
)?;
collect_sky_image(document, &mut programming)?;
let snapshot = SnapshotBuilder::new(temporary.join("play"))
.stage(
Expand Down Expand Up @@ -269,6 +274,48 @@ fn collect_sky_image(
Ok(())
}

fn collect_snapshot_scenes(
root: &Path,
current: &Path,
output: &mut Vec<SnapshotInput>,
) -> Result<(), String> {
let mut pending = [root.join("scene"), root.join("scenes")]
.into_iter()
.filter(|path| {
path.symlink_metadata()
.is_ok_and(|metadata| metadata.is_dir() && !metadata.file_type().is_symlink())
})
.collect::<Vec<_>>();
while let Some(directory) = pending.pop() {
for entry in std::fs::read_dir(directory).map_err(|e| e.to_string())? {
let entry = entry.map_err(|e| e.to_string())?;
let kind = entry.file_type().map_err(|e| e.to_string())?;
if kind.is_symlink() {
continue;
}
let path = entry.path();
if kind.is_dir() {
pending.push(path);
} else if kind.is_file()
&& path != current
&& matches!(
path.extension().and_then(|s| s.to_str()),
Some("scene" | "rscene")
)
{
let relative = path.strip_prefix(root).map_err(|e| e.to_string())?;
if !output.iter().any(|input| input.relative_path == relative) {
output.push(SnapshotInput::new(
relative,
std::fs::read(&path).map_err(|e| e.to_string())?,
));
}
}
}
}
Ok(())
}

fn collect_snapshot_assets(root: &Path, output: &mut Vec<SnapshotInput>) -> Result<(), String> {
let mut pending = ["assets", "ui"]
.into_iter()
Expand Down
3 changes: 2 additions & 1 deletion Engine/crates/engine-play/src/runtime_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ fn run_authenticated_session(
RuntimeScripts::load(snapshot.root(), &source_scene)
.map_err(RuntimeServerError::Scripts)?,
));
drop(source_scene);
if snapshot.manifest().mode != config.mode {
return Err(RuntimeServerError::SnapshotModeMismatch {
snapshot: snapshot.manifest().mode,
Expand Down Expand Up @@ -286,7 +287,7 @@ fn run_authenticated_session(
.map_err(|_| RuntimeServerError::SimulationPoisoned)?;
scripts.stop();
let changes = scripts
.runtime_changes(snapshot.source_scene_hash(), &source_scene)
.runtime_changes(snapshot.source_scene_hash(), &snapshot.scene_bytes()?)
.map_err(RuntimeServerError::Scripts)?;
connection.send(
received.request_id,
Expand Down
Loading
Loading