Fix sample hydration rendering regressions
This commit is contained in:
1 parent
06010c5922
commit
d52cc2e3b7
8 files changed
+193
-39
No files matched your search
@@ -2171,6 +2171,8 @@ fn load_composed_subscenes(
|
||||
}
|
||||
|
||||
fn finalize_scene_load(world: &mut World) {
|
||||
shared::initialize_level_object_visibility_hierarchy(world);
|
||||
|
||||
let rendering = world
|
||||
.resource::<settings::ProjectSettings>()
|
||||
.rendering
|
||||
@@ -2490,12 +2492,20 @@ mod tests {
|
||||
.world_mut()
|
||||
.spawn((
|
||||
LevelObject,
|
||||
EditorVisibility { visible: false },
|
||||
BrushDesc::default(),
|
||||
ColliderDesc::static_cuboid(Vec3::ONE),
|
||||
))
|
||||
.id();
|
||||
|
||||
finalize_scene_load(app.world_mut());
|
||||
assert_eq!(
|
||||
app.world().get::<Visibility>(actor),
|
||||
Some(&Visibility::Hidden),
|
||||
"scene actors must receive authored visibility before Update hydration"
|
||||
);
|
||||
assert!(app.world().get::<InheritedVisibility>(actor).is_some());
|
||||
assert!(app.world().get::<ViewVisibility>(actor).is_some());
|
||||
assert!(
|
||||
app.world().get::<Children>(actor).is_none(),
|
||||
"scene finalization must not create collider children ahead of Update"
|
||||
@@ -2511,6 +2521,7 @@ mod tests {
|
||||
.world()
|
||||
.get::<avian3d::prelude::ColliderConstructor>(first_child)
|
||||
.is_some());
|
||||
assert!(app.world().get::<InheritedVisibility>(actor).is_some());
|
||||
|
||||
app.update();
|
||||
assert_eq!(
|
||||
@@ -2522,6 +2533,57 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn brush_sample_parents_own_visibility_before_generated_meshes_attach() {
|
||||
let project_root = PathBuf::from(env!("CARGO_MANIFEST_DIR"))
|
||||
.join("../..")
|
||||
.canonicalize()
|
||||
.unwrap();
|
||||
let sample_path = project_root.join("assets/levels/samples/brush_blockout.scn.ron");
|
||||
let mut app = App::new();
|
||||
app.add_plugins(MinimalPlugins)
|
||||
.add_plugins(AssetPlugin::default())
|
||||
.add_plugins(bevy::pbr::MaterialPlugin::<StandardMaterial>::default())
|
||||
.init_asset::<Mesh>()
|
||||
.add_plugins(shared::SharedTypesPlugin);
|
||||
app.world_mut()
|
||||
.insert_resource(settings::ProjectSettings::default());
|
||||
app.world_mut()
|
||||
.insert_resource(crate::project_io::ProjectWorkspace {
|
||||
root: project_root.display().to_string(),
|
||||
..Default::default()
|
||||
});
|
||||
app.world_mut()
|
||||
.insert_resource(crate::ui::hierarchy_state::HierarchyPanelState::default());
|
||||
|
||||
load_level(app.world_mut(), &sample_path).unwrap();
|
||||
|
||||
let brush_actors: Vec<Entity> = app
|
||||
.world_mut()
|
||||
.query_filtered::<Entity, (With<LevelObject>, With<BrushDesc>)>()
|
||||
.iter(app.world())
|
||||
.collect();
|
||||
assert!(!brush_actors.is_empty());
|
||||
for actor in &brush_actors {
|
||||
assert!(app.world().get::<InheritedVisibility>(*actor).is_some());
|
||||
assert!(app.world().get::<ViewVisibility>(*actor).is_some());
|
||||
assert!(app.world().get::<Children>(*actor).is_none());
|
||||
}
|
||||
|
||||
app.update();
|
||||
|
||||
for actor in brush_actors {
|
||||
let generated_meshes = app
|
||||
.world()
|
||||
.get::<Children>(actor)
|
||||
.expect("brush hydration should attach generated mesh children");
|
||||
assert!(generated_meshes
|
||||
.iter()
|
||||
.any(|child| app.world().get::<Mesh3d>(child).is_some()));
|
||||
assert!(app.world().get::<InheritedVisibility>(actor).is_some());
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn scene_serialization_persists_composition_without_composed_members() {
|
||||
let mut app = App::new();
|
||||
|
||||
Reference in new issue
Block a user