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:
1 parent
0553a85220
commit
0798aa5d57
169 files changed
+27098
-3469
No files matched your search
@@ -12,6 +12,57 @@ pub fn migrate_v1_to_v2(body: &str) -> String {
|
||||
out
|
||||
}
|
||||
|
||||
/// Migrates v2 animated imported-model actors to the dedicated skinned renderer contract.
|
||||
///
|
||||
/// `ModelRef` and `SkinnedMeshRenderer` intentionally share the same serialized source fields, so
|
||||
/// the migration can preserve stable asset IDs and cached paths without lossy reconstruction.
|
||||
pub fn migrate_v2_to_v3(body: &str) -> String {
|
||||
let mut result = String::with_capacity(body.len() + 256);
|
||||
let mut rest = body;
|
||||
while let Some(index) = rest.find("components: {") {
|
||||
result.push_str(&rest[..index]);
|
||||
let after = &rest[index..];
|
||||
let Some(close) = find_components_close(after) else {
|
||||
result.push_str(after);
|
||||
return result;
|
||||
};
|
||||
let block = &after[..close];
|
||||
if block.contains("\"shared::animation::AnimationControllerDesc\"")
|
||||
&& block.contains("\"shared::components::ModelRef\"")
|
||||
{
|
||||
result.push_str(
|
||||
&block
|
||||
.replace(
|
||||
"\"shared::components::ModelRef\"",
|
||||
"\"shared::animation::SkinnedMeshRenderer\"",
|
||||
)
|
||||
.replace(
|
||||
"\"shared::components::ActorKind\": ImportedModel",
|
||||
"\"shared::components::ActorKind\": SkinnedMesh",
|
||||
)
|
||||
.replace(
|
||||
"\"shared::components::ActorKind\":ImportedModel",
|
||||
"\"shared::components::ActorKind\":SkinnedMesh",
|
||||
),
|
||||
);
|
||||
} else {
|
||||
result.push_str(block);
|
||||
}
|
||||
rest = &after[close..];
|
||||
}
|
||||
result.push_str(rest);
|
||||
result
|
||||
}
|
||||
|
||||
/// Migrates schema-v3 documents into the registry-driven renderer/component foundation.
|
||||
///
|
||||
/// The v4 authoring types deliberately use serde defaults for material-slot sets and component
|
||||
/// enable state, so normal loading can remain read-only. The explicit project upgrader later
|
||||
/// materializes shared Material assets and canonical slot IDs on disk.
|
||||
pub fn migrate_v3_to_v4(body: &str) -> String {
|
||||
body.to_string()
|
||||
}
|
||||
|
||||
fn backfill_actor_kinds(text: &str) -> String {
|
||||
let mut result = String::with_capacity(text.len() + 1024);
|
||||
let mut rest = text;
|
||||
@@ -89,6 +140,9 @@ fn infer_kind_from_block(block: &str) -> &'static str {
|
||||
if block.contains("\"shared::components::LightDesc\"") {
|
||||
return actor_kind_ron(ActorKind::Light);
|
||||
}
|
||||
if block.contains("\"shared::animation::SkinnedMeshRenderer\"") {
|
||||
return actor_kind_ron(ActorKind::SkinnedMesh);
|
||||
}
|
||||
if block.contains("\"shared::components::ModelRef\"") {
|
||||
return actor_kind_ron(ActorKind::ImportedModel);
|
||||
}
|
||||
@@ -111,6 +165,9 @@ fn infer_kind_from_block(block: &str) -> &'static str {
|
||||
if block.contains("\"shared::components::AudioListenerDesc\"") {
|
||||
return actor_kind_ron(ActorKind::AudioListener);
|
||||
}
|
||||
if block.contains("\"shared::navigation::Navigation") {
|
||||
return actor_kind_ron(ActorKind::Navigation);
|
||||
}
|
||||
actor_kind_ron(ActorKind::Empty)
|
||||
}
|
||||
|
||||
@@ -119,6 +176,7 @@ fn actor_kind_ron(kind: ActorKind) -> &'static str {
|
||||
ActorKind::Empty => "Empty",
|
||||
ActorKind::Brush => "Brush",
|
||||
ActorKind::StaticMesh => "StaticMesh",
|
||||
ActorKind::SkinnedMesh => "SkinnedMesh",
|
||||
ActorKind::ImportedModel => "ImportedModel",
|
||||
ActorKind::Light => "Light",
|
||||
ActorKind::PrefabAnchor => "PrefabAnchor",
|
||||
@@ -130,6 +188,7 @@ fn actor_kind_ron(kind: ActorKind) -> &'static str {
|
||||
ActorKind::Objective => "Objective",
|
||||
ActorKind::AudioSource => "AudioSource",
|
||||
ActorKind::AudioListener => "AudioListener",
|
||||
ActorKind::Navigation => "Navigation",
|
||||
}
|
||||
}
|
||||
|
||||
@@ -241,6 +300,35 @@ mod tests {
|
||||
assert!(migrated.contains("Brush"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn v2_animation_actor_moves_to_dedicated_skinned_renderer() {
|
||||
let body = r#"(
|
||||
resources: {},
|
||||
entities: {
|
||||
1: (components: {
|
||||
"shared::components::LevelObject": (),
|
||||
"shared::components::ActorKind": ImportedModel,
|
||||
"shared::components::ModelRef": (asset_id: "hero", path: "models/hero.glb", scene_index: 0),
|
||||
"shared::animation::AnimationControllerDesc": (skeleton: None, states: [], default_state: "", default_crossfade_seconds: 0.2),
|
||||
}),
|
||||
2: (components: {
|
||||
"shared::components::ActorKind": ImportedModel,
|
||||
"shared::components::ModelRef": (asset_id: "prop", path: "models/prop.glb", scene_index: 0),
|
||||
}),
|
||||
},
|
||||
)"#;
|
||||
|
||||
let migrated = migrate_v2_to_v3(body);
|
||||
|
||||
assert!(migrated.contains("\"shared::animation::SkinnedMeshRenderer\""));
|
||||
assert!(migrated.contains("\"shared::components::ActorKind\": SkinnedMesh"));
|
||||
assert_eq!(
|
||||
migrated.matches("\"shared::components::ModelRef\"").count(),
|
||||
1,
|
||||
"generic scene instance must remain a ModelRef"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn backfills_actor_kind_for_audio_source_entity() {
|
||||
let body = r#"(
|
||||
|
||||
Reference in new issue
Block a user