Upgrade to Bevy 0.19 and harden editor workflows
CI / Format, lint, test, build (push) Has been cancelled

This commit is contained in:
Rbanh committed 2026-07-09 23:43:47 -04:00
1 parent 3f85d25cc7
commit b5e561904c
204 files changed
+6972 -29907

No files matched your search

+56 -11
View File
@@ -29,7 +29,10 @@ use static_meshes::{
hydrate_static_mesh_renderers, spawn_static_mesh_parts, HydratedStaticMeshPart,
StaticMeshArtifactCache,
};
use visibility::{init_editor_visibility_on_spawn, sync_editor_visibility};
use visibility::{
ensure_level_object_visibility_hierarchy, init_editor_visibility_on_spawn,
sync_editor_visibility, visibility_from_editor,
};
use crate::{
inspector_component_active, BrushDesc, ColliderDesc, EditorVisibility, InspectorOrder,
@@ -61,12 +64,21 @@ impl Plugin for HydrationPlugin {
)
.add_systems(
Update,
(sync_editor_visibility, init_editor_visibility_on_spawn).chain(),
(
ensure_level_object_visibility_hierarchy,
sync_editor_visibility,
init_editor_visibility_on_spawn,
)
.chain(),
);
}
}
/// Runs the full hydration chain immediately (e.g. after scene load in the editor).
#[expect(
clippy::type_complexity,
reason = "exclusive hydration snapshots several authored component combinations"
)]
pub fn flush_level_object_hydration(world: &mut World) {
if !world.contains_resource::<StaticMeshArtifactCache>() {
world.insert_resource(StaticMeshArtifactCache::default());
@@ -227,8 +239,9 @@ pub fn flush_level_object_hydration(world: &mut World) {
)> = SystemState::new(world);
{
let (mut commands, asset_server, mut meshes, mut materials, mut artifact_cache) =
state.get_mut(world);
let (mut commands, asset_server, mut meshes, mut materials, mut artifact_cache) = state
.get_mut(world)
.expect("hydrate_level_objects system params should be valid");
for (entity, primitive) in primitives {
let mesh = meshes.add(primitive_mesh(&primitive));
@@ -285,12 +298,21 @@ pub fn flush_level_object_hydration(world: &mut World) {
state.apply(world);
for (entity, editor) in visibility_targets {
let visibility = visibility_from_editor(editor);
if let Some(mut vis) = world.get_mut::<Visibility>(entity) {
*vis = if editor.visible {
Visibility::Visible
} else {
Visibility::Hidden
};
*vis = visibility;
} else if let Ok(mut entity_mut) = world.get_entity_mut(entity) {
entity_mut.insert(visibility);
}
if world.get::<InheritedVisibility>(entity).is_none() {
if let Ok(mut entity_mut) = world.get_entity_mut(entity) {
entity_mut.insert(InheritedVisibility::default());
}
}
if world.get::<ViewVisibility>(entity).is_none() {
if let Ok(mut entity_mut) = world.get_entity_mut(entity) {
entity_mut.insert(ViewVisibility::default());
}
}
}
}
@@ -300,8 +322,8 @@ mod tests {
use super::flush_level_object_hydration;
use super::strip::strip_hydrated_entity;
use crate::{
AuthoringLightKind, ColorDesc, InspectorOrder, LevelObject, LightDesc, MaterialDesc,
Primitive, COMPONENT_LIGHT_DESC,
AuthoringLightKind, ColorDesc, EditorVisibility, InspectorOrder, LevelObject, LightDesc,
MaterialDesc, Primitive, COMPONENT_LIGHT_DESC,
};
use avian3d::prelude::*;
use bevy::prelude::*;
@@ -324,6 +346,29 @@ mod tests {
assert!(app.world().get::<PointLight>(entity).is_some());
}
#[test]
fn flush_hydration_initializes_level_object_visibility_hierarchy() {
let mut app = App::new();
app.add_plugins(MinimalPlugins);
app.add_plugins(AssetPlugin::default());
app.add_plugins(bevy::pbr::MaterialPlugin::<StandardMaterial>::default());
app.init_asset::<Mesh>();
let entity = app
.world_mut()
.spawn((LevelObject, EditorVisibility { visible: false }))
.id();
flush_level_object_hydration(app.world_mut());
assert_eq!(
app.world().get::<Visibility>(entity),
Some(&Visibility::Hidden)
);
assert!(app.world().get::<InheritedVisibility>(entity).is_some());
assert!(app.world().get::<ViewVisibility>(entity).is_some());
}
#[test]
fn flush_hydration_skips_point_light_when_solari_is_active() {
let mut app = App::new();