Build renderer and material component foundations

Add dedicated skinned rendering, pose restoration, shared Material and Material Instance slots, registry-driven components, Surface/Solari integration, transactional schema upgrades, navigation authoring, documentation, and evaluation evidence.
This commit is contained in:
Rbanh committed 2026-07-12 00:24:06 -04:00
1 parent 0553a85220
commit 0798aa5d57
169 files changed
+27098 -3469

No files matched your search

+10
View File
@@ -18,6 +18,16 @@ name = "package-project"
path = "src/package_project.rs"
required-features = ["validate-levels"]
[[bin]]
name = "bake-navigation"
path = "src/bake_navigation.rs"
required-features = ["validate-levels"]
[[bin]]
name = "upgrade-project"
path = "src/upgrade_project.rs"
required-features = ["validate-levels"]
[dependencies]
walkdir = "2.5"
scene = { path = "../crates/scene", optional = true }
+125
View File
@@ -0,0 +1,125 @@
//! Deterministically bake navigation artifacts from authored scene components.
use std::fs;
use std::path::{Path, PathBuf};
use scene::document::SceneDocument;
use scene::navigation::{
bake_navigation, navigation_bake_jobs_from_document, write_navigation_artifact,
};
use walkdir::WalkDir;
fn main() {
if let Err(error) = run() {
eprintln!("bake-navigation: {error}");
std::process::exit(1);
}
}
fn run() -> Result<(), String> {
let mut project_root = PathBuf::from(".");
let mut requested_scene = None;
let mut check = false;
let mut args = std::env::args().skip(1);
while let Some(argument) = args.next() {
match argument.as_str() {
"--project" => {
project_root = PathBuf::from(
args.next()
.ok_or_else(|| "--project requires a path".to_string())?,
);
}
"--scene" => {
requested_scene =
Some(PathBuf::from(args.next().ok_or_else(|| {
"--scene requires a project-relative path".to_string()
})?));
}
"--check" => check = true,
_ => return Err(format!("unknown argument `{argument}`")),
}
}
let project_root = project_root
.canonicalize()
.map_err(|error| format!("could not resolve project root: {error}"))?;
let scenes = match requested_scene {
Some(scene) => vec![safe_project_path(&project_root, &scene)?],
None => discover_scenes(&project_root)?,
};
let mut artifact_count = 0usize;
for scene_path in scenes {
let relative_scene = scene_path
.strip_prefix(&project_root)
.map_err(|_| format!("scene {} escaped the project", scene_path.display()))?
.to_string_lossy()
.replace('\\', "/");
let text = fs::read_to_string(&scene_path)
.map_err(|error| format!("could not read {}: {error}", scene_path.display()))?;
let document = SceneDocument::from_ron_text(&text)
.map_err(|error| format!("{}: {error}", scene_path.display()))?;
for job in navigation_bake_jobs_from_document(&document, &relative_scene)? {
let artifact = bake_navigation(&job.input)?;
let output = safe_artifact_path(&project_root, &job.artifact_path)?;
if check {
let existing = scene::navigation::read_navigation_artifact(&output)?;
if existing.is_stale_for(&job.input) {
return Err(format!(
"{} is stale for {}",
output.display(),
scene_path.display()
));
}
println!("current {}", output.display());
} else {
write_navigation_artifact(&output, &artifact)?;
println!("baked {}", output.display());
}
artifact_count += 1;
}
}
println!("bake-navigation: {artifact_count} artifacts");
Ok(())
}
fn discover_scenes(project_root: &Path) -> Result<Vec<PathBuf>, String> {
let levels = project_root.join("assets/levels");
if !levels.is_dir() {
return Err(format!("missing levels directory {}", levels.display()));
}
let mut scenes: Vec<PathBuf> = WalkDir::new(&levels)
.follow_links(false)
.into_iter()
.filter_map(Result::ok)
.filter(|entry| entry.file_type().is_file())
.map(|entry| entry.into_path())
.filter(|path| path.to_string_lossy().ends_with(".scn.ron"))
.collect();
scenes.sort();
Ok(scenes)
}
fn safe_artifact_path(project_root: &Path, authored: &str) -> Result<PathBuf, String> {
let normalized = authored.replace('\\', "/");
if !normalized.starts_with("assets/navigation/generated/") {
return Err(format!(
"navigation artifact `{authored}` must be under assets/navigation/generated/"
));
}
safe_project_path(project_root, Path::new(&normalized))
}
fn safe_project_path(project_root: &Path, relative: &Path) -> Result<PathBuf, String> {
if relative.is_absolute()
|| relative
.components()
.any(|component| matches!(component, std::path::Component::ParentDir))
{
return Err(format!(
"project-relative path `{}` is unsafe",
relative.display()
));
}
Ok(project_root.join(relative))
}
+52
View File
@@ -0,0 +1,52 @@
//! Transactional Blacksite project schema/material upgrader.
use std::path::PathBuf;
fn main() {
let mut project = PathBuf::from(".");
let mut apply = false;
let mut json = false;
let mut args = std::env::args().skip(1);
while let Some(argument) = args.next() {
match argument.as_str() {
"--project" => {
let Some(path) = args.next() else {
eprintln!("upgrade-project: --project requires a path");
std::process::exit(2);
};
project = PathBuf::from(path);
}
"--apply" => apply = true,
"--dry-run" => apply = false,
"--json" => json = true,
other => {
eprintln!("upgrade-project: unknown argument `{other}`");
std::process::exit(2);
}
}
}
match scene::upgrade_project(&project, apply) {
Ok(report) => {
if json {
println!("{}", serde_json::to_string_pretty(&report).unwrap());
} else {
println!(
"upgrade-project: {} changes, applied={}, backup={}",
report.changes.len(),
report.applied,
report.backup_path.as_deref().unwrap_or("none")
);
for change in report.changes {
println!(" {} [{}]", change.path, change.kind);
}
for warning in report.warnings {
eprintln!(" warning: {warning}");
}
}
}
Err(error) => {
eprintln!("upgrade-project failed: {error}");
std::process::exit(1);
}
}
}