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

+14 -7
View File
@@ -9,9 +9,10 @@ use bevy::mesh::{Indices, PrimitiveTopology};
use bevy::prelude::*;
use crate::{
asset_server_path, brush_math::validate_brush, inspector_component_active, BrushDesc,
BrushFaceDesc, ColliderDesc, InspectorOrder, LevelObject, MaterialAsset, MaterialDesc,
COMPONENT_BRUSH_DESC, COMPONENT_COLLIDER_DESC, COMPONENT_MATERIAL_DESC,
asset_server_path, authoring_component_active, brush_math::validate_brush,
AuthoringComponentStates, BrushDesc, BrushFaceDesc, ColliderDesc, InspectorOrder, LevelObject,
MaterialAsset, MaterialDesc, COMPONENT_BRUSH_DESC, COMPONENT_COLLIDER_DESC,
COMPONENT_MATERIAL_DESC,
};
use super::materials::material_from_desc;
@@ -33,6 +34,7 @@ pub fn hydrate_brushes(
&BrushDesc,
Option<&MaterialDesc>,
Option<&ColliderDesc>,
Option<&AuthoringComponentStates>,
Option<&InspectorOrder>,
),
(
@@ -42,6 +44,7 @@ pub fn hydrate_brushes(
Changed<BrushDesc>,
Changed<MaterialDesc>,
Changed<ColliderDesc>,
Changed<AuthoringComponentStates>,
Changed<InspectorOrder>,
)>,
),
@@ -49,9 +52,9 @@ pub fn hydrate_brushes(
children: Query<&Children>,
generated_brushes: Query<(), With<HydratedBrushMesh>>,
) {
for (entity, brush, material, collider, order) in &brushes {
for (entity, brush, material, collider, states, legacy_order) in &brushes {
despawn_brush_mesh(&mut commands, entity, &children, &generated_brushes);
if !inspector_component_active(order, COMPONENT_BRUSH_DESC) {
if !authoring_component_active(states, legacy_order, COMPONENT_BRUSH_DESC) {
continue;
}
spawn_brush_mesh(
@@ -61,8 +64,12 @@ pub fn hydrate_brushes(
&mut materials,
entity,
brush,
material.filter(|_| inspector_component_active(order, COMPONENT_MATERIAL_DESC)),
collider.filter(|_| inspector_component_active(order, COMPONENT_COLLIDER_DESC)),
material.filter(|_| {
authoring_component_active(states, legacy_order, COMPONENT_MATERIAL_DESC)
}),
collider.filter(|_| {
authoring_component_active(states, legacy_order, COMPONENT_COLLIDER_DESC)
}),
);
}
}
+33 -10
View File
@@ -5,8 +5,8 @@ use bevy::prelude::*;
use settings::{ActiveCameraRenderProfile, GiPath, RenderingCapabilities, RenderingSettings};
use crate::{
inspector_component_active, AuthoringLightKind, InspectorOrder, LevelObject, LightDesc,
COMPONENT_LIGHT_DESC,
authoring_component_active, AuthoringComponentStates, AuthoringLightKind, InspectorOrder,
LevelObject, LightDesc, COMPONENT_LIGHT_DESC,
};
/// Legacy directional lux below this is treated as invalid (see ADR 0011).
@@ -31,21 +31,36 @@ pub fn hydrate_lights(
settings: Res<settings::ProjectSettings>,
profile: Option<Res<ActiveCameraRenderProfile>>,
caps: Option<Res<RenderingCapabilities>>,
lights: Query<(Entity, Ref<LightDesc>, Option<Ref<InspectorOrder>>), With<LevelObject>>,
lights: Query<
(
Entity,
Ref<LightDesc>,
Option<Ref<AuthoringComponentStates>>,
Option<Ref<InspectorOrder>>,
),
With<LevelObject>,
>,
) {
let rendering = &settings.rendering;
let render_stack_changed = profile.as_ref().is_some_and(|profile| profile.is_changed())
|| caps.as_ref().is_some_and(|caps| caps.is_changed());
let profile = profile.as_deref();
let caps = caps.as_deref();
for (entity, light, order) in &lights {
let order_changed = order.as_ref().is_some_and(|order| order.is_changed());
if !light.is_changed() && !order_changed && !render_stack_changed {
for (entity, light, states, legacy_order) in &lights {
let state_changed = states.as_ref().is_some_and(|states| states.is_changed());
let legacy_changed = legacy_order
.as_ref()
.is_some_and(|order| order.is_changed());
if !light.is_changed() && !state_changed && !legacy_changed && !render_stack_changed {
continue;
}
let mut entity_commands = commands.entity(entity);
strip_light_components(&mut entity_commands);
if !inspector_component_active(order.as_deref(), COMPONENT_LIGHT_DESC) {
if !authoring_component_active(
states.as_deref(),
legacy_order.as_deref(),
COMPONENT_LIGHT_DESC,
) {
continue;
}
if local_light_disabled_in_solari(&light, profile, caps) {
@@ -86,7 +101,15 @@ pub fn reconcile_missing_runtime_lights(
settings: Res<settings::ProjectSettings>,
profile: Option<Res<ActiveCameraRenderProfile>>,
caps: Option<Res<RenderingCapabilities>>,
lights: Query<(Entity, &LightDesc, Option<&InspectorOrder>), With<LevelObject>>,
lights: Query<
(
Entity,
&LightDesc,
Option<&AuthoringComponentStates>,
Option<&InspectorOrder>,
),
With<LevelObject>,
>,
points: Query<(), With<PointLight>>,
spots: Query<(), With<SpotLight>>,
directionals: Query<(), With<DirectionalLight>>,
@@ -94,8 +117,8 @@ pub fn reconcile_missing_runtime_lights(
let rendering = &settings.rendering;
let profile = profile.as_deref();
let caps = caps.as_deref();
for (entity, light, order) in &lights {
if !inspector_component_active(order, COMPONENT_LIGHT_DESC) {
for (entity, light, states, legacy_order) in &lights {
if !authoring_component_active(states, legacy_order, COMPONENT_LIGHT_DESC) {
continue;
}
if local_light_disabled_in_solari(light, profile, caps) {
+11 -5
View File
@@ -3,8 +3,8 @@
use bevy::prelude::*;
use crate::{
asset_server_path, inspector_component_active, InspectorOrder, LevelObject, MaterialDesc,
MaterialShaderKind, Primitive, COMPONENT_MATERIAL_DESC,
asset_server_path, authoring_component_active, AuthoringComponentStates, InspectorOrder,
LevelObject, MaterialDesc, MaterialShaderKind, Primitive, COMPONENT_MATERIAL_DESC,
};
#[allow(clippy::type_complexity)]
@@ -13,7 +13,12 @@ pub fn hydrate_materials(
asset_server: Res<AssetServer>,
mut materials: ResMut<Assets<StandardMaterial>>,
targets: Query<
(Entity, &MaterialDesc, Option<&InspectorOrder>),
(
Entity,
&MaterialDesc,
Option<&AuthoringComponentStates>,
Option<&InspectorOrder>,
),
(
With<LevelObject>,
With<Mesh3d>,
@@ -21,13 +26,14 @@ pub fn hydrate_materials(
Changed<MaterialDesc>,
Added<Mesh3d>,
Changed<Primitive>,
Changed<AuthoringComponentStates>,
Changed<InspectorOrder>,
)>,
),
>,
) {
for (entity, desc, order) in &targets {
if !inspector_component_active(order, COMPONENT_MATERIAL_DESC) {
for (entity, desc, states, legacy_order) in &targets {
if !authoring_component_active(states, legacy_order, COMPONENT_MATERIAL_DESC) {
commands
.entity(entity)
.remove::<MeshMaterial3d<StandardMaterial>>();
+92 -49
View File
@@ -7,6 +7,7 @@ mod models;
mod physics;
mod prefabs;
mod primitives;
mod skinned_meshes;
mod static_meshes;
pub mod strip;
mod visibility;
@@ -27,6 +28,11 @@ use physics::hydrate_physics;
use prefabs::{hydrate_prefabs, tag_hydrated_prefab_members};
pub use prefabs::{HydratedPrefabMember, HydratedPrefabReady, PrefabHydrationBlocked};
use primitives::{hydrate_primitives, primitive_mesh};
pub use skinned_meshes::HydratedSkinnedMeshRoot;
use skinned_meshes::{
apply_skinned_renderer_material_changes, cleanup_removed_skinned_mesh_renderers,
hydrate_skinned_mesh_renderers, mark_skinned_materials_ready,
};
use static_meshes::{
hydrate_static_mesh_renderers, spawn_static_mesh_parts, HydratedStaticMeshPart,
StaticMeshArtifactCache,
@@ -37,10 +43,10 @@ use visibility::{
};
use crate::{
inspector_component_active, BrushDesc, ColliderDesc, EditorVisibility, InspectorOrder,
LevelObject, MaterialDesc, MaterialOverride, Primitive, StaticMeshRenderer,
COMPONENT_BRUSH_DESC, COMPONENT_COLLIDER_DESC, COMPONENT_LIGHT_DESC, COMPONENT_MATERIAL_DESC,
COMPONENT_PRIMITIVE, COMPONENT_STATIC_MESH_RENDERER,
authoring_component_active, AuthoringComponentStates, BrushDesc, ColliderDesc,
EditorVisibility, InspectorOrder, LevelObject, MaterialDesc, MaterialOverride, Primitive,
StaticMeshRenderer, COMPONENT_BRUSH_DESC, COMPONENT_COLLIDER_DESC, COMPONENT_LIGHT_DESC,
COMPONENT_MATERIAL_DESC, COMPONENT_PRIMITIVE, COMPONENT_STATIC_MESH_RENDERER,
};
/// Registers hydration systems in deterministic order.
@@ -50,6 +56,7 @@ impl Plugin for HydrationPlugin {
fn build(&self, app: &mut App) {
app.init_resource::<StaticMeshArtifactCache>()
.add_observer(tag_hydrated_prefab_members)
.add_observer(mark_skinned_materials_ready)
.add_observer(crate::prefab_overrides::apply_prefab_overrides_on_ready)
.add_systems(
Update,
@@ -60,6 +67,9 @@ impl Plugin for HydrationPlugin {
hydrate_lights,
reconcile_missing_runtime_lights,
hydrate_static_mesh_renderers,
hydrate_skinned_mesh_renderers,
apply_skinned_renderer_material_changes,
cleanup_removed_skinned_mesh_renderers,
hydrate_models,
hydrate_prefabs,
hydrate_physics,
@@ -89,17 +99,31 @@ pub fn flush_level_object_hydration(world: &mut World) {
}
let primitives: Vec<(Entity, Primitive)> = world
.query_filtered::<(Entity, &Primitive, Option<&InspectorOrder>), With<LevelObject>>()
.query_filtered::<(
Entity,
&Primitive,
Option<&AuthoringComponentStates>,
Option<&InspectorOrder>,
), With<LevelObject>>()
.iter(world)
.filter(|(_, _, order)| inspector_component_active(*order, COMPONENT_PRIMITIVE))
.map(|(entity, primitive, _)| (entity, primitive.clone()))
.filter(|(_, _, states, order)| {
authoring_component_active(*states, *order, COMPONENT_PRIMITIVE)
})
.map(|(entity, primitive, _, _)| (entity, primitive.clone()))
.collect();
let material_targets: Vec<(Entity, MaterialDesc)> = world
.query_filtered::<(Entity, &MaterialDesc, Option<&InspectorOrder>), With<LevelObject>>()
.query_filtered::<(
Entity,
&MaterialDesc,
Option<&AuthoringComponentStates>,
Option<&InspectorOrder>,
), With<LevelObject>>()
.iter(world)
.filter(|(_, _, order)| inspector_component_active(*order, COMPONENT_MATERIAL_DESC))
.map(|(entity, desc, _)| (entity, desc.clone()))
.filter(|(_, _, states, order)| {
authoring_component_active(*states, *order, COMPONENT_MATERIAL_DESC)
})
.map(|(entity, desc, _, _)| (entity, desc.clone()))
.collect();
let brush_entities_for_cleanup: Vec<Entity> = world
@@ -113,31 +137,33 @@ pub fn flush_level_object_hydration(world: &mut World) {
BrushDesc,
Option<MaterialDesc>,
Option<ColliderDesc>,
Option<InspectorOrder>,
)> = world
.query_filtered::<(
Entity,
&BrushDesc,
Option<&MaterialDesc>,
Option<&ColliderDesc>,
Option<&AuthoringComponentStates>,
Option<&InspectorOrder>,
), With<LevelObject>>()
.iter(world)
.map(|(entity, brush, material, collider, order)| {
(
entity,
brush.clone(),
material
.filter(|_| inspector_component_active(order, COMPONENT_MATERIAL_DESC))
.cloned(),
collider
.filter(|_| inspector_component_active(order, COMPONENT_COLLIDER_DESC))
.cloned(),
order.cloned(),
)
})
.filter(|(_, _, _, _, order)| {
inspector_component_active(order.as_ref(), COMPONENT_BRUSH_DESC)
.filter_map(|(entity, brush, material, collider, states, order)| {
authoring_component_active(states, order, COMPONENT_BRUSH_DESC).then(|| {
(
entity,
brush.clone(),
material
.filter(|_| {
authoring_component_active(states, order, COMPONENT_MATERIAL_DESC)
})
.cloned(),
collider
.filter(|_| {
authoring_component_active(states, order, COMPONENT_COLLIDER_DESC)
})
.cloned(),
)
})
})
.collect();
@@ -153,7 +179,6 @@ pub fn flush_level_object_hydration(world: &mut World) {
Option<MaterialDesc>,
Option<MaterialOverride>,
Option<ColliderDesc>,
Option<InspectorOrder>,
)> = world
.query_filtered::<(
Entity,
@@ -161,28 +186,41 @@ pub fn flush_level_object_hydration(world: &mut World) {
Option<&MaterialDesc>,
Option<&MaterialOverride>,
Option<&ColliderDesc>,
Option<&AuthoringComponentStates>,
Option<&InspectorOrder>,
), With<LevelObject>>()
.iter(world)
.map(
|(entity, renderer, material, material_override, collider, order)| {
(
entity,
renderer.clone(),
material
.filter(|_| inspector_component_active(order, COMPONENT_MATERIAL_DESC))
.cloned(),
material_override.cloned(),
collider
.filter(|_| inspector_component_active(order, COMPONENT_COLLIDER_DESC))
.cloned(),
order.cloned(),
.filter_map(
|(entity, renderer, material, material_override, collider, states, order)| {
authoring_component_active(states, order, COMPONENT_STATIC_MESH_RENDERER).then(
|| {
(
entity,
renderer.clone(),
material
.filter(|_| {
authoring_component_active(
states,
order,
COMPONENT_MATERIAL_DESC,
)
})
.cloned(),
material_override.cloned(),
collider
.filter(|_| {
authoring_component_active(
states,
order,
COMPONENT_COLLIDER_DESC,
)
})
.cloned(),
)
},
)
},
)
.filter(|(_, _, _, _, _, order)| {
inspector_component_active(order.as_ref(), COMPONENT_STATIC_MESH_RENDERER)
})
.collect();
let mut generated_static_mesh_parts = Vec::new();
@@ -225,13 +263,18 @@ pub fn flush_level_object_hydration(world: &mut World) {
.cloned();
let lights: Vec<(Entity, crate::LightDesc)> = world
.query_filtered::<(Entity, &crate::LightDesc, Option<&InspectorOrder>), With<LevelObject>>()
.query_filtered::<(
Entity,
&crate::LightDesc,
Option<&AuthoringComponentStates>,
Option<&InspectorOrder>,
), With<LevelObject>>()
.iter(world)
.filter(|(_, light, order)| {
inspector_component_active(*order, COMPONENT_LIGHT_DESC)
.filter(|(_, light, states, order)| {
authoring_component_active(*states, *order, COMPONENT_LIGHT_DESC)
&& !lights::local_light_disabled_in_solari(light, profile.as_ref(), caps.as_ref())
})
.map(|(entity, light, _)| (entity, light.clone()))
.map(|(entity, light, _, _)| (entity, light.clone()))
.collect();
let mut state: SystemState<(
@@ -261,7 +304,7 @@ pub fn flush_level_object_hydration(world: &mut World) {
commands.entity(child).despawn();
}
for (entity, brush, material, collider, _) in &brush_targets {
for (entity, brush, material, collider) in &brush_targets {
spawn_brush_mesh(
&mut commands,
&asset_server,
@@ -278,7 +321,7 @@ pub fn flush_level_object_hydration(world: &mut World) {
commands.entity(child).despawn();
}
for (entity, renderer, material, material_override, collider, _) in &static_mesh_renderers {
for (entity, renderer, material, material_override, collider) in &static_mesh_renderers {
spawn_static_mesh_parts(
&mut commands,
&asset_server,
+28 -12
View File
@@ -4,23 +4,37 @@ use avian3d::prelude::*;
use bevy::prelude::*;
use crate::{
inspector_component_active, AuthoringRigidBody, ColliderDesc, ColliderShapeDesc,
InspectorOrder, LevelObject, PhysicsBody, RigidBodyDesc, COMPONENT_COLLIDER_DESC,
COMPONENT_PHYSICS_BODY, COMPONENT_RIGID_BODY_DESC,
authoring_component_active, AuthoringComponentStates, AuthoringRigidBody, ColliderDesc,
ColliderShapeDesc, InspectorOrder, LevelObject, PhysicsBody, RigidBodyDesc,
COMPONENT_COLLIDER_DESC, COMPONENT_PHYSICS_BODY, COMPONENT_RIGID_BODY_DESC,
};
#[allow(clippy::type_complexity)]
pub fn hydrate_physics(
mut commands: Commands,
physics: Query<
(Entity, &PhysicsBody, Option<&InspectorOrder>),
(
Entity,
&PhysicsBody,
Option<&AuthoringComponentStates>,
Option<&InspectorOrder>,
),
(
With<LevelObject>,
Or<(Changed<PhysicsBody>, Changed<InspectorOrder>)>,
Or<(
Changed<PhysicsBody>,
Changed<AuthoringComponentStates>,
Changed<InspectorOrder>,
)>,
),
>,
new_physics: Query<
(Entity, &PhysicsBody, Option<&InspectorOrder>),
(
Entity,
&PhysicsBody,
Option<&AuthoringComponentStates>,
Option<&InspectorOrder>,
),
(With<LevelObject>, Added<PhysicsBody>),
>,
split_physics: Query<
@@ -28,6 +42,7 @@ pub fn hydrate_physics(
Entity,
Option<&RigidBodyDesc>,
Option<&ColliderDesc>,
Option<&AuthoringComponentStates>,
Option<&InspectorOrder>,
),
(
@@ -37,13 +52,14 @@ pub fn hydrate_physics(
Added<RigidBodyDesc>,
Changed<ColliderDesc>,
Added<ColliderDesc>,
Changed<AuthoringComponentStates>,
Changed<InspectorOrder>,
)>,
),
>,
) {
for (entity, body, order) in new_physics.iter().chain(physics.iter()) {
if !inspector_component_active(order, COMPONENT_PHYSICS_BODY) {
for (entity, body, states, legacy_order) in new_physics.iter().chain(physics.iter()) {
if !authoring_component_active(states, legacy_order, COMPONENT_PHYSICS_BODY) {
commands
.entity(entity)
.remove::<RigidBody>()
@@ -63,12 +79,12 @@ pub fn hydrate_physics(
.insert((rigid_body, body.collider.clone()));
}
for (entity, rigid_body, collider, order) in &split_physics {
for (entity, rigid_body, collider, states, legacy_order) in &split_physics {
let mut entity_commands = commands.entity(entity);
entity_commands.remove::<RigidBody>().remove::<Collider>();
if let Some(rigid_body) =
rigid_body.filter(|_| inspector_component_active(order, COMPONENT_RIGID_BODY_DESC))
if let Some(rigid_body) = rigid_body
.filter(|_| authoring_component_active(states, legacy_order, COMPONENT_RIGID_BODY_DESC))
{
entity_commands.insert(rigid_body_from_desc(rigid_body.body));
}
@@ -76,7 +92,7 @@ pub fn hydrate_physics(
let Some(collider) = collider else {
continue;
};
if !inspector_component_active(order, COMPONENT_COLLIDER_DESC) {
if !authoring_component_active(states, legacy_order, COMPONENT_COLLIDER_DESC) {
continue;
}
if !collider.enabled || matches!(collider.shape, ColliderShapeDesc::StaticMesh { .. }) {
+11 -5
View File
@@ -3,8 +3,8 @@
use bevy::prelude::*;
use crate::{
inspector_component_active, InspectorOrder, LevelObject, Primitive, PrimitiveShape,
COMPONENT_PRIMITIVE,
authoring_component_active, AuthoringComponentStates, InspectorOrder, LevelObject, Primitive,
PrimitiveShape, COMPONENT_PRIMITIVE,
};
pub(crate) fn primitive_mesh(primitive: &Primitive) -> Mesh {
@@ -32,20 +32,26 @@ pub(crate) fn primitive_mesh(primitive: &Primitive) -> Mesh {
pub fn hydrate_primitives(
mut commands: Commands,
primitives: Query<
(Entity, &Primitive, Option<&InspectorOrder>),
(
Entity,
&Primitive,
Option<&AuthoringComponentStates>,
Option<&InspectorOrder>,
),
(
With<LevelObject>,
Or<(
Added<Primitive>,
Changed<Primitive>,
Changed<AuthoringComponentStates>,
Changed<InspectorOrder>,
)>,
),
>,
mut meshes: ResMut<Assets<Mesh>>,
) {
for (entity, primitive, order) in &primitives {
if !inspector_component_active(order, COMPONENT_PRIMITIVE) {
for (entity, primitive, states, legacy_order) in &primitives {
if !authoring_component_active(states, legacy_order, COMPONENT_PRIMITIVE) {
commands
.entity(entity)
.remove::<Mesh3d>()
@@ -0,0 +1,473 @@
//! Dedicated scene hydration for rigged and skinned model geometry.
use std::fs;
use bevy::gltf::GltfAssetLabel;
use bevy::prelude::WorldAssetRoot;
use bevy::prelude::*;
use bevy::world_serialization::WorldInstanceReady;
use serde::Deserialize;
use crate::{
asset_server_path, authoring_component_active, AuthoringComponentStates,
HydratedRendererMaterialBinding, InspectorOrder, LevelObject, SkinnedMeshRenderer,
ANIMATION_ARTIFACT_DIR, COMPONENT_SKINNED_MESH_RENDERER,
};
use super::static_meshes::{
renderer_error_material, resolve_renderer_material_handle, StaticMeshArtifactCache,
};
/// Runtime hierarchy root generated for one authored [`SkinnedMeshRenderer`].
///
/// The loaded world contains Bevy's actual skinned-mesh bindings and joints. Keeping this marker
/// distinct from `HydratedModelRoot` prevents animation systems from binding to generic imported
/// scene instances.
#[derive(Component, Debug, Clone, Copy, PartialEq, Eq)]
pub struct HydratedSkinnedMeshRoot {
pub owner: Entity,
}
#[derive(Component, Debug, Clone, PartialEq, Eq)]
pub(super) struct HydratedSkinnedMeshSource {
asset_id: String,
path: String,
scene_index: usize,
}
impl From<&SkinnedMeshRenderer> for HydratedSkinnedMeshSource {
fn from(renderer: &SkinnedMeshRenderer) -> Self {
Self {
asset_id: renderer.asset_id.clone(),
path: renderer.path.clone(),
scene_index: renderer.scene_index,
}
}
}
#[derive(Component, Default)]
pub(super) struct SkinnedMaterialsDirty;
#[derive(Deserialize)]
struct AnimationArtifactLookup {
source: AnimationSourceLookup,
}
#[derive(Deserialize)]
struct AnimationSourceLookup {
path: String,
}
pub fn skinned_mesh_manifest_path(asset_id: &str) -> String {
format!("{ANIMATION_ARTIFACT_DIR}/{asset_id}.animation.ron")
}
/// Resolves the current model source from the animation artifact rather than the static-mesh
/// artifact. The authored cached path remains the fallback when a legacy/unindexed asset has no
/// generated animation metadata.
pub fn skinned_mesh_source_path(asset_id: &str) -> Result<String, String> {
let path = skinned_mesh_manifest_path(asset_id);
let text = fs::read_to_string(&path)
.map_err(|error| format!("could not read skinned mesh artifact {path}: {error}"))?;
let artifact: AnimationArtifactLookup = ron::from_str(&text)
.map_err(|error| format!("could not parse skinned mesh artifact {path}: {error}"))?;
Ok(artifact.source.path)
}
#[allow(clippy::type_complexity)]
pub(super) fn hydrate_skinned_mesh_renderers(
mut commands: Commands,
asset_server: Res<AssetServer>,
renderers: Query<
(
Entity,
&SkinnedMeshRenderer,
Option<&AuthoringComponentStates>,
Option<&InspectorOrder>,
),
(
With<LevelObject>,
Or<(
Added<SkinnedMeshRenderer>,
Changed<SkinnedMeshRenderer>,
Changed<AuthoringComponentStates>,
Changed<InspectorOrder>,
)>,
),
>,
generated_roots: Query<(
Entity,
&HydratedSkinnedMeshRoot,
Option<&HydratedSkinnedMeshSource>,
)>,
) {
for (entity, renderer, states, legacy_order) in &renderers {
if !authoring_component_active(states, legacy_order, COMPONENT_SKINNED_MESH_RENDERER) {
for (root, generated, _) in &generated_roots {
if generated.owner == entity {
commands.entity(root).despawn();
}
}
continue;
}
let requested_source = HydratedSkinnedMeshSource::from(renderer);
let mut matching_root = None;
for (root, generated, source) in &generated_roots {
if generated.owner == entity {
if source == Some(&requested_source) {
matching_root = Some(root);
} else {
commands.entity(root).despawn();
}
}
}
if let Some(root) = matching_root {
commands.entity(root).insert(SkinnedMaterialsDirty);
continue;
}
let resolved_path = if renderer.asset_id.trim().is_empty() {
renderer.path.clone()
} else {
match skinned_mesh_source_path(&renderer.asset_id) {
Ok(path) => path,
Err(error) => {
warn!(
"SkinnedMeshRenderer {entity} could not resolve stable asset {}: {error}; falling back to cached path {}",
renderer.asset_id, renderer.path
);
renderer.path.clone()
}
}
};
let path = asset_server_path(&resolved_path);
let handle = if path.to_ascii_lowercase().ends_with(".fbx") {
asset_server.load(SkinnedMeshRenderer::fbx_scene_asset_path(
&path,
renderer.scene_index,
))
} else {
asset_server.load(GltfAssetLabel::Scene(renderer.scene_index).from_asset(path))
};
commands.spawn((
Name::new("Hydrated Skinned Mesh Root"),
HydratedSkinnedMeshRoot { owner: entity },
requested_source,
WorldAssetRoot(handle),
ChildOf(entity),
));
}
}
/// Defers material application until the imported world has produced its actual draw entities.
pub(super) fn mark_skinned_materials_ready(
ready: On<WorldInstanceReady>,
roots: Query<(), With<HydratedSkinnedMeshRoot>>,
mut commands: Commands,
) {
if roots.get(ready.entity).is_ok() {
commands.entity(ready.entity).insert(SkinnedMaterialsDirty);
}
}
#[allow(clippy::too_many_arguments)]
pub(super) fn apply_skinned_renderer_material_changes(
mut commands: Commands,
asset_server: Res<AssetServer>,
mut materials: ResMut<Assets<StandardMaterial>>,
mut artifact_cache: ResMut<StaticMeshArtifactCache>,
dirty_roots: Query<(Entity, &HydratedSkinnedMeshRoot), With<SkinnedMaterialsDirty>>,
renderers: Query<&SkinnedMeshRenderer>,
children: Query<&Children>,
parents: Query<&ChildOf>,
names: Query<&Name>,
meshes: Query<(Entity, &Mesh3d)>,
) {
for (root_entity, root) in &dirty_roots {
let Ok(renderer) = renderers.get(root.owner) else {
commands
.entity(root_entity)
.remove::<SkinnedMaterialsDirty>();
continue;
};
let descendants = collect_descendants(root_entity, &children);
let mut candidates = Vec::new();
for entity in descendants {
let Ok((_, mesh)) = meshes.get(entity) else {
continue;
};
let label = asset_server
.get_path(mesh.id())
.and_then(|path| path.label().map(str::to_string));
let hierarchy_path = hierarchy_path(entity, root_entity, &parents, &names);
candidates.push((entity, label, hierarchy_path));
}
let mut used = std::collections::HashSet::new();
for slot in &renderer.materials.slots {
let Some(binding) = artifact_cache.resolve_draw_binding(&renderer.asset_id, &slot.id)
else {
warn!(
"Skinned material slot '{}' has no generated draw binding for asset {}",
slot.id.0, renderer.asset_id
);
continue;
};
let matched = candidates
.iter()
.filter(|(entity, label, _)| {
!used.contains(entity) && label.as_deref() == Some(binding.mesh_label.as_str())
})
.find(|(_, _, path)| {
binding
.source_node
.as_deref()
.is_none_or(|source| path.ends_with(source))
})
.or_else(|| {
candidates.iter().find(|(entity, label, _)| {
!used.contains(entity)
&& label.as_deref() == Some(binding.mesh_label.as_str())
})
});
let Some((entity, _, _)) = matched else {
warn!(
"Skinned material slot '{}' could not find hydrated mesh {} ({:?})",
slot.id.0, binding.mesh_label, binding.source_node
);
continue;
};
used.insert(*entity);
let effective = slot.effective_material().cloned();
let Some(reference) = effective.as_ref() else {
commands
.entity(*entity)
.insert(HydratedRendererMaterialBinding {
owner: root.owner,
slot_id: slot.id.clone(),
effective_material: None,
});
continue;
};
let handle = resolve_renderer_material_handle(
&asset_server,
&mut materials,
&mut artifact_cache,
reference,
)
.unwrap_or_else(|| renderer_error_material(&mut materials));
commands.entity(*entity).insert((
MeshMaterial3d(handle),
HydratedRendererMaterialBinding {
owner: root.owner,
slot_id: slot.id.clone(),
effective_material: effective,
},
));
}
commands
.entity(root_entity)
.remove::<SkinnedMaterialsDirty>();
}
}
fn collect_descendants(root: Entity, children: &Query<&Children>) -> Vec<Entity> {
let mut result = Vec::new();
let mut pending = vec![root];
while let Some(entity) = pending.pop() {
if entity != root {
result.push(entity);
}
if let Ok(entity_children) = children.get(entity) {
pending.extend(entity_children.iter());
}
}
result
}
fn hierarchy_path(
mut entity: Entity,
root: Entity,
parents: &Query<&ChildOf>,
names: &Query<&Name>,
) -> String {
let mut segments = Vec::new();
while entity != root {
if let Ok(name) = names.get(entity) {
segments.push(name.as_str().to_string());
}
let Ok(parent) = parents.get(entity) else {
break;
};
entity = parent.parent();
}
segments.reverse();
segments.join("/")
}
/// Removes generated roots if the authoring renderer is removed without another renderer change.
pub(super) fn cleanup_removed_skinned_mesh_renderers(
mut commands: Commands,
renderers: Query<
(Option<&AuthoringComponentStates>, Option<&InspectorOrder>),
With<SkinnedMeshRenderer>,
>,
roots: Query<(Entity, &HydratedSkinnedMeshRoot)>,
) {
for (root_entity, root) in &roots {
let active = renderers
.get(root.owner)
.is_ok_and(|(states, legacy_order)| {
authoring_component_active(states, legacy_order, COMPONENT_SKINNED_MESH_RENDERER)
});
if !active {
commands.entity(root_entity).despawn();
}
}
}
#[cfg(test)]
mod tests {
use super::*;
use bevy::asset::{AssetApp, AssetPlugin};
use bevy::prelude::WorldAsset;
use std::path::{Path, PathBuf};
struct TestManifest(PathBuf);
impl Drop for TestManifest {
fn drop(&mut self) {
let _ = std::fs::remove_file(&self.0);
}
}
fn write_test_manifest(asset_id: &str, source_path: &str) -> TestManifest {
let path = PathBuf::from(skinned_mesh_manifest_path(asset_id));
std::fs::create_dir_all(path.parent().expect("manifest has a parent directory"))
.expect("generated animation directory should be writable");
std::fs::write(&path, format!(r#"(source: (path: "{source_path}"))"#))
.expect("test animation manifest should be writable");
TestManifest(path)
}
fn hydration_app() -> App {
let mut app = App::new();
app.add_plugins((MinimalPlugins, AssetPlugin::default()))
.init_asset::<WorldAsset>()
.add_systems(
Update,
(
hydrate_skinned_mesh_renderers,
cleanup_removed_skinned_mesh_renderers,
)
.chain(),
);
app
}
fn generated_roots(world: &mut World, owner: Entity) -> Vec<Entity> {
world
.query::<(Entity, &HydratedSkinnedMeshRoot)>()
.iter(world)
.filter_map(|(entity, root)| (root.owner == owner).then_some(entity))
.collect()
}
#[test]
fn renderer_hydrates_a_dedicated_root_and_preserves_authored_children() {
let mut app = hydration_app();
let owner = app
.world_mut()
.spawn((
LevelObject,
SkinnedMeshRenderer::new("assets/models/character.glb"),
))
.id();
let authored_child = app
.world_mut()
.spawn((Name::new("Socket"), ChildOf(owner)))
.id();
app.update();
assert_eq!(generated_roots(app.world_mut(), owner).len(), 1);
assert!(app.world().get_entity(authored_child).is_ok());
}
#[test]
fn stable_asset_id_uses_animation_artifact_source() {
const ASSET_ID: &str = "fe1ea62f-9ca8-40c6-a747-a1f40567b8c6";
let _manifest = write_test_manifest(ASSET_ID, "assets/models/relocated/hero.glb");
let mut app = hydration_app();
let owner = app
.world_mut()
.spawn((
LevelObject,
SkinnedMeshRenderer::new("assets/models/stale.glb").with_asset_id(ASSET_ID),
))
.id();
app.update();
let root_entity = generated_roots(app.world_mut(), owner)[0];
let root = app.world().get::<WorldAssetRoot>(root_entity).unwrap();
let loaded_path = app
.world()
.resource::<AssetServer>()
.get_path(root.0.id())
.unwrap();
assert_eq!(loaded_path.path(), Path::new("models/relocated/hero.glb"));
assert_eq!(loaded_path.label(), Some("Scene0"));
}
#[test]
fn removing_renderer_despawns_only_its_generated_root() {
let mut app = hydration_app();
let owner = app
.world_mut()
.spawn((
LevelObject,
SkinnedMeshRenderer::new("assets/models/character.glb"),
))
.id();
app.update();
let root = generated_roots(app.world_mut(), owner)[0];
app.world_mut()
.entity_mut(owner)
.remove::<SkinnedMeshRenderer>();
app.update();
assert!(app.world().get_entity(root).is_err());
assert!(app.world().get_entity(owner).is_ok());
}
#[test]
fn disabling_renderer_removes_hydrated_root_and_reenable_restores_it() {
let mut app = hydration_app();
let owner = app
.world_mut()
.spawn((
LevelObject,
SkinnedMeshRenderer::new("assets/models/character.glb"),
AuthoringComponentStates::default(),
))
.id();
app.update();
assert_eq!(generated_roots(app.world_mut(), owner).len(), 1);
app.world_mut()
.get_mut::<AuthoringComponentStates>(owner)
.unwrap()
.set_component_active(COMPONENT_SKINNED_MESH_RENDERER, false);
app.update();
assert!(generated_roots(app.world_mut(), owner).is_empty());
app.world_mut()
.get_mut::<AuthoringComponentStates>(owner)
.unwrap()
.set_component_active(COMPONENT_SKINNED_MESH_RENDERER, true);
app.update();
assert_eq!(generated_roots(app.world_mut(), owner).len(), 1);
}
}
+253 -18
View File
@@ -3,13 +3,16 @@
use avian3d::prelude::ColliderConstructor;
use bevy::light::{NotShadowCaster, NotShadowReceiver};
use bevy::prelude::*;
use bevy::render::render_resource::Face;
use serde::Deserialize;
use std::collections::{HashMap, HashSet};
use crate::{
asset_server_path, inspector_component_active, standard_material_asset_path, ColliderDesc,
ColliderShapeDesc, EditorAssetRef, InspectorOrder, LevelObject, MaterialDesc, MaterialOverride,
StaticMeshRenderer, StaticMeshRendererEntry, COMPONENT_COLLIDER_DESC, COMPONENT_MATERIAL_DESC,
asset_server_path, authoring_component_active, standard_material_asset_path,
AuthoringComponentStates, ColliderDesc, ColliderShapeDesc, EditorAssetRef,
HydratedRendererMaterialBinding, InspectorOrder, LevelObject, MaterialAlphaMode, MaterialAsset,
MaterialDesc, MaterialInstanceAsset, MaterialOverride, MaterialRef, StaticMeshRenderer,
StaticMeshRendererEntry, COMPONENT_COLLIDER_DESC, COMPONENT_MATERIAL_DESC,
COMPONENT_STATIC_MESH_RENDERER,
};
@@ -35,16 +38,39 @@ struct ResolvedStaticMeshMaterial {
material_label: String,
}
#[derive(Debug, Clone)]
pub(crate) struct ResolvedRendererDraw {
pub mesh_label: String,
pub source_node: Option<String>,
}
/// Cache for generated static mesh artifact lookups.
#[derive(Resource, Default)]
pub struct StaticMeshArtifactCache {
parts: HashMap<(String, String), ResolvedStaticMeshPart>,
materials: HashMap<(String, String), ResolvedStaticMeshMaterial>,
draw_bindings: HashMap<(String, String), ResolvedRendererDraw>,
loaded_assets: HashSet<String>,
failed_assets: HashSet<String>,
project_materials: HashMap<MaterialRef, Handle<StandardMaterial>>,
}
impl StaticMeshArtifactCache {
pub(crate) fn resolve_draw_binding(
&mut self,
asset_id: &str,
slot_id: &crate::ComponentInstanceId,
) -> Option<ResolvedRendererDraw> {
let key = (asset_id.to_string(), slot_id.0.clone());
if let Some(binding) = self.draw_bindings.get(&key) {
return Some(binding.clone());
}
if !self.loaded_assets.contains(asset_id) && !self.failed_assets.contains(asset_id) {
self.load_artifact(asset_id);
}
self.draw_bindings.get(&key).cloned()
}
fn resolve(&mut self, mesh: &EditorAssetRef) -> Option<ResolvedStaticMeshPart> {
if !mesh.is_resolved() {
return None;
@@ -95,17 +121,18 @@ impl StaticMeshArtifactCache {
} else {
part.id.clone()
};
self.parts.insert(
(asset_id.to_string(), part_id),
ResolvedStaticMeshPart {
source_path: manifest.source.path.clone(),
let slot_id = format!("slot:{part_id}");
self.draw_bindings.insert(
(asset_id.to_string(), slot_id),
ResolvedRendererDraw {
mesh_label: part.mesh_label.clone(),
material_label: part.material_label.clone(),
source_node: part.source_node.clone(),
},
);
if let Some(material_label) = part.material_label {
if let Some(material_label) = part.material_label.clone() {
let material_id = part
.material_id
.clone()
.filter(|id| !id.trim().is_empty())
.unwrap_or_else(|| material_id_from_label(&material_label));
self.materials
@@ -115,6 +142,24 @@ impl StaticMeshArtifactCache {
material_label,
});
}
if part.skinned
|| manifest.metadata.animation_count > 0
|| manifest.metadata.skin_count > 0
{
warn!(
"Static mesh artifact part {} requires an animated/skinned hierarchy and was excluded from StaticMeshRenderer hydration",
part.mesh_label
);
continue;
}
self.parts.insert(
(asset_id.to_string(), part_id),
ResolvedStaticMeshPart {
source_path: manifest.source.path.clone(),
mesh_label: part.mesh_label.clone(),
material_label: part.material_label.clone(),
},
);
}
self.loaded_assets.insert(asset_id.to_string());
}
@@ -130,9 +175,19 @@ impl StaticMeshArtifactCache {
struct StaticMeshResolveManifest {
source: StaticMeshResolveSource,
#[serde(default)]
metadata: StaticMeshResolveMetadata,
#[serde(default)]
parts: Vec<StaticMeshResolvePart>,
}
#[derive(Debug, Default, Deserialize)]
struct StaticMeshResolveMetadata {
#[serde(default)]
animation_count: usize,
#[serde(default)]
skin_count: usize,
}
#[derive(Debug, Deserialize)]
struct StaticMeshResolveSource {
path: String,
@@ -147,6 +202,10 @@ struct StaticMeshResolvePart {
material_id: Option<String>,
#[serde(default)]
material_label: Option<String>,
#[serde(default)]
source_node: Option<String>,
#[serde(default)]
skinned: bool,
}
#[allow(clippy::type_complexity)]
@@ -162,6 +221,7 @@ pub fn hydrate_static_mesh_renderers(
Option<&MaterialDesc>,
Option<&MaterialOverride>,
Option<&ColliderDesc>,
Option<&AuthoringComponentStates>,
Option<&InspectorOrder>,
),
(
@@ -172,6 +232,7 @@ pub fn hydrate_static_mesh_renderers(
Changed<MaterialDesc>,
Changed<MaterialOverride>,
Changed<ColliderDesc>,
Changed<AuthoringComponentStates>,
Changed<InspectorOrder>,
)>,
),
@@ -179,15 +240,17 @@ pub fn hydrate_static_mesh_renderers(
children: Query<&Children>,
generated_parts: Query<(), With<HydratedStaticMeshPart>>,
) {
for (entity, renderer, parent_material, material_override, collider, order) in &renderers {
for (entity, renderer, parent_material, material_override, collider, states, order) in
&renderers
{
despawn_static_mesh_parts(&mut commands, entity, &children, &generated_parts);
if !inspector_component_active(order, COMPONENT_STATIC_MESH_RENDERER) {
if !authoring_component_active(states, order, COMPONENT_STATIC_MESH_RENDERER) {
continue;
}
let parent_material =
parent_material.filter(|_| inspector_component_active(order, COMPONENT_MATERIAL_DESC));
let parent_material = parent_material
.filter(|_| authoring_component_active(states, order, COMPONENT_MATERIAL_DESC));
let collider =
collider.filter(|_| inspector_component_active(order, COMPONENT_COLLIDER_DESC));
collider.filter(|_| authoring_component_active(states, order, COMPONENT_COLLIDER_DESC));
spawn_static_mesh_parts(
&mut commands,
&asset_server,
@@ -237,6 +300,7 @@ pub fn spawn_static_mesh_parts(
asset_server,
materials,
artifact_cache,
renderer,
entry,
&resolved,
parent_material,
@@ -253,6 +317,11 @@ pub fn spawn_static_mesh_parts(
Name::new(name),
Mesh3d(mesh_handle),
MeshMaterial3d(material_handle),
HydratedRendererMaterialBinding {
owner: parent,
slot_id: effective_material_slot_id(entry),
effective_material: effective_material_ref(renderer, entry).cloned(),
},
entry.local_transform,
Visibility::Visible,
ChildOf(parent),
@@ -296,6 +365,7 @@ fn material_for_entry(
asset_server: &AssetServer,
materials: &mut Assets<StandardMaterial>,
artifact_cache: &mut StaticMeshArtifactCache,
renderer: &StaticMeshRenderer,
entry: &StaticMeshRendererEntry,
resolved: &ResolvedStaticMeshPart,
parent_material: Option<&MaterialDesc>,
@@ -315,8 +385,13 @@ fn material_for_entry(
return materials.add(material_from_desc(asset_server, override_material));
}
if let Some(material_ref) = entry.material.as_ref() {
if let Some(resolved_material) = artifact_cache.resolve_material(material_ref) {
if let Some(material_ref) = effective_material_ref(renderer, entry) {
if let Some(handle) =
resolve_shared_material(asset_server, materials, artifact_cache, material_ref)
{
return handle;
}
if let Some(resolved_material) = artifact_cache.resolve_material(&material_ref.0) {
let source_path = asset_server_path(&resolved_material.source_path);
return asset_server.load(standard_material_asset_path(
&source_path,
@@ -325,16 +400,121 @@ fn material_for_entry(
}
debug!(
"Static mesh material ref unresolved: asset_id='{}' material='{}' label='{}'",
material_ref.asset_id, material_ref.sub_asset_id, material_ref.label
material_ref.0.asset_id, material_ref.0.sub_asset_id, material_ref.0.label
);
}
// Read-only compatibility path for schema-v1/v2 scenes. The explicit project upgrader moves
// this reference into `RendererMaterialSet` and clears the legacy draw-part field.
if let Some(material_ref) = entry.material.as_ref() {
let material_ref = MaterialRef::new(material_ref.clone());
if let Some(handle) =
resolve_shared_material(asset_server, materials, artifact_cache, &material_ref)
{
return handle;
}
if let Some(resolved_material) = artifact_cache.resolve_material(&material_ref.0) {
let source_path = asset_server_path(&resolved_material.source_path);
return asset_server.load(standard_material_asset_path(
&source_path,
&resolved_material.material_label,
));
}
}
if let Some(label) = resolved.material_label.as_deref() {
let source_path = asset_server_path(&resolved.source_path);
return asset_server.load(standard_material_asset_path(&source_path, label));
}
materials.add(StandardMaterial::default())
materials.add(error_material())
}
fn effective_material_slot_id(entry: &StaticMeshRendererEntry) -> crate::ComponentInstanceId {
if entry.material_slot_id.0.trim().is_empty() {
entry.id.clone()
} else {
entry.material_slot_id.clone()
}
}
fn effective_material_ref<'a>(
renderer: &'a StaticMeshRenderer,
entry: &'a StaticMeshRendererEntry,
) -> Option<&'a MaterialRef> {
let slot_id = effective_material_slot_id(entry);
renderer.materials.effective_material(&slot_id)
}
fn resolve_shared_material(
asset_server: &AssetServer,
materials: &mut Assets<StandardMaterial>,
cache: &mut StaticMeshArtifactCache,
reference: &MaterialRef,
) -> Option<Handle<StandardMaterial>> {
if let Some(handle) = cache.project_materials.get(reference) {
return Some(handle.clone());
}
let path = reference.0.source_path.as_deref()?;
let desc_and_state = MaterialAsset::load_from_path(path)
.map(|asset| (asset.material, asset.render_state))
.or_else(|_| {
let instance = MaterialInstanceAsset::load_from_path(path)?;
let base_path = instance.base.0.source_path.as_deref().ok_or_else(|| {
format!(
"material instance {} has no loadable base path",
instance.label
)
})?;
let base = MaterialAsset::load_from_path(base_path)?;
let mut desc = base.material;
instance.apply_to(&mut desc);
Ok::<_, String>((desc, base.render_state))
})
.ok()?;
let mut material = material_from_desc(asset_server, &desc_and_state.0);
material.alpha_mode = match desc_and_state.1.alpha_mode {
MaterialAlphaMode::Opaque => AlphaMode::Opaque,
MaterialAlphaMode::Cutout => AlphaMode::Mask(desc_and_state.1.alpha_cutoff),
};
material.cull_mode = (!desc_and_state.1.double_sided).then_some(Face::Back);
let handle = materials.add(material);
cache
.project_materials
.insert(reference.clone(), handle.clone());
Some(handle)
}
pub(crate) fn resolve_renderer_material_handle(
asset_server: &AssetServer,
materials: &mut Assets<StandardMaterial>,
cache: &mut StaticMeshArtifactCache,
reference: &MaterialRef,
) -> Option<Handle<StandardMaterial>> {
if let Some(handle) = resolve_shared_material(asset_server, materials, cache, reference) {
return Some(handle);
}
let resolved = cache.resolve_material(&reference.0)?;
let source_path = asset_server_path(&resolved.source_path);
Some(asset_server.load(standard_material_asset_path(
&source_path,
&resolved.material_label,
)))
}
pub(crate) fn renderer_error_material(
materials: &mut Assets<StandardMaterial>,
) -> Handle<StandardMaterial> {
materials.add(error_material())
}
fn error_material() -> StandardMaterial {
StandardMaterial {
base_color: Color::srgb(1.0, 0.0, 1.0),
perceptual_roughness: 0.35,
metallic: 0.0,
..default()
}
}
fn labeled_asset_path(path: &str, label: &str) -> String {
@@ -392,3 +572,58 @@ fn stable_sub_asset_slug(label: &str) -> String {
}
slug.trim_matches('_').to_string()
}
#[cfg(test)]
mod tests {
use super::*;
use std::path::PathBuf;
struct TestManifest(PathBuf);
impl Drop for TestManifest {
fn drop(&mut self) {
let _ = std::fs::remove_file(&self.0);
}
}
fn write_manifest(asset_id: &str, animation_count: usize, skinned: bool) -> TestManifest {
let path = PathBuf::from(static_mesh_manifest_path(asset_id));
std::fs::create_dir_all(path.parent().unwrap()).unwrap();
std::fs::write(
&path,
format!(
r#"(
source: (path: "assets/models/test.glb"),
metadata: (animation_count: {animation_count}),
parts: [(
id: "mesh:test",
mesh_label: "Mesh0/Primitive0",
skinned: {skinned},
)],
)"#
),
)
.unwrap();
TestManifest(path)
}
#[test]
fn cache_refuses_skin_bound_parts() {
const ASSET_ID: &str = "7cd29974-1503-4084-b4a0-7483d0a57d7d";
let _manifest = write_manifest(ASSET_ID, 0, true);
let mut cache = StaticMeshArtifactCache::default();
let reference = EditorAssetRef::new(ASSET_ID, "mesh:test", "Test");
assert!(cache.resolve(&reference).is_none());
}
#[test]
fn cache_refuses_geometry_from_animated_sources() {
const ASSET_ID: &str = "7f6fcf6a-e978-4dc6-8738-16d52fc3ed03";
let _manifest = write_manifest(ASSET_ID, 1, false);
let mut cache = StaticMeshArtifactCache::default();
let reference = EditorAssetRef::new(ASSET_ID, "mesh:test", "Test");
assert!(cache.resolve(&reference).is_none());
}
}