Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
62b538999d | ||
|
|
d52cc2e3b7 | ||
|
|
06010c5922 | ||
|
|
c55f34780f | ||
|
|
1ab3886028 |
No files matched your search
@@ -7,6 +7,7 @@ rustflags = ["-C", "link-arg=-fuse-ld=mold"]
|
||||
[alias]
|
||||
clean-target = "run -p xtask --bin clean-target --"
|
||||
validate-levels = "run -p xtask --features validate-levels --bin validate-levels --"
|
||||
validate-samples = "run -p xtask --features validate-samples --bin validate-samples --"
|
||||
bake-navigation = "run -p xtask --features validate-levels --bin bake-navigation --"
|
||||
package-project = "run -p xtask --features validate-levels --bin package-project --"
|
||||
upgrade-project = "run -p xtask --features validate-levels --bin upgrade-project --"
|
||||
@@ -0,0 +1,66 @@
|
||||
# Editor Sample Regression Pack
|
||||
|
||||
Date: 2026-07-13
|
||||
Issue: BS-JD-501 / Gitea #32
|
||||
Milestone: M5 - Regression, docs, and first-hour UX
|
||||
|
||||
## Goal
|
||||
|
||||
Ship a deterministic five-scene editor regression pack that is easy to open from the editor and
|
||||
that fails headless validation when its catalog, authored data, or referenced assets drift. The pack
|
||||
must cover Brush, Material, Terrain, Physics Placement, and Rendering workflows.
|
||||
|
||||
## Decisions
|
||||
|
||||
- `assets/samples/editor_samples.ron` is the conventional, versioned pack manifest. This remains a
|
||||
QA/editor convention and does not extend `ProjectSettings`.
|
||||
- The manifest is parsed and validated in the `scene` crate. Editor UI and headless tooling consume
|
||||
that one representation.
|
||||
- Every entry has a stable ID, label, area, project-relative `.scn.ron` path, summary, and nonempty
|
||||
operator checks. Manifest order is menu and report order.
|
||||
- Exactly one entry for each required area is release-gated. Scene paths must remain regular files
|
||||
inside `assets/levels/`; traversal, absolute paths, symlink escapes, duplicates, and future schemas
|
||||
are blocking.
|
||||
- Existing accepted terrain, physics-placement, and rendering fixtures remain canonical entries.
|
||||
Add dedicated brush and material scenes under `assets/levels/samples/` and strengthen weak visual
|
||||
anchors in the existing fixtures instead of duplicating them.
|
||||
- `cargo validate-samples --project .` combines pack-specific structure/feature checks with the
|
||||
authoritative `validate_project` report. It verifies stable actor IDs, required area components,
|
||||
authoring-only scene documents, and referenced content.
|
||||
- Terrain descriptors and their shared material layers become first-class project-validation input.
|
||||
Actor-owned invalid descriptors or missing material references are blocking findings.
|
||||
- `File > Open Sample` is backed by a cached project catalog and opens through normal scene-tab I/O.
|
||||
Invalid or unavailable catalogs produce a disabled, actionable row rather than a panic.
|
||||
- CI hydrates Git LFS before content validation and runs both validation commands. Packaged-runtime
|
||||
tests remain deferred by project-owner request.
|
||||
|
||||
## Implementation
|
||||
|
||||
1. Add the manifest schema, deterministic report, safe path resolver, and sample feature checks to
|
||||
`scene::sample_pack`, with malformed/missing/duplicate/path-escape fixture tests.
|
||||
2. Add typed `TerrainDesc` validation and base/layer material dependency collection to authoritative
|
||||
project validation, including owner-attributed tests.
|
||||
3. Add the `validate-samples` xtask binary, Cargo alias, JSON mode, stable console summary, and CI
|
||||
steps. Enable LFS hydration at checkout and verify hydrated objects.
|
||||
4. Add the five-entry manifest, `brush_blockout.scn.ron`, and `material_lab.scn.ron`. Give every
|
||||
sample actor a stable `ActorId`; add visible rendering anchors and distinct physics shapes where
|
||||
the current fixtures are ambiguous.
|
||||
5. Load the catalog after project startup, render `File > Open Sample` in manifest order, and route a
|
||||
selected stable ID through scene I/O. Add unknown-entry and deterministic-row tests.
|
||||
6. Add a no-GPU typed-deserialization test over every manifest scene so unknown Bevy component
|
||||
registrations fail before native QA.
|
||||
7. Document pack contracts, per-scene checks, release commands, and the editor workflow. Update ADR
|
||||
0028, the root README checklist/controls, editor/docs indexes, feature guides, roadmap status,
|
||||
debt audit, and production-readiness evidence.
|
||||
8. Run source gates, open all five samples through the native menu, exercise one representative tool
|
||||
interaction per area, inspect logs, and attach representative native issue images when useful.
|
||||
|
||||
## Acceptance
|
||||
|
||||
- Five manifest entries cover all required areas and open through `File > Open Sample`.
|
||||
- Every entry type-deserializes and has stable actor IDs plus its required authored feature.
|
||||
- `validate-levels` reports terrain material dependencies and has no blocking findings.
|
||||
- `validate-samples` is deterministic, CI-backed, and exits nonzero for pack or project blockers.
|
||||
- Native viewport captures are nonblank, correctly framed, and free of missing-reference, hydration,
|
||||
render, or operator errors.
|
||||
- Documentation gives contributors a single release-use workflow and explains every sample check.
|
||||
@@ -0,0 +1,33 @@
|
||||
# Operator Invariants Completion
|
||||
|
||||
Working plan for Gitea
|
||||
[`#33`](https://git.spacetrainclubhouse.com/Falling-Metal-Interactive/Blacksite/issues/33).
|
||||
|
||||
## Status
|
||||
|
||||
Implementation complete. Source and headless gates pass on the publication branch; the final exact
|
||||
commit is recorded in the issue closure comment. Packaged-runtime testing remains deferred by the
|
||||
project owner.
|
||||
|
||||
## Scope
|
||||
|
||||
1. Make registered commands distinguish immediate completion from modal Preview ownership.
|
||||
2. Require stable operator IDs and terminal phases for commit, cancel, block, failure, no-op, and
|
||||
automatic interruption paths.
|
||||
3. Make Group Selection and lighting changes atomic history transactions with repeatable undo/redo.
|
||||
4. Exercise production dispatch/finalizers for assets, material drops, brushes, terrain, physics
|
||||
placement, and transform gizmos through reusable semantic projections.
|
||||
5. Publish the invariant contract, acceptance evidence, and production-gate status without claiming
|
||||
release-candidate acceptance.
|
||||
|
||||
## Verification
|
||||
|
||||
- `cargo test -p editor --lib --no-fail-fast`
|
||||
- `cargo clippy -p editor --lib --tests -- -D warnings`
|
||||
- `cargo fmt --all -- --check`
|
||||
- `cargo test --workspace --all-targets --no-fail-fast`
|
||||
- `cargo clippy --workspace --all-targets -- -D warnings`
|
||||
- `cargo validate-levels --project .`
|
||||
|
||||
Live editor checks cover command-palette modal ownership and the grouped selection/lighting history
|
||||
surface. Packaged tests are deliberately excluded until re-enabled by the project owner.
|
||||
@@ -15,12 +15,12 @@ owner requests it again.
|
||||
|
||||
1. Keep one evidence matrix under `docs/editor/evaluations/production-readiness/`; historical H1-H6
|
||||
notes remain context only.
|
||||
2. Close implementation blockers before nominating a candidate: the deformed Solari geometry
|
||||
boundary in `#51`, terrain `#22`-`#24`, physics placement/diagnostics `#25`-`#26`, and their
|
||||
regression fixtures. Collaborative safety `#49`, Material Library/targeted drops `#16`/`#18`,
|
||||
and native-dialog responsiveness `#52` are accepted and integrated.
|
||||
3. Complete the representative regression project, mutation-invariant coverage, performance budgets,
|
||||
and first-hour workflow tracked by `#32`-`#36`.
|
||||
2. Close implementation blockers before nominating a candidate. Renderer foundation `#51`, terrain
|
||||
`#22`-`#24`, physics placement/diagnostics `#25`-`#26`, operator invariants `#33`, collaborative
|
||||
safety `#49`, Material Library/targeted drops `#16`/`#18`, and native-dialog responsiveness `#52`
|
||||
are accepted and integrated.
|
||||
3. Complete the representative regression project, performance budgets, and first-hour workflow
|
||||
tracked by `#32`, `#34`, `#35`, and `#36`.
|
||||
4. Nominate one exact commit, validate it from a clean checkout, and record source/headless results.
|
||||
5. When packaged testing is re-enabled, run the candidate's package/build and packaged-runtime
|
||||
matrix without substituting older artifacts.
|
||||
|
||||
@@ -17,6 +17,11 @@ jobs:
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
lfs: true
|
||||
|
||||
- name: Verify Git LFS checkout
|
||||
run: git lfs fsck
|
||||
|
||||
- name: Install Linux dependencies
|
||||
run: |
|
||||
@@ -55,6 +60,9 @@ jobs:
|
||||
- name: Validate level scenes
|
||||
run: cargo validate-levels
|
||||
|
||||
- name: Validate editor sample pack
|
||||
run: cargo validate-samples
|
||||
|
||||
- name: Clippy launch feature matrix
|
||||
run: cargo clippy -p editor -p game --bins --features dev,hot-reload -- -D warnings
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ cargo clippy --workspace --all-targets -- -D warnings
|
||||
cargo clippy -p editor -p game --bins --features dev,hot-reload -- -D warnings
|
||||
cargo test --workspace
|
||||
cargo validate-levels
|
||||
cargo validate-samples
|
||||
cargo bake-navigation --project . --check
|
||||
# Validate one artifact without opening a game window
|
||||
cargo run -p game -- --validate-navigation assets/navigation/generated/navigation_showcase_humanoid.nav.ron
|
||||
@@ -164,7 +165,7 @@ deep-stale variants.
|
||||
| Drag actor between rows / onto Scene Root (Hierarchy, Manual sort) | Reorder siblings / unparent to the root |
|
||||
| Hierarchy lock | Excludes the actor from selection, gizmos, multi-drag, structural drops, and mutating context actions |
|
||||
| Hierarchy context | Group selection, create authored local children below linked prefab roots, remove/reparent generated members through same-layer structural overrides, or unparent |
|
||||
| File menu | New, non-blocking native Open/Save As, recovery restore/keep-copy/discard when available, Import Assets, Export Selection, Save Selection As Prefab (including linked-root variants), Recent Scenes |
|
||||
| File menu | New, non-blocking native Open/Save As, **Open Sample** for the five-area regression pack, recovery restore/keep-copy/discard when available, Import Assets, Export Selection, Save Selection As Prefab (including linked-root variants), Recent Scenes |
|
||||
| Status strip / Asset Details source-state chip | Inspect compact clean, modified, untracked, conflicted, read-only, and optional ownership status; hover for the source path and provider details |
|
||||
| Authored File Not Saved dialog | Resolve an external edit, read-only target, or ownership lock with Reload, Compare Metadata, Save As, or Cancel; the editor never offers force overwrite |
|
||||
| Main toolbar, right side | Switch or close independent scene tabs, create an untitled tab, and manage loaded/locked composed subscenes |
|
||||
@@ -417,9 +418,10 @@ crates/
|
||||
- [x] Cursor/VSCode workspace tasks + launch configs
|
||||
- [x] Opaque Wayland window launch defaults + SDR/HDR runtime toggle
|
||||
- [x] CI workflow for format, check, clippy, tests, and binary builds
|
||||
- [x] Deterministic five-area editor sample regression pack with stable actor IDs, **File > Open Sample**, typed scene checks, headless validation, and committed brush/material/terrain/physics/rendering fixtures ([sample guide](docs/editor/sample-regression-pack.md), [Gitea #32](https://git.spacetrainclubhouse.com/Falling-Metal-Interactive/Blacksite/issues/32))
|
||||
- [x] ADRs for roadmap architecture and Bevy migration policy
|
||||
- [x] Determinism harness: same inputs over same ticks produce the same state summary/hash
|
||||
- [x] Reusable editor operator harness for commit/cancel/block, helper cleanup, dirty state, grouped undo, and undo/redo round trips
|
||||
- [x] Production operator invariants across palette dispatch, assets/material drops, brush/terrain/physics modal tools, grouping/lighting, and the transform finalizer: stable terminal status, exact cancel/failure rollback, helper cleanup, grouped history, and repeated undo/redo projections ([testing contract](docs/editor/operator-regression-testing.md), [evaluation](docs/editor/evaluations/operator-invariants/), [Gitea #33](https://git.spacetrainclubhouse.com/Falling-Metal-Interactive/Blacksite/issues/33))
|
||||
- [x] Verify: `cargo fmt --check` / `cargo check --workspace` / `cargo clippy --workspace` / strict foundation clippy / `cargo test -p sim`
|
||||
- [x] Stable asset registry with UUIDs + import settings in asset browser details
|
||||
- [x] Asset Browser expandable model subasset shelves, independent mesh/material/texture thumbnails, staged import/material details with shader-schema parameters, context actions, and trash-first file removal
|
||||
|
||||
@@ -287,6 +287,42 @@
|
||||
),
|
||||
dependencies: [],
|
||||
),
|
||||
(
|
||||
id: ("607864bf-fa77-4f9e-acc9-2c0906d34163"),
|
||||
path: "assets/levels/samples/material_lab.scn.ron",
|
||||
label: "material_lab.scn",
|
||||
kind_tag: "Level",
|
||||
import_settings: (
|
||||
scale: 1.0,
|
||||
generate_collider: true,
|
||||
lod0_only: true,
|
||||
placement_mode: StaticAsset,
|
||||
hierarchy_mode: SingleActor,
|
||||
material_policy: SourceMaterials,
|
||||
static_mesh_manifest_path: None,
|
||||
animation_manifest_path: None,
|
||||
default_animation_clip_id: None,
|
||||
),
|
||||
dependencies: [],
|
||||
),
|
||||
(
|
||||
id: ("bca13177-afa9-4691-9b40-288059c7a57e"),
|
||||
path: "assets/levels/samples/brush_blockout.scn.ron",
|
||||
label: "brush_blockout.scn",
|
||||
kind_tag: "Level",
|
||||
import_settings: (
|
||||
scale: 1.0,
|
||||
generate_collider: true,
|
||||
lod0_only: true,
|
||||
placement_mode: StaticAsset,
|
||||
hierarchy_mode: SingleActor,
|
||||
material_policy: SourceMaterials,
|
||||
static_mesh_manifest_path: None,
|
||||
animation_manifest_path: None,
|
||||
default_animation_clip_id: None,
|
||||
),
|
||||
dependencies: [],
|
||||
),
|
||||
(
|
||||
id: ("5a2307d0-48e5-40d3-a5c9-527c0cfd30f4"),
|
||||
path: "assets/levels/editor_scene.scn.ron",
|
||||
@@ -395,6 +431,24 @@
|
||||
),
|
||||
dependencies: [],
|
||||
),
|
||||
(
|
||||
id: ("e42185de-cda2-4a9e-9df0-df67ccd86123"),
|
||||
path: "assets/samples/editor_samples.ron",
|
||||
label: "editor_samples",
|
||||
kind_tag: "Level",
|
||||
import_settings: (
|
||||
scale: 1.0,
|
||||
generate_collider: true,
|
||||
lod0_only: true,
|
||||
placement_mode: StaticAsset,
|
||||
hierarchy_mode: SingleActor,
|
||||
material_policy: SourceMaterials,
|
||||
static_mesh_manifest_path: None,
|
||||
animation_manifest_path: None,
|
||||
default_animation_clip_id: None,
|
||||
),
|
||||
dependencies: [],
|
||||
),
|
||||
(
|
||||
id: ("04a4e00e-4732-43db-8e99-9cd99b94667b"),
|
||||
path: "assets/animations/generated/113f74df-e39c-41d4-9b5b-e48efe541f7f.animation.ron",
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
),
|
||||
}),
|
||||
2: (components: {
|
||||
"bevy_ecs::name::Name": "Placement Prop A",
|
||||
"bevy_ecs::name::Name": "Placement Cuboid",
|
||||
"bevy_transform::components::transform::Transform": (
|
||||
translation: (-2.0, 3.0, 0.0),
|
||||
rotation: (0.1305262, 0.0, 0.0, 0.9914449),
|
||||
@@ -70,7 +70,7 @@
|
||||
),
|
||||
}),
|
||||
3: (components: {
|
||||
"bevy_ecs::name::Name": "Placement Prop B",
|
||||
"bevy_ecs::name::Name": "Placement Sphere",
|
||||
"bevy_transform::components::transform::Transform": (
|
||||
translation: (0.0, 5.0, 0.0),
|
||||
rotation: (0.0, 0.2164396, 0.0, 0.976296),
|
||||
@@ -96,16 +96,16 @@
|
||||
parameters: [],
|
||||
textures: [],
|
||||
),
|
||||
"shared::components::Primitive": (shape: Box, size: (1.0, 1.6, 1.0)),
|
||||
"shared::components::Primitive": (shape: Sphere, size: (1.6, 1.6, 1.6)),
|
||||
"shared::components::RigidBodyDesc": (body: Static),
|
||||
"shared::components::ColliderDesc": (
|
||||
enabled: true,
|
||||
is_trigger: false,
|
||||
shape: Cuboid(x_length: 1.0, y_length: 1.6, z_length: 1.0),
|
||||
shape: Sphere(radius: 0.8),
|
||||
),
|
||||
}),
|
||||
4: (components: {
|
||||
"bevy_ecs::name::Name": "Placement Prop C",
|
||||
"bevy_ecs::name::Name": "Placement Capsule",
|
||||
"bevy_transform::components::transform::Transform": (
|
||||
translation: (2.0, 7.0, 0.0),
|
||||
rotation: (0.092296, 0.092296, -0.008077, 0.991405),
|
||||
@@ -131,12 +131,12 @@
|
||||
parameters: [],
|
||||
textures: [],
|
||||
),
|
||||
"shared::components::Primitive": (shape: Box, size: (1.4, 0.8, 1.0)),
|
||||
"shared::components::Primitive": (shape: Box, size: (0.9, 1.8, 0.9)),
|
||||
"shared::components::RigidBodyDesc": (body: Static),
|
||||
"shared::components::ColliderDesc": (
|
||||
enabled: true,
|
||||
is_trigger: false,
|
||||
shape: Cuboid(x_length: 1.4, y_length: 0.8, z_length: 1.0),
|
||||
shape: Capsule(radius: 0.45, height: 1.8),
|
||||
),
|
||||
}),
|
||||
5: (components: {
|
||||
|
||||
@@ -1,14 +1,160 @@
|
||||
(schema_version: 4,resources: {
|
||||
},
|
||||
entities: {
|
||||
4294968001: (components: {
|
||||
(schema_version: 4, resources: {}, entities: {
|
||||
1: (components: {
|
||||
"bevy_ecs::name::Name": "Rendering Lab Floor",
|
||||
"bevy_transform::components::transform::Transform": (
|
||||
translation: (1.0, -0.25, 0.0),
|
||||
rotation: (0.0, 0.0, 0.0, 1.0),
|
||||
scale: (1.0, 1.0, 1.0),
|
||||
),
|
||||
"shared::components::ActorId": ("rendering-showcase-floor"),
|
||||
"shared::components::ActorKind": StaticMesh,
|
||||
"shared::components::EditorVisibility": (visible: true),
|
||||
"shared::components::HierarchySiblingIndex": (0),
|
||||
"shared::components::LevelObject": (),
|
||||
"shared::components::Primitive": (shape: Box, size: (38.0, 0.5, 12.0)),
|
||||
"shared::components::MaterialDesc": (
|
||||
shader: (kind: StandardLit, schema_path: None, shader_path: None),
|
||||
base_color: (r: 0.12, g: 0.14, b: 0.16, a: 1.0),
|
||||
metallic: 0.05,
|
||||
roughness: 0.72,
|
||||
emissive_color: (r: 1.0, g: 1.0, b: 1.0, a: 1.0),
|
||||
emissive_intensity: 0.0,
|
||||
base_color_texture: None,
|
||||
emissive_texture: None,
|
||||
normal_map_texture: None,
|
||||
metallic_roughness_texture: None,
|
||||
material_asset_path: None,
|
||||
parameters: [],
|
||||
textures: [],
|
||||
),
|
||||
}),
|
||||
2: (components: {
|
||||
"bevy_ecs::name::Name": "Vignette Anchor",
|
||||
"bevy_transform::components::transform::Transform": (
|
||||
translation: (-12.0, 1.2, 0.0),
|
||||
rotation: (0.0, 0.0, 0.0, 1.0),
|
||||
scale: (1.0, 1.0, 1.0),
|
||||
),
|
||||
"shared::components::ActorId": ("rendering-showcase-vignette-anchor"),
|
||||
"shared::components::ActorKind": StaticMesh,
|
||||
"shared::components::EditorVisibility": (visible: true),
|
||||
"shared::components::HierarchySiblingIndex": (1),
|
||||
"shared::components::LevelObject": (),
|
||||
"shared::components::Primitive": (shape: Sphere, size: (2.4, 2.4, 2.4)),
|
||||
"shared::components::MaterialDesc": (
|
||||
shader: (kind: StandardLit, schema_path: None, shader_path: None),
|
||||
base_color: (r: 0.82, g: 0.18, b: 0.2, a: 1.0),
|
||||
metallic: 0.08,
|
||||
roughness: 0.38,
|
||||
emissive_color: (r: 1.0, g: 0.2, b: 0.2, a: 1.0),
|
||||
emissive_intensity: 0.0,
|
||||
base_color_texture: None,
|
||||
emissive_texture: None,
|
||||
normal_map_texture: None,
|
||||
metallic_roughness_texture: None,
|
||||
material_asset_path: None,
|
||||
parameters: [],
|
||||
textures: [],
|
||||
),
|
||||
}),
|
||||
3: (components: {
|
||||
"bevy_ecs::name::Name": "Fog Anchor",
|
||||
"bevy_transform::components::transform::Transform": (
|
||||
translation: (0.0, 1.4, 0.0),
|
||||
rotation: (0.0, 0.258819, 0.0, 0.9659258),
|
||||
scale: (1.0, 1.0, 1.0),
|
||||
),
|
||||
"shared::components::ActorId": ("rendering-showcase-fog-anchor"),
|
||||
"shared::components::ActorKind": StaticMesh,
|
||||
"shared::components::EditorVisibility": (visible: true),
|
||||
"shared::components::HierarchySiblingIndex": (2),
|
||||
"shared::components::LevelObject": (),
|
||||
"shared::components::Primitive": (shape: Box, size: (2.8, 2.8, 2.8)),
|
||||
"shared::components::MaterialDesc": (
|
||||
shader: (kind: StandardLit, schema_path: None, shader_path: None),
|
||||
base_color: (r: 0.1, g: 0.58, b: 0.72, a: 1.0),
|
||||
metallic: 0.15,
|
||||
roughness: 0.35,
|
||||
emissive_color: (r: 0.1, g: 0.58, b: 0.72, a: 1.0),
|
||||
emissive_intensity: 0.0,
|
||||
base_color_texture: None,
|
||||
emissive_texture: None,
|
||||
normal_map_texture: None,
|
||||
metallic_roughness_texture: None,
|
||||
material_asset_path: None,
|
||||
parameters: [],
|
||||
textures: [],
|
||||
),
|
||||
}),
|
||||
4: (components: {
|
||||
"bevy_ecs::name::Name": "Exposure Anchor",
|
||||
"bevy_transform::components::transform::Transform": (
|
||||
translation: (14.0, 1.3, 0.0),
|
||||
rotation: (0.0, -0.1736482, 0.0, 0.9848078),
|
||||
scale: (1.0, 1.0, 1.0),
|
||||
),
|
||||
"shared::components::ActorId": ("rendering-showcase-exposure-anchor"),
|
||||
"shared::components::ActorKind": StaticMesh,
|
||||
"shared::components::EditorVisibility": (visible: true),
|
||||
"shared::components::HierarchySiblingIndex": (3),
|
||||
"shared::components::LevelObject": (),
|
||||
"shared::components::Primitive": (shape: Box, size: (3.0, 2.6, 3.0)),
|
||||
"shared::components::MaterialDesc": (
|
||||
shader: (kind: StandardLit, schema_path: None, shader_path: None),
|
||||
base_color: (r: 0.92, g: 0.62, b: 0.12, a: 1.0),
|
||||
metallic: 0.12,
|
||||
roughness: 0.32,
|
||||
emissive_color: (r: 1.0, g: 0.65, b: 0.12, a: 1.0),
|
||||
emissive_intensity: 0.0,
|
||||
base_color_texture: None,
|
||||
emissive_texture: None,
|
||||
normal_map_texture: None,
|
||||
metallic_roughness_texture: None,
|
||||
material_asset_path: None,
|
||||
parameters: [],
|
||||
textures: [],
|
||||
),
|
||||
}),
|
||||
5: (components: {
|
||||
"bevy_ecs::name::Name": "Emissive Comparison Panel",
|
||||
"bevy_transform::components::transform::Transform": (
|
||||
translation: (0.0, 2.6, -4.8),
|
||||
rotation: (0.0, 0.0, 0.0, 1.0),
|
||||
scale: (1.0, 1.0, 1.0),
|
||||
),
|
||||
"shared::components::ActorId": ("rendering-showcase-emissive-panel"),
|
||||
"shared::components::ActorKind": StaticMesh,
|
||||
"shared::components::EditorVisibility": (visible: true),
|
||||
"shared::components::HierarchySiblingIndex": (4),
|
||||
"shared::components::LevelObject": (),
|
||||
"shared::components::Primitive": (shape: Box, size: (26.0, 1.2, 0.25)),
|
||||
"shared::components::MaterialDesc": (
|
||||
shader: (kind: StandardLit, schema_path: None, shader_path: None),
|
||||
base_color: (r: 0.15, g: 0.22, b: 0.28, a: 1.0),
|
||||
metallic: 0.0,
|
||||
roughness: 0.35,
|
||||
emissive_color: (r: 0.55, g: 0.85, b: 1.0, a: 1.0),
|
||||
emissive_intensity: 2500.0,
|
||||
base_color_texture: None,
|
||||
emissive_texture: None,
|
||||
normal_map_texture: None,
|
||||
metallic_roughness_texture: None,
|
||||
material_asset_path: Some("assets/materials/emissive_panel.ron"),
|
||||
parameters: [],
|
||||
textures: [],
|
||||
),
|
||||
}),
|
||||
6: (components: {
|
||||
"bevy_ecs::name::Name": "Fog Volume",
|
||||
"bevy_transform::components::transform::Transform": (
|
||||
translation: (0.0, 2.0, 0.0),
|
||||
rotation: (0.0, 0.0, 0.0, 1.0),
|
||||
scale: (1.0, 1.0, 1.0),
|
||||
),
|
||||
"shared::components::ActorId": ("rendering-showcase-fog-volume"),
|
||||
"shared::components::ActorKind": PostProcessVolume,
|
||||
"shared::components::EditorVisibility": (visible: true),
|
||||
"shared::components::HierarchySiblingIndex": (5),
|
||||
"shared::components::LevelObject": (),
|
||||
"shared::components::PostProcessVolumeDesc": (
|
||||
half_extents: (6.0, 3.0, 6.0),
|
||||
@@ -23,14 +169,17 @@
|
||||
label: Some("Foggy courtyard"),
|
||||
),
|
||||
}),
|
||||
4294968002: (components: {
|
||||
7: (components: {
|
||||
"bevy_ecs::name::Name": "Dark Exposure Volume",
|
||||
"bevy_transform::components::transform::Transform": (
|
||||
translation: (14.0, 2.0, 0.0),
|
||||
rotation: (0.0, 0.0, 0.0, 1.0),
|
||||
scale: (1.0, 1.0, 1.0),
|
||||
),
|
||||
"shared::components::ActorId": ("rendering-showcase-exposure-volume"),
|
||||
"shared::components::ActorKind": PostProcessVolume,
|
||||
"shared::components::EditorVisibility": (visible: true),
|
||||
"shared::components::HierarchySiblingIndex": (6),
|
||||
"shared::components::LevelObject": (),
|
||||
"shared::components::PostProcessVolumeDesc": (
|
||||
half_extents: (4.0, 2.5, 4.0),
|
||||
@@ -45,14 +194,17 @@
|
||||
label: Some("Cave mouth"),
|
||||
),
|
||||
}),
|
||||
4294968003: (components: {
|
||||
8: (components: {
|
||||
"bevy_ecs::name::Name": "Vignette FX Volume",
|
||||
"bevy_transform::components::transform::Transform": (
|
||||
translation: (-12.0, 2.0, 0.0),
|
||||
rotation: (0.0, 0.0, 0.0, 1.0),
|
||||
scale: (1.0, 1.0, 1.0),
|
||||
),
|
||||
"shared::components::ActorId": ("rendering-showcase-vignette-volume"),
|
||||
"shared::components::ActorKind": PostProcessVolume,
|
||||
"shared::components::EditorVisibility": (visible: true),
|
||||
"shared::components::HierarchySiblingIndex": (7),
|
||||
"shared::components::LevelObject": (),
|
||||
"shared::components::PostProcessVolumeDesc": (
|
||||
half_extents: (5.0, 2.0, 5.0),
|
||||
@@ -64,5 +216,26 @@
|
||||
label: Some("Vignette demo"),
|
||||
),
|
||||
}),
|
||||
},
|
||||
)
|
||||
9: (components: {
|
||||
"bevy_ecs::name::Name": "Rendering Lab Sun",
|
||||
"bevy_transform::components::transform::Transform": (
|
||||
translation: (0.0, 10.0, 5.0),
|
||||
rotation: (-0.3826834, 0.0, 0.0, 0.9238795),
|
||||
scale: (1.0, 1.0, 1.0),
|
||||
),
|
||||
"shared::components::ActorId": ("rendering-showcase-sun"),
|
||||
"shared::components::ActorKind": Light,
|
||||
"shared::components::EditorVisibility": (visible: true),
|
||||
"shared::components::HierarchySiblingIndex": (8),
|
||||
"shared::components::LevelObject": (),
|
||||
"shared::components::LightDesc": (
|
||||
kind: Directional,
|
||||
color: (r: 1.0, g: 0.95, b: 0.85, a: 1.0),
|
||||
intensity: 100000.0,
|
||||
range: 0.0,
|
||||
shadows: true,
|
||||
inner_angle_deg: 25.0,
|
||||
outer_angle_deg: 35.0,
|
||||
),
|
||||
}),
|
||||
})
|
||||
@@ -0,0 +1,332 @@
|
||||
(schema_version: 4, resources: {}, entities: {
|
||||
1: (components: {
|
||||
"bevy_ecs::name::Name": "Foundation Brush",
|
||||
"bevy_transform::components::transform::Transform": (
|
||||
translation: (0.0, 0.5, 0.0),
|
||||
rotation: (0.0, 0.0, 0.0, 1.0),
|
||||
scale: (1.0, 1.0, 1.0),
|
||||
),
|
||||
"shared::components::ActorId": ("sample-brush-foundation"),
|
||||
"shared::components::ActorKind": Brush,
|
||||
"shared::components::EditorVisibility": (visible: true),
|
||||
"shared::components::HierarchySiblingIndex": (0),
|
||||
"shared::components::LevelObject": (),
|
||||
"shared::components::MaterialDesc": (
|
||||
shader: (kind: StandardLit, schema_path: None, shader_path: None),
|
||||
base_color: (r: 0.55, g: 0.54, b: 0.52, a: 1.0),
|
||||
metallic: 0.0,
|
||||
roughness: 0.85,
|
||||
emissive_color: (r: 1.0, g: 1.0, b: 1.0, a: 1.0),
|
||||
emissive_intensity: 0.0,
|
||||
base_color_texture: None,
|
||||
emissive_texture: None,
|
||||
normal_map_texture: None,
|
||||
metallic_roughness_texture: None,
|
||||
material_asset_path: Some("assets/materials/concrete.ron"),
|
||||
parameters: [],
|
||||
textures: [],
|
||||
),
|
||||
"shared::components::BrushDesc": (
|
||||
kind: Additive,
|
||||
faces: [
|
||||
(
|
||||
id: ("face:+x"),
|
||||
plane: (normal: (1.0, 0.0, 0.0), distance: 5.0),
|
||||
vertices: [(5.0, -0.5, -4.0), (5.0, 0.5, -4.0), (5.0, 0.5, 4.0), (5.0, -0.5, 4.0)],
|
||||
material: None,
|
||||
texture: None,
|
||||
uv_offset: (0.0, 0.0),
|
||||
uv_scale: (1.0, 1.0),
|
||||
uv_rotation: 0.0,
|
||||
smoothing_group: 0,
|
||||
),
|
||||
(
|
||||
id: ("face:-x"),
|
||||
plane: (normal: (-1.0, 0.0, 0.0), distance: 5.0),
|
||||
vertices: [(-5.0, -0.5, 4.0), (-5.0, 0.5, 4.0), (-5.0, 0.5, -4.0), (-5.0, -0.5, -4.0)],
|
||||
material: None,
|
||||
texture: None,
|
||||
uv_offset: (0.0, 0.0),
|
||||
uv_scale: (1.0, 1.0),
|
||||
uv_rotation: 0.0,
|
||||
smoothing_group: 0,
|
||||
),
|
||||
(
|
||||
id: ("face:+y"),
|
||||
plane: (normal: (0.0, 1.0, 0.0), distance: 0.5),
|
||||
vertices: [(-5.0, 0.5, -4.0), (-5.0, 0.5, 4.0), (5.0, 0.5, 4.0), (5.0, 0.5, -4.0)],
|
||||
material: None,
|
||||
texture: None,
|
||||
uv_offset: (0.0, 0.0),
|
||||
uv_scale: (1.0, 1.0),
|
||||
uv_rotation: 0.0,
|
||||
smoothing_group: 0,
|
||||
),
|
||||
(
|
||||
id: ("face:-y"),
|
||||
plane: (normal: (0.0, -1.0, 0.0), distance: 0.5),
|
||||
vertices: [(-5.0, -0.5, 4.0), (-5.0, -0.5, -4.0), (5.0, -0.5, -4.0), (5.0, -0.5, 4.0)],
|
||||
material: None,
|
||||
texture: None,
|
||||
uv_offset: (0.0, 0.0),
|
||||
uv_scale: (1.0, 1.0),
|
||||
uv_rotation: 0.0,
|
||||
smoothing_group: 0,
|
||||
),
|
||||
(
|
||||
id: ("face:+z"),
|
||||
plane: (normal: (0.0, 0.0, 1.0), distance: 4.0),
|
||||
vertices: [(5.0, -0.5, 4.0), (5.0, 0.5, 4.0), (-5.0, 0.5, 4.0), (-5.0, -0.5, 4.0)],
|
||||
material: None,
|
||||
texture: None,
|
||||
uv_offset: (0.0, 0.0),
|
||||
uv_scale: (1.0, 1.0),
|
||||
uv_rotation: 0.0,
|
||||
smoothing_group: 0,
|
||||
),
|
||||
(
|
||||
id: ("face:-z"),
|
||||
plane: (normal: (0.0, 0.0, -1.0), distance: 4.0),
|
||||
vertices: [(-5.0, -0.5, -4.0), (-5.0, 0.5, -4.0), (5.0, 0.5, -4.0), (5.0, -0.5, -4.0)],
|
||||
material: None,
|
||||
texture: None,
|
||||
uv_offset: (0.0, 0.0),
|
||||
uv_scale: (1.0, 1.0),
|
||||
uv_rotation: 0.0,
|
||||
smoothing_group: 0,
|
||||
),
|
||||
],
|
||||
cast_shadows: true,
|
||||
receive_shadows: true,
|
||||
),
|
||||
}),
|
||||
2: (components: {
|
||||
"bevy_ecs::name::Name": "Material Face Tower",
|
||||
"bevy_transform::components::transform::Transform": (
|
||||
translation: (-2.5, 3.0, 0.0),
|
||||
rotation: (0.0, 0.0, 0.0, 1.0),
|
||||
scale: (1.0, 1.0, 1.0),
|
||||
),
|
||||
"shared::components::ActorId": ("sample-brush-material-tower"),
|
||||
"shared::components::ActorKind": Brush,
|
||||
"shared::components::EditorVisibility": (visible: true),
|
||||
"shared::components::HierarchySiblingIndex": (1),
|
||||
"shared::components::LevelObject": (),
|
||||
"shared::components::MaterialDesc": (
|
||||
shader: (kind: StandardLit, schema_path: None, shader_path: None),
|
||||
base_color: (r: 0.55, g: 0.54, b: 0.52, a: 1.0),
|
||||
metallic: 0.0,
|
||||
roughness: 0.85,
|
||||
emissive_color: (r: 1.0, g: 1.0, b: 1.0, a: 1.0),
|
||||
emissive_intensity: 0.0,
|
||||
base_color_texture: None,
|
||||
emissive_texture: None,
|
||||
normal_map_texture: None,
|
||||
metallic_roughness_texture: None,
|
||||
material_asset_path: Some("assets/materials/concrete.ron"),
|
||||
parameters: [],
|
||||
textures: [],
|
||||
),
|
||||
"shared::components::BrushDesc": (
|
||||
kind: Additive,
|
||||
faces: [
|
||||
(
|
||||
id: ("face:+x"),
|
||||
plane: (normal: (1.0, 0.0, 0.0), distance: 1.25),
|
||||
vertices: [(1.25, -2.0, -1.25), (1.25, 2.0, -1.25), (1.25, 2.0, 1.25), (1.25, -2.0, 1.25)],
|
||||
material: None,
|
||||
texture: None,
|
||||
uv_offset: (0.0, 0.0),
|
||||
uv_scale: (1.0, 1.0),
|
||||
uv_rotation: 0.0,
|
||||
smoothing_group: 0,
|
||||
),
|
||||
(
|
||||
id: ("face:-x"),
|
||||
plane: (normal: (-1.0, 0.0, 0.0), distance: 1.25),
|
||||
vertices: [(-1.25, -2.0, 1.25), (-1.25, 2.0, 1.25), (-1.25, 2.0, -1.25), (-1.25, -2.0, -1.25)],
|
||||
material: None,
|
||||
texture: None,
|
||||
uv_offset: (0.0, 0.0),
|
||||
uv_scale: (1.0, 1.0),
|
||||
uv_rotation: 0.0,
|
||||
smoothing_group: 0,
|
||||
),
|
||||
(
|
||||
id: ("face:+y"),
|
||||
plane: (normal: (0.0, 1.0, 0.0), distance: 2.0),
|
||||
vertices: [(-1.25, 2.0, -1.25), (-1.25, 2.0, 1.25), (1.25, 2.0, 1.25), (1.25, 2.0, -1.25)],
|
||||
material: Some((
|
||||
asset_id: "cc2769da-c9a5-4cb3-866a-cc81d0688ee2",
|
||||
sub_asset_id: "material:instance",
|
||||
label: "surface_tint_instance",
|
||||
source_path: Some("assets/materials/surface_tint_instance.ron"),
|
||||
)),
|
||||
texture: None,
|
||||
uv_offset: (0.0, 0.0),
|
||||
uv_scale: (1.0, 1.0),
|
||||
uv_rotation: 0.0,
|
||||
smoothing_group: 0,
|
||||
),
|
||||
(
|
||||
id: ("face:-y"),
|
||||
plane: (normal: (0.0, -1.0, 0.0), distance: 2.0),
|
||||
vertices: [(-1.25, -2.0, 1.25), (-1.25, -2.0, -1.25), (1.25, -2.0, -1.25), (1.25, -2.0, 1.25)],
|
||||
material: None,
|
||||
texture: None,
|
||||
uv_offset: (0.0, 0.0),
|
||||
uv_scale: (1.0, 1.0),
|
||||
uv_rotation: 0.0,
|
||||
smoothing_group: 0,
|
||||
),
|
||||
(
|
||||
id: ("face:+z"),
|
||||
plane: (normal: (0.0, 0.0, 1.0), distance: 1.25),
|
||||
vertices: [(1.25, -2.0, 1.25), (1.25, 2.0, 1.25), (-1.25, 2.0, 1.25), (-1.25, -2.0, 1.25)],
|
||||
material: None,
|
||||
texture: None,
|
||||
uv_offset: (0.0, 0.0),
|
||||
uv_scale: (1.0, 1.0),
|
||||
uv_rotation: 0.0,
|
||||
smoothing_group: 0,
|
||||
),
|
||||
(
|
||||
id: ("face:-z"),
|
||||
plane: (normal: (0.0, 0.0, -1.0), distance: 1.25),
|
||||
vertices: [(-1.25, -2.0, -1.25), (-1.25, 2.0, -1.25), (1.25, 2.0, -1.25), (1.25, -2.0, -1.25)],
|
||||
material: None,
|
||||
texture: None,
|
||||
uv_offset: (0.0, 0.0),
|
||||
uv_scale: (1.0, 1.0),
|
||||
uv_rotation: 0.0,
|
||||
smoothing_group: 0,
|
||||
),
|
||||
],
|
||||
cast_shadows: true,
|
||||
receive_shadows: true,
|
||||
),
|
||||
}),
|
||||
3: (components: {
|
||||
"bevy_ecs::name::Name": "Subtractive Marker",
|
||||
"bevy_transform::components::transform::Transform": (
|
||||
translation: (2.5, 2.0, 0.0),
|
||||
rotation: (0.0, 0.258819, 0.0, 0.9659258),
|
||||
scale: (1.0, 1.0, 1.0),
|
||||
),
|
||||
"shared::components::ActorId": ("sample-brush-subtractive-marker"),
|
||||
"shared::components::ActorKind": Brush,
|
||||
"shared::components::EditorVisibility": (visible: true),
|
||||
"shared::components::HierarchySiblingIndex": (2),
|
||||
"shared::components::LevelObject": (),
|
||||
"shared::components::MaterialDesc": (
|
||||
shader: (kind: StandardLit, schema_path: None, shader_path: None),
|
||||
base_color: (r: 0.72, g: 0.14, b: 0.16, a: 1.0),
|
||||
metallic: 0.05,
|
||||
roughness: 0.4,
|
||||
emissive_color: (r: 1.0, g: 0.25, b: 0.2, a: 1.0),
|
||||
emissive_intensity: 0.0,
|
||||
base_color_texture: None,
|
||||
emissive_texture: None,
|
||||
normal_map_texture: None,
|
||||
metallic_roughness_texture: None,
|
||||
material_asset_path: None,
|
||||
parameters: [],
|
||||
textures: [],
|
||||
),
|
||||
"shared::components::BrushDesc": (
|
||||
kind: SubtractiveMarker,
|
||||
faces: [
|
||||
(
|
||||
id: ("face:+x"),
|
||||
plane: (normal: (1.0, 0.0, 0.0), distance: 1.0),
|
||||
vertices: [(1.0, -1.0, -1.0), (1.0, 1.0, -1.0), (1.0, 1.0, 1.0), (1.0, -1.0, 1.0)],
|
||||
material: None,
|
||||
texture: None,
|
||||
uv_offset: (0.0, 0.0),
|
||||
uv_scale: (1.0, 1.0),
|
||||
uv_rotation: 0.0,
|
||||
smoothing_group: 0,
|
||||
),
|
||||
(
|
||||
id: ("face:-x"),
|
||||
plane: (normal: (-1.0, 0.0, 0.0), distance: 1.0),
|
||||
vertices: [(-1.0, -1.0, 1.0), (-1.0, 1.0, 1.0), (-1.0, 1.0, -1.0), (-1.0, -1.0, -1.0)],
|
||||
material: None,
|
||||
texture: None,
|
||||
uv_offset: (0.0, 0.0),
|
||||
uv_scale: (1.0, 1.0),
|
||||
uv_rotation: 0.0,
|
||||
smoothing_group: 0,
|
||||
),
|
||||
(
|
||||
id: ("face:+y"),
|
||||
plane: (normal: (0.0, 1.0, 0.0), distance: 1.0),
|
||||
vertices: [(-1.0, 1.0, -1.0), (-1.0, 1.0, 1.0), (1.0, 1.0, 1.0), (1.0, 1.0, -1.0)],
|
||||
material: None,
|
||||
texture: None,
|
||||
uv_offset: (0.0, 0.0),
|
||||
uv_scale: (1.0, 1.0),
|
||||
uv_rotation: 0.0,
|
||||
smoothing_group: 0,
|
||||
),
|
||||
(
|
||||
id: ("face:-y"),
|
||||
plane: (normal: (0.0, -1.0, 0.0), distance: 1.0),
|
||||
vertices: [(-1.0, -1.0, 1.0), (-1.0, -1.0, -1.0), (1.0, -1.0, -1.0), (1.0, -1.0, 1.0)],
|
||||
material: None,
|
||||
texture: None,
|
||||
uv_offset: (0.0, 0.0),
|
||||
uv_scale: (1.0, 1.0),
|
||||
uv_rotation: 0.0,
|
||||
smoothing_group: 0,
|
||||
),
|
||||
(
|
||||
id: ("face:+z"),
|
||||
plane: (normal: (0.0, 0.0, 1.0), distance: 1.0),
|
||||
vertices: [(1.0, -1.0, 1.0), (1.0, 1.0, 1.0), (-1.0, 1.0, 1.0), (-1.0, -1.0, 1.0)],
|
||||
material: None,
|
||||
texture: None,
|
||||
uv_offset: (0.0, 0.0),
|
||||
uv_scale: (1.0, 1.0),
|
||||
uv_rotation: 0.0,
|
||||
smoothing_group: 0,
|
||||
),
|
||||
(
|
||||
id: ("face:-z"),
|
||||
plane: (normal: (0.0, 0.0, -1.0), distance: 1.0),
|
||||
vertices: [(-1.0, -1.0, -1.0), (-1.0, 1.0, -1.0), (1.0, 1.0, -1.0), (1.0, -1.0, -1.0)],
|
||||
material: None,
|
||||
texture: None,
|
||||
uv_offset: (0.0, 0.0),
|
||||
uv_scale: (1.0, 1.0),
|
||||
uv_rotation: 0.0,
|
||||
smoothing_group: 0,
|
||||
),
|
||||
],
|
||||
cast_shadows: true,
|
||||
receive_shadows: true,
|
||||
),
|
||||
}),
|
||||
4: (components: {
|
||||
"bevy_ecs::name::Name": "Brush Lab Sun",
|
||||
"bevy_transform::components::transform::Transform": (
|
||||
translation: (0.0, 8.0, 4.0),
|
||||
rotation: (-0.3826834, 0.0, 0.0, 0.9238795),
|
||||
scale: (1.0, 1.0, 1.0),
|
||||
),
|
||||
"shared::components::ActorId": ("sample-brush-sun"),
|
||||
"shared::components::ActorKind": Light,
|
||||
"shared::components::EditorVisibility": (visible: true),
|
||||
"shared::components::HierarchySiblingIndex": (3),
|
||||
"shared::components::LevelObject": (),
|
||||
"shared::components::LightDesc": (
|
||||
kind: Directional,
|
||||
color: (r: 1.0, g: 0.95, b: 0.85, a: 1.0),
|
||||
intensity: 100000.0,
|
||||
range: 0.0,
|
||||
shadows: true,
|
||||
inner_angle_deg: 25.0,
|
||||
outer_angle_deg: 35.0,
|
||||
),
|
||||
}),
|
||||
})
|
||||
@@ -0,0 +1,189 @@
|
||||
(schema_version: 4, resources: {}, entities: {
|
||||
1: (components: {
|
||||
"bevy_ecs::name::Name": "Material Lab Floor",
|
||||
"bevy_transform::components::transform::Transform": (
|
||||
translation: (0.0, -0.2, 0.0),
|
||||
rotation: (0.0, 0.0, 0.0, 1.0),
|
||||
scale: (1.0, 1.0, 1.0),
|
||||
),
|
||||
"shared::components::ActorId": ("sample-material-floor"),
|
||||
"shared::components::ActorKind": StaticMesh,
|
||||
"shared::components::EditorVisibility": (visible: true),
|
||||
"shared::components::HierarchySiblingIndex": (0),
|
||||
"shared::components::LevelObject": (),
|
||||
"shared::components::Primitive": (shape: Box, size: (14.0, 0.4, 8.0)),
|
||||
"shared::components::MaterialDesc": (
|
||||
shader: (kind: StandardLit, schema_path: None, shader_path: None),
|
||||
base_color: (r: 0.55, g: 0.54, b: 0.52, a: 1.0),
|
||||
metallic: 0.0,
|
||||
roughness: 0.85,
|
||||
emissive_color: (r: 1.0, g: 1.0, b: 1.0, a: 1.0),
|
||||
emissive_intensity: 0.0,
|
||||
base_color_texture: None,
|
||||
emissive_texture: None,
|
||||
normal_map_texture: None,
|
||||
metallic_roughness_texture: None,
|
||||
material_asset_path: Some("assets/materials/concrete.ron"),
|
||||
parameters: [],
|
||||
textures: [],
|
||||
),
|
||||
}),
|
||||
2: (components: {
|
||||
"bevy_ecs::name::Name": "Concrete Reference",
|
||||
"bevy_transform::components::transform::Transform": (
|
||||
translation: (-4.0, 1.0, 0.0),
|
||||
rotation: (0.0, 0.2164396, 0.0, 0.976296),
|
||||
scale: (1.0, 1.0, 1.0),
|
||||
),
|
||||
"shared::components::ActorId": ("sample-material-concrete"),
|
||||
"shared::components::ActorKind": StaticMesh,
|
||||
"shared::components::EditorVisibility": (visible: true),
|
||||
"shared::components::HierarchySiblingIndex": (1),
|
||||
"shared::components::LevelObject": (),
|
||||
"shared::components::Primitive": (shape: Box, size: (2.0, 2.0, 2.0)),
|
||||
"shared::components::MaterialDesc": (
|
||||
shader: (kind: StandardLit, schema_path: None, shader_path: None),
|
||||
base_color: (r: 0.55, g: 0.54, b: 0.52, a: 1.0),
|
||||
metallic: 0.0,
|
||||
roughness: 0.85,
|
||||
emissive_color: (r: 1.0, g: 1.0, b: 1.0, a: 1.0),
|
||||
emissive_intensity: 0.0,
|
||||
base_color_texture: None,
|
||||
emissive_texture: None,
|
||||
normal_map_texture: None,
|
||||
metallic_roughness_texture: None,
|
||||
material_asset_path: Some("assets/materials/concrete.ron"),
|
||||
parameters: [],
|
||||
textures: [],
|
||||
),
|
||||
}),
|
||||
3: (components: {
|
||||
"bevy_ecs::name::Name": "Custom Surface Reference",
|
||||
"bevy_transform::components::transform::Transform": (
|
||||
translation: (0.0, 1.2, 0.0),
|
||||
rotation: (0.0, 0.0, 0.0, 1.0),
|
||||
scale: (1.0, 1.0, 1.0),
|
||||
),
|
||||
"shared::components::ActorId": ("sample-material-custom-surface"),
|
||||
"shared::components::ActorKind": StaticMesh,
|
||||
"shared::components::EditorVisibility": (visible: true),
|
||||
"shared::components::HierarchySiblingIndex": (2),
|
||||
"shared::components::LevelObject": (),
|
||||
"shared::components::Primitive": (shape: Sphere, size: (2.4, 2.4, 2.4)),
|
||||
"shared::components::MaterialDesc": (
|
||||
shader: (
|
||||
kind: Custom,
|
||||
schema_path: Some("assets/shaders/surface_tint.shader.ron"),
|
||||
shader_path: Some("assets/shaders/surface_tint.wgsl"),
|
||||
),
|
||||
base_color: (r: 0.12, g: 0.42, b: 0.95, a: 1.0),
|
||||
metallic: 0.15,
|
||||
roughness: 0.28,
|
||||
emissive_color: (r: 0.02, g: 0.08, b: 0.25, a: 1.0),
|
||||
emissive_intensity: 3.0,
|
||||
base_color_texture: None,
|
||||
emissive_texture: None,
|
||||
normal_map_texture: None,
|
||||
metallic_roughness_texture: None,
|
||||
material_asset_path: Some("assets/materials/surface_tint.ron"),
|
||||
parameters: [
|
||||
(name: "tint", value: Color((r: 0.12, g: 0.42, b: 0.95, a: 1.0))),
|
||||
(name: "roughness", value: Float(0.28)),
|
||||
(name: "metallic", value: Float(0.15)),
|
||||
(name: "emissive", value: Color((r: 0.02, g: 0.08, b: 0.25, a: 1.0))),
|
||||
(name: "emissive_intensity", value: Float(3.0)),
|
||||
],
|
||||
textures: [],
|
||||
),
|
||||
}),
|
||||
4: (components: {
|
||||
"bevy_ecs::name::Name": "Material Instance Reference",
|
||||
"bevy_transform::components::transform::Transform": (
|
||||
translation: (4.0, 1.0, 0.0),
|
||||
rotation: (0.0, -0.1305262, 0.0, 0.9914449),
|
||||
scale: (1.0, 1.0, 1.0),
|
||||
),
|
||||
"shared::components::ActorId": ("sample-material-instance"),
|
||||
"shared::components::ActorKind": StaticMesh,
|
||||
"shared::components::EditorVisibility": (visible: true),
|
||||
"shared::components::HierarchySiblingIndex": (3),
|
||||
"shared::components::LevelObject": (),
|
||||
"shared::components::Primitive": (shape: Box, size: (2.6, 2.0, 2.6)),
|
||||
"shared::components::MaterialDesc": (
|
||||
shader: (
|
||||
kind: Custom,
|
||||
schema_path: Some("assets/shaders/surface_tint.shader.ron"),
|
||||
shader_path: Some("assets/shaders/surface_tint.wgsl"),
|
||||
),
|
||||
base_color: (r: 0.12, g: 0.42, b: 0.95, a: 1.0),
|
||||
metallic: 0.15,
|
||||
roughness: 0.28,
|
||||
emissive_color: (r: 0.02, g: 0.08, b: 0.25, a: 1.0),
|
||||
emissive_intensity: 3.0,
|
||||
base_color_texture: None,
|
||||
emissive_texture: None,
|
||||
normal_map_texture: None,
|
||||
metallic_roughness_texture: None,
|
||||
material_asset_path: Some("assets/materials/surface_tint_instance.ron"),
|
||||
parameters: [
|
||||
(name: "tint", value: Color((r: 0.12, g: 0.42, b: 0.95, a: 1.0))),
|
||||
(name: "roughness", value: Float(0.28)),
|
||||
(name: "metallic", value: Float(0.15)),
|
||||
(name: "emissive", value: Color((r: 0.02, g: 0.08, b: 0.25, a: 1.0))),
|
||||
(name: "emissive_intensity", value: Float(3.0)),
|
||||
],
|
||||
textures: [],
|
||||
),
|
||||
}),
|
||||
5: (components: {
|
||||
"bevy_ecs::name::Name": "Emissive Reference Panel",
|
||||
"bevy_transform::components::transform::Transform": (
|
||||
translation: (0.0, 2.3, -3.6),
|
||||
rotation: (0.0, 0.0, 0.0, 1.0),
|
||||
scale: (1.0, 1.0, 1.0),
|
||||
),
|
||||
"shared::components::ActorId": ("sample-material-emissive-panel"),
|
||||
"shared::components::ActorKind": StaticMesh,
|
||||
"shared::components::EditorVisibility": (visible: true),
|
||||
"shared::components::HierarchySiblingIndex": (4),
|
||||
"shared::components::LevelObject": (),
|
||||
"shared::components::Primitive": (shape: Box, size: (9.0, 3.0, 0.25)),
|
||||
"shared::components::MaterialDesc": (
|
||||
shader: (kind: StandardLit, schema_path: None, shader_path: None),
|
||||
base_color: (r: 0.15, g: 0.22, b: 0.28, a: 1.0),
|
||||
metallic: 0.0,
|
||||
roughness: 0.35,
|
||||
emissive_color: (r: 0.55, g: 0.85, b: 1.0, a: 1.0),
|
||||
emissive_intensity: 2500.0,
|
||||
base_color_texture: None,
|
||||
emissive_texture: None,
|
||||
normal_map_texture: None,
|
||||
metallic_roughness_texture: None,
|
||||
material_asset_path: Some("assets/materials/emissive_panel.ron"),
|
||||
parameters: [],
|
||||
textures: [],
|
||||
),
|
||||
}),
|
||||
6: (components: {
|
||||
"bevy_ecs::name::Name": "Material Lab Sun",
|
||||
"bevy_transform::components::transform::Transform": (
|
||||
translation: (0.0, 8.0, 4.0),
|
||||
rotation: (-0.3826834, 0.0, 0.0, 0.9238795),
|
||||
scale: (1.0, 1.0, 1.0),
|
||||
),
|
||||
"shared::components::ActorId": ("sample-material-sun"),
|
||||
"shared::components::ActorKind": Light,
|
||||
"shared::components::EditorVisibility": (visible: true),
|
||||
"shared::components::HierarchySiblingIndex": (5),
|
||||
"shared::components::LevelObject": (),
|
||||
"shared::components::LightDesc": (
|
||||
kind: Directional,
|
||||
color: (r: 1.0, g: 0.95, b: 0.85, a: 1.0),
|
||||
intensity: 100000.0,
|
||||
range: 0.0,
|
||||
shadows: true,
|
||||
inner_angle_deg: 25.0,
|
||||
outer_angle_deg: 35.0,
|
||||
),
|
||||
}),
|
||||
})
|
||||
@@ -0,0 +1,65 @@
|
||||
(
|
||||
schema_version: 1,
|
||||
samples: [
|
||||
(
|
||||
id: "brush-blockout",
|
||||
label: "Brush Blockout",
|
||||
area: Brush,
|
||||
scene: "assets/levels/samples/brush_blockout.scn.ron",
|
||||
summary: "Convex additive brushes, a subtractive marker, and a shared face material for brush editing and CSG regression checks.",
|
||||
checks: [
|
||||
"valid authored BrushDesc geometry",
|
||||
"shared brush-face material resolution",
|
||||
"object, face, clip, and CSG selection targets",
|
||||
],
|
||||
),
|
||||
(
|
||||
id: "material-lab",
|
||||
label: "Material Lab",
|
||||
area: Material,
|
||||
scene: "assets/levels/samples/material_lab.scn.ron",
|
||||
summary: "A compact look-development stage for shared materials, material instances, custom surfaces, and emissive output.",
|
||||
checks: [
|
||||
"Material and Material Instance dependency resolution",
|
||||
"standard, custom, and emissive surface hydration",
|
||||
"primitive material assignment and targeted drops",
|
||||
],
|
||||
),
|
||||
(
|
||||
id: "terrain-authoring",
|
||||
label: "Terrain Authoring",
|
||||
area: Terrain,
|
||||
scene: "assets/levels/terrain_authoring_showcase.scn.ron",
|
||||
summary: "A deterministic height grid with shared material layers, normalized paint weights, chunks, and collision.",
|
||||
checks: [
|
||||
"TerrainDesc schema and normalized layer weights",
|
||||
"shared terrain material dependency resolution",
|
||||
"sculpt, paint, chunk, and collider hydration",
|
||||
],
|
||||
),
|
||||
(
|
||||
id: "physics-placement",
|
||||
label: "Physics Placement",
|
||||
area: PhysicsPlacement,
|
||||
scene: "assets/levels/physics_placement_showcase.scn.ron",
|
||||
summary: "Three visually distinct collider cases above a static floor for transactional multi-object settling.",
|
||||
checks: [
|
||||
"cuboid, sphere, and capsule collider diversity",
|
||||
"multi-selection settle and grouped history",
|
||||
"static floor collision and cancel restoration",
|
||||
],
|
||||
),
|
||||
(
|
||||
id: "rendering-lab",
|
||||
label: "Rendering Lab",
|
||||
area: Rendering,
|
||||
scene: "assets/levels/rendering_showcase.scn.ron",
|
||||
summary: "Visible comparison anchors for fog, exposure, rendering profiles, fullscreen effects, and emissive lighting.",
|
||||
checks: [
|
||||
"stable post-process volume ownership",
|
||||
"rendering profile and fullscreen effect dependency resolution",
|
||||
"visible fog, exposure, vignette, and emissive comparison anchors",
|
||||
],
|
||||
),
|
||||
],
|
||||
)
|
||||
@@ -6,6 +6,7 @@
|
||||
use std::collections::HashMap;
|
||||
use std::fs;
|
||||
|
||||
use bevy::material::OpaqueRendererMethod;
|
||||
use bevy::mesh::MeshVertexBufferLayoutRef;
|
||||
use bevy::pbr::{
|
||||
ExtendedMaterial, MaterialExtension, MaterialExtensionKey, MaterialExtensionPipeline,
|
||||
@@ -393,6 +394,9 @@ fn build_terrain_layer_material(
|
||||
base: StandardMaterial {
|
||||
base_color: Color::WHITE,
|
||||
perceptual_roughness: 1.0,
|
||||
// Terrain is intentionally absent from the Solari acceleration structure until its
|
||||
// ray-tracing evaluator exists, so keep the layer blend in the raster forward pass.
|
||||
opaque_render_method: OpaqueRendererMethod::Forward,
|
||||
..default()
|
||||
},
|
||||
extension,
|
||||
@@ -1079,6 +1083,10 @@ mod tests {
|
||||
assert_eq!(material.extension.uniform.uv_scales.y, 10.0);
|
||||
assert_eq!(material.extension.uniform.properties[0].w, 1.0);
|
||||
assert_eq!(material.extension.uniform.properties[1].w, 1.0);
|
||||
assert_eq!(
|
||||
material.base.opaque_render_method,
|
||||
OpaqueRendererMethod::Forward
|
||||
);
|
||||
assert_ne!(
|
||||
material.extension.uniform.base_colors[0],
|
||||
material.extension.uniform.base_colors[1]
|
||||
|
||||
@@ -469,6 +469,86 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn multi_actor_material_assignment_is_one_undo_group() {
|
||||
let mut world = World::new();
|
||||
world.init_resource::<ActiveOperator>();
|
||||
world.init_resource::<EditorHistory>();
|
||||
world.init_resource::<SceneIo>();
|
||||
let material_path = std::env::temp_dir().join(format!(
|
||||
"blacksite-material-operator-{}.material.ron",
|
||||
uuid::Uuid::new_v4()
|
||||
));
|
||||
let fixture = shared::MaterialAsset {
|
||||
schema_version: shared::MATERIAL_ASSET_SCHEMA_VERSION,
|
||||
label: "Concrete".into(),
|
||||
shader: None,
|
||||
shader_ref: None,
|
||||
render_state: Default::default(),
|
||||
material: MaterialDesc {
|
||||
roughness: 0.85,
|
||||
..Default::default()
|
||||
},
|
||||
};
|
||||
std::fs::write(
|
||||
&material_path,
|
||||
ron::ser::to_string_pretty(&fixture, ron::ser::PrettyConfig::default()).unwrap(),
|
||||
)
|
||||
.unwrap();
|
||||
let material_path = material_path.to_string_lossy().into_owned();
|
||||
world.insert_resource(AssetRegistry {
|
||||
records: vec![AssetRecord {
|
||||
id: AssetId::new(),
|
||||
path: material_path.clone(),
|
||||
label: "Concrete".into(),
|
||||
kind_tag: "Material".into(),
|
||||
import_settings: Default::default(),
|
||||
dependencies: Vec::new(),
|
||||
}],
|
||||
index_dirty: false,
|
||||
});
|
||||
let first = world.spawn((LevelObject, MaterialDesc::default())).id();
|
||||
let second = world.spawn((LevelObject, MaterialDesc::default())).id();
|
||||
let mut selected = SelectedEntities::default();
|
||||
selected.select_replace(first);
|
||||
selected.select_maybe_add(second, true);
|
||||
let asset = EditorAsset {
|
||||
label: "Concrete".to_string(),
|
||||
path: Some(material_path.clone()),
|
||||
folder_path: "assets/materials".to_string(),
|
||||
kind: super::super::EditorAssetKind::Material,
|
||||
};
|
||||
super::super::materials::material_desc_from_asset(&material_path)
|
||||
.expect("committed material fixture should resolve");
|
||||
let harness = OperatorInvariantHarness::capture(&mut world);
|
||||
let read_materials = move |world: &mut World| {
|
||||
[first, second]
|
||||
.into_iter()
|
||||
.map(|entity| {
|
||||
world
|
||||
.get::<MaterialDesc>(entity)
|
||||
.and_then(|material| material.material_asset_path.clone())
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
};
|
||||
|
||||
let applied = apply_material_operator(&mut world, asset, &selected);
|
||||
assert!(
|
||||
applied,
|
||||
"material operator failed: {:?}",
|
||||
world.resource::<ActiveOperator>().status
|
||||
);
|
||||
|
||||
harness.assert_committed(&mut world, 1, 0);
|
||||
assert_undo_redo_round_trip(
|
||||
&mut world,
|
||||
vec![None, None],
|
||||
vec![Some(material_path.clone()), Some(material_path.clone())],
|
||||
read_materials,
|
||||
);
|
||||
let _ = std::fs::remove_file(material_path);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn missing_subasset_commit_cancels_without_side_effects() {
|
||||
let mut world = World::new();
|
||||
@@ -533,4 +613,59 @@ mod tests {
|
||||
|
||||
harness.assert_blocked(&mut world);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn material_assignment_without_authored_selection_is_blocked() {
|
||||
let mut world = World::new();
|
||||
world.init_resource::<ActiveOperator>();
|
||||
world.init_resource::<EditorHistory>();
|
||||
world.init_resource::<SceneIo>();
|
||||
let harness = OperatorInvariantHarness::capture(&mut world);
|
||||
let asset = EditorAsset {
|
||||
label: "Concrete".to_string(),
|
||||
path: Some("assets/materials/concrete.ron".to_string()),
|
||||
folder_path: "assets/materials".to_string(),
|
||||
kind: super::super::EditorAssetKind::Material,
|
||||
};
|
||||
|
||||
assert!(!apply_material_operator(
|
||||
&mut world,
|
||||
asset,
|
||||
&SelectedEntities::default()
|
||||
));
|
||||
|
||||
harness.assert_blocked(&mut world);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn audio_and_animation_assignment_reject_incompatible_actors() {
|
||||
let mut world = World::new();
|
||||
world.init_resource::<ActiveOperator>();
|
||||
world.init_resource::<EditorHistory>();
|
||||
world.init_resource::<SceneIo>();
|
||||
let entity = world.spawn(LevelObject).id();
|
||||
let audio = EditorAsset {
|
||||
label: "Impact".into(),
|
||||
path: Some("assets/audio/impact.ogg".into()),
|
||||
folder_path: "assets/audio".into(),
|
||||
kind: super::super::EditorAssetKind::AudioClip,
|
||||
};
|
||||
let audio_harness = OperatorInvariantHarness::capture(&mut world);
|
||||
|
||||
assert!(!assign_audio_clip_operator(&mut world, audio, entity));
|
||||
audio_harness.assert_blocked(&mut world);
|
||||
|
||||
let animation_harness = OperatorInvariantHarness::capture(&mut world);
|
||||
let selection = AssetSelection::SubAsset {
|
||||
parent_path: "assets/models/missing.glb".into(),
|
||||
sub_asset_id: "animation:missing".into(),
|
||||
label: "Missing".into(),
|
||||
kind: super::super::AssetSubAssetKind::AnimationClip,
|
||||
source_path: None,
|
||||
};
|
||||
assert!(!assign_animation_clip_operator(
|
||||
&mut world, selection, entity
|
||||
));
|
||||
animation_harness.assert_blocked(&mut world);
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@ use bevy::prelude::*;
|
||||
use bevy_egui::{egui, EguiContexts, EguiPrimaryContextPass};
|
||||
|
||||
use crate::history::group_selection_with_history;
|
||||
use crate::operators::{run_immediate_operator, OperatorAvailability};
|
||||
use crate::operators::{run_operator_action, OperatorAction, OperatorAvailability};
|
||||
use crate::state::{EditorMode, PlayPossession};
|
||||
use crate::ui::helpers::{
|
||||
reset_scene_lighting_to_project_defaults, toggle_play_mode, toggle_play_paused,
|
||||
@@ -27,7 +27,7 @@ pub trait EditorCommand: Send + Sync {
|
||||
fn disabled_reason(&self, _world: &World) -> Option<String> {
|
||||
None
|
||||
}
|
||||
fn execute(&self, world: &mut World);
|
||||
fn execute(&self, world: &mut World) -> Result<OperatorAction, String>;
|
||||
}
|
||||
|
||||
#[derive(Resource, Default)]
|
||||
@@ -70,13 +70,11 @@ impl EditorCommandRegistry {
|
||||
.map(|cmd| (cmd.label().to_string(), cmd.disabled_reason(world)))
|
||||
}
|
||||
|
||||
pub fn run(&self, world: &mut World, name: &str) -> bool {
|
||||
if let Some(command) = self.commands.iter().find(|cmd| cmd.name() == name) {
|
||||
command.execute(world);
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
pub fn run(&self, world: &mut World, name: &str) -> Option<Result<OperatorAction, String>> {
|
||||
self.commands
|
||||
.iter()
|
||||
.find(|command| command.name() == name)
|
||||
.map(|command| command.execute(world))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -191,6 +189,10 @@ pub fn register_editor_plugin(app: &mut App, plugin: Box<dyn EditorPlugin>) {
|
||||
}
|
||||
|
||||
fn register_builtin_commands(mut registry: ResMut<EditorCommandRegistry>) {
|
||||
populate_builtin_commands(&mut registry);
|
||||
}
|
||||
|
||||
fn populate_builtin_commands(registry: &mut EditorCommandRegistry) {
|
||||
registry.register(Box::new(TogglePlayCommand));
|
||||
registry.register(Box::new(TogglePlayPausedCommand));
|
||||
registry.register(Box::new(TogglePossessionCommand));
|
||||
@@ -235,7 +237,7 @@ fn dispatch_editor_command(world: &mut World, name: &str) {
|
||||
let name_for_commit = name.to_string();
|
||||
let name_for_status = name.to_string();
|
||||
let label_for_commit = label.clone();
|
||||
run_immediate_operator(
|
||||
run_operator_action(
|
||||
world,
|
||||
&name_for_status,
|
||||
&label,
|
||||
@@ -244,14 +246,10 @@ fn dispatch_editor_command(world: &mut World, name: &str) {
|
||||
None => OperatorAvailability::Ready,
|
||||
},
|
||||
move |world| {
|
||||
let ran = world.resource_scope(|world, registry: Mut<EditorCommandRegistry>| {
|
||||
let result = world.resource_scope(|world, registry: Mut<EditorCommandRegistry>| {
|
||||
registry.run(world, &name_for_commit)
|
||||
});
|
||||
if ran {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(format!("Unknown editor command: {name_for_commit}"))
|
||||
}
|
||||
result.unwrap_or_else(|| Err(format!("Unknown editor command: {name_for_commit}")))
|
||||
},
|
||||
);
|
||||
|
||||
@@ -269,8 +267,9 @@ impl EditorCommand for TogglePlayCommand {
|
||||
"Toggle Play / Edit"
|
||||
}
|
||||
|
||||
fn execute(&self, world: &mut World) {
|
||||
fn execute(&self, world: &mut World) -> Result<OperatorAction, String> {
|
||||
toggle_play_mode(world);
|
||||
Ok(OperatorAction::Commit)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -290,8 +289,9 @@ impl EditorCommand for TogglePlayPausedCommand {
|
||||
.then(|| "Enter Play mode before pausing the simulation".to_string())
|
||||
}
|
||||
|
||||
fn execute(&self, world: &mut World) {
|
||||
fn execute(&self, world: &mut World) -> Result<OperatorAction, String> {
|
||||
toggle_play_paused(world);
|
||||
Ok(OperatorAction::Commit)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -311,12 +311,13 @@ impl EditorCommand for TogglePossessionCommand {
|
||||
.then(|| "Enter Play mode before toggling possession".to_string())
|
||||
}
|
||||
|
||||
fn execute(&self, world: &mut World) {
|
||||
fn execute(&self, world: &mut World) -> Result<OperatorAction, String> {
|
||||
let next = match *world.resource::<PlayPossession>() {
|
||||
PlayPossession::Possessed => PlayPossession::Ejected,
|
||||
PlayPossession::Ejected => PlayPossession::Possessed,
|
||||
};
|
||||
*world.resource_mut::<PlayPossession>() = next;
|
||||
Ok(OperatorAction::Commit)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -331,8 +332,9 @@ impl EditorCommand for ResetLightingCommand {
|
||||
"Reset Scene Lighting"
|
||||
}
|
||||
|
||||
fn execute(&self, world: &mut World) {
|
||||
fn execute(&self, world: &mut World) -> Result<OperatorAction, String> {
|
||||
reset_scene_lighting_to_project_defaults(world);
|
||||
Ok(OperatorAction::Commit)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -347,13 +349,23 @@ impl EditorCommand for GroupSelectionCommand {
|
||||
"Group Selection"
|
||||
}
|
||||
|
||||
fn execute(&self, world: &mut World) {
|
||||
fn disabled_reason(&self, world: &World) -> Option<String> {
|
||||
world
|
||||
.resource::<UiState>()
|
||||
.selected_entities
|
||||
.as_slice()
|
||||
.is_empty()
|
||||
.then(|| "Select at least one actor to group".to_string())
|
||||
}
|
||||
|
||||
fn execute(&self, world: &mut World) -> Result<OperatorAction, String> {
|
||||
let selected: Vec<Entity> = world
|
||||
.resource::<UiState>()
|
||||
.selected_entities
|
||||
.iter()
|
||||
.collect();
|
||||
group_selection_with_history(world, &selected);
|
||||
Ok(OperatorAction::Commit)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -368,8 +380,9 @@ impl EditorCommand for FocusSelectionCommand {
|
||||
"Focus Selection"
|
||||
}
|
||||
|
||||
fn execute(&self, world: &mut World) {
|
||||
fn execute(&self, world: &mut World) -> Result<OperatorAction, String> {
|
||||
focus_editor_camera_on_selection(world);
|
||||
Ok(OperatorAction::Commit)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -384,8 +397,9 @@ impl EditorCommand for ResetSelectionTransformCommand {
|
||||
"Reset Selection Transform"
|
||||
}
|
||||
|
||||
fn execute(&self, world: &mut World) {
|
||||
fn execute(&self, world: &mut World) -> Result<OperatorAction, String> {
|
||||
reset_selected_transforms(world);
|
||||
Ok(OperatorAction::Commit)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -405,8 +419,9 @@ impl EditorCommand for DrawBrushCommand {
|
||||
.then(|| "Enter Edit mode before drawing brushes".to_string())
|
||||
}
|
||||
|
||||
fn execute(&self, world: &mut World) {
|
||||
fn execute(&self, world: &mut World) -> Result<OperatorAction, String> {
|
||||
start_draw_brush_tool(world);
|
||||
Ok(OperatorAction::ContinuePreview)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -425,8 +440,9 @@ impl EditorCommand for IntersectBrushesCommand {
|
||||
(selected_brush_count(world) < 2).then(|| "Select at least two brushes".to_string())
|
||||
}
|
||||
|
||||
fn execute(&self, world: &mut World) {
|
||||
intersect_selected_brushes(world);
|
||||
fn execute(&self, world: &mut World) -> Result<OperatorAction, String> {
|
||||
intersect_selected_brushes(world)?;
|
||||
Ok(OperatorAction::ContinuePreview)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -445,8 +461,9 @@ impl EditorCommand for MergeBrushesCommand {
|
||||
(selected_brush_count(world) < 2).then(|| "Select at least two brushes".to_string())
|
||||
}
|
||||
|
||||
fn execute(&self, world: &mut World) {
|
||||
merge_selected_brushes(world);
|
||||
fn execute(&self, world: &mut World) -> Result<OperatorAction, String> {
|
||||
merge_selected_brushes(world)?;
|
||||
Ok(OperatorAction::ContinuePreview)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -465,8 +482,9 @@ impl EditorCommand for SubtractBrushesCommand {
|
||||
(selected_brush_count(world) < 2).then(|| "Select at least two brushes".to_string())
|
||||
}
|
||||
|
||||
fn execute(&self, world: &mut World) {
|
||||
subtract_selected_brushes(world);
|
||||
fn execute(&self, world: &mut World) -> Result<OperatorAction, String> {
|
||||
subtract_selected_brushes(world)?;
|
||||
Ok(OperatorAction::ContinuePreview)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -481,8 +499,9 @@ impl EditorCommand for CreatePostProcessVolumeCommand {
|
||||
"Create Post-process Volume"
|
||||
}
|
||||
|
||||
fn execute(&self, world: &mut World) {
|
||||
fn execute(&self, world: &mut World) -> Result<OperatorAction, String> {
|
||||
crate::rendering_diagnostics::spawn_post_process_volume_at_camera(world);
|
||||
Ok(OperatorAction::Commit)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -497,9 +516,10 @@ impl EditorCommand for FocusActiveVolumesCommand {
|
||||
"Focus Active Post-process Volumes"
|
||||
}
|
||||
|
||||
fn execute(&self, world: &mut World) {
|
||||
fn execute(&self, world: &mut World) -> Result<OperatorAction, String> {
|
||||
crate::rendering_diagnostics::select_volumes_at_camera(world);
|
||||
focus_editor_camera_on_selection(world);
|
||||
Ok(OperatorAction::Commit)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -514,8 +534,9 @@ impl EditorCommand for SelectVolumesAtCameraCommand {
|
||||
"Select Volumes at Camera"
|
||||
}
|
||||
|
||||
fn execute(&self, world: &mut World) {
|
||||
fn execute(&self, world: &mut World) -> Result<OperatorAction, String> {
|
||||
crate::rendering_diagnostics::select_volumes_at_camera(world);
|
||||
Ok(OperatorAction::Commit)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -542,6 +563,7 @@ fn command_palette_ui(
|
||||
}
|
||||
|
||||
let mut open = palette.open;
|
||||
let mut dismiss_requested = false;
|
||||
let palette_width = (ctx.content_rect().width() - 32.0).clamp(320.0, 520.0);
|
||||
egui::Window::new("Command Palette")
|
||||
.open(&mut open)
|
||||
@@ -590,13 +612,11 @@ fn command_palette_ui(
|
||||
if ui.input_mut(|input| input.consume_key(egui::Modifiers::NONE, egui::Key::Enter)) {
|
||||
if let Some(entry) = filtered_entries.get(palette.selected_index) {
|
||||
palette.pending_run = Some(entry.name.clone());
|
||||
palette.open = false;
|
||||
ui.close();
|
||||
dismiss_requested = true;
|
||||
}
|
||||
}
|
||||
if ui.input_mut(|input| input.consume_key(egui::Modifiers::NONE, egui::Key::Escape)) {
|
||||
palette.open = false;
|
||||
ui.close();
|
||||
dismiss_requested = true;
|
||||
}
|
||||
|
||||
ui.separator();
|
||||
@@ -618,17 +638,20 @@ fn command_palette_ui(
|
||||
if response.clicked() {
|
||||
palette.selected_index = index;
|
||||
palette.pending_run = Some(entry.name.clone());
|
||||
palette.open = false;
|
||||
ui.close();
|
||||
dismiss_requested = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
palette.open = open;
|
||||
palette.open = resolve_palette_open(open, dismiss_requested);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn resolve_palette_open(window_open: bool, dismiss_requested: bool) -> bool {
|
||||
window_open && !dismiss_requested
|
||||
}
|
||||
|
||||
fn filtered_command_entries(
|
||||
registry: &EditorCommandRegistry,
|
||||
filter: &str,
|
||||
@@ -671,6 +694,53 @@ fn command_palette_row(entry: &EditorCommandEntry) -> egui::WidgetText {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::history::{apply_command_redo, apply_command_undo, EditorHistory};
|
||||
use crate::operators::test_harness::OperatorInvariantHarness;
|
||||
use crate::operators::{ActiveOperator, OperatorPhase};
|
||||
use crate::scene_io::SceneIo;
|
||||
use crate::selection::{SelectedEntity, ViewportClick};
|
||||
use crate::viewport::brush_tool::BrushToolState;
|
||||
use shared::{
|
||||
ActorKind, AuthoringLightKind, BrushDesc, EditorVisibility, HierarchySiblingIndex,
|
||||
LevelObject, LightDesc,
|
||||
};
|
||||
|
||||
fn command_world() -> World {
|
||||
let mut world = World::new();
|
||||
world.init_resource::<ActiveOperator>();
|
||||
world.init_resource::<EditorHistory>();
|
||||
world.init_resource::<SceneIo>();
|
||||
world.init_resource::<SelectedEntity>();
|
||||
world.init_resource::<ViewportClick>();
|
||||
world.init_resource::<BrushToolState>();
|
||||
world.init_resource::<crate::viewport::brush_csg::BrushCsgPreview>();
|
||||
world.insert_resource(State::new(EditorMode::Editing));
|
||||
world.insert_resource(UiState::default_layout());
|
||||
let mut registry = EditorCommandRegistry::default();
|
||||
populate_builtin_commands(&mut registry);
|
||||
world.insert_resource(registry);
|
||||
world
|
||||
}
|
||||
|
||||
fn hierarchy_projection(world: &mut World) -> Vec<(String, Option<String>, i32)> {
|
||||
let mut query = world.query_filtered::<(Entity, &Name), With<LevelObject>>();
|
||||
let mut result = query
|
||||
.iter(world)
|
||||
.map(|(entity, name)| {
|
||||
let parent = world
|
||||
.get::<ChildOf>(entity)
|
||||
.and_then(|child| world.get::<Name>(child.parent()))
|
||||
.map(|name| name.as_str().to_string());
|
||||
let sibling_index = world
|
||||
.get::<HierarchySiblingIndex>(entity)
|
||||
.map(|index| index.0)
|
||||
.unwrap_or_default();
|
||||
(name.as_str().to_string(), parent, sibling_index)
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
result.sort();
|
||||
result
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn command_filter_matches_human_label_and_stable_id() {
|
||||
@@ -697,4 +767,228 @@ mod tests {
|
||||
assert_eq!(entries[0].name, "play.toggle");
|
||||
assert_eq!(entries[1].name, "scene.reset_lighting");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn command_palette_dismissal_wins_over_stale_window_open_state() {
|
||||
assert!(!resolve_palette_open(true, true));
|
||||
assert!(!resolve_palette_open(false, false));
|
||||
assert!(resolve_palette_open(true, false));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn grouping_dispatch_is_one_history_transaction_and_round_trips() {
|
||||
let mut world = command_world();
|
||||
let first = world
|
||||
.spawn((
|
||||
Name::new("First"),
|
||||
LevelObject,
|
||||
ActorKind::Empty,
|
||||
Transform::from_xyz(1.0, 0.0, 0.0),
|
||||
GlobalTransform::default(),
|
||||
HierarchySiblingIndex(0),
|
||||
EditorVisibility::default(),
|
||||
))
|
||||
.id();
|
||||
let second = world
|
||||
.spawn((
|
||||
Name::new("Second"),
|
||||
LevelObject,
|
||||
ActorKind::Empty,
|
||||
Transform::from_xyz(2.0, 0.0, 0.0),
|
||||
GlobalTransform::default(),
|
||||
HierarchySiblingIndex(1),
|
||||
EditorVisibility::default(),
|
||||
))
|
||||
.id();
|
||||
let unselected = world
|
||||
.spawn((
|
||||
Name::new("Unselected"),
|
||||
LevelObject,
|
||||
ActorKind::Empty,
|
||||
Transform::from_xyz(3.0, 0.0, 0.0),
|
||||
GlobalTransform::default(),
|
||||
HierarchySiblingIndex(2),
|
||||
EditorVisibility::default(),
|
||||
))
|
||||
.id();
|
||||
world
|
||||
.resource_mut::<UiState>()
|
||||
.selected_entities
|
||||
.select_replace(first);
|
||||
world
|
||||
.resource_mut::<UiState>()
|
||||
.selected_entities
|
||||
.select_maybe_add(second, true);
|
||||
let initial = hierarchy_projection(&mut world);
|
||||
let harness = OperatorInvariantHarness::capture(&mut world);
|
||||
|
||||
dispatch_editor_command(&mut world, "selection.group");
|
||||
|
||||
harness.assert_committed(&mut world, 1, 1);
|
||||
harness.assert_status(&world, "selection.group", OperatorPhase::Committed);
|
||||
let committed = hierarchy_projection(&mut world);
|
||||
assert!(committed
|
||||
.iter()
|
||||
.any(|(name, parent, _)| name == "First" && parent.as_deref() == Some("Group")));
|
||||
assert!(committed
|
||||
.iter()
|
||||
.any(|(name, parent, _)| name == "Second" && parent.as_deref() == Some("Group")));
|
||||
assert_group_has_visibility_hierarchy(&mut world);
|
||||
apply_command_undo(&mut world);
|
||||
assert_eq!(hierarchy_projection(&mut world), initial);
|
||||
apply_command_redo(&mut world);
|
||||
assert_eq!(hierarchy_projection(&mut world), committed);
|
||||
assert_group_has_visibility_hierarchy(&mut world);
|
||||
assert!(world.get::<ChildOf>(unselected).is_none());
|
||||
apply_command_undo(&mut world);
|
||||
assert_eq!(hierarchy_projection(&mut world), initial);
|
||||
apply_command_redo(&mut world);
|
||||
assert_eq!(hierarchy_projection(&mut world), committed);
|
||||
assert!(world.get::<ChildOf>(unselected).is_none());
|
||||
}
|
||||
|
||||
fn assert_group_has_visibility_hierarchy(world: &mut World) {
|
||||
let group = world
|
||||
.query::<(Entity, &Name)>()
|
||||
.iter(world)
|
||||
.find_map(|(entity, name)| (name.as_str() == "Group").then_some(entity))
|
||||
.expect("group command should spawn the group actor");
|
||||
assert!(world.get::<Visibility>(group).is_some());
|
||||
assert!(world.get::<InheritedVisibility>(group).is_some());
|
||||
assert!(world.get::<ViewVisibility>(group).is_some());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn reset_lighting_dispatch_is_one_undoable_group() {
|
||||
let mut world = command_world();
|
||||
let point = world
|
||||
.spawn((
|
||||
LevelObject,
|
||||
ActorKind::Light,
|
||||
LightDesc {
|
||||
kind: AuthoringLightKind::Point,
|
||||
..Default::default()
|
||||
},
|
||||
))
|
||||
.id();
|
||||
let directional = world
|
||||
.spawn((
|
||||
LevelObject,
|
||||
ActorKind::Light,
|
||||
LightDesc {
|
||||
kind: AuthoringLightKind::Directional,
|
||||
..Default::default()
|
||||
},
|
||||
))
|
||||
.id();
|
||||
let harness = OperatorInvariantHarness::capture(&mut world);
|
||||
|
||||
dispatch_editor_command(&mut world, "scene.reset_lighting");
|
||||
|
||||
harness.assert_committed(&mut world, 1, 0);
|
||||
harness.assert_status(&world, "scene.reset_lighting", OperatorPhase::Committed);
|
||||
assert!(world.get::<LightDesc>(point).is_none());
|
||||
assert!(world.get::<LightDesc>(directional).is_none());
|
||||
apply_command_undo(&mut world);
|
||||
assert!(world.get::<LightDesc>(point).is_some());
|
||||
assert!(world.get::<LightDesc>(directional).is_some());
|
||||
apply_command_redo(&mut world);
|
||||
assert!(world.get::<LightDesc>(point).is_none());
|
||||
assert!(world.get::<LightDesc>(directional).is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn modal_command_dispatch_retains_preview_ownership() {
|
||||
let mut world = command_world();
|
||||
let harness = OperatorInvariantHarness::capture(&mut world);
|
||||
|
||||
dispatch_editor_command(&mut world, "brush.draw");
|
||||
|
||||
harness.assert_status(&world, "brush.draw", OperatorPhase::Preview);
|
||||
harness.assert_projection_unchanged(&mut world, 0, |world| {
|
||||
world.resource::<EditorHistory>().undo_depth()
|
||||
});
|
||||
assert!(!world.resource::<SceneIo>().dirty);
|
||||
assert!(world.resource::<BrushToolState>().active);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn failed_csg_dispatch_terminates_without_preview_or_history() {
|
||||
let mut world = command_world();
|
||||
let first = world
|
||||
.spawn((
|
||||
LevelObject,
|
||||
BrushDesc::cuboid(Vec3::splat(1.0)),
|
||||
Transform::IDENTITY,
|
||||
))
|
||||
.id();
|
||||
let mut invalid = BrushDesc::cuboid(Vec3::splat(1.0));
|
||||
invalid.faces.clear();
|
||||
let second = world
|
||||
.spawn((LevelObject, invalid, Transform::IDENTITY))
|
||||
.id();
|
||||
world
|
||||
.resource_mut::<UiState>()
|
||||
.selected_entities
|
||||
.select_replace(first);
|
||||
world
|
||||
.resource_mut::<UiState>()
|
||||
.selected_entities
|
||||
.select_maybe_add(second, true);
|
||||
let harness = OperatorInvariantHarness::capture(&mut world);
|
||||
|
||||
dispatch_editor_command(&mut world, "brush.intersect");
|
||||
|
||||
harness.assert_canceled(&mut world);
|
||||
harness.assert_status(&world, "brush.intersect", OperatorPhase::Canceled);
|
||||
assert!(!world.resource::<SceneIo>().dirty);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn csg_dispatch_blocks_read_only_selection_without_history() {
|
||||
let mut world = command_world();
|
||||
let first = world
|
||||
.spawn((
|
||||
LevelObject,
|
||||
BrushDesc::cuboid(Vec3::splat(1.0)),
|
||||
Transform::IDENTITY,
|
||||
))
|
||||
.id();
|
||||
let second = world
|
||||
.spawn((
|
||||
LevelObject,
|
||||
BrushDesc::cuboid(Vec3::splat(1.0)),
|
||||
Transform::from_xyz(0.5, 0.0, 0.0),
|
||||
))
|
||||
.id();
|
||||
let mut hierarchy = crate::ui::hierarchy_state::HierarchyPanelState::default();
|
||||
hierarchy.locked.insert(second);
|
||||
world.insert_resource(hierarchy);
|
||||
world
|
||||
.resource_mut::<UiState>()
|
||||
.selected_entities
|
||||
.select_replace(first);
|
||||
world
|
||||
.resource_mut::<UiState>()
|
||||
.selected_entities
|
||||
.select_maybe_add(second, true);
|
||||
let harness = OperatorInvariantHarness::capture(&mut world);
|
||||
|
||||
dispatch_editor_command(&mut world, "brush.merge_convex");
|
||||
|
||||
harness.assert_blocked(&mut world);
|
||||
harness.assert_status(&world, "brush.merge_convex", OperatorPhase::Blocked);
|
||||
assert!(!world.resource::<SceneIo>().dirty);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn disabled_command_dispatch_is_a_blocked_no_op() {
|
||||
let mut world = command_world();
|
||||
let harness = OperatorInvariantHarness::capture(&mut world);
|
||||
|
||||
dispatch_editor_command(&mut world, "selection.group");
|
||||
|
||||
harness.assert_blocked(&mut world);
|
||||
harness.assert_status(&world, "selection.group", OperatorPhase::Blocked);
|
||||
}
|
||||
}
|
||||
@@ -106,6 +106,11 @@ pub struct PrefabEditState {
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum EditorCommand {
|
||||
GroupSelection {
|
||||
snapshot: EditorEntitySnapshot,
|
||||
group: Option<Entity>,
|
||||
changes: Vec<SiblingChange>,
|
||||
},
|
||||
Spawn {
|
||||
snapshot: EditorEntitySnapshot,
|
||||
entity: Option<Entity>,
|
||||
@@ -152,6 +157,12 @@ pub enum EditorCommand {
|
||||
old: Option<LightDesc>,
|
||||
new: LightDesc,
|
||||
},
|
||||
SetLightGroup {
|
||||
entities: Vec<Entity>,
|
||||
olds: Vec<Option<LightDesc>>,
|
||||
news: Vec<Option<LightDesc>>,
|
||||
label: &'static str,
|
||||
},
|
||||
SetAnimationController {
|
||||
entity: Entity,
|
||||
old: Option<AnimationControllerDesc>,
|
||||
@@ -293,6 +304,7 @@ pub enum EditorCommand {
|
||||
impl EditorCommand {
|
||||
pub fn label(&self) -> &'static str {
|
||||
match self {
|
||||
EditorCommand::GroupSelection { .. } => "Group Selection",
|
||||
EditorCommand::Spawn { .. } => "Spawn",
|
||||
EditorCommand::SpawnMany { .. } => "Spawn Brushes",
|
||||
EditorCommand::Despawn { .. } => "Delete",
|
||||
@@ -303,6 +315,7 @@ impl EditorCommand {
|
||||
EditorCommand::SetMaterialGroup { .. } => "Apply Material to Selection",
|
||||
EditorCommand::SetMaterialOverride { .. } => "Set Material Override",
|
||||
EditorCommand::SetLight { .. } => "Set Light",
|
||||
EditorCommand::SetLightGroup { label, .. } => label,
|
||||
EditorCommand::SetAnimationController { .. } => "Set Animation Controller",
|
||||
EditorCommand::SetAudioSource { .. } => "Set Audio Source",
|
||||
EditorCommand::SetAudioListener { .. } => "Set Audio Listener",
|
||||
|
||||
@@ -17,6 +17,7 @@ use shared::{
|
||||
TriggerVolume, WeaponSpawn,
|
||||
};
|
||||
|
||||
use crate::operators::{ActiveOperator, OperatorPhase, OperatorStatus};
|
||||
use crate::scene_io::{SceneIo, SceneIoRequest};
|
||||
use crate::selection::SelectedEntity;
|
||||
use crate::state::scene_tools_active;
|
||||
@@ -197,7 +198,20 @@ fn spawn_snapshot_with_parent(
|
||||
snapshot: &EditorEntitySnapshot,
|
||||
parent: Option<Entity>,
|
||||
) -> Entity {
|
||||
let mut entity_mut = world.spawn((LevelObject, snapshot.actor_kind, snapshot.transform));
|
||||
let visibility = if snapshot.editor_visibility.visible {
|
||||
Visibility::Visible
|
||||
} else {
|
||||
Visibility::Hidden
|
||||
};
|
||||
let mut entity_mut = world.spawn((
|
||||
LevelObject,
|
||||
snapshot.actor_kind,
|
||||
snapshot.transform,
|
||||
snapshot.editor_visibility,
|
||||
visibility,
|
||||
InheritedVisibility::default(),
|
||||
ViewVisibility::default(),
|
||||
));
|
||||
entity_mut.insert(
|
||||
snapshot
|
||||
.actor_id
|
||||
@@ -290,7 +304,6 @@ fn spawn_snapshot_with_parent(
|
||||
entity_mut.insert(link.clone());
|
||||
}
|
||||
entity_mut.insert(HierarchySiblingIndex(snapshot.hierarchy_sibling_index));
|
||||
entity_mut.insert(snapshot.editor_visibility);
|
||||
if let Some(order) = &snapshot.inspector_order {
|
||||
entity_mut.insert(order.clone());
|
||||
}
|
||||
@@ -560,6 +573,40 @@ pub fn set_light_with_history(world: &mut World, entity: Entity, new: LightDesc)
|
||||
push_history(world, EditorCommand::SetLight { entity, old, new });
|
||||
}
|
||||
|
||||
pub fn set_light_group_with_history(
|
||||
world: &mut World,
|
||||
changes: impl IntoIterator<Item = (Entity, Option<LightDesc>)>,
|
||||
label: &'static str,
|
||||
) {
|
||||
let mut entities = Vec::new();
|
||||
let mut olds = Vec::new();
|
||||
let mut news = Vec::new();
|
||||
for (entity, new) in changes {
|
||||
if !is_mutable_level_object(world, entity) {
|
||||
continue;
|
||||
}
|
||||
let old = world.get::<LightDesc>(entity).cloned();
|
||||
if old.is_none() && new.is_none() {
|
||||
continue;
|
||||
}
|
||||
apply_light(world, entity, &new);
|
||||
entities.push(entity);
|
||||
olds.push(old);
|
||||
news.push(new);
|
||||
}
|
||||
if !entities.is_empty() {
|
||||
push_history(
|
||||
world,
|
||||
EditorCommand::SetLightGroup {
|
||||
entities,
|
||||
olds,
|
||||
news,
|
||||
label,
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_audio_source_with_history(world: &mut World, entity: Entity, new: AudioSourceDesc) {
|
||||
if !is_mutable_level_object(world, entity) {
|
||||
return;
|
||||
@@ -752,9 +799,13 @@ pub fn apply_brush_csg_with_history(
|
||||
new_transform: Transform,
|
||||
new_brush: BrushDesc,
|
||||
delete_entities: &[Entity],
|
||||
) {
|
||||
if !is_level_object(world, primary) {
|
||||
return;
|
||||
) -> bool {
|
||||
if !is_mutable_level_object(world, primary)
|
||||
|| delete_entities
|
||||
.iter()
|
||||
.any(|entity| !is_mutable_level_object(world, *entity))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
let old_transform = world.get::<Transform>(primary).copied().unwrap_or_default();
|
||||
let old_brush = world.get::<BrushDesc>(primary).cloned();
|
||||
@@ -769,7 +820,7 @@ pub fn apply_brush_csg_with_history(
|
||||
&& old_brush.as_ref() == Some(&new_brush)
|
||||
&& deleted.is_empty()
|
||||
{
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
if let Ok(mut entity_mut) = world.get_entity_mut(primary) {
|
||||
entity_mut.insert(new_transform);
|
||||
@@ -790,6 +841,7 @@ pub fn apply_brush_csg_with_history(
|
||||
},
|
||||
);
|
||||
select_one(world, primary);
|
||||
true
|
||||
}
|
||||
|
||||
pub fn set_static_mesh_renderer_with_history(
|
||||
@@ -943,14 +995,16 @@ pub fn group_selection_with_history(world: &mut World, entities: &[Entity]) {
|
||||
children: Vec::new(),
|
||||
};
|
||||
let group = spawn_snapshot(world, &snapshot);
|
||||
let changes = reorder_entities_under_parent(world, &entities, Some(group), i32::MAX);
|
||||
push_history(
|
||||
world,
|
||||
EditorCommand::Spawn {
|
||||
EditorCommand::GroupSelection {
|
||||
snapshot,
|
||||
entity: Some(group),
|
||||
group: Some(group),
|
||||
changes,
|
||||
},
|
||||
);
|
||||
reorder_siblings_with_history(world, &entities, Some(group), i32::MAX);
|
||||
select_one(world, group);
|
||||
}
|
||||
|
||||
pub fn create_empty_child_with_history(world: &mut World, parent: Entity) {
|
||||
@@ -1637,6 +1691,13 @@ fn prepare_prefab_source_history(
|
||||
|
||||
fn undo_command(world: &mut World, command: &mut EditorCommand) {
|
||||
match command {
|
||||
EditorCommand::GroupSelection { group, changes, .. } => {
|
||||
for change in changes.iter().rev() {
|
||||
apply_sibling_change(world, change);
|
||||
}
|
||||
despawn_entity(world, *group);
|
||||
clear_selection(world);
|
||||
}
|
||||
EditorCommand::Spawn { entity, .. } => {
|
||||
despawn_entity(world, entity.take());
|
||||
clear_selection(world);
|
||||
@@ -1682,6 +1743,11 @@ fn undo_command(world: &mut World, command: &mut EditorCommand) {
|
||||
EditorCommand::SetLight { entity, old, .. } => {
|
||||
apply_light(world, *entity, old);
|
||||
}
|
||||
EditorCommand::SetLightGroup { entities, olds, .. } => {
|
||||
for (entity, old) in entities.iter().zip(olds.iter()) {
|
||||
apply_light(world, *entity, old);
|
||||
}
|
||||
}
|
||||
EditorCommand::SetAnimationController { entity, old, .. } => {
|
||||
apply_animation_controller(world, *entity, old);
|
||||
}
|
||||
@@ -1818,6 +1884,25 @@ fn undo_command(world: &mut World, command: &mut EditorCommand) {
|
||||
|
||||
fn redo_command(world: &mut World, command: &mut EditorCommand) {
|
||||
match command {
|
||||
EditorCommand::GroupSelection {
|
||||
snapshot,
|
||||
group,
|
||||
changes,
|
||||
} => {
|
||||
let previous_group = *group;
|
||||
let spawned = spawn_snapshot(world, snapshot);
|
||||
*group = Some(spawned);
|
||||
for change in changes.iter_mut() {
|
||||
if Some(change.entity) == previous_group {
|
||||
change.entity = spawned;
|
||||
}
|
||||
if change.new_parent == previous_group {
|
||||
change.new_parent = Some(spawned);
|
||||
}
|
||||
apply_sibling_change_new(world, change);
|
||||
}
|
||||
select_one(world, spawned);
|
||||
}
|
||||
EditorCommand::Spawn { snapshot, entity } => {
|
||||
let spawned = spawn_snapshot(world, snapshot);
|
||||
*entity = Some(spawned);
|
||||
@@ -1881,6 +1966,11 @@ fn redo_command(world: &mut World, command: &mut EditorCommand) {
|
||||
entity_mut.insert(new.clone());
|
||||
}
|
||||
}
|
||||
EditorCommand::SetLightGroup { entities, news, .. } => {
|
||||
for (entity, new) in entities.iter().zip(news.iter()) {
|
||||
apply_light(world, *entity, new);
|
||||
}
|
||||
}
|
||||
EditorCommand::SetAnimationController { entity, new, .. } => {
|
||||
if let Ok(mut entity_mut) = world.get_entity_mut(*entity) {
|
||||
entity_mut.insert(new.clone());
|
||||
@@ -2614,16 +2704,22 @@ fn capture_gizmo_transform_edits(world: &mut World) {
|
||||
let start_group =
|
||||
active.map(|(entity, transform)| selected_transforms(world, &selection, entity, transform));
|
||||
|
||||
let mut started_edit = false;
|
||||
let (finished_edit, live_edit) = {
|
||||
let mut tracker = world.resource_mut::<TransformEditTracker>();
|
||||
if tracker.active.is_none() {
|
||||
if let (Some((entity, transform)), Some(group)) = (active, start_group) {
|
||||
tracker.active = Some((entity, transform, group));
|
||||
return;
|
||||
started_edit = true;
|
||||
}
|
||||
}
|
||||
if started_edit {
|
||||
(None, None)
|
||||
} else {
|
||||
match tracker.active.take() {
|
||||
Some((primary, old, group)) if active.is_none() => (Some((primary, old, group)), None),
|
||||
Some((primary, old, group)) if active.is_none() => {
|
||||
(Some((primary, old, group)), None)
|
||||
}
|
||||
Some(state) if active.is_some() => {
|
||||
let live = Some(state.clone());
|
||||
tracker.active = Some(state);
|
||||
@@ -2631,8 +2727,18 @@ fn capture_gizmo_transform_edits(world: &mut World) {
|
||||
}
|
||||
_ => (None, None),
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if started_edit {
|
||||
set_transform_operator_status(
|
||||
world,
|
||||
OperatorPhase::Preview,
|
||||
"Transform gizmo drag in progress",
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if let Some((primary, old_primary, group)) = live_edit {
|
||||
let Some(new_primary) = world.get::<Transform>(primary).copied() else {
|
||||
return;
|
||||
@@ -2645,15 +2751,51 @@ fn capture_gizmo_transform_edits(world: &mut World) {
|
||||
|
||||
if let Some((primary, old_primary, group)) = finished_edit {
|
||||
let Some(new_primary) = world.get::<Transform>(primary).copied() else {
|
||||
for (entity, old) in group {
|
||||
if let Some(mut transform) = world.get_mut::<Transform>(entity) {
|
||||
*transform = old;
|
||||
}
|
||||
}
|
||||
set_transform_operator_status(
|
||||
world,
|
||||
OperatorPhase::Canceled,
|
||||
"Transform target disappeared; surviving previews restored",
|
||||
);
|
||||
return;
|
||||
};
|
||||
let undo_depth = world.resource::<EditorHistory>().undo_depth();
|
||||
if group.len() <= 1 {
|
||||
set_transform_with_history(world, primary, old_primary, new_primary);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
let changes = transform_group_changes(old_primary, new_primary, group);
|
||||
set_transform_group_with_history(world, changes);
|
||||
}
|
||||
if world.resource::<EditorHistory>().undo_depth() > undo_depth {
|
||||
set_transform_operator_status(
|
||||
world,
|
||||
OperatorPhase::Committed,
|
||||
"Transform gizmo edit committed",
|
||||
);
|
||||
} else {
|
||||
set_transform_operator_status(
|
||||
world,
|
||||
OperatorPhase::Canceled,
|
||||
"Transform gizmo edit made no changes",
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn set_transform_operator_status(world: &mut World, phase: OperatorPhase, hint: impl Into<String>) {
|
||||
if let Some(mut active) = world.get_resource_mut::<ActiveOperator>() {
|
||||
active.status = Some(OperatorStatus {
|
||||
id: "transform.gizmo".to_string(),
|
||||
label: "Transform Gizmo".to_string(),
|
||||
phase,
|
||||
hint: hint.into(),
|
||||
warnings: Vec::new(),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
fn transform_group_changes(
|
||||
@@ -2796,7 +2938,7 @@ pub(crate) fn material_eq(a: &MaterialDesc, b: &MaterialDesc) -> bool {
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::operators::test_harness::{assert_undo_redo_round_trip, OperatorInvariantHarness};
|
||||
use crate::operators::{ActiveOperator, OperatorPhase, OperatorStatus};
|
||||
use crate::operators::{ActiveOperator, OperatorPhase};
|
||||
|
||||
#[derive(Component, Reflect, Default, Debug, Clone, PartialEq)]
|
||||
#[reflect(Component, Default)]
|
||||
@@ -3074,6 +3216,7 @@ mod tests {
|
||||
world.init_resource::<ActiveOperator>();
|
||||
world.init_resource::<EditorHistory>();
|
||||
world.init_resource::<SceneIo>();
|
||||
world.init_resource::<TransformEditTracker>();
|
||||
let first = world.spawn((LevelObject, Transform::default())).id();
|
||||
let second = world
|
||||
.spawn((
|
||||
@@ -3085,30 +3228,19 @@ mod tests {
|
||||
let committed = vec![Vec3::Z, Vec3::new(2.0, 0.0, 1.0)];
|
||||
let harness = OperatorInvariantHarness::capture(&mut world);
|
||||
|
||||
set_transform_group_with_history(
|
||||
&mut world,
|
||||
[
|
||||
(
|
||||
world.resource_mut::<TransformEditTracker>().active = Some((
|
||||
first,
|
||||
Transform::default(),
|
||||
Transform::from_translation(committed[0]),
|
||||
),
|
||||
(
|
||||
second,
|
||||
Transform::from_translation(initial[1]),
|
||||
Transform::from_translation(committed[1]),
|
||||
),
|
||||
vec![
|
||||
(first, Transform::default()),
|
||||
(second, Transform::from_translation(initial[1])),
|
||||
],
|
||||
);
|
||||
world.resource_mut::<ActiveOperator>().status = Some(OperatorStatus {
|
||||
id: "transform.gizmo".to_string(),
|
||||
label: "Transform Gizmo".to_string(),
|
||||
phase: OperatorPhase::Committed,
|
||||
hint: "Committed multi-selection drag".to_string(),
|
||||
warnings: Vec::new(),
|
||||
});
|
||||
));
|
||||
*world.get_mut::<Transform>(first).unwrap() = Transform::from_translation(committed[0]);
|
||||
capture_gizmo_transform_edits(&mut world);
|
||||
|
||||
harness.assert_committed(&mut world, 1, 0);
|
||||
harness.assert_status(&world, "transform.gizmo", OperatorPhase::Committed);
|
||||
assert_undo_redo_round_trip(&mut world, initial, committed, |world| {
|
||||
[first, second]
|
||||
.into_iter()
|
||||
@@ -3117,6 +3249,63 @@ mod tests {
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn no_op_transform_release_terminates_preview_without_history() {
|
||||
let mut world = World::new();
|
||||
world.init_resource::<ActiveOperator>();
|
||||
world.init_resource::<EditorHistory>();
|
||||
world.init_resource::<SceneIo>();
|
||||
world.init_resource::<TransformEditTracker>();
|
||||
let transform = Transform::from_xyz(1.0, 2.0, 3.0);
|
||||
let entity = world.spawn((LevelObject, transform)).id();
|
||||
world.resource_mut::<TransformEditTracker>().active =
|
||||
Some((entity, transform, vec![(entity, transform)]));
|
||||
set_transform_operator_status(
|
||||
&mut world,
|
||||
OperatorPhase::Preview,
|
||||
"Transform gizmo drag in progress",
|
||||
);
|
||||
let harness = OperatorInvariantHarness::capture(&mut world);
|
||||
|
||||
capture_gizmo_transform_edits(&mut world);
|
||||
|
||||
harness.assert_canceled(&mut world);
|
||||
harness.assert_status(&world, "transform.gizmo", OperatorPhase::Canceled);
|
||||
assert_eq!(world.get::<Transform>(entity), Some(&transform));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn missing_primary_transform_rolls_back_surviving_preview_targets() {
|
||||
let mut world = World::new();
|
||||
world.init_resource::<ActiveOperator>();
|
||||
world.init_resource::<EditorHistory>();
|
||||
world.init_resource::<SceneIo>();
|
||||
world.init_resource::<TransformEditTracker>();
|
||||
let primary_old = Transform::from_xyz(1.0, 0.0, 0.0);
|
||||
let survivor_old = Transform::from_xyz(2.0, 0.0, 0.0);
|
||||
let primary = world.spawn((LevelObject, primary_old)).id();
|
||||
let survivor = world.spawn((LevelObject, survivor_old)).id();
|
||||
world.resource_mut::<TransformEditTracker>().active = Some((
|
||||
primary,
|
||||
primary_old,
|
||||
vec![(primary, primary_old), (survivor, survivor_old)],
|
||||
));
|
||||
*world.get_mut::<Transform>(survivor).unwrap() = Transform::from_xyz(8.0, 0.0, 0.0);
|
||||
world.despawn(primary);
|
||||
set_transform_operator_status(
|
||||
&mut world,
|
||||
OperatorPhase::Preview,
|
||||
"Transform gizmo drag in progress",
|
||||
);
|
||||
let harness = OperatorInvariantHarness::capture(&mut world);
|
||||
|
||||
capture_gizmo_transform_edits(&mut world);
|
||||
|
||||
harness.assert_canceled(&mut world);
|
||||
harness.assert_status(&world, "transform.gizmo", OperatorPhase::Canceled);
|
||||
assert_eq!(world.get::<Transform>(survivor), Some(&survivor_old));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unpack_prefab_is_one_undoable_history_command() {
|
||||
let mut world = World::new();
|
||||
|
||||
@@ -27,6 +27,7 @@ pub use project::diagnostics_bundle;
|
||||
pub use project::launcher;
|
||||
pub use project::native_dialog;
|
||||
pub use project::project_io;
|
||||
pub use project::samples;
|
||||
pub use project::session;
|
||||
pub use project::settings_ui;
|
||||
pub use scene::scene_io;
|
||||
@@ -74,6 +75,7 @@ use play::audio_preview::AudioPreviewPlugin;
|
||||
use play::PlaySessionPlugin;
|
||||
use project::collaboration::CollaborationPlugin;
|
||||
use project::native_dialog::NativeDialogPlugin;
|
||||
use project::samples::SampleCatalogPlugin;
|
||||
use project_io::ProjectIoPlugin;
|
||||
use render_view::RenderViewPlugin;
|
||||
use scene_io::SceneIoPlugin;
|
||||
@@ -98,6 +100,7 @@ impl PluginGroup for EditorPluginGroup {
|
||||
let group = PluginGroupBuilder::start::<Self>()
|
||||
.add(EditorInfraPlugin)
|
||||
.add(ProjectIoPlugin)
|
||||
.add(SampleCatalogPlugin)
|
||||
.add(NativeDialogPlugin)
|
||||
.add(scene_schema::SceneSchemaPlugin)
|
||||
.add(net_editor::NetEditorPlugin)
|
||||
|
||||
@@ -59,6 +59,12 @@ pub enum OperatorAvailability {
|
||||
Disabled(String),
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum OperatorAction {
|
||||
Commit,
|
||||
ContinuePreview,
|
||||
}
|
||||
|
||||
pub trait EditorOperator {
|
||||
fn id(&self) -> &str;
|
||||
fn label(&self) -> &str;
|
||||
@@ -221,6 +227,51 @@ pub fn run_immediate_operator(
|
||||
run_operator(world, &mut operator)
|
||||
}
|
||||
|
||||
/// Runs an editor command that may either complete immediately or hand ownership to a modal tool.
|
||||
/// Modal starters retain the preview status installed by their production entry point.
|
||||
pub fn run_operator_action(
|
||||
world: &mut World,
|
||||
id: &str,
|
||||
label: &str,
|
||||
availability: OperatorAvailability,
|
||||
action: impl FnOnce(&mut World) -> Result<OperatorAction, String>,
|
||||
) -> bool {
|
||||
if let OperatorAvailability::Disabled(reason) = availability {
|
||||
set_operator_status(
|
||||
world,
|
||||
OperatorStatus::new(id, label, OperatorPhase::Blocked, reason),
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
set_operator_status(
|
||||
world,
|
||||
OperatorStatus::new(id, label, OperatorPhase::Preview, "Starting"),
|
||||
);
|
||||
match action(world) {
|
||||
Ok(OperatorAction::Commit) => {
|
||||
set_operator_status(
|
||||
world,
|
||||
OperatorStatus::new(
|
||||
id,
|
||||
label,
|
||||
OperatorPhase::Committed,
|
||||
format!("Completed {label}"),
|
||||
),
|
||||
);
|
||||
true
|
||||
}
|
||||
Ok(OperatorAction::ContinuePreview) => true,
|
||||
Err(error) => {
|
||||
set_operator_status(
|
||||
world,
|
||||
OperatorStatus::new(id, label, OperatorPhase::Canceled, error),
|
||||
);
|
||||
false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn set_operator_status(world: &mut World, status: OperatorStatus) {
|
||||
if let Some(mut active) = world.get_resource_mut::<ActiveOperator>() {
|
||||
active.status = Some(status);
|
||||
@@ -355,6 +406,52 @@ mod tests {
|
||||
harness.assert_no_helpers::<PreviewHelper>(&mut world);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn preview_failure_runs_cancel_and_cleans_helpers() {
|
||||
struct PreviewFailure(CounterOperator);
|
||||
|
||||
impl EditorOperator for PreviewFailure {
|
||||
fn id(&self) -> &str {
|
||||
self.0.id()
|
||||
}
|
||||
|
||||
fn label(&self) -> &str {
|
||||
self.0.label()
|
||||
}
|
||||
|
||||
fn begin(&mut self, world: &mut World) -> Result<(), String> {
|
||||
self.0.begin(world)
|
||||
}
|
||||
|
||||
fn preview(&mut self, world: &mut World) -> Result<(), String> {
|
||||
self.0.preview(world)?;
|
||||
Err("preview failed".to_string())
|
||||
}
|
||||
|
||||
fn commit(&mut self, _world: &mut World) -> Result<(), String> {
|
||||
panic!("commit must not run after preview failure")
|
||||
}
|
||||
|
||||
fn cancel(&mut self, world: &mut World) {
|
||||
self.0.cancel(world);
|
||||
}
|
||||
}
|
||||
|
||||
let mut world = test_world();
|
||||
let harness = OperatorInvariantHarness::capture(&mut world);
|
||||
let mut operator = PreviewFailure(CounterOperator {
|
||||
before: 0,
|
||||
helper: None,
|
||||
});
|
||||
|
||||
assert!(!run_operator(&mut world, &mut operator));
|
||||
|
||||
harness.assert_canceled(&mut world);
|
||||
harness.assert_status(&world, "test.counter", OperatorPhase::Canceled);
|
||||
harness.assert_no_helpers::<PreviewHelper>(&mut world);
|
||||
assert_eq!(world.resource::<Counter>().0, 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn blocked_operator_never_begins_or_mutates_world() {
|
||||
let mut world = test_world();
|
||||
|
||||
@@ -47,6 +47,12 @@ impl OperatorInvariantHarness {
|
||||
world.resource::<SceneIo>().dirty,
|
||||
"a committed authored mutation must mark the scene dirty"
|
||||
);
|
||||
} else {
|
||||
assert_eq!(
|
||||
world.resource::<SceneIo>().dirty,
|
||||
self.dirty,
|
||||
"a committed non-authoring operator must preserve the prior dirty state"
|
||||
);
|
||||
}
|
||||
assert_eq!(
|
||||
authored_count(world) as isize,
|
||||
@@ -93,6 +99,39 @@ impl OperatorInvariantHarness {
|
||||
);
|
||||
}
|
||||
|
||||
pub(crate) fn assert_status(
|
||||
&self,
|
||||
world: &World,
|
||||
expected_id: &str,
|
||||
expected_phase: OperatorPhase,
|
||||
) {
|
||||
let status = world
|
||||
.resource::<ActiveOperator>()
|
||||
.status
|
||||
.as_ref()
|
||||
.expect("operator must retain an inspectable lifecycle status");
|
||||
assert_eq!(status.id, expected_id, "operator reported the wrong id");
|
||||
assert_eq!(
|
||||
status.phase, expected_phase,
|
||||
"operator reported the wrong phase"
|
||||
);
|
||||
}
|
||||
|
||||
pub(crate) fn assert_projection_unchanged<T>(
|
||||
&self,
|
||||
world: &mut World,
|
||||
expected: T,
|
||||
mut read: impl FnMut(&mut World) -> T,
|
||||
) where
|
||||
T: Debug + PartialEq,
|
||||
{
|
||||
assert_eq!(
|
||||
read(world),
|
||||
expected,
|
||||
"operator changed authored state without a committed history transaction"
|
||||
);
|
||||
}
|
||||
|
||||
fn assert_phase(&self, world: &World, expected: OperatorPhase) {
|
||||
let phase = world
|
||||
.resource::<ActiveOperator>()
|
||||
|
||||
@@ -5,5 +5,6 @@ pub mod diagnostics_bundle;
|
||||
pub mod launcher;
|
||||
pub mod native_dialog;
|
||||
pub mod project_io;
|
||||
pub mod samples;
|
||||
pub mod session;
|
||||
pub mod settings_ui;
|
||||
@@ -0,0 +1,208 @@
|
||||
//! Cached project sample catalog used by editor scene-opening UI.
|
||||
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use bevy::prelude::*;
|
||||
use scene::sample_pack::{
|
||||
validate_editor_sample_pack, EditorSampleEntry, EDITOR_SAMPLE_MANIFEST_PATH,
|
||||
};
|
||||
|
||||
use super::project_io::ProjectWorkspace;
|
||||
|
||||
const VALIDATION_HINT: &str = "Run `cargo validate-samples --project .` for details.";
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct SampleCatalogEntry {
|
||||
pub id: String,
|
||||
pub label: String,
|
||||
pub scene_path: PathBuf,
|
||||
pub project_relative_scene: String,
|
||||
pub summary: String,
|
||||
pub checks: Vec<String>,
|
||||
}
|
||||
|
||||
impl SampleCatalogEntry {
|
||||
pub fn hover_text(&self) -> String {
|
||||
let mut lines = vec![self.summary.clone()];
|
||||
if !self.checks.is_empty() {
|
||||
lines.push(format!("Checks: {}", self.checks.join(", ")));
|
||||
}
|
||||
lines.push(self.project_relative_scene.clone());
|
||||
lines.join("\n")
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Resource, Debug, Clone)]
|
||||
pub struct SampleCatalog {
|
||||
entries: Vec<SampleCatalogEntry>,
|
||||
unavailable_reason: Option<String>,
|
||||
}
|
||||
|
||||
impl Default for SampleCatalog {
|
||||
fn default() -> Self {
|
||||
Self::unavailable("Sample catalog is loading")
|
||||
}
|
||||
}
|
||||
|
||||
impl SampleCatalog {
|
||||
pub fn entries(&self) -> &[SampleCatalogEntry] {
|
||||
&self.entries
|
||||
}
|
||||
|
||||
pub fn entry(&self, stable_id: &str) -> Option<&SampleCatalogEntry> {
|
||||
self.unavailable_reason
|
||||
.is_none()
|
||||
.then(|| self.entries.iter().find(|entry| entry.id == stable_id))
|
||||
.flatten()
|
||||
}
|
||||
|
||||
pub fn unavailable_reason(&self) -> Option<&str> {
|
||||
self.unavailable_reason.as_deref()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
pub(crate) fn available_entries(entries: Vec<SampleCatalogEntry>) -> Self {
|
||||
Self {
|
||||
entries,
|
||||
unavailable_reason: None,
|
||||
}
|
||||
}
|
||||
|
||||
fn available(samples: Vec<EditorSampleEntry>) -> Self {
|
||||
Self {
|
||||
entries: samples.into_iter().map(catalog_entry).collect(),
|
||||
unavailable_reason: None,
|
||||
}
|
||||
}
|
||||
|
||||
fn unavailable(reason: impl Into<String>) -> Self {
|
||||
Self {
|
||||
entries: Vec::new(),
|
||||
unavailable_reason: Some(reason.into()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn catalog_entry(entry: EditorSampleEntry) -> SampleCatalogEntry {
|
||||
SampleCatalogEntry {
|
||||
id: entry.id,
|
||||
label: entry.label,
|
||||
scene_path: PathBuf::from(&entry.scene),
|
||||
project_relative_scene: entry.scene,
|
||||
summary: entry.summary,
|
||||
checks: entry.checks,
|
||||
}
|
||||
}
|
||||
|
||||
fn load_catalog(project_root: &Path) -> SampleCatalog {
|
||||
let validation = validate_editor_sample_pack(project_root);
|
||||
if !validation.is_release_ready() {
|
||||
let first_error = validation
|
||||
.report
|
||||
.findings
|
||||
.iter()
|
||||
.find(|finding| finding.severity == scene::ValidationSeverity::Error)
|
||||
.map(|finding| finding.message.as_str())
|
||||
.unwrap_or("sample pack validation failed");
|
||||
return SampleCatalog::unavailable(format!(
|
||||
"Sample manifest `{EDITOR_SAMPLE_MANIFEST_PATH}` is invalid: {first_error}\n{VALIDATION_HINT}"
|
||||
));
|
||||
}
|
||||
if validation.samples.is_empty() {
|
||||
return SampleCatalog::unavailable(format!(
|
||||
"Sample manifest contains no scenes.\n{VALIDATION_HINT}"
|
||||
));
|
||||
}
|
||||
SampleCatalog::available(validation.samples)
|
||||
}
|
||||
|
||||
fn load_sample_catalog(world: &mut World) {
|
||||
let project_root = PathBuf::from(&world.resource::<ProjectWorkspace>().root);
|
||||
world.insert_resource(load_catalog(&project_root));
|
||||
}
|
||||
|
||||
pub struct SampleCatalogPlugin;
|
||||
|
||||
impl Plugin for SampleCatalogPlugin {
|
||||
fn build(&self, app: &mut App) {
|
||||
app.init_resource::<SampleCatalog>()
|
||||
.add_systems(Startup, load_sample_catalog);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use scene::sample_pack::EditorSampleArea;
|
||||
|
||||
fn sample(id: &str, label: &str, scene: &str) -> EditorSampleEntry {
|
||||
EditorSampleEntry {
|
||||
id: id.into(),
|
||||
label: label.into(),
|
||||
area: EditorSampleArea::Brush,
|
||||
scene: scene.into(),
|
||||
summary: format!("Summary for {label}"),
|
||||
checks: vec!["selection".into(), "undo".into()],
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn available_catalog_preserves_manifest_order_and_resolves_paths() {
|
||||
let catalog = SampleCatalog::available(vec![
|
||||
sample(
|
||||
"terrain",
|
||||
"Terrain",
|
||||
"assets/levels/samples/terrain.scn.ron",
|
||||
),
|
||||
sample("brush", "Brush", "assets/levels/samples/brush.scn.ron"),
|
||||
]);
|
||||
|
||||
assert_eq!(
|
||||
catalog
|
||||
.entries()
|
||||
.iter()
|
||||
.map(|entry| entry.id.as_str())
|
||||
.collect::<Vec<_>>(),
|
||||
vec!["terrain", "brush"]
|
||||
);
|
||||
assert_eq!(
|
||||
catalog.entry("brush").unwrap().scene_path,
|
||||
PathBuf::from("assets/levels/samples/brush.scn.ron")
|
||||
);
|
||||
let hover = catalog.entry("brush").unwrap().hover_text();
|
||||
assert!(hover.contains("Summary for Brush"));
|
||||
assert!(hover.contains("Checks: selection, undo"));
|
||||
assert!(hover.contains("assets/levels/samples/brush.scn.ron"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unavailable_catalog_never_resolves_entries() {
|
||||
let catalog = SampleCatalog {
|
||||
entries: vec![catalog_entry(sample(
|
||||
"brush",
|
||||
"Brush",
|
||||
"assets/levels/samples/brush.scn.ron",
|
||||
))],
|
||||
unavailable_reason: Some("manifest invalid".into()),
|
||||
};
|
||||
|
||||
assert!(catalog.entry("brush").is_none());
|
||||
assert_eq!(catalog.unavailable_reason(), Some("manifest invalid"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn missing_manifest_reports_repair_command() {
|
||||
let root = std::env::temp_dir().join(format!(
|
||||
"blacksite-missing-sample-catalog-{}",
|
||||
uuid::Uuid::new_v4()
|
||||
));
|
||||
std::fs::create_dir_all(&root).unwrap();
|
||||
|
||||
let catalog = load_catalog(&root);
|
||||
|
||||
let reason = catalog.unavailable_reason().unwrap();
|
||||
assert!(reason.contains(EDITOR_SAMPLE_MANIFEST_PATH));
|
||||
assert!(reason.contains("cargo validate-samples --project ."));
|
||||
std::fs::remove_dir_all(root).unwrap();
|
||||
}
|
||||
}
|
||||
@@ -25,6 +25,7 @@ use crate::assets::{import_external_assets, EditorAssets, IMPORTABLE_ASSET_EXTEN
|
||||
use crate::history::{clear_level_objects, snapshot_entity, EditorHistory};
|
||||
use crate::native_dialog::NativeDialogBroker;
|
||||
use crate::project::collaboration::{publish_authored_file, FileSnapshot, FileWriteIntent};
|
||||
use crate::project::samples::SampleCatalog;
|
||||
use crate::scene::recovery::{
|
||||
default_state_root, discard_recovery_snapshots, latest_recovery_snapshot,
|
||||
write_recovery_snapshot,
|
||||
@@ -49,6 +50,7 @@ pub enum SceneIoRequest {
|
||||
SaveRecoveryCopyAs,
|
||||
DiscardRecovery,
|
||||
OpenRecent(usize),
|
||||
OpenSample(String),
|
||||
OpenPath(PathBuf),
|
||||
SwitchTab(usize),
|
||||
CloseTab(usize),
|
||||
@@ -313,6 +315,7 @@ fn process_scene_io_requests(world: &mut World) {
|
||||
SceneIoRequest::SaveRecoveryCopyAs => save_recovery_copy_with_dialog(world),
|
||||
SceneIoRequest::DiscardRecovery => discard_recovery(world),
|
||||
SceneIoRequest::OpenRecent(index) => open_recent(world, index),
|
||||
SceneIoRequest::OpenSample(stable_id) => open_sample(world, &stable_id),
|
||||
SceneIoRequest::OpenPath(path) => open_path(world, path),
|
||||
SceneIoRequest::SwitchTab(index) => switch_scene_tab(world, index),
|
||||
SceneIoRequest::CloseTab(index) => close_scene_tab(world, index),
|
||||
@@ -377,13 +380,72 @@ fn open_recent(world: &mut World, index: usize) -> String {
|
||||
open_path(world, path)
|
||||
}
|
||||
|
||||
fn open_sample(world: &mut World, stable_id: &str) -> String {
|
||||
let catalog_state = {
|
||||
let catalog = world.resource::<SampleCatalog>();
|
||||
(
|
||||
catalog.entry(stable_id).cloned(),
|
||||
catalog.unavailable_reason().map(str::to_string),
|
||||
)
|
||||
};
|
||||
match catalog_state {
|
||||
(Some(entry), _) => open_path(world, entry.scene_path),
|
||||
(None, Some(reason)) => format!("Open sample failed: {reason}"),
|
||||
(None, None) => format!("Open sample failed: unknown sample ID `{stable_id}`"),
|
||||
}
|
||||
}
|
||||
|
||||
/// Comparison-only key. Stored paths remain unchanged because recovery and bookmarks use them.
|
||||
fn scene_path_identity(project_root: &Path, path: &Path) -> PathBuf {
|
||||
let candidate = if path.is_absolute() {
|
||||
path.to_path_buf()
|
||||
} else {
|
||||
project_root.join(path)
|
||||
};
|
||||
candidate.canonicalize().unwrap_or(candidate)
|
||||
}
|
||||
|
||||
fn scene_paths_share_identity(project_root: &Path, first: &Path, second: &Path) -> bool {
|
||||
scene_path_identity(project_root, first) == scene_path_identity(project_root, second)
|
||||
}
|
||||
|
||||
fn remember_persisted_scene_path(
|
||||
preferences: &mut crate::project_io::UserPreferences,
|
||||
project_root: &Path,
|
||||
path: &Path,
|
||||
) {
|
||||
preferences
|
||||
.recent_levels
|
||||
.retain(|recent| !scene_paths_share_identity(project_root, Path::new(recent), path));
|
||||
preferences
|
||||
.recent_levels
|
||||
.insert(0, path.display().to_string());
|
||||
preferences.recent_levels.truncate(8);
|
||||
}
|
||||
|
||||
fn open_path(world: &mut World, path: PathBuf) -> String {
|
||||
if let Some(index) = world
|
||||
.resource::<SceneIo>()
|
||||
.tabs
|
||||
.iter()
|
||||
.position(|tab| tab.path.as_ref() == Some(&path))
|
||||
{
|
||||
let project_root = PathBuf::from(
|
||||
world
|
||||
.resource::<crate::project_io::ProjectWorkspace>()
|
||||
.root
|
||||
.clone(),
|
||||
);
|
||||
let Ok(project_root) = project_root.canonicalize() else {
|
||||
return format!(
|
||||
"Open failed: could not resolve project root {}",
|
||||
project_root.display()
|
||||
);
|
||||
};
|
||||
let matching_tab = world.resource::<SceneIo>().tabs.iter().position(|tab| {
|
||||
tab.path
|
||||
.as_deref()
|
||||
.is_some_and(|tab_path| scene_paths_share_identity(&project_root, tab_path, &path))
|
||||
});
|
||||
if let Some(index) = matching_tab {
|
||||
let established_path = world.resource::<SceneIo>().tabs[index].path.clone();
|
||||
if let Some(established_path) = established_path {
|
||||
remember_path(world, established_path);
|
||||
}
|
||||
return switch_scene_tab(world, index);
|
||||
}
|
||||
if let Err(error) = capture_active_tab(world) {
|
||||
@@ -2109,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
|
||||
@@ -2160,15 +2224,24 @@ fn backfill_missing_actor_kinds(world: &mut World) {
|
||||
}
|
||||
|
||||
fn remember_path(world: &mut World, path: PathBuf) {
|
||||
let configured_root = PathBuf::from(
|
||||
world
|
||||
.resource::<crate::project_io::ProjectWorkspace>()
|
||||
.root
|
||||
.clone(),
|
||||
);
|
||||
let project_root = configured_root.canonicalize().unwrap_or(configured_root);
|
||||
{
|
||||
let mut io = world.resource_mut::<SceneIo>();
|
||||
io.recent_paths.retain(|recent| recent != &path);
|
||||
io.recent_paths
|
||||
.retain(|recent| !scene_paths_share_identity(&project_root, recent, &path));
|
||||
io.recent_paths.insert(0, path.clone());
|
||||
io.recent_paths.truncate(8);
|
||||
}
|
||||
|
||||
if world.contains_resource::<crate::project_io::UserPreferences>() {
|
||||
let path_label = path.display().to_string();
|
||||
let mut prefs = world.resource_mut::<crate::project_io::UserPreferences>();
|
||||
crate::project_io::push_recent(&mut prefs.recent_levels, path_label, 8);
|
||||
remember_persisted_scene_path(&mut prefs, &project_root, &path);
|
||||
if let Err(error) = crate::project_io::write_user_preferences(&prefs) {
|
||||
warn!("Failed to save editor preferences: {error}");
|
||||
}
|
||||
@@ -2419,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"
|
||||
@@ -2440,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!(
|
||||
@@ -2451,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();
|
||||
@@ -3168,6 +3301,258 @@ mod tests {
|
||||
std::fs::remove_dir_all(root).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unknown_sample_id_does_not_change_scene_state() {
|
||||
let known = crate::project::samples::SampleCatalogEntry {
|
||||
id: "known".into(),
|
||||
label: "Known Sample".into(),
|
||||
scene_path: PathBuf::from("assets/levels/samples/known.scn.ron"),
|
||||
project_relative_scene: "assets/levels/samples/known.scn.ron".into(),
|
||||
summary: "Known fixture".into(),
|
||||
checks: vec!["opens".into()],
|
||||
};
|
||||
let mut world = World::new();
|
||||
world.init_resource::<SceneIo>();
|
||||
world.insert_resource(SampleCatalog::available_entries(vec![known]));
|
||||
let original_tab_id = world.resource::<SceneIo>().tabs[0].id;
|
||||
|
||||
let status = open_sample(&mut world, "missing");
|
||||
|
||||
assert_eq!(status, "Open sample failed: unknown sample ID `missing`");
|
||||
let io = world.resource::<SceneIo>();
|
||||
assert_eq!(io.tabs.len(), 1);
|
||||
assert_eq!(io.tabs[0].id, original_tab_id);
|
||||
assert_eq!(io.active_path, None);
|
||||
assert!(!io.dirty);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn in_project_absolute_and_relative_scene_paths_share_one_canonical_key() {
|
||||
let root = std::env::temp_dir().join(format!(
|
||||
"blacksite-scene-path-identity-{}",
|
||||
uuid::Uuid::new_v4()
|
||||
));
|
||||
let scene = root.join("assets/levels/samples/alias.scn.ron");
|
||||
std::fs::create_dir_all(scene.parent().unwrap()).unwrap();
|
||||
std::fs::write(&scene, "(schema_version: 4, resources: {}, entities: {})").unwrap();
|
||||
let root = root.canonicalize().unwrap();
|
||||
|
||||
let expected = scene.canonicalize().unwrap();
|
||||
assert_eq!(scene_path_identity(&root, &scene), expected);
|
||||
assert_eq!(
|
||||
scene_path_identity(&root, Path::new("assets/levels/./samples/alias.scn.ron")),
|
||||
expected
|
||||
);
|
||||
|
||||
std::fs::remove_dir_all(root).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn relative_and_absolute_scene_aliases_do_not_create_a_second_tab() {
|
||||
let root = std::env::temp_dir().join(format!(
|
||||
"blacksite-scene-tab-alias-{}",
|
||||
uuid::Uuid::new_v4()
|
||||
));
|
||||
let relative = PathBuf::from("assets/levels/samples/alias.scn.ron");
|
||||
let absolute = root.join(&relative);
|
||||
std::fs::create_dir_all(absolute.parent().unwrap()).unwrap();
|
||||
std::fs::write(
|
||||
&absolute,
|
||||
"(schema_version: 4, resources: {}, entities: {})",
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let mut world = World::new();
|
||||
world.init_resource::<SceneIo>();
|
||||
world.insert_resource(crate::project_io::ProjectWorkspace {
|
||||
root: root.display().to_string(),
|
||||
..Default::default()
|
||||
});
|
||||
{
|
||||
let mut io = world.resource_mut::<SceneIo>();
|
||||
io.active_path = Some(relative.clone());
|
||||
io.tabs[0].path = Some(relative.clone());
|
||||
io.recent_paths = vec![absolute.clone(), relative.clone()];
|
||||
}
|
||||
|
||||
let status = open_path(&mut world, absolute.clone());
|
||||
|
||||
assert_eq!(status, "Scene tab is already active");
|
||||
let io = world.resource::<SceneIo>();
|
||||
assert_eq!(io.tabs.len(), 1);
|
||||
assert_eq!(io.tabs[0].path.as_ref(), Some(&relative));
|
||||
assert_eq!(io.active_path.as_ref(), Some(&relative));
|
||||
assert_eq!(io.recent_paths, vec![relative.clone()]);
|
||||
let mut preferences = crate::project_io::UserPreferences {
|
||||
recent_levels: vec![
|
||||
absolute.display().to_string(),
|
||||
relative.display().to_string(),
|
||||
],
|
||||
..Default::default()
|
||||
};
|
||||
remember_persisted_scene_path(&mut preferences, &root, &relative);
|
||||
assert_eq!(
|
||||
preferences.recent_levels,
|
||||
vec![relative.display().to_string()]
|
||||
);
|
||||
|
||||
let mut world = World::new();
|
||||
world.init_resource::<SceneIo>();
|
||||
world.insert_resource(crate::project_io::ProjectWorkspace {
|
||||
root: root.display().to_string(),
|
||||
..Default::default()
|
||||
});
|
||||
{
|
||||
let mut io = world.resource_mut::<SceneIo>();
|
||||
io.active_path = Some(absolute.clone());
|
||||
io.tabs[0].path = Some(absolute.clone());
|
||||
}
|
||||
|
||||
let status = open_path(&mut world, relative.clone());
|
||||
|
||||
assert_eq!(status, "Scene tab is already active");
|
||||
let io = world.resource::<SceneIo>();
|
||||
assert_eq!(io.tabs.len(), 1);
|
||||
assert_eq!(io.tabs[0].path.as_ref(), Some(&absolute));
|
||||
assert_eq!(io.active_path.as_ref(), Some(&absolute));
|
||||
let mut preferences = crate::project_io::UserPreferences {
|
||||
recent_levels: vec![
|
||||
relative.display().to_string(),
|
||||
absolute.display().to_string(),
|
||||
],
|
||||
..Default::default()
|
||||
};
|
||||
remember_persisted_scene_path(&mut preferences, &root, &absolute);
|
||||
assert_eq!(
|
||||
preferences.recent_levels,
|
||||
vec![absolute.display().to_string()]
|
||||
);
|
||||
std::fs::remove_dir_all(root).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn alias_open_preserves_recovery_generation_and_camera_bookmark_keys() {
|
||||
let root = std::env::temp_dir().join(format!(
|
||||
"blacksite-scene-alias-state-{}",
|
||||
uuid::Uuid::new_v4()
|
||||
));
|
||||
std::fs::create_dir_all(&root).unwrap();
|
||||
let root = root.canonicalize().unwrap();
|
||||
let relative = PathBuf::from("assets/levels/samples/stateful.scn.ron");
|
||||
let absolute = root.join(&relative);
|
||||
std::fs::create_dir_all(absolute.parent().unwrap()).unwrap();
|
||||
std::fs::write(
|
||||
&absolute,
|
||||
"(schema_version: 4, resources: {}, entities: {})",
|
||||
)
|
||||
.unwrap();
|
||||
let state_root = root.join("editor-state");
|
||||
let first_recovery =
|
||||
write_recovery_snapshot(&state_root, &root, &absolute, b"first", 5).unwrap();
|
||||
let bookmark = Transform::from_xyz(7.0, 11.0, 13.0);
|
||||
let bookmark_key = absolute.display().to_string();
|
||||
let mut bookmarks = crate::viewport::CameraBookmarks::default();
|
||||
crate::viewport::save_camera_bookmark(&mut bookmarks, &bookmark_key, bookmark);
|
||||
|
||||
let mut world = World::new();
|
||||
world.init_resource::<SceneIo>();
|
||||
world.insert_resource(crate::project_io::ProjectWorkspace {
|
||||
root: root.display().to_string(),
|
||||
..Default::default()
|
||||
});
|
||||
world.insert_resource(bookmarks);
|
||||
{
|
||||
let mut io = world.resource_mut::<SceneIo>();
|
||||
io.active_path = Some(absolute.clone());
|
||||
io.recovery_snapshot = Some(first_recovery.clone());
|
||||
io.tabs[0].path = Some(absolute.clone());
|
||||
io.tabs[0].recovery_snapshot = Some(first_recovery.clone());
|
||||
}
|
||||
|
||||
let status = open_path(&mut world, relative);
|
||||
|
||||
assert_eq!(status, "Scene tab is already active");
|
||||
let active_path = world
|
||||
.resource::<SceneIo>()
|
||||
.active_path
|
||||
.clone()
|
||||
.expect("active path must remain established");
|
||||
assert_eq!(active_path, absolute);
|
||||
assert_eq!(
|
||||
world.resource::<SceneIo>().recovery_snapshot.as_ref(),
|
||||
Some(&first_recovery)
|
||||
);
|
||||
let second_recovery =
|
||||
write_recovery_snapshot(&state_root, &root, &active_path, b"second", 5).unwrap();
|
||||
assert_eq!(first_recovery.parent(), second_recovery.parent());
|
||||
let active_key = active_path.display().to_string();
|
||||
assert_eq!(
|
||||
crate::viewport::recall_camera_bookmark(
|
||||
world.resource::<crate::viewport::CameraBookmarks>(),
|
||||
&active_key,
|
||||
),
|
||||
Some(bookmark)
|
||||
);
|
||||
|
||||
std::fs::remove_dir_all(root).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn outside_project_scene_keeps_its_absolute_identity() {
|
||||
let root = std::env::temp_dir().join(format!(
|
||||
"blacksite-scene-path-root-{}",
|
||||
uuid::Uuid::new_v4()
|
||||
));
|
||||
let outside = std::env::temp_dir().join(format!(
|
||||
"blacksite-outside-scene-{}.scn.ron",
|
||||
uuid::Uuid::new_v4()
|
||||
));
|
||||
std::fs::create_dir_all(&root).unwrap();
|
||||
std::fs::write(&outside, "(schema_version: 4, resources: {}, entities: {})").unwrap();
|
||||
let root = root.canonicalize().unwrap();
|
||||
let outside = outside.canonicalize().unwrap();
|
||||
|
||||
assert_eq!(scene_path_identity(&root, &outside), outside);
|
||||
|
||||
std::fs::remove_file(outside).unwrap();
|
||||
std::fs::remove_dir_all(root).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn every_manifest_sample_typed_deserializes_without_a_gpu() {
|
||||
let project_root = PathBuf::from(env!("CARGO_MANIFEST_DIR"))
|
||||
.join("../..")
|
||||
.canonicalize()
|
||||
.unwrap();
|
||||
let manifest = scene::sample_pack::load_editor_sample_manifest(&project_root).unwrap();
|
||||
assert!(!manifest.samples.is_empty());
|
||||
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);
|
||||
|
||||
for sample in manifest.samples {
|
||||
let path = project_root.join(&sample.scene);
|
||||
let text = std::fs::read_to_string(&path)
|
||||
.unwrap_or_else(|error| panic!("could not read sample `{}`: {error}", sample.id));
|
||||
let document = SceneDocument::from_ron_text(&text).unwrap_or_else(|error| {
|
||||
panic!(
|
||||
"sample `{}` is not a valid scene document: {error}",
|
||||
sample.id
|
||||
)
|
||||
});
|
||||
let bevy_ron = strip_schema_version(document.normalized_ron()).unwrap();
|
||||
deserialize_dynamic_scene(app.world_mut(), &bevy_ron).unwrap_or_else(|error| {
|
||||
panic!(
|
||||
"sample `{}` failed typed deserialization: {error}",
|
||||
sample.id
|
||||
)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn scene_io_event_log_is_bounded_and_classifies_failures() {
|
||||
let mut io = SceneIo::default();
|
||||
|
||||
@@ -11,7 +11,10 @@ use sim::Player;
|
||||
use crate::assets::{snapshot_for_asset, EditorAsset, EditorAssetKind};
|
||||
use crate::camera::EditorCamera;
|
||||
use crate::gizmos::{EditorGizmoMode, EditorGizmoSpace};
|
||||
use crate::history::{set_material_group_with_history, spawn_with_history, EditorEntitySnapshot};
|
||||
use crate::history::{
|
||||
set_light_group_with_history, set_material_group_with_history, spawn_with_history,
|
||||
EditorEntitySnapshot,
|
||||
};
|
||||
use crate::play::default_player_spawn;
|
||||
use crate::scene_io::SceneIo;
|
||||
use crate::viewport::{recall_camera_bookmark, save_camera_bookmark, CameraBookmarks};
|
||||
@@ -191,37 +194,23 @@ pub fn ensure_player_spawn_for_edit(world: &mut World) -> Entity {
|
||||
|
||||
/// Removes all authored [`LightDesc`] so project sun/ambient drive outdoor lighting.
|
||||
pub fn reset_scene_lighting_to_project_defaults(world: &mut World) {
|
||||
let mut query = world.query_filtered::<Entity, With<LevelObject>>();
|
||||
let with_lights: Vec<Entity> = query
|
||||
let mut query = world.query_filtered::<(Entity, &LightDesc), With<LevelObject>>();
|
||||
let changes = query
|
||||
.iter(world)
|
||||
.filter(|entity| world.get::<LightDesc>(*entity).is_some())
|
||||
.collect();
|
||||
for entity in with_lights {
|
||||
if let Ok(mut entity_mut) = world.get_entity_mut(entity) {
|
||||
entity_mut.remove::<LightDesc>();
|
||||
}
|
||||
}
|
||||
world
|
||||
.resource_mut::<crate::scene_io::SceneIo>()
|
||||
.mark_dirty();
|
||||
.map(|(entity, _)| (entity, None))
|
||||
.collect::<Vec<_>>();
|
||||
set_light_group_with_history(world, changes, "Reset Scene Lighting");
|
||||
}
|
||||
|
||||
/// Removes authored directional lights so [`ProjectSun`] drives outdoor lighting.
|
||||
pub fn use_project_sun(world: &mut World) {
|
||||
let mut query = world.query_filtered::<(Entity, &LightDesc), With<LevelObject>>();
|
||||
let directionals: Vec<Entity> = query
|
||||
let changes = query
|
||||
.iter(world)
|
||||
.filter(|(_, light)| matches!(light.kind, AuthoringLightKind::Directional))
|
||||
.map(|(e, _)| e)
|
||||
.collect();
|
||||
for entity in directionals {
|
||||
if let Ok(mut entity_mut) = world.get_entity_mut(entity) {
|
||||
entity_mut.remove::<LightDesc>();
|
||||
}
|
||||
}
|
||||
world
|
||||
.resource_mut::<crate::scene_io::SceneIo>()
|
||||
.mark_dirty();
|
||||
.map(|(entity, _)| (entity, None))
|
||||
.collect::<Vec<_>>();
|
||||
set_light_group_with_history(world, changes, "Use Project Sun");
|
||||
}
|
||||
|
||||
pub fn create_scene_sun_override_from_project_settings(world: &mut World) -> Entity {
|
||||
|
||||
@@ -6,6 +6,7 @@ use bevy_inspector_egui::bevy_inspector::hierarchy::SelectedEntities;
|
||||
use egui_dock::DockState;
|
||||
|
||||
use crate::history::{apply_command_redo, apply_command_undo, EditorHistory};
|
||||
use crate::project::samples::{SampleCatalog, SampleCatalogEntry};
|
||||
use crate::scene_io::{SceneIo, SceneIoRequest};
|
||||
use crate::settings_ui::{open_project_settings_panel, ProjectSettingsPanel};
|
||||
use crate::state::{EditorMode, PlayPaused};
|
||||
@@ -19,6 +20,19 @@ use super::layout::reset_and_save_layout;
|
||||
use super::widgets::menu_item;
|
||||
use super::EditorTab;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
enum SampleMenuModel {
|
||||
Available(Vec<SampleCatalogEntry>),
|
||||
Unavailable(String),
|
||||
}
|
||||
|
||||
fn sample_menu_model(catalog: &SampleCatalog) -> SampleMenuModel {
|
||||
match catalog.unavailable_reason() {
|
||||
Some(reason) => SampleMenuModel::Unavailable(reason.to_string()),
|
||||
None => SampleMenuModel::Available(catalog.entries().to_vec()),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn top_menu_bar(
|
||||
world: &mut World,
|
||||
root_ui: &mut egui::Ui,
|
||||
@@ -37,6 +51,25 @@ pub fn top_menu_bar(
|
||||
world.resource_mut::<SceneIo>().request = Some(SceneIoRequest::Open);
|
||||
ui.close();
|
||||
}
|
||||
let sample_menu = sample_menu_model(world.resource::<SampleCatalog>());
|
||||
ui.menu_button("Open Sample", |ui| match sample_menu {
|
||||
SampleMenuModel::Available(entries) => {
|
||||
for entry in entries {
|
||||
if menu_item(ui, &entry.label, None, true)
|
||||
.on_hover_text(entry.hover_text())
|
||||
.clicked()
|
||||
{
|
||||
world.resource_mut::<SceneIo>().request =
|
||||
Some(SceneIoRequest::OpenSample(entry.id));
|
||||
ui.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
SampleMenuModel::Unavailable(reason) => {
|
||||
menu_item(ui, "Sample pack unavailable", None, false)
|
||||
.on_disabled_hover_text(reason);
|
||||
}
|
||||
});
|
||||
if menu_item(ui, "Save", Some("Ctrl+S"), true).clicked() {
|
||||
world.resource_mut::<SceneIo>().request = Some(SceneIoRequest::Save);
|
||||
ui.close();
|
||||
@@ -287,3 +320,50 @@ pub fn top_menu_bar(
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::path::PathBuf;
|
||||
|
||||
use super::*;
|
||||
|
||||
fn entry(id: &str, label: &str) -> SampleCatalogEntry {
|
||||
SampleCatalogEntry {
|
||||
id: id.into(),
|
||||
label: label.into(),
|
||||
scene_path: PathBuf::from(format!("assets/levels/samples/{id}.scn.ron")),
|
||||
project_relative_scene: format!("assets/levels/samples/{id}.scn.ron"),
|
||||
summary: format!("{label} summary"),
|
||||
checks: vec![format!("{label} check")],
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn sample_menu_preserves_catalog_order_and_hover_details() {
|
||||
let catalog = SampleCatalog::available_entries(vec![
|
||||
entry("material", "Material Lab"),
|
||||
entry("terrain", "Terrain Sculpt"),
|
||||
]);
|
||||
|
||||
let SampleMenuModel::Available(rows) = sample_menu_model(&catalog) else {
|
||||
panic!("valid catalog must produce actionable menu rows");
|
||||
};
|
||||
|
||||
assert_eq!(
|
||||
rows.iter().map(|row| row.id.as_str()).collect::<Vec<_>>(),
|
||||
vec!["material", "terrain"]
|
||||
);
|
||||
assert!(rows[0].hover_text().contains("Material Lab summary"));
|
||||
assert!(rows[0].hover_text().contains("Material Lab check"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unavailable_catalog_produces_one_disabled_explanation() {
|
||||
let catalog = SampleCatalog::default();
|
||||
|
||||
assert_eq!(
|
||||
sample_menu_model(&catalog),
|
||||
SampleMenuModel::Unavailable("Sample catalog is loading".into())
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@ use bevy::math::Affine3A;
|
||||
use bevy::prelude::*;
|
||||
use shared::{
|
||||
brush_math::{validate_brush, BrushDiagnosticSeverity},
|
||||
BrushDesc, LevelObject,
|
||||
BrushDesc,
|
||||
};
|
||||
|
||||
use crate::history::apply_brush_csg_with_history;
|
||||
@@ -64,24 +64,27 @@ pub fn selected_brush_count(world: &World) -> usize {
|
||||
.resource::<UiState>()
|
||||
.selected_entities
|
||||
.iter()
|
||||
.filter(|entity| world.get::<BrushDesc>(*entity).is_some())
|
||||
.filter(|entity| {
|
||||
world.get::<BrushDesc>(*entity).is_some()
|
||||
&& crate::ui::selection_ops::is_mutable_level_object(world, *entity)
|
||||
})
|
||||
.count()
|
||||
}
|
||||
|
||||
pub fn intersect_selected_brushes(world: &mut World) {
|
||||
run_bounds_csg(world, BrushCsgOp::Intersect);
|
||||
pub fn intersect_selected_brushes(world: &mut World) -> Result<(), String> {
|
||||
run_bounds_csg(world, BrushCsgOp::Intersect)
|
||||
}
|
||||
|
||||
pub fn merge_selected_brushes(world: &mut World) {
|
||||
run_bounds_csg(world, BrushCsgOp::Merge);
|
||||
pub fn merge_selected_brushes(world: &mut World) -> Result<(), String> {
|
||||
run_bounds_csg(world, BrushCsgOp::Merge)
|
||||
}
|
||||
|
||||
pub fn subtract_selected_brushes(world: &mut World) {
|
||||
run_bounds_csg(world, BrushCsgOp::Subtract);
|
||||
pub fn subtract_selected_brushes(world: &mut World) -> Result<(), String> {
|
||||
run_bounds_csg(world, BrushCsgOp::Subtract)
|
||||
}
|
||||
|
||||
#[derive(Resource, Default, Debug, Clone)]
|
||||
struct BrushCsgPreview {
|
||||
pub(crate) struct BrushCsgPreview {
|
||||
pending: Option<PendingBrushCsg>,
|
||||
}
|
||||
|
||||
@@ -99,18 +102,18 @@ enum BrushCsgOp {
|
||||
Subtract,
|
||||
}
|
||||
|
||||
fn run_bounds_csg(world: &mut World, op: BrushCsgOp) {
|
||||
fn run_bounds_csg(world: &mut World, op: BrushCsgOp) -> Result<(), String> {
|
||||
let selected: Vec<Entity> = world
|
||||
.resource::<UiState>()
|
||||
.selected_entities
|
||||
.iter()
|
||||
.filter(|entity| {
|
||||
world.get::<LevelObject>(*entity).is_some() && world.get::<BrushDesc>(*entity).is_some()
|
||||
world.get::<BrushDesc>(*entity).is_some()
|
||||
&& crate::ui::selection_ops::is_mutable_level_object(world, *entity)
|
||||
})
|
||||
.collect();
|
||||
if selected.len() < 2 {
|
||||
set_status(world, "Select at least two brushes for CSG");
|
||||
return;
|
||||
return csg_failure(world, "Select at least two editable brushes for CSG");
|
||||
}
|
||||
for entity in &selected {
|
||||
let Some(brush) = world.get::<BrushDesc>(*entity) else {
|
||||
@@ -118,20 +121,18 @@ fn run_bounds_csg(world: &mut World, op: BrushCsgOp) {
|
||||
};
|
||||
let validation = validate_brush(brush);
|
||||
if !validation.is_valid() {
|
||||
set_status(
|
||||
return csg_failure(
|
||||
world,
|
||||
format!(
|
||||
"CSG failed: selected brush is invalid: {}",
|
||||
first_brush_error(&validation)
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
let Some(primary_bounds) = brush_world_bounds(world, selected[0]) else {
|
||||
set_status(world, "Primary brush has no valid bounds");
|
||||
return;
|
||||
return csg_failure(world, "Primary brush has no valid bounds");
|
||||
};
|
||||
|
||||
let result = match op {
|
||||
@@ -147,8 +148,7 @@ fn run_bounds_csg(world: &mut World, op: BrushCsgOp) {
|
||||
continue;
|
||||
};
|
||||
let Some(intersection) = result.intersection(bounds) else {
|
||||
set_status(world, "Brush intersect failed: no overlap");
|
||||
return;
|
||||
return csg_failure(world, "Brush intersect failed: no overlap");
|
||||
};
|
||||
result = intersection;
|
||||
}
|
||||
@@ -156,16 +156,13 @@ fn run_bounds_csg(world: &mut World, op: BrushCsgOp) {
|
||||
}
|
||||
BrushCsgOp::Subtract => {
|
||||
let Some(cutter_bounds) = brush_world_bounds(world, selected[1]) else {
|
||||
set_status(world, "Subtract failed: cutter brush has no valid bounds");
|
||||
return;
|
||||
return csg_failure(world, "Subtract failed: cutter brush has no valid bounds");
|
||||
};
|
||||
let Some(overlap) = primary_bounds.intersection(cutter_bounds) else {
|
||||
set_status(world, "Subtract failed: brushes do not overlap");
|
||||
return;
|
||||
return csg_failure(world, "Subtract failed: brushes do not overlap");
|
||||
};
|
||||
let Some(result) = largest_remaining_slab(primary_bounds, overlap) else {
|
||||
set_status(world, "Subtract failed: result would be empty");
|
||||
return;
|
||||
return csg_failure(world, "Subtract failed: result would be empty");
|
||||
};
|
||||
result
|
||||
}
|
||||
@@ -175,14 +172,13 @@ fn run_bounds_csg(world: &mut World, op: BrushCsgOp) {
|
||||
let new_brush = BrushDesc::cuboid(size);
|
||||
let validation = validate_brush(&new_brush);
|
||||
if !validation.is_valid() {
|
||||
set_status(
|
||||
return csg_failure(
|
||||
world,
|
||||
format!(
|
||||
"CSG failed: result is invalid: {}",
|
||||
first_brush_error(&validation)
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
world.resource_mut::<BrushCsgPreview>().pending = Some(PendingBrushCsg {
|
||||
@@ -197,6 +193,13 @@ fn run_bounds_csg(world: &mut World, op: BrushCsgOp) {
|
||||
};
|
||||
set_status(world, hint);
|
||||
set_csg_operator_status(world, OperatorPhase::Preview, hint);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn csg_failure(world: &mut World, message: impl Into<String>) -> Result<(), String> {
|
||||
let message = message.into();
|
||||
set_status(world, message.clone());
|
||||
Err(message)
|
||||
}
|
||||
|
||||
fn brush_csg_preview_input(world: &mut World) {
|
||||
@@ -253,6 +256,22 @@ fn commit_csg_preview(world: &mut World, pending: PendingBrushCsg) {
|
||||
);
|
||||
return;
|
||||
}
|
||||
if pending
|
||||
.selected
|
||||
.iter()
|
||||
.any(|entity| !crate::ui::selection_ops::is_mutable_level_object(world, *entity))
|
||||
{
|
||||
set_status(
|
||||
world,
|
||||
"Brush CSG commit blocked: selected content is no longer editable",
|
||||
);
|
||||
set_csg_operator_status(
|
||||
world,
|
||||
OperatorPhase::Blocked,
|
||||
"Commit blocked: selected content is no longer editable",
|
||||
);
|
||||
return;
|
||||
}
|
||||
let new_brush = BrushDesc::cuboid(pending.result.size());
|
||||
let to_delete: Vec<_> = if matches!(pending.op, BrushCsgOp::Merge | BrushCsgOp::Intersect) {
|
||||
pending
|
||||
@@ -265,7 +284,11 @@ fn commit_csg_preview(world: &mut World, pending: PendingBrushCsg) {
|
||||
} else {
|
||||
Vec::new()
|
||||
};
|
||||
apply_bounds_result(world, primary, pending.result, new_brush, &to_delete);
|
||||
if !apply_bounds_result(world, primary, pending.result, new_brush, &to_delete) {
|
||||
set_status(world, "Brush CSG commit made no changes");
|
||||
set_csg_operator_status(world, OperatorPhase::Canceled, "No changes");
|
||||
return;
|
||||
}
|
||||
let hint = match pending.op {
|
||||
BrushCsgOp::Intersect => "Brush intersect committed",
|
||||
BrushCsgOp::Merge => "Brush convex merge committed",
|
||||
@@ -332,14 +355,14 @@ fn apply_bounds_result(
|
||||
bounds: BrushBounds,
|
||||
new_brush: BrushDesc,
|
||||
delete_entities: &[Entity],
|
||||
) {
|
||||
) -> bool {
|
||||
let center = bounds.center();
|
||||
let old_transform = world.get::<Transform>(entity).copied().unwrap_or_default();
|
||||
let mut new_transform = old_transform;
|
||||
new_transform.translation = center;
|
||||
new_transform.rotation = Quat::IDENTITY;
|
||||
new_transform.scale = Vec3::ONE;
|
||||
apply_brush_csg_with_history(world, entity, new_transform, new_brush, delete_entities);
|
||||
apply_brush_csg_with_history(world, entity, new_transform, new_brush, delete_entities)
|
||||
}
|
||||
|
||||
fn brush_world_bounds(world: &World, entity: Entity) -> Option<BrushBounds> {
|
||||
@@ -426,6 +449,7 @@ mod tests {
|
||||
use crate::history::{EditorCommand, EditorHistory};
|
||||
use crate::operators::test_harness::{assert_undo_redo_round_trip, OperatorInvariantHarness};
|
||||
use crate::selection::SelectedEntity;
|
||||
use shared::LevelObject;
|
||||
|
||||
fn bounds(min: Vec3, max: Vec3) -> BrushBounds {
|
||||
BrushBounds { min, max }
|
||||
|
||||
@@ -1308,4 +1308,55 @@ mod tests {
|
||||
assert!(state.old_brush.is_none());
|
||||
assert!(!state.changed);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn brush_element_release_uses_production_finalizer_and_round_trips() {
|
||||
let mut app = App::new();
|
||||
app.init_resource::<ActiveOperator>()
|
||||
.init_resource::<EditorHistory>()
|
||||
.init_resource::<SceneIo>()
|
||||
.init_resource::<BrushEditMode>()
|
||||
.init_resource::<BrushElementSelection>()
|
||||
.init_resource::<BrushElementGizmoState>()
|
||||
.add_systems(Update, apply_brush_element_gizmo);
|
||||
let original = BrushDesc::cuboid(Vec3::ONE);
|
||||
let preview = BrushDesc::cuboid(Vec3::new(1.5, 1.0, 1.0));
|
||||
let brush_entity = app
|
||||
.world_mut()
|
||||
.spawn((LevelObject, preview.clone(), GlobalTransform::default()))
|
||||
.id();
|
||||
let helper = app
|
||||
.world_mut()
|
||||
.spawn((
|
||||
BrushElementGizmo,
|
||||
Transform::default(),
|
||||
GizmoTarget::default(),
|
||||
))
|
||||
.id();
|
||||
*app.world_mut().resource_mut::<BrushEditMode>() = BrushEditMode::Vertex;
|
||||
*app.world_mut().resource_mut::<BrushElementSelection>() = BrushElementSelection {
|
||||
brush: Some(brush_entity),
|
||||
elements: vec![BrushElementKey::Vertex {
|
||||
face: original.faces[0].id.clone(),
|
||||
index: 0,
|
||||
}],
|
||||
};
|
||||
*app.world_mut().resource_mut::<BrushElementGizmoState>() = BrushElementGizmoState {
|
||||
entity: Some(helper),
|
||||
brush: Some(brush_entity),
|
||||
old_brush: Some(original.clone()),
|
||||
old_gizmo: Some(Transform::default()),
|
||||
last_gizmo: Some(Transform::from_translation(Vec3::X * 0.25)),
|
||||
changed: true,
|
||||
};
|
||||
let harness = OperatorInvariantHarness::capture(app.world_mut());
|
||||
|
||||
app.update();
|
||||
|
||||
harness.assert_committed(app.world_mut(), 1, 0);
|
||||
harness.assert_status(app.world(), "brush.edit_mode", OperatorPhase::Committed);
|
||||
assert_undo_redo_round_trip(app.world_mut(), original, preview, |world| {
|
||||
world.get::<BrushDesc>(brush_entity).unwrap().clone()
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -779,31 +779,17 @@ fn update_material_drop_session(world: &mut World) {
|
||||
.is_some_and(|buttons| buttons.just_pressed(MouseButton::Right));
|
||||
|
||||
if cancel_requested && (selection.is_some() || state.preview.is_some()) {
|
||||
restore_material_drop_preview(world, state.preview.take());
|
||||
cancel_material_drop_session(world, &mut state, true);
|
||||
clear_drag_and_viewport_click(world);
|
||||
state.feedback = None;
|
||||
state.captures_viewport_input = false;
|
||||
state.cancel_consumed = true;
|
||||
set_drop_operator_status(
|
||||
world,
|
||||
OperatorPhase::Canceled,
|
||||
"Surface assignment canceled",
|
||||
);
|
||||
world.insert_resource(state);
|
||||
return;
|
||||
}
|
||||
|
||||
let Some(selection) = selection else {
|
||||
let had_preview = state.preview.is_some();
|
||||
restore_material_drop_preview(world, state.preview.take());
|
||||
state.feedback = None;
|
||||
state.captures_viewport_input = false;
|
||||
if had_preview {
|
||||
set_drop_operator_status(
|
||||
world,
|
||||
OperatorPhase::Canceled,
|
||||
"Surface assignment canceled",
|
||||
);
|
||||
if state.preview.is_some() {
|
||||
cancel_material_drop_session(world, &mut state, false);
|
||||
} else {
|
||||
reset_material_drop_session(&mut state, false);
|
||||
}
|
||||
world.insert_resource(state);
|
||||
return;
|
||||
@@ -877,19 +863,44 @@ fn update_material_drop_session(world: &mut World) {
|
||||
);
|
||||
|
||||
if primary_released {
|
||||
let preview = state.preview.take();
|
||||
if let Some(preview) = preview.as_ref() {
|
||||
preview.snapshot.restore(world);
|
||||
}
|
||||
if let Some(preview) = preview {
|
||||
commit_material_drop_preview(world, preview);
|
||||
}
|
||||
commit_material_drop_session(world, &mut state);
|
||||
clear_drag_and_viewport_click(world);
|
||||
state.captures_viewport_input = false;
|
||||
}
|
||||
world.insert_resource(state);
|
||||
}
|
||||
|
||||
fn cancel_material_drop_session(
|
||||
world: &mut World,
|
||||
state: &mut MaterialDropState,
|
||||
cancel_consumed: bool,
|
||||
) {
|
||||
restore_material_drop_preview(world, state.preview.take());
|
||||
reset_material_drop_session(state, cancel_consumed);
|
||||
set_drop_operator_status(
|
||||
world,
|
||||
OperatorPhase::Canceled,
|
||||
"Surface assignment canceled",
|
||||
);
|
||||
}
|
||||
|
||||
fn commit_material_drop_session(world: &mut World, state: &mut MaterialDropState) -> bool {
|
||||
let Some(preview) = state.preview.take() else {
|
||||
reset_material_drop_session(state, false);
|
||||
return false;
|
||||
};
|
||||
preview.snapshot.restore(world);
|
||||
let committed = commit_material_drop_preview(world, preview);
|
||||
reset_material_drop_session(state, false);
|
||||
committed
|
||||
}
|
||||
|
||||
fn reset_material_drop_session(state: &mut MaterialDropState, cancel_consumed: bool) {
|
||||
state.resolved = None;
|
||||
state.feedback = None;
|
||||
state.captures_viewport_input = false;
|
||||
state.cancel_consumed = cancel_consumed;
|
||||
}
|
||||
|
||||
fn restore_material_drop_preview(world: &mut World, preview: Option<MaterialDropPreview>) {
|
||||
if let Some(preview) = preview {
|
||||
preview.snapshot.restore(world);
|
||||
@@ -1029,7 +1040,8 @@ fn draw_material_drop_target(
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::history::{apply_command_undo, EditorHistory};
|
||||
use crate::history::EditorHistory;
|
||||
use crate::operators::test_harness::{assert_undo_redo_round_trip, OperatorInvariantHarness};
|
||||
use shared::{ActorKind, RendererMaterialSet, RendererMaterialSlot, SharedTypesPlugin};
|
||||
|
||||
fn test_app() -> App {
|
||||
@@ -1098,6 +1110,7 @@ mod tests {
|
||||
hit_point: Vec3::ZERO,
|
||||
hit_normal: Vec3::Y,
|
||||
};
|
||||
let harness = OperatorInvariantHarness::capture(world);
|
||||
let preview = begin_material_drop_preview(
|
||||
world,
|
||||
AssetSelection::File("assets/materials/steel.ron".into()),
|
||||
@@ -1123,18 +1136,25 @@ mod tests {
|
||||
assert!(!world.resource::<SceneIo>().dirty);
|
||||
assert_eq!(world.resource::<EditorHistory>().undo_depth(), 0);
|
||||
|
||||
preview.snapshot.restore(world);
|
||||
assert!(world
|
||||
.get::<StaticMeshRenderer>(entity)
|
||||
.unwrap()
|
||||
.materials
|
||||
.slot(&slot_b)
|
||||
.unwrap()
|
||||
.material
|
||||
.is_none());
|
||||
assert!(commit_material_drop_preview(world, preview));
|
||||
assert_eq!(world.resource::<EditorHistory>().undo_depth(), 1);
|
||||
assert!(world.resource::<SceneIo>().dirty);
|
||||
let mut state = MaterialDropState {
|
||||
resolved: Some(target),
|
||||
preview: Some(preview),
|
||||
feedback: Some(MaterialDropFeedback {
|
||||
valid: true,
|
||||
action: "Assign material".into(),
|
||||
target: "Crate / B".into(),
|
||||
}),
|
||||
captures_viewport_input: true,
|
||||
cancel_consumed: false,
|
||||
};
|
||||
assert!(commit_material_drop_session(world, &mut state));
|
||||
harness.assert_committed(world, 1, 0);
|
||||
harness.assert_status(world, "assets.assign_surface", OperatorPhase::Committed);
|
||||
assert!(state.preview.is_none());
|
||||
assert!(state.resolved.is_none());
|
||||
assert!(state.feedback.is_none());
|
||||
assert!(!state.captures_viewport_input);
|
||||
assert!(!state.cancel_consumed);
|
||||
assert!(world
|
||||
.get::<StaticMeshRenderer>(entity)
|
||||
.unwrap()
|
||||
@@ -1143,16 +1163,17 @@ mod tests {
|
||||
.unwrap()
|
||||
.material
|
||||
.is_none());
|
||||
|
||||
apply_command_undo(world);
|
||||
assert!(world
|
||||
assert_undo_redo_round_trip(world, None, Some("steel".to_string()), |world| {
|
||||
world
|
||||
.get::<StaticMeshRenderer>(entity)
|
||||
.unwrap()
|
||||
.materials
|
||||
.slot(&slot_b)
|
||||
.unwrap()
|
||||
.material
|
||||
.is_none());
|
||||
.as_ref()
|
||||
.map(|material| material.0.asset_id.clone())
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -1172,6 +1193,7 @@ mod tests {
|
||||
hit_point: Vec3::ZERO,
|
||||
hit_normal: Vec3::Y,
|
||||
};
|
||||
let harness = OperatorInvariantHarness::capture(world);
|
||||
let preview = begin_material_drop_preview(
|
||||
world,
|
||||
AssetSelection::File("assets/materials/steel.ron".into()),
|
||||
@@ -1196,9 +1218,26 @@ mod tests {
|
||||
.material
|
||||
.is_none());
|
||||
|
||||
preview.snapshot.restore(world);
|
||||
let mut state = MaterialDropState {
|
||||
resolved: Some(target),
|
||||
preview: Some(preview),
|
||||
feedback: Some(MaterialDropFeedback {
|
||||
valid: true,
|
||||
action: "Assign material".into(),
|
||||
target: "Blockout / face".into(),
|
||||
}),
|
||||
captures_viewport_input: true,
|
||||
cancel_consumed: false,
|
||||
};
|
||||
cancel_material_drop_session(world, &mut state, true);
|
||||
harness.assert_canceled(world);
|
||||
harness.assert_status(world, "assets.assign_surface", OperatorPhase::Canceled);
|
||||
assert_eq!(world.get::<BrushDesc>(entity), Some(&brush));
|
||||
assert!(!world.resource::<SceneIo>().dirty);
|
||||
assert!(state.preview.is_none());
|
||||
assert!(state.resolved.is_none());
|
||||
assert!(state.feedback.is_none());
|
||||
assert!(!state.captures_viewport_input);
|
||||
assert!(state.cancel_consumed);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -6,7 +6,7 @@ use std::time::Duration;
|
||||
use avian3d::prelude::*;
|
||||
use bevy::prelude::*;
|
||||
|
||||
use crate::history::set_transform_group_with_history;
|
||||
use crate::history::{set_transform_group_with_history, EditorHistory};
|
||||
use crate::operators::{ActiveOperator, OperatorPhase, OperatorStatus};
|
||||
use crate::state::EditorMode;
|
||||
use crate::ui::selection_ops::{entity_name, is_mutable_level_object};
|
||||
@@ -256,6 +256,7 @@ fn finish_physics_placement(world: &mut World, commit: bool) {
|
||||
}
|
||||
}
|
||||
|
||||
let undo_depth = world.resource::<EditorHistory>().undo_depth();
|
||||
if commit {
|
||||
let changes = session.selected.iter().filter_map(|snapshot| {
|
||||
final_transforms
|
||||
@@ -265,6 +266,7 @@ fn finish_physics_placement(world: &mut World, commit: bool) {
|
||||
});
|
||||
set_transform_group_with_history(world, changes);
|
||||
}
|
||||
let committed = commit && world.resource::<EditorHistory>().undo_depth() > undo_depth;
|
||||
|
||||
state.phase = PhysicsPlacementPhase::Inactive;
|
||||
state.request = PhysicsPlacementRequest::None;
|
||||
@@ -272,7 +274,14 @@ fn finish_physics_placement(world: &mut World, commit: bool) {
|
||||
state.simulated_steps = 0;
|
||||
state.last_error = None;
|
||||
world.insert_resource(state);
|
||||
clear_operator_status(world);
|
||||
let (phase, hint) = if committed {
|
||||
(OperatorPhase::Committed, "Physics placement committed")
|
||||
} else if commit {
|
||||
(OperatorPhase::Canceled, "Physics placement made no changes")
|
||||
} else {
|
||||
(OperatorPhase::Canceled, "Physics placement canceled")
|
||||
};
|
||||
set_operator_status(world, phase, hint.to_string(), Vec::new());
|
||||
}
|
||||
|
||||
fn tick_physics_placement(world: &mut World) {
|
||||
@@ -437,22 +446,12 @@ fn set_operator_status(
|
||||
}
|
||||
}
|
||||
|
||||
fn clear_operator_status(world: &mut World) {
|
||||
if let Some(mut operator) = world.get_resource_mut::<ActiveOperator>() {
|
||||
if operator
|
||||
.status
|
||||
.as_ref()
|
||||
.is_some_and(|status| status.id == "physics.placement")
|
||||
{
|
||||
operator.status = None;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::history::{apply_command_undo, EditorHistory};
|
||||
use crate::history::EditorHistory;
|
||||
use crate::operators::test_harness::{assert_undo_redo_round_trip, OperatorInvariantHarness};
|
||||
use crate::scene_io::SceneIo;
|
||||
use bevy::asset::{AssetApp, AssetPlugin};
|
||||
use bevy::state::app::StatesPlugin;
|
||||
use shared::{ColliderDesc, LevelObject, RigidBodyDesc};
|
||||
@@ -469,7 +468,9 @@ mod tests {
|
||||
.init_asset::<Mesh>()
|
||||
.init_state::<EditorMode>()
|
||||
.init_resource::<PhysicsPlacementState>()
|
||||
.init_resource::<EditorHistory>();
|
||||
.init_resource::<EditorHistory>()
|
||||
.init_resource::<ActiveOperator>()
|
||||
.init_resource::<SceneIo>();
|
||||
app.finish();
|
||||
app.cleanup();
|
||||
app.update();
|
||||
@@ -498,12 +499,16 @@ mod tests {
|
||||
.world_mut()
|
||||
.spawn((Name::new("No Physics"), LevelObject, Transform::default()))
|
||||
.id();
|
||||
let harness = OperatorInvariantHarness::capture(app.world_mut());
|
||||
|
||||
let error = begin_physics_placement(app.world_mut(), [entity]).unwrap_err();
|
||||
|
||||
assert!(error.contains("add and enable a Rigid Body"));
|
||||
assert!(error.contains("add and enable a non-trigger Collider"));
|
||||
assert!(!app.world().resource::<PhysicsPlacementState>().active());
|
||||
harness.assert_blocked(app.world_mut());
|
||||
harness.assert_status(app.world(), "physics.placement", OperatorPhase::Blocked);
|
||||
harness.assert_no_helpers::<PhysicsPlacementPreview>(app.world_mut());
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -531,6 +536,7 @@ mod tests {
|
||||
))
|
||||
.id();
|
||||
app.update();
|
||||
let harness = OperatorInvariantHarness::capture(app.world_mut());
|
||||
|
||||
begin_physics_placement(app.world_mut(), [selected]).unwrap();
|
||||
assert_eq!(
|
||||
@@ -581,6 +587,9 @@ mod tests {
|
||||
Some(&LinearVelocity(Vec3::X * 3.0))
|
||||
);
|
||||
assert_eq!(app.world().resource::<EditorHistory>().undo_depth(), 0);
|
||||
harness.assert_canceled(app.world_mut());
|
||||
harness.assert_status(app.world(), "physics.placement", OperatorPhase::Canceled);
|
||||
harness.assert_no_helpers::<PhysicsPlacementPreview>(app.world_mut());
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -594,6 +603,7 @@ mod tests {
|
||||
let start = Transform::from_xyz(0.0, 4.0, 0.0);
|
||||
let prop = spawn_placeable(app.world_mut(), "Drop Prop", start);
|
||||
app.update();
|
||||
let harness = OperatorInvariantHarness::capture(app.world_mut());
|
||||
|
||||
begin_physics_placement(app.world_mut(), [prop]).unwrap();
|
||||
for _ in 0..400 {
|
||||
@@ -613,15 +623,75 @@ mod tests {
|
||||
|
||||
commit_physics_placement(app.world_mut());
|
||||
|
||||
assert_eq!(app.world().resource::<EditorHistory>().undo_depth(), 1);
|
||||
harness.assert_committed(app.world_mut(), 1, 0);
|
||||
harness.assert_status(app.world(), "physics.placement", OperatorPhase::Committed);
|
||||
harness.assert_no_helpers::<PhysicsPlacementPreview>(app.world_mut());
|
||||
assert_eq!(
|
||||
app.world().resource::<EditorHistory>().status,
|
||||
"Undo: Move Selection"
|
||||
);
|
||||
assert_eq!(app.world().get::<RigidBody>(prop), Some(&RigidBody::Static));
|
||||
assert_eq!(*app.world().get::<Transform>(prop).unwrap(), settled);
|
||||
assert_undo_redo_round_trip(app.world_mut(), start, settled, |world| {
|
||||
*world.get::<Transform>(prop).unwrap()
|
||||
});
|
||||
}
|
||||
|
||||
apply_command_undo(app.world_mut());
|
||||
#[test]
|
||||
fn no_op_commit_terminates_without_dirtying_or_history() {
|
||||
let mut app = app_with_physics();
|
||||
let start = Transform::from_xyz(0.0, 4.0, 0.0);
|
||||
let prop = spawn_placeable(app.world_mut(), "Static Prop", start);
|
||||
app.update();
|
||||
let harness = OperatorInvariantHarness::capture(app.world_mut());
|
||||
|
||||
begin_physics_placement(app.world_mut(), [prop]).unwrap();
|
||||
commit_physics_placement(app.world_mut());
|
||||
|
||||
harness.assert_canceled(app.world_mut());
|
||||
harness.assert_status(app.world(), "physics.placement", OperatorPhase::Canceled);
|
||||
harness.assert_no_helpers::<PhysicsPlacementPreview>(app.world_mut());
|
||||
assert_eq!(*app.world().get::<Transform>(prop).unwrap(), start);
|
||||
assert_eq!(app.world().get::<RigidBody>(prop), Some(&RigidBody::Static));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn multi_select_commit_is_one_transaction_and_cleans_every_preview_helper() {
|
||||
let mut app = app_with_physics();
|
||||
let starts = [
|
||||
Transform::from_xyz(-1.0, 4.0, 0.0),
|
||||
Transform::from_xyz(1.0, 6.0, 0.0),
|
||||
];
|
||||
let first = spawn_placeable(app.world_mut(), "First", starts[0]);
|
||||
let second = spawn_placeable(app.world_mut(), "Second", starts[1]);
|
||||
app.update();
|
||||
let harness = OperatorInvariantHarness::capture(app.world_mut());
|
||||
|
||||
begin_physics_placement(app.world_mut(), [first, second, first]).unwrap();
|
||||
assert_eq!(
|
||||
app.world()
|
||||
.resource::<PhysicsPlacementState>()
|
||||
.selected_count,
|
||||
2,
|
||||
"duplicate selections must collapse to one placement snapshot"
|
||||
);
|
||||
let committed = [
|
||||
Transform::from_xyz(-1.0, 0.5, 0.0),
|
||||
Transform::from_xyz(1.0, 0.5, 0.0),
|
||||
];
|
||||
app.world_mut().entity_mut(first).insert(committed[0]);
|
||||
app.world_mut().entity_mut(second).insert(committed[1]);
|
||||
|
||||
commit_physics_placement(app.world_mut());
|
||||
|
||||
harness.assert_committed(app.world_mut(), 1, 0);
|
||||
harness.assert_status(app.world(), "physics.placement", OperatorPhase::Committed);
|
||||
harness.assert_no_helpers::<PhysicsPlacementPreview>(app.world_mut());
|
||||
assert_undo_redo_round_trip(app.world_mut(), starts, committed, |world| {
|
||||
[
|
||||
*world.get::<Transform>(first).unwrap(),
|
||||
*world.get::<Transform>(second).unwrap(),
|
||||
]
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ use shared::{TerrainDesc, AUTHORING_COMPONENT_TERRAIN, COMPONENT_TERRAIN_DESC};
|
||||
|
||||
use super::terrain_sculpt::{active_scene_ray, smooth_falloff, terrain_ray_hit, TerrainHit};
|
||||
use crate::camera::EditorCamera;
|
||||
use crate::history::reflected_component_transaction;
|
||||
use crate::history::{reflected_component_transaction, EditorHistory};
|
||||
use crate::operators::{ActiveOperator, OperatorPhase, OperatorStatus};
|
||||
use crate::scene_io::SceneIo;
|
||||
use crate::selection::{SelectedEntity, ViewportClick};
|
||||
@@ -125,16 +125,30 @@ fn terrain_paint_input(
|
||||
viewport_click.0 = None;
|
||||
state.clamp_settings();
|
||||
let Some(entity) = state.target.or(selected.0) else {
|
||||
cancel_stroke(&mut state, &mut terrains);
|
||||
state.stop();
|
||||
stop_tool_with_rollback(
|
||||
&mut state,
|
||||
&mut terrains,
|
||||
&mut scene_io,
|
||||
&mut active_operator,
|
||||
OperatorPhase::Blocked,
|
||||
"Terrain paint stopped: target is unavailable",
|
||||
"Target unavailable",
|
||||
);
|
||||
return Ok(());
|
||||
};
|
||||
if selected.0 != Some(entity) {
|
||||
selected.0 = Some(entity);
|
||||
}
|
||||
if display.clean_game_view {
|
||||
cancel_stroke(&mut state, &mut terrains);
|
||||
state.stop();
|
||||
stop_tool_with_rollback(
|
||||
&mut state,
|
||||
&mut terrains,
|
||||
&mut scene_io,
|
||||
&mut active_operator,
|
||||
OperatorPhase::Canceled,
|
||||
"Terrain paint stopped for clean game view",
|
||||
"Clean game view enabled; weights restored",
|
||||
);
|
||||
return Ok(());
|
||||
}
|
||||
let ctx = contexts.ctx_mut()?;
|
||||
@@ -142,12 +156,11 @@ fn terrain_paint_input(
|
||||
keys.just_pressed(KeyCode::Escape) || buttons.just_pressed(MouseButton::Right);
|
||||
if cancel_requested {
|
||||
if state.is_stroking() {
|
||||
cancel_stroke(&mut state, &mut terrains);
|
||||
scene_io.status = "Terrain paint stroke canceled".into();
|
||||
set_status(
|
||||
cancel_active_stroke(
|
||||
&mut state,
|
||||
&mut terrains,
|
||||
&mut scene_io,
|
||||
&mut active_operator,
|
||||
OperatorPhase::Canceled,
|
||||
"Weights restored",
|
||||
);
|
||||
} else {
|
||||
state.stop();
|
||||
@@ -157,14 +170,29 @@ fn terrain_paint_input(
|
||||
return Ok(());
|
||||
}
|
||||
let Ok((global, mut terrain)) = terrains.get_mut(entity) else {
|
||||
state.stroke = None;
|
||||
state.stop();
|
||||
stop_tool_with_rollback(
|
||||
&mut state,
|
||||
&mut terrains,
|
||||
&mut scene_io,
|
||||
&mut active_operator,
|
||||
OperatorPhase::Blocked,
|
||||
"Terrain paint stopped: target no longer exists",
|
||||
"Target no longer exists",
|
||||
);
|
||||
return Ok(());
|
||||
};
|
||||
let layer_count = terrain.material_layers.len();
|
||||
if layer_count == 0 {
|
||||
if let Some(stroke) = state.stroke.take() {
|
||||
*terrain = stroke.original;
|
||||
}
|
||||
state.stop();
|
||||
scene_io.status = "Add a terrain material layer before painting".into();
|
||||
set_status(
|
||||
&mut active_operator,
|
||||
OperatorPhase::Blocked,
|
||||
"Add a material layer before painting",
|
||||
);
|
||||
return Ok(());
|
||||
}
|
||||
state.active_layer = state.active_layer.min(layer_count - 1);
|
||||
@@ -227,17 +255,8 @@ fn terrain_paint_input(
|
||||
let final_terrain = terrain.clone();
|
||||
let mode = state.mode;
|
||||
commands.queue(move |world: &mut World| {
|
||||
if let Err(error) = commit_paint_stroke(world, stroke, final_terrain) {
|
||||
world.resource_mut::<SceneIo>().status =
|
||||
format!("Terrain paint commit failed: {error}");
|
||||
}
|
||||
finish_paint_stroke(world, stroke, final_terrain, mode);
|
||||
});
|
||||
scene_io.status = format!("{} terrain material weights committed", mode.label());
|
||||
set_status(
|
||||
&mut active_operator,
|
||||
OperatorPhase::Committed,
|
||||
format!("{} weights; Ctrl+Z to undo", mode.label()),
|
||||
);
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
@@ -248,10 +267,11 @@ fn commit_paint_stroke(
|
||||
stroke: TerrainPaintStroke,
|
||||
final_terrain: TerrainDesc,
|
||||
) -> Result<(), String> {
|
||||
let original = stroke.original;
|
||||
if let Ok(mut actor) = world.get_entity_mut(stroke.entity) {
|
||||
actor.insert(stroke.original);
|
||||
actor.insert(original.clone());
|
||||
}
|
||||
reflected_component_transaction(
|
||||
let result = reflected_component_transaction(
|
||||
world,
|
||||
stroke.entity,
|
||||
"Paint Terrain Material",
|
||||
@@ -261,7 +281,77 @@ fn commit_paint_stroke(
|
||||
world.entity_mut(entity).insert(final_terrain);
|
||||
Ok(())
|
||||
},
|
||||
)
|
||||
);
|
||||
if result.is_err() {
|
||||
if let Ok(mut actor) = world.get_entity_mut(stroke.entity) {
|
||||
actor.insert(original);
|
||||
}
|
||||
}
|
||||
result
|
||||
}
|
||||
|
||||
fn finish_paint_stroke(
|
||||
world: &mut World,
|
||||
stroke: TerrainPaintStroke,
|
||||
final_terrain: TerrainDesc,
|
||||
mode: TerrainPaintMode,
|
||||
) {
|
||||
let undo_depth = world.resource::<EditorHistory>().undo_depth();
|
||||
match commit_paint_stroke(world, stroke, final_terrain) {
|
||||
Ok(()) if world.resource::<EditorHistory>().undo_depth() > undo_depth => {
|
||||
world.resource_mut::<SceneIo>().status =
|
||||
format!("{} terrain material weights committed", mode.label());
|
||||
set_status(
|
||||
&mut world.resource_mut::<ActiveOperator>(),
|
||||
OperatorPhase::Committed,
|
||||
format!("{} weights; Ctrl+Z to undo", mode.label()),
|
||||
);
|
||||
}
|
||||
Ok(()) => {
|
||||
world.resource_mut::<SceneIo>().status =
|
||||
format!("{} terrain stroke made no changes", mode.label());
|
||||
set_status(
|
||||
&mut world.resource_mut::<ActiveOperator>(),
|
||||
OperatorPhase::Canceled,
|
||||
format!("{} stroke made no changes", mode.label()),
|
||||
);
|
||||
}
|
||||
Err(error) => {
|
||||
world.resource_mut::<SceneIo>().status =
|
||||
format!("Terrain paint commit failed: {error}");
|
||||
set_status(
|
||||
&mut world.resource_mut::<ActiveOperator>(),
|
||||
OperatorPhase::Blocked,
|
||||
format!("Commit failed: {error}"),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn cancel_active_stroke(
|
||||
state: &mut TerrainPaintState,
|
||||
terrains: &mut Query<(&GlobalTransform, &mut TerrainDesc)>,
|
||||
scene_io: &mut SceneIo,
|
||||
active_operator: &mut ActiveOperator,
|
||||
) {
|
||||
cancel_stroke(state, terrains);
|
||||
scene_io.status = "Terrain paint stroke canceled".into();
|
||||
set_status(active_operator, OperatorPhase::Canceled, "Weights restored");
|
||||
}
|
||||
|
||||
fn stop_tool_with_rollback(
|
||||
state: &mut TerrainPaintState,
|
||||
terrains: &mut Query<(&GlobalTransform, &mut TerrainDesc)>,
|
||||
scene_io: &mut SceneIo,
|
||||
active_operator: &mut ActiveOperator,
|
||||
phase: OperatorPhase,
|
||||
message: &str,
|
||||
hint: &str,
|
||||
) {
|
||||
cancel_stroke(state, terrains);
|
||||
state.stop();
|
||||
scene_io.status = message.to_string();
|
||||
set_status(active_operator, phase, hint);
|
||||
}
|
||||
|
||||
fn cancel_stroke(
|
||||
@@ -415,7 +505,8 @@ fn draw_terrain_paint_preview(state: Res<TerrainPaintState>, mut gizmos: Gizmos)
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::history::{apply_command_redo, apply_command_undo, EditorHistory};
|
||||
use crate::history::EditorHistory;
|
||||
use crate::operators::test_harness::{assert_undo_redo_round_trip, OperatorInvariantHarness};
|
||||
use shared::{ActorKind, LevelObject};
|
||||
|
||||
#[test]
|
||||
@@ -452,8 +543,10 @@ mod tests {
|
||||
.register_type::<shared::TerrainMaterialLayer>()
|
||||
.register_type::<shared::EditorAssetRef>();
|
||||
let world = app.world_mut();
|
||||
world.init_resource::<ActiveOperator>();
|
||||
world.init_resource::<EditorHistory>();
|
||||
world.init_resource::<SceneIo>();
|
||||
world.init_resource::<TerrainPaintState>();
|
||||
let mut original = TerrainDesc::flat(9);
|
||||
original.material_layers = vec![Default::default(), Default::default()];
|
||||
let entity = world
|
||||
@@ -471,23 +564,121 @@ mod tests {
|
||||
);
|
||||
}
|
||||
world.entity_mut(entity).insert(final_terrain.clone());
|
||||
commit_paint_stroke(
|
||||
let stroke = TerrainPaintStroke {
|
||||
entity,
|
||||
original: original.clone(),
|
||||
last_local: Vec3::ZERO,
|
||||
};
|
||||
{
|
||||
let mut state = world.resource_mut::<TerrainPaintState>();
|
||||
state.start(entity, 2);
|
||||
state.stroke = Some(stroke);
|
||||
}
|
||||
let stroke = world
|
||||
.resource_mut::<TerrainPaintState>()
|
||||
.stroke
|
||||
.take()
|
||||
.unwrap();
|
||||
let harness = OperatorInvariantHarness::capture(world);
|
||||
|
||||
finish_paint_stroke(
|
||||
world,
|
||||
stroke,
|
||||
final_terrain.clone(),
|
||||
TerrainPaintMode::Paint,
|
||||
);
|
||||
|
||||
harness.assert_committed(world, 1, 0);
|
||||
harness.assert_status(world, "terrain.paint", OperatorPhase::Committed);
|
||||
assert_eq!(world.get::<TerrainDesc>(entity), Some(&final_terrain));
|
||||
let state = world.resource::<TerrainPaintState>();
|
||||
assert!(state.active);
|
||||
assert_eq!(state.target, Some(entity));
|
||||
assert!(!state.is_stroking());
|
||||
assert_undo_redo_round_trip(world, original, final_terrain, |world| {
|
||||
world.get::<TerrainDesc>(entity).unwrap().clone()
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn no_op_paint_release_terminates_without_dirtying_or_history() {
|
||||
let mut app = App::new();
|
||||
app.register_type::<ActorKind>()
|
||||
.register_type::<TerrainDesc>()
|
||||
.register_type::<shared::TerrainMaterialLayer>()
|
||||
.register_type::<shared::EditorAssetRef>();
|
||||
let world = app.world_mut();
|
||||
world.init_resource::<ActiveOperator>();
|
||||
world.init_resource::<EditorHistory>();
|
||||
world.init_resource::<SceneIo>();
|
||||
let mut original = TerrainDesc::flat(5);
|
||||
original.material_layers = vec![Default::default(), Default::default()];
|
||||
original.ensure_material_weights();
|
||||
let entity = world
|
||||
.spawn((LevelObject, ActorKind::Terrain, original.clone()))
|
||||
.id();
|
||||
let harness = OperatorInvariantHarness::capture(world);
|
||||
|
||||
finish_paint_stroke(
|
||||
world,
|
||||
TerrainPaintStroke {
|
||||
entity,
|
||||
original: original.clone(),
|
||||
last_local: Vec3::ZERO,
|
||||
},
|
||||
final_terrain.clone(),
|
||||
)
|
||||
.unwrap();
|
||||
original.clone(),
|
||||
TerrainPaintMode::Erase,
|
||||
);
|
||||
|
||||
assert_eq!(world.resource::<EditorHistory>().undo_depth(), 1);
|
||||
assert_eq!(world.get::<TerrainDesc>(entity), Some(&final_terrain));
|
||||
apply_command_undo(world);
|
||||
harness.assert_canceled(world);
|
||||
harness.assert_status(world, "terrain.paint", OperatorPhase::Canceled);
|
||||
assert_eq!(world.get::<TerrainDesc>(entity), Some(&original));
|
||||
apply_command_redo(world);
|
||||
assert_eq!(world.get::<TerrainDesc>(entity), Some(&final_terrain));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn commit_failure_restores_preview_and_reports_blocked_without_history() {
|
||||
let mut app = App::new();
|
||||
let world = app.world_mut();
|
||||
world.init_resource::<ActiveOperator>();
|
||||
world.init_resource::<EditorHistory>();
|
||||
world.init_resource::<SceneIo>();
|
||||
let mut original = TerrainDesc::flat(5);
|
||||
original.material_layers = vec![Default::default(), Default::default()];
|
||||
let mut preview = original.clone();
|
||||
apply_weight_dab(
|
||||
&mut preview,
|
||||
Vec3::ZERO,
|
||||
3.0,
|
||||
0.8,
|
||||
1,
|
||||
TerrainPaintMode::Paint,
|
||||
);
|
||||
let entity = world
|
||||
.spawn((LevelObject, ActorKind::Terrain, preview.clone()))
|
||||
.id();
|
||||
let mut hierarchy = crate::ui::hierarchy_state::HierarchyPanelState::default();
|
||||
hierarchy.locked.insert(entity);
|
||||
world.insert_resource(hierarchy);
|
||||
let harness = OperatorInvariantHarness::capture(world);
|
||||
|
||||
finish_paint_stroke(
|
||||
world,
|
||||
TerrainPaintStroke {
|
||||
entity,
|
||||
original: original.clone(),
|
||||
last_local: Vec3::ZERO,
|
||||
},
|
||||
preview,
|
||||
TerrainPaintMode::Paint,
|
||||
);
|
||||
|
||||
harness.assert_blocked(world);
|
||||
harness.assert_status(world, "terrain.paint", OperatorPhase::Blocked);
|
||||
assert_eq!(world.get::<TerrainDesc>(entity), Some(&original));
|
||||
assert!(world
|
||||
.resource::<SceneIo>()
|
||||
.status
|
||||
.starts_with("Terrain paint commit failed:"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -495,11 +686,21 @@ mod tests {
|
||||
fn cancel_once(
|
||||
mut state: ResMut<TerrainPaintState>,
|
||||
mut terrains: Query<(&GlobalTransform, &mut TerrainDesc)>,
|
||||
mut scene_io: ResMut<SceneIo>,
|
||||
mut active_operator: ResMut<ActiveOperator>,
|
||||
) {
|
||||
cancel_stroke(&mut state, &mut terrains);
|
||||
cancel_active_stroke(
|
||||
&mut state,
|
||||
&mut terrains,
|
||||
&mut scene_io,
|
||||
&mut active_operator,
|
||||
);
|
||||
}
|
||||
|
||||
let mut app = App::new();
|
||||
app.init_resource::<ActiveOperator>()
|
||||
.init_resource::<EditorHistory>()
|
||||
.init_resource::<SceneIo>();
|
||||
let mut original = TerrainDesc::flat(5);
|
||||
original.material_layers = vec![Default::default(), Default::default()];
|
||||
let mut preview = original.clone();
|
||||
@@ -513,7 +714,7 @@ mod tests {
|
||||
);
|
||||
let entity = app
|
||||
.world_mut()
|
||||
.spawn((GlobalTransform::default(), preview))
|
||||
.spawn((LevelObject, GlobalTransform::default(), preview))
|
||||
.id();
|
||||
let mut state = TerrainPaintState::default();
|
||||
state.start(entity, 2);
|
||||
@@ -523,9 +724,72 @@ mod tests {
|
||||
last_local: Vec3::ZERO,
|
||||
});
|
||||
app.insert_resource(state).add_systems(Update, cancel_once);
|
||||
let harness = OperatorInvariantHarness::capture(app.world_mut());
|
||||
|
||||
app.update();
|
||||
harness.assert_canceled(app.world_mut());
|
||||
harness.assert_status(app.world(), "terrain.paint", OperatorPhase::Canceled);
|
||||
assert_eq!(app.world().get::<TerrainDesc>(entity), Some(&original));
|
||||
assert!(!app.world().resource::<TerrainPaintState>().is_stroking());
|
||||
let state = app.world().resource::<TerrainPaintState>();
|
||||
assert!(state.active);
|
||||
assert_eq!(state.target, Some(entity));
|
||||
assert!(!state.is_stroking());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn clean_view_interruption_restores_weights_and_terminates_tool() {
|
||||
fn interrupt_once(
|
||||
mut state: ResMut<TerrainPaintState>,
|
||||
mut terrains: Query<(&GlobalTransform, &mut TerrainDesc)>,
|
||||
mut scene_io: ResMut<SceneIo>,
|
||||
mut active_operator: ResMut<ActiveOperator>,
|
||||
) {
|
||||
stop_tool_with_rollback(
|
||||
&mut state,
|
||||
&mut terrains,
|
||||
&mut scene_io,
|
||||
&mut active_operator,
|
||||
OperatorPhase::Canceled,
|
||||
"Terrain paint stopped for clean game view",
|
||||
"Clean game view enabled; weights restored",
|
||||
);
|
||||
}
|
||||
|
||||
let mut app = App::new();
|
||||
app.init_resource::<ActiveOperator>()
|
||||
.init_resource::<EditorHistory>()
|
||||
.init_resource::<SceneIo>();
|
||||
let mut original = TerrainDesc::flat(5);
|
||||
original.material_layers = vec![Default::default(), Default::default()];
|
||||
let mut preview = original.clone();
|
||||
apply_weight_dab(
|
||||
&mut preview,
|
||||
Vec3::ZERO,
|
||||
3.0,
|
||||
0.8,
|
||||
1,
|
||||
TerrainPaintMode::Paint,
|
||||
);
|
||||
let entity = app
|
||||
.world_mut()
|
||||
.spawn((LevelObject, GlobalTransform::default(), preview))
|
||||
.id();
|
||||
let mut state = TerrainPaintState::default();
|
||||
state.start(entity, 2);
|
||||
state.stroke = Some(TerrainPaintStroke {
|
||||
entity,
|
||||
original: original.clone(),
|
||||
last_local: Vec3::ZERO,
|
||||
});
|
||||
app.insert_resource(state)
|
||||
.add_systems(Update, interrupt_once);
|
||||
let harness = OperatorInvariantHarness::capture(app.world_mut());
|
||||
|
||||
app.update();
|
||||
|
||||
harness.assert_canceled(app.world_mut());
|
||||
harness.assert_status(app.world(), "terrain.paint", OperatorPhase::Canceled);
|
||||
assert_eq!(app.world().get::<TerrainDesc>(entity), Some(&original));
|
||||
assert!(!app.world().resource::<TerrainPaintState>().active);
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@ use bevy_egui::EguiContexts;
|
||||
use shared::{TerrainDesc, AUTHORING_COMPONENT_TERRAIN, COMPONENT_TERRAIN_DESC};
|
||||
|
||||
use crate::camera::EditorCamera;
|
||||
use crate::history::reflected_component_transaction;
|
||||
use crate::history::{reflected_component_transaction, EditorHistory};
|
||||
use crate::operators::{ActiveOperator, OperatorPhase, OperatorStatus};
|
||||
use crate::scene_io::SceneIo;
|
||||
use crate::selection::{SelectedEntity, ViewportClick};
|
||||
@@ -143,8 +143,15 @@ fn terrain_sculpt_input(
|
||||
state.clamp_settings();
|
||||
|
||||
let Some(entity) = state.target.or(selected.0) else {
|
||||
cancel_stroke(&mut state, &mut terrains);
|
||||
state.stop();
|
||||
stop_tool_with_rollback(
|
||||
&mut state,
|
||||
&mut terrains,
|
||||
&mut scene_io,
|
||||
&mut active_operator,
|
||||
OperatorPhase::Blocked,
|
||||
"Terrain sculpt stopped: target is unavailable",
|
||||
"Target unavailable",
|
||||
);
|
||||
return Ok(());
|
||||
};
|
||||
if selected.0 != Some(entity) {
|
||||
@@ -152,8 +159,15 @@ fn terrain_sculpt_input(
|
||||
}
|
||||
|
||||
if display.clean_game_view {
|
||||
cancel_stroke(&mut state, &mut terrains);
|
||||
state.stop();
|
||||
stop_tool_with_rollback(
|
||||
&mut state,
|
||||
&mut terrains,
|
||||
&mut scene_io,
|
||||
&mut active_operator,
|
||||
OperatorPhase::Canceled,
|
||||
"Terrain sculpt stopped for clean game view",
|
||||
"Clean game view enabled; terrain restored",
|
||||
);
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
@@ -163,12 +177,11 @@ fn terrain_sculpt_input(
|
||||
keys.just_pressed(KeyCode::Escape) || buttons.just_pressed(MouseButton::Right);
|
||||
if cancel_requested {
|
||||
if state.is_stroking() {
|
||||
cancel_stroke(&mut state, &mut terrains);
|
||||
scene_io.status = "Terrain sculpt stroke canceled".to_string();
|
||||
set_status(
|
||||
cancel_active_stroke(
|
||||
&mut state,
|
||||
&mut terrains,
|
||||
&mut scene_io,
|
||||
&mut active_operator,
|
||||
OperatorPhase::Canceled,
|
||||
"Stroke canceled; terrain restored",
|
||||
);
|
||||
} else {
|
||||
state.stop();
|
||||
@@ -179,8 +192,15 @@ fn terrain_sculpt_input(
|
||||
}
|
||||
|
||||
let Ok((global, mut terrain)) = terrains.get_mut(entity) else {
|
||||
state.stroke = None;
|
||||
state.stop();
|
||||
stop_tool_with_rollback(
|
||||
&mut state,
|
||||
&mut terrains,
|
||||
&mut scene_io,
|
||||
&mut active_operator,
|
||||
OperatorPhase::Blocked,
|
||||
"Terrain sculpt stopped: target no longer exists",
|
||||
"Target no longer exists",
|
||||
);
|
||||
return Ok(());
|
||||
};
|
||||
|
||||
@@ -253,18 +273,8 @@ fn terrain_sculpt_input(
|
||||
let label = sculpt_history_label(state.mode);
|
||||
let mode_label = state.mode.label();
|
||||
commands.queue(move |world: &mut World| {
|
||||
let result = commit_terrain_stroke(world, stroke, final_terrain, label);
|
||||
if let Err(error) = result {
|
||||
world.resource_mut::<SceneIo>().status =
|
||||
format!("Terrain sculpt commit failed: {error}");
|
||||
}
|
||||
finish_terrain_stroke(world, stroke, final_terrain, label, mode_label);
|
||||
});
|
||||
scene_io.status = format!("{mode_label} terrain stroke committed");
|
||||
set_status(
|
||||
&mut active_operator,
|
||||
OperatorPhase::Committed,
|
||||
format!("{mode_label} stroke; Ctrl+Z to undo"),
|
||||
);
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
@@ -276,10 +286,11 @@ fn commit_terrain_stroke(
|
||||
final_terrain: TerrainDesc,
|
||||
label: &'static str,
|
||||
) -> Result<(), String> {
|
||||
let original = stroke.original;
|
||||
if let Ok(mut actor) = world.get_entity_mut(stroke.entity) {
|
||||
actor.insert(stroke.original);
|
||||
actor.insert(original.clone());
|
||||
}
|
||||
reflected_component_transaction(
|
||||
let result = reflected_component_transaction(
|
||||
world,
|
||||
stroke.entity,
|
||||
label,
|
||||
@@ -289,7 +300,82 @@ fn commit_terrain_stroke(
|
||||
world.entity_mut(entity).insert(final_terrain);
|
||||
Ok(())
|
||||
},
|
||||
)
|
||||
);
|
||||
if result.is_err() {
|
||||
if let Ok(mut actor) = world.get_entity_mut(stroke.entity) {
|
||||
actor.insert(original);
|
||||
}
|
||||
}
|
||||
result
|
||||
}
|
||||
|
||||
fn finish_terrain_stroke(
|
||||
world: &mut World,
|
||||
stroke: TerrainStroke,
|
||||
final_terrain: TerrainDesc,
|
||||
label: &'static str,
|
||||
mode_label: &'static str,
|
||||
) {
|
||||
let undo_depth = world.resource::<EditorHistory>().undo_depth();
|
||||
match commit_terrain_stroke(world, stroke, final_terrain, label) {
|
||||
Ok(()) if world.resource::<EditorHistory>().undo_depth() > undo_depth => {
|
||||
world.resource_mut::<SceneIo>().status =
|
||||
format!("{mode_label} terrain stroke committed");
|
||||
set_status(
|
||||
&mut world.resource_mut::<ActiveOperator>(),
|
||||
OperatorPhase::Committed,
|
||||
format!("{mode_label} stroke; Ctrl+Z to undo"),
|
||||
);
|
||||
}
|
||||
Ok(()) => {
|
||||
world.resource_mut::<SceneIo>().status =
|
||||
format!("{mode_label} terrain stroke made no changes");
|
||||
set_status(
|
||||
&mut world.resource_mut::<ActiveOperator>(),
|
||||
OperatorPhase::Canceled,
|
||||
format!("{mode_label} stroke made no changes"),
|
||||
);
|
||||
}
|
||||
Err(error) => {
|
||||
world.resource_mut::<SceneIo>().status =
|
||||
format!("Terrain sculpt commit failed: {error}");
|
||||
set_status(
|
||||
&mut world.resource_mut::<ActiveOperator>(),
|
||||
OperatorPhase::Blocked,
|
||||
format!("Commit failed: {error}"),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn cancel_active_stroke(
|
||||
state: &mut TerrainSculptState,
|
||||
terrains: &mut Query<(&GlobalTransform, &mut TerrainDesc)>,
|
||||
scene_io: &mut SceneIo,
|
||||
active_operator: &mut ActiveOperator,
|
||||
) {
|
||||
cancel_stroke(state, terrains);
|
||||
scene_io.status = "Terrain sculpt stroke canceled".to_string();
|
||||
set_status(
|
||||
active_operator,
|
||||
OperatorPhase::Canceled,
|
||||
"Stroke canceled; terrain restored",
|
||||
);
|
||||
}
|
||||
|
||||
fn stop_tool_with_rollback(
|
||||
state: &mut TerrainSculptState,
|
||||
terrains: &mut Query<(&GlobalTransform, &mut TerrainDesc)>,
|
||||
scene_io: &mut SceneIo,
|
||||
active_operator: &mut ActiveOperator,
|
||||
phase: OperatorPhase,
|
||||
message: &str,
|
||||
hint: &str,
|
||||
) {
|
||||
cancel_stroke(state, terrains);
|
||||
state.stop();
|
||||
scene_io.status = message.to_string();
|
||||
set_status(active_operator, phase, hint);
|
||||
}
|
||||
|
||||
fn cancel_stroke(
|
||||
@@ -561,7 +647,8 @@ fn draw_terrain_sculpt_preview(state: Res<TerrainSculptState>, mut gizmos: Gizmo
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::history::{apply_command_redo, apply_command_undo, EditorHistory};
|
||||
use crate::history::EditorHistory;
|
||||
use crate::operators::test_harness::{assert_undo_redo_round_trip, OperatorInvariantHarness};
|
||||
use shared::{ActorKind, LevelObject};
|
||||
|
||||
fn sample(terrain: &TerrainDesc, x: u32, z: u32) -> f32 {
|
||||
@@ -657,8 +744,10 @@ mod tests {
|
||||
app.register_type::<ActorKind>()
|
||||
.register_type::<TerrainDesc>();
|
||||
let world = app.world_mut();
|
||||
world.init_resource::<ActiveOperator>();
|
||||
world.init_resource::<EditorHistory>();
|
||||
world.init_resource::<SceneIo>();
|
||||
world.init_resource::<TerrainSculptState>();
|
||||
let original = TerrainDesc::flat(9);
|
||||
let entity = world
|
||||
.spawn((LevelObject, ActorKind::Terrain, original.clone()))
|
||||
@@ -676,26 +765,126 @@ mod tests {
|
||||
);
|
||||
}
|
||||
world.entity_mut(entity).insert(final_terrain.clone());
|
||||
commit_terrain_stroke(
|
||||
let stroke = TerrainStroke {
|
||||
entity,
|
||||
original: original.clone(),
|
||||
last_local: Vec3::ZERO,
|
||||
flatten_height: 0.0,
|
||||
seed: 7,
|
||||
};
|
||||
{
|
||||
let mut state = world.resource_mut::<TerrainSculptState>();
|
||||
state.start(entity);
|
||||
state.stroke = Some(stroke);
|
||||
}
|
||||
let stroke = world
|
||||
.resource_mut::<TerrainSculptState>()
|
||||
.stroke
|
||||
.take()
|
||||
.unwrap();
|
||||
let harness = OperatorInvariantHarness::capture(world);
|
||||
|
||||
finish_terrain_stroke(
|
||||
world,
|
||||
stroke,
|
||||
final_terrain.clone(),
|
||||
"Raise Terrain",
|
||||
"Raise",
|
||||
);
|
||||
|
||||
harness.assert_committed(world, 1, 0);
|
||||
harness.assert_status(world, "terrain.sculpt", OperatorPhase::Committed);
|
||||
assert_eq!(world.get::<TerrainDesc>(entity), Some(&final_terrain));
|
||||
let state = world.resource::<TerrainSculptState>();
|
||||
assert!(state.active);
|
||||
assert_eq!(state.target, Some(entity));
|
||||
assert!(!state.is_stroking());
|
||||
assert_undo_redo_round_trip(world, original, final_terrain, |world| {
|
||||
world.get::<TerrainDesc>(entity).unwrap().clone()
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn no_op_stroke_terminates_without_dirtying_or_history() {
|
||||
let mut app = App::new();
|
||||
app.register_type::<ActorKind>()
|
||||
.register_type::<TerrainDesc>();
|
||||
let world = app.world_mut();
|
||||
world.init_resource::<ActiveOperator>();
|
||||
world.init_resource::<EditorHistory>();
|
||||
world.init_resource::<SceneIo>();
|
||||
let original = TerrainDesc::flat(5);
|
||||
let entity = world
|
||||
.spawn((LevelObject, ActorKind::Terrain, original.clone()))
|
||||
.id();
|
||||
let harness = OperatorInvariantHarness::capture(world);
|
||||
|
||||
finish_terrain_stroke(
|
||||
world,
|
||||
TerrainStroke {
|
||||
entity,
|
||||
original: original.clone(),
|
||||
last_local: Vec3::ZERO,
|
||||
flatten_height: 0.0,
|
||||
seed: 7,
|
||||
seed: 1,
|
||||
},
|
||||
final_terrain.clone(),
|
||||
"Raise Terrain",
|
||||
)
|
||||
.unwrap();
|
||||
original.clone(),
|
||||
"Smooth Terrain",
|
||||
"Smooth",
|
||||
);
|
||||
|
||||
assert_eq!(world.resource::<EditorHistory>().undo_depth(), 1);
|
||||
assert_eq!(world.get::<TerrainDesc>(entity), Some(&final_terrain));
|
||||
apply_command_undo(world);
|
||||
harness.assert_canceled(world);
|
||||
harness.assert_status(world, "terrain.sculpt", OperatorPhase::Canceled);
|
||||
assert_eq!(world.get::<TerrainDesc>(entity), Some(&original));
|
||||
apply_command_redo(world);
|
||||
assert_eq!(world.get::<TerrainDesc>(entity), Some(&final_terrain));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn commit_failure_restores_preview_and_reports_blocked_without_history() {
|
||||
let mut app = App::new();
|
||||
let world = app.world_mut();
|
||||
world.init_resource::<ActiveOperator>();
|
||||
world.init_resource::<EditorHistory>();
|
||||
world.init_resource::<SceneIo>();
|
||||
let original = TerrainDesc::flat(5);
|
||||
let mut preview = original.clone();
|
||||
apply_dab(
|
||||
&mut preview,
|
||||
Vec3::ZERO,
|
||||
3.0,
|
||||
0.8,
|
||||
TerrainSculptMode::Raise,
|
||||
0.0,
|
||||
11,
|
||||
);
|
||||
let entity = world
|
||||
.spawn((LevelObject, ActorKind::Terrain, preview.clone()))
|
||||
.id();
|
||||
let mut hierarchy = crate::ui::hierarchy_state::HierarchyPanelState::default();
|
||||
hierarchy.locked.insert(entity);
|
||||
world.insert_resource(hierarchy);
|
||||
let harness = OperatorInvariantHarness::capture(world);
|
||||
|
||||
finish_terrain_stroke(
|
||||
world,
|
||||
TerrainStroke {
|
||||
entity,
|
||||
original: original.clone(),
|
||||
last_local: Vec3::ZERO,
|
||||
flatten_height: 0.0,
|
||||
seed: 11,
|
||||
},
|
||||
preview,
|
||||
"Raise Terrain",
|
||||
"Raise",
|
||||
);
|
||||
|
||||
harness.assert_blocked(world);
|
||||
harness.assert_status(world, "terrain.sculpt", OperatorPhase::Blocked);
|
||||
assert_eq!(world.get::<TerrainDesc>(entity), Some(&original));
|
||||
assert!(world
|
||||
.resource::<SceneIo>()
|
||||
.status
|
||||
.starts_with("Terrain sculpt commit failed:"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -703,11 +892,21 @@ mod tests {
|
||||
fn cancel_once(
|
||||
mut state: ResMut<TerrainSculptState>,
|
||||
mut terrains: Query<(&GlobalTransform, &mut TerrainDesc)>,
|
||||
mut scene_io: ResMut<SceneIo>,
|
||||
mut active_operator: ResMut<ActiveOperator>,
|
||||
) {
|
||||
cancel_stroke(&mut state, &mut terrains);
|
||||
cancel_active_stroke(
|
||||
&mut state,
|
||||
&mut terrains,
|
||||
&mut scene_io,
|
||||
&mut active_operator,
|
||||
);
|
||||
}
|
||||
|
||||
let mut app = App::new();
|
||||
app.init_resource::<ActiveOperator>()
|
||||
.init_resource::<EditorHistory>()
|
||||
.init_resource::<SceneIo>();
|
||||
let original = TerrainDesc::flat(5);
|
||||
let mut preview = original.clone();
|
||||
apply_dab(
|
||||
@@ -721,7 +920,7 @@ mod tests {
|
||||
);
|
||||
let entity = app
|
||||
.world_mut()
|
||||
.spawn((GlobalTransform::default(), preview))
|
||||
.spawn((LevelObject, GlobalTransform::default(), preview))
|
||||
.id();
|
||||
let mut state = TerrainSculptState::default();
|
||||
state.start(entity);
|
||||
@@ -733,9 +932,74 @@ mod tests {
|
||||
seed: 11,
|
||||
});
|
||||
app.insert_resource(state).add_systems(Update, cancel_once);
|
||||
let harness = OperatorInvariantHarness::capture(app.world_mut());
|
||||
|
||||
app.update();
|
||||
harness.assert_canceled(app.world_mut());
|
||||
harness.assert_status(app.world(), "terrain.sculpt", OperatorPhase::Canceled);
|
||||
assert_eq!(app.world().get::<TerrainDesc>(entity), Some(&original));
|
||||
assert!(!app.world().resource::<TerrainSculptState>().is_stroking());
|
||||
let state = app.world().resource::<TerrainSculptState>();
|
||||
assert!(state.active);
|
||||
assert_eq!(state.target, Some(entity));
|
||||
assert!(!state.is_stroking());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn clean_view_interruption_restores_stroke_and_terminates_tool() {
|
||||
fn interrupt_once(
|
||||
mut state: ResMut<TerrainSculptState>,
|
||||
mut terrains: Query<(&GlobalTransform, &mut TerrainDesc)>,
|
||||
mut scene_io: ResMut<SceneIo>,
|
||||
mut active_operator: ResMut<ActiveOperator>,
|
||||
) {
|
||||
stop_tool_with_rollback(
|
||||
&mut state,
|
||||
&mut terrains,
|
||||
&mut scene_io,
|
||||
&mut active_operator,
|
||||
OperatorPhase::Canceled,
|
||||
"Terrain sculpt stopped for clean game view",
|
||||
"Clean game view enabled; terrain restored",
|
||||
);
|
||||
}
|
||||
|
||||
let mut app = App::new();
|
||||
app.init_resource::<ActiveOperator>()
|
||||
.init_resource::<EditorHistory>()
|
||||
.init_resource::<SceneIo>();
|
||||
let original = TerrainDesc::flat(5);
|
||||
let mut preview = original.clone();
|
||||
apply_dab(
|
||||
&mut preview,
|
||||
Vec3::ZERO,
|
||||
3.0,
|
||||
0.8,
|
||||
TerrainSculptMode::Raise,
|
||||
0.0,
|
||||
11,
|
||||
);
|
||||
let entity = app
|
||||
.world_mut()
|
||||
.spawn((LevelObject, GlobalTransform::default(), preview))
|
||||
.id();
|
||||
let mut state = TerrainSculptState::default();
|
||||
state.start(entity);
|
||||
state.stroke = Some(TerrainStroke {
|
||||
entity,
|
||||
original: original.clone(),
|
||||
last_local: Vec3::ZERO,
|
||||
flatten_height: 0.0,
|
||||
seed: 11,
|
||||
});
|
||||
app.insert_resource(state)
|
||||
.add_systems(Update, interrupt_once);
|
||||
let harness = OperatorInvariantHarness::capture(app.world_mut());
|
||||
|
||||
app.update();
|
||||
|
||||
harness.assert_canceled(app.world_mut());
|
||||
harness.assert_status(app.world(), "terrain.sculpt", OperatorPhase::Canceled);
|
||||
assert_eq!(app.world().get::<TerrainDesc>(entity), Some(&original));
|
||||
assert!(!app.world().resource::<TerrainSculptState>().active);
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ mod migrate;
|
||||
pub mod navigation;
|
||||
mod prefab;
|
||||
mod project_validation;
|
||||
pub mod sample_pack;
|
||||
mod upgrade;
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
@@ -13,7 +13,7 @@ use shared::{
|
||||
AudioSourceDesc, BrushDesc, ColliderDesc, ColliderShapeDesc, EditorAssetRef, MaterialAsset,
|
||||
MaterialDesc, MaterialInstanceAsset, MaterialOverride, ModelRef, PostProcessEffectAsset,
|
||||
PostProcessVolumeDesc, PrefabInstance, PrefabRef, RendererMaterialSet, ShaderSchemaAsset,
|
||||
SkinnedMeshRenderer, StaticMeshRenderer, ANIMATION_MANIFEST_SCHEMA_VERSION,
|
||||
SkinnedMeshRenderer, StaticMeshRenderer, TerrainDesc, ANIMATION_MANIFEST_SCHEMA_VERSION,
|
||||
AUDIO_CLIP_SUB_ASSET_ID, COMPONENT_ANIMATION_CONTROLLER_DESC, COMPONENT_SKINNED_MESH_RENDERER,
|
||||
NAVIGATION_GENERATED_ARTIFACT_DIRECTORY,
|
||||
};
|
||||
@@ -25,6 +25,7 @@ const MATERIAL_DESC: &str = "shared::components::MaterialDesc";
|
||||
const MATERIAL_OVERRIDE: &str = "shared::components::MaterialOverride";
|
||||
const STATIC_MESH_RENDERER: &str = "shared::components::StaticMeshRenderer";
|
||||
const BRUSH_DESC: &str = "shared::components::BrushDesc";
|
||||
const TERRAIN_DESC: &str = "shared::components::TerrainDesc";
|
||||
const COLLIDER_DESC: &str = "shared::components::ColliderDesc";
|
||||
const POST_PROCESS_VOLUME: &str = "shared::components::PostProcessVolumeDesc";
|
||||
const PREFAB_INSTANCE: &str = "shared::components::PrefabInstance";
|
||||
@@ -1905,6 +1906,53 @@ fn collect_component_references(
|
||||
}
|
||||
}
|
||||
}
|
||||
TERRAIN_DESC => match ron::from_str::<TerrainDesc>(&component.ron) {
|
||||
Ok(terrain) => {
|
||||
if let Err(error) = terrain.validate() {
|
||||
report.findings.push(ProjectValidationFinding {
|
||||
severity: ValidationSeverity::Error,
|
||||
code: "terrain.invalid".into(),
|
||||
source_path: source_path.to_string(),
|
||||
owner_actor_id: actor_id.map(str::to_string),
|
||||
reference: None,
|
||||
message: error,
|
||||
repair: "Repair the terrain dimensions, samples, layers, and chunk settings in the Inspector."
|
||||
.into(),
|
||||
});
|
||||
}
|
||||
if let Some(material) = &terrain.base_material {
|
||||
collect_terrain_material_ref(
|
||||
project_root,
|
||||
report,
|
||||
source_path,
|
||||
actor_id,
|
||||
"TerrainDesc.base_material",
|
||||
material,
|
||||
);
|
||||
}
|
||||
for (index, layer) in terrain.material_layers.iter().enumerate() {
|
||||
if let Some(material) = &layer.material {
|
||||
collect_terrain_material_ref(
|
||||
project_root,
|
||||
report,
|
||||
source_path,
|
||||
actor_id,
|
||||
&format!("TerrainDesc.material_layers[{index}].material"),
|
||||
material,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(error) => report.findings.push(ProjectValidationFinding {
|
||||
severity: ValidationSeverity::Error,
|
||||
code: "terrain.malformed".into(),
|
||||
source_path: source_path.to_string(),
|
||||
owner_actor_id: actor_id.map(str::to_string),
|
||||
reference: None,
|
||||
message: format!("could not parse TerrainDesc: {error}"),
|
||||
repair: "Remove and recreate the Terrain component with the current editor.".into(),
|
||||
}),
|
||||
},
|
||||
COLLIDER_DESC => validate_collider(
|
||||
project_root,
|
||||
report,
|
||||
@@ -2736,6 +2784,64 @@ fn collect_material(
|
||||
}
|
||||
}
|
||||
|
||||
fn collect_terrain_material_ref(
|
||||
project_root: &Path,
|
||||
report: &mut ProjectValidationReport,
|
||||
source_path: &str,
|
||||
actor_id: Option<&str>,
|
||||
property: &str,
|
||||
reference: &EditorAssetRef,
|
||||
) {
|
||||
let Some(path) = reference
|
||||
.source_path
|
||||
.as_deref()
|
||||
.filter(|path| !path.trim().is_empty())
|
||||
else {
|
||||
report.findings.push(ProjectValidationFinding {
|
||||
severity: ValidationSeverity::Error,
|
||||
code: "terrain.material_ref_unresolved".into(),
|
||||
source_path: source_path.to_string(),
|
||||
owner_actor_id: actor_id.map(str::to_string),
|
||||
reference: Some(property.to_string()),
|
||||
message: format!("{property} has no loadable project source path"),
|
||||
repair:
|
||||
"Assign an existing project Material or Material Instance in the Terrain inspector."
|
||||
.into(),
|
||||
});
|
||||
return;
|
||||
};
|
||||
let path_value = Path::new(path);
|
||||
if path_value.is_absolute()
|
||||
|| path_value == Path::new("assets")
|
||||
|| !path_value.starts_with("assets")
|
||||
|| !path_value
|
||||
.components()
|
||||
.all(|component| matches!(component, Component::Normal(_)))
|
||||
{
|
||||
report.findings.push(ProjectValidationFinding {
|
||||
severity: ValidationSeverity::Error,
|
||||
code: "terrain.material_ref_invalid".into(),
|
||||
source_path: source_path.to_string(),
|
||||
owner_actor_id: actor_id.map(str::to_string),
|
||||
reference: Some(path.to_string()),
|
||||
message: format!(
|
||||
"{property} source path must be a normalized project-relative path below assets/"
|
||||
),
|
||||
repair: "Reassign the terrain layer from a project Material or Material Instance."
|
||||
.into(),
|
||||
});
|
||||
return;
|
||||
}
|
||||
add_reference(
|
||||
project_root,
|
||||
report,
|
||||
source_path,
|
||||
actor_id,
|
||||
"terrain_material",
|
||||
path,
|
||||
);
|
||||
}
|
||||
|
||||
fn collect_asset_ref(
|
||||
project_root: &Path,
|
||||
report: &mut ProjectValidationReport,
|
||||
@@ -3888,6 +3994,132 @@ mod tests {
|
||||
std::fs::remove_dir_all(root).unwrap();
|
||||
}
|
||||
|
||||
fn write_terrain_scene(root: &Path, terrain: &TerrainDesc) {
|
||||
let terrain = ron::to_string(terrain).unwrap();
|
||||
std::fs::write(
|
||||
root.join("assets/levels/main.scn.ron"),
|
||||
format!(
|
||||
"(schema_version:4,resources:{{}},entities:{{1:(components:{{\"shared::components::ActorId\":(\"terrain-owner\"),\"{TERRAIN_DESC}\":{terrain},}})}})"
|
||||
),
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn terrain_material_references_are_actor_owned_dependencies() {
|
||||
let root = fixture_root();
|
||||
let mut terrain = TerrainDesc::flat(3);
|
||||
terrain.base_material = Some(
|
||||
EditorAssetRef::new("base-id", "material:instance", "Base")
|
||||
.with_source_path("assets/materials/base.ron"),
|
||||
);
|
||||
terrain.material_layers = vec![shared::TerrainMaterialLayer {
|
||||
material: Some(
|
||||
EditorAssetRef::new("layer-id", "material:source", "Layer")
|
||||
.with_source_path("assets/materials/layer.ron"),
|
||||
),
|
||||
uv_scale: 4.0,
|
||||
}];
|
||||
write_terrain_scene(&root, &terrain);
|
||||
|
||||
let report = validate_project(&root);
|
||||
let dependencies = report
|
||||
.dependencies
|
||||
.iter()
|
||||
.filter(|dependency| dependency.kind == "terrain_material")
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
assert_eq!(dependencies.len(), 2, "{:?}", report.dependencies);
|
||||
assert!(dependencies
|
||||
.iter()
|
||||
.all(|dependency| dependency.owner_actor_id.as_deref() == Some("terrain-owner")));
|
||||
assert_eq!(
|
||||
report
|
||||
.findings
|
||||
.iter()
|
||||
.filter(|finding| finding.code == "asset.missing")
|
||||
.count(),
|
||||
2
|
||||
);
|
||||
std::fs::remove_dir_all(root).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn terrain_material_references_require_runtime_source_paths() {
|
||||
let root = fixture_root();
|
||||
let mut terrain = TerrainDesc::flat(3);
|
||||
terrain.base_material = Some(
|
||||
EditorAssetRef::new("empty-path-id", "material:source", "Empty")
|
||||
.with_source_path(" "),
|
||||
);
|
||||
terrain.material_layers = vec![
|
||||
shared::TerrainMaterialLayer {
|
||||
material: Some(EditorAssetRef::new(
|
||||
"source-less-id",
|
||||
"material:source",
|
||||
"Source-less",
|
||||
)),
|
||||
uv_scale: 4.0,
|
||||
},
|
||||
shared::TerrainMaterialLayer {
|
||||
material: Some(
|
||||
EditorAssetRef::new("missing-id", "material:source", "Missing")
|
||||
.with_source_path("assets/materials/missing.ron"),
|
||||
),
|
||||
uv_scale: 8.0,
|
||||
},
|
||||
];
|
||||
write_terrain_scene(&root, &terrain);
|
||||
|
||||
let report = validate_project(&root);
|
||||
let unresolved = report
|
||||
.findings
|
||||
.iter()
|
||||
.filter(|finding| finding.code == "terrain.material_ref_unresolved")
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
assert_eq!(unresolved.len(), 2, "{:?}", report.findings);
|
||||
assert!(unresolved
|
||||
.iter()
|
||||
.all(|finding| finding.owner_actor_id.as_deref() == Some("terrain-owner")));
|
||||
assert!(report.findings.iter().any(|finding| {
|
||||
finding.code == "asset.missing"
|
||||
&& finding.owner_actor_id.as_deref() == Some("terrain-owner")
|
||||
&& finding.reference.as_deref() == Some("assets/materials/missing.ron")
|
||||
}));
|
||||
assert!(report.dependencies.iter().any(|dependency| {
|
||||
dependency.kind == "terrain_material"
|
||||
&& dependency.reference == "assets/materials/missing.ron"
|
||||
}));
|
||||
assert!(!report.dependencies.iter().any(|dependency| {
|
||||
dependency.kind == "generated_manifest"
|
||||
&& (dependency.reference.contains("empty-path-id")
|
||||
|| dependency.reference.contains("source-less-id"))
|
||||
}));
|
||||
assert!(!report.is_release_ready());
|
||||
std::fs::remove_dir_all(root).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn invalid_terrain_descriptor_blocks_project_validation() {
|
||||
let root = fixture_root();
|
||||
let mut terrain = TerrainDesc::flat(3);
|
||||
terrain.heights.pop();
|
||||
write_terrain_scene(&root, &terrain);
|
||||
|
||||
let report = validate_project(&root);
|
||||
let finding = report
|
||||
.findings
|
||||
.iter()
|
||||
.find(|finding| finding.code == "terrain.invalid")
|
||||
.expect("invalid terrain should block release validation");
|
||||
|
||||
assert_eq!(finding.owner_actor_id.as_deref(), Some("terrain-owner"));
|
||||
assert!(finding.message.contains("requires 9 height samples"));
|
||||
assert!(!report.is_release_ready());
|
||||
std::fs::remove_dir_all(root).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn project_default_level_must_be_in_the_audited_levels_tree() {
|
||||
let root = fixture_root();
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -40,16 +40,17 @@ use static_meshes::{
|
||||
};
|
||||
pub use terrain::HydratedTerrainChunk;
|
||||
use terrain::{cleanup_removed_terrain, hydrate_terrain};
|
||||
pub use visibility::initialize_level_object_visibility_hierarchy;
|
||||
use visibility::{
|
||||
ensure_level_object_visibility_hierarchy, init_editor_visibility_on_spawn,
|
||||
sync_editor_visibility, visibility_from_editor,
|
||||
sync_editor_visibility,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
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,
|
||||
authoring_component_active, AuthoringComponentStates, BrushDesc, ColliderDesc, 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.
|
||||
@@ -115,6 +116,8 @@ pub fn flush_level_object_hydration(world: &mut World) {
|
||||
world.insert_resource(StaticMeshArtifactCache::default());
|
||||
}
|
||||
|
||||
initialize_level_object_visibility_hierarchy(world);
|
||||
|
||||
let primitives: Vec<(Entity, Primitive)> = world
|
||||
.query_filtered::<(
|
||||
Entity,
|
||||
@@ -250,12 +253,6 @@ pub fn flush_level_object_hydration(world: &mut World) {
|
||||
}
|
||||
}
|
||||
|
||||
let visibility_targets: Vec<(Entity, EditorVisibility)> = world
|
||||
.query_filtered::<(Entity, &EditorVisibility), With<LevelObject>>()
|
||||
.iter(world)
|
||||
.map(|(entity, vis)| (entity, *vis))
|
||||
.collect();
|
||||
|
||||
let rendering = world
|
||||
.get_resource::<settings::ProjectSettings>()
|
||||
.map(|s| s.rendering.clone())
|
||||
@@ -348,25 +345,6 @@ 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 = 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());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -3,6 +3,24 @@
|
||||
use crate::{EditorVisibility, LevelObject};
|
||||
use bevy::prelude::*;
|
||||
|
||||
/// Establishes the runtime visibility hierarchy synchronously for all authored actors.
|
||||
///
|
||||
/// Scene loading can occur between scheduled hydration sets, so callers that materialize a scene
|
||||
/// must run this before generated render children can be attached in the same frame.
|
||||
pub fn initialize_level_object_visibility_hierarchy(world: &mut World) {
|
||||
let targets: Vec<(Entity, EditorVisibility)> = world
|
||||
.query_filtered::<(Entity, Option<&EditorVisibility>), With<LevelObject>>()
|
||||
.iter(world)
|
||||
.map(|(entity, visibility)| (entity, visibility.copied().unwrap_or_default()))
|
||||
.collect();
|
||||
|
||||
for (entity, editor_visibility) in targets {
|
||||
if let Ok(mut entity_mut) = world.get_entity_mut(entity) {
|
||||
entity_mut.insert((editor_visibility, visibility_from_editor(editor_visibility)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[expect(
|
||||
clippy::type_complexity,
|
||||
reason = "the query mirrors Bevy's three visibility hierarchy components"
|
||||
@@ -81,7 +99,9 @@ pub fn visibility_from_editor(editor: EditorVisibility) -> Visibility {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::ensure_level_object_visibility_hierarchy;
|
||||
use super::{
|
||||
ensure_level_object_visibility_hierarchy, initialize_level_object_visibility_hierarchy,
|
||||
};
|
||||
use crate::{EditorVisibility, LevelObject};
|
||||
use bevy::prelude::*;
|
||||
|
||||
@@ -102,4 +122,34 @@ mod tests {
|
||||
assert!(world.get::<InheritedVisibility>(entity).is_some());
|
||||
assert!(world.get::<ViewVisibility>(entity).is_some());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn immediate_initializer_establishes_hierarchy_before_scheduled_hydration() {
|
||||
let mut world = World::new();
|
||||
let entity = world
|
||||
.spawn((LevelObject, EditorVisibility { visible: false }))
|
||||
.id();
|
||||
|
||||
initialize_level_object_visibility_hierarchy(&mut world);
|
||||
|
||||
assert_eq!(world.get::<Visibility>(entity), Some(&Visibility::Hidden));
|
||||
assert!(world.get::<InheritedVisibility>(entity).is_some());
|
||||
assert!(world.get::<ViewVisibility>(entity).is_some());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn immediate_initializer_migrates_missing_authored_visibility() {
|
||||
let mut world = World::new();
|
||||
let entity = world.spawn(LevelObject).id();
|
||||
|
||||
initialize_level_object_visibility_hierarchy(&mut world);
|
||||
|
||||
assert_eq!(
|
||||
world.get::<EditorVisibility>(entity),
|
||||
Some(&EditorVisibility::default())
|
||||
);
|
||||
assert_eq!(world.get::<Visibility>(entity), Some(&Visibility::Visible));
|
||||
assert!(world.get::<InheritedVisibility>(entity).is_some());
|
||||
assert!(world.get::<ViewVisibility>(entity).is_some());
|
||||
}
|
||||
}
|
||||
@@ -20,10 +20,10 @@ pub use actor::{infer_actor_kind, validate_actor, ActorValidationError};
|
||||
pub use animation::*;
|
||||
pub use components::*;
|
||||
pub use hydration::{
|
||||
cascade_config_from_rendering, flush_level_object_hydration, material_from_desc,
|
||||
strip_hydrated, strip_hydrated_entity, HydratedModelRoot, HydratedPrefabMember,
|
||||
HydratedPrefabReady, HydratedSkinnedMeshRoot, HydratedTerrainChunk, HydrationPlugin,
|
||||
PrefabHydrationBlocked,
|
||||
cascade_config_from_rendering, flush_level_object_hydration,
|
||||
initialize_level_object_visibility_hierarchy, material_from_desc, strip_hydrated,
|
||||
strip_hydrated_entity, HydratedModelRoot, HydratedPrefabMember, HydratedPrefabReady,
|
||||
HydratedSkinnedMeshRoot, HydratedTerrainChunk, HydrationPlugin, PrefabHydrationBlocked,
|
||||
};
|
||||
pub use material_asset::{
|
||||
load_resolved_material_from_path, MaterialAlphaMode, MaterialAsset, MaterialInstanceAsset,
|
||||
|
||||
@@ -85,12 +85,15 @@ Immutable-style log of significant decisions. Add a new numbered ADR when changi
|
||||
| [editor/terrain.md](editor/terrain.md) | Terrain schema, inspector workflow, chunk hydration, collision, and follow-on boundaries |
|
||||
| [editor/physics-placement.md](editor/physics-placement.md) | Transactional gravity placement, diagnostics, isolation, and undo workflow |
|
||||
| [editor/collider-authoring.md](editor/collider-authoring.md) | Collider shape authoring, hydration diagnostics, semantic overlays, and placement prerequisites |
|
||||
| [editor/sample-regression-pack.md](editor/sample-regression-pack.md) | Five-area sample catalog, editor workflow, validation gates, and visual QA contract |
|
||||
| [editor/evaluations/material-renderer-foundation/](editor/evaluations/material-renderer-foundation/) | Live screenshots and acceptance results for the renderer/material/component foundation |
|
||||
| [editor/evaluations/terrain-sculpt-tools/](editor/evaluations/terrain-sculpt-tools/) | Live screenshot and acceptance results for modal terrain sculpt tools |
|
||||
| [editor/evaluations/terrain-material-layers/](editor/evaluations/terrain-material-layers/) | Live screenshot and acceptance results for terrain material assignment, blending, painting, and history |
|
||||
| [editor/evaluations/physics-placement/](editor/evaluations/physics-placement/) | Live screenshot and acceptance results for physics settling, cancel, commit, undo, and redo |
|
||||
| [editor/evaluations/collider-diagnostics/](editor/evaluations/collider-diagnostics/) | Live screenshot and acceptance results for collider overlays, diagnostics, shape history, and placement preflight |
|
||||
| [editor/evaluations/navigation-authoring/](editor/evaluations/navigation-authoring/) | Live screenshots and acceptance results for navigation authoring and runtime parity |
|
||||
| [editor/evaluations/operator-invariants/](editor/evaluations/operator-invariants/) | Source acceptance results for production operator lifecycle, rollback, cleanup, and undo/redo invariants |
|
||||
| [editor/evaluations/sample-regression-pack/](editor/evaluations/sample-regression-pack/) | Exact-implementation source and native acceptance evidence for the editor sample regression pack |
|
||||
| [editor/evaluations/production-readiness/](editor/evaluations/production-readiness/) | Current versioned production gate, evidence matrix, candidate commands, soak protocol, and independent sign-off requirements |
|
||||
|
||||
## Working plans (not canonical long-term)
|
||||
@@ -114,6 +117,8 @@ Detailed milestone and feature plans live in [`.cursor/plans/`](../.cursor/plans
|
||||
| `production_readiness_acceptance_*.plan.md` | Release-candidate evidence matrix, blocker sequence, clean-checkout checks, soak, budgets, and independent sign-off |
|
||||
| `material_library_and_targeted_drop_*.plan.md` | Dedicated Material Library, exact viewport slot/primitive/brush targeting, hover preview, cancel, and grouped history |
|
||||
| `terrain_material_layers_*.plan.md` | Terrain shared-material layers, normalized weights, blended hydration, and modal painting |
|
||||
| `operator_invariants_completion_*.plan.md` | Production operator dispatch, interruption, rollback, cleanup, and undo/redo acceptance |
|
||||
| `editor_sample_regression_pack_*.plan.md` | Five-area sample manifest, editor catalog, deterministic validation, and native regression acceptance |
|
||||
|
||||
## Crate responsibilities (quick reference)
|
||||
|
||||
|
||||
@@ -23,6 +23,14 @@ Both the editor Diagnostics window and the `cargo validate-levels` headless comm
|
||||
entry point. The command supports `--project <path>` and `--json`; the editor can select the live
|
||||
owning actor for an attributed finding. Blocking errors produce a nonzero headless exit status.
|
||||
|
||||
The optional editor regression pack has one conventional manifest at
|
||||
`assets/samples/editor_samples.ron`. Schema v1 contains exactly one Brush, Material, Terrain,
|
||||
Physics Placement, and Rendering sample with stable metadata, project-relative scene paths, and
|
||||
explicit manual checks. `cargo validate-samples` validates that catalog and combines its findings
|
||||
with the authoritative project report. Projects without the manifest remain valid ordinary
|
||||
projects; Blacksite CI invokes the sample command to make the complete pack mandatory for this
|
||||
repository.
|
||||
|
||||
Project validation covers the project manifest and asset roots, registry IDs/sources/dependencies,
|
||||
generated static mesh manifests, material and shader documents, post effects, scene and prefab
|
||||
graphs, authored model/material/texture/brush/collider references, rendering profiles, and
|
||||
@@ -34,6 +42,10 @@ startup entrypoint. Unknown newer scene schemas are rejected rather than down-st
|
||||
requirements are explicit findings; for example, Solari projects record the required forward-path
|
||||
fallback QA when ray tracing is unavailable.
|
||||
|
||||
Terrain descriptors participate in the same actor-owned dependency pass. Their authored dimensions,
|
||||
height and weight grids, chunk settings, base material, and material layers are validated before
|
||||
hydration so a sample or shipping scene cannot hide an invalid or unresolved terrain reference.
|
||||
|
||||
## Consequences
|
||||
|
||||
- Headless and editor validation share result semantics and finding ownership.
|
||||
@@ -42,3 +54,7 @@ fallback QA when ray tracing is unavailable.
|
||||
Gitea #44 acceptance verifies the shared gate against real development output.
|
||||
- Asset formats added later must register their dependencies with this validator and extend the
|
||||
valid, missing, cyclic, and incompatible project-fixture matrix.
|
||||
- The sample manifest is discovery and regression metadata, not a second project-settings schema;
|
||||
editor UI and headless tooling consume the same scene ordering and validation result.
|
||||
- CI must hydrate Git LFS before validation because a pointer file is intentionally treated as
|
||||
missing runtime content.
|
||||
@@ -22,7 +22,8 @@ weights through `Mesh::ATTRIBUTE_COLOR`.
|
||||
`blacksite_surface` owns the terrain-specific `ExtendedMaterial` and blends each resolved layer's
|
||||
albedo, tangent-space normal, metallic, and roughness inputs. Invalid or unavailable references leave
|
||||
the existing visible terrain fallback in place and emit diagnostics. Terrain remains excluded from
|
||||
Solari geometry until a matching ray-tracing evaluator exists.
|
||||
Solari geometry until a matching ray-tracing evaluator exists, and its opaque material is therefore
|
||||
forced through Bevy's forward raster path even when the project default is deferred.
|
||||
|
||||
Editor paint strokes materialize the implicit default map only when needed. Each pointer stroke is a
|
||||
single reflected `TerrainDesc` transaction; cancel restores the exact original descriptor.
|
||||
|
||||
@@ -28,6 +28,7 @@ Docs for the in-process egui editor (`crates/editor/`). Update this index when a
|
||||
| [terrain.md](terrain.md) | Inline height-grid terrain, chunk hydration, collision, inspector workflow, and fixtures |
|
||||
| [physics-placement.md](physics-placement.md) | Transactional gravity placement, prerequisites, isolation, commit/cancel, and undo |
|
||||
| [collider-authoring.md](collider-authoring.md) | Collider shape editing, shared health diagnostics, overlays, hydration status, and placement reuse |
|
||||
| [sample-regression-pack.md](sample-regression-pack.md) | Five-area sample manifest, native workflow, visual composition, validation, and maintenance contract |
|
||||
| [evaluations/](evaluations/) | Acceptance evidence records and native Gitea attachment publishing policy |
|
||||
| [evaluations/material-renderer-foundation/](evaluations/material-renderer-foundation/) | Live screenshots and verification record for the renderer/material/component foundation |
|
||||
| [evaluations/material-library-targeted-drop/](evaluations/material-library-targeted-drop/) | Live screenshot and verification record for the docked Material Library and exact reversible surface drops |
|
||||
@@ -39,6 +40,8 @@ Docs for the in-process egui editor (`crates/editor/`). Update this index when a
|
||||
| [evaluations/physics-placement/](evaluations/physics-placement/) | Live screenshot and verification record for multi-prop settling, cancel, commit, undo, and redo |
|
||||
| [evaluations/collider-diagnostics/](evaluations/collider-diagnostics/) | Live screenshot and verification record for semantic collider overlays, health linking, shape switching, and placement reuse |
|
||||
| [evaluations/navigation-authoring/](evaluations/navigation-authoring/) | Live screenshots and verification record for navigation authoring and runtime parity |
|
||||
| [evaluations/operator-invariants/](evaluations/operator-invariants/) | Source acceptance record for production operator lifecycle, rollback, cleanup, and undo/redo invariants |
|
||||
| [evaluations/sample-regression-pack/](evaluations/sample-regression-pack/) | Exact-implementation source and native acceptance evidence for the five-area editor regression pack |
|
||||
| [evaluations/production-readiness/](evaluations/production-readiness/) | Current #50 release-candidate matrix and required clean-checkout, soak, performance, limitation, and independent-signoff evidence |
|
||||
|
||||
## Subsystems (code → doc)
|
||||
@@ -66,6 +69,7 @@ Docs for the in-process egui editor (`crates/editor/`). Update this index when a
|
||||
| `project/session.rs` | Versioned XDG session document, clean marker, and safe resume | session-recovery.md, ADR 0024 |
|
||||
| `project/diagnostics_bundle.rs` | Privacy-bounded transactional support report export | session-recovery.md, ADR 0024 |
|
||||
| `project/launcher.rs` | Strict project inspection, CLI activation, recent filtering, and sandbox scaffolding | project-launcher.md, ADR 0025 |
|
||||
| `project/samples.rs` / `scene::sample_pack` / `xtask/src/validate_samples.rs` | Cached editor sample catalog, canonical pack contract, and deterministic headless release gate | sample-regression-pack.md, ADR 0028 |
|
||||
| `ext/` | Command palette, BRP, game panel adapters | ADR 0007 |
|
||||
| `ui/mod.rs` | Dock layout, unified viewport, menus | README controls |
|
||||
| `ui/scene_tabs.rs` | Main-toolbar scene tabs and composition controls | multi-scene-composition.md, ADR 0026 |
|
||||
|
||||
@@ -245,13 +245,16 @@ the Edit-to-Play boundary restore the complete runtime snapshot. See
|
||||
|
||||
Structural edits (spawn, delete, transform, rename) go through `EditorHistory` command objects in `history.rs`.
|
||||
User-facing actions route through the operator lifecycle in `operators.rs`: begin, preview,
|
||||
commit, cancel, disabled reason, and status text. The first bridge wraps command-palette and queued
|
||||
editor commands as immediate operators, while existing `EditorHistory` commands remain the undo
|
||||
payload. Asset placement, mesh-subasset placement, texture apply, and material apply actions now
|
||||
use immediate operators from `assets::operators`; texture/material changes across a selection use
|
||||
one `SetMaterialGroup` command. Draw Brush, brush CSG, clip, and element gizmo paths publish the
|
||||
same preview/commit/cancel phases. `operators/test_harness.rs` verifies authored deltas, dirty
|
||||
state, helper cleanup, undo grouping, and undo/redo restoration; see
|
||||
commit, cancel, disabled reason, stable ID, and status text. Registered commands return typed
|
||||
`OperatorAction::Commit` or `OperatorAction::ContinuePreview`, so immediate commands finish while
|
||||
Draw Brush and CSG retain modal Preview ownership; validation failures terminate instead of leaving
|
||||
stale status. Existing `EditorHistory` commands remain the undo payload. Group Selection is one
|
||||
atomic command that remaps its transient group identity on every redo without reparenting unrelated
|
||||
siblings. Lighting reset and Project Sun changes use one grouped light command. Asset placement,
|
||||
assignment, exact material drops, brush tools, terrain strokes, physics placement, and the real
|
||||
transform tracker all publish terminal lifecycle state. `operators/test_harness.rs` verifies semantic
|
||||
projections, dirty-state preservation, stable IDs, helper cleanup, undo grouping, repeated undo/redo,
|
||||
and automatic interruption rollback; see
|
||||
[operator-regression-testing.md](operator-regression-testing.md).
|
||||
|
||||
PIE stop restores player simulation state only; authored `LevelObject` edits made during PIE remain in the scene.
|
||||
|
||||
@@ -10,6 +10,8 @@ Living checklist for the production editor program ([ADR 0012](../adr/0012-zero-
|
||||
| Monolithic `hydrate_authoring_entities` | Done | `crates/shared/src/hydration/*` modules |
|
||||
| Optional / inferred `ActorKind` as long-term save path | Done | Schema v2 + migration; save validates |
|
||||
| Hydrated components in committed `.scn.ron` | CI | `scene::validate_scene_authoring_only` + `repo_editor_scene_has_no_hydrated_components` |
|
||||
| Production mutation without commit/cancel/failure/undo invariants | Done | Shared operator harness plus typed history projections cover palette, asset, brush, terrain, physics, grouping, lighting, material-drop, and transform paths; see [evaluation](evaluations/operator-invariants/) |
|
||||
| Representative editor coverage can silently disappear | Done | Versioned five-area manifest, typed scene gate, `validate-samples`, and native protocol; see [sample pack](sample-regression-pack.md) |
|
||||
| Dual FBX thumbnail ad-hoc path (parallel to unified pipeline) | Partial | Phase 5 `assets/thumbnails/` refactor |
|
||||
| `failed_keys` thumbnail cache without retry API | Partial | `asset_thumbnails.rs`; Phase 5 `ThumbnailState` |
|
||||
|
||||
@@ -21,7 +23,7 @@ Living checklist for the production editor program ([ADR 0012](../adr/0012-zero-
|
||||
| P1 | `ActorKind` required; `validate_actor` on save |
|
||||
| P2 | No runtime components in default inspector |
|
||||
| P3 | `HierarchySiblingIndex`; no undefined sibling order |
|
||||
| P6 | `ActorInspectorSection` registry; command palette commands; BRP authoring policy |
|
||||
| P6 | `ActorInspectorSection` registry; typed immediate/modal command dispatch; BRP authoring policy; production mutation invariants |
|
||||
| P7 | ADRs 0009–0012 indexed; CI `shared` + `scene` + `editor` checks |
|
||||
|
||||
## Manual verification (release)
|
||||
@@ -29,3 +31,5 @@ Living checklist for the production editor program ([ADR 0012](../adr/0012-zero-
|
||||
- [ ] R1–R6 rendering/inspector scenarios ([roadmap.md](roadmap.md))
|
||||
- [ ] Save/load roundtrip: hierarchy, lights, materials unchanged
|
||||
- [ ] PIE 60s stop: project lighting profile unchanged unless scene overrides edited
|
||||
- [ ] Rerun the [operator invariant matrix](operator-regression-testing.md) from the nominated release-candidate commit
|
||||
- [ ] Open all five [sample regression pack](sample-regression-pack.md) entries through the native File menu and record exact-candidate results
|
||||
@@ -0,0 +1,56 @@
|
||||
# Operator Invariants Evaluation
|
||||
|
||||
Date: 2026-07-12
|
||||
|
||||
Gitea issue:
|
||||
[`#33`](https://git.spacetrainclubhouse.com/Falling-Metal-Interactive/Blacksite/issues/33)
|
||||
|
||||
This acceptance record covers the source-level production operator contract. It does not nominate a
|
||||
release candidate or replace the clean-checkout rerun required by production-readiness gate G3.
|
||||
|
||||
## Accepted Coverage
|
||||
|
||||
- Registered commands distinguish immediate completion from modal Preview ownership; validation
|
||||
failures terminate with their stable command ID. Palette execution and cancellation fully dismiss
|
||||
the palette instead of leaving an empty title bar.
|
||||
- Group Selection is one history transaction and preserves unrelated hierarchy rows through repeated
|
||||
undo/redo even though the transient group entity is respawned. Newly spawned and redone group
|
||||
actors own their visibility hierarchy before viewport icon children attach.
|
||||
- Reset Lighting and Project Sun changes are grouped, undoable light transactions.
|
||||
- Asset/sub-asset placement; material/texture/audio/animation assignment; and exact viewport material
|
||||
drops cover commit, block/failure, cancel where applicable, and semantic undo/redo projections.
|
||||
- Draw Brush, CSG, clip, and element-gizmo paths exercise production modal finalizers and helper
|
||||
cleanup.
|
||||
- Terrain sculpt/paint cover multi-dab commit, failure rollback, cancel, clean-view interruption, and
|
||||
resource cleanup.
|
||||
- Physics placement covers prerequisite block, exact cancel, real settle commit, multi-selection
|
||||
grouping, helper cleanup, undo, and redo.
|
||||
- The transform tracker covers continuous multi-target grouping and no-op release termination.
|
||||
|
||||
## Verification
|
||||
|
||||
The publication worktree passed:
|
||||
|
||||
- `cargo test -p editor --lib --no-fail-fast`: 245 passed, 0 failed.
|
||||
- `cargo clippy -p editor --lib --tests -- -D warnings`.
|
||||
- `cargo fmt --all -- --check`.
|
||||
- `cargo test --workspace --all-targets --no-fail-fast`.
|
||||
- `cargo clippy --workspace --all-targets -- -D warnings`.
|
||||
- `cargo validate-levels --project .`: 62 dependencies, 5 expected non-blocking findings, 0 blocking
|
||||
errors.
|
||||
|
||||
The Gitea closure comment records these results with the exact publication commit.
|
||||
|
||||
## Native Editor Follow-up
|
||||
|
||||
A native-editor replay on 2026-07-13 loaded the collider diagnostics scene, exercised Draw Brush
|
||||
Preview/cancel, and grouped two hierarchy actors through undo/redo. The replay exposed two issues
|
||||
that source-only checks did not make visible: command execution left a collapsed palette title bar,
|
||||
and the viewport icon child briefly inherited from a group actor without Bevy visibility hierarchy
|
||||
components. Both paths now have focused regression assertions; a rebuilt replay dismissed the
|
||||
palette completely and emitted no hierarchy warning.
|
||||
|
||||
No screenshot is required for this ticket: the accepted surface is lifecycle, rollback, cleanup, and
|
||||
history behavior exercised through headless production entry points. Live command/status checks add
|
||||
confidence but are not substituted for semantic assertions. Packaged-runtime testing remains
|
||||
deferred by project-owner request.
|
||||
@@ -4,15 +4,17 @@ Date: 2026-07-12
|
||||
|
||||

|
||||
|
||||
The native Wayland editor is shown with the committed
|
||||
`assets/levels/physics_placement_showcase.scn.ron` fixture. Placement Prop A, B, and C were
|
||||
The native Wayland editor is shown with the 2026-07-12 revision of
|
||||
`assets/levels/physics_placement_showcase.scn.ron`. At that revision, Placement Prop A, B, and C were
|
||||
multi-selected and released from three different heights through the hand/down-arrow action in the
|
||||
existing horizontal viewport toolbar.
|
||||
existing horizontal viewport toolbar. The fixture now exposes those stable actor IDs as Placement
|
||||
Cuboid, Placement Sphere, and Placement Capsule; its distinct-shape rerun is tracked by the
|
||||
[sample-pack evaluation](../sample-regression-pack/).
|
||||
|
||||
## Acceptance
|
||||
|
||||
- All three props used the hydrated Avian cuboid colliders and settled on Placement Floor after
|
||||
1.5 simulated seconds.
|
||||
- In the recorded revision, all three props used hydrated Avian cuboid colliders and settled on
|
||||
Placement Floor after 1.5 simulated seconds.
|
||||
- During preview the HUD reported selection count, simulated time, and Settled state; transform
|
||||
gizmos and viewport picking did not compete with the modal tool.
|
||||
- Escape restored every starting transform and left history empty.
|
||||
@@ -25,4 +27,3 @@ existing horizontal viewport toolbar.
|
||||
error after the stale-binding fix.
|
||||
|
||||
Packaged-runtime tests remain intentionally deferred by project-owner request.
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
# Production-Readiness Acceptance Matrix
|
||||
|
||||
**Matrix version:** 0.2
|
||||
**Matrix version:** 0.4
|
||||
|
||||
**Last audit:** 2026-07-12
|
||||
**Last audit:** 2026-07-13
|
||||
|
||||
**Release-candidate commit:** Not nominated
|
||||
|
||||
@@ -30,21 +30,21 @@ another commit, a dirty worktree, or an older package do not transfer to the can
|
||||
|
||||
| ID | Requirement | State | Current evidence and gap |
|
||||
|----|-------------|-------|--------------------------|
|
||||
| G1 | Project create/open/resume, scene authoring, autosave/recovery, hierarchy, prefab, and asset integrity pass | Partial | Project/recovery/session/multi-scene/prefab implementations are documented in [project launcher](../../project-launcher.md), [session recovery](../../session-recovery.md), [multi-scene composition](../../multi-scene-composition.md), and [prefab authoring](../../prefab-authoring.md). Collaborative file safety `#49` and non-blocking native dialogs `#52` passed live acceptance. Candidate-specific end-to-end reruns remain. |
|
||||
| G2 | Brush, material, terrain, physics placement, animation, audio, navigation, PIE, and build/package samples pass | Fail | Animation, audio, navigation, renderer/material foundation `#51`, Material Library, targeted material drops, terrain `#22`-`#24`, physics placement `#25`, and build foundations are implemented with source/live fixtures. Brush acceptance `#37` remains incomplete. Packaged testing is owner-deferred. |
|
||||
| G3 | Undo/redo/cancel invariants and helper cleanup cover every production mutation path | Partial | The reusable harness and current tool coverage are documented in [operator regression testing](../../operator-regression-testing.md). Terrain stroke and physics settle/cancel/undo fixtures now exist; Gitea `#33` remains open for full mutation-path coverage. |
|
||||
| G1 | Project create/open/resume, scene authoring, autosave/recovery, hierarchy, prefab, and asset integrity pass | Fail | Project/recovery/session/multi-scene/prefab implementations are documented in [project launcher](../../project-launcher.md), [session recovery](../../session-recovery.md), [multi-scene composition](../../multi-scene-composition.md), and [prefab authoring](../../prefab-authoring.md). Collaborative file safety `#49` and non-blocking native dialogs `#52` passed live acceptance, but `#55` records unguarded native dirty shutdown and a missing clean-history savepoint. Candidate-specific end-to-end reruns also remain. |
|
||||
| G2 | Brush, material, terrain, physics placement, animation, audio, navigation, PIE, and build/package samples pass | Partial | The [five-area sample pack](../sample-regression-pack/) passed source and native acceptance on exact implementation commit `d52cc2e`, including Brush, Material, Terrain, Physics Placement, and Rendering. No release candidate is nominated, brush acceptance `#37` remains open, and combined animation/audio/navigation/PIE/build evidence is incomplete. Packaged testing is owner-deferred. |
|
||||
| G3 | Undo/redo/cancel invariants and helper cleanup cover every production mutation path | Partial | Source implementation and focused evidence are complete in [operator regression testing](../../operator-regression-testing.md) and the [operator-invariants evaluation](../operator-invariants/); Gitea `#33` closed at `c55f347`. A clean, exact-candidate rerun is still required for `Pass`. |
|
||||
| G4 | Representative project completes an eight-hour soak without unbounded memory/target growth or unrecoverable failure | Missing | No candidate soak log, resource timeline, failure ledger, or target-growth measurement exists. |
|
||||
| G5 | Cold start, scene open/save, asset refresh, common manipulation, and package-build budgets are documented and measured | Missing | Gitea `#34` is open; no ratified budgets or candidate measurement record exists. |
|
||||
| G6 | Headless content validation and CI are green from a clean checkout | Missing | [CI configuration](../../../../.github/workflows/ci.yml) exists and local source/headless checks have passed during feature work, but no clean-checkout candidate run is linked. The current Gitea server does not expose an Actions run endpoint for this repository. |
|
||||
| G6 | Headless content validation and CI are green from a clean checkout | Missing | [CI configuration](../../../../.github/workflows/ci.yml) hydrates LFS and includes both project and sample content gates. Local implementation checks have passed, but no clean-checkout candidate run is linked. The current Gitea server does not expose an Actions run endpoint for this repository. |
|
||||
| G7 | First-hour UX and recovery QA are signed off by someone other than the implementer | External | No independent sign-off exists. Gitea `#36` remains open; historical H1-H6 implementation-pass notes do not count. |
|
||||
| G8 | Known limitations have severity/workaround and no P0 blocker remains | Fail | Limitations are distributed across feature docs rather than one candidate ledger. Open P0 work includes `#32` and `#33`; `#50` cannot close while a gate-relevant P0 remains. Renderer foundation `#51`, roadmap audit `#35`, Material Library `#16`, targeted drops `#18`, collaborative safety `#49`, and dialog responsiveness `#52` are closed. Property-block application `#53` is P1; dynamic deformed Solari geometry `#54` is a documented P2 limitation with Forward/raster fallback. |
|
||||
| G8 | Known limitations have severity/workaround and no P0 blocker remains | Fail | Sample-pack gap `#32` has exact-implementation source/native evidence at `d52cc2e`, but guarded native shutdown and clean history savepoints remain the open P0 `#55`. A consolidated candidate limitations ledger is also missing. Deterministic imported-asset fingerprints `#56` and property-block application `#53` are P1; dynamic deformed Solari geometry `#54` is a documented P2 limitation with Forward/raster fallback. |
|
||||
|
||||
## Deliverables
|
||||
|
||||
| ID | Deliverable | State | Evidence or next action |
|
||||
|----|-------------|-------|-------------------------|
|
||||
| D1 | Versioned acceptance matrix under `docs/editor/evaluations/` | Pass | This file, version 0.2. |
|
||||
| D2 | Release-candidate representative project and reproducible validation commands | Missing | Expand the committed project/regression pack through `#32`, including terrain and physics-placement samples, then nominate an exact commit. |
|
||||
| D1 | Versioned acceptance matrix under `docs/editor/evaluations/` | Pass | This file, version 0.4. |
|
||||
| D2 | Release-candidate representative project and reproducible validation commands | Partial | The committed [sample regression pack](../sample-regression-pack/), commands, and exact-implementation native evidence exist. Nominate a release candidate and rerun from a clean LFS-hydrated checkout. |
|
||||
| D3 | Signed milestone comment linking evidence, limitations, and exact commit | Missing | Post only after G1-G8 pass; no candidate exists yet. |
|
||||
|
||||
## Workflow Coverage
|
||||
@@ -55,11 +55,13 @@ another commit, a dirty worktree, or an older package do not transfer to the can
|
||||
| Scene save, autosave, recovery | Implemented | Not rerun |
|
||||
| Hierarchy parenting and prefab structure | Implemented | Not rerun |
|
||||
| Multi-scene composition | Implemented | Not rerun |
|
||||
| Five-area editor sample pack | Implemented with manifest, native menu, typed scene gate, and headless validation | Exact-implementation source/native acceptance passed at `d52cc2e`; not rerun as one release candidate |
|
||||
| Brush blockout/edit/CSG | Implemented foundation; `#37` open | Not signed off |
|
||||
| Material catalog and assignment | Renderer/material foundation `#51`, Material Library, and exact targeted drops accepted; optional property-block promotion is `#53` | Not rerun as one candidate |
|
||||
| Terrain authoring | `#22`-`#24` source/live acceptance complete; M3 closed | Pass; packaged-runtime acceptance owner-deferred |
|
||||
| Physics placement | `#25` source/live acceptance complete | Pass; packaged-runtime acceptance owner-deferred |
|
||||
| Collider authoring and diagnostics | `#26` source/live acceptance complete | Pass; packaged-runtime acceptance owner-deferred |
|
||||
| Rendering volumes and look development | Deterministic visible rendering fixture is in the sample pack | Not rerun as one candidate |
|
||||
| Terrain authoring | `#22`-`#24` source/live acceptance complete; M3 closed | Feature-level live acceptance exists; not rerun as one candidate. Packaged-runtime acceptance owner-deferred. |
|
||||
| Physics placement | `#25` source/live acceptance complete | Feature-level live acceptance exists; not rerun as one candidate. Packaged-runtime acceptance owner-deferred. |
|
||||
| Collider authoring and diagnostics | `#26` source/live acceptance complete | Feature-level live acceptance exists; not rerun as one candidate. Packaged-runtime acceptance owner-deferred. |
|
||||
| Animation | Implemented | Not rerun |
|
||||
| Audio | Implemented | Not rerun |
|
||||
| Navigation | Implemented | Not rerun |
|
||||
@@ -81,6 +83,7 @@ cargo clippy --workspace --all-targets -- -D warnings
|
||||
cargo clippy -p editor -p game --bins --features dev,hot-reload -- -D warnings
|
||||
cargo test --workspace
|
||||
cargo validate-levels --project .
|
||||
cargo validate-samples --project .
|
||||
cargo bake-navigation --project . --check
|
||||
```
|
||||
|
||||
@@ -92,8 +95,9 @@ package hash verification, and packaged-runtime smoke protocol used for the cand
|
||||
The final candidate must run for eight continuous hours against the representative project. The
|
||||
record must sample process RSS, GPU memory, target-directory size, recovery generations, background
|
||||
job counts, and error/warning totals at least every five minutes. Exercise scene switching, save and
|
||||
recovery, asset refresh, material editing, brush/terrain/physics tools, animation/audio/navigation,
|
||||
PIE transitions, and build UI cancellation without replacing the candidate during the run.
|
||||
recovery, asset refresh, all five sample-pack scenes, material editing, brush/terrain/physics tools,
|
||||
animation/audio/navigation, PIE transitions, and build UI cancellation without replacing the
|
||||
candidate during the run.
|
||||
|
||||
A pass requires no unrecoverable editor failure, no lost authored work, no unbounded upward trend in
|
||||
steady-state resource use, bounded recovery/cache behavior, and a triaged explanation for every
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
# Sample Regression Pack Evaluation
|
||||
|
||||
**Date:** 2026-07-13
|
||||
|
||||
**Issue:** [Gitea #32](https://git.spacetrainclubhouse.com/Falling-Metal-Interactive/Blacksite/issues/32)
|
||||
|
||||
**Implementation commit:** `d52cc2e3b72c908d192ed9e9f49306c25367599b`
|
||||
|
||||
**Release-candidate commit:** Not nominated
|
||||
|
||||
**Implementation validation:** **Pass**
|
||||
|
||||
**Native visual acceptance:** **Pass**
|
||||
|
||||
This record separates source/fixture verification from release-candidate acceptance. The exact
|
||||
implementation commit above passed the five-area native protocol on a clean tracked worktree. These
|
||||
results do not transfer to a later release-candidate commit.
|
||||
|
||||
## Source Evidence
|
||||
|
||||
| Check | Result | Evidence |
|
||||
|-------|--------|----------|
|
||||
| Manifest contract | Pass | Schema v1 contains one ordered entry for Brush, Material, Terrain, Physics Placement, and Rendering, with stable IDs and nonempty checks. |
|
||||
| Authored scene fixtures | Pass | All five scene paths exist; actors use stable IDs and each scene contains its required authored feature. |
|
||||
| Project validation | Pass | `cargo validate-levels --project .` reported 81 dependencies, five known nonblocking import/platform findings, and zero blocking errors on 2026-07-13. |
|
||||
| Typed no-GPU deserialization | Pass | `cargo test -p editor every_manifest_sample_typed_deserializes_without_a_gpu --lib`: one passed, zero failed, 257 filtered out. |
|
||||
| Sample-pack validation | Pass | `cargo validate-samples --project .`: five ordered samples, 86 dependencies, five known nonblocking findings, zero blocking errors. |
|
||||
| Clean-checkout CI | Pending | The exact candidate must hydrate LFS and pass both content gates. Current Gitea does not expose an Actions run endpoint for this repository. |
|
||||
|
||||
## Native Protocol
|
||||
|
||||
Open every row through **File > Open Sample**, not through a typed filesystem path. Capture native
|
||||
screenshots only after confirming the viewport is nonblank and correctly framed.
|
||||
|
||||
| Sample | Required native interaction and visual result | Result |
|
||||
|--------|-----------------------------------------------|--------|
|
||||
| Brush Blockout | Foundation, material-face tower, and red subtractive marker are distinct; enter brush edit and cancel one edit or clip preview without leaving helpers | Pass - selected one tower face in Brush Clip, observed the magenta preview, then canceled with no history or helper leak. |
|
||||
| Material Lab | Concrete cube, custom sphere, instance block, and emissive panel are visible; perform one exact primitive material drop and undo | Pass - dropped `surface_tint_instance` on `Concrete Reference / Surface`; one history entry was created and Ctrl+Z restored the exact prior material. |
|
||||
| Terrain Authoring | Hill chunks and two material layers render; perform and cancel one sculpt stroke and one paint stroke | Pass - Concrete/Surface Tint rendered visibly under active Solari through the forward raster boundary; both stroke cancels restored data and left history clean. |
|
||||
| Physics Placement | Cuboid, sphere, and capsule settle on the floor; cancel restores all three, then commit/undo behaves as one transaction | Pass - three props settled in 2.3 seconds; cancel restored the airborne transforms, and the second run committed one `Move Selection` entry that Ctrl+Z restored. |
|
||||
| Rendering Lab | Red/cyan/amber anchors and emissive strip render; camera traversal visibly changes vignette, fog, and exposure ownership | Pass - HUD ownership reached Foggy courtyard 73%/2 overrides, Cave mouth 100%/2 overrides, and Vignette demo 68% with the expected visible changes. |
|
||||
|
||||
For each row, inspect the status strip, Diagnostics panel, and process log for missing references,
|
||||
hydration errors, render errors, helper leaks, or operator failures. Attach native images to the Gitea
|
||||
issue as ordinary uploaded attachments rather than embedding repository raw URLs. A committed
|
||||
original may remain beside this record through Git LFS under the shared evaluation policy.
|
||||
|
||||
## Native Environment And Artifacts
|
||||
|
||||
- Arch Linux `7.1.3-arch1-1`, Hyprland `0.55.4`, native Wayland.
|
||||
- NVIDIA GeForce RTX 3080 Ti, driver `610.43.03`.
|
||||
- Bevy `0.19.0`; the viewport reported the effective `Solari` path throughout the pass.
|
||||
- Exact binary: `target/debug/editor --project .`, built from the implementation commit above.
|
||||
- Process log: no warnings or errors across all five menu opens and interactions.
|
||||
- [Gitea issue comment #1057](https://git.spacetrainclubhouse.com/Falling-Metal-Interactive/Blacksite/issues/32#issuecomment-1057)
|
||||
embeds full-resolution 3426x1384 PNG uploads, not repository/LFS raw links:
|
||||
`blacksite-brush-d52cc2e.png`
|
||||
(`sha256:3853bb51a70320b95af2cc48a1609251defc22705fb5f27fd3b1ab434f71877f`),
|
||||
`blacksite-terrain-solari-d52cc2e.png`
|
||||
(`sha256:8ee4e5d5c40436a5719fbec34deaef10f5bcb79748b052268781c29468e1ef7b`), and
|
||||
`blacksite-rendering-vignette-d52cc2e.png`
|
||||
(`sha256:67a09743f86439adf98ad2cf9b9d91041f89954aea2b8f29c29bbf10ead8c000`).
|
||||
|
||||
## Release Use
|
||||
|
||||
A future candidate may mark this evaluation fully passed only when the exact nominated commit has:
|
||||
|
||||
1. Passed typed scene deserialization, `validate-levels`, and `validate-samples` from a clean,
|
||||
LFS-hydrated checkout.
|
||||
2. Opened all five entries through the native menu and completed the interactions above.
|
||||
3. Recorded the commit, machine profile, commands, exit codes, logs, and native attachments.
|
||||
@@ -11,11 +11,13 @@ Every production operator test must cover the paths it exposes:
|
||||
|
||||
| Path | Required proof |
|
||||
|------|----------------|
|
||||
| Commit | Expected authored entity delta, exact undo-group delta, dirty state, committed phase |
|
||||
| Cancel or commit failure | No authored entity delta, no new history, prior dirty state, canceled phase |
|
||||
| Commit | Expected authored projection, exact undo-group delta, dirty state, stable operator ID, committed phase |
|
||||
| Zero-history commit | Authored projection and prior dirty state remain unchanged |
|
||||
| Cancel or commit failure | Exact authored projection restored, no new history, prior dirty state, stable operator ID, terminal canceled/blocked phase |
|
||||
| Blocked start | Commit closure never runs; authored state, history, and dirty state are unchanged |
|
||||
| Preview failure | Cancel finalizer runs, authored state is restored, and helpers are removed |
|
||||
| Preview helpers | No helper component remains after commit or cancel |
|
||||
| Undoable commit | `assert_undo_redo_round_trip` restores both initial and committed projections |
|
||||
| Undoable commit | `assert_undo_redo_round_trip` restores both initial and committed semantic projections |
|
||||
| Continuous edit | The entire interaction creates one history command, not one per frame or target |
|
||||
|
||||
The harness intentionally fails with the invariant name in the assertion message. Tests may add
|
||||
@@ -26,12 +28,12 @@ domain assertions, but should not replace these shared lifecycle checks.
|
||||
1. Build a minimal `World` with `ActiveOperator`, `EditorHistory`, and `SceneIo`. Add tool-specific
|
||||
selection/resources and `SelectedEntity` when history helpers update selection.
|
||||
2. Capture `OperatorInvariantHarness` immediately before starting the operation.
|
||||
3. Run the real operator entry point or the same production commit/cancel function used by its
|
||||
input system.
|
||||
3. Run the real dispatch path or production finalizer used by the input system. Do not duplicate its
|
||||
state transition in the test.
|
||||
4. Call `assert_committed`, `assert_canceled`, or `assert_blocked` with the expected authored and
|
||||
undo deltas.
|
||||
undo deltas, then `assert_status` with the stable operator ID and terminal phase.
|
||||
5. For helpers, call `assert_no_helpers::<ToolHelper>`. For undoable work, project the meaningful
|
||||
state through `assert_undo_redo_round_trip`.
|
||||
state through `assert_undo_redo_round_trip`; use `assert_projection_unchanged` for no-op paths.
|
||||
|
||||
Do not satisfy a lifecycle test by constructing an `EditorCommand` and checking only its label.
|
||||
The test must mutate a world and prove restoration.
|
||||
@@ -40,15 +42,17 @@ The test must mutate a world and prove restoration.
|
||||
|
||||
| Workflow | Coverage |
|
||||
|----------|----------|
|
||||
| Generic `EditorOperator` | Commit cleanup, commit failure rollback, blocked no-op |
|
||||
| Asset placement | Commit, dirty state, single undo, authored spawn round trip |
|
||||
| Sub-asset placement | Missing dependency commit failure leaves no side effects |
|
||||
| Texture/material assignment | Multi-actor grouped undo; missing material failure; empty-selection block |
|
||||
| Draw Brush | Full modal-state cancel; decomposed multi-brush grouped commit and round trip |
|
||||
| Brush CSG | Pending-preview cancel; merge commit/deletion grouped round trip |
|
||||
| Brush clip and element gizmo | Clip grouped geometry round trip; Escape rollback and helper cleanup |
|
||||
| Transform gizmo finalization | Multi-target continuous edit grouped into one undo command |
|
||||
| Generic `EditorOperator` | Commit cleanup, preview/commit failure rollback, blocked no-op, terminal ID/phase |
|
||||
| Palette and registered commands | Typed immediate commit versus modal preview ownership; Enter/click/Escape dismissal cannot be overwritten by stale window state; failed CSG start terminates |
|
||||
| Selection and scene commands | Atomic Group Selection across repeated undo/redo; spawned group actors have an immediate Bevy visibility hierarchy; grouped Reset Lighting and Project Sun history |
|
||||
| Asset workflows | Asset/sub-asset placement; material/texture group assignment; audio/animation assignment and incompatible targets |
|
||||
| Viewport material drop | Exact renderer slot/primitive/brush-face preview, cancel, commit, cleanup, undo, and redo |
|
||||
| Draw Brush and CSG | Modal cancel; decomposed commit; CSG validation/read-only block, cancel, grouped commit, and deleted-brush restoration |
|
||||
| Brush clip and element gizmo | Production finalizers, geometry round trip, Escape rollback, and helper cleanup |
|
||||
| Terrain sculpt and paint | Multi-dab grouped commit, no-op release, commit failure rollback, cancel, clean-view interruption, and resource cleanup |
|
||||
| Physics placement | Prerequisite block, no-op commit, exact cancel, real settle commit, multi-selection grouping, helper cleanup, undo, and redo |
|
||||
| Transform gizmo finalization | Actual tracker finalizer, continuous multi-target grouping, no-op release, and missing-primary survivor rollback |
|
||||
|
||||
Terrain strokes and physics-settle sessions are roadmap tools, not current production operators.
|
||||
Their implementation tickets must add harness fixtures before those tools can pass their own exit
|
||||
gates; Gitea issue BS-JD-502 remains the umbrella until that coverage exists.
|
||||
The shared harness covers formal operators and multi-frame modal paths. Atomic inspector and history
|
||||
mutations that do not own `ActiveOperator` use focused typed history tests with equivalent semantic
|
||||
projection and undo/redo assertions.
|
||||
@@ -30,9 +30,10 @@ and placement status agree about missing, invalid, stale, disabled, or trigger c
|
||||
ten-second simulated-time limit stops unstable previews while
|
||||
leaving explicit commit and cancel available.
|
||||
|
||||
`assets/levels/physics_placement_showcase.scn.ron` is the committed acceptance fixture. Select
|
||||
**Placement Prop A**, **B**, and **C** together, start physics placement, and verify that the three
|
||||
different shapes settle on **Placement Floor** as one commit/cancel transaction.
|
||||
`assets/levels/physics_placement_showcase.scn.ron` is the Physics Placement entry in the committed
|
||||
[sample regression pack](sample-regression-pack.md). Select **Placement Cuboid**, **Placement
|
||||
Sphere**, and **Placement Capsule** together, start physics placement, and verify that the three
|
||||
distinct collider cases settle on **Placement Floor** as one commit/cancel transaction.
|
||||
|
||||
The clock and transaction boundary are specified by
|
||||
[ADR 0041](../adr/0041-transactional-editor-physics-placement.md).
|
||||
@@ -89,7 +89,10 @@ Shipped examples: `post_fx/vignette.ron`, `post_fx/chromatic_aberration.ron`, `r
|
||||
|
||||
## Example level
|
||||
|
||||
Open `assets/levels/rendering_showcase.scn.ron` for fog, exposure, and vignette volume examples.
|
||||
Open **File > Open Sample > Rendering Lab** for the committed rendering fixture. Its red sphere,
|
||||
cyan cube, amber block, and emissive horizon make the adjacent vignette, fog, and dark-exposure zones
|
||||
visually comparable while the volume actors exercise stable ownership, profile, and fullscreen-effect
|
||||
references. See the [sample regression pack](sample-regression-pack.md) for the native QA protocol.
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
|
||||
@@ -124,6 +124,7 @@ Phased work for the in-process editor (`crates/editor`). Status reflects the cur
|
||||
| Thumbnails | Done | Textures via asset load; glTF albedo fast-path; FBX/untextured models via offscreen studio |
|
||||
| Import settings per asset | Done | Scale/collider/LOD in registry + details pane |
|
||||
| Prefab workflow | Done | Shared stable nested property/component/structural overrides, recursive validation, committed variant fixtures, transactional source Apply, conflict recovery, and undoable outer unpack/recursive local conversion passed headless, packaged-runtime, and live editor acceptance in Gitea #43 |
|
||||
| Curated editor regression samples | Done | Versioned five-area manifest, dedicated brush/material labs, strengthened terrain/physics/rendering fixtures, **File > Open Sample**, typed scene coverage, and `validate-samples` release gate in Gitea #32 |
|
||||
|
||||
## Phase 6 — Extensibility
|
||||
|
||||
@@ -134,6 +135,7 @@ Phased work for the in-process editor (`crates/editor`). Status reflects the cur
|
||||
| `ActorInspectorSection` registry | Done | `ext/extensibility.rs` + `game_inspector.rs` |
|
||||
| Command registry | Done | Play, lighting reset, group, focus |
|
||||
| Command palette (Ctrl+P) | Done | Executes registered commands |
|
||||
| Typed operator dispatch and mutation invariants | Done | Immediate commands commit, modal commands retain Preview ownership, and production asset/brush/terrain/physics/history paths pass the shared lifecycle and undo contract ([testing guide](operator-regression-testing.md), [Gitea #33](https://git.spacetrainclubhouse.com/Falling-Metal-Interactive/Blacksite/issues/33)) |
|
||||
| `EditorPlugin` trait | Done | `register_editor_plugin`; dogfood panel from `game::editor_ext` |
|
||||
| Undo: `SetActorKind`, add/remove component | Done | `SetActorKind` + `AddComponent` / `RemoveComponent` |
|
||||
| BRP authoring-only policy | Done | [brp.md](brp.md) |
|
||||
@@ -149,7 +151,7 @@ with implementation sequencing in
|
||||
| Milestone | Exit condition | Status |
|
||||
|-----------|----------------|--------|
|
||||
| M6 Reliability, recovery, and project workflow | Transactional save/recovery, stable sessions, project launcher, hardened hierarchy/prefabs, multi-scene composition | Implementation complete; all six scoped issues are closed after prefab #43 passed workspace, headless, packaged-runtime, and live editor acceptance |
|
||||
| M7 Content production and shipping | Build/package profiles, content release gate, animation, audio, navigation, collaborative safety | Active; #44-#48 are complete. #49 implementation and source/headless acceptance are complete, with live visual acceptance pending; final readiness gate #50 remains. Packaged acceptance is deferred until requested by the project owner. |
|
||||
| M7 Content production and shipping | Build/package profiles, content release gate, animation, audio, navigation, collaborative safety | Active; #44-#49 are complete after source, headless, and native acceptance. Final readiness gate #50 remains blocked by open P0 shutdown/savepoint work #55; deterministic imported-asset fingerprints #56 are P1 follow-up work. Packaged acceptance is deferred until requested by the project owner. |
|
||||
|
||||
Production readiness is not inferred from feature count. Gitea
|
||||
[`#50`](https://git.spacetrainclubhouse.com/Falling-Metal-Interactive/Blacksite/issues/50)
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
# Editor Sample Regression Pack
|
||||
|
||||
The editor sample regression pack is the committed, deterministic first stop for content and native
|
||||
viewport QA. Its source of truth is `assets/samples/editor_samples.ron`; manifest order is also the
|
||||
order shown by **File > Open Sample** and by headless reports.
|
||||
|
||||
## Open And Exercise A Sample
|
||||
|
||||
1. Open **File > Open Sample** and choose the relevant area.
|
||||
2. Confirm the scene opens in a normal scene tab and the viewport contains the expected anchors.
|
||||
3. Perform the checks listed in the manifest and the table below.
|
||||
4. Watch the status strip and Diagnostics panel for missing references, hydration failures, or
|
||||
operator errors.
|
||||
5. Use **Save As** before destructive experimentation. The committed samples are regular project
|
||||
scenes, not disposable or read-only copies.
|
||||
|
||||
An invalid or unavailable manifest leaves an actionable disabled item in the menu. It must not
|
||||
silently fall back to another scene.
|
||||
|
||||
## Pack Contents
|
||||
|
||||
| Area | Scene and visual composition | Representative checks |
|
||||
|------|------------------------------|-----------------------|
|
||||
| Brush | `brush_blockout.scn.ron`: broad concrete foundation, tall additive brush with a contrasting shared-material top face, red rotated subtractive marker | Select object and face targets; enter brush edit; exercise draw/clip/CSG preview and cancel; verify shared face material resolution |
|
||||
| Material | `material_lab.scn.ron`: neutral floor, concrete cube, blue custom-surface sphere, rotated Material Instance block, cyan emissive backdrop | Inspect shared Material/Instance paths; target a primitive with a Material drop; compare standard, custom, and emissive hydration |
|
||||
| Terrain | `terrain_authoring_showcase.scn.ron`: asymmetric 5x5 hill, four deterministic chunks, two painted shared-material layers | Sculpt and paint preview/cancel; inspect normalized weights and layer refs; verify generated selection and collider state |
|
||||
| Physics Placement | `physics_placement_showcase.scn.ron`: cuboid, sphere, and tall capsule above a static floor | Multi-select all three props; settle; cancel and compare exact starting transforms; repeat, commit, undo, and redo as one group |
|
||||
| Rendering | `rendering_showcase.scn.ron`: red sphere, cyan cube, amber block, emissive horizon, and three adjacent vignette/fog/exposure volumes | Move the camera through all zones; inspect active-volume ownership; verify profile/fullscreen-effect refs and visible transitions |
|
||||
|
||||
All authored sample actors have stable `ActorId` values. Generated hydration children are deliberately
|
||||
absent from the committed scene documents.
|
||||
|
||||
## Headless Validation
|
||||
|
||||
Run both gates from the project root with Git LFS content hydrated:
|
||||
|
||||
```bash
|
||||
cargo validate-levels --project .
|
||||
cargo validate-samples --project .
|
||||
```
|
||||
|
||||
`validate-levels` remains the authoritative project dependency/finding report. `validate-samples`
|
||||
adds the pack contract: schema and safe paths, exactly one entry per required area, stable actor IDs,
|
||||
authoring-only scene data, required area components, and nonempty operator checks. Either command
|
||||
must exit nonzero on a blocking finding. Use `--json` when attaching machine-readable evidence.
|
||||
|
||||
## Maintenance Contract
|
||||
|
||||
- Keep exactly the five areas `Brush`, `Material`, `Terrain`, `PhysicsPlacement`, and `Rendering`.
|
||||
- Treat manifest IDs as persistent automation keys; rename labels instead of IDs.
|
||||
- Keep scene paths project-relative, inside `assets/levels/`, and free of symlink or traversal escapes.
|
||||
- When a sample changes, update its manifest summary/checks and this visual-composition table in the
|
||||
same change.
|
||||
- Run the typed no-GPU scene test plus both validation commands before native QA.
|
||||
- Record exact-commit native results under
|
||||
[evaluations/sample-regression-pack/](evaluations/sample-regression-pack/). Implementation checks
|
||||
from a dirty worktree do not satisfy release-candidate acceptance.
|
||||
@@ -38,10 +38,12 @@ weight to the remaining channels. Every sample stays normalized to 255, the terr
|
||||
or amber footprint previews the brush, and release records one undo entry. Escape or right-click
|
||||
restores the exact pre-stroke weights or closes the idle tool.
|
||||
|
||||
`assets/levels/terrain_authoring_showcase.scn.ron` is the deterministic foundation fixture. Its 5×5
|
||||
`assets/levels/terrain_authoring_showcase.scn.ron` is the Terrain entry in the deterministic
|
||||
[sample regression pack](sample-regression-pack.md). Its 5×5
|
||||
grid forms an asymmetric hill split into four 2×2-quad chunks. It validates chunk boundaries,
|
||||
normals, selection through generated children, collider generation, inspector state, and save
|
||||
stripping without requiring external assets.
|
||||
stripping. Height geometry is inline, while its committed shared Material and Material Instance
|
||||
references deliberately validate terrain dependency resolution and layer transport.
|
||||
|
||||
## Data And Hydration
|
||||
|
||||
@@ -57,9 +59,10 @@ stripping without requiring external assets.
|
||||
fallback rather than missing geometry.
|
||||
- Generated `HydratedTerrainChunk` children own mesh, optional trimesh collider, and shadow state.
|
||||
They are runtime-only and never serialized as authored actors.
|
||||
- Foundation chunks are explicitly excluded from Solari submission and remain raster-visible while
|
||||
Auto/Solari is active. Raster material-layer parity is shipped; matching Solari terrain evaluation
|
||||
remains explicit future work, and the editor never substitutes a semantically different proxy.
|
||||
- Foundation chunks are explicitly excluded from Solari submission and force their layer blend
|
||||
through Bevy's forward opaque raster path while Auto/Solari is active. Raster material-layer
|
||||
parity is shipped; matching Solari terrain evaluation remains explicit future work, and the editor
|
||||
never substitutes a semantically different proxy.
|
||||
|
||||
The terrain foundation is recorded in [ADR 0039](../adr/0039-inline-height-grid-terrain-foundation.md),
|
||||
and layer weight persistence/render transport in
|
||||
|
||||
@@ -9,6 +9,11 @@ name = "validate-levels"
|
||||
path = "src/validate_levels.rs"
|
||||
required-features = ["validate-levels"]
|
||||
|
||||
[[bin]]
|
||||
name = "validate-samples"
|
||||
path = "src/validate_samples.rs"
|
||||
required-features = ["validate-samples"]
|
||||
|
||||
[[bin]]
|
||||
name = "clean-target"
|
||||
path = "src/clean_target.rs"
|
||||
@@ -44,3 +49,4 @@ libc = "0.2"
|
||||
[features]
|
||||
default = []
|
||||
validate-levels = ["dep:scene", "dep:settings", "dep:shared"]
|
||||
validate-samples = ["validate-levels"]
|
||||
@@ -0,0 +1,209 @@
|
||||
//! Validate the canonical editor sample pack and the complete project dependency graph.
|
||||
|
||||
use std::path::PathBuf;
|
||||
|
||||
use scene::{
|
||||
sample_pack::validate_editor_sample_pack, ProjectValidationReport, ValidationSeverity,
|
||||
};
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Serialize)]
|
||||
struct ValidateSamplesOutput<'a> {
|
||||
manifest_path: &'a str,
|
||||
samples: &'a [scene::sample_pack::EditorSampleEntry],
|
||||
dependencies: &'a [scene::ProjectDependency],
|
||||
findings: &'a [scene::ProjectValidationFinding],
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let mut project_root = PathBuf::from(".");
|
||||
let mut json = false;
|
||||
let mut args = std::env::args().skip(1);
|
||||
while let Some(argument) = args.next() {
|
||||
match argument.as_str() {
|
||||
"--json" => json = true,
|
||||
"--project" => {
|
||||
let Some(path) = args.next() else {
|
||||
eprintln!("validate-samples: --project requires a path");
|
||||
std::process::exit(2);
|
||||
};
|
||||
project_root = PathBuf::from(path);
|
||||
}
|
||||
_ => {
|
||||
eprintln!("validate-samples: unknown argument `{argument}`");
|
||||
std::process::exit(2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let sample_validation = validate_editor_sample_pack(&project_root);
|
||||
let mut report = scene::validate_project(&project_root);
|
||||
merge_reports(&mut report, &sample_validation.report);
|
||||
|
||||
if json {
|
||||
let output = ValidateSamplesOutput {
|
||||
manifest_path: &sample_validation.manifest_path,
|
||||
samples: &sample_validation.samples,
|
||||
dependencies: &report.dependencies,
|
||||
findings: &report.findings,
|
||||
};
|
||||
println!(
|
||||
"{}",
|
||||
serde_json::to_string_pretty(&output).expect("sample validation report must serialize")
|
||||
);
|
||||
} else {
|
||||
for sample in &sample_validation.samples {
|
||||
println!(
|
||||
"sample: {} [{}] {} ({})",
|
||||
sample.area, sample.id, sample.label, sample.scene
|
||||
);
|
||||
}
|
||||
for finding in &report.findings {
|
||||
let actor = finding
|
||||
.owner_actor_id
|
||||
.as_deref()
|
||||
.map(|actor| format!(" actor={actor}"))
|
||||
.unwrap_or_default();
|
||||
eprintln!(
|
||||
"{:?} [{}] {}{}: {}",
|
||||
finding.severity, finding.code, finding.source_path, actor, finding.message
|
||||
);
|
||||
}
|
||||
println!(
|
||||
"validate-samples: {} samples, {} dependencies, {} findings, {} blocking errors",
|
||||
sample_validation.samples.len(),
|
||||
report.dependencies.len(),
|
||||
report.findings.len(),
|
||||
report.blocking_error_count()
|
||||
);
|
||||
}
|
||||
|
||||
if !report.is_release_ready() {
|
||||
std::process::exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
fn merge_reports(target: &mut ProjectValidationReport, source: &ProjectValidationReport) {
|
||||
target
|
||||
.dependencies
|
||||
.extend(source.dependencies.iter().cloned());
|
||||
target.findings.extend(source.findings.iter().cloned());
|
||||
target.dependencies.sort_by(|left, right| {
|
||||
(
|
||||
&left.owner_path,
|
||||
&left.owner_actor_id,
|
||||
&left.kind,
|
||||
&left.reference,
|
||||
)
|
||||
.cmp(&(
|
||||
&right.owner_path,
|
||||
&right.owner_actor_id,
|
||||
&right.kind,
|
||||
&right.reference,
|
||||
))
|
||||
});
|
||||
target.dependencies.dedup();
|
||||
target.findings.sort_by(|left, right| {
|
||||
(
|
||||
&left.source_path,
|
||||
&left.owner_actor_id,
|
||||
&left.code,
|
||||
&left.reference,
|
||||
&left.message,
|
||||
severity_rank(left.severity),
|
||||
&left.repair,
|
||||
)
|
||||
.cmp(&(
|
||||
&right.source_path,
|
||||
&right.owner_actor_id,
|
||||
&right.code,
|
||||
&right.reference,
|
||||
&right.message,
|
||||
severity_rank(right.severity),
|
||||
&right.repair,
|
||||
))
|
||||
});
|
||||
target.findings.dedup();
|
||||
}
|
||||
|
||||
const fn severity_rank(severity: ValidationSeverity) -> u8 {
|
||||
match severity {
|
||||
ValidationSeverity::Error => 0,
|
||||
ValidationSeverity::Warning => 1,
|
||||
ValidationSeverity::Info => 2,
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use scene::{ProjectDependency, ProjectValidationFinding};
|
||||
|
||||
#[test]
|
||||
fn merged_report_is_sorted_and_deduplicated() {
|
||||
let dependency = ProjectDependency {
|
||||
owner_path: "assets/samples/editor_samples.ron".into(),
|
||||
owner_actor_id: None,
|
||||
kind: "editor_sample_scene".into(),
|
||||
reference: "assets/levels/samples/brush.scn.ron".into(),
|
||||
};
|
||||
let finding = ProjectValidationFinding {
|
||||
severity: ValidationSeverity::Error,
|
||||
code: "sample_pack.scene_missing".into(),
|
||||
source_path: "assets/samples/editor_samples.ron".into(),
|
||||
owner_actor_id: None,
|
||||
reference: Some("assets/levels/samples/brush.scn.ron".into()),
|
||||
message: "missing".into(),
|
||||
repair: "restore".into(),
|
||||
};
|
||||
let source = ProjectValidationReport {
|
||||
dependencies: vec![dependency.clone()],
|
||||
findings: vec![finding.clone()],
|
||||
};
|
||||
let mut target = source.clone();
|
||||
|
||||
merge_reports(&mut target, &source);
|
||||
|
||||
assert_eq!(target.dependencies, vec![dependency]);
|
||||
assert_eq!(target.findings, vec![finding]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn merged_json_is_deterministic_across_input_order() {
|
||||
let dependency = |reference: &str| ProjectDependency {
|
||||
owner_path: "assets/samples/editor_samples.ron".into(),
|
||||
owner_actor_id: None,
|
||||
kind: "editor_sample_scene".into(),
|
||||
reference: reference.into(),
|
||||
};
|
||||
let finding = |code: &str, repair: &str| ProjectValidationFinding {
|
||||
severity: ValidationSeverity::Error,
|
||||
code: code.into(),
|
||||
source_path: "assets/samples/editor_samples.ron".into(),
|
||||
owner_actor_id: None,
|
||||
reference: Some(code.into()),
|
||||
message: code.into(),
|
||||
repair: repair.into(),
|
||||
};
|
||||
let first = ProjectValidationReport {
|
||||
dependencies: vec![dependency("assets/levels/z.scn.ron")],
|
||||
findings: vec![finding("sample_pack.same", "repair-z")],
|
||||
};
|
||||
let second = ProjectValidationReport {
|
||||
dependencies: vec![dependency("assets/levels/a.scn.ron")],
|
||||
findings: vec![finding("sample_pack.same", "repair-a")],
|
||||
};
|
||||
let mut left = first.clone();
|
||||
merge_reports(&mut left, &second);
|
||||
let mut right = second;
|
||||
merge_reports(&mut right, &first);
|
||||
|
||||
let left_json = serde_json::to_string(&left).unwrap();
|
||||
let right_json = serde_json::to_string(&right).unwrap();
|
||||
|
||||
assert_eq!(left, right);
|
||||
assert_eq!(left_json, right_json);
|
||||
assert_eq!(left.findings[0].repair, "repair-a");
|
||||
assert_eq!(left.findings[1].repair, "repair-z");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user